effect-browserbase 0.1.0-beta.102

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 (136) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +441 -0
  3. package/dist/Account.d.mts +34 -0
  4. package/dist/Account.mjs +41 -0
  5. package/dist/Account.mjs.map +1 -0
  6. package/dist/Acquisition-WBafHwXH.mjs +280 -0
  7. package/dist/Acquisition-WBafHwXH.mjs.map +1 -0
  8. package/dist/Agents.d.mts +156 -0
  9. package/dist/Agents.mjs +307 -0
  10. package/dist/Agents.mjs.map +1 -0
  11. package/dist/Allocation.d.mts +99 -0
  12. package/dist/Allocation.mjs +29 -0
  13. package/dist/Allocation.mjs.map +1 -0
  14. package/dist/Association-CEps4hYP.mjs +10 -0
  15. package/dist/Association-CEps4hYP.mjs.map +1 -0
  16. package/dist/Authorization-Ll5f_XNM.mjs +12 -0
  17. package/dist/Authorization-Ll5f_XNM.mjs.map +1 -0
  18. package/dist/Bootstrap-BXuzZojd.mjs +194 -0
  19. package/dist/Bootstrap-BXuzZojd.mjs.map +1 -0
  20. package/dist/Bootstrap-m7lHgj0D.d.mts +177 -0
  21. package/dist/Bootstrap.d.mts +2 -0
  22. package/dist/Bootstrap.mjs +2 -0
  23. package/dist/Browser-joE4Zgys.mjs +1557 -0
  24. package/dist/Browser-joE4Zgys.mjs.map +1 -0
  25. package/dist/Browser.d.mts +195 -0
  26. package/dist/Browser.mjs +2 -0
  27. package/dist/BrowserBinding-qbQA6JhH.mjs +2452 -0
  28. package/dist/BrowserBinding-qbQA6JhH.mjs.map +1 -0
  29. package/dist/BrowserBinding.d.mts +40 -0
  30. package/dist/BrowserBinding.mjs +2 -0
  31. package/dist/BrowserData-LpcAuAub.d.mts +369 -0
  32. package/dist/BrowserData.d.mts +2 -0
  33. package/dist/BrowserData.mjs +442 -0
  34. package/dist/BrowserData.mjs.map +1 -0
  35. package/dist/Capture-CZJPuD7b.mjs +532 -0
  36. package/dist/Capture-CZJPuD7b.mjs.map +1 -0
  37. package/dist/Capture-Dr5MkIJb.d.mts +125 -0
  38. package/dist/Capture.d.mts +2 -0
  39. package/dist/Capture.mjs +2 -0
  40. package/dist/Certificates.d.mts +35 -0
  41. package/dist/Certificates.mjs +90 -0
  42. package/dist/Certificates.mjs.map +1 -0
  43. package/dist/Cleanup-G2YpTCuU.d.mts +24 -0
  44. package/dist/Cleanup.d.mts +2 -0
  45. package/dist/Cleanup.mjs +48 -0
  46. package/dist/Cleanup.mjs.map +1 -0
  47. package/dist/Client-Ca0zSg1n.d.mts +53 -0
  48. package/dist/Client-D1_xYM9o.mjs +424 -0
  49. package/dist/Client-D1_xYM9o.mjs.map +1 -0
  50. package/dist/Client.d.mts +2 -0
  51. package/dist/Client.mjs +2 -0
  52. package/dist/ContextCoordination.d.mts +16 -0
  53. package/dist/ContextCoordination.mjs +67 -0
  54. package/dist/ContextCoordination.mjs.map +1 -0
  55. package/dist/ContextWriter-BrQmoXRg.mjs +187 -0
  56. package/dist/ContextWriter-BrQmoXRg.mjs.map +1 -0
  57. package/dist/Contexts.d.mts +32 -0
  58. package/dist/Contexts.mjs +103 -0
  59. package/dist/Contexts.mjs.map +1 -0
  60. package/dist/Deadline-CrViaogr.mjs +13 -0
  61. package/dist/Deadline-CrViaogr.mjs.map +1 -0
  62. package/dist/Downloads.d.mts +44 -0
  63. package/dist/Downloads.mjs +142 -0
  64. package/dist/Downloads.mjs.map +1 -0
  65. package/dist/Errors.d.mts +123 -0
  66. package/dist/Errors.mjs +329 -0
  67. package/dist/Errors.mjs.map +1 -0
  68. package/dist/Extensions-ClZbYb1H.mjs +237 -0
  69. package/dist/Extensions-ClZbYb1H.mjs.map +1 -0
  70. package/dist/Extensions.d.mts +44 -0
  71. package/dist/Extensions.mjs +2 -0
  72. package/dist/Functions.d.mts +227 -0
  73. package/dist/Functions.mjs +332 -0
  74. package/dist/Functions.mjs.map +1 -0
  75. package/dist/Images-DgscEfSf.mjs +127 -0
  76. package/dist/Images-DgscEfSf.mjs.map +1 -0
  77. package/dist/Issued-DejqoMYL.mjs +15 -0
  78. package/dist/Issued-DejqoMYL.mjs.map +1 -0
  79. package/dist/Launch-BHcAEq05.mjs +111 -0
  80. package/dist/Launch-BHcAEq05.mjs.map +1 -0
  81. package/dist/Launch-C8CfaYxb.d.mts +132 -0
  82. package/dist/Launch.d.mts +2 -0
  83. package/dist/Launch.mjs +105 -0
  84. package/dist/Launch.mjs.map +1 -0
  85. package/dist/PageControl.d.mts +16 -0
  86. package/dist/PageControl.mjs +36 -0
  87. package/dist/PageControl.mjs.map +1 -0
  88. package/dist/PageControlAssociation-DabEg5AR.mjs +10 -0
  89. package/dist/PageControlAssociation-DabEg5AR.mjs.map +1 -0
  90. package/dist/PageFetch.d.mts +40 -0
  91. package/dist/PageFetch.mjs +64 -0
  92. package/dist/PageFetch.mjs.map +1 -0
  93. package/dist/Projects.d.mts +39 -0
  94. package/dist/Projects.mjs +71 -0
  95. package/dist/Projects.mjs.map +1 -0
  96. package/dist/Recordings.d.mts +28 -0
  97. package/dist/Recordings.mjs +131 -0
  98. package/dist/Recordings.mjs.map +1 -0
  99. package/dist/References-URDAtapt.d.mts +35 -0
  100. package/dist/References.d.mts +2 -0
  101. package/dist/References.mjs +41 -0
  102. package/dist/References.mjs.map +1 -0
  103. package/dist/Replays.d.mts +28 -0
  104. package/dist/Replays.mjs +109 -0
  105. package/dist/Replays.mjs.map +1 -0
  106. package/dist/Resource-DBksC4zB.mjs +50 -0
  107. package/dist/Resource-DBksC4zB.mjs.map +1 -0
  108. package/dist/Search.d.mts +38 -0
  109. package/dist/Search.mjs +53 -0
  110. package/dist/Search.mjs.map +1 -0
  111. package/dist/SessionData-DRKcKCqw.d.mts +39 -0
  112. package/dist/SessionData.d.mts +2 -0
  113. package/dist/SessionData.mjs +55 -0
  114. package/dist/SessionData.mjs.map +1 -0
  115. package/dist/Sessions-B8E4kMxo.d.mts +68 -0
  116. package/dist/Sessions-CtbseWEh.mjs +244 -0
  117. package/dist/Sessions-CtbseWEh.mjs.map +1 -0
  118. package/dist/Sessions.d.mts +3 -0
  119. package/dist/Sessions.mjs +3 -0
  120. package/dist/TransferPolicy-DQ06i7SZ.mjs +25 -0
  121. package/dist/TransferPolicy-DQ06i7SZ.mjs.map +1 -0
  122. package/dist/Transfers-Czv5IZzJ.d.mts +76 -0
  123. package/dist/Transfers.d.mts +2 -0
  124. package/dist/Transfers.mjs +101 -0
  125. package/dist/Transfers.mjs.map +1 -0
  126. package/dist/Uploads.d.mts +29 -0
  127. package/dist/Uploads.mjs +107 -0
  128. package/dist/Uploads.mjs.map +1 -0
  129. package/dist/Webhooks.d.mts +60 -0
  130. package/dist/Webhooks.mjs +143 -0
  131. package/dist/Webhooks.mjs.map +1 -0
  132. package/dist/WriterFacts-osvYAsIx.d.mts +61 -0
  133. package/dist/index.d.mts +30 -0
  134. package/dist/index.mjs +30 -0
  135. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  136. package/package.json +163 -0
@@ -0,0 +1,307 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { ContextReference, Identifier } from "./References.mjs";
3
+ import { PlatformError } from "./Errors.mjs";
4
+ import { t as BrowserbaseClient } from "./Client-D1_xYM9o.mjs";
5
+ import { t as resource } from "./Resource-DBksC4zB.mjs";
6
+ import { ProxyRule } from "./Launch.mjs";
7
+ import { n as proxy } from "./Launch-BHcAEq05.mjs";
8
+ import { n as isContextWriterBusy } from "./ContextWriter-BrQmoXRg.mjs";
9
+ import { Clock, Context, Effect, Layer, Schema } from "effect";
10
+ //#region src/Agents.ts
11
+ var Agents_exports = /* @__PURE__ */ __exportAll({
12
+ AgentDefinition: () => AgentDefinition,
13
+ AgentListQuery: () => AgentListQuery,
14
+ AgentMessageQuery: () => AgentMessageQuery,
15
+ AgentMetadata: () => AgentMetadata,
16
+ AgentRun: () => AgentRun,
17
+ AgentRunListQuery: () => AgentRunListQuery,
18
+ AgentRunMessage: () => AgentRunMessage,
19
+ AgentRunRequest: () => AgentRunRequest,
20
+ AgentRunStatus: () => AgentRunStatus,
21
+ AgentRunWaitOptions: () => AgentRunWaitOptions,
22
+ AgentUpdate: () => AgentUpdate,
23
+ BrowserbaseAgents: () => BrowserbaseAgents,
24
+ isTerminalAgentRunStatus: () => isTerminalAgentRunStatus
25
+ });
26
+ const Timestamp = Schema.String.check(Schema.isMaxLength(64));
27
+ const Cursor = Schema.NonEmptyString.check(Schema.isMaxLength(4096));
28
+ const JsonObject = Schema.Record(Schema.String, Schema.Json);
29
+ const Prompt = Schema.String.check(Schema.isMaxLength(1e5));
30
+ const AgentRunStatus = Schema.Literals([
31
+ "PENDING",
32
+ "RUNNING",
33
+ "COMPLETED",
34
+ "FAILED",
35
+ "STOPPED",
36
+ "TIMED_OUT"
37
+ ]);
38
+ const isTerminalAgentRunStatus = (status) => status !== "PENDING" && status !== "RUNNING";
39
+ var AgentMetadata = class extends Schema.Class("BrowserbaseAgentMetadata")({
40
+ agentId: Identifier,
41
+ name: Schema.String.check(Schema.isMaxLength(255)),
42
+ systemPrompt: Schema.optionalKey(Prompt),
43
+ resultSchema: Schema.optionalKey(JsonObject),
44
+ createdAt: Timestamp,
45
+ updatedAt: Timestamp
46
+ }) {};
47
+ var AgentRun = class extends Schema.Class("BrowserbaseAgentRun")({
48
+ runId: Identifier,
49
+ agentId: Schema.optionalKey(Identifier),
50
+ task: Prompt,
51
+ status: AgentRunStatus,
52
+ sessionId: Schema.optionalKey(Identifier),
53
+ sandboxId: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(256))),
54
+ resultSchema: Schema.optionalKey(JsonObject),
55
+ result: Schema.optionalKey(JsonObject),
56
+ cause: Schema.optionalKey(Schema.Struct({
57
+ code: Schema.String.check(Schema.isMaxLength(64)),
58
+ message: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(500)))
59
+ })),
60
+ startedAt: Schema.optionalKey(Timestamp),
61
+ endedAt: Schema.optionalKey(Timestamp),
62
+ createdAt: Timestamp,
63
+ updatedAt: Timestamp
64
+ }) {};
65
+ var AgentRunMessage = class extends Schema.Class("BrowserbaseAgentRunMessage")({
66
+ id: Schema.String.check(Schema.isMaxLength(256)),
67
+ createdAt: Timestamp,
68
+ role: Schema.Literals(["assistant", "tool"]),
69
+ content: Schema.Json
70
+ }) {};
71
+ const AgentDefinition = Schema.Struct({
72
+ name: Schema.NonEmptyString.check(Schema.isMaxLength(255)),
73
+ systemPrompt: Schema.optionalKey(Prompt),
74
+ resultSchema: Schema.optionalKey(JsonObject)
75
+ });
76
+ const AgentUpdate = Schema.Struct({
77
+ name: Schema.optionalKey(AgentDefinition.fields.name),
78
+ systemPrompt: Schema.optionalKey(Prompt),
79
+ resultSchema: Schema.optionalKey(JsonObject)
80
+ });
81
+ const AgentRunRequest = Schema.Struct({
82
+ task: Schema.NonEmptyString.check(Schema.isMaxLength(1e5)),
83
+ agentId: Schema.optionalKey(Identifier),
84
+ resultSchema: Schema.optionalKey(JsonObject),
85
+ variables: Schema.optionalKey(Schema.Record(Schema.String.check(Schema.isMaxLength(128)), Schema.Struct({
86
+ value: Schema.String.check(Schema.isMaxLength(1e5)),
87
+ description: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024)))
88
+ }))),
89
+ browserSettings: Schema.optionalKey(Schema.Struct({
90
+ /**
91
+ * A persisting run writes the Context from Browserbase's side, outside
92
+ * `ContextCoordination.withWriter`. It is refused while a local writer holds the
93
+ * Context, but nothing stops a later local writer from racing the hosted run.
94
+ */
95
+ context: Schema.optionalKey(Schema.Struct({
96
+ reference: ContextReference,
97
+ persist: Schema.Boolean
98
+ })),
99
+ proxies: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Array(ProxyRule).check(Schema.isMaxLength(64))])),
100
+ verified: Schema.optionalKey(Schema.Boolean)
101
+ }))
102
+ });
103
+ const Window = {
104
+ startAt: Schema.optionalKey(Timestamp),
105
+ endAt: Schema.optionalKey(Timestamp),
106
+ cursor: Schema.optionalKey(Cursor)
107
+ };
108
+ const AgentListQuery = Schema.Struct({
109
+ ...Window,
110
+ limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
111
+ minimum: 1,
112
+ maximum: 1e3
113
+ })))
114
+ });
115
+ const AgentRunListQuery = Schema.Struct({
116
+ ...Window,
117
+ status: Schema.optionalKey(AgentRunStatus),
118
+ agentId: Schema.optionalKey(Identifier),
119
+ limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
120
+ minimum: 1,
121
+ maximum: 1e3
122
+ })))
123
+ });
124
+ const AgentMessageQuery = Schema.Struct({
125
+ since: Schema.optionalKey(Cursor),
126
+ limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
127
+ minimum: 1,
128
+ maximum: 100
129
+ }))),
130
+ all: Schema.optionalKey(Schema.Boolean)
131
+ });
132
+ const AgentRunWaitOptions = Schema.Struct({
133
+ timeoutMillis: Schema.Int.check(Schema.isBetween({
134
+ minimum: 1,
135
+ maximum: 216e5
136
+ })),
137
+ pollIntervalMillis: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
138
+ minimum: 250,
139
+ maximum: 6e4
140
+ })))
141
+ });
142
+ const ProviderAgent = Schema.Struct({
143
+ agentId: Identifier,
144
+ name: AgentMetadata.fields.name,
145
+ systemPrompt: Schema.optionalKey(Prompt),
146
+ resultSchema: Schema.optionalKey(JsonObject),
147
+ createdAt: Timestamp,
148
+ updatedAt: Timestamp
149
+ });
150
+ const ProviderPage = (item) => Schema.Struct({
151
+ data: Schema.Array(item).check(Schema.isMaxLength(1e3)),
152
+ nextCursor: Schema.optionalKey(Schema.NullOr(Schema.String.check(Schema.isMaxLength(4096))))
153
+ });
154
+ const ProviderMessages = Schema.Struct({
155
+ data: Schema.Array(Schema.Struct({
156
+ id: AgentRunMessage.fields.id,
157
+ createdAt: Timestamp,
158
+ message: Schema.Struct({
159
+ role: AgentRunMessage.fields.role,
160
+ content: Schema.Json
161
+ })
162
+ })).check(Schema.isMaxLength(100)),
163
+ nextSince: Schema.optionalKey(Schema.NullOr(Schema.String.check(Schema.isMaxLength(4096))))
164
+ });
165
+ const now = Clock.monotonicTimeNanos.pipe(Effect.map((value) => Number(value) / 1e6));
166
+ /**
167
+ * Browserbase Agents: hosted autonomous runs that allocate their own browser sessions and
168
+ * bill inference. Creating or stopping a run is never retried; a lost reply is `unknown`.
169
+ */
170
+ var BrowserbaseAgents = class BrowserbaseAgents extends Context.Service()("effect-browserbase/Agents") {
171
+ static layer = Layer.effect(BrowserbaseAgents, Effect.gen(function* () {
172
+ const client = yield* BrowserbaseClient;
173
+ const api = resource(client, (failure) => PlatformError.make({
174
+ ...failure,
175
+ service: "agents"
176
+ }));
177
+ const agentPath = (id) => `/v1/agents/${api.segment(id)}`;
178
+ const runPath = (id) => `/v1/agents/runs/${api.segment(id)}`;
179
+ const agent = (operation, mutation, expected) => Effect.fnUntraced(function* (value) {
180
+ if (expected !== void 0 && value.agentId !== expected) return yield* api.malformed(operation, mutation);
181
+ return AgentMetadata.make(value);
182
+ });
183
+ const run = (operation, mutation, expected) => Effect.fnUntraced(function* (value) {
184
+ if (expected !== void 0 && value.runId !== expected) return yield* api.malformed(operation, mutation);
185
+ return value;
186
+ });
187
+ const create = Effect.fn("BrowserbaseAgents.create")(function* (definition) {
188
+ const value = yield* api.input(AgentDefinition, definition, "agent-create");
189
+ return yield* api.request("POST", "/v1/agents", ProviderAgent, "agent-create", value).pipe(Effect.flatMap(agent("agent-create", true)));
190
+ });
191
+ const list = Effect.fn("BrowserbaseAgents.list")(function* (query = {}) {
192
+ const value = yield* api.input(AgentListQuery, query, "agent-list");
193
+ const page = yield* api.request("GET", `/v1/agents${api.query(value)}`, ProviderPage(ProviderAgent), "agent-list");
194
+ return {
195
+ items: page.data.map((row) => AgentMetadata.make(row)),
196
+ nextCursor: page.nextCursor ?? void 0
197
+ };
198
+ });
199
+ const retrieve = Effect.fn("BrowserbaseAgents.retrieve")(function* (agentId) {
200
+ const id = yield* api.input(Identifier, agentId, "agent-retrieve");
201
+ return yield* api.request("GET", agentPath(id), ProviderAgent, "agent-retrieve").pipe(Effect.flatMap(agent("agent-retrieve", false, id)));
202
+ });
203
+ const update = Effect.fn("BrowserbaseAgents.update")(function* (agentId, changes) {
204
+ const id = yield* api.input(Identifier, agentId, "agent-update");
205
+ const value = yield* api.input(AgentUpdate, changes, "agent-update");
206
+ if (Object.keys(value).length === 0) return yield* api.configuration("agent-update");
207
+ return yield* api.request("PATCH", agentPath(id), ProviderAgent, "agent-update", value).pipe(Effect.flatMap(agent("agent-update", true, id)));
208
+ });
209
+ const remove = Effect.fn("BrowserbaseAgents.delete")(function* (agentId) {
210
+ const id = yield* api.input(Identifier, agentId, "agent-delete");
211
+ yield* api.remove(agentPath(id), "agent-delete");
212
+ });
213
+ const start = Effect.fn("BrowserbaseAgents.run")(function* (request) {
214
+ const value = yield* api.input(AgentRunRequest, request, "agent-run");
215
+ const settings = value.browserSettings;
216
+ const context = settings?.context;
217
+ if (context !== void 0) {
218
+ if (context.reference.projectId !== client.projectId) return yield* api.make({
219
+ operation: "agent-run",
220
+ reason: "authorization",
221
+ outcome: "undispatched"
222
+ });
223
+ if (context.persist && isContextWriterBusy(context.reference)) return yield* api.make({
224
+ operation: "agent-run",
225
+ reason: "active",
226
+ outcome: "undispatched"
227
+ });
228
+ }
229
+ const body = {
230
+ task: value.task,
231
+ ...value.agentId === void 0 ? {} : { agentId: value.agentId },
232
+ ...value.resultSchema === void 0 ? {} : { resultSchema: value.resultSchema },
233
+ ...value.variables === void 0 ? {} : { variables: value.variables },
234
+ ...settings === void 0 ? {} : { browserSettings: {
235
+ ...context === void 0 ? {} : { context: {
236
+ id: context.reference.contextId,
237
+ persist: context.persist
238
+ } },
239
+ ...settings.proxies === void 0 ? {} : { proxies: typeof settings.proxies === "boolean" ? settings.proxies : settings.proxies.map(proxy) },
240
+ ...settings.verified === void 0 ? {} : { verified: settings.verified }
241
+ } }
242
+ };
243
+ return yield* api.request("POST", "/v1/agents/runs", AgentRun, "agent-run", body);
244
+ });
245
+ const retrieveRun = Effect.fn("BrowserbaseAgents.retrieveRun")(function* (runId) {
246
+ const id = yield* api.input(Identifier, runId, "agent-run-retrieve");
247
+ return yield* api.request("GET", runPath(id), AgentRun, "agent-run-retrieve").pipe(Effect.flatMap(run("agent-run-retrieve", false, id)));
248
+ });
249
+ const listRuns = Effect.fn("BrowserbaseAgents.listRuns")(function* (query = {}) {
250
+ const value = yield* api.input(AgentRunListQuery, query, "agent-run-list");
251
+ const page = yield* api.request("GET", `/v1/agents/runs${api.query(value)}`, ProviderPage(AgentRun), "agent-run-list");
252
+ return {
253
+ items: page.data,
254
+ nextCursor: page.nextCursor ?? void 0
255
+ };
256
+ });
257
+ const stopRun = Effect.fn("BrowserbaseAgents.stopRun")(function* (runId) {
258
+ const id = yield* api.input(Identifier, runId, "agent-run-stop");
259
+ return yield* api.request("POST", `${runPath(id)}/stop`, AgentRun, "agent-run-stop").pipe(Effect.flatMap(run("agent-run-stop", true, id)));
260
+ });
261
+ const messages = Effect.fn("BrowserbaseAgents.messages")(function* (runId, query = {}) {
262
+ const id = yield* api.input(Identifier, runId, "agent-run-messages");
263
+ const value = yield* api.input(AgentMessageQuery, query, "agent-run-messages");
264
+ const page = yield* api.request("GET", `${runPath(id)}/messages${api.query(value)}`, ProviderMessages, "agent-run-messages");
265
+ return {
266
+ messages: page.data.map((row) => AgentRunMessage.make({
267
+ id: row.id,
268
+ createdAt: row.createdAt,
269
+ role: row.message.role,
270
+ content: row.message.content
271
+ })),
272
+ nextSince: page.nextSince ?? void 0
273
+ };
274
+ });
275
+ const waitForRun = Effect.fn("BrowserbaseAgents.waitForRun")(function* (runId, options) {
276
+ const bounds = yield* api.input(AgentRunWaitOptions, options, "agent-run-wait");
277
+ const deadline = (yield* now) + bounds.timeoutMillis;
278
+ for (;;) {
279
+ const current = yield* retrieveRun(runId);
280
+ if (isTerminalAgentRunStatus(current.status)) return current;
281
+ const remaining = deadline - (yield* now);
282
+ if (remaining <= 0) return yield* api.make({
283
+ operation: "agent-run-wait",
284
+ reason: "timeout"
285
+ });
286
+ yield* Effect.sleep(Math.min(bounds.pollIntervalMillis ?? 2e3, remaining));
287
+ }
288
+ });
289
+ return BrowserbaseAgents.of({
290
+ create,
291
+ list,
292
+ retrieve,
293
+ update,
294
+ delete: remove,
295
+ run: start,
296
+ retrieveRun,
297
+ listRuns,
298
+ stopRun,
299
+ messages,
300
+ waitForRun
301
+ });
302
+ }));
303
+ };
304
+ //#endregion
305
+ export { AgentDefinition, AgentListQuery, AgentMessageQuery, AgentMetadata, AgentRun, AgentRunListQuery, AgentRunMessage, AgentRunRequest, AgentRunStatus, AgentRunWaitOptions, AgentUpdate, BrowserbaseAgents, isTerminalAgentRunStatus, Agents_exports as t };
306
+
307
+ //# sourceMappingURL=Agents.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Agents.mjs","names":[],"sources":["../src/Agents.ts"],"sourcesContent":["import { Clock, Context, Effect, Layer, Schema } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport { PlatformError } from \"./Errors.ts\";\nimport { resource } from \"./internal/http/Resource.ts\";\nimport { proxy } from \"./internal/provider/Launch.ts\";\nimport { isContextWriterBusy } from \"./internal/session/ContextWriter.ts\";\nimport { ProxyRule } from \"./Launch.ts\";\nimport { ContextReference, Identifier } from \"./References.ts\";\n\nconst Timestamp = Schema.String.check(Schema.isMaxLength(64));\nconst Cursor = Schema.NonEmptyString.check(Schema.isMaxLength(4096));\nconst JsonObject = Schema.Record(Schema.String, Schema.Json);\nconst Prompt = Schema.String.check(Schema.isMaxLength(100_000));\n\nexport const AgentRunStatus = Schema.Literals([\n \"PENDING\",\n \"RUNNING\",\n \"COMPLETED\",\n \"FAILED\",\n \"STOPPED\",\n \"TIMED_OUT\",\n]);\n\nexport type AgentRunStatus = typeof AgentRunStatus.Type;\n\nexport const isTerminalAgentRunStatus = (status: AgentRunStatus): boolean =>\n status !== \"PENDING\" && status !== \"RUNNING\";\n\nexport class AgentMetadata extends Schema.Class<AgentMetadata>(\"BrowserbaseAgentMetadata\")({\n agentId: Identifier,\n name: Schema.String.check(Schema.isMaxLength(255)),\n systemPrompt: Schema.optionalKey(Prompt),\n resultSchema: Schema.optionalKey(JsonObject),\n createdAt: Timestamp,\n updatedAt: Timestamp,\n}) {}\n\nexport class AgentRun extends Schema.Class<AgentRun>(\"BrowserbaseAgentRun\")({\n runId: Identifier,\n agentId: Schema.optionalKey(Identifier),\n task: Prompt,\n status: AgentRunStatus,\n sessionId: Schema.optionalKey(Identifier),\n sandboxId: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(256))),\n resultSchema: Schema.optionalKey(JsonObject),\n result: Schema.optionalKey(JsonObject),\n cause: Schema.optionalKey(\n Schema.Struct({\n code: Schema.String.check(Schema.isMaxLength(64)),\n message: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(500))),\n }),\n ),\n startedAt: Schema.optionalKey(Timestamp),\n endedAt: Schema.optionalKey(Timestamp),\n createdAt: Timestamp,\n updatedAt: Timestamp,\n}) {}\n\nexport class AgentRunMessage extends Schema.Class<AgentRunMessage>(\"BrowserbaseAgentRunMessage\")({\n id: Schema.String.check(Schema.isMaxLength(256)),\n createdAt: Timestamp,\n role: Schema.Literals([\"assistant\", \"tool\"]),\n content: Schema.Json,\n}) {}\n\nexport const AgentDefinition = Schema.Struct({\n name: Schema.NonEmptyString.check(Schema.isMaxLength(255)),\n systemPrompt: Schema.optionalKey(Prompt),\n resultSchema: Schema.optionalKey(JsonObject),\n});\n\nexport type AgentDefinition = typeof AgentDefinition.Type;\n\nexport const AgentUpdate = Schema.Struct({\n name: Schema.optionalKey(AgentDefinition.fields.name),\n systemPrompt: Schema.optionalKey(Prompt),\n resultSchema: Schema.optionalKey(JsonObject),\n});\n\nexport type AgentUpdate = typeof AgentUpdate.Type;\n\nexport const AgentRunRequest = Schema.Struct({\n task: Schema.NonEmptyString.check(Schema.isMaxLength(100_000)),\n agentId: Schema.optionalKey(Identifier),\n resultSchema: Schema.optionalKey(JsonObject),\n variables: Schema.optionalKey(\n Schema.Record(\n Schema.String.check(Schema.isMaxLength(128)),\n Schema.Struct({\n value: Schema.String.check(Schema.isMaxLength(100_000)),\n description: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),\n }),\n ),\n ),\n browserSettings: Schema.optionalKey(\n Schema.Struct({\n /**\n * A persisting run writes the Context from Browserbase's side, outside\n * `ContextCoordination.withWriter`. It is refused while a local writer holds the\n * Context, but nothing stops a later local writer from racing the hosted run.\n */\n context: Schema.optionalKey(\n Schema.Struct({ reference: ContextReference, persist: Schema.Boolean }),\n ),\n proxies: Schema.optionalKey(\n Schema.Union([Schema.Boolean, Schema.Array(ProxyRule).check(Schema.isMaxLength(64))]),\n ),\n verified: Schema.optionalKey(Schema.Boolean),\n }),\n ),\n});\n\nexport type AgentRunRequest = typeof AgentRunRequest.Type;\n\nconst Window = {\n startAt: Schema.optionalKey(Timestamp),\n endAt: Schema.optionalKey(Timestamp),\n cursor: Schema.optionalKey(Cursor),\n};\n\nexport const AgentListQuery = Schema.Struct({\n ...Window,\n limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1000 }))),\n});\n\nexport type AgentListQuery = typeof AgentListQuery.Type;\n\nexport const AgentRunListQuery = Schema.Struct({\n ...Window,\n status: Schema.optionalKey(AgentRunStatus),\n agentId: Schema.optionalKey(Identifier),\n limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 1000 }))),\n});\n\nexport type AgentRunListQuery = typeof AgentRunListQuery.Type;\n\nexport const AgentMessageQuery = Schema.Struct({\n since: Schema.optionalKey(Cursor),\n limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 }))),\n all: Schema.optionalKey(Schema.Boolean),\n});\n\nexport type AgentMessageQuery = typeof AgentMessageQuery.Type;\n\nexport const AgentRunWaitOptions = Schema.Struct({\n timeoutMillis: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 21_600_000 })),\n pollIntervalMillis: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 250, maximum: 60_000 })),\n ),\n});\n\nexport type AgentRunWaitOptions = typeof AgentRunWaitOptions.Type;\n\nexport interface Page<A> {\n readonly items: ReadonlyArray<A>;\n readonly nextCursor: string | undefined;\n}\n\nexport interface AgentMessages {\n readonly messages: ReadonlyArray<AgentRunMessage>;\n readonly nextSince: string | undefined;\n}\n\nconst ProviderAgent = Schema.Struct({\n agentId: Identifier,\n name: AgentMetadata.fields.name,\n systemPrompt: Schema.optionalKey(Prompt),\n resultSchema: Schema.optionalKey(JsonObject),\n createdAt: Timestamp,\n updatedAt: Timestamp,\n});\n\nconst ProviderPage = <S extends Schema.Top>(item: S) =>\n Schema.Struct({\n data: Schema.Array(item).check(Schema.isMaxLength(1000)),\n nextCursor: Schema.optionalKey(Schema.NullOr(Schema.String.check(Schema.isMaxLength(4096)))),\n });\n\nconst ProviderMessages = Schema.Struct({\n data: Schema.Array(\n Schema.Struct({\n id: AgentRunMessage.fields.id,\n createdAt: Timestamp,\n message: Schema.Struct({ role: AgentRunMessage.fields.role, content: Schema.Json }),\n }),\n ).check(Schema.isMaxLength(100)),\n nextSince: Schema.optionalKey(Schema.NullOr(Schema.String.check(Schema.isMaxLength(4096)))),\n});\n\nconst now = Clock.monotonicTimeNanos.pipe(Effect.map((value) => Number(value) / 1_000_000));\n\n/**\n * Browserbase Agents: hosted autonomous runs that allocate their own browser sessions and\n * bill inference. Creating or stopping a run is never retried; a lost reply is `unknown`.\n */\nexport class BrowserbaseAgents extends Context.Service<\n BrowserbaseAgents,\n {\n readonly create: (definition: AgentDefinition) => Effect.Effect<AgentMetadata, PlatformError>;\n readonly list: (query?: AgentListQuery) => Effect.Effect<Page<AgentMetadata>, PlatformError>;\n readonly retrieve: (agentId: string) => Effect.Effect<AgentMetadata, PlatformError>;\n readonly update: (\n agentId: string,\n update: AgentUpdate,\n ) => Effect.Effect<AgentMetadata, PlatformError>;\n readonly delete: (agentId: string) => Effect.Effect<void, PlatformError>;\n readonly run: (request: AgentRunRequest) => Effect.Effect<AgentRun, PlatformError>;\n readonly retrieveRun: (runId: string) => Effect.Effect<AgentRun, PlatformError>;\n readonly listRuns: (query?: AgentRunListQuery) => Effect.Effect<Page<AgentRun>, PlatformError>;\n readonly stopRun: (runId: string) => Effect.Effect<AgentRun, PlatformError>;\n readonly messages: (\n runId: string,\n query?: AgentMessageQuery,\n ) => Effect.Effect<AgentMessages, PlatformError>;\n /** Polls until the run is terminal. Interrupting the wait does not stop the run. */\n readonly waitForRun: (\n runId: string,\n options: AgentRunWaitOptions,\n ) => Effect.Effect<AgentRun, PlatformError>;\n }\n>()(\"effect-browserbase/Agents\") {\n static readonly layer: Layer.Layer<BrowserbaseAgents, never, BrowserbaseClient> = Layer.effect(\n BrowserbaseAgents,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n\n const api = resource<PlatformError>(client, (failure) =>\n PlatformError.make({ ...failure, service: \"agents\" }),\n );\n\n const agentPath = (id: string) => `/v1/agents/${api.segment(id)}`;\n const runPath = (id: string) => `/v1/agents/runs/${api.segment(id)}`;\n\n const agent = (operation: PlatformError[\"operation\"], mutation: boolean, expected?: string) =>\n Effect.fnUntraced(function* (value: typeof ProviderAgent.Type) {\n if (expected !== undefined && value.agentId !== expected)\n return yield* api.malformed(operation, mutation);\n\n return AgentMetadata.make(value);\n });\n\n const run = (operation: PlatformError[\"operation\"], mutation: boolean, expected?: string) =>\n Effect.fnUntraced(function* (value: AgentRun) {\n if (expected !== undefined && value.runId !== expected)\n return yield* api.malformed(operation, mutation);\n\n return value;\n });\n\n const create = Effect.fn(\"BrowserbaseAgents.create\")(function* (definition: AgentDefinition) {\n const value = yield* api.input(AgentDefinition, definition, \"agent-create\");\n\n return yield* api\n .request(\"POST\", \"/v1/agents\", ProviderAgent, \"agent-create\", value)\n .pipe(Effect.flatMap(agent(\"agent-create\", true)));\n });\n\n const list = Effect.fn(\"BrowserbaseAgents.list\")(function* (query: AgentListQuery = {}) {\n const value = yield* api.input(AgentListQuery, query, \"agent-list\");\n\n const page = yield* api.request(\n \"GET\",\n `/v1/agents${api.query(value)}`,\n ProviderPage(ProviderAgent),\n \"agent-list\",\n );\n\n return {\n items: page.data.map((row) => AgentMetadata.make(row)),\n nextCursor: page.nextCursor ?? undefined,\n };\n });\n\n const retrieve = Effect.fn(\"BrowserbaseAgents.retrieve\")(function* (agentId: string) {\n const id = yield* api.input(Identifier, agentId, \"agent-retrieve\");\n\n return yield* api\n .request(\"GET\", agentPath(id), ProviderAgent, \"agent-retrieve\")\n .pipe(Effect.flatMap(agent(\"agent-retrieve\", false, id)));\n });\n\n const update = Effect.fn(\"BrowserbaseAgents.update\")(function* (\n agentId: string,\n changes: AgentUpdate,\n ) {\n const id = yield* api.input(Identifier, agentId, \"agent-update\");\n const value = yield* api.input(AgentUpdate, changes, \"agent-update\");\n\n if (Object.keys(value).length === 0) return yield* api.configuration(\"agent-update\");\n\n return yield* api\n .request(\"PATCH\", agentPath(id), ProviderAgent, \"agent-update\", value)\n .pipe(Effect.flatMap(agent(\"agent-update\", true, id)));\n });\n\n const remove = Effect.fn(\"BrowserbaseAgents.delete\")(function* (agentId: string) {\n const id = yield* api.input(Identifier, agentId, \"agent-delete\");\n\n yield* api.remove(agentPath(id), \"agent-delete\");\n });\n\n const start = Effect.fn(\"BrowserbaseAgents.run\")(function* (request: AgentRunRequest) {\n const value = yield* api.input(AgentRunRequest, request, \"agent-run\");\n const settings = value.browserSettings;\n const context = settings?.context;\n\n if (context !== undefined) {\n if (context.reference.projectId !== client.projectId)\n return yield* api.make({\n operation: \"agent-run\",\n reason: \"authorization\",\n outcome: \"undispatched\",\n });\n if (context.persist && isContextWriterBusy(context.reference))\n return yield* api.make({\n operation: \"agent-run\",\n reason: \"active\",\n outcome: \"undispatched\",\n });\n }\n\n const body: Schema.Json = {\n task: value.task,\n ...(value.agentId === undefined ? {} : { agentId: value.agentId }),\n ...(value.resultSchema === undefined ? {} : { resultSchema: value.resultSchema }),\n ...(value.variables === undefined ? {} : { variables: value.variables }),\n ...(settings === undefined\n ? {}\n : {\n browserSettings: {\n ...(context === undefined\n ? {}\n : {\n context: { id: context.reference.contextId, persist: context.persist },\n }),\n ...(settings.proxies === undefined\n ? {}\n : {\n proxies:\n typeof settings.proxies === \"boolean\"\n ? settings.proxies\n : settings.proxies.map(proxy),\n }),\n ...(settings.verified === undefined ? {} : { verified: settings.verified }),\n },\n }),\n };\n\n return yield* api.request(\"POST\", \"/v1/agents/runs\", AgentRun, \"agent-run\", body);\n });\n\n const retrieveRun = Effect.fn(\"BrowserbaseAgents.retrieveRun\")(function* (runId: string) {\n const id = yield* api.input(Identifier, runId, \"agent-run-retrieve\");\n\n return yield* api\n .request(\"GET\", runPath(id), AgentRun, \"agent-run-retrieve\")\n .pipe(Effect.flatMap(run(\"agent-run-retrieve\", false, id)));\n });\n\n const listRuns = Effect.fn(\"BrowserbaseAgents.listRuns\")(function* (\n query: AgentRunListQuery = {},\n ) {\n const value = yield* api.input(AgentRunListQuery, query, \"agent-run-list\");\n\n const page = yield* api.request(\n \"GET\",\n `/v1/agents/runs${api.query(value)}`,\n ProviderPage(AgentRun),\n \"agent-run-list\",\n );\n\n return { items: page.data, nextCursor: page.nextCursor ?? undefined };\n });\n\n const stopRun = Effect.fn(\"BrowserbaseAgents.stopRun\")(function* (runId: string) {\n const id = yield* api.input(Identifier, runId, \"agent-run-stop\");\n\n return yield* api\n .request(\"POST\", `${runPath(id)}/stop`, AgentRun, \"agent-run-stop\")\n .pipe(Effect.flatMap(run(\"agent-run-stop\", true, id)));\n });\n\n const messages = Effect.fn(\"BrowserbaseAgents.messages\")(function* (\n runId: string,\n query: AgentMessageQuery = {},\n ) {\n const id = yield* api.input(Identifier, runId, \"agent-run-messages\");\n const value = yield* api.input(AgentMessageQuery, query, \"agent-run-messages\");\n\n const page = yield* api.request(\n \"GET\",\n `${runPath(id)}/messages${api.query(value)}`,\n ProviderMessages,\n \"agent-run-messages\",\n );\n\n return {\n messages: page.data.map((row) =>\n AgentRunMessage.make({\n id: row.id,\n createdAt: row.createdAt,\n role: row.message.role,\n content: row.message.content,\n }),\n ),\n nextSince: page.nextSince ?? undefined,\n };\n });\n\n const waitForRun = Effect.fn(\"BrowserbaseAgents.waitForRun\")(function* (\n runId: string,\n options: AgentRunWaitOptions,\n ) {\n const bounds = yield* api.input(AgentRunWaitOptions, options, \"agent-run-wait\");\n const deadline = (yield* now) + bounds.timeoutMillis;\n\n for (;;) {\n const current = yield* retrieveRun(runId);\n\n if (isTerminalAgentRunStatus(current.status)) return current;\n const remaining = deadline - (yield* now);\n\n if (remaining <= 0)\n return yield* api.make({ operation: \"agent-run-wait\", reason: \"timeout\" });\n yield* Effect.sleep(Math.min(bounds.pollIntervalMillis ?? 2_000, remaining));\n }\n });\n\n return BrowserbaseAgents.of({\n create,\n list,\n retrieve,\n update,\n delete: remove,\n run: start,\n retrieveRun,\n listRuns,\n stopRun,\n messages,\n waitForRun,\n });\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,YAAY,OAAO,OAAO,MAAM,OAAO,YAAY,EAAE,CAAC;AAC5D,MAAM,SAAS,OAAO,eAAe,MAAM,OAAO,YAAY,IAAI,CAAC;AACnE,MAAM,aAAa,OAAO,OAAO,OAAO,QAAQ,OAAO,IAAI;AAC3D,MAAM,SAAS,OAAO,OAAO,MAAM,OAAO,YAAY,GAAO,CAAC;AAE9D,MAAa,iBAAiB,OAAO,SAAS;CAC5C;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,MAAa,4BAA4B,WACvC,WAAW,aAAa,WAAW;AAErC,IAAa,gBAAb,cAAmC,OAAO,MAAqB,0BAA0B,CAAC,CAAC;CACzF,SAAS;CACT,MAAM,OAAO,OAAO,MAAM,OAAO,YAAY,GAAG,CAAC;CACjD,cAAc,OAAO,YAAY,MAAM;CACvC,cAAc,OAAO,YAAY,U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yBAAyB,QAAQ,MAAM,GAAG,OAAO;IACrD,MAAM,YAAY,YAAY,OAAO;IAErC,IAAI,aAAa,GACf,OAAO,OAAO,IAAI,KAAK;KAAE,WAAW;KAAkB,QAAQ;IAAU,CAAC;IAC3E,OAAO,OAAO,MAAM,KAAK,IAAI,OAAO,sBAAsB,KAAO,SAAS,CAAC;GAC7E;EACF,CAAC;EAED,OAAO,kBAAkB,GAAG;GAC1B;GACA;GACA;GACA;GACA,QAAQ;GACR,KAAK;GACL;GACA;GACA;GACA;GACA;EACF,CAAC;CACH,CAAC,CACH;AACF"}
@@ -0,0 +1,99 @@
1
+ import { n as ContextReference, o as SessionReference, r as ExtensionReference, t as AllocationAttempt } from "./References-URDAtapt.mjs";
2
+ import { AllocationError, BrowserError, ContextError } from "./Errors.mjs";
3
+ import { t as BrowserbaseClient } from "./Client-Ca0zSg1n.mjs";
4
+ import { t as BrowserbaseSessions } from "./Sessions-B8E4kMxo.mjs";
5
+ import { n as CleanupResult } from "./Cleanup-G2YpTCuU.mjs";
6
+ import { n as ContextWriterPermit } from "./WriterFacts-osvYAsIx.mjs";
7
+ import "./ContextCoordination.mjs";
8
+ import { Effect, Option } from "effect";
9
+ declare namespace Allocation_d_exports {
10
+ export { AllocatedSession, AllocationOptions, scoped };
11
+ }
12
+ /** A session this process allocated and owns, with no browser connected to it. */
13
+ export interface AllocatedSession {
14
+ readonly reference: SessionReference;
15
+ /** The creation attempt, retained so an unknown provider outcome stays attributable. */
16
+ readonly attempt: AllocationAttempt;
17
+ /**
18
+ * Release now and read the cleanup evidence. The scope finalizer performs the same
19
+ * release, so an uncalled `release` is a scope that has not closed yet, not a leak.
20
+ */
21
+ readonly release: Effect.Effect<CleanupResult>;
22
+ /** The cleanup evidence once it exists, and `None` while the session is still held. */
23
+ readonly cleanupResult: Effect.Effect<Option.Option<CleanupResult>>;
24
+ }
25
+ export interface AllocationOptions {
26
+ /** Required exactly when the recipe persists a Context, and refused when it does not. */
27
+ readonly contextWriter?: ContextWriterPermit;
28
+ readonly allocationDeadline?: number;
29
+ /** Bounded host notification of the canonical facts. Reporting never changes them. */
30
+ readonly onCleanup?: (result: CleanupResult) => Effect.Effect<void>;
31
+ /** Exactly one notification when a creation attempt's effect on the provider is unknown. */
32
+ readonly onAllocationUncertain?: (attempt: AllocationAttempt) => Effect.Effect<void>;
33
+ }
34
+ /**
35
+ * Allocate a session without connecting a browser, for a caller that drives the remote
36
+ * session with its own automation client. This is the allocation path the browser owner
37
+ * uses, so release, unknown-outcome reporting and Context writer authority keep a single
38
+ * owner: the creation request is never retried, a foreign project is refused before it is
39
+ * sent, and no native peer is loaded. The scope owns the release; closing it releases the
40
+ * session whether or not the caller ever connected to it.
41
+ */
42
+ export declare const scoped: (launch: {
43
+ readonly remoteTimeoutSeconds: number;
44
+ readonly keepAlive?: boolean | undefined;
45
+ readonly context?: {
46
+ readonly reference: ContextReference;
47
+ readonly persist: boolean;
48
+ } | undefined;
49
+ readonly extension?: ExtensionReference | undefined;
50
+ readonly viewport: {
51
+ readonly _tag: "ProviderManaged";
52
+ } | {
53
+ readonly _tag: "Fixed";
54
+ readonly width: number;
55
+ readonly height: number;
56
+ };
57
+ readonly provider: {
58
+ readonly region?: "ap-southeast-1" | "eu-central-1" | "us-east-1" | "us-west-2" | undefined;
59
+ readonly proxies?: boolean | readonly ({
60
+ readonly type: "browserbase";
61
+ readonly domainPattern?: string | undefined;
62
+ readonly geolocation?: {
63
+ readonly country: string;
64
+ readonly state?: string | undefined;
65
+ readonly city?: string | undefined;
66
+ } | undefined;
67
+ } | {
68
+ readonly type: "external";
69
+ readonly server: string;
70
+ readonly domainPattern?: string | undefined;
71
+ readonly username?: import("effect/Redacted").Redacted<string> | undefined;
72
+ readonly password?: import("effect/Redacted").Redacted<string> | undefined;
73
+ } | {
74
+ readonly type: "none";
75
+ readonly domainPattern?: string | undefined;
76
+ })[] | undefined;
77
+ readonly proxySettings?: {
78
+ readonly caCertificates?: readonly string[] | undefined;
79
+ } | undefined;
80
+ readonly browserSettings?: {
81
+ readonly verified?: boolean | undefined;
82
+ readonly os?: "linux" | "mac" | "mobile" | "tablet" | "windows" | undefined;
83
+ readonly allowedDomains?: readonly string[] | undefined;
84
+ readonly blockAds?: boolean | undefined;
85
+ readonly captchaImageSelector?: string | undefined;
86
+ readonly captchaInputSelector?: string | undefined;
87
+ readonly ignoreCertificateErrors?: boolean | undefined;
88
+ readonly logSession?: boolean | undefined;
89
+ readonly recordSession?: boolean | undefined;
90
+ readonly solveCaptchas?: boolean | undefined;
91
+ } | undefined;
92
+ readonly userMetadata?: {
93
+ readonly [x: string]: import("effect/Schema").Json;
94
+ } | undefined;
95
+ };
96
+ }, options?: AllocationOptions | undefined) => Effect.Effect<AllocatedSession, AllocationError | BrowserError | ContextError, BrowserbaseClient | BrowserbaseSessions | import("effect/Scope").Scope>;
97
+ //#endregion
98
+ export { Allocation_d_exports as t };
99
+ //# sourceMappingURL=Allocation.d.mts.map
@@ -0,0 +1,29 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { t as acquireRemote } from "./Acquisition-WBafHwXH.mjs";
3
+ import { Effect } from "effect";
4
+ //#region src/Allocation.ts
5
+ var Allocation_exports = /* @__PURE__ */ __exportAll({ scoped: () => scoped });
6
+ /**
7
+ * Allocate a session without connecting a browser, for a caller that drives the remote
8
+ * session with its own automation client. This is the allocation path the browser owner
9
+ * uses, so release, unknown-outcome reporting and Context writer authority keep a single
10
+ * owner: the creation request is never retried, a foreign project is refused before it is
11
+ * sent, and no native peer is loaded. The scope owns the release; closing it releases the
12
+ * session whether or not the caller ever connected to it.
13
+ */
14
+ const scoped = Effect.fnUntraced(function* (launch, options = {}) {
15
+ const acquisition = yield* acquireRemote({
16
+ launch,
17
+ ...options
18
+ });
19
+ return {
20
+ reference: acquisition.reference,
21
+ attempt: acquisition.attempt,
22
+ release: acquisition.release,
23
+ cleanupResult: acquisition.cleanupResult
24
+ };
25
+ });
26
+ //#endregion
27
+ export { scoped, Allocation_exports as t };
28
+
29
+ //# sourceMappingURL=Allocation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Allocation.mjs","names":[],"sources":["../src/Allocation.ts"],"sourcesContent":["import { Effect, type Option } from \"effect\";\n\nimport type { CleanupResult } from \"./Cleanup.ts\";\nimport type { ContextWriterPermit } from \"./ContextCoordination.ts\";\nimport { acquireRemote } from \"./internal/session/Acquisition.ts\";\nimport type { LaunchRecipe } from \"./Launch.ts\";\nimport type { AllocationAttempt, SessionReference } from \"./References.ts\";\n\n/** A session this process allocated and owns, with no browser connected to it. */\nexport interface AllocatedSession {\n readonly reference: SessionReference;\n /** The creation attempt, retained so an unknown provider outcome stays attributable. */\n readonly attempt: AllocationAttempt;\n /**\n * Release now and read the cleanup evidence. The scope finalizer performs the same\n * release, so an uncalled `release` is a scope that has not closed yet, not a leak.\n */\n readonly release: Effect.Effect<CleanupResult>;\n /** The cleanup evidence once it exists, and `None` while the session is still held. */\n readonly cleanupResult: Effect.Effect<Option.Option<CleanupResult>>;\n}\n\nexport interface AllocationOptions {\n /** Required exactly when the recipe persists a Context, and refused when it does not. */\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 * Allocate a session without connecting a browser, for a caller that drives the remote\n * session with its own automation client. This is the allocation path the browser owner\n * uses, so release, unknown-outcome reporting and Context writer authority keep a single\n * owner: the creation request is never retried, a foreign project is refused before it is\n * sent, and no native peer is loaded. The scope owns the release; closing it releases the\n * session whether or not the caller ever connected to it.\n */\nexport const scoped = Effect.fnUntraced(function* (\n launch: LaunchRecipe,\n options: AllocationOptions = {},\n) {\n const acquisition = yield* acquireRemote({ launch, ...options });\n\n const allocated: AllocatedSession = {\n reference: acquisition.reference,\n attempt: acquisition.attempt,\n release: acquisition.release,\n cleanupResult: acquisition.cleanupResult,\n };\n\n return allocated;\n});\n"],"mappings":";;;;;;;;;;;;;AAwCA,MAAa,SAAS,OAAO,WAAW,WACtC,QACA,UAA6B,CAAC,GAC9B;CACA,MAAM,cAAc,OAAO,cAAc;EAAE;EAAQ,GAAG;CAAQ,CAAC;CAS/D,OAAO;EANL,WAAW,YAAY;EACvB,SAAS,YAAY;EACrB,SAAS,YAAY;EACrB,eAAe,YAAY;CAGd;AACjB,CAAC"}
@@ -0,0 +1,10 @@
1
+ //#region src/internal/browser/Association.ts
2
+ const parents = /* @__PURE__ */ new WeakMap();
3
+ const associate = (session, parent) => {
4
+ parents.set(session, parent);
5
+ };
6
+ const captureParent = (session) => parents.get(session);
7
+ //#endregion
8
+ export { captureParent as n, associate as t };
9
+
10
+ //# sourceMappingURL=Association-CEps4hYP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Association-CEps4hYP.mjs","names":[],"sources":["../src/internal/browser/Association.ts"],"sourcesContent":["import type { Effect } from \"effect\";\n\nimport type { PageInfo, Target } from \"../../BrowserData.ts\";\nimport type { BrowserError } from \"../../Errors.ts\";\nimport type { CaptureSource } from \"./Driver.ts\";\nimport type { Owner, Ticket } from \"./Owner.ts\";\n\nexport interface CaptureLease {\n readonly stop: Effect.Effect<void>;\n readonly invalidate: (reason: string) => void;\n readonly reservedBytes: number;\n}\n\nexport interface CaptureResolution {\n /** Stable native page identity used to quarantine an unconfirmed screencast across reconnects. */\n readonly key: string;\n readonly target: Target;\n readonly source: CaptureSource;\n}\n\nexport interface CaptureParent {\n readonly owner: Owner;\n readonly resolve: (\n ticket: Ticket,\n target?: PageInfo,\n ) => Effect.Effect<CaptureResolution, BrowserError>;\n readonly target: () => Target;\n readonly captureLeases: Map<string, CaptureLease>;\n captureReservedBytes: number;\n}\n\n// This is a private capability registry, not stored domain data. Exact live session identity is\n// required: spreading/cloning a session must not copy authority to mutate its capture owner,\n// leases or reservations. A public/enumerable parent field would weaken that boundary.\n// Keep this access centralized here; schemas describe data, never this mutable ownership state.\nconst parents = new WeakMap<object, CaptureParent>();\n\nexport const associate = (session: object, parent: CaptureParent): void => {\n parents.set(session, parent);\n};\n\nexport const captureParent = (session: object): CaptureParent | undefined => parents.get(session);\n"],"mappings":";AAmCA,MAAM,0BAAU,IAAI,QAA+B;AAEnD,MAAa,aAAa,SAAiB,WAAgC;CACzE,QAAQ,IAAI,SAAS,MAAM;AAC7B;AAEA,MAAa,iBAAiB,YAA+C,QAAQ,IAAI,OAAO"}
@@ -0,0 +1,12 @@
1
+ import { isTerminalSessionStatus } from "./SessionData.mjs";
2
+ import { Effect } from "effect";
3
+ //#region src/internal/artifact/Authorization.ts
4
+ /**
5
+ * Provider artifacts belong to a finished session. This reads the exact session through the
6
+ * one canonical resource service; it never infers terminality from an artifact listing.
7
+ */
8
+ const requireTerminalSession = (sessions, reference, active, rejected) => sessions.retrieve(reference).pipe(Effect.mapError(rejected), Effect.flatMap((metadata) => isTerminalSessionStatus(metadata.status) ? Effect.void : Effect.fail(active())));
9
+ //#endregion
10
+ export { requireTerminalSession as t };
11
+
12
+ //# sourceMappingURL=Authorization-Ll5f_XNM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Authorization-Ll5f_XNM.mjs","names":[],"sources":["../src/internal/artifact/Authorization.ts"],"sourcesContent":["import { Effect } from \"effect\";\n\nimport type { SessionError } from \"../../Errors.ts\";\nimport type { SessionReference } from \"../../References.ts\";\nimport { isTerminalSessionStatus } from \"../../SessionData.ts\";\nimport type { BrowserbaseSessions } from \"../../Sessions.ts\";\n\n/**\n * Provider artifacts belong to a finished session. This reads the exact session through the\n * one canonical resource service; it never infers terminality from an artifact listing.\n */\nexport const requireTerminalSession = <E>(\n sessions: BrowserbaseSessions[\"Service\"],\n reference: SessionReference,\n active: () => E,\n rejected: (error: SessionError) => E,\n) =>\n sessions.retrieve(reference).pipe(\n Effect.mapError(rejected),\n Effect.flatMap((metadata) =>\n isTerminalSessionStatus(metadata.status) ? Effect.void : Effect.fail(active()),\n ),\n );\n"],"mappings":";;;;;;;AAWA,MAAa,0BACX,UACA,WACA,QACA,aAEA,SAAS,SAAS,SAAS,CAAC,CAAC,KAC3B,OAAO,SAAS,QAAQ,GACxB,OAAO,SAAS,aACd,wBAAwB,SAAS,MAAM,IAAI,OAAO,OAAO,OAAO,KAAK,OAAO,CAAC,CAC/E,CACF"}