effect-browserbase 0.2.0-beta.9 → 0.3.0-beta.5
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 +250 -317
- package/dist/Browserbase-FDltiz36.mjs +542 -0
- package/dist/Browserbase-FDltiz36.mjs.map +1 -0
- package/dist/Browserbase.d.mts +105 -0
- package/dist/Browserbase.mjs +3 -0
- package/dist/BrowserbaseClient-CtAQ2rg4.d.mts +195 -0
- package/dist/BrowserbaseClient.d.mts +2 -0
- package/dist/BrowserbaseClient.mjs +190 -0
- package/dist/BrowserbaseClient.mjs.map +1 -0
- package/dist/BrowserbaseError-D1EOrLNc.d.mts +79 -0
- package/dist/BrowserbaseError.d.mts +2 -0
- package/dist/BrowserbaseError.mjs +101 -0
- package/dist/BrowserbaseError.mjs.map +1 -0
- package/dist/ContextLease.d.mts +42 -0
- package/dist/ContextLease.mjs +80 -0
- package/dist/ContextLease.mjs.map +1 -0
- package/dist/index.d.mts +5 -27
- package/dist/index.mjs +5 -26
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/testing/index.d.mts +134 -0
- package/dist/testing/index.mjs +382 -0
- package/dist/testing/index.mjs.map +1 -0
- package/package.json +51 -121
- package/src/Browserbase.ts +698 -0
- package/src/BrowserbaseClient.ts +559 -0
- package/src/BrowserbaseError.ts +108 -0
- package/src/ContextLease.ts +118 -0
- package/src/index.ts +7 -0
- package/src/internal/captureConnection.ts +214 -0
- package/src/testing/BrowserbaseContract.ts +170 -0
- package/src/testing/TestBrowserbase.ts +445 -0
- package/src/testing/index.ts +7 -0
- package/dist/Account.d.mts +0 -32
- package/dist/Account.mjs +0 -36
- package/dist/Account.mjs.map +0 -1
- package/dist/Acquisition-BOABu_qJ.mjs +0 -244
- package/dist/Acquisition-BOABu_qJ.mjs.map +0 -1
- package/dist/Agents-CPaTOH_g.d.mts +0 -156
- package/dist/Agents.d.mts +0 -3
- package/dist/Agents.mjs +0 -292
- package/dist/Agents.mjs.map +0 -1
- package/dist/Allocation.d.mts +0 -97
- package/dist/Allocation.mjs +0 -27
- package/dist/Allocation.mjs.map +0 -1
- package/dist/Authorization-Ll5f_XNM.mjs +0 -12
- package/dist/Authorization-Ll5f_XNM.mjs.map +0 -1
- package/dist/Browser-ByrWJ0ss.mjs +0 -274
- package/dist/Browser-ByrWJ0ss.mjs.map +0 -1
- package/dist/Browser.d.mts +0 -83
- package/dist/Browser.mjs +0 -3
- package/dist/BrowserBinding.d.mts +0 -13
- package/dist/BrowserBinding.mjs +0 -31
- package/dist/BrowserBinding.mjs.map +0 -1
- package/dist/Certificates-D4NQmyeA.d.mts +0 -34
- package/dist/Certificates.d.mts +0 -3
- package/dist/Certificates.mjs +0 -85
- package/dist/Certificates.mjs.map +0 -1
- package/dist/Cleanup-DMTDBir8.d.mts +0 -23
- package/dist/Cleanup.d.mts +0 -3
- package/dist/Cleanup.mjs +0 -43
- package/dist/Cleanup.mjs.map +0 -1
- package/dist/Client-BEC4Q8ZS.mjs +0 -564
- package/dist/Client-BEC4Q8ZS.mjs.map +0 -1
- package/dist/Client-B_f6bBLT.d.mts +0 -52
- package/dist/Client.d.mts +0 -3
- package/dist/Client.mjs +0 -2
- package/dist/Connection-sxyxtwlk.mjs +0 -56
- package/dist/Connection-sxyxtwlk.mjs.map +0 -1
- package/dist/ContextCoordination.d.mts +0 -29
- package/dist/ContextCoordination.mjs +0 -94
- package/dist/ContextCoordination.mjs.map +0 -1
- package/dist/ContextWriter-CiEma24z.mjs +0 -204
- package/dist/ContextWriter-CiEma24z.mjs.map +0 -1
- package/dist/Contexts-DqdL7cyX.d.mts +0 -31
- package/dist/Contexts.d.mts +0 -3
- package/dist/Contexts.mjs +0 -97
- package/dist/Contexts.mjs.map +0 -1
- package/dist/Deadline-CrViaogr.mjs +0 -13
- package/dist/Deadline-CrViaogr.mjs.map +0 -1
- package/dist/Downloads-CX52GOFJ.d.mts +0 -43
- package/dist/Downloads.d.mts +0 -3
- package/dist/Downloads.mjs +0 -137
- package/dist/Downloads.mjs.map +0 -1
- package/dist/Errors.d.mts +0 -100
- package/dist/Errors.mjs +0 -194
- package/dist/Errors.mjs.map +0 -1
- package/dist/Extensions-BTUn9zhK.mjs +0 -231
- package/dist/Extensions-BTUn9zhK.mjs.map +0 -1
- package/dist/Extensions-DBXuVM1f.d.mts +0 -43
- package/dist/Extensions.d.mts +0 -3
- package/dist/Extensions.mjs +0 -2
- package/dist/Functions-CsKMMUuZ.d.mts +0 -226
- package/dist/Functions.d.mts +0 -3
- package/dist/Functions.mjs +0 -318
- package/dist/Functions.mjs.map +0 -1
- package/dist/Issued-DejqoMYL.mjs +0 -15
- package/dist/Issued-DejqoMYL.mjs.map +0 -1
- package/dist/Launch-cAdE2rrZ.mjs +0 -115
- package/dist/Launch-cAdE2rrZ.mjs.map +0 -1
- package/dist/Launch.d.mts +0 -127
- package/dist/Launch.mjs +0 -97
- package/dist/Launch.mjs.map +0 -1
- package/dist/PageFetch-CjAM_0DS.d.mts +0 -40
- package/dist/PageFetch.d.mts +0 -3
- package/dist/PageFetch.mjs +0 -59
- package/dist/PageFetch.mjs.map +0 -1
- package/dist/Projects-tm5bTDH0.d.mts +0 -38
- package/dist/Projects.d.mts +0 -3
- package/dist/Projects.mjs +0 -65
- package/dist/Projects.mjs.map +0 -1
- package/dist/Recordings-B9k5aODB.d.mts +0 -27
- package/dist/Recordings.d.mts +0 -3
- package/dist/Recordings.mjs +0 -144
- package/dist/Recordings.mjs.map +0 -1
- package/dist/References-DOH3Wu44.d.mts +0 -34
- package/dist/References.d.mts +0 -3
- package/dist/References.mjs +0 -33
- package/dist/References.mjs.map +0 -1
- package/dist/Replays-mV93WGtx.d.mts +0 -27
- package/dist/Replays.d.mts +0 -3
- package/dist/Replays.mjs +0 -107
- package/dist/Replays.mjs.map +0 -1
- package/dist/Resource-J7Kkk5mu.mjs +0 -54
- package/dist/Resource-J7Kkk5mu.mjs.map +0 -1
- package/dist/Search-B64e7g-h.d.mts +0 -37
- package/dist/Search.d.mts +0 -3
- package/dist/Search.mjs +0 -46
- package/dist/Search.mjs.map +0 -1
- package/dist/SessionData-5xYZDshJ.d.mts +0 -38
- package/dist/SessionData.d.mts +0 -3
- package/dist/SessionData.mjs +0 -48
- package/dist/SessionData.mjs.map +0 -1
- package/dist/Sessions-D2H5m6rF.mjs +0 -260
- package/dist/Sessions-D2H5m6rF.mjs.map +0 -1
- package/dist/Sessions-oJEUmZth.d.mts +0 -69
- package/dist/Sessions.d.mts +0 -4
- package/dist/Sessions.mjs +0 -3
- package/dist/Testing.d.mts +0 -119
- package/dist/Testing.mjs +0 -206
- package/dist/Testing.mjs.map +0 -1
- package/dist/TransferPolicy-DQ06i7SZ.mjs +0 -25
- package/dist/TransferPolicy-DQ06i7SZ.mjs.map +0 -1
- package/dist/Transfers-GVqzrDWl.d.mts +0 -89
- package/dist/Transfers.d.mts +0 -3
- package/dist/Transfers.mjs +0 -85
- package/dist/Transfers.mjs.map +0 -1
- package/dist/Uploads-C2_bACgv.d.mts +0 -28
- package/dist/Uploads.d.mts +0 -3
- package/dist/Uploads.mjs +0 -105
- package/dist/Uploads.mjs.map +0 -1
- package/dist/Webhooks-BoeRAxzG.d.mts +0 -59
- package/dist/Webhooks.d.mts +0 -3
- package/dist/Webhooks.mjs +0 -134
- package/dist/Webhooks.mjs.map +0 -1
- package/dist/WriterFacts-BBJRDZYY.d.mts +0 -54
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import { SessionError } from "./Errors.mjs";
|
|
2
|
-
import { r as span, t as BrowserbaseClient } from "./Client-BEC4Q8ZS.mjs";
|
|
3
|
-
import { DownloadObservation } from "./Transfers.mjs";
|
|
4
|
-
import { r as isList } from "./Launch-cAdE2rrZ.mjs";
|
|
5
|
-
import { isTerminalSessionStatus } from "./SessionData.mjs";
|
|
6
|
-
import { a as issueLiveView, o as browserRequestFailure, t as BrowserbaseSessions } from "./Sessions-D2H5m6rF.mjs";
|
|
7
|
-
import { t as issuedUpload } from "./Issued-DejqoMYL.mjs";
|
|
8
|
-
import { t as connectionAddress } from "./Connection-sxyxtwlk.mjs";
|
|
9
|
-
import { a as reported, i as noLocalConnection, n as reportCleanup, r as makeCleanup, t as acquireRemote } from "./Acquisition-BOABu_qJ.mjs";
|
|
10
|
-
import { BrowserbaseBrowserBinding } from "./BrowserBinding.mjs";
|
|
11
|
-
import { Context, Crypto, Effect, Exit, Layer, Option, Schema, Scope } from "effect";
|
|
12
|
-
import { BrowserError, Reasons } from "effect-browser/errors";
|
|
13
|
-
import * as BrowserRuntime from "effect-browser/browser-runtime";
|
|
14
|
-
//#region src/internal/session/Attachment.ts
|
|
15
|
-
const failure = (reason) => SessionError.make({
|
|
16
|
-
operation: "session-attach",
|
|
17
|
-
reason,
|
|
18
|
-
outcome: "undispatched"
|
|
19
|
-
});
|
|
20
|
-
/**
|
|
21
|
-
* Borrowing an already running session. This scope owns its local connection and nothing
|
|
22
|
-
* else: no allocation attempt is made, no release is requested, and no Context-writer
|
|
23
|
-
* authority is claimed. Whoever allocated the session keeps all three.
|
|
24
|
-
*/
|
|
25
|
-
const attachRemote = Effect.fnUntraced(function* (options, local = noLocalConnection, limits) {
|
|
26
|
-
const client = yield* BrowserbaseClient;
|
|
27
|
-
const sessions = yield* BrowserbaseSessions;
|
|
28
|
-
const parent = yield* Scope.Scope;
|
|
29
|
-
const pendingWaitMillis = options.pendingWaitMillis ?? 0;
|
|
30
|
-
if (!Number.isSafeInteger(pendingWaitMillis) || pendingWaitMillis < 0 || pendingWaitMillis > 6e5) return yield* failure("configuration");
|
|
31
|
-
const observed = yield* sessions.retrieve(options.reference);
|
|
32
|
-
if (isTerminalSessionStatus(observed.status)) return yield* failure("expired");
|
|
33
|
-
if (observed.status !== "RUNNING") {
|
|
34
|
-
if (pendingWaitMillis === 0) return yield* failure("active");
|
|
35
|
-
yield* sessions.waitUntilRunning(observed.reference, { timeoutMillis: pendingWaitMillis });
|
|
36
|
-
}
|
|
37
|
-
const reference = observed.reference;
|
|
38
|
-
return yield* Effect.uninterruptible(Effect.gen(function* () {
|
|
39
|
-
const resourceScope = yield* Scope.make();
|
|
40
|
-
let closing = false;
|
|
41
|
-
let cleanup;
|
|
42
|
-
const terminate = yield* Effect.cached(Effect.uninterruptible(Effect.gen(function* () {
|
|
43
|
-
closing = true;
|
|
44
|
-
yield* (yield* makeCleanup(reference, "borrowed", sessions, local, (result) => {
|
|
45
|
-
cleanup = result;
|
|
46
|
-
}, limits)).close;
|
|
47
|
-
const result = cleanup;
|
|
48
|
-
const notify = options.onCleanup;
|
|
49
|
-
if (result !== void 0) {
|
|
50
|
-
yield* reported(Effect.suspend(() => reportCleanup(result)));
|
|
51
|
-
if (notify !== void 0) yield* reported(Effect.suspend(() => notify(result)).pipe(span("Browserbase.callback.cleanup")));
|
|
52
|
-
}
|
|
53
|
-
}).pipe(span("Browserbase.terminate", { attributes: { "browser.ownership": "borrowed" } }))));
|
|
54
|
-
const closeScope = yield* Effect.cached(Scope.close(resourceScope, Exit.void));
|
|
55
|
-
yield* Scope.addFinalizer(resourceScope, terminate);
|
|
56
|
-
yield* Scope.addFinalizer(parent, closeScope);
|
|
57
|
-
return {
|
|
58
|
-
reference,
|
|
59
|
-
status: observed,
|
|
60
|
-
connection: (timeoutMillis) => Effect.suspend(() => closing ? Effect.fail(SessionError.make({
|
|
61
|
-
operation: "session-connect",
|
|
62
|
-
reason: "expired",
|
|
63
|
-
outcome: "undispatched"
|
|
64
|
-
})) : connectionAddress(client, sessions, reference, timeoutMillis).pipe(span("Browserbase.connection", { attributes: { "browser.ownership": "borrowed" } }))),
|
|
65
|
-
release: closeScope.pipe(Effect.andThen(Effect.suspend(() => cleanup === void 0 ? Effect.die(/* @__PURE__ */ new Error("Borrowed session closed without cleanup evidence")) : Effect.succeed(cleanup))), span("Browserbase.release", { attributes: { "browser.ownership": "borrowed" } })),
|
|
66
|
-
cleanupResult: Effect.sync(() => Option.fromNullishOr(cleanup))
|
|
67
|
-
};
|
|
68
|
-
}));
|
|
69
|
-
}, span("Browserbase.attachRemote", { attributes: { "browser.ownership": "borrowed" } }));
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region src/internal/session/Browser.ts
|
|
72
|
-
/** A borrowed connection closes without requiring or requesting remote termination. */
|
|
73
|
-
const checkedCleanup = (close) => close.pipe(Effect.filterOrFail((result) => result.local === "closed" && result.issues.length === 0 && (result.ownership === "borrowed" ? result.remote === "not-owned" : result.remote === "confirmed"), () => BrowserError.make({
|
|
74
|
-
operation: "close",
|
|
75
|
-
reason: Reasons.Provider.make({}),
|
|
76
|
-
outcome: "unknown"
|
|
77
|
-
})));
|
|
78
|
-
const withConnection = (acquired) => ({
|
|
79
|
-
...acquired,
|
|
80
|
-
connection: (timeoutMillis) => acquired.connection(timeoutMillis).pipe(Effect.mapError((error) => browserRequestFailure("connect", error))),
|
|
81
|
-
closeChecked: checkedCleanup(acquired.release),
|
|
82
|
-
controlRetired: acquired.cleanupResult.pipe(Effect.map((result) => Option.isSome(result) && result.value.ownership === "owned" && result.value.remote === "confirmed"))
|
|
83
|
-
});
|
|
84
|
-
/** Allocates the session, and therefore owns releasing it. */
|
|
85
|
-
const providerControls = (client, sessions, reference) => ({
|
|
86
|
-
liveView: (ttl) => issueLiveView(client, reference, ttl),
|
|
87
|
-
verifyReconnect: sessions.retrieve(reference).pipe(Effect.mapError((error) => browserRequestFailure("reconnect", error)), Effect.flatMap((status) => status.status === "RUNNING" ? Effect.void : Effect.fail(BrowserError.make({
|
|
88
|
-
operation: "reconnect",
|
|
89
|
-
reason: Reasons.Expired.make({}),
|
|
90
|
-
outcome: "undispatched"
|
|
91
|
-
}))))
|
|
92
|
-
});
|
|
93
|
-
const ownedRemote = (options) => (local, lifetimeDeadline) => Effect.gen(function* () {
|
|
94
|
-
const client = yield* BrowserbaseClient;
|
|
95
|
-
const sessions = yield* BrowserbaseSessions;
|
|
96
|
-
const acquired = yield* acquireRemote({
|
|
97
|
-
launch: options.launch,
|
|
98
|
-
...options.contextWriter === void 0 ? {} : { contextWriter: options.contextWriter },
|
|
99
|
-
allocationDeadline: lifetimeDeadline,
|
|
100
|
-
...options.onCleanup === void 0 ? {} : { onCleanup: options.onCleanup },
|
|
101
|
-
...options.onAllocationUncertain === void 0 ? {} : { onAllocationUncertain: options.onAllocationUncertain }
|
|
102
|
-
}, local);
|
|
103
|
-
return {
|
|
104
|
-
...withConnection(acquired),
|
|
105
|
-
...providerControls(client, sessions, acquired.reference)
|
|
106
|
-
};
|
|
107
|
-
});
|
|
108
|
-
/** Borrows a running session: local connection only, and never a release request. */
|
|
109
|
-
const borrowedRemote = (options) => (local) => Effect.gen(function* () {
|
|
110
|
-
const client = yield* BrowserbaseClient;
|
|
111
|
-
const sessions = yield* BrowserbaseSessions;
|
|
112
|
-
const acquired = yield* attachRemote(options, local);
|
|
113
|
-
return {
|
|
114
|
-
...withConnection(acquired),
|
|
115
|
-
...providerControls(client, sessions, acquired.reference)
|
|
116
|
-
};
|
|
117
|
-
});
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region src/Browser.ts
|
|
120
|
-
/** Only receipts issued for this exact provider session may resolve to stored paths. */
|
|
121
|
-
const selection = (request, reference, operation) => Effect.suspend(() => {
|
|
122
|
-
if (request.selection._tag === "Inline") return Effect.succeed({
|
|
123
|
-
_tag: "Inline",
|
|
124
|
-
files: request.selection.files
|
|
125
|
-
});
|
|
126
|
-
const uploads = request.selection.uploads;
|
|
127
|
-
if (!isList(uploads) || uploads.length < 1 || uploads.length > 8) return Effect.fail(BrowserError.make({
|
|
128
|
-
operation,
|
|
129
|
-
reason: Reasons.Configuration.make({}),
|
|
130
|
-
outcome: "undispatched"
|
|
131
|
-
}));
|
|
132
|
-
const paths = [];
|
|
133
|
-
for (const receipt of uploads) {
|
|
134
|
-
const issued = issuedUpload(receipt);
|
|
135
|
-
if (issued === void 0 || issued.reference.projectId !== reference.projectId || issued.reference.sessionId !== reference.sessionId) return Effect.fail(BrowserError.make({
|
|
136
|
-
operation,
|
|
137
|
-
reason: Reasons.Authorization.make({}),
|
|
138
|
-
outcome: "undispatched"
|
|
139
|
-
}));
|
|
140
|
-
paths.push(issued.remotePath);
|
|
141
|
-
}
|
|
142
|
-
return Effect.succeed({
|
|
143
|
-
_tag: "Stored",
|
|
144
|
-
paths
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
const makeSession = (connection, lifetime) => {
|
|
148
|
-
const { session, operations } = connection;
|
|
149
|
-
const transfers = (page) => operations.forPage(page);
|
|
150
|
-
return Object.assign(session, {
|
|
151
|
-
reference: lifetime.reference,
|
|
152
|
-
closeChecked: session.closeChecked.pipe(Effect.andThen(lifetime.closeChecked)),
|
|
153
|
-
clickForDownload: (page, request, options) => transfers(page).pipe(Effect.flatMap((operations) => operations.clickForDownload(request, options)), Effect.flatMap((event) => Schema.decodeEffect(DownloadObservation)({
|
|
154
|
-
...event,
|
|
155
|
-
reference: lifetime.reference
|
|
156
|
-
}).pipe(Effect.mapError(() => BrowserError.make({
|
|
157
|
-
operation: "download-action",
|
|
158
|
-
reason: Reasons.Malformed.make({}),
|
|
159
|
-
outcome: "performed"
|
|
160
|
-
}))))),
|
|
161
|
-
selectFiles: (page, request, options) => transfers(page).pipe(Effect.flatMap((operations) => selection(request, lifetime.reference, "select-files").pipe(Effect.flatMap((files) => operations.selectFiles({
|
|
162
|
-
selector: request.selector,
|
|
163
|
-
selection: files
|
|
164
|
-
}, options))))),
|
|
165
|
-
clickForFileSelection: (page, request, options) => transfers(page).pipe(Effect.flatMap((operations) => selection(request, lifetime.reference, "file-chooser").pipe(Effect.flatMap((files) => operations.clickForFileSelection({
|
|
166
|
-
selector: request.selector,
|
|
167
|
-
selection: files
|
|
168
|
-
}, options))))),
|
|
169
|
-
liveView: (ttl = 60, options) => operations.liveView(lifetime.liveView(ttl), options),
|
|
170
|
-
beginHandoff: (ttl = 60, options) => operations.beginHandoff(lifetime.liveView(ttl), options),
|
|
171
|
-
resume: operations.resume,
|
|
172
|
-
detach: operations.detach,
|
|
173
|
-
reconnect: operations.reconnect,
|
|
174
|
-
close: lifetime.release,
|
|
175
|
-
cleanupResult: lifetime.cleanupResult
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
var BrowserbaseBrowser = class BrowserbaseBrowser extends Context.Service()("effect-browserbase/Browser") {
|
|
179
|
-
/** Open through the configured account and browser service, in the caller's scope. */
|
|
180
|
-
static open(policy, request) {
|
|
181
|
-
return Effect.flatMap(BrowserbaseBrowser, (browser) => browser.open(policy, request));
|
|
182
|
-
}
|
|
183
|
-
/** Allocate the provider lifetime before connecting, preserving its attempt and cleanup. */
|
|
184
|
-
static acquire(policy, request) {
|
|
185
|
-
return Effect.flatMap(BrowserbaseBrowser, (browser) => browser.acquire(policy, request));
|
|
186
|
-
}
|
|
187
|
-
/** Borrow a provider session without acquiring release authority over it. */
|
|
188
|
-
static attach(reference, request) {
|
|
189
|
-
return Effect.flatMap(BrowserbaseBrowser, (browser) => browser.attach(reference, request));
|
|
190
|
-
}
|
|
191
|
-
/** Allocation attempts, connection ids and handoff tokens come from the required `Crypto`. */
|
|
192
|
-
static layer(options) {
|
|
193
|
-
return Layer.effect(BrowserbaseBrowser, Effect.gen(function* () {
|
|
194
|
-
const client = yield* BrowserbaseClient;
|
|
195
|
-
const sessions = yield* BrowserbaseSessions;
|
|
196
|
-
const crypto = yield* Crypto.Crypto;
|
|
197
|
-
const binding = yield* BrowserbaseBrowserBinding;
|
|
198
|
-
if (options.launch.context?.persist === true && options.contextWriter === void 0) return yield* BrowserError.make({
|
|
199
|
-
operation: "configure",
|
|
200
|
-
reason: Reasons.ContextLease.make({}),
|
|
201
|
-
outcome: "undispatched"
|
|
202
|
-
});
|
|
203
|
-
if (Object.prototype.hasOwnProperty.call(options, "bootstrap")) return yield* BrowserError.make({
|
|
204
|
-
operation: "configure",
|
|
205
|
-
reason: Reasons.Configuration.make({}),
|
|
206
|
-
outcome: "undispatched"
|
|
207
|
-
});
|
|
208
|
-
const runtime = yield* BrowserRuntime.make({
|
|
209
|
-
implementation: "browserbase-playwright-cdp",
|
|
210
|
-
binding,
|
|
211
|
-
automation: projected(options),
|
|
212
|
-
viewport: options.launch.viewport._tag === "Fixed" ? {
|
|
213
|
-
width: options.launch.viewport.width,
|
|
214
|
-
height: options.launch.viewport.height
|
|
215
|
-
} : {
|
|
216
|
-
width: 1280,
|
|
217
|
-
height: 720
|
|
218
|
-
},
|
|
219
|
-
preserveViewport: options.launch.viewport._tag !== "Fixed",
|
|
220
|
-
keepAlive: options.launch.keepAlive === true
|
|
221
|
-
});
|
|
222
|
-
const source = (remote) => (cleanup, deadline) => remote(cleanup, deadline).pipe(Effect.provideService(BrowserbaseClient, client), Effect.provideService(BrowserbaseSessions, sessions), Effect.provideService(Crypto.Crypto, crypto));
|
|
223
|
-
const acquire = Effect.fnUntraced(function* (policy, request = {}) {
|
|
224
|
-
const acquired = yield* runtime.acquire(policy, source(ownedRemote({
|
|
225
|
-
launch: options.launch,
|
|
226
|
-
...options.contextWriter === void 0 ? {} : { contextWriter: options.contextWriter },
|
|
227
|
-
...options.onCleanup === void 0 ? {} : { onCleanup: options.onCleanup },
|
|
228
|
-
...options.onAllocationUncertain === void 0 ? {} : { onAllocationUncertain: options.onAllocationUncertain }
|
|
229
|
-
})), request);
|
|
230
|
-
const connected = yield* Effect.cached(acquired.connect.pipe(Effect.map((connection) => makeSession(connection, acquired.lifetime))));
|
|
231
|
-
return {
|
|
232
|
-
reference: acquired.reference,
|
|
233
|
-
attempt: acquired.lifetime.attempt,
|
|
234
|
-
failure: acquired.failure,
|
|
235
|
-
close: acquired.close,
|
|
236
|
-
connect: acquired.connect.pipe(Effect.andThen(connected))
|
|
237
|
-
};
|
|
238
|
-
});
|
|
239
|
-
const attach = Effect.fnUntraced(function* (reference, request) {
|
|
240
|
-
const acquired = yield* runtime.acquire(request.policy, source(borrowedRemote({
|
|
241
|
-
reference,
|
|
242
|
-
...request.pendingWaitMillis === void 0 ? {} : { pendingWaitMillis: request.pendingWaitMillis },
|
|
243
|
-
...options.onCleanup === void 0 ? {} : { onCleanup: options.onCleanup }
|
|
244
|
-
})), {
|
|
245
|
-
...request.bootstrap === void 0 ? {} : { bootstrap: request.bootstrap },
|
|
246
|
-
existingTarget: request.target ?? {}
|
|
247
|
-
});
|
|
248
|
-
return yield* acquired.connect.pipe(Effect.map((connection) => makeSession(connection, acquired.lifetime)));
|
|
249
|
-
});
|
|
250
|
-
return BrowserbaseBrowser.of({
|
|
251
|
-
acquire,
|
|
252
|
-
attach,
|
|
253
|
-
open: (policy, request) => acquire(policy, request).pipe(Effect.flatMap((acquired) => acquired.connect))
|
|
254
|
-
});
|
|
255
|
-
}));
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
/** Only the automation fields cross the schema boundary; launch and callbacks are separate. */
|
|
259
|
-
const projected = (options) => ({
|
|
260
|
-
...options.timelineLimits === void 0 ? {} : { timelineLimits: options.timelineLimits },
|
|
261
|
-
...options.admissionLimits === void 0 ? {} : { admissionLimits: options.admissionLimits },
|
|
262
|
-
...options.observationLimits === void 0 ? {} : { observationLimits: options.observationLimits },
|
|
263
|
-
...options.maxHostReads === void 0 ? {} : { maxHostReads: options.maxHostReads },
|
|
264
|
-
...options.actionTimeoutMillis === void 0 ? {} : { actionTimeoutMillis: options.actionTimeoutMillis },
|
|
265
|
-
...options.maxPages === void 0 ? {} : { maxPages: options.maxPages },
|
|
266
|
-
...options.initialPage === void 0 ? {} : { initialPage: options.initialPage },
|
|
267
|
-
...options.popupPolicy === void 0 ? {} : { popupPolicy: options.popupPolicy },
|
|
268
|
-
...options.dialogPolicy === void 0 ? {} : { dialogPolicy: options.dialogPolicy },
|
|
269
|
-
...options.pageControl === void 0 ? {} : { pageControl: options.pageControl }
|
|
270
|
-
});
|
|
271
|
-
//#endregion
|
|
272
|
-
export { BrowserbaseBrowser as t };
|
|
273
|
-
|
|
274
|
-
//# sourceMappingURL=Browser-ByrWJ0ss.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Browser-ByrWJ0ss.mjs","names":["Trace.span"],"sources":["../src/internal/session/Attachment.ts","../src/internal/session/Browser.ts","../src/Browser.ts"],"sourcesContent":["import { Effect, Exit, Option, Scope } from \"effect\";\n\nimport type { CleanupResult } from \"../../Cleanup.ts\";\nimport { BrowserbaseClient } from \"../../Client.ts\";\nimport { SessionError } from \"../../Errors.ts\";\nimport type { SessionReference } from \"../../References.ts\";\nimport { isTerminalSessionStatus } from \"../../SessionData.ts\";\nimport { BrowserbaseSessions } from \"../../Sessions.ts\";\nimport { connectionAddress } from \"../provider/Connection.ts\";\nimport * as Trace from \"../Trace.ts\";\nimport {\n makeCleanup,\n noLocalConnection,\n reported,\n type CleanupLimits,\n type LocalCleanup,\n} from \"./Cleanup.ts\";\nimport { reportCleanup } from \"./Diagnostics.ts\";\n\nexport interface AttachmentOptions {\n readonly reference: SessionReference;\n /** Bounded admission of a session the provider has not finished starting. */\n readonly pendingWaitMillis?: number;\n readonly onCleanup?: (result: CleanupResult) => Effect.Effect<void>;\n}\n\nconst failure = (reason: SessionError[\"reason\"]) =>\n SessionError.make({ operation: \"session-attach\", reason, outcome: \"undispatched\" });\n\n/**\n * Borrowing an already running session. This scope owns its local connection and nothing\n * else: no allocation attempt is made, no release is requested, and no Context-writer\n * authority is claimed. Whoever allocated the session keeps all three.\n */\nexport const attachRemote = Effect.fnUntraced(\n function* (\n options: AttachmentOptions,\n local: LocalCleanup = noLocalConnection,\n limits?: CleanupLimits,\n ) {\n const client = yield* BrowserbaseClient;\n const sessions = yield* BrowserbaseSessions;\n const parent = yield* Scope.Scope;\n const pendingWaitMillis = options.pendingWaitMillis ?? 0;\n\n if (\n !Number.isSafeInteger(pendingWaitMillis) ||\n pendingWaitMillis < 0 ||\n pendingWaitMillis > 600_000\n )\n return yield* failure(\"configuration\");\n\n // The status read validates project authority before anything is borrowed. A terminal\n // session needs a fresh allocation from durable state, never a reattachment.\n const observed = yield* sessions.retrieve(options.reference);\n\n if (isTerminalSessionStatus(observed.status)) return yield* failure(\"expired\");\n if (observed.status !== \"RUNNING\") {\n if (pendingWaitMillis === 0) return yield* failure(\"active\");\n yield* sessions.waitUntilRunning(observed.reference, { timeoutMillis: pendingWaitMillis });\n }\n const reference = observed.reference;\n\n return yield* Effect.uninterruptible(\n Effect.gen(function* () {\n const resourceScope = yield* Scope.make();\n let closing = false;\n let cleanup: CleanupResult | undefined;\n\n const terminate = yield* Effect.cached(\n Effect.uninterruptible(\n Effect.gen(function* () {\n closing = true;\n\n const coordinator = yield* makeCleanup(\n reference,\n \"borrowed\",\n sessions,\n local,\n (result) => {\n cleanup = result;\n },\n limits,\n );\n\n yield* coordinator.close;\n const result = cleanup;\n const notify = options.onCleanup;\n\n if (result !== undefined) {\n yield* reported(Effect.suspend(() => reportCleanup(result)));\n if (notify !== undefined)\n yield* reported(\n Effect.suspend(() => notify(result)).pipe(\n Trace.span(\"Browserbase.callback.cleanup\"),\n ),\n );\n }\n }).pipe(\n Trace.span(\"Browserbase.terminate\", {\n attributes: { \"browser.ownership\": \"borrowed\" },\n }),\n ),\n ),\n );\n\n const closeScope = yield* Effect.cached(Scope.close(resourceScope, Exit.void));\n\n // Teardown is registered before the first connection, exactly as an owned scope does.\n yield* Scope.addFinalizer(resourceScope, terminate);\n yield* Scope.addFinalizer(parent, closeScope);\n\n return {\n reference,\n status: observed,\n connection: (timeoutMillis: number) =>\n Effect.suspend(() =>\n closing\n ? Effect.fail(\n SessionError.make({\n operation: \"session-connect\",\n reason: \"expired\",\n outcome: \"undispatched\",\n }),\n )\n : // Credentials are fetched fresh: an expiry can race the caller's own read.\n connectionAddress(client, sessions, reference, timeoutMillis).pipe(\n Trace.span(\"Browserbase.connection\", {\n attributes: { \"browser.ownership\": \"borrowed\" },\n }),\n ),\n ),\n release: closeScope.pipe(\n Effect.andThen(\n Effect.suspend(() =>\n cleanup === undefined\n ? Effect.die(new Error(\"Borrowed session closed without cleanup evidence\"))\n : Effect.succeed(cleanup),\n ),\n ),\n Trace.span(\"Browserbase.release\", { attributes: { \"browser.ownership\": \"borrowed\" } }),\n ),\n cleanupResult: Effect.sync(() => Option.fromNullishOr(cleanup)),\n };\n }),\n );\n },\n Trace.span(\"Browserbase.attachRemote\", { attributes: { \"browser.ownership\": \"borrowed\" } }),\n);\n","import { type Crypto, Effect, Option, type Redacted } from \"effect\";\nimport type { Lifetime, Source } from \"effect-browser/browser-runtime\";\nimport { BrowserError, Reasons } from \"effect-browser/errors\";\n\nimport type { CleanupResult } from \"../../Cleanup.ts\";\nimport { BrowserbaseClient } from \"../../Client.ts\";\nimport type { AllocationError, ContextError, SessionError } from \"../../Errors.ts\";\nimport type { LaunchRecipe } from \"../../Launch.ts\";\nimport type { AllocationAttempt, SessionReference } from \"../../References.ts\";\nimport { BrowserbaseSessions } from \"../../Sessions.ts\";\nimport { issueLiveView, type LiveView } from \"../browser/LiveView.ts\";\nimport { browserRequestFailure } from \"../browser/RequestFailure.ts\";\nimport { acquireRemote } from \"./Acquisition.ts\";\nimport { attachRemote } from \"./Attachment.ts\";\nimport type { ContextWriterPermit } from \"./WriterFacts.ts\";\n\nexport interface RemoteLease extends Lifetime {\n readonly reference: SessionReference;\n readonly closeChecked: Effect.Effect<CleanupResult, BrowserError>;\n readonly attempt?: AllocationAttempt;\n readonly release: Effect.Effect<CleanupResult>;\n readonly cleanupResult: Effect.Effect<Option.Option<CleanupResult>>;\n readonly liveView: (ttl: number) => Effect.Effect<LiveView, BrowserError>;\n}\n\ntype RemoteSource<L extends Lifetime, E> = Source<\n L,\n E,\n BrowserbaseClient | BrowserbaseSessions | Crypto.Crypto\n>;\n\n/** A borrowed connection closes without requiring or requesting remote termination. */\nconst checkedCleanup = (\n close: Effect.Effect<CleanupResult>,\n): Effect.Effect<CleanupResult, BrowserError> =>\n close.pipe(\n Effect.filterOrFail(\n (result) =>\n result.local === \"closed\" &&\n result.issues.length === 0 &&\n (result.ownership === \"borrowed\"\n ? result.remote === \"not-owned\"\n : result.remote === \"confirmed\"),\n () =>\n BrowserError.make({\n operation: \"close\",\n reason: Reasons.Provider.make({}),\n outcome: \"unknown\",\n }),\n ),\n );\n\nconst withConnection = <\n A extends {\n readonly reference: SessionReference;\n readonly connection: (\n timeoutMillis: number,\n ) => Effect.Effect<Redacted.Redacted<string>, SessionError>;\n readonly release: Effect.Effect<CleanupResult>;\n readonly cleanupResult: Effect.Effect<Option.Option<CleanupResult>>;\n },\n>(\n acquired: A,\n) => ({\n ...acquired,\n connection: (timeoutMillis: number) =>\n acquired\n .connection(timeoutMillis)\n .pipe(Effect.mapError((error) => browserRequestFailure(\"connect\", error))),\n closeChecked: checkedCleanup(acquired.release),\n controlRetired: acquired.cleanupResult.pipe(\n Effect.map(\n (result) =>\n Option.isSome(result) &&\n result.value.ownership === \"owned\" &&\n result.value.remote === \"confirmed\",\n ),\n ),\n});\n\nexport interface OwnedLease extends RemoteLease {\n readonly attempt: AllocationAttempt;\n}\n\nexport interface OwnedOptions {\n /** The single provider-faithful launch description; the owner adds no second default body. */\n readonly launch: LaunchRecipe;\n /** Required for a persistent context; the writer permit, not this owner, holds that authority. */\n readonly contextWriter?: ContextWriterPermit;\n readonly onCleanup?: (result: CleanupResult) => Effect.Effect<void>;\n readonly onAllocationUncertain?: (attempt: AllocationAttempt) => Effect.Effect<void>;\n}\n\n/** Allocates the session, and therefore owns releasing it. */\nconst providerControls = (\n client: BrowserbaseClient[\"Service\"],\n sessions: BrowserbaseSessions[\"Service\"],\n reference: SessionReference,\n) => ({\n liveView: (ttl: number) => issueLiveView(client, reference, ttl),\n verifyReconnect: sessions.retrieve(reference).pipe(\n Effect.mapError((error) => browserRequestFailure(\"reconnect\", error)),\n Effect.flatMap((status) =>\n status.status === \"RUNNING\"\n ? Effect.void\n : Effect.fail(\n BrowserError.make({\n operation: \"reconnect\",\n reason: Reasons.Expired.make({}),\n outcome: \"undispatched\",\n }),\n ),\n ),\n ),\n});\n\nexport const ownedRemote =\n (\n options: OwnedOptions,\n ): RemoteSource<OwnedLease, AllocationError | BrowserError | ContextError> =>\n (local, lifetimeDeadline) =>\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n const sessions = yield* BrowserbaseSessions;\n\n const acquired = yield* acquireRemote(\n {\n launch: options.launch,\n ...(options.contextWriter === undefined ? {} : { contextWriter: options.contextWriter }),\n allocationDeadline: lifetimeDeadline,\n ...(options.onCleanup === undefined ? {} : { onCleanup: options.onCleanup }),\n ...(options.onAllocationUncertain === undefined\n ? {}\n : { onAllocationUncertain: options.onAllocationUncertain }),\n },\n local,\n );\n\n return {\n ...withConnection(acquired),\n ...providerControls(client, sessions, acquired.reference),\n };\n });\n\n/** Borrows a running session: local connection only, and never a release request. */\nexport const borrowedRemote =\n (options: {\n readonly reference: SessionReference;\n readonly pendingWaitMillis?: number;\n readonly onCleanup?: (result: CleanupResult) => Effect.Effect<void>;\n }): RemoteSource<RemoteLease, SessionError> =>\n (local) =>\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n const sessions = yield* BrowserbaseSessions;\n const acquired = yield* attachRemote(options, local);\n\n return {\n ...withConnection(acquired),\n ...providerControls(client, sessions, acquired.reference),\n };\n });\n","import {\n Context,\n Crypto,\n Effect,\n Layer,\n type Option,\n type Redacted,\n Schema,\n type Scope,\n} from \"effect\";\nimport type { BrowserSession, OpenOptions, OperationOptions, Page } from \"effect-browser/browser\";\nimport type {\n ActionResult,\n AutomationOptions,\n BrowserPolicy,\n ClickRequest,\n Inventory,\n} from \"effect-browser/browser-data\";\nimport * as BrowserRuntime from \"effect-browser/browser-runtime\";\nimport {\n BrowserError,\n Reasons,\n type BrowserOperation,\n type InitializationError,\n} from \"effect-browser/errors\";\n\nimport { BrowserbaseBrowserBinding } from \"./BrowserBinding.ts\";\nimport type { CleanupResult } from \"./Cleanup.ts\";\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport type { AllocationError, ContextError, SessionError } from \"./Errors.ts\";\nimport type { LiveView } from \"./internal/browser/LiveView.ts\";\nimport { isList } from \"./internal/List.ts\";\nimport { borrowedRemote, ownedRemote, type RemoteLease } from \"./internal/session/Browser.ts\";\nimport type { ContextWriterPermit } from \"./internal/session/WriterFacts.ts\";\nimport { issuedUpload } from \"./internal/upload/Issued.ts\";\nimport type { LaunchRecipe } from \"./Launch.ts\";\nimport type { AllocationAttempt, SessionReference } from \"./References.ts\";\nimport { BrowserbaseSessions } from \"./Sessions.ts\";\nimport { DownloadObservation, type SelectFilesRequest } from \"./Transfers.ts\";\n\nexport type { LiveView } from \"./internal/browser/LiveView.ts\";\nexport type { FileSelection, SelectFilesRequest } from \"./Transfers.ts\";\n\n/** Host configuration. Credentials live in the Client; a model never selects these values. */\nexport interface BrowserOptions extends AutomationOptions {\n readonly launch: LaunchRecipe;\n /** Required whenever the launch recipe persists a context. */\n readonly contextWriter?: ContextWriterPermit;\n readonly onCleanup?: (result: CleanupResult) => Effect.Effect<void>;\n readonly onAllocationUncertain?: (attempt: AllocationAttempt) => Effect.Effect<void>;\n}\n\nexport interface Handoff {\n readonly token: Redacted.Redacted<string>;\n readonly view: LiveView;\n}\n\n/** Browserbase identity, remote artifacts and provider cleanup remain hosted capabilities. */\nexport interface BrowserbaseSession<E = never> extends BrowserSession<E> {\n readonly reference: SessionReference;\n readonly closeChecked: Effect.Effect<CleanupResult, BrowserError>;\n /** Transfers take the issued Page first, like `Capture.start(page)` and `PageControl`. */\n readonly clickForDownload: (\n page: Page,\n request: ClickRequest,\n options?: OperationOptions,\n ) => Effect.Effect<DownloadObservation, BrowserError>;\n /** Attaches to an existing file input; an uploaded branch needs a receipt for this session. */\n readonly selectFiles: (\n page: Page,\n request: SelectFilesRequest,\n options?: OperationOptions,\n ) => Effect.Effect<ActionResult, BrowserError>;\n /** Registers the chooser observation before the single click that opens it. */\n readonly clickForFileSelection: (\n page: Page,\n request: SelectFilesRequest,\n options?: OperationOptions,\n ) => Effect.Effect<ActionResult, BrowserError>;\n readonly liveView: (\n expiresInSeconds?: number,\n options?: OperationOptions,\n ) => Effect.Effect<LiveView, BrowserError>;\n readonly beginHandoff: (\n expiresInSeconds?: number,\n options?: OperationOptions,\n ) => Effect.Effect<Handoff, BrowserError>;\n readonly resume: (\n token: Redacted.Redacted<string>,\n operatorReleasedControl: boolean,\n options?: OperationOptions,\n ) => Effect.Effect<Inventory, BrowserError>;\n readonly detach: Effect.Effect<\n {\n readonly reference: SessionReference;\n readonly targetId: string;\n readonly inventory: Inventory;\n },\n BrowserError\n >;\n readonly reconnect: (\n operatorReleasedControl: boolean,\n options?: OperationOptions,\n ) => Effect.Effect<Inventory, BrowserError | InitializationError>;\n readonly close: Effect.Effect<CleanupResult>;\n readonly cleanupResult: Effect.Effect<Option.Option<CleanupResult>>;\n}\n\nexport interface AttachRequest<E = never, R = never> extends OpenOptions<E, R> {\n readonly policy: BrowserPolicy;\n /** The exact page to resume; without it the session must have exactly one page. */\n readonly target?: { readonly targetId: string };\n /** Bounded admission of a session the provider has not finished starting. */\n readonly pendingWaitMillis?: number;\n}\n\nexport interface BrowserAcquisition<E = never> {\n readonly reference: SessionReference;\n readonly attempt: AllocationAttempt;\n readonly failure: Effect.Effect<never, E | InitializationError>;\n readonly connect: Effect.Effect<BrowserbaseSession<E>, BrowserError | E | InitializationError>;\n readonly close: Effect.Effect<CleanupResult>;\n}\n\n/** Only receipts issued for this exact provider session may resolve to stored paths. */\nconst selection = (\n request: SelectFilesRequest,\n reference: SessionReference,\n operation: BrowserOperation,\n): Effect.Effect<BrowserRuntime.ResolvedFileSelection, BrowserError> =>\n Effect.suspend(() => {\n if (request.selection._tag === \"Inline\")\n return Effect.succeed<BrowserRuntime.ResolvedFileSelection>({\n _tag: \"Inline\",\n files: request.selection.files,\n });\n\n const uploads = request.selection.uploads;\n\n if (!isList(uploads) || uploads.length < 1 || uploads.length > 8)\n return Effect.fail(\n BrowserError.make({\n operation,\n reason: Reasons.Configuration.make({}),\n outcome: \"undispatched\",\n }),\n );\n const paths: string[] = [];\n\n for (const receipt of uploads) {\n const issued = issuedUpload(receipt);\n\n if (\n issued === undefined ||\n issued.reference.projectId !== reference.projectId ||\n issued.reference.sessionId !== reference.sessionId\n )\n return Effect.fail(\n BrowserError.make({\n operation,\n reason: Reasons.Authorization.make({}),\n outcome: \"undispatched\",\n }),\n );\n paths.push(issued.remotePath);\n }\n\n return Effect.succeed<BrowserRuntime.ResolvedFileSelection>({ _tag: \"Stored\", paths });\n });\n\nconst makeSession = <E>(\n connection: BrowserRuntime.Connection<SessionReference, E>,\n lifetime: RemoteLease,\n): BrowserbaseSession<E> => {\n const { session, operations } = connection;\n\n const transfers = (page: Page): Effect.Effect<BrowserRuntime.TransferOperations, BrowserError> =>\n operations.forPage(page);\n\n // Decorating the same object preserves its private capture and page-control associations.\n return Object.assign(session, {\n reference: lifetime.reference,\n closeChecked: session.closeChecked.pipe(Effect.andThen(lifetime.closeChecked)),\n clickForDownload: (page, request, options) =>\n transfers(page).pipe(\n Effect.flatMap((operations) => operations.clickForDownload(request, options)),\n Effect.flatMap((event) =>\n Schema.decodeEffect(DownloadObservation)({\n ...event,\n reference: lifetime.reference,\n }).pipe(\n Effect.mapError(() =>\n BrowserError.make({\n operation: \"download-action\",\n reason: Reasons.Malformed.make({}),\n outcome: \"performed\",\n }),\n ),\n ),\n ),\n ),\n selectFiles: (page, request, options) =>\n transfers(page).pipe(\n Effect.flatMap((operations) =>\n selection(request, lifetime.reference, \"select-files\").pipe(\n Effect.flatMap((files) =>\n operations.selectFiles({ selector: request.selector, selection: files }, options),\n ),\n ),\n ),\n ),\n clickForFileSelection: (page, request, options) =>\n transfers(page).pipe(\n Effect.flatMap((operations) =>\n selection(request, lifetime.reference, \"file-chooser\").pipe(\n Effect.flatMap((files) =>\n operations.clickForFileSelection(\n { selector: request.selector, selection: files },\n options,\n ),\n ),\n ),\n ),\n ),\n liveView: (ttl = 60, options) => operations.liveView(lifetime.liveView(ttl), options),\n beginHandoff: (ttl = 60, options) => operations.beginHandoff(lifetime.liveView(ttl), options),\n resume: operations.resume,\n detach: operations.detach,\n reconnect: operations.reconnect,\n close: lifetime.release,\n cleanupResult: lifetime.cleanupResult,\n } satisfies Omit<BrowserbaseSession<E>, Exclude<keyof BrowserSession<E>, \"closeChecked\">>);\n};\n\nexport class BrowserbaseBrowser extends Context.Service<\n BrowserbaseBrowser,\n {\n readonly acquire: <E = never, R = never>(\n policy: BrowserPolicy,\n request?: OpenOptions<E, R>,\n ) => Effect.Effect<\n BrowserAcquisition<E>,\n AllocationError | BrowserError | ContextError,\n Scope.Scope | Exclude<R, Scope.Scope>\n >;\n /** Borrowed control of a session this process did not allocate and will not release. */\n readonly attach: <E = never, R = never>(\n reference: SessionReference,\n request: AttachRequest<E, R>,\n ) => Effect.Effect<\n BrowserbaseSession<E>,\n BrowserError | SessionError | E | InitializationError,\n Scope.Scope | Exclude<R, Scope.Scope>\n >;\n readonly open: <E = never, R = never>(\n policy: BrowserPolicy,\n request?: OpenOptions<E, R>,\n ) => Effect.Effect<\n BrowserbaseSession<E>,\n AllocationError | BrowserError | ContextError | E | InitializationError,\n Scope.Scope | Exclude<R, Scope.Scope>\n >;\n }\n>()(\"effect-browserbase/Browser\") {\n /** Open through the configured account and browser service, in the caller's scope. */\n static open<E = never, R = never>(policy: BrowserPolicy, request?: OpenOptions<E, R>) {\n return Effect.flatMap(BrowserbaseBrowser, (browser) => browser.open(policy, request));\n }\n\n /** Allocate the provider lifetime before connecting, preserving its attempt and cleanup. */\n static acquire<E = never, R = never>(policy: BrowserPolicy, request?: OpenOptions<E, R>) {\n return Effect.flatMap(BrowserbaseBrowser, (browser) => browser.acquire(policy, request));\n }\n\n /** Borrow a provider session without acquiring release authority over it. */\n static attach<E = never, R = never>(reference: SessionReference, request: AttachRequest<E, R>) {\n return Effect.flatMap(BrowserbaseBrowser, (browser) => browser.attach(reference, request));\n }\n\n /** Allocation attempts, connection ids and handoff tokens come from the required `Crypto`. */\n static layer(\n options: BrowserOptions,\n ): Layer.Layer<\n BrowserbaseBrowser,\n BrowserError,\n BrowserbaseClient | BrowserbaseSessions | Crypto.Crypto\n > {\n return Layer.effect(\n BrowserbaseBrowser,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n const sessions = yield* BrowserbaseSessions;\n const crypto = yield* Crypto.Crypto;\n const binding = yield* BrowserbaseBrowserBinding;\n\n if (options.launch.context?.persist === true && options.contextWriter === undefined)\n return yield* BrowserError.make({\n operation: \"configure\",\n reason: Reasons.ContextLease.make({}),\n outcome: \"undispatched\",\n });\n if (Object.prototype.hasOwnProperty.call(options, \"bootstrap\"))\n return yield* BrowserError.make({\n operation: \"configure\",\n reason: Reasons.Configuration.make({}),\n outcome: \"undispatched\",\n });\n\n const runtime = yield* BrowserRuntime.make({\n implementation: \"browserbase-playwright-cdp\",\n binding,\n automation: projected(options),\n viewport:\n options.launch.viewport._tag === \"Fixed\"\n ? { width: options.launch.viewport.width, height: options.launch.viewport.height }\n : { width: 1280, height: 720 },\n preserveViewport: options.launch.viewport._tag !== \"Fixed\",\n keepAlive: options.launch.keepAlive === true,\n });\n\n const source =\n <L extends BrowserRuntime.Lifetime, E>(\n remote: BrowserRuntime.Source<\n L,\n E,\n BrowserbaseClient | BrowserbaseSessions | Crypto.Crypto\n >,\n ): BrowserRuntime.Source<L, E> =>\n (cleanup, deadline) =>\n remote(cleanup, deadline).pipe(\n Effect.provideService(BrowserbaseClient, client),\n Effect.provideService(BrowserbaseSessions, sessions),\n Effect.provideService(Crypto.Crypto, crypto),\n );\n\n const acquire = Effect.fnUntraced(function* <E = never, R = never>(\n policy: BrowserPolicy,\n request: OpenOptions<E, R> = {},\n ) {\n const acquired = yield* runtime.acquire(\n policy,\n source(\n ownedRemote({\n launch: options.launch,\n ...(options.contextWriter === undefined\n ? {}\n : { contextWriter: options.contextWriter }),\n ...(options.onCleanup === undefined ? {} : { onCleanup: options.onCleanup }),\n ...(options.onAllocationUncertain === undefined\n ? {}\n : { onAllocationUncertain: options.onAllocationUncertain }),\n }),\n ),\n request,\n );\n\n const connected = yield* Effect.cached(\n acquired.connect.pipe(\n Effect.map((connection) => makeSession(connection, acquired.lifetime)),\n ),\n );\n\n return {\n reference: acquired.reference,\n attempt: acquired.lifetime.attempt,\n failure: acquired.failure,\n close: acquired.close,\n connect: acquired.connect.pipe(Effect.andThen(connected)),\n } satisfies BrowserAcquisition<E>;\n });\n\n const attach = Effect.fnUntraced(function* <E = never, R = never>(\n reference: SessionReference,\n request: AttachRequest<E, R>,\n ) {\n const acquired = yield* runtime.acquire(\n request.policy,\n source(\n borrowedRemote({\n reference,\n ...(request.pendingWaitMillis === undefined\n ? {}\n : { pendingWaitMillis: request.pendingWaitMillis }),\n ...(options.onCleanup === undefined ? {} : { onCleanup: options.onCleanup }),\n }),\n ),\n {\n ...(request.bootstrap === undefined ? {} : { bootstrap: request.bootstrap }),\n existingTarget: request.target ?? {},\n },\n );\n\n return yield* acquired.connect.pipe(\n Effect.map((connection) => makeSession(connection, acquired.lifetime)),\n );\n });\n\n return BrowserbaseBrowser.of({\n acquire,\n attach,\n open: (policy, request) =>\n acquire(policy, request).pipe(Effect.flatMap((acquired) => acquired.connect)),\n });\n }),\n );\n }\n}\n\n/** Only the automation fields cross the schema boundary; launch and callbacks are separate. */\nconst projected = (options: BrowserOptions) => ({\n ...(options.timelineLimits === undefined ? {} : { timelineLimits: options.timelineLimits }),\n ...(options.admissionLimits === undefined ? {} : { admissionLimits: options.admissionLimits }),\n ...(options.observationLimits === undefined\n ? {}\n : { observationLimits: options.observationLimits }),\n ...(options.maxHostReads === undefined ? {} : { maxHostReads: options.maxHostReads }),\n ...(options.actionTimeoutMillis === undefined\n ? {}\n : { actionTimeoutMillis: options.actionTimeoutMillis }),\n ...(options.maxPages === undefined ? {} : { maxPages: options.maxPages }),\n ...(options.initialPage === undefined ? {} : { initialPage: options.initialPage }),\n ...(options.popupPolicy === undefined ? {} : { popupPolicy: options.popupPolicy }),\n ...(options.dialogPolicy === undefined ? {} : { dialogPolicy: options.dialogPolicy }),\n ...(options.pageControl === undefined ? {} : { pageControl: options.pageControl }),\n});\n"],"mappings":";;;;;;;;;;;;;;A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,IAAI,EAAE,gBAAgB,QAAQ,eAAe;CACzF,GAAI,QAAQ,oBAAoB,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB,QAAQ,gBAAgB;CAC5F,GAAI,QAAQ,sBAAsB,KAAA,IAC9B,CAAC,IACD,EAAE,mBAAmB,QAAQ,kBAAkB;CACnD,GAAI,QAAQ,iBAAiB,KAAA,IAAY,CAAC,IAAI,EAAE,cAAc,QAAQ,aAAa;CACnF,GAAI,QAAQ,wBAAwB,KAAA,IAChC,CAAC,IACD,EAAE,qBAAqB,QAAQ,oBAAoB;CACvD,GAAI,QAAQ,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,QAAQ,SAAS;CACvE,GAAI,QAAQ,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,QAAQ,YAAY;CAChF,GAAI,QAAQ,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,QAAQ,YAAY;CAChF,GAAI,QAAQ,iBAAiB,KAAA,IAAY,CAAC,IAAI,EAAE,cAAc,QAAQ,aAAa;CACnF,GAAI,QAAQ,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,QAAQ,YAAY;AAClF"}
|
package/dist/Browser.d.mts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
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-oJEUmZth.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, Inventory } from "effect-browser/browser-data";
|
|
11
|
-
import { BrowserError, InitializationError } from "effect-browser/errors";
|
|
12
|
-
import { BrowserSession, OpenOptions, OperationOptions, Page } from "effect-browser/browser";
|
|
13
|
-
//#region src/Browser.d.ts
|
|
14
|
-
/** Host configuration. Credentials live in the Client; a model never selects these values. */
|
|
15
|
-
export interface BrowserOptions extends AutomationOptions {
|
|
16
|
-
readonly launch: LaunchRecipe;
|
|
17
|
-
/** Required whenever the launch recipe persists a context. */
|
|
18
|
-
readonly contextWriter?: ContextWriterPermit;
|
|
19
|
-
readonly onCleanup?: (result: CleanupResult) => Effect.Effect<void>;
|
|
20
|
-
readonly onAllocationUncertain?: (attempt: AllocationAttempt) => Effect.Effect<void>;
|
|
21
|
-
}
|
|
22
|
-
export interface Handoff {
|
|
23
|
-
readonly token: Redacted.Redacted<string>;
|
|
24
|
-
readonly view: LiveView;
|
|
25
|
-
}
|
|
26
|
-
/** Browserbase identity, remote artifacts and provider cleanup remain hosted capabilities. */
|
|
27
|
-
export interface BrowserbaseSession<E = never> extends BrowserSession<E> {
|
|
28
|
-
readonly reference: SessionReference;
|
|
29
|
-
readonly closeChecked: Effect.Effect<CleanupResult, BrowserError>;
|
|
30
|
-
/** Transfers take the issued Page first, like `Capture.start(page)` and `PageControl`. */
|
|
31
|
-
readonly clickForDownload: (page: Page, request: ClickRequest, options?: OperationOptions) => Effect.Effect<DownloadObservation, BrowserError>;
|
|
32
|
-
/** Attaches to an existing file input; an uploaded branch needs a receipt for this session. */
|
|
33
|
-
readonly selectFiles: (page: Page, request: SelectFilesRequest, options?: OperationOptions) => Effect.Effect<ActionResult, BrowserError>;
|
|
34
|
-
/** Registers the chooser observation before the single click that opens it. */
|
|
35
|
-
readonly clickForFileSelection: (page: Page, request: SelectFilesRequest, options?: OperationOptions) => Effect.Effect<ActionResult, BrowserError>;
|
|
36
|
-
readonly liveView: (expiresInSeconds?: number, options?: OperationOptions) => Effect.Effect<LiveView, BrowserError>;
|
|
37
|
-
readonly beginHandoff: (expiresInSeconds?: number, options?: OperationOptions) => Effect.Effect<Handoff, BrowserError>;
|
|
38
|
-
readonly resume: (token: Redacted.Redacted<string>, operatorReleasedControl: boolean, options?: OperationOptions) => Effect.Effect<Inventory, BrowserError>;
|
|
39
|
-
readonly detach: Effect.Effect<{
|
|
40
|
-
readonly reference: SessionReference;
|
|
41
|
-
readonly targetId: string;
|
|
42
|
-
readonly inventory: Inventory;
|
|
43
|
-
}, BrowserError>;
|
|
44
|
-
readonly reconnect: (operatorReleasedControl: boolean, options?: OperationOptions) => Effect.Effect<Inventory, BrowserError | InitializationError>;
|
|
45
|
-
readonly close: Effect.Effect<CleanupResult>;
|
|
46
|
-
readonly cleanupResult: Effect.Effect<Option.Option<CleanupResult>>;
|
|
47
|
-
}
|
|
48
|
-
export interface AttachRequest<E = never, R = never> extends OpenOptions<E, R> {
|
|
49
|
-
readonly policy: BrowserPolicy;
|
|
50
|
-
/** The exact page to resume; without it the session must have exactly one page. */
|
|
51
|
-
readonly target?: {
|
|
52
|
-
readonly targetId: string;
|
|
53
|
-
};
|
|
54
|
-
/** Bounded admission of a session the provider has not finished starting. */
|
|
55
|
-
readonly pendingWaitMillis?: number;
|
|
56
|
-
}
|
|
57
|
-
export interface BrowserAcquisition<E = never> {
|
|
58
|
-
readonly reference: SessionReference;
|
|
59
|
-
readonly attempt: AllocationAttempt;
|
|
60
|
-
readonly failure: Effect.Effect<never, E | InitializationError>;
|
|
61
|
-
readonly connect: Effect.Effect<BrowserbaseSession<E>, BrowserError | E | InitializationError>;
|
|
62
|
-
readonly close: Effect.Effect<CleanupResult>;
|
|
63
|
-
}
|
|
64
|
-
declare const BrowserbaseBrowser_base: Context.ServiceClass<BrowserbaseBrowser, "effect-browserbase/Browser", {
|
|
65
|
-
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>>;
|
|
66
|
-
/** Borrowed control of a session this process did not allocate and will not release. */
|
|
67
|
-
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>>;
|
|
68
|
-
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>>;
|
|
69
|
-
}>;
|
|
70
|
-
export declare class BrowserbaseBrowser extends BrowserbaseBrowser_base {
|
|
71
|
-
/** Open through the configured account and browser service, in the caller's scope. */
|
|
72
|
-
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>>;
|
|
73
|
-
/** Allocate the provider lifetime before connecting, preserving its attempt and cleanup. */
|
|
74
|
-
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>>;
|
|
75
|
-
/** Borrow a provider session without acquiring release authority over it. */
|
|
76
|
-
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>>;
|
|
77
|
-
/** Allocation attempts, connection ids and handoff tokens come from the required `Crypto`. */
|
|
78
|
-
static layer(options: BrowserOptions): Layer.Layer<BrowserbaseBrowser, BrowserError, BrowserbaseClient | BrowserbaseSessions | Crypto.Crypto>;
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
|
-
export type { FileSelection, LiveView, SelectFilesRequest };
|
|
82
|
-
export {};
|
|
83
|
-
//# sourceMappingURL=Browser.d.mts.map
|
package/dist/Browser.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Context, Layer } from "effect";
|
|
2
|
-
import * as BrowserRuntime from "effect-browser/browser-runtime";
|
|
3
|
-
//#region src/BrowserBinding.d.ts
|
|
4
|
-
export type BrowserBinding = BrowserRuntime.BrowserBinding;
|
|
5
|
-
export type PlaywrightOptions = BrowserRuntime.PlaywrightOptions;
|
|
6
|
-
/** Validate provider authority before invoking any trusted host routing. */
|
|
7
|
-
export declare const playwright: (options?: PlaywrightOptions) => BrowserBinding;
|
|
8
|
-
export declare const BrowserbaseBrowserBinding: Context.Reference<BrowserRuntime.BrowserBinding>;
|
|
9
|
-
export declare const layer: (binding: BrowserBinding) => Layer.Layer<never>;
|
|
10
|
-
export declare const layerPlaywright: Layer.Layer<never>;
|
|
11
|
-
//#endregion
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=BrowserBinding.d.mts.map
|
package/dist/BrowserBinding.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
|
29
|
-
export { BrowserbaseBrowserBinding, layer, layerPlaywright, playwright };
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=BrowserBinding.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,34 +0,0 @@
|
|
|
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
DELETED
package/dist/Certificates.mjs
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { Identifier } from "./References.mjs";
|
|
2
|
-
import { CertificateError } from "./Errors.mjs";
|
|
3
|
-
import { r as span, t as BrowserbaseClient } from "./Client-BEC4Q8ZS.mjs";
|
|
4
|
-
import { SafeFilename } from "./Transfers.mjs";
|
|
5
|
-
import { t as resource } from "./Resource-J7Kkk5mu.mjs";
|
|
6
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
7
|
-
//#region src/Certificates.ts
|
|
8
|
-
const Timestamp = Schema.String.check(Schema.isMaxLength(64));
|
|
9
|
-
const MAX_CERTIFICATE_BYTES = 1048576;
|
|
10
|
-
/** Select a certificate at launch with `provider.proxySettings.caCertificates: [certificateId]`. */
|
|
11
|
-
var CertificateMetadata = class extends Schema.Class("BrowserbaseCertificateMetadata")({
|
|
12
|
-
certificateId: Identifier,
|
|
13
|
-
projectId: Identifier,
|
|
14
|
-
createdAt: Timestamp,
|
|
15
|
-
updatedAt: Timestamp
|
|
16
|
-
}) {};
|
|
17
|
-
const Upload = Schema.Struct({
|
|
18
|
-
filename: Schema.optionalKey(SafeFilename),
|
|
19
|
-
maxBytes: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
20
|
-
minimum: 1,
|
|
21
|
-
maximum: MAX_CERTIFICATE_BYTES
|
|
22
|
-
}))),
|
|
23
|
-
timeoutMillis: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
24
|
-
minimum: 1,
|
|
25
|
-
maximum: 6e5
|
|
26
|
-
})))
|
|
27
|
-
});
|
|
28
|
-
const ProviderCertificate = Schema.Struct({
|
|
29
|
-
id: Identifier,
|
|
30
|
-
projectId: Identifier,
|
|
31
|
-
createdAt: Timestamp,
|
|
32
|
-
updatedAt: Timestamp
|
|
33
|
-
});
|
|
34
|
-
/** Proxy CA certificates. Registration is one bounded multipart mutation, never retried. */
|
|
35
|
-
var BrowserbaseCertificates = class BrowserbaseCertificates extends Context.Service()("effect-browserbase/Certificates") {
|
|
36
|
-
static layer = Layer.effect(BrowserbaseCertificates, Effect.gen(function* () {
|
|
37
|
-
const client = yield* BrowserbaseClient;
|
|
38
|
-
const api = resource(client, (failure) => CertificateError.make(failure));
|
|
39
|
-
const own = (operation, mutation) => Effect.fnUntraced(function* (value) {
|
|
40
|
-
if (value.projectId !== client.projectId) return yield* api.malformed(operation, mutation);
|
|
41
|
-
const { id, ...rest } = value;
|
|
42
|
-
return CertificateMetadata.make({
|
|
43
|
-
certificateId: id,
|
|
44
|
-
...rest
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
const create = Effect.fnUntraced(function* (upload) {
|
|
48
|
-
const { bytes, ...options } = upload;
|
|
49
|
-
const value = yield* api.input(Upload, options, "certificate-create");
|
|
50
|
-
const owned = new Uint8Array(bytes);
|
|
51
|
-
const raw = yield* client.upload("/v1/certificates", {
|
|
52
|
-
field: "file",
|
|
53
|
-
filename: value.filename ?? "certificate.pem",
|
|
54
|
-
mediaType: "application/x-pem-file",
|
|
55
|
-
bytes: owned
|
|
56
|
-
}, {
|
|
57
|
-
maxBytes: value.maxBytes ?? 65536,
|
|
58
|
-
...value.timeoutMillis === void 0 ? {} : { timeoutMillis: value.timeoutMillis }
|
|
59
|
-
}).pipe(Effect.mapError(api.fromClient("certificate-create")));
|
|
60
|
-
const created = yield* Schema.decodeUnknownEffect(ProviderCertificate)(raw).pipe(Effect.mapError(() => api.malformed("certificate-create", true)));
|
|
61
|
-
return yield* own("certificate-create", true)(created);
|
|
62
|
-
}, span("BrowserbaseCertificates.create"));
|
|
63
|
-
const list = api.request("GET", "/v1/certificates", Schema.Array(ProviderCertificate).check(Schema.isMaxLength(1024)), "certificate-list").pipe(Effect.flatMap(Effect.forEach(own("certificate-list", false))), span("BrowserbaseCertificates.list"));
|
|
64
|
-
const retrieve = Effect.fnUntraced(function* (certificateId) {
|
|
65
|
-
const id = yield* api.input(Identifier, certificateId, "certificate-retrieve");
|
|
66
|
-
const value = yield* api.request("GET", `/v1/certificates/${api.segment(id)}`, ProviderCertificate, "certificate-retrieve");
|
|
67
|
-
if (value.id !== id) return yield* api.malformed("certificate-retrieve", false);
|
|
68
|
-
return yield* own("certificate-retrieve", false)(value);
|
|
69
|
-
}, span("BrowserbaseCertificates.retrieve"));
|
|
70
|
-
const remove = Effect.fnUntraced(function* (certificateId) {
|
|
71
|
-
const id = yield* api.input(Identifier, certificateId, "certificate-delete");
|
|
72
|
-
yield* api.remove(`/v1/certificates/${api.segment(id)}`, "certificate-delete");
|
|
73
|
-
}, span("BrowserbaseCertificates.delete"));
|
|
74
|
-
return BrowserbaseCertificates.of({
|
|
75
|
-
create,
|
|
76
|
-
list,
|
|
77
|
-
retrieve,
|
|
78
|
-
delete: remove
|
|
79
|
-
});
|
|
80
|
-
}));
|
|
81
|
-
};
|
|
82
|
-
//#endregion
|
|
83
|
-
export { BrowserbaseCertificates, CertificateMetadata };
|
|
84
|
-
|
|
85
|
-
//# sourceMappingURL=Certificates.mjs.map
|