effect-browser 0.2.0-beta.7 → 0.2.0-beta.9

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 (68) hide show
  1. package/README.md +504 -152
  2. package/dist/Browser-BF9_sORP.d.mts +388 -0
  3. package/dist/Browser.d.mts +3 -200
  4. package/dist/Browser.mjs +9 -1
  5. package/dist/Browser.mjs.map +1 -1
  6. package/dist/{BrowserData-KHk4o__c.d.mts → BrowserData-CPIIIHol.d.mts} +81 -7
  7. package/dist/BrowserData.d.mts +2 -2
  8. package/dist/BrowserData.mjs +104 -6
  9. package/dist/BrowserData.mjs.map +1 -1
  10. package/dist/{BrowserRuntime-hxkTNlRa.d.mts → BrowserRuntime-B6nT1G4X.d.mts} +16 -11
  11. package/dist/{BrowserRuntime-Cr76CN4I.mjs → BrowserRuntime-C1r2aSRK.mjs} +5065 -4305
  12. package/dist/BrowserRuntime-C1r2aSRK.mjs.map +1 -0
  13. package/dist/BrowserRuntime.d.mts +2 -2
  14. package/dist/BrowserRuntime.mjs +2 -1
  15. package/dist/Capture.d.mts +9 -7
  16. package/dist/Capture.mjs +157 -32
  17. package/dist/Capture.mjs.map +1 -1
  18. package/dist/{CaptureData-Dys0Ko9d.mjs → CaptureData-CYriZHX1.mjs} +25 -6
  19. package/dist/CaptureData-CYriZHX1.mjs.map +1 -0
  20. package/dist/CaptureData.d.mts +62 -3
  21. package/dist/CaptureData.mjs +2 -2
  22. package/dist/Chromium.d.mts +2 -2
  23. package/dist/Chromium.mjs +19 -10
  24. package/dist/Chromium.mjs.map +1 -1
  25. package/dist/Errors.d.mts +66 -17
  26. package/dist/Errors.mjs +47 -5
  27. package/dist/Errors.mjs.map +1 -1
  28. package/dist/Images-yCG9BmRU.mjs +76 -0
  29. package/dist/Images-yCG9BmRU.mjs.map +1 -0
  30. package/dist/OperationOptions-DAeRS6O9.mjs +55 -0
  31. package/dist/OperationOptions-DAeRS6O9.mjs.map +1 -0
  32. package/dist/PageControl.d.mts +6 -6
  33. package/dist/PageControl.mjs +16 -10
  34. package/dist/PageControl.mjs.map +1 -1
  35. package/dist/PageRegistry-B3q9DS3g.mjs +164 -0
  36. package/dist/PageRegistry-B3q9DS3g.mjs.map +1 -0
  37. package/dist/Plan-Dyxu2q8C.mjs +543 -0
  38. package/dist/Plan-Dyxu2q8C.mjs.map +1 -0
  39. package/dist/Plan.d.mts +3 -0
  40. package/dist/Plan.mjs +2 -0
  41. package/dist/PlanData-B668RxbQ.d.mts +4831 -0
  42. package/dist/PlanData.d.mts +3 -0
  43. package/dist/PlanData.mjs +268 -0
  44. package/dist/PlanData.mjs.map +1 -0
  45. package/dist/PlanInput-BJcPPncs.mjs +75 -0
  46. package/dist/PlanInput-BJcPPncs.mjs.map +1 -0
  47. package/dist/PublicSession-DCSMMqOj.mjs +5602 -0
  48. package/dist/PublicSession-DCSMMqOj.mjs.map +1 -0
  49. package/dist/Testing.d.mts +48 -6
  50. package/dist/Testing.mjs +651 -113
  51. package/dist/Testing.mjs.map +1 -1
  52. package/dist/Timeline-fV22Xk-S.d.mts +29 -0
  53. package/dist/Timeline.d.mts +4 -0
  54. package/dist/Timeline.mjs +20 -0
  55. package/dist/Timeline.mjs.map +1 -0
  56. package/dist/TimelineData-BsOn-YGZ.d.mts +3818 -0
  57. package/dist/TimelineData.d.mts +3 -0
  58. package/dist/TimelineData.mjs +482 -0
  59. package/dist/TimelineData.mjs.map +1 -0
  60. package/dist/index.d.mts +5 -1
  61. package/dist/index.mjs +5 -1
  62. package/package.json +18 -2
  63. package/dist/Association-CH3kPHXE.mjs +0 -167
  64. package/dist/Association-CH3kPHXE.mjs.map +0 -1
  65. package/dist/BrowserRuntime-Cr76CN4I.mjs.map +0 -1
  66. package/dist/CaptureData-Dys0Ko9d.mjs.map +0 -1
  67. package/dist/PageControlAssociation-DabEg5AR.mjs +0 -10
  68. package/dist/PageControlAssociation-DabEg5AR.mjs.map +0 -1
@@ -0,0 +1,388 @@
1
+ import { f as Plan, g as ReadinessOutcome, s as Bootstrap_d_exports, t as BindingDiagnostics } from "./Bootstrap-B9UUXsvF.mjs";
2
+ import { BrowserError, BrowserOperation, Containment, InitializationError } from "./Errors.mjs";
3
+ import { $ as Target, A as NavigationResult, B as PressRequest, D as KeyStroke, G as ScreenshotResult, I as PageInfo, K as ScrollRequest, M as ObservationOptions, P as ObservedElement, Q as StartNavigationRequest, R as PointerMoveRequest, V as ReadTextRequest, W as ScreenshotRequest, Z as SessionStatus, a as BrowserDiagnostics, b as HoverRequest, c as CheckpointOptions, ct as WaitForElementRequest, f as FillFormOptions, h as FillRequest, it as Viewport, j as Observation, k as NavigateRequest, l as ClickRequest, lt as WheelRequest, m as FillFormResult, p as FillFormRequest, q as SelectOptions, rt as TypeRequest, s as Checkpoint, t as ActionResult, tt as TextResult, u as ControlFacts, w as InputReceipt, y as FrameInfo } from "./BrowserData-CPIIIHol.mjs";
4
+ import { A as PlanEncoded, D as PerformedEncoded, K as StepAttempt, N as Ran, P as RanStep, U as SettledEvidence, a as AttemptSnapshot, b as LivePlanEncoded, f as DescriptorEncoded, h as InputBindings, k as Plan$1, y as LivePlan, z as ResolveGuard } from "./PlanData-B668RxbQ.mjs";
5
+ import { R as TimelineError, y as PageEvent } from "./TimelineData-BsOn-YGZ.mjs";
6
+ import { t as Timeline } from "./Timeline-fV22Xk-S.mjs";
7
+ import { Duration, Effect, Schema, Scope, Stream } from "effect";
8
+ //#region src/Plan.d.ts
9
+ /** All execution stays on the issued Page/Frame and its original scoped owner. */
10
+ interface RunOptions extends OperationOptions {
11
+ readonly style?: "plain" | PerformedEncoded;
12
+ /** Intended boundary in this owner's original monotonic runtime, measured when executed. */
13
+ readonly startAt?: bigint;
14
+ readonly within?: Duration.Input;
15
+ readonly through?: string;
16
+ readonly inputs?: InputBindings;
17
+ readonly policy?: ElementAdmission;
18
+ readonly checkpoint?: CheckpointOptions;
19
+ }
20
+ /**
21
+ * Check and normalize host run options exactly as `page.start` and `page.run` will, without
22
+ * exposing private deadline/queue accounting fields. A caller that builds options from untrusted
23
+ * configuration can fail early with the same `Configuration` refusal.
24
+ */
25
+ declare const checkRunOptions: (value: unknown) => Effect.Effect<RunOptions, BrowserError>;
26
+ interface StepFailure {
27
+ readonly stage: "PreparationFailed" | "AttemptFailed";
28
+ readonly stepId?: string;
29
+ readonly completed: ReadonlyArray<RanStep>;
30
+ readonly attempt?: StepAttempt;
31
+ readonly error: BrowserError;
32
+ }
33
+ declare const StepFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
34
+ readonly _tag: "StepFailed";
35
+ } & Readonly<A>;
36
+ /**
37
+ * Live host failure evidence is not a durable plan or a serialization schema. Its message names
38
+ * only the stage, step and reason; the evidence fields can retain authored literal values, so
39
+ * log the message rather than the whole value.
40
+ */
41
+ declare class StepFailed extends StepFailed_base<StepFailure & {
42
+ readonly message: string;
43
+ }> {
44
+ constructor(failure: StepFailure);
45
+ }
46
+ declare const RecordingIncomplete_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
47
+ readonly _tag: "RecordingIncomplete";
48
+ } & Readonly<A>;
49
+ declare class RecordingIncomplete extends RecordingIncomplete_base<{
50
+ readonly stepId?: string;
51
+ readonly reason: "InvalidThrough" | "NoCompletedSteps" | "IncompleteCapture" | "Unacknowledged";
52
+ }> {}
53
+ /** A retained value keeps its evidence after interruption; joining never submits another walk. */
54
+ interface RunOperation {
55
+ readonly id: string;
56
+ readonly attempts: Effect.Effect<AttemptSnapshot>;
57
+ readonly completed: Effect.Effect<Ran, StepFailed>;
58
+ readonly cancel: Effect.Effect<void>;
59
+ }
60
+ interface PlanOperations {
61
+ readonly start: (plan: LivePlanEncoded | PlanEncoded, options?: RunOptions) => Effect.Effect<RunOperation, StepFailed, Scope.Scope>;
62
+ readonly run: (plan: LivePlanEncoded | PlanEncoded, options?: RunOptions) => Effect.Effect<Ran, StepFailed>;
63
+ }
64
+ /** Validate and normalize authored data, including explicit document/Strict defaults. */
65
+ declare const make: (value: LivePlanEncoded) => Effect.Effect<LivePlan, Schema.SchemaError>;
66
+ /** Descriptor-only ingress for stored intent; it never decodes a live Ref. */
67
+ declare const decode: (value: unknown) => Effect.Effect<Plan$1, Schema.SchemaError>;
68
+ /** The normalized scope and guards are always included in encoded durable intent. */
69
+ declare const encode: (value: Plan$1) => Effect.Effect<PlanEncoded, Schema.SchemaError>;
70
+ /** A named input a plan reads: the step and action path that read it, and how it is used. */
71
+ interface InputSlot {
72
+ readonly name: string;
73
+ readonly stepId: string;
74
+ readonly path: ReadonlyArray<string>;
75
+ /** `text` is typed key by key into focus; `value` replaces a field's whole contents. */
76
+ readonly kind: "text" | "value";
77
+ }
78
+ /**
79
+ * The named inputs a stored or live plan reads, in step order. A recorded plan's literal fill and
80
+ * type values are such slots; bind each `name` in `inputs` to replay it.
81
+ */
82
+ declare const inputSlots: (plan: Plan$1 | LivePlan) => ReadonlyArray<InputSlot>;
83
+ /**
84
+ * Project only acknowledged, faithfully captured intent. An explicitly chosen completed prefix
85
+ * can be retained after a later failure by passing the operation's host snapshot and `through`.
86
+ * Literal input values are replaced during capture with deterministic named input slots.
87
+ */
88
+ declare const recorded: (value: Ran | AttemptSnapshot, options?: {
89
+ readonly through?: string;
90
+ }) => Effect.Effect<Plan$1, RecordingIncomplete>;
91
+ /**
92
+ * Project one `startNavigation` operation, such as an agent-browser `Navigation` receipt's, as a
93
+ * plan of one `Navigate` step named `id` ("navigate" by default). It joins `completed`, which
94
+ * stops nothing: only a navigation that reached DOMContentLoaded is acknowledged, and one that
95
+ * failed, was stopped or interrupted, or whose outcome is unknown is refused `Unacknowledged`.
96
+ * The step repeats the request, not the address a redirect reached, as a recorded run's
97
+ * Navigate step does. An `id` that is not a step identifier fails `IncompleteCapture`.
98
+ */
99
+ declare const recordedNavigation: (operation: NavigationOperation, options?: {
100
+ readonly id?: string;
101
+ }) => Effect.Effect<Plan$1, RecordingIncomplete>;
102
+ //#endregion
103
+ //#region src/Browser.d.ts
104
+ /**
105
+ * Host-only ordinary admission. Omission or zero fails immediately; positive finite duration
106
+ * queues FIFO. Page closure uses reserved fail-fast admission and a deadline-bounded shared close.
107
+ */
108
+ interface AdmissionOptions {
109
+ readonly queue?: Duration.Input;
110
+ }
111
+ /** Explicit host options, separate from request data and exact-element admission callbacks. */
112
+ interface OperationOptions {
113
+ readonly timeoutMillis?: number;
114
+ readonly admission?: AdmissionOptions;
115
+ }
116
+ /** Explicit descriptor guard and ordinary host admission; no selector or geometry fallback. */
117
+ interface ResolveOptions extends OperationOptions {
118
+ readonly guard?: typeof ResolveGuard.Encoded;
119
+ }
120
+ /** Named native quiet signals within the original positive finite deadline. */
121
+ interface SettledRequest {
122
+ readonly quiet: Duration.Input;
123
+ readonly within: Duration.Input;
124
+ }
125
+ /** A bounded host-memory snapshot; it grants no priority or native authority. */
126
+ interface AdmissionStatus {
127
+ readonly active: BrowserOperation | null;
128
+ readonly waiting: number;
129
+ readonly maximum: number;
130
+ readonly oldestWaitMillis: number | null;
131
+ readonly nativePending: number;
132
+ readonly nativeWaitPending: boolean;
133
+ readonly stopSetupPending: boolean;
134
+ }
135
+ interface SessionAdmissionStatus {
136
+ readonly waiting: number;
137
+ readonly maximum: number;
138
+ readonly nativePending: number;
139
+ readonly nativeMaximum: number;
140
+ readonly nativeWaits: number;
141
+ readonly stopSetups: number;
142
+ readonly registry: AdmissionStatus;
143
+ }
144
+ /** Terminal facts remain readable after this page loses live authority. */
145
+ interface PageStatus {
146
+ readonly identity: Target;
147
+ readonly phase: "open" | "paused" | "closing" | "closed" | "stale";
148
+ readonly containment: Containment;
149
+ readonly admission: AdmissionStatus;
150
+ }
151
+ interface PageOperations {
152
+ readonly navigate: (request: NavigateRequest, options?: OperationOptions) => Effect.Effect<NavigationResult, BrowserError>;
153
+ /** `navigate`, left in flight: the same single dispatch, completed by the caller. */
154
+ readonly startNavigation: (request: StartNavigationRequest, options?: OperationOptions) => Effect.Effect<NavigationOperation, BrowserError, Scope.Scope>;
155
+ readonly readText: (request: ReadTextRequest, options?: OperationOptions) => Effect.Effect<TextResult, BrowserError>;
156
+ readonly click: (request: ClickRequest, options?: OperationOptions) => Effect.Effect<ActionResult, BrowserError>;
157
+ readonly fill: (request: FillRequest, options?: OperationOptions) => Effect.Effect<ActionResult, BrowserError>;
158
+ /** Script in the page: instantaneous, and it raises no wheel event. */
159
+ readonly scroll: (request: ScrollRequest, options?: OperationOptions) => Effect.Effect<ActionResult, BrowserError>;
160
+ /** One real pointer move, in main-frame viewport pixels. */
161
+ readonly pointerMove: (request: PointerMoveRequest, options?: OperationOptions) => Effect.Effect<InputReceipt, BrowserError>;
162
+ /** Places the pointer on one exact element where it is, or fails `not-visible` unsent. */
163
+ readonly hover: (request: HoverRequest, options?: OperationOptions) => Effect.Effect<InputReceipt, BrowserError>;
164
+ /** One real wheel event; the browser decides what under the pointer scrolls. */
165
+ readonly wheel: (request: WheelRequest, options?: OperationOptions) => Effect.Effect<InputReceipt, BrowserError>;
166
+ /** One real key stroke to whatever has focus, or fails `not-focused` unsent if `into` lacks it. */
167
+ readonly press: (request: PressRequest, options?: OperationOptions) => Effect.Effect<InputReceipt, BrowserError>;
168
+ /** Text as the real key strokes that produce it, under the same focus rule as `press`. */
169
+ readonly type: (request: TypeRequest, options?: OperationOptions) => Effect.Effect<InputReceipt, BrowserError>;
170
+ readonly screenshot: (request: ScreenshotRequest, options?: OperationOptions) => Effect.Effect<ScreenshotResult, BrowserError>;
171
+ /**
172
+ * The one observation whose nodes later actions may name. `scope: "viewport"` keeps only text
173
+ * and controls that are on screen and reachable, plus bounded choices of visible native
174
+ * selects; the default reads the whole document. It carries no destination, form or field value.
175
+ */
176
+ readonly observe: (options?: ObservationOptions, operationOptions?: OperationOptions) => Effect.Effect<Observation, BrowserError>;
177
+ /**
178
+ * Passive evidence for a recorder, with a picture when asked. It issues no references and
179
+ * leaves the observation above exactly as it was. Host-only: it carries control facts.
180
+ */
181
+ readonly checkpoint: (options?: CheckpointOptions, operationOptions?: OperationOptions) => Effect.Effect<Checkpoint, BrowserError>;
182
+ /** Host-only facts about one observed control, read from that exact node just now. */
183
+ readonly controlFacts: (reference: ObservedElement, options?: OperationOptions) => Effect.Effect<ControlFacts, BrowserError>;
184
+ /**
185
+ * After a page hold, nothing observed on that page may be acted on unchecked. This checks one
186
+ * reference: still attached, and still the control that was inspected. It never searches by
187
+ * selector or label for a substitute, and it sends nothing.
188
+ */
189
+ readonly revalidateElement: (reference: ObservedElement, options?: OperationOptions) => Effect.Effect<ObservedElement, BrowserError>;
190
+ readonly clickElement: (reference: ObservedElement, admission?: ElementAdmission, options?: OperationOptions) => Effect.Effect<ActionResult, BrowserError>;
191
+ readonly fillElement: (reference: ObservedElement, value: string, admission?: ElementAdmission, options?: OperationOptions) => Effect.Effect<ActionResult, BrowserError>;
192
+ /** One selection using this exact select and its issued option element IDs, with fresh checks. */
193
+ readonly selectOption: (reference: ObservedElement, options: SelectOptions, admission?: ElementAdmission, operationOptions?: OperationOptions) => Effect.Effect<ActionResult, BrowserError>;
194
+ readonly hoverElement: (reference: ObservedElement, admission?: ElementAdmission, options?: OperationOptions) => Effect.Effect<InputReceipt, BrowserError>;
195
+ /** A key stroke sent only if the exact node an observation named already has focus. */
196
+ readonly pressElement: (reference: ObservedElement, stroke: KeyStroke, admission?: ElementAdmission, options?: OperationOptions) => Effect.Effect<InputReceipt, BrowserError>;
197
+ /** Real typing with `fillElement`'s exactness: that node must already have focus. */
198
+ readonly typeElement: (reference: ObservedElement, text: string, admission?: ElementAdmission, options?: OperationOptions) => Effect.Effect<InputReceipt, BrowserError>;
199
+ /**
200
+ * Set several controls of one observation in order, then optionally click one submit control.
201
+ * Every step acts on the exact observed node after the same fresh checks as `fillElement`,
202
+ * except that a control may have become enabled since it was observed, and each is admitted
203
+ * and charged as its own action. The observation stays usable for this form's own steps only;
204
+ * anything else that changes the page still retires it, and the form retires it when it ends.
205
+ * The first refused or uncertain step ends the form. Submit is sent only after every field
206
+ * succeeded and, unless `verify` is false, still holds what its step left there. Fields set
207
+ * before a stop stay set. It fails only when its first step does; otherwise `stopped` says
208
+ * where it ended and why.
209
+ */
210
+ readonly fillForm: (request: FillFormRequest, admission?: ElementAdmission, options?: FillFormOptions, operationOptions?: OperationOptions) => Effect.Effect<FillFormResult, BrowserError>;
211
+ /**
212
+ * Wait on the original observed node within the host deadline. Hidden includes its detachment;
213
+ * document replacement is stale. Success observes a condition, without authorizing later input.
214
+ */
215
+ readonly waitForElement: (request: WaitForElementRequest, options?: OperationOptions) => Effect.Effect<void, BrowserError>;
216
+ readonly waitFor: (request: {
217
+ readonly selector: string;
218
+ readonly state: "visible" | "hidden" | "attached" | "detached";
219
+ }, options?: OperationOptions) => Effect.Effect<void, BrowserError>;
220
+ /** Navigation observation is registered before the single click dispatch. */
221
+ readonly clickAndWait: (request: ClickRequest, options?: OperationOptions) => Effect.Effect<ActionResult, BrowserError>;
222
+ /**
223
+ * Readiness of the current document only. Dependent operations wait for it themselves;
224
+ * this reports it without charging an action, so a caller can decide what to do about a
225
+ * document that predates the registrations.
226
+ */
227
+ readonly ready: (options?: OperationOptions) => Effect.Effect<ReadinessOutcome, InitializationError>;
228
+ }
229
+ /**
230
+ * Issued live authority for one native frame; navigation keeps the frame and retires its references.
231
+ *
232
+ * Pass the issued object itself. Capture, page control, provider transfers, agent tools and
233
+ * `checkPage` authenticate it by identity, so a spread copy, wrapper or Proxy is refused
234
+ * `UnregisteredSession` even though its copied methods still run. Observe work through the
235
+ * timeline and run receipts rather than by wrapping methods.
236
+ */
237
+ interface Frame extends PageOperations, PlanOperations {
238
+ readonly identity: Target;
239
+ readonly status: Effect.Effect<PageStatus>;
240
+ /**
241
+ * The original owner's host monotonic clock, the same one `session.monotonicTimeNanos` reads,
242
+ * so a host bound to this Page or Frame can compute a plan's `startAt` without the session.
243
+ */
244
+ readonly monotonicTimeNanos: Effect.Effect<bigint>;
245
+ /** Resolve full descriptor intent against the complete current native candidate inventory. */
246
+ readonly resolve: (descriptor: DescriptorEncoded, options?: ResolveOptions) => Effect.Effect<ObservedElement, BrowserError>;
247
+ /**
248
+ * Quiet DOM mutation, scroll, root geometry and viewport signals in one pinned document.
249
+ * This does not establish network, animation or business completion.
250
+ */
251
+ readonly settled: (request: SettledRequest, options?: OperationOptions) => Effect.Effect<SettledEvidence, BrowserError>;
252
+ }
253
+ /** Issued live authority for one native page on its original connection; pass it as issued, see `Frame`. */
254
+ interface Page extends Frame {
255
+ /** Evidence for this issued Page's original domain; navigation does not change its journal. */
256
+ readonly timeline: Timeline;
257
+ /**
258
+ * Read this page's address and title. Like `listFrames`, it is a read of the page and shares
259
+ * its permit; pass `admission.queue` to wait behind work already running there.
260
+ */
261
+ readonly describe: (options?: OperationOptions) => Effect.Effect<PageInfo, BrowserError>;
262
+ readonly listFrames: (options?: OperationOptions) => Effect.Effect<ReadonlyArray<FrameInfo>, BrowserError>;
263
+ /** Issue a child Frame. Like `session.page`, issuing takes the registry permit, not this page's. */
264
+ readonly frame: (info: FrameInfo, options?: OperationOptions) => Effect.Effect<Frame, BrowserError>;
265
+ readonly resizeViewport: (viewport: Viewport, options?: OperationOptions) => Effect.Effect<void, BrowserError>;
266
+ /** Reserved fail-fast admission; timeoutMillis bounds joining a close, not admission.queue. */
267
+ readonly close: (options?: OperationOptions) => Effect.Effect<void, BrowserError>;
268
+ }
269
+ /**
270
+ * A host's decision about one control, made on facts read from the exact node immediately
271
+ * before input. Returning anything but `true`, or throwing, sends nothing and fails `denied`.
272
+ * It is a plain synchronous function on purpose: it runs while the owner's permit is held, where
273
+ * waiting on a model or a network call would stall other ordinary operations on that Page. It is not an atomic
274
+ * check-and-input transaction, because page script can still run before the native input lands.
275
+ */
276
+ interface ElementAdmission {
277
+ readonly admit: (facts: ControlFacts) => boolean;
278
+ }
279
+ /**
280
+ * A navigation the browser is still performing. The owner's permit was released when it was
281
+ * dispatched, so while it loads a host may read, `checkpoint`, hold and resume this page, and
282
+ * use any other page. Anything that would change this page fails `busy` until it settles.
283
+ *
284
+ * Leaving its scope unsettled revokes and attempts to close its exact page. Positive closure
285
+ * preserves healthy peers; unconfirmed closure fences the session. Its outcome remains unknown
286
+ * because nothing then knows what the browser did. It is never replayed.
287
+ */
288
+ interface NavigationOperation {
289
+ /** What was navigated, read before dispatch. */
290
+ readonly target: Target;
291
+ /**
292
+ * What was asked for, as checked before dispatch. `Plan.recordedNavigation` records this
293
+ * request, not the address `completed` reports after any redirect.
294
+ */
295
+ readonly request: StartNavigationRequest;
296
+ /**
297
+ * The document reached DOMContentLoaded. It belongs to this one navigation: a successor that
298
+ * reaches the same URL fails it instead. Interrupting a waiter stops nothing in the browser.
299
+ */
300
+ readonly completed: Effect.Effect<NavigationResult, BrowserError>;
301
+ /**
302
+ * Asks the browser to stop loading and waits for this navigation to settle, after which
303
+ * `completed` fails `interrupted`. Success is a known outcome and the session stays usable:
304
+ * the page holds whatever had loaded. It does not undo anything the page already did.
305
+ * An already-completed navigation cannot stop a successor. Concurrent callers share their
306
+ * active attempt. Before dispatch, cancellation or a busy refusal permits a later request
307
+ * once native setup has retired. A dispatched attempt's outcome, including failure or
308
+ * interruption, is retained permanently; an uncertain stop is never replayed.
309
+ */
310
+ readonly stop: Effect.Effect<void, BrowserError>;
311
+ }
312
+ /**
313
+ * Host control over one owned browser. This is not a serializable model value: copying a
314
+ * session object cannot copy its capture, page-control or connection authority.
315
+ *
316
+ * Browser operations belong to issued Page and Frame objects. Display selection and owner
317
+ * lifecycle are separate from those exact capabilities.
318
+ */
319
+ interface BrowserSession<E = never> {
320
+ /** The original owner's host clock, for same-runtime absolute cue scheduling. */
321
+ readonly monotonicTimeNanos: Effect.Effect<bigint>;
322
+ /** Stable facade: each snapshot/stream captures the current journal when it executes. */
323
+ readonly timeline: Timeline;
324
+ /** Atomic cached Inventory baseline followed by lifecycle evidence on its pinned journal. */
325
+ readonly pages: Stream.Stream<PageEvent, TimelineError>;
326
+ /** The page acquired on the initial connection, independent of later display selection. */
327
+ readonly initialPage: Page;
328
+ /**
329
+ * Authenticate `info` against the live native page and return its canonical issued Page. This
330
+ * takes the registry permit, not the page's own: it never waits for, or fails `busy` on, work
331
+ * already running on that page.
332
+ */
333
+ readonly page: (info: PageInfo, options?: OperationOptions) => Effect.Effect<Page, BrowserError>;
334
+ readonly listPages: (options?: OperationOptions) => Effect.Effect<ReadonlyArray<PageInfo>, BrowserError>;
335
+ /** The implementation which owns this live connection. */
336
+ readonly implementation: string;
337
+ /** Copied host-only state, readable without admission in every lifecycle phase. */
338
+ readonly status: Effect.Effect<SessionStatus>;
339
+ /** Bounded native/policy diagnostics. Typed callback causes remain in bindingDiagnostics. */
340
+ readonly diagnostics: Effect.Effect<BrowserDiagnostics>;
341
+ readonly admission: Effect.Effect<SessionAdmissionStatus>;
342
+ /** Close this scope and require its own ownership-specific cleanup evidence. */
343
+ readonly closeChecked: Effect.Effect<void, BrowserError>;
344
+ /** First fail-session callback cause, preserving the consumer's error type on the host. */
345
+ readonly failure: Effect.Effect<never, E | InitializationError>;
346
+ /** Bounded host-only evidence; consumer causes are never projected into a page reply. */
347
+ readonly bindingDiagnostics: Effect.Effect<BindingDiagnostics<E>>;
348
+ /**
349
+ * Choose the displayed page, which is also the page `detach` records and `reconnect` resumes on.
350
+ * Nothing else: it never retargets a Page or Frame operation, which keep their own exact
351
+ * authority. Pass a Page this session issued; a closed or stale one is refused unsent.
352
+ */
353
+ readonly selectPage: (page: Page, options?: OperationOptions) => Effect.Effect<void, BrowserError>;
354
+ /**
355
+ * Open a page in its own window, sized like the others, without selecting it, and return the
356
+ * Page issued for it. Chromium paints every window, so any page can be pictured and read at
357
+ * speed, not only the one in front. Registry admission fails immediately by default; pass a
358
+ * positive finite admission.queue to wait FIFO within the operation deadline.
359
+ */
360
+ readonly createPage: (options?: OperationOptions) => Effect.Effect<Page, BrowserError>;
361
+ }
362
+ /** Helpers that do not supervise callback failures accept any live browser session. */
363
+ type AnySession = BrowserSession<unknown>;
364
+ /**
365
+ * Check that `page` is a Page or Frame this session issued, by identity, and that its authority
366
+ * is still current: a foreign or copied object fails `UnregisteredSession`, a closed, stale or
367
+ * detached one fails with the same refusal its own operations would report. Adapters such as
368
+ * agent-browser hosts call it once when they bind, so a wrong target fails before any work.
369
+ */
370
+ declare const checkPage: (session: AnySession, page: Page | Frame) => Effect.Effect<void, BrowserError>;
371
+ /** Dependencies are captured at acquisition, not erased into an environment-free service Layer. */
372
+ interface OpenOptions<E = never, R = never> {
373
+ readonly bootstrap?: Plan<E, R>;
374
+ }
375
+ /**
376
+ * Acquire, supervise and close one browser in a fresh scope. The callback keeps the concrete
377
+ * Chromium or provider session type. Its scoped work is joined before checked browser cleanup,
378
+ * and cleanup failures remain typed even when the callback has already failed or was cancelled.
379
+ * Acquisition is evaluated once; an uncertain result is never retried.
380
+ */
381
+ declare const scoped: {
382
+ <S extends BrowserSession<unknown>, A, E2, R2>(f: (session: S) => Effect.Effect<A, E2, R2>): <E, AE, AR>(open: Effect.Effect<S & BrowserSession<E>, AE, AR>) => Effect.Effect<A, AE | E | E2 | InitializationError | BrowserError, Exclude<AR | R2, Scope.Scope>>;
383
+ <S, E, AE, AR, A, E2, R2>(open: Effect.Effect<S & BrowserSession<E>, AE, AR>, f: (session: S & BrowserSession<E>) => Effect.Effect<A, E2, R2>): Effect.Effect<A, AE | E | E2 | InitializationError | BrowserError, Exclude<AR | R2, Scope.Scope>>;
384
+ };
385
+ //#endregion
386
+ export { recordedNavigation as A, StepFailed as C, inputSlots as D, encode as E, make as O, RunOptions as S, decode as T, scoped as _, ElementAdmission as a, RecordingIncomplete as b, OpenOptions as c, PageOperations as d, PageStatus as f, checkPage as g, SettledRequest as h, BrowserSession as i, recorded as k, OperationOptions as l, SessionAdmissionStatus as m, AdmissionStatus as n, Frame as o, ResolveOptions as p, AnySession as r, NavigationOperation as s, AdmissionOptions as t, Page as u, InputSlot as v, checkRunOptions as w, RunOperation as x, PlanOperations as y };
387
+ export {};
388
+ //# sourceMappingURL=Browser-BF9_sORP.d.mts.map
@@ -1,200 +1,3 @@
1
- import { f as Plan, g as ReadinessOutcome, s as Bootstrap_d_exports, t as BindingDiagnostics } from "./Bootstrap-B9UUXsvF.mjs";
2
- import { BrowserError, InitializationError } from "./Errors.mjs";
3
- import { $ as TypeRequest, D as NavigationResult, E as NavigateRequest, F as PointerMoveRequest, H as ScreenshotResult, J as SessionStatus, L as PressRequest, N as PageInfo, O as Observation, Q as TextResult, R as ReadTextRequest, S as InputReceipt, U as ScrollRequest, V as ScreenshotRequest, W as SelectOptions, X as Target, Y as StartNavigationRequest, _ as FrameInfo, at as WheelRequest, c as ClickRequest, d as FillFormRequest, et as Viewport, f as FillFormResult, i as BrowserDiagnostics, it as WaitForElementRequest, j as ObservedElement, k as ObservationOptions, l as ControlFacts, o as Checkpoint, p as FillRequest, s as CheckpointOptions, t as ActionResult, u as FillFormOptions, v as HoverRequest, w as KeyStroke } from "./BrowserData-KHk4o__c.mjs";
4
- import { Effect, Scope } from "effect";
5
- //#region src/Browser.d.ts
6
- /**
7
- * A host's decision about one control, made on facts read from the exact node immediately
8
- * before input. Returning anything but `true`, or throwing, sends nothing and fails `denied`.
9
- * It is a plain synchronous function on purpose: it runs while the owner's permit is held, where
10
- * waiting on a model or a network call would stall every other operation. It is not an atomic
11
- * check-and-input transaction, because page script can still run before the native input lands.
12
- */
13
- export interface ElementAdmission {
14
- readonly admit: (facts: ControlFacts) => boolean;
15
- }
16
- /**
17
- * A navigation the browser is still performing. The owner's permit was released when it was
18
- * dispatched, so while it loads a host may read, `checkpoint`, hold and resume this page, and
19
- * use any other page. Anything that would change this page fails `busy` until it settles.
20
- *
21
- * Leaving its scope unsettled fences the session, exactly as an interrupted mutation does,
22
- * because nothing then knows what the browser did. It is never replayed.
23
- */
24
- export interface NavigationOperation {
25
- /** What was navigated, read before dispatch. */
26
- readonly target: Target;
27
- /**
28
- * The document reached DOMContentLoaded. It belongs to this one navigation: a successor that
29
- * reaches the same URL fails it instead. Interrupting a waiter stops nothing in the browser.
30
- */
31
- readonly completed: Effect.Effect<NavigationResult, BrowserError>;
32
- /**
33
- * Asks the browser to stop loading and waits for this navigation to settle, after which
34
- * `completed` fails `interrupted`. Success is a known outcome and the session stays usable:
35
- * the page holds whatever had loaded. It does not undo anything the page already did.
36
- * An already-completed navigation cannot stop a successor. Concurrent callers share their
37
- * active attempt. Before dispatch, cancellation or a busy refusal permits a later request
38
- * once native setup has retired. A dispatched attempt's outcome, including failure or
39
- * interruption, is retained permanently; an uncertain stop is never replayed.
40
- */
41
- readonly stop: Effect.Effect<void, BrowserError>;
42
- }
43
- /** Common operations. Direct, retained and pinned views choose their target at different times. */
44
- export interface TargetOperations {
45
- readonly navigate: (request: NavigateRequest) => Effect.Effect<NavigationResult, BrowserError>;
46
- /** `navigate`, left in flight: the same single dispatch, completed by the caller. */
47
- readonly startNavigation: (request: StartNavigationRequest) => Effect.Effect<NavigationOperation, BrowserError, Scope.Scope>;
48
- readonly readText: (request: ReadTextRequest) => Effect.Effect<TextResult, BrowserError>;
49
- readonly click: (request: ClickRequest) => Effect.Effect<ActionResult, BrowserError>;
50
- readonly fill: (request: FillRequest) => Effect.Effect<ActionResult, BrowserError>;
51
- /** Script in the page: instantaneous, and it raises no wheel event. */
52
- readonly scroll: (request: ScrollRequest) => Effect.Effect<ActionResult, BrowserError>;
53
- /** One real pointer move, in main-frame viewport pixels. */
54
- readonly pointerMove: (request: PointerMoveRequest) => Effect.Effect<InputReceipt, BrowserError>;
55
- /** Places the pointer on one exact element where it is, or fails `not-visible` unsent. */
56
- readonly hover: (request: HoverRequest) => Effect.Effect<InputReceipt, BrowserError>;
57
- /** One real wheel event; the browser decides what under the pointer scrolls. */
58
- readonly wheel: (request: WheelRequest) => Effect.Effect<InputReceipt, BrowserError>;
59
- /** One real key stroke to whatever has focus, or fails `not-focused` unsent if `into` lacks it. */
60
- readonly press: (request: PressRequest) => Effect.Effect<InputReceipt, BrowserError>;
61
- /** Text as the real key strokes that produce it, under the same focus rule as `press`. */
62
- readonly type: (request: TypeRequest) => Effect.Effect<InputReceipt, BrowserError>;
63
- readonly screenshot: (request: ScreenshotRequest) => Effect.Effect<ScreenshotResult, BrowserError>;
64
- }
65
- /**
66
- * One explicit page/frame target. Selection may move independently; each operation re-resolves
67
- * this identity inside the same owner and connection. Closing/detaching it or reconnecting makes
68
- * the handle stale before dispatch.
69
- */
70
- export interface PinnedTarget extends TargetOperations {
71
- readonly target: Target;
72
- }
73
- /** A checked selection retained at acquisition; moving selection away and back makes it stale. */
74
- export interface RetainedTarget extends TargetOperations {}
75
- /**
76
- * Host control over one owned browser. This is not a serializable model value: copying a
77
- * session object cannot copy its capture, page-control or connection authority.
78
- *
79
- * The inherited target operations resolve the selected page/frame when their Effect executes.
80
- * Use `retain` to retain the current selection with stale-on-selection-change semantics, or
81
- * `pinPage` / `pinFrame` when work must stay on an explicit target while selection moves.
82
- */
83
- export interface BrowserSession<E = never> extends TargetOperations {
84
- /** The implementation which owns this live connection. */
85
- readonly implementation: string;
86
- /** Copied host-only state, readable without admission in every lifecycle phase. */
87
- readonly status: Effect.Effect<SessionStatus>;
88
- /** Bounded native/policy diagnostics. Typed callback causes remain in bindingDiagnostics. */
89
- readonly diagnostics: Effect.Effect<BrowserDiagnostics>;
90
- /** Close this scope and require its own ownership-specific cleanup evidence. */
91
- readonly closeChecked: Effect.Effect<void, BrowserError>;
92
- /** First fail-session callback cause, preserving the consumer's error type on the host. */
93
- readonly failure: Effect.Effect<never, E | InitializationError>;
94
- /** Bounded host-only evidence; consumer causes are never projected into a page reply. */
95
- readonly bindingDiagnostics: Effect.Effect<BindingDiagnostics<E>>;
96
- /** Resolve, validate and retain the selection under owner admission. */
97
- readonly retain: Effect.Effect<RetainedTarget, BrowserError>;
98
- readonly target: Effect.Effect<Target, BrowserError>;
99
- /**
100
- * The one observation whose nodes later actions may name. `scope: "viewport"` keeps only text
101
- * and controls that are on screen and reachable, plus bounded choices of visible native
102
- * selects; the default reads the whole document. It carries no destination, form or field value.
103
- */
104
- readonly observe: (options?: ObservationOptions) => Effect.Effect<Observation, BrowserError>;
105
- /**
106
- * Passive evidence for a recorder, with a picture when asked. It issues no references and
107
- * leaves the observation above exactly as it was. Host-only: it carries control facts.
108
- */
109
- readonly checkpoint: (options?: CheckpointOptions) => Effect.Effect<Checkpoint, BrowserError>;
110
- /** Host-only facts about one observed control, read from that exact node just now. */
111
- readonly controlFacts: (reference: ObservedElement) => Effect.Effect<ControlFacts, BrowserError>;
112
- /**
113
- * After a page hold, nothing observed on that page may be acted on unchecked. This checks one
114
- * reference: still attached, and still the control that was inspected. It never searches by
115
- * selector or label for a substitute, and it sends nothing.
116
- */
117
- readonly revalidateElement: (reference: ObservedElement) => Effect.Effect<ObservedElement, BrowserError>;
118
- readonly clickElement: (reference: ObservedElement, admission?: ElementAdmission) => Effect.Effect<ActionResult, BrowserError>;
119
- readonly fillElement: (reference: ObservedElement, value: string, admission?: ElementAdmission) => Effect.Effect<ActionResult, BrowserError>;
120
- /** One selection using this exact select and its issued option element IDs, with fresh checks. */
121
- readonly selectOption: (reference: ObservedElement, options: SelectOptions, admission?: ElementAdmission) => Effect.Effect<ActionResult, BrowserError>;
122
- readonly hoverElement: (reference: ObservedElement, admission?: ElementAdmission) => Effect.Effect<InputReceipt, BrowserError>;
123
- /** A key stroke sent only if the exact node an observation named already has focus. */
124
- readonly pressElement: (reference: ObservedElement, stroke: KeyStroke, admission?: ElementAdmission) => Effect.Effect<InputReceipt, BrowserError>;
125
- /** Real typing with `fillElement`'s exactness: that node must already have focus. */
126
- readonly typeElement: (reference: ObservedElement, text: string, admission?: ElementAdmission) => Effect.Effect<InputReceipt, BrowserError>;
127
- /**
128
- * Set several controls of one observation in order, then optionally click one submit control.
129
- * Every step acts on the exact observed node after the same fresh checks as `fillElement`,
130
- * except that a control may have become enabled since it was observed, and each is admitted
131
- * and charged as its own action. The observation stays usable for this form's own steps only;
132
- * anything else that changes the page still retires it, and the form retires it when it ends.
133
- * The first refused or uncertain step ends the form. Submit is sent only after every field
134
- * succeeded and, unless `verify` is false, still holds what its step left there. Fields set
135
- * before a stop stay set. It fails only when its first step does; otherwise `stopped` says
136
- * where it ended and why.
137
- */
138
- readonly fillForm: (request: FillFormRequest, admission?: ElementAdmission, options?: FillFormOptions) => Effect.Effect<FillFormResult, BrowserError>;
139
- readonly pages: Effect.Effect<ReadonlyArray<PageInfo>, BrowserError>;
140
- /**
141
- * One exact page's address and title as they are now, and whether it is selected, without
142
- * reading every other page as `pages` does. An identity that no longer names an open page
143
- * fails undispatched.
144
- */
145
- readonly describePage: (page: PageInfo) => Effect.Effect<PageInfo, BrowserError>;
146
- readonly frames: Effect.Effect<ReadonlyArray<FrameInfo>, BrowserError>;
147
- /** List frames on one exact page without selecting it. */
148
- readonly framesOf: (page: PageInfo) => Effect.Effect<ReadonlyArray<FrameInfo>, BrowserError>;
149
- /** Pin the page's main frame without changing the session selection. */
150
- readonly pinPage: (page: PageInfo) => Effect.Effect<PinnedTarget, BrowserError>;
151
- /** Pin one frame that currently belongs to the exact page, without changing selection. */
152
- readonly pinFrame: (page: PageInfo, frame: FrameInfo) => Effect.Effect<PinnedTarget, BrowserError>;
153
- readonly selectPage: (page: PageInfo) => Effect.Effect<void, BrowserError>;
154
- readonly selectFrame: (frameId: string) => Effect.Effect<void, BrowserError>;
155
- /**
156
- * Open a page in its own window, sized like the others, without selecting it, and return that
157
- * exact page's checked identity. Chromium paints every window, so any page can be pictured
158
- * and read at speed, not only the one in front. It waits its turn behind other operations,
159
- * within its action timeout, rather than failing `busy`.
160
- */
161
- readonly createPage: Effect.Effect<PageInfo, BrowserError>;
162
- readonly closePage: (page: PageInfo) => Effect.Effect<void, BrowserError>;
163
- readonly resizeViewport: (viewport: Viewport) => Effect.Effect<void, BrowserError>;
164
- /**
165
- * Wait on the original observed node within the host deadline. Hidden includes its detachment;
166
- * document replacement is stale. Success observes a condition, without authorizing later input.
167
- */
168
- readonly waitForElement: (request: WaitForElementRequest) => Effect.Effect<void, BrowserError>;
169
- readonly waitFor: (request: {
170
- readonly selector: string;
171
- readonly state: "visible" | "hidden" | "attached" | "detached";
172
- }) => Effect.Effect<void, BrowserError>;
173
- /** Navigation observation is registered before the single click dispatch. */
174
- readonly clickAndWait: (request: ClickRequest) => Effect.Effect<ActionResult, BrowserError>;
175
- /**
176
- * Readiness of the current document only. Dependent operations wait for it themselves;
177
- * this reports it without charging an action, so a caller can decide what to do about a
178
- * document that predates the registrations.
179
- */
180
- readonly ready: Effect.Effect<ReadinessOutcome, InitializationError>;
181
- }
182
- /** Helpers that do not supervise callback failures accept any live browser session. */
183
- export type AnySession = BrowserSession<unknown>;
184
- /** Dependencies are captured at acquisition, not erased into an environment-free service Layer. */
185
- export interface OpenOptions<E = never, R = never> {
186
- readonly bootstrap?: Plan<E, R>;
187
- }
188
- /**
189
- * Acquire, supervise and close one browser in a fresh scope. The callback keeps the concrete
190
- * Chromium or provider session type. Its scoped work is joined before checked browser cleanup,
191
- * and cleanup failures remain typed even when the callback has already failed or was cancelled.
192
- * Acquisition is evaluated once; an uncertain result is never retried.
193
- */
194
- export declare const scoped: {
195
- <S extends BrowserSession<unknown>, A, E2, R2>(f: (session: S) => Effect.Effect<A, E2, R2>): <E, AE, AR>(open: Effect.Effect<S & BrowserSession<E>, AE, AR>) => Effect.Effect<A, AE | E | E2 | InitializationError | BrowserError, Exclude<AR | R2, Scope.Scope>>;
196
- <S, E, AE, AR, A, E2, R2>(open: Effect.Effect<S & BrowserSession<E>, AE, AR>, f: (session: S & BrowserSession<E>) => Effect.Effect<A, E2, R2>): Effect.Effect<A, AE | E | E2 | InitializationError | BrowserError, Exclude<AR | R2, Scope.Scope>>;
197
- };
198
- //#endregion
199
- export {};
200
- //# sourceMappingURL=Browser.d.mts.map
1
+ import { _ as scoped, a as ElementAdmission, c as OpenOptions, d as PageOperations, f as PageStatus, g as checkPage, h as SettledRequest, i as BrowserSession, l as OperationOptions, m as SessionAdmissionStatus, n as AdmissionStatus, o as Frame, p as ResolveOptions, r as AnySession, s as NavigationOperation, t as AdmissionOptions, u as Page } from "./Browser-BF9_sORP.mjs";
2
+ export { AdmissionOptions, AdmissionStatus, AnySession, BrowserSession, ElementAdmission, Frame, NavigationOperation, OpenOptions, OperationOptions, Page, PageOperations, PageStatus, ResolveOptions, SessionAdmissionStatus, SettledRequest, checkPage, scoped };
3
+ export {};
package/dist/Browser.mjs CHANGED
@@ -1,7 +1,15 @@
1
+ import { l as resolveTargetControlsForSession } from "./PageRegistry-B3q9DS3g.mjs";
1
2
  import { Effect } from "effect";
2
3
  import { dual } from "effect/Function";
3
4
  //#region src/Browser.ts
4
5
  /**
6
+ * Check that `page` is a Page or Frame this session issued, by identity, and that its authority
7
+ * is still current: a foreign or copied object fails `UnregisteredSession`, a closed, stale or
8
+ * detached one fails with the same refusal its own operations would report. Adapters such as
9
+ * agent-browser hosts call it once when they bind, so a wrong target fails before any work.
10
+ */
11
+ const checkPage = (session, page) => resolveTargetControlsForSession(session, page).pipe(Effect.asVoid);
12
+ /**
5
13
  * Acquire, supervise and close one browser in a fresh scope. The callback keeps the concrete
6
14
  * Chromium or provider session type. Its scoped work is joined before checked browser cleanup,
7
15
  * and cleanup failures remain typed even when the callback has already failed or was cancelled.
@@ -9,6 +17,6 @@ import { dual } from "effect/Function";
9
17
  */
10
18
  const scoped = dual(2, (open, f) => Effect.scoped(Effect.flatMap(open, (session) => Effect.scoped(Effect.raceFirst(session.failure, Effect.suspend(() => f(session)))).pipe(Effect.onExit(() => session.closeChecked)))));
11
19
  //#endregion
12
- export { scoped };
20
+ export { checkPage, scoped };
13
21
 
14
22
  //# sourceMappingURL=Browser.mjs.map