effect-browserbase 0.2.0-beta.0 → 0.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +47 -4
  2. package/dist/Account.d.mts +15 -15
  3. package/dist/Account.mjs +3 -3
  4. package/dist/{Acquisition-D8o4jtCg.mjs → Acquisition-CAsTTXp4.mjs} +9 -8
  5. package/dist/Acquisition-CAsTTXp4.mjs.map +1 -0
  6. package/dist/Agents-5HpTp9YE.d.mts +155 -0
  7. package/dist/Agents.d.mts +3 -154
  8. package/dist/Agents.mjs +3 -3
  9. package/dist/Allocation.d.mts +4 -4
  10. package/dist/Allocation.mjs +1 -1
  11. package/dist/Browser-DpSajNai.mjs +270 -0
  12. package/dist/Browser-DpSajNai.mjs.map +1 -0
  13. package/dist/Browser.d.mts +6 -5
  14. package/dist/Browser.mjs +2 -266
  15. package/dist/BrowserBinding.mjs +3 -3
  16. package/dist/BrowserBinding.mjs.map +1 -1
  17. package/dist/Certificates-D4NQmyeA.d.mts +34 -0
  18. package/dist/Certificates.d.mts +3 -33
  19. package/dist/Certificates.mjs +1 -1
  20. package/dist/{Client-BQteUePT.mjs → Client-4RMKIpL2.mjs} +11 -9
  21. package/dist/Client-4RMKIpL2.mjs.map +1 -0
  22. package/dist/Client-B_f6bBLT.d.mts +52 -0
  23. package/dist/Client.d.mts +3 -51
  24. package/dist/Client.mjs +1 -1
  25. package/dist/{Connection-DcvJZEdc.mjs → Connection-sxyxtwlk.mjs} +2 -11
  26. package/dist/Connection-sxyxtwlk.mjs.map +1 -0
  27. package/dist/ContextCoordination.d.mts +1 -1
  28. package/dist/ContextCoordination.mjs +1 -1
  29. package/dist/ContextCoordination.mjs.map +1 -1
  30. package/dist/{ContextWriter-BrQmoXRg.mjs → ContextWriter-oKWFLHuP.mjs} +8 -12
  31. package/dist/ContextWriter-oKWFLHuP.mjs.map +1 -0
  32. package/dist/Contexts-DqdL7cyX.d.mts +31 -0
  33. package/dist/Contexts.d.mts +3 -30
  34. package/dist/Contexts.mjs +2 -2
  35. package/dist/Contexts.mjs.map +1 -1
  36. package/dist/Downloads-CdhiCO5X.d.mts +43 -0
  37. package/dist/Downloads.d.mts +3 -42
  38. package/dist/Downloads.mjs +2 -2
  39. package/dist/Downloads.mjs.map +1 -1
  40. package/dist/Extensions-DBXuVM1f.d.mts +43 -0
  41. package/dist/{Extensions-nMNMPGCc.mjs → Extensions-Dg3jHOf0.mjs} +2 -2
  42. package/dist/Extensions-Dg3jHOf0.mjs.map +1 -0
  43. package/dist/Extensions.d.mts +3 -42
  44. package/dist/Extensions.mjs +1 -1
  45. package/dist/Functions-CsKMMUuZ.d.mts +226 -0
  46. package/dist/Functions.d.mts +3 -225
  47. package/dist/Functions.mjs +3 -3
  48. package/dist/{Launch-m0fxzJ49.mjs → Launch-cAdE2rrZ.mjs} +12 -8
  49. package/dist/Launch-cAdE2rrZ.mjs.map +1 -0
  50. package/dist/Launch.d.mts +1 -4
  51. package/dist/Launch.mjs +1 -2
  52. package/dist/Launch.mjs.map +1 -1
  53. package/dist/PageFetch-CAMqb5m8.d.mts +39 -0
  54. package/dist/PageFetch.d.mts +3 -38
  55. package/dist/PageFetch.mjs +1 -1
  56. package/dist/Projects-tm5bTDH0.d.mts +38 -0
  57. package/dist/Projects.d.mts +3 -37
  58. package/dist/Projects.mjs +1 -1
  59. package/dist/Recordings-bVI33sTq.d.mts +27 -0
  60. package/dist/Recordings.d.mts +3 -26
  61. package/dist/Recordings.mjs +2 -2
  62. package/dist/Replays-Bo-9xeLz.d.mts +27 -0
  63. package/dist/Replays.d.mts +3 -26
  64. package/dist/Replays.mjs +2 -2
  65. package/dist/Search-1g6TUem7.d.mts +37 -0
  66. package/dist/Search.d.mts +3 -36
  67. package/dist/Search.mjs +1 -1
  68. package/dist/{Sessions-tFJYaXFq.d.mts → Sessions-BpZgjteE.d.mts} +2 -2
  69. package/dist/{Sessions-DoQGg9nB.mjs → Sessions-suOLSym9.mjs} +2 -2
  70. package/dist/Sessions-suOLSym9.mjs.map +1 -0
  71. package/dist/Sessions.d.mts +1 -1
  72. package/dist/Sessions.mjs +1 -1
  73. package/dist/Testing.d.mts +119 -0
  74. package/dist/Testing.mjs +206 -0
  75. package/dist/Testing.mjs.map +1 -0
  76. package/dist/Uploads-C2neBEpj.d.mts +28 -0
  77. package/dist/Uploads.d.mts +3 -27
  78. package/dist/Uploads.mjs +2 -2
  79. package/dist/Webhooks-BoeRAxzG.d.mts +59 -0
  80. package/dist/Webhooks.d.mts +3 -58
  81. package/dist/Webhooks.mjs +1 -1
  82. package/dist/{WriterFacts-5CPBGG1P.d.mts → WriterFacts-BBJRDZYY.d.mts} +5 -13
  83. package/package.json +6 -2
  84. package/dist/Acquisition-D8o4jtCg.mjs.map +0 -1
  85. package/dist/Browser.mjs.map +0 -1
  86. package/dist/Client-BQteUePT.mjs.map +0 -1
  87. package/dist/Connection-DcvJZEdc.mjs.map +0 -1
  88. package/dist/ContextWriter-BrQmoXRg.mjs.map +0 -1
  89. package/dist/Extensions-nMNMPGCc.mjs.map +0 -1
  90. package/dist/Launch-m0fxzJ49.mjs.map +0 -1
  91. package/dist/Sessions-DoQGg9nB.mjs.map +0 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  `effect-browserbase` supplies Browserbase resources and hosted lifetimes to the shared browser runtime: account identity and transport, session, context and extension resources, one owned browser over Playwright/CDP — allocated or borrowed — with trusted registrations, modeled file selection, bounded live capture, explicit page holds, the provider's recordings, replays, uploads and website downloads, and the platform APIs outside a browser session (projects, certificates, Search, Fetch, Agents, Functions and webhooks).
4
4
 
5
- Its host supplies the required `effect-browser` peer, at the same coordinated `0.2.0-beta.0` version for this candidate; it has no Effect Agent dependency. Install both packages explicitly so the provider and application share one runtime instance. Playwright is an optional peer of the shared runtime and is loaded only when a browser connects; artifact-only consumers do not need it. The existing Effect peer range remains `^4.0.0-rc.115`, with only rc.115 qualified by this candidate. The package targets trusted Node and Bun hosts. It is an unpublished maintainer-review candidate: hosted provider behavior requires separate validation, and ordinary tests never create a paid Browserbase session or invoke a paid model.
5
+ Its host supplies the required `effect-browser` peer, at the same coordinated `0.2.0-beta.1` version; it has no Effect Agent dependency. Install both packages explicitly so the provider and application share one runtime instance. Playwright is an optional peer of the shared runtime and is loaded only when a browser connects; artifact-only consumers do not need it. The existing Effect peer range remains `^4.0.0-rc.115`, with only rc.115 qualified. The package targets trusted Node and Bun hosts. It is published as a beta (`0.2.0-beta.0` on the `beta` dist-tag): hosted provider behavior requires separate validation, and ordinary tests never create a paid Browserbase session or invoke a paid model.
6
6
 
7
7
  ## One account, then resources
8
8
 
@@ -19,7 +19,7 @@ const account = Account.layerConfig({
19
19
  });
20
20
  ```
21
21
 
22
- `Account.layer({ projectId, apiKey: Redacted.make(key), ... })` takes the same authority explicitly. Either one bundles every resource service on a single Client, so credentials are composed once instead of per service; each service still exports its own `layer` when you want a narrower set. `BrowserbaseBrowser.layer` stays separate, because a browser also fixes budgets and a connection lifetime that an account does not. The Client uses Effect's `FetchHttpClient.Fetch` reference, which already defaults to `globalThis.fetch`; provide a different `fetch` only when you need one.
22
+ `Account.layer({ projectId, apiKey: Redacted.make(key), ... })` takes the same authority explicitly. Either one bundles every resource service on a single Client, so credentials are composed once instead of per service; each service still exports its own `layer` when you want a narrower set. `BrowserbaseBrowser.layer` stays separate, because a browser also fixes budgets and a connection lifetime that an account does not. It also requires Effect's `Crypto` from the host platform (`NodeServices.layer`, `BunServices.layer` or `NodeCrypto.layer`), which supplies allocation attempt ids, connection ids and handoff tokens; the account services need no `Crypto`. The Client uses Effect's `FetchHttpClient.Fetch` reference, which already defaults to `globalThis.fetch`; provide a different `fetch` only when you need one.
23
23
 
24
24
  `artifactOrigins` is the exact set of HTTPS origins this client will fetch provider media from, and it is deliberately empty by default: recording downloads and replay media are refused with `unsafe-url` until you approve a host. Browserbase documents only a "signed CDN URL" and does not publish that origin, so discover your own rather than copying anyone's — request a recording for a completed session, read `downloadUrl` from `GET /v1/sessions/{id}/recording/downloads`, and approve exactly its origin. A hosted run on 21 September 2026 confirmed that a completed recording then downloads through this check rather than around it. The origin is an observation and not a contract: it may differ by project or region, the provider can re-point it without notice, and a BYOS project returns no signed URL at all. Treat a later `unsafe-url` as the delivery host having moved, not as a defect.
25
25
 
@@ -34,6 +34,7 @@ const account = Account.layerConfig({
34
34
  For the simplest post-session video path, opt in to Browserbase recording in the launch recipe:
35
35
 
36
36
  ```ts
37
+ import { NodeServices } from "@effect/platform-node";
37
38
  import { BrowserbaseBrowser } from "effect-browserbase/browser";
38
39
  import * as Browser from "effect-browser/browser";
39
40
  import { BrowserPolicy, NavigateRequest } from "effect-browser/browser-data";
@@ -50,6 +51,7 @@ const policy = BrowserPolicy.unrestricted();
50
51
 
51
52
  const layers = Layer.merge(BrowserbaseBrowser.layer({ launch }), BrowserbaseRecordings.layer).pipe(
52
53
  Layer.provide(account),
54
+ Layer.provide(NodeServices.layer),
53
55
  );
54
56
 
55
57
  const program = Effect.gen(function* () {
@@ -116,7 +118,7 @@ Prefer provider recording when post-session MP4/HLS is enough. Use `capture` whe
116
118
 
117
119
  That split is why an agent can use one browser for many turns while provider artifacts remain accessible after the interactive scope ends. Importing a Layer does not allocate a browser.
118
120
 
119
- `Allocation.scoped(recipe)` allocates a session without connecting a browser, for a caller that drives the remote session with its own automation client. It is the same allocation path the browser owner uses, so the creation request is never retried, an unknown outcome is still reported exactly once, a persisting Context still needs a live writer permit, and no native peer is loaded. The scope owns the release: closing it releases the session whether or not anything ever connected. A reply naming another project is refused, and because a foreign reference is never acted on, the caller is handed that reference rather than a mutation attempted against it.
121
+ `Allocation.scoped(recipe)` allocates a session without connecting a browser, for a caller that drives the remote session with its own automation client. It is the same allocation path the browser owner uses, so the creation request is never retried, an unknown outcome is still reported exactly once, a persisting Context still needs a live writer permit, and no native peer is loaded. The scope owns the release: closing it releases the session whether or not anything ever connected. A reply naming another project is refused, and because a foreign reference is never acted on, the caller is handed that reference rather than a mutation attempted against it. The attempt id comes from Effect's `Crypto`, so `Allocation.scoped` requires that service beside the account.
120
122
 
121
123
  The shared browser runtime delegates allocation and release to this provider lifetime. It supplies the local half of cleanup — fence, capture stop, initialization teardown, disconnect — and the canonical control plane owns the release request and the terminal status observation. A local disconnect, an accepted provider release request and provider-confirmed termination therefore stay distinct facts in one `CleanupResult`, together with the exact steps that failed.
122
124
 
@@ -223,6 +225,46 @@ A host that does this still selects `Unrestricted` here, and the containment cla
223
225
 
224
226
  What this package does check is input, not requests. `controlFacts` and an `admit` policy ([above](#what-is-on-screen-and-what-a-host-may-know-about-it)) let a host that drives the session refuse a link or a form by its resolved destination before anything is sent. That limits what the host's own automation acts on. It does not limit what a page loads, or where it redirects.
225
227
 
228
+ ## Testing against a scripted control plane
229
+
230
+ `effect-browserbase/testing` supplies the provider side of a test the way `effect-browser/testing` supplies the browser side. `Testing.provider(script)` returns a `fetch` for `FetchHttpClient.Fetch` and a `ProviderControl` handle; the real `Client`, `Sessions`, `Uploads`, allocation and cleanup code parse its replies, apply their bounds and reconcile release against it. The script says how creation answers (`Accept`, `Reject` with a status the transport classifies and an optional `retryAfterMillis`, `Malformed`, or `Lost` after the request was sent, so the allocation outcome is unknown), whether a release request is `confirmed`, stays `pending` or fails, whether a Live View is issued, and whose identity a session's retrieval and release replies carry (`own`, `foreign-session` or `foreign-project`). Its secrets are marker strings, so evidence can be grepped for a leak, and nothing in it is a credential.
231
+
232
+ `Testing.layer({ browser, provider?, launch?, options? })` composes that control plane under the real `Account.layer` and `BrowserbaseBrowser.layer`, with the scripted engine from `effect-browser/testing` as the `BrowserBinding` and its `sequentialCrypto` as the browser's `Crypto`, and adds a `ScriptedBrowserbase` service whose `provider` is the control handle and whose `browsers` are the engine control handles, one per provider session: a keep-alive reconnection or a borrowed attachment reaches the same scripted browser again, with the pages it kept. An application written against `BrowserbaseBrowser.open` runs unchanged:
233
+
234
+ ```ts
235
+ import { expect, it } from "@effect/vitest";
236
+ import { Effect } from "effect";
237
+ import * as Browser from "effect-browser/browser";
238
+ import { BrowserPolicy } from "effect-browser/browser-data";
239
+ import { BrowserbaseBrowser } from "effect-browserbase/browser";
240
+ import * as Testing from "effect-browserbase/testing";
241
+
242
+ it.effect("release is requested once and confirmed", () =>
243
+ Effect.gen(function* () {
244
+ const scripted = yield* Testing.ScriptedBrowserbase;
245
+
246
+ const receipt = yield* Browser.scoped(
247
+ BrowserbaseBrowser.open(BrowserPolicy.unrestricted()),
248
+ (session) =>
249
+ Effect.gen(function* () {
250
+ yield* session.navigate({ url: "https://shop.test/" });
251
+
252
+ return yield* session.closeChecked;
253
+ }),
254
+ );
255
+
256
+ expect(receipt).toMatchObject({ releaseRequested: true, remote: "confirmed", local: "closed" });
257
+ expect(yield* scripted.provider.sessions).toMatchObject([
258
+ { id: "session-1", status: "COMPLETED", releaseRequests: 1 },
259
+ ]);
260
+ }).pipe(Effect.provide(Testing.layer({ browser: shop }))),
261
+ );
262
+ ```
263
+
264
+ Sessions are numbered `session-1`, `session-2`, … in creation order. A `pending` release leaves the session `RUNNING`, so checked close fails `Provider` with outcome `unknown` after the real status bound elapses, and the receipt carries `remote: "pending"`; under `it.effect` a `TestClock.adjust` reaches that bound with nothing real elapsing. A `Lost` creation makes `onAllocationUncertain` fire once, as it does when a real request is cut off. A `foreign-session` or `foreign-project` identity makes connection fail `Malformed` before any page is reached, and no reply about the other session can confirm this one's release, so its receipt carries `remote: "unknown"`. Borrowed attachment through `attach` makes a second connection to the owner's scripted browser, which its control lists under `connections`, and no release request. `Allocation.scoped`, `BrowserbaseSessions` and the other resource services run over the same `fetch` with `Testing.provider()` alone, with no browser at all; `Allocation.scoped` also takes a `Crypto`, and `sequentialCrypto` from `effect-browser/testing` keeps its attempt ids predictable.
265
+
266
+ What a scripted control plane answers is what this repository has read of the provider API, replayed. It establishes that this package handles those answers correctly; it establishes nothing about what Browserbase answers today, which only the hosted checks in [Status](../../docs/STATUS.md) record.
267
+
226
268
  ## Beyond the browser session
227
269
 
228
270
  These services share the Client and its rules: strict input decoding, identity-checked replies, 1 MiB reply bounds, mutations that are never retried, and typed failures whose `outcome` says whether a request was sent. They are host APIs; none of them is exposed to a model by the adapter package.
@@ -251,6 +293,7 @@ An agent run or Function invocation that persists a Context writes it from Brows
251
293
  - `downloads` — ordinary website download metadata, provider-side filters, bounded byte streams and deletion, separate from provider recordings.
252
294
  - `projects`, `certificates` — project inspection and usage; proxy CA certificate administration.
253
295
  - `search`, `page-fetch`, `agents`, `functions`, `webhooks` — the Browserbase platform APIs outside a browser session.
296
+ - `testing` — a scripted control plane as `fetch`, and the real account and browser Layers composed over it and over the scripted engine from `effect-browser/testing`.
254
297
 
255
298
  Every expected failure says three things. `operation` is what you asked for, from a closed vocabulary per error class: `BrowserError` names the browser operations, `SessionError` only session calls, and so on, so you can match on them exhaustively and a misspelling is a type error, not a string that happens to compile. `reason` is why it failed. `outcome`, when present, is whether the work was sent: `undispatched` is safe to retry, `rejected` was refused, and `unknown` means a mutation may have happened and is never replayed for you. Why an extension archive was refused is a `reason` (`limit`, `unsafe-filename`, `configuration`) of the one `extension-archive` operation. A native step's own name never appears: the driver raises a private failure, and the owner stamps the operation it admitted.
256
299
 
@@ -268,4 +311,4 @@ Live frames and page holds follow the common [capture guarantees](../browser/REA
268
311
 
269
312
  ## Development and evidence
270
313
 
271
- Read [Contributing](../../CONTRIBUTING.md) for the frozen compatibility workspace and required checks. Provider unit tests cover HTTP/resources and release reconciliation. Cross-package source regression tests live in `test/integration`. The `generic` and `agent-hosted` installed consumers run the maintained native suites against real Chromium with scripted provider HTTP; the `resources` consumer installs no Playwright or Effect Agent. Hosted evidence remains separately recorded in [Status](../../docs/STATUS.md) and never inferred from a local pass.
314
+ Read [Contributing](../../CONTRIBUTING.md) for the frozen compatibility workspace and required checks. Provider unit tests cover HTTP/resources and release reconciliation; `test/testing.test.ts` runs the public scripted control plane and Layer through the real allocation and cleanup code. Provider regressions that need a browser, such as release reconciliation around a held teardown or a keep-alive reconnection, run over the same public entries in this package's `test/`. The `generic` and `agent-hosted` installed consumers run the maintained native suites against real Chromium with scripted provider HTTP; the `resources` consumer installs no Playwright or Effect Agent, and it also opens scripted browsers through both testing entry points from the packed tarballs. Hosted evidence remains separately recorded in [Status](../../docs/STATUS.md) and never inferred from a local pass.
@@ -1,19 +1,19 @@
1
1
  import { ClientError } from "./Errors.mjs";
2
- import { BrowserbaseClient, ClientOptions } from "./Client.mjs";
3
- import { BrowserbaseAgents } from "./Agents.mjs";
4
- import { BrowserbaseCertificates } from "./Certificates.mjs";
5
- import { BrowserbaseContexts } from "./Contexts.mjs";
6
- import { t as BrowserbaseSessions } from "./Sessions-tFJYaXFq.mjs";
7
- import { BrowserbaseDownloads } from "./Downloads.mjs";
8
- import { BrowserbaseExtensions } from "./Extensions.mjs";
9
- import { BrowserbaseFunctions } from "./Functions.mjs";
10
- import { BrowserbasePageFetch } from "./PageFetch.mjs";
11
- import { BrowserbaseProjects } from "./Projects.mjs";
12
- import { BrowserbaseRecordings } from "./Recordings.mjs";
13
- import { BrowserbaseReplays } from "./Replays.mjs";
14
- import { BrowserbaseSearch } from "./Search.mjs";
15
- import { BrowserbaseUploads } from "./Uploads.mjs";
16
- import { BrowserbaseWebhooks } from "./Webhooks.mjs";
2
+ import { r as ClientOptions, t as BrowserbaseClient } from "./Client-B_f6bBLT.mjs";
3
+ import { p as BrowserbaseAgents } from "./Agents-5HpTp9YE.mjs";
4
+ import { t as BrowserbaseCertificates } from "./Certificates-D4NQmyeA.mjs";
5
+ import { t as BrowserbaseContexts } from "./Contexts-DqdL7cyX.mjs";
6
+ import { t as BrowserbaseSessions } from "./Sessions-BpZgjteE.mjs";
7
+ import { t as BrowserbaseDownloads } from "./Downloads-CdhiCO5X.mjs";
8
+ import { t as BrowserbaseExtensions } from "./Extensions-DBXuVM1f.mjs";
9
+ import { t as BrowserbaseFunctions } from "./Functions-CsKMMUuZ.mjs";
10
+ import { t as BrowserbasePageFetch } from "./PageFetch-CAMqb5m8.mjs";
11
+ import { t as BrowserbaseProjects } from "./Projects-tm5bTDH0.mjs";
12
+ import { t as BrowserbaseRecordings } from "./Recordings-bVI33sTq.mjs";
13
+ import { t as BrowserbaseReplays } from "./Replays-Bo-9xeLz.mjs";
14
+ import { t as BrowserbaseSearch } from "./Search-1g6TUem7.mjs";
15
+ import { t as BrowserbaseUploads } from "./Uploads-C2neBEpj.mjs";
16
+ import { t as BrowserbaseWebhooks } from "./Webhooks-BoeRAxzG.mjs";
17
17
  import { Config, Layer } from "effect";
18
18
  //#region src/Account.d.ts
19
19
  /** Every resource service this package owns, on one account's authority. */
package/dist/Account.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { t as BrowserbaseClient } from "./Client-BQteUePT.mjs";
1
+ import { t as BrowserbaseClient } from "./Client-4RMKIpL2.mjs";
2
2
  import { BrowserbaseAgents } from "./Agents.mjs";
3
3
  import { BrowserbaseCertificates } from "./Certificates.mjs";
4
4
  import { BrowserbaseContexts } from "./Contexts.mjs";
5
- import { t as BrowserbaseSessions } from "./Sessions-DoQGg9nB.mjs";
5
+ import { t as BrowserbaseSessions } from "./Sessions-suOLSym9.mjs";
6
6
  import { BrowserbaseDownloads } from "./Downloads.mjs";
7
- import { t as BrowserbaseExtensions } from "./Extensions-nMNMPGCc.mjs";
7
+ import { t as BrowserbaseExtensions } from "./Extensions-Dg3jHOf0.mjs";
8
8
  import { BrowserbaseFunctions } from "./Functions.mjs";
9
9
  import { BrowserbasePageFetch } from "./PageFetch.mjs";
10
10
  import { BrowserbaseProjects } from "./Projects.mjs";
@@ -1,12 +1,12 @@
1
1
  import { Identifier, SessionReference } from "./References.mjs";
2
2
  import { AllocationError, ContextError, SessionError } from "./Errors.mjs";
3
- import { t as BrowserbaseClient } from "./Client-BQteUePT.mjs";
4
- import { t as compileLaunch } from "./Launch-m0fxzJ49.mjs";
3
+ import { t as BrowserbaseClient } from "./Client-4RMKIpL2.mjs";
4
+ import { t as compileLaunch } from "./Launch-cAdE2rrZ.mjs";
5
5
  import { CleanupIssue, CleanupResult } from "./Cleanup.mjs";
6
- import { i as requireContextWriterPermit } from "./ContextWriter-BrQmoXRg.mjs";
7
- import { t as BrowserbaseSessions } from "./Sessions-DoQGg9nB.mjs";
8
- import { t as connectionAddress } from "./Connection-DcvJZEdc.mjs";
9
- import { Cause, Clock, Data, Effect, ErrorReporter, Exit, Option, Schema, Scope } from "effect";
6
+ import { i as requireContextWriterPermit } from "./ContextWriter-oKWFLHuP.mjs";
7
+ import { t as BrowserbaseSessions } from "./Sessions-suOLSym9.mjs";
8
+ import { t as connectionAddress } from "./Connection-sxyxtwlk.mjs";
9
+ import { Cause, Clock, Crypto, Data, Effect, ErrorReporter, Exit, Option, Schema, Scope } from "effect";
10
10
  import { cleanupStep, noConnection, reported } from "effect-browser/browser-runtime";
11
11
  //#region src/internal/session/Cleanup.ts
12
12
  const noLocalConnection = noConnection;
@@ -116,10 +116,11 @@ const AllocatedIdentity = Schema.Struct({
116
116
  const acquireRemote = Effect.fnUntraced(function* (options, local = noLocalConnection, limits) {
117
117
  const client = yield* BrowserbaseClient;
118
118
  const sessions = yield* BrowserbaseSessions;
119
+ const crypto = yield* Crypto.Crypto;
119
120
  const parent = yield* Scope.Scope;
120
121
  const launch = yield* compileLaunch(options.launch, {
121
122
  projectId: client.projectId,
122
- attemptId: globalThis.crypto.randomUUID(),
123
+ attemptId: yield* Effect.orDie(crypto.randomUUIDv4),
123
124
  requestedAtMillis: yield* Clock.currentTimeMillis
124
125
  });
125
126
  const attempt = launch.attempt;
@@ -231,4 +232,4 @@ const acquireRemote = Effect.fnUntraced(function* (options, local = noLocalConne
231
232
  //#endregion
232
233
  export { reported as a, noLocalConnection as i, reportCleanup as n, makeCleanup as r, acquireRemote as t };
233
234
 
234
- //# sourceMappingURL=Acquisition-D8o4jtCg.mjs.map
235
+ //# sourceMappingURL=Acquisition-CAsTTXp4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Acquisition-CAsTTXp4.mjs","names":[],"sources":["../src/internal/session/Cleanup.ts","../src/internal/session/Diagnostics.ts","../src/internal/session/Acquisition.ts"],"sourcesContent":["import { Effect, Option } from \"effect\";\nimport { cleanupStep, noConnection, type ConnectionCleanup } from \"effect-browser/browser-runtime\";\n\nexport { reported } from \"effect-browser/browser-runtime\";\nexport type { ConnectionCleanup as LocalCleanup } from \"effect-browser/browser-runtime\";\n\nimport { CleanupIssue, CleanupResult } from \"../../Cleanup.ts\";\nimport type { SessionReference } from \"../../References.ts\";\nimport type { SessionStatus } from \"../../SessionData.ts\";\nimport type { BrowserbaseSessions } from \"../../Sessions.ts\";\n\nexport const noLocalConnection = noConnection;\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: ConnectionCleanup,\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 cleanupStep(action, milliseconds).pipe(\n Effect.tap((result) =>\n Effect.sync(() => {\n if (result._tag === \"Failure\")\n issues.push(CleanupIssue.make({ step: name, reason: result.reason }));\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 = disconnected._tag === \"Success\" ? 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 = requested._tag === \"Success\";\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 (terminal._tag === \"Success\") {\n remote = \"confirmed\";\n observedStatus = terminal.value.status;\n } else if (requested._tag === \"Success\") {\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 override readonly [ErrorReporter.severity] = \"Warn\" as const;\n\n override 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, Crypto, 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 crypto = yield* Crypto.Crypto;\n const parent = yield* Scope.Scope;\n\n const launch = yield* compileLaunch(options.launch, {\n projectId: client.projectId,\n // Secure randomness is a platform precondition, so its failure is a defect, not an outcome.\n attemptId: yield* Effect.orDie(crypto.randomUUIDv4),\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 const result = cleanup;\n const notify = options.onCleanup;\n\n if (result !== undefined) {\n yield* reported(Effect.suspend(() => reportCleanup(result)));\n if (notify !== undefined) yield* reported(Effect.suspend(() => notify(result)));\n }\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":";;;;;;;;;;;AAWA,MAAa,oBAAoB;AASjC,MAAa,uBAAsC;CACjD,iBAAiB;CACjB,eAAe;CACf,gBAAgB;AAClB;;;;;;AAOA,MAAa,cAAc,OAAO,WAAW,WAC3C,WACA,WACA,UACA,OACA,QACA,SAAwB,sBACxB;CACA,IAAI;CA2EJ,OAAO;EACL,OAAA,OA1EmB,OAAO,OAC1B,OAAO,gBACL,OAAO,IAAI,aAAa;GACtB,MAAM,SAAyB,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;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"}
@@ -0,0 +1,155 @@
1
+ import { n as ContextReference } from "./References-DOH3Wu44.mjs";
2
+ import { PlatformError } from "./Errors.mjs";
3
+ import { t as BrowserbaseClient } from "./Client-B_f6bBLT.mjs";
4
+ import { Context, Effect, Layer, Schema } from "effect";
5
+ //#region src/Agents.d.ts
6
+ declare const AgentRunStatus: Schema.Literals<readonly ["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"]>;
7
+ type AgentRunStatus = typeof AgentRunStatus.Type;
8
+ declare const isTerminalAgentRunStatus: (status: AgentRunStatus) => boolean;
9
+ declare const AgentMetadata_base: Schema.Class<AgentMetadata, Schema.Struct<{
10
+ readonly agentId: Schema.NonEmptyString;
11
+ readonly name: Schema.String;
12
+ readonly systemPrompt: Schema.optionalKey<Schema.String>;
13
+ readonly resultSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
14
+ readonly createdAt: Schema.String;
15
+ readonly updatedAt: Schema.String;
16
+ }>, {}>;
17
+ declare class AgentMetadata extends AgentMetadata_base {}
18
+ declare const AgentRun_base: Schema.Class<AgentRun, Schema.Struct<{
19
+ readonly runId: Schema.NonEmptyString;
20
+ readonly agentId: Schema.optionalKey<Schema.NonEmptyString>;
21
+ readonly task: Schema.String;
22
+ readonly status: Schema.Literals<readonly ["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"]>;
23
+ readonly sessionId: Schema.optionalKey<Schema.NonEmptyString>;
24
+ readonly sandboxId: Schema.optionalKey<Schema.String>;
25
+ readonly resultSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
26
+ readonly result: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
27
+ readonly cause: Schema.optionalKey<Schema.Struct<{
28
+ readonly code: Schema.String;
29
+ readonly message: Schema.optionalKey<Schema.String>;
30
+ }>>;
31
+ readonly startedAt: Schema.optionalKey<Schema.String>;
32
+ readonly endedAt: Schema.optionalKey<Schema.String>;
33
+ readonly createdAt: Schema.String;
34
+ readonly updatedAt: Schema.String;
35
+ }>, {}>;
36
+ declare class AgentRun extends AgentRun_base {}
37
+ declare const AgentRunMessage_base: Schema.Class<AgentRunMessage, Schema.Struct<{
38
+ readonly id: Schema.String;
39
+ readonly createdAt: Schema.String;
40
+ readonly role: Schema.Literals<readonly ["assistant", "tool"]>;
41
+ readonly content: Schema.Codec<Schema.Json, Schema.Json, never, never>;
42
+ }>, {}>;
43
+ declare class AgentRunMessage extends AgentRunMessage_base {}
44
+ declare const AgentDefinition: Schema.Struct<{
45
+ readonly name: Schema.NonEmptyString;
46
+ readonly systemPrompt: Schema.optionalKey<Schema.String>;
47
+ readonly resultSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
48
+ }>;
49
+ type AgentDefinition = typeof AgentDefinition.Type;
50
+ declare const AgentUpdate: Schema.Struct<{
51
+ readonly name: Schema.optionalKey<Schema.NonEmptyString>;
52
+ readonly systemPrompt: Schema.optionalKey<Schema.String>;
53
+ readonly resultSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
54
+ }>;
55
+ type AgentUpdate = typeof AgentUpdate.Type;
56
+ declare const AgentRunRequest: Schema.Struct<{
57
+ readonly task: Schema.NonEmptyString;
58
+ readonly agentId: Schema.optionalKey<Schema.NonEmptyString>;
59
+ readonly resultSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
60
+ readonly variables: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
61
+ readonly value: Schema.String;
62
+ readonly description: Schema.optionalKey<Schema.String>;
63
+ }>>>;
64
+ readonly browserSettings: Schema.optionalKey<Schema.Struct<{
65
+ /**
66
+ * A persisting run writes the Context from Browserbase's side, outside
67
+ * `ContextCoordination.withWriter`. It is refused while a local writer holds the
68
+ * Context, but nothing stops a later local writer from racing the hosted run.
69
+ */
70
+ readonly context: Schema.optionalKey<Schema.Struct<{
71
+ readonly reference: typeof ContextReference;
72
+ readonly persist: Schema.Boolean;
73
+ }>>;
74
+ readonly proxies: Schema.optionalKey<Schema.Union<readonly [Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
75
+ readonly type: Schema.Literal<"browserbase">;
76
+ readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
77
+ readonly geolocation: Schema.optionalKey<Schema.Struct<{
78
+ readonly country: Schema.String;
79
+ readonly state: Schema.optionalKey<Schema.String>;
80
+ readonly city: Schema.optionalKey<Schema.NonEmptyString>;
81
+ }>>;
82
+ }>, Schema.Struct<{
83
+ readonly type: Schema.Literal<"external">;
84
+ readonly server: Schema.NonEmptyString;
85
+ readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
86
+ readonly username: Schema.optionalKey<Schema.Redacted<Schema.String>>;
87
+ readonly password: Schema.optionalKey<Schema.Redacted<Schema.String>>;
88
+ }>, Schema.Struct<{
89
+ readonly type: Schema.Literal<"none">;
90
+ readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
91
+ }>]>>]>>;
92
+ readonly verified: Schema.optionalKey<Schema.Boolean>;
93
+ }>>;
94
+ }>;
95
+ type AgentRunRequest = typeof AgentRunRequest.Type;
96
+ declare const AgentListQuery: Schema.Struct<{
97
+ readonly startAt: Schema.optionalKey<Schema.String>;
98
+ readonly endAt: Schema.optionalKey<Schema.String>;
99
+ readonly cursor: Schema.optionalKey<Schema.NonEmptyString>;
100
+ readonly limit: Schema.optionalKey<Schema.Int>;
101
+ }>;
102
+ type AgentListQuery = typeof AgentListQuery.Type;
103
+ declare const AgentRunListQuery: Schema.Struct<{
104
+ readonly startAt: Schema.optionalKey<Schema.String>;
105
+ readonly endAt: Schema.optionalKey<Schema.String>;
106
+ readonly cursor: Schema.optionalKey<Schema.NonEmptyString>;
107
+ readonly status: Schema.optionalKey<Schema.Literals<readonly ["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"]>>;
108
+ readonly agentId: Schema.optionalKey<Schema.NonEmptyString>;
109
+ readonly limit: Schema.optionalKey<Schema.Int>;
110
+ }>;
111
+ type AgentRunListQuery = typeof AgentRunListQuery.Type;
112
+ declare const AgentMessageQuery: Schema.Struct<{
113
+ readonly since: Schema.optionalKey<Schema.NonEmptyString>;
114
+ readonly limit: Schema.optionalKey<Schema.Int>;
115
+ readonly all: Schema.optionalKey<Schema.Boolean>;
116
+ }>;
117
+ type AgentMessageQuery = typeof AgentMessageQuery.Type;
118
+ declare const AgentRunWaitOptions: Schema.Struct<{
119
+ readonly timeoutMillis: Schema.Int;
120
+ readonly pollIntervalMillis: Schema.optionalKey<Schema.Int>;
121
+ }>;
122
+ type AgentRunWaitOptions = typeof AgentRunWaitOptions.Type;
123
+ interface Page<A> {
124
+ readonly items: ReadonlyArray<A>;
125
+ readonly nextCursor: string | undefined;
126
+ }
127
+ interface AgentMessages {
128
+ readonly messages: ReadonlyArray<AgentRunMessage>;
129
+ readonly nextSince: string | undefined;
130
+ }
131
+ declare const BrowserbaseAgents_base: Context.ServiceClass<BrowserbaseAgents, "effect-browserbase/Agents", {
132
+ readonly create: (definition: AgentDefinition) => Effect.Effect<AgentMetadata, PlatformError>;
133
+ readonly list: (query?: AgentListQuery) => Effect.Effect<Page<AgentMetadata>, PlatformError>;
134
+ readonly retrieve: (agentId: string) => Effect.Effect<AgentMetadata, PlatformError>;
135
+ readonly update: (agentId: string, update: AgentUpdate) => Effect.Effect<AgentMetadata, PlatformError>;
136
+ readonly delete: (agentId: string) => Effect.Effect<void, PlatformError>;
137
+ readonly run: (request: AgentRunRequest) => Effect.Effect<AgentRun, PlatformError>;
138
+ readonly retrieveRun: (runId: string) => Effect.Effect<AgentRun, PlatformError>;
139
+ readonly listRuns: (query?: AgentRunListQuery) => Effect.Effect<Page<AgentRun>, PlatformError>;
140
+ readonly stopRun: (runId: string) => Effect.Effect<AgentRun, PlatformError>;
141
+ readonly messages: (runId: string, query?: AgentMessageQuery) => Effect.Effect<AgentMessages, PlatformError>;
142
+ /** Polls until the run is terminal. Interrupting the wait does not stop the run. */
143
+ readonly waitForRun: (runId: string, options: AgentRunWaitOptions) => Effect.Effect<AgentRun, PlatformError>;
144
+ }>;
145
+ /**
146
+ * Browserbase Agents: hosted autonomous runs that allocate their own browser sessions and
147
+ * bill inference. Creating or stopping a run is never retried; a lost reply is `unknown`.
148
+ */
149
+ declare class BrowserbaseAgents extends BrowserbaseAgents_base {
150
+ static readonly layer: Layer.Layer<BrowserbaseAgents, never, BrowserbaseClient>;
151
+ }
152
+ //#endregion
153
+ export { AgentMetadata as a, AgentRunMessage as c, AgentRunWaitOptions as d, AgentUpdate as f, isTerminalAgentRunStatus as h, AgentMessages as i, AgentRunRequest as l, Page as m, AgentListQuery as n, AgentRun as o, BrowserbaseAgents as p, AgentMessageQuery as r, AgentRunListQuery as s, AgentDefinition as t, AgentRunStatus as u };
154
+ export {};
155
+ //# sourceMappingURL=Agents-5HpTp9YE.d.mts.map
package/dist/Agents.d.mts CHANGED
@@ -1,154 +1,3 @@
1
- import { n as ContextReference } from "./References-DOH3Wu44.mjs";
2
- import { PlatformError } from "./Errors.mjs";
3
- import { BrowserbaseClient } from "./Client.mjs";
4
- import { Context, Effect, Layer, Schema } from "effect";
5
- //#region src/Agents.d.ts
6
- export declare const AgentRunStatus: Schema.Literals<readonly ["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"]>;
7
- export type AgentRunStatus = typeof AgentRunStatus.Type;
8
- export declare const isTerminalAgentRunStatus: (status: AgentRunStatus) => boolean;
9
- declare const AgentMetadata_base: Schema.Class<AgentMetadata, Schema.Struct<{
10
- readonly agentId: Schema.NonEmptyString;
11
- readonly name: Schema.String;
12
- readonly systemPrompt: Schema.optionalKey<Schema.String>;
13
- readonly resultSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
14
- readonly createdAt: Schema.String;
15
- readonly updatedAt: Schema.String;
16
- }>, {}>;
17
- export declare class AgentMetadata extends AgentMetadata_base {}
18
- declare const AgentRun_base: Schema.Class<AgentRun, Schema.Struct<{
19
- readonly runId: Schema.NonEmptyString;
20
- readonly agentId: Schema.optionalKey<Schema.NonEmptyString>;
21
- readonly task: Schema.String;
22
- readonly status: Schema.Literals<readonly ["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"]>;
23
- readonly sessionId: Schema.optionalKey<Schema.NonEmptyString>;
24
- readonly sandboxId: Schema.optionalKey<Schema.String>;
25
- readonly resultSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
26
- readonly result: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
27
- readonly cause: Schema.optionalKey<Schema.Struct<{
28
- readonly code: Schema.String;
29
- readonly message: Schema.optionalKey<Schema.String>;
30
- }>>;
31
- readonly startedAt: Schema.optionalKey<Schema.String>;
32
- readonly endedAt: Schema.optionalKey<Schema.String>;
33
- readonly createdAt: Schema.String;
34
- readonly updatedAt: Schema.String;
35
- }>, {}>;
36
- export declare class AgentRun extends AgentRun_base {}
37
- declare const AgentRunMessage_base: Schema.Class<AgentRunMessage, Schema.Struct<{
38
- readonly id: Schema.String;
39
- readonly createdAt: Schema.String;
40
- readonly role: Schema.Literals<readonly ["assistant", "tool"]>;
41
- readonly content: Schema.Codec<Schema.Json, Schema.Json, never, never>;
42
- }>, {}>;
43
- export declare class AgentRunMessage extends AgentRunMessage_base {}
44
- export declare const AgentDefinition: Schema.Struct<{
45
- readonly name: Schema.NonEmptyString;
46
- readonly systemPrompt: Schema.optionalKey<Schema.String>;
47
- readonly resultSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
48
- }>;
49
- export type AgentDefinition = typeof AgentDefinition.Type;
50
- export declare const AgentUpdate: Schema.Struct<{
51
- readonly name: Schema.optionalKey<Schema.NonEmptyString>;
52
- readonly systemPrompt: Schema.optionalKey<Schema.String>;
53
- readonly resultSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
54
- }>;
55
- export type AgentUpdate = typeof AgentUpdate.Type;
56
- export declare const AgentRunRequest: Schema.Struct<{
57
- readonly task: Schema.NonEmptyString;
58
- readonly agentId: Schema.optionalKey<Schema.NonEmptyString>;
59
- readonly resultSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
60
- readonly variables: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
61
- readonly value: Schema.String;
62
- readonly description: Schema.optionalKey<Schema.String>;
63
- }>>>;
64
- readonly browserSettings: Schema.optionalKey<Schema.Struct<{
65
- /**
66
- * A persisting run writes the Context from Browserbase's side, outside
67
- * `ContextCoordination.withWriter`. It is refused while a local writer holds the
68
- * Context, but nothing stops a later local writer from racing the hosted run.
69
- */
70
- readonly context: Schema.optionalKey<Schema.Struct<{
71
- readonly reference: typeof ContextReference;
72
- readonly persist: Schema.Boolean;
73
- }>>;
74
- readonly proxies: Schema.optionalKey<Schema.Union<readonly [Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
75
- readonly type: Schema.Literal<"browserbase">;
76
- readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
77
- readonly geolocation: Schema.optionalKey<Schema.Struct<{
78
- readonly country: Schema.String;
79
- readonly state: Schema.optionalKey<Schema.String>;
80
- readonly city: Schema.optionalKey<Schema.NonEmptyString>;
81
- }>>;
82
- }>, Schema.Struct<{
83
- readonly type: Schema.Literal<"external">;
84
- readonly server: Schema.NonEmptyString;
85
- readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
86
- readonly username: Schema.optionalKey<Schema.Redacted<Schema.String>>;
87
- readonly password: Schema.optionalKey<Schema.Redacted<Schema.String>>;
88
- }>, Schema.Struct<{
89
- readonly type: Schema.Literal<"none">;
90
- readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
91
- }>]>>]>>;
92
- readonly verified: Schema.optionalKey<Schema.Boolean>;
93
- }>>;
94
- }>;
95
- export type AgentRunRequest = typeof AgentRunRequest.Type;
96
- export declare const AgentListQuery: Schema.Struct<{
97
- readonly startAt: Schema.optionalKey<Schema.String>;
98
- readonly endAt: Schema.optionalKey<Schema.String>;
99
- readonly cursor: Schema.optionalKey<Schema.NonEmptyString>;
100
- readonly limit: Schema.optionalKey<Schema.Int>;
101
- }>;
102
- export type AgentListQuery = typeof AgentListQuery.Type;
103
- export declare const AgentRunListQuery: Schema.Struct<{
104
- readonly startAt: Schema.optionalKey<Schema.String>;
105
- readonly endAt: Schema.optionalKey<Schema.String>;
106
- readonly cursor: Schema.optionalKey<Schema.NonEmptyString>;
107
- readonly status: Schema.optionalKey<Schema.Literals<readonly ["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"]>>;
108
- readonly agentId: Schema.optionalKey<Schema.NonEmptyString>;
109
- readonly limit: Schema.optionalKey<Schema.Int>;
110
- }>;
111
- export type AgentRunListQuery = typeof AgentRunListQuery.Type;
112
- export declare const AgentMessageQuery: Schema.Struct<{
113
- readonly since: Schema.optionalKey<Schema.NonEmptyString>;
114
- readonly limit: Schema.optionalKey<Schema.Int>;
115
- readonly all: Schema.optionalKey<Schema.Boolean>;
116
- }>;
117
- export type AgentMessageQuery = typeof AgentMessageQuery.Type;
118
- export declare const AgentRunWaitOptions: Schema.Struct<{
119
- readonly timeoutMillis: Schema.Int;
120
- readonly pollIntervalMillis: Schema.optionalKey<Schema.Int>;
121
- }>;
122
- export type AgentRunWaitOptions = typeof AgentRunWaitOptions.Type;
123
- export interface Page<A> {
124
- readonly items: ReadonlyArray<A>;
125
- readonly nextCursor: string | undefined;
126
- }
127
- export interface AgentMessages {
128
- readonly messages: ReadonlyArray<AgentRunMessage>;
129
- readonly nextSince: string | undefined;
130
- }
131
- declare const BrowserbaseAgents_base: Context.ServiceClass<BrowserbaseAgents, "effect-browserbase/Agents", {
132
- readonly create: (definition: AgentDefinition) => Effect.Effect<AgentMetadata, PlatformError>;
133
- readonly list: (query?: AgentListQuery) => Effect.Effect<Page<AgentMetadata>, PlatformError>;
134
- readonly retrieve: (agentId: string) => Effect.Effect<AgentMetadata, PlatformError>;
135
- readonly update: (agentId: string, update: AgentUpdate) => Effect.Effect<AgentMetadata, PlatformError>;
136
- readonly delete: (agentId: string) => Effect.Effect<void, PlatformError>;
137
- readonly run: (request: AgentRunRequest) => Effect.Effect<AgentRun, PlatformError>;
138
- readonly retrieveRun: (runId: string) => Effect.Effect<AgentRun, PlatformError>;
139
- readonly listRuns: (query?: AgentRunListQuery) => Effect.Effect<Page<AgentRun>, PlatformError>;
140
- readonly stopRun: (runId: string) => Effect.Effect<AgentRun, PlatformError>;
141
- readonly messages: (runId: string, query?: AgentMessageQuery) => Effect.Effect<AgentMessages, PlatformError>;
142
- /** Polls until the run is terminal. Interrupting the wait does not stop the run. */
143
- readonly waitForRun: (runId: string, options: AgentRunWaitOptions) => Effect.Effect<AgentRun, PlatformError>;
144
- }>;
145
- /**
146
- * Browserbase Agents: hosted autonomous runs that allocate their own browser sessions and
147
- * bill inference. Creating or stopping a run is never retried; a lost reply is `unknown`.
148
- */
149
- export declare class BrowserbaseAgents extends BrowserbaseAgents_base {
150
- static readonly layer: Layer.Layer<BrowserbaseAgents, never, BrowserbaseClient>;
151
- }
152
- //#endregion
153
- export {};
154
- //# sourceMappingURL=Agents.d.mts.map
1
+ import { a as AgentMetadata, c as AgentRunMessage, d as AgentRunWaitOptions, f as AgentUpdate, h as isTerminalAgentRunStatus, i as AgentMessages, l as AgentRunRequest, m as Page, n as AgentListQuery, o as AgentRun, p as BrowserbaseAgents, r as AgentMessageQuery, s as AgentRunListQuery, t as AgentDefinition, u as AgentRunStatus } from "./Agents-5HpTp9YE.mjs";
2
+ export { AgentDefinition, AgentListQuery, AgentMessageQuery, AgentMessages, AgentMetadata, AgentRun, AgentRunListQuery, AgentRunMessage, AgentRunRequest, AgentRunStatus, AgentRunWaitOptions, AgentUpdate, BrowserbaseAgents, Page, isTerminalAgentRunStatus };
3
+ export {};
package/dist/Agents.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { ContextReference, Identifier } from "./References.mjs";
2
2
  import { PlatformError } from "./Errors.mjs";
3
- import { t as BrowserbaseClient } from "./Client-BQteUePT.mjs";
3
+ import { t as BrowserbaseClient } from "./Client-4RMKIpL2.mjs";
4
4
  import { t as resource } from "./Resource-DBksC4zB.mjs";
5
5
  import { ProxyRule } from "./Launch.mjs";
6
- import { n as proxy } from "./Launch-m0fxzJ49.mjs";
7
- import { n as isContextWriterBusy } from "./ContextWriter-BrQmoXRg.mjs";
6
+ import { n as proxy } from "./Launch-cAdE2rrZ.mjs";
7
+ import { n as isContextWriterBusy } from "./ContextWriter-oKWFLHuP.mjs";
8
8
  import { Clock, Context, Effect, Layer, Schema } from "effect";
9
9
  //#region src/Agents.ts
10
10
  const Timestamp = Schema.String.check(Schema.isMaxLength(64));
@@ -1,9 +1,9 @@
1
1
  import { a as SessionReference, n as ContextReference, r as ExtensionReference, t as AllocationAttempt } from "./References-DOH3Wu44.mjs";
2
2
  import { AllocationError, ContextError } from "./Errors.mjs";
3
- import { BrowserbaseClient } from "./Client.mjs";
4
- import { t as BrowserbaseSessions } from "./Sessions-tFJYaXFq.mjs";
3
+ import { t as BrowserbaseClient } from "./Client-B_f6bBLT.mjs";
4
+ import { t as BrowserbaseSessions } from "./Sessions-BpZgjteE.mjs";
5
5
  import { n as CleanupResult } from "./Cleanup-DMTDBir8.mjs";
6
- import { n as ContextWriterPermit } from "./WriterFacts-5CPBGG1P.mjs";
6
+ import { n as ContextWriterPermit } from "./WriterFacts-BBJRDZYY.mjs";
7
7
  import "./ContextCoordination.mjs";
8
8
  import { Effect, Option } from "effect";
9
9
  //#region src/Allocation.d.ts
@@ -91,7 +91,7 @@ export declare const scoped: (launch: {
91
91
  readonly [x: string]: import("effect/Schema").Json;
92
92
  } | undefined;
93
93
  };
94
- }, options?: AllocationOptions | undefined) => Effect.Effect<AllocatedSession, AllocationError | import("effect-browser/errors").BrowserError | ContextError, BrowserbaseClient | BrowserbaseSessions | import("effect/Scope").Scope>;
94
+ }, options?: AllocationOptions | undefined) => Effect.Effect<AllocatedSession, AllocationError | import("effect-browser/errors").BrowserError | ContextError, BrowserbaseClient | BrowserbaseSessions | import("effect/Crypto").Crypto | import("effect/Scope").Scope>;
95
95
  //#endregion
96
96
  export {};
97
97
  //# sourceMappingURL=Allocation.d.mts.map
@@ -1,4 +1,4 @@
1
- import { t as acquireRemote } from "./Acquisition-D8o4jtCg.mjs";
1
+ import { t as acquireRemote } from "./Acquisition-CAsTTXp4.mjs";
2
2
  import { Effect } from "effect";
3
3
  //#region src/Allocation.ts
4
4
  /**