effect-browserbase 0.2.0-beta.9 → 0.3.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +250 -317
  2. package/dist/Browserbase-FDltiz36.mjs +542 -0
  3. package/dist/Browserbase-FDltiz36.mjs.map +1 -0
  4. package/dist/Browserbase.d.mts +105 -0
  5. package/dist/Browserbase.mjs +3 -0
  6. package/dist/BrowserbaseClient-CtAQ2rg4.d.mts +195 -0
  7. package/dist/BrowserbaseClient.d.mts +2 -0
  8. package/dist/BrowserbaseClient.mjs +190 -0
  9. package/dist/BrowserbaseClient.mjs.map +1 -0
  10. package/dist/BrowserbaseError-D1EOrLNc.d.mts +79 -0
  11. package/dist/BrowserbaseError.d.mts +2 -0
  12. package/dist/BrowserbaseError.mjs +101 -0
  13. package/dist/BrowserbaseError.mjs.map +1 -0
  14. package/dist/ContextLease.d.mts +42 -0
  15. package/dist/ContextLease.mjs +80 -0
  16. package/dist/ContextLease.mjs.map +1 -0
  17. package/dist/index.d.mts +5 -27
  18. package/dist/index.mjs +5 -26
  19. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  20. package/dist/testing/index.d.mts +134 -0
  21. package/dist/testing/index.mjs +382 -0
  22. package/dist/testing/index.mjs.map +1 -0
  23. package/package.json +51 -121
  24. package/src/Browserbase.ts +698 -0
  25. package/src/BrowserbaseClient.ts +559 -0
  26. package/src/BrowserbaseError.ts +108 -0
  27. package/src/ContextLease.ts +118 -0
  28. package/src/index.ts +7 -0
  29. package/src/internal/captureConnection.ts +214 -0
  30. package/src/testing/BrowserbaseContract.ts +170 -0
  31. package/src/testing/TestBrowserbase.ts +445 -0
  32. package/src/testing/index.ts +7 -0
  33. package/dist/Account.d.mts +0 -32
  34. package/dist/Account.mjs +0 -36
  35. package/dist/Account.mjs.map +0 -1
  36. package/dist/Acquisition-BOABu_qJ.mjs +0 -244
  37. package/dist/Acquisition-BOABu_qJ.mjs.map +0 -1
  38. package/dist/Agents-CPaTOH_g.d.mts +0 -156
  39. package/dist/Agents.d.mts +0 -3
  40. package/dist/Agents.mjs +0 -292
  41. package/dist/Agents.mjs.map +0 -1
  42. package/dist/Allocation.d.mts +0 -97
  43. package/dist/Allocation.mjs +0 -27
  44. package/dist/Allocation.mjs.map +0 -1
  45. package/dist/Authorization-Ll5f_XNM.mjs +0 -12
  46. package/dist/Authorization-Ll5f_XNM.mjs.map +0 -1
  47. package/dist/Browser-ByrWJ0ss.mjs +0 -274
  48. package/dist/Browser-ByrWJ0ss.mjs.map +0 -1
  49. package/dist/Browser.d.mts +0 -83
  50. package/dist/Browser.mjs +0 -3
  51. package/dist/BrowserBinding.d.mts +0 -13
  52. package/dist/BrowserBinding.mjs +0 -31
  53. package/dist/BrowserBinding.mjs.map +0 -1
  54. package/dist/Certificates-D4NQmyeA.d.mts +0 -34
  55. package/dist/Certificates.d.mts +0 -3
  56. package/dist/Certificates.mjs +0 -85
  57. package/dist/Certificates.mjs.map +0 -1
  58. package/dist/Cleanup-DMTDBir8.d.mts +0 -23
  59. package/dist/Cleanup.d.mts +0 -3
  60. package/dist/Cleanup.mjs +0 -43
  61. package/dist/Cleanup.mjs.map +0 -1
  62. package/dist/Client-BEC4Q8ZS.mjs +0 -564
  63. package/dist/Client-BEC4Q8ZS.mjs.map +0 -1
  64. package/dist/Client-B_f6bBLT.d.mts +0 -52
  65. package/dist/Client.d.mts +0 -3
  66. package/dist/Client.mjs +0 -2
  67. package/dist/Connection-sxyxtwlk.mjs +0 -56
  68. package/dist/Connection-sxyxtwlk.mjs.map +0 -1
  69. package/dist/ContextCoordination.d.mts +0 -29
  70. package/dist/ContextCoordination.mjs +0 -94
  71. package/dist/ContextCoordination.mjs.map +0 -1
  72. package/dist/ContextWriter-CiEma24z.mjs +0 -204
  73. package/dist/ContextWriter-CiEma24z.mjs.map +0 -1
  74. package/dist/Contexts-DqdL7cyX.d.mts +0 -31
  75. package/dist/Contexts.d.mts +0 -3
  76. package/dist/Contexts.mjs +0 -97
  77. package/dist/Contexts.mjs.map +0 -1
  78. package/dist/Deadline-CrViaogr.mjs +0 -13
  79. package/dist/Deadline-CrViaogr.mjs.map +0 -1
  80. package/dist/Downloads-CX52GOFJ.d.mts +0 -43
  81. package/dist/Downloads.d.mts +0 -3
  82. package/dist/Downloads.mjs +0 -137
  83. package/dist/Downloads.mjs.map +0 -1
  84. package/dist/Errors.d.mts +0 -100
  85. package/dist/Errors.mjs +0 -194
  86. package/dist/Errors.mjs.map +0 -1
  87. package/dist/Extensions-BTUn9zhK.mjs +0 -231
  88. package/dist/Extensions-BTUn9zhK.mjs.map +0 -1
  89. package/dist/Extensions-DBXuVM1f.d.mts +0 -43
  90. package/dist/Extensions.d.mts +0 -3
  91. package/dist/Extensions.mjs +0 -2
  92. package/dist/Functions-CsKMMUuZ.d.mts +0 -226
  93. package/dist/Functions.d.mts +0 -3
  94. package/dist/Functions.mjs +0 -318
  95. package/dist/Functions.mjs.map +0 -1
  96. package/dist/Issued-DejqoMYL.mjs +0 -15
  97. package/dist/Issued-DejqoMYL.mjs.map +0 -1
  98. package/dist/Launch-cAdE2rrZ.mjs +0 -115
  99. package/dist/Launch-cAdE2rrZ.mjs.map +0 -1
  100. package/dist/Launch.d.mts +0 -127
  101. package/dist/Launch.mjs +0 -97
  102. package/dist/Launch.mjs.map +0 -1
  103. package/dist/PageFetch-CjAM_0DS.d.mts +0 -40
  104. package/dist/PageFetch.d.mts +0 -3
  105. package/dist/PageFetch.mjs +0 -59
  106. package/dist/PageFetch.mjs.map +0 -1
  107. package/dist/Projects-tm5bTDH0.d.mts +0 -38
  108. package/dist/Projects.d.mts +0 -3
  109. package/dist/Projects.mjs +0 -65
  110. package/dist/Projects.mjs.map +0 -1
  111. package/dist/Recordings-B9k5aODB.d.mts +0 -27
  112. package/dist/Recordings.d.mts +0 -3
  113. package/dist/Recordings.mjs +0 -144
  114. package/dist/Recordings.mjs.map +0 -1
  115. package/dist/References-DOH3Wu44.d.mts +0 -34
  116. package/dist/References.d.mts +0 -3
  117. package/dist/References.mjs +0 -33
  118. package/dist/References.mjs.map +0 -1
  119. package/dist/Replays-mV93WGtx.d.mts +0 -27
  120. package/dist/Replays.d.mts +0 -3
  121. package/dist/Replays.mjs +0 -107
  122. package/dist/Replays.mjs.map +0 -1
  123. package/dist/Resource-J7Kkk5mu.mjs +0 -54
  124. package/dist/Resource-J7Kkk5mu.mjs.map +0 -1
  125. package/dist/Search-B64e7g-h.d.mts +0 -37
  126. package/dist/Search.d.mts +0 -3
  127. package/dist/Search.mjs +0 -46
  128. package/dist/Search.mjs.map +0 -1
  129. package/dist/SessionData-5xYZDshJ.d.mts +0 -38
  130. package/dist/SessionData.d.mts +0 -3
  131. package/dist/SessionData.mjs +0 -48
  132. package/dist/SessionData.mjs.map +0 -1
  133. package/dist/Sessions-D2H5m6rF.mjs +0 -260
  134. package/dist/Sessions-D2H5m6rF.mjs.map +0 -1
  135. package/dist/Sessions-oJEUmZth.d.mts +0 -69
  136. package/dist/Sessions.d.mts +0 -4
  137. package/dist/Sessions.mjs +0 -3
  138. package/dist/Testing.d.mts +0 -119
  139. package/dist/Testing.mjs +0 -206
  140. package/dist/Testing.mjs.map +0 -1
  141. package/dist/TransferPolicy-DQ06i7SZ.mjs +0 -25
  142. package/dist/TransferPolicy-DQ06i7SZ.mjs.map +0 -1
  143. package/dist/Transfers-GVqzrDWl.d.mts +0 -89
  144. package/dist/Transfers.d.mts +0 -3
  145. package/dist/Transfers.mjs +0 -85
  146. package/dist/Transfers.mjs.map +0 -1
  147. package/dist/Uploads-C2_bACgv.d.mts +0 -28
  148. package/dist/Uploads.d.mts +0 -3
  149. package/dist/Uploads.mjs +0 -105
  150. package/dist/Uploads.mjs.map +0 -1
  151. package/dist/Webhooks-BoeRAxzG.d.mts +0 -59
  152. package/dist/Webhooks.d.mts +0 -3
  153. package/dist/Webhooks.mjs +0 -134
  154. package/dist/Webhooks.mjs.map +0 -1
  155. package/dist/WriterFacts-BBJRDZYY.d.mts +0 -54
@@ -1,244 +0,0 @@
1
- import { Identifier, SessionReference } from "./References.mjs";
2
- import { AllocationError, ContextError, SessionError } from "./Errors.mjs";
3
- import { n as annotate, r as span, t as BrowserbaseClient } from "./Client-BEC4Q8ZS.mjs";
4
- import { t as compileLaunch } from "./Launch-cAdE2rrZ.mjs";
5
- import { CleanupIssue, CleanupResult } from "./Cleanup.mjs";
6
- import { a as requireContextWriterPermit } from "./ContextWriter-CiEma24z.mjs";
7
- import { t as BrowserbaseSessions } from "./Sessions-D2H5m6rF.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
- import { cleanupStep, noConnection, reported } from "effect-browser/browser-runtime";
11
- //#region src/internal/session/Cleanup.ts
12
- const noLocalConnection = noConnection;
13
- const defaultCleanupLimits = {
14
- localStepMillis: 3e3,
15
- releaseMillis: 4e3,
16
- terminalMillis: 4e3
17
- };
18
- /**
19
- * Close is one uninterruptible, bounded transaction over *local cleanup evidence*, not
20
- * a transaction over the remote browser. Each step observes its own Exit so failures
21
- * cannot suppress a later disconnect, release request, or exact-session status read.
22
- */
23
- const makeCleanup = Effect.fnUntraced(function* (reference, ownership, sessions, local, report, limits = defaultCleanupLimits) {
24
- let latest;
25
- return {
26
- close: yield* Effect.cached(Effect.uninterruptible(Effect.gen(function* () {
27
- const issues = [];
28
- const step = (name, action, milliseconds) => cleanupStep(action.pipe(span("Browserbase.cleanup.step", { attributes: {
29
- "browser.cleanup.step": name,
30
- "browser.ownership": ownership
31
- } })), milliseconds).pipe(Effect.tap((result) => Effect.sync(() => {
32
- if (result._tag === "Failure") issues.push(CleanupIssue.make({
33
- step: name,
34
- reason: result.reason
35
- }));
36
- })));
37
- yield* step("fence", local.fence, limits.localStepMillis);
38
- yield* step("capture", local.capture, limits.localStepMillis);
39
- yield* step("initialization", local.initialization, limits.localStepMillis);
40
- const disconnected = yield* step("disconnect", local.disconnect, limits.localStepMillis);
41
- const localState = disconnected._tag === "Success" ? disconnected.value : "failed";
42
- let releaseRequested = false;
43
- let remote = ownership === "borrowed" ? "not-owned" : "unknown";
44
- let observedStatus;
45
- if (ownership === "owned") {
46
- const requested = yield* step("release", sessions.requestRelease(reference), limits.releaseMillis);
47
- releaseRequested = requested._tag === "Success";
48
- const terminal = yield* step("status", sessions.waitForTerminal(reference, { timeoutMillis: limits.terminalMillis }), limits.terminalMillis);
49
- if (terminal._tag === "Success") {
50
- remote = "confirmed";
51
- observedStatus = terminal.value.status;
52
- } else if (requested._tag === "Success") remote = "pending";
53
- }
54
- const result = CleanupResult.make({
55
- reference,
56
- ownership,
57
- releaseRequested,
58
- remote,
59
- local: localState,
60
- ...observedStatus === void 0 ? {} : { observedStatus },
61
- issues
62
- });
63
- Object.freeze(result.issues);
64
- latest = Object.freeze(result);
65
- report(latest);
66
- yield* annotate({
67
- "browser.cleanup.local": latest.local,
68
- "browser.cleanup.remote": latest.remote,
69
- "browser.cleanup.releaseRequested": latest.releaseRequested,
70
- "browser.cleanup.issueCount": latest.issues.length
71
- });
72
- return latest;
73
- }).pipe(span("Browserbase.cleanup", { attributes: { "browser.ownership": ownership } })))),
74
- result: Effect.sync(() => Option.fromNullishOr(latest))
75
- };
76
- });
77
- //#endregion
78
- //#region src/internal/session/Diagnostics.ts
79
- /**
80
- * Operator-visible evidence that a session's fate was not settled. It carries identity and
81
- * outcome labels only: no provider body, connection URL, credential or page content. The
82
- * transport deliberately disables tracing where credentials travel, so without this an
83
- * unconfirmed release or an allocation of unknown outcome would leave no trace for anyone who
84
- * did not register a callback.
85
- */
86
- var SessionUnsettled = class extends Data.TaggedError("BrowserbaseSessionUnsettled") {
87
- [ErrorReporter.severity] = "Warn";
88
- get [ErrorReporter.attributes]() {
89
- return this.details;
90
- }
91
- };
92
- const surface = (message, details) => Effect.logWarning(message).pipe(Effect.annotateLogs(details), Effect.andThen(ErrorReporter.report(Cause.fail(new SessionUnsettled({
93
- message,
94
- details
95
- })))));
96
- /** A borrowed scope never owns release, so only its local teardown can be unsettled. */
97
- const reportCleanup = (result) => {
98
- if (!(result.ownership === "owned" && (result.remote !== "confirmed" || !result.releaseRequested)) && result.local !== "failed" && result.issues.length === 0) return Effect.void;
99
- return surface("Browserbase session cleanup ended without confirmation", {
100
- projectId: result.reference.projectId,
101
- sessionId: result.reference.sessionId,
102
- ownership: result.ownership,
103
- remote: result.remote,
104
- local: result.local,
105
- observedStatus: result.observedStatus ?? "unobserved",
106
- issues: result.issues.map((issue) => `${issue.step}:${issue.reason}`).join(",") || "none"
107
- });
108
- };
109
- /** The provider may have allocated a session this process has no reference for. */
110
- const reportAllocationUncertain = (attempt) => surface("Browserbase allocation outcome is unknown", {
111
- projectId: attempt.projectId,
112
- attemptId: attempt.attemptId,
113
- requestedAtMillis: attempt.requestedAtMillis
114
- });
115
- //#endregion
116
- //#region src/internal/session/Acquisition.ts
117
- const AllocatedIdentity = Schema.Struct({
118
- id: Identifier,
119
- projectId: Identifier
120
- });
121
- /**
122
- * The remote lease is registered before POST. Local connection work is supplied by
123
- * the same browser owner; the control plane never invents a second operation owner.
124
- */
125
- const acquireRemote = Effect.fnUntraced(function* (options, local = noLocalConnection, limits) {
126
- const client = yield* BrowserbaseClient;
127
- const sessions = yield* BrowserbaseSessions;
128
- const crypto = yield* Crypto.Crypto;
129
- const parent = yield* Scope.Scope;
130
- const launch = yield* compileLaunch(options.launch, {
131
- projectId: client.projectId,
132
- attemptId: yield* Effect.orDie(crypto.randomUUIDv4),
133
- requestedAtMillis: yield* Clock.currentTimeMillis
134
- });
135
- const attempt = launch.attempt;
136
- let writer;
137
- if (launch.context?.persist) {
138
- if (options.contextWriter === void 0) return yield* ContextError.make({
139
- operation: "writer-authority",
140
- reason: "authorization",
141
- outcome: "undispatched"
142
- });
143
- writer = yield* requireContextWriterPermit(options.contextWriter, {
144
- provider: "browserbase",
145
- projectId: client.projectId,
146
- contextId: launch.context.id
147
- });
148
- } else if (options.contextWriter !== void 0) return yield* ContextError.make({
149
- operation: "writer-authority",
150
- reason: "configuration",
151
- outcome: "undispatched"
152
- });
153
- return yield* Effect.uninterruptibleMask((restore) => Effect.gen(function* () {
154
- const resourceScope = yield* Scope.make();
155
- let reference;
156
- let admitted = false;
157
- let knownRejection = false;
158
- let closing = false;
159
- let cleanup;
160
- let uncertainReported = false;
161
- const allocationUncertain = Effect.suspend(() => {
162
- if (uncertainReported) return Effect.void;
163
- uncertainReported = true;
164
- return reportAllocationUncertain(attempt).pipe(Effect.andThen(options.onAllocationUncertain === void 0 ? Effect.void : reported(Effect.suspend(() => options.onAllocationUncertain?.(attempt) ?? Effect.void).pipe(span("Browserbase.callback.allocationUncertain")))));
165
- });
166
- const terminate = yield* Effect.cached(Effect.uninterruptible(Effect.gen(function* () {
167
- closing = true;
168
- if (reference === void 0) {
169
- if (admitted && !knownRejection) {
170
- writer?.uncertain(attempt);
171
- yield* allocationUncertain;
172
- }
173
- return;
174
- }
175
- yield* (yield* makeCleanup(reference, "owned", sessions, local, (result) => {
176
- cleanup = result;
177
- writer?.completed(attempt, result);
178
- }, limits)).close;
179
- const result = cleanup;
180
- const notify = options.onCleanup;
181
- if (result !== void 0) {
182
- yield* reported(Effect.suspend(() => reportCleanup(result)));
183
- if (notify !== void 0) yield* reported(Effect.suspend(() => notify(result)).pipe(span("Browserbase.callback.cleanup")));
184
- }
185
- }).pipe(span("Browserbase.terminate", { attributes: { "browser.ownership": "owned" } }))));
186
- const closeScope = yield* Effect.cached(Scope.close(resourceScope, Exit.void));
187
- yield* Scope.addFinalizer(resourceScope, terminate);
188
- yield* Scope.addFinalizer(parent, closeScope);
189
- const failedAllocation = (error) => {
190
- knownRejection = error.outcome === "rejected" || error.outcome === "undispatched";
191
- if (knownRejection) writer?.rejected(attempt);
192
- else writer?.uncertain(attempt);
193
- const reason = error.reason;
194
- return AllocationError.make({
195
- attempt,
196
- outcome: knownRejection ? "rejected" : "unknown",
197
- reason: reason === "authorization" || reason === "rate-limited" || reason === "configuration" || reason === "transport" || reason === "timeout" || reason === "malformed" ? reason : "provider",
198
- ...error.status === void 0 ? {} : { status: error.status },
199
- ...error.retryAfterMillis === void 0 ? {} : { retryAfterMillis: error.retryAfterMillis }
200
- });
201
- };
202
- return yield* Effect.gen(function* () {
203
- if (writer !== void 0) yield* writer.recordAttempt(attempt);
204
- admitted = true;
205
- const raw = yield* restore(client.json("POST", "/v1/sessions", launch.body, options.allocationDeadline)).pipe(Effect.mapError(failedAllocation));
206
- const identity = yield* Schema.decodeUnknownEffect(AllocatedIdentity)(raw).pipe(Effect.mapError(() => AllocationError.make({
207
- attempt,
208
- outcome: "unknown",
209
- reason: "malformed"
210
- })));
211
- reference = Object.freeze(SessionReference.make({
212
- provider: "browserbase",
213
- projectId: identity.projectId,
214
- sessionId: identity.id
215
- }));
216
- writer?.recordSession(attempt, reference);
217
- if (reference.projectId !== client.projectId) return yield* AllocationError.make({
218
- attempt,
219
- reference,
220
- outcome: "unknown",
221
- reason: "malformed"
222
- });
223
- const ref = reference;
224
- return {
225
- reference: ref,
226
- attempt,
227
- launch,
228
- resourceScope,
229
- isClosed: () => closing,
230
- connection: (timeoutMillis) => Effect.suspend(() => closing ? Effect.fail(SessionError.make({
231
- operation: "session-connect",
232
- reason: "expired",
233
- outcome: "undispatched"
234
- })) : connectionAddress(client, sessions, ref, timeoutMillis).pipe(span("Browserbase.connection", { attributes: { "browser.ownership": "owned" } }))),
235
- release: closeScope.pipe(Effect.andThen(Effect.suspend(() => cleanup === void 0 ? Effect.die(/* @__PURE__ */ new Error("Owned session closed without cleanup evidence")) : Effect.succeed(cleanup))), span("Browserbase.release", { attributes: { "browser.ownership": "owned" } })),
236
- cleanupResult: Effect.sync(() => Option.fromNullishOr(cleanup))
237
- };
238
- }).pipe(Effect.onError(() => closeScope), Effect.onInterrupt(() => annotate({ "browser.outcome": admitted ? knownRejection ? "rejected" : "unknown" : "undispatched" }).pipe(Effect.andThen(closeScope))));
239
- }));
240
- }, span("Browserbase.acquireRemote", { attributes: { "browser.ownership": "owned" } }));
241
- //#endregion
242
- export { reported as a, noLocalConnection as i, reportCleanup as n, makeCleanup as r, acquireRemote as t };
243
-
244
- //# sourceMappingURL=Acquisition-BOABu_qJ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Acquisition-BOABu_qJ.mjs","names":["Trace.span","Trace.annotate","Trace.span","Trace.annotate"],"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\";\nimport * as Trace from \"../Trace.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(\n action.pipe(\n Trace.span(\"Browserbase.cleanup.step\", {\n attributes: { \"browser.cleanup.step\": name, \"browser.ownership\": ownership },\n }),\n ),\n milliseconds,\n ).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 yield* Trace.annotate({\n \"browser.cleanup.local\": latest.local,\n \"browser.cleanup.remote\": latest.remote,\n \"browser.cleanup.releaseRequested\": latest.releaseRequested,\n \"browser.cleanup.issueCount\": latest.issues.length,\n });\n\n return latest;\n }).pipe(\n Trace.span(\"Browserbase.cleanup\", {\n attributes: { \"browser.ownership\": ownership },\n }),\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 * as Trace from \"../Trace.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(\n 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(\n Effect.suspend(\n () => options.onAllocationUncertain?.(attempt) ?? Effect.void,\n ).pipe(Trace.span(\"Browserbase.callback.allocationUncertain\")),\n ),\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)\n yield* reported(\n Effect.suspend(() => notify(result)).pipe(\n Trace.span(\"Browserbase.callback.cleanup\"),\n ),\n );\n }\n }).pipe(\n Trace.span(\"Browserbase.terminate\", {\n attributes: { \"browser.ownership\": \"owned\" },\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).pipe(\n Trace.span(\"Browserbase.connection\", {\n attributes: { \"browser.ownership\": \"owned\" },\n }),\n ),\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 Trace.span(\"Browserbase.release\", { attributes: { \"browser.ownership\": \"owned\" } }),\n ),\n cleanupResult: Effect.sync(() => Option.fromNullishOr(cleanup)),\n };\n });\n\n return yield* allocate.pipe(\n Effect.onError(() => closeScope),\n Effect.onInterrupt(() =>\n Trace.annotate({\n \"browser.outcome\": admitted\n ? knownRejection\n ? \"rejected\"\n : \"unknown\"\n : \"undispatched\",\n }).pipe(Effect.andThen(closeScope)),\n ),\n );\n }),\n );\n },\n Trace.span(\"Browserbase.acquireRemote\", { attributes: { \"browser.ownership\": \"owned\" } }),\n);\n\nexport type RemoteAcquisition = Effect.Success<ReturnType<typeof acquireRemote>>;\n"],"mappings":";;;;;;;;;;;AAYA,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;CA6FJ,OAAO;EACL,OAAA,OA5FmB,OAAO,OAC1B,OAAO,gBACL,OAAO,IAAI,aAAa;GACtB,MAAM,SAAyB,CAAC;GAEhC,MAAM,QACJ,MACA,QACA,iBAEA,YACE,OAAO,KACLA,KAAW,4BAA4B,EACrC,YAAY;IAAE,wBAAwB;IAAM,qBAA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O,kBACLC,SAAe,EACb,mBAAmB,WACf,iBACE,aACA,YACF,eACN,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,UAAU,CAAC,CACpC,CACF;CACF,CAAC,CACH;AACF,GACAD,KAAW,6BAA6B,EAAE,YAAY,EAAE,qBAAqB,QAAQ,EAAE,CAAC,CAC1F"}
@@ -1,156 +0,0 @@
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
- * can incur inference charges. Creating or stopping a run is never retried; a lost reply is
148
- * `unknown`. A run reply is not a charge or completion receipt.
149
- */
150
- declare class BrowserbaseAgents extends BrowserbaseAgents_base {
151
- static readonly layer: Layer.Layer<BrowserbaseAgents, never, BrowserbaseClient>;
152
- }
153
- //#endregion
154
- 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 };
155
- export {};
156
- //# sourceMappingURL=Agents-CPaTOH_g.d.mts.map
package/dist/Agents.d.mts DELETED
@@ -1,3 +0,0 @@
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-CPaTOH_g.mjs";
2
- export { AgentDefinition, AgentListQuery, AgentMessageQuery, AgentMessages, AgentMetadata, AgentRun, AgentRunListQuery, AgentRunMessage, AgentRunRequest, AgentRunStatus, AgentRunWaitOptions, AgentUpdate, BrowserbaseAgents, Page, isTerminalAgentRunStatus };
3
- export {};