effect-browser 0.3.0-beta.24 → 0.3.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +333 -157
- 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 +1 -1
- package/dist/BrowserEvent.mjs +166 -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 +33 -6
- 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/{Style.d.mts → InputStyle.d.mts} +93 -25
- package/dist/{Style.mjs → InputStyle.mjs} +1 -1
- package/dist/Layout.d.mts +2 -2
- package/dist/Layout.mjs +58 -16
- package/dist/Layout.mjs.map +1 -1
- package/dist/Overlay.d.mts +2 -2
- package/dist/Overlay.mjs +33 -5
- package/dist/Overlay.mjs.map +1 -1
- package/dist/Page.d.mts +2 -2
- package/dist/Page.mjs +2 -2
- package/dist/PageTime.d.mts +2 -2
- package/dist/PageTime.mjs +13 -3
- package/dist/PageTime.mjs.map +1 -1
- package/dist/Pose.d.mts +2 -2
- package/dist/Pose.mjs +30 -9
- package/dist/Pose.mjs.map +1 -1
- package/dist/Site.d.mts +288 -18
- package/dist/Site.mjs +11 -3
- package/dist/Site.mjs.map +1 -1
- 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 -18
- package/dist/index.mjs +6 -9
- package/dist/{Action-24sLOubi.d.mts → internal/Action-CkanNTUw.d.mts} +64 -4
- package/dist/{Browser-DGR6ZEYo.d.mts → internal/Browser-DD9Vm1c-.d.mts} +75 -11
- package/dist/{Browser-CAQFhTkM.mjs → internal/Browser-vzD7i2oj.mjs} +174 -237
- 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-C2p-NwuU.d.mts → internal/BrowserEvent-tGPYYf6R.d.mts} +168 -13
- package/dist/internal/BrowserTools-Yi3lOX4h.mjs +497 -0
- package/dist/internal/BrowserTools-Yi3lOX4h.mjs.map +1 -0
- package/dist/{Style-T3ezDYLI.mjs → internal/InputStyle-CPzxoN4g.mjs} +75 -20
- 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} +53 -20
- package/dist/internal/Page-BfGxn7oN.d.mts +1553 -0
- package/dist/{Page-BaAOshxo.mjs → internal/Page-DqF-tuTx.mjs} +62 -74
- 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-Db-YtlbE.d.mts → internal/connection-BaB0vp1o.d.mts} +6 -6
- package/dist/{connection-C_jWYIwe.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-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} +3 -3
- 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/{pose.inpage-CLq7Mfdr.mjs → internal/pose.inpage-CBFeWcVa.mjs} +2 -48
- 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/{film → presentation}/Film.d.mts +83 -16
- package/dist/{film → presentation}/Film.mjs +82 -30
- 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 +42 -7
- package/dist/presentation/Presentation.mjs +26 -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 -311
- package/dist/testing/index.mjs +6 -521
- 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 -163
- package/src/Action.ts +73 -8
- package/src/Browser.ts +75 -9
- package/src/BrowserError.ts +258 -63
- package/src/BrowserEvent.ts +252 -55
- package/src/Cdp.ts +42 -0
- package/src/Change.ts +68 -3
- package/src/Frame.ts +247 -14
- package/src/{Style.ts → InputStyle.ts} +98 -22
- package/src/Layout.ts +95 -24
- package/src/Overlay.ts +42 -3
- package/src/Page.ts +144 -320
- package/src/PageTime.ts +29 -4
- package/src/Pose.ts +38 -7
- package/src/Site.ts +15 -3
- 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 +83 -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 +5 -5
- package/src/internal/input/pointer.ts +2 -2
- package/src/internal/input/targets.inpage.ts +3 -3
- package/src/{Matching.ts → internal/matching.ts} +6 -6
- package/src/internal/page/bridge.ts +2 -2
- package/src/internal/page/clock.inpage.ts +1 -1
- package/src/internal/page/compose.inpage.ts +2 -2
- package/src/internal/page/context.ts +2 -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/page.ts +33 -35
- package/src/internal/page/port.ts +14 -8
- 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.ts +1 -1
- 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 +53 -61
- 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 +3 -3
- package/src/internal/reading/layout.ts +5 -5
- package/src/internal/reading/outline.inpage.ts +3 -3
- package/src/internal/reading/reading.ts +11 -19
- package/src/internal/reading/ready.inpage.ts +2 -2
- package/src/internal/reading/ready.ts +3 -2
- package/src/internal/reading/subjects.inpage.ts +3 -3
- package/src/internal/reading/text.inpage.ts +2 -2
- package/src/internal/reading/walk.inpage.ts +1 -1
- package/src/internal/timeline/changes.inpage.ts +2 -2
- package/src/internal/timeline/changes.ts +3 -4
- 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/{film → presentation}/Film.ts +104 -37
- package/src/presentation/Motion.ts +45 -3
- package/src/presentation/Presentation.ts +47 -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 -56
- package/src/{moment → timeline}/Moment.ts +79 -29
- package/src/{stillness → timeline}/Stillness.ts +61 -43
- package/src/timeline/index.ts +18 -0
- package/src/{stillness/Pixels.ts → timeline/internal/pixels.ts} +2 -2
- 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-CAQFhTkM.mjs.map +0 -1
- package/dist/Change-CxT1mp2e.d.mts +0 -80
- package/dist/Clock-Du5nP-nK.d.mts +0 -57
- package/dist/Clock.d.mts +0 -2
- 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-MtcWZ_hA.d.mts +0 -266
- package/dist/Matching.d.mts +0 -2
- package/dist/Matching.mjs.map +0 -1
- package/dist/Overlay-CoGw5tL_.d.mts +0 -27
- package/dist/Page-BaAOshxo.mjs.map +0 -1
- package/dist/Page-CLzh5E9w.d.mts +0 -718
- package/dist/PageTime-68UPUZpZ.d.mts +0 -29
- package/dist/Pose-2qqGzPvb.d.mts +0 -32
- package/dist/Released-tURbFmal.d.mts +0 -15
- package/dist/Snapshot-CtBVOtuu.d.mts +0 -73
- package/dist/Stillness-BwP0RdI4.mjs +0 -157
- package/dist/Stillness-BwP0RdI4.mjs.map +0 -1
- package/dist/Style-T3ezDYLI.mjs.map +0 -1
- package/dist/Url-B7P-TWwL.d.mts +0 -26
- package/dist/Url.d.mts +0 -2
- package/dist/Url.mjs.map +0 -1
- package/dist/Window-BDa8MtNP.d.mts +0 -34
- package/dist/connection-C_jWYIwe.mjs.map +0 -1
- package/dist/film/Film.mjs.map +0 -1
- package/dist/moment/Moment.mjs.map +0 -1
- package/dist/plan/index.mjs.map +0 -1
- package/dist/pose.inpage-CLq7Mfdr.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/{fold.inpage-CyVZQHZL.d.mts → internal/fold.inpage-CyVZQHZL.d.mts} +0 -0
- /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
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Schema, Stream } from "effect";
|
|
2
|
+
import { AiError, LanguageModel, Model, Prompt, Response, Tool } from "effect/ai";
|
|
3
|
+
declare namespace TestModel_d_exports {
|
|
4
|
+
export { Reply, Request, ScriptError, TestModel, Turn, call, calling, canonical, fingerprint, finish, isScriptError, layer, reply, streamed, text, textOf };
|
|
5
|
+
}
|
|
6
|
+
declare const ScriptError_base: Schema.Class<ScriptError, Schema.TaggedStruct<"ScriptError", {
|
|
7
|
+
readonly detail: Schema.String;
|
|
8
|
+
}>, import("effect/Cause").YieldableError>;
|
|
9
|
+
/**
|
|
10
|
+
* @stability stable
|
|
11
|
+
* @category errors
|
|
12
|
+
* @since 0.3.0
|
|
13
|
+
*/
|
|
14
|
+
export declare class ScriptError extends ScriptError_base {}
|
|
15
|
+
/**
|
|
16
|
+
* @stability stable
|
|
17
|
+
* @category guards
|
|
18
|
+
* @since 0.3.0
|
|
19
|
+
*/
|
|
20
|
+
export declare const isScriptError: <I>(input: I) => input is I & ScriptError;
|
|
21
|
+
/**
|
|
22
|
+
* Canonical JSON for request identity; object key order never changes a match.
|
|
23
|
+
*
|
|
24
|
+
* @stability stable
|
|
25
|
+
* @category combinators
|
|
26
|
+
* @since 0.3.0
|
|
27
|
+
*/
|
|
28
|
+
export declare const canonical: (value: unknown) => string;
|
|
29
|
+
/**
|
|
30
|
+
* @stability stable
|
|
31
|
+
* @category combinators
|
|
32
|
+
* @since 0.3.0
|
|
33
|
+
*/
|
|
34
|
+
export declare const fingerprint: (tools: ReadonlyArray<Tool.Any>) => string;
|
|
35
|
+
/**
|
|
36
|
+
* @stability stable
|
|
37
|
+
* @category models
|
|
38
|
+
* @since 0.3.0
|
|
39
|
+
*/
|
|
40
|
+
export interface Request {
|
|
41
|
+
readonly turn: number;
|
|
42
|
+
readonly options: LanguageModel.ProviderOptions;
|
|
43
|
+
readonly prompt: Prompt.Prompt;
|
|
44
|
+
readonly tools: ReadonlyArray<Tool.Any>;
|
|
45
|
+
readonly toolsFingerprint: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @stability stable
|
|
49
|
+
* @category models
|
|
50
|
+
* @since 0.3.0
|
|
51
|
+
*/
|
|
52
|
+
export interface Reply {
|
|
53
|
+
readonly parts: ReadonlyArray<Response.PartEncoded>;
|
|
54
|
+
/** Override delivery to model pacing, stalls, or a broken-off stream without changing generation. */
|
|
55
|
+
readonly stream?: Stream.Stream<Response.StreamPartEncoded, AiError.AiError> | undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @stability stable
|
|
59
|
+
* @category models
|
|
60
|
+
* @since 0.3.0
|
|
61
|
+
*/
|
|
62
|
+
export type Turn = (request: Request) => Effect.Effect<Reply, ScriptError | AiError.AiError>;
|
|
63
|
+
declare const TestModel_base: Context.ServiceClass<TestModel, "effect-browser/testing/TestModel", {
|
|
64
|
+
readonly requests: Effect.Effect<ReadonlyArray<Request>>;
|
|
65
|
+
readonly assertExhausted: Effect.Effect<void, ScriptError>;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* @stability stable
|
|
69
|
+
* @category services
|
|
70
|
+
* @since 0.3.0
|
|
71
|
+
*/
|
|
72
|
+
export declare class TestModel extends TestModel_base {}
|
|
73
|
+
/**
|
|
74
|
+
* Translate the finite response vocabulary at the streaming provider boundary.
|
|
75
|
+
*
|
|
76
|
+
* @stability stable
|
|
77
|
+
* @category constructors
|
|
78
|
+
* @since 0.3.0
|
|
79
|
+
*/
|
|
80
|
+
export declare const streamed: (parts: ReadonlyArray<Response.PartEncoded>) => ReadonlyArray<Response.StreamPartEncoded>;
|
|
81
|
+
/**
|
|
82
|
+
* @stability stable
|
|
83
|
+
* @category constructors
|
|
84
|
+
* @since 0.3.0
|
|
85
|
+
*/
|
|
86
|
+
export declare const finish: (reason?: "stop" | "tool-calls") => Response.PartEncoded;
|
|
87
|
+
/**
|
|
88
|
+
* @stability stable
|
|
89
|
+
* @category constructors
|
|
90
|
+
* @since 0.3.0
|
|
91
|
+
*/
|
|
92
|
+
export declare const text: (value: string) => ReadonlyArray<Response.PartEncoded>;
|
|
93
|
+
/**
|
|
94
|
+
* @stability stable
|
|
95
|
+
* @category constructors
|
|
96
|
+
* @since 0.3.0
|
|
97
|
+
*/
|
|
98
|
+
export declare const reply: (parts: ReadonlyArray<Response.PartEncoded>, stream?: Reply["stream"]) => Reply;
|
|
99
|
+
/**
|
|
100
|
+
* Call ids are explicit or local to a scripted turn; there is no process-global counter.
|
|
101
|
+
*
|
|
102
|
+
* @stability stable
|
|
103
|
+
* @category constructors
|
|
104
|
+
* @since 0.3.0
|
|
105
|
+
*/
|
|
106
|
+
export declare const call: (name: string, params: unknown, id?: string) => Response.PartEncoded;
|
|
107
|
+
/**
|
|
108
|
+
* @stability stable
|
|
109
|
+
* @category constructors
|
|
110
|
+
* @since 0.3.0
|
|
111
|
+
*/
|
|
112
|
+
export declare const calling: (...calls: ReadonlyArray<Response.PartEncoded>) => ReadonlyArray<Response.PartEncoded>;
|
|
113
|
+
/**
|
|
114
|
+
* @stability stable
|
|
115
|
+
* @category combinators
|
|
116
|
+
* @since 0.3.0
|
|
117
|
+
*/
|
|
118
|
+
export declare const textOf: (prompt: Prompt.Prompt) => string;
|
|
119
|
+
/**
|
|
120
|
+
* Ref allocation belongs to Layer construction, so rebuilding the layer starts the script afresh.
|
|
121
|
+
*
|
|
122
|
+
* @stability stable
|
|
123
|
+
* @category layers
|
|
124
|
+
* @since 0.3.0
|
|
125
|
+
*/
|
|
126
|
+
export declare const layer: (turns: ReadonlyArray<Turn> | {
|
|
127
|
+
readonly respond: Turn;
|
|
128
|
+
}, options?: {
|
|
129
|
+
readonly onRequest?: ((request: Request) => Effect.Effect<void>) | undefined;
|
|
130
|
+
}) => Layer.Layer<LanguageModel.LanguageModel | Model.ModelName | Model.ProviderName | TestModel, never, never>;
|
|
131
|
+
//#endregion
|
|
132
|
+
export { TestModel_d_exports as t };
|
|
133
|
+
//# sourceMappingURL=TestModel.d.mts.map
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { t as __exportAll } from "../internal/rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Context, Effect, Layer, Predicate, Ref, Schema, Stream } from "effect";
|
|
3
|
+
import { AiError, LanguageModel, Model } from "effect/ai";
|
|
4
|
+
//#region src/testing/TestModel.ts
|
|
5
|
+
/**
|
|
6
|
+
* Prompt-aware model scripts with per-layer request evidence and explicit exhaustion.
|
|
7
|
+
*
|
|
8
|
+
* @stability stable
|
|
9
|
+
* @since 0.3.0
|
|
10
|
+
*/
|
|
11
|
+
var TestModel_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
ScriptError: () => ScriptError,
|
|
13
|
+
TestModel: () => TestModel,
|
|
14
|
+
call: () => call,
|
|
15
|
+
calling: () => calling,
|
|
16
|
+
canonical: () => canonical,
|
|
17
|
+
fingerprint: () => fingerprint,
|
|
18
|
+
finish: () => finish,
|
|
19
|
+
isScriptError: () => isScriptError,
|
|
20
|
+
layer: () => layer,
|
|
21
|
+
reply: () => reply,
|
|
22
|
+
streamed: () => streamed,
|
|
23
|
+
text: () => text,
|
|
24
|
+
textOf: () => textOf
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* @stability stable
|
|
28
|
+
* @category errors
|
|
29
|
+
* @since 0.3.0
|
|
30
|
+
*/
|
|
31
|
+
var ScriptError = class extends Schema.TaggedError("effect-browser/testing/TestModel/ScriptError")("ScriptError", { detail: Schema.String }) {};
|
|
32
|
+
/**
|
|
33
|
+
* @stability stable
|
|
34
|
+
* @category guards
|
|
35
|
+
* @since 0.3.0
|
|
36
|
+
*/
|
|
37
|
+
const isScriptError = Schema.is(ScriptError);
|
|
38
|
+
const normalized = (value) => Array.isArray(value) ? value.map(normalized) : Predicate.isObject(value) ? Object.fromEntries(Object.keys(value).toSorted().map((key) => [key, normalized(Reflect.get(value, key))])) : value ?? null;
|
|
39
|
+
/**
|
|
40
|
+
* Canonical JSON for request identity; object key order never changes a match.
|
|
41
|
+
*
|
|
42
|
+
* @stability stable
|
|
43
|
+
* @category combinators
|
|
44
|
+
* @since 0.3.0
|
|
45
|
+
*/
|
|
46
|
+
const canonical = (value) => JSON.stringify(normalized(value));
|
|
47
|
+
/**
|
|
48
|
+
* @stability stable
|
|
49
|
+
* @category combinators
|
|
50
|
+
* @since 0.3.0
|
|
51
|
+
*/
|
|
52
|
+
const fingerprint = (tools) => canonical(tools.map((tool) => ({
|
|
53
|
+
name: String(tool.name),
|
|
54
|
+
description: tool.description,
|
|
55
|
+
parameters: Schema.toJsonSchemaDocument(tool.parametersSchema)
|
|
56
|
+
})).toSorted((left, right) => left.name.localeCompare(right.name)));
|
|
57
|
+
/**
|
|
58
|
+
* @stability stable
|
|
59
|
+
* @category services
|
|
60
|
+
* @since 0.3.0
|
|
61
|
+
*/
|
|
62
|
+
var TestModel = class extends Context.Service()("effect-browser/testing/TestModel") {};
|
|
63
|
+
const failed = (error) => AiError.make({
|
|
64
|
+
module: "TestModel",
|
|
65
|
+
method: "request",
|
|
66
|
+
reason: new AiError.InvalidRequestError({ description: error.detail })
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Translate the finite response vocabulary at the streaming provider boundary.
|
|
70
|
+
*
|
|
71
|
+
* @stability stable
|
|
72
|
+
* @category constructors
|
|
73
|
+
* @since 0.3.0
|
|
74
|
+
*/
|
|
75
|
+
const streamed = (parts) => parts.flatMap((part, index) => {
|
|
76
|
+
if (part.type === "text" || part.type === "reasoning") {
|
|
77
|
+
const id = `${part.type}-${index}`;
|
|
78
|
+
return part.type === "text" ? [
|
|
79
|
+
{
|
|
80
|
+
type: "text-start",
|
|
81
|
+
id
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: "text-delta",
|
|
85
|
+
id,
|
|
86
|
+
delta: part.text
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: "text-end",
|
|
90
|
+
id
|
|
91
|
+
}
|
|
92
|
+
] : [
|
|
93
|
+
{
|
|
94
|
+
type: "reasoning-start",
|
|
95
|
+
id
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
type: "reasoning-delta",
|
|
99
|
+
id,
|
|
100
|
+
delta: part.text
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: "reasoning-end",
|
|
104
|
+
id
|
|
105
|
+
}
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
return [part];
|
|
109
|
+
});
|
|
110
|
+
/**
|
|
111
|
+
* @stability stable
|
|
112
|
+
* @category constructors
|
|
113
|
+
* @since 0.3.0
|
|
114
|
+
*/
|
|
115
|
+
const finish = (reason = "stop") => ({
|
|
116
|
+
type: "finish",
|
|
117
|
+
reason,
|
|
118
|
+
usage: {
|
|
119
|
+
inputTokens: { total: 100 },
|
|
120
|
+
outputTokens: { total: 10 }
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
/**
|
|
124
|
+
* @stability stable
|
|
125
|
+
* @category constructors
|
|
126
|
+
* @since 0.3.0
|
|
127
|
+
*/
|
|
128
|
+
const text = (value) => [{
|
|
129
|
+
type: "text",
|
|
130
|
+
text: value
|
|
131
|
+
}, finish()];
|
|
132
|
+
/**
|
|
133
|
+
* @stability stable
|
|
134
|
+
* @category constructors
|
|
135
|
+
* @since 0.3.0
|
|
136
|
+
*/
|
|
137
|
+
const reply = (parts, stream) => ({
|
|
138
|
+
parts,
|
|
139
|
+
stream
|
|
140
|
+
});
|
|
141
|
+
/**
|
|
142
|
+
* Call ids are explicit or local to a scripted turn; there is no process-global counter.
|
|
143
|
+
*
|
|
144
|
+
* @stability stable
|
|
145
|
+
* @category constructors
|
|
146
|
+
* @since 0.3.0
|
|
147
|
+
*/
|
|
148
|
+
const call = (name, params, id = "") => ({
|
|
149
|
+
type: "tool-call",
|
|
150
|
+
id,
|
|
151
|
+
name,
|
|
152
|
+
params
|
|
153
|
+
});
|
|
154
|
+
/**
|
|
155
|
+
* @stability stable
|
|
156
|
+
* @category constructors
|
|
157
|
+
* @since 0.3.0
|
|
158
|
+
*/
|
|
159
|
+
const calling = (...calls) => [...calls, finish("tool-calls")];
|
|
160
|
+
/**
|
|
161
|
+
* @stability stable
|
|
162
|
+
* @category combinators
|
|
163
|
+
* @since 0.3.0
|
|
164
|
+
*/
|
|
165
|
+
const textOf = (prompt) => prompt.content.flatMap((message) => message.role === "system" ? [message.content] : message.content.flatMap((part) => part.type === "text" ? [part.text] : part.type === "tool-result" ? [JSON.stringify(part.result)] : [])).join("\n");
|
|
166
|
+
/**
|
|
167
|
+
* Ref allocation belongs to Layer construction, so rebuilding the layer starts the script afresh.
|
|
168
|
+
*
|
|
169
|
+
* @stability stable
|
|
170
|
+
* @category layers
|
|
171
|
+
* @since 0.3.0
|
|
172
|
+
*/
|
|
173
|
+
const layer = (turns, options = {}) => Layer.unwrap(Effect.gen(function* () {
|
|
174
|
+
const requests = yield* Ref.make([]);
|
|
175
|
+
const next = (options) => Effect.gen(function* () {
|
|
176
|
+
const request = yield* Ref.modify(requests, (seen) => {
|
|
177
|
+
const request = {
|
|
178
|
+
turn: seen.length + 1,
|
|
179
|
+
options,
|
|
180
|
+
prompt: options.prompt,
|
|
181
|
+
tools: options.tools,
|
|
182
|
+
toolsFingerprint: fingerprint(options.tools)
|
|
183
|
+
};
|
|
184
|
+
return [request, [...seen, request]];
|
|
185
|
+
});
|
|
186
|
+
yield* optionsOnRequest(request);
|
|
187
|
+
const turn = "respond" in turns ? turns.respond : turns[request.turn - 1];
|
|
188
|
+
return turn === void 0 ? yield* new ScriptError({ detail: `script exhausted at request ${request.turn}` }) : yield* Effect.map(turn(request), (reply) => ({
|
|
189
|
+
...reply,
|
|
190
|
+
parts: reply.parts.map((part, index) => part.type === "tool-call" && part.id === "" ? {
|
|
191
|
+
...part,
|
|
192
|
+
id: `call-${request.turn}-${index}`
|
|
193
|
+
} : part)
|
|
194
|
+
}));
|
|
195
|
+
}).pipe(Effect.mapError((error) => isScriptError(error) ? failed(error) : error));
|
|
196
|
+
const optionsOnRequest = options.onRequest ?? (() => Effect.void);
|
|
197
|
+
const model = yield* LanguageModel.make({
|
|
198
|
+
generateText: (request) => Effect.map(next(request), ({ parts }) => [...parts]),
|
|
199
|
+
streamText: (request) => Stream.unwrap(Effect.map(next(request), (reply) => reply.stream ?? Stream.fromIterable(streamed(reply.parts))))
|
|
200
|
+
});
|
|
201
|
+
return Layer.merge(Model.make("scripted", "test-model", Layer.succeed(LanguageModel.LanguageModel, model)), Layer.succeed(TestModel, {
|
|
202
|
+
requests: Ref.get(requests),
|
|
203
|
+
assertExhausted: Effect.flatMap(Ref.get(requests), (seen) => "respond" in turns || seen.length === turns.length ? Effect.void : Effect.fail(new ScriptError({ detail: seen.length > turns.length ? `${seen.length - turns.length} unexpected scripted requests` : `${turns.length - seen.length} unused scripted turns` })))
|
|
204
|
+
}));
|
|
205
|
+
}));
|
|
206
|
+
//#endregion
|
|
207
|
+
export { ScriptError, TestModel, call, calling, canonical, fingerprint, finish, isScriptError, layer, reply, streamed, TestModel_exports as t, text, textOf };
|
|
208
|
+
|
|
209
|
+
//# sourceMappingURL=TestModel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestModel.mjs","names":[],"sources":["../../src/testing/TestModel.ts"],"sourcesContent":["/**\n * Prompt-aware model scripts with per-layer request evidence and explicit exhaustion.\n *\n * @stability stable\n * @since 0.3.0\n */\nimport { Context, Effect, Layer, Predicate, Ref, Schema, Stream } from \"effect\";\nimport { AiError, LanguageModel, Model, type Prompt, type Response, type Tool } from \"effect/ai\";\n\n/**\n * @stability stable\n * @category errors\n * @since 0.3.0\n */\nexport class ScriptError extends Schema.TaggedError<ScriptError>(\n \"effect-browser/testing/TestModel/ScriptError\",\n)(\"ScriptError\", {\n detail: Schema.String,\n}) {}\n\n/**\n * @stability stable\n * @category guards\n * @since 0.3.0\n */\nexport const isScriptError = Schema.is(ScriptError);\n\nconst normalized = (value: unknown): unknown =>\n Array.isArray(value)\n ? value.map(normalized)\n : Predicate.isObject(value)\n ? Object.fromEntries(\n Object.keys(value)\n .toSorted()\n .map((key) => [key, normalized(Reflect.get(value, key))]),\n )\n : (value ?? null);\n\n/**\n * Canonical JSON for request identity; object key order never changes a match.\n *\n * @stability stable\n * @category combinators\n * @since 0.3.0\n */\nexport const canonical = (value: unknown): string => JSON.stringify(normalized(value));\n\n/**\n * @stability stable\n * @category combinators\n * @since 0.3.0\n */\nexport const fingerprint = (tools: ReadonlyArray<Tool.Any>): string =>\n canonical(\n tools\n .map((tool) => ({\n name: String(tool.name),\n description: tool.description,\n parameters: Schema.toJsonSchemaDocument(tool.parametersSchema),\n }))\n .toSorted((left, right) => left.name.localeCompare(right.name)),\n );\n\n/**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Request {\n readonly turn: number;\n readonly options: LanguageModel.ProviderOptions;\n readonly prompt: Prompt.Prompt;\n readonly tools: ReadonlyArray<Tool.Any>;\n readonly toolsFingerprint: string;\n}\n\n/**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Reply {\n readonly parts: ReadonlyArray<Response.PartEncoded>;\n /** Override delivery to model pacing, stalls, or a broken-off stream without changing generation. */\n readonly stream?: Stream.Stream<Response.StreamPartEncoded, AiError.AiError> | undefined;\n}\n\n/**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport type Turn = (request: Request) => Effect.Effect<Reply, ScriptError | AiError.AiError>;\n\n/**\n * @stability stable\n * @category services\n * @since 0.3.0\n */\nexport class TestModel extends Context.Service<\n TestModel,\n {\n readonly requests: Effect.Effect<ReadonlyArray<Request>>;\n readonly assertExhausted: Effect.Effect<void, ScriptError>;\n }\n>()(\"effect-browser/testing/TestModel\") {}\n\nconst failed = (error: ScriptError) =>\n AiError.make({\n module: \"TestModel\",\n method: \"request\",\n reason: new AiError.InvalidRequestError({ description: error.detail }),\n });\n\n/**\n * Translate the finite response vocabulary at the streaming provider boundary.\n *\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const streamed = (\n parts: ReadonlyArray<Response.PartEncoded>,\n): ReadonlyArray<Response.StreamPartEncoded> =>\n parts.flatMap((part, index): ReadonlyArray<Response.StreamPartEncoded> => {\n if (part.type === \"text\" || part.type === \"reasoning\") {\n const id = `${part.type}-${index}`;\n\n return part.type === \"text\"\n ? [\n { type: \"text-start\", id },\n { type: \"text-delta\", id, delta: part.text },\n { type: \"text-end\", id },\n ]\n : [\n { type: \"reasoning-start\", id },\n { type: \"reasoning-delta\", id, delta: part.text },\n { type: \"reasoning-end\", id },\n ];\n }\n\n return [part];\n });\n\n/**\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const finish = (reason: \"stop\" | \"tool-calls\" = \"stop\"): Response.PartEncoded => ({\n type: \"finish\",\n reason,\n usage: { inputTokens: { total: 100 }, outputTokens: { total: 10 } },\n});\n\n/**\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const text = (value: string): ReadonlyArray<Response.PartEncoded> => [\n { type: \"text\", text: value },\n finish(),\n];\n\n/**\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const reply = (\n parts: ReadonlyArray<Response.PartEncoded>,\n stream?: Reply[\"stream\"],\n): Reply => ({ parts, stream });\n\n/**\n * Call ids are explicit or local to a scripted turn; there is no process-global counter.\n *\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const call = (name: string, params: unknown, id = \"\"): Response.PartEncoded => ({\n type: \"tool-call\",\n id,\n name,\n params,\n});\n\n/**\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const calling = (\n ...calls: ReadonlyArray<Response.PartEncoded>\n): ReadonlyArray<Response.PartEncoded> => [...calls, finish(\"tool-calls\")];\n\n/**\n * @stability stable\n * @category combinators\n * @since 0.3.0\n */\nexport const textOf = (prompt: Prompt.Prompt): string =>\n prompt.content\n .flatMap((message) =>\n message.role === \"system\"\n ? [message.content]\n : message.content.flatMap((part) =>\n part.type === \"text\"\n ? [part.text]\n : part.type === \"tool-result\"\n ? [JSON.stringify(part.result)]\n : [],\n ),\n )\n .join(\"\\n\");\n\n/**\n * Ref allocation belongs to Layer construction, so rebuilding the layer starts the script afresh.\n *\n * @stability stable\n * @category layers\n * @since 0.3.0\n */\nexport const layer = (\n turns: ReadonlyArray<Turn> | { readonly respond: Turn },\n options: {\n readonly onRequest?: ((request: Request) => Effect.Effect<void>) | undefined;\n } = {},\n) =>\n Layer.unwrap(\n Effect.gen(function* () {\n const requests = yield* Ref.make<ReadonlyArray<Request>>([]);\n\n const next = (options: LanguageModel.ProviderOptions) =>\n Effect.gen(function* () {\n const request = yield* Ref.modify(requests, (seen) => {\n const request: Request = {\n turn: seen.length + 1,\n options,\n prompt: options.prompt,\n tools: options.tools,\n toolsFingerprint: fingerprint(options.tools),\n };\n\n return [request, [...seen, request]];\n });\n\n yield* optionsOnRequest(request);\n const turn = \"respond\" in turns ? turns.respond : turns[request.turn - 1];\n\n return turn === undefined\n ? yield* new ScriptError({ detail: `script exhausted at request ${request.turn}` })\n : yield* Effect.map(turn(request), (reply) => ({\n ...reply,\n parts: reply.parts.map((part, index) =>\n part.type === \"tool-call\" && part.id === \"\"\n ? { ...part, id: `call-${request.turn}-${index}` }\n : part,\n ),\n }));\n }).pipe(Effect.mapError((error) => (isScriptError(error) ? failed(error) : error)));\n\n const optionsOnRequest = options.onRequest ?? (() => Effect.void);\n\n const model = yield* LanguageModel.make({\n generateText: (request) => Effect.map(next(request), ({ parts }) => [...parts]),\n streamText: (request) =>\n Stream.unwrap(\n Effect.map(\n next(request),\n (reply) => reply.stream ?? Stream.fromIterable(streamed(reply.parts)),\n ),\n ),\n });\n\n return Layer.merge(\n Model.make(\"scripted\", \"test-model\", Layer.succeed(LanguageModel.LanguageModel, model)),\n Layer.succeed(TestModel, {\n requests: Ref.get(requests),\n assertExhausted: Effect.flatMap(Ref.get(requests), (seen) =>\n \"respond\" in turns || seen.length === turns.length\n ? Effect.void\n : Effect.fail(\n new ScriptError({\n detail:\n seen.length > turns.length\n ? `${seen.length - turns.length} unexpected scripted requests`\n : `${turns.length - seen.length} unused scripted turns`,\n }),\n ),\n ),\n }),\n );\n }),\n );\n"],"mappings":"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"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { t as __exportAll } from "../internal/rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { i as key, n as functionsOf, t as Implementation } from "../internal/functions-jBOs6GKv.mjs";
|
|
3
|
+
import { t as makeIn } from "../internal/page-DFQb-YOK.mjs";
|
|
4
|
+
//#region src/testing/TestPage.ts
|
|
5
|
+
var TestPage_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
make: () => make,
|
|
7
|
+
withPictures: () => withPictures
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* @stability stable
|
|
11
|
+
* @category constructors
|
|
12
|
+
* @since 0.3.0
|
|
13
|
+
*/
|
|
14
|
+
const make = (seed = {}, options = {}) => makeIn(seed, options);
|
|
15
|
+
/**
|
|
16
|
+
* A copy of `page` whose `Frame` functions read what `pictures` makes of its own, so a test can
|
|
17
|
+
* watch what a reader took or give it pictures of its own making. The page's members are its own.
|
|
18
|
+
*
|
|
19
|
+
* @stability stable
|
|
20
|
+
* @category combinators
|
|
21
|
+
* @since 0.3.0
|
|
22
|
+
*/
|
|
23
|
+
const withPictures = (page, pictures) => {
|
|
24
|
+
const functions = functionsOf(page);
|
|
25
|
+
const { read, zoom, capture, recent, paint } = pictures({
|
|
26
|
+
read: functions.frame,
|
|
27
|
+
zoom: functions.zoom,
|
|
28
|
+
capture: functions.capture,
|
|
29
|
+
recent: functions.recentFrames,
|
|
30
|
+
paint: functions.paint
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
...page,
|
|
34
|
+
[key]: new Implementation({
|
|
35
|
+
...functions,
|
|
36
|
+
frame: read,
|
|
37
|
+
zoom,
|
|
38
|
+
capture,
|
|
39
|
+
recentFrames: recent,
|
|
40
|
+
paint
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { make, TestPage_exports as t, withPictures };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=TestPage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestPage.mjs","names":[],"sources":["../../src/testing/TestPage.ts"],"sourcesContent":["/**\n * Seed a deterministic page without executing page code or inferring browser effects, or give a\n * page pictures of a test's own.\n *\n * @stability stable\n * @since 0.3.0\n */\nimport type { Effect, Scope } from \"effect\";\n\nimport type { BrowserError } from \"../BrowserError.ts\";\nimport type * as Frame from \"../Frame.ts\";\nimport { functionsOf, Implementation, key } from \"../internal/page/functions.ts\";\nimport type { Page } from \"../Page.ts\";\nimport type { Seed } from \"./internal/model.ts\";\nimport { makeIn } from \"./internal/page.ts\";\n\nexport type {\n /**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\n Seed,\n /**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\n Element,\n /**\n * @stability stable\n * @category models\n * @since 0.3.0\n */\n ChangeTrack,\n} from \"./internal/model.ts\";\n\n/**\n * @stability stable\n * @category constructors\n * @since 0.3.0\n */\nexport const make = (\n seed: Seed = {},\n options: { readonly id?: string; readonly session?: string; readonly connection?: string } = {},\n) => makeIn(seed, options);\n\n/**\n * What a page's `Frame` functions read, each under its function's name.\n *\n * @stability stable\n * @category models\n * @since 0.3.0\n */\nexport interface Pictures {\n readonly read: (options?: Frame.FrameOptions) => Effect.Effect<Frame.Frame, BrowserError>;\n readonly zoom: (\n region: Frame.Region,\n options?: Pick<Frame.FrameOptions, \"quality\" | \"format\" | \"scale\">,\n ) => Effect.Effect<Frame.Zoom, BrowserError>;\n readonly capture: (\n options?: Frame.ScreencastOptions,\n ) => Effect.Effect<Frame.Capture, BrowserError, Scope.Scope>;\n readonly recent: Effect.Effect<ReadonlyArray<Frame.Frame>>;\n readonly paint: (options: Frame.Paint) => Effect.Effect<void, BrowserError, Scope.Scope>;\n}\n\n/**\n * A copy of `page` whose `Frame` functions read what `pictures` makes of its own, so a test can\n * watch what a reader took or give it pictures of its own making. The page's members are its own.\n *\n * @stability stable\n * @category combinators\n * @since 0.3.0\n */\nexport const withPictures = <P extends Page>(page: P, pictures: (own: Pictures) => Pictures): P => {\n const functions = functionsOf(page);\n\n const { read, zoom, capture, recent, paint } = pictures({\n read: functions.frame,\n zoom: functions.zoom,\n capture: functions.capture,\n recent: functions.recentFrames,\n paint: functions.paint,\n });\n\n return {\n ...page,\n [key]: new Implementation({\n ...functions,\n frame: read,\n zoom,\n capture,\n recentFrames: recent,\n paint,\n }),\n };\n};\n"],"mappings":";;;;;;;;;;;;;AA0CA,MAAa,QACX,OAAa,CAAC,GACd,UAA6F,CAAC,MAC3F,OAAO,MAAM,OAAO;;;;;;;;;AA8BzB,MAAa,gBAAgC,MAAS,aAA6C;CACjG,MAAM,YAAY,YAAY,IAAI;CAElC,MAAM,EAAE,MAAM,MAAM,SAAS,QAAQ,UAAU,SAAS;EACtD,MAAM,UAAU;EAChB,MAAM,UAAU;EAChB,SAAS,UAAU;EACnB,QAAQ,UAAU;EAClB,OAAO,UAAU;CACnB,CAAC;CAED,OAAO;EACL,GAAG;GACF,MAAM,IAAI,eAAe;GACxB,GAAG;GACH,OAAO;GACP;GACA;GACA,cAAc;GACd;EACF,CAAC;CACH;AACF"}
|