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.
Files changed (243) hide show
  1. package/README.md +221 -158
  2. package/dist/Action-24sLOubi.d.mts +110 -0
  3. package/dist/Action.d.mts +2 -0
  4. package/dist/Action.mjs +141 -0
  5. package/dist/Action.mjs.map +1 -0
  6. package/dist/ActionPort.d.mts +15 -0
  7. package/dist/ActionPort.mjs +101 -0
  8. package/dist/ActionPort.mjs.map +1 -0
  9. package/dist/Browser-Cq2K1FEA.mjs +4075 -0
  10. package/dist/Browser-Cq2K1FEA.mjs.map +1 -0
  11. package/dist/Browser-wZhwZSlG.d.mts +167 -0
  12. package/dist/Browser.d.mts +2 -129
  13. package/dist/Browser.mjs +1 -1
  14. package/dist/{BrowserError-Coy7EW1N.d.mts → BrowserError-BlcmLVzn.d.mts} +22 -7
  15. package/dist/BrowserError.d.mts +2 -2
  16. package/dist/BrowserError.mjs +46 -9
  17. package/dist/BrowserError.mjs.map +1 -1
  18. package/dist/{BrowserEvent-dq6FRT8w.d.mts → BrowserEvent-lLqJ3GJS.d.mts} +93 -37
  19. package/dist/BrowserEvent.d.mts +2 -2
  20. package/dist/BrowserEvent.mjs +29 -24
  21. package/dist/BrowserEvent.mjs.map +1 -1
  22. package/dist/{Change-DqING3tr.d.mts → Change-Ba7INmay.d.mts} +4 -6
  23. package/dist/Change.d.mts +2 -2
  24. package/dist/Change.mjs +97 -2
  25. package/dist/Change.mjs.map +1 -0
  26. package/dist/Clock.d.mts +57 -0
  27. package/dist/Clock.mjs +80 -0
  28. package/dist/Clock.mjs.map +1 -0
  29. package/dist/{Frame-DkNdjjjr.d.mts → Frame-UEH2hO5T.d.mts} +10 -3
  30. package/dist/Frame.d.mts +2 -2
  31. package/dist/Frame.mjs +10 -2
  32. package/dist/Frame.mjs.map +1 -1
  33. package/dist/{Motion-DND6I-64.d.mts → Geometry-DJx9qrYy.d.mts} +7 -10
  34. package/dist/Geometry.d.mts +2 -0
  35. package/dist/Geometry.mjs +32 -0
  36. package/dist/Geometry.mjs.map +1 -0
  37. package/dist/LICENSE-jpeg-js +28 -0
  38. package/dist/Matching.d.mts +37 -0
  39. package/dist/{match.inpage-xOe9LNO0.mjs → Matching.mjs} +28 -4
  40. package/dist/Matching.mjs.map +1 -0
  41. package/dist/{Page-CfB6Zn1p.mjs → Page-BF5izr8R.mjs} +216 -31
  42. package/dist/Page-BF5izr8R.mjs.map +1 -0
  43. package/dist/{Page-ku6j5t-v.d.mts → Page-CvsOEorc.d.mts} +158 -185
  44. package/dist/Page.d.mts +2 -2
  45. package/dist/Page.mjs +1 -1
  46. package/dist/Released-tURbFmal.d.mts +15 -0
  47. package/dist/{Snapshot-B34hZ4Jl.d.mts → Snapshot-CtBVOtuu.d.mts} +6 -1
  48. package/dist/Snapshot.d.mts +1 -1
  49. package/dist/Snapshot.mjs.map +1 -1
  50. package/dist/Stillness-CNlvayIo.mjs +136 -0
  51. package/dist/Stillness-CNlvayIo.mjs.map +1 -0
  52. package/dist/Style-AO4V7Czt.mjs +357 -0
  53. package/dist/Style-AO4V7Czt.mjs.map +1 -0
  54. package/dist/Style.d.mts +72 -0
  55. package/dist/Style.mjs +2 -0
  56. package/dist/Url.d.mts +26 -0
  57. package/dist/Url.mjs +74 -0
  58. package/dist/Url.mjs.map +1 -0
  59. package/dist/Window-CMddGMt1.d.mts +34 -0
  60. package/dist/Window.d.mts +2 -0
  61. package/dist/Window.mjs +35 -0
  62. package/dist/Window.mjs.map +1 -0
  63. package/dist/connection-2KHI4_KN.d.mts +41 -0
  64. package/dist/connection-BTeO0Hiz.mjs +68 -0
  65. package/dist/connection-BTeO0Hiz.mjs.map +1 -0
  66. package/dist/index.d.mts +15 -17
  67. package/dist/index.mjs +11 -14
  68. package/dist/moment/Moment.d.mts +86 -0
  69. package/dist/{Moment.mjs → moment/Moment.mjs} +44 -38
  70. package/dist/moment/Moment.mjs.map +1 -0
  71. package/dist/{Plan-DJ4hEEna.d.mts → plan/index.d.mts} +169 -64
  72. package/dist/{Plan-C-d5QYS8.mjs → plan/index.mjs} +122 -155
  73. package/dist/plan/index.mjs.map +1 -0
  74. package/dist/{Policy.d.mts → policy/Policy.d.mts} +5 -9
  75. package/dist/{Policy.mjs → policy/Policy.mjs} +11 -21
  76. package/dist/policy/Policy.mjs.map +1 -0
  77. package/dist/presentation/Motion.d.mts +12 -0
  78. package/dist/{Motion.mjs → presentation/Motion.mjs} +4 -27
  79. package/dist/presentation/Motion.mjs.map +1 -0
  80. package/dist/presentation/Presentation.d.mts +30 -0
  81. package/dist/presentation/Presentation.mjs +105 -0
  82. package/dist/presentation/Presentation.mjs.map +1 -0
  83. package/dist/{Stage.d.mts → presentation/Stage.d.mts} +5 -8
  84. package/dist/{Stage.mjs → presentation/Stage.mjs} +68 -76
  85. package/dist/presentation/Stage.mjs.map +1 -0
  86. package/dist/presentation/feed.d.mts +20 -0
  87. package/dist/presentation/feed.mjs +18 -0
  88. package/dist/presentation/feed.mjs.map +1 -0
  89. package/dist/providers/Cdp.d.mts +9 -0
  90. package/dist/providers/Cdp.mjs +15 -0
  91. package/dist/providers/Cdp.mjs.map +1 -0
  92. package/dist/{Chromium.d.mts → providers/Chromium.d.mts} +6 -7
  93. package/dist/{Chromium.mjs → providers/Chromium.mjs} +7 -16
  94. package/dist/providers/Chromium.mjs.map +1 -0
  95. package/dist/providers/Released.d.mts +2 -0
  96. package/dist/providers/Released.mjs +12 -0
  97. package/dist/providers/Released.mjs.map +1 -0
  98. package/dist/stillness/Stillness.d.mts +12 -0
  99. package/dist/stillness/Stillness.mjs +2 -0
  100. package/dist/supervisor/Supervisor.d.mts +104 -0
  101. package/dist/supervisor/Supervisor.mjs +513 -0
  102. package/dist/supervisor/Supervisor.mjs.map +1 -0
  103. package/dist/testing/index.d.mts +337 -0
  104. package/dist/testing/index.mjs +515 -0
  105. package/dist/testing/index.mjs.map +1 -0
  106. package/dist/workerd/Cdp.d.mts +8 -0
  107. package/dist/workerd/Cdp.mjs +13 -0
  108. package/dist/workerd/Cdp.mjs.map +1 -0
  109. package/package.json +94 -33
  110. package/src/Action.ts +127 -0
  111. package/src/ActionPort.ts +128 -0
  112. package/src/Browser.ts +366 -225
  113. package/src/BrowserError.ts +63 -6
  114. package/src/BrowserEvent.ts +26 -25
  115. package/src/Change.ts +0 -2
  116. package/src/{internal/pictures/clock.ts → Clock.ts} +17 -6
  117. package/src/Frame.ts +14 -0
  118. package/src/Geometry.ts +48 -0
  119. package/src/{internal/reading/match.inpage.ts → Matching.ts} +34 -4
  120. package/src/Page.ts +111 -92
  121. package/src/Snapshot.ts +5 -0
  122. package/src/{internal/input/style.ts → Style.ts} +121 -14
  123. package/src/Window.ts +30 -0
  124. package/src/index.ts +8 -13
  125. package/src/internal/input/actions.ts +61 -119
  126. package/src/internal/input/dispatch.ts +3 -3
  127. package/src/internal/input/gate.ts +21 -18
  128. package/src/internal/input/guard.inpage.ts +25 -58
  129. package/src/internal/input/guard.ts +11 -20
  130. package/src/internal/input/keyboard.ts +12 -3
  131. package/src/internal/input/perform.ts +78 -60
  132. package/src/internal/input/pointer.ts +4 -2
  133. package/src/internal/input/settle.ts +7 -5
  134. package/src/internal/input/targets.inpage.ts +1 -1
  135. package/src/internal/input/targets.ts +4 -9
  136. package/src/internal/page/bridge.ts +210 -114
  137. package/src/internal/page/context.ts +23 -73
  138. package/src/internal/page/dialogs.ts +58 -0
  139. package/src/internal/page/identity.ts +6 -23
  140. package/src/internal/page/lane.ts +14 -15
  141. package/src/internal/page/navigation.ts +50 -42
  142. package/src/internal/page/openings.ts +11 -5
  143. package/src/internal/page/page.ts +44 -81
  144. package/src/internal/page/port.ts +125 -0
  145. package/src/internal/{input → page}/replies.ts +1 -1
  146. package/src/internal/page/request-owner.ts +269 -0
  147. package/src/internal/page/requests.ts +357 -0
  148. package/src/internal/page/scripts.ts +124 -0
  149. package/src/internal/pictures/capture.ts +255 -332
  150. package/src/internal/pictures/dimensions.ts +162 -0
  151. package/src/internal/pictures/frame.ts +68 -0
  152. package/src/internal/pictures/pictures.ts +57 -23
  153. package/src/internal/pictures/quiescence.ts +1 -1
  154. package/src/internal/pictures/state.ts +26 -0
  155. package/src/internal/pictures/transport.ts +21 -4
  156. package/src/internal/reading/controls.inpage.ts +5 -70
  157. package/src/internal/reading/expect.inpage.ts +13 -17
  158. package/src/internal/reading/names.inpage.ts +89 -45
  159. package/src/internal/reading/outline.inpage.ts +6 -7
  160. package/src/internal/reading/reading.ts +144 -176
  161. package/src/internal/reading/ready.inpage.ts +6 -17
  162. package/src/internal/reading/ready.ts +13 -135
  163. package/src/internal/reading/subjects.inpage.ts +83 -43
  164. package/src/internal/reading/walk.inpage.ts +33 -13
  165. package/src/internal/timeline/changes.ts +55 -6
  166. package/src/internal/timeline/events.ts +15 -5
  167. package/src/internal/timeline/history.inpage.ts +1 -1
  168. package/src/internal/timeline/record.inpage.ts +4 -1
  169. package/src/internal/timeline/window.ts +2 -1
  170. package/src/{Moment.ts → moment/Moment.ts} +13 -31
  171. package/src/{internal/timeline → moment}/words.ts +2 -2
  172. package/src/{internal/reading → plan}/choose.ts +3 -3
  173. package/src/plan/data.ts +117 -0
  174. package/src/plan/execute.ts +411 -0
  175. package/src/plan/index.ts +36 -0
  176. package/src/plan/record.ts +71 -0
  177. package/src/plan/targets.ts +71 -0
  178. package/src/{Policy.ts → policy/Policy.ts} +13 -10
  179. package/src/{Motion.ts → presentation/Motion.ts} +12 -46
  180. package/src/presentation/Presentation.ts +176 -0
  181. package/src/{Stage.ts → presentation/Stage.ts} +147 -112
  182. package/src/presentation/feed.ts +21 -0
  183. package/src/providers/Cdp.ts +16 -0
  184. package/src/{Chromium.ts → providers/Chromium.ts} +7 -10
  185. package/src/providers/Released.ts +13 -0
  186. package/src/providers/connection.ts +134 -0
  187. package/src/{internal/pictures/motion.ts → stillness/Pixels.ts} +4 -4
  188. package/src/stillness/Stillness.ts +166 -0
  189. package/src/supervisor/Supervisor.ts +170 -0
  190. package/src/supervisor/contract.ts +105 -0
  191. package/src/supervisor/lifecycle.ts +272 -0
  192. package/src/supervisor/runtime.ts +234 -0
  193. package/src/testing/TestBrowser.ts +115 -0
  194. package/src/testing/TestPage.ts +10 -0
  195. package/src/testing/evidence.ts +154 -0
  196. package/src/testing/index.ts +3 -0
  197. package/src/testing/model.ts +222 -0
  198. package/src/testing/page.ts +360 -0
  199. package/src/workerd/Cdp.ts +11 -0
  200. package/dist/Browser-BwCldIff.mjs +0 -629
  201. package/dist/Browser-BwCldIff.mjs.map +0 -1
  202. package/dist/Cdp.d.mts +0 -32
  203. package/dist/Cdp.mjs +0 -61
  204. package/dist/Cdp.mjs.map +0 -1
  205. package/dist/Change-DNvztNLu.mjs +0 -138
  206. package/dist/Change-DNvztNLu.mjs.map +0 -1
  207. package/dist/Chromium.mjs.map +0 -1
  208. package/dist/Expect.d.mts +0 -62
  209. package/dist/Expect.mjs +0 -114
  210. package/dist/Expect.mjs.map +0 -1
  211. package/dist/Moment.d.mts +0 -2
  212. package/dist/Moment.mjs.map +0 -1
  213. package/dist/Motion.d.mts +0 -2
  214. package/dist/Motion.mjs.map +0 -1
  215. package/dist/Page-CfB6Zn1p.mjs.map +0 -1
  216. package/dist/Plan-C-d5QYS8.mjs.map +0 -1
  217. package/dist/Plan.d.mts +0 -2
  218. package/dist/Plan.mjs +0 -2
  219. package/dist/Policy.mjs.map +0 -1
  220. package/dist/Presentation.d.mts +0 -48
  221. package/dist/Presentation.mjs +0 -118
  222. package/dist/Presentation.mjs.map +0 -1
  223. package/dist/Stage.mjs.map +0 -1
  224. package/dist/Supervisor-2mPjIYYs.mjs +0 -676
  225. package/dist/Supervisor-2mPjIYYs.mjs.map +0 -1
  226. package/dist/Supervisor-mVPeEUp8.d.mts +0 -317
  227. package/dist/Supervisor.d.mts +0 -2
  228. package/dist/Supervisor.mjs +0 -2
  229. package/dist/context-w3NJPRLo.mjs +0 -335
  230. package/dist/context-w3NJPRLo.mjs.map +0 -1
  231. package/dist/match.inpage-xOe9LNO0.mjs.map +0 -1
  232. package/dist/page-BKwfF6z-.mjs +0 -5099
  233. package/dist/page-BKwfF6z-.mjs.map +0 -1
  234. package/dist/url-Cd04Okid.mjs +0 -264
  235. package/dist/url-Cd04Okid.mjs.map +0 -1
  236. package/src/Cdp.ts +0 -101
  237. package/src/Expect.ts +0 -180
  238. package/src/Plan.ts +0 -674
  239. package/src/Presentation.ts +0 -196
  240. package/src/Supervisor.ts +0 -632
  241. package/src/internal/supervisor/lifecycle.ts +0 -484
  242. /package/src/{internal/page/url.ts → Url.ts} +0 -0
  243. /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 the Playwright context |
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` | A screencast 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.waitFor` waits, in one call the page answers as it comes, until what a selector matches
49
- shows, hides or is enabled, with some text if asked. `press` takes `on`, a ref it focuses before the
50
- first key, such as a link only the keyboard reaches. `Change.describe` tells a change in the words
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. A canvas mounted blank, as chart libraries mount theirs,
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
- With `quietMillis`, the screen must then also stay still that long: no screencast frame comes,
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
- `Page.ready({ still: "foreground", quietMillis })` allows motion already seen in the 1.5 seconds
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
- `Page.ready({ still: "content", quietMillis })` instead observes a full interval without visible
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 at the start of each later document, once it
159
- is parsed, until nobody has read it for two minutes; a page nobody reads records nothing and costs
160
- nothing. The first read also registers the recorder, in the same round trip, and every later read
161
- is one call. A browser whose clock no capture has mapped yet maps it on its first read of changes,
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. A wait for a still screen is `Page.ready({ quietMillis })`, which
198
- also holds through a stalled connection.
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 `Page.ready` (`settle` sets how, or `false` not to wait), finds the element with
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. Call `page.ready` after replay
251
- when the final page must be still. `Plan.replay` returns those receipts;
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)` selects the stored version: recordings without expected checks remain
278
- version 1; checks require version 2. Both decode, with version and contents validated together.
279
- From beta.13, decoding rejects `durable: true` on `Gone` or URL-less `Navigated`, including older
280
- version 2 payloads that used these unsupported recovery claims. Execution independently refuses
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) leaves the input unjudged. `make` then denies the input
349
- if it has any fact, with the judge's failure as the `PolicyDenied` cause, and lets an input without
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. `view.aim(target)` starts
471
- the glide as soon as a target is known, as when it appears in a model's streamed tool call; the
472
- view's next action completes it if it acts on that target, and stops it where it is otherwise. An
473
- aim records no action, and does nothing under an input guard.
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
- `Expect` is that check, for an action whose effect the page shows. An attempt names what the action
693
- is for, `appeared(query)`, `gone(query)`, `changed(query)` or `navigated(url?)`, with `Page.find`'s
694
- queries over the whole document, and takes its baseline as it begins. Each `run` checks first and
695
- sends nothing where the expectation holds already, `AlreadyDone`; otherwise it acts and waits for
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 placing = yield * Expect.attempt(page, Expect.appeared({ text: "Order placed" }));
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
- A check is one call to the page, and so is a wait, which the page answers as the effect comes;
706
- `navigated` reads what the page already knows, at no call. `changed` compares what the query found
707
- at the start, its elements' text, field values and states but focus, by a mark the page keeps, so
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, in the order actions were asked; reads (the
750
- outline, `find`, `text`, `changes`, pictures, zooms, `title` and the viewport) share it, after the action in
751
- flight and every action asked before them, so a read describes the page an action left, never one
752
- an action is still changing. `ready` follows the action in flight too, and holds none back while it
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 an action timeout,
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 browser generations
932
+ ## Supervising resource generations
813
933
 
814
- `Supervisor.make` keeps a browser open across losses and session ends. Its `open` builds each
815
- generation in a scope of its own and can return `{ browser, value }`: the application's pages,
816
- tools or other resources belong to that generation. A caller that stops waiting never interrupts
817
- the shared acquisition. Browser-only providers can continue returning `{ browser }`, with a
818
- `void` value. Pages and values do not carry over when a new generation opens.
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 browsers = yield* Supervisor.make({
827
- open: Effect.gen(function* () {
828
- const browser = yield* Chromium.open();
829
- const page = yield* browser.firstPage;
946
+ const sessions = yield* Supervisor.make({
947
+ open: () =>
948
+ Effect.gen(function* () {
949
+ const browser = yield* Chromium.open();
830
950
 
831
- return { browser, value: page };
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
- A retained scope transfers a hold beyond the `use` call. Acquire anything that must travel with
846
- that hold in its scope, and close it when the receiver is finished. Within a scoped program with
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
- // Hand `prepared` to its next owner; that owner eventually lets it go.
863
- yield * Scope.close(prepared.hold, Exit.void);
958
+ }).pipe(Effect.scoped);
864
959
  ```
865
960
 
866
- Rotation publishes `Draining` for the outgoing generation. It stays alive until its last hold
867
- closes or `handover` expires, 30 seconds by default. `ending` is the first notice that it stopped
868
- serving, with a `Superseded` reason and monotonic `revokeAt`; loss or retirement can revoke sooner.
869
- At revocation, `use` interrupts work still running, waits for its finalizers and fails
870
- `Superseded`. New `retain` calls refuse a revoked or releasing generation, and a retained scope
871
- cannot extend the deadline. Retained scopes and work scopes close before the provider's
872
- `release`; the generation's own scope closes last. Cleanup can therefore extend the time taken to
873
- finish revocation. `Superseded` does not say whether an input reached the site: use the action's
874
- receipt and plan stopping point to resolve that uncertainty.
875
-
876
- Nonexclusive `rotate`, including `rotateBefore` timed rotation, opens the next generation while
877
- old holds drain. Handover does not delay later rotations; multiple old generations can remain
878
- owned, so the consumer chooses its rotation and overlap budget. Calls share one acquisition in
879
- progress. Under `exclusive`, the current generation drains and finishes its provider release
880
- before acquisition starts. Call `rotate` outside `use` for a clean cut: an exclusive rotation
881
- inside `use` waits for its own hold to end or be revoked.
882
-
883
- A loss publishes `Lost` with the browser's `disconnected` cause and revokes its holds immediately.
884
- When the consumer detects an unusable page or capture while the browser stays connected,
885
- `lease.lose(detail)` applies the same transition with `cause: "declared"` and that detail. It stops
886
- serving the generation and revokes work without a handover wait, including work declaring its own
887
- loss and returning immediately. Declaring loss does not wait for work cleanup or provider release.
888
- Repeated declarations and declarations from draining or closed generations do nothing.
889
- It reopens on `reopen`, which also retries an open failure until the schedule ends. A provider's
890
- `definite` failure goes `Down` at once, with the cause also available through `Unavailable`.
891
-
892
- `admit({ number, after })` runs before every open attempt, including the first and each retry,
893
- inside the opening scope. `after` covers every earlier session that stopped serving: all older
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