effect-browser 0.3.0-beta.20 → 0.3.0-beta.22
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 +221 -158
- package/dist/Action-24sLOubi.d.mts +110 -0
- package/dist/Action.d.mts +2 -0
- package/dist/Action.mjs +141 -0
- package/dist/Action.mjs.map +1 -0
- package/dist/ActionPort.d.mts +15 -0
- package/dist/ActionPort.mjs +101 -0
- package/dist/ActionPort.mjs.map +1 -0
- package/dist/Browser-Cq2K1FEA.mjs +4075 -0
- package/dist/Browser-Cq2K1FEA.mjs.map +1 -0
- package/dist/Browser-wZhwZSlG.d.mts +167 -0
- package/dist/Browser.d.mts +2 -129
- package/dist/Browser.mjs +1 -1
- package/dist/{BrowserError-Coy7EW1N.d.mts → BrowserError-BlcmLVzn.d.mts} +22 -7
- package/dist/BrowserError.d.mts +2 -2
- package/dist/BrowserError.mjs +46 -9
- package/dist/BrowserError.mjs.map +1 -1
- package/dist/{BrowserEvent-dq6FRT8w.d.mts → BrowserEvent-lLqJ3GJS.d.mts} +93 -37
- package/dist/BrowserEvent.d.mts +2 -2
- package/dist/BrowserEvent.mjs +29 -24
- package/dist/BrowserEvent.mjs.map +1 -1
- package/dist/{Change-DqING3tr.d.mts → Change-Ba7INmay.d.mts} +4 -6
- package/dist/Change.d.mts +2 -2
- package/dist/Change.mjs +97 -2
- package/dist/Change.mjs.map +1 -0
- package/dist/Clock.d.mts +57 -0
- package/dist/Clock.mjs +80 -0
- package/dist/Clock.mjs.map +1 -0
- package/dist/{Frame-DkNdjjjr.d.mts → Frame-UEH2hO5T.d.mts} +10 -3
- package/dist/Frame.d.mts +2 -2
- package/dist/Frame.mjs +10 -2
- package/dist/Frame.mjs.map +1 -1
- package/dist/{Motion-DND6I-64.d.mts → Geometry-DJx9qrYy.d.mts} +7 -10
- package/dist/Geometry.d.mts +2 -0
- package/dist/Geometry.mjs +32 -0
- package/dist/Geometry.mjs.map +1 -0
- package/dist/LICENSE-jpeg-js +28 -0
- package/dist/Matching.d.mts +37 -0
- package/dist/{match.inpage-xOe9LNO0.mjs → Matching.mjs} +28 -4
- package/dist/Matching.mjs.map +1 -0
- package/dist/{Page-CfB6Zn1p.mjs → Page-BF5izr8R.mjs} +216 -31
- package/dist/Page-BF5izr8R.mjs.map +1 -0
- package/dist/{Page-ku6j5t-v.d.mts → Page-CvsOEorc.d.mts} +158 -185
- package/dist/Page.d.mts +2 -2
- package/dist/Page.mjs +1 -1
- package/dist/Released-tURbFmal.d.mts +15 -0
- package/dist/{Snapshot-B34hZ4Jl.d.mts → Snapshot-CtBVOtuu.d.mts} +6 -1
- package/dist/Snapshot.d.mts +1 -1
- package/dist/Snapshot.mjs.map +1 -1
- package/dist/Stillness-CNlvayIo.mjs +136 -0
- package/dist/Stillness-CNlvayIo.mjs.map +1 -0
- package/dist/Style-AO4V7Czt.mjs +357 -0
- package/dist/Style-AO4V7Czt.mjs.map +1 -0
- package/dist/Style.d.mts +72 -0
- package/dist/Style.mjs +2 -0
- package/dist/Url.d.mts +26 -0
- package/dist/Url.mjs +74 -0
- package/dist/Url.mjs.map +1 -0
- package/dist/Window-CMddGMt1.d.mts +34 -0
- package/dist/Window.d.mts +2 -0
- package/dist/Window.mjs +35 -0
- package/dist/Window.mjs.map +1 -0
- package/dist/connection-2KHI4_KN.d.mts +41 -0
- package/dist/connection-BTeO0Hiz.mjs +68 -0
- package/dist/connection-BTeO0Hiz.mjs.map +1 -0
- package/dist/index.d.mts +15 -17
- package/dist/index.mjs +11 -14
- package/dist/moment/Moment.d.mts +86 -0
- package/dist/{Moment.mjs → moment/Moment.mjs} +44 -38
- package/dist/moment/Moment.mjs.map +1 -0
- package/dist/{Plan-DJ4hEEna.d.mts → plan/index.d.mts} +169 -64
- package/dist/{Plan-C-d5QYS8.mjs → plan/index.mjs} +122 -155
- package/dist/plan/index.mjs.map +1 -0
- package/dist/{Policy.d.mts → policy/Policy.d.mts} +5 -9
- package/dist/{Policy.mjs → policy/Policy.mjs} +11 -21
- package/dist/policy/Policy.mjs.map +1 -0
- package/dist/presentation/Motion.d.mts +12 -0
- package/dist/{Motion.mjs → presentation/Motion.mjs} +4 -27
- package/dist/presentation/Motion.mjs.map +1 -0
- package/dist/presentation/Presentation.d.mts +30 -0
- package/dist/presentation/Presentation.mjs +105 -0
- package/dist/presentation/Presentation.mjs.map +1 -0
- package/dist/{Stage.d.mts → presentation/Stage.d.mts} +5 -8
- package/dist/{Stage.mjs → presentation/Stage.mjs} +68 -76
- package/dist/presentation/Stage.mjs.map +1 -0
- package/dist/presentation/feed.d.mts +20 -0
- package/dist/presentation/feed.mjs +18 -0
- package/dist/presentation/feed.mjs.map +1 -0
- package/dist/providers/Cdp.d.mts +9 -0
- package/dist/providers/Cdp.mjs +15 -0
- package/dist/providers/Cdp.mjs.map +1 -0
- package/dist/{Chromium.d.mts → providers/Chromium.d.mts} +6 -7
- package/dist/{Chromium.mjs → providers/Chromium.mjs} +7 -16
- package/dist/providers/Chromium.mjs.map +1 -0
- package/dist/providers/Released.d.mts +2 -0
- package/dist/providers/Released.mjs +12 -0
- package/dist/providers/Released.mjs.map +1 -0
- package/dist/stillness/Stillness.d.mts +12 -0
- package/dist/stillness/Stillness.mjs +2 -0
- package/dist/supervisor/Supervisor.d.mts +104 -0
- package/dist/supervisor/Supervisor.mjs +513 -0
- package/dist/supervisor/Supervisor.mjs.map +1 -0
- package/dist/testing/index.d.mts +337 -0
- package/dist/testing/index.mjs +515 -0
- package/dist/testing/index.mjs.map +1 -0
- package/dist/workerd/Cdp.d.mts +8 -0
- package/dist/workerd/Cdp.mjs +13 -0
- package/dist/workerd/Cdp.mjs.map +1 -0
- package/package.json +94 -33
- package/src/Action.ts +127 -0
- package/src/ActionPort.ts +128 -0
- package/src/Browser.ts +366 -225
- package/src/BrowserError.ts +63 -6
- package/src/BrowserEvent.ts +26 -25
- package/src/Change.ts +0 -2
- package/src/{internal/pictures/clock.ts → Clock.ts} +17 -6
- package/src/Frame.ts +14 -0
- package/src/Geometry.ts +48 -0
- package/src/{internal/reading/match.inpage.ts → Matching.ts} +34 -4
- package/src/Page.ts +111 -92
- package/src/Snapshot.ts +5 -0
- package/src/{internal/input/style.ts → Style.ts} +121 -14
- package/src/Window.ts +30 -0
- package/src/index.ts +8 -13
- package/src/internal/input/actions.ts +61 -119
- package/src/internal/input/dispatch.ts +3 -3
- package/src/internal/input/gate.ts +21 -18
- package/src/internal/input/guard.inpage.ts +25 -58
- package/src/internal/input/guard.ts +11 -20
- package/src/internal/input/keyboard.ts +12 -3
- package/src/internal/input/perform.ts +78 -60
- package/src/internal/input/pointer.ts +4 -2
- package/src/internal/input/settle.ts +7 -5
- package/src/internal/input/targets.inpage.ts +1 -1
- package/src/internal/input/targets.ts +4 -9
- package/src/internal/page/bridge.ts +210 -114
- package/src/internal/page/context.ts +23 -73
- package/src/internal/page/dialogs.ts +58 -0
- package/src/internal/page/identity.ts +6 -23
- package/src/internal/page/lane.ts +14 -15
- package/src/internal/page/navigation.ts +50 -42
- package/src/internal/page/openings.ts +11 -5
- package/src/internal/page/page.ts +44 -81
- package/src/internal/page/port.ts +125 -0
- package/src/internal/{input → page}/replies.ts +1 -1
- package/src/internal/page/request-owner.ts +269 -0
- package/src/internal/page/requests.ts +357 -0
- package/src/internal/page/scripts.ts +124 -0
- package/src/internal/pictures/capture.ts +255 -332
- package/src/internal/pictures/dimensions.ts +162 -0
- package/src/internal/pictures/frame.ts +68 -0
- package/src/internal/pictures/pictures.ts +57 -23
- package/src/internal/pictures/quiescence.ts +1 -1
- package/src/internal/pictures/state.ts +26 -0
- package/src/internal/pictures/transport.ts +21 -4
- package/src/internal/reading/controls.inpage.ts +5 -70
- package/src/internal/reading/expect.inpage.ts +13 -17
- package/src/internal/reading/names.inpage.ts +89 -45
- package/src/internal/reading/outline.inpage.ts +6 -7
- package/src/internal/reading/reading.ts +144 -176
- package/src/internal/reading/ready.inpage.ts +6 -17
- package/src/internal/reading/ready.ts +13 -135
- package/src/internal/reading/subjects.inpage.ts +83 -43
- package/src/internal/reading/walk.inpage.ts +33 -13
- package/src/internal/timeline/changes.ts +55 -6
- package/src/internal/timeline/events.ts +15 -5
- package/src/internal/timeline/history.inpage.ts +1 -1
- package/src/internal/timeline/record.inpage.ts +4 -1
- package/src/internal/timeline/window.ts +2 -1
- package/src/{Moment.ts → moment/Moment.ts} +13 -31
- package/src/{internal/timeline → moment}/words.ts +2 -2
- package/src/{internal/reading → plan}/choose.ts +3 -3
- package/src/plan/data.ts +117 -0
- package/src/plan/execute.ts +411 -0
- package/src/plan/index.ts +36 -0
- package/src/plan/record.ts +71 -0
- package/src/plan/targets.ts +71 -0
- package/src/{Policy.ts → policy/Policy.ts} +13 -10
- package/src/{Motion.ts → presentation/Motion.ts} +12 -46
- package/src/presentation/Presentation.ts +176 -0
- package/src/{Stage.ts → presentation/Stage.ts} +147 -112
- package/src/presentation/feed.ts +21 -0
- package/src/providers/Cdp.ts +16 -0
- package/src/{Chromium.ts → providers/Chromium.ts} +7 -10
- package/src/providers/Released.ts +13 -0
- package/src/providers/connection.ts +134 -0
- package/src/{internal/pictures/motion.ts → stillness/Pixels.ts} +4 -4
- package/src/stillness/Stillness.ts +166 -0
- package/src/supervisor/Supervisor.ts +170 -0
- package/src/supervisor/contract.ts +105 -0
- package/src/supervisor/lifecycle.ts +272 -0
- package/src/supervisor/runtime.ts +234 -0
- package/src/testing/TestBrowser.ts +115 -0
- package/src/testing/TestPage.ts +10 -0
- package/src/testing/evidence.ts +154 -0
- package/src/testing/index.ts +3 -0
- package/src/testing/model.ts +222 -0
- package/src/testing/page.ts +360 -0
- package/src/workerd/Cdp.ts +11 -0
- package/dist/Browser-BwCldIff.mjs +0 -629
- package/dist/Browser-BwCldIff.mjs.map +0 -1
- package/dist/Cdp.d.mts +0 -32
- package/dist/Cdp.mjs +0 -61
- package/dist/Cdp.mjs.map +0 -1
- package/dist/Change-DNvztNLu.mjs +0 -138
- package/dist/Change-DNvztNLu.mjs.map +0 -1
- package/dist/Chromium.mjs.map +0 -1
- package/dist/Expect.d.mts +0 -62
- package/dist/Expect.mjs +0 -114
- package/dist/Expect.mjs.map +0 -1
- package/dist/Moment.d.mts +0 -2
- package/dist/Moment.mjs.map +0 -1
- package/dist/Motion.d.mts +0 -2
- package/dist/Motion.mjs.map +0 -1
- package/dist/Page-CfB6Zn1p.mjs.map +0 -1
- package/dist/Plan-C-d5QYS8.mjs.map +0 -1
- package/dist/Plan.d.mts +0 -2
- package/dist/Plan.mjs +0 -2
- package/dist/Policy.mjs.map +0 -1
- package/dist/Presentation.d.mts +0 -48
- package/dist/Presentation.mjs +0 -118
- package/dist/Presentation.mjs.map +0 -1
- package/dist/Stage.mjs.map +0 -1
- package/dist/Supervisor-2mPjIYYs.mjs +0 -676
- package/dist/Supervisor-2mPjIYYs.mjs.map +0 -1
- package/dist/Supervisor-mVPeEUp8.d.mts +0 -317
- package/dist/Supervisor.d.mts +0 -2
- package/dist/Supervisor.mjs +0 -2
- package/dist/context-w3NJPRLo.mjs +0 -335
- package/dist/context-w3NJPRLo.mjs.map +0 -1
- package/dist/match.inpage-xOe9LNO0.mjs.map +0 -1
- package/dist/page-BKwfF6z-.mjs +0 -5099
- package/dist/page-BKwfF6z-.mjs.map +0 -1
- package/dist/url-Cd04Okid.mjs +0 -264
- package/dist/url-Cd04Okid.mjs.map +0 -1
- package/src/Cdp.ts +0 -101
- package/src/Expect.ts +0 -180
- package/src/Plan.ts +0 -674
- package/src/Presentation.ts +0 -196
- package/src/Supervisor.ts +0 -632
- package/src/internal/supervisor/lifecycle.ts +0 -484
- /package/src/{internal/page/url.ts → Url.ts} +0 -0
- /package/src/{internal/pictures → stillness}/utilsBundle.d.ts +0 -0
package/README.md
CHANGED
|
@@ -24,12 +24,12 @@ with it, since its pipe closes, but leaves Playwright's temporary profile behind
|
|
|
24
24
|
|
|
25
25
|
| Module | What it holds |
|
|
26
26
|
| -------------- | --------------------------------------------------------------------------------- |
|
|
27
|
-
| `Browser` | The `Browser` service: tabs, recent events and
|
|
27
|
+
| `Browser` | The `Browser` service: tabs, recent events, lifetime and input suspension |
|
|
28
28
|
| `Chromium` | A local Chromium as a `Browser` layer |
|
|
29
29
|
| `Cdp` | Any DevTools endpoint as a `Browser` layer |
|
|
30
30
|
| `Page` | One tab: navigation, reads, screenshots, input, waits and the screencast |
|
|
31
31
|
| `Snapshot` | The model-readable outline of a page, with refs for its controls |
|
|
32
|
-
| `Frame` |
|
|
32
|
+
| `Frame` | Pictures, timing evidence and capture identity |
|
|
33
33
|
| `BrowserEvent` | Tabs, documents, loads, actions, dialogs, pointer motion and the browser's end |
|
|
34
34
|
| `Motion` | A bounded pointer planner, as a value, and the tuned sigma-lognormal one |
|
|
35
35
|
| `Presentation` | Input performed for viewers: a presenter, and its views of pages |
|
|
@@ -41,13 +41,133 @@ with it, since its pipe closes, but leaves Playwright's temporary profile behind
|
|
|
41
41
|
| `Plan` | A walk recorded from a page's events, replayed on a fresh page by subject |
|
|
42
42
|
| `Supervisor` | A browser kept open across losses and session ends, as generations |
|
|
43
43
|
|
|
44
|
+
Providers and features use explicit subpaths, such as `effect-browser/Chromium` and
|
|
45
|
+
`effect-browser/Plan`. The root exports the kernel. `Action`, `ActionPort`, `Clock`, `Geometry`,
|
|
46
|
+
`Matching`, `Style` and `Window` provide its execution, timing, matching and observation contracts.
|
|
47
|
+
`effect-browser/Stillness` owns screen/content quiet waits. `effect-browser/testing` exports
|
|
48
|
+
seeded TestPage/TestBrowser services; they execute explicit test data and refuse page scripts.
|
|
49
|
+
|
|
50
|
+
## Runtime CDP connectors
|
|
51
|
+
|
|
52
|
+
`Cdp.open` and `Cdp.layer` accept `connect: Cdp.Connector`, a callback receiving the endpoint and
|
|
53
|
+
`{ timeout, headers, signal }` and returning a real Playwright CDP `Browser`. Node uses
|
|
54
|
+
`playwright-core`'s `chromium.connectOverCDP` by default. A consumer can supply a connector using
|
|
55
|
+
its runtime's WebSocket implementation to avoid Playwright's Node WebSocket transport.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { Redacted } from "effect";
|
|
59
|
+
import * as Cdp from "effect-browser/Cdp";
|
|
60
|
+
|
|
61
|
+
declare const connect: Cdp.Connector; // The consumer's runtime-compatible Playwright connector.
|
|
62
|
+
|
|
63
|
+
const Remote = Cdp.layer({ endpoint: Redacted.make("wss://browser.example/cdp"), connect });
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
For Bun, this connector uses the global `WebSocket` and Playwright 1.63's public transport
|
|
67
|
+
argument. It accepts `ws:` and `wss:` endpoints. Standard `WebSocket` cannot add custom headers,
|
|
68
|
+
so this example refuses them; a consumer needing headers supplies a runtime-specific connector.
|
|
69
|
+
The same example is exercised against local Chromium under Node and Bun, without a hosted session.
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import * as Cdp from "effect-browser/Cdp";
|
|
73
|
+
import { chromium, type ConnectOverCDPTransport } from "playwright-core";
|
|
74
|
+
|
|
75
|
+
const nativeConnect: Cdp.Connector = async (endpoint, { timeout, headers, signal }) => {
|
|
76
|
+
if (headers !== undefined)
|
|
77
|
+
throw new Error("This native connector does not support custom headers");
|
|
78
|
+
if (signal.aborted) throw new Error("CDP opening canceled");
|
|
79
|
+
const socket = new WebSocket(endpoint);
|
|
80
|
+
|
|
81
|
+
const transport: ConnectOverCDPTransport = {
|
|
82
|
+
send: (message) => socket.send(JSON.stringify(message)),
|
|
83
|
+
close: () => socket.close(),
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const abort = () => socket.close();
|
|
87
|
+
|
|
88
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
89
|
+
socket.addEventListener("message", (event) => {
|
|
90
|
+
transport.onmessage?.(JSON.parse(String(event.data)) as object);
|
|
91
|
+
});
|
|
92
|
+
socket.addEventListener("close", () => {
|
|
93
|
+
signal.removeEventListener("abort", abort);
|
|
94
|
+
transport.onclose?.();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
await new Promise<void>((resolve, reject) => {
|
|
99
|
+
socket.addEventListener("open", () => resolve(), { once: true });
|
|
100
|
+
socket.addEventListener("error", () => reject(new Error("Native CDP WebSocket failed")), {
|
|
101
|
+
once: true,
|
|
102
|
+
});
|
|
103
|
+
socket.addEventListener("close", () => reject(new Error("Native CDP WebSocket closed")), {
|
|
104
|
+
once: true,
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return await chromium.connectOverCDP(transport, { timeout });
|
|
109
|
+
} catch (cause) {
|
|
110
|
+
signal.removeEventListener("abort", abort);
|
|
111
|
+
socket.close();
|
|
112
|
+
|
|
113
|
+
throw cause;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Pass `nativeConnect` as `connect` to `Cdp.open` or `Cdp.layer`, or to the Browserbase options.
|
|
119
|
+
|
|
120
|
+
The `workerd` export condition selects a CDP entry without the Node transport. It requires
|
|
121
|
+
`connect`; omitting it fails with `BrowserError` reason `InvalidRequest`. The Workers root entry
|
|
122
|
+
excludes local `Chromium`; import `effect-browser/Cdp` for remote connections. Bundlers must select
|
|
123
|
+
the `workerd` condition. Local Worker/CDP checks also pass without `nodejs_compat`; the consumer still supplies and qualifies the runtime's Playwright
|
|
124
|
+
implementation against this package's Playwright peer; the seam does not certify a different
|
|
125
|
+
Playwright version or provide a Cloudflare connector.
|
|
126
|
+
|
|
127
|
+
The callback receives a finite positive `connectTimeoutMillis`, 30 seconds by default, and an
|
|
128
|
+
`AbortSignal`. Opening enforces that deadline independently, fails with reason `Timeout` and aborts
|
|
129
|
+
the signal when it expires or the caller is interrupted. A connector should stop its own pending
|
|
130
|
+
work when aborted. A browser it returns late is disconnected, as is one whose opening fails or
|
|
131
|
+
whose scope closes. Its `close()` must disconnect the CDP connection without ending the remote
|
|
132
|
+
browser; do not return a locally launched browser. Endpoints and headers can contain credentials:
|
|
133
|
+
keep them out of logs and model inputs. Connect failures retain typed reasons and redact the
|
|
134
|
+
endpoint's userinfo, path and query. A failure diagnostic that echoes a nonempty supplied header
|
|
135
|
+
value is withheld entirely, including in serialized errors.
|
|
136
|
+
|
|
137
|
+
`page.perform(action)` and the named input methods share the `Action` schema. Guards receive
|
|
138
|
+
that value as `InputRequest.action`; event records and plans preserve it with secret text redacted.
|
|
139
|
+
`page.read(fn, { arg, result })` returns `{ value, document, connection }` after schema decoding.
|
|
140
|
+
`page.act(fn, { arg, result, document, connection })` validates the document and optional connection,
|
|
141
|
+
passes the input guard as an opaque scripted action, and records dispatch before evaluation.
|
|
142
|
+
Scripts run in the main world; keep them self-contained because bundlers can rewrite functions.
|
|
143
|
+
Neither source nor arguments are recorded. A timed-out or cancelled `act` may still execute;
|
|
144
|
+
later input retains its ordering by waiting for that script's actual reply. If it never settles,
|
|
145
|
+
use `page.close` and open a replacement page. A caller timeout is not script cancellation.
|
|
146
|
+
`Browser.Options.viewport` is fixed at registration;
|
|
147
|
+
`requests` installs bounded allow/refuse/fulfill decisions for its context before pages open,
|
|
148
|
+
including each redirect hop. A decision sees the exact UTF-8 request body, or `null` when absent;
|
|
149
|
+
incomplete or binary body evidence refuses the request and ends the connection's authority.
|
|
150
|
+
Installation refuses contexts with preexisting workers because Chrome does not expose their
|
|
151
|
+
traffic to a newly enabled browser interceptor. Workers created after installation are covered.
|
|
152
|
+
Policies receive only their own context's traffic. Refusal events include the containing page only
|
|
153
|
+
when established; worker and out-of-process iframe requests can omit it. Decision failure, timeout, unknown ownership
|
|
154
|
+
and saturated queues end authority. Closing the scope attempts to settle paused traffic first; when ownership
|
|
155
|
+
cannot be established it closes only that context's targets. Failed cleanup remains observable,
|
|
156
|
+
but detachment can release unresolved traffic. Enforcement lasts for this connection's scope; CDP disconnection removes interception, so this
|
|
157
|
+
request-control API does not provide a network firewall for an external browser after disconnect.
|
|
158
|
+
Raw Playwright pages and contexts are no longer public members.
|
|
159
|
+
|
|
44
160
|
A snapshot outlines the viewport, or the whole page, with a ref such as `e12` on each control, and
|
|
45
161
|
lists those controls as values, `Snapshot.Control`: each one's ref, kind, name and what it holds,
|
|
46
162
|
a select's options, and whether it is disabled, checked or takes typed text. `within` reads only
|
|
47
163
|
inside the elements a CSS selector matches, and `query` keeps the lines that hold some text.
|
|
48
|
-
`Page.
|
|
49
|
-
|
|
50
|
-
|
|
164
|
+
`Page.until(query, want, millis)` waits using `find` matching, including CSS `selector` and
|
|
165
|
+
`state: "enabled"`. It searches the document by default. `want` is `"some"`, `"none"`, or
|
|
166
|
+
`{ other: previous.mark }`; comparison marks reveal no text or values and ignore focus.
|
|
167
|
+
A finite nonnegative deadline returns `{ met, mark }`; document replacements share that deadline.
|
|
168
|
+
If no document answers before it, an unmet positive wait has `mark: ""`, meaning no baseline was
|
|
169
|
+
sampled. A zero-duration baseline reads once and fails if its document disappears. `press` takes
|
|
170
|
+
`on`, a ref it focuses before the first key, such as a link only the keyboard reaches. `Moment.describeChange` tells a change in the words
|
|
51
171
|
a moment uses. The actions a call performs record a caller's id as their `correlation` when it runs
|
|
52
172
|
under `Page.correlate(id)`, such as a model's tool call.
|
|
53
173
|
|
|
@@ -100,12 +220,14 @@ out of view, away from those points or ignoring the pointer, is missed. The outl
|
|
|
100
220
|
is, or until the time is up: its document is parsed and has painted since, nothing that ends is
|
|
101
221
|
animating in view, its fonts and the images in view have loaded, nothing in view is marked busy
|
|
102
222
|
(`aria-busy`), and the viewport shows something: text, a canvas drawn on, a picture or drawing
|
|
103
|
-
larger than an icon, a video or a frame.
|
|
223
|
+
larger than an icon, a video or a frame. It polls every 50 ms and follows document replacements
|
|
224
|
+
within one timeout. `quietMillis` also checks changes when a recorder is already running; it does
|
|
225
|
+
not start a recorder or a capture. A canvas mounted blank, as chart libraries mount theirs,
|
|
104
226
|
or a spinner alone is still loading. A screen that only says "Loading…" in words reads as ready,
|
|
105
227
|
and a WebGL canvas drawn once, without keeping its drawing, reads as blank. A hidden tab, which
|
|
106
228
|
paints nothing, is never ready.
|
|
107
229
|
|
|
108
|
-
|
|
230
|
+
`Stillness.wait(page, { quietMillis, still: "screen" })` waits for a ready screen to stay still that long: no screencast frame comes,
|
|
109
231
|
counted from the first frame of a capture the wait starts itself, since a hosted browser sends that
|
|
110
232
|
frame over half a second late. A capture's silence alone proves little: a stalled connection holds
|
|
111
233
|
frames on their way, and Chromium sends frames only while few acknowledgements are unanswered. So
|
|
@@ -122,13 +244,13 @@ longer than `quietMillis` between phases reads as still. On the slot machine fix
|
|
|
122
244
|
connection stalled for 450 to 900 ms toward either end while the reels spun, none of 132 waits
|
|
123
245
|
ended early, where all 36 did before.
|
|
124
246
|
|
|
125
|
-
`
|
|
247
|
+
`Stillness.wait(page, { still: "foreground", quietMillis })` allows motion already seen in the 1.5 seconds
|
|
126
248
|
before the page's latest input, such as idle decoration. Motion elsewhere restarts the quiet
|
|
127
249
|
interval. It compares newly accepted frames, including brief motion between polls and frames
|
|
128
250
|
accepted after a viewport-size check; missing history or more than eight new frames in one poll
|
|
129
251
|
restarts the interval conservatively. Without pre-input frame history, all motion counts.
|
|
130
252
|
|
|
131
|
-
`
|
|
253
|
+
`Stillness.wait(page, { still: "content", quietMillis })` instead observes a full interval without visible
|
|
132
254
|
recorded DOM changes. It starts the recorder itself and starts the interval again in each new
|
|
133
255
|
document; navigation retries share the original timeout. Canvas animation can continue while DOM
|
|
134
256
|
content is ready. This does not prove pixel or screencast stillness and inherits the change
|
|
@@ -155,10 +277,11 @@ What a busy page costs is the credit for an effect out of a click's reach, which
|
|
|
155
277
|
tells as a step; on a still page, an unrelated line 250 ms after a click is still credited.
|
|
156
278
|
|
|
157
279
|
A page records once something reads its changes: the first read starts it, and finds nothing yet.
|
|
158
|
-
From then the page's own session starts the recorder
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
is one call. A browser whose clock no capture has mapped
|
|
280
|
+
From then the page's own session starts the recorder in later documents once parsed. Two minutes
|
|
281
|
+
after the last read on the owning clock, it stops the current recorder and unregisters future
|
|
282
|
+
starts, even across navigation; a page nobody reads records nothing. The first read also
|
|
283
|
+
registers the recorder; every later read is one call. A browser whose clock no capture has mapped
|
|
284
|
+
yet maps it on its first read of changes,
|
|
162
285
|
once, in four round trips more. While it runs, a MutationObserver marks what changed: a text-only
|
|
163
286
|
element, as most prices are, is read at once, and anything else, with whether it was in view, as
|
|
164
287
|
the page renders it, through an IntersectionObserver that forces no layout. A change counts as seen
|
|
@@ -194,8 +317,8 @@ rest, each showing what it settled at, as a price that ticked and stopped does.
|
|
|
194
317
|
how long the page had been still, by the last change in view its record shows or the last paint
|
|
195
318
|
among its screencast frames; a screenshot shows the page, not when it changed. Frames show paint
|
|
196
319
|
only while a capture runs, and the record does not see a canvas, so a canvas that draws with no
|
|
197
|
-
capture running reads as still.
|
|
198
|
-
|
|
320
|
+
capture running reads as still. Use `Stillness.wait(page, { still: "screen", quietMillis })`
|
|
321
|
+
when a wait must observe screen quiet and hold through a stalled capture connection.
|
|
199
322
|
|
|
200
323
|
`Moment.capture` is a window that ends at a picture of the page now. It takes the picture first,
|
|
201
324
|
then the window up to its paint, from where a previous window or moment ended, so the changes hold
|
|
@@ -223,7 +346,8 @@ what was typed as an input slot named for its field, never the text itself. A na
|
|
|
223
346
|
address with a credential withheld is an input slot too, `address`, so replay goes where the caller
|
|
224
347
|
says, never to the address without its credential. `Plan.replay(page,
|
|
225
348
|
plan, { inputs })` takes the steps in turn: before each step except an opening navigate, back or
|
|
226
|
-
reload, it waits for
|
|
349
|
+
reload, it waits for readiness (`settle` sets how, or `false` skips it). A `quietMillis` option uses
|
|
350
|
+
`Stillness.wait` for content quiet; otherwise it calls `Page.ready`. It finds the element with
|
|
227
351
|
`Plan.locate`, and acts on it. An element that does not repeat every part of the recorded context
|
|
228
352
|
is another subject: its row read whole, so a row named "Wrapped BTC" is not the row "BTC" (laid out
|
|
229
353
|
again without rows, as cards, one of its fields must start with the row's words), its column where
|
|
@@ -247,8 +371,8 @@ of later actions after its earlier navigation has expired.
|
|
|
247
371
|
|
|
248
372
|
`Plan.take(page, plan, index)` takes one step and returns a `Receipt`: the step index, host-clock
|
|
249
373
|
`startedAt` and `at`, and `taken`, `verified` or `skipped`. Readiness is a precondition of the next
|
|
250
|
-
step, including later navigation, never a wait after the last step.
|
|
251
|
-
|
|
374
|
+
step, including later navigation, never a wait after the last step. After replay, call `page.ready`
|
|
375
|
+
for document readiness or `Stillness.wait` for a quiet final page. `Plan.replay` returns those receipts;
|
|
252
376
|
a `ReplayError` includes completed receipts and a serializable `stopped` value with the next step
|
|
253
377
|
and whether its input is `unsent` or `unknown`. Resume with `{ from: error.stopped }`. A numeric
|
|
254
378
|
index means fresh input, so never convert an unresolved stopping point into a number to retry it.
|
|
@@ -274,11 +398,10 @@ back, reload, insertion, presses, drags and ordinary clicks cannot. `Plan.repeat
|
|
|
274
398
|
which applies. `Plan.restore(page, plan, { upTo, inputs })` reconstructs earlier steps on a fresh
|
|
275
399
|
page using those same rules and refuses unresolved commitments. `upTo` is exclusive.
|
|
276
400
|
|
|
277
|
-
`Plan.Plan.new(steps)`
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
to recover through them. Old 0.2 plans and unknown versions do not decode.
|
|
401
|
+
`Plan.Plan.new(steps)` emits version 3 with canonical typed Actions. Prior version 1/2
|
|
402
|
+
string-action plans and unknown versions do not decode. This is a hard cutover; rerecord or
|
|
403
|
+
explicitly convert an older plan before replay. Decoding rejects `durable: true` on `Gone` or
|
|
404
|
+
URL-less `Navigated`; execution also refuses recovery through those unsupported claims.
|
|
282
405
|
|
|
283
406
|
`Browser.Options.guard` is the input policy. Its `InputRequest` schema contains the action, the
|
|
284
407
|
resolved element, the page's URL and title, and the `facts` the page's structure establishes:
|
|
@@ -345,9 +468,8 @@ The task comes from `Policy.Task`, which `effect-agent-browser`'s tools provide
|
|
|
345
468
|
from the run's `task`; elsewhere, provide it yourself, or risky input is denied for want of one. A judge sees the task, the action, the typed
|
|
346
469
|
text and the facts as trusted, and the page's text only as evidence. It never sees the agent's own
|
|
347
470
|
words. A judgement only adds to structure: a `secret` fact counts whatever the judge reads. A judge
|
|
348
|
-
that fails or exceeds `timeout` (30 seconds)
|
|
349
|
-
|
|
350
|
-
facts, such as a same-origin link, go ahead. With `@effect/ai-openrouter`, set
|
|
471
|
+
that fails or exceeds `timeout` (30 seconds) fails closed with `PolicyDenied`, including inputs
|
|
472
|
+
without structural facts. Script actions also pass the guard as opaque scripted input. With `@effect/ai-openrouter`, set
|
|
351
473
|
`strictJsonSchema: true` in the model's config for structured judge outputs.
|
|
352
474
|
|
|
353
475
|
Holds use `policyTimeout`, a finite positive duration defaulting to five minutes, separately from
|
|
@@ -467,16 +589,17 @@ change, 600 ms after a new document and 1 second on another page; the pointer gl
|
|
|
467
589
|
viewers last saw it, on whichever page; a field is clicked before typing; and the wheel turns in
|
|
468
590
|
100 px notches, in bursts of up to nine. One view acts at a time. The time a view spends showing an
|
|
469
591
|
action, its glides, holds and typing, has a budget of its own outside `actionTimeout`. `page`
|
|
470
|
-
itself stays plain, and plain input on any page never waits for a view.
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
592
|
+
itself stays plain, and plain input on any page never waits for a view. Styles flow through
|
|
593
|
+
`Style.Current`, including to followed tabs. Hand acquisition honours `failFast` and the action's
|
|
594
|
+
wait bound after approval. Planned typing and scrolling have a separate 10-second cap and fail
|
|
595
|
+
`InvalidRequest` before input when the schedule exceeds it.
|
|
474
596
|
|
|
475
597
|
A stage is one per live output. `stage.cue(page)` starts capture now; `cue.ready` waits for a
|
|
476
598
|
current frame, and `cue.commit({ at })` switches on the host time of an event that actually
|
|
477
599
|
happened. Preparing belongs to the caller's scope; once committed, capture belongs to the stage.
|
|
478
600
|
Closing an abandoned cue stops its capture. `present(page, { at })` is the convenience for cueing
|
|
479
|
-
and committing in one call.
|
|
601
|
+
and committing in one call. A stage uses the first page's owning clock; cueing a page with a
|
|
602
|
+
different clock fails `InvalidRequest`, since host times from those clocks cannot be compared.
|
|
480
603
|
|
|
481
604
|
```ts
|
|
482
605
|
// Inside a scoped program: lineSent yields Some(hostTime) when the line goes out, or None if dropped.
|
|
@@ -545,7 +668,10 @@ Compare these stamps only within that clock: they are not epoch dates or compara
|
|
|
545
668
|
`Frame.timing` distinguishes `BrowserPaint` from `Screenshot`. Native frames retain browser epoch
|
|
546
669
|
milliseconds in `timestamp` and map them to `hostTime`, with an explicit clock uncertainty.
|
|
547
670
|
Screenshot fallbacks have only a host capture interval; their `timestamp` getter is undefined.
|
|
548
|
-
Windows and a moment's frame captions use `hostTime`, so delayed delivery cannot make old paint current.
|
|
671
|
+
Windows and a moment's frame captions use `hostTime`, so delayed delivery cannot make old paint current. `Frame.sameCapture(a, b)` compares
|
|
672
|
+
page/session/connection/document/generation/sequence lineage, so an image copy can retain its
|
|
673
|
+
capture evidence. Untagged pictures match only by object identity. Currency additionally requires
|
|
674
|
+
an active capture and the page's current document.
|
|
549
675
|
A picture states how old it may be. `Page.frame({ maxAge, after })` serves the newest screencast
|
|
550
676
|
frame when it has the viewport's size and was painted at most `maxAge` ago, at the earliest its
|
|
551
677
|
timing allows: 250 ms by default, while 0 always takes a new screenshot. With `after: "input"` the
|
|
@@ -689,25 +815,18 @@ reached the browser; `check` its effect first, as it may have taken place; `poin
|
|
|
689
815
|
such as with a stale ref; or `resume` reading events from a newer cursor. `message` is a sentence
|
|
690
816
|
for operators, and the browser tools tell a model what to do about the failure.
|
|
691
817
|
|
|
692
|
-
`
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
it, `Done`, or `NotDone` after `wait`, 5 seconds by default. An action that fails after its input
|
|
697
|
-
went is checked too: `Done` if its effect came, else its own failure, so the next `run` of the same
|
|
698
|
-
attempt, on the same page or the one a reconnect finds by its id, acts only if nothing came.
|
|
818
|
+
`Plan.take` checks an authored expected effect before input and after a dispatched failure.
|
|
819
|
+
Unknown consequential input requires positive durable evidence before continuation; the Plan
|
|
820
|
+
section above describes that recovery contract. `Page.until` provides the underlying bounded
|
|
821
|
+
observation without deciding whether an action may be repeated:
|
|
699
822
|
|
|
700
823
|
```ts
|
|
701
|
-
const
|
|
702
|
-
const outcome = yield * placing.run(page, (page) => page.click(ref));
|
|
824
|
+
const observed = yield * page.until({ text: "Order 42" }, "some", 5000);
|
|
703
825
|
```
|
|
704
826
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
none of it leaves the page. On a page a reconnect found, `navigated` without an address tells only
|
|
709
|
-
a move to another address, as the new connection counts documents afresh. A presenter's view is
|
|
710
|
-
checked as its page is; a page a `Browser` did not make is refused.
|
|
827
|
+
The mark from `until` compares matching elements' text, values and states except focus. Keep it
|
|
828
|
+
only as an observation baseline; an unmet or changed observation does not authorize repeating
|
|
829
|
+
unknown consequential input.
|
|
711
830
|
|
|
712
831
|
Every address the library reports, in events, frames, reads, errors, a guard's request and the
|
|
713
832
|
outline's links, keeps its identity and loses its userinfo and its credentials' values, which read
|
|
@@ -746,10 +865,11 @@ submission, including cleanup releases. Cursor shape comes from resolved target
|
|
|
746
865
|
events. Compositing remains the consumer’s job.
|
|
747
866
|
|
|
748
867
|
A page waits only for itself. Its operations take turns in one lane of its own: an action, which
|
|
749
|
-
sends input or navigates, has the page to itself
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
868
|
+
sends input or navigates, has the page to itself in FIFO order once it asks for admission.
|
|
869
|
+
Policy preparation reads the page first and a guard can wait outside that queue, so a later
|
|
870
|
+
approved action may enter before an earlier held one. Reads (the outline, `find`, `text`, `changes`,
|
|
871
|
+
pictures, zooms, `title` and the viewport) share the lane after the earlier queued writes, so they
|
|
872
|
+
describe the page those actions left. `ready` follows the action in flight too, and holds none back while it
|
|
753
873
|
watches. An action then waits for its page's unresolved input replies. Its timeout bounds those
|
|
754
874
|
waits before a full timeout bounds the action itself: a turn not given in time fails `Busy`, with
|
|
755
875
|
how long it waited and how many operations were ahead, and replies not answered in time fail
|
|
@@ -788,8 +908,8 @@ The consumer owns the operator's decisions and any durable workflow journal.
|
|
|
788
908
|
Reads keep their work. An identical read asked while one is in flight on the page, with no action
|
|
789
909
|
asked between them, joins it, and costs no call of its own. Each read runs in the page's scope under
|
|
790
910
|
the action timeout whoever gives up, so a caller's own `Effect.timeout` loses nothing: a read that
|
|
791
|
-
ends after all its callers gave up serves the next caller to ask the same within
|
|
792
|
-
unless an action or a new document came first. An action stops the reads nobody awaits rather than
|
|
911
|
+
ends after all its callers gave up serves the next caller to ask the same within 250 milliseconds
|
|
912
|
+
of completion, unless an action or a new document came first. An action stops the reads nobody awaits rather than
|
|
793
913
|
wait for them. Pictures and `changes` only join: a picture's caller says how old it may be, and a
|
|
794
914
|
window of changes ends as it is read.
|
|
795
915
|
|
|
@@ -809,13 +929,13 @@ its first glide starts mid-viewport, and each later one where the one before end
|
|
|
809
929
|
input on another tab does meanwhile. Every sent move updates the position, including a partially
|
|
810
930
|
cancelled glide. A later viewport clamps the starting point to its bounds if necessary.
|
|
811
931
|
|
|
812
|
-
## Supervising
|
|
932
|
+
## Supervising resource generations
|
|
813
933
|
|
|
814
|
-
`Supervisor
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
934
|
+
`effect-browser/Supervisor` owns a scoped resource through acquisition failures, loss and rotation.
|
|
935
|
+
Its generic core does not inspect browsers. `open(number)` acquires a generation in its own scope
|
|
936
|
+
and returns `{ value, lost?, release? }`; `lost` produces a reason string, and `release(why)` reports
|
|
937
|
+
`Settled` or `Unconfirmed` through `effect-browser/Released`. Without a release hook, closing
|
|
938
|
+
the generation's scope ends its resource.
|
|
819
939
|
|
|
820
940
|
```ts
|
|
821
941
|
import { Effect } from "effect";
|
|
@@ -823,113 +943,56 @@ import * as Chromium from "effect-browser/Chromium";
|
|
|
823
943
|
import * as Supervisor from "effect-browser/Supervisor";
|
|
824
944
|
|
|
825
945
|
const program = Effect.gen(function* () {
|
|
826
|
-
const
|
|
827
|
-
open:
|
|
828
|
-
|
|
829
|
-
|
|
946
|
+
const sessions = yield* Supervisor.make({
|
|
947
|
+
open: () =>
|
|
948
|
+
Effect.gen(function* () {
|
|
949
|
+
const browser = yield* Chromium.open();
|
|
830
950
|
|
|
831
|
-
|
|
832
|
-
|
|
951
|
+
return { value: browser, lost: browser.disconnected };
|
|
952
|
+
}),
|
|
833
953
|
});
|
|
834
|
-
return yield* browsers.use(({ value: page }) => page.snapshot());
|
|
835
|
-
});
|
|
836
|
-
```
|
|
837
|
-
|
|
838
|
-
`use(work, { wait })` atomically borrows the serving generation and runs `work` in a scope of its
|
|
839
|
-
own. The lease gives its `generation`, `browser`, `value`, an `ending` notice, `retain` and `lose`.
|
|
840
|
-
`wait` defaults to `waitTimeout` (two minutes); zero either borrows immediately or fails
|
|
841
|
-
`Unavailable`. Cancelling the caller closes its work scope and lets its hold go. Ordinary work
|
|
842
|
-
errors stay ordinary work errors. `browser` still returns an unheld browser: use it only when the
|
|
843
|
-
caller can tolerate that generation being released underneath it.
|
|
844
954
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
`browsers` as above and `Exit` and `Scope` imported from `effect`:
|
|
848
|
-
|
|
849
|
-
```ts
|
|
850
|
-
const prepared =
|
|
851
|
-
yield *
|
|
852
|
-
browsers.use((lease) =>
|
|
853
|
-
Effect.gen(function* () {
|
|
854
|
-
const hold = yield* lease.retain;
|
|
855
|
-
const page = yield* Effect.acquireRelease(lease.browser.newPage(), (page) =>
|
|
856
|
-
page.close.pipe(Effect.ignore),
|
|
857
|
-
).pipe(Scope.provide(hold));
|
|
858
|
-
|
|
859
|
-
return { page, hold, ending: lease.ending };
|
|
860
|
-
}),
|
|
955
|
+
return yield* sessions.use(({ value: browser }) =>
|
|
956
|
+
Effect.flatMap(browser.firstPage, (page) => page.text()),
|
|
861
957
|
);
|
|
862
|
-
|
|
863
|
-
yield * Scope.close(prepared.hold, Exit.void);
|
|
958
|
+
}).pipe(Effect.scoped);
|
|
864
959
|
```
|
|
865
960
|
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
generations still draining or releasing, and sessions whose acquisition or application build
|
|
895
|
-
failed. It waits for all of their pending releases. If any end is `Unconfirmed`, that outcome
|
|
896
|
-
remains visible on every later admission, even after newer releases settle. The supervisor keeps
|
|
897
|
-
the first unconfirmed outcome as its witness, without retaining completed generations' resources.
|
|
898
|
-
|
|
899
|
-
Before any release there is no `after`; completed confirmed releases resolve immediately. A
|
|
900
|
-
nonexclusive rotation excludes its still-serving predecessor, so awaiting `after` preserves
|
|
901
|
-
make-before-break rotation unless an older release remains pending or unconfirmed. The facts are
|
|
902
|
-
checked again before every retry. Exclusive acquisition also waits for all pending releases.
|
|
903
|
-
Admission failures follow `reopen` and `definite`, and retirement interrupts admission while
|
|
904
|
-
releases run to their outcomes. Ignoring `after` adds no release wait for nonexclusive acquisition.
|
|
905
|
-
|
|
906
|
-
Provider adapters can read the optional `Supervisor.Releasing` service during `open`. When an
|
|
907
|
-
attempt fails, its cleanup reports the actual outcome with `released(outcome)` before finishing;
|
|
908
|
-
the original acquisition failure stays a failure. Successful generations return `Opened.release`
|
|
909
|
-
as usual. `Browserbase.supervise` supplies failed-connect and failed-build outcomes this way, so
|
|
910
|
-
consumers do not need to wrap or repeat a provider release.
|
|
911
|
-
|
|
912
|
-
`retire` revokes immediately, stops acquisition and waits for every generation to release.
|
|
913
|
-
Closing the supervisor's scope does the same unless `keep` is set: then only the serving
|
|
914
|
-
generation skips provider release, `Kept`; its application scopes still close. Other generations
|
|
915
|
-
are released normally.
|
|
916
|
-
|
|
917
|
-
`states` streams `Opening`, `Reopening`, `Open`, `Draining`, `Lost`, `Down`, `Closed` and `Kept`.
|
|
918
|
-
`Down.released` and an opening generation's `Closed.released` publish that generation's reported
|
|
919
|
-
failed-try cleanup, even when no later admission follows. The first `Unconfirmed` stays visible
|
|
920
|
-
after later tries settle; no reported cleanup leaves `released` undefined. A successful `Open`
|
|
921
|
-
ends this opening record, while `Admission.after` keeps earlier uncertainty. `Closed.released`
|
|
922
|
-
also preserves the serving generation's provider release. `Unconfirmed` does not establish that
|
|
923
|
-
a provider stopped the browser or its billing. `Generation.at` is wall-clock epoch milliseconds;
|
|
924
|
-
`hostTime` and `revokeAt` are host monotonic milliseconds from the supervisor's Effect `Clock`.
|
|
925
|
-
They can be compared with browser event and frame times when those use that same clock and host,
|
|
926
|
-
not across processes or against a provider's wall-clock timestamps. A generation event is
|
|
927
|
-
lifetime evidence, not proof that a frame was shown. `Browserbase.supervise` supplies hosted
|
|
928
|
-
generations and, with `keep`, can adopt one it previously kept.
|
|
929
|
-
|
|
930
|
-
Every module is also an entry point, such as `effect-browser/Page`. The
|
|
961
|
+
`use` holds one generation through the callback and its scoped cleanup. Its lease has `generation`,
|
|
962
|
+
`value`, `ending` and `lose(detail)`. Rotation and loss revoke work with typed `Superseded`; a stale
|
|
963
|
+
loss declaration does nothing. The caller owns application decisions about retrying interrupted work
|
|
964
|
+
and reading its input receipts. `use(work, { wait })` accepts a finite nonnegative admission budget on the
|
|
965
|
+
supervisor's owning clock; zero peeks, and omission waits. Invalid budgets fail with typed `InvalidWait`. A permanent acquisition failure or
|
|
966
|
+
retirement fails waiting callers with `Unavailable`.
|
|
967
|
+
|
|
968
|
+
`rotate(from?)` opens a replacement, ignoring a stale generation number. By default a healthy
|
|
969
|
+
predecessor serves while its replacement opens. With `exclusive: true`, revocation, callback cleanup
|
|
970
|
+
and provider release complete before replacement acquisition. A lost generation always revokes
|
|
971
|
+
immediately. Its release starts after all admitted callbacks finish cleanup. Generation resources
|
|
972
|
+
created by `open` close after the release hook.
|
|
973
|
+
|
|
974
|
+
Failed acquisitions close their scope before retrying. Every attempt publishes its own typed error;
|
|
975
|
+
cleanup evidence stays attached to that error rather than being combined with later attempts.
|
|
976
|
+
`reopen` supplies the retry schedule, exponential from one second for at most five minutes by default;
|
|
977
|
+
`definite(error)` stops retries for permanent errors. An acquisition already running finishes and
|
|
978
|
+
cleans up during retirement, while a retry delay stops immediately. `retire` and scope closure await
|
|
979
|
+
all acquisition and release work. Cancelling a caller waiting for `retire` leaves retirement running.
|
|
980
|
+
|
|
981
|
+
`states` replays the latest 64 changes: `Opening`, `Failed`, `Open`, `Ending`, `Down` and `Closed`.
|
|
982
|
+
`Closed.released` reports that generation's outcome, including failed scope closure. `at` is epoch
|
|
983
|
+
milliseconds and `hostTime` is monotonic milliseconds on the owning Effect clock. They are lifecycle
|
|
984
|
+
evidence, separate from evidence that a frame reached a viewer. Provider scheduling, accounting,
|
|
985
|
+
process restart adoption and application retention remain caller composition. Browserbase supplies
|
|
986
|
+
`Browserbase.generations(...)` for this same core.
|
|
987
|
+
|
|
988
|
+
Public modules have explicit entry points, such as `effect-browser/Page`. The
|
|
931
989
|
[repository README](https://github.com/mannyc2/effect-agent-browserbase#readme) has examples.
|
|
932
990
|
|
|
991
|
+
The published build embeds the complete page script as a closed JavaScript source string. Consumer
|
|
992
|
+
bundlers can preserve function names or minify the library without changing that script's dependencies.
|
|
993
|
+
The `@effect-browser/source` export condition is for this workspace's development tools; consumer
|
|
994
|
+
bundles should use the default built exports, which also supply the Workers-specific packaging.
|
|
995
|
+
|
|
933
996
|
## Tracing
|
|
934
997
|
|
|
935
998
|
Operations are spans in Effect's tracer, so an application that installs an exporter sees them in
|