effect-browserbase 0.1.0-beta.104 → 0.2.0-beta.0

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 (135) hide show
  1. package/README.md +61 -305
  2. package/dist/Account.d.mts +4 -6
  3. package/dist/Account.mjs +4 -9
  4. package/dist/Account.mjs.map +1 -1
  5. package/dist/{Acquisition-WBafHwXH.mjs → Acquisition-D8o4jtCg.mjs} +22 -68
  6. package/dist/Acquisition-D8o4jtCg.mjs.map +1 -0
  7. package/dist/Agents.d.mts +4 -6
  8. package/dist/Agents.mjs +3 -19
  9. package/dist/Agents.mjs.map +1 -1
  10. package/dist/Allocation.d.mts +9 -11
  11. package/dist/Allocation.mjs +2 -4
  12. package/dist/Allocation.mjs.map +1 -1
  13. package/dist/Browser.d.mts +23 -141
  14. package/dist/Browser.mjs +208 -164
  15. package/dist/Browser.mjs.map +1 -1
  16. package/dist/BrowserBinding.d.mts +7 -34
  17. package/dist/BrowserBinding.mjs +30 -1
  18. package/dist/BrowserBinding.mjs.map +1 -0
  19. package/dist/Certificates.d.mts +3 -5
  20. package/dist/Certificates.mjs +2 -7
  21. package/dist/Certificates.mjs.map +1 -1
  22. package/dist/{Cleanup-G2YpTCuU.d.mts → Cleanup-DMTDBir8.d.mts} +5 -6
  23. package/dist/Cleanup.d.mts +3 -2
  24. package/dist/Cleanup.mjs +1 -6
  25. package/dist/Cleanup.mjs.map +1 -1
  26. package/dist/{Client-D1_xYM9o.mjs → Client-BQteUePT.mjs} +2 -4
  27. package/dist/{Client-D1_xYM9o.mjs.map → Client-BQteUePT.mjs.map} +1 -1
  28. package/dist/Client.d.mts +51 -2
  29. package/dist/Client.mjs +1 -1
  30. package/dist/Connection-DcvJZEdc.mjs +65 -0
  31. package/dist/Connection-DcvJZEdc.mjs.map +1 -0
  32. package/dist/ContextCoordination.d.mts +5 -6
  33. package/dist/ContextCoordination.mjs +1 -8
  34. package/dist/ContextCoordination.mjs.map +1 -1
  35. package/dist/Contexts.d.mts +4 -6
  36. package/dist/Contexts.mjs +2 -8
  37. package/dist/Contexts.mjs.map +1 -1
  38. package/dist/Downloads.d.mts +6 -8
  39. package/dist/Downloads.mjs +3 -8
  40. package/dist/Downloads.mjs.map +1 -1
  41. package/dist/Errors.d.mts +3 -26
  42. package/dist/Errors.mjs +1 -137
  43. package/dist/Errors.mjs.map +1 -1
  44. package/dist/{Extensions-ClZbYb1H.mjs → Extensions-nMNMPGCc.mjs} +3 -9
  45. package/dist/{Extensions-ClZbYb1H.mjs.map → Extensions-nMNMPGCc.mjs.map} +1 -1
  46. package/dist/Extensions.d.mts +4 -6
  47. package/dist/Extensions.mjs +1 -1
  48. package/dist/Functions.d.mts +4 -6
  49. package/dist/Functions.mjs +3 -17
  50. package/dist/Functions.mjs.map +1 -1
  51. package/dist/{Launch-BHcAEq05.mjs → Launch-m0fxzJ49.mjs} +5 -5
  52. package/dist/Launch-m0fxzJ49.mjs.map +1 -0
  53. package/dist/Launch.d.mts +130 -2
  54. package/dist/Launch.mjs +4 -11
  55. package/dist/Launch.mjs.map +1 -1
  56. package/dist/PageFetch.d.mts +3 -5
  57. package/dist/PageFetch.mjs +2 -8
  58. package/dist/PageFetch.mjs.map +1 -1
  59. package/dist/Projects.d.mts +3 -5
  60. package/dist/Projects.mjs +2 -8
  61. package/dist/Projects.mjs.map +1 -1
  62. package/dist/Recordings.d.mts +6 -8
  63. package/dist/Recordings.mjs +3 -5
  64. package/dist/Recordings.mjs.map +1 -1
  65. package/dist/{References-URDAtapt.d.mts → References-DOH3Wu44.d.mts} +5 -6
  66. package/dist/References.d.mts +3 -2
  67. package/dist/References.mjs +10 -18
  68. package/dist/References.mjs.map +1 -1
  69. package/dist/Replays.d.mts +6 -8
  70. package/dist/Replays.mjs +3 -5
  71. package/dist/Replays.mjs.map +1 -1
  72. package/dist/Search.d.mts +3 -5
  73. package/dist/Search.mjs +2 -9
  74. package/dist/Search.mjs.map +1 -1
  75. package/dist/{SessionData-DRKcKCqw.d.mts → SessionData-5xYZDshJ.d.mts} +5 -6
  76. package/dist/SessionData.d.mts +3 -2
  77. package/dist/SessionData.mjs +1 -8
  78. package/dist/SessionData.mjs.map +1 -1
  79. package/dist/{Sessions-CtbseWEh.mjs → Sessions-DoQGg9nB.mjs} +34 -18
  80. package/dist/Sessions-DoQGg9nB.mjs.map +1 -0
  81. package/dist/{Sessions-B8E4kMxo.d.mts → Sessions-tFJYaXFq.d.mts} +8 -8
  82. package/dist/Sessions.d.mts +4 -3
  83. package/dist/Sessions.mjs +1 -1
  84. package/dist/{Transfers-Czv5IZzJ.d.mts → Transfers-GVqzrDWl.d.mts} +22 -9
  85. package/dist/Transfers.d.mts +3 -2
  86. package/dist/Transfers.mjs +12 -28
  87. package/dist/Transfers.mjs.map +1 -1
  88. package/dist/Uploads.d.mts +6 -8
  89. package/dist/Uploads.mjs +3 -5
  90. package/dist/Uploads.mjs.map +1 -1
  91. package/dist/Webhooks.d.mts +3 -5
  92. package/dist/Webhooks.mjs +2 -11
  93. package/dist/Webhooks.mjs.map +1 -1
  94. package/dist/{WriterFacts-osvYAsIx.d.mts → WriterFacts-5CPBGG1P.d.mts} +4 -3
  95. package/dist/index.d.mts +27 -31
  96. package/dist/index.mjs +26 -31
  97. package/package.json +3 -28
  98. package/dist/Acquisition-WBafHwXH.mjs.map +0 -1
  99. package/dist/Association-CEps4hYP.mjs +0 -10
  100. package/dist/Association-CEps4hYP.mjs.map +0 -1
  101. package/dist/Bootstrap-BXuzZojd.mjs +0 -194
  102. package/dist/Bootstrap-BXuzZojd.mjs.map +0 -1
  103. package/dist/Bootstrap-m7lHgj0D.d.mts +0 -177
  104. package/dist/Bootstrap.d.mts +0 -2
  105. package/dist/Bootstrap.mjs +0 -2
  106. package/dist/BrowserBinding-DlJTGYZL.mjs +0 -2508
  107. package/dist/BrowserBinding-DlJTGYZL.mjs.map +0 -1
  108. package/dist/BrowserData-LpcAuAub.d.mts +0 -369
  109. package/dist/BrowserData.d.mts +0 -2
  110. package/dist/BrowserData.mjs +0 -442
  111. package/dist/BrowserData.mjs.map +0 -1
  112. package/dist/Capture-Bc0z9IAi.mjs +0 -571
  113. package/dist/Capture-Bc0z9IAi.mjs.map +0 -1
  114. package/dist/Capture-BvWI-l1A.d.mts +0 -168
  115. package/dist/Capture.d.mts +0 -2
  116. package/dist/Capture.mjs +0 -2
  117. package/dist/Client-Ca0zSg1n.d.mts +0 -53
  118. package/dist/Images-DgscEfSf.mjs +0 -127
  119. package/dist/Images-DgscEfSf.mjs.map +0 -1
  120. package/dist/Launch-BHcAEq05.mjs.map +0 -1
  121. package/dist/Launch-C8CfaYxb.d.mts +0 -132
  122. package/dist/LocalBrowser-BLancJ3R.d.mts +0 -79
  123. package/dist/LocalBrowser-DsQLWNL1.mjs +0 -439
  124. package/dist/LocalBrowser-DsQLWNL1.mjs.map +0 -1
  125. package/dist/LocalBrowser.d.mts +0 -2
  126. package/dist/LocalBrowser.mjs +0 -2
  127. package/dist/PageControl.d.mts +0 -16
  128. package/dist/PageControl.mjs +0 -36
  129. package/dist/PageControl.mjs.map +0 -1
  130. package/dist/PageControlAssociation-DabEg5AR.mjs +0 -10
  131. package/dist/PageControlAssociation-DabEg5AR.mjs.map +0 -1
  132. package/dist/Session-D4nT9hOO.mjs +0 -1379
  133. package/dist/Session-D4nT9hOO.mjs.map +0 -1
  134. package/dist/Sessions-CtbseWEh.mjs.map +0 -1
  135. package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"Downloads.mjs","names":[],"sources":["../src/Downloads.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema, Stream } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport { type ClientError, FileError } from \"./Errors.ts\";\nimport { downloadTransferPolicy } from \"./internal/artifact/TransferPolicy.ts\";\nimport { deadlineAfter, nowMillis, until } from \"./internal/Deadline.ts\";\nimport { Identifier, type SessionReference } from \"./References.ts\";\nimport { BrowserbaseSessions } from \"./Sessions.ts\";\nimport { type ArtifactTransferPolicy, DownloadMetadata } from \"./Transfers.ts\";\n\nexport interface DownloadPolicy extends ArtifactTransferPolicy {\n readonly mimeTypes: ReadonlyArray<string>;\n}\n\nexport interface DownloadListing {\n readonly downloads: ReadonlyArray<DownloadMetadata>;\n readonly total: number;\n readonly offset: number;\n readonly complete: boolean;\n}\n\nconst Timestamp = Schema.String.check(Schema.isMaxLength(64));\n\n/** Provider-side filters over one session's files; every bound is optional. */\nexport const DownloadQuery = Schema.Struct({\n offset: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 10_000 }))),\n filename: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(1024))),\n mimeType: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(256))),\n minSize: Schema.optionalKey(Schema.Natural),\n maxSize: Schema.optionalKey(Schema.Natural),\n createdAfter: Schema.optionalKey(Timestamp),\n createdBefore: Schema.optionalKey(Timestamp),\n});\n\nexport type DownloadQuery = typeof DownloadQuery.Type;\n\nconst Listing = Schema.Struct({\n downloads: Schema.Array(DownloadMetadata).check(Schema.isMaxLength(100)),\n total: Schema.Natural,\n});\n\nconst failure = (operation: FileError[\"operation\"], reason: FileError[\"reason\"]) =>\n FileError.make({ operation, reason });\n\nconst fromClient = (operation: FileError[\"operation\"]) => (error: ClientError) =>\n FileError.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 within = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n deadline: number,\n operation: FileError[\"operation\"],\n) => until(effect, deadline, () => failure(operation, \"timeout\"));\n\n/** Website files are not session-recording MP4s. They retain their own provider download ID. */\nexport class BrowserbaseDownloads extends Context.Service<\n BrowserbaseDownloads,\n {\n readonly list: (\n reference: SessionReference,\n query?: DownloadQuery,\n ) => Effect.Effect<DownloadListing, FileError>;\n readonly metadata: (\n reference: SessionReference,\n downloadId: string,\n ) => Effect.Effect<DownloadMetadata, FileError>;\n readonly stream: (\n reference: SessionReference,\n downloadId: string,\n policy: DownloadPolicy,\n ) => Stream.Stream<Uint8Array, FileError>;\n /** Deletes one stored file. A lost reply is `outcome: \"unknown\"` and is never retried. */\n readonly delete: (\n reference: SessionReference,\n downloadId: string,\n ) => Effect.Effect<void, FileError>;\n readonly waitForNew: (\n reference: SessionReference,\n previousIds: ReadonlyArray<string>,\n timeoutMillis?: number,\n ) => Effect.Effect<ReadonlyArray<DownloadMetadata>, FileError>;\n }\n>()(\"effect-browserbase/Downloads\") {\n static readonly layer: Layer.Layer<\n BrowserbaseDownloads,\n never,\n BrowserbaseClient | BrowserbaseSessions\n > = Layer.effect(\n BrowserbaseDownloads,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n const sessions = yield* BrowserbaseSessions;\n\n // Files are readable while the session runs; only the exact owning session is admitted.\n const owned = (ref: SessionReference, operation: FileError[\"operation\"]) =>\n sessions.retrieve(ref).pipe(\n Effect.mapError((error) => FileError.make({ operation, reason: error.reason })),\n Effect.asVoid,\n );\n\n const list = Effect.fnUntraced(function* (ref: SessionReference, query: DownloadQuery = {}) {\n const checked = yield* Schema.decodeEffect(DownloadQuery)(query, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => failure(\"downloads-list\", \"configuration\")));\n\n const offset = checked.offset ?? 0;\n\n yield* owned(ref, \"downloads-list\");\n\n const search = new URLSearchParams({\n sessionId: ref.sessionId,\n limit: \"100\",\n offset: String(offset),\n });\n\n for (const key of [\n \"filename\",\n \"mimeType\",\n \"minSize\",\n \"maxSize\",\n \"createdAfter\",\n \"createdBefore\",\n ] as const) {\n const value = checked[key];\n\n if (value !== undefined) search.set(key, String(value));\n }\n\n const raw = yield* client.json(\"GET\", `/v1/downloads?${search}`).pipe(\n Effect.mapError(fromClient(\"downloads-list\")),\n Effect.flatMap((value) =>\n Schema.decodeUnknownEffect(Listing)(value).pipe(\n Effect.mapError(() => failure(\"downloads-list\", \"malformed\")),\n ),\n ),\n );\n\n if (\n raw.downloads.some((entry) => entry.sessionId !== ref.sessionId) ||\n new Set(raw.downloads.map((entry) => entry.id)).size !== raw.downloads.length\n ) {\n return yield* failure(\"downloads-list\", \"malformed\");\n }\n\n return { ...raw, offset, complete: offset + raw.downloads.length >= raw.total };\n });\n\n const metadata = Effect.fnUntraced(function* (ref: SessionReference, id: string) {\n yield* Schema.decodeEffect(Identifier)(id).pipe(\n Effect.mapError(() => failure(\"download-metadata\", \"configuration\")),\n );\n\n yield* owned(ref, \"download-metadata\");\n\n const value = yield* client.json(\"GET\", `/v1/downloads/${encodeURIComponent(id)}`).pipe(\n Effect.mapError(fromClient(\"download-metadata\")),\n Effect.flatMap((raw) =>\n Schema.decodeUnknownEffect(DownloadMetadata)(raw).pipe(\n Effect.mapError(() => failure(\"download-metadata\", \"malformed\")),\n ),\n ),\n );\n\n if (value.id !== id || value.sessionId !== ref.sessionId)\n return yield* failure(\"download-metadata\", \"malformed\");\n\n return value;\n });\n\n const stream = (ref: SessionReference, id: string, policy: DownloadPolicy) =>\n Stream.unwrap(\n Effect.gen(function* () {\n const { maxBytes, timeoutMillis, mimeTypes } = yield* downloadTransferPolicy(\n policy,\n () => failure(\"download\", \"configuration\"),\n );\n\n const deadline = yield* deadlineAfter(timeoutMillis);\n const file = yield* within(metadata(ref, id), deadline, \"download\");\n\n if (!mimeTypes.includes(file.mimeType.toLowerCase()))\n return yield* failure(\"download\", \"content-type\");\n if (file.size > maxBytes) return yield* failure(\"download\", \"limit\");\n let received = 0;\n\n return client\n .bytes(\n `/v1/downloads/${encodeURIComponent(id)}`,\n maxBytes,\n [\"application/octet-stream\", file.mimeType.toLowerCase()],\n timeoutMillis,\n deadline,\n )\n .pipe(\n Stream.mapError(fromClient(\"download\")),\n Stream.tap((chunk) =>\n Effect.sync(() => {\n received += chunk.byteLength;\n }),\n ),\n Stream.concat(\n Stream.fromEffect(\n Effect.suspend(() =>\n received === file.size\n ? Effect.void\n : Effect.fail(failure(\"download\", \"malformed\")),\n ),\n ).pipe(Stream.drain),\n ),\n );\n }),\n );\n\n const waitForNew = Effect.fnUntraced(function* (\n ref: SessionReference,\n previousIds: ReadonlyArray<string>,\n timeoutMillis = 30_000,\n ) {\n if (\n previousIds.length > 10_000 ||\n !Number.isSafeInteger(timeoutMillis) ||\n timeoutMillis < 1 ||\n timeoutMillis > 300_000\n ) {\n return yield* failure(\"download-wait\", \"configuration\");\n }\n const previous = new Set(previousIds);\n const deadline = yield* deadlineAfter(timeoutMillis);\n\n do {\n const result = yield* within(list(ref), deadline, \"download-wait\");\n\n // Never claim a complete candidate set from a partial listing.\n if (!result.complete) return yield* failure(\"download-wait\", \"limit\");\n const fresh = result.downloads.filter((entry) => !previous.has(entry.id));\n\n if (fresh.length > 0) return fresh;\n const remaining = deadline - (yield* nowMillis);\n\n if (remaining <= 0) break;\n yield* Effect.sleep(Math.min(500, remaining));\n } while ((yield* nowMillis) < deadline);\n\n return yield* failure(\"download-wait\", \"timeout\");\n });\n\n const remove = Effect.fnUntraced(function* (ref: SessionReference, id: string) {\n yield* Schema.decodeEffect(Identifier)(id).pipe(\n Effect.mapError(() =>\n FileError.make({\n operation: \"download-delete\",\n reason: \"configuration\",\n outcome: \"undispatched\",\n }),\n ),\n );\n\n // Ownership is proved by reading the file's session before any mutation.\n yield* metadata(ref, id).pipe(\n Effect.mapError((error) =>\n FileError.make({\n operation: \"download-delete\",\n reason: error.reason,\n outcome: \"undispatched\",\n ...(error.status === undefined ? {} : { status: error.status }),\n ...(error.retryAfterMillis === undefined\n ? {}\n : { retryAfterMillis: error.retryAfterMillis }),\n }),\n ),\n );\n\n yield* client\n .noContent(\"DELETE\", `/v1/downloads/${encodeURIComponent(id)}`)\n .pipe(Effect.mapError(fromClient(\"download-delete\")));\n });\n\n return BrowserbaseDownloads.of({ list, metadata, stream, waitForNew, del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SAAS;IACT,GAAI,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,MAAM,OAAO;IAC7D,GAAI,MAAM,qBAAqB,KAAA,IAC3B,CAAC,IACD,EAAE,kBAAkB,MAAM,iBAAiB;GACjD,CAAC,CACH,CACF;GAEA,OAAO,OACJ,UAAU,UAAU,iBAAiB,mBAAmB,EAAE,GAAG,CAAC,CAC9D,KAAK,OAAO,SAAS,WAAW,iBAAiB,CAAC,CAAC;EACxD,CAAC;EAED,OAAO,qBAAqB,GAAG;GAAE;GAAM;GAAU;GAAQ;GAAY,QAAQ;EAAO,CAAC;CACvF,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"Downloads.mjs","names":[],"sources":["../src/Downloads.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema, Stream } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport { type ClientError, FileError } from \"./Errors.ts\";\nimport { downloadTransferPolicy } from \"./internal/artifact/TransferPolicy.ts\";\nimport { deadlineAfter, nowMillis, until } from \"./internal/Deadline.ts\";\nimport { Identifier, type SessionReference } from \"./References.ts\";\nimport { BrowserbaseSessions } from \"./Sessions.ts\";\nimport { type ArtifactTransferPolicy, DownloadMetadata } from \"./Transfers.ts\";\n\nexport interface DownloadPolicy extends ArtifactTransferPolicy {\n readonly mimeTypes: ReadonlyArray<string>;\n}\n\nexport interface DownloadListing {\n readonly downloads: ReadonlyArray<DownloadMetadata>;\n readonly total: number;\n readonly offset: number;\n readonly complete: boolean;\n}\n\nconst Timestamp = Schema.String.check(Schema.isMaxLength(64));\n\n/** Provider-side filters over one session's files; every bound is optional. */\nexport const DownloadQuery = Schema.Struct({\n offset: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 10_000 }))),\n filename: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(1024))),\n mimeType: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(256))),\n minSize: Schema.optionalKey(Schema.Natural),\n maxSize: Schema.optionalKey(Schema.Natural),\n createdAfter: Schema.optionalKey(Timestamp),\n createdBefore: Schema.optionalKey(Timestamp),\n});\n\nexport type DownloadQuery = typeof DownloadQuery.Type;\n\nconst Listing = Schema.Struct({\n downloads: Schema.Array(DownloadMetadata).check(Schema.isMaxLength(100)),\n total: Schema.Natural,\n});\n\nconst failure = (operation: FileError[\"operation\"], reason: FileError[\"reason\"]) =>\n FileError.make({ operation, reason });\n\nconst fromClient = (operation: FileError[\"operation\"]) => (error: ClientError) =>\n FileError.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 within = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n deadline: number,\n operation: FileError[\"operation\"],\n) => until(effect, deadline, () => failure(operation, \"timeout\"));\n\n/** Website files are not session-recording MP4s. They retain their own provider download ID. */\nexport class BrowserbaseDownloads extends Context.Service<\n BrowserbaseDownloads,\n {\n readonly list: (\n reference: SessionReference,\n query?: DownloadQuery,\n ) => Effect.Effect<DownloadListing, FileError>;\n readonly metadata: (\n reference: SessionReference,\n downloadId: string,\n ) => Effect.Effect<DownloadMetadata, FileError>;\n readonly stream: (\n reference: SessionReference,\n downloadId: string,\n policy: DownloadPolicy,\n ) => Stream.Stream<Uint8Array, FileError>;\n /** Deletes one stored file. A lost reply is `outcome: \"unknown\"` and is never retried. */\n readonly delete: (\n reference: SessionReference,\n downloadId: string,\n ) => Effect.Effect<void, FileError>;\n readonly waitForNew: (\n reference: SessionReference,\n previousIds: ReadonlyArray<string>,\n timeoutMillis?: number,\n ) => Effect.Effect<ReadonlyArray<DownloadMetadata>, FileError>;\n }\n>()(\"effect-browserbase/Downloads\") {\n static readonly layer: Layer.Layer<\n BrowserbaseDownloads,\n never,\n BrowserbaseClient | BrowserbaseSessions\n > = Layer.effect(\n BrowserbaseDownloads,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n const sessions = yield* BrowserbaseSessions;\n\n // Files are readable while the session runs; only the exact owning session is admitted.\n const owned = (ref: SessionReference, operation: FileError[\"operation\"]) =>\n sessions.retrieve(ref).pipe(\n Effect.mapError((error) => FileError.make({ operation, reason: error.reason })),\n Effect.asVoid,\n );\n\n const list = Effect.fnUntraced(function* (ref: SessionReference, query: DownloadQuery = {}) {\n const checked = yield* Schema.decodeEffect(DownloadQuery)(query, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => failure(\"downloads-list\", \"configuration\")));\n\n const offset = checked.offset ?? 0;\n\n yield* owned(ref, \"downloads-list\");\n\n const search = new URLSearchParams({\n sessionId: ref.sessionId,\n limit: \"100\",\n offset: String(offset),\n });\n\n for (const key of [\n \"filename\",\n \"mimeType\",\n \"minSize\",\n \"maxSize\",\n \"createdAfter\",\n \"createdBefore\",\n ] as const) {\n const value = checked[key];\n\n if (value !== undefined) search.set(key, String(value));\n }\n\n const raw = yield* client.json(\"GET\", `/v1/downloads?${search}`).pipe(\n Effect.mapError(fromClient(\"downloads-list\")),\n Effect.flatMap((value) =>\n Schema.decodeUnknownEffect(Listing)(value).pipe(\n Effect.mapError(() => failure(\"downloads-list\", \"malformed\")),\n ),\n ),\n );\n\n if (\n raw.downloads.some((entry) => entry.sessionId !== ref.sessionId) ||\n new Set(raw.downloads.map((entry) => entry.id)).size !== raw.downloads.length\n ) {\n return yield* failure(\"downloads-list\", \"malformed\");\n }\n\n return { ...raw, offset, complete: offset + raw.downloads.length >= raw.total };\n });\n\n const metadata = Effect.fnUntraced(function* (ref: SessionReference, id: string) {\n yield* Schema.decodeEffect(Identifier)(id).pipe(\n Effect.mapError(() => failure(\"download-metadata\", \"configuration\")),\n );\n\n yield* owned(ref, \"download-metadata\");\n\n const value = yield* client.json(\"GET\", `/v1/downloads/${encodeURIComponent(id)}`).pipe(\n Effect.mapError(fromClient(\"download-metadata\")),\n Effect.flatMap((raw) =>\n Schema.decodeUnknownEffect(DownloadMetadata)(raw).pipe(\n Effect.mapError(() => failure(\"download-metadata\", \"malformed\")),\n ),\n ),\n );\n\n if (value.id !== id || value.sessionId !== ref.sessionId)\n return yield* failure(\"download-metadata\", \"malformed\");\n\n return value;\n });\n\n const stream = (ref: SessionReference, id: string, policy: DownloadPolicy) =>\n Stream.unwrap(\n Effect.gen(function* () {\n const { maxBytes, timeoutMillis, mimeTypes } = yield* downloadTransferPolicy(\n policy,\n () => failure(\"download\", \"configuration\"),\n );\n\n const deadline = yield* deadlineAfter(timeoutMillis);\n const file = yield* within(metadata(ref, id), deadline, \"download\");\n\n if (!mimeTypes.includes(file.mimeType.toLowerCase()))\n return yield* failure(\"download\", \"content-type\");\n if (file.size > maxBytes) return yield* failure(\"download\", \"limit\");\n let received = 0;\n\n return client\n .bytes(\n `/v1/downloads/${encodeURIComponent(id)}`,\n maxBytes,\n [\"application/octet-stream\", file.mimeType.toLowerCase()],\n timeoutMillis,\n deadline,\n )\n .pipe(\n Stream.mapError(fromClient(\"download\")),\n Stream.tap((chunk) =>\n Effect.sync(() => {\n received += chunk.byteLength;\n }),\n ),\n Stream.concat(\n Stream.fromEffect(\n Effect.suspend(() =>\n received === file.size\n ? Effect.void\n : Effect.fail(failure(\"download\", \"malformed\")),\n ),\n ).pipe(Stream.drain),\n ),\n );\n }),\n );\n\n const waitForNew = Effect.fnUntraced(function* (\n ref: SessionReference,\n previousIds: ReadonlyArray<string>,\n timeoutMillis = 30_000,\n ) {\n if (\n previousIds.length > 10_000 ||\n !Number.isSafeInteger(timeoutMillis) ||\n timeoutMillis < 1 ||\n timeoutMillis > 300_000\n ) {\n return yield* failure(\"download-wait\", \"configuration\");\n }\n const previous = new Set(previousIds);\n const deadline = yield* deadlineAfter(timeoutMillis);\n\n do {\n const result = yield* within(list(ref), deadline, \"download-wait\");\n\n // Never claim a complete candidate set from a partial listing.\n if (!result.complete) return yield* failure(\"download-wait\", \"limit\");\n const fresh = result.downloads.filter((entry) => !previous.has(entry.id));\n\n if (fresh.length > 0) return fresh;\n const remaining = deadline - (yield* nowMillis);\n\n if (remaining <= 0) break;\n yield* Effect.sleep(Math.min(500, remaining));\n } while ((yield* nowMillis) < deadline);\n\n return yield* failure(\"download-wait\", \"timeout\");\n });\n\n const remove = Effect.fnUntraced(function* (ref: SessionReference, id: string) {\n yield* Schema.decodeEffect(Identifier)(id).pipe(\n Effect.mapError(() =>\n FileError.make({\n operation: \"download-delete\",\n reason: \"configuration\",\n outcome: \"undispatched\",\n }),\n ),\n );\n\n // Ownership is proved by reading the file's session before any mutation.\n yield* metadata(ref, id).pipe(\n Effect.mapError((error) =>\n FileError.make({\n operation: \"download-delete\",\n reason: error.reason,\n outcome: \"undispatched\",\n ...(error.status === undefined ? {} : { status: error.status }),\n ...(error.retryAfterMillis === undefined\n ? {}\n : { retryAfterMillis: error.retryAfterMillis }),\n }),\n ),\n );\n\n yield* client\n .noContent(\"DELETE\", `/v1/downloads/${encodeURIComponent(id)}`)\n .pipe(Effect.mapError(fromClient(\"download-delete\")));\n });\n\n return BrowserbaseDownloads.of({ list, metadata, stream, waitForNew, delete: remove });\n }),\n );\n}\n"],"mappings":";;;;;;;;;AAqBA,MAAM,YAAY,OAAO,OAAO,MAAM,OAAO,YAAY,EAAE,CAAC;;AAG5D,MAAa,gBAAgB,OAAO,OAAO;CACzC,QAAQ,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAO,CAAC,CAAC,CAAC;CAC9F,UAAU,OAAO,YAAY,OAAO,eAAe,MAAM,OAAO,YAAY,IAAI,CAAC,CAAC;CAClF,UAAU,OAAO,YAAY,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC,CAAC;CACjF,SAAS,OAAO,YAAY,OAAO,OAAO;CAC1C,SAAS,OAAO,YAAY,OAAO,OAAO;CAC1C,cAAc,OAAO,YAAY,SAAS;CAC1C,eAAe,OAAO,YAAY,SAAS;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O,KAAK,GAAG,GAAG,UAAU,eAAe;IAGjE,IAAI,CAAC,OAAO,UAAU,OAAO,OAAO,QAAQ,iBAAiB,OAAO;IACpE,MAAM,QAAQ,OAAO,UAAU,QAAQ,UAAU,CAAC,SAAS,IAAI,MAAM,EAAE,CAAC;IAExE,IAAI,MAAM,SAAS,GAAG,OAAO;IAC7B,MAAM,YAAY,YAAY,OAAO;IAErC,IAAI,aAAa,GAAG;IACpB,OAAO,OAAO,MAAM,KAAK,IAAI,KAAK,SAAS,CAAC;GAC9C,UAAU,OAAO,aAAa;GAE9B,OAAO,OAAO,QAAQ,iBAAiB,SAAS;EAClD,CAAC;EAED,MAAM,SAAS,OAAO,WAAW,WAAW,KAAuB,IAAY;GAC7E,OAAO,OAAO,aAAa,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,KACzC,OAAO,eACL,UAAU,KAAK;IACb,WAAW;IACX,QAAQ;IACR,SAAS;GACX,CAAC,CACH,CACF;GAGA,OAAO,SAAS,KAAK,EAAE,CAAC,CAAC,KACvB,OAAO,UAAU,UACf,UAAU,KAAK;IACb,WAAW;IACX,QAAQ,MAAM;IACd,SAAS;IACT,GAAI,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,MAAM,OAAO;IAC7D,GAAI,MAAM,qBAAqB,KAAA,IAC3B,CAAC,IACD,EAAE,kBAAkB,MAAM,iBAAiB;GACjD,CAAC,CACH,CACF;GAEA,OAAO,OACJ,UAAU,UAAU,iBAAiB,mBAAmB,EAAE,GAAG,CAAC,CAC9D,KAAK,OAAO,SAAS,WAAW,iBAAiB,CAAC,CAAC;EACxD,CAAC;EAED,OAAO,qBAAqB,GAAG;GAAE;GAAM;GAAU;GAAQ;GAAY,QAAQ;EAAO,CAAC;CACvF,CAAC,CACH;AACF"}
package/dist/Errors.d.mts CHANGED
@@ -1,23 +1,6 @@
1
- import { o as SessionReference, t as AllocationAttempt } from "./References-URDAtapt.mjs";
1
+ import { a as SessionReference, t as AllocationAttempt } from "./References-DOH3Wu44.mjs";
2
2
  import { Schema } from "effect";
3
- declare namespace Errors_d_exports {
4
- export { AllocationError, ArtifactError, BrowserError, BrowserOperation, CertificateError, ClientError, ContextError, ExtensionError, FileError, InitializationError, PlatformError, ProjectError, SessionError };
5
- }
6
- /**
7
- * What a caller asked the owned browser to do. The vocabulary is closed: the owner stamps it
8
- * when it admits an operation, so a native step's own name can never become API, and a new
9
- * spelling is a deliberate edit here rather than a string that merely compiles.
10
- */
11
- export declare const BrowserOperation: Schema.Literals<readonly ["configure", "launch", "connect", "reconnect", "detach", "disconnect", "close", "handoff", "resume", "live-view", "target", "handle", "list-pages", "list-frames", "select-page", "select-frame", "new-page", "close-page", "resize", "ready", "observe", "checkpoint", "control-facts", "revalidate", "read-text", "screenshot", "wait", "navigate", "navigate-stop", "click", "fill", "scroll", "click-and-wait", "download-action", "select-files", "file-chooser", "action-result", "pointer-move", "hover", "wheel", "press", "type", "page-control", "page-state", "page-suspend", "page-resume", "capture", "capture-start", "capture-stop", "capture-consume"]>;
12
- export type BrowserOperation = typeof BrowserOperation.Type;
13
- declare const BrowserError_base: Schema.Class<BrowserError, Schema.TaggedStruct<"BrowserError", {
14
- readonly operation: Schema.Literals<readonly ["configure", "launch", "connect", "reconnect", "detach", "disconnect", "close", "handoff", "resume", "live-view", "target", "handle", "list-pages", "list-frames", "select-page", "select-frame", "new-page", "close-page", "resize", "ready", "observe", "checkpoint", "control-facts", "revalidate", "read-text", "screenshot", "wait", "navigate", "navigate-stop", "click", "fill", "scroll", "click-and-wait", "download-action", "select-files", "file-chooser", "action-result", "pointer-move", "hover", "wheel", "press", "type", "page-control", "page-state", "page-suspend", "page-resume", "capture", "capture-start", "capture-stop", "capture-consume"]>;
15
- readonly reason: Schema.Literals<readonly ["configuration", "unsupported", "busy", "closed", "stale", "not-found", "ambiguous", "malformed", "limit", "timeout", "transport", "provider", "authorization", "rate-limited", "disconnected", "active", "disabled", "expired", "failed", "unsafe-url", "content-type", "timestamp", "resized", "target-changed", "interrupted", "context-lease", "not-visible", "denied", "not-focused"]>;
16
- readonly outcome: Schema.optionalKey<Schema.Literals<readonly ["undispatched", "rejected", "unknown"]>>;
17
- readonly status: Schema.optionalKey<Schema.Int>;
18
- readonly retryAfterMillis: Schema.optionalKey<Schema.Natural>;
19
- }>, import("effect/Cause").YieldableError>;
20
- export declare class BrowserError extends BrowserError_base {}
3
+ //#region src/Errors.d.ts
21
4
  declare const ClientError_base: Schema.Class<ClientError, Schema.TaggedStruct<"ClientError", {
22
5
  operation: Schema.Literals<readonly ["configure", "provider-read", "provider-mutation", "provider-upload", "media-download"]>;
23
6
  reason: Schema.Literals<readonly ["configuration", "authorization", "rate-limited", "not-found", "active", "disabled", "expired", "provider", "transport", "timeout", "malformed", "limit", "unsafe-url", "content-type"]>;
@@ -102,12 +85,6 @@ declare const ArtifactError_base: Schema.Class<ArtifactError, Schema.TaggedStruc
102
85
  readonly reason: Schema.Literals<readonly ["configuration", "authorization", "rate-limited", "not-found", "active", "disabled", "expired", "provider", "transport", "timeout", "malformed", "limit", "unsafe-url", "content-type", "failed", "byos", "assembly-unknown", "unsupported", "ambiguous"]>;
103
86
  }>, import("effect/Cause").YieldableError>;
104
87
  export declare class ArtifactError extends ArtifactError_base {}
105
- declare const InitializationError_base: Schema.Class<InitializationError, Schema.TaggedStruct<"InitializationError", {
106
- readonly operation: Schema.Literals<readonly ["configure", "register", "ready", "callback", "dispose"]>;
107
- readonly step: Schema.String;
108
- readonly reason: Schema.Literals<readonly ["configuration", "unsupported", "origin", "stale", "busy", "closed", "timeout", "input", "output", "native"]>;
109
- }>, import("effect/Cause").YieldableError>;
110
- export declare class InitializationError extends InitializationError_base {}
111
88
  declare const AllocationError_base: Schema.Class<AllocationError, Schema.TaggedStruct<"AllocationError", {
112
89
  readonly attempt: typeof AllocationAttempt;
113
90
  readonly reference: Schema.optionalKey<typeof SessionReference>;
@@ -119,5 +96,5 @@ declare const AllocationError_base: Schema.Class<AllocationError, Schema.TaggedS
119
96
  /** Creation has a known rejection or an uncertain effect; absence of a reply is not a rejection. */
120
97
  export declare class AllocationError extends AllocationError_base {}
121
98
  //#endregion
122
- export { Errors_d_exports as t };
99
+ export {};
123
100
  //# sourceMappingURL=Errors.d.mts.map
package/dist/Errors.mjs CHANGED
@@ -1,120 +1,6 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
1
  import { AllocationAttempt, SessionReference } from "./References.mjs";
3
2
  import { Schema } from "effect";
4
3
  //#region src/Errors.ts
5
- var Errors_exports = /* @__PURE__ */ __exportAll({
6
- AllocationError: () => AllocationError,
7
- ArtifactError: () => ArtifactError,
8
- BrowserError: () => BrowserError,
9
- BrowserOperation: () => BrowserOperation,
10
- CertificateError: () => CertificateError,
11
- ClientError: () => ClientError,
12
- ContextError: () => ContextError,
13
- ExtensionError: () => ExtensionError,
14
- FileError: () => FileError,
15
- InitializationError: () => InitializationError,
16
- PlatformError: () => PlatformError,
17
- ProjectError: () => ProjectError,
18
- SessionError: () => SessionError
19
- });
20
- /**
21
- * What a caller asked the owned browser to do. The vocabulary is closed: the owner stamps it
22
- * when it admits an operation, so a native step's own name can never become API, and a new
23
- * spelling is a deliberate edit here rather than a string that merely compiles.
24
- */
25
- const BrowserOperation = Schema.Literals([
26
- "configure",
27
- "launch",
28
- "connect",
29
- "reconnect",
30
- "detach",
31
- "disconnect",
32
- "close",
33
- "handoff",
34
- "resume",
35
- "live-view",
36
- "target",
37
- "handle",
38
- "list-pages",
39
- "list-frames",
40
- "select-page",
41
- "select-frame",
42
- "new-page",
43
- "close-page",
44
- "resize",
45
- "ready",
46
- "observe",
47
- "checkpoint",
48
- "control-facts",
49
- "revalidate",
50
- "read-text",
51
- "screenshot",
52
- "wait",
53
- "navigate",
54
- "navigate-stop",
55
- "click",
56
- "fill",
57
- "scroll",
58
- "click-and-wait",
59
- "download-action",
60
- "select-files",
61
- "file-chooser",
62
- "action-result",
63
- "pointer-move",
64
- "hover",
65
- "wheel",
66
- "press",
67
- "type",
68
- "page-control",
69
- "page-state",
70
- "page-suspend",
71
- "page-resume",
72
- "capture",
73
- "capture-start",
74
- "capture-stop",
75
- "capture-consume"
76
- ]);
77
- var BrowserError = class extends Schema.TaggedError()("BrowserError", {
78
- operation: BrowserOperation,
79
- reason: Schema.Literals([
80
- "configuration",
81
- "unsupported",
82
- "busy",
83
- "closed",
84
- "stale",
85
- "not-found",
86
- "ambiguous",
87
- "malformed",
88
- "limit",
89
- "timeout",
90
- "transport",
91
- "provider",
92
- "authorization",
93
- "rate-limited",
94
- "disconnected",
95
- "active",
96
- "disabled",
97
- "expired",
98
- "failed",
99
- "unsafe-url",
100
- "content-type",
101
- "timestamp",
102
- "resized",
103
- "target-changed",
104
- "interrupted",
105
- "context-lease",
106
- "not-visible",
107
- "denied",
108
- "not-focused"
109
- ]),
110
- outcome: Schema.optionalKey(Schema.Literals([
111
- "undispatched",
112
- "rejected",
113
- "unknown"
114
- ])),
115
- status: Schema.optionalKey(Schema.Int),
116
- retryAfterMillis: Schema.optionalKey(Schema.Natural)
117
- }) {};
118
4
  const RequestReason = Schema.Literals([
119
5
  "configuration",
120
6
  "authorization",
@@ -284,28 +170,6 @@ var ArtifactError = class extends Schema.TaggedError()("ArtifactError", {
284
170
  "ambiguous"
285
171
  ])
286
172
  }) {};
287
- var InitializationError = class extends Schema.TaggedError()("InitializationError", {
288
- operation: Schema.Literals([
289
- "configure",
290
- "register",
291
- "ready",
292
- "callback",
293
- "dispose"
294
- ]),
295
- step: Schema.String.check(Schema.isMaxLength(128)),
296
- reason: Schema.Literals([
297
- "configuration",
298
- "unsupported",
299
- "origin",
300
- "stale",
301
- "busy",
302
- "closed",
303
- "timeout",
304
- "input",
305
- "output",
306
- "native"
307
- ])
308
- }) {};
309
173
  /** Creation has a known rejection or an uncertain effect; absence of a reply is not a rejection. */
310
174
  var AllocationError = class extends Schema.TaggedError()("AllocationError", {
311
175
  attempt: AllocationAttempt,
@@ -324,6 +188,6 @@ var AllocationError = class extends Schema.TaggedError()("AllocationError", {
324
188
  retryAfterMillis: Schema.optionalKey(Schema.Natural)
325
189
  }) {};
326
190
  //#endregion
327
- export { AllocationError, ArtifactError, BrowserError, BrowserOperation, CertificateError, ClientError, ContextError, ExtensionError, FileError, InitializationError, PlatformError, ProjectError, SessionError, Errors_exports as t };
191
+ export { AllocationError, ArtifactError, CertificateError, ClientError, ContextError, ExtensionError, FileError, PlatformError, ProjectError, SessionError };
328
192
 
329
193
  //# sourceMappingURL=Errors.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Errors.mjs","names":[],"sources":["../src/Errors.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport { AllocationAttempt, SessionReference } from \"./References.ts\";\n\n/**\n * What a caller asked the owned browser to do. The vocabulary is closed: the owner stamps it\n * when it admits an operation, so a native step's own name can never become API, and a new\n * spelling is a deliberate edit here rather than a string that merely compiles.\n */\nexport const BrowserOperation = Schema.Literals([\n // configuration and lifetime\n \"configure\",\n \"launch\",\n \"connect\",\n \"reconnect\",\n \"detach\",\n \"disconnect\",\n \"close\",\n \"handoff\",\n \"resume\",\n \"live-view\",\n // targets\n \"target\",\n \"handle\",\n \"list-pages\",\n \"list-frames\",\n \"select-page\",\n \"select-frame\",\n \"new-page\",\n \"close-page\",\n \"resize\",\n // reading\n \"ready\",\n \"observe\",\n \"checkpoint\",\n \"control-facts\",\n \"revalidate\",\n \"read-text\",\n \"screenshot\",\n \"wait\",\n // input\n \"navigate\",\n \"navigate-stop\",\n \"click\",\n \"fill\",\n \"scroll\",\n \"click-and-wait\",\n \"download-action\",\n \"select-files\",\n \"file-chooser\",\n \"action-result\",\n // native pointer input\n \"pointer-move\",\n \"hover\",\n \"wheel\",\n // native key input\n \"press\",\n \"type\",\n // page control\n \"page-control\",\n \"page-state\",\n \"page-suspend\",\n \"page-resume\",\n // capture\n \"capture\",\n \"capture-start\",\n \"capture-stop\",\n \"capture-consume\",\n]);\n\nexport type BrowserOperation = typeof BrowserOperation.Type;\n\nexport class BrowserError extends Schema.TaggedError<BrowserError>()(\"BrowserError\", {\n operation: BrowserOperation,\n reason: Schema.Literals([\n \"configuration\",\n \"unsupported\",\n \"busy\",\n \"closed\",\n \"stale\",\n \"not-found\",\n \"ambiguous\",\n \"malformed\",\n \"limit\",\n \"timeout\",\n \"transport\",\n \"provider\",\n \"authorization\",\n \"rate-limited\",\n \"disconnected\",\n \"active\",\n \"disabled\",\n \"expired\",\n \"failed\",\n \"unsafe-url\",\n \"content-type\",\n \"timestamp\",\n \"resized\",\n \"target-changed\",\n \"interrupted\",\n \"context-lease\",\n // The pointer cannot be placed on it: outside the viewport, without area, or covered.\n \"not-visible\",\n // The host's own admission policy refused it, on facts read just before any input.\n \"denied\",\n // Keys would not reach it: neither it nor anything inside it has focus.\n \"not-focused\",\n ]),\n outcome: Schema.optionalKey(Schema.Literals([\"undispatched\", \"rejected\", \"unknown\"])),\n status: Schema.optionalKey(Schema.Int),\n retryAfterMillis: Schema.optionalKey(Schema.Natural),\n}) {}\n\nconst RequestReason = Schema.Literals([\n \"configuration\",\n \"authorization\",\n \"rate-limited\",\n \"not-found\",\n \"active\",\n \"disabled\",\n \"expired\",\n \"provider\",\n \"transport\",\n \"timeout\",\n \"malformed\",\n \"limit\",\n \"unsafe-url\",\n \"content-type\",\n]);\n\n/**\n * Every control-plane error shares these fields, but never a vocabulary: each names only the\n * operations its own service performs, so a caller can match on them exhaustively.\n */\nconst requestFields = <const Operations extends ReadonlyArray<string>>(operations: Operations) => ({\n operation: Schema.Literals(operations),\n reason: RequestReason,\n outcome: Schema.optionalKey(Schema.Literals([\"undispatched\", \"rejected\", \"unknown\"])),\n status: Schema.optionalKey(Schema.Int),\n retryAfterMillis: Schema.optionalKey(Schema.Natural),\n});\n\n/** Credential-free control-plane failures; response bodies and native causes never escape. */\nexport class ClientError extends Schema.TaggedError<ClientError>()(\n \"ClientError\",\n requestFields([\n \"configure\",\n \"provider-read\",\n \"provider-mutation\",\n \"provider-upload\",\n \"media-download\",\n ]),\n) {}\n\nexport class SessionError extends Schema.TaggedError<SessionError>()(\n \"SessionError\",\n requestFields([\n \"session-retrieve\",\n \"session-list\",\n \"session-release\",\n \"session-wait\",\n \"session-logs\",\n \"session-live-view\",\n \"session-connect\",\n \"session-attach\",\n ]),\n) {}\n\nexport class ContextError extends Schema.TaggedError<ContextError>()(\n \"ContextError\",\n requestFields([\n \"context-create\",\n \"context-retrieve\",\n \"context-delete\",\n \"writer\",\n \"writer-admit\",\n \"writer-authority\",\n \"writer-readback\",\n \"writer-settle\",\n ]),\n) {}\n\n/**\n * `extension-archive` is the local inspection of the bytes a caller supplied, before any\n * request. Why an archive was refused is its reason, never a second operation.\n */\nexport class ExtensionError extends Schema.TaggedError<ExtensionError>()(\"ExtensionError\", {\n ...requestFields([\n \"extension-archive\",\n \"extension-register\",\n \"extension-retrieve\",\n \"extension-delete\",\n ]),\n reason: Schema.Literals([...RequestReason.literals, \"unsafe-filename\"]),\n}) {}\n\n/** Project inspection and usage. */\nexport class ProjectError extends Schema.TaggedError<ProjectError>()(\n \"ProjectError\",\n requestFields([\"project-list\", \"project-retrieve\", \"project-usage\"]),\n) {}\n\n/** Proxy CA certificate administration. */\nexport class CertificateError extends Schema.TaggedError<CertificateError>()(\n \"CertificateError\",\n requestFields([\n \"certificate-create\",\n \"certificate-list\",\n \"certificate-retrieve\",\n \"certificate-delete\",\n ]),\n) {}\n\n/**\n * Browserbase platform services outside a browser session: Search, Fetch, Agents, Functions\n * and Webhooks. `service` names which one; these are host APIs, never model-facing tools.\n */\nexport class PlatformError extends Schema.TaggedError<PlatformError>()(\"PlatformError\", {\n ...requestFields([\n \"search-web\",\n \"fetch\",\n \"agent-create\",\n \"agent-list\",\n \"agent-retrieve\",\n \"agent-update\",\n \"agent-delete\",\n \"agent-run\",\n \"agent-run-list\",\n \"agent-run-retrieve\",\n \"agent-run-messages\",\n \"agent-run-stop\",\n \"agent-run-wait\",\n \"function-list\",\n \"function-retrieve\",\n \"function-versions\",\n \"function-version\",\n \"function-builds\",\n \"function-build\",\n \"function-build-logs\",\n \"function-invoke\",\n \"function-invocations\",\n \"function-invocation\",\n \"function-invocation-logs\",\n \"function-wait\",\n \"webhook-create\",\n \"webhook-list\",\n \"webhook-retrieve\",\n \"webhook-update\",\n \"webhook-delete\",\n \"webhook-rotate-secret\",\n ]),\n service: Schema.Literals([\"search\", \"fetch\", \"agents\", \"functions\", \"webhooks\"]),\n}) {}\n\nexport class FileError extends Schema.TaggedError<FileError>()(\"FileError\", {\n ...requestFields([\n \"upload\",\n \"downloads-list\",\n \"download-metadata\",\n \"download\",\n \"download-wait\",\n \"download-delete\",\n ]),\n reason: Schema.Literals([\n ...RequestReason.literals,\n \"unsafe-filename\",\n \"ambiguous\",\n \"checksum\",\n \"unsupported\",\n ]),\n}) {}\n\nexport class ArtifactError extends Schema.TaggedError<ArtifactError>()(\"ArtifactError\", {\n ...requestFields([\n \"recording-request\",\n \"recording-status\",\n \"recording-wait\",\n \"recording\",\n \"recording-download\",\n \"replay-metadata\",\n \"replay\",\n \"replay-playlist\",\n \"replay-media\",\n ]),\n reason: Schema.Literals([\n ...RequestReason.literals,\n \"failed\",\n \"byos\",\n \"assembly-unknown\",\n \"unsupported\",\n \"ambiguous\",\n ]),\n}) {}\n\nexport class InitializationError extends Schema.TaggedError<InitializationError>()(\n \"InitializationError\",\n {\n operation: Schema.Literals([\"configure\", \"register\", \"ready\", \"callback\", \"dispose\"]),\n step: Schema.String.check(Schema.isMaxLength(128)),\n reason: Schema.Literals([\n \"configuration\",\n \"unsupported\",\n \"origin\",\n \"stale\",\n \"busy\",\n \"closed\",\n \"timeout\",\n \"input\",\n \"output\",\n \"native\",\n ]),\n },\n) {}\n\n/** Creation has a known rejection or an uncertain effect; absence of a reply is not a rejection. */\nexport class AllocationError extends Schema.TaggedError<AllocationError>()(\"AllocationError\", {\n attempt: AllocationAttempt,\n reference: Schema.optionalKey(SessionReference),\n outcome: Schema.Literals([\"rejected\", \"unknown\"]),\n reason: Schema.Literals([\n \"authorization\",\n \"rate-limited\",\n \"configuration\",\n \"provider\",\n \"transport\",\n \"timeout\",\n \"malformed\",\n ]),\n status: Schema.optionalKey(Schema.Int),\n retryAfterMillis: Schema.optionalKey(Schema.Natural),\n}) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,mBAAmB,OAAO,SAAS;CAE9C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;AACF,CAAC;AAID,IAAa,eAAb,cAAkC,OAAO,YAA0B,CAAC,CAAC,gBAAgB;CACnF,WAAW;CACX,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EAEA;EAEA;CACF,CAAC;CACD,SAAS,OAAO,YAAY,OAAO,SAAS;EAAC;EAAgB;EAAY;CAAS,CAAC,CAAC;CACpF,QAAQ,OAAO,YAAY,OAAO,GAAG;CACrC,kBAAkB,OAAO,YAAY,OAAO,OAAO;AACrD,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,gBAAgB,OAAO,SAAS;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;AAMD,MAAM,iBAAiE,gBAA4B;CACjG,WAAW,OAAO,SAAS,UAAU;CACrC,QAAQ;CACR,SAAS,OAAO,YAAY,OAAO,SAAS;EAAC;EAAgB;EAAY;CAAS,CAAC,CAAC;CACpF,QAAQ,OAAO,YAAY,OAAO,GAAG;CACrC,kBAAkB,OA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,OAAO,YAAuB,CAAC,CAAC,aAAa;CAC1E,GAAG,cAAc;EACf;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,QAAQ,OAAO,SAAS;EACtB,GAAG,cAAc;EACjB;EACA;EACA;EACA;CACF,CAAC;AACH,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,gBAAb,cAAmC,OAAO,YAA2B,CAAC,CAAC,iBAAiB;CACtF,GAAG,cAAc;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,QAAQ,OAAO,SAAS;EACtB,GAAG,cAAc;EACjB;EACA;EACA;EACA;EACA;CACF,CAAC;AACH,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CACE,WAAW,OAAO,SAAS;EAAC;EAAa;EAAY;EAAS;EAAY;CAAS,CAAC;CACpF,MAAM,OAAO,OAAO,MAAM,OAAO,YAAY,GAAG,CAAC;CACjD,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH,CACF,CAAC,CAAC,CAAC;;AAGH,IAAa,kBAAb,cAAqC,OAAO,YAA6B,CAAC,CAAC,mBAAmB;CAC5F,SAAS;CACT,WAAW,OAAO,YAAY,gBAAgB;CAC9C,SAAS,OAAO,SAAS,CAAC,YAAY,SAAS,CAAC;CAChD,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,QAAQ,OAAO,YAAY,OAAO,GAAG;CACrC,kBAAkB,OAAO,YAAY,OAAO,OAAO;AACrD,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"Errors.mjs","names":[],"sources":["../src/Errors.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport { AllocationAttempt, SessionReference } from \"./References.ts\";\n\nconst RequestReason = Schema.Literals([\n \"configuration\",\n \"authorization\",\n \"rate-limited\",\n \"not-found\",\n \"active\",\n \"disabled\",\n \"expired\",\n \"provider\",\n \"transport\",\n \"timeout\",\n \"malformed\",\n \"limit\",\n \"unsafe-url\",\n \"content-type\",\n]);\n\n/**\n * Every control-plane error shares these fields, but never a vocabulary: each names only the\n * operations its own service performs, so a caller can match on them exhaustively.\n */\nconst requestFields = <const Operations extends ReadonlyArray<string>>(operations: Operations) => ({\n operation: Schema.Literals(operations),\n reason: RequestReason,\n outcome: Schema.optionalKey(Schema.Literals([\"undispatched\", \"rejected\", \"unknown\"])),\n status: Schema.optionalKey(Schema.Int),\n retryAfterMillis: Schema.optionalKey(Schema.Natural),\n});\n\n/** Credential-free control-plane failures; response bodies and native causes never escape. */\nexport class ClientError extends Schema.TaggedError<ClientError>()(\n \"ClientError\",\n requestFields([\n \"configure\",\n \"provider-read\",\n \"provider-mutation\",\n \"provider-upload\",\n \"media-download\",\n ]),\n) {}\n\nexport class SessionError extends Schema.TaggedError<SessionError>()(\n \"SessionError\",\n requestFields([\n \"session-retrieve\",\n \"session-list\",\n \"session-release\",\n \"session-wait\",\n \"session-logs\",\n \"session-live-view\",\n \"session-connect\",\n \"session-attach\",\n ]),\n) {}\n\nexport class ContextError extends Schema.TaggedError<ContextError>()(\n \"ContextError\",\n requestFields([\n \"context-create\",\n \"context-retrieve\",\n \"context-delete\",\n \"writer\",\n \"writer-admit\",\n \"writer-authority\",\n \"writer-readback\",\n \"writer-settle\",\n ]),\n) {}\n\n/**\n * `extension-archive` is the local inspection of the bytes a caller supplied, before any\n * request. Why an archive was refused is its reason, never a second operation.\n */\nexport class ExtensionError extends Schema.TaggedError<ExtensionError>()(\"ExtensionError\", {\n ...requestFields([\n \"extension-archive\",\n \"extension-register\",\n \"extension-retrieve\",\n \"extension-delete\",\n ]),\n reason: Schema.Literals([...RequestReason.literals, \"unsafe-filename\"]),\n}) {}\n\n/** Project inspection and usage. */\nexport class ProjectError extends Schema.TaggedError<ProjectError>()(\n \"ProjectError\",\n requestFields([\"project-list\", \"project-retrieve\", \"project-usage\"]),\n) {}\n\n/** Proxy CA certificate administration. */\nexport class CertificateError extends Schema.TaggedError<CertificateError>()(\n \"CertificateError\",\n requestFields([\n \"certificate-create\",\n \"certificate-list\",\n \"certificate-retrieve\",\n \"certificate-delete\",\n ]),\n) {}\n\n/**\n * Browserbase platform services outside a browser session: Search, Fetch, Agents, Functions\n * and Webhooks. `service` names which one; these are host APIs, never model-facing tools.\n */\nexport class PlatformError extends Schema.TaggedError<PlatformError>()(\"PlatformError\", {\n ...requestFields([\n \"search-web\",\n \"fetch\",\n \"agent-create\",\n \"agent-list\",\n \"agent-retrieve\",\n \"agent-update\",\n \"agent-delete\",\n \"agent-run\",\n \"agent-run-list\",\n \"agent-run-retrieve\",\n \"agent-run-messages\",\n \"agent-run-stop\",\n \"agent-run-wait\",\n \"function-list\",\n \"function-retrieve\",\n \"function-versions\",\n \"function-version\",\n \"function-builds\",\n \"function-build\",\n \"function-build-logs\",\n \"function-invoke\",\n \"function-invocations\",\n \"function-invocation\",\n \"function-invocation-logs\",\n \"function-wait\",\n \"webhook-create\",\n \"webhook-list\",\n \"webhook-retrieve\",\n \"webhook-update\",\n \"webhook-delete\",\n \"webhook-rotate-secret\",\n ]),\n service: Schema.Literals([\"search\", \"fetch\", \"agents\", \"functions\", \"webhooks\"]),\n}) {}\n\nexport class FileError extends Schema.TaggedError<FileError>()(\"FileError\", {\n ...requestFields([\n \"upload\",\n \"downloads-list\",\n \"download-metadata\",\n \"download\",\n \"download-wait\",\n \"download-delete\",\n ]),\n reason: Schema.Literals([\n ...RequestReason.literals,\n \"unsafe-filename\",\n \"ambiguous\",\n \"checksum\",\n \"unsupported\",\n ]),\n}) {}\n\nexport class ArtifactError extends Schema.TaggedError<ArtifactError>()(\"ArtifactError\", {\n ...requestFields([\n \"recording-request\",\n \"recording-status\",\n \"recording-wait\",\n \"recording\",\n \"recording-download\",\n \"replay-metadata\",\n \"replay\",\n \"replay-playlist\",\n \"replay-media\",\n ]),\n reason: Schema.Literals([\n ...RequestReason.literals,\n \"failed\",\n \"byos\",\n \"assembly-unknown\",\n \"unsupported\",\n \"ambiguous\",\n ]),\n}) {}\n\n/** Creation has a known rejection or an uncertain effect; absence of a reply is not a rejection. */\nexport class AllocationError extends Schema.TaggedError<AllocationError>()(\"AllocationError\", {\n attempt: AllocationAttempt,\n reference: Schema.optionalKey(SessionReference),\n outcome: Schema.Literals([\"rejected\", \"unknown\"]),\n reason: Schema.Literals([\n \"authorization\",\n \"rate-limited\",\n \"configuration\",\n \"provider\",\n \"transport\",\n \"timeout\",\n \"malformed\",\n ]),\n status: Schema.optionalKey(Schema.Int),\n retryAfterMillis: Schema.optionalKey(Schema.Natural),\n}) {}\n"],"mappings":";;;AAIA,MAAM,gBAAgB,OAAO,SAAS;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;AAMD,MAAM,iBAAiE,gBAA4B;CACjG,WAAW,OAAO,SAAS,UAAU;CACrC,QAAQ;CACR,SAAS,OAAO,YAAY,OAAO,SAAS;EAAC;EAAgB;EAAY;CAAS,CAAC,CAAC;CACpF,QAAQ,OAAO,YAAY,OAAO,GAAG;CACrC,kBAAkB,OAAO,YAAY,OAAO,OAAO;AACrD;;AAGA,IAAa,cAAb,cAAiC,OAAO,YAAyB,CAAC,CAChE,eACA,cAAc;CACZ;CACA;CACA;CACA;CACA;AACF,CAAC,CACH,CAAC,CAAC,CAAC;AAEH,IAAa,eAAb,cAAkC,OAAO,YAA0B,CAAC,CAClE,gBACA,cAAc;CACZ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CACH,CAAC,CAAC,CAAC;AAEH,IAAa,eAAb,cAAkC,OAAO,YAA0B,CAAC,CAClE,gBACA,cAAc;CACZ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CACH,CAAC,CAAC,CAAC;;;;;AAMH,IAAa,iBAAb,cAAoC,OAAO,YAA4B,CA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,YAA6B,CAAC,CAAC,mBAAmB;CAC5F,SAAS;CACT,WAAW,OAAO,YAAY,gBAAgB;CAC9C,SAAS,OAAO,SAAS,CAAC,YAAY,SAAS,CAAC;CAChD,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,QAAQ,OAAO,YAAY,OAAO,GAAG;CACrC,kBAAkB,OAAO,YAAY,OAAO,OAAO;AACrD,CAAC,CAAC,CAAC,CAAC"}
@@ -1,8 +1,7 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
1
  import { ExtensionReference, Identifier } from "./References.mjs";
3
2
  import { ExtensionError } from "./Errors.mjs";
4
3
  import { SafeFilename } from "./Transfers.mjs";
5
- import { t as BrowserbaseClient } from "./Client-D1_xYM9o.mjs";
4
+ import { t as BrowserbaseClient } from "./Client-BQteUePT.mjs";
6
5
  import { Context, Effect, Layer, Schema } from "effect";
7
6
  //#region src/internal/extension/Archive.ts
8
7
  const MAX_ENTRIES = 4096;
@@ -97,11 +96,6 @@ const inspectExtensionArchive = (archive) => {
97
96
  };
98
97
  //#endregion
99
98
  //#region src/Extensions.ts
100
- var Extensions_exports = /* @__PURE__ */ __exportAll({
101
- BrowserbaseExtensions: () => BrowserbaseExtensions,
102
- ExtensionMetadata: () => ExtensionMetadata,
103
- ExtensionRegistration: () => ExtensionRegistration
104
- });
105
99
  const Timestamp = Schema.String.check(Schema.isMaxLength(64));
106
100
  /** The provider documents a 100 MB archive; a caller may request less, never more. */
107
101
  const MAX_ARCHIVE_BYTES = 104857600;
@@ -232,6 +226,6 @@ var BrowserbaseExtensions = class BrowserbaseExtensions extends Context.Service(
232
226
  }));
233
227
  };
234
228
  //#endregion
235
- export { Extensions_exports as i, ExtensionMetadata as n, ExtensionRegistration as r, BrowserbaseExtensions as t };
229
+ export { ExtensionMetadata as n, ExtensionRegistration as r, BrowserbaseExtensions as t };
236
230
 
237
- //# sourceMappingURL=Extensions-ClZbYb1H.mjs.map
231
+ //# sourceMappingURL=Extensions-nMNMPGCc.mjs.map
@@ -1 +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,OAAO,SAAS,WAAW;CAGxD,MAAM,WAAW,KAAK,IAAI,GAAG,QAA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BAAiB,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"}
1
+ {"version":3,"file":"Extensions-nMNMPGCc.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,2B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AAM,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"}
@@ -1,10 +1,8 @@
1
- import { r as ExtensionReference } from "./References-URDAtapt.mjs";
1
+ import { r as ExtensionReference } from "./References-DOH3Wu44.mjs";
2
2
  import { ExtensionError } from "./Errors.mjs";
3
- import { t as BrowserbaseClient } from "./Client-Ca0zSg1n.mjs";
3
+ import { BrowserbaseClient } from "./Client.mjs";
4
4
  import { Context, Effect, Layer, Schema } from "effect";
5
- declare namespace Extensions_d_exports {
6
- export { BrowserbaseExtensions, ExtensionMetadata, ExtensionRegistration, ExtensionUploadOptions };
7
- }
5
+ //#region src/Extensions.d.ts
8
6
  declare const ExtensionMetadata_base: Schema.Class<ExtensionMetadata, Schema.Struct<{
9
7
  readonly reference: typeof ExtensionReference;
10
8
  readonly fileName: Schema.optionalKey<Schema.String>;
@@ -40,5 +38,5 @@ export declare class BrowserbaseExtensions extends BrowserbaseExtensions_base {
40
38
  static readonly layer: Layer.Layer<BrowserbaseExtensions, never, BrowserbaseClient>;
41
39
  }
42
40
  //#endregion
43
- export { Extensions_d_exports as t };
41
+ export {};
44
42
  //# sourceMappingURL=Extensions.d.mts.map
@@ -1,2 +1,2 @@
1
- import { n as ExtensionMetadata, r as ExtensionRegistration, t as BrowserbaseExtensions } from "./Extensions-ClZbYb1H.mjs";
1
+ import { n as ExtensionMetadata, r as ExtensionRegistration, t as BrowserbaseExtensions } from "./Extensions-nMNMPGCc.mjs";
2
2
  export { BrowserbaseExtensions, ExtensionMetadata, ExtensionRegistration };
@@ -1,10 +1,8 @@
1
- import { n as ContextReference } from "./References-URDAtapt.mjs";
1
+ import { n as ContextReference } from "./References-DOH3Wu44.mjs";
2
2
  import { PlatformError } from "./Errors.mjs";
3
- import { t as BrowserbaseClient } from "./Client-Ca0zSg1n.mjs";
3
+ import { BrowserbaseClient } from "./Client.mjs";
4
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
- }
5
+ //#region src/Functions.d.ts
8
6
  declare const Status: Schema.Literals<readonly ["PENDING", "RUNNING", "COMPLETED", "FAILED"]>;
9
7
  export type FunctionStatus = typeof Status.Type;
10
8
  declare const FunctionMetadata_base: Schema.Class<FunctionMetadata, Schema.Struct<{
@@ -223,5 +221,5 @@ export declare class BrowserbaseFunctions extends BrowserbaseFunctions_base {
223
221
  static readonly layer: Layer.Layer<BrowserbaseFunctions, never, BrowserbaseClient>;
224
222
  }
225
223
  //#endregion
226
- export { Functions_d_exports as t };
224
+ export {};
227
225
  //# sourceMappingURL=Functions.d.mts.map
@@ -1,26 +1,12 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
1
  import { ContextReference, Identifier } from "./References.mjs";
3
2
  import { PlatformError } from "./Errors.mjs";
4
- import { t as BrowserbaseClient } from "./Client-D1_xYM9o.mjs";
3
+ import { t as BrowserbaseClient } from "./Client-BQteUePT.mjs";
5
4
  import { t as resource } from "./Resource-DBksC4zB.mjs";
6
5
  import { ProxyRule } from "./Launch.mjs";
7
- import { n as proxy } from "./Launch-BHcAEq05.mjs";
6
+ import { n as proxy } from "./Launch-m0fxzJ49.mjs";
8
7
  import { n as isContextWriterBusy } from "./ContextWriter-BrQmoXRg.mjs";
9
8
  import { Clock, Context, Effect, Layer, Schema } from "effect";
10
9
  //#region src/Functions.ts
11
- var Functions_exports = /* @__PURE__ */ __exportAll({
12
- BrowserbaseFunctions: () => BrowserbaseFunctions,
13
- FunctionBuild: () => FunctionBuild,
14
- FunctionInvocation: () => FunctionInvocation,
15
- FunctionInvokeRequest: () => FunctionInvokeRequest,
16
- FunctionLogLine: () => FunctionLogLine,
17
- FunctionMetadata: () => FunctionMetadata,
18
- FunctionPageQuery: () => FunctionPageQuery,
19
- FunctionSessionParams: () => FunctionSessionParams,
20
- FunctionStatusQuery: () => FunctionStatusQuery,
21
- FunctionVersion: () => FunctionVersion,
22
- FunctionWaitOptions: () => FunctionWaitOptions
23
- });
24
10
  const Timestamp = Schema.String.check(Schema.isMaxLength(64));
25
11
  const JsonObject = Schema.Record(Schema.String, Schema.Json);
26
12
  const Name = Schema.String.check(Schema.isMaxLength(1024));
@@ -327,6 +313,6 @@ var BrowserbaseFunctions = class BrowserbaseFunctions extends Context.Service()(
327
313
  }));
328
314
  };
329
315
  //#endregion
330
- export { BrowserbaseFunctions, FunctionBuild, FunctionInvocation, FunctionInvokeRequest, FunctionLogLine, FunctionMetadata, FunctionPageQuery, FunctionSessionParams, FunctionStatusQuery, FunctionVersion, FunctionWaitOptions, Functions_exports as t };
316
+ export { BrowserbaseFunctions, FunctionBuild, FunctionInvocation, FunctionInvokeRequest, FunctionLogLine, FunctionMetadata, FunctionPageQuery, FunctionSessionParams, FunctionStatusQuery, FunctionVersion, FunctionWaitOptions };
331
317
 
332
318
  //# sourceMappingURL=Functions.mjs.map