effect-browserbase 0.2.0-beta.8 → 0.3.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +277 -315
- package/dist/Browserbase-CaPKwEY9.mjs +544 -0
- package/dist/Browserbase-CaPKwEY9.mjs.map +1 -0
- package/dist/Browserbase.d.mts +110 -0
- package/dist/Browserbase.mjs +3 -0
- package/dist/BrowserbaseClient-CtAQ2rg4.d.mts +195 -0
- package/dist/BrowserbaseClient.d.mts +2 -0
- package/dist/BrowserbaseClient.mjs +190 -0
- package/dist/BrowserbaseClient.mjs.map +1 -0
- package/dist/BrowserbaseError-D1EOrLNc.d.mts +79 -0
- package/dist/BrowserbaseError.d.mts +2 -0
- package/dist/BrowserbaseError.mjs +101 -0
- package/dist/BrowserbaseError.mjs.map +1 -0
- package/dist/ContextLease.d.mts +42 -0
- package/dist/ContextLease.mjs +80 -0
- package/dist/ContextLease.mjs.map +1 -0
- package/dist/index.d.mts +5 -27
- package/dist/index.mjs +5 -26
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/testing/index.d.mts +136 -0
- package/dist/testing/index.mjs +440 -0
- package/dist/testing/index.mjs.map +1 -0
- package/package.json +51 -121
- package/src/Browserbase.ts +729 -0
- package/src/BrowserbaseClient.ts +559 -0
- package/src/BrowserbaseError.ts +108 -0
- package/src/ContextLease.ts +118 -0
- package/src/index.ts +7 -0
- package/src/internal/captureConnection.ts +214 -0
- package/src/testing/BrowserbaseContract.ts +170 -0
- package/src/testing/TestBrowserbase.ts +509 -0
- package/src/testing/index.ts +7 -0
- package/dist/Account.d.mts +0 -32
- package/dist/Account.mjs +0 -36
- package/dist/Account.mjs.map +0 -1
- package/dist/Acquisition-BOABu_qJ.mjs +0 -244
- package/dist/Acquisition-BOABu_qJ.mjs.map +0 -1
- package/dist/Agents-CPaTOH_g.d.mts +0 -156
- package/dist/Agents.d.mts +0 -3
- package/dist/Agents.mjs +0 -292
- package/dist/Agents.mjs.map +0 -1
- package/dist/Allocation.d.mts +0 -97
- package/dist/Allocation.mjs +0 -27
- package/dist/Allocation.mjs.map +0 -1
- package/dist/Authorization-Ll5f_XNM.mjs +0 -12
- package/dist/Authorization-Ll5f_XNM.mjs.map +0 -1
- package/dist/Browser-ByrWJ0ss.mjs +0 -274
- package/dist/Browser-ByrWJ0ss.mjs.map +0 -1
- package/dist/Browser.d.mts +0 -83
- package/dist/Browser.mjs +0 -3
- package/dist/BrowserBinding.d.mts +0 -13
- package/dist/BrowserBinding.mjs +0 -31
- package/dist/BrowserBinding.mjs.map +0 -1
- package/dist/Certificates-D4NQmyeA.d.mts +0 -34
- package/dist/Certificates.d.mts +0 -3
- package/dist/Certificates.mjs +0 -85
- package/dist/Certificates.mjs.map +0 -1
- package/dist/Cleanup-DMTDBir8.d.mts +0 -23
- package/dist/Cleanup.d.mts +0 -3
- package/dist/Cleanup.mjs +0 -43
- package/dist/Cleanup.mjs.map +0 -1
- package/dist/Client-BEC4Q8ZS.mjs +0 -564
- package/dist/Client-BEC4Q8ZS.mjs.map +0 -1
- package/dist/Client-B_f6bBLT.d.mts +0 -52
- package/dist/Client.d.mts +0 -3
- package/dist/Client.mjs +0 -2
- package/dist/Connection-sxyxtwlk.mjs +0 -56
- package/dist/Connection-sxyxtwlk.mjs.map +0 -1
- package/dist/ContextCoordination.d.mts +0 -29
- package/dist/ContextCoordination.mjs +0 -94
- package/dist/ContextCoordination.mjs.map +0 -1
- package/dist/ContextWriter-CiEma24z.mjs +0 -204
- package/dist/ContextWriter-CiEma24z.mjs.map +0 -1
- package/dist/Contexts-DqdL7cyX.d.mts +0 -31
- package/dist/Contexts.d.mts +0 -3
- package/dist/Contexts.mjs +0 -97
- package/dist/Contexts.mjs.map +0 -1
- package/dist/Deadline-CrViaogr.mjs +0 -13
- package/dist/Deadline-CrViaogr.mjs.map +0 -1
- package/dist/Downloads-CX52GOFJ.d.mts +0 -43
- package/dist/Downloads.d.mts +0 -3
- package/dist/Downloads.mjs +0 -137
- package/dist/Downloads.mjs.map +0 -1
- package/dist/Errors.d.mts +0 -100
- package/dist/Errors.mjs +0 -194
- package/dist/Errors.mjs.map +0 -1
- package/dist/Extensions-BTUn9zhK.mjs +0 -231
- package/dist/Extensions-BTUn9zhK.mjs.map +0 -1
- package/dist/Extensions-DBXuVM1f.d.mts +0 -43
- package/dist/Extensions.d.mts +0 -3
- package/dist/Extensions.mjs +0 -2
- package/dist/Functions-CsKMMUuZ.d.mts +0 -226
- package/dist/Functions.d.mts +0 -3
- package/dist/Functions.mjs +0 -318
- package/dist/Functions.mjs.map +0 -1
- package/dist/Issued-DejqoMYL.mjs +0 -15
- package/dist/Issued-DejqoMYL.mjs.map +0 -1
- package/dist/Launch-cAdE2rrZ.mjs +0 -115
- package/dist/Launch-cAdE2rrZ.mjs.map +0 -1
- package/dist/Launch.d.mts +0 -127
- package/dist/Launch.mjs +0 -97
- package/dist/Launch.mjs.map +0 -1
- package/dist/PageFetch-CjAM_0DS.d.mts +0 -40
- package/dist/PageFetch.d.mts +0 -3
- package/dist/PageFetch.mjs +0 -59
- package/dist/PageFetch.mjs.map +0 -1
- package/dist/Projects-tm5bTDH0.d.mts +0 -38
- package/dist/Projects.d.mts +0 -3
- package/dist/Projects.mjs +0 -65
- package/dist/Projects.mjs.map +0 -1
- package/dist/Recordings-B9k5aODB.d.mts +0 -27
- package/dist/Recordings.d.mts +0 -3
- package/dist/Recordings.mjs +0 -144
- package/dist/Recordings.mjs.map +0 -1
- package/dist/References-DOH3Wu44.d.mts +0 -34
- package/dist/References.d.mts +0 -3
- package/dist/References.mjs +0 -33
- package/dist/References.mjs.map +0 -1
- package/dist/Replays-mV93WGtx.d.mts +0 -27
- package/dist/Replays.d.mts +0 -3
- package/dist/Replays.mjs +0 -107
- package/dist/Replays.mjs.map +0 -1
- package/dist/Resource-J7Kkk5mu.mjs +0 -54
- package/dist/Resource-J7Kkk5mu.mjs.map +0 -1
- package/dist/Search-B64e7g-h.d.mts +0 -37
- package/dist/Search.d.mts +0 -3
- package/dist/Search.mjs +0 -46
- package/dist/Search.mjs.map +0 -1
- package/dist/SessionData-5xYZDshJ.d.mts +0 -38
- package/dist/SessionData.d.mts +0 -3
- package/dist/SessionData.mjs +0 -48
- package/dist/SessionData.mjs.map +0 -1
- package/dist/Sessions-D2H5m6rF.mjs +0 -260
- package/dist/Sessions-D2H5m6rF.mjs.map +0 -1
- package/dist/Sessions-oJEUmZth.d.mts +0 -69
- package/dist/Sessions.d.mts +0 -4
- package/dist/Sessions.mjs +0 -3
- package/dist/Testing.d.mts +0 -119
- package/dist/Testing.mjs +0 -206
- package/dist/Testing.mjs.map +0 -1
- package/dist/TransferPolicy-DQ06i7SZ.mjs +0 -25
- package/dist/TransferPolicy-DQ06i7SZ.mjs.map +0 -1
- package/dist/Transfers-GVqzrDWl.d.mts +0 -89
- package/dist/Transfers.d.mts +0 -3
- package/dist/Transfers.mjs +0 -85
- package/dist/Transfers.mjs.map +0 -1
- package/dist/Uploads-C2_bACgv.d.mts +0 -28
- package/dist/Uploads.d.mts +0 -3
- package/dist/Uploads.mjs +0 -105
- package/dist/Uploads.mjs.map +0 -1
- package/dist/Webhooks-BoeRAxzG.d.mts +0 -59
- package/dist/Webhooks.d.mts +0 -3
- package/dist/Webhooks.mjs +0 -134
- package/dist/Webhooks.mjs.map +0 -1
- package/dist/WriterFacts-BBJRDZYY.d.mts +0 -54
package/dist/Agents.mjs
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import { ContextReference, Identifier } from "./References.mjs";
|
|
2
|
-
import { PlatformError } from "./Errors.mjs";
|
|
3
|
-
import { r as span, t as BrowserbaseClient } from "./Client-BEC4Q8ZS.mjs";
|
|
4
|
-
import { t as resource } from "./Resource-J7Kkk5mu.mjs";
|
|
5
|
-
import { ProxyRule } from "./Launch.mjs";
|
|
6
|
-
import { n as proxy } from "./Launch-cAdE2rrZ.mjs";
|
|
7
|
-
import { r as isContextWriterBusy } from "./ContextWriter-CiEma24z.mjs";
|
|
8
|
-
import { Clock, Context, Effect, Layer, Schema } from "effect";
|
|
9
|
-
//#region src/Agents.ts
|
|
10
|
-
const Timestamp = Schema.String.check(Schema.isMaxLength(64));
|
|
11
|
-
const Cursor = Schema.NonEmptyString.check(Schema.isMaxLength(4096));
|
|
12
|
-
const JsonObject = Schema.Record(Schema.String, Schema.Json);
|
|
13
|
-
const Prompt = Schema.String.check(Schema.isMaxLength(1e5));
|
|
14
|
-
const AgentRunStatus = Schema.Literals([
|
|
15
|
-
"PENDING",
|
|
16
|
-
"RUNNING",
|
|
17
|
-
"COMPLETED",
|
|
18
|
-
"FAILED",
|
|
19
|
-
"STOPPED",
|
|
20
|
-
"TIMED_OUT"
|
|
21
|
-
]);
|
|
22
|
-
const isTerminalAgentRunStatus = (status) => status !== "PENDING" && status !== "RUNNING";
|
|
23
|
-
var AgentMetadata = class extends Schema.Class("BrowserbaseAgentMetadata")({
|
|
24
|
-
agentId: Identifier,
|
|
25
|
-
name: Schema.String.check(Schema.isMaxLength(255)),
|
|
26
|
-
systemPrompt: Schema.optionalKey(Prompt),
|
|
27
|
-
resultSchema: Schema.optionalKey(JsonObject),
|
|
28
|
-
createdAt: Timestamp,
|
|
29
|
-
updatedAt: Timestamp
|
|
30
|
-
}) {};
|
|
31
|
-
var AgentRun = class extends Schema.Class("BrowserbaseAgentRun")({
|
|
32
|
-
runId: Identifier,
|
|
33
|
-
agentId: Schema.optionalKey(Identifier),
|
|
34
|
-
task: Prompt,
|
|
35
|
-
status: AgentRunStatus,
|
|
36
|
-
sessionId: Schema.optionalKey(Identifier),
|
|
37
|
-
sandboxId: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(256))),
|
|
38
|
-
resultSchema: Schema.optionalKey(JsonObject),
|
|
39
|
-
result: Schema.optionalKey(JsonObject),
|
|
40
|
-
cause: Schema.optionalKey(Schema.Struct({
|
|
41
|
-
code: Schema.String.check(Schema.isMaxLength(64)),
|
|
42
|
-
message: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(500)))
|
|
43
|
-
})),
|
|
44
|
-
startedAt: Schema.optionalKey(Timestamp),
|
|
45
|
-
endedAt: Schema.optionalKey(Timestamp),
|
|
46
|
-
createdAt: Timestamp,
|
|
47
|
-
updatedAt: Timestamp
|
|
48
|
-
}) {};
|
|
49
|
-
var AgentRunMessage = class extends Schema.Class("BrowserbaseAgentRunMessage")({
|
|
50
|
-
id: Schema.String.check(Schema.isMaxLength(256)),
|
|
51
|
-
createdAt: Timestamp,
|
|
52
|
-
role: Schema.Literals(["assistant", "tool"]),
|
|
53
|
-
content: Schema.Json
|
|
54
|
-
}) {};
|
|
55
|
-
const AgentDefinition = Schema.Struct({
|
|
56
|
-
name: Schema.NonEmptyString.check(Schema.isMaxLength(255)),
|
|
57
|
-
systemPrompt: Schema.optionalKey(Prompt),
|
|
58
|
-
resultSchema: Schema.optionalKey(JsonObject)
|
|
59
|
-
});
|
|
60
|
-
const AgentUpdate = Schema.Struct({
|
|
61
|
-
name: Schema.optionalKey(AgentDefinition.fields.name),
|
|
62
|
-
systemPrompt: Schema.optionalKey(Prompt),
|
|
63
|
-
resultSchema: Schema.optionalKey(JsonObject)
|
|
64
|
-
});
|
|
65
|
-
const AgentRunRequest = Schema.Struct({
|
|
66
|
-
task: Schema.NonEmptyString.check(Schema.isMaxLength(1e5)),
|
|
67
|
-
agentId: Schema.optionalKey(Identifier),
|
|
68
|
-
resultSchema: Schema.optionalKey(JsonObject),
|
|
69
|
-
variables: Schema.optionalKey(Schema.Record(Schema.String.check(Schema.isMaxLength(128)), Schema.Struct({
|
|
70
|
-
value: Schema.String.check(Schema.isMaxLength(1e5)),
|
|
71
|
-
description: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024)))
|
|
72
|
-
}))),
|
|
73
|
-
browserSettings: Schema.optionalKey(Schema.Struct({
|
|
74
|
-
/**
|
|
75
|
-
* A persisting run writes the Context from Browserbase's side, outside
|
|
76
|
-
* `ContextCoordination.withWriter`. It is refused while a local writer holds the
|
|
77
|
-
* Context, but nothing stops a later local writer from racing the hosted run.
|
|
78
|
-
*/
|
|
79
|
-
context: Schema.optionalKey(Schema.Struct({
|
|
80
|
-
reference: ContextReference,
|
|
81
|
-
persist: Schema.Boolean
|
|
82
|
-
})),
|
|
83
|
-
proxies: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Array(ProxyRule).check(Schema.isMaxLength(64))])),
|
|
84
|
-
verified: Schema.optionalKey(Schema.Boolean)
|
|
85
|
-
}))
|
|
86
|
-
});
|
|
87
|
-
const Window = {
|
|
88
|
-
startAt: Schema.optionalKey(Timestamp),
|
|
89
|
-
endAt: Schema.optionalKey(Timestamp),
|
|
90
|
-
cursor: Schema.optionalKey(Cursor)
|
|
91
|
-
};
|
|
92
|
-
const AgentListQuery = Schema.Struct({
|
|
93
|
-
...Window,
|
|
94
|
-
limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
95
|
-
minimum: 1,
|
|
96
|
-
maximum: 1e3
|
|
97
|
-
})))
|
|
98
|
-
});
|
|
99
|
-
const AgentRunListQuery = Schema.Struct({
|
|
100
|
-
...Window,
|
|
101
|
-
status: Schema.optionalKey(AgentRunStatus),
|
|
102
|
-
agentId: Schema.optionalKey(Identifier),
|
|
103
|
-
limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
104
|
-
minimum: 1,
|
|
105
|
-
maximum: 1e3
|
|
106
|
-
})))
|
|
107
|
-
});
|
|
108
|
-
const AgentMessageQuery = Schema.Struct({
|
|
109
|
-
since: Schema.optionalKey(Cursor),
|
|
110
|
-
limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
111
|
-
minimum: 1,
|
|
112
|
-
maximum: 100
|
|
113
|
-
}))),
|
|
114
|
-
all: Schema.optionalKey(Schema.Boolean)
|
|
115
|
-
});
|
|
116
|
-
const AgentRunWaitOptions = Schema.Struct({
|
|
117
|
-
timeoutMillis: Schema.Int.check(Schema.isBetween({
|
|
118
|
-
minimum: 1,
|
|
119
|
-
maximum: 216e5
|
|
120
|
-
})),
|
|
121
|
-
pollIntervalMillis: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
122
|
-
minimum: 250,
|
|
123
|
-
maximum: 6e4
|
|
124
|
-
})))
|
|
125
|
-
});
|
|
126
|
-
const ProviderAgent = Schema.Struct({
|
|
127
|
-
agentId: Identifier,
|
|
128
|
-
name: AgentMetadata.fields.name,
|
|
129
|
-
systemPrompt: Schema.optionalKey(Prompt),
|
|
130
|
-
resultSchema: Schema.optionalKey(JsonObject),
|
|
131
|
-
createdAt: Timestamp,
|
|
132
|
-
updatedAt: Timestamp
|
|
133
|
-
});
|
|
134
|
-
const ProviderPage = (item) => Schema.Struct({
|
|
135
|
-
data: Schema.Array(item).check(Schema.isMaxLength(1e3)),
|
|
136
|
-
nextCursor: Schema.optionalKey(Schema.NullOr(Schema.String.check(Schema.isMaxLength(4096))))
|
|
137
|
-
});
|
|
138
|
-
const ProviderMessages = Schema.Struct({
|
|
139
|
-
data: Schema.Array(Schema.Struct({
|
|
140
|
-
id: AgentRunMessage.fields.id,
|
|
141
|
-
createdAt: Timestamp,
|
|
142
|
-
message: Schema.Struct({
|
|
143
|
-
role: AgentRunMessage.fields.role,
|
|
144
|
-
content: Schema.Json
|
|
145
|
-
})
|
|
146
|
-
})).check(Schema.isMaxLength(100)),
|
|
147
|
-
nextSince: Schema.optionalKey(Schema.NullOr(Schema.String.check(Schema.isMaxLength(4096))))
|
|
148
|
-
});
|
|
149
|
-
const now = Clock.monotonicTimeNanos.pipe(Effect.map((value) => Number(value) / 1e6));
|
|
150
|
-
/**
|
|
151
|
-
* Browserbase Agents: hosted autonomous runs that allocate their own browser sessions and
|
|
152
|
-
* can incur inference charges. Creating or stopping a run is never retried; a lost reply is
|
|
153
|
-
* `unknown`. A run reply is not a charge or completion receipt.
|
|
154
|
-
*/
|
|
155
|
-
var BrowserbaseAgents = class BrowserbaseAgents extends Context.Service()("effect-browserbase/Agents") {
|
|
156
|
-
static layer = Layer.effect(BrowserbaseAgents, Effect.gen(function* () {
|
|
157
|
-
const client = yield* BrowserbaseClient;
|
|
158
|
-
const api = resource(client, (failure) => PlatformError.make({
|
|
159
|
-
...failure,
|
|
160
|
-
service: "agents"
|
|
161
|
-
}));
|
|
162
|
-
const agentPath = (id) => `/v1/agents/${api.segment(id)}`;
|
|
163
|
-
const runPath = (id) => `/v1/agents/runs/${api.segment(id)}`;
|
|
164
|
-
const agent = (operation, mutation, expected) => Effect.fnUntraced(function* (value) {
|
|
165
|
-
if (expected !== void 0 && value.agentId !== expected) return yield* api.malformed(operation, mutation);
|
|
166
|
-
return AgentMetadata.make(value);
|
|
167
|
-
});
|
|
168
|
-
const run = (operation, mutation, expected) => Effect.fnUntraced(function* (value) {
|
|
169
|
-
if (expected !== void 0 && value.runId !== expected) return yield* api.malformed(operation, mutation);
|
|
170
|
-
return value;
|
|
171
|
-
});
|
|
172
|
-
const create = Effect.fnUntraced(function* (definition) {
|
|
173
|
-
const value = yield* api.input(AgentDefinition, definition, "agent-create");
|
|
174
|
-
return yield* api.request("POST", "/v1/agents", ProviderAgent, "agent-create", value).pipe(Effect.flatMap(agent("agent-create", true)));
|
|
175
|
-
}, span("BrowserbaseAgents.create"));
|
|
176
|
-
const list = Effect.fnUntraced(function* (query = {}) {
|
|
177
|
-
const value = yield* api.input(AgentListQuery, query, "agent-list");
|
|
178
|
-
const page = yield* api.request("GET", `/v1/agents${api.query(value)}`, ProviderPage(ProviderAgent), "agent-list");
|
|
179
|
-
return {
|
|
180
|
-
items: page.data.map((row) => AgentMetadata.make(row)),
|
|
181
|
-
nextCursor: page.nextCursor ?? void 0
|
|
182
|
-
};
|
|
183
|
-
}, span("BrowserbaseAgents.list"));
|
|
184
|
-
const retrieve = Effect.fnUntraced(function* (agentId) {
|
|
185
|
-
const id = yield* api.input(Identifier, agentId, "agent-retrieve");
|
|
186
|
-
return yield* api.request("GET", agentPath(id), ProviderAgent, "agent-retrieve").pipe(Effect.flatMap(agent("agent-retrieve", false, id)));
|
|
187
|
-
}, span("BrowserbaseAgents.retrieve"));
|
|
188
|
-
const update = Effect.fnUntraced(function* (agentId, changes) {
|
|
189
|
-
const id = yield* api.input(Identifier, agentId, "agent-update");
|
|
190
|
-
const value = yield* api.input(AgentUpdate, changes, "agent-update");
|
|
191
|
-
if (Object.keys(value).length === 0) return yield* api.configuration("agent-update");
|
|
192
|
-
return yield* api.request("PATCH", agentPath(id), ProviderAgent, "agent-update", value).pipe(Effect.flatMap(agent("agent-update", true, id)));
|
|
193
|
-
}, span("BrowserbaseAgents.update"));
|
|
194
|
-
const remove = Effect.fnUntraced(function* (agentId) {
|
|
195
|
-
const id = yield* api.input(Identifier, agentId, "agent-delete");
|
|
196
|
-
yield* api.remove(agentPath(id), "agent-delete");
|
|
197
|
-
}, span("BrowserbaseAgents.delete"));
|
|
198
|
-
const start = Effect.fnUntraced(function* (request) {
|
|
199
|
-
const value = yield* api.input(AgentRunRequest, request, "agent-run");
|
|
200
|
-
const settings = value.browserSettings;
|
|
201
|
-
const context = settings?.context;
|
|
202
|
-
if (context !== void 0) {
|
|
203
|
-
if (context.reference.projectId !== client.projectId) return yield* api.make({
|
|
204
|
-
operation: "agent-run",
|
|
205
|
-
reason: "authorization",
|
|
206
|
-
outcome: "undispatched"
|
|
207
|
-
});
|
|
208
|
-
if (context.persist && isContextWriterBusy(context.reference)) return yield* api.make({
|
|
209
|
-
operation: "agent-run",
|
|
210
|
-
reason: "active",
|
|
211
|
-
outcome: "undispatched"
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
const body = {
|
|
215
|
-
task: value.task,
|
|
216
|
-
...value.agentId === void 0 ? {} : { agentId: value.agentId },
|
|
217
|
-
...value.resultSchema === void 0 ? {} : { resultSchema: value.resultSchema },
|
|
218
|
-
...value.variables === void 0 ? {} : { variables: value.variables },
|
|
219
|
-
...settings === void 0 ? {} : { browserSettings: {
|
|
220
|
-
...context === void 0 ? {} : { context: {
|
|
221
|
-
id: context.reference.contextId,
|
|
222
|
-
persist: context.persist
|
|
223
|
-
} },
|
|
224
|
-
...settings.proxies === void 0 ? {} : { proxies: typeof settings.proxies === "boolean" ? settings.proxies : settings.proxies.map(proxy) },
|
|
225
|
-
...settings.verified === void 0 ? {} : { verified: settings.verified }
|
|
226
|
-
} }
|
|
227
|
-
};
|
|
228
|
-
return yield* api.request("POST", "/v1/agents/runs", AgentRun, "agent-run", body);
|
|
229
|
-
}, span("BrowserbaseAgents.run"));
|
|
230
|
-
const retrieveRun = Effect.fnUntraced(function* (runId) {
|
|
231
|
-
const id = yield* api.input(Identifier, runId, "agent-run-retrieve");
|
|
232
|
-
return yield* api.request("GET", runPath(id), AgentRun, "agent-run-retrieve").pipe(Effect.flatMap(run("agent-run-retrieve", false, id)));
|
|
233
|
-
}, span("BrowserbaseAgents.retrieveRun"));
|
|
234
|
-
const listRuns = Effect.fnUntraced(function* (query = {}) {
|
|
235
|
-
const value = yield* api.input(AgentRunListQuery, query, "agent-run-list");
|
|
236
|
-
const page = yield* api.request("GET", `/v1/agents/runs${api.query(value)}`, ProviderPage(AgentRun), "agent-run-list");
|
|
237
|
-
return {
|
|
238
|
-
items: page.data,
|
|
239
|
-
nextCursor: page.nextCursor ?? void 0
|
|
240
|
-
};
|
|
241
|
-
}, span("BrowserbaseAgents.listRuns"));
|
|
242
|
-
const stopRun = Effect.fnUntraced(function* (runId) {
|
|
243
|
-
const id = yield* api.input(Identifier, runId, "agent-run-stop");
|
|
244
|
-
return yield* api.request("POST", `${runPath(id)}/stop`, AgentRun, "agent-run-stop").pipe(Effect.flatMap(run("agent-run-stop", true, id)));
|
|
245
|
-
}, span("BrowserbaseAgents.stopRun"));
|
|
246
|
-
const messages = Effect.fnUntraced(function* (runId, query = {}) {
|
|
247
|
-
const id = yield* api.input(Identifier, runId, "agent-run-messages");
|
|
248
|
-
const value = yield* api.input(AgentMessageQuery, query, "agent-run-messages");
|
|
249
|
-
const page = yield* api.request("GET", `${runPath(id)}/messages${api.query(value)}`, ProviderMessages, "agent-run-messages");
|
|
250
|
-
return {
|
|
251
|
-
messages: page.data.map((row) => AgentRunMessage.make({
|
|
252
|
-
id: row.id,
|
|
253
|
-
createdAt: row.createdAt,
|
|
254
|
-
role: row.message.role,
|
|
255
|
-
content: row.message.content
|
|
256
|
-
})),
|
|
257
|
-
nextSince: page.nextSince ?? void 0
|
|
258
|
-
};
|
|
259
|
-
}, span("BrowserbaseAgents.messages"));
|
|
260
|
-
const waitForRun = Effect.fnUntraced(function* (runId, options) {
|
|
261
|
-
const bounds = yield* api.input(AgentRunWaitOptions, options, "agent-run-wait");
|
|
262
|
-
const deadline = (yield* now) + bounds.timeoutMillis;
|
|
263
|
-
for (;;) {
|
|
264
|
-
const current = yield* retrieveRun(runId).pipe(Effect.withTracerEnabled(false));
|
|
265
|
-
if (isTerminalAgentRunStatus(current.status)) return current;
|
|
266
|
-
const remaining = deadline - (yield* now);
|
|
267
|
-
if (remaining <= 0) return yield* api.make({
|
|
268
|
-
operation: "agent-run-wait",
|
|
269
|
-
reason: "timeout"
|
|
270
|
-
});
|
|
271
|
-
yield* Effect.sleep(Math.min(bounds.pollIntervalMillis ?? 2e3, remaining));
|
|
272
|
-
}
|
|
273
|
-
}, span("BrowserbaseAgents.waitForRun"));
|
|
274
|
-
return BrowserbaseAgents.of({
|
|
275
|
-
create,
|
|
276
|
-
list,
|
|
277
|
-
retrieve,
|
|
278
|
-
update,
|
|
279
|
-
delete: remove,
|
|
280
|
-
run: start,
|
|
281
|
-
retrieveRun,
|
|
282
|
-
listRuns,
|
|
283
|
-
stopRun,
|
|
284
|
-
messages,
|
|
285
|
-
waitForRun
|
|
286
|
-
});
|
|
287
|
-
}));
|
|
288
|
-
};
|
|
289
|
-
//#endregion
|
|
290
|
-
export { AgentDefinition, AgentListQuery, AgentMessageQuery, AgentMetadata, AgentRun, AgentRunListQuery, AgentRunMessage, AgentRunRequest, AgentRunStatus, AgentRunWaitOptions, AgentUpdate, BrowserbaseAgents, isTerminalAgentRunStatus };
|
|
291
|
-
|
|
292
|
-
//# sourceMappingURL=Agents.mjs.map
|
package/dist/Agents.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Agents.mjs","names":["Trace.span"],"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 * as Trace from \"./internal/Trace.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 * can incur inference charges. Creating or stopping a run is never retried; a lost reply is\n * `unknown`. A run reply is not a charge or completion receipt.\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.fnUntraced(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 }, Trace.span(\"BrowserbaseAgents.create\"));\n\n const list = Effect.fnUntraced(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 }, Trace.span(\"BrowserbaseAgents.list\"));\n\n const retrieve = Effect.fnUntraced(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 }, Trace.span(\"BrowserbaseAgents.retrieve\"));\n\n const update = Effect.fnUntraced(function* (agentId: string, changes: AgentUpdate) {\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 }, Trace.span(\"BrowserbaseAgents.update\"));\n\n const remove = Effect.fnUntraced(function* (agentId: string) {\n const id = yield* api.input(Identifier, agentId, \"agent-delete\");\n\n yield* api.remove(agentPath(id), \"agent-delete\");\n }, Trace.span(\"BrowserbaseAgents.delete\"));\n\n const start = Effect.fnUntraced(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 }, Trace.span(\"BrowserbaseAgents.run\"));\n\n const retrieveRun = Effect.fnUntraced(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 }, Trace.span(\"BrowserbaseAgents.retrieveRun\"));\n\n const listRuns = Effect.fnUntraced(function* (query: AgentRunListQuery = {}) {\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 }, Trace.span(\"BrowserbaseAgents.listRuns\"));\n\n const stopRun = Effect.fnUntraced(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 }, Trace.span(\"BrowserbaseAgents.stopRun\"));\n\n const messages = Effect.fnUntraced(function* (runId: string, query: AgentMessageQuery = {}) {\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 }, Trace.span(\"BrowserbaseAgents.messages\"));\n\n const waitForRun = Effect.fnUntraced(function* (runId: string, options: AgentRunWaitOptions) {\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).pipe(Effect.withTracerEnabled(false));\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 }, Trace.span(\"BrowserbaseAgents.waitForRun\"));\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":";;;;;;;;;AAWA,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,UAAU;CAC3C,WAAW;CACX,WAAW;AACb,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,WAAb,cAA8B,OAAO,MAAgB,qBAAqB,CAAC,CAAC;CAC1E,OAAO;CACP,SAAS,OAAO,YAAY,UAAU;CACtC,MAAM;CACN,QAAQ;CACR,WAAW,OAAO,YAAY,UAAU;CACxC,WAAW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AC;IAC3E,OAAO,OAAO,MAAM,KAAK,IAAI,OAAO,sBAAsB,KAAO,SAAS,CAAC;GAC7E;EACF,GAAGA,KAAW,8BAA8B,CAAC;EAE7C,OAAO,kBAAkB,GAAG;GAC1B;GACA;GACA;GACA;GACA,QAAQ;GACR,KAAK;GACL;GACA;GACA;GACA;GACA;EACF,CAAC;CACH,CAAC,CACH;AACF"}
|
package/dist/Allocation.d.mts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { a as SessionReference, n as ContextReference, r as ExtensionReference, t as AllocationAttempt } from "./References-DOH3Wu44.mjs";
|
|
2
|
-
import { AllocationError, ContextError } from "./Errors.mjs";
|
|
3
|
-
import { t as BrowserbaseClient } from "./Client-B_f6bBLT.mjs";
|
|
4
|
-
import { t as BrowserbaseSessions } from "./Sessions-oJEUmZth.mjs";
|
|
5
|
-
import { n as CleanupResult } from "./Cleanup-DMTDBir8.mjs";
|
|
6
|
-
import { n as ContextWriterPermit } from "./WriterFacts-BBJRDZYY.mjs";
|
|
7
|
-
import "./ContextCoordination.mjs";
|
|
8
|
-
import { Effect, Option } from "effect";
|
|
9
|
-
//#region src/Allocation.d.ts
|
|
10
|
-
/** A session this process allocated and owns, with no browser connected to it. */
|
|
11
|
-
export interface AllocatedSession {
|
|
12
|
-
readonly reference: SessionReference;
|
|
13
|
-
/** The creation attempt, retained so an unknown provider outcome stays attributable. */
|
|
14
|
-
readonly attempt: AllocationAttempt;
|
|
15
|
-
/**
|
|
16
|
-
* Release now and read the cleanup evidence. The scope finalizer performs the same
|
|
17
|
-
* release, so an uncalled `release` is a scope that has not closed yet, not a leak.
|
|
18
|
-
*/
|
|
19
|
-
readonly release: Effect.Effect<CleanupResult>;
|
|
20
|
-
/** The cleanup evidence once it exists, and `None` while the session is still held. */
|
|
21
|
-
readonly cleanupResult: Effect.Effect<Option.Option<CleanupResult>>;
|
|
22
|
-
}
|
|
23
|
-
export interface AllocationOptions {
|
|
24
|
-
/** Required exactly when the recipe persists a Context, and refused when it does not. */
|
|
25
|
-
readonly contextWriter?: ContextWriterPermit;
|
|
26
|
-
readonly allocationDeadline?: number;
|
|
27
|
-
/** Bounded host notification of the canonical facts. Reporting never changes them. */
|
|
28
|
-
readonly onCleanup?: (result: CleanupResult) => Effect.Effect<void>;
|
|
29
|
-
/** Exactly one notification when a creation attempt's effect on the provider is unknown. */
|
|
30
|
-
readonly onAllocationUncertain?: (attempt: AllocationAttempt) => Effect.Effect<void>;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Allocate a session without connecting a browser, for a caller that drives the remote
|
|
34
|
-
* session with its own automation client. This is the allocation path the browser owner
|
|
35
|
-
* uses, so release, unknown-outcome reporting and Context writer authority keep a single
|
|
36
|
-
* owner: the creation request is never retried, a foreign project is refused before it is
|
|
37
|
-
* sent, and no native peer is loaded. The scope owns the release; closing it releases the
|
|
38
|
-
* session whether or not the caller ever connected to it.
|
|
39
|
-
*/
|
|
40
|
-
export declare const scoped: (launch: {
|
|
41
|
-
readonly remoteTimeoutSeconds: number;
|
|
42
|
-
readonly keepAlive?: boolean | undefined;
|
|
43
|
-
readonly context?: {
|
|
44
|
-
readonly reference: ContextReference;
|
|
45
|
-
readonly persist: boolean;
|
|
46
|
-
} | undefined;
|
|
47
|
-
readonly extension?: ExtensionReference | undefined;
|
|
48
|
-
readonly viewport: {
|
|
49
|
-
readonly _tag: "ProviderManaged";
|
|
50
|
-
} | {
|
|
51
|
-
readonly _tag: "Fixed";
|
|
52
|
-
readonly width: number;
|
|
53
|
-
readonly height: number;
|
|
54
|
-
};
|
|
55
|
-
readonly provider: {
|
|
56
|
-
readonly region?: "ap-southeast-1" | "eu-central-1" | "us-east-1" | "us-west-2" | undefined;
|
|
57
|
-
readonly proxies?: boolean | readonly ({
|
|
58
|
-
readonly type: "browserbase";
|
|
59
|
-
readonly domainPattern?: string | undefined;
|
|
60
|
-
readonly geolocation?: {
|
|
61
|
-
readonly country: string;
|
|
62
|
-
readonly state?: string | undefined;
|
|
63
|
-
readonly city?: string | undefined;
|
|
64
|
-
} | undefined;
|
|
65
|
-
} | {
|
|
66
|
-
readonly type: "external";
|
|
67
|
-
readonly server: string;
|
|
68
|
-
readonly domainPattern?: string | undefined;
|
|
69
|
-
readonly username?: import("effect/Redacted").Redacted<string> | undefined;
|
|
70
|
-
readonly password?: import("effect/Redacted").Redacted<string> | undefined;
|
|
71
|
-
} | {
|
|
72
|
-
readonly type: "none";
|
|
73
|
-
readonly domainPattern?: string | undefined;
|
|
74
|
-
})[] | undefined;
|
|
75
|
-
readonly proxySettings?: {
|
|
76
|
-
readonly caCertificates?: readonly string[] | undefined;
|
|
77
|
-
} | undefined;
|
|
78
|
-
readonly browserSettings?: {
|
|
79
|
-
readonly verified?: boolean | undefined;
|
|
80
|
-
readonly os?: "linux" | "mac" | "mobile" | "tablet" | "windows" | undefined;
|
|
81
|
-
readonly allowedDomains?: readonly string[] | undefined;
|
|
82
|
-
readonly blockAds?: boolean | undefined;
|
|
83
|
-
readonly captchaImageSelector?: string | undefined;
|
|
84
|
-
readonly captchaInputSelector?: string | undefined;
|
|
85
|
-
readonly ignoreCertificateErrors?: boolean | undefined;
|
|
86
|
-
readonly logSession?: boolean | undefined;
|
|
87
|
-
readonly recordSession?: boolean | undefined;
|
|
88
|
-
readonly solveCaptchas?: boolean | undefined;
|
|
89
|
-
} | undefined;
|
|
90
|
-
readonly userMetadata?: {
|
|
91
|
-
readonly [x: string]: import("effect/Schema").Json;
|
|
92
|
-
} | undefined;
|
|
93
|
-
};
|
|
94
|
-
}, options?: AllocationOptions | undefined) => Effect.Effect<AllocatedSession, AllocationError | import("effect-browser/errors").BrowserError | ContextError, BrowserbaseClient | BrowserbaseSessions | import("effect/Crypto").Crypto | import("effect/Scope").Scope>;
|
|
95
|
-
//#endregion
|
|
96
|
-
export {};
|
|
97
|
-
//# sourceMappingURL=Allocation.d.mts.map
|
package/dist/Allocation.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { t as acquireRemote } from "./Acquisition-BOABu_qJ.mjs";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
//#region src/Allocation.ts
|
|
4
|
-
/**
|
|
5
|
-
* Allocate a session without connecting a browser, for a caller that drives the remote
|
|
6
|
-
* session with its own automation client. This is the allocation path the browser owner
|
|
7
|
-
* uses, so release, unknown-outcome reporting and Context writer authority keep a single
|
|
8
|
-
* owner: the creation request is never retried, a foreign project is refused before it is
|
|
9
|
-
* sent, and no native peer is loaded. The scope owns the release; closing it releases the
|
|
10
|
-
* session whether or not the caller ever connected to it.
|
|
11
|
-
*/
|
|
12
|
-
const scoped = Effect.fnUntraced(function* (launch, options = {}) {
|
|
13
|
-
const acquisition = yield* acquireRemote({
|
|
14
|
-
launch,
|
|
15
|
-
...options
|
|
16
|
-
});
|
|
17
|
-
return {
|
|
18
|
-
reference: acquisition.reference,
|
|
19
|
-
attempt: acquisition.attempt,
|
|
20
|
-
release: acquisition.release,
|
|
21
|
-
cleanupResult: acquisition.cleanupResult
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
//#endregion
|
|
25
|
-
export { scoped };
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=Allocation.mjs.map
|
package/dist/Allocation.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|