effect-browser 0.3.0-beta.24 → 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 (345) hide show
  1. package/README.md +333 -157
  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 +1 -1
  11. package/dist/BrowserEvent.mjs +166 -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 +33 -6
  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/{Style.d.mts → InputStyle.d.mts} +93 -25
  23. package/dist/{Style.mjs → InputStyle.mjs} +1 -1
  24. package/dist/Layout.d.mts +2 -2
  25. package/dist/Layout.mjs +58 -16
  26. package/dist/Layout.mjs.map +1 -1
  27. package/dist/Overlay.d.mts +2 -2
  28. package/dist/Overlay.mjs +33 -5
  29. package/dist/Overlay.mjs.map +1 -1
  30. package/dist/Page.d.mts +2 -2
  31. package/dist/Page.mjs +2 -2
  32. package/dist/PageTime.d.mts +2 -2
  33. package/dist/PageTime.mjs +13 -3
  34. package/dist/PageTime.mjs.map +1 -1
  35. package/dist/Pose.d.mts +2 -2
  36. package/dist/Pose.mjs +30 -9
  37. package/dist/Pose.mjs.map +1 -1
  38. package/dist/Site.d.mts +288 -18
  39. package/dist/Site.mjs +11 -3
  40. package/dist/Site.mjs.map +1 -1
  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 -18
  66. package/dist/index.mjs +6 -9
  67. package/dist/{Action-24sLOubi.d.mts → internal/Action-CkanNTUw.d.mts} +64 -4
  68. package/dist/{Browser-DGR6ZEYo.d.mts → internal/Browser-DD9Vm1c-.d.mts} +75 -11
  69. package/dist/{Browser-CAQFhTkM.mjs → internal/Browser-vzD7i2oj.mjs} +174 -237
  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-C2p-NwuU.d.mts → internal/BrowserEvent-tGPYYf6R.d.mts} +168 -13
  73. package/dist/internal/BrowserTools-Yi3lOX4h.mjs +497 -0
  74. package/dist/internal/BrowserTools-Yi3lOX4h.mjs.map +1 -0
  75. package/dist/{Style-T3ezDYLI.mjs → internal/InputStyle-CPzxoN4g.mjs} +75 -20
  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} +53 -20
  80. package/dist/internal/Page-BfGxn7oN.d.mts +1553 -0
  81. package/dist/{Page-BaAOshxo.mjs → internal/Page-DqF-tuTx.mjs} +62 -74
  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-Db-YtlbE.d.mts → internal/connection-BaB0vp1o.d.mts} +6 -6
  106. package/dist/{connection-C_jWYIwe.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-uhrT-dOB.mjs +49 -0
  111. package/dist/internal/fold.inpage-uhrT-dOB.mjs.map +1 -0
  112. package/dist/internal/functions-jBOs6GKv.mjs +27 -0
  113. package/dist/internal/functions-jBOs6GKv.mjs.map +1 -0
  114. package/dist/{Geometry-DJx9qrYy.d.mts → internal/geometry-Dhj_ztJs.d.mts} +3 -3
  115. package/dist/{Geometry.mjs → internal/geometry-Lxyflb9J.mjs} +3 -12
  116. package/dist/internal/geometry-Lxyflb9J.mjs.map +1 -0
  117. package/dist/{Matching.mjs → internal/matching-Cs-UeOY0.mjs} +3 -3
  118. package/dist/internal/matching-Cs-UeOY0.mjs.map +1 -0
  119. package/dist/internal/page-DFQb-YOK.mjs +436 -0
  120. package/dist/internal/page-DFQb-YOK.mjs.map +1 -0
  121. package/dist/{pose.inpage-CLq7Mfdr.mjs → internal/pose.inpage-CBFeWcVa.mjs} +2 -48
  122. package/dist/internal/pose.inpage-CBFeWcVa.mjs.map +1 -0
  123. package/dist/{Url.mjs → internal/url-DB0pQYk6.mjs} +3 -12
  124. package/dist/internal/url-DB0pQYk6.mjs.map +1 -0
  125. package/dist/policy/Policy.d.mts +60 -6
  126. package/dist/policy/Policy.mjs +52 -9
  127. package/dist/policy/Policy.mjs.map +1 -1
  128. package/dist/policy/index.d.mts +2 -0
  129. package/dist/policy/index.mjs +2 -0
  130. package/dist/{film → presentation}/Film.d.mts +83 -16
  131. package/dist/{film → presentation}/Film.mjs +82 -30
  132. package/dist/presentation/Film.mjs.map +1 -0
  133. package/dist/presentation/Motion.d.mts +5 -1
  134. package/dist/presentation/Motion.mjs +16 -2
  135. package/dist/presentation/Motion.mjs.map +1 -1
  136. package/dist/presentation/Presentation.d.mts +42 -7
  137. package/dist/presentation/Presentation.mjs +26 -9
  138. package/dist/presentation/Presentation.mjs.map +1 -1
  139. package/dist/presentation/Stage.d.mts +40 -6
  140. package/dist/presentation/Stage.mjs +1 -262
  141. package/dist/presentation/index.d.mts +5 -0
  142. package/dist/presentation/index.mjs +5 -0
  143. package/dist/supervisor/Release.d.mts +2 -0
  144. package/dist/supervisor/Release.mjs +40 -0
  145. package/dist/supervisor/Release.mjs.map +1 -0
  146. package/dist/supervisor/Supervisor.d.mts +2 -104
  147. package/dist/supervisor/Supervisor.mjs +2 -515
  148. package/dist/supervisor/index.d.mts +3 -0
  149. package/dist/supervisor/index.mjs +3 -0
  150. package/dist/testing/HttpCassette.d.mts +98 -0
  151. package/dist/testing/HttpCassette.mjs +146 -0
  152. package/dist/testing/HttpCassette.mjs.map +1 -0
  153. package/dist/testing/Story.d.mts +31 -0
  154. package/dist/testing/Story.mjs +76 -0
  155. package/dist/testing/Story.mjs.map +1 -0
  156. package/dist/testing/TestBrowser.d.mts +191 -0
  157. package/dist/testing/TestBrowser.mjs +105 -0
  158. package/dist/testing/TestBrowser.mjs.map +1 -0
  159. package/dist/testing/TestModel.d.mts +133 -0
  160. package/dist/testing/TestModel.mjs +209 -0
  161. package/dist/testing/TestModel.mjs.map +1 -0
  162. package/dist/testing/TestPage.d.mts +2 -0
  163. package/dist/testing/TestPage.mjs +47 -0
  164. package/dist/testing/TestPage.mjs.map +1 -0
  165. package/dist/testing/index.d.mts +6 -311
  166. package/dist/testing/index.mjs +6 -521
  167. package/dist/timeline/Moment.d.mts +3 -0
  168. package/dist/timeline/Moment.mjs +3 -0
  169. package/dist/timeline/Stillness.d.mts +34 -0
  170. package/dist/timeline/Stillness.mjs +2 -0
  171. package/dist/timeline/index.d.mts +3 -0
  172. package/dist/timeline/index.mjs +3 -0
  173. package/dist/walk/Walk.d.mts +2 -0
  174. package/dist/walk/Walk.mjs +2 -0
  175. package/dist/walk/index.d.mts +2 -0
  176. package/dist/walk/index.mjs +2 -0
  177. package/package.json +54 -163
  178. package/src/Action.ts +73 -8
  179. package/src/Browser.ts +75 -9
  180. package/src/BrowserError.ts +258 -63
  181. package/src/BrowserEvent.ts +252 -55
  182. package/src/Cdp.ts +42 -0
  183. package/src/Change.ts +68 -3
  184. package/src/Frame.ts +247 -14
  185. package/src/{Style.ts → InputStyle.ts} +98 -22
  186. package/src/Layout.ts +95 -24
  187. package/src/Overlay.ts +42 -3
  188. package/src/Page.ts +144 -320
  189. package/src/PageTime.ts +29 -4
  190. package/src/Pose.ts +38 -7
  191. package/src/Site.ts +15 -3
  192. package/src/Snapshot.ts +179 -3
  193. package/src/Text.ts +60 -0
  194. package/src/Window.ts +53 -3
  195. package/src/ai/BrowserTools.ts +778 -0
  196. package/src/ai/PageControl.ts +702 -0
  197. package/src/ai/PromptCache.ts +87 -0
  198. package/src/ai/Tabs.ts +84 -0
  199. package/src/ai/ToolError.ts +50 -0
  200. package/src/ai/index.ts +36 -0
  201. package/src/ai/internal/crops.ts +38 -0
  202. package/src/ai/internal/points.ts +57 -0
  203. package/src/ai/internal/receipts.ts +107 -0
  204. package/src/index.ts +83 -6
  205. package/src/{ActionPort.ts → internal/action-port.ts} +3 -3
  206. package/src/{providers → internal/cdp}/connection.ts +19 -12
  207. package/src/internal/cdp/workerd.ts +36 -0
  208. package/src/{Clock.ts → internal/clock.ts} +20 -0
  209. package/src/internal/input/actions.ts +1 -1
  210. package/src/internal/input/dispatch.ts +2 -2
  211. package/src/internal/input/guard.inpage.ts +1 -1
  212. package/src/internal/input/guard.ts +1 -1
  213. package/src/internal/input/perform.ts +5 -5
  214. package/src/internal/input/pointer.ts +2 -2
  215. package/src/internal/input/targets.inpage.ts +3 -3
  216. package/src/{Matching.ts → internal/matching.ts} +6 -6
  217. package/src/internal/page/bridge.ts +2 -2
  218. package/src/internal/page/clock.inpage.ts +1 -1
  219. package/src/internal/page/compose.inpage.ts +2 -2
  220. package/src/internal/page/context.ts +2 -2
  221. package/src/internal/page/functions.ts +84 -0
  222. package/src/internal/page/navigation.ts +1 -1
  223. package/src/internal/page/openings.ts +2 -2
  224. package/src/internal/page/page.ts +33 -35
  225. package/src/internal/page/port.ts +14 -8
  226. package/src/internal/page/replies.ts +1 -1
  227. package/src/internal/page/requests.ts +1 -1
  228. package/src/internal/page/scripts.ts +1 -1
  229. package/src/internal/page/time.ts +1 -1
  230. package/src/internal/pictures/capture.ts +1 -4
  231. package/src/internal/pictures/dimensions.ts +1 -1
  232. package/src/internal/pictures/frame.ts +1 -1
  233. package/src/internal/pictures/pictures.ts +53 -61
  234. package/src/internal/reading/context.inpage.ts +2 -2
  235. package/src/internal/reading/expect.inpage.ts +1 -1
  236. package/src/internal/reading/layout.inpage.ts +3 -3
  237. package/src/internal/reading/layout.ts +5 -5
  238. package/src/internal/reading/outline.inpage.ts +3 -3
  239. package/src/internal/reading/reading.ts +11 -19
  240. package/src/internal/reading/ready.inpage.ts +2 -2
  241. package/src/internal/reading/ready.ts +3 -2
  242. package/src/internal/reading/subjects.inpage.ts +3 -3
  243. package/src/internal/reading/text.inpage.ts +2 -2
  244. package/src/internal/reading/walk.inpage.ts +1 -1
  245. package/src/internal/timeline/changes.inpage.ts +2 -2
  246. package/src/internal/timeline/changes.ts +3 -4
  247. package/src/internal/timeline/sight.inpage.ts +2 -2
  248. package/src/internal/timeline/window.ts +3 -4
  249. package/src/policy/Policy.ts +70 -16
  250. package/src/policy/index.ts +12 -0
  251. package/src/{film → presentation}/Film.ts +104 -37
  252. package/src/presentation/Motion.ts +45 -3
  253. package/src/presentation/Presentation.ts +47 -14
  254. package/src/presentation/Stage.ts +73 -35
  255. package/src/presentation/index.ts +30 -0
  256. package/src/presentation/{feed.ts → internal/feed.ts} +1 -1
  257. package/src/supervisor/Release.ts +45 -0
  258. package/src/supervisor/Supervisor.ts +80 -5
  259. package/src/supervisor/index.ts +18 -0
  260. package/src/supervisor/{contract.ts → internal/contract.ts} +14 -10
  261. package/src/supervisor/{lifecycle.ts → internal/lifecycle.ts} +7 -7
  262. package/src/supervisor/{runtime.ts → internal/runtime.ts} +7 -7
  263. package/src/testing/HttpCassette.ts +260 -0
  264. package/src/testing/Story.ts +103 -0
  265. package/src/testing/TestBrowser.ts +14 -4
  266. package/src/testing/TestModel.ts +297 -0
  267. package/src/testing/TestPage.ts +92 -4
  268. package/src/testing/index.ts +35 -1
  269. package/src/testing/{evidence.ts → internal/evidence.ts} +19 -11
  270. package/src/testing/{model.ts → internal/model.ts} +14 -8
  271. package/src/testing/{page.ts → internal/page.ts} +55 -56
  272. package/src/{moment → timeline}/Moment.ts +79 -29
  273. package/src/{stillness → timeline}/Stillness.ts +61 -43
  274. package/src/timeline/index.ts +18 -0
  275. package/src/{stillness/Pixels.ts → timeline/internal/pixels.ts} +2 -2
  276. package/src/{moment → timeline/internal}/words.ts +2 -2
  277. package/src/walk/Walk.ts +165 -0
  278. package/src/walk/index.ts +12 -0
  279. package/src/{plan → walk/internal}/choose.ts +23 -14
  280. package/src/{plan → walk/internal}/data.ts +37 -14
  281. package/src/{plan → walk/internal}/execute.ts +79 -36
  282. package/src/{plan → walk/internal}/record.ts +6 -6
  283. package/src/{plan → walk/internal}/targets.ts +35 -25
  284. package/dist/ActionPort.d.mts +0 -15
  285. package/dist/ActionPort.mjs.map +0 -1
  286. package/dist/Browser-CAQFhTkM.mjs.map +0 -1
  287. package/dist/Change-CxT1mp2e.d.mts +0 -80
  288. package/dist/Clock-Du5nP-nK.d.mts +0 -57
  289. package/dist/Clock.d.mts +0 -2
  290. package/dist/Clock.mjs.map +0 -1
  291. package/dist/Frame-UEH2hO5T.d.mts +0 -124
  292. package/dist/Geometry.d.mts +0 -2
  293. package/dist/Geometry.mjs.map +0 -1
  294. package/dist/Matching-MtcWZ_hA.d.mts +0 -266
  295. package/dist/Matching.d.mts +0 -2
  296. package/dist/Matching.mjs.map +0 -1
  297. package/dist/Overlay-CoGw5tL_.d.mts +0 -27
  298. package/dist/Page-BaAOshxo.mjs.map +0 -1
  299. package/dist/Page-CLzh5E9w.d.mts +0 -718
  300. package/dist/PageTime-68UPUZpZ.d.mts +0 -29
  301. package/dist/Pose-2qqGzPvb.d.mts +0 -32
  302. package/dist/Released-tURbFmal.d.mts +0 -15
  303. package/dist/Snapshot-CtBVOtuu.d.mts +0 -73
  304. package/dist/Stillness-BwP0RdI4.mjs +0 -157
  305. package/dist/Stillness-BwP0RdI4.mjs.map +0 -1
  306. package/dist/Style-T3ezDYLI.mjs.map +0 -1
  307. package/dist/Url-B7P-TWwL.d.mts +0 -26
  308. package/dist/Url.d.mts +0 -2
  309. package/dist/Url.mjs.map +0 -1
  310. package/dist/Window-BDa8MtNP.d.mts +0 -34
  311. package/dist/connection-C_jWYIwe.mjs.map +0 -1
  312. package/dist/film/Film.mjs.map +0 -1
  313. package/dist/moment/Moment.mjs.map +0 -1
  314. package/dist/plan/index.mjs.map +0 -1
  315. package/dist/pose.inpage-CLq7Mfdr.mjs.map +0 -1
  316. package/dist/presentation/Stage.mjs.map +0 -1
  317. package/dist/presentation/feed.d.mts +0 -20
  318. package/dist/presentation/feed.mjs +0 -18
  319. package/dist/presentation/feed.mjs.map +0 -1
  320. package/dist/providers/Cdp.d.mts +0 -9
  321. package/dist/providers/Cdp.mjs +0 -15
  322. package/dist/providers/Cdp.mjs.map +0 -1
  323. package/dist/providers/Chromium.d.mts +0 -32
  324. package/dist/providers/Chromium.mjs +0 -55
  325. package/dist/providers/Chromium.mjs.map +0 -1
  326. package/dist/providers/Released.d.mts +0 -2
  327. package/dist/providers/Released.mjs +0 -12
  328. package/dist/providers/Released.mjs.map +0 -1
  329. package/dist/stillness/Stillness.d.mts +0 -12
  330. package/dist/stillness/Stillness.mjs +0 -2
  331. package/dist/supervisor/Supervisor.mjs.map +0 -1
  332. package/dist/testing/index.mjs.map +0 -1
  333. package/dist/workerd/Cdp.d.mts +0 -8
  334. package/dist/workerd/Cdp.mjs +0 -13
  335. package/dist/workerd/Cdp.mjs.map +0 -1
  336. package/src/plan/index.ts +0 -36
  337. package/src/providers/Cdp.ts +0 -16
  338. package/src/providers/Chromium.ts +0 -99
  339. package/src/providers/Released.ts +0 -13
  340. package/src/workerd/Cdp.ts +0 -11
  341. /package/dist/{fold.inpage-CyVZQHZL.d.mts → internal/fold.inpage-CyVZQHZL.d.mts} +0 -0
  342. /package/dist/{rolldown-runtime-D7D4PA-g.mjs → internal/rolldown-runtime-D7D4PA-g.mjs} +0 -0
  343. /package/src/{Geometry.ts → internal/geometry.ts} +0 -0
  344. /package/src/{Url.ts → internal/url.ts} +0 -0
  345. /package/src/{stillness → timeline/internal}/utilsBundle.d.ts +0 -0
package/README.md CHANGED
@@ -5,59 +5,78 @@ compact page outline for models, screencast frames, a record of what visibly cha
5
5
  windows over a page's events, changes and frames, and moments, an account in pictures and words of
6
6
  what a page showed and what changed on it. It films pages on their own held time, with layout as
7
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 through [`effect-agent-browser`](../agent-browser), with
9
- Yielded Agent's browser tools.
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.
10
10
 
11
11
  ```sh
12
- npm install effect-browser@beta effect playwright-core
12
+ npm install effect-browser@beta @effect-browser/chromium@beta effect playwright-core
13
13
  npx playwright-core install chromium
14
14
  ```
15
15
 
16
- `Chromium.layer` launches that Chromium without its sandbox, as Playwright does, so an exploit in a
17
- page's renderer runs with your user's privileges. `Chromium.layer({ sandbox: true })` runs it
18
- sandboxed. Hosts that don't allow unprivileged user namespaces, such as many containers and Ubuntu
19
- 23.10 or later by default, can't start the sandbox; opening then fails and says so.
20
-
21
- `Chromium.layer` leaves signals to your program: Playwright's own handlers, which close every
22
- browser and, on SIGINT, exit before any finalizer runs, are off. Run the program with
23
- `NodeRuntime.runMain` from `@effect/platform-node`, which interrupts it on SIGINT and SIGTERM, so
24
- the browser closes with its scope. A signal that ends the process outright still takes Chromium
25
- with it, since its pipe closes, but leaves Playwright's temporary profile behind.
26
-
27
- | Module | What it holds |
28
- | -------------- | --------------------------------------------------------------------------------- |
29
- | `Browser` | The `Browser` service: tabs, recent events, lifetime and input suspension |
30
- | `Chromium` | A local Chromium as a `Browser` layer |
31
- | `Cdp` | Any DevTools endpoint as a `Browser` layer |
32
- | `Page` | One tab: navigation, reads, screenshots, input, waits and the screencast |
33
- | `Snapshot` | The model-readable outline of a page, with refs for its controls |
34
- | `Frame` | Pictures, timing evidence and capture identity |
35
- | `BrowserEvent` | Tabs, documents, loads, actions, dialogs, pointer motion and the browser's end |
36
- | `Motion` | A bounded pointer planner, as a value, and the tuned sigma-lognormal one |
37
- | `Presentation` | Input performed for viewers: a presenter, and its views of pages |
38
- | `Stage` | The source of a live output, switched between pages and stamped |
39
- | `Layout` | Where picked things and their words are on a page, as data, and rehearsals |
40
- | `Overlay` | A layer over a page that the library draws a caller's SVG into and never reads |
41
- | `PageTime` | A page's own time, held and stepped, with its scroll, poses and overlay |
42
- | `Pose` | A page's own elements moved, turned and scaled about a point |
43
- | `Film` | A page filmed as a function of time: frames, inputs on their frames, passages |
44
- | `Site` | The readers, change record, overlay and poses, run by a site on its own page |
45
- | `BrowserError` | Typed failures, whether input reached the page first, and what each leaves |
46
- | `Policy` | Judges that read what an input means, and a guard that acts on them unattended |
47
- | `Change` | What visibly changed on a page over a window, element by element |
48
- | `Moment` | A page's events, changes and frames over a window; a moment, laid out as a prompt |
49
- | `Plan` | A walk recorded from a page's events, replayed on a fresh page by subject |
50
- | `Supervisor` | A browser kept open across losses and session ends, as generations |
51
-
52
- Providers and features use explicit subpaths, such as `effect-browser/Chromium` and
53
- `effect-browser/Plan`. The root exports the kernel. `Action`, `ActionPort`, `Clock`, `Geometry`,
54
- `Matching`, `Style` and `Window` provide its execution, timing, matching and observation contracts.
55
- `effect-browser/Stillness` owns screen/content quiet waits. `effect-browser/testing` exports
56
- 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.
57
76
 
58
77
  ## Runtime CDP connectors
59
78
 
60
- `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
61
80
  `{ timeout, headers, signal }` and returning a real Playwright CDP `Browser`. Node uses
62
81
  `playwright-core`'s `chromium.connectOverCDP` by default. A consumer can supply a connector using
63
82
  its runtime's WebSocket implementation to avoid Playwright's Node WebSocket transport.
@@ -123,17 +142,19 @@ const nativeConnect: Cdp.Connector = async (endpoint, { timeout, headers, signal
123
142
  };
124
143
  ```
125
144
 
126
- 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.
127
148
 
128
149
  The `workerd` export condition selects a CDP entry without the Node transport. It requires
129
- `connect`; omitting it fails with `BrowserError` reason `InvalidRequest`. The Workers root entry
130
- 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
131
152
  the `workerd` condition. Local Worker/CDP checks also pass without `nodejs_compat`; the consumer still supplies and qualifies the runtime's Playwright
132
153
  implementation against this package's Playwright peer; the seam does not certify a different
133
154
  Playwright version or provide a Cloudflare connector.
134
155
 
135
- The callback receives a finite positive `connectTimeoutMillis`, 30 seconds by default, and an
136
- `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
137
158
  the signal when it expires or the caller is interrupted. A connector should stop its own pending
138
159
  work when aborted. A browser it returns late is disconnected, as is one whose opening fails or
139
160
  whose scope closes. Its `close()` must disconnect the CDP connection without ending the remote
@@ -143,7 +164,7 @@ endpoint's userinfo, path and query. A failure diagnostic that echoes a nonempty
143
164
  value is withheld entirely, including in serialized errors.
144
165
 
145
166
  `page.perform(action)` and the named input methods share the `Action` schema. Guards receive
146
- 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.
147
168
  `page.read(fn, { arg, result })` returns `{ value, document, connection }` after schema decoding.
148
169
  `page.act(fn, { arg, result, document, connection })` validates the document and optional connection,
149
170
  passes the input guard as an opaque scripted action, and records dispatch before evaluation.
@@ -169,7 +190,7 @@ A snapshot outlines the viewport, or the whole page, with a ref such as `e12` on
169
190
  lists those controls as values, `Snapshot.Control`: each one's ref, kind, name and what it holds,
170
191
  a select's options, and whether it is disabled, checked or takes typed text. `within` reads only
171
192
  inside the elements a CSS selector matches, and `query` keeps the lines that hold some text.
172
- `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
173
194
  `state: "enabled"`. It searches the document by default. `want` is `"some"`, `"none"`, or
174
195
  `{ other: previous.mark }`; comparison marks reveal no text or values and ignore focus.
175
196
  A finite nonnegative deadline returns `{ met, mark }`; document replacements share that deadline.
@@ -179,7 +200,7 @@ sampled. A zero-duration baseline reads once and fails if its document disappear
179
200
  a moment uses. The actions a call performs record a caller's id as their `correlation` when it runs
180
201
  under `Page.correlate(id)`, such as a model's tool call.
181
202
 
182
- `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`;
183
204
  crop pixel coordinates need the region's origin added before using them as click coordinates.
184
205
 
185
206
  `Page.click` returns a `ResolvedTarget` captured before input: the requested point, element label,
@@ -196,18 +217,18 @@ counted; elsewhere, `label` is the words just before it in its row, item, group
196
217
  is the nearest heading above it, left out for what is pinned to the viewport. The page binds each to
197
218
  the element, so a value is never read under another column's header.
198
219
 
199
- `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
200
221
  that matches a query, in tree order, each a `Found`: a ref the actions take, its `subject`, its box,
201
222
  whether it is in the viewport, and its state (disabled, focused, and checked, expanded, selected,
202
223
  pressed or a heading's level where they apply). A `role` matches ignoring case. A `name` matches
203
224
  when it reads the same once spaces are collapsed and case folded, or when a `RegExp` finds itself
204
225
  in it. `text` matches the smallest element showing it, and a control or heading for the words
205
226
  inside it; `near` matches whole words of the context, as replay's choice does. With no rule,
206
- `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
207
228
  caller tells equal elements apart by their context, and finding none is an empty result, not a
208
229
  failure. `scope: "document"` reads the whole page; the default is the viewport.
209
230
 
210
- `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
211
232
  call to the page: a line per block, table cells apart by tabs, cut at a line after `maxChars`
212
233
  (12,000 by default). Like the outline, it leaves out what the page hides from assistive technology,
213
234
  such as icon glyphs. What a field holds reads `••••` unless `unmask` is set, and a secret field's
@@ -216,7 +237,7 @@ holds, as a PIN field's may, and one that was secret when the library saw it, su
216
237
  its page now reveals. The outline shows what fields hold, as the agent needs, but masks a secret
217
238
  field the same way.
218
239
 
219
- 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
220
241
  styling anything in it, so a long table costs only its rows in view. A box says nothing of what is
221
242
  positioned out of it, so a subtree is kept when its box is empty; when it holds what is painted at
222
243
  the viewport's edges, corners or middle, beneath any transparent layer too, or in its top layer; or
@@ -229,13 +250,13 @@ is, or until the time is up: its document is parsed and has painted since, nothi
229
250
  animating in view, its fonts and the images in view have loaded, nothing in view is marked busy
230
251
  (`aria-busy`), and the viewport shows something: text, a canvas drawn on, a picture or drawing
231
252
  larger than an icon, a video or a frame. It polls every 50 ms and follows document replacements
232
- 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
233
254
  not start a recorder or a capture. A canvas mounted blank, as chart libraries mount theirs,
234
255
  or a spinner alone is still loading. A screen that only says "Loading…" in words reads as ready,
235
256
  and a WebGL canvas drawn once, without keeping its drawing, reads as blank. A hidden tab, which
236
257
  paints nothing, is never ready.
237
258
 
238
- `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,
239
260
  counted from the first frame of a capture the wait starts itself, since a hosted browser sends that
240
261
  frame over half a second late. A capture's silence alone proves little: a stalled connection holds
241
262
  frames on their way, and Chromium sends frames only while few acknowledgements are unanswered. So
@@ -248,23 +269,23 @@ of 2 waits before, and in none since. Where the page's changes are recorded, the
248
269
  page's own check also waits until nothing in view has changed for the spell, so frames the browser
249
270
  holds back, as an encoder's backlog does, cannot pass for a still page. Stillness is a heuristic
250
271
  on a canvas: a canvas that keeps drawing, such as a live chart, is never still, and one that pauses
251
- 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
252
273
  connection stalled for 450 to 900 ms toward either end while the reels spun, none of 132 waits
253
274
  ended early, where all 36 did before.
254
275
 
255
- `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
256
277
  before the page's latest input, such as idle decoration. Motion elsewhere restarts the quiet
257
278
  interval. It compares newly accepted frames, including brief motion between polls and frames
258
279
  accepted after a viewport-size check; missing history or more than eight new frames in one poll
259
280
  restarts the interval conservatively. Without pre-input frame history, all motion counts.
260
281
 
261
- `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
262
283
  recorded DOM changes. It starts the recorder itself and starts the interval again in each new
263
284
  document; navigation retries share the original timeout. Canvas animation can continue while DOM
264
285
  content is ready. This does not prove pixel or screencast stillness and inherits the change
265
286
  recorder's limits for canvas, SVG, frames, shadow content and values changed only by scripts.
266
287
 
267
- `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
268
289
  the page, element by element, as a `Change`: text that changed, appeared, disappeared or came and
269
290
  went (`brief`), a field's value, or the title. Each says what it showed at the window's start and
270
291
  end, how often that changed, the lowest and highest of a number that changed more than once, when
@@ -311,7 +332,7 @@ sets, or a class that reveals an element it has not seen before, such as a toast
311
332
  page, though its later changes it does.
312
333
 
313
334
  A page's timeline has three tracks on the browser's host clock: its events, what changed on it,
314
- 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
315
336
  events and frames the page keeps, at no call, and its changes, in one call, the first starting its
316
337
  record as any read of changes does. `since` is a previous window, to go on exactly where it ended, a
317
338
  frame, a host time, or a `Duration` back from `until`; `until` is a frame or a host time, now by
@@ -326,10 +347,10 @@ rest, each showing what it settled at, as a price that ticked and stopped does.
326
347
  how long the page had been still, by the last change in view its record shows or the last paint
327
348
  among its screencast frames; a screenshot shows the page, not when it changed. Frames show paint
328
349
  only while a capture runs, and the record does not see a canvas, so a canvas that draws with no
329
- 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 })`
330
351
  when a wait must observe screen quiet and hold through a stalled capture connection.
331
352
 
332
- `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,
333
354
  then the window up to its paint, from where a previous window or moment ended, so the changes hold
334
355
  nothing the picture does not show. A cached picture from before the latest action finished is
335
356
  replaced with a fresh screenshot, keeping a navigation's triggering action in the moment.
@@ -348,16 +369,16 @@ changed was not recorded and lists every step instead; one whose record began wi
348
369
  says nothing changed only after that. What it could not read, it names, with why, and a last frame
349
370
  that is not the picture is not shown as the moment.
350
371
 
351
- `Plan` rehearses a walk once and replays it later, near live, with no model call.
352
- `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
353
374
  the options they were given, its navigations with the address asked for and the one reached, and
354
375
  what was typed as an input slot named for its field, never the text itself. A navigation to an
355
376
  address with a credential withheld is an input slot too, `address`, so replay goes where the caller
356
- says, never to the address without its credential. `Plan.replay(page,
377
+ says, never to the address without its credential. `Walk.replay(page,
357
378
  plan, { inputs })` takes the steps in turn: before each step except an opening navigate, back or
358
- 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
359
380
  `Stillness.wait` for content quiet; otherwise it calls `Page.ready`. It finds the element with
360
- `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
361
382
  is another subject: its row read whole, so a row named "Wrapped BTC" is not the row "BTC" (laid out
362
383
  again without rows, as cards, one of its fields must start with the row's words), its column where
363
384
  it is under one, and its label and heading read the same or found as words in order. So the one
@@ -370,18 +391,19 @@ A press recorded on a subject resolves and focuses it before sending keys. Text
370
391
  typed into a secret field is typed only into one. An element step never falls back to coordinates.
371
392
  A step recorded at a point presses the same place within the element found, brought into view
372
393
  first, and only when a press there reaches that element, not something over it. Replay stops at
373
- the first step it cannot take, with a `ReplayError` naming the step and why: `Missing`,
374
- `Ambiguous`, `Drifted` (nothing with the subject's role and name repeats its context, or the walk
375
- 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
376
398
  are bounded by `arrival` (five seconds by default), including redirects after an action. A zero
377
399
  wait makes one read without polling; that read retains the page operation's own timeout.
378
400
  Each `Action` now records its ending address, so a bounded event history can still record the site
379
401
  of later actions after its earlier navigation has expired.
380
402
 
381
- `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
382
404
  `startedAt` and `at`, and `taken`, `verified` or `skipped`. Readiness is a precondition of the next
383
405
  step, including later navigation, never a wait after the last step. After replay, call `page.ready`
384
- 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;
385
407
  a `ReplayError` includes completed receipts and a serializable `stopped` value with the next step
386
408
  and whether its input is `unsent` or `unknown`. Resume with `{ from: error.stopped }`. A numeric
387
409
  index means fresh input, so never convert an unresolved stopping point into a number to retry it.
@@ -394,7 +416,7 @@ input and waits for it afterward. Relative `Navigated` (without a URL) never ski
394
416
  it compares with the page immediately before dispatch, after readiness and arrival. It observes
395
417
  change after that baseline, without proving the input caused it.
396
418
  `verified` means the specified observation held; it is not a transaction
397
- 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.
398
420
  `Checked` can converge a checkbox click to a desired boolean.
399
421
  Unknown non-repeatable input is never automatically sent again: only a positive check explicitly
400
422
  marked `durable: true` permits continuation. Only `Appeared` or `Navigated` with an explicit exact
@@ -403,13 +425,13 @@ read-back, such as a saved order receipt or its operation-specific URL. An arbit
403
425
  toast or intermediate URL cannot justify it. `Gone`, relative navigation, and a negative or failed
404
426
  durable check still leave unknown consequential input uncertain.
405
427
  Navigation, hover, scroll, selection and replacement typing without submission can be repeated;
406
- back, reload, insertion, presses, drags and ordinary clicks cannot. `Plan.repeatable(step)` says
407
- 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
408
430
  page using those same rules and refuses unresolved commitments. `upTo` is exclusive.
409
431
 
410
- `Plan.Plan.new(steps)` emits version 3 with canonical typed Actions. Prior version 1/2
411
- string-action plans and unknown versions do not decode. This is a hard cutover; rerecord or
412
- 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
413
435
  URL-less `Navigated`; execution also refuses recovery through those unsupported claims.
414
436
 
415
437
  `Browser.Options.guard` is the input policy. Its `InputRequest` schema contains the action, the
@@ -438,9 +460,9 @@ The policy's effect succeeds to allow, fails with `PolicyDenied` to refuse, or w
438
460
  the consumer owns to hold. For example:
439
461
 
440
462
  ```ts
463
+ import { Chromium } from "@effect-browser/chromium";
441
464
  import { Effect } from "effect";
442
465
  import { PolicyDenied } from "effect-browser/BrowserError";
443
- import * as Chromium from "effect-browser/Chromium";
444
466
 
445
467
  const browser = Chromium.layer({
446
468
  guard: (request) =>
@@ -450,7 +472,7 @@ const browser = Chromium.layer({
450
472
  });
451
473
  ```
452
474
 
453
- `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
454
476
  input means. `Policy.reviewer()` asks the `LanguageModel` in context for a structured review, and
455
477
  `Policy.decider` asks a `DecisionModel`, such as Jev through `@effect/ai-typesafe`. Both give a
456
478
  `Judgement`: for each `Risk` (`financial`, `account`, `access`, `deletion`, `communication` and
@@ -460,9 +482,9 @@ for it. `Policy.escalate(first, second)` asks `second` only when `first` is unsu
460
482
  and why. `origins` keeps input to some origins, and `deny` refuses facts outright:
461
483
 
462
484
  ```ts
485
+ import { Chromium } from "@effect-browser/chromium";
463
486
  import { Effect, Layer } from "effect";
464
- import * as Chromium from "effect-browser/Chromium";
465
- import * as Policy from "effect-browser/Policy";
487
+ import { Policy } from "effect-browser/policy";
466
488
 
467
489
  const browser = Layer.unwrap(
468
490
  Effect.gen(function* () {
@@ -473,7 +495,7 @@ const browser = Layer.unwrap(
473
495
  );
474
496
  ```
475
497
 
476
- 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
477
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
478
500
  text and the facts as trusted, and the page's text only as evidence. It never sees the agent's own
479
501
  words. A judgement only adds to structure: a `secret` fact counts whatever the judge reads. A judge
@@ -521,14 +543,15 @@ samples and 5,000 milliseconds, ending at the exact destination. The browser dec
521
543
  `InvalidRequest` before their track or input is sent. Equal-time samples are retained. Plain input
522
544
  never plans a glide: its pointer jumps, or moves in eight short steps while dragging.
523
545
 
524
- 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
525
547
  its planner to the presenter:
526
548
 
549
+ <!-- prettier-ignore -->
527
550
  ```ts
528
- import * as HumanStrokes from "effect-browser-human-strokes";
529
- import * as Presentation from "effect-browser/Presentation";
551
+ import * as HumanStrokes from "@effect-browser/human-strokes";
552
+ import { Presentation } from "effect-browser/presentation";
530
553
 
531
- const presenter = yield * Presentation.make({ motion: yield * HumanStrokes.motion });
554
+ const presenter = yield* Presentation.make({ motion: yield* HumanStrokes.motion });
532
555
  ```
533
556
 
534
557
  That package bundles 32,130 attributed CC BY 4.0 strokes, preserving their original sample times.
@@ -546,8 +569,9 @@ nothing, for example keys, or typing into the focused field.
546
569
 
547
570
  A presenter's `lead` runs after the announcement and before the glide:
548
571
 
572
+ <!-- prettier-ignore -->
549
573
  ```ts
550
- const presenter = yield * Presentation.make({ lead: (announced) => performer.arrive(announced) });
574
+ const presenter = yield* Presentation.make({ lead: (announced) => performer.arrive(announced) });
551
575
  ```
552
576
 
553
577
  Use it to give whatever is shown performing the input, such as a character, time to arrive. It
@@ -593,17 +617,16 @@ cancellation; a wrapper's timeout cannot surrender their authority.
593
617
 
594
618
  ```ts
595
619
  import { Effect, Stream } from "effect";
596
- import { Browser } from "effect-browser/Browser";
620
+ import * as Browser from "effect-browser/Browser";
597
621
  import type { Frame } from "effect-browser/Frame";
598
- import * as Presentation from "effect-browser/Presentation";
599
- import * as Stage from "effect-browser/Stage";
622
+ import { Presentation, Stage } from "effect-browser/presentation";
600
623
 
601
624
  declare const encode: (frame: Frame) => Effect.Effect<void>; // the application's own output
602
625
 
603
626
  const program = Effect.gen(function* () {
604
627
  const stage = yield* Stage.make({ quality: 80 });
605
628
  const presenter = yield* Presentation.make();
606
- const page = yield* (yield* Browser).newPage("https://example.com");
629
+ const page = yield* Browser.newPage("https://example.com");
607
630
  yield* stage.frames.pipe(Stream.runForEach(encode), Effect.forkScoped);
608
631
  const shown = yield* stage.present(page); // Presented { page, at, latency }
609
632
  yield* presenter.view(page).click("e12"); // glides, then clicks, as a person would
@@ -617,7 +640,7 @@ viewers last saw it, on whichever page; a field is clicked before typing; and th
617
640
  100 px notches, in bursts of up to nine. One view acts at a time. The time a view spends showing an
618
641
  action, its glides, holds and typing, has a budget of its own outside `actionTimeout`. `page`
619
642
  itself stays plain, and plain input on any page never waits for a view. Styles flow through
620
- `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
621
644
  wait bound after approval. Planned typing and scrolling have a separate 10-second cap and fail
622
645
  `InvalidRequest` before input when the schedule exceeds it.
623
646
 
@@ -628,17 +651,18 @@ Closing an abandoned cue stops its capture. `present(page, { at })` is the conve
628
651
  and committing in one call. A stage uses the first page's owning clock; cueing a page with a
629
652
  different clock fails `InvalidRequest`, since host times from those clocks cannot be compared.
630
653
 
654
+ <!-- prettier-ignore -->
631
655
  ```ts
632
656
  // Inside a scoped program: lineSent yields Some(hostTime) when the line goes out, or None if dropped.
633
- const cue = yield * stage.cue(page);
634
- yield * cue.ready;
635
- const sent = yield * lineSent;
636
- 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 });
637
661
  ```
638
662
 
639
663
  Commits serialize in call order. A switch waits until `at` and for admitted old-page input and
640
664
  its native replies, keeping new old-page input queued through the cut. Reads and capture continue.
641
- 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
642
666
  the switch changes nothing and leaves the cue usable. A committed switch keeps ownership through
643
667
  outgoing capture cleanup, even if its caller is interrupted then.
644
668
 
@@ -699,20 +723,19 @@ Windows and a moment's frame captions use `hostTime`, so delayed delivery cannot
699
723
  page/session/connection/document/generation/sequence lineage, so an image copy can retain its
700
724
  capture evidence. Untagged pictures match only by object identity. Currency additionally requires
701
725
  an active capture and the page's current document.
702
- 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
703
727
  frame when it has the viewport's size and was painted at most `maxAge` ago, at the earliest its
704
728
  timing allows: 250 ms by default, while 0 always takes a new screenshot. With `after: "input"` the
705
729
  frame must also follow the page's latest submitted input, including input of an interrupted action,
706
- and the read waits for the action in flight: what a caller that has just acted needs.
707
- `Page.screenshot` always applies that rule, so a caller that acts and then looks sees what its
708
- action did; a deck or a narrator that wants a picture of a stated age reads `frame`, which a frame
709
- 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
710
733
  miss a final paint, so a frame is only ever as current as its age. No read reuses a frame painted
711
734
  before the page's current document began, when the page's own session saw its main frame commit
712
735
  it: a page that keeps painting while the next document loads would otherwise leave its own frames
713
736
  the newest when the navigation returns. Otherwise a new screenshot is
714
- taken, which `frame` returns as a `Screenshot`-timed frame. A screenshot, which the agent's
715
- 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
716
739
  final paint or later input never presents older paint as the page an action left.
717
740
 
718
741
  A new picture goes on the page's own protocol session. Where a device pixel is a CSS pixel and
@@ -738,7 +761,7 @@ and the clock probe runs in a world of its own.
738
761
  Every operation is recorded as an `Action`, also when its caller interrupts it. An element or point
739
762
  action records its `subject`, and a drag where it ended (`to`): the role, accessible name, tag and
740
763
  context of what it found, read when its target was resolved, before the pointer moved or any input
741
- 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
742
765
  reused by later outlines, so read `subject` rather than resolving `target` against a later snapshot.
743
766
 
744
767
  Every renderer reads the same host wall clock, so the browser keeps one clock mapping for all of its
@@ -761,7 +784,7 @@ was meant for; until then Chromium stamps them as it receives them, and input ne
761
784
  measurement. Shortcut chords retain Playwright's platform behavior, and Unicode insertion has no
762
785
  timestamp field.
763
786
 
764
- `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
765
788
  minute: received and accepted frames, missing timestamps, `late` frames (Chromium encodes several at
766
789
  once and finished these after a newer one; they are dropped, never reordered, and a busy machine
767
790
  makes more of them), frames dropped for their size (`foreignSize`) or for coming during one of the
@@ -795,7 +818,7 @@ capture keeps delivering, whatever else is attached; a capture starts once the b
795
818
  confirmed it, and fails with `Timeout` at the action timeout if a renderer stuck in a script never
796
819
  does.
797
820
  A provider that reaches its browser over a network can run captures on a connection of their own,
798
- 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
799
822
  frame never waits behind a large message on the connection that drives the page. Frames then carry
800
823
  the document their own connection saw commit, numbered as `Navigated` numbers them, and a failure
801
824
  of that connection ends the capture with `Failed` and leaves the page as it was.
@@ -804,7 +827,7 @@ joins whatever is running, and one whose explicit options differ fails with `Inv
804
827
  than silently receiving other frames. Each reader has a bounded 16-frame queue; a slow reader's
805
828
  observed sequence gaps add to `lost`. Late subscribers do not count earlier history.
806
829
  ACKs are independent of reader speed and bounded to 32 unresolved replies; exhaustion ends capture
807
- 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,
808
831
  5 seconds by default, a moment's default window. Capture stops when its last
809
832
  reader leaves; a stop whose reply is late is never resent, and the next capture waits for it (up
810
833
  to 2 s per attempt) rather than disabling capture for the page.
@@ -813,6 +836,7 @@ A page's `id` is its CDP target id. A new connection to the same browser, as aft
813
836
  finds each page under the id it had, with `browser.page(id)`; a stored id the browser no longer
814
837
  finds is a page that closed. `browser.pages` lists the open pages in the order the browser began
815
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.
816
840
 
817
841
  A page's life is told on the browser's timeline. `PageOpened`; `Navigated` for every move of its
818
842
  main frame, `sameDocument` for one within the document, such as `pushState`, with `document`
@@ -840,18 +864,21 @@ A failure on a page that is gone is `Closed` with its cause: `page`, `crashed`,
840
864
  `page`, or the `session` with its pages), and whether to `repeat` the call: `safe`, as nothing
841
865
  reached the browser; `check` its effect first, as it may have taken place; `pointless` as it is,
842
866
  such as with a stale ref; or `resume` reading events from a newer cursor. `message` is a sentence
843
- 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`.
844
870
 
845
- `Plan.take` checks an authored expected effect before input and after a dispatched failure.
846
- Unknown consequential input requires positive durable evidence before continuation; the Plan
847
- 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
848
874
  observation without deciding whether an action may be repeated:
849
875
 
876
+ <!-- prettier-ignore -->
850
877
  ```ts
851
- const observed = yield * page.until({ text: "Order 42" }, "some", 5000);
878
+ const observed = yield* Snapshot.until(page, { text: "Order 42" }, "some", "5 seconds");
852
879
  ```
853
880
 
854
- 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
855
882
  only as an observation baseline; an unmet or changed observation does not authorize repeating
856
883
  unknown consequential input.
857
884
 
@@ -894,8 +921,8 @@ events. Compositing remains the consumer’s job.
894
921
  A page waits only for itself. Its operations take turns in one lane of its own: an action, which
895
922
  sends input or navigates, has the page to itself in FIFO order once it asks for admission.
896
923
  Policy preparation reads the page first and a guard can wait outside that queue, so a later
897
- approved action may enter before an earlier held one. Reads (the outline, `find`, `text`, `changes`,
898
- 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
899
926
  describe the page those actions left. `ready` follows the action in flight too, and holds none back while it
900
927
  watches. An action then waits for its page's unresolved input replies. Its timeout bounds those
901
928
  waits before a full timeout bounds the action itself: a turn not given in time fails `Busy`, with
@@ -912,15 +939,15 @@ New and queued writes fail `Suspended`, with
912
939
  Already-held authority refuses input before invoking an input guard; a guard already waiting is
913
940
  checked again at admission. Reads, captures and events continue.
914
941
 
942
+ <!-- prettier-ignore -->
915
943
  ```ts
916
- yield *
917
- Effect.gen(function* () {
918
- const paused = yield* browser.suspend();
919
- // An event reader can resume from paused.since; paused.at is host monotonic time.
920
- const page = yield* browser.firstPage;
921
- yield* page.screenshot();
922
- yield* operatorDone;
923
- }).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);
924
951
  // Input resumes after this scope, provided no other suspension still holds it.
925
952
  ```
926
953
 
@@ -937,15 +964,15 @@ asked between them, joins it, and costs no call of its own. Each read runs in th
937
964
  the action timeout whoever gives up, so a caller's own `Effect.timeout` loses nothing: a read that
938
965
  ends after all its callers gave up serves the next caller to ask the same within 250 milliseconds
939
966
  of completion, unless an action or a new document came first. An action stops the reads nobody awaits rather than
940
- 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
941
968
  window of changes ends as it is read.
942
969
 
943
970
  `page.state` is what the library already knows of a page, at no call and with no wait for its
944
971
  turn: where its main frame is, its document and when it was committed, how far that document has
945
- loaded, its newest screencast frame, and the viewport's text and title as last read in that
946
- document, each with when it was learned, so a caller reads their ages. A caller that must never
947
- wait, such as one reading the screen on air, reads it rather than polling the page. Chromium
948
- 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.
949
976
 
950
977
  `Browser.Options.maxPages` bounds the pages a browser keeps open, those a site opened included,
951
978
  which are never refused: at the limit, `newPage` waits within the action timeout for one to close,
@@ -961,19 +988,19 @@ cancelled glide. A later viewport clamps the starting point to its bounds if nec
961
988
  A browser opened with `pageTime` can film a page frame by frame, each frame showing the page at its
962
989
  film time however long the last one took to picture. Each part is a module of its own:
963
990
 
964
- - `page.layout(picks)` reads where things are, as data: a box for each pick in the viewport and the
991
+ - `Layout.measure(page, picks)` reads where things are, as data: a box for each pick in the viewport and the
965
992
  document, the boxes of its words, and the viewport, scroll and scale, in one call.
966
993
  `Layout.rehearse` measures what exists only after an interaction, such as an open menu, and puts
967
994
  the page back.
968
- - `page.overlay` is a layer over the page for a scope that shows a caller's SVG. Screenshots and
969
- live views show it; `find`, `layout`, `changes`, `ready` and stillness never read it.
970
- - `page.hold` holds the page's timers, animation frames, clocks and animations for a scope.
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.
971
998
  `advance(by, { scroll, poses, overlay })` steps them and, in the same call, scrolls, poses and
972
999
  draws.
973
- - `page.poses` moves, turns and scales the page's own elements about a point, as data, through
1000
+ - `Pose.make(page)` moves, turns and scales the page's own elements about a point, as data, through
974
1001
  CSS `translate`, `rotate` and `scale`. Readers and clicks see a posed element where it is drawn,
975
1002
  and the change record does not report a pose. The scope's end takes every pose off.
976
- - `page.paint({ scale, scrollbars })` sets an attached browser's device pixels to each CSS pixel,
1003
+ - `Frame.paint(page, { scale, scrollbars })` sets an attached browser's device pixels to each CSS pixel,
977
1004
  and hides scrollbars from the next document on. `Chromium.layer` takes its `deviceScaleFactor`
978
1005
  at launch.
979
1006
  - `Film.frames(page, options)` is a stream of `Shot`s. At each film time it asks `at` for the
@@ -981,12 +1008,17 @@ film time however long the last one took to picture. Each part is a module of it
981
1008
  document that replaces the page is a `Passage`: the film holds its time while it loads, measures
982
1009
  its layout with the film's `picks`, and passes it to `at` from then on.
983
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
+
984
1016
  ```ts
985
1017
  const film = Effect.gen(function* () {
986
- const time = yield* page.hold;
987
- const overlay = yield* page.overlay;
1018
+ const time = yield* PageTime.hold(page);
1019
+ const overlay = yield* Overlay.make(page);
988
1020
 
989
- yield* page.poses;
1021
+ yield* Pose.make(page);
990
1022
 
991
1023
  return yield* Film.frames(page, {
992
1024
  times: { fps: 30, to: 8000 },
@@ -1005,9 +1037,9 @@ const film = Effect.gen(function* () {
1005
1037
  ```
1006
1038
 
1007
1039
  The frames are pictures; encoding them is the caller's. What an input changed is
1008
- `page.changes({ since })` read after it. Each `Change` has the `box` to frame it by, and `at`, on
1040
+ `Change.read(page, { since })` read after it. Each `Change` has the `box` to frame it by, and `at`, on
1009
1041
  the same clock as a `Shot`'s `at`, so on held time the first shot at or after it is the first to
1010
- show it. To lift an element off the page, take its picture with a clipped screenshot at
1042
+ show it. To lift an element off the page, take its picture with `Frame.zoom` at
1011
1043
  `scale: "device"`, then pose it to `sx: 0, sy: 0`, which hides it and leaves the page laid out as
1012
1044
  it was. `examples/film.ts` films a small site this way: a hover, a tab, a selected word, a copy,
1013
1045
  a search typed a key at a time, an eased scroll, a row selected by a drag and a link to the next
@@ -1050,29 +1082,30 @@ any globals the site's code patches.
1050
1082
 
1051
1083
  ## Supervising resource generations
1052
1084
 
1053
- `effect-browser/Supervisor` owns a scoped resource through acquisition failures, loss and rotation.
1054
- 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
1055
1087
  and returns `{ value, lost?, release? }`; `lost` produces a reason string, and `release(why)` reports
1056
- `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
1057
1089
  the generation's scope ends its resource.
1058
1090
 
1059
1091
  ```ts
1092
+ import { Chromium } from "@effect-browser/chromium";
1060
1093
  import { Effect } from "effect";
1061
- import * as Chromium from "effect-browser/Chromium";
1062
- import * as Supervisor from "effect-browser/Supervisor";
1094
+ import { Supervisor } from "effect-browser/supervisor";
1095
+ import * as Text from "effect-browser/Text";
1063
1096
 
1064
1097
  const program = Effect.gen(function* () {
1065
1098
  const sessions = yield* Supervisor.make({
1066
1099
  open: () =>
1067
1100
  Effect.gen(function* () {
1068
- const browser = yield* Chromium.open();
1101
+ const browser = yield* Chromium.make();
1069
1102
 
1070
1103
  return { value: browser, lost: browser.disconnected };
1071
1104
  }),
1072
1105
  });
1073
1106
 
1074
1107
  return yield* sessions.use(({ value: browser }) =>
1075
- Effect.flatMap(browser.firstPage, (page) => page.text()),
1108
+ Effect.flatMap(browser.firstPage, Text.read()),
1076
1109
  );
1077
1110
  }).pipe(Effect.scoped);
1078
1111
  ```
@@ -1112,6 +1145,148 @@ bundlers can preserve function names or minify the library without changing that
1112
1145
  The `@effect-browser/source` export condition is for this workspace's development tools; consumer
1113
1146
  bundles should use the default built exports, which also supply the Workers-specific packaging.
1114
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
+
1115
1290
  ## Tracing
1116
1291
 
1117
1292
  Operations are spans in Effect's tracer, so an application that installs an exporter sees them in
@@ -1144,15 +1319,16 @@ records except text: the target, the subject's role, name and tag, whether input
1144
1319
  `error.type`. A read that shared another's work says so in `shared`: `joined` or `kept`.
1145
1320
  `Page.prepare`, the policy's preparation, and `Page.guard`, which lasts as long as a hold and holds
1146
1321
  a judge's model call, are its children, as are pointer travel (`Page.move`) and the settle after input (`Page.settle`).
1147
- `Page.snapshot`, `Page.find`, `Page.text`, `Page.title`, `Page.viewport`,
1148
- `Page.screenshot` and `Page.frame` (with
1149
- `source`: a reused screencast `frame` or a new `screenshot`), `Page.zoom`, `Page.ready` and the
1150
- 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
1151
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`,
1152
1328
  `bytesOut` and `bytesIn` (their parameters and results as JSON) and `waitedMillis`, how long at
1153
1329
  least one call awaited its reply. An operation inside another counts toward both. Calls Playwright
1154
1330
  makes on its own sessions, such as navigation, are not counted. `Chromium.launch`, `Cdp.connect` and
1155
- `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,
1156
1332
  `Browserbase.release` a release and its outcome, and `Browserbase.holdContext` the wait for a
1157
1333
  stored context another session writes to. `Page.calibrateClock` maps the browser's clock onto the
1158
1334
  host's with three probes, each a `Page.evaluate` of `clock`, and records the fastest answered