effect-browser 0.3.0-beta.20 → 0.3.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +221 -158
- package/dist/Action-24sLOubi.d.mts +110 -0
- package/dist/Action.d.mts +2 -0
- package/dist/Action.mjs +141 -0
- package/dist/Action.mjs.map +1 -0
- package/dist/ActionPort.d.mts +15 -0
- package/dist/ActionPort.mjs +101 -0
- package/dist/ActionPort.mjs.map +1 -0
- package/dist/Browser-Cq2K1FEA.mjs +4075 -0
- package/dist/Browser-Cq2K1FEA.mjs.map +1 -0
- package/dist/Browser-wZhwZSlG.d.mts +167 -0
- package/dist/Browser.d.mts +2 -129
- package/dist/Browser.mjs +1 -1
- package/dist/{BrowserError-Coy7EW1N.d.mts → BrowserError-BlcmLVzn.d.mts} +22 -7
- package/dist/BrowserError.d.mts +2 -2
- package/dist/BrowserError.mjs +46 -9
- package/dist/BrowserError.mjs.map +1 -1
- package/dist/{BrowserEvent-dq6FRT8w.d.mts → BrowserEvent-lLqJ3GJS.d.mts} +93 -37
- package/dist/BrowserEvent.d.mts +2 -2
- package/dist/BrowserEvent.mjs +29 -24
- package/dist/BrowserEvent.mjs.map +1 -1
- package/dist/{Change-DqING3tr.d.mts → Change-Ba7INmay.d.mts} +4 -6
- package/dist/Change.d.mts +2 -2
- package/dist/Change.mjs +97 -2
- package/dist/Change.mjs.map +1 -0
- package/dist/Clock.d.mts +57 -0
- package/dist/Clock.mjs +80 -0
- package/dist/Clock.mjs.map +1 -0
- package/dist/{Frame-DkNdjjjr.d.mts → Frame-UEH2hO5T.d.mts} +10 -3
- package/dist/Frame.d.mts +2 -2
- package/dist/Frame.mjs +10 -2
- package/dist/Frame.mjs.map +1 -1
- package/dist/{Motion-DND6I-64.d.mts → Geometry-DJx9qrYy.d.mts} +7 -10
- package/dist/Geometry.d.mts +2 -0
- package/dist/Geometry.mjs +32 -0
- package/dist/Geometry.mjs.map +1 -0
- package/dist/LICENSE-jpeg-js +28 -0
- package/dist/Matching.d.mts +37 -0
- package/dist/{match.inpage-xOe9LNO0.mjs → Matching.mjs} +28 -4
- package/dist/Matching.mjs.map +1 -0
- package/dist/{Page-CfB6Zn1p.mjs → Page-BF5izr8R.mjs} +216 -31
- package/dist/Page-BF5izr8R.mjs.map +1 -0
- package/dist/{Page-ku6j5t-v.d.mts → Page-CvsOEorc.d.mts} +158 -185
- package/dist/Page.d.mts +2 -2
- package/dist/Page.mjs +1 -1
- package/dist/Released-tURbFmal.d.mts +15 -0
- package/dist/{Snapshot-B34hZ4Jl.d.mts → Snapshot-CtBVOtuu.d.mts} +6 -1
- package/dist/Snapshot.d.mts +1 -1
- package/dist/Snapshot.mjs.map +1 -1
- package/dist/Stillness-CNlvayIo.mjs +136 -0
- package/dist/Stillness-CNlvayIo.mjs.map +1 -0
- package/dist/Style-AO4V7Czt.mjs +357 -0
- package/dist/Style-AO4V7Czt.mjs.map +1 -0
- package/dist/Style.d.mts +72 -0
- package/dist/Style.mjs +2 -0
- package/dist/Url.d.mts +26 -0
- package/dist/Url.mjs +74 -0
- package/dist/Url.mjs.map +1 -0
- package/dist/Window-CMddGMt1.d.mts +34 -0
- package/dist/Window.d.mts +2 -0
- package/dist/Window.mjs +35 -0
- package/dist/Window.mjs.map +1 -0
- package/dist/connection-2KHI4_KN.d.mts +41 -0
- package/dist/connection-BTeO0Hiz.mjs +68 -0
- package/dist/connection-BTeO0Hiz.mjs.map +1 -0
- package/dist/index.d.mts +15 -17
- package/dist/index.mjs +11 -14
- package/dist/moment/Moment.d.mts +86 -0
- package/dist/{Moment.mjs → moment/Moment.mjs} +44 -38
- package/dist/moment/Moment.mjs.map +1 -0
- package/dist/{Plan-DJ4hEEna.d.mts → plan/index.d.mts} +169 -64
- package/dist/{Plan-C-d5QYS8.mjs → plan/index.mjs} +122 -155
- package/dist/plan/index.mjs.map +1 -0
- package/dist/{Policy.d.mts → policy/Policy.d.mts} +5 -9
- package/dist/{Policy.mjs → policy/Policy.mjs} +11 -21
- package/dist/policy/Policy.mjs.map +1 -0
- package/dist/presentation/Motion.d.mts +12 -0
- package/dist/{Motion.mjs → presentation/Motion.mjs} +4 -27
- package/dist/presentation/Motion.mjs.map +1 -0
- package/dist/presentation/Presentation.d.mts +30 -0
- package/dist/presentation/Presentation.mjs +105 -0
- package/dist/presentation/Presentation.mjs.map +1 -0
- package/dist/{Stage.d.mts → presentation/Stage.d.mts} +5 -8
- package/dist/{Stage.mjs → presentation/Stage.mjs} +68 -76
- package/dist/presentation/Stage.mjs.map +1 -0
- package/dist/presentation/feed.d.mts +20 -0
- package/dist/presentation/feed.mjs +18 -0
- package/dist/presentation/feed.mjs.map +1 -0
- package/dist/providers/Cdp.d.mts +9 -0
- package/dist/providers/Cdp.mjs +15 -0
- package/dist/providers/Cdp.mjs.map +1 -0
- package/dist/{Chromium.d.mts → providers/Chromium.d.mts} +6 -7
- package/dist/{Chromium.mjs → providers/Chromium.mjs} +7 -16
- package/dist/providers/Chromium.mjs.map +1 -0
- package/dist/providers/Released.d.mts +2 -0
- package/dist/providers/Released.mjs +12 -0
- package/dist/providers/Released.mjs.map +1 -0
- package/dist/stillness/Stillness.d.mts +12 -0
- package/dist/stillness/Stillness.mjs +2 -0
- package/dist/supervisor/Supervisor.d.mts +104 -0
- package/dist/supervisor/Supervisor.mjs +513 -0
- package/dist/supervisor/Supervisor.mjs.map +1 -0
- package/dist/testing/index.d.mts +337 -0
- package/dist/testing/index.mjs +515 -0
- package/dist/testing/index.mjs.map +1 -0
- package/dist/workerd/Cdp.d.mts +8 -0
- package/dist/workerd/Cdp.mjs +13 -0
- package/dist/workerd/Cdp.mjs.map +1 -0
- package/package.json +94 -33
- package/src/Action.ts +127 -0
- package/src/ActionPort.ts +128 -0
- package/src/Browser.ts +366 -225
- package/src/BrowserError.ts +63 -6
- package/src/BrowserEvent.ts +26 -25
- package/src/Change.ts +0 -2
- package/src/{internal/pictures/clock.ts → Clock.ts} +17 -6
- package/src/Frame.ts +14 -0
- package/src/Geometry.ts +48 -0
- package/src/{internal/reading/match.inpage.ts → Matching.ts} +34 -4
- package/src/Page.ts +111 -92
- package/src/Snapshot.ts +5 -0
- package/src/{internal/input/style.ts → Style.ts} +121 -14
- package/src/Window.ts +30 -0
- package/src/index.ts +8 -13
- package/src/internal/input/actions.ts +61 -119
- package/src/internal/input/dispatch.ts +3 -3
- package/src/internal/input/gate.ts +21 -18
- package/src/internal/input/guard.inpage.ts +25 -58
- package/src/internal/input/guard.ts +11 -20
- package/src/internal/input/keyboard.ts +12 -3
- package/src/internal/input/perform.ts +78 -60
- package/src/internal/input/pointer.ts +4 -2
- package/src/internal/input/settle.ts +7 -5
- package/src/internal/input/targets.inpage.ts +1 -1
- package/src/internal/input/targets.ts +4 -9
- package/src/internal/page/bridge.ts +210 -114
- package/src/internal/page/context.ts +23 -73
- package/src/internal/page/dialogs.ts +58 -0
- package/src/internal/page/identity.ts +6 -23
- package/src/internal/page/lane.ts +14 -15
- package/src/internal/page/navigation.ts +50 -42
- package/src/internal/page/openings.ts +11 -5
- package/src/internal/page/page.ts +44 -81
- package/src/internal/page/port.ts +125 -0
- package/src/internal/{input → page}/replies.ts +1 -1
- package/src/internal/page/request-owner.ts +269 -0
- package/src/internal/page/requests.ts +357 -0
- package/src/internal/page/scripts.ts +124 -0
- package/src/internal/pictures/capture.ts +255 -332
- package/src/internal/pictures/dimensions.ts +162 -0
- package/src/internal/pictures/frame.ts +68 -0
- package/src/internal/pictures/pictures.ts +57 -23
- package/src/internal/pictures/quiescence.ts +1 -1
- package/src/internal/pictures/state.ts +26 -0
- package/src/internal/pictures/transport.ts +21 -4
- package/src/internal/reading/controls.inpage.ts +5 -70
- package/src/internal/reading/expect.inpage.ts +13 -17
- package/src/internal/reading/names.inpage.ts +89 -45
- package/src/internal/reading/outline.inpage.ts +6 -7
- package/src/internal/reading/reading.ts +144 -176
- package/src/internal/reading/ready.inpage.ts +6 -17
- package/src/internal/reading/ready.ts +13 -135
- package/src/internal/reading/subjects.inpage.ts +83 -43
- package/src/internal/reading/walk.inpage.ts +33 -13
- package/src/internal/timeline/changes.ts +55 -6
- package/src/internal/timeline/events.ts +15 -5
- package/src/internal/timeline/history.inpage.ts +1 -1
- package/src/internal/timeline/record.inpage.ts +4 -1
- package/src/internal/timeline/window.ts +2 -1
- package/src/{Moment.ts → moment/Moment.ts} +13 -31
- package/src/{internal/timeline → moment}/words.ts +2 -2
- package/src/{internal/reading → plan}/choose.ts +3 -3
- package/src/plan/data.ts +117 -0
- package/src/plan/execute.ts +411 -0
- package/src/plan/index.ts +36 -0
- package/src/plan/record.ts +71 -0
- package/src/plan/targets.ts +71 -0
- package/src/{Policy.ts → policy/Policy.ts} +13 -10
- package/src/{Motion.ts → presentation/Motion.ts} +12 -46
- package/src/presentation/Presentation.ts +176 -0
- package/src/{Stage.ts → presentation/Stage.ts} +147 -112
- package/src/presentation/feed.ts +21 -0
- package/src/providers/Cdp.ts +16 -0
- package/src/{Chromium.ts → providers/Chromium.ts} +7 -10
- package/src/providers/Released.ts +13 -0
- package/src/providers/connection.ts +134 -0
- package/src/{internal/pictures/motion.ts → stillness/Pixels.ts} +4 -4
- package/src/stillness/Stillness.ts +166 -0
- package/src/supervisor/Supervisor.ts +170 -0
- package/src/supervisor/contract.ts +105 -0
- package/src/supervisor/lifecycle.ts +272 -0
- package/src/supervisor/runtime.ts +234 -0
- package/src/testing/TestBrowser.ts +115 -0
- package/src/testing/TestPage.ts +10 -0
- package/src/testing/evidence.ts +154 -0
- package/src/testing/index.ts +3 -0
- package/src/testing/model.ts +222 -0
- package/src/testing/page.ts +360 -0
- package/src/workerd/Cdp.ts +11 -0
- package/dist/Browser-BwCldIff.mjs +0 -629
- package/dist/Browser-BwCldIff.mjs.map +0 -1
- package/dist/Cdp.d.mts +0 -32
- package/dist/Cdp.mjs +0 -61
- package/dist/Cdp.mjs.map +0 -1
- package/dist/Change-DNvztNLu.mjs +0 -138
- package/dist/Change-DNvztNLu.mjs.map +0 -1
- package/dist/Chromium.mjs.map +0 -1
- package/dist/Expect.d.mts +0 -62
- package/dist/Expect.mjs +0 -114
- package/dist/Expect.mjs.map +0 -1
- package/dist/Moment.d.mts +0 -2
- package/dist/Moment.mjs.map +0 -1
- package/dist/Motion.d.mts +0 -2
- package/dist/Motion.mjs.map +0 -1
- package/dist/Page-CfB6Zn1p.mjs.map +0 -1
- package/dist/Plan-C-d5QYS8.mjs.map +0 -1
- package/dist/Plan.d.mts +0 -2
- package/dist/Plan.mjs +0 -2
- package/dist/Policy.mjs.map +0 -1
- package/dist/Presentation.d.mts +0 -48
- package/dist/Presentation.mjs +0 -118
- package/dist/Presentation.mjs.map +0 -1
- package/dist/Stage.mjs.map +0 -1
- package/dist/Supervisor-2mPjIYYs.mjs +0 -676
- package/dist/Supervisor-2mPjIYYs.mjs.map +0 -1
- package/dist/Supervisor-mVPeEUp8.d.mts +0 -317
- package/dist/Supervisor.d.mts +0 -2
- package/dist/Supervisor.mjs +0 -2
- package/dist/context-w3NJPRLo.mjs +0 -335
- package/dist/context-w3NJPRLo.mjs.map +0 -1
- package/dist/match.inpage-xOe9LNO0.mjs.map +0 -1
- package/dist/page-BKwfF6z-.mjs +0 -5099
- package/dist/page-BKwfF6z-.mjs.map +0 -1
- package/dist/url-Cd04Okid.mjs +0 -264
- package/dist/url-Cd04Okid.mjs.map +0 -1
- package/src/Cdp.ts +0 -101
- package/src/Expect.ts +0 -180
- package/src/Plan.ts +0 -674
- package/src/Presentation.ts +0 -196
- package/src/Supervisor.ts +0 -632
- package/src/internal/supervisor/lifecycle.ts +0 -484
- /package/src/{internal/page/url.ts → Url.ts} +0 -0
- /package/src/{internal/pictures → stillness}/utilsBundle.d.ts +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { t as BrowserError } from "./BrowserError-BlcmLVzn.mjs";
|
|
2
|
+
import { E as WheelScrolled, S as TextInserted, T as TrackPlanned, a as CursorChanged, c as Disconnected, d as PageClosed, f as PageLoaded, g as PointerReleased, h as PointerPressed, l as KeyChanged, m as PageUntracked, o as DialogShown, p as PageOpened, t as Action, u as Navigated, v as RequestRefused, w as TrackPerformed, y as SessionEnding } from "./BrowserEvent-lLqJ3GJS.mjs";
|
|
3
|
+
import { r as Changes } from "./Change-Ba7INmay.mjs";
|
|
4
|
+
import { r as Frame } from "./Frame-UEH2hO5T.mjs";
|
|
5
|
+
import { Schema } from "effect";
|
|
6
|
+
declare namespace Window_d_exports {
|
|
7
|
+
export { Window };
|
|
8
|
+
}
|
|
9
|
+
declare const Window_base: Schema.Class<Window, Schema.Struct<{
|
|
10
|
+
readonly page: Schema.String;
|
|
11
|
+
/** Where the window starts, in host monotonic milliseconds on the owning browser’s clock. */
|
|
12
|
+
readonly since: Schema.Finite;
|
|
13
|
+
/** Where it ends, never after it was taken. */
|
|
14
|
+
readonly until: Schema.Finite;
|
|
15
|
+
/** The page's events after `since`, up to `until`, oldest first, without the input presentation track. */
|
|
16
|
+
readonly events: Schema.$Array<Schema.Union<readonly [typeof RequestRefused, 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]>>;
|
|
17
|
+
/**
|
|
18
|
+
* What visibly changed after `since`, up to `until`; absent where `missing` says why. A page's
|
|
19
|
+
* first window starts its record, so the record sees none of it.
|
|
20
|
+
*/
|
|
21
|
+
readonly changes: Schema.optional<typeof Changes>;
|
|
22
|
+
/** Screencast frames painted from `since` to `until`, oldest first, as far back as kept. */
|
|
23
|
+
readonly frames: Schema.$Array<typeof Frame>;
|
|
24
|
+
/**
|
|
25
|
+
* Why each part that could not be read is missing: the read of its changes, by whatever
|
|
26
|
+
* operation failed there, or a moment's picture (`frame`) or outline (`snapshot`).
|
|
27
|
+
*/
|
|
28
|
+
readonly missing: Schema.$Array<typeof BrowserError>;
|
|
29
|
+
}>, {}>;
|
|
30
|
+
/** A page's events, changes and frames over one window of its browser's host clock. */
|
|
31
|
+
declare class Window extends Window_base {}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Window_d_exports as n, Window as t };
|
|
34
|
+
//# sourceMappingURL=Window-CMddGMt1.d.mts.map
|
package/dist/Window.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { BrowserEvent } from "./BrowserEvent.mjs";
|
|
3
|
+
import { BrowserError } from "./BrowserError.mjs";
|
|
4
|
+
import { Frame } from "./Frame.mjs";
|
|
5
|
+
import { Changes } from "./Change.mjs";
|
|
6
|
+
import { Schema } from "effect";
|
|
7
|
+
//#region src/Window.ts
|
|
8
|
+
/** A bounded window of a page's events, visible changes and frames on the owning clock. */
|
|
9
|
+
var Window_exports = /* @__PURE__ */ __exportAll({ Window: () => Window });
|
|
10
|
+
/** A page's events, changes and frames over one window of its browser's host clock. */
|
|
11
|
+
var Window = class extends Schema.Class("effect-browser/Window")({
|
|
12
|
+
page: Schema.String,
|
|
13
|
+
/** Where the window starts, in host monotonic milliseconds on the owning browser’s clock. */
|
|
14
|
+
since: Schema.Finite,
|
|
15
|
+
/** Where it ends, never after it was taken. */
|
|
16
|
+
until: Schema.Finite,
|
|
17
|
+
/** The page's events after `since`, up to `until`, oldest first, without the input presentation track. */
|
|
18
|
+
events: Schema.Array(BrowserEvent),
|
|
19
|
+
/**
|
|
20
|
+
* What visibly changed after `since`, up to `until`; absent where `missing` says why. A page's
|
|
21
|
+
* first window starts its record, so the record sees none of it.
|
|
22
|
+
*/
|
|
23
|
+
changes: Schema.optional(Changes),
|
|
24
|
+
/** Screencast frames painted from `since` to `until`, oldest first, as far back as kept. */
|
|
25
|
+
frames: Schema.Array(Frame),
|
|
26
|
+
/**
|
|
27
|
+
* Why each part that could not be read is missing: the read of its changes, by whatever
|
|
28
|
+
* operation failed there, or a moment's picture (`frame`) or outline (`snapshot`).
|
|
29
|
+
*/
|
|
30
|
+
missing: Schema.Array(BrowserError)
|
|
31
|
+
}) {};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Window, Window_exports as t };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=Window.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Window.mjs","names":[],"sources":["../src/Window.ts"],"sourcesContent":["/** A bounded window of a page's events, visible changes and frames on the owning clock. */\nimport { Schema } from \"effect\";\n\nimport { BrowserError } from \"./BrowserError.ts\";\nimport { BrowserEvent } from \"./BrowserEvent.ts\";\nimport { Changes } from \"./Change.ts\";\nimport { Frame } from \"./Frame.ts\";\n\n/** A page's events, changes and frames over one window of its browser's host clock. */\nexport class Window extends Schema.Class<Window>(\"effect-browser/Window\")({\n page: Schema.String,\n /** Where the window starts, in host monotonic milliseconds on the owning browser’s clock. */\n since: Schema.Finite,\n /** Where it ends, never after it was taken. */\n until: Schema.Finite,\n /** The page's events after `since`, up to `until`, oldest first, without the input presentation track. */\n events: Schema.Array(BrowserEvent),\n /**\n * What visibly changed after `since`, up to `until`; absent where `missing` says why. A page's\n * first window starts its record, so the record sees none of it.\n */\n changes: Schema.optional(Changes),\n /** Screencast frames painted from `since` to `until`, oldest first, as far back as kept. */\n frames: Schema.Array(Frame),\n /**\n * Why each part that could not be read is missing: the read of its changes, by whatever\n * operation failed there, or a moment's picture (`frame`) or outline (`snapshot`).\n */\n missing: Schema.Array(BrowserError),\n}) {}\n"],"mappings":";;;;;;;;;;AASA,IAAa,SAAb,cAA4B,OAAO,MAAc,uBAAuB,CAAC,CAAC;CACxE,MAAM,OAAO;;CAEb,OAAO,OAAO;;CAEd,OAAO,OAAO;;CAEd,QAAQ,OAAO,MAAM,YAAY;;;;;CAKjC,SAAS,OAAO,SAAS,OAAO;;CAEhC,QAAQ,OAAO,MAAM,KAAK;;;;;CAK1B,SAAS,OAAO,MAAM,YAAY;AACpC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import "./BrowserError-BlcmLVzn.mjs";
|
|
2
|
+
import { n as Browser_d_exports, o as Options$1, r as CaptureSource } from "./Browser-wZhwZSlG.mjs";
|
|
3
|
+
import { DateTime, Effect, Layer, Redacted } from "effect";
|
|
4
|
+
import { Browser } from "playwright-core";
|
|
5
|
+
//#region src/providers/connection.d.ts
|
|
6
|
+
/** The runtime connector receives the bound and cancellation signal owned by the opening scope. */
|
|
7
|
+
interface ConnectOptions {
|
|
8
|
+
readonly timeout: number;
|
|
9
|
+
readonly headers?: Readonly<Record<string, string>> | undefined;
|
|
10
|
+
readonly signal: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Return a real Playwright CDP browser whose `close()` disconnects without ending the remote
|
|
14
|
+
* browser. Honor `signal` to cancel work; a browser returned after cancellation is disconnected.
|
|
15
|
+
* The endpoint and headers may contain credentials and must not be logged.
|
|
16
|
+
*/
|
|
17
|
+
type Connector = (endpoint: string, options: ConnectOptions) => Promise<Browser>;
|
|
18
|
+
interface Options extends Options$1, Pick<ConnectOptions, "headers"> {
|
|
19
|
+
/**
|
|
20
|
+
* `ws://`, `wss://` or `http://` DevTools endpoint. Often a credential, so it may be redacted;
|
|
21
|
+
* connect failures never include its userinfo, path or query.
|
|
22
|
+
*/
|
|
23
|
+
readonly endpoint: string | Redacted.Redacted<string>;
|
|
24
|
+
/** Runtime-supplied Playwright connection. Required by the `workerd` entry. */
|
|
25
|
+
readonly connect?: Connector | undefined;
|
|
26
|
+
/** Identifies the session in `Browser.id`. Defaults to `"cdp"`. */
|
|
27
|
+
readonly id?: string | undefined;
|
|
28
|
+
readonly provider?: string | undefined;
|
|
29
|
+
/** Bound on connecting. Defaults to 30 seconds. */
|
|
30
|
+
readonly connectTimeoutMillis?: number | undefined;
|
|
31
|
+
/** When the provider ends the session on its own, as a hosted session's timeout does. */
|
|
32
|
+
readonly expiresAt?: DateTime.Utc | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* A connection apart from this one for the pages' screencasts, as a hosted provider supplies.
|
|
35
|
+
* Without one, each page's capture runs on its own session.
|
|
36
|
+
*/
|
|
37
|
+
readonly capture?: CaptureSource | undefined;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { Connector as n, Options as r, ConnectOptions as t };
|
|
41
|
+
//# sourceMappingURL=connection-2KHI4_KN.d.mts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { quoted } from "./Url.mjs";
|
|
2
|
+
import { InvalidRequest, Timeout, reasonOf, undispatched } from "./BrowserError.mjs";
|
|
3
|
+
import { i as make$1, t as Browser } from "./Browser-Cq2K1FEA.mjs";
|
|
4
|
+
import { Effect, Layer, Redacted } from "effect";
|
|
5
|
+
//#region src/providers/connection.ts
|
|
6
|
+
/**
|
|
7
|
+
* A browser reached over the Chrome DevTools Protocol: a Chrome started with
|
|
8
|
+
* `--remote-debugging-port`, or any provider that hands out a CDP WebSocket URL.
|
|
9
|
+
*
|
|
10
|
+
* Closing the scope disconnects. It does not close the remote browser; its owner does that.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.3.0
|
|
13
|
+
*/
|
|
14
|
+
/** Runtime facades supply the default transport; the shared lifetime imports no Node transport. */
|
|
15
|
+
const make = (defaultConnect) => {
|
|
16
|
+
const open = Effect.fn("Cdp.open")(function* (options) {
|
|
17
|
+
const endpoint = Redacted.isRedacted(options.endpoint) ? Redacted.value(options.endpoint) : options.endpoint;
|
|
18
|
+
const timeout = options.connectTimeoutMillis ?? 3e4;
|
|
19
|
+
const connector = options.connect ?? defaultConnect;
|
|
20
|
+
const headers = options.headers === void 0 ? void 0 : { ...options.headers };
|
|
21
|
+
const invalid = (detail) => undispatched("connect", new InvalidRequest({ detail }));
|
|
22
|
+
if (!Number.isFinite(timeout) || timeout <= 0) return yield* invalid("connectTimeoutMillis must be finite and greater than zero");
|
|
23
|
+
if (connector === void 0) return yield* invalid("This runtime requires a CDP connect callback");
|
|
24
|
+
const redact = (message) => {
|
|
25
|
+
if (Object.values(headers ?? {}).some((value) => value !== "" && message.includes(value))) return "CDP diagnostic withheld";
|
|
26
|
+
const origins = message.replace(quoted, (url) => {
|
|
27
|
+
const parsed = URL.parse(url);
|
|
28
|
+
return parsed?.host ? `${parsed.protocol}//${parsed.host}` : "<url>";
|
|
29
|
+
});
|
|
30
|
+
return endpoint === "" ? origins : origins.replaceAll(endpoint, "<endpoint>");
|
|
31
|
+
};
|
|
32
|
+
const failed = (cause, timeoutMillis) => undispatched("connect", reasonOf(cause, timeoutMillis, "connection", redact));
|
|
33
|
+
const connected = yield* Effect.acquireRelease(Effect.tryPromise({
|
|
34
|
+
try: (signal) => connector(endpoint, {
|
|
35
|
+
timeout,
|
|
36
|
+
signal,
|
|
37
|
+
...headers === void 0 ? {} : { headers: { ...headers } }
|
|
38
|
+
}).then(async (browser) => {
|
|
39
|
+
if (signal.aborted) await browser.close().catch(() => void 0);
|
|
40
|
+
return browser;
|
|
41
|
+
}),
|
|
42
|
+
catch: (cause) => failed(cause, timeout)
|
|
43
|
+
}).pipe(Effect.timeoutOrElse({
|
|
44
|
+
duration: timeout,
|
|
45
|
+
orElse: () => Effect.fail(undispatched("connect", new Timeout({ millis: timeout })))
|
|
46
|
+
}), Effect.withSpan("Cdp.connect", {}, { captureStackTrace: false })), (browser) => Effect.tryPromise(() => browser.close()).pipe(Effect.ignore), { interruptible: true });
|
|
47
|
+
const context = connected.contexts()[0] ?? (yield* Effect.tryPromise({
|
|
48
|
+
try: () => connected.newContext(),
|
|
49
|
+
catch: (cause) => failed(cause)
|
|
50
|
+
}));
|
|
51
|
+
const { id = "cdp", provider = "cdp", expiresAt, capture } = options;
|
|
52
|
+
return yield* make$1(context, {
|
|
53
|
+
id,
|
|
54
|
+
provider,
|
|
55
|
+
expiresAt,
|
|
56
|
+
capture
|
|
57
|
+
}, options);
|
|
58
|
+
});
|
|
59
|
+
const layer = (options) => Layer.effect(Browser, open(options));
|
|
60
|
+
return {
|
|
61
|
+
open,
|
|
62
|
+
layer
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
//#endregion
|
|
66
|
+
export { make as t };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=connection-BTeO0Hiz.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-BTeO0Hiz.mjs","names":["Errors.InvalidRequest","Url.quoted","Errors.Timeout","Browser.make","Browser.Browser"],"sources":["../src/providers/connection.ts"],"sourcesContent":["/**\n * A browser reached over the Chrome DevTools Protocol: a Chrome started with\n * `--remote-debugging-port`, or any provider that hands out a CDP WebSocket URL.\n *\n * Closing the scope disconnects. It does not close the remote browser; its owner does that.\n *\n * @since 0.3.0\n */\nimport { type DateTime, Effect, Layer, Redacted } from \"effect\";\nimport type { Browser as PlaywrightBrowser } from \"playwright-core\";\n\nimport * as Browser from \"../Browser.ts\";\nimport * as Errors from \"../BrowserError.ts\";\nimport { reasonOf, undispatched } from \"../BrowserError.ts\";\nimport * as Url from \"../Url.ts\";\n\n/** The runtime connector receives the bound and cancellation signal owned by the opening scope. */\nexport interface ConnectOptions {\n readonly timeout: number;\n readonly headers?: Readonly<Record<string, string>> | undefined;\n readonly signal: AbortSignal;\n}\n\n/**\n * Return a real Playwright CDP browser whose `close()` disconnects without ending the remote\n * browser. Honor `signal` to cancel work; a browser returned after cancellation is disconnected.\n * The endpoint and headers may contain credentials and must not be logged.\n */\nexport type Connector = (endpoint: string, options: ConnectOptions) => Promise<PlaywrightBrowser>;\n\nexport interface Options extends Browser.Options, Pick<ConnectOptions, \"headers\"> {\n /**\n * `ws://`, `wss://` or `http://` DevTools endpoint. Often a credential, so it may be redacted;\n * connect failures never include its userinfo, path or query.\n */\n readonly endpoint: string | Redacted.Redacted<string>;\n /** Runtime-supplied Playwright connection. Required by the `workerd` entry. */\n readonly connect?: Connector | undefined;\n /** Identifies the session in `Browser.id`. Defaults to `\"cdp\"`. */\n readonly id?: string | undefined;\n readonly provider?: string | undefined;\n /** Bound on connecting. Defaults to 30 seconds. */\n readonly connectTimeoutMillis?: number | undefined;\n /** When the provider ends the session on its own, as a hosted session's timeout does. */\n readonly expiresAt?: DateTime.Utc | undefined;\n /**\n * A connection apart from this one for the pages' screencasts, as a hosted provider supplies.\n * Without one, each page's capture runs on its own session.\n */\n readonly capture?: Browser.CaptureSource | undefined;\n}\n\n/** Runtime facades supply the default transport; the shared lifetime imports no Node transport. */\nexport const make = (defaultConnect?: Connector) => {\n const open = Effect.fn(\"Cdp.open\")(function* (options: Options) {\n const endpoint = Redacted.isRedacted(options.endpoint)\n ? Redacted.value(options.endpoint)\n : options.endpoint;\n\n const timeout = options.connectTimeoutMillis ?? 30_000;\n const connector = options.connect ?? defaultConnect;\n const headers = options.headers === undefined ? undefined : { ...options.headers };\n\n const invalid = (detail: string) =>\n undispatched(\"connect\", new Errors.InvalidRequest({ detail }));\n\n if (!Number.isFinite(timeout) || timeout <= 0)\n return yield* invalid(\"connectTimeoutMillis must be finite and greater than zero\");\n if (connector === undefined)\n return yield* invalid(\"This runtime requires a CDP connect callback\");\n\n // Inspect before URL normalization or truncation. Withhold an echoed diagnostic entirely so\n // overlapping header values cannot leave fragments; other URLs keep only their scheme and host.\n const redact = (message: string) => {\n if (Object.values(headers ?? {}).some((value) => value !== \"\" && message.includes(value)))\n return \"CDP diagnostic withheld\";\n\n const origins = message.replace(Url.quoted, (url) => {\n const parsed = URL.parse(url);\n\n return parsed?.host ? `${parsed.protocol}//${parsed.host}` : \"<url>\";\n });\n\n return endpoint === \"\" ? origins : origins.replaceAll(endpoint, \"<endpoint>\");\n };\n\n const failed = (cause: unknown, timeoutMillis?: number) =>\n undispatched(\"connect\", reasonOf(cause, timeoutMillis, \"connection\", redact));\n\n // The endpoint is often a credential, so the connect span names no part of it.\n const connected = yield* Effect.acquireRelease(\n Effect.tryPromise({\n try: (signal) =>\n connector(endpoint, {\n timeout,\n signal,\n ...(headers === undefined ? {} : { headers: { ...headers } }),\n }).then(async (browser) => {\n // Cancellation can precede a connector that ignores its signal. Its late browser still\n // belongs to this acquisition, so disconnect it before dropping the promise result.\n if (signal.aborted) await browser.close().catch(() => undefined);\n\n return browser;\n }),\n catch: (cause) => failed(cause, timeout),\n }).pipe(\n Effect.timeoutOrElse({\n duration: timeout,\n orElse: () =>\n Effect.fail(undispatched(\"connect\", new Errors.Timeout({ millis: timeout }))),\n }),\n Effect.withSpan(\"Cdp.connect\", {}, { captureStackTrace: false }),\n ),\n (browser) => Effect.tryPromise(() => browser.close()).pipe(Effect.ignore),\n { interruptible: true },\n );\n\n const context =\n connected.contexts()[0] ??\n (yield* Effect.tryPromise({\n try: () => connected.newContext(),\n catch: (cause) => failed(cause),\n }));\n\n const { id = \"cdp\", provider = \"cdp\", expiresAt, capture } = options;\n\n return yield* Browser.make(context, { id, provider, expiresAt, capture }, options);\n });\n\n const layer = (options: Options): Layer.Layer<Browser.Browser, Errors.BrowserError> =>\n Layer.effect(Browser.Browser, open(options));\n\n return { open, layer };\n};\n"],"mappings":";;;;;;;;;;;;;;AAqDA,MAAa,QAAQ,mBAA+B;CAClD,MAAM,OAAO,OAAO,GAAG,UAAU,CAAC,CAAC,WAAW,SAAkB;EAC9D,MAAM,WAAW,SAAS,WAAW,QAAQ,QAAQ,IACjD,SAAS,MAAM,QAAQ,QAAQ,IAC/B,QAAQ;EAEZ,MAAM,UAAU,QAAQ,wBAAwB;EAChD,MAAM,YAAY,QAAQ,WAAW;EACrC,MAAM,UAAU,QAAQ,YAAY,KAAA,IAAY,KAAA,IAAY,EAAE,GAAG,QAAQ,QAAQ;EAEjF,MAAM,WAAW,WACf,aAAa,WAAW,IAAIA,eAAsB,EAAE,OAAO,CAAC,CAAC;EAE/D,IAAI,CAAC,OAAO,SAAS,OAAO,KAAK,WAAW,GAC1C,OAAO,OAAO,QAAQ,2DAA2D;EACnF,IAAI,cAAc,KAAA,GAChB,OAAO,OAAO,QAAQ,8CAA8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K;EAChC,CAAC;EAEH,MAAM,EAAE,KAAK,OAAO,WAAW,OAAO,WAAW,YAAY;EAE7D,OAAO,OAAOC,OAAa,SAAS;GAAE;GAAI;GAAU;GAAW;EAAQ,GAAG,OAAO;CACnF,CAAC;CAED,MAAM,SAAS,YACb,MAAM,OAAOC,SAAiB,KAAK,OAAO,CAAC;CAE7C,OAAO;EAAE;EAAM;CAAM;AACvB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { t as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { t as
|
|
14
|
-
import { t as
|
|
15
|
-
|
|
16
|
-
import { l as Supervisor_d_exports } from "./Supervisor-mVPeEUp8.mjs";
|
|
17
|
-
export { Browser_d_exports as Browser, BrowserError_d_exports as BrowserError, BrowserEvent_d_exports as BrowserEvent, Cdp_d_exports as Cdp, Change_d_exports as Change, Chromium_d_exports as Chromium, Expect_d_exports as Expect, Frame_d_exports as Frame, Moment_d_exports as Moment, Motion_d_exports as Motion, Page_d_exports as Page, Plan_d_exports as Plan, Policy_d_exports as Policy, Presentation_d_exports as Presentation, Snapshot_d_exports as Snapshot, Stage_d_exports as Stage, Supervisor_d_exports as Supervisor };
|
|
1
|
+
import { n as Action_d_exports } from "./Action-24sLOubi.mjs";
|
|
2
|
+
import { n as BrowserError_d_exports } from "./BrowserError-BlcmLVzn.mjs";
|
|
3
|
+
import { i as BrowserEvent_d_exports } from "./BrowserEvent-lLqJ3GJS.mjs";
|
|
4
|
+
import { n as Change_d_exports } from "./Change-Ba7INmay.mjs";
|
|
5
|
+
import { i as Frame_d_exports } from "./Frame-UEH2hO5T.mjs";
|
|
6
|
+
import { t as Geometry_d_exports } from "./Geometry-DJx9qrYy.mjs";
|
|
7
|
+
import { i as Snapshot_d_exports } from "./Snapshot-CtBVOtuu.mjs";
|
|
8
|
+
import { n as Window_d_exports } from "./Window-CMddGMt1.mjs";
|
|
9
|
+
import { p as Page_d_exports } from "./Page-CvsOEorc.mjs";
|
|
10
|
+
import { t as ActionPort_d_exports } from "./ActionPort.mjs";
|
|
11
|
+
import { n as Browser_d_exports } from "./Browser-wZhwZSlG.mjs";
|
|
12
|
+
import { t as Clock_d_exports } from "./Clock.mjs";
|
|
13
|
+
import { t as Style_d_exports } from "./Style.mjs";
|
|
14
|
+
import { t as Url_d_exports } from "./Url.mjs";
|
|
15
|
+
export { Action_d_exports as Action, ActionPort_d_exports as ActionPort, Browser_d_exports as Browser, BrowserError_d_exports as BrowserError, BrowserEvent_d_exports as BrowserEvent, Change_d_exports as Change, Clock_d_exports as Clock, Frame_d_exports as Frame, Geometry_d_exports as Geometry, Page_d_exports as Page, Snapshot_d_exports as Snapshot, Style_d_exports as Style, Url_d_exports as Url, Window_d_exports as Window };
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as Geometry_exports } from "./Geometry.mjs";
|
|
2
|
+
import { t as Url_exports } from "./Url.mjs";
|
|
3
|
+
import { t as Action_exports } from "./Action.mjs";
|
|
2
4
|
import { t as BrowserEvent_exports } from "./BrowserEvent.mjs";
|
|
3
5
|
import { t as BrowserError_exports } from "./BrowserError.mjs";
|
|
4
|
-
import { n as Browser_exports } from "./Browser-BwCldIff.mjs";
|
|
5
6
|
import { t as Frame_exports } from "./Frame.mjs";
|
|
6
|
-
import { a as Page_exports } from "./Page-
|
|
7
|
+
import { a as Page_exports } from "./Page-BF5izr8R.mjs";
|
|
7
8
|
import { t as Snapshot_exports } from "./Snapshot.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { t as
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
import { t as Presentation_exports } from "./Presentation.mjs";
|
|
16
|
-
import { t as Stage_exports } from "./Stage.mjs";
|
|
17
|
-
import { i as Supervisor_exports } from "./Supervisor-2mPjIYYs.mjs";
|
|
18
|
-
export { Browser_exports as Browser, BrowserError_exports as BrowserError, BrowserEvent_exports as BrowserEvent, Cdp_exports as Cdp, Change_exports as Change, Chromium_exports as Chromium, Expect_exports as Expect, Frame_exports as Frame, Moment_exports as Moment, Motion_exports as Motion, Page_exports as Page, Plan_exports as Plan, Policy_exports as Policy, Presentation_exports as Presentation, Snapshot_exports as Snapshot, Stage_exports as Stage, Supervisor_exports as Supervisor };
|
|
9
|
+
import { t as ActionPort_exports } from "./ActionPort.mjs";
|
|
10
|
+
import { t as Clock_exports } from "./Clock.mjs";
|
|
11
|
+
import { n as Browser_exports } from "./Browser-Cq2K1FEA.mjs";
|
|
12
|
+
import { n as Style_exports } from "./Style-AO4V7Czt.mjs";
|
|
13
|
+
import { t as Change_exports } from "./Change.mjs";
|
|
14
|
+
import { t as Window_exports } from "./Window.mjs";
|
|
15
|
+
export { Action_exports as Action, ActionPort_exports as ActionPort, Browser_exports as Browser, BrowserError_exports as BrowserError, BrowserEvent_exports as BrowserEvent, Change_exports as Change, Clock_exports as Clock, Frame_exports as Frame, Geometry_exports as Geometry, Page_exports as Page, Snapshot_exports as Snapshot, Style_exports as Style, Url_exports as Url, Window_exports as Window };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { t as BrowserError } from "../BrowserError-BlcmLVzn.mjs";
|
|
2
|
+
import { E as WheelScrolled, S as TextInserted, T as TrackPlanned, a as CursorChanged, c as Disconnected, d as PageClosed, f as PageLoaded, g as PointerReleased, h as PointerPressed, l as KeyChanged, m as PageUntracked, o as DialogShown, p as PageOpened, t as Action, u as Navigated, v as RequestRefused, w as TrackPerformed, y as SessionEnding } from "../BrowserEvent-lLqJ3GJS.mjs";
|
|
3
|
+
import { r as Changes, t as Change } from "../Change-Ba7INmay.mjs";
|
|
4
|
+
import { r as Frame } from "../Frame-UEH2hO5T.mjs";
|
|
5
|
+
import { n as Snapshot, r as SnapshotOptions } from "../Snapshot-CtBVOtuu.mjs";
|
|
6
|
+
import { t as Window } from "../Window-CMddGMt1.mjs";
|
|
7
|
+
import { f as Page, k as WindowOptions, p as Page_d_exports } from "../Page-CvsOEorc.mjs";
|
|
8
|
+
import { Effect, Schema } from "effect";
|
|
9
|
+
import { Prompt } from "effect/ai";
|
|
10
|
+
//#region src/moment/words.d.ts
|
|
11
|
+
/** A change in words, such as `"$61,240" became "$62,010" (row "Bitcoin", column "Price")`. */
|
|
12
|
+
declare const describe: (change: Change, grouped?: boolean) => string;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/moment/Moment.d.ts
|
|
15
|
+
declare const Moment_base: Schema.Class<Moment, Schema.Struct<{
|
|
16
|
+
readonly page: Schema.String;
|
|
17
|
+
readonly since: Schema.Finite;
|
|
18
|
+
readonly until: Schema.Finite;
|
|
19
|
+
readonly events: Schema.$Array<Schema.Union<readonly [typeof RequestRefused, 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
|
+
readonly changes: Schema.optional<typeof Changes>;
|
|
21
|
+
readonly frames: Schema.$Array<typeof Frame>;
|
|
22
|
+
readonly missing: Schema.$Array<typeof BrowserError>;
|
|
23
|
+
snapshot: Schema.optional<typeof Snapshot>;
|
|
24
|
+
}>, Window> & Pick<{}, never>;
|
|
25
|
+
/**
|
|
26
|
+
* A window that ends at a picture of the page, its last frame, unless `missing` says why it has
|
|
27
|
+
* none. Its frames are a few, spread over the window, so that it still begins where it starts.
|
|
28
|
+
*/
|
|
29
|
+
export declare class Moment extends Moment_base {}
|
|
30
|
+
export interface CaptureOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Where the window starts, as for `Page.window`: a previous window or moment, so that consecutive
|
|
33
|
+
* ones neither repeat nor miss an event or a change, or a `Duration` back from the picture.
|
|
34
|
+
* Defaults to 5 seconds.
|
|
35
|
+
*/
|
|
36
|
+
readonly since?: WindowOptions["since"] | undefined;
|
|
37
|
+
/** Frames to keep, at least 1, spread over the window and ending with the picture. Defaults to 2. */
|
|
38
|
+
readonly frames?: number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to take the page's outline at the end, or its options; `true` means 4,000 characters.
|
|
41
|
+
* Defaults to `false`: the frames and the timeline carry most moments, while an outline costs a
|
|
42
|
+
* round trip to the page and can double a moment's tokens.
|
|
43
|
+
*/
|
|
44
|
+
readonly snapshot?: SnapshotOptions | boolean | undefined;
|
|
45
|
+
/** Show what fields hold in the moment's changes; a secret field still reads `••••`. */
|
|
46
|
+
readonly unmask?: boolean | undefined;
|
|
47
|
+
}
|
|
48
|
+
export declare const capture: (page: Page, options?: CaptureOptions | undefined) => Effect.Effect<Moment, BrowserError, never>;
|
|
49
|
+
/** What a window says of its page at its end: what was still in flux, and what had settled. */
|
|
50
|
+
export interface Account {
|
|
51
|
+
/**
|
|
52
|
+
* How long, in milliseconds, the page had been still at the end: since the last change in view
|
|
53
|
+
* its record shows, or the last paint its screencast frames show, or else since the window, or
|
|
54
|
+
* its record, began. Undefined where neither could tell, with no record of the window and no
|
|
55
|
+
* painted frame: a screenshot shows the page, not when it last changed. Frames show paint only
|
|
56
|
+
* while a capture runs, and the record does not see a canvas, so a canvas that keeps drawing
|
|
57
|
+
* with no capture running reads as still.
|
|
58
|
+
*/
|
|
59
|
+
readonly stillFor: number | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* The changes still under way at the end: what kept changing, more than once in the window or
|
|
62
|
+
* already before it, and changed again within twice its own pace before the end.
|
|
63
|
+
*/
|
|
64
|
+
readonly changing: ReadonlyArray<Change>;
|
|
65
|
+
/** Every other change, which shows what it settled at. */
|
|
66
|
+
readonly settled: ReadonlyArray<Change>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* An account of the window's page at its end: how long it had been still, and which of its
|
|
70
|
+
* changes were still under way and which had settled. A window whose record saw none of it has
|
|
71
|
+
* neither.
|
|
72
|
+
*/
|
|
73
|
+
export declare const account: (window: Window) => Account;
|
|
74
|
+
/**
|
|
75
|
+
* The moment as one user message: the page's outline when the moment has one, what changed, most
|
|
76
|
+
* notable first, what kept changing told as still changing at the moment or settled since when, by
|
|
77
|
+
* its account, with the actions that the changes followed, that changes followed though none
|
|
78
|
+
* names them, or that drew what only the screenshots show, what could not be read and why, and its
|
|
79
|
+
* frames captioned with their times, the last one "the moment" where it is the picture at its end.
|
|
80
|
+
* Give a model its task with `Prompt.setSystem`, and add what the caller knows about the page as
|
|
81
|
+
* more text.
|
|
82
|
+
*/
|
|
83
|
+
export declare const toPrompt: (moment: Moment) => Prompt.Prompt;
|
|
84
|
+
//#endregion
|
|
85
|
+
export { Window, describe as describeChange };
|
|
86
|
+
//# sourceMappingURL=Moment.d.mts.map
|
|
@@ -1,13 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { s as refuse } from "./context-w3NJPRLo.mjs";
|
|
5
|
-
import { Frame } from "./Frame.mjs";
|
|
6
|
-
import { Snapshot } from "./Snapshot.mjs";
|
|
7
|
-
import { c as quoted, l as where, o as describe, r as Changes, s as named } from "./Change-DNvztNLu.mjs";
|
|
1
|
+
import { refuse } from "../BrowserError.mjs";
|
|
2
|
+
import { Snapshot } from "../Snapshot.mjs";
|
|
3
|
+
import { Window } from "../Window.mjs";
|
|
8
4
|
import { Duration, Effect, Option, Result, Schema } from "effect";
|
|
9
5
|
import { Prompt } from "effect/ai";
|
|
10
|
-
//#region src/
|
|
6
|
+
//#region src/moment/words.ts
|
|
7
|
+
const quoted = (value) => JSON.stringify(value ?? "");
|
|
8
|
+
/** A subject in words, such as `button "Play"`; one without a name says where it was. */
|
|
9
|
+
const named = (subject, point) => {
|
|
10
|
+
const kind = subject.role ?? subject.tag;
|
|
11
|
+
if (subject.name !== "") return `${kind} ${JSON.stringify(subject.name)}`;
|
|
12
|
+
return point === void 0 ? kind : `${kind} at ${point}`;
|
|
13
|
+
};
|
|
14
|
+
/** A change's context in words: `row "Ether", column "1h"` or `beside "Price", under "Bitcoin"`. */
|
|
15
|
+
const where = ({ row, column, label, heading }, grouped = false) => {
|
|
16
|
+
const parts = [
|
|
17
|
+
row === void 0 ? "" : `row ${quoted(row)}`,
|
|
18
|
+
column === void 0 || grouped ? "" : `column ${quoted(column)}`,
|
|
19
|
+
label === void 0 ? "" : `beside ${quoted(label)}`,
|
|
20
|
+
heading === void 0 || grouped ? "" : `under ${quoted(heading)}`
|
|
21
|
+
].filter((part) => part !== "");
|
|
22
|
+
return parts.length === 0 ? "" : ` (${parts.join(", ")})`;
|
|
23
|
+
};
|
|
24
|
+
/** A change in words, such as `"$61,240" became "$62,010" (row "Bitcoin", column "Price")`. */
|
|
25
|
+
const describe = (change, grouped = false) => {
|
|
26
|
+
const { subject, before, after, count, lowest, highest } = change;
|
|
27
|
+
const context = where(subject.context, grouped);
|
|
28
|
+
const range = lowest === void 0 || highest === void 0 ? "" : `, from ${lowest} to ${highest}`;
|
|
29
|
+
const times = count > 1 ? ` (it changed ${count} times${range})` : "";
|
|
30
|
+
switch (change.kind) {
|
|
31
|
+
case "title": return `the title ${before === void 0 ? "now reads" : `${quoted(before)} became`} ${quoted(after)}`;
|
|
32
|
+
case "value": {
|
|
33
|
+
const field = named(subject, void 0);
|
|
34
|
+
if (after === "checked" || after === "not checked") return `${field} is now ${after}`;
|
|
35
|
+
if (after === void 0 || after === "") return `${field} was cleared`;
|
|
36
|
+
return after === "••••" || before === void 0 || before === "" ? `${field} was ${after === "••••" ? "edited" : `set to ${quoted(after)}`}` : `${field} changed from ${quoted(before)} to ${quoted(after)}`;
|
|
37
|
+
}
|
|
38
|
+
case "appeared": return `${quoted(after)} appeared${context}`;
|
|
39
|
+
case "disappeared": return `${quoted(before)} disappeared${context}`;
|
|
40
|
+
case "brief": return `${quoted(after)} appeared and went away again${context}`;
|
|
41
|
+
case "text": return before === void 0 ? `now reads ${quoted(after)}${context}${times}` : `${quoted(before)} became ${quoted(after)}${context}${times}`;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/moment/Moment.ts
|
|
11
46
|
/**
|
|
12
47
|
* What a page showed, and what changed on it, over a window of time.
|
|
13
48
|
*
|
|
@@ -34,35 +69,6 @@ import { Prompt } from "effect/ai";
|
|
|
34
69
|
*
|
|
35
70
|
* @since 0.3.0
|
|
36
71
|
*/
|
|
37
|
-
var Moment_exports = /* @__PURE__ */ __exportAll({
|
|
38
|
-
Moment: () => Moment,
|
|
39
|
-
Window: () => Window,
|
|
40
|
-
account: () => account,
|
|
41
|
-
capture: () => capture,
|
|
42
|
-
toPrompt: () => toPrompt
|
|
43
|
-
});
|
|
44
|
-
/** A page's events, changes and frames over one window of its browser's host clock. */
|
|
45
|
-
var Window = class extends Schema.Class("effect-browser/Window")({
|
|
46
|
-
page: Schema.String,
|
|
47
|
-
/** Where the window starts, in host monotonic milliseconds on the owning browser’s clock. */
|
|
48
|
-
since: Schema.Finite,
|
|
49
|
-
/** Where it ends, never after it was taken. */
|
|
50
|
-
until: Schema.Finite,
|
|
51
|
-
/** The page's events after `since`, up to `until`, oldest first, without the input presentation track. */
|
|
52
|
-
events: Schema.Array(BrowserEvent),
|
|
53
|
-
/**
|
|
54
|
-
* What visibly changed after `since`, up to `until`; absent where `missing` says why. A page's
|
|
55
|
-
* first window starts its record, so the record sees none of it.
|
|
56
|
-
*/
|
|
57
|
-
changes: Schema.optional(Changes),
|
|
58
|
-
/** Screencast frames painted from `since` to `until`, oldest first, as far back as kept. */
|
|
59
|
-
frames: Schema.Array(Frame),
|
|
60
|
-
/**
|
|
61
|
-
* Why each part that could not be read is missing: the read of its changes, by whatever
|
|
62
|
-
* operation failed there, or a moment's picture (`frame`) or outline (`snapshot`).
|
|
63
|
-
*/
|
|
64
|
-
missing: Schema.Array(BrowserError)
|
|
65
|
-
}) {};
|
|
66
72
|
/**
|
|
67
73
|
* A window that ends at a picture of the page, its last frame, unless `missing` says why it has
|
|
68
74
|
* none. Its frames are a few, spread over the window, so that it still begins where it starts.
|
|
@@ -287,6 +293,6 @@ const toPrompt = (moment) => {
|
|
|
287
293
|
})])] })]);
|
|
288
294
|
};
|
|
289
295
|
//#endregion
|
|
290
|
-
export { Moment, Window, account, capture,
|
|
296
|
+
export { Moment, Window, account, capture, describe as describeChange, toPrompt };
|
|
291
297
|
|
|
292
298
|
//# sourceMappingURL=Moment.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Moment.mjs","names":[],"sources":["../../src/moment/words.ts","../../src/moment/Moment.ts"],"sourcesContent":["/**\n * What changed on a page, in words for a model: a change with where it is, and what it is. A moment\n * tells its changes this way, and a tool's receipt the changes its action caused.\n */\nimport type { Subject, SubjectContext } from \"../BrowserEvent.ts\";\nimport type { Change } from \"../Change.ts\";\n\nexport const quoted = (value: string | undefined) => JSON.stringify(value ?? \"\");\n\n/** A subject in words, such as `button \"Play\"`; one without a name says where it was. */\nexport const named = (subject: Subject, point: string | undefined) => {\n const kind = subject.role ?? subject.tag;\n\n if (subject.name !== \"\") return `${kind} ${JSON.stringify(subject.name)}`;\n\n return point === undefined ? kind : `${kind} at ${point}`;\n};\n\n/** A change's context in words: `row \"Ether\", column \"1h\"` or `beside \"Price\", under \"Bitcoin\"`. */\nexport const where = ({ row, column, label, heading }: SubjectContext, grouped = false) => {\n const parts = [\n row === undefined ? \"\" : `row ${quoted(row)}`,\n column === undefined || grouped ? \"\" : `column ${quoted(column)}`,\n label === undefined ? \"\" : `beside ${quoted(label)}`,\n heading === undefined || grouped ? \"\" : `under ${quoted(heading)}`,\n ].filter((part) => part !== \"\");\n\n return parts.length === 0 ? \"\" : ` (${parts.join(\", \")})`;\n};\n\n/** A change in words, such as `\"$61,240\" became \"$62,010\" (row \"Bitcoin\", column \"Price\")`. */\nexport const describe = (change: Change, grouped = false): string => {\n const { subject, before, after, count, lowest, highest } = change;\n const context = where(subject.context, grouped);\n\n const range =\n lowest === undefined || highest === undefined ? \"\" : `, from ${lowest} to ${highest}`;\n\n const times = count > 1 ? ` (it changed ${count} times${range})` : \"\";\n\n switch (change.kind) {\n case \"title\":\n return `the title ${before === undefined ? \"now reads\" : `${quoted(before)} became`} ${quoted(after)}`;\n case \"value\": {\n const field = named(subject, undefined);\n\n if (after === \"checked\" || after === \"not checked\") return `${field} is now ${after}`;\n if (after === undefined || after === \"\") return `${field} was cleared`;\n\n return after === \"••••\" || before === undefined || before === \"\"\n ? `${field} was ${after === \"••••\" ? \"edited\" : `set to ${quoted(after)}`}`\n : `${field} changed from ${quoted(before)} to ${quoted(after)}`;\n }\n case \"appeared\":\n return `${quoted(after)} appeared${context}`;\n case \"disappeared\":\n return `${quoted(before)} disappeared${context}`;\n case \"brief\":\n return `${quoted(after)} appeared and went away again${context}`;\n case \"text\":\n return before === undefined\n ? `now reads ${quoted(after)}${context}${times}`\n : `${quoted(before)} became ${quoted(after)}${context}${times}`;\n }\n};\n","/**\n * What a page showed, and what changed on it, over a window of time.\n *\n * A page's timeline has three tracks on its browser's host clock: its events, what visibly changed\n * on it (`Change`), and its screencast frames. A `Window` holds the three from `since` to `until`,\n * and says why a part it could not read is missing rather than fail. `Page.window` takes one, which\n * can end in the past, at a frame a delayed consumer airs late, so that a line written now tells\n * what its viewers will see. Its `account` says what was so at its end: how long the page had been\n * still, which of its changes were still under way, and which had settled.\n *\n * A `Moment` is a window that ends at a picture of the page now: `capture` takes the picture, then\n * the window up to it, and on request the page's outline. `toPrompt` turns a moment into one user\n * message for any `effect/ai` call: a structured answer from `LanguageModel.generateObject`, a\n * caption from `generateText`, or one turn of a `Chat` that follows moment after moment. It leads\n * with what changed, news and what settled before what was still changing, as its account tells\n * them apart, and names an action as what a change followed; as a step where changes followed it\n * but none names it, or where its effect is drawn rather than written, as on a canvas, which only\n * the screenshots show; and claims nothing of what changed where the record did not see, or of a\n * part it could not read, which it names with why.\n *\n * Frames come from a running screencast, as far back as the browser's `frameHistory` keeps them.\n * A moment's picture is the newest frame if it was painted after the page's latest input and\n * completed action, at most 250 ms ago, else a new screenshot timed by its capture.\n *\n * @since 0.3.0\n */\nimport { Duration, Effect, Option, Result, Schema } from \"effect\";\nimport { Prompt } from \"effect/ai\";\n\nimport { refuse } from \"../BrowserError.ts\";\nimport { type Action } from \"../BrowserEvent.ts\";\nimport { type Change, type Changes } from \"../Change.ts\";\nimport { type Frame } from \"../Frame.ts\";\nimport type * as Page from \"../Page.ts\";\nimport { Snapshot, type SnapshotOptions } from \"../Snapshot.ts\";\nimport { describe, named, quoted, where } from \"./words.ts\";\n\nexport { Window } from \"../Window.ts\";\nimport { Window } from \"../Window.ts\";\n\n/**\n * A window that ends at a picture of the page, its last frame, unless `missing` says why it has\n * none. Its frames are a few, spread over the window, so that it still begins where it starts.\n */\nexport class Moment extends Window.extend<Moment>(\"effect-browser/Moment\")({\n /** The page's outline at the end of the window, when the capture asked for it. */\n snapshot: Schema.optional(Snapshot),\n}) {}\n\nexport interface CaptureOptions {\n /**\n * Where the window starts, as for `Page.window`: a previous window or moment, so that consecutive\n * ones neither repeat nor miss an event or a change, or a `Duration` back from the picture.\n * Defaults to 5 seconds.\n */\n readonly since?: Page.WindowOptions[\"since\"] | undefined;\n /** Frames to keep, at least 1, spread over the window and ending with the picture. Defaults to 2. */\n readonly frames?: number | undefined;\n /**\n * Whether to take the page's outline at the end, or its options; `true` means 4,000 characters.\n * Defaults to `false`: the frames and the timeline carry most moments, while an outline costs a\n * round trip to the page and can double a moment's tokens.\n */\n readonly snapshot?: SnapshotOptions | boolean | undefined;\n /** Show what fields hold in the moment's changes; a secret field still reads `••••`. */\n readonly unmask?: boolean | undefined;\n}\n\n/** Pick `count` frames spread evenly over `frames`, always including the last. */\nconst spread = (frames: ReadonlyArray<Frame>, count: number): ReadonlyArray<Frame> => {\n if (frames.length <= count) return frames;\n if (count <= 1) return frames.slice(-1);\n const step = (frames.length - 1) / (count - 1);\n\n return Array.from({ length: count }, (_, index) => frames[Math.round(index * step)]).filter(\n (frame): frame is Frame => frame !== undefined,\n );\n};\n\n// An action ends after its navigation settles, which can follow the last paint. A fresh picture\n// keeps that completed action inside the moment without moving events between adjacent windows.\nconst pictureOf = Effect.fnUntraced(function* (page: Page.Page) {\n const frame = yield* page.frame({ after: \"input\" });\n const events = yield* page.recentEvents;\n\n return events.some((event) => event._tag === \"Action\" && event.at > frame.hostTime)\n ? yield* page.frame({ maxAge: 0 })\n : frame;\n});\n\nexport const capture = Effect.fn(\"Moment.capture\")(function* (\n page: Page.Page,\n options: CaptureOptions = {},\n) {\n const count = options.frames ?? 2;\n\n if (!Number.isSafeInteger(count) || count < 1)\n return yield* refuse(\"moment\", \"frames must be a positive safe integer\");\n const outline = options.snapshot ?? false;\n\n // The picture comes first, at no call with a running screencast, and the window ends at its\n // paint, so its changes hold nothing it does not show; without one, the window ends now. The\n // outline is taken alongside. What cannot be read is missing from the moment, not its end.\n const { pictured, outlined } = yield* Effect.all(\n {\n pictured: Effect.result(pictureOf(page)).pipe(\n Effect.flatMap((picture) =>\n Effect.map(\n page.window({\n since: options.since ?? Duration.seconds(5),\n until: Result.getOrUndefined(picture),\n unmask: options.unmask,\n }),\n (window) => ({ window, picture }),\n ),\n ),\n ),\n outlined: Effect.result(\n outline === false\n ? Effect.void\n : page.snapshot({ maxChars: 4000, ...(outline === true ? {} : outline) }),\n ),\n },\n { concurrency: 2 },\n );\n\n const { window, picture } = pictured;\n const shown = Result.getOrUndefined(picture);\n\n return new Moment({\n ...window,\n frames: spread(\n shown === undefined\n ? window.frames\n : [...window.frames.filter((frame) => frame !== shown), shown],\n count,\n ),\n snapshot: Result.getOrUndefined(outlined) ?? undefined,\n missing: [\n ...window.missing,\n ...Option.toArray(Result.getFailure(picture)),\n ...Option.toArray(Result.getFailure(outlined)),\n ],\n });\n});\n\n/** A window's record of changes, if it saw any of the window: a page's first has none. */\nconst recordOf = ({ changes }: Window) =>\n changes !== undefined && changes.from < changes.until ? changes : undefined;\n\n/** What a window says of its page at its end: what was still in flux, and what had settled. */\nexport interface Account {\n /**\n * How long, in milliseconds, the page had been still at the end: since the last change in view\n * its record shows, or the last paint its screencast frames show, or else since the window, or\n * its record, began. Undefined where neither could tell, with no record of the window and no\n * painted frame: a screenshot shows the page, not when it last changed. Frames show paint only\n * while a capture runs, and the record does not see a canvas, so a canvas that keeps drawing\n * with no capture running reads as still.\n */\n readonly stillFor: number | undefined;\n /**\n * The changes still under way at the end: what kept changing, more than once in the window or\n * already before it, and changed again within twice its own pace before the end.\n */\n readonly changing: ReadonlyArray<Change>;\n /** Every other change, which shows what it settled at. */\n readonly settled: ReadonlyArray<Change>;\n}\n\n/** Whether a change was still under way at `until`, by its own pace. */\nconst underWay = (change: Change, until: number) => {\n const pace =\n change.count > 1\n ? (change.at - change.startedAt) / (change.count - 1)\n : change.earlier === undefined\n ? undefined\n : change.startedAt - change.earlier;\n\n return pace !== undefined && until - change.at < 2 * pace;\n};\n\n/**\n * An account of the window's page at its end: how long it had been still, and which of its\n * changes were still under way and which had settled. A window whose record saw none of it has\n * neither.\n */\nexport const account = (window: Window): Account => {\n const record = recordOf(window);\n const changes = record?.changes ?? [];\n\n const stirred = [\n ...changes.flatMap((change) => (change.kind === \"title\" ? [] : [change.at])),\n ...window.frames.flatMap((frame) =>\n frame.timing._tag === \"BrowserPaint\" ? [frame.hostTime] : [],\n ),\n ];\n\n return {\n stillFor:\n record === undefined && stirred.length === 0\n ? undefined\n : window.until - Math.max(window.since, record?.from ?? window.since, ...stirred),\n changing: changes.filter((change) => underWay(change, window.until)),\n settled: changes.filter((change) => !underWay(change, window.until)),\n };\n};\n\nconst seconds = (moment: Moment, at: number) => `${((at - moment.until) / 1000).toFixed(1)}s`;\n\nconst pointOf = (x: number | undefined, y: number | undefined) =>\n x === undefined || y === undefined ? undefined : `(${Math.round(x)}, ${Math.round(y)})`;\n\n/**\n * What an action acted on. Without a subject the action failed before finding it, and a ref it was\n * given is left out: refs are reused, so the page's outline may give it to something else by now.\n */\nconst acted = (event: Action): string => {\n const point = pointOf(event.x, event.y);\n\n if (event.subject === undefined)\n return event.target === undefined || /^e\\d+$|\"e\\d+\"/.test(event.target)\n ? (point ?? \"\")\n : event.target;\n // A drag's point is where it ended.\n if (event.to !== undefined)\n return `${named(event.subject, undefined)} to ${named(event.to, point)}`;\n\n return named(event.subject, point);\n};\n\n/**\n * An action as a step: `click button \"Pay\"`. A failed one says only that: its error is advice for\n * the caller that acted, which may name a ref, not a fact about the page.\n */\nconst step = (event: Action): string => {\n const target = acted(event);\n const text = event.text === undefined ? \"\" : JSON.stringify(event.text);\n\n const what =\n event.name === \"type\" && target !== \"\"\n ? `${text} into ${target}`\n : event.name === \"select\" && target !== \"\"\n ? `${text} in ${target}`\n : `${target} ${text}`;\n\n return `${event.name} ${what}${event.ok ? \"\" : \" (failed)\"}`.replace(/\\s+/g, \" \").trim();\n};\n\n/** What is drawn rather than written, whose changes only the screenshots show. */\nconst drawn = new Set([\"canvas\", \"iframe\", \"video\", \"embed\", \"object\", \"svg\"]);\n\nconst onDrawn = (event: Action) =>\n event.ok && event.subject !== undefined && drawn.has(event.subject.role ?? event.subject.tag);\n\ninterface Line {\n readonly at: number;\n readonly rank: number;\n readonly text: string;\n}\n\n/** At most this many lines of what happened; the least notable are counted, not listed. */\nconst maxLines = 24;\n\n/**\n * The changes as lines, news first, and the actions they name; cells of one column that changed\n * together as one line. What kept changing says whether it still was at the moment, by its account.\n */\nconst changed = (moment: Moment, record: Changes) => {\n const actions = moment.events.filter((event): event is Action => event._tag === \"Action\");\n const named = new Set<Action>();\n const changing = new Set(account(moment).changing);\n\n const state = (change: Change) =>\n changing.has(change)\n ? \", still changing at the moment\"\n : change.count > 1 || change.earlier !== undefined\n ? `, settled since ${seconds(moment, change.at)}`\n : \"\";\n\n // The action whose input a change followed: one that ran while the input arrived, give or take\n // the clock's mapping, so input the library did not send names no action.\n const cause = (change: Change) => {\n const input = change.cause;\n\n const action =\n input === undefined\n ? undefined\n : actions.findLast((event) => event.startedAt <= input + 100 && event.at >= input - 100);\n\n if (action === undefined) return \"\";\n named.add(action);\n\n return `, after ${step(action)}`;\n };\n\n const columns = Map.groupBy(\n record.changes.filter(\n (change) => change.kind === \"text\" && change.subject.context.column !== undefined,\n ),\n ({ subject: { context } }) => JSON.stringify([context.heading, context.column]),\n );\n\n const lines: Array<Line> = [];\n const collapsed = new Set<Change>();\n\n for (const [first, ...cells] of columns.values())\n if (first !== undefined && cells.length >= 2) {\n const still = [first, ...cells].filter((cell) => changing.has(cell)).length;\n\n for (const cell of [first, ...cells]) collapsed.add(cell);\n lines.push({\n at: first.startedAt,\n rank: still > 0 ? 3 : 2,\n text: `${cells.length + 1} cells in column ${quoted(first.subject.context.column)}${where({ heading: first.subject.context.heading })} changed, such as ${describe(first, true)}${still > 0 ? `, ${still} still changing at the moment` : \"\"}`,\n });\n }\n for (const change of record.changes)\n if (!collapsed.has(change))\n lines.push({\n at: change.startedAt,\n rank: changing.has(change) ? 3 : 2,\n text: describe(change) + cause(change) + state(change),\n });\n\n return { lines, named };\n};\n\n/** What a part a moment could not read was, by the operation that failed: a window's one read is its changes. */\nconst parts = new Map([\n [\"frame\", \"A picture of the moment\"],\n [\"snapshot\", \"The page's outline\"],\n]);\n\n/** The moment's changes and events as lines, most notable first when its changes are recorded. */\nconst happened = (moment: Moment): ReadonlyArray<string> => {\n const record = recordOf(moment);\n\n const { lines, named } =\n record === undefined\n ? { lines: new Array<Line>(), named: new Set<Action>() }\n : changed(moment, record);\n\n // Whether anything but a field's own edit changed after an action began.\n const followed = (event: Action) =>\n record?.changes.some((change) => change.kind !== \"value\" && change.at > event.startedAt) ===\n true;\n\n // With a record, an action is told as a step where changes followed it and none names it, so a\n // click whose effect a busy page leaves uncredited is not lost; where its effect is drawn; or\n // where it started before the record began, as on the document a click opened. An attempt that\n // nothing followed, a failed one, a hover and a scroll are left out.\n const told = (event: Action) =>\n !(event.ok && [\"navigate\", \"back\", \"reload\"].includes(event.name)) &&\n (record === undefined ||\n event.startedAt <= record.from ||\n (event.ok &&\n event.name !== \"scroll\" &&\n (onDrawn(event) || (event.name !== \"hover\" && !named.has(event) && followed(event)))));\n\n for (const event of moment.events)\n if (event._tag === \"Action\" && event.page === moment.page && told(event))\n lines.push({ at: event.at, rank: 4, text: step(event) });\n else if (event._tag === \"Navigated\")\n lines.push({\n at: event.at,\n rank: 0,\n text: `${event.sameDocument ? \"moved within the page\" : \"navigated\"} to ${event.url}`,\n });\n else if (event._tag === \"PageOpened\")\n lines.push({ at: event.at, rank: 0, text: `a tab opened at ${event.url}` });\n else if (event._tag === \"PageClosed\")\n lines.push({\n at: event.at,\n rank: 0,\n text: `the tab ${event.cause === \"crashed\" ? \"crashed\" : \"closed\"}`,\n });\n else if (event._tag === \"DialogShown\")\n lines.push({\n at: event.at,\n rank: 1,\n text: `a dialog (${event.kind}) said ${JSON.stringify(event.message)}`,\n });\n\n const ordered = lines.toSorted((left, right) =>\n record === undefined ? left.at - right.at : left.rank - right.rank || left.at - right.at,\n );\n\n const kept = ordered.slice(0, maxLines);\n const drawing = moment.events.some((event) => event._tag === \"Action\" && onDrawn(event));\n const begins = record === undefined ? moment.since : Math.max(moment.since, record.from);\n const unread = moment.missing.some((error) => !parts.has(error.operation));\n\n return [\n ...kept.map((line) => `${seconds(moment, line.at)} ${line.text}`),\n ...(ordered.length > maxLines ? [`…and ${ordered.length - maxLines} less notable`] : []),\n ...(record === undefined\n ? unread\n ? []\n : [\"What changed on the page was not recorded.\"]\n : record.changes.length > 0\n ? []\n : [\n `No text in view changed${begins > moment.since ? ` after ${seconds(moment, begins)}` : \"\"}${drawing ? \"; what is drawn, such as a canvas, shows only in the screenshots\" : \"\"}.`,\n ]),\n ...(record !== undefined && record.dropped > 0\n ? [\n `The page changed too much to tell it all: at least ${record.dropped} changes are not told.`,\n ]\n : []),\n ...(begins > moment.since\n ? [`Changes before ${seconds(moment, begins)} are not all known.`]\n : []),\n ...moment.missing.map(\n (error) =>\n `${parts.get(error.operation) ?? \"What changed on the page\"} could not be read: ${error.reason.message}.`,\n ),\n ];\n};\n\n/**\n * The moment as one user message: the page's outline when the moment has one, what changed, most\n * notable first, what kept changing told as still changing at the moment or settled since when, by\n * its account, with the actions that the changes followed, that changes followed though none\n * names them, or that drew what only the screenshots show, what could not be read and why, and its\n * frames captioned with their times, the last one \"the moment\" where it is the picture at its end.\n * Give a model its task with `Prompt.setSystem`, and add what the caller knows about the page as\n * more text.\n */\nexport const toPrompt = (moment: Moment): Prompt.Prompt => {\n const count = moment.frames.length;\n const last = count - 1;\n const pictured = moment.frames.at(-1)?.hostTime === moment.until;\n\n const following =\n count === 1 ? \"One screenshot follows\" : `${count} screenshots follow, oldest first`;\n\n return Prompt.fromMessages([\n Prompt.makeMessage(\"user\", {\n content: [\n Prompt.makePart(\"text\", {\n text: [\n \"One moment of a browser session. Rely only on what this material shows, and prefer concrete details: numbers, names, colours, positions and motion.\",\n \"\",\n ...(moment.snapshot === undefined ? [] : [moment.snapshot.rendered, \"\"]),\n `${recordOf(moment) === undefined ? \"What happened\" : \"What changed, most notable first\"} (seconds before the moment, over ${((moment.until - moment.since) / 1000).toFixed(1)}s):`,\n ...happened(moment),\n ...(count === 0\n ? []\n : [\n \"\",\n `${following}${pictured ? (count === 1 ? \": the moment itself.\" : \"; the last one is the moment itself.\") : \".\"}`,\n ]),\n ].join(\"\\n\"),\n }),\n ...moment.frames.flatMap((frame, index) => [\n Prompt.makePart(\"text\", {\n text:\n index === last && pictured ? \"The moment:\" : `${seconds(moment, frame.hostTime)}:`,\n }),\n Prompt.makePart(\"file\", { mediaType: \"image/jpeg\", data: frame.data }),\n ]),\n ],\n }),\n ]);\n};\n\n/** Describe one change using the same prose as moment prompts. */\nexport { describe as describeChange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