effect-browser 0.2.0-beta.9 → 0.3.0-beta.11

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 (205) hide show
  1. package/README.md +861 -1161
  2. package/dist/Browser-B4qncxe7.mjs +628 -0
  3. package/dist/Browser-B4qncxe7.mjs.map +1 -0
  4. package/dist/Browser.d.mts +129 -3
  5. package/dist/Browser.mjs +2 -22
  6. package/dist/BrowserError-Coy7EW1N.d.mts +140 -0
  7. package/dist/BrowserError.d.mts +2 -0
  8. package/dist/BrowserError.mjs +211 -0
  9. package/dist/BrowserError.mjs.map +1 -0
  10. package/dist/BrowserEvent-BRu2juEz.d.mts +279 -0
  11. package/dist/BrowserEvent.d.mts +2 -0
  12. package/dist/BrowserEvent.mjs +297 -0
  13. package/dist/BrowserEvent.mjs.map +1 -0
  14. package/dist/Cdp.d.mts +32 -0
  15. package/dist/Cdp.mjs +61 -0
  16. package/dist/Cdp.mjs.map +1 -0
  17. package/dist/Change-DNvztNLu.mjs +138 -0
  18. package/dist/Change-DNvztNLu.mjs.map +1 -0
  19. package/dist/Change-iMlcuzVD.d.mts +71 -0
  20. package/dist/Change.d.mts +2 -0
  21. package/dist/Change.mjs +2 -0
  22. package/dist/Chromium.d.mts +29 -81
  23. package/dist/Chromium.mjs +57 -392
  24. package/dist/Chromium.mjs.map +1 -1
  25. package/dist/Expect.d.mts +62 -0
  26. package/dist/Expect.mjs +114 -0
  27. package/dist/Expect.mjs.map +1 -0
  28. package/dist/Frame-Di2PxyF7.d.mts +119 -0
  29. package/dist/Frame.d.mts +2 -0
  30. package/dist/Frame.mjs +125 -0
  31. package/dist/Frame.mjs.map +1 -0
  32. package/dist/Moment.d.mts +2 -0
  33. package/dist/Moment.mjs +288 -0
  34. package/dist/Moment.mjs.map +1 -0
  35. package/dist/Motion.d.mts +40 -0
  36. package/dist/Motion.mjs +122 -0
  37. package/dist/Motion.mjs.map +1 -0
  38. package/dist/Page-B5cjaUp5.mjs +618 -0
  39. package/dist/Page-B5cjaUp5.mjs.map +1 -0
  40. package/dist/Page-B7X6DQUn.d.mts +595 -0
  41. package/dist/Page.d.mts +2 -0
  42. package/dist/Page.mjs +2 -0
  43. package/dist/Plan-Akcac63g.d.mts +209 -0
  44. package/dist/Plan-D1wrJVs8.mjs +508 -0
  45. package/dist/Plan-D1wrJVs8.mjs.map +1 -0
  46. package/dist/Plan.d.mts +2 -3
  47. package/dist/Plan.mjs +2 -2
  48. package/dist/Policy.d.mts +76 -0
  49. package/dist/Policy.mjs +237 -0
  50. package/dist/Policy.mjs.map +1 -0
  51. package/dist/Presentation.d.mts +48 -0
  52. package/dist/Presentation.mjs +117 -0
  53. package/dist/Presentation.mjs.map +1 -0
  54. package/dist/Snapshot-B34hZ4Jl.d.mts +68 -0
  55. package/dist/Snapshot.d.mts +2 -0
  56. package/dist/Snapshot.mjs +79 -0
  57. package/dist/Snapshot.mjs.map +1 -0
  58. package/dist/Stage.d.mts +64 -0
  59. package/dist/Stage.mjs +237 -0
  60. package/dist/Stage.mjs.map +1 -0
  61. package/dist/Supervisor-CYWFK3vM.d.mts +280 -0
  62. package/dist/Supervisor-TNKNOVzu.mjs +599 -0
  63. package/dist/Supervisor-TNKNOVzu.mjs.map +1 -0
  64. package/dist/Supervisor.d.mts +2 -0
  65. package/dist/Supervisor.mjs +2 -0
  66. package/dist/context-B6xr8nVi.mjs +261 -0
  67. package/dist/context-B6xr8nVi.mjs.map +1 -0
  68. package/dist/index.d.mts +17 -14
  69. package/dist/index.mjs +18 -13
  70. package/dist/match.inpage-xOe9LNO0.mjs +48 -0
  71. package/dist/match.inpage-xOe9LNO0.mjs.map +1 -0
  72. package/dist/page-BAf__WKX.mjs +5075 -0
  73. package/dist/page-BAf__WKX.mjs.map +1 -0
  74. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  75. package/dist/url-Cd04Okid.mjs +264 -0
  76. package/dist/url-Cd04Okid.mjs.map +1 -0
  77. package/package.json +96 -61
  78. package/src/Browser.ts +672 -0
  79. package/src/BrowserError.ts +234 -0
  80. package/src/BrowserEvent.ts +296 -0
  81. package/src/Cdp.ts +101 -0
  82. package/src/Change.ts +88 -0
  83. package/src/Chromium.ts +102 -0
  84. package/src/Expect.ts +180 -0
  85. package/src/Frame.ts +132 -0
  86. package/src/Moment.ts +479 -0
  87. package/src/Motion.ts +166 -0
  88. package/src/Page.ts +522 -0
  89. package/src/Plan.ts +663 -0
  90. package/src/Policy.ts +325 -0
  91. package/src/Presentation.ts +195 -0
  92. package/src/Snapshot.ts +89 -0
  93. package/src/Stage.ts +467 -0
  94. package/src/Supervisor.ts +599 -0
  95. package/src/index.ts +20 -0
  96. package/src/internal/input/actions.ts +610 -0
  97. package/src/internal/input/dispatch.ts +161 -0
  98. package/src/internal/input/edit.inpage.ts +162 -0
  99. package/src/internal/input/evidence.inpage.ts +164 -0
  100. package/src/internal/input/gate.ts +224 -0
  101. package/src/internal/input/guard.inpage.ts +605 -0
  102. package/src/internal/input/guard.ts +184 -0
  103. package/src/internal/input/keyboard.ts +112 -0
  104. package/src/internal/input/keys.ts +127 -0
  105. package/src/internal/input/perform.ts +376 -0
  106. package/src/internal/input/pointer.ts +153 -0
  107. package/src/internal/input/replies.ts +195 -0
  108. package/src/internal/input/settle.ts +50 -0
  109. package/src/internal/input/style.ts +186 -0
  110. package/src/internal/input/targets.inpage.ts +293 -0
  111. package/src/internal/input/targets.ts +148 -0
  112. package/src/internal/page/bridge.ts +391 -0
  113. package/src/internal/page/context.ts +314 -0
  114. package/src/internal/page/identity.ts +35 -0
  115. package/src/internal/page/lane.ts +311 -0
  116. package/src/internal/page/navigation.ts +183 -0
  117. package/src/internal/page/openings.ts +87 -0
  118. package/src/internal/page/page.ts +165 -0
  119. package/src/internal/page/url.ts +100 -0
  120. package/src/internal/page/viewport.ts +43 -0
  121. package/src/internal/pictures/capture.ts +776 -0
  122. package/src/internal/pictures/clock.ts +141 -0
  123. package/src/internal/pictures/counts.ts +92 -0
  124. package/src/internal/pictures/pictures.ts +521 -0
  125. package/src/internal/pictures/transport.ts +243 -0
  126. package/src/internal/reading/choose.ts +100 -0
  127. package/src/internal/reading/context.inpage.ts +201 -0
  128. package/src/internal/reading/controls.inpage.ts +158 -0
  129. package/src/internal/reading/expect.inpage.ts +70 -0
  130. package/src/internal/reading/match.inpage.ts +92 -0
  131. package/src/internal/reading/names.inpage.ts +306 -0
  132. package/src/internal/reading/outline.inpage.ts +260 -0
  133. package/src/internal/reading/reading.ts +223 -0
  134. package/src/internal/reading/ready.inpage.ts +164 -0
  135. package/src/internal/reading/ready.ts +111 -0
  136. package/src/internal/reading/subjects.inpage.ts +188 -0
  137. package/src/internal/reading/text.inpage.ts +135 -0
  138. package/src/internal/reading/walk.inpage.ts +220 -0
  139. package/src/internal/supervisor/lifecycle.ts +416 -0
  140. package/src/internal/timeline/changes.inpage.ts +216 -0
  141. package/src/internal/timeline/changes.ts +100 -0
  142. package/src/internal/timeline/events.ts +94 -0
  143. package/src/internal/timeline/fold.inpage.ts +123 -0
  144. package/src/internal/timeline/history.inpage.ts +229 -0
  145. package/src/internal/timeline/marks.inpage.ts +207 -0
  146. package/src/internal/timeline/record.inpage.ts +133 -0
  147. package/src/internal/timeline/sight.inpage.ts +122 -0
  148. package/src/internal/timeline/window.ts +96 -0
  149. package/src/internal/timeline/words.ts +65 -0
  150. package/dist/Bootstrap-B9UUXsvF.d.mts +0 -183
  151. package/dist/Bootstrap-CeQOWBy6.mjs +0 -189
  152. package/dist/Bootstrap-CeQOWBy6.mjs.map +0 -1
  153. package/dist/Bootstrap.d.mts +0 -3
  154. package/dist/Bootstrap.mjs +0 -2
  155. package/dist/Browser-BF9_sORP.d.mts +0 -388
  156. package/dist/Browser.mjs.map +0 -1
  157. package/dist/BrowserData-CPIIIHol.d.mts +0 -585
  158. package/dist/BrowserData.d.mts +0 -3
  159. package/dist/BrowserData.mjs +0 -695
  160. package/dist/BrowserData.mjs.map +0 -1
  161. package/dist/BrowserRuntime-B6nT1G4X.d.mts +0 -148
  162. package/dist/BrowserRuntime-C1r2aSRK.mjs +0 -6820
  163. package/dist/BrowserRuntime-C1r2aSRK.mjs.map +0 -1
  164. package/dist/BrowserRuntime.d.mts +0 -3
  165. package/dist/BrowserRuntime.mjs +0 -3
  166. package/dist/Capture.d.mts +0 -56
  167. package/dist/Capture.mjs +0 -678
  168. package/dist/Capture.mjs.map +0 -1
  169. package/dist/CaptureData-CYriZHX1.mjs +0 -201
  170. package/dist/CaptureData-CYriZHX1.mjs.map +0 -1
  171. package/dist/CaptureData.d.mts +0 -219
  172. package/dist/CaptureData.mjs +0 -2
  173. package/dist/Errors.d.mts +0 -158
  174. package/dist/Errors.mjs +0 -207
  175. package/dist/Errors.mjs.map +0 -1
  176. package/dist/Images-yCG9BmRU.mjs +0 -76
  177. package/dist/Images-yCG9BmRU.mjs.map +0 -1
  178. package/dist/OperationOptions-DAeRS6O9.mjs +0 -55
  179. package/dist/OperationOptions-DAeRS6O9.mjs.map +0 -1
  180. package/dist/PageControl.d.mts +0 -15
  181. package/dist/PageControl.mjs +0 -34
  182. package/dist/PageControl.mjs.map +0 -1
  183. package/dist/PageRegistry-B3q9DS3g.mjs +0 -164
  184. package/dist/PageRegistry-B3q9DS3g.mjs.map +0 -1
  185. package/dist/Plan-Dyxu2q8C.mjs +0 -543
  186. package/dist/Plan-Dyxu2q8C.mjs.map +0 -1
  187. package/dist/PlanData-B668RxbQ.d.mts +0 -4831
  188. package/dist/PlanData.d.mts +0 -3
  189. package/dist/PlanData.mjs +0 -268
  190. package/dist/PlanData.mjs.map +0 -1
  191. package/dist/PlanInput-BJcPPncs.mjs +0 -75
  192. package/dist/PlanInput-BJcPPncs.mjs.map +0 -1
  193. package/dist/PublicSession-DCSMMqOj.mjs +0 -5602
  194. package/dist/PublicSession-DCSMMqOj.mjs.map +0 -1
  195. package/dist/Testing.d.mts +0 -479
  196. package/dist/Testing.mjs +0 -2147
  197. package/dist/Testing.mjs.map +0 -1
  198. package/dist/Timeline-fV22Xk-S.d.mts +0 -29
  199. package/dist/Timeline.d.mts +0 -4
  200. package/dist/Timeline.mjs +0 -20
  201. package/dist/Timeline.mjs.map +0 -1
  202. package/dist/TimelineData-BsOn-YGZ.d.mts +0 -3818
  203. package/dist/TimelineData.d.mts +0 -3
  204. package/dist/TimelineData.mjs +0 -482
  205. package/dist/TimelineData.mjs.map +0 -1
@@ -0,0 +1,595 @@
1
+ import { p as PolicyDenied, t as BrowserError } from "./BrowserError-Coy7EW1N.mjs";
2
+ import { E as WheelScrolled, S as TextInserted, T as TrackPlanned, _ as PointerReleased, b as Subject, d as Navigated, f as PageClosed, g as PointerPressed, h as PageUntracked, i as BrowserEvent, l as Disconnected, m as PageOpened, o as CursorChanged, p as PageLoaded, s as DialogShown, t as Action, u as KeyChanged, w as TrackPerformed, y as SessionEnding } from "./BrowserEvent-BRu2juEz.mjs";
3
+ import { r as Changes, t as Change } from "./Change-iMlcuzVD.mjs";
4
+ import { a as Image, n as CaptureStats, o as ScreencastOptions, r as Frame } from "./Frame-Di2PxyF7.mjs";
5
+ import { n as Snapshot, r as SnapshotOptions } from "./Snapshot-B34hZ4Jl.mjs";
6
+ import { Duration, Effect, Schema, Stream } from "effect";
7
+ import { Prompt } from "effect/ai";
8
+ import { Page } from "playwright-core";
9
+ declare namespace Moment_d_exports {
10
+ export { Account, CaptureOptions, Moment, Window, account, capture, toPrompt };
11
+ }
12
+ declare const Window_base: Schema.Class<Window, Schema.Struct<{
13
+ readonly page: Schema.String;
14
+ /** Where the window starts, in host monotonic milliseconds on the owning browser’s clock. */
15
+ readonly since: Schema.Finite;
16
+ /** Where it ends, never after it was taken. */
17
+ readonly until: Schema.Finite;
18
+ /** The page's events after `since`, up to `until`, oldest first, without the input presentation track. */
19
+ readonly events: Schema.$Array<Schema.Union<readonly [typeof PageOpened, typeof PageClosed, typeof PageUntracked, typeof Navigated, typeof PageLoaded, typeof Action, typeof TrackPlanned, typeof TrackPerformed, typeof PointerPressed, typeof PointerReleased, typeof WheelScrolled, typeof KeyChanged, typeof TextInserted, typeof CursorChanged, typeof DialogShown, typeof Disconnected, typeof SessionEnding]>>;
20
+ /**
21
+ * What visibly changed after `since`, up to `until`; absent where `missing` says why. A page's
22
+ * first window starts its record, so the record sees none of it.
23
+ */
24
+ readonly changes: Schema.optional<typeof Changes>;
25
+ /** Screencast frames painted from `since` to `until`, oldest first, as far back as kept. */
26
+ readonly frames: Schema.$Array<typeof Frame>;
27
+ /**
28
+ * Why each part that could not be read is missing: the read of its changes, by whatever
29
+ * operation failed there, or a moment's picture (`frame`) or outline (`snapshot`).
30
+ */
31
+ readonly missing: Schema.$Array<typeof BrowserError>;
32
+ }>, {}>;
33
+ /** A page's events, changes and frames over one window of its browser's host clock. */
34
+ declare class Window extends Window_base {}
35
+ declare const Moment_base: Schema.Class<Moment, Schema.Struct<{
36
+ readonly page: Schema.String;
37
+ readonly since: Schema.Finite;
38
+ readonly until: Schema.Finite;
39
+ readonly events: Schema.$Array<Schema.Union<readonly [typeof PageOpened, typeof PageClosed, typeof PageUntracked, typeof Navigated, typeof PageLoaded, typeof Action, typeof TrackPlanned, typeof TrackPerformed, typeof PointerPressed, typeof PointerReleased, typeof WheelScrolled, typeof KeyChanged, typeof TextInserted, typeof CursorChanged, typeof DialogShown, typeof Disconnected, typeof SessionEnding]>>;
40
+ readonly changes: Schema.optional<typeof Changes>;
41
+ readonly frames: Schema.$Array<typeof Frame>;
42
+ readonly missing: Schema.$Array<typeof BrowserError>;
43
+ snapshot: Schema.optional<typeof Snapshot>;
44
+ }>, Window> & Pick<{}, never>;
45
+ /**
46
+ * A window that ends at a picture of the page, its last frame, unless `missing` says why it has
47
+ * none. Its frames are a few, spread over the window, so that it still begins where it starts.
48
+ */
49
+ declare class Moment extends Moment_base {}
50
+ interface CaptureOptions {
51
+ /**
52
+ * Where the window starts, as for `Page.window`: a previous window or moment, so that consecutive
53
+ * ones neither repeat nor miss an event or a change, or a `Duration` back from the picture.
54
+ * Defaults to 5 seconds.
55
+ */
56
+ readonly since?: WindowOptions["since"] | undefined;
57
+ /** Frames to keep, at least 1, spread over the window and ending with the picture. Defaults to 2. */
58
+ readonly frames?: number | undefined;
59
+ /**
60
+ * Whether to take the page's outline at the end, or its options; `true` means 4,000 characters.
61
+ * Defaults to `false`: the frames and the timeline carry most moments, while an outline costs a
62
+ * round trip to the page and can double a moment's tokens.
63
+ */
64
+ readonly snapshot?: SnapshotOptions | boolean | undefined;
65
+ /** Show what fields hold in the moment's changes; a secret field still reads `••••`. */
66
+ readonly unmask?: boolean | undefined;
67
+ }
68
+ declare const capture: (page: Page$1, options?: CaptureOptions | undefined) => Effect.Effect<Moment, BrowserError, never>;
69
+ /** What a window says of its page at its end: what was still in flux, and what had settled. */
70
+ interface Account {
71
+ /**
72
+ * How long, in milliseconds, the page had been still at the end: since the last change in view
73
+ * its record shows, or the last paint its screencast frames show, or else since the window, or
74
+ * its record, began. Undefined where neither could tell, with no record of the window and no
75
+ * painted frame: a screenshot shows the page, not when it last changed. Frames show paint only
76
+ * while a capture runs, and the record does not see a canvas, so a canvas that keeps drawing
77
+ * with no capture running reads as still.
78
+ */
79
+ readonly stillFor: number | undefined;
80
+ /**
81
+ * The changes still under way at the end: what kept changing, more than once in the window or
82
+ * already before it, and changed again within twice its own pace before the end.
83
+ */
84
+ readonly changing: ReadonlyArray<Change>;
85
+ /** Every other change, which shows what it settled at. */
86
+ readonly settled: ReadonlyArray<Change>;
87
+ }
88
+ /**
89
+ * An account of the window's page at its end: how long it had been still, and which of its
90
+ * changes were still under way and which had settled. A window whose record saw none of it has
91
+ * neither.
92
+ */
93
+ declare const account: (window: Window) => Account;
94
+ /**
95
+ * The moment as one user message: the page's outline when the moment has one, what changed, most
96
+ * notable first, what kept changing told as still changing at the moment or settled since when, by
97
+ * its account, with the actions that the changes followed, that changes followed though none
98
+ * names them, or that drew what only the screenshots show, what could not be read and why, and its
99
+ * frames captioned with their times, the last one "the moment" where it is the picture at its end.
100
+ * Give a model its task with `Prompt.setSystem`, and add what the caller knows about the page as
101
+ * more text.
102
+ */
103
+ declare const toPrompt: (moment: Moment) => Prompt.Prompt;
104
+ declare namespace Page_d_exports {
105
+ export { ChangesOptions, ClickOptions, ElementState, Fact, FindQuery, Found, FrameOptions, InputGuard, InputRequest, Page$1 as Page, Point, PressOptions, ReadyOptions, Region, ResolvedTarget, ScreenshotOptions, ScrollOptions, State, Target, Text, TextOptions, TypeOptions, WaitCondition, WindowOptions, Zoom, correlate, failFast, redacted };
106
+ }
107
+ interface Point {
108
+ readonly x: number;
109
+ readonly y: number;
110
+ }
111
+ /** A ref from a snapshot, such as `"e12"`, or a viewport point. */
112
+ type Target = string | Point;
113
+ declare const Region_base: Schema.Class<Region, Schema.Struct<{
114
+ readonly x: Schema.Int;
115
+ readonly y: Schema.Int;
116
+ readonly width: Schema.Int;
117
+ readonly height: Schema.Int;
118
+ }>, {}>;
119
+ /** An integer rectangle in viewport CSS pixels. */
120
+ declare class Region extends Region_base {}
121
+ declare const Zoom_base: Schema.Class<Zoom, Schema.Struct<{
122
+ readonly page: Schema.String;
123
+ readonly region: typeof Region;
124
+ readonly image: typeof Image;
125
+ }>, {}>;
126
+ /** A crop and its viewport origin: add that origin to a point read from the crop. */
127
+ declare class Zoom extends Zoom_base {}
128
+ declare const ResolvedTarget_base: Schema.Class<ResolvedTarget, Schema.Struct<{
129
+ readonly point: Schema.Struct<{
130
+ readonly x: Schema.Finite;
131
+ readonly y: Schema.Finite;
132
+ }>;
133
+ readonly element: Schema.String;
134
+ /** The element's lowercase tag name. */
135
+ readonly tag: Schema.String;
136
+ readonly role: Schema.NullOr<Schema.String>;
137
+ readonly name: Schema.String;
138
+ readonly context: Schema.Struct<{
139
+ readonly row: Schema.optional<Schema.String>;
140
+ readonly column: Schema.optional<Schema.String>;
141
+ readonly label: Schema.optional<Schema.String>;
142
+ readonly heading: Schema.optional<Schema.String>;
143
+ }>;
144
+ /** For a point target, the box of what it found there. */
145
+ readonly box: Schema.optional<Schema.Struct<{
146
+ readonly x: Schema.Finite;
147
+ readonly y: Schema.Finite;
148
+ readonly width: Schema.Finite;
149
+ readonly height: Schema.Finite;
150
+ }>>;
151
+ readonly cursor: Schema.String;
152
+ readonly href: Schema.optional<Schema.String>;
153
+ }>, {}>;
154
+ /** The target as it read before input. Point coordinates are never snapped to another position. */
155
+ declare class ResolvedTarget extends ResolvedTarget_base {}
156
+ interface ClickOptions {
157
+ readonly button?: "left" | "right" | "middle" | undefined;
158
+ /** 2 for a double click. */
159
+ readonly clickCount?: number | undefined;
160
+ /** Hold the button down this long before releasing it. */
161
+ readonly holdMillis?: number | undefined;
162
+ }
163
+ interface TypeOptions {
164
+ /** Type into this text field: it is focused first, and its content replaced unless `replace` is false. */
165
+ readonly into?: string | undefined;
166
+ readonly replace?: boolean | undefined;
167
+ /** Press Enter afterwards. */
168
+ readonly submit?: boolean | undefined;
169
+ /**
170
+ * The text is a secret: type it only into a field the page marks secret, such as a password,
171
+ * and otherwise refuse with `NotActionable` before any input. A replayed password asks this.
172
+ */
173
+ readonly secret?: boolean | undefined;
174
+ }
175
+ interface PressOptions {
176
+ /**
177
+ * Focus this element, by ref, before the first press: a link, a button or a field. The keys go to
178
+ * whatever has focus otherwise.
179
+ */
180
+ readonly on?: string | undefined;
181
+ /** Press the keys this many times. */
182
+ readonly times?: number | undefined;
183
+ /** Hold the keys down this long before releasing them, as a game control might need. */
184
+ readonly holdMillis?: number | undefined;
185
+ }
186
+ interface ScrollOptions {
187
+ readonly dx?: number | undefined;
188
+ /** Pixels to scroll down; negative scrolls up. Defaults to most of a viewport. */
189
+ readonly dy?: number | undefined;
190
+ /** Scroll whatever is under this point or element. Defaults to the middle of the viewport. */
191
+ readonly at?: Target | undefined;
192
+ }
193
+ /**
194
+ * How current a picture must be. The newest screencast frame serves when it qualifies, at no cost;
195
+ * otherwise a new screenshot is taken.
196
+ */
197
+ interface FrameOptions {
198
+ /**
199
+ * The oldest a reused frame may be, from its paint, at the earliest its timing allows, to now.
200
+ * Defaults to 250 milliseconds; 0 always takes a new screenshot.
201
+ */
202
+ readonly maxAge?: Duration.Input | undefined;
203
+ /**
204
+ * `"input"`: reuse only a frame painted after this page's latest input, including input of an
205
+ * interrupted action, and never while an action is changing the page. For a caller that has
206
+ * just acted on the page.
207
+ */
208
+ readonly after?: "input" | undefined;
209
+ }
210
+ /** A screenshot reuses only a frame painted after the page's latest input, as `after: "input"`. */
211
+ interface ScreenshotOptions {
212
+ /** The oldest a reused frame may be, as for `frame`. Defaults to 250 milliseconds. */
213
+ readonly maxAge?: Duration.Input | undefined;
214
+ /** A region of the viewport, captured in CSS pixels at the viewport's own scale; always new. */
215
+ readonly clip?: {
216
+ readonly x: number;
217
+ readonly y: number;
218
+ readonly width: number;
219
+ readonly height: number;
220
+ } | undefined;
221
+ /** JPEG quality, 0 to 100. Defaults to 80. */
222
+ readonly quality?: number | undefined;
223
+ /** `"jpeg"`, the default, or `"png"`, which is always a new picture. */
224
+ readonly format?: "jpeg" | "png" | undefined;
225
+ }
226
+ /**
227
+ * What `find` looks for. Every rule given must hold; with none, it finds every element in scope
228
+ * that has a role or is a control.
229
+ */
230
+ interface FindQuery {
231
+ /** An ARIA role, such as `"button"` or `"heading"`, ignoring case. */
232
+ readonly role?: string | undefined;
233
+ /**
234
+ * The accessible name: a string that reads the same once spaces are collapsed and case folded,
235
+ * or a pattern found in it.
236
+ */
237
+ readonly name?: string | RegExp | undefined;
238
+ /**
239
+ * Text it shows, ignoring case and spacing, or a pattern. Text inside a control or a heading is
240
+ * that control's or heading's, and only the smallest element showing it matches, not every
241
+ * element around it.
242
+ */
243
+ readonly text?: string | RegExp | undefined;
244
+ /** Whole words in its context (row, column, label or heading), ignoring case and spacing. */
245
+ readonly near?: string | undefined;
246
+ /** Only what a point action at this viewport point would reach: the control there, or else what is painted there. */
247
+ readonly at?: Point | undefined;
248
+ /** The viewport (the default), or the whole document. */
249
+ readonly scope?: "viewport" | "document" | undefined;
250
+ }
251
+ /**
252
+ * An element's state as its markup gives it: `checked` for what can be checked, `expanded`,
253
+ * `selected` and `pressed` where the page says either way, and `level` for headings.
254
+ */
255
+ declare const ElementState: Schema.Struct<{
256
+ readonly disabled: Schema.Boolean;
257
+ readonly focused: Schema.Boolean;
258
+ readonly checked: Schema.optional<Schema.Boolean>;
259
+ readonly expanded: Schema.optional<Schema.Boolean>;
260
+ readonly selected: Schema.optional<Schema.Boolean>;
261
+ readonly pressed: Schema.optional<Schema.Boolean>;
262
+ readonly level: Schema.optional<Schema.Int>;
263
+ }>;
264
+ type ElementState = typeof ElementState.Type;
265
+ declare const Found_base: Schema.Class<Found, Schema.Struct<{
266
+ readonly ref: Schema.String;
267
+ readonly subject: typeof Subject;
268
+ /** Its box, rounded. Reading the document, it may be out of view. */
269
+ readonly box: Schema.Struct<{
270
+ readonly x: Schema.Finite;
271
+ readonly y: Schema.Finite;
272
+ readonly width: Schema.Finite;
273
+ readonly height: Schema.Finite;
274
+ }>;
275
+ readonly inViewport: Schema.Boolean;
276
+ readonly state: Schema.Struct<{
277
+ readonly disabled: Schema.Boolean;
278
+ readonly focused: Schema.Boolean;
279
+ readonly checked: Schema.optional<Schema.Boolean>;
280
+ readonly expanded: Schema.optional<Schema.Boolean>;
281
+ readonly selected: Schema.optional<Schema.Boolean>;
282
+ readonly pressed: Schema.optional<Schema.Boolean>;
283
+ readonly level: Schema.optional<Schema.Int>;
284
+ }>;
285
+ }>, {}>;
286
+ /** An element `find` found: a ref for the actions, what it is, where it is and its state. */
287
+ declare class Found extends Found_base {}
288
+ interface TextOptions {
289
+ /** `"viewport"` (the default) reads what the viewport shows; a ref reads that element whole. */
290
+ readonly scope?: string | undefined;
291
+ /** Bound on the text's length, cut at a line. Defaults to 12,000 characters. */
292
+ readonly maxChars?: number | undefined;
293
+ /** Show what fields hold; a secret field still reads `••••`. Defaults to false. */
294
+ readonly unmask?: boolean | undefined;
295
+ }
296
+ declare const Text_base: Schema.Class<Text, Schema.Struct<{
297
+ readonly url: Schema.String;
298
+ readonly title: Schema.String;
299
+ readonly text: Schema.String;
300
+ /** True when `text` was cut at `maxChars`. */
301
+ readonly truncated: Schema.Boolean;
302
+ /** Host monotonic milliseconds from the browser's captured Effect Clock. */
303
+ readonly at: Schema.Finite;
304
+ }>, {}>;
305
+ /** What a page showed as text: a line per block, with table cells apart by tabs. */
306
+ declare class Text extends Text_base {}
307
+ /** What `waitFor` waits for. */
308
+ interface WaitCondition {
309
+ /** A CSS selector for what to watch; the document's body without one. */
310
+ readonly selector?: string | undefined;
311
+ /**
312
+ * `"visible"` (the default): something it matches shows; `"hidden"`: nothing it matches shows;
313
+ * `"enabled"`: something it matches shows and is not disabled.
314
+ */
315
+ readonly state?: "visible" | "hidden" | "enabled" | undefined;
316
+ /** Only what shows this text counts, case and all, with runs of spaces read as one. */
317
+ readonly text?: string | undefined;
318
+ }
319
+ interface ReadyOptions {
320
+ /** What must stay still during quietMillis: screen paint (default), or recorded content. */
321
+ readonly still?: "screen" | "content" | undefined;
322
+ /** How long the selected evidence must stay still; screen paint by default. */
323
+ readonly quietMillis?: number | undefined;
324
+ readonly timeout?: Duration.Input | undefined;
325
+ }
326
+ /** The window `changes` reads, and whether to show what fields hold. */
327
+ interface ChangesOptions {
328
+ /**
329
+ * Where the window starts: the changes a previous read returned, to continue exactly where they
330
+ * ended; a frame, at its paint; or host monotonic milliseconds, which mapped to the page's clock
331
+ * may miss or repeat changes near the start if the browser's clock mapping changed since. Defaults
332
+ * to the start of the record.
333
+ */
334
+ readonly since?: Changes | Frame | number | undefined;
335
+ /**
336
+ * Where it ends: a frame, at its paint, so a delayed frame's window holds nothing it does not
337
+ * show; or host monotonic milliseconds. Defaults to now, and is never later.
338
+ */
339
+ readonly until?: Frame | number | undefined;
340
+ /** Show what fields hold; a secret field still reads `••••`. Defaults to false. */
341
+ readonly unmask?: boolean | undefined;
342
+ }
343
+ /** The window `window` reads, and whether to show what fields hold. */
344
+ interface WindowOptions {
345
+ /**
346
+ * Where the window starts: a previous window, to continue exactly where it ended; a frame, at its
347
+ * paint; host monotonic milliseconds; or a `Duration` back from `until`. A start after `until`
348
+ * leaves the window empty there.
349
+ */
350
+ readonly since: Window | Frame | Duration.Duration | number;
351
+ /**
352
+ * Where it ends: a frame, at its paint, such as one a delayed consumer airs now; or host
353
+ * monotonic milliseconds. Defaults to now, and is never later.
354
+ */
355
+ readonly until?: Frame | number | undefined;
356
+ /** Show what fields hold in its changes; a secret field still reads `••••`. Defaults to false. */
357
+ readonly unmask?: boolean | undefined;
358
+ }
359
+ declare const State_base: Schema.Class<State, Schema.Struct<{
360
+ readonly page: Schema.String;
361
+ /** When this was taken. */
362
+ readonly at: Schema.Finite;
363
+ /** Where the main frame last committed or moved, without userinfo or known secret parameters. */
364
+ readonly url: Schema.String;
365
+ /** The page's document, as `Navigated` counts them. */
366
+ readonly document: Schema.Int;
367
+ /** When the main frame committed it; absent for the one the browser began tracking it with. */
368
+ readonly committedAt: Schema.optional<Schema.Finite>;
369
+ /** How far that document has loaded, as the page's own session heard; absent until parsed. */
370
+ readonly load: Schema.optional<typeof PageLoaded>;
371
+ /** The newest screencast frame, of whichever document it names. */
372
+ readonly frame: Schema.optional<typeof Frame>;
373
+ /** The viewport's text as it was last read, with the page's title then. */
374
+ readonly text: Schema.optional<typeof Text>;
375
+ }>, {}>;
376
+ /**
377
+ * What the library knows of a page now, without asking it, each part with when it learned it, in
378
+ * host monotonic milliseconds: a part's age is `at` less its time. Text read before the current
379
+ * document began is left out, since it tells of a document that has gone.
380
+ */
381
+ declare class State extends State_base {}
382
+ /**
383
+ * What the page's structure establishes about an input, or says it cannot establish:
384
+ *
385
+ * - `form-submit`: it submits a form, which sends the form's fields.
386
+ * - `cross-origin`: it navigates or submits to another origin.
387
+ * - `download`: it follows a download link.
388
+ * - `upload`: it opens a file chooser.
389
+ * - `secret`: it types, with `type`, into a field marked as a password, a one-time code or a
390
+ * card's number, code or expiry, or submits a form holding a filled one.
391
+ * - `scripted`: it activates something the browser gives no effect of its own, such as a
392
+ * `type="button"` button, a `role="button"` element or a canvas, so only the page's script
393
+ * decides what happens.
394
+ * - `opaque`: nothing names what receives it: a canvas, a frame or an unnamed element.
395
+ *
396
+ * Facts never come from what an element's text says. What an input means, such as a payment
397
+ * or a deletion, takes a judge that reads the evidence in the {@link InputRequest}.
398
+ */
399
+ declare const Fact: Schema.Literals<readonly ["form-submit", "cross-origin", "download", "upload", "secret", "scripted", "opaque"]>;
400
+ type Fact = typeof Fact.Type;
401
+ declare const InputRequest_base: Schema.Class<InputRequest, Schema.Struct<{
402
+ readonly page: Schema.String;
403
+ /**
404
+ * The page's URL, without a fragment that only names a place on the page. This and the other
405
+ * addresses keep no userinfo or known secret parameters.
406
+ */
407
+ readonly url: Schema.String;
408
+ /** The page's title, at most 120 characters. */
409
+ readonly title: Schema.String;
410
+ readonly action: Schema.String;
411
+ readonly target: Schema.optional<Schema.String>;
412
+ readonly element: Schema.optional<Schema.String>;
413
+ /** Literal pixel targets only; ref coordinates are resolved after the policy allows them. */
414
+ readonly point: Schema.optional<Schema.Struct<{
415
+ readonly x: Schema.Finite;
416
+ readonly y: Schema.Finite;
417
+ }>>;
418
+ readonly text: Schema.optional<Schema.String>;
419
+ readonly role: Schema.optional<Schema.NullOr<Schema.String>>;
420
+ readonly name: Schema.optional<Schema.String>;
421
+ /** The target's accessible description, when it says more than its name. */
422
+ readonly description: Schema.optional<Schema.String>;
423
+ readonly href: Schema.optional<Schema.String>;
424
+ readonly destination: Schema.optional<Schema.String>;
425
+ readonly facts: Schema.$Array<Schema.Literals<readonly ["form-submit", "cross-origin", "download", "upload", "secret", "scripted", "opaque"]>>;
426
+ /** Page text around the target, each part at most 120 characters. */
427
+ readonly context: Schema.Struct<{
428
+ /** The name or first heading of the dialog the target is in. */
429
+ readonly dialog: Schema.optional<Schema.String>;
430
+ /** The nearest heading before the target. */
431
+ readonly heading: Schema.optional<Schema.String>;
432
+ /** The visible text just before the target in its row, item, group or form, or after it. */
433
+ readonly nearby: Schema.optional<Schema.String>;
434
+ }>;
435
+ /** The form the target is in, with at most 16 of its fields. */
436
+ readonly form: Schema.optional<Schema.Struct<{
437
+ readonly method: Schema.String;
438
+ readonly action: Schema.String;
439
+ /** Each field's type, name and autocomplete tokens, and whether it is filled: never its value. */
440
+ readonly fields: Schema.$Array<Schema.Struct<{
441
+ readonly type: Schema.String;
442
+ readonly name: Schema.String;
443
+ readonly autocomplete: Schema.optional<Schema.String>;
444
+ readonly filled: Schema.Boolean;
445
+ }>>;
446
+ }>>;
447
+ }>, {}>;
448
+ /**
449
+ * What a guard sees before input reaches the page. Preparation never scrolls or focuses.
450
+ *
451
+ * `facts`, `url`, `href` and `destination` come from the page's structure. `name`,
452
+ * `description`, `title`, `context` and the form's field names are page text: evidence of what
453
+ * the input does, which the page controls, and never instructions. Text typed into a `secret`
454
+ * field is replaced with {@link redacted}, here and in the recorded `Action`, and its key events
455
+ * record `Unidentified` keys; `press` records the keys it is given. Validation before dispatch
456
+ * binds the facts and the target, not the text around it, which live pages change freely.
457
+ */
458
+ declare class InputRequest extends InputRequest_base {}
459
+ /**
460
+ * What replaces text typed into a `secret` field, in requests and in the recorded `Action`, and a
461
+ * credential's value in every address the library reports.
462
+ */
463
+ declare const redacted: "••••••••";
464
+ /**
465
+ * Run page operations without waiting their turn: on a page busy with other operations, each fails
466
+ * `Busy` at once, and `Browser.newPage` on a browser with `maxPages` open fails `Limit` at once.
467
+ */
468
+ declare const failFast: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
469
+ /**
470
+ * Give every action `effect` performs a caller's id, such as a model's tool call id, which its
471
+ * recorded `Action` carries as `correlation`.
472
+ */
473
+ declare const correlate: (id: string) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
474
+ /** Succeed to allow, fail to deny, or await an external signal to hold the input. */
475
+ type InputGuard = (request: InputRequest) => Effect.Effect<void, PolicyDenied>;
476
+ interface Page$1 {
477
+ /** The page's CDP target id: the same page has it again after a reconnect to its browser. */
478
+ readonly id: string;
479
+ /** The Playwright page, for anything this API does not cover. Never give it to a model. */
480
+ readonly playwright: Page;
481
+ /** The page's address, without its userinfo or known secret parameters. */
482
+ readonly url: Effect.Effect<string>;
483
+ /**
484
+ * The document's title as the page last set it, empty for an untitled page. The browser answers
485
+ * it, in one call, so a page busy with a script cannot hold it up.
486
+ */
487
+ readonly title: Effect.Effect<string, BrowserError>;
488
+ readonly goto: (url: string) => Effect.Effect<void, BrowserError>;
489
+ /** The previous history entry, including one only a frame created; `NotFound` when none. */
490
+ readonly back: Effect.Effect<void, BrowserError>;
491
+ readonly reload: Effect.Effect<void, BrowserError>;
492
+ /** Make this the visible tab. Background tabs paint rarely and send few screencast frames. */
493
+ readonly bringToFront: Effect.Effect<void, BrowserError>;
494
+ /** Close the tab, succeeding once it has closed, or at once when it already had. */
495
+ readonly close: Effect.Effect<void, BrowserError>;
496
+ readonly snapshot: (options?: SnapshotOptions) => Effect.Effect<Snapshot, BrowserError>;
497
+ /**
498
+ * A picture of the viewport, in CSS pixels: a screencast frame painted since the page's latest
499
+ * input, if one qualifies, or a new one. A caller that has just acted sees what its action did.
500
+ */
501
+ readonly screenshot: (options?: ScreenshotOptions) => Effect.Effect<Image, BrowserError>;
502
+ /**
503
+ * The viewport with its timing: the newest screencast frame if it qualifies, else a new
504
+ * screenshot timed by the host interval in which it was taken.
505
+ */
506
+ readonly frame: (options?: FrameOptions) => Effect.Effect<Frame, BrowserError>;
507
+ /** A crop in CSS pixels, unmagnified, with the origin that keeps later input in viewport pixels. */
508
+ readonly zoom: (region: Region) => Effect.Effect<Zoom, BrowserError>;
509
+ /**
510
+ * The viewport's size in CSS pixels, the space of points, crops and page scrolls. Over CDP the
511
+ * page reports it, within the action timeout.
512
+ */
513
+ readonly viewport: Effect.Effect<{
514
+ readonly width: number;
515
+ readonly height: number;
516
+ }, BrowserError>;
517
+ /**
518
+ * The elements that match a query, in tree order, with refs the actions take, in one call to the
519
+ * page. All that match are returned, so a caller tells them apart by their context; none is an
520
+ * empty result, not a failure.
521
+ */
522
+ readonly find: (query?: FindQuery) => Effect.Effect<ReadonlyArray<Found>, BrowserError>;
523
+ /**
524
+ * The text the viewport shows, or one element whole, in one call to the page. Field values read
525
+ * `••••` unless `unmask`, and a secret field's always do, as does one that was secret when the
526
+ * library saw it.
527
+ */
528
+ readonly text: (options?: TextOptions) => Effect.Effect<Text, BrowserError>;
529
+ /**
530
+ * What visibly changed over a window, in one call to the page. The first read starts the page's
531
+ * record, so it finds none; from then the page records, and from the start of each later
532
+ * document, until nobody has read it for two minutes. See `Change`.
533
+ */
534
+ readonly changes: (options?: ChangesOptions) => Effect.Effect<Changes, BrowserError>;
535
+ /**
536
+ * The page's events, changes and frames over a window: the frames and events it keeps, at no
537
+ * call, and its changes, in one call, the first starting its record as `changes` does. A part
538
+ * that cannot be read is missing, with why; the window fails only for bounds that are not finite.
539
+ */
540
+ readonly window: (options: WindowOptions) => Effect.Effect<Window, BrowserError>;
541
+ /**
542
+ * What the library knows of the page now, at no call and with no wait for its turn: where it is,
543
+ * its document and how far it has loaded, its newest frame, and its text and title as last read.
544
+ */
545
+ readonly state: Effect.Effect<State>;
546
+ readonly click: (target: Target, options?: ClickOptions) => Effect.Effect<ResolvedTarget, BrowserError>;
547
+ readonly hover: (target: Target) => Effect.Effect<void, BrowserError>;
548
+ readonly drag: (from: Target, to: Target) => Effect.Effect<void, BrowserError>;
549
+ /** Type into a text field, or to whatever has focus unless a typed key could activate it. */
550
+ readonly type: (text: string, options?: TypeOptions) => Effect.Effect<void, BrowserError>;
551
+ /** Keys such as `"Enter"`, `"Space"`, `"ArrowLeft"` or `"Control+A"`. */
552
+ readonly press: (keys: string, options?: PressOptions) => Effect.Effect<void, BrowserError>;
553
+ readonly scroll: (options?: ScrollOptions) => Effect.Effect<void, BrowserError>;
554
+ /**
555
+ * Choose options of a `<select>` by value or label; returns the chosen labels. A refusal, such
556
+ * as no matching option, is undispatched.
557
+ */
558
+ readonly select: (ref: string, values: ReadonlyArray<string>) => Effect.Effect<string, BrowserError>;
559
+ /**
560
+ * Wait until a condition holds, in one call that the page answers as it comes, looking every
561
+ * 100 ms, or `Timeout` after `timeout`, 10 seconds by default. A selector that is not CSS is an
562
+ * `InvalidRequest`.
563
+ */
564
+ readonly waitFor: (condition: WaitCondition, timeout?: Duration.Input) => Effect.Effect<void, BrowserError>;
565
+ /**
566
+ * Wait until the page is ready to be shown, asking the page every 100 ms: its document is parsed
567
+ * and has painted since, nothing that ends is animating in view, its fonts and the images in
568
+ * view have loaded, and the viewport shows something. With `quietMillis`, the screen must then
569
+ * also stay still that long: nothing in view changed, where the page's changes are recorded, and
570
+ * no frame comes, counted from the first frame of a capture the wait starts itself. A canvas
571
+ * that keeps drawing, such as a live chart, is never still, and a page
572
+ * is never ready without a painted frame, as a hidden tab may be. `Timeout` after `timeout`,
573
+ * 15 seconds by default.
574
+ */
575
+ readonly ready: (options?: ReadyOptions) => Effect.Effect<void, BrowserError>;
576
+ /**
577
+ * Screencast frames for as long as the stream runs. Concurrent streams share one screencast and
578
+ * its settings; explicit options that differ from a running screencast's fail with InvalidRequest.
579
+ */
580
+ readonly screencast: (options?: ScreencastOptions) => Stream.Stream<Frame, BrowserError>;
581
+ /**
582
+ * What this page's captures received, delivered and dropped, over its life or the latest
583
+ * `window`, which reaches back at most a minute; a longer one is an `InvalidRequest`.
584
+ */
585
+ readonly captureStats: (options?: {
586
+ readonly window?: Duration.Input | undefined;
587
+ }) => Effect.Effect<CaptureStats, BrowserError>;
588
+ /** Screencast frames painted within `frameHistory` of the newest, oldest first. */
589
+ readonly recentFrames: Effect.Effect<ReadonlyArray<Frame>>;
590
+ /** This page's events among the browser's latest `eventHistory`, oldest first. */
591
+ readonly recentEvents: Effect.Effect<ReadonlyArray<BrowserEvent>>;
592
+ }
593
+ //#endregion
594
+ export { Account as A, TypeOptions as C, correlate as D, Zoom as E, account as F, capture as I, toPrompt as L, Moment as M, Moment_d_exports as N, failFast as O, Window as P, TextOptions as S, WindowOptions as T, ScreenshotOptions as _, FindQuery as a, Target as b, InputGuard as c, Page_d_exports as d, Point as f, ResolvedTarget as g, Region as h, Fact as i, CaptureOptions as j, redacted as k, InputRequest as l, ReadyOptions as m, ClickOptions as n, Found as o, PressOptions as p, ElementState as r, FrameOptions as s, ChangesOptions as t, Page$1 as u, ScrollOptions as v, WaitCondition as w, Text as x, State as y };
595
+ //# sourceMappingURL=Page-B7X6DQUn.d.mts.map
@@ -0,0 +1,2 @@
1
+ import { C as TypeOptions, D as correlate, E as Zoom, O as failFast, S as TextOptions, T as WindowOptions, _ as ScreenshotOptions, a as FindQuery, b as Target, c as InputGuard, f as Point, g as ResolvedTarget, h as Region, i as Fact, k as redacted, l as InputRequest, m as ReadyOptions, n as ClickOptions, o as Found, p as PressOptions, r as ElementState, s as FrameOptions, t as ChangesOptions, u as Page, v as ScrollOptions, w as WaitCondition, x as Text, y as State } from "./Page-B7X6DQUn.mjs";
2
+ export { ChangesOptions, ClickOptions, ElementState, Fact, FindQuery, Found, FrameOptions, InputGuard, InputRequest, Page, Point, PressOptions, ReadyOptions, Region, ResolvedTarget, ScreenshotOptions, ScrollOptions, State, Target, Text, TextOptions, TypeOptions, WaitCondition, WindowOptions, Zoom, correlate, failFast, redacted };
package/dist/Page.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { c as State, d as correlate, f as failFast, i as InputRequest, l as Text, n as Fact, o as Region, p as redacted, r as Found, s as ResolvedTarget, t as ElementState, u as Zoom } from "./Page-B5cjaUp5.mjs";
2
+ export { ElementState, Fact, Found, InputRequest, Region, ResolvedTarget, State, Text, Zoom, correlate, failFast, redacted };