effect-browserbase 0.1.0-beta.104 → 0.2.0-beta.1
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 +106 -307
- package/dist/Account.d.mts +17 -19
- package/dist/Account.mjs +4 -9
- package/dist/Account.mjs.map +1 -1
- package/dist/{Acquisition-WBafHwXH.mjs → Acquisition-CAsTTXp4.mjs} +25 -70
- package/dist/Acquisition-CAsTTXp4.mjs.map +1 -0
- package/dist/Agents-5HpTp9YE.d.mts +155 -0
- package/dist/Agents.d.mts +3 -156
- package/dist/Agents.mjs +4 -20
- package/dist/Agents.mjs.map +1 -1
- package/dist/Allocation.d.mts +9 -11
- package/dist/Allocation.mjs +2 -4
- package/dist/Allocation.mjs.map +1 -1
- package/dist/Browser-DpSajNai.mjs +270 -0
- package/dist/Browser-DpSajNai.mjs.map +1 -0
- package/dist/Browser.d.mts +26 -143
- package/dist/Browser.mjs +3 -223
- package/dist/BrowserBinding.d.mts +7 -34
- package/dist/BrowserBinding.mjs +30 -1
- package/dist/BrowserBinding.mjs.map +1 -0
- package/dist/Certificates-D4NQmyeA.d.mts +34 -0
- package/dist/Certificates.d.mts +3 -35
- package/dist/Certificates.mjs +2 -7
- package/dist/Certificates.mjs.map +1 -1
- package/dist/{Cleanup-G2YpTCuU.d.mts → Cleanup-DMTDBir8.d.mts} +5 -6
- package/dist/Cleanup.d.mts +3 -2
- package/dist/Cleanup.mjs +1 -6
- package/dist/Cleanup.mjs.map +1 -1
- package/dist/{Client-D1_xYM9o.mjs → Client-4RMKIpL2.mjs} +12 -12
- package/dist/Client-4RMKIpL2.mjs.map +1 -0
- package/dist/{Client-Ca0zSg1n.d.mts → Client-B_f6bBLT.d.mts} +4 -5
- package/dist/Client.d.mts +3 -2
- package/dist/Client.mjs +1 -1
- package/dist/Connection-sxyxtwlk.mjs +56 -0
- package/dist/Connection-sxyxtwlk.mjs.map +1 -0
- package/dist/ContextCoordination.d.mts +5 -6
- package/dist/ContextCoordination.mjs +2 -9
- package/dist/ContextCoordination.mjs.map +1 -1
- package/dist/{ContextWriter-BrQmoXRg.mjs → ContextWriter-oKWFLHuP.mjs} +8 -12
- package/dist/ContextWriter-oKWFLHuP.mjs.map +1 -0
- package/dist/Contexts-DqdL7cyX.d.mts +31 -0
- package/dist/Contexts.d.mts +3 -32
- package/dist/Contexts.mjs +3 -9
- package/dist/Contexts.mjs.map +1 -1
- package/dist/Downloads-CdhiCO5X.d.mts +43 -0
- package/dist/Downloads.d.mts +3 -44
- package/dist/Downloads.mjs +3 -8
- package/dist/Downloads.mjs.map +1 -1
- package/dist/Errors.d.mts +3 -26
- package/dist/Errors.mjs +1 -137
- package/dist/Errors.mjs.map +1 -1
- package/dist/Extensions-DBXuVM1f.d.mts +43 -0
- package/dist/{Extensions-ClZbYb1H.mjs → Extensions-Dg3jHOf0.mjs} +3 -9
- package/dist/Extensions-Dg3jHOf0.mjs.map +1 -0
- package/dist/Extensions.d.mts +3 -44
- package/dist/Extensions.mjs +1 -1
- package/dist/Functions-CsKMMUuZ.d.mts +226 -0
- package/dist/Functions.d.mts +3 -227
- package/dist/Functions.mjs +4 -18
- package/dist/Functions.mjs.map +1 -1
- package/dist/{Launch-BHcAEq05.mjs → Launch-cAdE2rrZ.mjs} +16 -12
- package/dist/Launch-cAdE2rrZ.mjs.map +1 -0
- package/dist/Launch.d.mts +127 -2
- package/dist/Launch.mjs +5 -13
- package/dist/Launch.mjs.map +1 -1
- package/dist/PageFetch-CAMqb5m8.d.mts +39 -0
- package/dist/PageFetch.d.mts +3 -40
- package/dist/PageFetch.mjs +2 -8
- package/dist/PageFetch.mjs.map +1 -1
- package/dist/Projects-tm5bTDH0.d.mts +38 -0
- package/dist/Projects.d.mts +3 -39
- package/dist/Projects.mjs +2 -8
- package/dist/Projects.mjs.map +1 -1
- package/dist/Recordings-bVI33sTq.d.mts +27 -0
- package/dist/Recordings.d.mts +3 -28
- package/dist/Recordings.mjs +3 -5
- package/dist/Recordings.mjs.map +1 -1
- package/dist/{References-URDAtapt.d.mts → References-DOH3Wu44.d.mts} +5 -6
- package/dist/References.d.mts +3 -2
- package/dist/References.mjs +10 -18
- package/dist/References.mjs.map +1 -1
- package/dist/Replays-Bo-9xeLz.d.mts +27 -0
- package/dist/Replays.d.mts +3 -28
- package/dist/Replays.mjs +3 -5
- package/dist/Replays.mjs.map +1 -1
- package/dist/Search-1g6TUem7.d.mts +37 -0
- package/dist/Search.d.mts +3 -38
- package/dist/Search.mjs +2 -9
- package/dist/Search.mjs.map +1 -1
- package/dist/{SessionData-DRKcKCqw.d.mts → SessionData-5xYZDshJ.d.mts} +5 -6
- package/dist/SessionData.d.mts +3 -2
- package/dist/SessionData.mjs +1 -8
- package/dist/SessionData.mjs.map +1 -1
- package/dist/{Sessions-B8E4kMxo.d.mts → Sessions-BpZgjteE.d.mts} +8 -8
- package/dist/{Sessions-CtbseWEh.mjs → Sessions-suOLSym9.mjs} +34 -18
- package/dist/Sessions-suOLSym9.mjs.map +1 -0
- package/dist/Sessions.d.mts +4 -3
- package/dist/Sessions.mjs +1 -1
- package/dist/Testing.d.mts +119 -0
- package/dist/Testing.mjs +206 -0
- package/dist/Testing.mjs.map +1 -0
- package/dist/{Transfers-Czv5IZzJ.d.mts → Transfers-GVqzrDWl.d.mts} +22 -9
- package/dist/Transfers.d.mts +3 -2
- package/dist/Transfers.mjs +12 -28
- package/dist/Transfers.mjs.map +1 -1
- package/dist/Uploads-C2neBEpj.d.mts +28 -0
- package/dist/Uploads.d.mts +3 -29
- package/dist/Uploads.mjs +3 -5
- package/dist/Uploads.mjs.map +1 -1
- package/dist/Webhooks-BoeRAxzG.d.mts +59 -0
- package/dist/Webhooks.d.mts +3 -60
- package/dist/Webhooks.mjs +2 -11
- package/dist/Webhooks.mjs.map +1 -1
- package/dist/{WriterFacts-osvYAsIx.d.mts → WriterFacts-BBJRDZYY.d.mts} +8 -15
- package/dist/index.d.mts +27 -31
- package/dist/index.mjs +26 -31
- package/package.json +7 -28
- package/dist/Acquisition-WBafHwXH.mjs.map +0 -1
- package/dist/Association-CEps4hYP.mjs +0 -10
- package/dist/Association-CEps4hYP.mjs.map +0 -1
- package/dist/Bootstrap-BXuzZojd.mjs +0 -194
- package/dist/Bootstrap-BXuzZojd.mjs.map +0 -1
- package/dist/Bootstrap-m7lHgj0D.d.mts +0 -177
- package/dist/Bootstrap.d.mts +0 -2
- package/dist/Bootstrap.mjs +0 -2
- package/dist/Browser.mjs.map +0 -1
- package/dist/BrowserBinding-DlJTGYZL.mjs +0 -2508
- package/dist/BrowserBinding-DlJTGYZL.mjs.map +0 -1
- package/dist/BrowserData-LpcAuAub.d.mts +0 -369
- package/dist/BrowserData.d.mts +0 -2
- package/dist/BrowserData.mjs +0 -442
- package/dist/BrowserData.mjs.map +0 -1
- package/dist/Capture-Bc0z9IAi.mjs +0 -571
- package/dist/Capture-Bc0z9IAi.mjs.map +0 -1
- package/dist/Capture-BvWI-l1A.d.mts +0 -168
- package/dist/Capture.d.mts +0 -2
- package/dist/Capture.mjs +0 -2
- package/dist/Client-D1_xYM9o.mjs.map +0 -1
- package/dist/ContextWriter-BrQmoXRg.mjs.map +0 -1
- package/dist/Extensions-ClZbYb1H.mjs.map +0 -1
- package/dist/Images-DgscEfSf.mjs +0 -127
- package/dist/Images-DgscEfSf.mjs.map +0 -1
- package/dist/Launch-BHcAEq05.mjs.map +0 -1
- package/dist/Launch-C8CfaYxb.d.mts +0 -132
- package/dist/LocalBrowser-BLancJ3R.d.mts +0 -79
- package/dist/LocalBrowser-DsQLWNL1.mjs +0 -439
- package/dist/LocalBrowser-DsQLWNL1.mjs.map +0 -1
- package/dist/LocalBrowser.d.mts +0 -2
- package/dist/LocalBrowser.mjs +0 -2
- package/dist/PageControl.d.mts +0 -16
- package/dist/PageControl.mjs +0 -36
- package/dist/PageControl.mjs.map +0 -1
- package/dist/PageControlAssociation-DabEg5AR.mjs +0 -10
- package/dist/PageControlAssociation-DabEg5AR.mjs.map +0 -1
- package/dist/Session-D4nT9hOO.mjs +0 -1379
- package/dist/Session-D4nT9hOO.mjs.map +0 -1
- package/dist/Sessions-CtbseWEh.mjs.map +0 -1
- package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
package/dist/Browser.d.mts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AllocationError,
|
|
3
|
-
import { t as BrowserbaseClient } from "./Client-
|
|
4
|
-
import {
|
|
5
|
-
import { r as DownloadObservation } from "./Transfers-
|
|
6
|
-
import { n as CleanupResult } from "./Cleanup-
|
|
7
|
-
import { n as ContextWriterPermit } from "./WriterFacts-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
1
|
+
import { a as SessionReference, t as AllocationAttempt } from "./References-DOH3Wu44.mjs";
|
|
2
|
+
import { AllocationError, ContextError, SessionError } from "./Errors.mjs";
|
|
3
|
+
import { t as BrowserbaseClient } from "./Client-B_f6bBLT.mjs";
|
|
4
|
+
import { o as LiveView, t as BrowserbaseSessions } from "./Sessions-BpZgjteE.mjs";
|
|
5
|
+
import { f as SelectFilesRequest, i as FileSelection, r as DownloadObservation } from "./Transfers-GVqzrDWl.mjs";
|
|
6
|
+
import { n as CleanupResult } from "./Cleanup-DMTDBir8.mjs";
|
|
7
|
+
import { n as ContextWriterPermit } from "./WriterFacts-BBJRDZYY.mjs";
|
|
8
|
+
import { LaunchRecipe } from "./Launch.mjs";
|
|
9
|
+
import { Context, Crypto, Effect, Layer, Option, Redacted, Scope } from "effect";
|
|
10
|
+
import { ActionResult, AutomationOptions, BrowserPolicy, ClickRequest, Observation } from "effect-browser/browser-data";
|
|
11
|
+
import { BrowserError, InitializationError } from "effect-browser/errors";
|
|
12
|
+
import { BrowserSession, OpenOptions } from "effect-browser/browser";
|
|
13
|
+
//#region src/Browser.d.ts
|
|
15
14
|
/** Host configuration. Credentials live in the Client; a model never selects these values. */
|
|
16
15
|
export interface BrowserOptions extends AutomationOptions {
|
|
17
16
|
readonly launch: LaunchRecipe;
|
|
@@ -24,124 +23,10 @@ export interface Handoff {
|
|
|
24
23
|
readonly token: Redacted.Redacted<string>;
|
|
25
24
|
readonly view: LiveView;
|
|
26
25
|
}
|
|
27
|
-
/**
|
|
28
|
-
* A host's decision about one control, made on facts read from the exact node immediately
|
|
29
|
-
* before input. Returning anything but `true`, or throwing, sends nothing and fails `denied`.
|
|
30
|
-
* It is a plain synchronous function on purpose: it runs while the owner's permit is held, where
|
|
31
|
-
* waiting on a model or a network call would stall every other operation. It is not an atomic
|
|
32
|
-
* check-and-input transaction, because page script can still run before the native input lands.
|
|
33
|
-
*/
|
|
34
|
-
export interface ElementAdmission {
|
|
35
|
-
readonly admit: (facts: ControlFacts) => boolean;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* A navigation the browser is still performing. The owner's permit was released when it was
|
|
39
|
-
* dispatched, so while it loads a host may read, `checkpoint`, hold and resume this page, and
|
|
40
|
-
* use any other page. Anything that would change this page fails `busy` until it settles.
|
|
41
|
-
*
|
|
42
|
-
* Leaving its scope unsettled fences the session, exactly as an interrupted mutation does,
|
|
43
|
-
* because nothing then knows what the browser did. It is never replayed.
|
|
44
|
-
*/
|
|
45
|
-
export interface NavigationOperation {
|
|
46
|
-
/** What was navigated, read before dispatch. */
|
|
47
|
-
readonly target: Target;
|
|
48
|
-
/**
|
|
49
|
-
* The document reached DOMContentLoaded. It belongs to this one navigation: a successor that
|
|
50
|
-
* reaches the same URL fails it instead. Interrupting a waiter stops nothing in the browser.
|
|
51
|
-
*/
|
|
52
|
-
readonly completed: Effect.Effect<NavigationResult, BrowserError>;
|
|
53
|
-
/**
|
|
54
|
-
* Asks the browser to stop loading and waits for this navigation to settle, after which
|
|
55
|
-
* `completed` fails `interrupted`. Success is a known outcome and the session stays usable:
|
|
56
|
-
* the page holds whatever had loaded. It does not undo anything the page already did.
|
|
57
|
-
*/
|
|
58
|
-
readonly stop: Effect.Effect<void, BrowserError>;
|
|
59
|
-
}
|
|
60
|
-
/** One selected page and frame at one connection generation, never the current DOM. */
|
|
61
|
-
export interface BoundTarget {
|
|
62
|
-
readonly navigate: (request: NavigateRequest) => Effect.Effect<NavigationResult, BrowserError>;
|
|
63
|
-
/** `navigate`, left in flight: the same single dispatch, completed by the caller. */
|
|
64
|
-
readonly startNavigation: (request: StartNavigationRequest) => Effect.Effect<NavigationOperation, BrowserError, Scope.Scope>;
|
|
65
|
-
readonly readText: (request: ReadTextRequest) => Effect.Effect<TextResult, BrowserError>;
|
|
66
|
-
readonly click: (request: ClickRequest) => Effect.Effect<ActionResult, BrowserError>;
|
|
67
|
-
readonly fill: (request: FillRequest) => Effect.Effect<ActionResult, BrowserError>;
|
|
68
|
-
/** Script in the page: instantaneous, and it raises no wheel event. */
|
|
69
|
-
readonly scroll: (request: ScrollRequest) => Effect.Effect<ActionResult, BrowserError>;
|
|
70
|
-
/** One real pointer move, in main-frame viewport pixels. */
|
|
71
|
-
readonly pointerMove: (request: PointerMoveRequest) => Effect.Effect<InputReceipt, BrowserError>;
|
|
72
|
-
/** Places the pointer on one exact element where it is, or fails `not-visible` unsent. */
|
|
73
|
-
readonly hover: (request: HoverRequest) => Effect.Effect<InputReceipt, BrowserError>;
|
|
74
|
-
/** One real wheel event; the browser decides what under the pointer scrolls. */
|
|
75
|
-
readonly wheel: (request: WheelRequest) => Effect.Effect<InputReceipt, BrowserError>;
|
|
76
|
-
/** One real key stroke to whatever has focus, or fails `not-focused` unsent if `into` lacks it. */
|
|
77
|
-
readonly press: (request: PressRequest) => Effect.Effect<InputReceipt, BrowserError>;
|
|
78
|
-
/** Text as the real key strokes that produce it, under the same focus rule as `press`. */
|
|
79
|
-
readonly type: (request: TypeRequest) => Effect.Effect<InputReceipt, BrowserError>;
|
|
80
|
-
readonly screenshot: (request: ScreenshotRequest) => Effect.Effect<ScreenshotResult, BrowserError>;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Host control over one owned browser. This is not a serializable model value: copying a
|
|
84
|
-
* session object cannot copy its capture, page-control or connection authority.
|
|
85
|
-
*/
|
|
86
|
-
export interface BrowserSession<E = never> {
|
|
87
|
-
/** First fail-session callback cause, preserving the consumer's error type on the host. */
|
|
88
|
-
readonly failure: Effect.Effect<never, E | InitializationError>;
|
|
89
|
-
/** Bounded host-only evidence; consumer causes are never projected into a page reply. */
|
|
90
|
-
readonly bindingDiagnostics: Effect.Effect<BindingDiagnostics<E>>;
|
|
91
|
-
readonly bind: () => BoundTarget;
|
|
92
|
-
/** Re-reads the live selection first, so a stale generation fails before any dispatch. */
|
|
93
|
-
readonly currentTarget: Effect.Effect<BoundTarget, BrowserError>;
|
|
94
|
-
readonly target: Effect.Effect<Target, BrowserError>;
|
|
95
|
-
/**
|
|
96
|
-
* The one observation whose nodes later actions may name. `scope: "viewport"` keeps only text
|
|
97
|
-
* and controls that are on screen and reachable; the default reads the whole document. It is
|
|
98
|
-
* safe to show a model: it carries no destination, form or field value.
|
|
99
|
-
*/
|
|
100
|
-
readonly observe: (options?: ObservationOptions) => Effect.Effect<Observation, BrowserError>;
|
|
101
|
-
/**
|
|
102
|
-
* Passive evidence for a recorder, with a picture when asked. It issues no references and
|
|
103
|
-
* leaves the observation above exactly as it was. Host-only: it carries control facts.
|
|
104
|
-
*/
|
|
105
|
-
readonly checkpoint: (options?: CheckpointOptions) => Effect.Effect<Checkpoint, BrowserError>;
|
|
106
|
-
/** Host-only facts about one observed control, read from that exact node just now. */
|
|
107
|
-
readonly controlFacts: (reference: ObservedElement) => Effect.Effect<ControlFacts, BrowserError>;
|
|
108
|
-
/**
|
|
109
|
-
* After a page hold, nothing observed on that page may be acted on unchecked. This checks one
|
|
110
|
-
* reference: still attached, and still the control that was inspected. It never searches by
|
|
111
|
-
* selector or label for a substitute, and it sends nothing.
|
|
112
|
-
*/
|
|
113
|
-
readonly revalidateElement: (reference: ObservedElement) => Effect.Effect<ObservedElement, BrowserError>;
|
|
114
|
-
readonly clickElement: (reference: ObservedElement, admission?: ElementAdmission) => Effect.Effect<ActionResult, BrowserError>;
|
|
115
|
-
readonly fillElement: (reference: ObservedElement, value: string, admission?: ElementAdmission) => Effect.Effect<ActionResult, BrowserError>;
|
|
116
|
-
readonly hoverElement: (reference: ObservedElement, admission?: ElementAdmission) => Effect.Effect<InputReceipt, BrowserError>;
|
|
117
|
-
/** A key stroke sent only if the exact node an observation named already has focus. */
|
|
118
|
-
readonly pressElement: (reference: ObservedElement, stroke: KeyStroke, admission?: ElementAdmission) => Effect.Effect<InputReceipt, BrowserError>;
|
|
119
|
-
/** Real typing with `fillElement`'s exactness: that node must already have focus. */
|
|
120
|
-
readonly typeElement: (reference: ObservedElement, text: string, admission?: ElementAdmission) => Effect.Effect<InputReceipt, BrowserError>;
|
|
121
|
-
readonly pages: Effect.Effect<ReadonlyArray<PageInfo>, BrowserError>;
|
|
122
|
-
readonly frames: Effect.Effect<ReadonlyArray<FrameInfo>, BrowserError>;
|
|
123
|
-
readonly selectPage: (pageId: string) => Effect.Effect<BoundTarget, BrowserError>;
|
|
124
|
-
readonly selectFrame: (frameId: string) => Effect.Effect<BoundTarget, BrowserError>;
|
|
125
|
-
/** Create a tab without selecting it. */
|
|
126
|
-
readonly createPage: Effect.Effect<string, BrowserError>;
|
|
127
|
-
readonly closePage: (pageId: string) => Effect.Effect<void, BrowserError>;
|
|
128
|
-
readonly resizeViewport: (viewport: Viewport) => Effect.Effect<void, BrowserError>;
|
|
129
|
-
readonly waitFor: (request: {
|
|
130
|
-
readonly selector: string;
|
|
131
|
-
readonly state: "visible" | "hidden" | "attached" | "detached";
|
|
132
|
-
}) => Effect.Effect<void, BrowserError>;
|
|
133
|
-
/** Navigation observation is registered before the single click dispatch. */
|
|
134
|
-
readonly clickAndWait: (request: ClickRequest) => Effect.Effect<ActionResult, BrowserError>;
|
|
135
|
-
/**
|
|
136
|
-
* Readiness of the current document only. Dependent operations wait for it themselves;
|
|
137
|
-
* this reports it without charging an action, so a caller can decide what to do about a
|
|
138
|
-
* document that predates the registrations.
|
|
139
|
-
*/
|
|
140
|
-
readonly ready: Effect.Effect<ReadinessOutcome, InitializationError>;
|
|
141
|
-
}
|
|
142
26
|
/** Browserbase identity, remote artifacts and provider cleanup remain hosted capabilities. */
|
|
143
27
|
export interface BrowserbaseSession<E = never> extends BrowserSession<E> {
|
|
144
28
|
readonly reference: SessionReference;
|
|
29
|
+
readonly closeChecked: Effect.Effect<CleanupResult, BrowserError>;
|
|
145
30
|
readonly clickForDownload: (request: ClickRequest) => Effect.Effect<DownloadObservation, BrowserError>;
|
|
146
31
|
/** Attaches to an existing file input; an uploaded branch needs a receipt for this session. */
|
|
147
32
|
readonly selectFiles: (request: SelectFilesRequest) => Effect.Effect<ActionResult, BrowserError>;
|
|
@@ -155,13 +40,9 @@ export interface BrowserbaseSession<E = never> extends BrowserSession<E> {
|
|
|
155
40
|
readonly targetId: string;
|
|
156
41
|
}, BrowserError>;
|
|
157
42
|
readonly reconnect: (operatorReleasedControl: boolean) => Effect.Effect<Observation, BrowserError | InitializationError>;
|
|
158
|
-
readonly close: Effect.Effect<CleanupResult
|
|
43
|
+
readonly close: Effect.Effect<CleanupResult>;
|
|
159
44
|
readonly cleanupResult: Effect.Effect<Option.Option<CleanupResult>>;
|
|
160
45
|
}
|
|
161
|
-
/** Dependencies are captured at acquisition, not erased into an environment-free service Layer. */
|
|
162
|
-
export interface OpenOptions<E = never, R = never> {
|
|
163
|
-
readonly bootstrap?: Plan<E, R>;
|
|
164
|
-
}
|
|
165
46
|
export interface AttachRequest<E = never, R = never> extends OpenOptions<E, R> {
|
|
166
47
|
readonly policy: BrowserPolicy;
|
|
167
48
|
/** The exact page to resume; without it the session must have exactly one page. */
|
|
@@ -176,23 +57,25 @@ export interface BrowserAcquisition<E = never> {
|
|
|
176
57
|
readonly attempt: AllocationAttempt;
|
|
177
58
|
readonly failure: Effect.Effect<never, E | InitializationError>;
|
|
178
59
|
readonly connect: Effect.Effect<BrowserbaseSession<E>, BrowserError | E | InitializationError>;
|
|
179
|
-
readonly close: Effect.Effect<CleanupResult
|
|
60
|
+
readonly close: Effect.Effect<CleanupResult>;
|
|
180
61
|
}
|
|
181
62
|
declare const BrowserbaseBrowser_base: Context.ServiceClass<BrowserbaseBrowser, "effect-browserbase/Browser", {
|
|
182
63
|
readonly acquire: <E = never, R = never>(policy: BrowserPolicy, request?: OpenOptions<E, R>) => Effect.Effect<BrowserAcquisition<E>, AllocationError | BrowserError | ContextError, Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
183
64
|
/** Borrowed control of a session this process did not allocate and will not release. */
|
|
184
65
|
readonly attach: <E = never, R = never>(reference: SessionReference, request: AttachRequest<E, R>) => Effect.Effect<BrowserbaseSession<E>, BrowserError | SessionError | E | InitializationError, Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
185
66
|
readonly open: <E = never, R = never>(policy: BrowserPolicy, request?: OpenOptions<E, R>) => Effect.Effect<BrowserbaseSession<E>, AllocationError | BrowserError | ContextError | E | InitializationError, Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
186
|
-
/** Race the consumer with typed callback failure and confirm cleanup before normal success. */
|
|
187
|
-
readonly withBrowser: <E, R, A, E2, R2>(policy: BrowserPolicy, request: OpenOptions<E, R>, use: (session: BrowserbaseSession<E>) => Effect.Effect<A, E2, R2>) => Effect.Effect<A, AllocationError | BrowserError | ContextError | InitializationError | E | E2, Exclude<R | R2, Scope.Scope>>;
|
|
188
67
|
}>;
|
|
189
|
-
/**
|
|
190
|
-
* Credentials, budgets and connection lifetime are fixed when this Layer is built. Building it
|
|
191
|
-
* allocates nothing and loads no native peer; every acquisition is scoped by its caller.
|
|
192
|
-
*/
|
|
193
68
|
export declare class BrowserbaseBrowser extends BrowserbaseBrowser_base {
|
|
194
|
-
|
|
69
|
+
/** Open through the configured account and browser service, in the caller's scope. */
|
|
70
|
+
static open<E = never, R = never>(policy: BrowserPolicy, request?: OpenOptions<E, R>): Effect.Effect<BrowserbaseSession<E>, E | AllocationError | BrowserError | ContextError | InitializationError, BrowserbaseBrowser | Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
71
|
+
/** Allocate the provider lifetime before connecting, preserving its attempt and cleanup. */
|
|
72
|
+
static acquire<E = never, R = never>(policy: BrowserPolicy, request?: OpenOptions<E, R>): Effect.Effect<BrowserAcquisition<E>, AllocationError | BrowserError | ContextError, BrowserbaseBrowser | Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
73
|
+
/** Borrow a provider session without acquiring release authority over it. */
|
|
74
|
+
static attach<E = never, R = never>(reference: SessionReference, request: AttachRequest<E, R>): Effect.Effect<BrowserbaseSession<E>, E | BrowserError | InitializationError | SessionError, BrowserbaseBrowser | Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
75
|
+
/** Allocation attempts, connection ids and handoff tokens come from the required `Crypto`. */
|
|
76
|
+
static layer(options: BrowserOptions): Layer.Layer<BrowserbaseBrowser, BrowserError, BrowserbaseClient | BrowserbaseSessions | Crypto.Crypto>;
|
|
195
77
|
}
|
|
196
78
|
//#endregion
|
|
197
|
-
export {
|
|
79
|
+
export type { FileSelection, LiveView, SelectFilesRequest };
|
|
80
|
+
export {};
|
|
198
81
|
//# sourceMappingURL=Browser.d.mts.map
|
package/dist/Browser.mjs
CHANGED
|
@@ -1,223 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { DownloadObservation } from "./Transfers.mjs";
|
|
5
|
-
import { t as BrowserbaseClient } from "./Client-D1_xYM9o.mjs";
|
|
6
|
-
import { ActionResult, AutomationOptions, BrowserPolicy, ClickRequest, InlineFiles, Selector, Viewport } from "./BrowserData.mjs";
|
|
7
|
-
import { t as BrowserbaseSessions } from "./Sessions-CtbseWEh.mjs";
|
|
8
|
-
import { t as issuedUpload } from "./Issued-DejqoMYL.mjs";
|
|
9
|
-
import { d as empty } from "./Bootstrap-BXuzZojd.mjs";
|
|
10
|
-
import { t as BrowserbaseBrowserBinding } from "./BrowserBinding-DlJTGYZL.mjs";
|
|
11
|
-
import { a as decoded, c as preparePlan, i as checked, l as compileBootstrap, n as borrowedRemote, o as makeSession$1, r as ownedRemote, s as makeBindings, t as acquireSession } from "./Session-D4nT9hOO.mjs";
|
|
12
|
-
import { Context, Effect, Layer, Scope } from "effect";
|
|
13
|
-
//#region src/Browser.ts
|
|
14
|
-
var Browser_exports = /* @__PURE__ */ __exportAll({ BrowserbaseBrowser: () => BrowserbaseBrowser });
|
|
15
|
-
/**
|
|
16
|
-
* Uploaded selection is admitted by the identity of a receipt this package issued for this
|
|
17
|
-
* exact session, never by a path read off the caller's value. A fabricated receipt has no
|
|
18
|
-
* issuance record, so an arbitrary server pathname can never become an attached file.
|
|
19
|
-
*/
|
|
20
|
-
const selection = (request, reference, operation) => Effect.suspend(() => {
|
|
21
|
-
const invalid = BrowserError.make({
|
|
22
|
-
operation,
|
|
23
|
-
reason: "configuration",
|
|
24
|
-
outcome: "undispatched"
|
|
25
|
-
});
|
|
26
|
-
if (request.selection._tag === "Inline") return checked(InlineFiles, request.selection.files, operation).pipe(Effect.map((files) => files.map((file) => ({
|
|
27
|
-
_tag: "Inline",
|
|
28
|
-
name: file.name,
|
|
29
|
-
mediaType: file.mediaType,
|
|
30
|
-
bytes: new Uint8Array(file.bytes)
|
|
31
|
-
}))));
|
|
32
|
-
const uploads = request.selection.uploads;
|
|
33
|
-
if (!Array.isArray(uploads) || uploads.length < 1 || uploads.length > 8) return Effect.fail(invalid);
|
|
34
|
-
const files = [];
|
|
35
|
-
for (const receipt of uploads) {
|
|
36
|
-
const issued = issuedUpload(receipt);
|
|
37
|
-
if (issued === void 0) return Effect.fail(BrowserError.make({
|
|
38
|
-
operation,
|
|
39
|
-
reason: "authorization",
|
|
40
|
-
outcome: "undispatched"
|
|
41
|
-
}));
|
|
42
|
-
if (issued.reference.projectId !== reference.projectId || issued.reference.sessionId !== reference.sessionId) return Effect.fail(BrowserError.make({
|
|
43
|
-
operation,
|
|
44
|
-
reason: "authorization",
|
|
45
|
-
outcome: "undispatched"
|
|
46
|
-
}));
|
|
47
|
-
files.push({
|
|
48
|
-
_tag: "Remote",
|
|
49
|
-
path: issued.remotePath
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return Effect.succeed(files);
|
|
53
|
-
});
|
|
54
|
-
const makeSession = (controls, bindings) => {
|
|
55
|
-
const session = makeSession$1(controls, bindings);
|
|
56
|
-
const navigate = (url) => decoded(ActionResult, "action-result")({ url });
|
|
57
|
-
return Object.assign(session, {
|
|
58
|
-
reference: controls.reference,
|
|
59
|
-
clickForDownload: (request) => checked(ClickRequest, request, "download-action").pipe(Effect.flatMap((value) => controls.clickForDownload(value.selector)), Effect.flatMap((raw) => decoded(DownloadObservation, "download-action")({
|
|
60
|
-
...raw,
|
|
61
|
-
reference: controls.reference
|
|
62
|
-
}))),
|
|
63
|
-
selectFiles: (request) => checked(Selector, request.selector, "select-files").pipe(Effect.flatMap((selector) => selection(request, controls.reference, "select-files").pipe(Effect.flatMap((files) => controls.selectFiles(selector, files)))), Effect.flatMap(navigate)),
|
|
64
|
-
clickForFileSelection: (request) => checked(Selector, request.selector, "file-chooser").pipe(Effect.flatMap((selector) => selection(request, controls.reference, "file-chooser").pipe(Effect.flatMap((files) => controls.clickForFileSelection(selector, files)))), Effect.flatMap(navigate)),
|
|
65
|
-
liveView: (ttl = 60) => controls.liveView(ttl),
|
|
66
|
-
beginHandoff: (ttl = 60) => controls.beginHandoff(ttl),
|
|
67
|
-
resume: (token, released) => controls.resume(token, released),
|
|
68
|
-
detach: controls.detach,
|
|
69
|
-
reconnect: (released) => controls.reconnect(released),
|
|
70
|
-
close: controls.close,
|
|
71
|
-
cleanupResult: controls.cleanupResult
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Credentials, budgets and connection lifetime are fixed when this Layer is built. Building it
|
|
76
|
-
* allocates nothing and loads no native peer; every acquisition is scoped by its caller.
|
|
77
|
-
*/
|
|
78
|
-
var BrowserbaseBrowser = class BrowserbaseBrowser extends Context.Service()("effect-browserbase/Browser") {
|
|
79
|
-
static layer(options) {
|
|
80
|
-
return Layer.effect(BrowserbaseBrowser, Effect.gen(function* () {
|
|
81
|
-
const client = yield* BrowserbaseClient;
|
|
82
|
-
const sessions = yield* BrowserbaseSessions;
|
|
83
|
-
const binding = yield* BrowserbaseBrowserBinding;
|
|
84
|
-
const automation = yield* checked(AutomationOptions, projected(options), "configure");
|
|
85
|
-
const viewport = yield* checked(Viewport, options.launch.viewport._tag === "Fixed" ? {
|
|
86
|
-
width: options.launch.viewport.width,
|
|
87
|
-
height: options.launch.viewport.height
|
|
88
|
-
} : {
|
|
89
|
-
width: 1280,
|
|
90
|
-
height: 720
|
|
91
|
-
}, "configure");
|
|
92
|
-
const actionTimeoutMillis = automation.actionTimeoutMillis ?? 1e4;
|
|
93
|
-
const maxPages = automation.maxPages ?? 10;
|
|
94
|
-
const pageControl = automation.pageControl ?? false;
|
|
95
|
-
const popupPolicy = automation.popupPolicy ?? "retain";
|
|
96
|
-
const dialogPolicy = automation.dialogPolicy ?? "dismiss";
|
|
97
|
-
if (pageControl && (options.launch.keepAlive === true || popupPolicy === "pause" || dialogPolicy === "pause")) return yield* BrowserError.make({
|
|
98
|
-
operation: "configure",
|
|
99
|
-
reason: "unsupported",
|
|
100
|
-
outcome: "undispatched"
|
|
101
|
-
});
|
|
102
|
-
if (options.launch.context?.persist === true && options.contextWriter === void 0) return yield* BrowserError.make({
|
|
103
|
-
operation: "configure",
|
|
104
|
-
reason: "context-lease"
|
|
105
|
-
});
|
|
106
|
-
if (Object.prototype.hasOwnProperty.call(options, "bootstrap")) return yield* BrowserError.make({
|
|
107
|
-
operation: "configure",
|
|
108
|
-
reason: "configuration",
|
|
109
|
-
outcome: "undispatched"
|
|
110
|
-
});
|
|
111
|
-
const driver = {
|
|
112
|
-
pageControl,
|
|
113
|
-
viewport,
|
|
114
|
-
maxPages,
|
|
115
|
-
popupPolicy,
|
|
116
|
-
dialogPolicy,
|
|
117
|
-
preserveViewport: options.launch.viewport._tag !== "Fixed",
|
|
118
|
-
...automation.initialPage === void 0 ? {} : "targetId" in automation.initialPage ? { initialTargetId: automation.initialPage.targetId } : { newPage: true }
|
|
119
|
-
};
|
|
120
|
-
const acquire = Effect.fnUntraced(function* (policy, request = {}) {
|
|
121
|
-
const fixed = yield* checked(BrowserPolicy, policy, "configure");
|
|
122
|
-
const plan = yield* preparePlan(request.bootstrap ?? empty);
|
|
123
|
-
const scope = yield* Scope.fork(yield* Scope.Scope, "sequential");
|
|
124
|
-
const bindings = yield* makeBindings(plan).pipe(Scope.provide(scope));
|
|
125
|
-
const bootstrap = compileBootstrap(plan);
|
|
126
|
-
const acquired = yield* acquireSession({
|
|
127
|
-
maxActions: fixed.maxActions,
|
|
128
|
-
maxElapsedMillis: fixed.maxElapsedMillis,
|
|
129
|
-
actionTimeoutMillis
|
|
130
|
-
}, {
|
|
131
|
-
remote: ownedRemote({
|
|
132
|
-
launch: options.launch,
|
|
133
|
-
...options.contextWriter === void 0 ? {} : { contextWriter: options.contextWriter },
|
|
134
|
-
...options.onCleanup === void 0 ? {} : { onCleanup: options.onCleanup },
|
|
135
|
-
...options.onAllocationUncertain === void 0 ? {} : { onAllocationUncertain: options.onAllocationUncertain }
|
|
136
|
-
}),
|
|
137
|
-
keepAlive: options.launch.keepAlive === true,
|
|
138
|
-
driver: {
|
|
139
|
-
...driver,
|
|
140
|
-
...bootstrap === void 0 ? {} : { bootstrap }
|
|
141
|
-
},
|
|
142
|
-
connectBindings: bindings.connect,
|
|
143
|
-
maxReturnedBytes: fixed.maxReturnedBytes
|
|
144
|
-
}).pipe(Effect.provideService(BrowserbaseClient, client), Effect.provideService(BrowserbaseSessions, sessions), Effect.provideService(BrowserbaseBrowserBinding, binding), Scope.provide(scope));
|
|
145
|
-
const connected = yield* Effect.cached(acquired.connect.pipe(Effect.map((controls) => makeSession(controls, bindings))));
|
|
146
|
-
return {
|
|
147
|
-
reference: acquired.reference,
|
|
148
|
-
attempt: acquired.lease.attempt,
|
|
149
|
-
failure: bindings.failure,
|
|
150
|
-
close: acquired.close,
|
|
151
|
-
connect: Effect.raceFirst(bindings.failure, acquired.connect.pipe(Effect.andThen(connected))).pipe(Effect.onError(() => acquired.close.pipe(Effect.asVoid)))
|
|
152
|
-
};
|
|
153
|
-
});
|
|
154
|
-
/**
|
|
155
|
-
* Borrowing a session another process allocated. The launch recipe is not replayed and
|
|
156
|
-
* no allocation is attempted: the requested target is resolved explicitly, credentials
|
|
157
|
-
* are fetched fresh because expiry races the caller's own status read, and this scope
|
|
158
|
-
* disconnects locally without ever requesting release. Detaching and reattaching inside
|
|
159
|
-
* a borrowed scope is deliberately absent; attaching again is the cross-process path,
|
|
160
|
-
* and it revalidates the session instead of assuming it is still there.
|
|
161
|
-
*/
|
|
162
|
-
const attach = Effect.fnUntraced(function* (reference, request) {
|
|
163
|
-
const fixed = yield* checked(BrowserPolicy, request.policy, "configure");
|
|
164
|
-
const plan = yield* preparePlan(request.bootstrap ?? empty);
|
|
165
|
-
const scope = yield* Scope.fork(yield* Scope.Scope, "sequential");
|
|
166
|
-
const bindings = yield* makeBindings(plan).pipe(Scope.provide(scope));
|
|
167
|
-
const bootstrap = compileBootstrap(plan);
|
|
168
|
-
const targetId = request.target === void 0 ? void 0 : yield* checked(Identifier, request.target.targetId, "configure");
|
|
169
|
-
const acquired = yield* acquireSession({
|
|
170
|
-
maxActions: fixed.maxActions,
|
|
171
|
-
maxElapsedMillis: fixed.maxElapsedMillis,
|
|
172
|
-
actionTimeoutMillis
|
|
173
|
-
}, {
|
|
174
|
-
remote: borrowedRemote({
|
|
175
|
-
reference,
|
|
176
|
-
...request.pendingWaitMillis === void 0 ? {} : { pendingWaitMillis: request.pendingWaitMillis },
|
|
177
|
-
...options.onCleanup === void 0 ? {} : { onCleanup: options.onCleanup }
|
|
178
|
-
}),
|
|
179
|
-
keepAlive: false,
|
|
180
|
-
driver: {
|
|
181
|
-
...driver,
|
|
182
|
-
...bootstrap === void 0 ? {} : { bootstrap },
|
|
183
|
-
newPage: false,
|
|
184
|
-
preserveViewport: true,
|
|
185
|
-
...targetId === void 0 ? {} : { initialTargetId: targetId }
|
|
186
|
-
},
|
|
187
|
-
maxReturnedBytes: fixed.maxReturnedBytes,
|
|
188
|
-
connectBindings: bindings.connect
|
|
189
|
-
}).pipe(Effect.provideService(BrowserbaseClient, client), Effect.provideService(BrowserbaseSessions, sessions), Effect.provideService(BrowserbaseBrowserBinding, binding), Scope.provide(scope));
|
|
190
|
-
return yield* Effect.raceFirst(bindings.failure, acquired.connect.pipe(Effect.map((controls) => makeSession(controls, bindings)))).pipe(Effect.onError(() => acquired.close.pipe(Effect.asVoid)));
|
|
191
|
-
});
|
|
192
|
-
return BrowserbaseBrowser.of({
|
|
193
|
-
acquire,
|
|
194
|
-
attach,
|
|
195
|
-
open: (policy, request) => acquire(policy, request).pipe(Effect.flatMap((acquired) => acquired.connect)),
|
|
196
|
-
withBrowser: (policy, request, use) => Effect.scoped(Effect.gen(function* () {
|
|
197
|
-
const session = yield* (yield* acquire(policy, request)).connect;
|
|
198
|
-
const result = yield* Effect.raceFirst(session.failure, Effect.suspend(() => use(session)));
|
|
199
|
-
const cleanup = yield* session.close;
|
|
200
|
-
if (cleanup.remote !== "confirmed" || cleanup.local !== "closed" || cleanup.issues.length > 0) return yield* BrowserError.make({
|
|
201
|
-
operation: "close",
|
|
202
|
-
reason: "provider",
|
|
203
|
-
outcome: "unknown"
|
|
204
|
-
});
|
|
205
|
-
return result;
|
|
206
|
-
}))
|
|
207
|
-
});
|
|
208
|
-
}));
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
/** Only the automation fields cross the schema boundary; launch and callbacks are separate. */
|
|
212
|
-
const projected = (options) => ({
|
|
213
|
-
...options.actionTimeoutMillis === void 0 ? {} : { actionTimeoutMillis: options.actionTimeoutMillis },
|
|
214
|
-
...options.maxPages === void 0 ? {} : { maxPages: options.maxPages },
|
|
215
|
-
...options.initialPage === void 0 ? {} : { initialPage: options.initialPage },
|
|
216
|
-
...options.popupPolicy === void 0 ? {} : { popupPolicy: options.popupPolicy },
|
|
217
|
-
...options.dialogPolicy === void 0 ? {} : { dialogPolicy: options.dialogPolicy },
|
|
218
|
-
...options.pageControl === void 0 ? {} : { pageControl: options.pageControl }
|
|
219
|
-
});
|
|
220
|
-
//#endregion
|
|
221
|
-
export { BrowserbaseBrowser, Browser_exports as t };
|
|
222
|
-
|
|
223
|
-
//# sourceMappingURL=Browser.mjs.map
|
|
1
|
+
import "./BrowserBinding.mjs";
|
|
2
|
+
import { t as BrowserbaseBrowser } from "./Browser-DpSajNai.mjs";
|
|
3
|
+
export { BrowserbaseBrowser };
|
|
@@ -1,40 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Context, Layer } from "effect";
|
|
2
|
+
import * as BrowserRuntime from "effect-browser/browser-runtime";
|
|
3
3
|
//#region src/BrowserBinding.d.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* rather than trusted with a connection.
|
|
8
|
-
*/
|
|
9
|
-
export interface BrowserBinding {
|
|
10
|
-
readonly _tag: "BrowserbaseBrowserBinding";
|
|
11
|
-
}
|
|
12
|
-
export interface PlaywrightOptions {
|
|
13
|
-
/**
|
|
14
|
-
* Trusted host routing. It runs only after the provider-issued address passed the same strict
|
|
15
|
-
* checks as the default, and returns the CDP endpoint to connect to instead. A local engine
|
|
16
|
-
* reached this way says nothing about how a hosted connection behaves.
|
|
17
|
-
*/
|
|
18
|
-
readonly resolveEndpoint?: (provider: {
|
|
19
|
-
readonly url: Redacted.Redacted<string>;
|
|
20
|
-
}) => Effect.Effect<string, BrowserError>;
|
|
21
|
-
/**
|
|
22
|
-
* Trusted instrumentation of the engine's own browser object, called once per connection with
|
|
23
|
-
* the endpoint it reached, before the owner drives it. The object is typed `unknown` so that
|
|
24
|
-
* no declaration of this package names the optional native peer; it is host configuration,
|
|
25
|
-
* never model-facing.
|
|
26
|
-
*/
|
|
27
|
-
readonly onConnected?: (connection: {
|
|
28
|
-
readonly native: unknown;
|
|
29
|
-
readonly endpoint: string;
|
|
30
|
-
}) => void;
|
|
31
|
-
}
|
|
32
|
-
/** Playwright over CDP, lazily loaded at connection time and never at Layer construction. */
|
|
4
|
+
export type BrowserBinding = BrowserRuntime.BrowserBinding;
|
|
5
|
+
export type PlaywrightOptions = BrowserRuntime.PlaywrightOptions;
|
|
6
|
+
/** Validate provider authority before invoking any trusted host routing. */
|
|
33
7
|
export declare const playwright: (options?: PlaywrightOptions) => BrowserBinding;
|
|
34
|
-
|
|
35
|
-
export declare const BrowserbaseBrowserBinding: Context.Reference<BrowserBinding>;
|
|
36
|
-
/** Supply a binding to every browser Layer built beneath it. */
|
|
8
|
+
export declare const BrowserbaseBrowserBinding: Context.Reference<BrowserRuntime.BrowserBinding>;
|
|
37
9
|
export declare const layer: (binding: BrowserBinding) => Layer.Layer<never>;
|
|
38
10
|
export declare const layerPlaywright: Layer.Layer<never>;
|
|
39
11
|
//#endregion
|
|
12
|
+
export {};
|
|
40
13
|
//# sourceMappingURL=BrowserBinding.d.mts.map
|
package/dist/BrowserBinding.mjs
CHANGED
|
@@ -1,2 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as validateConnection } from "./Connection-sxyxtwlk.mjs";
|
|
2
|
+
import { Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
3
|
+
import { BrowserError, Reasons } from "effect-browser/errors";
|
|
4
|
+
import * as BrowserRuntime from "effect-browser/browser-runtime";
|
|
5
|
+
//#region src/BrowserBinding.ts
|
|
6
|
+
/** Validate provider authority before invoking any trusted host routing. */
|
|
7
|
+
const playwright = (options = {}) => {
|
|
8
|
+
const { resolveEndpoint, onConnected } = options;
|
|
9
|
+
return BrowserRuntime.playwright({
|
|
10
|
+
resolveEndpoint: ({ url }) => Effect.gen(function* () {
|
|
11
|
+
const validated = yield* Effect.try({
|
|
12
|
+
try: () => validateConnection(Redacted.value(url)),
|
|
13
|
+
catch: (error) => Schema.is(BrowserError)(error) ? error : BrowserError.make({
|
|
14
|
+
operation: "connect",
|
|
15
|
+
reason: Reasons.Malformed.make({}),
|
|
16
|
+
outcome: "undispatched"
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
return yield* resolveEndpoint === void 0 ? Effect.succeed(validated) : resolveEndpoint({ url: Redacted.make(validated) });
|
|
20
|
+
}),
|
|
21
|
+
...onConnected === void 0 ? {} : { onConnected }
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const defaultBinding = playwright();
|
|
25
|
+
const BrowserbaseBrowserBinding = Context.Reference("effect-browserbase/BrowserBinding", { defaultValue: () => defaultBinding });
|
|
26
|
+
const layer = (binding) => Layer.succeed(BrowserbaseBrowserBinding, binding);
|
|
27
|
+
const layerPlaywright = layer(defaultBinding);
|
|
28
|
+
//#endregion
|
|
2
29
|
export { BrowserbaseBrowserBinding, layer, layerPlaywright, playwright };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=BrowserBinding.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrowserBinding.mjs","names":[],"sources":["../src/BrowserBinding.ts"],"sourcesContent":["import { Context, Effect, Layer, Redacted, Schema } from \"effect\";\nimport * as BrowserRuntime from \"effect-browser/browser-runtime\";\nimport { BrowserError, Reasons } from \"effect-browser/errors\";\n\nimport { validateConnection } from \"./internal/provider/Connection.ts\";\n\nexport type BrowserBinding = BrowserRuntime.BrowserBinding;\nexport type PlaywrightOptions = BrowserRuntime.PlaywrightOptions;\n\n/** Validate provider authority before invoking any trusted host routing. */\nexport const playwright = (options: PlaywrightOptions = {}): BrowserBinding => {\n const { resolveEndpoint, onConnected } = options;\n\n return BrowserRuntime.playwright({\n resolveEndpoint: ({ url }) =>\n Effect.gen(function* () {\n const validated = yield* Effect.try({\n try: () => validateConnection(Redacted.value(url)),\n catch: (error) =>\n Schema.is(BrowserError)(error)\n ? error\n : BrowserError.make({\n operation: \"connect\",\n reason: Reasons.Malformed.make({}),\n outcome: \"undispatched\",\n }),\n });\n\n return yield* resolveEndpoint === undefined\n ? Effect.succeed(validated)\n : resolveEndpoint({ url: Redacted.make(validated) });\n }),\n ...(onConnected === undefined ? {} : { onConnected }),\n });\n};\n\nconst defaultBinding = playwright();\n\nexport const BrowserbaseBrowserBinding = Context.Reference<BrowserBinding>(\n \"effect-browserbase/BrowserBinding\",\n { defaultValue: () => defaultBinding },\n);\n\nexport const layer = (binding: BrowserBinding): Layer.Layer<never> =>\n Layer.succeed(BrowserbaseBrowserBinding, binding);\n\nexport const layerPlaywright: Layer.Layer<never> = layer(defaultBinding);\n"],"mappings":";;;;;;AAUA,MAAa,cAAc,UAA6B,CAAC,MAAsB;CAC7E,MAAM,EAAE,iBAAiB,gBAAgB;CAEzC,OAAO,eAAe,WAAW;EAC/B,kBAAkB,EAAE,UAClB,OAAO,IAAI,aAAa;GACtB,MAAM,YAAY,OAAO,OAAO,IAAI;IAClC,WAAW,mBAAmB,SAAS,MAAM,GAAG,CAAC;IACjD,QAAQ,UACN,OAAO,GAAG,YAAY,CAAC,CAAC,KAAK,IACzB,QACA,aAAa,KAAK;KAChB,WAAW;KACX,QAAQ,QAAQ,UAAU,KAAK,CAAC,CAAC;KACjC,SAAS;IACX,CAAC;GACT,CAAC;GAED,OAAO,OAAO,oBAAoB,KAAA,IAC9B,OAAO,QAAQ,SAAS,IACxB,gBAAgB,EAAE,KAAK,SAAS,KAAK,SAAS,EAAE,CAAC;EACvD,CAAC;EACH,GAAI,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY;CACrD,CAAC;AACH;AAEA,MAAM,iBAAiB,WAAW;AAElC,MAAa,4BAA4B,QAAQ,UAC/C,qCACA,EAAE,oBAAoB,eAAe,CACvC;AAEA,MAAa,SAAS,YACpB,MAAM,QAAQ,2BAA2B,OAAO;AAElD,MAAa,kBAAsC,MAAM,cAAc"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CertificateError } from "./Errors.mjs";
|
|
2
|
+
import { t as BrowserbaseClient } from "./Client-B_f6bBLT.mjs";
|
|
3
|
+
import { Context, Effect, Layer, Schema } from "effect";
|
|
4
|
+
//#region src/Certificates.d.ts
|
|
5
|
+
declare const CertificateMetadata_base: Schema.Class<CertificateMetadata, Schema.Struct<{
|
|
6
|
+
readonly certificateId: Schema.NonEmptyString;
|
|
7
|
+
readonly projectId: Schema.NonEmptyString;
|
|
8
|
+
readonly createdAt: Schema.String;
|
|
9
|
+
readonly updatedAt: Schema.String;
|
|
10
|
+
}>, {}>;
|
|
11
|
+
/** Select a certificate at launch with `provider.proxySettings.caCertificates: [certificateId]`. */
|
|
12
|
+
declare class CertificateMetadata extends CertificateMetadata_base {}
|
|
13
|
+
interface CertificateUpload {
|
|
14
|
+
/** PEM or DER bytes of one CA certificate. */
|
|
15
|
+
readonly bytes: Uint8Array;
|
|
16
|
+
/** Portable basename sent with the part; defaults to `certificate.pem`. */
|
|
17
|
+
readonly filename?: string;
|
|
18
|
+
readonly maxBytes?: number;
|
|
19
|
+
readonly timeoutMillis?: number;
|
|
20
|
+
}
|
|
21
|
+
declare const BrowserbaseCertificates_base: Context.ServiceClass<BrowserbaseCertificates, "effect-browserbase/Certificates", {
|
|
22
|
+
readonly create: (upload: CertificateUpload) => Effect.Effect<CertificateMetadata, CertificateError>;
|
|
23
|
+
readonly list: Effect.Effect<ReadonlyArray<CertificateMetadata>, CertificateError>;
|
|
24
|
+
readonly retrieve: (certificateId: string) => Effect.Effect<CertificateMetadata, CertificateError>;
|
|
25
|
+
readonly delete: (certificateId: string) => Effect.Effect<void, CertificateError>;
|
|
26
|
+
}>;
|
|
27
|
+
/** Proxy CA certificates. Registration is one bounded multipart mutation, never retried. */
|
|
28
|
+
declare class BrowserbaseCertificates extends BrowserbaseCertificates_base {
|
|
29
|
+
static readonly layer: Layer.Layer<BrowserbaseCertificates, never, BrowserbaseClient>;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { CertificateMetadata as n, CertificateUpload as r, BrowserbaseCertificates as t };
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=Certificates-D4NQmyeA.d.mts.map
|
package/dist/Certificates.d.mts
CHANGED
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare namespace Certificates_d_exports {
|
|
5
|
-
export { BrowserbaseCertificates, CertificateMetadata, CertificateUpload };
|
|
6
|
-
}
|
|
7
|
-
declare const CertificateMetadata_base: Schema.Class<CertificateMetadata, Schema.Struct<{
|
|
8
|
-
readonly certificateId: Schema.NonEmptyString;
|
|
9
|
-
readonly projectId: Schema.NonEmptyString;
|
|
10
|
-
readonly createdAt: Schema.String;
|
|
11
|
-
readonly updatedAt: Schema.String;
|
|
12
|
-
}>, {}>;
|
|
13
|
-
/** Select a certificate at launch with `provider.proxySettings.caCertificates: [certificateId]`. */
|
|
14
|
-
export declare class CertificateMetadata extends CertificateMetadata_base {}
|
|
15
|
-
export interface CertificateUpload {
|
|
16
|
-
/** PEM or DER bytes of one CA certificate. */
|
|
17
|
-
readonly bytes: Uint8Array;
|
|
18
|
-
/** Portable basename sent with the part; defaults to `certificate.pem`. */
|
|
19
|
-
readonly filename?: string;
|
|
20
|
-
readonly maxBytes?: number;
|
|
21
|
-
readonly timeoutMillis?: number;
|
|
22
|
-
}
|
|
23
|
-
declare const BrowserbaseCertificates_base: Context.ServiceClass<BrowserbaseCertificates, "effect-browserbase/Certificates", {
|
|
24
|
-
readonly create: (upload: CertificateUpload) => Effect.Effect<CertificateMetadata, CertificateError>;
|
|
25
|
-
readonly list: Effect.Effect<ReadonlyArray<CertificateMetadata>, CertificateError>;
|
|
26
|
-
readonly retrieve: (certificateId: string) => Effect.Effect<CertificateMetadata, CertificateError>;
|
|
27
|
-
readonly delete: (certificateId: string) => Effect.Effect<void, CertificateError>;
|
|
28
|
-
}>;
|
|
29
|
-
/** Proxy CA certificates. Registration is one bounded multipart mutation, never retried. */
|
|
30
|
-
export declare class BrowserbaseCertificates extends BrowserbaseCertificates_base {
|
|
31
|
-
static readonly layer: Layer.Layer<BrowserbaseCertificates, never, BrowserbaseClient>;
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
export { Certificates_d_exports as t };
|
|
35
|
-
//# sourceMappingURL=Certificates.d.mts.map
|
|
1
|
+
import { n as CertificateMetadata, r as CertificateUpload, t as BrowserbaseCertificates } from "./Certificates-D4NQmyeA.mjs";
|
|
2
|
+
export { BrowserbaseCertificates, CertificateMetadata, CertificateUpload };
|
|
3
|
+
export {};
|
package/dist/Certificates.mjs
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
1
|
import { Identifier } from "./References.mjs";
|
|
3
2
|
import { CertificateError } from "./Errors.mjs";
|
|
4
3
|
import { SafeFilename } from "./Transfers.mjs";
|
|
5
|
-
import { t as BrowserbaseClient } from "./Client-
|
|
4
|
+
import { t as BrowserbaseClient } from "./Client-4RMKIpL2.mjs";
|
|
6
5
|
import { t as resource } from "./Resource-DBksC4zB.mjs";
|
|
7
6
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
8
7
|
//#region src/Certificates.ts
|
|
9
|
-
var Certificates_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
-
BrowserbaseCertificates: () => BrowserbaseCertificates,
|
|
11
|
-
CertificateMetadata: () => CertificateMetadata
|
|
12
|
-
});
|
|
13
8
|
const Timestamp = Schema.String.check(Schema.isMaxLength(64));
|
|
14
9
|
const MAX_CERTIFICATE_BYTES = 1048576;
|
|
15
10
|
/** Select a certificate at launch with `provider.proxySettings.caCertificates: [certificateId]`. */
|
|
@@ -85,6 +80,6 @@ var BrowserbaseCertificates = class BrowserbaseCertificates extends Context.Serv
|
|
|
85
80
|
}));
|
|
86
81
|
};
|
|
87
82
|
//#endregion
|
|
88
|
-
export { BrowserbaseCertificates, CertificateMetadata
|
|
83
|
+
export { BrowserbaseCertificates, CertificateMetadata };
|
|
89
84
|
|
|
90
85
|
//# sourceMappingURL=Certificates.mjs.map
|