effect-browser 0.3.0-beta.23 → 0.3.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +437 -142
- package/dist/Action.d.mts +1 -1
- package/dist/Action.mjs +61 -9
- package/dist/Action.mjs.map +1 -1
- package/dist/Browser.d.mts +2 -2
- package/dist/Browser.mjs +2 -2
- package/dist/BrowserError.d.mts +2 -2
- package/dist/BrowserError.mjs +194 -41
- package/dist/BrowserError.mjs.map +1 -1
- package/dist/BrowserEvent.d.mts +2 -2
- package/dist/BrowserEvent.mjs +185 -35
- package/dist/BrowserEvent.mjs.map +1 -1
- package/dist/Cdp.d.mts +15 -0
- package/dist/Cdp.mjs +22 -0
- package/dist/Cdp.mjs.map +1 -0
- package/dist/Change.d.mts +2 -2
- package/dist/Change.mjs +40 -7
- package/dist/Change.mjs.map +1 -1
- package/dist/Frame.d.mts +2 -2
- package/dist/Frame.mjs +132 -14
- package/dist/Frame.mjs.map +1 -1
- package/dist/InputStyle.d.mts +153 -0
- package/dist/InputStyle.mjs +2 -0
- package/dist/Layout.d.mts +2 -0
- package/dist/Layout.mjs +123 -0
- package/dist/Layout.mjs.map +1 -0
- package/dist/Overlay.d.mts +2 -0
- package/dist/Overlay.mjs +58 -0
- package/dist/Overlay.mjs.map +1 -0
- package/dist/Page.d.mts +2 -2
- package/dist/Page.mjs +2 -2
- package/dist/PageTime.d.mts +2 -0
- package/dist/PageTime.mjs +17 -0
- package/dist/PageTime.mjs.map +1 -0
- package/dist/Pose.d.mts +2 -0
- package/dist/Pose.mjs +65 -0
- package/dist/Pose.mjs.map +1 -0
- package/dist/Site.d.mts +984 -0
- package/dist/Site.mjs +110 -0
- package/dist/Site.mjs.map +1 -0
- package/dist/Snapshot.d.mts +2 -2
- package/dist/Snapshot.mjs +87 -6
- package/dist/Snapshot.mjs.map +1 -1
- package/dist/Text.d.mts +2 -0
- package/dist/Text.mjs +45 -0
- package/dist/Text.mjs.map +1 -0
- package/dist/Window.d.mts +2 -2
- package/dist/Window.mjs +31 -6
- package/dist/Window.mjs.map +1 -1
- package/dist/ai/BrowserTools.d.mts +4987 -0
- package/dist/ai/BrowserTools.mjs +3 -0
- package/dist/ai/PageControl.d.mts +286 -0
- package/dist/ai/PageControl.mjs +426 -0
- package/dist/ai/PageControl.mjs.map +1 -0
- package/dist/ai/PromptCache.d.mts +16 -0
- package/dist/ai/PromptCache.mjs +72 -0
- package/dist/ai/PromptCache.mjs.map +1 -0
- package/dist/ai/Tabs.d.mts +2 -0
- package/dist/ai/Tabs.mjs +72 -0
- package/dist/ai/Tabs.mjs.map +1 -0
- package/dist/ai/ToolError.d.mts +34 -0
- package/dist/ai/ToolError.mjs +2 -0
- package/dist/ai/index.d.mts +6 -0
- package/dist/ai/index.mjs +6 -0
- package/dist/index.d.mts +7 -15
- package/dist/index.mjs +9 -8
- package/dist/{Action-24sLOubi.d.mts → internal/Action-CkanNTUw.d.mts} +64 -4
- package/dist/{Browser-wZhwZSlG.d.mts → internal/Browser-DD9Vm1c-.d.mts} +80 -10
- package/dist/{Browser-BKPAbyys.mjs → internal/Browser-vzD7i2oj.mjs} +658 -495
- package/dist/internal/Browser-vzD7i2oj.mjs.map +1 -0
- package/dist/{BrowserError-BlcmLVzn.d.mts → internal/BrowserError-CsuRYcDX.d.mts} +187 -28
- package/dist/{BrowserEvent-lLqJ3GJS.d.mts → internal/BrowserEvent-tGPYYf6R.d.mts} +197 -18
- package/dist/internal/BrowserTools-Yi3lOX4h.mjs +497 -0
- package/dist/internal/BrowserTools-Yi3lOX4h.mjs.map +1 -0
- package/dist/{Style-AO4V7Czt.mjs → internal/InputStyle-CPzxoN4g.mjs} +94 -16
- package/dist/internal/InputStyle-CPzxoN4g.mjs.map +1 -0
- package/dist/{moment/Moment.mjs → internal/Moment-CstaX1mR.mjs} +49 -16
- package/dist/internal/Moment-CstaX1mR.mjs.map +1 -0
- package/dist/{moment/Moment.d.mts → internal/Moment-DOcldBdf.d.mts} +54 -21
- package/dist/internal/Page-BfGxn7oN.d.mts +1553 -0
- package/dist/{Page-BF5izr8R.mjs → internal/Page-DqF-tuTx.mjs} +62 -72
- package/dist/internal/Page-DqF-tuTx.mjs.map +1 -0
- package/dist/internal/Release-CFONkPDP.d.mts +39 -0
- package/dist/internal/Stage-D5ymSXDT.mjs +298 -0
- package/dist/internal/Stage-D5ymSXDT.mjs.map +1 -0
- package/dist/internal/Stillness-DCPeAN1a.mjs +1124 -0
- package/dist/internal/Stillness-DCPeAN1a.mjs.map +1 -0
- package/dist/internal/Supervisor-BcY_QNIY.d.mts +108 -0
- package/dist/internal/Supervisor-BcglY23c.mjs +531 -0
- package/dist/internal/Supervisor-BcglY23c.mjs.map +1 -0
- package/dist/internal/Tabs-dXMscIUQ.d.mts +52 -0
- package/dist/internal/TestPage-CYiYbh63.d.mts +159 -0
- package/dist/internal/ToolError-DArsRS2m.mjs +117 -0
- package/dist/internal/ToolError-DArsRS2m.mjs.map +1 -0
- package/dist/{plan/index.d.mts → internal/Walk-BNXcfZ2z.d.mts} +59 -35
- package/dist/{plan/index.mjs → internal/Walk-C5ky7uSf.mjs} +83 -51
- package/dist/internal/Walk-C5ky7uSf.mjs.map +1 -0
- package/dist/{ActionPort.mjs → internal/action-port-B5EkeGOR.mjs} +6 -12
- package/dist/internal/action-port-B5EkeGOR.mjs.map +1 -0
- package/dist/internal/cdp/workerd.d.mts +13 -0
- package/dist/internal/cdp/workerd.mjs +19 -0
- package/dist/internal/cdp/workerd.mjs.map +1 -0
- package/dist/{Clock.mjs → internal/clock-BKSAEf00.mjs} +13 -13
- package/dist/internal/clock-BKSAEf00.mjs.map +1 -0
- package/dist/{connection-2KHI4_KN.d.mts → internal/connection-BaB0vp1o.d.mts} +6 -6
- package/dist/{connection-CK83pvqP.mjs → internal/connection-C2X4GmXM.mjs} +19 -15
- package/dist/internal/connection-C2X4GmXM.mjs.map +1 -0
- package/dist/internal/events-DzCrww-y.mjs +72 -0
- package/dist/internal/events-DzCrww-y.mjs.map +1 -0
- package/dist/internal/fold.inpage-CyVZQHZL.d.mts +49 -0
- package/dist/internal/fold.inpage-uhrT-dOB.mjs +49 -0
- package/dist/internal/fold.inpage-uhrT-dOB.mjs.map +1 -0
- package/dist/internal/functions-jBOs6GKv.mjs +27 -0
- package/dist/internal/functions-jBOs6GKv.mjs.map +1 -0
- package/dist/{Geometry-DJx9qrYy.d.mts → internal/geometry-Dhj_ztJs.d.mts} +3 -3
- package/dist/{Geometry.mjs → internal/geometry-Lxyflb9J.mjs} +3 -12
- package/dist/internal/geometry-Lxyflb9J.mjs.map +1 -0
- package/dist/{Matching.mjs → internal/matching-Cs-UeOY0.mjs} +24 -19
- package/dist/internal/matching-Cs-UeOY0.mjs.map +1 -0
- package/dist/internal/page-DFQb-YOK.mjs +436 -0
- package/dist/internal/page-DFQb-YOK.mjs.map +1 -0
- package/dist/internal/pose.inpage-CBFeWcVa.mjs +1996 -0
- package/dist/internal/pose.inpage-CBFeWcVa.mjs.map +1 -0
- package/dist/{Url.mjs → internal/url-DB0pQYk6.mjs} +3 -12
- package/dist/internal/url-DB0pQYk6.mjs.map +1 -0
- package/dist/policy/Policy.d.mts +60 -6
- package/dist/policy/Policy.mjs +52 -9
- package/dist/policy/Policy.mjs.map +1 -1
- package/dist/policy/index.d.mts +2 -0
- package/dist/policy/index.mjs +2 -0
- package/dist/presentation/Film.d.mts +332 -0
- package/dist/presentation/Film.mjs +298 -0
- package/dist/presentation/Film.mjs.map +1 -0
- package/dist/presentation/Motion.d.mts +5 -1
- package/dist/presentation/Motion.mjs +16 -2
- package/dist/presentation/Motion.mjs.map +1 -1
- package/dist/presentation/Presentation.d.mts +48 -6
- package/dist/presentation/Presentation.mjs +28 -9
- package/dist/presentation/Presentation.mjs.map +1 -1
- package/dist/presentation/Stage.d.mts +40 -6
- package/dist/presentation/Stage.mjs +1 -262
- package/dist/presentation/index.d.mts +5 -0
- package/dist/presentation/index.mjs +5 -0
- package/dist/supervisor/Release.d.mts +2 -0
- package/dist/supervisor/Release.mjs +40 -0
- package/dist/supervisor/Release.mjs.map +1 -0
- package/dist/supervisor/Supervisor.d.mts +2 -104
- package/dist/supervisor/Supervisor.mjs +2 -515
- package/dist/supervisor/index.d.mts +3 -0
- package/dist/supervisor/index.mjs +3 -0
- package/dist/testing/HttpCassette.d.mts +98 -0
- package/dist/testing/HttpCassette.mjs +146 -0
- package/dist/testing/HttpCassette.mjs.map +1 -0
- package/dist/testing/Story.d.mts +31 -0
- package/dist/testing/Story.mjs +76 -0
- package/dist/testing/Story.mjs.map +1 -0
- package/dist/testing/TestBrowser.d.mts +191 -0
- package/dist/testing/TestBrowser.mjs +105 -0
- package/dist/testing/TestBrowser.mjs.map +1 -0
- package/dist/testing/TestModel.d.mts +133 -0
- package/dist/testing/TestModel.mjs +209 -0
- package/dist/testing/TestModel.mjs.map +1 -0
- package/dist/testing/TestPage.d.mts +2 -0
- package/dist/testing/TestPage.mjs +47 -0
- package/dist/testing/TestPage.mjs.map +1 -0
- package/dist/testing/index.d.mts +6 -337
- package/dist/testing/index.mjs +6 -515
- package/dist/timeline/Moment.d.mts +3 -0
- package/dist/timeline/Moment.mjs +3 -0
- package/dist/timeline/Stillness.d.mts +34 -0
- package/dist/timeline/Stillness.mjs +2 -0
- package/dist/timeline/index.d.mts +3 -0
- package/dist/timeline/index.mjs +3 -0
- package/dist/walk/Walk.d.mts +2 -0
- package/dist/walk/Walk.mjs +2 -0
- package/dist/walk/index.d.mts +2 -0
- package/dist/walk/index.mjs +2 -0
- package/package.json +54 -133
- package/src/Action.ts +73 -8
- package/src/Browser.ts +85 -14
- package/src/BrowserError.ts +258 -63
- package/src/BrowserEvent.ts +264 -48
- package/src/Cdp.ts +42 -0
- package/src/Change.ts +75 -4
- package/src/Frame.ts +247 -14
- package/src/{Style.ts → InputStyle.ts} +130 -18
- package/src/Layout.ts +187 -0
- package/src/Overlay.ts +76 -0
- package/src/Page.ts +144 -275
- package/src/PageTime.ts +72 -0
- package/src/Pose.ts +81 -0
- package/src/Site.ts +136 -0
- package/src/Snapshot.ts +179 -3
- package/src/Text.ts +60 -0
- package/src/Window.ts +53 -3
- package/src/ai/BrowserTools.ts +778 -0
- package/src/ai/PageControl.ts +702 -0
- package/src/ai/PromptCache.ts +87 -0
- package/src/ai/Tabs.ts +84 -0
- package/src/ai/ToolError.ts +50 -0
- package/src/ai/index.ts +36 -0
- package/src/ai/internal/crops.ts +38 -0
- package/src/ai/internal/points.ts +57 -0
- package/src/ai/internal/receipts.ts +107 -0
- package/src/index.ts +87 -6
- package/src/{ActionPort.ts → internal/action-port.ts} +3 -3
- package/src/{providers → internal/cdp}/connection.ts +19 -12
- package/src/internal/cdp/workerd.ts +36 -0
- package/src/{Clock.ts → internal/clock.ts} +20 -0
- package/src/internal/input/actions.ts +1 -1
- package/src/internal/input/dispatch.ts +2 -2
- package/src/internal/input/guard.inpage.ts +1 -1
- package/src/internal/input/guard.ts +1 -1
- package/src/internal/input/perform.ts +35 -7
- package/src/internal/input/pointer.ts +9 -6
- package/src/internal/input/targets.inpage.ts +3 -3
- package/src/internal/input/targets.ts +1 -1
- package/src/{Matching.ts → internal/matching.ts} +28 -19
- package/src/internal/page/bridge.ts +67 -35
- package/src/internal/page/clock.inpage.ts +306 -0
- package/src/internal/page/compose.inpage.ts +101 -0
- package/src/internal/page/context.ts +4 -2
- package/src/internal/page/functions.ts +84 -0
- package/src/internal/page/navigation.ts +1 -1
- package/src/internal/page/openings.ts +2 -2
- package/src/internal/page/overlay.inpage.ts +96 -0
- package/src/internal/page/overlay.ts +89 -0
- package/src/internal/page/page.ts +39 -29
- package/src/internal/page/port.ts +14 -8
- package/src/internal/page/pose.inpage.ts +200 -0
- package/src/internal/page/pose.ts +80 -0
- package/src/internal/page/replies.ts +1 -1
- package/src/internal/page/requests.ts +1 -1
- package/src/internal/page/scripts.ts +1 -1
- package/src/internal/page/time.inpage.ts +49 -0
- package/src/internal/page/time.ts +122 -0
- package/src/internal/page/viewport.ts +3 -2
- package/src/internal/pictures/capture.ts +1 -4
- package/src/internal/pictures/dimensions.ts +1 -1
- package/src/internal/pictures/frame.ts +1 -1
- package/src/internal/pictures/pictures.ts +144 -91
- package/src/internal/reading/context.inpage.ts +2 -2
- package/src/internal/reading/expect.inpage.ts +1 -1
- package/src/internal/reading/layout.inpage.ts +193 -0
- package/src/internal/reading/layout.ts +101 -0
- package/src/internal/reading/names.inpage.ts +15 -0
- package/src/internal/reading/outline.inpage.ts +5 -21
- package/src/internal/reading/reading.ts +33 -21
- package/src/internal/reading/ready.inpage.ts +21 -26
- package/src/internal/reading/ready.ts +26 -5
- package/src/internal/reading/subjects.inpage.ts +3 -3
- package/src/internal/reading/text.inpage.ts +3 -16
- package/src/internal/reading/walk.inpage.ts +1 -1
- package/src/internal/timeline/changes.inpage.ts +7 -15
- package/src/internal/timeline/changes.ts +17 -5
- package/src/internal/timeline/record.inpage.ts +15 -6
- package/src/internal/timeline/sight.inpage.ts +2 -2
- package/src/internal/timeline/window.ts +3 -4
- package/src/policy/Policy.ts +70 -16
- package/src/policy/index.ts +12 -0
- package/src/presentation/Film.ts +451 -0
- package/src/presentation/Motion.ts +45 -3
- package/src/presentation/Presentation.ts +60 -14
- package/src/presentation/Stage.ts +73 -35
- package/src/presentation/index.ts +30 -0
- package/src/presentation/{feed.ts → internal/feed.ts} +1 -1
- package/src/supervisor/Release.ts +45 -0
- package/src/supervisor/Supervisor.ts +80 -5
- package/src/supervisor/index.ts +18 -0
- package/src/supervisor/{contract.ts → internal/contract.ts} +14 -10
- package/src/supervisor/{lifecycle.ts → internal/lifecycle.ts} +7 -7
- package/src/supervisor/{runtime.ts → internal/runtime.ts} +7 -7
- package/src/testing/HttpCassette.ts +260 -0
- package/src/testing/Story.ts +103 -0
- package/src/testing/TestBrowser.ts +14 -4
- package/src/testing/TestModel.ts +297 -0
- package/src/testing/TestPage.ts +92 -4
- package/src/testing/index.ts +35 -1
- package/src/testing/{evidence.ts → internal/evidence.ts} +19 -11
- package/src/testing/{model.ts → internal/model.ts} +14 -8
- package/src/testing/{page.ts → internal/page.ts} +55 -51
- package/src/{moment → timeline}/Moment.ts +79 -29
- package/src/{stillness → timeline}/Stillness.ts +89 -46
- package/src/timeline/index.ts +18 -0
- package/src/{stillness/Pixels.ts → timeline/internal/pixels.ts} +27 -1
- package/src/{moment → timeline/internal}/words.ts +2 -2
- package/src/walk/Walk.ts +165 -0
- package/src/walk/index.ts +12 -0
- package/src/{plan → walk/internal}/choose.ts +23 -14
- package/src/{plan → walk/internal}/data.ts +37 -14
- package/src/{plan → walk/internal}/execute.ts +79 -36
- package/src/{plan → walk/internal}/record.ts +6 -6
- package/src/{plan → walk/internal}/targets.ts +35 -25
- package/dist/ActionPort.d.mts +0 -15
- package/dist/ActionPort.mjs.map +0 -1
- package/dist/Browser-BKPAbyys.mjs.map +0 -1
- package/dist/Change-Ba7INmay.d.mts +0 -69
- package/dist/Clock.d.mts +0 -57
- package/dist/Clock.mjs.map +0 -1
- package/dist/Frame-UEH2hO5T.d.mts +0 -124
- package/dist/Geometry.d.mts +0 -2
- package/dist/Geometry.mjs.map +0 -1
- package/dist/Matching.d.mts +0 -37
- package/dist/Matching.mjs.map +0 -1
- package/dist/Page-BF5izr8R.mjs.map +0 -1
- package/dist/Page-CvsOEorc.d.mts +0 -566
- package/dist/Released-tURbFmal.d.mts +0 -15
- package/dist/Snapshot-CtBVOtuu.d.mts +0 -73
- package/dist/Stillness-CNlvayIo.mjs +0 -136
- package/dist/Stillness-CNlvayIo.mjs.map +0 -1
- package/dist/Style-AO4V7Czt.mjs.map +0 -1
- package/dist/Style.d.mts +0 -72
- package/dist/Style.mjs +0 -2
- package/dist/Url.d.mts +0 -26
- package/dist/Url.mjs.map +0 -1
- package/dist/Window-CMddGMt1.d.mts +0 -34
- package/dist/connection-CK83pvqP.mjs.map +0 -1
- package/dist/moment/Moment.mjs.map +0 -1
- package/dist/plan/index.mjs.map +0 -1
- package/dist/presentation/Stage.mjs.map +0 -1
- package/dist/presentation/feed.d.mts +0 -20
- package/dist/presentation/feed.mjs +0 -18
- package/dist/presentation/feed.mjs.map +0 -1
- package/dist/providers/Cdp.d.mts +0 -9
- package/dist/providers/Cdp.mjs +0 -15
- package/dist/providers/Cdp.mjs.map +0 -1
- package/dist/providers/Chromium.d.mts +0 -32
- package/dist/providers/Chromium.mjs +0 -55
- package/dist/providers/Chromium.mjs.map +0 -1
- package/dist/providers/Released.d.mts +0 -2
- package/dist/providers/Released.mjs +0 -12
- package/dist/providers/Released.mjs.map +0 -1
- package/dist/stillness/Stillness.d.mts +0 -12
- package/dist/stillness/Stillness.mjs +0 -2
- package/dist/supervisor/Supervisor.mjs.map +0 -1
- package/dist/testing/index.mjs.map +0 -1
- package/dist/workerd/Cdp.d.mts +0 -8
- package/dist/workerd/Cdp.mjs +0 -13
- package/dist/workerd/Cdp.mjs.map +0 -1
- package/src/plan/index.ts +0 -36
- package/src/providers/Cdp.ts +0 -16
- package/src/providers/Chromium.ts +0 -99
- package/src/providers/Released.ts +0 -13
- package/src/workerd/Cdp.ts +0 -11
- /package/dist/{rolldown-runtime-D7D4PA-g.mjs → internal/rolldown-runtime-D7D4PA-g.mjs} +0 -0
- /package/src/{Geometry.ts → internal/geometry.ts} +0 -0
- /package/src/{Url.ts → internal/url.ts} +0 -0
- /package/src/{stillness → timeline/internal}/utilsBundle.d.ts +0 -0
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
* that was secret when the library saw it, such as a password its page now reveals. Text, and the
|
|
5
5
|
* outline, are cut at a line. See `names.inpage.ts` for what a page-side part may use.
|
|
6
6
|
*/
|
|
7
|
-
import { Schema } from "effect";
|
|
8
|
-
|
|
9
7
|
import type { Names } from "./names.inpage.ts";
|
|
10
|
-
import type {
|
|
8
|
+
import type { TextResult } from "./reading.ts";
|
|
9
|
+
import type { Walked } from "./walk.inpage.ts";
|
|
11
10
|
|
|
12
11
|
export interface TextRequest {
|
|
13
12
|
/** An element to read whole, or null for what the viewport shows. */
|
|
@@ -16,19 +15,7 @@ export interface TextRequest {
|
|
|
16
15
|
readonly unmask: boolean;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
export const TextResultSchema = Schema.NullOr(
|
|
21
|
-
Schema.Struct({
|
|
22
|
-
text: Schema.String,
|
|
23
|
-
truncated: Schema.Boolean,
|
|
24
|
-
url: Schema.String,
|
|
25
|
-
title: Schema.String,
|
|
26
|
-
}),
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
export type TextResult = typeof TextResultSchema.Type;
|
|
30
|
-
|
|
31
|
-
export const text = (names: Names, walked: Walk) => {
|
|
18
|
+
export const text = (names: Names, walked: Walked) => {
|
|
32
19
|
const { isHtml, isInput, isSecret, isSelect, isTextArea, lookup } = names;
|
|
33
20
|
|
|
34
21
|
// Input types whose value is a label or a choice rather than something entered.
|
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
* the input's own doing, by `Change.cause`'s rule. See `names.inpage.ts` for what a page-side part
|
|
9
9
|
* may use.
|
|
10
10
|
*/
|
|
11
|
-
import { Schema } from "effect";
|
|
12
11
|
|
|
13
|
-
import { Change } from "../../Change.ts";
|
|
12
|
+
import type { Change } from "../../Change.ts";
|
|
14
13
|
import type { Known, ContextReader } from "../reading/context.inpage.ts";
|
|
15
14
|
import type { Names } from "../reading/names.inpage.ts";
|
|
15
|
+
import type { Walked } from "../reading/walk.inpage.ts";
|
|
16
|
+
import type { ChangesResult } from "./changes.ts";
|
|
16
17
|
import type { Folded } from "./fold.inpage.ts";
|
|
17
18
|
import type { History } from "./history.inpage.ts";
|
|
18
19
|
import type { Marks } from "./marks.inpage.ts";
|
|
@@ -26,21 +27,9 @@ export interface ChangesRequest {
|
|
|
26
27
|
readonly unmask: boolean;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
/**
|
|
30
|
-
* What a read sends back: its window and the record's state, and each change as `Change` encodes
|
|
31
|
-
* it, all on the page's clock.
|
|
32
|
-
*/
|
|
33
|
-
export const ChangesResultSchema = Schema.Struct({
|
|
34
|
-
until: Schema.Finite,
|
|
35
|
-
from: Schema.Finite,
|
|
36
|
-
dropped: Schema.Int,
|
|
37
|
-
records: Schema.Array(Change),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export type ChangesResult = typeof ChangesResultSchema.Encoded;
|
|
41
|
-
|
|
42
30
|
export const changes = (
|
|
43
31
|
names: Names,
|
|
32
|
+
walked: Walked,
|
|
44
33
|
placing: ContextReader,
|
|
45
34
|
kept: History,
|
|
46
35
|
seeing: Sight,
|
|
@@ -151,6 +140,8 @@ export const changes = (
|
|
|
151
140
|
const { track, kind, before, after, lowest, highest, ...times } = one;
|
|
152
141
|
const element = track.key instanceof Element ? track.key : null;
|
|
153
142
|
const where = element?.isConnected === true ? element : (marking.placeOf(track.key) ?? null);
|
|
143
|
+
// What is hidden is drawn nowhere, so it has no box.
|
|
144
|
+
const box = where === null ? undefined : walked.boxOf(where);
|
|
154
145
|
const role = element === null ? null : roleOf(element);
|
|
155
146
|
const field = kind === "value";
|
|
156
147
|
|
|
@@ -176,6 +167,7 @@ export const changes = (
|
|
|
176
167
|
tag: element === null ? "title" : element.tagName.toLowerCase(),
|
|
177
168
|
context: kind === "title" || where === null ? {} : placing.contextOf(where, known),
|
|
178
169
|
},
|
|
170
|
+
box: box === undefined || (box.width === 0 && box.height === 0) ? undefined : box,
|
|
179
171
|
before: masked(before),
|
|
180
172
|
after: masked(after),
|
|
181
173
|
lowest: field ? undefined : lowest,
|
|
@@ -11,13 +11,25 @@
|
|
|
11
11
|
import { Clock, Duration, Effect, type Fiber, Schema, Semaphore } from "effect";
|
|
12
12
|
|
|
13
13
|
import type { BrowserError } from "../../BrowserError.ts";
|
|
14
|
-
import { Change, Changes } from "../../Change.ts";
|
|
15
|
-
import * as BrowserClock from "../../Clock.ts";
|
|
14
|
+
import { Change, Changes, type ChangesOptions } from "../../Change.ts";
|
|
16
15
|
import type { Frame } from "../../Frame.ts";
|
|
17
|
-
import
|
|
16
|
+
import * as BrowserClock from "../clock.ts";
|
|
18
17
|
import { type Bridge, scriptCall } from "../page/bridge.ts";
|
|
19
18
|
import { decodeWith, type PageContext } from "../page/context.ts";
|
|
20
|
-
import {
|
|
19
|
+
import type { ChangesRequest } from "./changes.inpage.ts";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* What a read sends back: its window and the record's state, and each change as `Change` encodes
|
|
23
|
+
* it, all on the page's clock.
|
|
24
|
+
*/
|
|
25
|
+
const ChangesResultSchema = Schema.Struct({
|
|
26
|
+
until: Schema.Finite,
|
|
27
|
+
from: Schema.Finite,
|
|
28
|
+
dropped: Schema.Int,
|
|
29
|
+
records: Schema.Array(Change),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export type ChangesResult = typeof ChangesResultSchema.Encoded;
|
|
21
33
|
|
|
22
34
|
const isChanges = Schema.is(Changes);
|
|
23
35
|
|
|
@@ -145,5 +157,5 @@ export const make = (
|
|
|
145
157
|
),
|
|
146
158
|
});
|
|
147
159
|
}).pipe(page.within("changes")),
|
|
148
|
-
).pipe(page.span("
|
|
160
|
+
).pipe(page.span("Change.read"), page.owned);
|
|
149
161
|
};
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* nobody has read for two minutes. While it runs, a MutationObserver hands each batch to
|
|
5
5
|
* `marks.inpage.ts`, and an IntersectionObserver judges as the page renders whether what was marked
|
|
6
6
|
* was in view (`sight.inpage.ts`). A field reports its value as it is edited, a secret one only as
|
|
7
|
-
* `••••`, and trusted pointer and key input is kept, for a read to name
|
|
8
|
-
* is read: no walk, no words, no layout. See `names.inpage.ts` for what
|
|
7
|
+
* `••••`, and trusted pointer and key input is kept, or input noted as such, for a read to name
|
|
8
|
+
* causes by. Nothing unmarked is read: no walk, no words, no layout. See `names.inpage.ts` for what
|
|
9
|
+
* a page-side part may use.
|
|
9
10
|
*/
|
|
10
11
|
import type { Names } from "../reading/names.inpage.ts";
|
|
11
12
|
import type { Texts } from "../reading/text.inpage.ts";
|
|
@@ -63,13 +64,16 @@ export const record = (
|
|
|
63
64
|
if (sample !== undefined) seeing.look(field, sample);
|
|
64
65
|
};
|
|
65
66
|
|
|
67
|
+
// Protocol timestamps are mapped estimates; observation and mutations share this clock.
|
|
68
|
+
const note = (target: Element) => {
|
|
69
|
+
inputs.push({ at: epoch(), target });
|
|
70
|
+
if (inputs.length > 8) inputs.shift();
|
|
71
|
+
};
|
|
72
|
+
|
|
66
73
|
const onInput = (event: Event) => {
|
|
67
74
|
const target = targetOf(event);
|
|
68
75
|
|
|
69
|
-
if (
|
|
70
|
-
// Protocol timestamps are mapped estimates; observation and mutations share this clock.
|
|
71
|
-
inputs.push({ at: epoch(), target });
|
|
72
|
-
if (inputs.length > 8) inputs.shift();
|
|
76
|
+
if (event.isTrusted && target !== undefined) note(target);
|
|
73
77
|
};
|
|
74
78
|
|
|
75
79
|
const listeners = [
|
|
@@ -129,6 +133,11 @@ export const record = (
|
|
|
129
133
|
document.addEventListener("DOMContentLoaded", begin, { once: true });
|
|
130
134
|
else begin();
|
|
131
135
|
},
|
|
136
|
+
/**
|
|
137
|
+
* Keep an input at `target` now, as a trusted one is kept: what a site does through its own
|
|
138
|
+
* app, whose events the page sees as untrusted, so its changes can name their cause.
|
|
139
|
+
*/
|
|
140
|
+
note,
|
|
132
141
|
inputs: (): ReadonlyArray<{ readonly at: number; readonly target: Element }> => inputs,
|
|
133
142
|
};
|
|
134
143
|
};
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { Names } from "../reading/names.inpage.ts";
|
|
12
12
|
import type { Texts } from "../reading/text.inpage.ts";
|
|
13
|
-
import type {
|
|
13
|
+
import type { Walked } from "../reading/walk.inpage.ts";
|
|
14
14
|
import type { Sample, Shown } from "./fold.inpage.ts";
|
|
15
15
|
import type { History } from "./history.inpage.ts";
|
|
16
16
|
|
|
17
|
-
export const sight = (names: Names, walked:
|
|
17
|
+
export const sight = (names: Names, walked: Walked, texts: Texts, kept: History) => {
|
|
18
18
|
const { clean } = names;
|
|
19
19
|
const { visible } = walked;
|
|
20
20
|
// Whether each watched element was in view as the page last rendered it, and whether the style
|
|
@@ -7,10 +7,9 @@ import { Duration, Effect, Option, Result, Schema } from "effect";
|
|
|
7
7
|
|
|
8
8
|
import type { BrowserError } from "../../BrowserError.ts";
|
|
9
9
|
import { type BrowserEvent, TrackEvent } from "../../BrowserEvent.ts";
|
|
10
|
-
import type { Changes } from "../../Change.ts";
|
|
10
|
+
import type { Changes, ChangesOptions } from "../../Change.ts";
|
|
11
11
|
import { Frame } from "../../Frame.ts";
|
|
12
|
-
import
|
|
13
|
-
import { Window } from "../../Window.ts";
|
|
12
|
+
import { Window, type WindowOptions } from "../../Window.ts";
|
|
14
13
|
import { type PageContext, refuse } from "../page/context.ts";
|
|
15
14
|
|
|
16
15
|
const isWindow = Schema.is(Window);
|
|
@@ -89,4 +88,4 @@ export const make =
|
|
|
89
88
|
changes: Result.getOrUndefined(changes),
|
|
90
89
|
missing: Option.toArray(Result.getFailure(changes)),
|
|
91
90
|
});
|
|
92
|
-
}).pipe(page.span("
|
|
91
|
+
}).pipe(page.span("Window.read"), page.owned);
|
package/src/policy/Policy.ts
CHANGED
|
@@ -14,15 +14,22 @@
|
|
|
14
14
|
* whatever the judge reads. A judge that fails or runs out of time leaves the input unjudged,
|
|
15
15
|
* which `make` refuses.
|
|
16
16
|
*
|
|
17
|
+
* @stability stable
|
|
17
18
|
* @since 0.3.0
|
|
18
19
|
*/
|
|
19
|
-
import { Cause, Context, Duration, Effect, Record, Result, Schema } from "effect";
|
|
20
|
+
import { Cause, Context, Duration, Effect, Function, Record, Result, Schema } from "effect";
|
|
20
21
|
import { type AiError, Decision, DecisionModel, LanguageModel, Prompt } from "effect/ai";
|
|
21
22
|
|
|
22
23
|
import { PolicyDenied } from "../BrowserError.ts";
|
|
23
24
|
import { Fact, type InputGuard, InputRequest } from "../Page.ts";
|
|
24
25
|
|
|
25
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* What an input means. Only a judge reading the evidence can recognise these.
|
|
28
|
+
*
|
|
29
|
+
* @stability stable
|
|
30
|
+
* @category schemas
|
|
31
|
+
* @since 0.3.0
|
|
32
|
+
*/
|
|
26
33
|
export const Risk = Schema.Literals([
|
|
27
34
|
"financial",
|
|
28
35
|
"account",
|
|
@@ -32,6 +39,11 @@ export const Risk = Schema.Literals([
|
|
|
32
39
|
"secret",
|
|
33
40
|
]);
|
|
34
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @stability stable
|
|
44
|
+
* @category models
|
|
45
|
+
* @since 0.3.0
|
|
46
|
+
*/
|
|
35
47
|
export type Risk = typeof Risk.Type;
|
|
36
48
|
|
|
37
49
|
// What each risk covers, in the words both judges are given.
|
|
@@ -48,8 +60,14 @@ const covers: { readonly [K in Risk]: string } = {
|
|
|
48
60
|
|
|
49
61
|
const Probability = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 1 }));
|
|
50
62
|
|
|
51
|
-
/**
|
|
52
|
-
|
|
63
|
+
/**
|
|
64
|
+
* A judge's reading of one input.
|
|
65
|
+
*
|
|
66
|
+
* @stability stable
|
|
67
|
+
* @category schemas
|
|
68
|
+
* @since 0.3.0
|
|
69
|
+
*/
|
|
70
|
+
export class Judgement extends Schema.Class<Judgement>("effect-browser/policy/Policy/Judgement")({
|
|
53
71
|
/** For each risk, the probability that the input does it. */
|
|
54
72
|
risks: Schema.Struct({
|
|
55
73
|
financial: Probability,
|
|
@@ -68,12 +86,22 @@ export class Judgement extends Schema.Class<Judgement>("effect-browser/Judgement
|
|
|
68
86
|
/**
|
|
69
87
|
* The user's task: what authorizes a risky input. `PageControl` provides its task to every input it
|
|
70
88
|
* makes; provide one around other calls with `Effect.provideService`.
|
|
89
|
+
*
|
|
90
|
+
* @stability stable
|
|
91
|
+
* @category services
|
|
92
|
+
* @since 0.3.0
|
|
71
93
|
*/
|
|
72
|
-
export const Task = Context.Reference<string | undefined>("effect-browser/Policy/Task", {
|
|
94
|
+
export const Task = Context.Reference<string | undefined>("effect-browser/policy/Policy/Task", {
|
|
73
95
|
defaultValue: () => undefined,
|
|
74
96
|
});
|
|
75
97
|
|
|
76
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Reads what an input means, with the user's task from `Task`.
|
|
100
|
+
*
|
|
101
|
+
* @stability stable
|
|
102
|
+
* @category models
|
|
103
|
+
* @since 0.3.0
|
|
104
|
+
*/
|
|
77
105
|
export type Judge = (request: InputRequest) => Effect.Effect<Judgement, AiError.AiError>;
|
|
78
106
|
|
|
79
107
|
/** What a judge is shown. Everything under `evidence` is the page's to write. */
|
|
@@ -148,6 +176,10 @@ const unit = (value: number) => Math.min(1, Math.max(0, value));
|
|
|
148
176
|
/**
|
|
149
177
|
* A judge that asks the `LanguageModel` in context for a structured review. `rules` adds the
|
|
150
178
|
* user's own policy in plain words, such as "Purchases under $20 are fine".
|
|
179
|
+
*
|
|
180
|
+
* @stability stable
|
|
181
|
+
* @category constructors
|
|
182
|
+
* @since 0.3.0
|
|
151
183
|
*/
|
|
152
184
|
export const reviewer = Effect.fnUntraced(function* (
|
|
153
185
|
options: { readonly rules?: string | undefined } = {},
|
|
@@ -196,6 +228,10 @@ const decisions = Decision.make({
|
|
|
196
228
|
* A judge that answers one probability per risk from the `DecisionModel` in context, all in one
|
|
197
229
|
* call. Jev is one: `TypeSafeDecisionModel.layer({ model: "jev-1.13.0" })` from
|
|
198
230
|
* `@effect/ai-typesafe` provides it.
|
|
231
|
+
*
|
|
232
|
+
* @stability stable
|
|
233
|
+
* @category constructors
|
|
234
|
+
* @since 0.3.0
|
|
199
235
|
*/
|
|
200
236
|
export const decider: Effect.Effect<Judge, never, DecisionModel.DecisionModel> = Effect.gen(
|
|
201
237
|
function* () {
|
|
@@ -219,19 +255,33 @@ const unsure = (value: number) => value > 0.2 && value < 0.8;
|
|
|
219
255
|
/**
|
|
220
256
|
* `first`'s judgement, or `second`'s when `first` is unsure: a risk between 0.2 and 0.8, or a
|
|
221
257
|
* likely risk whose request is. A confident mistake by `first` stands.
|
|
258
|
+
*
|
|
259
|
+
* @stability stable
|
|
260
|
+
* @category combinators
|
|
261
|
+
* @since 0.3.0
|
|
222
262
|
*/
|
|
223
|
-
export const escalate
|
|
263
|
+
export const escalate: {
|
|
264
|
+
(second: Judge): (first: Judge) => Judge;
|
|
265
|
+
(first: Judge, second: Judge): Judge;
|
|
266
|
+
} = Function.dual(
|
|
267
|
+
2,
|
|
224
268
|
(first: Judge, second: Judge): Judge =>
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
269
|
+
(request) =>
|
|
270
|
+
Effect.flatMap(first(request), (judgement) => {
|
|
271
|
+
const risks = Object.values(judgement.risks);
|
|
272
|
+
|
|
273
|
+
return risks.some(unsure) ||
|
|
274
|
+
(risks.some((value) => value >= 0.5) && unsure(judgement.requested ?? 0))
|
|
275
|
+
? second(request)
|
|
276
|
+
: Effect.succeed(judgement);
|
|
277
|
+
}),
|
|
278
|
+
);
|
|
234
279
|
|
|
280
|
+
/**
|
|
281
|
+
* @stability stable
|
|
282
|
+
* @category options
|
|
283
|
+
* @since 0.3.0
|
|
284
|
+
*/
|
|
235
285
|
export interface Options {
|
|
236
286
|
/** Reads what an input means. Without one, only origins and facts decide. */
|
|
237
287
|
readonly judge?: Judge | undefined;
|
|
@@ -260,6 +310,10 @@ const originOf = (url: string) => {
|
|
|
260
310
|
* input on a page or towards a destination outside `origins`, input with a fact in `deny`, and,
|
|
261
311
|
* when a judge finds a risk, input the task does not ask for. An input the judge could not judge
|
|
262
312
|
* in time is denied with the judge's failure as the denial's cause.
|
|
313
|
+
*
|
|
314
|
+
* @stability stable
|
|
315
|
+
* @category constructors
|
|
316
|
+
* @since 0.3.0
|
|
263
317
|
*/
|
|
264
318
|
export const make = (options: Options = {}): InputGuard => {
|
|
265
319
|
const threshold = options.threshold ?? 0.5;
|