effect-browserbase 0.2.0-beta.9 → 0.3.0-beta.6
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 +252 -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 +136 -0
- package/dist/testing/index.mjs +440 -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 +509 -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
package/dist/Search.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Search.mjs","names":["Trace.span"],"sources":["../src/Search.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport { PlatformError } from \"./Errors.ts\";\nimport { resource } from \"./internal/http/Resource.ts\";\nimport * as Trace from \"./internal/Trace.ts\";\n\nconst Text = Schema.String.check(Schema.isMaxLength(16_384));\n\nexport const SearchQuery = Schema.Struct({\n query: Schema.NonEmptyString.check(Schema.isMaxLength(2048)),\n /** 1–25; the provider defaults to 10. */\n numResults: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 25 }))),\n});\n\nexport type SearchQuery = typeof SearchQuery.Type;\n\nexport class SearchResult extends Schema.Class<SearchResult>(\"BrowserbaseSearchResult\")({\n id: Text,\n url: Text,\n title: Text,\n author: Schema.optionalKey(Text),\n publishedDate: Schema.optionalKey(Text),\n image: Schema.optionalKey(Text),\n favicon: Schema.optionalKey(Text),\n}) {}\n\nexport class SearchResults extends Schema.Class<SearchResults>(\"BrowserbaseSearchResults\")({\n requestId: Text,\n query: Text,\n results: Schema.Array(SearchResult).check(Schema.isMaxLength(25)),\n}) {}\n\n/** Browserbase web search. The POST is never retried; billing of each outcome is provider-owned. */\nexport class BrowserbaseSearch extends Context.Service<\n BrowserbaseSearch,\n {\n readonly web: (query: SearchQuery) => Effect.Effect<SearchResults, PlatformError>;\n }\n>()(\"effect-browserbase/Search\") {\n static readonly layer: Layer.Layer<BrowserbaseSearch, never, BrowserbaseClient> = Layer.effect(\n BrowserbaseSearch,\n Effect.gen(function* () {\n const api = resource<PlatformError>(yield* BrowserbaseClient, (failure) =>\n PlatformError.make({ ...failure, service: \"search\" }),\n );\n\n const web = Effect.fnUntraced(function* (query: SearchQuery) {\n const value = yield* api.input(SearchQuery, query, \"search-web\");\n\n return yield* api.request(\"POST\", \"/v1/search\", SearchResults, \"search-web\", value);\n }, Trace.span(\"BrowserbaseSearch.web\"));\n\n return BrowserbaseSearch.of({ web });\n }),\n );\n}\n"],"mappings":";;;;;AAOA,MAAM,OAAO,OAAO,OAAO,MAAM,OAAO,YAAY,KAAM,CAAC;AAE3D,MAAa,cAAc,OAAO,OAAO;CACvC,OAAO,OAAO,eAAe,MAAM,OAAO,YAAY,IAAI,CAAC;;CAE3D,YAAY,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAG,CAAC,CAAC,CAAC;AAChG,CAAC;AAID,IAAa,eAAb,cAAkC,OAAO,MAAoB,yBAAyB,CAAC,CAAC;CACtF,IAAI;CACJ,KAAK;CACL,OAAO;CACP,QAAQ,OAAO,YAAY,IAAI;CAC/B,eAAe,OAAO,YAAY,IAAI;CACtC,OAAO,OAAO,YAAY,IAAI;CAC9B,SAAS,OAAO,YAAY,IAAI;AAClC,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,gBAAb,cAAmC,OAAO,MAAqB,0BAA0B,CAAC,CAAC;CACzF,WAAW;CACX,OAAO;CACP,SAAS,OAAO,MAAM,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,EAAE,CAAC;AAClE,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,oBAAb,MAAa,0BAA0B,QAAQ,QAK7C,CAAC,CAAC,2BAA2B,CAAC,CAAC;CAC/B,OAAgB,QAAkE,MAAM,OACtF,mBACA,OAAO,IAAI,aAAa;EACtB,MAAM,MAAM,SAAwB,OAAO,oBAAoB,YAC7D,cAAc,KAAK;GAAE,GAAG;GAAS,SAAS;EAAS,CAAC,CACtD;EAEA,MAAM,MAAM,OAAO,WAAW,WAAW,OAAoB;GAC3D,MAAM,QAAQ,OAAO,IAAI,MAAM,aAAa,OAAO,YAAY;GAE/D,OAAO,OAAO,IAAI,QAAQ,QAAQ,cAAc,eAAe,cAAc,KAAK;EACpF,GAAGA,KAAW,uBAAuB,CAAC;EAEtC,OAAO,kBAAkB,GAAG,EAAE,IAAI,CAAC;CACrC,CAAC,CACH;AACF"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { a as SessionReference } from "./References-DOH3Wu44.mjs";
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
//#region src/SessionData.d.ts
|
|
4
|
-
declare const SessionStatus: Schema.Literals<readonly ["PENDING", "RUNNING", "ERROR", "TIMED_OUT", "COMPLETED"]>;
|
|
5
|
-
type SessionStatus = typeof SessionStatus.Type;
|
|
6
|
-
declare const isTerminalSessionStatus: (status: SessionStatus) => boolean;
|
|
7
|
-
declare const ProviderSession: Schema.Struct<{
|
|
8
|
-
readonly id: Schema.NonEmptyString;
|
|
9
|
-
readonly projectId: Schema.NonEmptyString;
|
|
10
|
-
readonly status: Schema.Literals<readonly ["PENDING", "RUNNING", "ERROR", "TIMED_OUT", "COMPLETED"]>;
|
|
11
|
-
readonly createdAt: Schema.String;
|
|
12
|
-
readonly updatedAt: Schema.String;
|
|
13
|
-
readonly expiresAt: Schema.String;
|
|
14
|
-
readonly startedAt: Schema.String;
|
|
15
|
-
readonly endedAt: Schema.optionalKey<Schema.String>;
|
|
16
|
-
readonly keepAlive: Schema.Boolean;
|
|
17
|
-
readonly proxyBytes: Schema.Finite;
|
|
18
|
-
readonly region: Schema.Literals<readonly ["us-west-2", "us-east-1", "eu-central-1", "ap-southeast-1"]>;
|
|
19
|
-
readonly contextId: Schema.optionalKey<Schema.NonEmptyString>;
|
|
20
|
-
}>;
|
|
21
|
-
declare const SessionMetadata_base: Schema.Class<SessionMetadata, Schema.Struct<{
|
|
22
|
-
readonly reference: typeof SessionReference;
|
|
23
|
-
readonly status: Schema.Literals<readonly ["PENDING", "RUNNING", "ERROR", "TIMED_OUT", "COMPLETED"]>;
|
|
24
|
-
readonly createdAt: Schema.String;
|
|
25
|
-
readonly updatedAt: Schema.String;
|
|
26
|
-
readonly expiresAt: Schema.String;
|
|
27
|
-
readonly startedAt: Schema.String;
|
|
28
|
-
readonly endedAt: Schema.optionalKey<Schema.String>;
|
|
29
|
-
readonly keepAlive: Schema.Boolean;
|
|
30
|
-
readonly proxyBytes: Schema.Finite;
|
|
31
|
-
readonly region: Schema.Literals<readonly ["us-west-2", "us-east-1", "eu-central-1", "ap-southeast-1"]>;
|
|
32
|
-
readonly contextId: Schema.optionalKey<Schema.NonEmptyString>;
|
|
33
|
-
}>, {}>;
|
|
34
|
-
declare class SessionMetadata extends SessionMetadata_base {}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { isTerminalSessionStatus as i, SessionMetadata as n, SessionStatus as r, ProviderSession as t };
|
|
37
|
-
export {};
|
|
38
|
-
//# sourceMappingURL=SessionData-5xYZDshJ.d.mts.map
|
package/dist/SessionData.d.mts
DELETED
package/dist/SessionData.mjs
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Identifier, SessionReference } from "./References.mjs";
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
//#region src/SessionData.ts
|
|
4
|
-
const SessionStatus = Schema.Literals([
|
|
5
|
-
"PENDING",
|
|
6
|
-
"RUNNING",
|
|
7
|
-
"ERROR",
|
|
8
|
-
"TIMED_OUT",
|
|
9
|
-
"COMPLETED"
|
|
10
|
-
]);
|
|
11
|
-
const isTerminalSessionStatus = (status) => status === "COMPLETED" || status === "ERROR" || status === "TIMED_OUT";
|
|
12
|
-
const Timestamp = Schema.String.check(Schema.isMaxLength(64));
|
|
13
|
-
const ProviderSession = Schema.Struct({
|
|
14
|
-
id: Identifier,
|
|
15
|
-
projectId: Identifier,
|
|
16
|
-
status: SessionStatus,
|
|
17
|
-
createdAt: Timestamp,
|
|
18
|
-
updatedAt: Timestamp,
|
|
19
|
-
expiresAt: Timestamp,
|
|
20
|
-
startedAt: Timestamp,
|
|
21
|
-
endedAt: Schema.optionalKey(Timestamp),
|
|
22
|
-
keepAlive: Schema.Boolean,
|
|
23
|
-
proxyBytes: Schema.Finite,
|
|
24
|
-
region: Schema.Literals([
|
|
25
|
-
"us-west-2",
|
|
26
|
-
"us-east-1",
|
|
27
|
-
"eu-central-1",
|
|
28
|
-
"ap-southeast-1"
|
|
29
|
-
]),
|
|
30
|
-
contextId: Schema.optionalKey(Identifier)
|
|
31
|
-
});
|
|
32
|
-
var SessionMetadata = class extends Schema.Class("BrowserbaseSessionMetadata")({
|
|
33
|
-
reference: SessionReference,
|
|
34
|
-
status: SessionStatus,
|
|
35
|
-
createdAt: Timestamp,
|
|
36
|
-
updatedAt: Timestamp,
|
|
37
|
-
expiresAt: Timestamp,
|
|
38
|
-
startedAt: Timestamp,
|
|
39
|
-
endedAt: Schema.optionalKey(Timestamp),
|
|
40
|
-
keepAlive: Schema.Boolean,
|
|
41
|
-
proxyBytes: Schema.Finite,
|
|
42
|
-
region: ProviderSession.fields.region,
|
|
43
|
-
contextId: Schema.optionalKey(Identifier)
|
|
44
|
-
}) {};
|
|
45
|
-
//#endregion
|
|
46
|
-
export { ProviderSession, SessionMetadata, SessionStatus, isTerminalSessionStatus };
|
|
47
|
-
|
|
48
|
-
//# sourceMappingURL=SessionData.mjs.map
|
package/dist/SessionData.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SessionData.mjs","names":[],"sources":["../src/SessionData.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport { Identifier, SessionReference } from \"./References.ts\";\n\nexport const SessionStatus = Schema.Literals([\n \"PENDING\",\n \"RUNNING\",\n \"ERROR\",\n \"TIMED_OUT\",\n \"COMPLETED\",\n]);\n\nexport type SessionStatus = typeof SessionStatus.Type;\n\nexport const isTerminalSessionStatus = (status: SessionStatus): boolean =>\n status === \"COMPLETED\" || status === \"ERROR\" || status === \"TIMED_OUT\";\n\nconst Timestamp = Schema.String.check(Schema.isMaxLength(64));\n\nexport const ProviderSession = Schema.Struct({\n id: Identifier,\n projectId: Identifier,\n status: SessionStatus,\n createdAt: Timestamp,\n updatedAt: Timestamp,\n expiresAt: Timestamp,\n startedAt: Timestamp,\n endedAt: Schema.optionalKey(Timestamp),\n keepAlive: Schema.Boolean,\n proxyBytes: Schema.Finite,\n region: Schema.Literals([\"us-west-2\", \"us-east-1\", \"eu-central-1\", \"ap-southeast-1\"]),\n contextId: Schema.optionalKey(Identifier),\n});\n\nexport class SessionMetadata extends Schema.Class<SessionMetadata>(\"BrowserbaseSessionMetadata\")({\n reference: SessionReference,\n status: SessionStatus,\n createdAt: Timestamp,\n updatedAt: Timestamp,\n expiresAt: Timestamp,\n startedAt: Timestamp,\n endedAt: Schema.optionalKey(Timestamp),\n keepAlive: Schema.Boolean,\n proxyBytes: Schema.Finite,\n region: ProviderSession.fields.region,\n contextId: Schema.optionalKey(Identifier),\n}) {}\n"],"mappings":";;;AAIA,MAAa,gBAAgB,OAAO,SAAS;CAC3C;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,MAAa,2BAA2B,WACtC,WAAW,eAAe,WAAW,WAAW,WAAW;AAE7D,MAAM,YAAY,OAAO,OAAO,MAAM,OAAO,YAAY,EAAE,CAAC;AAE5D,MAAa,kBAAkB,OAAO,OAAO;CAC3C,IAAI;CACJ,WAAW;CACX,QAAQ;CACR,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,SAAS,OAAO,YAAY,SAAS;CACrC,WAAW,OAAO;CAClB,YAAY,OAAO;CACnB,QAAQ,OAAO,SAAS;EAAC;EAAa;EAAa;EAAgB;CAAgB,CAAC;CACpF,WAAW,OAAO,YAAY,UAAU;AAC1C,CAAC;AAED,IAAa,kBAAb,cAAqC,OAAO,MAAuB,4BAA4B,CAAC,CAAC;CAC/F,WAAW;CACX,QAAQ;CACR,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,SAAS,OAAO,YAAY,SAAS;CACrC,WAAW,OAAO;CAClB,YAAY,OAAO;CACnB,QAAQ,gBAAgB,OAAO;CAC/B,WAAW,OAAO,YAAY,UAAU;AAC1C,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import { Identifier, SessionReference } from "./References.mjs";
|
|
2
|
-
import { ClientError, SessionError } from "./Errors.mjs";
|
|
3
|
-
import { r as span, t as BrowserbaseClient } from "./Client-BEC4Q8ZS.mjs";
|
|
4
|
-
import { ProviderSession, SessionMetadata, SessionStatus, isTerminalSessionStatus } from "./SessionData.mjs";
|
|
5
|
-
import { Clock, Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
6
|
-
import { BrowserError, Reasons } from "effect-browser/errors";
|
|
7
|
-
//#region src/internal/browser/RequestFailure.ts
|
|
8
|
-
/** Only control-plane reads reach this bridge, before a modeled browser action dispatches. */
|
|
9
|
-
const browserRequestFailure = (operation, error) => {
|
|
10
|
-
const reason = () => {
|
|
11
|
-
switch (error.reason) {
|
|
12
|
-
case "configuration": return Reasons.Configuration.make({});
|
|
13
|
-
case "authorization": return Reasons.Authorization.make({});
|
|
14
|
-
case "rate-limited": return Reasons.RateLimited.make(error.retryAfterMillis === void 0 ? {} : { retryAfterMillis: error.retryAfterMillis });
|
|
15
|
-
case "not-found": return Reasons.NotFound.make({});
|
|
16
|
-
case "active": return Reasons.Active.make({});
|
|
17
|
-
case "disabled": return Reasons.Disabled.make({});
|
|
18
|
-
case "expired": return Reasons.Expired.make({});
|
|
19
|
-
case "transport": return Reasons.Transport.make(error.status === void 0 ? {} : { status: error.status });
|
|
20
|
-
case "timeout": return Reasons.Timeout.make({});
|
|
21
|
-
case "malformed": return Reasons.Malformed.make({});
|
|
22
|
-
case "unsafe-url": return Reasons.UnsafeUrl.make({});
|
|
23
|
-
case "content-type": return Reasons.ContentType.make({});
|
|
24
|
-
case "limit":
|
|
25
|
-
case "provider": return Reasons.Provider.make(error.status === void 0 ? {} : { status: error.status });
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
return BrowserError.make({
|
|
29
|
-
operation,
|
|
30
|
-
reason: reason(),
|
|
31
|
-
outcome: error.outcome ?? "undispatched"
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/internal/browser/LiveView.ts
|
|
36
|
-
const LiveUrl = Schema.String.check(Schema.isMaxLength(16384), Schema.makeFilter((value) => {
|
|
37
|
-
try {
|
|
38
|
-
const url = new URL(value);
|
|
39
|
-
return url.protocol === "https:" && !url.username && !url.password && (url.hostname === "browserbase.com" || url.hostname.endsWith(".browserbase.com"));
|
|
40
|
-
} catch {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}));
|
|
44
|
-
const Live = Schema.Struct({
|
|
45
|
-
debuggerFullscreenUrl: LiveUrl,
|
|
46
|
-
pages: Schema.Array(Schema.Struct({
|
|
47
|
-
id: Identifier,
|
|
48
|
-
debuggerFullscreenUrl: LiveUrl
|
|
49
|
-
})).check(Schema.isMaxLength(64))
|
|
50
|
-
});
|
|
51
|
-
/**
|
|
52
|
-
* These URLs are bearer capabilities: issuing one is an authorization step, not proof that an
|
|
53
|
-
* operator took control. Redaction keeps them out of ordinary logs and model-facing values.
|
|
54
|
-
*/
|
|
55
|
-
const issueLiveUrls = Effect.fnUntraced(function* (client, reference, expiresInSeconds) {
|
|
56
|
-
if (!Number.isSafeInteger(expiresInSeconds) || expiresInSeconds < 1 || expiresInSeconds > 21600) return yield* ClientError.make({
|
|
57
|
-
operation: "provider-read",
|
|
58
|
-
reason: "configuration",
|
|
59
|
-
outcome: "undispatched"
|
|
60
|
-
});
|
|
61
|
-
if (reference.projectId !== client.projectId) return yield* ClientError.make({
|
|
62
|
-
operation: "provider-read",
|
|
63
|
-
reason: "authorization",
|
|
64
|
-
outcome: "undispatched"
|
|
65
|
-
});
|
|
66
|
-
const raw = yield* client.json("GET", `/v1/sessions/${encodeURIComponent(reference.sessionId)}/debug?expiresIn=${expiresInSeconds}`);
|
|
67
|
-
const value = yield* Schema.decodeUnknownEffect(Live)(raw).pipe(Effect.mapError(() => ClientError.make({
|
|
68
|
-
operation: "provider-read",
|
|
69
|
-
reason: "malformed"
|
|
70
|
-
})));
|
|
71
|
-
return {
|
|
72
|
-
session: Redacted.make(value.debuggerFullscreenUrl),
|
|
73
|
-
pages: value.pages.map((page) => ({
|
|
74
|
-
liveViewPageId: page.id,
|
|
75
|
-
url: Redacted.make(page.debuggerFullscreenUrl)
|
|
76
|
-
})),
|
|
77
|
-
requestedTtlSeconds: expiresInSeconds
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
const issueLiveView = (client, reference, expiresInSeconds) => issueLiveUrls(client, reference, expiresInSeconds).pipe(Effect.mapError((error) => browserRequestFailure("live-view", error)));
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/Sessions.ts
|
|
83
|
-
const SessionListQuery = Schema.Struct({
|
|
84
|
-
status: Schema.optionalKey(SessionStatus),
|
|
85
|
-
q: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(2048)))
|
|
86
|
-
});
|
|
87
|
-
const SessionWaitOptions = Schema.Struct({
|
|
88
|
-
timeoutMillis: Schema.Int.check(Schema.isBetween({
|
|
89
|
-
minimum: 1,
|
|
90
|
-
maximum: 6e5
|
|
91
|
-
})),
|
|
92
|
-
pollIntervalMillis: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
93
|
-
minimum: 25,
|
|
94
|
-
maximum: 5e3
|
|
95
|
-
})))
|
|
96
|
-
});
|
|
97
|
-
const Millis = Schema.Finite;
|
|
98
|
-
/**
|
|
99
|
-
* One CDP-level log entry. Protocol payloads are present only when requested: they carry
|
|
100
|
-
* page content, cookies and typed input, so they are host evidence, never model input.
|
|
101
|
-
*/
|
|
102
|
-
var SessionLogEntry = class extends Schema.Class("BrowserbaseSessionLogEntry")({
|
|
103
|
-
method: Schema.String.check(Schema.isMaxLength(256)),
|
|
104
|
-
pageId: Schema.Int,
|
|
105
|
-
frameId: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(256))),
|
|
106
|
-
loaderId: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(256))),
|
|
107
|
-
timestamp: Schema.optionalKey(Millis),
|
|
108
|
-
requestTimestamp: Schema.optionalKey(Millis),
|
|
109
|
-
responseTimestamp: Schema.optionalKey(Millis),
|
|
110
|
-
params: Schema.optionalKey(Schema.Json),
|
|
111
|
-
result: Schema.optionalKey(Schema.Json)
|
|
112
|
-
}) {};
|
|
113
|
-
const ProviderLog = Schema.Struct({
|
|
114
|
-
method: SessionLogEntry.fields.method,
|
|
115
|
-
pageId: Schema.Int,
|
|
116
|
-
sessionId: Schema.String,
|
|
117
|
-
frameId: SessionLogEntry.fields.frameId,
|
|
118
|
-
loaderId: SessionLogEntry.fields.loaderId,
|
|
119
|
-
timestamp: Schema.optionalKey(Millis),
|
|
120
|
-
request: Schema.optionalKey(Schema.Struct({
|
|
121
|
-
params: Schema.optionalKey(Schema.Json),
|
|
122
|
-
timestamp: Schema.optionalKey(Millis)
|
|
123
|
-
})),
|
|
124
|
-
response: Schema.optionalKey(Schema.Struct({
|
|
125
|
-
result: Schema.optionalKey(Schema.Json),
|
|
126
|
-
timestamp: Schema.optionalKey(Millis)
|
|
127
|
-
}))
|
|
128
|
-
});
|
|
129
|
-
const now = Clock.monotonicTimeNanos.pipe(Effect.map((value) => Number(value) / 1e6));
|
|
130
|
-
const fromClient = (operation, error) => SessionError.make({
|
|
131
|
-
operation,
|
|
132
|
-
reason: error.reason,
|
|
133
|
-
...error.outcome === void 0 ? {} : { outcome: error.outcome },
|
|
134
|
-
...error.status === void 0 ? {} : { status: error.status },
|
|
135
|
-
...error.retryAfterMillis === void 0 ? {} : { retryAfterMillis: error.retryAfterMillis }
|
|
136
|
-
});
|
|
137
|
-
const malformed = (operation, mutation = false) => SessionError.make({
|
|
138
|
-
operation,
|
|
139
|
-
reason: "malformed",
|
|
140
|
-
...mutation ? { outcome: "unknown" } : {}
|
|
141
|
-
});
|
|
142
|
-
const configuration = (operation) => SessionError.make({
|
|
143
|
-
operation,
|
|
144
|
-
reason: "configuration",
|
|
145
|
-
outcome: "undispatched"
|
|
146
|
-
});
|
|
147
|
-
/** Passive inspection never releases a remote session. Release is a separate explicit mutation. */
|
|
148
|
-
var BrowserbaseSessions = class BrowserbaseSessions extends Context.Service()("effect-browserbase/Sessions") {
|
|
149
|
-
static layer = Layer.effect(BrowserbaseSessions, Effect.gen(function* () {
|
|
150
|
-
const client = yield* BrowserbaseClient;
|
|
151
|
-
const validate = Effect.fnUntraced(function* (reference, operation) {
|
|
152
|
-
const ref = yield* Schema.decodeEffect(SessionReference)(reference, { onExcessProperty: "error" }).pipe(Effect.mapError(() => configuration(operation)));
|
|
153
|
-
if (ref.projectId !== client.projectId) return yield* SessionError.make({
|
|
154
|
-
operation,
|
|
155
|
-
reason: "authorization",
|
|
156
|
-
outcome: "undispatched"
|
|
157
|
-
});
|
|
158
|
-
return ref;
|
|
159
|
-
});
|
|
160
|
-
const decode = Effect.fnUntraced(function* (raw, operation, expected, mutation = false) {
|
|
161
|
-
const value = yield* Schema.decodeUnknownEffect(ProviderSession)(raw).pipe(Effect.mapError(() => malformed(operation, mutation)));
|
|
162
|
-
if (value.projectId !== client.projectId || expected !== void 0 && (value.id !== expected.sessionId || value.projectId !== expected.projectId)) return yield* malformed(operation, mutation);
|
|
163
|
-
const { id, projectId, ...metadata } = value;
|
|
164
|
-
return SessionMetadata.make({
|
|
165
|
-
reference: SessionReference.make({
|
|
166
|
-
provider: "browserbase",
|
|
167
|
-
projectId,
|
|
168
|
-
sessionId: id
|
|
169
|
-
}),
|
|
170
|
-
...metadata
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
const read = Effect.fnUntraced(function* (reference, deadline) {
|
|
174
|
-
const ref = yield* validate(reference, "session-retrieve");
|
|
175
|
-
const raw = yield* client.json("GET", `/v1/sessions/${encodeURIComponent(ref.sessionId)}`, void 0, deadline).pipe(Effect.mapError((error) => fromClient("session-retrieve", error)));
|
|
176
|
-
return yield* decode(raw, "session-retrieve", ref);
|
|
177
|
-
});
|
|
178
|
-
const retrieve = Effect.fnUntraced(function* (reference) {
|
|
179
|
-
return yield* read(reference);
|
|
180
|
-
}, span("BrowserbaseSessions.retrieve"));
|
|
181
|
-
const list = Effect.fnUntraced(function* (query = {}) {
|
|
182
|
-
const checked = yield* Schema.decodeEffect(SessionListQuery)(query, { onExcessProperty: "error" }).pipe(Effect.mapError(() => configuration("session-list")));
|
|
183
|
-
const search = new URLSearchParams();
|
|
184
|
-
if (checked.status !== void 0) search.set("status", checked.status);
|
|
185
|
-
if (checked.q !== void 0) search.set("q", checked.q);
|
|
186
|
-
const raw = yield* client.json("GET", `/v1/sessions${search.size === 0 ? "" : `?${search}`}`).pipe(Effect.mapError((error) => fromClient("session-list", error)));
|
|
187
|
-
const rows = yield* Schema.decodeUnknownEffect(Schema.Array(ProviderSession).check(Schema.isMaxLength(1024)))(raw).pipe(Effect.mapError(() => malformed("session-list")));
|
|
188
|
-
if (new Set(rows.map((row) => row.id)).size !== rows.length) return yield* malformed("session-list");
|
|
189
|
-
const output = [];
|
|
190
|
-
for (const row of rows) output.push(yield* decode(row, "session-list"));
|
|
191
|
-
return output;
|
|
192
|
-
}, span("BrowserbaseSessions.list"));
|
|
193
|
-
const requestRelease = Effect.fnUntraced(function* (reference) {
|
|
194
|
-
const ref = yield* validate(reference, "session-release");
|
|
195
|
-
const raw = yield* client.json("POST", `/v1/sessions/${encodeURIComponent(ref.sessionId)}`, {
|
|
196
|
-
projectId: ref.projectId,
|
|
197
|
-
status: "REQUEST_RELEASE"
|
|
198
|
-
}).pipe(Effect.mapError((error) => fromClient("session-release", error)));
|
|
199
|
-
return yield* decode(raw, "session-release", ref, true);
|
|
200
|
-
}, span("BrowserbaseSessions.requestRelease"));
|
|
201
|
-
const wait = Effect.fnUntraced(function* (reference, options, untilRunning) {
|
|
202
|
-
const bounds = yield* Schema.decodeEffect(SessionWaitOptions)(options, { onExcessProperty: "error" }).pipe(Effect.mapError(() => configuration("session-wait")));
|
|
203
|
-
const deadline = (yield* now) + bounds.timeoutMillis;
|
|
204
|
-
for (;;) {
|
|
205
|
-
const remaining = deadline - (yield* now);
|
|
206
|
-
if (remaining <= 0) return yield* SessionError.make({
|
|
207
|
-
operation: "session-wait",
|
|
208
|
-
reason: "timeout"
|
|
209
|
-
});
|
|
210
|
-
const metadata = yield* read(reference, deadline).pipe(Effect.withTracerEnabled(false), Effect.timeoutOrElse({
|
|
211
|
-
duration: remaining,
|
|
212
|
-
orElse: () => Effect.fail(SessionError.make({
|
|
213
|
-
operation: "session-wait",
|
|
214
|
-
reason: "timeout"
|
|
215
|
-
}))
|
|
216
|
-
}));
|
|
217
|
-
if (untilRunning ? metadata.status === "RUNNING" : isTerminalSessionStatus(metadata.status)) return metadata;
|
|
218
|
-
if (untilRunning && isTerminalSessionStatus(metadata.status)) return yield* SessionError.make({
|
|
219
|
-
operation: "session-wait",
|
|
220
|
-
reason: "expired"
|
|
221
|
-
});
|
|
222
|
-
yield* Effect.sleep(Math.max(0, Math.min(bounds.pollIntervalMillis ?? 250, deadline - (yield* now))));
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
const logs = Effect.fnUntraced(function* (reference, options = {}) {
|
|
226
|
-
const ref = yield* validate(reference, "session-logs");
|
|
227
|
-
const raw = yield* client.json("GET", `/v1/sessions/${encodeURIComponent(ref.sessionId)}/logs`).pipe(Effect.mapError((error) => fromClient("session-logs", error)));
|
|
228
|
-
const rows = yield* Schema.decodeUnknownEffect(Schema.Array(ProviderLog).check(Schema.isMaxLength(1e5)))(raw).pipe(Effect.mapError(() => malformed("session-logs")));
|
|
229
|
-
if (rows.some((row) => row.sessionId !== ref.sessionId)) return yield* malformed("session-logs");
|
|
230
|
-
return rows.map((row) => SessionLogEntry.make({
|
|
231
|
-
method: row.method,
|
|
232
|
-
pageId: row.pageId,
|
|
233
|
-
...row.frameId === void 0 ? {} : { frameId: row.frameId },
|
|
234
|
-
...row.loaderId === void 0 ? {} : { loaderId: row.loaderId },
|
|
235
|
-
...row.timestamp === void 0 ? {} : { timestamp: row.timestamp },
|
|
236
|
-
...row.request?.timestamp === void 0 ? {} : { requestTimestamp: row.request.timestamp },
|
|
237
|
-
...row.response?.timestamp === void 0 ? {} : { responseTimestamp: row.response.timestamp },
|
|
238
|
-
...options.includePayloads === true && row.request?.params !== void 0 ? { params: row.request.params } : {},
|
|
239
|
-
...options.includePayloads === true && row.response?.result !== void 0 ? { result: row.response.result } : {}
|
|
240
|
-
}));
|
|
241
|
-
}, span("BrowserbaseSessions.logs"));
|
|
242
|
-
const liveUrls = Effect.fnUntraced(function* (reference, expiresInSeconds = 300) {
|
|
243
|
-
const ref = yield* validate(reference, "session-live-view");
|
|
244
|
-
return yield* issueLiveUrls(client, ref, expiresInSeconds).pipe(Effect.mapError((error) => fromClient("session-live-view", error)));
|
|
245
|
-
}, span("BrowserbaseSessions.liveUrls"));
|
|
246
|
-
return BrowserbaseSessions.of({
|
|
247
|
-
logs,
|
|
248
|
-
liveUrls,
|
|
249
|
-
retrieve,
|
|
250
|
-
list,
|
|
251
|
-
requestRelease,
|
|
252
|
-
waitForTerminal: (ref, options) => wait(ref, options, false).pipe(span("BrowserbaseSessions.waitForTerminal")),
|
|
253
|
-
waitUntilRunning: (ref, options) => wait(ref, options, true).pipe(span("BrowserbaseSessions.waitUntilRunning"))
|
|
254
|
-
});
|
|
255
|
-
}));
|
|
256
|
-
};
|
|
257
|
-
//#endregion
|
|
258
|
-
export { issueLiveView as a, SessionWaitOptions as i, SessionListQuery as n, browserRequestFailure as o, SessionLogEntry as r, BrowserbaseSessions as t };
|
|
259
|
-
|
|
260
|
-
//# sourceMappingURL=Sessions-D2H5m6rF.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Sessions-D2H5m6rF.mjs","names":["Trace.span"],"sources":["../src/internal/browser/RequestFailure.ts","../src/internal/browser/LiveView.ts","../src/Sessions.ts"],"sourcesContent":["import { BrowserError, Reasons, type BrowserReason } from \"effect-browser/errors\";\n\nimport type { ClientError } from \"../../Errors.ts\";\n\ntype RequestFailure = Pick<ClientError, \"reason\" | \"outcome\" | \"status\" | \"retryAfterMillis\">;\n\n/** Only control-plane reads reach this bridge, before a modeled browser action dispatches. */\nexport const browserRequestFailure = (\n operation: \"connect\" | \"reconnect\" | \"live-view\",\n error: RequestFailure,\n): BrowserError => {\n const reason = (): BrowserReason => {\n switch (error.reason) {\n case \"configuration\":\n return Reasons.Configuration.make({});\n case \"authorization\":\n return Reasons.Authorization.make({});\n case \"rate-limited\":\n return Reasons.RateLimited.make(\n error.retryAfterMillis === undefined ? {} : { retryAfterMillis: error.retryAfterMillis },\n );\n case \"not-found\":\n return Reasons.NotFound.make({});\n case \"active\":\n return Reasons.Active.make({});\n case \"disabled\":\n return Reasons.Disabled.make({});\n case \"expired\":\n return Reasons.Expired.make({});\n case \"transport\":\n return Reasons.Transport.make(error.status === undefined ? {} : { status: error.status });\n case \"timeout\":\n return Reasons.Timeout.make({});\n case \"malformed\":\n return Reasons.Malformed.make({});\n case \"unsafe-url\":\n return Reasons.UnsafeUrl.make({});\n case \"content-type\":\n return Reasons.ContentType.make({});\n // A control-plane limit carries no measured bound. Do not invent native Limit facts.\n case \"limit\":\n case \"provider\":\n return Reasons.Provider.make(error.status === undefined ? {} : { status: error.status });\n }\n };\n\n return BrowserError.make({\n operation,\n reason: reason(),\n outcome: error.outcome ?? \"undispatched\",\n });\n};\n","import { Effect, Redacted, Schema } from \"effect\";\n\nimport type { BrowserbaseClient } from \"../../Client.ts\";\nimport { ClientError } from \"../../Errors.ts\";\nimport { Identifier, type SessionReference } from \"../../References.ts\";\nimport { browserRequestFailure } from \"./RequestFailure.ts\";\n\nconst LiveUrl = Schema.String.check(\n Schema.isMaxLength(16384),\n Schema.makeFilter((value) => {\n try {\n const url = new URL(value);\n\n return (\n url.protocol === \"https:\" &&\n !url.username &&\n !url.password &&\n (url.hostname === \"browserbase.com\" || url.hostname.endsWith(\".browserbase.com\"))\n );\n } catch {\n return false;\n }\n }),\n);\n\nconst Live = Schema.Struct({\n debuggerFullscreenUrl: LiveUrl,\n pages: Schema.Array(Schema.Struct({ id: Identifier, debuggerFullscreenUrl: LiveUrl })).check(\n Schema.isMaxLength(64),\n ),\n});\n\nexport interface LiveView {\n readonly session: Redacted.Redacted<string>;\n readonly pages: ReadonlyArray<{\n readonly liveViewPageId: string;\n readonly url: Redacted.Redacted<string>;\n }>;\n /** Echo of the requested TTL, not a provider-confirmed expiration time. */\n readonly requestedTtlSeconds: number;\n}\n\n/**\n * These URLs are bearer capabilities: issuing one is an authorization step, not proof that an\n * operator took control. Redaction keeps them out of ordinary logs and model-facing values.\n */\nexport const issueLiveUrls = Effect.fnUntraced(function* (\n client: BrowserbaseClient[\"Service\"],\n reference: SessionReference,\n expiresInSeconds: number,\n) {\n // The pinned SDK documents an optional `expiresIn` with a 21,600 second maximum, but neither\n // it nor the published debug-route schema specifies a provider minimum. One second is this\n // adapter's positive-integer input bound, not a claim that Browserbase will accept or honor it.\n if (!Number.isSafeInteger(expiresInSeconds) || expiresInSeconds < 1 || expiresInSeconds > 21600)\n return yield* ClientError.make({\n operation: \"provider-read\",\n reason: \"configuration\",\n outcome: \"undispatched\",\n });\n if (reference.projectId !== client.projectId)\n return yield* ClientError.make({\n operation: \"provider-read\",\n reason: \"authorization\",\n outcome: \"undispatched\",\n });\n\n const raw = yield* client.json(\n \"GET\",\n `/v1/sessions/${encodeURIComponent(reference.sessionId)}/debug?expiresIn=${expiresInSeconds}`,\n );\n\n const value = yield* Schema.decodeUnknownEffect(Live)(raw).pipe(\n Effect.mapError(() => ClientError.make({ operation: \"provider-read\", reason: \"malformed\" })),\n );\n\n return {\n session: Redacted.make(value.debuggerFullscreenUrl),\n pages: value.pages.map((page) => ({\n liveViewPageId: page.id,\n url: Redacted.make(page.debuggerFullscreenUrl),\n })),\n requestedTtlSeconds: expiresInSeconds,\n } satisfies LiveView;\n});\n\nexport const issueLiveView = (\n client: BrowserbaseClient[\"Service\"],\n reference: SessionReference,\n expiresInSeconds: number,\n) =>\n issueLiveUrls(client, reference, expiresInSeconds).pipe(\n Effect.mapError((error) => browserRequestFailure(\"live-view\", error)),\n );\n","import { Clock, Context, Effect, Layer, Schema } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport { type ClientError, SessionError } from \"./Errors.ts\";\nimport { issueLiveUrls, type LiveView } from \"./internal/browser/LiveView.ts\";\nimport * as Trace from \"./internal/Trace.ts\";\nexport type { LiveView } from \"./internal/browser/LiveView.ts\";\nimport { SessionReference } from \"./References.ts\";\nimport {\n ProviderSession,\n SessionMetadata,\n SessionStatus,\n isTerminalSessionStatus,\n} from \"./SessionData.ts\";\nexport { SessionMetadata, SessionStatus, isTerminalSessionStatus } from \"./SessionData.ts\";\n\nexport const SessionListQuery = Schema.Struct({\n status: Schema.optionalKey(SessionStatus),\n q: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(2048))),\n});\n\nexport type SessionListQuery = typeof SessionListQuery.Type;\n\nexport const SessionWaitOptions = Schema.Struct({\n timeoutMillis: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 600000 })),\n pollIntervalMillis: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 25, maximum: 5000 })),\n ),\n});\n\nexport type SessionWaitOptions = typeof SessionWaitOptions.Type;\n\nconst Millis = Schema.Finite;\n\n/**\n * One CDP-level log entry. Protocol payloads are present only when requested: they carry\n * page content, cookies and typed input, so they are host evidence, never model input.\n */\nexport class SessionLogEntry extends Schema.Class<SessionLogEntry>(\"BrowserbaseSessionLogEntry\")({\n method: Schema.String.check(Schema.isMaxLength(256)),\n pageId: Schema.Int,\n frameId: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(256))),\n loaderId: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(256))),\n timestamp: Schema.optionalKey(Millis),\n requestTimestamp: Schema.optionalKey(Millis),\n responseTimestamp: Schema.optionalKey(Millis),\n params: Schema.optionalKey(Schema.Json),\n result: Schema.optionalKey(Schema.Json),\n}) {}\n\nconst ProviderLog = Schema.Struct({\n method: SessionLogEntry.fields.method,\n pageId: Schema.Int,\n sessionId: Schema.String,\n frameId: SessionLogEntry.fields.frameId,\n loaderId: SessionLogEntry.fields.loaderId,\n timestamp: Schema.optionalKey(Millis),\n request: Schema.optionalKey(\n Schema.Struct({\n params: Schema.optionalKey(Schema.Json),\n timestamp: Schema.optionalKey(Millis),\n }),\n ),\n response: Schema.optionalKey(\n Schema.Struct({\n result: Schema.optionalKey(Schema.Json),\n timestamp: Schema.optionalKey(Millis),\n }),\n ),\n});\n\nexport interface SessionLogOptions {\n /** Include CDP `params`/`result` payloads. Off by default; see `SessionLogEntry`. */\n readonly includePayloads?: boolean;\n}\n\nconst now = Clock.monotonicTimeNanos.pipe(Effect.map((value) => Number(value) / 1000000));\n\nconst fromClient = (operation: SessionError[\"operation\"], error: ClientError): SessionError =>\n SessionError.make({\n operation,\n reason: error.reason,\n ...(error.outcome === undefined ? {} : { outcome: error.outcome }),\n ...(error.status === undefined ? {} : { status: error.status }),\n ...(error.retryAfterMillis === undefined ? {} : { retryAfterMillis: error.retryAfterMillis }),\n });\n\nconst malformed = (operation: SessionError[\"operation\"], mutation = false) =>\n SessionError.make({\n operation,\n reason: \"malformed\",\n ...(mutation ? { outcome: \"unknown\" as const } : {}),\n });\n\nconst configuration = (operation: SessionError[\"operation\"]) =>\n SessionError.make({ operation, reason: \"configuration\", outcome: \"undispatched\" });\n\n/** Passive inspection never releases a remote session. Release is a separate explicit mutation. */\nexport class BrowserbaseSessions extends Context.Service<\n BrowserbaseSessions,\n {\n readonly retrieve: (\n reference: SessionReference,\n ) => Effect.Effect<SessionMetadata, SessionError>;\n readonly list: (\n query?: SessionListQuery,\n ) => Effect.Effect<ReadonlyArray<SessionMetadata>, SessionError>;\n readonly requestRelease: (\n reference: SessionReference,\n ) => Effect.Effect<SessionMetadata, SessionError>;\n readonly waitForTerminal: (\n reference: SessionReference,\n options: SessionWaitOptions,\n ) => Effect.Effect<SessionMetadata, SessionError>;\n readonly waitUntilRunning: (\n reference: SessionReference,\n options: SessionWaitOptions,\n ) => Effect.Effect<SessionMetadata, SessionError>;\n /** Session logs, bounded by the 1 MiB control-plane reply limit (`reason: \"limit\"`). */\n readonly logs: (\n reference: SessionReference,\n options?: SessionLogOptions,\n ) => Effect.Effect<ReadonlyArray<SessionLogEntry>, SessionError>;\n /**\n * Redacted Live View URLs for any session in the project, owned or not. Issuing a URL\n * grants view and input access to whoever holds it; it does not pause automation.\n */\n readonly liveUrls: (\n reference: SessionReference,\n expiresInSeconds?: number,\n ) => Effect.Effect<LiveView, SessionError>;\n }\n>()(\"effect-browserbase/Sessions\") {\n static readonly layer: Layer.Layer<BrowserbaseSessions, never, BrowserbaseClient> = Layer.effect(\n BrowserbaseSessions,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n\n const validate = Effect.fnUntraced(function* (\n reference: SessionReference,\n operation: SessionError[\"operation\"],\n ) {\n const ref = yield* Schema.decodeEffect(SessionReference)(reference, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => configuration(operation)));\n\n if (ref.projectId !== client.projectId)\n return yield* SessionError.make({\n operation,\n reason: \"authorization\",\n outcome: \"undispatched\",\n });\n\n return ref;\n });\n\n const decode = Effect.fnUntraced(function* (\n raw: unknown,\n operation: SessionError[\"operation\"],\n expected?: SessionReference,\n mutation: boolean = false,\n ) {\n const value = yield* Schema.decodeUnknownEffect(ProviderSession)(raw).pipe(\n Effect.mapError(() => malformed(operation, mutation)),\n );\n\n if (\n value.projectId !== client.projectId ||\n (expected !== undefined &&\n (value.id !== expected.sessionId || value.projectId !== expected.projectId))\n )\n return yield* malformed(operation, mutation);\n const { id, projectId, ...metadata } = value;\n\n return SessionMetadata.make({\n reference: SessionReference.make({ provider: \"browserbase\", projectId, sessionId: id }),\n ...metadata,\n });\n });\n\n const read = Effect.fnUntraced(function* (reference: SessionReference, deadline?: number) {\n const ref = yield* validate(reference, \"session-retrieve\");\n\n const raw = yield* client\n .json(\"GET\", `/v1/sessions/${encodeURIComponent(ref.sessionId)}`, undefined, deadline)\n .pipe(Effect.mapError((error) => fromClient(\"session-retrieve\", error)));\n\n return yield* decode(raw, \"session-retrieve\", ref);\n });\n\n const retrieve = Effect.fnUntraced(function* (reference: SessionReference) {\n return yield* read(reference);\n }, Trace.span(\"BrowserbaseSessions.retrieve\"));\n\n const list = Effect.fnUntraced(function* (query: SessionListQuery = {}) {\n const checked = yield* Schema.decodeEffect(SessionListQuery)(query, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => configuration(\"session-list\")));\n\n const search = new URLSearchParams();\n\n if (checked.status !== undefined) search.set(\"status\", checked.status);\n if (checked.q !== undefined) search.set(\"q\", checked.q);\n\n const raw = yield* client\n .json(\"GET\", `/v1/sessions${search.size === 0 ? \"\" : `?${search}`}`)\n .pipe(Effect.mapError((error) => fromClient(\"session-list\", error)));\n\n const rows = yield* Schema.decodeUnknownEffect(\n Schema.Array(ProviderSession).check(Schema.isMaxLength(1024)),\n )(raw).pipe(Effect.mapError(() => malformed(\"session-list\")));\n\n if (new Set(rows.map((row) => row.id)).size !== rows.length)\n return yield* malformed(\"session-list\");\n const output: SessionMetadata[] = [];\n\n for (const row of rows) output.push(yield* decode(row, \"session-list\"));\n\n return output;\n }, Trace.span(\"BrowserbaseSessions.list\"));\n\n const requestRelease = Effect.fnUntraced(function* (reference: SessionReference) {\n const ref = yield* validate(reference, \"session-release\");\n\n const raw = yield* client\n .json(\"POST\", `/v1/sessions/${encodeURIComponent(ref.sessionId)}`, {\n projectId: ref.projectId,\n status: \"REQUEST_RELEASE\",\n })\n .pipe(Effect.mapError((error) => fromClient(\"session-release\", error)));\n\n return yield* decode(raw, \"session-release\", ref, true);\n }, Trace.span(\"BrowserbaseSessions.requestRelease\"));\n\n const wait = Effect.fnUntraced(function* (\n reference: SessionReference,\n options: SessionWaitOptions,\n untilRunning: boolean,\n ) {\n const bounds = yield* Schema.decodeEffect(SessionWaitOptions)(options, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => configuration(\"session-wait\")));\n\n const deadline = (yield* now) + bounds.timeoutMillis;\n\n for (;;) {\n const remaining = deadline - (yield* now);\n\n if (remaining <= 0)\n return yield* SessionError.make({ operation: \"session-wait\", reason: \"timeout\" });\n\n // The deadline bounds the provider read too, not just sleeps between reads.\n const metadata = yield* read(reference, deadline).pipe(\n Effect.withTracerEnabled(false),\n Effect.timeoutOrElse({\n duration: remaining,\n orElse: () =>\n Effect.fail(SessionError.make({ operation: \"session-wait\", reason: \"timeout\" })),\n }),\n );\n\n if (\n untilRunning ? metadata.status === \"RUNNING\" : isTerminalSessionStatus(metadata.status)\n )\n return metadata;\n if (untilRunning && isTerminalSessionStatus(metadata.status))\n return yield* SessionError.make({ operation: \"session-wait\", reason: \"expired\" });\n yield* Effect.sleep(\n Math.max(0, Math.min(bounds.pollIntervalMillis ?? 250, deadline - (yield* now))),\n );\n }\n });\n\n const logs = Effect.fnUntraced(function* (\n reference: SessionReference,\n options: SessionLogOptions = {},\n ) {\n const ref = yield* validate(reference, \"session-logs\");\n\n const raw = yield* client\n .json(\"GET\", `/v1/sessions/${encodeURIComponent(ref.sessionId)}/logs`)\n .pipe(Effect.mapError((error) => fromClient(\"session-logs\", error)));\n\n const rows = yield* Schema.decodeUnknownEffect(\n Schema.Array(ProviderLog).check(Schema.isMaxLength(100_000)),\n )(raw).pipe(Effect.mapError(() => malformed(\"session-logs\")));\n\n if (rows.some((row) => row.sessionId !== ref.sessionId))\n return yield* malformed(\"session-logs\");\n\n return rows.map((row) =>\n SessionLogEntry.make({\n method: row.method,\n pageId: row.pageId,\n ...(row.frameId === undefined ? {} : { frameId: row.frameId }),\n ...(row.loaderId === undefined ? {} : { loaderId: row.loaderId }),\n ...(row.timestamp === undefined ? {} : { timestamp: row.timestamp }),\n ...(row.request?.timestamp === undefined\n ? {}\n : { requestTimestamp: row.request.timestamp }),\n ...(row.response?.timestamp === undefined\n ? {}\n : { responseTimestamp: row.response.timestamp }),\n ...(options.includePayloads === true && row.request?.params !== undefined\n ? { params: row.request.params }\n : {}),\n ...(options.includePayloads === true && row.response?.result !== undefined\n ? { result: row.response.result }\n : {}),\n }),\n );\n }, Trace.span(\"BrowserbaseSessions.logs\"));\n\n const liveUrls = Effect.fnUntraced(function* (\n reference: SessionReference,\n expiresInSeconds: number = 300,\n ) {\n const ref = yield* validate(reference, \"session-live-view\");\n\n return yield* issueLiveUrls(client, ref, expiresInSeconds).pipe(\n Effect.mapError((error) => fromClient(\"session-live-view\", error)),\n );\n }, Trace.span(\"BrowserbaseSessions.liveUrls\"));\n\n return BrowserbaseSessions.of({\n logs,\n liveUrls,\n retrieve,\n list,\n requestRelease,\n waitForTerminal: (ref, options) =>\n wait(ref, options, false).pipe(Trace.span(\"BrowserbaseSessions.waitForTerminal\")),\n waitUntilRunning: (ref, options) =>\n wait(ref, options, true).pipe(Trace.span(\"BrowserbaseSessions.waitUntilRunning\")),\n });\n }),\n );\n}\n"],"mappings":";;;;;;;;AAOA,MAAa,yBACX,WACA,UACiB;CACjB,MAAM,eAA8B;EAClC,QAAQ,MAAM,QAAd;GACE,KAAK,iBACH,OAAO,QAAQ,cAAc,KAAK,CAAC,CAAC;GACtC,KAAK,iBACH,OAAO,QAAQ,cAAc,KAAK,CAAC,CAAC;GACtC,KAAK,gBACH,OAAO,QAAQ,YAAY,KACzB,MAAM,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,kBAAkB,MAAM,iBAAiB,CACzF;GACF,KAAK,aACH,OAAO,QAAQ,SAAS,KAAK,CAAC,CAAC;GACjC,KAAK,UACH,OAAO,QAAQ,OAAO,KAAK,CAAC,CAAC;GAC/B,KAAK,YACH,OAAO,QAAQ,SAAS,KAAK,CAAC,CAAC;GACjC,KAAK,WACH,OAAO,QAAQ,QAAQ,KAAK,CAAC,CAAC;GAChC,KAAK,aACH,OAAO,QAAQ,UAAU,KAAK,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,MAAM,OAAO,CAAC;GAC1F,KAAK,WACH,OAAO,QAAQ,QAAQ,KAAK,CAAC,CAAC;GAChC,KAAK,aACH,OAAO,QAAQ,UAAU,KAAK,CAAC,CAAC;GAClC,KAAK,cACH,OAAO,QAAQ,UAAU,KAAK,CAAC,CAAC;GAClC,KAAK,gBACH,OAAO,QAAQ,YAAY,KAAK,CAAC,CAAC;GAEpC,KAAK;GACL,KAAK,YACH,OAAO,QAAQ,SAAS,KAAK,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,MAAM,OAAO,CAAC;EAC3F;CACF;CAEA,OAAO,aAAa,KA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K,KAAK,SAAS,IAAI,CAAC,CAAC,KAAKA,KAAW,sCAAsC,CAAC;EACpF,CAAC;CACH,CAAC,CACH;AACF"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { a as SessionReference } from "./References-DOH3Wu44.mjs";
|
|
2
|
-
import { SessionError } from "./Errors.mjs";
|
|
3
|
-
import { t as BrowserbaseClient } from "./Client-B_f6bBLT.mjs";
|
|
4
|
-
import { n as SessionMetadata } from "./SessionData-5xYZDshJ.mjs";
|
|
5
|
-
import { Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
6
|
-
//#region src/internal/browser/LiveView.d.ts
|
|
7
|
-
interface LiveView {
|
|
8
|
-
readonly session: Redacted.Redacted<string>;
|
|
9
|
-
readonly pages: ReadonlyArray<{
|
|
10
|
-
readonly liveViewPageId: string;
|
|
11
|
-
readonly url: Redacted.Redacted<string>;
|
|
12
|
-
}>;
|
|
13
|
-
/** Echo of the requested TTL, not a provider-confirmed expiration time. */
|
|
14
|
-
readonly requestedTtlSeconds: number;
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/Sessions.d.ts
|
|
18
|
-
declare const SessionListQuery: Schema.Struct<{
|
|
19
|
-
readonly status: Schema.optionalKey<Schema.Literals<readonly ["PENDING", "RUNNING", "ERROR", "TIMED_OUT", "COMPLETED"]>>;
|
|
20
|
-
readonly q: Schema.optionalKey<Schema.NonEmptyString>;
|
|
21
|
-
}>;
|
|
22
|
-
type SessionListQuery = typeof SessionListQuery.Type;
|
|
23
|
-
declare const SessionWaitOptions: Schema.Struct<{
|
|
24
|
-
readonly timeoutMillis: Schema.Int;
|
|
25
|
-
readonly pollIntervalMillis: Schema.optionalKey<Schema.Int>;
|
|
26
|
-
}>;
|
|
27
|
-
type SessionWaitOptions = typeof SessionWaitOptions.Type;
|
|
28
|
-
declare const SessionLogEntry_base: Schema.Class<SessionLogEntry, Schema.Struct<{
|
|
29
|
-
readonly method: Schema.String;
|
|
30
|
-
readonly pageId: Schema.Int;
|
|
31
|
-
readonly frameId: Schema.optionalKey<Schema.String>;
|
|
32
|
-
readonly loaderId: Schema.optionalKey<Schema.String>;
|
|
33
|
-
readonly timestamp: Schema.optionalKey<Schema.Finite>;
|
|
34
|
-
readonly requestTimestamp: Schema.optionalKey<Schema.Finite>;
|
|
35
|
-
readonly responseTimestamp: Schema.optionalKey<Schema.Finite>;
|
|
36
|
-
readonly params: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
37
|
-
readonly result: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
38
|
-
}>, {}>;
|
|
39
|
-
/**
|
|
40
|
-
* One CDP-level log entry. Protocol payloads are present only when requested: they carry
|
|
41
|
-
* page content, cookies and typed input, so they are host evidence, never model input.
|
|
42
|
-
*/
|
|
43
|
-
declare class SessionLogEntry extends SessionLogEntry_base {}
|
|
44
|
-
interface SessionLogOptions {
|
|
45
|
-
/** Include CDP `params`/`result` payloads. Off by default; see `SessionLogEntry`. */
|
|
46
|
-
readonly includePayloads?: boolean;
|
|
47
|
-
}
|
|
48
|
-
declare const BrowserbaseSessions_base: Context.ServiceClass<BrowserbaseSessions, "effect-browserbase/Sessions", {
|
|
49
|
-
readonly retrieve: (reference: SessionReference) => Effect.Effect<SessionMetadata, SessionError>;
|
|
50
|
-
readonly list: (query?: SessionListQuery) => Effect.Effect<ReadonlyArray<SessionMetadata>, SessionError>;
|
|
51
|
-
readonly requestRelease: (reference: SessionReference) => Effect.Effect<SessionMetadata, SessionError>;
|
|
52
|
-
readonly waitForTerminal: (reference: SessionReference, options: SessionWaitOptions) => Effect.Effect<SessionMetadata, SessionError>;
|
|
53
|
-
readonly waitUntilRunning: (reference: SessionReference, options: SessionWaitOptions) => Effect.Effect<SessionMetadata, SessionError>;
|
|
54
|
-
/** Session logs, bounded by the 1 MiB control-plane reply limit (`reason: "limit"`). */
|
|
55
|
-
readonly logs: (reference: SessionReference, options?: SessionLogOptions) => Effect.Effect<ReadonlyArray<SessionLogEntry>, SessionError>;
|
|
56
|
-
/**
|
|
57
|
-
* Redacted Live View URLs for any session in the project, owned or not. Issuing a URL
|
|
58
|
-
* grants view and input access to whoever holds it; it does not pause automation.
|
|
59
|
-
*/
|
|
60
|
-
readonly liveUrls: (reference: SessionReference, expiresInSeconds?: number) => Effect.Effect<LiveView, SessionError>;
|
|
61
|
-
}>;
|
|
62
|
-
/** Passive inspection never releases a remote session. Release is a separate explicit mutation. */
|
|
63
|
-
declare class BrowserbaseSessions extends BrowserbaseSessions_base {
|
|
64
|
-
static readonly layer: Layer.Layer<BrowserbaseSessions, never, BrowserbaseClient>;
|
|
65
|
-
}
|
|
66
|
-
//#endregion
|
|
67
|
-
export { SessionWaitOptions as a, SessionLogOptions as i, SessionListQuery as n, LiveView as o, SessionLogEntry as r, BrowserbaseSessions as t };
|
|
68
|
-
export {};
|
|
69
|
-
//# sourceMappingURL=Sessions-oJEUmZth.d.mts.map
|
package/dist/Sessions.d.mts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { a as SessionWaitOptions, i as SessionLogOptions, n as SessionListQuery, o as LiveView, r as SessionLogEntry, t as BrowserbaseSessions } from "./Sessions-oJEUmZth.mjs";
|
|
2
|
-
import { i as isTerminalSessionStatus, n as SessionMetadata, r as SessionStatus } from "./SessionData-5xYZDshJ.mjs";
|
|
3
|
-
export { BrowserbaseSessions, type LiveView, SessionListQuery, SessionLogEntry, SessionLogOptions, SessionMetadata, SessionStatus, SessionWaitOptions, isTerminalSessionStatus };
|
|
4
|
-
export {};
|
package/dist/Sessions.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { SessionMetadata, SessionStatus, isTerminalSessionStatus } from "./SessionData.mjs";
|
|
2
|
-
import { i as SessionWaitOptions, n as SessionListQuery, r as SessionLogEntry, t as BrowserbaseSessions } from "./Sessions-D2H5m6rF.mjs";
|
|
3
|
-
export { BrowserbaseSessions, SessionListQuery, SessionLogEntry, SessionMetadata, SessionStatus, SessionWaitOptions, isTerminalSessionStatus };
|
package/dist/Testing.d.mts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { ClientError } from "./Errors.mjs";
|
|
2
|
-
import { r as SessionStatus } from "./SessionData-5xYZDshJ.mjs";
|
|
3
|
-
import { Services } from "./Account.mjs";
|
|
4
|
-
import { LaunchRecipe } from "./Launch.mjs";
|
|
5
|
-
import { BrowserOptions, BrowserbaseBrowser } from "./Browser.mjs";
|
|
6
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
7
|
-
import { BrowserError } from "effect-browser/errors";
|
|
8
|
-
import * as BrowserTesting from "effect-browser/testing";
|
|
9
|
-
//#region src/Testing.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* How the scripted control plane answers. Everything else about a session is what the real
|
|
12
|
-
* `Client`, `Sessions`, allocation and cleanup code makes of those answers.
|
|
13
|
-
*/
|
|
14
|
-
export declare const ProviderScript: Schema.Struct<{
|
|
15
|
-
readonly projectId: Schema.optionalKey<Schema.NonEmptyString>;
|
|
16
|
-
/**
|
|
17
|
-
* The creation reply: `Accept` allocates a session (running unless told otherwise), `Reject`
|
|
18
|
-
* refuses with a status the real transport classifies, `Malformed` replies without an
|
|
19
|
-
* identity, and `Lost` fails the request after it was sent, so the outcome is unknown.
|
|
20
|
-
*/
|
|
21
|
-
readonly create: Schema.optionalKey<Schema.Union<readonly [Schema.TaggedStruct<"Accept", {
|
|
22
|
-
readonly status: Schema.optionalKey<Schema.Literals<readonly ["PENDING", "RUNNING", "ERROR", "TIMED_OUT", "COMPLETED"]>>;
|
|
23
|
-
}>, Schema.TaggedStruct<"Reject", {
|
|
24
|
-
readonly status: Schema.Int;
|
|
25
|
-
readonly retryAfterMillis: Schema.optionalKey<Schema.Natural>;
|
|
26
|
-
}>, Schema.TaggedStruct<"Malformed", {}>, Schema.TaggedStruct<"Lost", {}>]>>;
|
|
27
|
-
/** What a release request does: the session ends, stays running, or the request fails. */
|
|
28
|
-
readonly release: Schema.optionalKey<Schema.Literals<readonly ["confirmed", "pending", "failed"]>>;
|
|
29
|
-
readonly liveView: Schema.optionalKey<Schema.Literals<readonly ["issued", "denied"]>>;
|
|
30
|
-
readonly region: Schema.optionalKey<Schema.Literals<readonly ["us-west-2", "us-east-1", "eu-central-1", "ap-southeast-1"]>>;
|
|
31
|
-
/**
|
|
32
|
-
* Whose identity a session's retrieval and release replies carry: its own, another session's
|
|
33
|
-
* or another project's. The real client refuses a reply it cannot match, so a test can see
|
|
34
|
-
* what allocation, connection and cleanup make of a provider that answers for someone else.
|
|
35
|
-
*/
|
|
36
|
-
readonly identity: Schema.optionalKey<Schema.Literals<readonly ["own", "foreign-session", "foreign-project"]>>;
|
|
37
|
-
}>;
|
|
38
|
-
export type ProviderScript = typeof ProviderScript.Type;
|
|
39
|
-
export interface ProviderCall {
|
|
40
|
-
readonly method: string;
|
|
41
|
-
readonly path: string;
|
|
42
|
-
}
|
|
43
|
-
export interface ProviderSessionRecord {
|
|
44
|
-
readonly id: string;
|
|
45
|
-
readonly status: SessionStatus;
|
|
46
|
-
readonly releaseRequests: number;
|
|
47
|
-
readonly uploads: ReadonlyArray<string>;
|
|
48
|
-
}
|
|
49
|
-
export interface ProviderControl {
|
|
50
|
-
readonly projectId: string;
|
|
51
|
-
readonly calls: Effect.Effect<ReadonlyArray<ProviderCall>>;
|
|
52
|
-
readonly sessions: Effect.Effect<ReadonlyArray<ProviderSessionRecord>>;
|
|
53
|
-
/** Move a session as the provider might while it is connected, for example to `TIMED_OUT`. */
|
|
54
|
-
readonly setStatus: (sessionId: string, status: SessionStatus) => Effect.Effect<void>;
|
|
55
|
-
/** Marker strings the double uses where real secrets would be, to grep evidence for leaks. */
|
|
56
|
-
readonly secrets: {
|
|
57
|
-
readonly apiKey: string;
|
|
58
|
-
readonly connectUrl: string;
|
|
59
|
-
readonly liveView: string;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/** A scripted control plane: a `FetchHttpClient.Fetch` and the handle that inspects it. */
|
|
63
|
-
export interface ScriptedProvider {
|
|
64
|
-
readonly fetch: typeof globalThis.fetch;
|
|
65
|
-
readonly control: ProviderControl;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* The reviewed session subset of the provider API, answered in memory: creation, retrieval,
|
|
69
|
-
* listing, release, Live View issuance and uploads. Provide it as `FetchHttpClient.Fetch`
|
|
70
|
-
* beneath the real `BrowserbaseClient.layer`, or use `layer` below, which does that.
|
|
71
|
-
*/
|
|
72
|
-
export declare const provider: (script?: {
|
|
73
|
-
readonly projectId?: string | undefined;
|
|
74
|
-
readonly create?: {
|
|
75
|
-
readonly _tag: "Accept";
|
|
76
|
-
readonly status?: "COMPLETED" | "ERROR" | "PENDING" | "RUNNING" | "TIMED_OUT" | undefined;
|
|
77
|
-
} | {
|
|
78
|
-
readonly _tag: "Reject";
|
|
79
|
-
readonly status: number;
|
|
80
|
-
readonly retryAfterMillis?: number | undefined;
|
|
81
|
-
} | {
|
|
82
|
-
readonly _tag: "Malformed";
|
|
83
|
-
} | {
|
|
84
|
-
readonly _tag: "Lost";
|
|
85
|
-
} | undefined;
|
|
86
|
-
readonly release?: "confirmed" | "failed" | "pending" | undefined;
|
|
87
|
-
readonly liveView?: "denied" | "issued" | undefined;
|
|
88
|
-
readonly region?: "ap-southeast-1" | "eu-central-1" | "us-east-1" | "us-west-2" | undefined;
|
|
89
|
-
readonly identity?: "foreign-project" | "foreign-session" | "own" | undefined;
|
|
90
|
-
} | undefined) => Effect.Effect<ScriptedProvider, ClientError, never>;
|
|
91
|
-
declare const ScriptedBrowserbase_base: Context.ServiceClass<ScriptedBrowserbase, "effect-browserbase/testing/ScriptedBrowserbase", {
|
|
92
|
-
readonly provider: ProviderControl;
|
|
93
|
-
/**
|
|
94
|
-
* One control for each scripted browser the Layer connected to, in first-connection order:
|
|
95
|
-
* one per provider session, which a keep-alive reconnection or a borrowed attachment reaches
|
|
96
|
-
* again.
|
|
97
|
-
*/
|
|
98
|
-
readonly browsers: Effect.Effect<ReadonlyArray<BrowserTesting.ScriptedControl>>;
|
|
99
|
-
}>;
|
|
100
|
-
/** The scripted provider and the scripted engines behind one `layer`, for a test to inspect. */
|
|
101
|
-
export declare class ScriptedBrowserbase extends ScriptedBrowserbase_base {}
|
|
102
|
-
export interface ScriptedLayerOptions {
|
|
103
|
-
readonly browser: BrowserTesting.Script;
|
|
104
|
-
readonly provider?: ProviderScript;
|
|
105
|
-
/** Defaults to `recipe()`: a five-minute provider lifetime and a provider-managed viewport. */
|
|
106
|
-
readonly launch?: LaunchRecipe;
|
|
107
|
-
readonly options?: Omit<BrowserOptions, "launch">;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* The real account and browser Layers over the scripted provider and the scripted engine.
|
|
111
|
-
* Allocation attempts, release reconciliation, cleanup receipts, `onCleanup`,
|
|
112
|
-
* `onAllocationUncertain`, borrowed attachment and every resource service run for real;
|
|
113
|
-
* only the provider's replies and the browser's pages are scripted. Attempt ids and handoff
|
|
114
|
-
* tokens come from `sequentialCrypto` in `effect-browser/testing`, so they are predictable too.
|
|
115
|
-
*/
|
|
116
|
-
export declare const layer: (options: ScriptedLayerOptions) => Layer.Layer<BrowserbaseBrowser | Services | ScriptedBrowserbase, BrowserError | ClientError>;
|
|
117
|
-
//#endregion
|
|
118
|
-
export {};
|
|
119
|
-
//# sourceMappingURL=Testing.d.mts.map
|