effect-browser 0.3.0-beta.23 → 0.3.0-beta.25

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 (348) hide show
  1. package/README.md +437 -142
  2. package/dist/Action.d.mts +1 -1
  3. package/dist/Action.mjs +61 -9
  4. package/dist/Action.mjs.map +1 -1
  5. package/dist/Browser.d.mts +2 -2
  6. package/dist/Browser.mjs +2 -2
  7. package/dist/BrowserError.d.mts +2 -2
  8. package/dist/BrowserError.mjs +194 -41
  9. package/dist/BrowserError.mjs.map +1 -1
  10. package/dist/BrowserEvent.d.mts +2 -2
  11. package/dist/BrowserEvent.mjs +185 -35
  12. package/dist/BrowserEvent.mjs.map +1 -1
  13. package/dist/Cdp.d.mts +15 -0
  14. package/dist/Cdp.mjs +22 -0
  15. package/dist/Cdp.mjs.map +1 -0
  16. package/dist/Change.d.mts +2 -2
  17. package/dist/Change.mjs +40 -7
  18. package/dist/Change.mjs.map +1 -1
  19. package/dist/Frame.d.mts +2 -2
  20. package/dist/Frame.mjs +132 -14
  21. package/dist/Frame.mjs.map +1 -1
  22. package/dist/InputStyle.d.mts +153 -0
  23. package/dist/InputStyle.mjs +2 -0
  24. package/dist/Layout.d.mts +2 -0
  25. package/dist/Layout.mjs +123 -0
  26. package/dist/Layout.mjs.map +1 -0
  27. package/dist/Overlay.d.mts +2 -0
  28. package/dist/Overlay.mjs +58 -0
  29. package/dist/Overlay.mjs.map +1 -0
  30. package/dist/Page.d.mts +2 -2
  31. package/dist/Page.mjs +2 -2
  32. package/dist/PageTime.d.mts +2 -0
  33. package/dist/PageTime.mjs +17 -0
  34. package/dist/PageTime.mjs.map +1 -0
  35. package/dist/Pose.d.mts +2 -0
  36. package/dist/Pose.mjs +65 -0
  37. package/dist/Pose.mjs.map +1 -0
  38. package/dist/Site.d.mts +984 -0
  39. package/dist/Site.mjs +110 -0
  40. package/dist/Site.mjs.map +1 -0
  41. package/dist/Snapshot.d.mts +2 -2
  42. package/dist/Snapshot.mjs +87 -6
  43. package/dist/Snapshot.mjs.map +1 -1
  44. package/dist/Text.d.mts +2 -0
  45. package/dist/Text.mjs +45 -0
  46. package/dist/Text.mjs.map +1 -0
  47. package/dist/Window.d.mts +2 -2
  48. package/dist/Window.mjs +31 -6
  49. package/dist/Window.mjs.map +1 -1
  50. package/dist/ai/BrowserTools.d.mts +4987 -0
  51. package/dist/ai/BrowserTools.mjs +3 -0
  52. package/dist/ai/PageControl.d.mts +286 -0
  53. package/dist/ai/PageControl.mjs +426 -0
  54. package/dist/ai/PageControl.mjs.map +1 -0
  55. package/dist/ai/PromptCache.d.mts +16 -0
  56. package/dist/ai/PromptCache.mjs +72 -0
  57. package/dist/ai/PromptCache.mjs.map +1 -0
  58. package/dist/ai/Tabs.d.mts +2 -0
  59. package/dist/ai/Tabs.mjs +72 -0
  60. package/dist/ai/Tabs.mjs.map +1 -0
  61. package/dist/ai/ToolError.d.mts +34 -0
  62. package/dist/ai/ToolError.mjs +2 -0
  63. package/dist/ai/index.d.mts +6 -0
  64. package/dist/ai/index.mjs +6 -0
  65. package/dist/index.d.mts +7 -15
  66. package/dist/index.mjs +9 -8
  67. package/dist/{Action-24sLOubi.d.mts → internal/Action-CkanNTUw.d.mts} +64 -4
  68. package/dist/{Browser-wZhwZSlG.d.mts → internal/Browser-DD9Vm1c-.d.mts} +80 -10
  69. package/dist/{Browser-BKPAbyys.mjs → internal/Browser-vzD7i2oj.mjs} +658 -495
  70. package/dist/internal/Browser-vzD7i2oj.mjs.map +1 -0
  71. package/dist/{BrowserError-BlcmLVzn.d.mts → internal/BrowserError-CsuRYcDX.d.mts} +187 -28
  72. package/dist/{BrowserEvent-lLqJ3GJS.d.mts → internal/BrowserEvent-tGPYYf6R.d.mts} +197 -18
  73. package/dist/internal/BrowserTools-Yi3lOX4h.mjs +497 -0
  74. package/dist/internal/BrowserTools-Yi3lOX4h.mjs.map +1 -0
  75. package/dist/{Style-AO4V7Czt.mjs → internal/InputStyle-CPzxoN4g.mjs} +94 -16
  76. package/dist/internal/InputStyle-CPzxoN4g.mjs.map +1 -0
  77. package/dist/{moment/Moment.mjs → internal/Moment-CstaX1mR.mjs} +49 -16
  78. package/dist/internal/Moment-CstaX1mR.mjs.map +1 -0
  79. package/dist/{moment/Moment.d.mts → internal/Moment-DOcldBdf.d.mts} +54 -21
  80. package/dist/internal/Page-BfGxn7oN.d.mts +1553 -0
  81. package/dist/{Page-BF5izr8R.mjs → internal/Page-DqF-tuTx.mjs} +62 -72
  82. package/dist/internal/Page-DqF-tuTx.mjs.map +1 -0
  83. package/dist/internal/Release-CFONkPDP.d.mts +39 -0
  84. package/dist/internal/Stage-D5ymSXDT.mjs +298 -0
  85. package/dist/internal/Stage-D5ymSXDT.mjs.map +1 -0
  86. package/dist/internal/Stillness-DCPeAN1a.mjs +1124 -0
  87. package/dist/internal/Stillness-DCPeAN1a.mjs.map +1 -0
  88. package/dist/internal/Supervisor-BcY_QNIY.d.mts +108 -0
  89. package/dist/internal/Supervisor-BcglY23c.mjs +531 -0
  90. package/dist/internal/Supervisor-BcglY23c.mjs.map +1 -0
  91. package/dist/internal/Tabs-dXMscIUQ.d.mts +52 -0
  92. package/dist/internal/TestPage-CYiYbh63.d.mts +159 -0
  93. package/dist/internal/ToolError-DArsRS2m.mjs +117 -0
  94. package/dist/internal/ToolError-DArsRS2m.mjs.map +1 -0
  95. package/dist/{plan/index.d.mts → internal/Walk-BNXcfZ2z.d.mts} +59 -35
  96. package/dist/{plan/index.mjs → internal/Walk-C5ky7uSf.mjs} +83 -51
  97. package/dist/internal/Walk-C5ky7uSf.mjs.map +1 -0
  98. package/dist/{ActionPort.mjs → internal/action-port-B5EkeGOR.mjs} +6 -12
  99. package/dist/internal/action-port-B5EkeGOR.mjs.map +1 -0
  100. package/dist/internal/cdp/workerd.d.mts +13 -0
  101. package/dist/internal/cdp/workerd.mjs +19 -0
  102. package/dist/internal/cdp/workerd.mjs.map +1 -0
  103. package/dist/{Clock.mjs → internal/clock-BKSAEf00.mjs} +13 -13
  104. package/dist/internal/clock-BKSAEf00.mjs.map +1 -0
  105. package/dist/{connection-2KHI4_KN.d.mts → internal/connection-BaB0vp1o.d.mts} +6 -6
  106. package/dist/{connection-CK83pvqP.mjs → internal/connection-C2X4GmXM.mjs} +19 -15
  107. package/dist/internal/connection-C2X4GmXM.mjs.map +1 -0
  108. package/dist/internal/events-DzCrww-y.mjs +72 -0
  109. package/dist/internal/events-DzCrww-y.mjs.map +1 -0
  110. package/dist/internal/fold.inpage-CyVZQHZL.d.mts +49 -0
  111. package/dist/internal/fold.inpage-uhrT-dOB.mjs +49 -0
  112. package/dist/internal/fold.inpage-uhrT-dOB.mjs.map +1 -0
  113. package/dist/internal/functions-jBOs6GKv.mjs +27 -0
  114. package/dist/internal/functions-jBOs6GKv.mjs.map +1 -0
  115. package/dist/{Geometry-DJx9qrYy.d.mts → internal/geometry-Dhj_ztJs.d.mts} +3 -3
  116. package/dist/{Geometry.mjs → internal/geometry-Lxyflb9J.mjs} +3 -12
  117. package/dist/internal/geometry-Lxyflb9J.mjs.map +1 -0
  118. package/dist/{Matching.mjs → internal/matching-Cs-UeOY0.mjs} +24 -19
  119. package/dist/internal/matching-Cs-UeOY0.mjs.map +1 -0
  120. package/dist/internal/page-DFQb-YOK.mjs +436 -0
  121. package/dist/internal/page-DFQb-YOK.mjs.map +1 -0
  122. package/dist/internal/pose.inpage-CBFeWcVa.mjs +1996 -0
  123. package/dist/internal/pose.inpage-CBFeWcVa.mjs.map +1 -0
  124. package/dist/{Url.mjs → internal/url-DB0pQYk6.mjs} +3 -12
  125. package/dist/internal/url-DB0pQYk6.mjs.map +1 -0
  126. package/dist/policy/Policy.d.mts +60 -6
  127. package/dist/policy/Policy.mjs +52 -9
  128. package/dist/policy/Policy.mjs.map +1 -1
  129. package/dist/policy/index.d.mts +2 -0
  130. package/dist/policy/index.mjs +2 -0
  131. package/dist/presentation/Film.d.mts +332 -0
  132. package/dist/presentation/Film.mjs +298 -0
  133. package/dist/presentation/Film.mjs.map +1 -0
  134. package/dist/presentation/Motion.d.mts +5 -1
  135. package/dist/presentation/Motion.mjs +16 -2
  136. package/dist/presentation/Motion.mjs.map +1 -1
  137. package/dist/presentation/Presentation.d.mts +48 -6
  138. package/dist/presentation/Presentation.mjs +28 -9
  139. package/dist/presentation/Presentation.mjs.map +1 -1
  140. package/dist/presentation/Stage.d.mts +40 -6
  141. package/dist/presentation/Stage.mjs +1 -262
  142. package/dist/presentation/index.d.mts +5 -0
  143. package/dist/presentation/index.mjs +5 -0
  144. package/dist/supervisor/Release.d.mts +2 -0
  145. package/dist/supervisor/Release.mjs +40 -0
  146. package/dist/supervisor/Release.mjs.map +1 -0
  147. package/dist/supervisor/Supervisor.d.mts +2 -104
  148. package/dist/supervisor/Supervisor.mjs +2 -515
  149. package/dist/supervisor/index.d.mts +3 -0
  150. package/dist/supervisor/index.mjs +3 -0
  151. package/dist/testing/HttpCassette.d.mts +98 -0
  152. package/dist/testing/HttpCassette.mjs +146 -0
  153. package/dist/testing/HttpCassette.mjs.map +1 -0
  154. package/dist/testing/Story.d.mts +31 -0
  155. package/dist/testing/Story.mjs +76 -0
  156. package/dist/testing/Story.mjs.map +1 -0
  157. package/dist/testing/TestBrowser.d.mts +191 -0
  158. package/dist/testing/TestBrowser.mjs +105 -0
  159. package/dist/testing/TestBrowser.mjs.map +1 -0
  160. package/dist/testing/TestModel.d.mts +133 -0
  161. package/dist/testing/TestModel.mjs +209 -0
  162. package/dist/testing/TestModel.mjs.map +1 -0
  163. package/dist/testing/TestPage.d.mts +2 -0
  164. package/dist/testing/TestPage.mjs +47 -0
  165. package/dist/testing/TestPage.mjs.map +1 -0
  166. package/dist/testing/index.d.mts +6 -337
  167. package/dist/testing/index.mjs +6 -515
  168. package/dist/timeline/Moment.d.mts +3 -0
  169. package/dist/timeline/Moment.mjs +3 -0
  170. package/dist/timeline/Stillness.d.mts +34 -0
  171. package/dist/timeline/Stillness.mjs +2 -0
  172. package/dist/timeline/index.d.mts +3 -0
  173. package/dist/timeline/index.mjs +3 -0
  174. package/dist/walk/Walk.d.mts +2 -0
  175. package/dist/walk/Walk.mjs +2 -0
  176. package/dist/walk/index.d.mts +2 -0
  177. package/dist/walk/index.mjs +2 -0
  178. package/package.json +54 -133
  179. package/src/Action.ts +73 -8
  180. package/src/Browser.ts +85 -14
  181. package/src/BrowserError.ts +258 -63
  182. package/src/BrowserEvent.ts +264 -48
  183. package/src/Cdp.ts +42 -0
  184. package/src/Change.ts +75 -4
  185. package/src/Frame.ts +247 -14
  186. package/src/{Style.ts → InputStyle.ts} +130 -18
  187. package/src/Layout.ts +187 -0
  188. package/src/Overlay.ts +76 -0
  189. package/src/Page.ts +144 -275
  190. package/src/PageTime.ts +72 -0
  191. package/src/Pose.ts +81 -0
  192. package/src/Site.ts +136 -0
  193. package/src/Snapshot.ts +179 -3
  194. package/src/Text.ts +60 -0
  195. package/src/Window.ts +53 -3
  196. package/src/ai/BrowserTools.ts +778 -0
  197. package/src/ai/PageControl.ts +702 -0
  198. package/src/ai/PromptCache.ts +87 -0
  199. package/src/ai/Tabs.ts +84 -0
  200. package/src/ai/ToolError.ts +50 -0
  201. package/src/ai/index.ts +36 -0
  202. package/src/ai/internal/crops.ts +38 -0
  203. package/src/ai/internal/points.ts +57 -0
  204. package/src/ai/internal/receipts.ts +107 -0
  205. package/src/index.ts +87 -6
  206. package/src/{ActionPort.ts → internal/action-port.ts} +3 -3
  207. package/src/{providers → internal/cdp}/connection.ts +19 -12
  208. package/src/internal/cdp/workerd.ts +36 -0
  209. package/src/{Clock.ts → internal/clock.ts} +20 -0
  210. package/src/internal/input/actions.ts +1 -1
  211. package/src/internal/input/dispatch.ts +2 -2
  212. package/src/internal/input/guard.inpage.ts +1 -1
  213. package/src/internal/input/guard.ts +1 -1
  214. package/src/internal/input/perform.ts +35 -7
  215. package/src/internal/input/pointer.ts +9 -6
  216. package/src/internal/input/targets.inpage.ts +3 -3
  217. package/src/internal/input/targets.ts +1 -1
  218. package/src/{Matching.ts → internal/matching.ts} +28 -19
  219. package/src/internal/page/bridge.ts +67 -35
  220. package/src/internal/page/clock.inpage.ts +306 -0
  221. package/src/internal/page/compose.inpage.ts +101 -0
  222. package/src/internal/page/context.ts +4 -2
  223. package/src/internal/page/functions.ts +84 -0
  224. package/src/internal/page/navigation.ts +1 -1
  225. package/src/internal/page/openings.ts +2 -2
  226. package/src/internal/page/overlay.inpage.ts +96 -0
  227. package/src/internal/page/overlay.ts +89 -0
  228. package/src/internal/page/page.ts +39 -29
  229. package/src/internal/page/port.ts +14 -8
  230. package/src/internal/page/pose.inpage.ts +200 -0
  231. package/src/internal/page/pose.ts +80 -0
  232. package/src/internal/page/replies.ts +1 -1
  233. package/src/internal/page/requests.ts +1 -1
  234. package/src/internal/page/scripts.ts +1 -1
  235. package/src/internal/page/time.inpage.ts +49 -0
  236. package/src/internal/page/time.ts +122 -0
  237. package/src/internal/page/viewport.ts +3 -2
  238. package/src/internal/pictures/capture.ts +1 -4
  239. package/src/internal/pictures/dimensions.ts +1 -1
  240. package/src/internal/pictures/frame.ts +1 -1
  241. package/src/internal/pictures/pictures.ts +144 -91
  242. package/src/internal/reading/context.inpage.ts +2 -2
  243. package/src/internal/reading/expect.inpage.ts +1 -1
  244. package/src/internal/reading/layout.inpage.ts +193 -0
  245. package/src/internal/reading/layout.ts +101 -0
  246. package/src/internal/reading/names.inpage.ts +15 -0
  247. package/src/internal/reading/outline.inpage.ts +5 -21
  248. package/src/internal/reading/reading.ts +33 -21
  249. package/src/internal/reading/ready.inpage.ts +21 -26
  250. package/src/internal/reading/ready.ts +26 -5
  251. package/src/internal/reading/subjects.inpage.ts +3 -3
  252. package/src/internal/reading/text.inpage.ts +3 -16
  253. package/src/internal/reading/walk.inpage.ts +1 -1
  254. package/src/internal/timeline/changes.inpage.ts +7 -15
  255. package/src/internal/timeline/changes.ts +17 -5
  256. package/src/internal/timeline/record.inpage.ts +15 -6
  257. package/src/internal/timeline/sight.inpage.ts +2 -2
  258. package/src/internal/timeline/window.ts +3 -4
  259. package/src/policy/Policy.ts +70 -16
  260. package/src/policy/index.ts +12 -0
  261. package/src/presentation/Film.ts +451 -0
  262. package/src/presentation/Motion.ts +45 -3
  263. package/src/presentation/Presentation.ts +60 -14
  264. package/src/presentation/Stage.ts +73 -35
  265. package/src/presentation/index.ts +30 -0
  266. package/src/presentation/{feed.ts → internal/feed.ts} +1 -1
  267. package/src/supervisor/Release.ts +45 -0
  268. package/src/supervisor/Supervisor.ts +80 -5
  269. package/src/supervisor/index.ts +18 -0
  270. package/src/supervisor/{contract.ts → internal/contract.ts} +14 -10
  271. package/src/supervisor/{lifecycle.ts → internal/lifecycle.ts} +7 -7
  272. package/src/supervisor/{runtime.ts → internal/runtime.ts} +7 -7
  273. package/src/testing/HttpCassette.ts +260 -0
  274. package/src/testing/Story.ts +103 -0
  275. package/src/testing/TestBrowser.ts +14 -4
  276. package/src/testing/TestModel.ts +297 -0
  277. package/src/testing/TestPage.ts +92 -4
  278. package/src/testing/index.ts +35 -1
  279. package/src/testing/{evidence.ts → internal/evidence.ts} +19 -11
  280. package/src/testing/{model.ts → internal/model.ts} +14 -8
  281. package/src/testing/{page.ts → internal/page.ts} +55 -51
  282. package/src/{moment → timeline}/Moment.ts +79 -29
  283. package/src/{stillness → timeline}/Stillness.ts +89 -46
  284. package/src/timeline/index.ts +18 -0
  285. package/src/{stillness/Pixels.ts → timeline/internal/pixels.ts} +27 -1
  286. package/src/{moment → timeline/internal}/words.ts +2 -2
  287. package/src/walk/Walk.ts +165 -0
  288. package/src/walk/index.ts +12 -0
  289. package/src/{plan → walk/internal}/choose.ts +23 -14
  290. package/src/{plan → walk/internal}/data.ts +37 -14
  291. package/src/{plan → walk/internal}/execute.ts +79 -36
  292. package/src/{plan → walk/internal}/record.ts +6 -6
  293. package/src/{plan → walk/internal}/targets.ts +35 -25
  294. package/dist/ActionPort.d.mts +0 -15
  295. package/dist/ActionPort.mjs.map +0 -1
  296. package/dist/Browser-BKPAbyys.mjs.map +0 -1
  297. package/dist/Change-Ba7INmay.d.mts +0 -69
  298. package/dist/Clock.d.mts +0 -57
  299. package/dist/Clock.mjs.map +0 -1
  300. package/dist/Frame-UEH2hO5T.d.mts +0 -124
  301. package/dist/Geometry.d.mts +0 -2
  302. package/dist/Geometry.mjs.map +0 -1
  303. package/dist/Matching.d.mts +0 -37
  304. package/dist/Matching.mjs.map +0 -1
  305. package/dist/Page-BF5izr8R.mjs.map +0 -1
  306. package/dist/Page-CvsOEorc.d.mts +0 -566
  307. package/dist/Released-tURbFmal.d.mts +0 -15
  308. package/dist/Snapshot-CtBVOtuu.d.mts +0 -73
  309. package/dist/Stillness-CNlvayIo.mjs +0 -136
  310. package/dist/Stillness-CNlvayIo.mjs.map +0 -1
  311. package/dist/Style-AO4V7Czt.mjs.map +0 -1
  312. package/dist/Style.d.mts +0 -72
  313. package/dist/Style.mjs +0 -2
  314. package/dist/Url.d.mts +0 -26
  315. package/dist/Url.mjs.map +0 -1
  316. package/dist/Window-CMddGMt1.d.mts +0 -34
  317. package/dist/connection-CK83pvqP.mjs.map +0 -1
  318. package/dist/moment/Moment.mjs.map +0 -1
  319. package/dist/plan/index.mjs.map +0 -1
  320. package/dist/presentation/Stage.mjs.map +0 -1
  321. package/dist/presentation/feed.d.mts +0 -20
  322. package/dist/presentation/feed.mjs +0 -18
  323. package/dist/presentation/feed.mjs.map +0 -1
  324. package/dist/providers/Cdp.d.mts +0 -9
  325. package/dist/providers/Cdp.mjs +0 -15
  326. package/dist/providers/Cdp.mjs.map +0 -1
  327. package/dist/providers/Chromium.d.mts +0 -32
  328. package/dist/providers/Chromium.mjs +0 -55
  329. package/dist/providers/Chromium.mjs.map +0 -1
  330. package/dist/providers/Released.d.mts +0 -2
  331. package/dist/providers/Released.mjs +0 -12
  332. package/dist/providers/Released.mjs.map +0 -1
  333. package/dist/stillness/Stillness.d.mts +0 -12
  334. package/dist/stillness/Stillness.mjs +0 -2
  335. package/dist/supervisor/Supervisor.mjs.map +0 -1
  336. package/dist/testing/index.mjs.map +0 -1
  337. package/dist/workerd/Cdp.d.mts +0 -8
  338. package/dist/workerd/Cdp.mjs +0 -13
  339. package/dist/workerd/Cdp.mjs.map +0 -1
  340. package/src/plan/index.ts +0 -36
  341. package/src/providers/Cdp.ts +0 -16
  342. package/src/providers/Chromium.ts +0 -99
  343. package/src/providers/Released.ts +0 -13
  344. package/src/workerd/Cdp.ts +0 -11
  345. /package/dist/{rolldown-runtime-D7D4PA-g.mjs → internal/rolldown-runtime-D7D4PA-g.mjs} +0 -0
  346. /package/src/{Geometry.ts → internal/geometry.ts} +0 -0
  347. /package/src/{Url.ts → internal/url.ts} +0 -0
  348. /package/src/{stillness → timeline/internal}/utilsBundle.d.ts +0 -0
package/README.md CHANGED
@@ -3,53 +3,80 @@
3
3
  Browser automation for [Effect](https://effect.website) agents, over Playwright: page control, a
4
4
  compact page outline for models, screencast frames, a record of what visibly changed on a page,
5
5
  windows over a page's events, changes and frames, and moments, an account in pictures and words of
6
- what a page showed and what changed on it. An agent drives its pages through
7
- [`effect-agent-browser`](../agent-browser), with Yielded Agent's browser tools.
6
+ what a page showed and what changed on it. It films pages on their own held time, with layout as
7
+ data, an overlay, element poses and input on its frame, and gives its in-page readers to a site that
8
+ owns its page. An agent drives its pages with the browser tools of `effect-browser/ai`, in any
9
+ `effect/ai` loop, or through [`@effect-browser/yielded`](../yielded) in a Yielded Agent run.
8
10
 
9
11
  ```sh
10
- npm install effect-browser@beta effect playwright-core
12
+ npm install effect-browser@beta @effect-browser/chromium@beta effect playwright-core
11
13
  npx playwright-core install chromium
12
14
  ```
13
15
 
14
- `Chromium.layer` launches that Chromium without its sandbox, as Playwright does, so an exploit in a
15
- page's renderer runs with your user's privileges. `Chromium.layer({ sandbox: true })` runs it
16
- sandboxed. Hosts that don't allow unprivileged user namespaces, such as many containers and Ubuntu
17
- 23.10 or later by default, can't start the sandbox; opening then fails and says so.
18
-
19
- `Chromium.layer` leaves signals to your program: Playwright's own handlers, which close every
20
- browser and, on SIGINT, exit before any finalizer runs, are off. Run the program with
21
- `NodeRuntime.runMain` from `@effect/platform-node`, which interrupts it on SIGINT and SIGTERM, so
22
- the browser closes with its scope. A signal that ends the process outright still takes Chromium
23
- with it, since its pipe closes, but leaves Playwright's temporary profile behind.
24
-
25
- | Module | What it holds |
26
- | -------------- | --------------------------------------------------------------------------------- |
27
- | `Browser` | The `Browser` service: tabs, recent events, lifetime and input suspension |
28
- | `Chromium` | A local Chromium as a `Browser` layer |
29
- | `Cdp` | Any DevTools endpoint as a `Browser` layer |
30
- | `Page` | One tab: navigation, reads, screenshots, input, waits and the screencast |
31
- | `Snapshot` | The model-readable outline of a page, with refs for its controls |
32
- | `Frame` | Pictures, timing evidence and capture identity |
33
- | `BrowserEvent` | Tabs, documents, loads, actions, dialogs, pointer motion and the browser's end |
34
- | `Motion` | A bounded pointer planner, as a value, and the tuned sigma-lognormal one |
35
- | `Presentation` | Input performed for viewers: a presenter, and its views of pages |
36
- | `Stage` | The source of a live output, switched between pages and stamped |
37
- | `BrowserError` | Typed failures, whether input reached the page first, and what each leaves |
38
- | `Policy` | Judges that read what an input means, and a guard that acts on them unattended |
39
- | `Change` | What visibly changed on a page over a window, element by element |
40
- | `Moment` | A page's events, changes and frames over a window; a moment, laid out as a prompt |
41
- | `Plan` | A walk recorded from a page's events, replayed on a fresh page by subject |
42
- | `Supervisor` | A browser kept open across losses and session ends, as generations |
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.
16
+ `Chromium.layer`, from [`@effect-browser/chromium`](../chromium), launches a local Chromium as a
17
+ `Browser` layer. It runs Chromium without its sandbox unless given `sandbox: true`; that package's
18
+ README says what that risks and how signals end the browser.
19
+
20
+ | Module | Import from | What it holds |
21
+ | -------------- | ----------------------------- | --------------------------------------------------------------------------------- |
22
+ | `Browser` | `effect-browser` | The `Browser` service: tabs, recent events, lifetime and input suspension |
23
+ | `Page` | `effect-browser` | One tab: navigation, input and waits |
24
+ | `Snapshot` | `effect-browser` | The model-readable outline of a page, with refs, and the elements a query finds |
25
+ | `Text` | `effect-browser` | What a page shows as text, from its viewport or one element whole |
26
+ | `Frame` | `effect-browser` | A page's pictures, crops and screencast, with timing and capture identity |
27
+ | `BrowserEvent` | `effect-browser` | Tabs, documents, loads, actions, dialogs, pointer motion and the browser's end |
28
+ | `BrowserError` | `effect-browser` | Typed failures, whether input reached the page first, and what each leaves |
29
+ | `Action` | `effect-browser` | Typed actions, shared by input, guards, event records and walks |
30
+ | `InputStyle` | `effect-browser` | How input is sent: plainly, or performed for viewers |
31
+ | `Change` | `effect-browser` | What visibly changed on a page over a window, element by element |
32
+ | `Window` | `effect-browser` | A page's events, changes and frames over one window of its browser's clock |
33
+ | `Layout` | `effect-browser` | Where picked things and their words are on a page, as data, and rehearsals |
34
+ | `Overlay` | `effect-browser` | A layer over a page that the library draws a caller's SVG into and never reads |
35
+ | `PageTime` | `effect-browser` | A page's own time, held and stepped, with its scroll, poses and overlay |
36
+ | `Pose` | `effect-browser` | A page's own elements moved, turned and scaled about a point |
37
+ | `Cdp` | `effect-browser/Cdp` | Any DevTools endpoint as a `Browser` layer |
38
+ | `Site` | `effect-browser/Site` | The readers, change record, overlay and poses, run by a site on its own page |
39
+ | `Moment` | `effect-browser/timeline` | A page's events, changes and frames over a window; a moment, laid out as a prompt |
40
+ | `Stillness` | `effect-browser/timeline` | Waits for a page's screen, content or foreground to stay still |
41
+ | `Presentation` | `effect-browser/presentation` | Input performed for viewers: a presenter, and its views of pages |
42
+ | `Stage` | `effect-browser/presentation` | The source of a live output, switched between pages and stamped |
43
+ | `Motion` | `effect-browser/presentation` | A bounded pointer planner, as a value, and the tuned sigma-lognormal one |
44
+ | `Film` | `effect-browser/presentation` | A page filmed as a function of time: frames, inputs on their frames, passages |
45
+ | `Walk` | `effect-browser/walk` | A walk recorded from a page's events, replayed on a fresh page by subject |
46
+ | `Policy` | `effect-browser/policy` | Judges that read what an input means, and a guard that acts on them unattended |
47
+ | `Supervisor` | `effect-browser/supervisor` | A resource, such as a browser, kept serving across losses and rotation |
48
+ | `Release` | `effect-browser/supervisor` | What a provider said of a release: `Confirmed` or `Unconfirmed` |
49
+ | `TestBrowser` | `effect-browser/testing` | A seeded browser over the production lane, suspension gate and event timeline |
50
+ | `TestPage` | `effect-browser/testing` | A deterministic page seeded from data, without page code |
51
+ | `TestModel` | `effect-browser/testing` | A model that answers from a script, prompt by prompt, and fails when it runs out |
52
+ | `HttpCassette` | `effect-browser/testing` | HTTP exchanges recorded once and replayed, with every live request reserved |
53
+ | `Story` | `effect-browser/testing` | Ports released in a scripted order, with one end check for unfinished work |
54
+ | `BrowserTools` | `effect-browser/ai` | An agent's browser tools, the pictures before each turn and their layer |
55
+ | `PageControl` | `effect-browser/ai` | The controller the tools act through, and its observations and results' schemas |
56
+ | `Tabs` | `effect-browser/ai` | The tabs the tools follow, as data to save and resume |
57
+ | `ToolError` | `effect-browser/ai` | What a failed tool tells the model, and whether its input went |
58
+ | `PromptCache` | `effect-browser/ai` | An HTTP client layer that keeps OpenRouter's prompt cache across pictured turns |
59
+
60
+ The root, `effect-browser`, exports the kernel, and each of its modules also has a path of its own,
61
+ such as `effect-browser/Page`. `effect-browser/Cdp` and `effect-browser/Site` are reached only by
62
+ path, never through the root, which loads only `effect`. Each feature is a subpath that exports
63
+ its modules together, as in `import { Moment } from "effect-browser/timeline"`. `Film` is
64
+ experimental. `effect-browser/testing`'s seeded services execute explicit test data and refuse
65
+ page scripts.
66
+
67
+ `Page` holds what a tab is and how it takes its turns: its identity, the order and time of what is
68
+ done on it, and input. Everything else a page does is a function in the module of what it returns,
69
+ taking the page first: `Snapshot.read(page)`, `Snapshot.find(page, query)`,
70
+ `Snapshot.until(page, query, want, timeout)`, `Text.read(page)`, `Layout.measure(page, picks)`,
71
+ `Change.read(page)`, `Window.read(page, options)`, `Overlay.make(page)`, `Pose.make(page)` and
72
+ `PageTime.hold(page)`. Those with more than the page also take it last, for a pipeline, as in
73
+ `Effect.flatMap(browser.firstPage, Snapshot.read({ full: true }))`. A new capability follows the
74
+ same rule: `Page` gains a member only for identity, order, time or input, and everything else is a
75
+ function in its job's module.
49
76
 
50
77
  ## Runtime CDP connectors
51
78
 
52
- `Cdp.open` and `Cdp.layer` accept `connect: Cdp.Connector`, a callback receiving the endpoint and
79
+ `Cdp.make` and `Cdp.layer` accept `connect: Cdp.Connector`, a callback receiving the endpoint and
53
80
  `{ timeout, headers, signal }` and returning a real Playwright CDP `Browser`. Node uses
54
81
  `playwright-core`'s `chromium.connectOverCDP` by default. A consumer can supply a connector using
55
82
  its runtime's WebSocket implementation to avoid Playwright's Node WebSocket transport.
@@ -115,17 +142,19 @@ const nativeConnect: Cdp.Connector = async (endpoint, { timeout, headers, signal
115
142
  };
116
143
  ```
117
144
 
118
- Pass `nativeConnect` as `connect` to `Cdp.open` or `Cdp.layer`, or to the Browserbase options.
145
+ Pass `nativeConnect` as `connect` to `Cdp.make` or `Cdp.layer`, or to the Browserbase options.
146
+ `Cdp.layerConfig` takes the same options as `Config` values, such as
147
+ `{ endpoint: Config.Redacted("CDP_ENDPOINT") }` for an endpoint that is a credential.
119
148
 
120
149
  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
150
+ `connect`; omitting it fails with `BrowserError` reason `InvalidRequest`. The root entry loads only
151
+ `effect`; import `effect-browser/Cdp` for remote connections. Bundlers must select
123
152
  the `workerd` condition. Local Worker/CDP checks also pass without `nodejs_compat`; the consumer still supplies and qualifies the runtime's Playwright
124
153
  implementation against this package's Playwright peer; the seam does not certify a different
125
154
  Playwright version or provide a Cloudflare connector.
126
155
 
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
156
+ The callback receives the `connectTimeout`, 30 seconds by default, as its `timeout` in
157
+ milliseconds, and an `AbortSignal`. Opening enforces that deadline independently, fails with reason `Timeout` and aborts
129
158
  the signal when it expires or the caller is interrupted. A connector should stop its own pending
130
159
  work when aborted. A browser it returns late is disconnected, as is one whose opening fails or
131
160
  whose scope closes. Its `close()` must disconnect the CDP connection without ending the remote
@@ -135,7 +164,7 @@ endpoint's userinfo, path and query. A failure diagnostic that echoes a nonempty
135
164
  value is withheld entirely, including in serialized errors.
136
165
 
137
166
  `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.
167
+ that value as `InputRequest.action`; event records and walks preserve it with secret text redacted.
139
168
  `page.read(fn, { arg, result })` returns `{ value, document, connection }` after schema decoding.
140
169
  `page.act(fn, { arg, result, document, connection })` validates the document and optional connection,
141
170
  passes the input guard as an opaque scripted action, and records dispatch before evaluation.
@@ -161,7 +190,7 @@ A snapshot outlines the viewport, or the whole page, with a ref such as `e12` on
161
190
  lists those controls as values, `Snapshot.Control`: each one's ref, kind, name and what it holds,
162
191
  a select's options, and whether it is disabled, checked or takes typed text. `within` reads only
163
192
  inside the elements a CSS selector matches, and `query` keeps the lines that hold some text.
164
- `Page.until(query, want, millis)` waits using `find` matching, including CSS `selector` and
193
+ `Snapshot.until(page, query, want, timeout)` waits using `Snapshot.find`'s matching, including CSS `selector` and
165
194
  `state: "enabled"`. It searches the document by default. `want` is `"some"`, `"none"`, or
166
195
  `{ other: previous.mark }`; comparison marks reveal no text or values and ignore focus.
167
196
  A finite nonnegative deadline returns `{ met, mark }`; document replacements share that deadline.
@@ -171,7 +200,7 @@ sampled. A zero-duration baseline reads once and fails if its document disappear
171
200
  a moment uses. The actions a call performs record a caller's id as their `correlation` when it runs
172
201
  under `Page.correlate(id)`, such as a model's tool call.
173
202
 
174
- `Page.zoom` captures a region in viewport CSS pixels as a `Zoom` schema value with `region` and `image`;
203
+ `Frame.zoom` captures a region in viewport CSS pixels as a `Zoom` schema value with `region` and `image`;
175
204
  crop pixel coordinates need the region's origin added before using them as click coordinates.
176
205
 
177
206
  `Page.click` returns a `ResolvedTarget` captured before input: the requested point, element label,
@@ -188,18 +217,18 @@ counted; elsewhere, `label` is the words just before it in its row, item, group
188
217
  is the nearest heading above it, left out for what is pinned to the viewport. The page binds each to
189
218
  the element, so a value is never read under another column's header.
190
219
 
191
- `Page.find` reads structure without the outline, in one call to the page. It returns every element
220
+ `Snapshot.find` reads structure without the outline, in one call to the page. It returns every element
192
221
  that matches a query, in tree order, each a `Found`: a ref the actions take, its `subject`, its box,
193
222
  whether it is in the viewport, and its state (disabled, focused, and checked, expanded, selected,
194
223
  pressed or a heading's level where they apply). A `role` matches ignoring case. A `name` matches
195
224
  when it reads the same once spaces are collapsed and case folded, or when a `RegExp` finds itself
196
225
  in it. `text` matches the smallest element showing it, and a control or heading for the words
197
226
  inside it; `near` matches whole words of the context, as replay's choice does. With no rule,
198
- `find` returns every element in scope that has a role or is a control. There is no ordinal: a
227
+ it returns every element in scope that has a role or is a control. There is no ordinal: a
199
228
  caller tells equal elements apart by their context, and finding none is an empty result, not a
200
229
  failure. `scope: "document"` reads the whole page; the default is the viewport.
201
230
 
202
- `Page.text` reads what the viewport shows, or one element whole with `scope` set to its ref, in one
231
+ `Text.read` reads what the viewport shows, or one element whole with `scope` set to its ref, in one
203
232
  call to the page: a line per block, table cells apart by tabs, cut at a line after `maxChars`
204
233
  (12,000 by default). Like the outline, it leaves out what the page hides from assistive technology,
205
234
  such as icon glyphs. What a field holds reads `••••` unless `unmask` is set, and a secret field's
@@ -208,7 +237,7 @@ holds, as a PIN field's may, and one that was secret when the library saw it, su
208
237
  its page now reveals. The outline shows what fields hold, as the agent needs, but masks a secret
209
238
  field the same way.
210
239
 
211
- Reading the viewport, the outline, `find` and `text` skip a subtree whose box lies outside it before
240
+ Reading the viewport, the outline, `Snapshot.find` and `Text.read` skip a subtree whose box lies outside it before
212
241
  styling anything in it, so a long table costs only its rows in view. A box says nothing of what is
213
242
  positioned out of it, so a subtree is kept when its box is empty; when it holds what is painted at
214
243
  the viewport's edges, corners or middle, beneath any transparent layer too, or in its top layer; or
@@ -221,13 +250,13 @@ is, or until the time is up: its document is parsed and has painted since, nothi
221
250
  animating in view, its fonts and the images in view have loaded, nothing in view is marked busy
222
251
  (`aria-busy`), and the viewport shows something: text, a canvas drawn on, a picture or drawing
223
252
  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
253
+ within one timeout. `quiet` also checks changes when a recorder is already running; it does
225
254
  not start a recorder or a capture. A canvas mounted blank, as chart libraries mount theirs,
226
255
  or a spinner alone is still loading. A screen that only says "Loading…" in words reads as ready,
227
256
  and a WebGL canvas drawn once, without keeping its drawing, reads as blank. A hidden tab, which
228
257
  paints nothing, is never ready.
229
258
 
230
- `Stillness.wait(page, { quietMillis, still: "screen" })` waits for a ready screen to stay still that long: no screencast frame comes,
259
+ `Stillness.wait(page, { quiet, still: "screen" })` waits for a ready screen to stay still that long: no screencast frame comes,
231
260
  counted from the first frame of a capture the wait starts itself, since a hosted browser sends that
232
261
  frame over half a second late. A capture's silence alone proves little: a stalled connection holds
233
262
  frames on their way, and Chromium sends frames only while few acknowledgements are unanswered. So
@@ -240,28 +269,29 @@ of 2 waits before, and in none since. Where the page's changes are recorded, the
240
269
  page's own check also waits until nothing in view has changed for the spell, so frames the browser
241
270
  holds back, as an encoder's backlog does, cannot pass for a still page. Stillness is a heuristic
242
271
  on a canvas: a canvas that keeps drawing, such as a live chart, is never still, and one that pauses
243
- longer than `quietMillis` between phases reads as still. On the slot machine fixture, with the
272
+ longer than `quiet` between phases reads as still. On the slot machine fixture, with the
244
273
  connection stalled for 450 to 900 ms toward either end while the reels spun, none of 132 waits
245
274
  ended early, where all 36 did before.
246
275
 
247
- `Stillness.wait(page, { still: "foreground", quietMillis })` allows motion already seen in the 1.5 seconds
276
+ `Stillness.wait(page, { still: "foreground", quiet })` allows motion already seen in the 1.5 seconds
248
277
  before the page's latest input, such as idle decoration. Motion elsewhere restarts the quiet
249
278
  interval. It compares newly accepted frames, including brief motion between polls and frames
250
279
  accepted after a viewport-size check; missing history or more than eight new frames in one poll
251
280
  restarts the interval conservatively. Without pre-input frame history, all motion counts.
252
281
 
253
- `Stillness.wait(page, { still: "content", quietMillis })` instead observes a full interval without visible
282
+ `Stillness.wait(page, { still: "content", quiet })` instead observes a full interval without visible
254
283
  recorded DOM changes. It starts the recorder itself and starts the interval again in each new
255
284
  document; navigation retries share the original timeout. Canvas animation can continue while DOM
256
285
  content is ready. This does not prove pixel or screencast stillness and inherits the change
257
286
  recorder's limits for canvas, SVG, frames, shadow content and values changed only by scripts.
258
287
 
259
- `Page.changes({ since, until })` says what visibly changed on a page over a window, in one call to
288
+ `Change.read(page, { since, until })` says what visibly changed on a page over a window, in one call to
260
289
  the page, element by element, as a `Change`: text that changed, appeared, disappeared or came and
261
290
  went (`brief`), a field's value, or the title. Each says what it showed at the window's start and
262
291
  end, how often that changed, the lowest and highest of a number that changed more than once, when
263
292
  it last changed before the window, so news stands apart from what keeps changing, and its
264
- `subject` with the context that binds it: a price under its row and column. A field's value reads
293
+ `subject` with the context that binds it: a price under its row and column, and its `box`, where it
294
+ is as the changes are read, or for what went, where what it sat in is. A field's value reads
265
295
  `••••` unless `unmask` is set, and a secret field's always does. A change names its `cause`, the
266
296
  trusted input it followed, only where it was that input's doing. It must not have been in flux: in
267
297
  the 10 s before the input it had not changed, and nothing had come into or left what it sits in, so
@@ -302,7 +332,7 @@ sets, or a class that reveals an element it has not seen before, such as a toast
302
332
  page, though its later changes it does.
303
333
 
304
334
  A page's timeline has three tracks on the browser's host clock: its events, what changed on it,
305
- and its frames. `page.window({ since, until })` reads them over a window, a `Moment.Window`: the
335
+ and its frames. `Window.read(page, { since, until })` reads them over a window, a `Window`: the
306
336
  events and frames the page keeps, at no call, and its changes, in one call, the first starting its
307
337
  record as any read of changes does. `since` is a previous window, to go on exactly where it ended, a
308
338
  frame, a host time, or a `Duration` back from `until`; `until` is a frame or a host time, now by
@@ -317,10 +347,10 @@ rest, each showing what it settled at, as a price that ticked and stopped does.
317
347
  how long the page had been still, by the last change in view its record shows or the last paint
318
348
  among its screencast frames; a screenshot shows the page, not when it changed. Frames show paint
319
349
  only while a capture runs, and the record does not see a canvas, so a canvas that draws with no
320
- capture running reads as still. Use `Stillness.wait(page, { still: "screen", quietMillis })`
350
+ capture running reads as still. Use `Stillness.wait(page, { still: "screen", quiet })`
321
351
  when a wait must observe screen quiet and hold through a stalled capture connection.
322
352
 
323
- `Moment.capture` is a window that ends at a picture of the page now. It takes the picture first,
353
+ `Moment.read` is a window that ends at a picture of the page now. It takes the picture first,
324
354
  then the window up to its paint, from where a previous window or moment ended, so the changes hold
325
355
  nothing the picture does not show. A cached picture from before the latest action finished is
326
356
  replaced with a fresh screenshot, keeping a navigation's triggering action in the moment.
@@ -339,16 +369,16 @@ changed was not recorded and lists every step instead; one whose record began wi
339
369
  says nothing changed only after that. What it could not read, it names, with why, and a last frame
340
370
  that is not the picture is not shown as the moment.
341
371
 
342
- `Plan` rehearses a walk once and replays it later, near live, with no model call.
343
- `Plan.fromEvents(page.recentEvents)` keeps one page's completed actions with their subjects and
372
+ `Walk` rehearses a walk once and replays it later, near live, with no model call.
373
+ `Walk.fromEvents(page.recentEvents)` keeps one page's completed actions with their subjects and
344
374
  the options they were given, its navigations with the address asked for and the one reached, and
345
375
  what was typed as an input slot named for its field, never the text itself. A navigation to an
346
376
  address with a credential withheld is an input slot too, `address`, so replay goes where the caller
347
- says, never to the address without its credential. `Plan.replay(page,
377
+ says, never to the address without its credential. `Walk.replay(page,
348
378
  plan, { inputs })` takes the steps in turn: before each step except an opening navigate, back or
349
- reload, it waits for readiness (`settle` sets how, or `false` skips it). A `quietMillis` option uses
379
+ reload, it waits for readiness (`settle` sets how, or `false` skips it). A `quiet` option uses
350
380
  `Stillness.wait` for content quiet; otherwise it calls `Page.ready`. It finds the element with
351
- `Plan.locate`, and acts on it. An element that does not repeat every part of the recorded context
381
+ `Walk.locate`, and acts on it. An element that does not repeat every part of the recorded context
352
382
  is another subject: its row read whole, so a row named "Wrapped BTC" is not the row "BTC" (laid out
353
383
  again without rows, as cards, one of its fields must start with the row's words), its column where
354
384
  it is under one, and its label and heading read the same or found as words in order. So the one
@@ -361,18 +391,19 @@ A press recorded on a subject resolves and focuses it before sending keys. Text
361
391
  typed into a secret field is typed only into one. An element step never falls back to coordinates.
362
392
  A step recorded at a point presses the same place within the element found, brought into view
363
393
  first, and only when a press there reaches that element, not something over it. Replay stops at
364
- the first step it cannot take, with a `ReplayError` naming the step and why: `Missing`,
365
- `Ambiguous`, `Drifted` (nothing with the subject's role and name repeats its context, or the walk
366
- did not arrive at the recorded site), the step's `BrowserError`, or `Uncertain`. Arrival waits
394
+ the first step it cannot take, with a `ReplayError` naming the step and why, its
395
+ `ReplayErrorReason`: `Missing`, `Ambiguous`, `Drifted` (nothing with the subject's role and name
396
+ repeats its context, or the walk did not arrive at the recorded site), the step's `BrowserError`,
397
+ or `Uncertain`; `Walk.isReplayError` tells one from other failures. Arrival waits
367
398
  are bounded by `arrival` (five seconds by default), including redirects after an action. A zero
368
399
  wait makes one read without polling; that read retains the page operation's own timeout.
369
400
  Each `Action` now records its ending address, so a bounded event history can still record the site
370
401
  of later actions after its earlier navigation has expired.
371
402
 
372
- `Plan.take(page, plan, index)` takes one step and returns a `Receipt`: the step index, host-clock
403
+ `Walk.step(page, plan, index)` takes one step and returns a `Receipt`: the step index, host-clock
373
404
  `startedAt` and `at`, and `taken`, `verified` or `skipped`. Readiness is a precondition of the next
374
405
  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;
406
+ for document readiness or `Stillness.wait` for a quiet final page. `Walk.replay` returns those receipts;
376
407
  a `ReplayError` includes completed receipts and a serializable `stopped` value with the next step
377
408
  and whether its input is `unsent` or `unknown`. Resume with `{ from: error.stopped }`. A numeric
378
409
  index means fresh input, so never convert an unresolved stopping point into a number to retry it.
@@ -385,7 +416,7 @@ input and waits for it afterward. Relative `Navigated` (without a URL) never ski
385
416
  it compares with the page immediately before dispatch, after readiness and arrival. It observes
386
417
  change after that baseline, without proving the input caused it.
387
418
  `verified` means the specified observation held; it is not a transaction
388
- receipt from the target service. Keep the receipt with its plan to interpret that evidence.
419
+ receipt from the target service. Keep the receipt with its walk to interpret that evidence.
389
420
  `Checked` can converge a checkbox click to a desired boolean.
390
421
  Unknown non-repeatable input is never automatically sent again: only a positive check explicitly
391
422
  marked `durable: true` permits continuation. Only `Appeared` or `Navigated` with an explicit exact
@@ -394,13 +425,13 @@ read-back, such as a saved order receipt or its operation-specific URL. An arbit
394
425
  toast or intermediate URL cannot justify it. `Gone`, relative navigation, and a negative or failed
395
426
  durable check still leave unknown consequential input uncertain.
396
427
  Navigation, hover, scroll, selection and replacement typing without submission can be repeated;
397
- back, reload, insertion, presses, drags and ordinary clicks cannot. `Plan.repeatable(step)` says
398
- which applies. `Plan.restore(page, plan, { upTo, inputs })` reconstructs earlier steps on a fresh
428
+ back, reload, insertion, presses, drags and ordinary clicks cannot. `Walk.repeatable(step)` says
429
+ which applies. `Walk.restore(page, plan, { upTo, inputs })` reconstructs earlier steps on a fresh
399
430
  page using those same rules and refuses unresolved commitments. `upTo` is exclusive.
400
431
 
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
432
+ `Walk.Walk.new(steps)` emits version 3 with canonical typed Actions. Prior version 1/2
433
+ string-action walks and unknown versions do not decode. This is a hard cutover; rerecord or
434
+ explicitly convert an older walk before replay. Decoding rejects `durable: true` on `Gone` or
404
435
  URL-less `Navigated`; execution also refuses recovery through those unsupported claims.
405
436
 
406
437
  `Browser.Options.guard` is the input policy. Its `InputRequest` schema contains the action, the
@@ -429,9 +460,9 @@ The policy's effect succeeds to allow, fails with `PolicyDenied` to refuse, or w
429
460
  the consumer owns to hold. For example:
430
461
 
431
462
  ```ts
463
+ import { Chromium } from "@effect-browser/chromium";
432
464
  import { Effect } from "effect";
433
465
  import { PolicyDenied } from "effect-browser/BrowserError";
434
- import * as Chromium from "effect-browser/Chromium";
435
466
 
436
467
  const browser = Chromium.layer({
437
468
  guard: (request) =>
@@ -441,7 +472,7 @@ const browser = Chromium.layer({
441
472
  });
442
473
  ```
443
474
 
444
- `effect-browser/Policy` builds guards for a browser with nobody watching. A judge reads what an
475
+ `Policy`, from `effect-browser/policy`, builds guards for a browser with nobody watching. A judge reads what an
445
476
  input means. `Policy.reviewer()` asks the `LanguageModel` in context for a structured review, and
446
477
  `Policy.decider` asks a `DecisionModel`, such as Jev through `@effect/ai-typesafe`. Both give a
447
478
  `Judgement`: for each `Risk` (`financial`, `account`, `access`, `deletion`, `communication` and
@@ -451,9 +482,9 @@ for it. `Policy.escalate(first, second)` asks `second` only when `first` is unsu
451
482
  and why. `origins` keeps input to some origins, and `deny` refuses facts outright:
452
483
 
453
484
  ```ts
485
+ import { Chromium } from "@effect-browser/chromium";
454
486
  import { Effect, Layer } from "effect";
455
- import * as Chromium from "effect-browser/Chromium";
456
- import * as Policy from "effect-browser/Policy";
487
+ import { Policy } from "effect-browser/policy";
457
488
 
458
489
  const browser = Layer.unwrap(
459
490
  Effect.gen(function* () {
@@ -464,7 +495,7 @@ const browser = Layer.unwrap(
464
495
  );
465
496
  ```
466
497
 
467
- The task comes from `Policy.Task`, which `effect-agent-browser`'s tools provide to their inputs
498
+ The task comes from `Policy.Task`, which `effect-browser/ai`'s tools provide to their inputs
468
499
  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
469
500
  text and the facts as trusted, and the page's text only as evidence. It never sees the agent's own
470
501
  words. A judgement only adds to structure: a `secret` fact counts whatever the judge reads. A judge
@@ -512,14 +543,15 @@ samples and 5,000 milliseconds, ending at the exact destination. The browser dec
512
543
  `InvalidRequest` before their track or input is sent. Equal-time samples are retained. Plain input
513
544
  never plans a glide: its pointer jumps, or moves in eight short steps while dragging.
514
545
 
515
- For recorded human strokes, install the optional `effect-browser-human-strokes` package and give
546
+ For recorded human strokes, install the optional `@effect-browser/human-strokes` package and give
516
547
  its planner to the presenter:
517
548
 
549
+ <!-- prettier-ignore -->
518
550
  ```ts
519
- import * as HumanStrokes from "effect-browser-human-strokes";
520
- import * as Presentation from "effect-browser/Presentation";
551
+ import * as HumanStrokes from "@effect-browser/human-strokes";
552
+ import { Presentation } from "effect-browser/presentation";
521
553
 
522
- const presenter = yield * Presentation.make({ motion: yield * HumanStrokes.motion });
554
+ const presenter = yield* Presentation.make({ motion: yield* HumanStrokes.motion });
523
555
  ```
524
556
 
525
557
  That package bundles 32,130 attributed CC BY 4.0 strokes, preserving their original sample times.
@@ -529,6 +561,25 @@ At most 2,112 input commands and reservations are owned at once; ordinary input
529
561
  64-command admission limit. Actions still await their replies before succeeding, and interruption
530
562
  stops the unsent suffix and releases held input.
531
563
 
564
+ An action announces its target before its pointer travels there. Once it has found the target, it
565
+ publishes `ActionAnnounced`, with the action's name and `correlation`, the target's `subject` and
566
+ `box`, and the point the pointer goes to. A glide that only scrolls a target into view comes
567
+ before the target is found, so it is not announced. Input with no pointer travel announces
568
+ nothing, for example keys, or typing into the focused field.
569
+
570
+ A presenter's `lead` runs after the announcement and before the glide:
571
+
572
+ <!-- prettier-ignore -->
573
+ ```ts
574
+ const presenter = yield* Presentation.make({ lead: (announced) => performer.arrive(announced) });
575
+ ```
576
+
577
+ Use it to give whatever is shown performing the input, such as a character, time to arrive. It
578
+ runs after the reaction's wait. It holds the page's turn, and it counts against the action's
579
+ deadline: a lead that has not finished by then fails the action with `Timeout`, and no input is
580
+ sent. The target is not found again after the lead, so a page that moves meanwhile is pressed
581
+ where the target was.
582
+
532
583
  Typing sends key pairs for printable US characters, plainly and in a view; other text uses
533
584
  Unicode insertion. A typed space or letter can press a focused button, toggle a box, follow a
534
585
  link or change a select, so `type` refuses before any input when its `into` ref is not a text field
@@ -566,17 +617,16 @@ cancellation; a wrapper's timeout cannot surrender their authority.
566
617
 
567
618
  ```ts
568
619
  import { Effect, Stream } from "effect";
569
- import { Browser } from "effect-browser/Browser";
620
+ import * as Browser from "effect-browser/Browser";
570
621
  import type { Frame } from "effect-browser/Frame";
571
- import * as Presentation from "effect-browser/Presentation";
572
- import * as Stage from "effect-browser/Stage";
622
+ import { Presentation, Stage } from "effect-browser/presentation";
573
623
 
574
624
  declare const encode: (frame: Frame) => Effect.Effect<void>; // the application's own output
575
625
 
576
626
  const program = Effect.gen(function* () {
577
627
  const stage = yield* Stage.make({ quality: 80 });
578
628
  const presenter = yield* Presentation.make();
579
- const page = yield* (yield* Browser).newPage("https://example.com");
629
+ const page = yield* Browser.newPage("https://example.com");
580
630
  yield* stage.frames.pipe(Stream.runForEach(encode), Effect.forkScoped);
581
631
  const shown = yield* stage.present(page); // Presented { page, at, latency }
582
632
  yield* presenter.view(page).click("e12"); // glides, then clicks, as a person would
@@ -590,7 +640,7 @@ viewers last saw it, on whichever page; a field is clicked before typing; and th
590
640
  100 px notches, in bursts of up to nine. One view acts at a time. The time a view spends showing an
591
641
  action, its glides, holds and typing, has a budget of its own outside `actionTimeout`. `page`
592
642
  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
643
+ `InputStyle.Current`, including to followed tabs. Hand acquisition honours `failFast` and the action's
594
644
  wait bound after approval. Planned typing and scrolling have a separate 10-second cap and fail
595
645
  `InvalidRequest` before input when the schedule exceeds it.
596
646
 
@@ -601,17 +651,18 @@ Closing an abandoned cue stops its capture. `present(page, { at })` is the conve
601
651
  and committing in one call. A stage uses the first page's owning clock; cueing a page with a
602
652
  different clock fails `InvalidRequest`, since host times from those clocks cannot be compared.
603
653
 
654
+ <!-- prettier-ignore -->
604
655
  ```ts
605
656
  // Inside a scoped program: lineSent yields Some(hostTime) when the line goes out, or None if dropped.
606
- const cue = yield * stage.cue(page);
607
- yield * cue.ready;
608
- const sent = yield * lineSent;
609
- if (Option.isSome(sent)) yield * cue.commit({ at: sent.value });
657
+ const cue = yield* stage.cue(page);
658
+ yield* cue.ready;
659
+ const sent = yield* lineSent;
660
+ if (Option.isSome(sent)) yield* cue.commit({ at: sent.value });
610
661
  ```
611
662
 
612
663
  Commits serialize in call order. A switch waits until `at` and for admitted old-page input and
613
664
  its native replies, keeping new old-page input queued through the cut. Reads and capture continue.
614
- The consumer can stop performance between `Plan.take` steps for a clean cut. Interruption before
665
+ The consumer can stop performance between `Walk.step` calls for a clean cut. Interruption before
615
666
  the switch changes nothing and leaves the cue usable. A committed switch keeps ownership through
616
667
  outgoing capture cleanup, even if its caller is interrupted then.
617
668
 
@@ -672,20 +723,19 @@ Windows and a moment's frame captions use `hostTime`, so delayed delivery cannot
672
723
  page/session/connection/document/generation/sequence lineage, so an image copy can retain its
673
724
  capture evidence. Untagged pictures match only by object identity. Currency additionally requires
674
725
  an active capture and the page's current document.
675
- A picture states how old it may be. `Page.frame({ maxAge, after })` serves the newest screencast
726
+ A picture states how old it may be. `Frame.read(page, { maxAge, after })` serves the newest screencast
676
727
  frame when it has the viewport's size and was painted at most `maxAge` ago, at the earliest its
677
728
  timing allows: 250 ms by default, while 0 always takes a new screenshot. With `after: "input"` the
678
729
  frame must also follow the page's latest submitted input, including input of an interrupted action,
679
- and the read waits for the action in flight: what a caller that has just acted needs.
680
- `Page.screenshot` always applies that rule, so a caller that acts and then looks sees what its
681
- action did; a deck or a narrator that wants a picture of a stated age reads `frame`, which a frame
682
- that qualifies serves at once, even while an action runs. A screencast sends only changes and can
730
+ and the read waits for the action in flight: what a caller that has just acted needs, so a caller
731
+ that acts and then looks sees what its action did. A deck or a narrator that wants a picture of a
732
+ stated age leaves `after` out, and a frame that qualifies serves at once, even while an action runs. A screencast sends only changes and can
683
733
  miss a final paint, so a frame is only ever as current as its age. No read reuses a frame painted
684
734
  before the page's current document began, when the page's own session saw its main frame commit
685
735
  it: a page that keeps painting while the next document loads would otherwise leave its own frames
686
736
  the newest when the navigation returns. Otherwise a new screenshot is
687
- taken, which `frame` returns as a `Screenshot`-timed frame. A screenshot, which the agent's
688
- observations take, and a `Moment`'s picture use `after: "input"`, so a stopped capture, a lost
737
+ taken, which `Frame.read` returns as a `Screenshot`-timed frame. The agent's observations and a
738
+ `Moment`'s picture use `after: "input"`, so a stopped capture, a lost
689
739
  final paint or later input never presents older paint as the page an action left.
690
740
 
691
741
  A new picture goes on the page's own protocol session. Where a device pixel is a CSS pixel and
@@ -711,7 +761,7 @@ and the clock probe runs in a world of its own.
711
761
  Every operation is recorded as an `Action`, also when its caller interrupts it. An element or point
712
762
  action records its `subject`, and a drag where it ended (`to`): the role, accessible name, tag and
713
763
  context of what it found, read when its target was resolved, before the pointer moved or any input
714
- was sent, so a click that removes its element still names it: the same subject `Page.find` gives. A ref is
764
+ was sent, so a click that removes its element still names it: the same subject `Snapshot.find` gives. A ref is
715
765
  reused by later outlines, so read `subject` rather than resolving `target` against a later snapshot.
716
766
 
717
767
  Every renderer reads the same host wall clock, so the browser keeps one clock mapping for all of its
@@ -734,7 +784,7 @@ was meant for; until then Chromium stamps them as it receives them, and input ne
734
784
  measurement. Shortcut chords retain Playwright's platform behavior, and Unicode insertion has no
735
785
  timestamp field.
736
786
 
737
- `Page.captureStats()` counts, over the page's life or with `{ window }` over up to the latest
787
+ A capture's `stats()` counts, over the page's life or with `{ window }` over up to the latest
738
788
  minute: received and accepted frames, missing timestamps, `late` frames (Chromium encodes several at
739
789
  once and finished these after a newer one; they are dropped, never reordered, and a busy machine
740
790
  makes more of them), frames dropped for their size (`foreignSize`) or for coming during one of the
@@ -768,7 +818,7 @@ capture keeps delivering, whatever else is attached; a capture starts once the b
768
818
  confirmed it, and fails with `Timeout` at the action timeout if a renderer stuck in a script never
769
819
  does.
770
820
  A provider that reaches its browser over a network can run captures on a connection of their own,
771
- a `Browser.CaptureSource` given as `Cdp.Options.capture`, as `effect-browserbase` does: there a
821
+ a `Browser.CaptureSource` given as `Cdp.Options.capture`, as `@effect-browser/browserbase` does: there a
772
822
  frame never waits behind a large message on the connection that drives the page. Frames then carry
773
823
  the document their own connection saw commit, numbered as `Navigated` numbers them, and a failure
774
824
  of that connection ends the capture with `Failed` and leaves the page as it was.
@@ -777,7 +827,7 @@ joins whatever is running, and one whose explicit options differ fails with `Inv
777
827
  than silently receiving other frames. Each reader has a bounded 16-frame queue; a slow reader's
778
828
  observed sequence gaps add to `lost`. Late subscribers do not count earlier history.
779
829
  ACKs are independent of reader speed and bounded to 32 unresolved replies; exhaustion ends capture
780
- with a typed error. `recentFrames` keeps the frames painted within `frameHistory` of the newest,
830
+ with a typed error. `Frame.recent` keeps the frames painted within `frameHistory` of the newest,
781
831
  5 seconds by default, a moment's default window. Capture stops when its last
782
832
  reader leaves; a stop whose reply is late is never resent, and the next capture waits for it (up
783
833
  to 2 s per attempt) rather than disabling capture for the page.
@@ -786,6 +836,7 @@ A page's `id` is its CDP target id. A new connection to the same browser, as aft
786
836
  finds each page under the id it had, with `browser.page(id)`; a stored id the browser no longer
787
837
  finds is a page that closed. `browser.pages` lists the open pages in the order the browser began
788
838
  tracking them, and `browser.firstPage` gives the first, opening one when there is none.
839
+ `Browser.newPage(url)` opens a page in the context's browser, as `browser.newPage(url)` does.
789
840
 
790
841
  A page's life is told on the browser's timeline. `PageOpened`; `Navigated` for every move of its
791
842
  main frame, `sameDocument` for one within the document, such as `pushState`, with `document`
@@ -813,18 +864,21 @@ A failure on a page that is gone is `Closed` with its cause: `page`, `crashed`,
813
864
  `page`, or the `session` with its pages), and whether to `repeat` the call: `safe`, as nothing
814
865
  reached the browser; `check` its effect first, as it may have taken place; `pointless` as it is,
815
866
  such as with a stale ref; or `resume` reading events from a newer cursor. `message` is a sentence
816
- for operators, and the browser tools tell a model what to do about the failure.
867
+ for operators, and the browser tools tell a model what to do about the failure. The reasons make up
868
+ `BrowserErrorReason`, and `isBrowserError` and `isBrowserErrorReason` tell them from other values.
869
+ As Effect's do, each error names itself by its path, such as `effect-browser/BrowserError/Timeout`.
817
870
 
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
871
+ `Walk.step` checks an authored expected effect before input and after a dispatched failure.
872
+ Unknown consequential input requires positive durable evidence before continuation; the `Walk`
873
+ section above describes that recovery contract. `Snapshot.until` provides the underlying bounded
821
874
  observation without deciding whether an action may be repeated:
822
875
 
876
+ <!-- prettier-ignore -->
823
877
  ```ts
824
- const observed = yield * page.until({ text: "Order 42" }, "some", 5000);
878
+ const observed = yield* Snapshot.until(page, { text: "Order 42" }, "some", "5 seconds");
825
879
  ```
826
880
 
827
- The mark from `until` compares matching elements' text, values and states except focus. Keep it
881
+ The mark from `Snapshot.until` compares matching elements' text, values and states except focus. Keep it
828
882
  only as an observation baseline; an unmet or changed observation does not authorize repeating
829
883
  unknown consequential input.
830
884
 
@@ -851,8 +905,8 @@ event has expired fails with `EventHistoryExpired`; it never skips events silent
851
905
  stream promptly and size retention for the consumer’s delay. Closing the browser scope wakes and
852
906
  ends idle readers.
853
907
 
854
- The presentation track uses the same channel. `TrackPlanned` publishes a whole glide before
855
- input, with `from` and samples whose `afterMillis` are offsets from `at`. Its sequence identifies
908
+ The presentation track uses the same channel. `ActionAnnounced` comes first, as above.
909
+ `TrackPlanned` publishes a whole glide before input, with `from` and samples whose `afterMillis` are offsets from `at`. Its sequence identifies
856
910
  the plan. `TrackPerformed` ends that plan, names it in `plan`, and records the number of samples
857
911
  actually submitted plus the last submitted point. The consumer must trim the planned suffix to
858
912
  that count after interruption or failure. `complete` means all samples were submitted; it does
@@ -867,8 +921,8 @@ events. Compositing remains the consumer’s job.
867
921
  A page waits only for itself. Its operations take turns in one lane of its own: an action, which
868
922
  sends input or navigates, has the page to itself in FIFO order once it asks for admission.
869
923
  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
924
+ approved action may enter before an earlier held one. Reads (the outline, `Snapshot.find`, `Text.read`,
925
+ `Change.read`, pictures, zooms, `title` and the viewport) share the lane after the earlier queued writes, so they
872
926
  describe the page those actions left. `ready` follows the action in flight too, and holds none back while it
873
927
  watches. An action then waits for its page's unresolved input replies. Its timeout bounds those
874
928
  waits before a full timeout bounds the action itself: a turn not given in time fails `Busy`, with
@@ -885,15 +939,15 @@ New and queued writes fail `Suspended`, with
885
939
  Already-held authority refuses input before invoking an input guard; a guard already waiting is
886
940
  checked again at admission. Reads, captures and events continue.
887
941
 
942
+ <!-- prettier-ignore -->
888
943
  ```ts
889
- yield *
890
- Effect.gen(function* () {
891
- const paused = yield* browser.suspend();
892
- // An event reader can resume from paused.since; paused.at is host monotonic time.
893
- const page = yield* browser.firstPage;
894
- yield* page.screenshot();
895
- yield* operatorDone;
896
- }).pipe(Effect.scoped);
944
+ yield* Effect.gen(function* () {
945
+ const paused = yield* browser.suspend();
946
+ // An event reader can resume from paused.since; paused.at is host monotonic time.
947
+ const page = yield* browser.firstPage;
948
+ yield* Frame.read(page);
949
+ yield* operatorDone;
950
+ }).pipe(Effect.scoped);
897
951
  // Input resumes after this scope, provided no other suspension still holds it.
898
952
  ```
899
953
 
@@ -910,15 +964,15 @@ asked between them, joins it, and costs no call of its own. Each read runs in th
910
964
  the action timeout whoever gives up, so a caller's own `Effect.timeout` loses nothing: a read that
911
965
  ends after all its callers gave up serves the next caller to ask the same within 250 milliseconds
912
966
  of completion, unless an action or a new document came first. An action stops the reads nobody awaits rather than
913
- wait for them. Pictures and `changes` only join: a picture's caller says how old it may be, and a
967
+ wait for them. Pictures and `Change.read` only join: a picture's caller says how old it may be, and a
914
968
  window of changes ends as it is read.
915
969
 
916
970
  `page.state` is what the library already knows of a page, at no call and with no wait for its
917
971
  turn: where its main frame is, its document and when it was committed, how far that document has
918
- loaded, its newest screencast frame, and the viewport's text and title as last read in that
919
- document, each with when it was learned, so a caller reads their ages. A caller that must never
920
- wait, such as one reading the screen on air, reads it rather than polling the page. Chromium
921
- announces no title change, so the title is as a read of the text last found it.
972
+ loaded, and its newest screencast frame, each with when it was learned, so a caller reads their
973
+ ages. A caller that must never wait, such as one reading the screen on air, reads it rather than
974
+ polling the page. `Overlay.drawn(page)` says, at no call either, where the page's overlay last
975
+ drew.
922
976
 
923
977
  `Browser.Options.maxPages` bounds the pages a browser keeps open, those a site opened included,
924
978
  which are never refused: at the limit, `newPage` waits within the action timeout for one to close,
@@ -929,31 +983,129 @@ its first glide starts mid-viewport, and each later one where the one before end
929
983
  input on another tab does meanwhile. Every sent move updates the position, including a partially
930
984
  cancelled glide. A later viewport clamps the starting point to its bounds if necessary.
931
985
 
986
+ ## Filming a page
987
+
988
+ A browser opened with `pageTime` can film a page frame by frame, each frame showing the page at its
989
+ film time however long the last one took to picture. Each part is a module of its own:
990
+
991
+ - `Layout.measure(page, picks)` reads where things are, as data: a box for each pick in the viewport and the
992
+ document, the boxes of its words, and the viewport, scroll and scale, in one call.
993
+ `Layout.rehearse` measures what exists only after an interaction, such as an open menu, and puts
994
+ the page back.
995
+ - `Overlay.make(page)` is a layer over the page for a scope that shows a caller's SVG. Screenshots
996
+ and live views show it; `Snapshot`, `Layout`, `Change`, `ready` and stillness never read it.
997
+ - `PageTime.hold(page)` holds the page's timers, animation frames, clocks and animations for a scope.
998
+ `advance(by, { scroll, poses, overlay })` steps them and, in the same call, scrolls, poses and
999
+ draws.
1000
+ - `Pose.make(page)` moves, turns and scales the page's own elements about a point, as data, through
1001
+ CSS `translate`, `rotate` and `scale`. Readers and clicks see a posed element where it is drawn,
1002
+ and the change record does not report a pose. The scope's end takes every pose off.
1003
+ - `Frame.paint(page, { scale, scrollbars })` sets an attached browser's device pixels to each CSS pixel,
1004
+ and hides scrollbars from the next document on. `Chromium.layer` takes its `deviceScaleFactor`
1005
+ at launch.
1006
+ - `Film.frames(page, options)` is a stream of `Shot`s. At each film time it asks `at` for the
1007
+ scroll, poses and overlay, sends the `inputs` due on that frame, and takes a screenshot. A
1008
+ document that replaces the page is a `Passage`: the film holds its time while it loads, measures
1009
+ its layout with the film's `picks`, and passes it to `at` from then on.
1010
+
1011
+ `Film` is `@stability experimental`, so Effect's language service warns (`experimentalApiUsage`)
1012
+ at each use of it. A project whose build denies warnings allows it among the
1013
+ `@effect/language-service` plugin's options in its tsconfig, as this repository's
1014
+ `tsconfig.base.json` does: `"allowedExperimentalApis": ["effect-browser/presentation/Film"]`.
1015
+
1016
+ ```ts
1017
+ const film = Effect.gen(function* () {
1018
+ const time = yield* PageTime.hold(page);
1019
+ const overlay = yield* Overlay.make(page);
1020
+
1021
+ yield* Pose.make(page);
1022
+
1023
+ return yield* Film.frames(page, {
1024
+ times: { fps: 30, to: 8000 },
1025
+ time,
1026
+ overlay,
1027
+ image: { format: "png" },
1028
+ inputs: [{ t: 1200, label: "tab", action: { _tag: "Click", target: usage.ref } }],
1029
+ at: (t) =>
1030
+ Effect.succeed({
1031
+ scroll: scrollAt(t),
1032
+ poses: squashAt(t),
1033
+ overlay: { _tag: "Svg", markup: ringAt(t) },
1034
+ }),
1035
+ }).pipe(Stream.tap(write), Film.summary);
1036
+ });
1037
+ ```
1038
+
1039
+ The frames are pictures; encoding them is the caller's. What an input changed is
1040
+ `Change.read(page, { since })` read after it. Each `Change` has the `box` to frame it by, and `at`, on
1041
+ the same clock as a `Shot`'s `at`, so on held time the first shot at or after it is the first to
1042
+ show it. To lift an element off the page, take its picture with `Frame.zoom` at
1043
+ `scale: "device"`, then pose it to `sx: 0, sy: 0`, which hides it and leaves the page laid out as
1044
+ it was. `examples/film.ts` films a small site this way: a hover, a tab, a selected word, a copy,
1045
+ a search typed a key at a time, an eased scroll, a row selected by a drag and a link to the next
1046
+ page, with what changed framed after each. It serves the site through the browser's request
1047
+ policy (`Browser.Options.requests`), so a hosted browser films it as a local one does.
1048
+
1049
+ ## A site that owns its page
1050
+
1051
+ `effect-browser/Site` is the same composition the library installs in a page over the protocol,
1052
+ for a site to call in its own bundle on its own document. It holds no protocol and loads no
1053
+ `effect`: about 16 KB gzipped, minified. A site reads the same refs, subjects, outline, text,
1054
+ layout and changes as an agent does, draws in the same overlay, and poses its elements the same
1055
+ way.
1056
+
1057
+ ```ts
1058
+ import * as Site from "effect-browser/Site";
1059
+
1060
+ const site = Site.make();
1061
+ const read = site.layout({
1062
+ save: { role: "button", name: "Save" },
1063
+ lede: { selector: "p", words: "postal" },
1064
+ });
1065
+
1066
+ site.record();
1067
+ site.note(saveButton); // the site acts through its own app, and says so
1068
+ app.dispatch(Save());
1069
+ await site.settle();
1070
+ const { records } = site.changes({ since: null, until: null, unmask: false }); // each with its box and cause
1071
+ site.layer().append(character); // a closed shadow root no reader reads
1072
+ ```
1073
+
1074
+ What needs the protocol stays out: trusted input and its checks, screenshots and `Film`, held page
1075
+ time, and a record that starts before the page's own scripts. In their place, the site acts through
1076
+ its own app and `note`s each act, so the changes it brings name it as their `cause`, as a trusted
1077
+ input's would. Time is real, so a pose or a drawing is set again on each animation frame. The
1078
+ record starts when the site calls `record`. Requests and results are the page script's plain data,
1079
+ with boxes in viewport CSS pixels and times in epoch milliseconds, and an unservable request
1080
+ answers `{ invalid }` rather than throwing. The parts run in the site's own world, so they share
1081
+ any globals the site's code patches.
1082
+
932
1083
  ## Supervising resource generations
933
1084
 
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
1085
+ `Supervisor`, from `effect-browser/supervisor`, owns a scoped resource through acquisition failures,
1086
+ loss and rotation. Its generic core does not inspect browsers. `open(number)` acquires a generation in its own scope
936
1087
  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
1088
+ a `Release` from the same subpath: `Confirmed` or `Unconfirmed`. Without a release hook, closing
938
1089
  the generation's scope ends its resource.
939
1090
 
940
1091
  ```ts
1092
+ import { Chromium } from "@effect-browser/chromium";
941
1093
  import { Effect } from "effect";
942
- import * as Chromium from "effect-browser/Chromium";
943
- import * as Supervisor from "effect-browser/Supervisor";
1094
+ import { Supervisor } from "effect-browser/supervisor";
1095
+ import * as Text from "effect-browser/Text";
944
1096
 
945
1097
  const program = Effect.gen(function* () {
946
1098
  const sessions = yield* Supervisor.make({
947
1099
  open: () =>
948
1100
  Effect.gen(function* () {
949
- const browser = yield* Chromium.open();
1101
+ const browser = yield* Chromium.make();
950
1102
 
951
1103
  return { value: browser, lost: browser.disconnected };
952
1104
  }),
953
1105
  });
954
1106
 
955
1107
  return yield* sessions.use(({ value: browser }) =>
956
- Effect.flatMap(browser.firstPage, (page) => page.text()),
1108
+ Effect.flatMap(browser.firstPage, Text.read()),
957
1109
  );
958
1110
  }).pipe(Effect.scoped);
959
1111
  ```
@@ -993,6 +1145,148 @@ bundlers can preserve function names or minify the library without changing that
993
1145
  The `@effect-browser/source` export condition is for this workspace's development tools; consumer
994
1146
  bundles should use the default built exports, which also supply the Workers-specific packaging.
995
1147
 
1148
+ ## An agent's tools
1149
+
1150
+ `effect-browser/ai` gives an agent in any `effect/ai` loop a browser: the tools it calls, what it
1151
+ sees of the page before each turn, and the controller the tools act through.
1152
+ [`@effect-browser/yielded`](../yielded) gives the same tools to a
1153
+ [Yielded Agent](https://github.com/yielded-dev/agent) run.
1154
+
1155
+ ```ts
1156
+ import { Effect } from "effect";
1157
+ import { Browser } from "effect-browser";
1158
+ import { BrowserTools } from "effect-browser/ai";
1159
+ import { LanguageModel, Prompt } from "effect/ai";
1160
+
1161
+ const tools = BrowserTools.make();
1162
+
1163
+ const solve = (task: string) =>
1164
+ Effect.gen(function* () {
1165
+ const pictures = yield* BrowserTools.Pictures;
1166
+ let thread = Prompt.make(task);
1167
+
1168
+ for (let turn = 0; turn < 20; turn++) {
1169
+ const response = yield* LanguageModel.generateText({
1170
+ // The pictures are for this request alone: the thread never keeps them.
1171
+ prompt: Prompt.concat(thread, yield* pictures.next),
1172
+ toolkit: tools.toolkit,
1173
+ // One call at a time: a turn's calls act on one page, in the order the model made them.
1174
+ concurrency: 1,
1175
+ });
1176
+
1177
+ thread = Prompt.concat(thread, Prompt.fromResponseParts(response.content));
1178
+ if (response.toolCalls.length === 0) return response.text;
1179
+ }
1180
+
1181
+ return "Out of turns.";
1182
+ });
1183
+
1184
+ const program = Effect.gen(function* () {
1185
+ const page = yield* (yield* Browser.Browser).firstPage;
1186
+ const task = "Report the title and points of the top story.";
1187
+
1188
+ yield* page.goto("https://news.ycombinator.com");
1189
+
1190
+ // The tools act on this page, and the input policy's judge reads the task.
1191
+ return yield* solve(task).pipe(Effect.provide(tools.layer({ page }, { task })));
1192
+ });
1193
+ ```
1194
+
1195
+ Provide a `Browser` and a `LanguageModel`, as the repository's
1196
+ [README](https://github.com/mannyc2/effect-agent-browserbase#readme) does. A failed tool does not
1197
+ fail the loop: the model reads a `ToolError`, `invalid` for a request the tools cannot carry out or
1198
+ `browser` for a browser failure, with `dispatch` saying whether its input may have gone.
1199
+
1200
+ `BrowserTools.make()` gives the ref and control tools, with the names, parameters and descriptions
1201
+ Yielded Agent gave them until `0.1.0-beta.174` moved its browser tools to Code Mode over CDP:
1202
+
1203
+ | Tool | What it does |
1204
+ | ------------ | ---------------------------------------------------------------------------------------- |
1205
+ | `observe` | Reads the viewport as an outline whose controls carry refs such as `e12`, and lists them |
1206
+ | `act` | Clicks, fills or selects up to eight refs in order, then observes |
1207
+ | `inspect` | Reads inside a CSS selector, or narrows a select's options |
1208
+ | `navigate` | Opens an http or https address, a `data:` URL or `about:blank`, then observes |
1209
+ | `scroll` | Scrolls the page, or what a ref names, by pixels, then observes |
1210
+ | `wait` | Waits for what a selector matches to show, hide, enable or hold some text |
1211
+ | `press` | Presses a key on the element a ref names, focusing it first |
1212
+ | `select_tab` | Makes another tab current, where the tools follow a browser's tabs |
1213
+
1214
+ and pointer tools of their own, for what has no ref, such as a canvas game or a chart:
1215
+
1216
+ | Tool | What it does |
1217
+ | ------------ | -------------------------------------------------------------------- |
1218
+ | `click_at` | Clicks a point of the screenshot |
1219
+ | `hover` | Moves the pointer over a ref or a point |
1220
+ | `drag` | Drags from a ref or point to another, as a slider or a chart's range |
1221
+ | `type_text` | Types into whatever has focus |
1222
+ | `press_keys` | Presses a key or chord, held or repeated, on whatever has focus |
1223
+ | `zoom` | Crops a region of the viewport, shown before the next turn |
1224
+ | `wait_still` | Waits for the screen to stop moving, as reels coming to rest |
1225
+ | `back` | Goes back in the tab |
1226
+
1227
+ `BrowserTools.Control` and `BrowserTools.Pointer` are the two groups, to build an agent with fewer;
1228
+ the layer serves every tool either way. `make({ mode: "single" })` lets `act` take one action.
1229
+
1230
+ - `Pictures`' `next` holds a screenshot of the current tab and the crops `zoom` took since the
1231
+ last turn. Its pixel coordinates are viewport coordinates, which the pointer tools take.
1232
+ `vision: false` leaves the pictures out, and `zoom` then refuses. A queued crop is discarded if another tab
1233
+ becomes current before the next turn, so its coordinates never describe that other tab.
1234
+ - `vision: "ask"` shows the screenshot only before a turn after the model called `look`, a tool in
1235
+ `BrowserTools.Look` to merge into the toolkit; crops still follow `zoom`. `vision: "page"`
1236
+ also shows it after pointer input, and while the viewport shows a canvas, a video or another
1237
+ site's frame, where the outline cannot say what is there.
1238
+ - `BrowserTools.Find` holds `find`, which lists the whole page's outline lines that hold a text,
1239
+ in view or not, with their refs. Merge it into the toolkit; the layer serves it either way.
1240
+ - The layer also provides `BrowserTools.Controller`, the tools' controller, for an application's
1241
+ own tools on the same tabs, as `@effect-browser/tradingview`'s chart tools are: they act on the tab
1242
+ the model sees now, with the run's task, and say what followed.
1243
+ - `boxes: true` ends each control's line in the outline with its box, `WxH at (x,y)` in viewport
1244
+ CSS pixels, so the model can match a ref to what the screenshot shows there. `changes: true`
1245
+ gives, after an action, only the outline's lines gone and new since the tab's last whole look,
1246
+ when those are fewer; `observe` reads the whole outline again.
1247
+ - `placement: "crop"` makes `click_at` and `drag` first show a crop of the viewport around each
1248
+ point and act only once called at points inside crops already shown, which costs a turn per
1249
+ placement. A ref needs no crop.
1250
+ - An observation after an action begins with what followed it: a dialog and how the browser
1251
+ answered it, where the page went, a tab it opened and up to three changes its input caused,
1252
+ such as `"Full" became "Kept"`. A pointer tool's result says the same in `followed`.
1253
+ - Every action result says whether input reached the browser: `acknowledged`; `not-dispatched`,
1254
+ when it was refused first, by a stale ref or the input policy; or `possibly-dispatched`, when it failed after.
1255
+ An observation after an action that fails is still returned, and nothing is ever retried.
1256
+ - The input policy's judge reads `task`, the agent's task, as what authorizes a risky input.
1257
+ - The browser answers dialogs itself, as `effect-browser` does, so no tool answers one. The model
1258
+ sees a screenshot before each turn rather than calling for one.
1259
+ - Frames from the same origin are read inline, and none is listed, so `inspect` and `wait` refuse
1260
+ a `frame`.
1261
+
1262
+ Only the current pictures are ever in a request, so a provider's prompt cache keeps the thread.
1263
+ A turn's picture is dropped on the next call, so a provider that caches up to a breakpoint at the
1264
+ end of the prompt, as OpenAI's models do on OpenRouter, caches nothing a later call can use.
1265
+ `PromptCache.layer` marks the end of each chat completion's history instead: its last tool result
1266
+ or, before there is one, its system message. Provide it to the OpenRouter client:
1267
+
1268
+ ```ts
1269
+ import { OpenRouterClient } from "@effect/ai-openrouter";
1270
+ import { Config, Layer } from "effect";
1271
+ import { PromptCache } from "effect-browser/ai";
1272
+ import { FetchHttpClient } from "effect/http";
1273
+
1274
+ const openRouter = OpenRouterClient.layerConfig({
1275
+ apiKey: Config.Redacted("OPENROUTER_API_KEY"),
1276
+ }).pipe(Layer.provide(PromptCache.layer), Layer.provide(FetchHttpClient.layer));
1277
+ ```
1278
+
1279
+ `tools.layer({ page })` pins the tools to one page: they list no tabs, and a tab the page opens stays where
1280
+ it is. `tools.layer({ browser, follow })` acts on the tab the model last saw and lists the others; a tab an
1281
+ action opens is shown at the next look as `follow` says: `"select"`, the default, makes it current
1282
+ without bringing it to front, so the page on air and an operator's view stay where they are;
1283
+ `"front"` also brings it to front; `"never"` keeps the current tab.
1284
+
1285
+ `PageControl.make(target, options)` gives the controller the tools act through, for a host that
1286
+ drives a page without a model: `actions.observe` and `actions.act`, and `control.inspect`,
1287
+ `navigate`, `scroll`, `wait`, `press` and `selectTab`. Their results are `PageControl.Observation`
1288
+ and `PageControl.ActionResult`.
1289
+
996
1290
  ## Tracing
997
1291
 
998
1292
  Operations are spans in Effect's tracer, so an application that installs an exporter sees them in
@@ -1025,15 +1319,16 @@ records except text: the target, the subject's role, name and tag, whether input
1025
1319
  `error.type`. A read that shared another's work says so in `shared`: `joined` or `kept`.
1026
1320
  `Page.prepare`, the policy's preparation, and `Page.guard`, which lasts as long as a hold and holds
1027
1321
  a judge's model call, are its children, as are pointer travel (`Page.move`) and the settle after input (`Page.settle`).
1028
- `Page.snapshot`, `Page.find`, `Page.text`, `Page.title`, `Page.viewport`,
1029
- `Page.screenshot` and `Page.frame` (with
1030
- `source`: a reused screencast `frame` or a new `screenshot`), `Page.zoom`, `Page.ready` and the
1031
- other waits are spans, as are `Plan.replay` and `Plan.locate`, and so is each round trip to the
1322
+ `Snapshot.read`, `Snapshot.find`, `Snapshot.until`, `Text.read`, `Layout.measure`, `Change.read`,
1323
+ `Window.read`, `Page.title`, `Page.viewport`,
1324
+ `Frame.read` (with
1325
+ `source`: a reused screencast `frame` or a new `screenshot`), `Frame.zoom`, `Page.ready` and the
1326
+ other waits are spans, as are `Walk.replay` and `Walk.locate`, and so is each round trip to the
1032
1327
  page's script (`Page.evaluate`) and its registration (`Page.register`). Each page span reports its cost on the page's own protocol session: `calls`,
1033
1328
  `bytesOut` and `bytesIn` (their parameters and results as JSON) and `waitedMillis`, how long at
1034
1329
  least one call awaited its reply. An operation inside another counts toward both. Calls Playwright
1035
1330
  makes on its own sessions, such as navigation, are not counted. `Chromium.launch`, `Cdp.connect` and
1036
- `Browser.newPage` cover opening a browser; `Browserbase.open` records its session's id and region,
1331
+ `Browser.newPage` cover opening a browser; `Browserbase.make` records its session's id and region,
1037
1332
  `Browserbase.release` a release and its outcome, and `Browserbase.holdContext` the wait for a
1038
1333
  stored context another session writes to. `Page.calibrateClock` maps the browser's clock onto the
1039
1334
  host's with three probes, each a `Page.evaluate` of `clock`, and records the fastest answered