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,237 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { ExtensionReference, Identifier } from "./References.mjs";
3
+ import { ExtensionError } from "./Errors.mjs";
4
+ import { SafeFilename } from "./Transfers.mjs";
5
+ import { t as BrowserbaseClient } from "./Client-D1_xYM9o.mjs";
6
+ import { Context, Effect, Layer, Schema } from "effect";
7
+ //#region src/internal/extension/Archive.ts
8
+ const MAX_ENTRIES = 4096;
9
+ const MAX_NAME_BYTES = 512;
10
+ const MAX_DECLARED_BYTES = 536870912;
11
+ const EOCD_SIZE = 22;
12
+ const LOCAL_HEADER_SIZE = 30;
13
+ const STORED = 0;
14
+ const DEFLATED = 8;
15
+ const LOCAL_HEADER = 67324752;
16
+ const CENTRAL_HEADER = 33639248;
17
+ const END_OF_CENTRAL_DIRECTORY = 101010256;
18
+ const rejected = (reason) => ({
19
+ _tag: "Rejected",
20
+ reason
21
+ });
22
+ const control = (name) => [...name].some((character) => character < " " || character === "");
23
+ /** Any `..` or rooted member would name a file outside the extension directory. */
24
+ const unsafeName = (name) => name.length === 0 || name.startsWith("/") || name.includes("\\") || name.includes("//") || /^[A-Za-z]:/.test(name) || control(name) || name.split("/").some((segment) => segment === "." || segment === "..");
25
+ const inspectExtensionArchive = (archive) => {
26
+ if (archive.byteLength < EOCD_SIZE) return rejected("malformed");
27
+ const view = new DataView(archive.buffer, archive.byteOffset, archive.byteLength);
28
+ const u16 = (offset) => view.getUint16(offset, true);
29
+ const u32 = (offset) => view.getUint32(offset, true);
30
+ if (u32(0) !== LOCAL_HEADER) return rejected("signature");
31
+ const earliest = Math.max(0, archive.byteLength - EOCD_SIZE - 65535);
32
+ let end = -1;
33
+ for (let offset = archive.byteLength - EOCD_SIZE; offset >= earliest; offset--) if (u32(offset) === END_OF_CENTRAL_DIRECTORY) {
34
+ end = offset;
35
+ break;
36
+ }
37
+ if (end < 0) return rejected("malformed");
38
+ const entries = u16(end + 10);
39
+ const directorySize = u32(end + 12);
40
+ const directoryOffset = u32(end + 16);
41
+ const commentLength = u16(end + 20);
42
+ if (u16(end + 4) !== 0 || u16(end + 6) !== 0 || u16(end + 8) !== entries) return rejected("unsupported");
43
+ if (entries === 65535 || directorySize === 4294967295 || directoryOffset === 4294967295) return rejected("unsupported");
44
+ if (end + EOCD_SIZE + commentLength !== archive.byteLength) return rejected("malformed");
45
+ if (directoryOffset + directorySize > end) return rejected("malformed");
46
+ if (entries > MAX_ENTRIES) return rejected("limit");
47
+ const names = new TextDecoder("utf-8", { fatal: true });
48
+ const limit = directoryOffset + directorySize;
49
+ let offset = directoryOffset;
50
+ let declaredBytes = 0;
51
+ let manifest = false;
52
+ for (let index = 0; index < entries; index++) {
53
+ if (offset + 46 > limit || u32(offset) !== CENTRAL_HEADER) return rejected("malformed");
54
+ const flags = u16(offset + 8);
55
+ const method = u16(offset + 10);
56
+ const compressed = u32(offset + 20);
57
+ const declared = u32(offset + 24);
58
+ const nameLength = u16(offset + 28);
59
+ const extraLength = u16(offset + 30);
60
+ const entryCommentLength = u16(offset + 32);
61
+ const localOffset = u32(offset + 42);
62
+ if (declared === 4294967295 || compressed === 4294967295 || localOffset === 4294967295) return rejected("unsupported");
63
+ if ((flags & 1) !== 0 || method !== STORED && method !== DEFLATED) return rejected("unsupported");
64
+ if (nameLength === 0 || nameLength > MAX_NAME_BYTES) return rejected("name");
65
+ if (offset + 46 + nameLength + extraLength + entryCommentLength > limit) return rejected("malformed");
66
+ if (localOffset >= directoryOffset) return rejected("malformed");
67
+ let name;
68
+ try {
69
+ name = names.decode(archive.subarray(offset + 46, offset + 46 + nameLength));
70
+ } catch {
71
+ return rejected("name");
72
+ }
73
+ if (unsafeName(name)) return rejected("name");
74
+ if (localOffset + LOCAL_HEADER_SIZE > directoryOffset || u32(localOffset) !== LOCAL_HEADER) return rejected("malformed");
75
+ const localNameLength = u16(localOffset + 26);
76
+ const localStart = localOffset + LOCAL_HEADER_SIZE;
77
+ if ((u16(localOffset + 6) & 1) !== 0 || u16(localOffset + 8) !== method || localNameLength !== nameLength || localStart + localNameLength + u16(localOffset + 28) + compressed > directoryOffset) return rejected("malformed");
78
+ try {
79
+ if (names.decode(archive.subarray(localStart, localStart + localNameLength)) !== name) return rejected("malformed");
80
+ } catch {
81
+ return rejected("name");
82
+ }
83
+ if (name === "manifest.json") manifest = true;
84
+ declaredBytes += declared;
85
+ if (declaredBytes > MAX_DECLARED_BYTES) return rejected("limit");
86
+ offset += 46 + nameLength + extraLength + entryCommentLength;
87
+ }
88
+ if (offset !== limit) return rejected("malformed");
89
+ if (!manifest) return rejected("manifest");
90
+ return {
91
+ _tag: "Accepted",
92
+ facts: {
93
+ entries,
94
+ declaredBytes
95
+ }
96
+ };
97
+ };
98
+ //#endregion
99
+ //#region src/Extensions.ts
100
+ var Extensions_exports = /* @__PURE__ */ __exportAll({
101
+ BrowserbaseExtensions: () => BrowserbaseExtensions,
102
+ ExtensionMetadata: () => ExtensionMetadata,
103
+ ExtensionRegistration: () => ExtensionRegistration
104
+ });
105
+ const Timestamp = Schema.String.check(Schema.isMaxLength(64));
106
+ /** The provider documents a 100 MB archive; a caller may request less, never more. */
107
+ const MAX_ARCHIVE_BYTES = 104857600;
108
+ const ProviderExtension = Schema.Struct({
109
+ id: Identifier,
110
+ projectId: Identifier,
111
+ fileName: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),
112
+ createdAt: Schema.optionalKey(Timestamp),
113
+ updatedAt: Schema.optionalKey(Timestamp)
114
+ });
115
+ /** Only fields the provider actually returned are reported; absence is never invented. */
116
+ var ExtensionMetadata = class extends Schema.Class("BrowserbaseExtensionMetadata")({
117
+ reference: ExtensionReference,
118
+ fileName: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),
119
+ createdAt: Schema.optionalKey(Timestamp),
120
+ updatedAt: Schema.optionalKey(Timestamp)
121
+ }) {};
122
+ /** Registration evidence is what this package inspected, not a provider load receipt. */
123
+ var ExtensionRegistration = class extends Schema.Class("BrowserbaseExtensionRegistration")({
124
+ reference: ExtensionReference,
125
+ archiveBytes: Schema.Natural,
126
+ entries: Schema.Natural,
127
+ declaredBytes: Schema.Natural
128
+ }) {};
129
+ const Upload = Schema.Struct({
130
+ filename: Schema.optionalKey(SafeFilename.check(Schema.makeFilter((value) => value.toLowerCase().endsWith(".zip")))),
131
+ maxBytes: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
132
+ minimum: 1,
133
+ maximum: MAX_ARCHIVE_BYTES
134
+ }))),
135
+ timeoutMillis: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
136
+ minimum: 1,
137
+ maximum: 6e5
138
+ })))
139
+ });
140
+ const fromClient = (operation, error) => ExtensionError.make({
141
+ operation,
142
+ reason: error.reason,
143
+ ...error.outcome === void 0 ? {} : { outcome: error.outcome },
144
+ ...error.status === void 0 ? {} : { status: error.status },
145
+ ...error.retryAfterMillis === void 0 ? {} : { retryAfterMillis: error.retryAfterMillis }
146
+ });
147
+ const configuration = (operation) => ExtensionError.make({
148
+ operation,
149
+ reason: "configuration",
150
+ outcome: "undispatched"
151
+ });
152
+ const malformed = (operation, mutation = false) => ExtensionError.make({
153
+ operation,
154
+ reason: "malformed",
155
+ ...mutation ? { outcome: "unknown" } : {}
156
+ });
157
+ /**
158
+ * A provisioned extension is a durable project resource selected at launch, never uploaded
159
+ * again on connect. The archive is inspected before transport; loading remains the provider's.
160
+ */
161
+ var BrowserbaseExtensions = class BrowserbaseExtensions extends Context.Service()("effect-browserbase/Extensions") {
162
+ static layer = Layer.effect(BrowserbaseExtensions, Effect.gen(function* () {
163
+ const client = yield* BrowserbaseClient;
164
+ const validate = Effect.fnUntraced(function* (reference, operation) {
165
+ const ref = yield* Schema.decodeEffect(ExtensionReference)(reference, { onExcessProperty: "error" }).pipe(Effect.mapError(() => configuration(operation)));
166
+ if (ref.projectId !== client.projectId) return yield* ExtensionError.make({
167
+ operation,
168
+ reason: "authorization",
169
+ outcome: "undispatched"
170
+ });
171
+ return ref;
172
+ });
173
+ const register = Effect.fn("BrowserbaseExtensions.register")(function* (archive, options = {}) {
174
+ const value = yield* Schema.decodeEffect(Upload)(options, { onExcessProperty: "error" }).pipe(Effect.mapError(() => configuration("extension-register")));
175
+ if (!(archive instanceof Uint8Array)) return yield* configuration("extension-register");
176
+ const maxBytes = value.maxBytes ?? MAX_ARCHIVE_BYTES;
177
+ if (archive.byteLength < 1 || archive.byteLength > maxBytes) return yield* ExtensionError.make({
178
+ operation: "extension-archive",
179
+ reason: "limit",
180
+ outcome: "undispatched"
181
+ });
182
+ const owned = new Uint8Array(archive);
183
+ const inspected = inspectExtensionArchive(owned);
184
+ if (inspected._tag === "Rejected") return yield* ExtensionError.make({
185
+ operation: "extension-archive",
186
+ reason: inspected.reason === "limit" ? "limit" : inspected.reason === "name" ? "unsafe-filename" : "configuration",
187
+ outcome: "undispatched"
188
+ });
189
+ const raw = yield* client.upload("/v1/extensions", {
190
+ field: "file",
191
+ filename: value.filename ?? "extension.zip",
192
+ mediaType: "application/zip",
193
+ bytes: owned
194
+ }, {
195
+ maxBytes,
196
+ ...value.timeoutMillis === void 0 ? {} : { timeoutMillis: value.timeoutMillis }
197
+ }).pipe(Effect.mapError((error) => fromClient("extension-register", error)));
198
+ const created = yield* Schema.decodeUnknownEffect(ProviderExtension)(raw).pipe(Effect.mapError(() => malformed("extension-register", true)));
199
+ if (created.projectId !== client.projectId) return yield* malformed("extension-register", true);
200
+ return ExtensionRegistration.make({
201
+ reference: ExtensionReference.make({
202
+ provider: "browserbase",
203
+ projectId: client.projectId,
204
+ extensionId: created.id
205
+ }),
206
+ archiveBytes: owned.byteLength,
207
+ entries: inspected.facts.entries,
208
+ declaredBytes: inspected.facts.declaredBytes
209
+ });
210
+ });
211
+ const retrieve = Effect.fn("BrowserbaseExtensions.retrieve")(function* (reference) {
212
+ const ref = yield* validate(reference, "extension-retrieve");
213
+ const raw = yield* client.json("GET", `/v1/extensions/${encodeURIComponent(ref.extensionId)}`).pipe(Effect.mapError((error) => fromClient("extension-retrieve", error)));
214
+ const value = yield* Schema.decodeUnknownEffect(ProviderExtension)(raw).pipe(Effect.mapError(() => malformed("extension-retrieve")));
215
+ if (value.id !== ref.extensionId || value.projectId !== ref.projectId) return yield* malformed("extension-retrieve");
216
+ return ExtensionMetadata.make({
217
+ reference: ref,
218
+ ...value.fileName === void 0 ? {} : { fileName: value.fileName },
219
+ ...value.createdAt === void 0 ? {} : { createdAt: value.createdAt },
220
+ ...value.updatedAt === void 0 ? {} : { updatedAt: value.updatedAt }
221
+ });
222
+ });
223
+ const remove = Effect.fn("BrowserbaseExtensions.delete")(function* (reference) {
224
+ const ref = yield* validate(reference, "extension-delete");
225
+ yield* client.noContent("DELETE", `/v1/extensions/${encodeURIComponent(ref.extensionId)}`).pipe(Effect.mapError((error) => fromClient("extension-delete", error)));
226
+ });
227
+ return BrowserbaseExtensions.of({
228
+ register,
229
+ retrieve,
230
+ delete: remove
231
+ });
232
+ }));
233
+ };
234
+ //#endregion
235
+ export { Extensions_exports as i, ExtensionMetadata as n, ExtensionRegistration as r, BrowserbaseExtensions as t };
236
+
237
+ //# sourceMappingURL=Extensions-ClZbYb1H.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Extensions-ClZbYb1H.mjs","names":[],"sources":["../src/internal/extension/Archive.ts","../src/Extensions.ts"],"sourcesContent":["/**\n * A bounded, allocation-free inspection of an extension ZIP: enough to prove a root\n * `manifest.json` and reject traversal before an upload, never an extractor. No entry is\n * decompressed and no path is written; the provider remains the loader of record.\n */\nexport interface ArchiveFacts {\n readonly entries: number;\n /** Uncompressed size the central directory itself declares, not a measured expansion. */\n readonly declaredBytes: number;\n}\n\nexport type ArchiveRejection =\n | \"signature\"\n | \"malformed\"\n | \"unsupported\"\n | \"name\"\n | \"manifest\"\n | \"limit\";\n\nexport type ArchiveResult =\n | { readonly _tag: \"Accepted\"; readonly facts: ArchiveFacts }\n | { readonly _tag: \"Rejected\"; readonly reason: ArchiveRejection };\n\nconst MAX_ENTRIES = 4096;\nconst MAX_NAME_BYTES = 512;\nconst MAX_DECLARED_BYTES = 512 * 1024 * 1024;\nconst EOCD_SIZE = 22;\nconst LOCAL_HEADER_SIZE = 30;\nconst STORED = 0;\nconst DEFLATED = 8;\n\nconst LOCAL_HEADER = 0x04034b50;\nconst CENTRAL_HEADER = 0x02014b50;\nconst END_OF_CENTRAL_DIRECTORY = 0x06054b50;\n\nconst rejected = (reason: ArchiveRejection): ArchiveResult => ({ _tag: \"Rejected\", reason });\n\nconst control = (name: string): boolean =>\n [...name].some((character) => character < \" \" || character === \"\\x7f\");\n\n/** Any `..` or rooted member would name a file outside the extension directory. */\nconst unsafeName = (name: string): boolean =>\n name.length === 0 ||\n name.startsWith(\"/\") ||\n name.includes(\"\\\\\") ||\n name.includes(\"//\") ||\n /^[A-Za-z]:/.test(name) ||\n control(name) ||\n name.split(\"/\").some((segment) => segment === \".\" || segment === \"..\");\n\nexport const inspectExtensionArchive = (archive: Uint8Array): ArchiveResult => {\n if (archive.byteLength < EOCD_SIZE) return rejected(\"malformed\");\n const view = new DataView(archive.buffer, archive.byteOffset, archive.byteLength);\n const u16 = (offset: number) => view.getUint16(offset, true);\n const u32 = (offset: number) => view.getUint32(offset, true);\n\n if (u32(0) !== LOCAL_HEADER) return rejected(\"signature\");\n\n // The comment is bounded by its own 16-bit length, so the record cannot hide further back.\n const earliest = Math.max(0, archive.byteLength - EOCD_SIZE - 0xffff);\n let end = -1;\n\n for (let offset = archive.byteLength - EOCD_SIZE; offset >= earliest; offset--) {\n if (u32(offset) === END_OF_CENTRAL_DIRECTORY) {\n end = offset;\n break;\n }\n }\n if (end < 0) return rejected(\"malformed\");\n\n const entries = u16(end + 10);\n const directorySize = u32(end + 12);\n const directoryOffset = u32(end + 16);\n const commentLength = u16(end + 20);\n\n if (u16(end + 4) !== 0 || u16(end + 6) !== 0 || u16(end + 8) !== entries)\n return rejected(\"unsupported\");\n if (entries === 0xffff || directorySize === 0xffffffff || directoryOffset === 0xffffffff)\n return rejected(\"unsupported\");\n if (end + EOCD_SIZE + commentLength !== archive.byteLength) return rejected(\"malformed\");\n if (directoryOffset + directorySize > end) return rejected(\"malformed\");\n if (entries > MAX_ENTRIES) return rejected(\"limit\");\n\n const names = new TextDecoder(\"utf-8\", { fatal: true });\n const limit = directoryOffset + directorySize;\n let offset = directoryOffset;\n let declaredBytes = 0;\n let manifest = false;\n\n for (let index = 0; index < entries; index++) {\n if (offset + 46 > limit || u32(offset) !== CENTRAL_HEADER) return rejected(\"malformed\");\n const flags = u16(offset + 8);\n const method = u16(offset + 10);\n const compressed = u32(offset + 20);\n const declared = u32(offset + 24);\n const nameLength = u16(offset + 28);\n const extraLength = u16(offset + 30);\n const entryCommentLength = u16(offset + 32);\n const localOffset = u32(offset + 42);\n\n if (declared === 0xffffffff || compressed === 0xffffffff || localOffset === 0xffffffff)\n return rejected(\"unsupported\");\n // An encrypted or unusually compressed member is not something a browser will load.\n if ((flags & 1) !== 0 || (method !== STORED && method !== DEFLATED))\n return rejected(\"unsupported\");\n if (nameLength === 0 || nameLength > MAX_NAME_BYTES) return rejected(\"name\");\n if (offset + 46 + nameLength + extraLength + entryCommentLength > limit)\n return rejected(\"malformed\");\n if (localOffset >= directoryOffset) return rejected(\"malformed\");\n\n let name: string;\n\n try {\n name = names.decode(archive.subarray(offset + 46, offset + 46 + nameLength));\n } catch {\n return rejected(\"name\");\n }\n if (unsafeName(name)) return rejected(\"name\");\n\n // The directory must agree with the local header it points at: a member that describes\n // itself differently in two places has no single meaning worth uploading.\n if (localOffset + LOCAL_HEADER_SIZE > directoryOffset || u32(localOffset) !== LOCAL_HEADER)\n return rejected(\"malformed\");\n const localNameLength = u16(localOffset + 26);\n const localStart = localOffset + LOCAL_HEADER_SIZE;\n\n if (\n (u16(localOffset + 6) & 1) !== 0 ||\n u16(localOffset + 8) !== method ||\n localNameLength !== nameLength ||\n localStart + localNameLength + u16(localOffset + 28) + compressed > directoryOffset\n )\n return rejected(\"malformed\");\n\n try {\n if (names.decode(archive.subarray(localStart, localStart + localNameLength)) !== name)\n return rejected(\"malformed\");\n } catch {\n return rejected(\"name\");\n }\n if (name === \"manifest.json\") manifest = true;\n declaredBytes += declared;\n if (declaredBytes > MAX_DECLARED_BYTES) return rejected(\"limit\");\n offset += 46 + nameLength + extraLength + entryCommentLength;\n }\n if (offset !== limit) return rejected(\"malformed\");\n if (!manifest) return rejected(\"manifest\");\n\n return { _tag: \"Accepted\", facts: { entries, declaredBytes } };\n};\n","import { Context, Effect, Layer, Schema } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport type { ClientError } from \"./Errors.ts\";\nimport { ExtensionError } from \"./Errors.ts\";\nimport { inspectExtensionArchive } from \"./internal/extension/Archive.ts\";\nimport { ExtensionReference, Identifier } from \"./References.ts\";\nimport { SafeFilename } from \"./Transfers.ts\";\n\nconst Timestamp = Schema.String.check(Schema.isMaxLength(64));\n\n/** The provider documents a 100 MB archive; a caller may request less, never more. */\nconst MAX_ARCHIVE_BYTES = 100 * 1024 * 1024;\n\nconst ProviderExtension = Schema.Struct({\n id: Identifier,\n projectId: Identifier,\n fileName: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),\n createdAt: Schema.optionalKey(Timestamp),\n updatedAt: Schema.optionalKey(Timestamp),\n});\n\n/** Only fields the provider actually returned are reported; absence is never invented. */\nexport class ExtensionMetadata extends Schema.Class<ExtensionMetadata>(\n \"BrowserbaseExtensionMetadata\",\n)({\n reference: ExtensionReference,\n fileName: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),\n createdAt: Schema.optionalKey(Timestamp),\n updatedAt: Schema.optionalKey(Timestamp),\n}) {}\n\n/** Registration evidence is what this package inspected, not a provider load receipt. */\nexport class ExtensionRegistration extends Schema.Class<ExtensionRegistration>(\n \"BrowserbaseExtensionRegistration\",\n)({\n reference: ExtensionReference,\n archiveBytes: Schema.Natural,\n entries: Schema.Natural,\n declaredBytes: Schema.Natural,\n}) {}\n\nexport interface ExtensionUploadOptions {\n /** Portable basename sent with the part; defaults to `extension.zip`. */\n readonly filename?: string;\n readonly maxBytes?: number;\n readonly timeoutMillis?: number;\n}\n\nconst Upload = Schema.Struct({\n filename: Schema.optionalKey(\n SafeFilename.check(Schema.makeFilter((value) => value.toLowerCase().endsWith(\".zip\"))),\n ),\n maxBytes: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: MAX_ARCHIVE_BYTES })),\n ),\n timeoutMillis: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 600_000 })),\n ),\n});\n\nconst fromClient = (operation: ExtensionError[\"operation\"], error: ClientError): ExtensionError =>\n ExtensionError.make({\n operation,\n reason: error.reason,\n ...(error.outcome === undefined ? {} : { outcome: error.outcome }),\n ...(error.status === undefined ? {} : { status: error.status }),\n ...(error.retryAfterMillis === undefined ? {} : { retryAfterMillis: error.retryAfterMillis }),\n });\n\nconst configuration = (operation: ExtensionError[\"operation\"]) =>\n ExtensionError.make({ operation, reason: \"configuration\", outcome: \"undispatched\" });\n\nconst malformed = (operation: ExtensionError[\"operation\"], mutation = false) =>\n ExtensionError.make({\n operation,\n reason: \"malformed\",\n ...(mutation ? { outcome: \"unknown\" as const } : {}),\n });\n\n/**\n * A provisioned extension is a durable project resource selected at launch, never uploaded\n * again on connect. The archive is inspected before transport; loading remains the provider's.\n */\nexport class BrowserbaseExtensions extends Context.Service<\n BrowserbaseExtensions,\n {\n readonly register: (\n archive: Uint8Array,\n options?: ExtensionUploadOptions,\n ) => Effect.Effect<ExtensionRegistration, ExtensionError>;\n readonly retrieve: (\n reference: ExtensionReference,\n ) => Effect.Effect<ExtensionMetadata, ExtensionError>;\n readonly delete: (reference: ExtensionReference) => Effect.Effect<void, ExtensionError>;\n }\n>()(\"effect-browserbase/Extensions\") {\n static readonly layer: Layer.Layer<BrowserbaseExtensions, never, BrowserbaseClient> =\n Layer.effect(\n BrowserbaseExtensions,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n\n const validate = Effect.fnUntraced(function* (\n reference: ExtensionReference,\n operation: ExtensionError[\"operation\"],\n ) {\n const ref = yield* Schema.decodeEffect(ExtensionReference)(reference, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => configuration(operation)));\n\n if (ref.projectId !== client.projectId)\n return yield* ExtensionError.make({\n operation,\n reason: \"authorization\",\n outcome: \"undispatched\",\n });\n\n return ref;\n });\n\n const register = Effect.fn(\"BrowserbaseExtensions.register\")(function* (\n archive: Uint8Array,\n options: ExtensionUploadOptions = {},\n ) {\n const value = yield* Schema.decodeEffect(Upload)(options, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => configuration(\"extension-register\")));\n\n if (!(archive instanceof Uint8Array)) return yield* configuration(\"extension-register\");\n const maxBytes = value.maxBytes ?? MAX_ARCHIVE_BYTES;\n\n if (archive.byteLength < 1 || archive.byteLength > maxBytes)\n return yield* ExtensionError.make({\n operation: \"extension-archive\",\n reason: \"limit\",\n outcome: \"undispatched\",\n });\n\n // Inspect and send the same immutable bytes: a caller cannot swap the\n // archive between its manifest check and the multipart encoding.\n const owned = new Uint8Array(archive);\n const inspected = inspectExtensionArchive(owned);\n\n if (inspected._tag === \"Rejected\") {\n return yield* ExtensionError.make({\n operation: \"extension-archive\",\n reason:\n inspected.reason === \"limit\"\n ? \"limit\"\n : inspected.reason === \"name\"\n ? \"unsafe-filename\"\n : \"configuration\",\n outcome: \"undispatched\",\n });\n }\n\n const raw = yield* client\n .upload(\n \"/v1/extensions\",\n {\n field: \"file\",\n filename: value.filename ?? \"extension.zip\",\n mediaType: \"application/zip\",\n bytes: owned,\n },\n {\n maxBytes,\n ...(value.timeoutMillis === undefined\n ? {}\n : { timeoutMillis: value.timeoutMillis }),\n },\n )\n .pipe(Effect.mapError((error) => fromClient(\"extension-register\", error)));\n\n const created = yield* Schema.decodeUnknownEffect(ProviderExtension)(raw).pipe(\n Effect.mapError(() => malformed(\"extension-register\", true)),\n );\n\n if (created.projectId !== client.projectId)\n return yield* malformed(\"extension-register\", true);\n\n return ExtensionRegistration.make({\n reference: ExtensionReference.make({\n provider: \"browserbase\",\n projectId: client.projectId,\n extensionId: created.id,\n }),\n archiveBytes: owned.byteLength,\n entries: inspected.facts.entries,\n declaredBytes: inspected.facts.declaredBytes,\n });\n });\n\n const retrieve = Effect.fn(\"BrowserbaseExtensions.retrieve\")(function* (\n reference: ExtensionReference,\n ) {\n const ref = yield* validate(reference, \"extension-retrieve\");\n\n const raw = yield* client\n .json(\"GET\", `/v1/extensions/${encodeURIComponent(ref.extensionId)}`)\n .pipe(Effect.mapError((error) => fromClient(\"extension-retrieve\", error)));\n\n const value = yield* Schema.decodeUnknownEffect(ProviderExtension)(raw).pipe(\n Effect.mapError(() => malformed(\"extension-retrieve\")),\n );\n\n if (value.id !== ref.extensionId || value.projectId !== ref.projectId)\n return yield* malformed(\"extension-retrieve\");\n\n return ExtensionMetadata.make({\n reference: ref,\n ...(value.fileName === undefined ? {} : { fileName: value.fileName }),\n ...(value.createdAt === undefined ? {} : { createdAt: value.createdAt }),\n ...(value.updatedAt === undefined ? {} : { updatedAt: value.updatedAt }),\n });\n });\n\n const remove = Effect.fn(\"BrowserbaseExtensions.delete\")(function* (\n reference: ExtensionReference,\n ) {\n const ref = yield* validate(reference, \"extension-delete\");\n\n yield* client\n .noContent(\"DELETE\", `/v1/extensions/${encodeURIComponent(ref.extensionId)}`)\n .pipe(Effect.mapError((error) => fromClient(\"extension-delete\", error)));\n });\n\n return BrowserbaseExtensions.of({ register, retrieve, delete: remove });\n }),\n );\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAC3B,MAAM,YAAY;AAClB,MAAM,oBAAoB;AAC1B,MAAM,SAAS;AACf,MAAM,WAAW;AAEjB,MAAM,eAAe;AACrB,MAAM,iBAAiB;AACvB,MAAM,2BAA2B;AAEjC,MAAM,YAAY,YAA6C;CAAE,MAAM;CAAY;AAAO;AAE1F,MAAM,WAAW,SACf,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,cAAc,YAAY,OAAO,cAAc,GAAM;;AAGvE,MAAM,cAAc,SAClB,KAAK,WAAW,KAChB,KAAK,WAAW,GAAG,KACnB,KAAK,SAAS,IAAI,KAClB,KAAK,SAAS,IAAI,KAClB,aAAa,KAAK,IAAI,KACtB,QAAQ,IAAI,KACZ,KAAK,MAAM,GAAG,CAAC,CAAC,MAAM,YAAY,YAAY,OAAO,YAAY,IAAI;AAEvE,MAAa,2BAA2B,YAAuC;CAC7E,IAAI,QAAQ,aAAa,WAAW,OAAO,SAAS,WAAW;CAC/D,MAAM,OAAO,IAAI,SAAS,QAAQ,QAAQ,QAAQ,YAAY,QAAQ,UAAU;CAChF,MAAM,OAAO,WAAmB,KAAK,UAAU,QAAQ,IAAI;CAC3D,MAAM,OAAO,WAAmB,KAAK,UAAU,QAAQ,IAAI;CAE3D,IAAI,IAAI,CAAC,MAAM,cAAc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KAAK,CAAC,CAAC;GAE3E,MAAM,QAAQ,OAAO,OAAO,oBAAoB,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,KACtE,OAAO,eAAe,UAAU,oBAAoB,CAAC,CACvD;GAEA,IAAI,MAAM,OAAO,IAAI,eAAe,MAAM,cAAc,IAAI,WAC1D,OAAO,OAAO,UAAU,oBAAoB;GAE9C,OAAO,kBAAkB,KAAK;IAC5B,WAAW;IACX,GAAI,MAAM,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,MAAM,SAAS;IACnE,GAAI,MAAM,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,MAAM,UAAU;IACtE,GAAI,MAAM,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,MAAM,UAAU;GACxE,CAAC;EACH,CAAC;EAED,MAAM,SAAS,OAAO,GAAG,8BAA8B,CAAC,CAAC,WACvD,WACA;GACA,MAAM,MAAM,OAAO,SAAS,WAAW,kBAAkB;GAEzD,OAAO,OACJ,UAAU,UAAU,kBAAkB,mBAAmB,IAAI,WAAW,GAAG,CAAC,CAC5E,KAAK,OAAO,UAAU,UAAU,WAAW,oBAAoB,KAAK,CAAC,CAAC;EAC3E,CAAC;EAED,OAAO,sBAAsB,GAAG;GAAE;GAAU;GAAU,QAAQ;EAAO,CAAC;CACxE,CAAC,CACH;AACJ"}
@@ -0,0 +1,44 @@
1
+ import { r as ExtensionReference } from "./References-URDAtapt.mjs";
2
+ import { ExtensionError } from "./Errors.mjs";
3
+ import { t as BrowserbaseClient } from "./Client-Ca0zSg1n.mjs";
4
+ import { Context, Effect, Layer, Schema } from "effect";
5
+ declare namespace Extensions_d_exports {
6
+ export { BrowserbaseExtensions, ExtensionMetadata, ExtensionRegistration, ExtensionUploadOptions };
7
+ }
8
+ declare const ExtensionMetadata_base: Schema.Class<ExtensionMetadata, Schema.Struct<{
9
+ readonly reference: typeof ExtensionReference;
10
+ readonly fileName: Schema.optionalKey<Schema.String>;
11
+ readonly createdAt: Schema.optionalKey<Schema.String>;
12
+ readonly updatedAt: Schema.optionalKey<Schema.String>;
13
+ }>, {}>;
14
+ /** Only fields the provider actually returned are reported; absence is never invented. */
15
+ export declare class ExtensionMetadata extends ExtensionMetadata_base {}
16
+ declare const ExtensionRegistration_base: Schema.Class<ExtensionRegistration, Schema.Struct<{
17
+ readonly reference: typeof ExtensionReference;
18
+ readonly archiveBytes: Schema.Natural;
19
+ readonly entries: Schema.Natural;
20
+ readonly declaredBytes: Schema.Natural;
21
+ }>, {}>;
22
+ /** Registration evidence is what this package inspected, not a provider load receipt. */
23
+ export declare class ExtensionRegistration extends ExtensionRegistration_base {}
24
+ export interface ExtensionUploadOptions {
25
+ /** Portable basename sent with the part; defaults to `extension.zip`. */
26
+ readonly filename?: string;
27
+ readonly maxBytes?: number;
28
+ readonly timeoutMillis?: number;
29
+ }
30
+ declare const BrowserbaseExtensions_base: Context.ServiceClass<BrowserbaseExtensions, "effect-browserbase/Extensions", {
31
+ readonly register: (archive: Uint8Array, options?: ExtensionUploadOptions) => Effect.Effect<ExtensionRegistration, ExtensionError>;
32
+ readonly retrieve: (reference: ExtensionReference) => Effect.Effect<ExtensionMetadata, ExtensionError>;
33
+ readonly delete: (reference: ExtensionReference) => Effect.Effect<void, ExtensionError>;
34
+ }>;
35
+ /**
36
+ * A provisioned extension is a durable project resource selected at launch, never uploaded
37
+ * again on connect. The archive is inspected before transport; loading remains the provider's.
38
+ */
39
+ export declare class BrowserbaseExtensions extends BrowserbaseExtensions_base {
40
+ static readonly layer: Layer.Layer<BrowserbaseExtensions, never, BrowserbaseClient>;
41
+ }
42
+ //#endregion
43
+ export { Extensions_d_exports as t };
44
+ //# sourceMappingURL=Extensions.d.mts.map
@@ -0,0 +1,2 @@
1
+ import { n as ExtensionMetadata, r as ExtensionRegistration, t as BrowserbaseExtensions } from "./Extensions-ClZbYb1H.mjs";
2
+ export { BrowserbaseExtensions, ExtensionMetadata, ExtensionRegistration };
@@ -0,0 +1,227 @@
1
+ import { n as ContextReference } from "./References-URDAtapt.mjs";
2
+ import { PlatformError } from "./Errors.mjs";
3
+ import { t as BrowserbaseClient } from "./Client-Ca0zSg1n.mjs";
4
+ import { Context, Effect, Layer, Schema } from "effect";
5
+ declare namespace Functions_d_exports {
6
+ export { BrowserbaseFunctions, FunctionBuild, FunctionInvocation, FunctionInvokeRequest, FunctionLogLine, FunctionMetadata, FunctionPageQuery, FunctionSessionParams, FunctionStatus, FunctionStatusQuery, FunctionVersion, FunctionWaitOptions, OffsetPage };
7
+ }
8
+ declare const Status: Schema.Literals<readonly ["PENDING", "RUNNING", "COMPLETED", "FAILED"]>;
9
+ export type FunctionStatus = typeof Status.Type;
10
+ declare const FunctionMetadata_base: Schema.Class<FunctionMetadata, Schema.Struct<{
11
+ readonly id: Schema.NonEmptyString;
12
+ readonly projectId: Schema.NonEmptyString;
13
+ readonly name: Schema.String;
14
+ readonly createdAt: Schema.String;
15
+ readonly updatedAt: Schema.String;
16
+ }>, {}>;
17
+ export declare class FunctionMetadata extends FunctionMetadata_base {}
18
+ declare const FunctionVersion_base: Schema.Class<FunctionVersion, Schema.Struct<{
19
+ readonly id: Schema.NonEmptyString;
20
+ readonly projectId: Schema.NonEmptyString;
21
+ readonly functionId: Schema.NonEmptyString;
22
+ readonly functionBuildId: Schema.NonEmptyString;
23
+ readonly sessionCreateParams: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
24
+ readonly userParamsSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
25
+ readonly createdAt: Schema.String;
26
+ readonly updatedAt: Schema.String;
27
+ }>, {}>;
28
+ export declare class FunctionVersion extends FunctionVersion_base {}
29
+ declare const FunctionBuild_base: Schema.Class<FunctionBuild, Schema.Struct<{
30
+ readonly id: Schema.NonEmptyString;
31
+ readonly projectId: Schema.NonEmptyString;
32
+ readonly request: Schema.Struct<{
33
+ readonly entrypoint: Schema.String;
34
+ readonly functionNames: Schema.optionalKey<Schema.$Array<Schema.String>>;
35
+ }>;
36
+ readonly status: Schema.Literals<readonly ["PENDING", "RUNNING", "COMPLETED", "FAILED"]>;
37
+ readonly createdAt: Schema.String;
38
+ readonly updatedAt: Schema.String;
39
+ readonly startedAt: Schema.String;
40
+ readonly endedAt: Schema.optionalKey<Schema.String>;
41
+ readonly expiresAt: Schema.String;
42
+ readonly cause: Schema.optionalKey<Schema.Struct<{
43
+ readonly code: Schema.String;
44
+ readonly message: Schema.optionalKey<Schema.String>;
45
+ }>>;
46
+ }>, {}>;
47
+ export declare class FunctionBuild extends FunctionBuild_base {}
48
+ declare const FunctionInvocation_base: Schema.Class<FunctionInvocation, Schema.Struct<{
49
+ readonly id: Schema.NonEmptyString;
50
+ readonly projectId: Schema.NonEmptyString;
51
+ readonly functionId: Schema.NonEmptyString;
52
+ readonly versionId: Schema.NonEmptyString;
53
+ readonly sessionId: Schema.NonEmptyString;
54
+ readonly region: Schema.optionalKey<Schema.String>;
55
+ readonly params: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
56
+ readonly status: Schema.Literals<readonly ["PENDING", "RUNNING", "COMPLETED", "FAILED"]>;
57
+ readonly results: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
58
+ readonly cause: Schema.optionalKey<Schema.Struct<{
59
+ readonly code: Schema.String;
60
+ readonly message: Schema.optionalKey<Schema.String>;
61
+ }>>;
62
+ readonly createdAt: Schema.String;
63
+ readonly updatedAt: Schema.String;
64
+ readonly startedAt: Schema.String;
65
+ readonly endedAt: Schema.optionalKey<Schema.String>;
66
+ readonly expiresAt: Schema.String;
67
+ }>, {}>;
68
+ export declare class FunctionInvocation extends FunctionInvocation_base {}
69
+ declare const FunctionLogLine_base: Schema.Class<FunctionLogLine, Schema.Struct<{
70
+ readonly message: Schema.String;
71
+ readonly timestamp: Schema.Finite;
72
+ }>, {}>;
73
+ export declare class FunctionLogLine extends FunctionLogLine_base {}
74
+ /** The session a Function invocation runs in; the provider's invoke-time subset. */
75
+ export declare const FunctionSessionParams: Schema.Struct<{
76
+ /** Seconds, 60–900; the provider defaults to 900. */
77
+ readonly timeout: Schema.optionalKey<Schema.Int>;
78
+ readonly extensionId: Schema.optionalKey<Schema.NonEmptyString>;
79
+ readonly context: Schema.optionalKey<Schema.Struct<{
80
+ readonly reference: typeof ContextReference;
81
+ readonly persist: Schema.Boolean;
82
+ }>>;
83
+ readonly proxies: Schema.optionalKey<Schema.Union<readonly [Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
84
+ readonly type: Schema.Literal<"browserbase">;
85
+ readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
86
+ readonly geolocation: Schema.optionalKey<Schema.Struct<{
87
+ readonly country: Schema.String;
88
+ readonly state: Schema.optionalKey<Schema.String>;
89
+ readonly city: Schema.optionalKey<Schema.NonEmptyString>;
90
+ }>>;
91
+ }>, Schema.Struct<{
92
+ readonly type: Schema.Literal<"external">;
93
+ readonly server: Schema.NonEmptyString;
94
+ readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
95
+ readonly username: Schema.optionalKey<Schema.Redacted<Schema.String>>;
96
+ readonly password: Schema.optionalKey<Schema.Redacted<Schema.String>>;
97
+ }>, Schema.Struct<{
98
+ readonly type: Schema.Literal<"none">;
99
+ readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
100
+ }>]>>]>>;
101
+ readonly proxySettings: Schema.optionalKey<Schema.Struct<{
102
+ readonly caCertificates: Schema.optionalKey<Schema.$Array<Schema.NonEmptyString>>;
103
+ }>>;
104
+ readonly userMetadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
105
+ readonly browserSettings: Schema.optionalKey<Schema.Struct<{
106
+ readonly viewport: Schema.optionalKey<Schema.Struct<{
107
+ readonly width: Schema.optionalKey<Schema.Int>;
108
+ readonly height: Schema.optionalKey<Schema.Int>;
109
+ }>>;
110
+ readonly blockAds: Schema.optionalKey<Schema.Boolean>;
111
+ readonly solveCaptchas: Schema.optionalKey<Schema.Boolean>;
112
+ readonly recordSession: Schema.optionalKey<Schema.Boolean>;
113
+ readonly logSession: Schema.optionalKey<Schema.Boolean>;
114
+ readonly verified: Schema.optionalKey<Schema.Boolean>;
115
+ readonly captchaImageSelector: Schema.optionalKey<Schema.NonEmptyString>;
116
+ readonly captchaInputSelector: Schema.optionalKey<Schema.NonEmptyString>;
117
+ readonly os: Schema.optionalKey<Schema.Literals<readonly ["windows", "mac", "linux", "mobile", "tablet"]>>;
118
+ readonly size: Schema.optionalKey<Schema.Literals<readonly ["small", "medium", "large"]>>;
119
+ readonly enableNativeSelectPolyfill: Schema.optionalKey<Schema.Boolean>;
120
+ readonly enablePdfViewer: Schema.optionalKey<Schema.Boolean>;
121
+ readonly extensions: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["onepassword", "browser-events"]>>>;
122
+ readonly allowedDomains: Schema.optionalKey<Schema.$Array<Schema.NonEmptyString>>;
123
+ readonly ignoreCertificateErrors: Schema.optionalKey<Schema.Boolean>;
124
+ }>>;
125
+ }>;
126
+ export type FunctionSessionParams = typeof FunctionSessionParams.Type;
127
+ export declare const FunctionInvokeRequest: Schema.Struct<{
128
+ readonly params: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
129
+ readonly session: Schema.optionalKey<Schema.Struct<{
130
+ /** Seconds, 60–900; the provider defaults to 900. */
131
+ readonly timeout: Schema.optionalKey<Schema.Int>;
132
+ readonly extensionId: Schema.optionalKey<Schema.NonEmptyString>;
133
+ readonly context: Schema.optionalKey<Schema.Struct<{
134
+ readonly reference: typeof ContextReference;
135
+ readonly persist: Schema.Boolean;
136
+ }>>;
137
+ readonly proxies: Schema.optionalKey<Schema.Union<readonly [Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
138
+ readonly type: Schema.Literal<"browserbase">;
139
+ readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
140
+ readonly geolocation: Schema.optionalKey<Schema.Struct<{
141
+ readonly country: Schema.String;
142
+ readonly state: Schema.optionalKey<Schema.String>;
143
+ readonly city: Schema.optionalKey<Schema.NonEmptyString>;
144
+ }>>;
145
+ }>, Schema.Struct<{
146
+ readonly type: Schema.Literal<"external">;
147
+ readonly server: Schema.NonEmptyString;
148
+ readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
149
+ readonly username: Schema.optionalKey<Schema.Redacted<Schema.String>>;
150
+ readonly password: Schema.optionalKey<Schema.Redacted<Schema.String>>;
151
+ }>, Schema.Struct<{
152
+ readonly type: Schema.Literal<"none">;
153
+ readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
154
+ }>]>>]>>;
155
+ readonly proxySettings: Schema.optionalKey<Schema.Struct<{
156
+ readonly caCertificates: Schema.optionalKey<Schema.$Array<Schema.NonEmptyString>>;
157
+ }>>;
158
+ readonly userMetadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
159
+ readonly browserSettings: Schema.optionalKey<Schema.Struct<{
160
+ readonly viewport: Schema.optionalKey<Schema.Struct<{
161
+ readonly width: Schema.optionalKey<Schema.Int>;
162
+ readonly height: Schema.optionalKey<Schema.Int>;
163
+ }>>;
164
+ readonly blockAds: Schema.optionalKey<Schema.Boolean>;
165
+ readonly solveCaptchas: Schema.optionalKey<Schema.Boolean>;
166
+ readonly recordSession: Schema.optionalKey<Schema.Boolean>;
167
+ readonly logSession: Schema.optionalKey<Schema.Boolean>;
168
+ readonly verified: Schema.optionalKey<Schema.Boolean>;
169
+ readonly captchaImageSelector: Schema.optionalKey<Schema.NonEmptyString>;
170
+ readonly captchaInputSelector: Schema.optionalKey<Schema.NonEmptyString>;
171
+ readonly os: Schema.optionalKey<Schema.Literals<readonly ["windows", "mac", "linux", "mobile", "tablet"]>>;
172
+ readonly size: Schema.optionalKey<Schema.Literals<readonly ["small", "medium", "large"]>>;
173
+ readonly enableNativeSelectPolyfill: Schema.optionalKey<Schema.Boolean>;
174
+ readonly enablePdfViewer: Schema.optionalKey<Schema.Boolean>;
175
+ readonly extensions: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["onepassword", "browser-events"]>>>;
176
+ readonly allowedDomains: Schema.optionalKey<Schema.$Array<Schema.NonEmptyString>>;
177
+ readonly ignoreCertificateErrors: Schema.optionalKey<Schema.Boolean>;
178
+ }>>;
179
+ }>>;
180
+ }>;
181
+ export type FunctionInvokeRequest = typeof FunctionInvokeRequest.Type;
182
+ export declare const FunctionPageQuery: Schema.Struct<{
183
+ offset: Schema.optionalKey<Schema.Int>;
184
+ limit: Schema.optionalKey<Schema.Int>;
185
+ }>;
186
+ export type FunctionPageQuery = typeof FunctionPageQuery.Type;
187
+ export declare const FunctionStatusQuery: Schema.Struct<{
188
+ readonly offset: Schema.optionalKey<Schema.Int>;
189
+ readonly limit: Schema.optionalKey<Schema.Int>;
190
+ readonly status: Schema.optionalKey<Schema.Literals<readonly ["PENDING", "RUNNING", "COMPLETED", "FAILED"]>>;
191
+ }>;
192
+ export type FunctionStatusQuery = typeof FunctionStatusQuery.Type;
193
+ export declare const FunctionWaitOptions: Schema.Struct<{
194
+ readonly timeoutMillis: Schema.Int;
195
+ readonly pollIntervalMillis: Schema.optionalKey<Schema.Int>;
196
+ }>;
197
+ export type FunctionWaitOptions = typeof FunctionWaitOptions.Type;
198
+ export interface OffsetPage<A> {
199
+ readonly items: ReadonlyArray<A>;
200
+ readonly total: number;
201
+ }
202
+ declare const BrowserbaseFunctions_base: Context.ServiceClass<BrowserbaseFunctions, "effect-browserbase/Functions", {
203
+ readonly list: (query?: FunctionPageQuery) => Effect.Effect<OffsetPage<FunctionMetadata>, PlatformError>;
204
+ readonly retrieve: (functionId: string) => Effect.Effect<FunctionMetadata, PlatformError>;
205
+ readonly invoke: (functionId: string, request?: FunctionInvokeRequest) => Effect.Effect<FunctionInvocation, PlatformError>;
206
+ readonly versions: (functionId: string, query?: FunctionPageQuery) => Effect.Effect<OffsetPage<FunctionVersion>, PlatformError>;
207
+ readonly version: (versionId: string) => Effect.Effect<FunctionVersion, PlatformError>;
208
+ readonly invocations: (versionId: string, query?: FunctionStatusQuery) => Effect.Effect<OffsetPage<FunctionInvocation>, PlatformError>;
209
+ readonly invocation: (invocationId: string) => Effect.Effect<FunctionInvocation, PlatformError>;
210
+ readonly invocationLogs: (invocationId: string) => Effect.Effect<OffsetPage<FunctionLogLine>, PlatformError>;
211
+ readonly builds: (query?: FunctionStatusQuery) => Effect.Effect<OffsetPage<FunctionBuild>, PlatformError>;
212
+ readonly build: (buildId: string) => Effect.Effect<FunctionBuild, PlatformError>;
213
+ readonly buildLogs: (buildId: string) => Effect.Effect<OffsetPage<FunctionLogLine>, PlatformError>;
214
+ /** Polls until the invocation is terminal. Interrupting the wait does not cancel it. */
215
+ readonly waitForInvocation: (invocationId: string, options: FunctionWaitOptions) => Effect.Effect<FunctionInvocation, PlatformError>;
216
+ }>;
217
+ /**
218
+ * Browserbase Functions: deployed code invoked in a provider-allocated session. Deployment
219
+ * happens through Browserbase's CLI; this service reads, invokes and observes. `invoke` is
220
+ * never retried, and a lost reply is `outcome: "unknown"`.
221
+ */
222
+ export declare class BrowserbaseFunctions extends BrowserbaseFunctions_base {
223
+ static readonly layer: Layer.Layer<BrowserbaseFunctions, never, BrowserbaseClient>;
224
+ }
225
+ //#endregion
226
+ export { Functions_d_exports as t };
227
+ //# sourceMappingURL=Functions.d.mts.map