effect-browserbase 0.1.0-beta.102 → 0.2.0-beta.0
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 +61 -231
- package/dist/Account.d.mts +4 -6
- package/dist/Account.mjs +4 -9
- package/dist/Account.mjs.map +1 -1
- package/dist/{Acquisition-WBafHwXH.mjs → Acquisition-D8o4jtCg.mjs} +22 -68
- package/dist/Acquisition-D8o4jtCg.mjs.map +1 -0
- package/dist/Agents.d.mts +4 -6
- package/dist/Agents.mjs +3 -19
- package/dist/Agents.mjs.map +1 -1
- package/dist/Allocation.d.mts +9 -11
- package/dist/Allocation.mjs +2 -4
- package/dist/Allocation.mjs.map +1 -1
- package/dist/Browser.d.mts +25 -140
- package/dist/Browser.mjs +266 -1
- package/dist/Browser.mjs.map +1 -0
- package/dist/BrowserBinding.d.mts +7 -34
- package/dist/BrowserBinding.mjs +30 -1
- package/dist/BrowserBinding.mjs.map +1 -0
- package/dist/Certificates.d.mts +3 -5
- package/dist/Certificates.mjs +2 -7
- package/dist/Certificates.mjs.map +1 -1
- package/dist/{Cleanup-G2YpTCuU.d.mts → Cleanup-DMTDBir8.d.mts} +5 -6
- package/dist/Cleanup.d.mts +3 -2
- package/dist/Cleanup.mjs +1 -6
- package/dist/Cleanup.mjs.map +1 -1
- package/dist/{Client-D1_xYM9o.mjs → Client-BQteUePT.mjs} +2 -4
- package/dist/{Client-D1_xYM9o.mjs.map → Client-BQteUePT.mjs.map} +1 -1
- package/dist/Client.d.mts +51 -2
- package/dist/Client.mjs +1 -1
- package/dist/Connection-DcvJZEdc.mjs +65 -0
- package/dist/Connection-DcvJZEdc.mjs.map +1 -0
- package/dist/ContextCoordination.d.mts +5 -6
- package/dist/ContextCoordination.mjs +1 -8
- package/dist/ContextCoordination.mjs.map +1 -1
- package/dist/Contexts.d.mts +4 -6
- package/dist/Contexts.mjs +2 -8
- package/dist/Contexts.mjs.map +1 -1
- package/dist/Downloads.d.mts +6 -8
- package/dist/Downloads.mjs +3 -8
- package/dist/Downloads.mjs.map +1 -1
- package/dist/Errors.d.mts +3 -26
- package/dist/Errors.mjs +1 -137
- package/dist/Errors.mjs.map +1 -1
- package/dist/{Extensions-ClZbYb1H.mjs → Extensions-nMNMPGCc.mjs} +3 -9
- package/dist/{Extensions-ClZbYb1H.mjs.map → Extensions-nMNMPGCc.mjs.map} +1 -1
- package/dist/Extensions.d.mts +4 -6
- package/dist/Extensions.mjs +1 -1
- package/dist/Functions.d.mts +4 -6
- package/dist/Functions.mjs +3 -17
- package/dist/Functions.mjs.map +1 -1
- package/dist/{Launch-BHcAEq05.mjs → Launch-m0fxzJ49.mjs} +5 -5
- package/dist/Launch-m0fxzJ49.mjs.map +1 -0
- package/dist/Launch.d.mts +130 -2
- package/dist/Launch.mjs +4 -11
- package/dist/Launch.mjs.map +1 -1
- package/dist/PageFetch.d.mts +3 -5
- package/dist/PageFetch.mjs +2 -8
- package/dist/PageFetch.mjs.map +1 -1
- package/dist/Projects.d.mts +3 -5
- package/dist/Projects.mjs +2 -8
- package/dist/Projects.mjs.map +1 -1
- package/dist/Recordings.d.mts +6 -8
- package/dist/Recordings.mjs +3 -5
- package/dist/Recordings.mjs.map +1 -1
- package/dist/{References-URDAtapt.d.mts → References-DOH3Wu44.d.mts} +5 -6
- package/dist/References.d.mts +3 -2
- package/dist/References.mjs +10 -18
- package/dist/References.mjs.map +1 -1
- package/dist/Replays.d.mts +6 -8
- package/dist/Replays.mjs +3 -5
- package/dist/Replays.mjs.map +1 -1
- package/dist/Search.d.mts +3 -5
- package/dist/Search.mjs +2 -9
- package/dist/Search.mjs.map +1 -1
- package/dist/{SessionData-DRKcKCqw.d.mts → SessionData-5xYZDshJ.d.mts} +5 -6
- package/dist/SessionData.d.mts +3 -2
- package/dist/SessionData.mjs +1 -8
- package/dist/SessionData.mjs.map +1 -1
- package/dist/{Sessions-CtbseWEh.mjs → Sessions-DoQGg9nB.mjs} +34 -18
- package/dist/Sessions-DoQGg9nB.mjs.map +1 -0
- package/dist/{Sessions-B8E4kMxo.d.mts → Sessions-tFJYaXFq.d.mts} +8 -8
- package/dist/Sessions.d.mts +4 -3
- package/dist/Sessions.mjs +1 -1
- package/dist/{Transfers-Czv5IZzJ.d.mts → Transfers-GVqzrDWl.d.mts} +22 -9
- package/dist/Transfers.d.mts +3 -2
- package/dist/Transfers.mjs +12 -28
- package/dist/Transfers.mjs.map +1 -1
- package/dist/Uploads.d.mts +6 -8
- package/dist/Uploads.mjs +3 -5
- package/dist/Uploads.mjs.map +1 -1
- package/dist/Webhooks.d.mts +3 -5
- package/dist/Webhooks.mjs +2 -11
- package/dist/Webhooks.mjs.map +1 -1
- package/dist/{WriterFacts-osvYAsIx.d.mts → WriterFacts-5CPBGG1P.d.mts} +4 -3
- package/dist/index.d.mts +27 -30
- package/dist/index.mjs +26 -30
- package/package.json +3 -24
- package/dist/Acquisition-WBafHwXH.mjs.map +0 -1
- package/dist/Association-CEps4hYP.mjs +0 -10
- package/dist/Association-CEps4hYP.mjs.map +0 -1
- package/dist/Bootstrap-BXuzZojd.mjs +0 -194
- package/dist/Bootstrap-BXuzZojd.mjs.map +0 -1
- package/dist/Bootstrap-m7lHgj0D.d.mts +0 -177
- package/dist/Bootstrap.d.mts +0 -2
- package/dist/Bootstrap.mjs +0 -2
- package/dist/Browser-joE4Zgys.mjs +0 -1557
- package/dist/Browser-joE4Zgys.mjs.map +0 -1
- package/dist/BrowserBinding-qbQA6JhH.mjs +0 -2452
- package/dist/BrowserBinding-qbQA6JhH.mjs.map +0 -1
- package/dist/BrowserData-LpcAuAub.d.mts +0 -369
- package/dist/BrowserData.d.mts +0 -2
- package/dist/BrowserData.mjs +0 -442
- package/dist/BrowserData.mjs.map +0 -1
- package/dist/Capture-CZJPuD7b.mjs +0 -532
- package/dist/Capture-CZJPuD7b.mjs.map +0 -1
- package/dist/Capture-Dr5MkIJb.d.mts +0 -125
- package/dist/Capture.d.mts +0 -2
- package/dist/Capture.mjs +0 -2
- package/dist/Client-Ca0zSg1n.d.mts +0 -53
- package/dist/Images-DgscEfSf.mjs +0 -127
- package/dist/Images-DgscEfSf.mjs.map +0 -1
- package/dist/Launch-BHcAEq05.mjs.map +0 -1
- package/dist/Launch-C8CfaYxb.d.mts +0 -132
- package/dist/PageControl.d.mts +0 -16
- package/dist/PageControl.mjs +0 -36
- package/dist/PageControl.mjs.map +0 -1
- package/dist/PageControlAssociation-DabEg5AR.mjs +0 -10
- package/dist/PageControlAssociation-DabEg5AR.mjs.map +0 -1
- package/dist/Sessions-CtbseWEh.mjs.map +0 -1
- package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
package/dist/index.d.mts
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
import { t as Capture_d_exports } from "./Capture-Dr5MkIJb.mjs";
|
|
29
|
-
import { t as PageControl_d_exports } from "./PageControl.mjs";
|
|
30
|
-
export { Account_d_exports as Account, Agents_d_exports as Agents, Allocation_d_exports as Allocation, Bootstrap_d_exports as Bootstrap, Browser_d_exports as Browser, BrowserData_d_exports as BrowserData, Capture_d_exports as Capture, Certificates_d_exports as Certificates, Cleanup_d_exports as Cleanup, Client_d_exports as Client, ContextCoordination_d_exports as ContextCoordination, Contexts_d_exports as Contexts, Downloads_d_exports as Downloads, Errors_d_exports as Errors, Extensions_d_exports as Extensions, Functions_d_exports as Functions, Launch_d_exports as Launch, PageControl_d_exports as PageControl, PageFetch_d_exports as PageFetch, Projects_d_exports as Projects, Recordings_d_exports as Recordings, References_d_exports as References, Replays_d_exports as Replays, Search_d_exports as Search, SessionData_d_exports as SessionData, Sessions_d_exports as Sessions, Transfers_d_exports as Transfers, Uploads_d_exports as Uploads, Webhooks_d_exports as Webhooks };
|
|
1
|
+
import * as Account from "./Account.mjs";
|
|
2
|
+
import * as Agents from "./Agents.mjs";
|
|
3
|
+
import * as Allocation from "./Allocation.mjs";
|
|
4
|
+
import * as Browser from "./Browser.mjs";
|
|
5
|
+
import * as Certificates from "./Certificates.mjs";
|
|
6
|
+
import * as Cleanup from "./Cleanup.mjs";
|
|
7
|
+
import * as Client from "./Client.mjs";
|
|
8
|
+
import * as ContextCoordination from "./ContextCoordination.mjs";
|
|
9
|
+
import * as Contexts from "./Contexts.mjs";
|
|
10
|
+
import * as Downloads from "./Downloads.mjs";
|
|
11
|
+
import * as Errors from "./Errors.mjs";
|
|
12
|
+
import * as Extensions from "./Extensions.mjs";
|
|
13
|
+
import * as Functions from "./Functions.mjs";
|
|
14
|
+
import * as Launch from "./Launch.mjs";
|
|
15
|
+
import * as PageFetch from "./PageFetch.mjs";
|
|
16
|
+
import * as Projects from "./Projects.mjs";
|
|
17
|
+
import * as Recordings from "./Recordings.mjs";
|
|
18
|
+
import * as References from "./References.mjs";
|
|
19
|
+
import * as Replays from "./Replays.mjs";
|
|
20
|
+
import * as Search from "./Search.mjs";
|
|
21
|
+
import * as SessionData from "./SessionData.mjs";
|
|
22
|
+
import * as Sessions from "./Sessions.mjs";
|
|
23
|
+
import * as Transfers from "./Transfers.mjs";
|
|
24
|
+
import * as Uploads from "./Uploads.mjs";
|
|
25
|
+
import * as Webhooks from "./Webhooks.mjs";
|
|
26
|
+
export { Account, Agents, Allocation, Browser, Certificates, Cleanup, Client, ContextCoordination, Contexts, Downloads, Errors, Extensions, Functions, Launch, PageFetch, Projects, Recordings, References, Replays, Search, SessionData, Sessions, Transfers, Uploads, Webhooks };
|
|
27
|
+
export {};
|
package/dist/index.mjs
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
|
|
27
|
-
import { t as Capture_exports } from "./Capture-CZJPuD7b.mjs";
|
|
28
|
-
import { t as ContextCoordination_exports } from "./ContextCoordination.mjs";
|
|
29
|
-
import { t as PageControl_exports } from "./PageControl.mjs";
|
|
30
|
-
export { Account_exports as Account, Agents_exports as Agents, Allocation_exports as Allocation, Bootstrap_exports as Bootstrap, Browser_exports as Browser, BrowserData_exports as BrowserData, Capture_exports as Capture, Certificates_exports as Certificates, Cleanup_exports as Cleanup, Client_exports as Client, ContextCoordination_exports as ContextCoordination, Contexts_exports as Contexts, Downloads_exports as Downloads, Errors_exports as Errors, Extensions_exports as Extensions, Functions_exports as Functions, Launch_exports as Launch, PageControl_exports as PageControl, PageFetch_exports as PageFetch, Projects_exports as Projects, Recordings_exports as Recordings, References_exports as References, Replays_exports as Replays, Search_exports as Search, SessionData_exports as SessionData, Sessions_exports as Sessions, Transfers_exports as Transfers, Uploads_exports as Uploads, Webhooks_exports as Webhooks };
|
|
1
|
+
import * as Account from "./Account.mjs";
|
|
2
|
+
import * as Agents from "./Agents.mjs";
|
|
3
|
+
import * as Allocation from "./Allocation.mjs";
|
|
4
|
+
import * as Browser from "./Browser.mjs";
|
|
5
|
+
import * as Certificates from "./Certificates.mjs";
|
|
6
|
+
import * as Cleanup from "./Cleanup.mjs";
|
|
7
|
+
import * as Client from "./Client.mjs";
|
|
8
|
+
import * as ContextCoordination from "./ContextCoordination.mjs";
|
|
9
|
+
import * as Contexts from "./Contexts.mjs";
|
|
10
|
+
import * as Downloads from "./Downloads.mjs";
|
|
11
|
+
import * as Errors from "./Errors.mjs";
|
|
12
|
+
import * as Extensions from "./Extensions.mjs";
|
|
13
|
+
import * as Functions from "./Functions.mjs";
|
|
14
|
+
import * as Launch from "./Launch.mjs";
|
|
15
|
+
import * as PageFetch from "./PageFetch.mjs";
|
|
16
|
+
import * as Projects from "./Projects.mjs";
|
|
17
|
+
import * as Recordings from "./Recordings.mjs";
|
|
18
|
+
import * as References from "./References.mjs";
|
|
19
|
+
import * as Replays from "./Replays.mjs";
|
|
20
|
+
import * as Search from "./Search.mjs";
|
|
21
|
+
import * as SessionData from "./SessionData.mjs";
|
|
22
|
+
import * as Sessions from "./Sessions.mjs";
|
|
23
|
+
import * as Transfers from "./Transfers.mjs";
|
|
24
|
+
import * as Uploads from "./Uploads.mjs";
|
|
25
|
+
import * as Webhooks from "./Webhooks.mjs";
|
|
26
|
+
export { Account, Agents, Allocation, Browser, Certificates, Cleanup, Client, ContextCoordination, Contexts, Downloads, Errors, Extensions, Functions, Launch, PageFetch, Projects, Recordings, References, Replays, Search, SessionData, Sessions, Transfers, Uploads, Webhooks };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-browserbase",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Effect-based Browserbase resources
|
|
3
|
+
"version": "0.2.0-beta.0",
|
|
4
|
+
"description": "Effect-based Browserbase resources and hosted integration for effect-browser.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -15,12 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"effect": "^4.0.0-rc.115",
|
|
18
|
-
"
|
|
19
|
-
},
|
|
20
|
-
"peerDependenciesMeta": {
|
|
21
|
-
"playwright-core": {
|
|
22
|
-
"optional": true
|
|
23
|
-
}
|
|
18
|
+
"effect-browser": "0.2.0-beta.0"
|
|
24
19
|
},
|
|
25
20
|
"homepage": "https://github.com/mannyc2/effect-agent-browserbase#readme",
|
|
26
21
|
"bugs": {
|
|
@@ -46,10 +41,6 @@
|
|
|
46
41
|
"types": "./dist/Allocation.d.mts",
|
|
47
42
|
"default": "./dist/Allocation.mjs"
|
|
48
43
|
},
|
|
49
|
-
"./bootstrap": {
|
|
50
|
-
"types": "./dist/Bootstrap.d.mts",
|
|
51
|
-
"default": "./dist/Bootstrap.mjs"
|
|
52
|
-
},
|
|
53
44
|
"./browser": {
|
|
54
45
|
"types": "./dist/Browser.d.mts",
|
|
55
46
|
"default": "./dist/Browser.mjs"
|
|
@@ -58,14 +49,6 @@
|
|
|
58
49
|
"types": "./dist/BrowserBinding.d.mts",
|
|
59
50
|
"default": "./dist/BrowserBinding.mjs"
|
|
60
51
|
},
|
|
61
|
-
"./browser-data": {
|
|
62
|
-
"types": "./dist/BrowserData.d.mts",
|
|
63
|
-
"default": "./dist/BrowserData.mjs"
|
|
64
|
-
},
|
|
65
|
-
"./capture": {
|
|
66
|
-
"types": "./dist/Capture.d.mts",
|
|
67
|
-
"default": "./dist/Capture.mjs"
|
|
68
|
-
},
|
|
69
52
|
"./certificates": {
|
|
70
53
|
"types": "./dist/Certificates.d.mts",
|
|
71
54
|
"default": "./dist/Certificates.mjs"
|
|
@@ -106,10 +89,6 @@
|
|
|
106
89
|
"types": "./dist/Launch.d.mts",
|
|
107
90
|
"default": "./dist/Launch.mjs"
|
|
108
91
|
},
|
|
109
|
-
"./page-control": {
|
|
110
|
-
"types": "./dist/PageControl.d.mts",
|
|
111
|
-
"default": "./dist/PageControl.mjs"
|
|
112
|
-
},
|
|
113
92
|
"./page-fetch": {
|
|
114
93
|
"types": "./dist/PageFetch.d.mts",
|
|
115
94
|
"default": "./dist/PageFetch.mjs"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Acquisition-WBafHwXH.mjs","names":[],"sources":["../src/internal/provider/Connection.ts","../src/internal/session/Cleanup.ts","../src/internal/session/Diagnostics.ts","../src/internal/session/Acquisition.ts"],"sourcesContent":["import { Effect, Redacted, Schema } from \"effect\";\n\nimport type { BrowserbaseClient } from \"../../Client.ts\";\nimport { SessionError } from \"../../Errors.ts\";\nimport { SessionReference } from \"../../References.ts\";\nimport { ProviderSession } from \"../../SessionData.ts\";\nimport type { BrowserbaseSessions } from \"../../Sessions.ts\";\nimport { deadlineAfter, nowMillis, until } from \"../Deadline.ts\";\n\nconst Connection = Schema.Struct({\n ...ProviderSession.fields,\n connectUrl: Schema.String.check(Schema.isMaxLength(16384)),\n});\n\n/** A provider-issued endpoint is authority, not a persisted session identifier. */\nexport const connectionUrl = 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 === \"wss:\" &&\n !url.username &&\n !url.password &&\n !url.port &&\n !url.hash &&\n url.hostname.endsWith(\".browserbase.com\")\n );\n } catch {\n return false;\n }\n }),\n);\n\nexport const connectionAddress = Effect.fnUntraced(function* (\n client: BrowserbaseClient[\"Service\"],\n sessions: BrowserbaseSessions[\"Service\"],\n reference: SessionReference,\n timeoutMillis: number,\n) {\n const fail = (reason: SessionError[\"reason\"]) =>\n SessionError.make({ operation: \"session-connect\", reason });\n\n const ref = yield* Schema.decodeEffect(SessionReference)(reference).pipe(\n Effect.mapError(() => fail(\"configuration\")),\n );\n\n if (ref.projectId !== client.projectId) return yield* fail(\"authorization\");\n const deadline = yield* deadlineAfter(timeoutMillis);\n\n yield* sessions.waitUntilRunning(ref, { timeoutMillis });\n if ((yield* nowMillis) >= deadline) return yield* fail(\"timeout\");\n\n const raw = yield* until(\n client.json(\"GET\", `/v1/sessions/${encodeURIComponent(ref.sessionId)}`, undefined, deadline),\n deadline,\n () => fail(\"timeout\"),\n ).pipe(Effect.mapError((error) => fail(error.reason)));\n\n const value = yield* Schema.decodeUnknownEffect(Connection)(raw).pipe(\n Effect.mapError(() => fail(\"malformed\")),\n );\n\n if (value.id !== ref.sessionId || value.projectId !== ref.projectId)\n return yield* fail(\"malformed\");\n if (value.status !== \"RUNNING\") return yield* fail(\"expired\");\n\n const url = yield* Schema.decodeEffect(connectionUrl)(value.connectUrl).pipe(\n Effect.mapError(() => fail(\"unsafe-url\")),\n );\n\n return Redacted.make(url);\n});\n","import { Cause, Effect, Exit, Option } from \"effect\";\n\nimport { CleanupIssue, CleanupResult } from \"../../Cleanup.ts\";\nimport type { BrowserError, InitializationError } from \"../../Errors.ts\";\nimport type { SessionReference } from \"../../References.ts\";\nimport type { SessionStatus } from \"../../SessionData.ts\";\nimport type { BrowserbaseSessions } from \"../../Sessions.ts\";\n\n/** All effects are captured by the owning connection; no native value is exported. */\nexport interface LocalCleanup {\n readonly fence: Effect.Effect<void>;\n readonly capture: Effect.Effect<void, BrowserError>;\n readonly initialization: Effect.Effect<void, BrowserError | InitializationError>;\n readonly disconnect: Effect.Effect<CleanupResult[\"local\"], BrowserError>;\n}\n\nexport const noLocalConnection: LocalCleanup = {\n fence: Effect.void,\n capture: Effect.void,\n initialization: Effect.void,\n disconnect: Effect.succeed(\"not-connected\"),\n};\n\n/** Bounded host notification of canonical facts. Reporting never changes them. */\nexport const reported = <A, E>(effect: Effect.Effect<A, E>) =>\n effect.pipe(\n Effect.interruptible,\n Effect.timeoutOrElse({ duration: 2000, orElse: () => Effect.void }),\n Effect.ignore,\n );\n\n/** Internal limits, also injectable by deterministic failure tests. */\nexport interface CleanupLimits {\n readonly localStepMillis: number;\n readonly releaseMillis: number;\n readonly terminalMillis: number;\n}\n\nexport const defaultCleanupLimits: CleanupLimits = {\n localStepMillis: 3000,\n releaseMillis: 4000,\n terminalMillis: 4000,\n};\n\n/**\n * Close is one uninterruptible, bounded transaction over *local cleanup evidence*, not\n * a transaction over the remote browser. Each step observes its own Exit so failures\n * cannot suppress a later disconnect, release request, or exact-session status read.\n */\nexport const makeCleanup = Effect.fnUntraced(function* (\n reference: SessionReference,\n ownership: CleanupResult[\"ownership\"],\n sessions: BrowserbaseSessions[\"Service\"],\n local: LocalCleanup,\n report: (result: CleanupResult) => void,\n limits: CleanupLimits = defaultCleanupLimits,\n) {\n let latest: CleanupResult | undefined;\n\n const close = yield* Effect.cached(\n Effect.uninterruptible(\n Effect.gen(function* () {\n const issues: CleanupIssue[] = [];\n\n const step = <A, E>(\n name: CleanupIssue[\"step\"],\n action: Effect.Effect<A, E>,\n milliseconds: number,\n ) =>\n action.pipe(\n Effect.interruptible,\n Effect.timeoutOrElse({\n duration: milliseconds,\n orElse: () => Effect.fail(CleanupIssue.make({ step: name, reason: \"timeout\" })),\n }),\n Effect.exit,\n Effect.tap((exit) =>\n Effect.sync(() => {\n if (Exit.isSuccess(exit)) return;\n const reason = Cause.findErrorOption(exit.cause);\n\n issues.push(\n CleanupIssue.make({\n step: name,\n reason:\n Option.isSome(reason) && reason.value instanceof CleanupIssue\n ? reason.value.reason\n : Cause.hasInterrupts(exit.cause)\n ? \"interrupted\"\n : \"failed\",\n }),\n );\n }),\n ),\n );\n\n // The fence runs synchronously before interruptible native teardown begins.\n yield* step(\"fence\", local.fence, limits.localStepMillis);\n yield* step(\"capture\", local.capture, limits.localStepMillis);\n yield* step(\"initialization\", local.initialization, limits.localStepMillis);\n const disconnected = yield* step(\"disconnect\", local.disconnect, limits.localStepMillis);\n const localState = Exit.isSuccess(disconnected) ? disconnected.value : \"failed\";\n\n let releaseRequested = false;\n let remote: CleanupResult[\"remote\"] = ownership === \"borrowed\" ? \"not-owned\" : \"unknown\";\n let observedStatus: SessionStatus | undefined;\n\n if (ownership === \"owned\") {\n const requested = yield* step(\n \"release\",\n sessions.requestRelease(reference),\n limits.releaseMillis,\n );\n\n releaseRequested = Exit.isSuccess(requested);\n\n // A POST response is never substituted for a passive terminal-state observation.\n const terminal = yield* step(\n \"status\",\n sessions.waitForTerminal(reference, { timeoutMillis: limits.terminalMillis }),\n limits.terminalMillis,\n );\n\n if (Exit.isSuccess(terminal)) {\n remote = \"confirmed\";\n observedStatus = terminal.value.status;\n } else if (Exit.isSuccess(requested)) {\n remote = \"pending\";\n }\n }\n\n const result = CleanupResult.make({\n reference,\n ownership,\n releaseRequested,\n remote,\n local: localState,\n ...(observedStatus === undefined ? {} : { observedStatus }),\n issues,\n });\n\n Object.freeze(result.issues);\n latest = Object.freeze(result);\n report(latest);\n\n return latest;\n }),\n ),\n );\n\n return {\n close,\n result: Effect.sync(() => Option.fromNullishOr(latest)),\n };\n});\n","import { Cause, Data, Effect, ErrorReporter } from \"effect\";\n\nimport type { CleanupResult } from \"../../Cleanup.ts\";\nimport type { AllocationAttempt } from \"../../References.ts\";\n\n/**\n * Operator-visible evidence that a session's fate was not settled. It carries identity and\n * outcome labels only: no provider body, connection URL, credential or page content. The\n * transport deliberately disables tracing where credentials travel, so without this an\n * unconfirmed release or an allocation of unknown outcome would leave no trace for anyone who\n * did not register a callback.\n */\nclass SessionUnsettled extends Data.TaggedError(\"BrowserbaseSessionUnsettled\")<{\n readonly message: string;\n readonly details: Readonly<Record<string, string | number>>;\n}> {\n readonly [ErrorReporter.severity] = \"Warn\" as const;\n\n get [ErrorReporter.attributes]() {\n return this.details;\n }\n}\n\nconst surface = (message: string, details: Readonly<Record<string, string | number>>) =>\n Effect.logWarning(message).pipe(\n Effect.annotateLogs(details),\n Effect.andThen(ErrorReporter.report(Cause.fail(new SessionUnsettled({ message, details })))),\n );\n\n/** A borrowed scope never owns release, so only its local teardown can be unsettled. */\nexport const reportCleanup = (result: CleanupResult): Effect.Effect<void> => {\n const remoteUnsettled =\n result.ownership === \"owned\" && (result.remote !== \"confirmed\" || !result.releaseRequested);\n\n if (!remoteUnsettled && result.local !== \"failed\" && result.issues.length === 0)\n return Effect.void;\n\n return surface(\"Browserbase session cleanup ended without confirmation\", {\n projectId: result.reference.projectId,\n sessionId: result.reference.sessionId,\n ownership: result.ownership,\n remote: result.remote,\n local: result.local,\n observedStatus: result.observedStatus ?? \"unobserved\",\n issues: result.issues.map((issue) => `${issue.step}:${issue.reason}`).join(\",\") || \"none\",\n });\n};\n\n/** The provider may have allocated a session this process has no reference for. */\nexport const reportAllocationUncertain = (attempt: AllocationAttempt): Effect.Effect<void> =>\n surface(\"Browserbase allocation outcome is unknown\", {\n projectId: attempt.projectId,\n attemptId: attempt.attemptId,\n requestedAtMillis: attempt.requestedAtMillis,\n });\n","import { Clock, Effect, Exit, Option, Schema, Scope } from \"effect\";\n\nimport type { CleanupResult } from \"../../Cleanup.ts\";\nimport { BrowserbaseClient } from \"../../Client.ts\";\nimport { AllocationError, ContextError, type ClientError, SessionError } from \"../../Errors.ts\";\nimport type { LaunchRecipe } from \"../../Launch.ts\";\nimport { type AllocationAttempt, Identifier, SessionReference } from \"../../References.ts\";\nimport { BrowserbaseSessions } from \"../../Sessions.ts\";\nimport { connectionAddress } from \"../provider/Connection.ts\";\nimport { compileLaunch } from \"../provider/Launch.ts\";\nimport {\n makeCleanup,\n noLocalConnection,\n reported,\n type CleanupLimits,\n type LocalCleanup,\n} from \"./Cleanup.ts\";\nimport { requireContextWriterPermit, type ContextWriterPermitInternal } from \"./ContextWriter.ts\";\nimport { reportAllocationUncertain, reportCleanup } from \"./Diagnostics.ts\";\nimport type { ContextWriterPermit } from \"./WriterFacts.ts\";\n\nconst AllocatedIdentity = Schema.Struct({ id: Identifier, projectId: Identifier });\n\nexport interface AcquisitionOptions {\n readonly launch: LaunchRecipe;\n readonly contextWriter?: ContextWriterPermit;\n readonly allocationDeadline?: number;\n /** Bounded host notification of the canonical facts. Reporting never changes them. */\n readonly onCleanup?: (result: CleanupResult) => Effect.Effect<void>;\n /** Exactly one notification when a creation attempt's effect on the provider is unknown. */\n readonly onAllocationUncertain?: (attempt: AllocationAttempt) => Effect.Effect<void>;\n}\n\n/**\n * The remote lease is registered before POST. Local connection work is supplied by\n * the same browser owner; the control plane never invents a second operation owner.\n */\nexport const acquireRemote = Effect.fnUntraced(function* (\n options: AcquisitionOptions,\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\n const launch = yield* compileLaunch(options.launch, {\n projectId: client.projectId,\n attemptId: globalThis.crypto.randomUUID(),\n requestedAtMillis: yield* Clock.currentTimeMillis,\n });\n\n const attempt = launch.attempt;\n let writer: ContextWriterPermitInternal | undefined;\n\n if (launch.context?.persist) {\n if (options.contextWriter === undefined) {\n return yield* ContextError.make({\n operation: \"writer-authority\",\n reason: \"authorization\",\n outcome: \"undispatched\",\n });\n }\n writer = yield* requireContextWriterPermit(options.contextWriter, {\n provider: \"browserbase\",\n projectId: client.projectId,\n contextId: launch.context.id,\n });\n } else if (options.contextWriter !== undefined) {\n return yield* ContextError.make({\n operation: \"writer-authority\",\n reason: \"configuration\",\n outcome: \"undispatched\",\n });\n }\n\n return yield* Effect.uninterruptibleMask((restore) =>\n Effect.gen(function* () {\n const resourceScope = yield* Scope.make();\n let reference: SessionReference | undefined;\n let admitted = false;\n let knownRejection = false;\n let closing = false;\n let cleanup: CleanupResult | undefined;\n\n let uncertainReported = false;\n\n const allocationUncertain = Effect.suspend(() => {\n if (uncertainReported) return Effect.void;\n uncertainReported = true;\n\n return reportAllocationUncertain(attempt).pipe(\n Effect.andThen(\n options.onAllocationUncertain === undefined\n ? Effect.void\n : reported(options.onAllocationUncertain(attempt)),\n ),\n );\n });\n\n const terminate = yield* Effect.cached(\n Effect.uninterruptible(\n Effect.gen(function* () {\n closing = true;\n if (reference === undefined) {\n if (admitted && !knownRejection) {\n writer?.uncertain(attempt);\n yield* allocationUncertain;\n }\n\n return;\n }\n\n const coordinator = yield* makeCleanup(\n reference,\n \"owned\",\n sessions,\n local,\n (result) => {\n cleanup = result;\n writer?.completed(attempt, result);\n },\n limits,\n );\n\n yield* coordinator.close;\n if (cleanup !== undefined) yield* reportCleanup(cleanup);\n if (cleanup !== undefined && options.onCleanup !== undefined)\n yield* reported(options.onCleanup(cleanup));\n }),\n ),\n );\n\n const closeScope = yield* Effect.cached(Scope.close(resourceScope, Exit.void));\n\n yield* Scope.addFinalizer(resourceScope, terminate);\n yield* Scope.addFinalizer(parent, closeScope);\n\n const failedAllocation = (error: ClientError): AllocationError => {\n knownRejection = error.outcome === \"rejected\" || error.outcome === \"undispatched\";\n if (knownRejection) writer?.rejected(attempt);\n else writer?.uncertain(attempt);\n const reason = error.reason;\n\n return AllocationError.make({\n attempt,\n outcome: knownRejection ? \"rejected\" : \"unknown\",\n reason:\n reason === \"authorization\" ||\n reason === \"rate-limited\" ||\n reason === \"configuration\" ||\n reason === \"transport\" ||\n reason === \"timeout\" ||\n reason === \"malformed\"\n ? reason\n : \"provider\",\n ...(error.status === undefined ? {} : { status: error.status }),\n ...(error.retryAfterMillis === undefined\n ? {}\n : { retryAfterMillis: error.retryAfterMillis }),\n });\n };\n\n const allocate = Effect.gen(function* () {\n if (writer !== undefined) yield* writer.recordAttempt(attempt);\n admitted = true;\n\n const raw = yield* restore(\n client.json(\"POST\", \"/v1/sessions\", launch.body, options.allocationDeadline),\n ).pipe(Effect.mapError(failedAllocation));\n\n const identity = yield* Schema.decodeUnknownEffect(AllocatedIdentity)(raw).pipe(\n Effect.mapError(() =>\n AllocationError.make({ attempt, outcome: \"unknown\", reason: \"malformed\" }),\n ),\n );\n\n // Save identity before interpreting any connection credentials or provider metadata.\n reference = Object.freeze(\n SessionReference.make({\n provider: \"browserbase\",\n projectId: identity.projectId,\n sessionId: identity.id,\n }),\n );\n writer?.recordSession(attempt, reference);\n if (reference.projectId !== client.projectId) {\n return yield* AllocationError.make({\n attempt,\n reference,\n outcome: \"unknown\",\n reason: \"malformed\",\n });\n }\n const ref = reference;\n\n return {\n reference: ref,\n attempt,\n launch,\n resourceScope,\n isClosed: () => closing,\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 : connectionAddress(client, sessions, ref, timeoutMillis),\n ),\n release: closeScope.pipe(\n Effect.andThen(\n Effect.suspend(() =>\n cleanup === undefined\n ? Effect.die(new Error(\"Owned session closed without cleanup evidence\"))\n : Effect.succeed(cleanup),\n ),\n ),\n ),\n cleanupResult: Effect.sync(() => Option.fromNullishOr(cleanup)),\n };\n });\n\n return yield* allocate.pipe(\n Effect.onError(() => closeScope),\n Effect.onInterrupt(() => closeScope),\n );\n }),\n );\n});\n\nexport type RemoteAcquisition = Effect.Success<ReturnType<typeof acquireRemote>>;\n"],"mappings":";;;;;;;;;;;AASA,MAAM,aAAa,OAAO,OAAO;CAC/B,GAAG,gBAAgB;CACnB,YAAY,OAAO,OAAO,MAAM,OAAO,YAAY,KAAK,CAAC;AAC3D,CAAC;;AAGD,MAAa,gBAAgB,OAAO,OAAO,MACzC,OAAO,YAAY,KAAK,GACxB,OAAO,YAAY,UAAU;CAC3B,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,KAAK;EAEzB,OACE,IAAI,aAAa,UACjB,CAAC,IAAI,YACL,CAAC,IAAI,YACL,CAAC,IAAI,QACL,CAAC,IAAI,QACL,IAAI,SAAS,SAAS,kBAAkB;CAE5C,QAAQ;EACN,OAAO;CACT;AACF,CAAC,CACH;AAEA,MAAa,oBAAoB,OAAO,WAAW,WACjD,QACA,UACA,WACA,eACA;CACA,MAAM,QAAQ,WACZ,aAAa,KAAK;EAAE,WAAW;EAAmB;CAAO,CAAC;CAE5D,MAAM,MAAM,OAAO,OAAO,aAAa,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,KAClE,OAAO,eAAe,KAAK,eAAe,CAAC,CAC7C;CAEA,IAAI,IAAI,cAAc,OAAO,WAAW,OAAO,OAAO,KAAK,eAAe;CAC1E,MAAM,WAAW,OAAO,cAAc,aAAa;CAEnD,O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M,WAAW,OAAO,OAAO,oBAAoB,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,KACzE,OAAO,eACL,gBAAgB,KAAK;IAAE;IAAS,SAAS;IAAW,QAAQ;GAAY,CAAC,CAC3E,CACF;GAGA,YAAY,OAAO,OACjB,iBAAiB,KAAK;IACpB,UAAU;IACV,WAAW,SAAS;IACpB,WAAW,SAAS;GACtB,CAAC,CACH;GACA,QAAQ,cAAc,SAAS,SAAS;GACxC,IAAI,UAAU,cAAc,OAAO,WACjC,OAAO,OAAO,gBAAgB,KAAK;IACjC;IACA;IACA,SAAS;IACT,QAAQ;GACV,CAAC;GAEH,MAAM,MAAM;GAEZ,OAAO;IACL,WAAW;IACX;IACA;IACA;IACA,gBAAgB;IAChB,aAAa,kBACX,OAAO,cACL,UACI,OAAO,KACL,aAAa,KAAK;KAChB,WAAW;KACX,QAAQ;KACR,SAAS;IACX,CAAC,CACH,IACA,kBAAkB,QAAQ,UAAU,KAAK,aAAa,CAC5D;IACF,SAAS,WAAW,KAClB,OAAO,QACL,OAAO,cACL,YAAY,KAAA,IACR,OAAO,oBAAI,IAAI,MAAM,+CAA+C,CAAC,IACrE,OAAO,QAAQ,OAAO,CAC5B,CACF,CACF;IACA,eAAe,OAAO,WAAW,OAAO,cAAc,OAAO,CAAC;GAChE;EACF,CAEqB,CAAC,CAAC,KACrB,OAAO,cAAc,UAAU,GAC/B,OAAO,kBAAkB,UAAU,CACrC;CACF,CAAC,CACH;AACF,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//#region src/internal/browser/Association.ts
|
|
2
|
-
const parents = /* @__PURE__ */ new WeakMap();
|
|
3
|
-
const associate = (session, parent) => {
|
|
4
|
-
parents.set(session, parent);
|
|
5
|
-
};
|
|
6
|
-
const captureParent = (session) => parents.get(session);
|
|
7
|
-
//#endregion
|
|
8
|
-
export { captureParent as n, associate as t };
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=Association-CEps4hYP.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Association-CEps4hYP.mjs","names":[],"sources":["../src/internal/browser/Association.ts"],"sourcesContent":["import type { Effect } from \"effect\";\n\nimport type { PageInfo, Target } from \"../../BrowserData.ts\";\nimport type { BrowserError } from \"../../Errors.ts\";\nimport type { CaptureSource } from \"./Driver.ts\";\nimport type { Owner, Ticket } from \"./Owner.ts\";\n\nexport interface CaptureLease {\n readonly stop: Effect.Effect<void>;\n readonly invalidate: (reason: string) => void;\n readonly reservedBytes: number;\n}\n\nexport interface CaptureResolution {\n /** Stable native page identity used to quarantine an unconfirmed screencast across reconnects. */\n readonly key: string;\n readonly target: Target;\n readonly source: CaptureSource;\n}\n\nexport interface CaptureParent {\n readonly owner: Owner;\n readonly resolve: (\n ticket: Ticket,\n target?: PageInfo,\n ) => Effect.Effect<CaptureResolution, BrowserError>;\n readonly target: () => Target;\n readonly captureLeases: Map<string, CaptureLease>;\n captureReservedBytes: number;\n}\n\n// This is a private capability registry, not stored domain data. Exact live session identity is\n// required: spreading/cloning a session must not copy authority to mutate its capture owner,\n// leases or reservations. A public/enumerable parent field would weaken that boundary.\n// Keep this access centralized here; schemas describe data, never this mutable ownership state.\nconst parents = new WeakMap<object, CaptureParent>();\n\nexport const associate = (session: object, parent: CaptureParent): void => {\n parents.set(session, parent);\n};\n\nexport const captureParent = (session: object): CaptureParent | undefined => parents.get(session);\n"],"mappings":";AAmCA,MAAM,0BAAU,IAAI,QAA+B;AAEnD,MAAa,aAAa,SAAiB,WAAgC;CACzE,QAAQ,IAAI,SAAS,MAAM;AAC7B;AAEA,MAAa,iBAAiB,YAA+C,QAAQ,IAAI,OAAO"}
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { Identifier } from "./References.mjs";
|
|
3
|
-
import { BrowserError, InitializationError } from "./Errors.mjs";
|
|
4
|
-
import { Effect, Schema } from "effect";
|
|
5
|
-
//#region src/internal/browser/BindingRegistration.ts
|
|
6
|
-
const Invoke = Symbol("BrowserbaseBindingRegistration");
|
|
7
|
-
const issued = /* @__PURE__ */ new WeakSet();
|
|
8
|
-
const Origin$1 = Schema.NonEmptyString.check(Schema.isMaxLength(2048), Schema.makeFilter((value) => {
|
|
9
|
-
try {
|
|
10
|
-
const url = new URL(value);
|
|
11
|
-
return ["http:", "https:"].includes(url.protocol) && url.origin === value && !url.username && !url.password;
|
|
12
|
-
} catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}, { title: "an exact http(s) origin" }));
|
|
16
|
-
const FailureMode = Schema.Literals(["reject-call", "fail-session"]);
|
|
17
|
-
const metadataSchema = Schema.Struct({
|
|
18
|
-
name: Identifier,
|
|
19
|
-
origins: Schema.Array(Origin$1).check(Schema.isMaxLength(16), Schema.isUnique(), Schema.makeFilter((origins) => origins.length > 0, { title: "at least one allowed origin" })),
|
|
20
|
-
maxConcurrent: Schema.Int.check(Schema.isBetween({
|
|
21
|
-
minimum: 1,
|
|
22
|
-
maximum: 64
|
|
23
|
-
})),
|
|
24
|
-
maxInputBytes: Schema.Int.check(Schema.isBetween({
|
|
25
|
-
minimum: 1,
|
|
26
|
-
maximum: 1048576
|
|
27
|
-
})),
|
|
28
|
-
maxOutputBytes: Schema.Int.check(Schema.isBetween({
|
|
29
|
-
minimum: 1,
|
|
30
|
-
maximum: 4194304
|
|
31
|
-
})),
|
|
32
|
-
timeoutMillis: Schema.Int.check(Schema.isBetween({
|
|
33
|
-
minimum: 1,
|
|
34
|
-
maximum: 12e4
|
|
35
|
-
})),
|
|
36
|
-
failureMode: FailureMode
|
|
37
|
-
});
|
|
38
|
-
/** Retain an issued live capability at schema boundaries; a copied shape is not authority. */
|
|
39
|
-
const schema = Schema.declare((value) => typeof value === "object" && value !== null && issued.has(value), { title: "an issued Browserbase binding registration" });
|
|
40
|
-
const issue = (metadata, invoke) => {
|
|
41
|
-
const registration = Object.freeze({
|
|
42
|
-
...metadata,
|
|
43
|
-
origins: Object.freeze([...metadata.origins]),
|
|
44
|
-
[Invoke]: invoke
|
|
45
|
-
});
|
|
46
|
-
issued.add(registration);
|
|
47
|
-
return registration;
|
|
48
|
-
};
|
|
49
|
-
/** Pack heterogeneous codecs and handlers while their concrete input/output types are known. */
|
|
50
|
-
const make = (options) => {
|
|
51
|
-
const metadata = Schema.decodeSync(metadataSchema)(options);
|
|
52
|
-
const { input, output, handle } = options;
|
|
53
|
-
if (!Schema.isSchema(input) || !Schema.isSchema(output) || typeof handle !== "function") throw new TypeError("Invalid binding registration");
|
|
54
|
-
const fail = (reason) => InitializationError.make({
|
|
55
|
-
operation: "callback",
|
|
56
|
-
step: metadata.name,
|
|
57
|
-
reason
|
|
58
|
-
});
|
|
59
|
-
return issue(metadata, Effect.fnUntraced(function* (text, check) {
|
|
60
|
-
if (new TextEncoder().encode(text).length > metadata.maxInputBytes) return yield* fail("input");
|
|
61
|
-
const decoded = yield* Schema.decodeEffect(Schema.fromJsonString(input))(text).pipe(Effect.catchCause(() => Effect.fail(fail("input"))));
|
|
62
|
-
yield* check;
|
|
63
|
-
const value = yield* Effect.suspend(() => handle(decoded));
|
|
64
|
-
const encoded = yield* Schema.encodeEffect(output)(value).pipe(Effect.catchCause(() => Effect.fail(fail("output"))));
|
|
65
|
-
const json = yield* Schema.decodeUnknownEffect(Schema.Json)(encoded).pipe(Effect.catchCause(() => Effect.fail(fail("output"))));
|
|
66
|
-
const result = yield* Schema.encodeEffect(Schema.fromJsonString(Schema.Json))(json).pipe(Effect.catchCause(() => Effect.fail(fail("output"))));
|
|
67
|
-
if (new TextEncoder().encode(result).length > metadata.maxOutputBytes) return yield* fail("output");
|
|
68
|
-
return result;
|
|
69
|
-
}));
|
|
70
|
-
};
|
|
71
|
-
/** Authentication is identity-based even when a caller copies every enumerable field/symbol. */
|
|
72
|
-
const snapshot = Effect.fnUntraced(function* (registration) {
|
|
73
|
-
const invalid = () => BrowserError.make({
|
|
74
|
-
operation: "configure",
|
|
75
|
-
reason: "configuration",
|
|
76
|
-
outcome: "undispatched"
|
|
77
|
-
});
|
|
78
|
-
if (!issued.has(registration)) return yield* invalid();
|
|
79
|
-
const metadata = yield* Schema.decodeEffect(metadataSchema)(registration).pipe(Effect.mapError(invalid));
|
|
80
|
-
return issue(metadata, registration[Invoke]);
|
|
81
|
-
});
|
|
82
|
-
const invoke = (registration, text, check) => registration[Invoke](text, check);
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region src/Bootstrap.ts
|
|
85
|
-
var Bootstrap_exports = /* @__PURE__ */ __exportAll({
|
|
86
|
-
BindingFailureMode: () => BindingFailureMode,
|
|
87
|
-
InitScript: () => InitScript,
|
|
88
|
-
Origin: () => Origin,
|
|
89
|
-
Permission: () => Permission,
|
|
90
|
-
PermissionGrant: () => PermissionGrant,
|
|
91
|
-
Plan: () => Plan,
|
|
92
|
-
Readiness: () => Readiness,
|
|
93
|
-
binding: () => binding,
|
|
94
|
-
combine: () => combine,
|
|
95
|
-
empty: () => empty,
|
|
96
|
-
init: () => init,
|
|
97
|
-
permissions: () => permissions
|
|
98
|
-
});
|
|
99
|
-
/**
|
|
100
|
-
* Exact scheme-and-host origin, as a document reports it. Patterns are deliberately absent:
|
|
101
|
-
* a registration that cannot say exactly where it applies does not belong in a plan.
|
|
102
|
-
*/
|
|
103
|
-
const Origin = Origin$1;
|
|
104
|
-
/**
|
|
105
|
-
* The reviewed subset of native permission capabilities. Each name is checked against a real
|
|
106
|
-
* browser in native acceptance; an unsupported capability is refused before it is exposed.
|
|
107
|
-
*/
|
|
108
|
-
const Permission = Schema.Literals([
|
|
109
|
-
"accelerometer",
|
|
110
|
-
"background-sync",
|
|
111
|
-
"camera",
|
|
112
|
-
"clipboard-read",
|
|
113
|
-
"clipboard-write",
|
|
114
|
-
"geolocation",
|
|
115
|
-
"gyroscope",
|
|
116
|
-
"magnetometer",
|
|
117
|
-
"microphone",
|
|
118
|
-
"midi",
|
|
119
|
-
"notifications",
|
|
120
|
-
"payment-handler",
|
|
121
|
-
"storage-access"
|
|
122
|
-
]);
|
|
123
|
-
const PermissionGrant = Schema.Struct({
|
|
124
|
-
origin: Origin,
|
|
125
|
-
permissions: Schema.Array(Permission).check(Schema.isMaxLength(16), Schema.isUnique())
|
|
126
|
-
});
|
|
127
|
-
/**
|
|
128
|
-
* Registration is not readiness. A script may start asynchronous work, but it cannot pause the
|
|
129
|
-
* website's own scripts, so a document is ready only when its expression resolves to exactly
|
|
130
|
-
* `true`. A document that was already running when the bundle was registered never ran it:
|
|
131
|
-
* `RequireFreshNavigation` reports that instead of pretending otherwise, and an explicit
|
|
132
|
-
* reload of possibly uncertain work stays a caller's decision.
|
|
133
|
-
*/
|
|
134
|
-
const Readiness = Schema.Struct({
|
|
135
|
-
expression: Schema.NonEmptyString.check(Schema.isMaxLength(4096)),
|
|
136
|
-
timeoutMillis: Schema.Int.check(Schema.isBetween({
|
|
137
|
-
minimum: 1,
|
|
138
|
-
maximum: 12e4
|
|
139
|
-
})),
|
|
140
|
-
existingDocuments: Schema.Literals(["RequireFreshNavigation", "AcceptAlreadyRunning"])
|
|
141
|
-
});
|
|
142
|
-
/** Trusted host configuration. Script content is never model output or page input. */
|
|
143
|
-
const InitScript = Schema.Struct({
|
|
144
|
-
id: Identifier,
|
|
145
|
-
content: Schema.NonEmptyString.check(Schema.isMaxLength(65536)),
|
|
146
|
-
/** When present, the step runs only on these documents and readiness skips the rest. */
|
|
147
|
-
origins: Schema.optionalKey(Schema.Array(Origin).check(Schema.isMaxLength(16), Schema.isUnique())),
|
|
148
|
-
readiness: Schema.optionalKey(Readiness)
|
|
149
|
-
});
|
|
150
|
-
/** A callback failure can reject one page invocation or permanently fence the session. */
|
|
151
|
-
const BindingFailureMode = FailureMode;
|
|
152
|
-
/**
|
|
153
|
-
* Static plans remain serializable. Live binding plans retain issued registrations by identity;
|
|
154
|
-
* this schema neither executes their callbacks nor turns copied metadata into authority. Typed
|
|
155
|
-
* acquisition validates a separate snapshot so consumer E/R is not erased by a generic decoder.
|
|
156
|
-
*/
|
|
157
|
-
const Plan = Schema.Struct({
|
|
158
|
-
scripts: Schema.Array(InitScript).check(Schema.isMaxLength(16)),
|
|
159
|
-
permissions: Schema.Array(PermissionGrant).check(Schema.isMaxLength(16)),
|
|
160
|
-
bindings: Schema.optionalKey(Schema.Array(schema).check(Schema.isMaxLength(16)))
|
|
161
|
-
});
|
|
162
|
-
const empty = {
|
|
163
|
-
scripts: [],
|
|
164
|
-
permissions: []
|
|
165
|
-
};
|
|
166
|
-
const init = (script) => ({
|
|
167
|
-
scripts: [script],
|
|
168
|
-
permissions: []
|
|
169
|
-
});
|
|
170
|
-
const permissions = (grant) => ({
|
|
171
|
-
scripts: [],
|
|
172
|
-
permissions: [grant]
|
|
173
|
-
});
|
|
174
|
-
/**
|
|
175
|
-
* Register a page-callable host callback without running it or capturing an ambient runtime.
|
|
176
|
-
* Native installation later owns origin/document checks, bounded admission and disposal.
|
|
177
|
-
*/
|
|
178
|
-
const binding = (options) => ({
|
|
179
|
-
scripts: [],
|
|
180
|
-
permissions: [],
|
|
181
|
-
bindings: [make(options)]
|
|
182
|
-
});
|
|
183
|
-
function combine(...plans) {
|
|
184
|
-
const bindings = plans.flatMap((plan) => plan.bindings === void 0 ? [] : [...plan.bindings]);
|
|
185
|
-
return {
|
|
186
|
-
scripts: plans.flatMap((plan) => [...plan.scripts]),
|
|
187
|
-
permissions: plans.flatMap((plan) => [...plan.permissions]),
|
|
188
|
-
...bindings.length === 0 ? {} : { bindings }
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
//#endregion
|
|
192
|
-
export { Permission as a, Readiness as c, empty as d, init as f, snapshot as h, Origin as i, binding as l, invoke as m, Bootstrap_exports as n, PermissionGrant as o, permissions as p, InitScript as r, Plan as s, BindingFailureMode as t, combine as u };
|
|
193
|
-
|
|
194
|
-
//# sourceMappingURL=Bootstrap-BXuzZojd.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Bootstrap-BXuzZojd.mjs","names":["Origin","Registration.Origin","Registration.FailureMode","Registration.schema","Registration.make"],"sources":["../src/internal/browser/BindingRegistration.ts","../src/Bootstrap.ts"],"sourcesContent":["import { Effect, Schema } from \"effect\";\n\nimport type * as Bootstrap from \"../../Bootstrap.ts\";\nimport { BrowserError, InitializationError } from \"../../Errors.ts\";\nimport { Identifier } from \"../../References.ts\";\n\nconst Invoke = Symbol(\"BrowserbaseBindingRegistration\");\nconst issued = new WeakSet<object>();\n\nexport const Origin = Schema.NonEmptyString.check(\n Schema.isMaxLength(2048),\n Schema.makeFilter(\n (value) => {\n try {\n const url = new URL(value);\n\n return (\n [\"http:\", \"https:\"].includes(url.protocol) &&\n url.origin === value &&\n !url.username &&\n !url.password\n );\n } catch {\n return false;\n }\n },\n { title: \"an exact http(s) origin\" },\n ),\n);\n\nexport const FailureMode = Schema.Literals([\"reject-call\", \"fail-session\"]);\n\nconst metadataSchema = Schema.Struct({\n name: Identifier,\n origins: Schema.Array(Origin).check(\n Schema.isMaxLength(16),\n Schema.isUnique(),\n Schema.makeFilter((origins) => origins.length > 0, { title: \"at least one allowed origin\" }),\n ),\n maxConcurrent: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 64 })),\n maxInputBytes: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1024 * 1024 })),\n maxOutputBytes: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 4 * 1024 * 1024 })),\n timeoutMillis: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 120_000 })),\n failureMode: FailureMode,\n});\n\ntype Metadata = typeof metadataSchema.Type;\n\nexport interface Registration<E, R> extends Metadata {\n readonly [Invoke]: (\n text: string,\n check: Effect.Effect<void, InitializationError>,\n ) => Effect.Effect<string, E | InitializationError, R>;\n}\n\n/** Retain an issued live capability at schema boundaries; a copied shape is not authority. */\nexport const schema = Schema.declare<Registration<unknown, unknown>>(\n (value): value is Registration<unknown, unknown> =>\n typeof value === \"object\" && value !== null && issued.has(value),\n { title: \"an issued Browserbase binding registration\" },\n);\n\nconst issue = <E, R>(\n metadata: Metadata,\n invoke: Registration<E, R>[typeof Invoke],\n): Registration<E, R> => {\n const registration = Object.freeze({\n ...metadata,\n origins: Object.freeze([...metadata.origins]),\n [Invoke]: invoke,\n });\n\n issued.add(registration);\n\n return registration;\n};\n\n/** Pack heterogeneous codecs and handlers while their concrete input/output types are known. */\nexport const make = <I, IEncoded, O, OEncoded, E, R>(\n options: Bootstrap.BindingOptions<I, IEncoded, O, OEncoded, E, R>,\n): Registration<E, R> => {\n const metadata = Schema.decodeSync(metadataSchema)(options);\n const { input, output, handle } = options;\n\n if (!Schema.isSchema(input) || !Schema.isSchema(output) || typeof handle !== \"function\") {\n throw new TypeError(\"Invalid binding registration\");\n }\n\n const fail = (reason: \"input\" | \"output\") =>\n InitializationError.make({ operation: \"callback\", step: metadata.name, reason });\n\n return issue(\n metadata,\n Effect.fnUntraced(function* (text, check) {\n if (new TextEncoder().encode(text).length > metadata.maxInputBytes)\n return yield* fail(\"input\");\n\n const decoded = yield* Schema.decodeEffect(Schema.fromJsonString(input))(text).pipe(\n Effect.catchCause(() => Effect.fail(fail(\"input\"))),\n );\n\n yield* check;\n const value = yield* Effect.suspend(() => handle(decoded));\n\n const encoded = yield* Schema.encodeEffect(output)(value).pipe(\n Effect.catchCause(() => Effect.fail(fail(\"output\"))),\n );\n\n const json = yield* Schema.decodeUnknownEffect(Schema.Json)(encoded).pipe(\n Effect.catchCause(() => Effect.fail(fail(\"output\"))),\n );\n\n const result = yield* Schema.encodeEffect(Schema.fromJsonString(Schema.Json))(json).pipe(\n Effect.catchCause(() => Effect.fail(fail(\"output\"))),\n );\n\n if (new TextEncoder().encode(result).length > metadata.maxOutputBytes)\n return yield* fail(\"output\");\n\n return result;\n }),\n );\n};\n\n/** Authentication is identity-based even when a caller copies every enumerable field/symbol. */\nexport const snapshot = Effect.fnUntraced(function* <E, R>(\n registration: Registration<E, R>,\n): Effect.fn.Return<Registration<E, R>, BrowserError> {\n const invalid = () =>\n BrowserError.make({ operation: \"configure\", reason: \"configuration\", outcome: \"undispatched\" });\n\n if (!issued.has(registration)) return yield* invalid();\n\n const metadata = yield* Schema.decodeEffect(metadataSchema)(registration).pipe(\n Effect.mapError(invalid),\n );\n\n return issue(metadata, registration[Invoke]);\n});\n\nexport const invoke = <E, R>(\n registration: Registration<E, R>,\n text: string,\n check: Effect.Effect<void, InitializationError>,\n): Effect.Effect<string, E | InitializationError, R> => registration[Invoke](text, check);\n","import { type Cause, type Effect, Schema } from \"effect\";\n\nimport type { InitializationError } from \"./Errors.ts\";\nimport * as Registration from \"./internal/browser/BindingRegistration.ts\";\nimport { Identifier } from \"./References.ts\";\n\n/**\n * Exact scheme-and-host origin, as a document reports it. Patterns are deliberately absent:\n * a registration that cannot say exactly where it applies does not belong in a plan.\n */\nexport const Origin = Registration.Origin;\n\nexport type Origin = typeof Origin.Type;\n\n/**\n * The reviewed subset of native permission capabilities. Each name is checked against a real\n * browser in native acceptance; an unsupported capability is refused before it is exposed.\n */\nexport const Permission = Schema.Literals([\n \"accelerometer\",\n \"background-sync\",\n \"camera\",\n \"clipboard-read\",\n \"clipboard-write\",\n \"geolocation\",\n \"gyroscope\",\n \"magnetometer\",\n \"microphone\",\n \"midi\",\n \"notifications\",\n \"payment-handler\",\n \"storage-access\",\n]);\n\nexport type Permission = typeof Permission.Type;\n\nexport const PermissionGrant = Schema.Struct({\n origin: Origin,\n permissions: Schema.Array(Permission).check(Schema.isMaxLength(16), Schema.isUnique()),\n});\n\nexport type PermissionGrant = typeof PermissionGrant.Type;\n\n/**\n * Registration is not readiness. A script may start asynchronous work, but it cannot pause the\n * website's own scripts, so a document is ready only when its expression resolves to exactly\n * `true`. A document that was already running when the bundle was registered never ran it:\n * `RequireFreshNavigation` reports that instead of pretending otherwise, and an explicit\n * reload of possibly uncertain work stays a caller's decision.\n */\nexport const Readiness = Schema.Struct({\n expression: Schema.NonEmptyString.check(Schema.isMaxLength(4096)),\n timeoutMillis: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 120_000 })),\n existingDocuments: Schema.Literals([\"RequireFreshNavigation\", \"AcceptAlreadyRunning\"]),\n});\n\nexport type Readiness = typeof Readiness.Type;\n\n/** Trusted host configuration. Script content is never model output or page input. */\nexport const InitScript = Schema.Struct({\n id: Identifier,\n content: Schema.NonEmptyString.check(Schema.isMaxLength(64 * 1024)),\n /** When present, the step runs only on these documents and readiness skips the rest. */\n origins: Schema.optionalKey(\n Schema.Array(Origin).check(Schema.isMaxLength(16), Schema.isUnique()),\n ),\n readiness: Schema.optionalKey(Readiness),\n});\n\nexport type InitScript = typeof InitScript.Type;\n\n/** A callback failure can reject one page invocation or permanently fence the session. */\nexport const BindingFailureMode = Registration.FailureMode;\n\nexport type BindingFailureMode = typeof BindingFailureMode.Type;\n\n/**\n * A registration issued by `binding`. Its private executable closure carries the real consumer\n * E/R; copying the metadata or fabricating an object does not grant callback authority.\n */\nexport type BindingRegistration<E = never, R = never> = Registration.Registration<E, R>;\n\n/**\n * Environment-free boundary codecs keep page data validation separate from consumer services.\n * The handler's E/R remain visible on the Plan and are supplied only by the trusted host.\n */\nexport interface BindingOptions<I, IEncoded, O, OEncoded, E, R> {\n readonly name: string;\n readonly origins: ReadonlyArray<Origin>;\n readonly input: Schema.ConstraintCodec<I, IEncoded, never, never>;\n readonly output: Schema.ConstraintCodec<O, OEncoded, never, never>;\n readonly maxConcurrent: number;\n readonly maxInputBytes: number;\n readonly maxOutputBytes: number;\n readonly timeoutMillis: number;\n readonly failureMode: BindingFailureMode;\n readonly handle: (input: I) => Effect.Effect<O, E, R>;\n}\n\n/**\n * One ordered bundle plus its host capabilities. Callback registrations preserve E/R through\n * their executable closures; static script/permission plans remain serializable values.\n */\nexport interface Plan<E = unknown, R = unknown> {\n readonly scripts: ReadonlyArray<InitScript>;\n readonly permissions: ReadonlyArray<PermissionGrant>;\n readonly bindings?: ReadonlyArray<BindingRegistration<E, R>>;\n}\n\n/** Host-only typed evidence. Causes are never logged or returned to page callers. */\nexport interface BindingFailure<E> {\n readonly name: string;\n readonly mode: BindingFailureMode;\n readonly cause: Cause.Cause<E | InitializationError>;\n}\n\nexport interface BindingStatistics {\n readonly name: string;\n readonly inFlight: number;\n readonly pendingNative: number;\n /** Finished/interrupted invocations whose native work or disposal has not settled. */\n readonly retired: number;\n readonly accepted: number;\n readonly succeeded: number;\n readonly rejected: number;\n}\n\n/** Copied snapshot: at most sixteen bindings and the latest thirty-two failure records. */\nexport interface BindingDiagnostics<E> {\n readonly faulted: boolean;\n readonly bindings: ReadonlyArray<BindingStatistics>;\n readonly failures: ReadonlyArray<BindingFailure<E>>;\n readonly droppedFailures: number;\n}\n\n/**\n * Static plans remain serializable. Live binding plans retain issued registrations by identity;\n * this schema neither executes their callbacks nor turns copied metadata into authority. Typed\n * acquisition validates a separate snapshot so consumer E/R is not erased by a generic decoder.\n */\nexport const Plan = Schema.Struct({\n scripts: Schema.Array(InitScript).check(Schema.isMaxLength(16)),\n permissions: Schema.Array(PermissionGrant).check(Schema.isMaxLength(16)),\n bindings: Schema.optionalKey(Schema.Array(Registration.schema).check(Schema.isMaxLength(16))),\n});\n\ntype AnyPlan = Plan<unknown, unknown>;\n\nexport type PlanError<P extends AnyPlan> = P extends Plan<infer E, infer _R> ? E : never;\nexport type PlanRequirements<P extends AnyPlan> = P extends Plan<infer _E, infer R> ? R : never;\n\nexport const empty: Plan<never, never> = { scripts: [], permissions: [] };\n\nexport const init = (script: InitScript): Plan<never, never> => ({\n scripts: [script],\n permissions: [],\n});\n\nexport const permissions = (grant: PermissionGrant): Plan<never, never> => ({\n scripts: [],\n permissions: [grant],\n});\n\n/**\n * Register a page-callable host callback without running it or capturing an ambient runtime.\n * Native installation later owns origin/document checks, bounded admission and disposal.\n */\nexport const binding = <I, IEncoded, O, OEncoded, E, R>(\n options: BindingOptions<I, IEncoded, O, OEncoded, E, R>,\n): Plan<E, R> => ({\n scripts: [],\n permissions: [],\n bindings: [Registration.make(options)],\n});\n\n/** Combination is ordered and preserves every callback's consumer E/R union. */\nexport function combine<const Plans extends ReadonlyArray<AnyPlan>>(\n ...plans: Plans\n): Plan<PlanError<Plans[number]>, PlanRequirements<Plans[number]>>;\n\nexport function combine(...plans: ReadonlyArray<AnyPlan>): AnyPlan {\n const bindings = plans.flatMap((plan) => (plan.bindings === undefined ? [] : [...plan.bindings]));\n\n return {\n scripts: plans.flatMap((plan) => [...plan.scripts]),\n permissions: plans.flatMap((plan) => [...plan.permissions]),\n ...(bindings.length === 0 ? {} : { bindings }),\n };\n}\n\n/** What the current document is, not a promise about any other document. */\nexport type ReadinessOutcome =\n | { readonly _tag: \"Ready\" }\n | { readonly _tag: \"NotApplicable\" }\n | { readonly _tag: \"RequiresNavigation\" };\n"],"mappings":";;;;;AAMA,MAAM,SAAS,OAAO,gCAAgC;AACtD,MAAM,yBAAS,IAAI,QAAgB;AAEnC,MAAaA,WAAS,OAAO,eAAe,MAC1C,OAAO,YAAY,IAAI,GACvB,OAAO,YACJ,UAAU;CACT,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,KAAK;EAEzB,OACE,CAAC,SAAS,QAAQ,CAAC,CAAC,SAAS,IAAI,QAAQ,KACzC,IAAI,WAAW,SACf,CAAC,IAAI,YACL,CAAC,IAAI;CAET,QAAQ;EACN,OAAO;CACT;AACF,GACA,EAAE,OAAO,0BAA0B,CACrC,CACF;AAEA,MAAa,cAAc,OAAO,SAAS,CAAC,eAAe,cAAc,CAAC;AAE1E,MAAM,iBAAiB,OAAO,OAAO;CACnC,MAAM;CACN,SAAS,OAAO,MAAMA,QAAM,CAAC,CAAC,MAC5B,OAAO,YAAY,EAAE,GACrB,OAAO,SAAS,GAChB,OAAO,YAAY,YAAY,QAAQ,SAAS,GAAG,EAAE,OAAO,8BAA8B,CAAC,CAC7F;CACA,eAAe,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAG,CAAC,CAAC;CAC7E,eA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