effect-browserbase 0.1.0-beta.102 → 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.
- package/README.md +61 -231
- package/dist/Account.d.mts +4 -6
- package/dist/Account.mjs +4 -9
- package/dist/Account.mjs.map +1 -1
- package/dist/{Acquisition-WBafHwXH.mjs → Acquisition-D8o4jtCg.mjs} +22 -68
- package/dist/Acquisition-D8o4jtCg.mjs.map +1 -0
- package/dist/Agents.d.mts +4 -6
- package/dist/Agents.mjs +3 -19
- package/dist/Agents.mjs.map +1 -1
- package/dist/Allocation.d.mts +9 -11
- package/dist/Allocation.mjs +2 -4
- package/dist/Allocation.mjs.map +1 -1
- package/dist/Browser.d.mts +25 -140
- package/dist/Browser.mjs +266 -1
- package/dist/Browser.mjs.map +1 -0
- package/dist/BrowserBinding.d.mts +7 -34
- package/dist/BrowserBinding.mjs +30 -1
- package/dist/BrowserBinding.mjs.map +1 -0
- package/dist/Certificates.d.mts +3 -5
- package/dist/Certificates.mjs +2 -7
- package/dist/Certificates.mjs.map +1 -1
- package/dist/{Cleanup-G2YpTCuU.d.mts → Cleanup-DMTDBir8.d.mts} +5 -6
- package/dist/Cleanup.d.mts +3 -2
- package/dist/Cleanup.mjs +1 -6
- package/dist/Cleanup.mjs.map +1 -1
- package/dist/{Client-D1_xYM9o.mjs → Client-BQteUePT.mjs} +2 -4
- package/dist/{Client-D1_xYM9o.mjs.map → Client-BQteUePT.mjs.map} +1 -1
- package/dist/Client.d.mts +51 -2
- package/dist/Client.mjs +1 -1
- package/dist/Connection-DcvJZEdc.mjs +65 -0
- package/dist/Connection-DcvJZEdc.mjs.map +1 -0
- package/dist/ContextCoordination.d.mts +5 -6
- package/dist/ContextCoordination.mjs +1 -8
- package/dist/ContextCoordination.mjs.map +1 -1
- package/dist/Contexts.d.mts +4 -6
- package/dist/Contexts.mjs +2 -8
- package/dist/Contexts.mjs.map +1 -1
- package/dist/Downloads.d.mts +6 -8
- package/dist/Downloads.mjs +3 -8
- package/dist/Downloads.mjs.map +1 -1
- package/dist/Errors.d.mts +3 -26
- package/dist/Errors.mjs +1 -137
- package/dist/Errors.mjs.map +1 -1
- package/dist/{Extensions-ClZbYb1H.mjs → Extensions-nMNMPGCc.mjs} +3 -9
- package/dist/{Extensions-ClZbYb1H.mjs.map → Extensions-nMNMPGCc.mjs.map} +1 -1
- package/dist/Extensions.d.mts +4 -6
- package/dist/Extensions.mjs +1 -1
- package/dist/Functions.d.mts +4 -6
- package/dist/Functions.mjs +3 -17
- package/dist/Functions.mjs.map +1 -1
- package/dist/{Launch-BHcAEq05.mjs → Launch-m0fxzJ49.mjs} +5 -5
- package/dist/Launch-m0fxzJ49.mjs.map +1 -0
- package/dist/Launch.d.mts +130 -2
- package/dist/Launch.mjs +4 -11
- package/dist/Launch.mjs.map +1 -1
- package/dist/PageFetch.d.mts +3 -5
- package/dist/PageFetch.mjs +2 -8
- package/dist/PageFetch.mjs.map +1 -1
- package/dist/Projects.d.mts +3 -5
- package/dist/Projects.mjs +2 -8
- package/dist/Projects.mjs.map +1 -1
- package/dist/Recordings.d.mts +6 -8
- package/dist/Recordings.mjs +3 -5
- package/dist/Recordings.mjs.map +1 -1
- package/dist/{References-URDAtapt.d.mts → References-DOH3Wu44.d.mts} +5 -6
- package/dist/References.d.mts +3 -2
- package/dist/References.mjs +10 -18
- package/dist/References.mjs.map +1 -1
- package/dist/Replays.d.mts +6 -8
- package/dist/Replays.mjs +3 -5
- package/dist/Replays.mjs.map +1 -1
- package/dist/Search.d.mts +3 -5
- package/dist/Search.mjs +2 -9
- package/dist/Search.mjs.map +1 -1
- package/dist/{SessionData-DRKcKCqw.d.mts → SessionData-5xYZDshJ.d.mts} +5 -6
- package/dist/SessionData.d.mts +3 -2
- package/dist/SessionData.mjs +1 -8
- package/dist/SessionData.mjs.map +1 -1
- package/dist/{Sessions-CtbseWEh.mjs → Sessions-DoQGg9nB.mjs} +34 -18
- package/dist/Sessions-DoQGg9nB.mjs.map +1 -0
- package/dist/{Sessions-B8E4kMxo.d.mts → Sessions-tFJYaXFq.d.mts} +8 -8
- package/dist/Sessions.d.mts +4 -3
- package/dist/Sessions.mjs +1 -1
- package/dist/{Transfers-Czv5IZzJ.d.mts → Transfers-GVqzrDWl.d.mts} +22 -9
- package/dist/Transfers.d.mts +3 -2
- package/dist/Transfers.mjs +12 -28
- package/dist/Transfers.mjs.map +1 -1
- package/dist/Uploads.d.mts +6 -8
- package/dist/Uploads.mjs +3 -5
- package/dist/Uploads.mjs.map +1 -1
- package/dist/Webhooks.d.mts +3 -5
- package/dist/Webhooks.mjs +2 -11
- package/dist/Webhooks.mjs.map +1 -1
- package/dist/{WriterFacts-osvYAsIx.d.mts → WriterFacts-5CPBGG1P.d.mts} +4 -3
- package/dist/index.d.mts +27 -30
- package/dist/index.mjs +26 -30
- package/package.json +3 -24
- package/dist/Acquisition-WBafHwXH.mjs.map +0 -1
- package/dist/Association-CEps4hYP.mjs +0 -10
- package/dist/Association-CEps4hYP.mjs.map +0 -1
- package/dist/Bootstrap-BXuzZojd.mjs +0 -194
- package/dist/Bootstrap-BXuzZojd.mjs.map +0 -1
- package/dist/Bootstrap-m7lHgj0D.d.mts +0 -177
- package/dist/Bootstrap.d.mts +0 -2
- package/dist/Bootstrap.mjs +0 -2
- package/dist/Browser-joE4Zgys.mjs +0 -1557
- package/dist/Browser-joE4Zgys.mjs.map +0 -1
- package/dist/BrowserBinding-qbQA6JhH.mjs +0 -2452
- package/dist/BrowserBinding-qbQA6JhH.mjs.map +0 -1
- package/dist/BrowserData-LpcAuAub.d.mts +0 -369
- package/dist/BrowserData.d.mts +0 -2
- package/dist/BrowserData.mjs +0 -442
- package/dist/BrowserData.mjs.map +0 -1
- package/dist/Capture-CZJPuD7b.mjs +0 -532
- package/dist/Capture-CZJPuD7b.mjs.map +0 -1
- package/dist/Capture-Dr5MkIJb.d.mts +0 -125
- package/dist/Capture.d.mts +0 -2
- package/dist/Capture.mjs +0 -2
- package/dist/Client-Ca0zSg1n.d.mts +0 -53
- package/dist/Images-DgscEfSf.mjs +0 -127
- package/dist/Images-DgscEfSf.mjs.map +0 -1
- package/dist/Launch-BHcAEq05.mjs.map +0 -1
- package/dist/Launch-C8CfaYxb.d.mts +0 -132
- package/dist/PageControl.d.mts +0 -16
- package/dist/PageControl.mjs +0 -36
- package/dist/PageControl.mjs.map +0 -1
- package/dist/PageControlAssociation-DabEg5AR.mjs +0 -10
- package/dist/PageControlAssociation-DabEg5AR.mjs.map +0 -1
- package/dist/Sessions-CtbseWEh.mjs.map +0 -1
- package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
package/dist/Contexts.d.mts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { n as ContextReference } from "./References-
|
|
1
|
+
import { n as ContextReference } from "./References-DOH3Wu44.mjs";
|
|
2
2
|
import { ContextError } from "./Errors.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { BrowserbaseClient } from "./Client.mjs";
|
|
4
4
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
5
|
-
|
|
6
|
-
export { BrowserbaseContexts, ContextCreation, ContextMetadata };
|
|
7
|
-
}
|
|
5
|
+
//#region src/Contexts.d.ts
|
|
8
6
|
declare const ContextMetadata_base: Schema.Class<ContextMetadata, Schema.Struct<{
|
|
9
7
|
readonly reference: typeof ContextReference;
|
|
10
8
|
readonly createdAt: Schema.String;
|
|
@@ -28,5 +26,5 @@ export declare class BrowserbaseContexts extends BrowserbaseContexts_base {
|
|
|
28
26
|
static readonly layer: Layer.Layer<BrowserbaseContexts, never, BrowserbaseClient>;
|
|
29
27
|
}
|
|
30
28
|
//#endregion
|
|
31
|
-
export {
|
|
29
|
+
export {};
|
|
32
30
|
//# sourceMappingURL=Contexts.d.mts.map
|
package/dist/Contexts.mjs
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
1
|
import { ContextReference, Identifier } from "./References.mjs";
|
|
3
2
|
import { ContextError } from "./Errors.mjs";
|
|
4
|
-
import { t as BrowserbaseClient } from "./Client-
|
|
3
|
+
import { t as BrowserbaseClient } from "./Client-BQteUePT.mjs";
|
|
5
4
|
import { n as isContextWriterBusy } from "./ContextWriter-BrQmoXRg.mjs";
|
|
6
5
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
7
6
|
//#region src/Contexts.ts
|
|
8
|
-
var Contexts_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
-
BrowserbaseContexts: () => BrowserbaseContexts,
|
|
10
|
-
ContextCreation: () => ContextCreation,
|
|
11
|
-
ContextMetadata: () => ContextMetadata
|
|
12
|
-
});
|
|
13
7
|
const Timestamp = Schema.String.check(Schema.isMaxLength(64));
|
|
14
8
|
const ContextName = Schema.NonEmptyString.check(Schema.isMaxLength(1024), Schema.makeFilter((value) => value.trim().length > 0));
|
|
15
9
|
const ProviderContext = Schema.Struct({
|
|
@@ -98,6 +92,6 @@ var BrowserbaseContexts = class BrowserbaseContexts extends Context.Service()("e
|
|
|
98
92
|
}));
|
|
99
93
|
};
|
|
100
94
|
//#endregion
|
|
101
|
-
export { BrowserbaseContexts, ContextCreation, ContextMetadata
|
|
95
|
+
export { BrowserbaseContexts, ContextCreation, ContextMetadata };
|
|
102
96
|
|
|
103
97
|
//# sourceMappingURL=Contexts.mjs.map
|
package/dist/Contexts.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contexts.mjs","names":[],"sources":["../src/Contexts.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport type { ClientError } from \"./Errors.ts\";\nimport { ContextError } from \"./Errors.ts\";\nimport { isContextWriterBusy } from \"./internal/session/ContextWriter.ts\";\nimport { ContextReference, Identifier } from \"./References.ts\";\n\nconst Timestamp = Schema.String.check(Schema.isMaxLength(64));\n\nconst ContextName = Schema.NonEmptyString.check(\n Schema.isMaxLength(1024),\n Schema.makeFilter((value) => value.trim().length > 0),\n);\n\nconst ProviderContext = Schema.Struct({\n id: Identifier,\n projectId: Identifier,\n createdAt: Timestamp,\n updatedAt: Timestamp,\n name: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),\n});\n\nexport class ContextMetadata extends Schema.Class<ContextMetadata>(\"BrowserbaseContextMetadata\")({\n reference: ContextReference,\n createdAt: Timestamp,\n updatedAt: Timestamp,\n name: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),\n}) {}\n\nexport class ContextCreation extends Schema.Class<ContextCreation>(\"BrowserbaseContextCreation\")({\n reference: ContextReference,\n}) {}\n\nconst fromClient = (operation: ContextError[\"operation\"], error: ClientError): ContextError =>\n ContextError.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: ContextError[\"operation\"]) =>\n ContextError.make({ operation, reason: \"configuration\", outcome: \"undispatched\" });\n\nconst malformed = (operation: ContextError[\"operation\"], mutation = false) =>\n ContextError.make({\n operation,\n reason: \"malformed\",\n ...(mutation ? { outcome: \"unknown\" as const } : {}),\n });\n\n/** Context administration is independent of any live browser connection. */\nexport class BrowserbaseContexts extends Context.Service<\n BrowserbaseContexts,\n {\n readonly create: (options?: {\n readonly name?: string;\n }) => Effect.Effect<ContextCreation, ContextError>;\n readonly retrieve: (\n reference: ContextReference,\n ) => Effect.Effect<ContextMetadata, ContextError>;\n readonly delete: (reference: ContextReference) => Effect.Effect<void, ContextError>;\n }\n>()(\"effect-browserbase/Contexts\") {\n static readonly layer: Layer.Layer<BrowserbaseContexts, never, BrowserbaseClient> = Layer.effect(\n BrowserbaseContexts,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n\n const validate = Effect.fnUntraced(function* (\n reference: ContextReference,\n operation: ContextError[\"operation\"],\n ) {\n const ref = yield* Schema.decodeEffect(ContextReference)(reference, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => configuration(operation)));\n\n if (ref.projectId !== client.projectId)\n return yield* ContextError.make({\n operation,\n reason: \"authorization\",\n outcome: \"undispatched\",\n });\n\n return ref;\n });\n\n const create = Effect.fn(\"BrowserbaseContexts.create\")(function* (\n options: { readonly name?: string } = {},\n ) {\n const value = yield* Schema.decodeEffect(\n Schema.Struct({ name: Schema.optionalKey(ContextName) }),\n )(options, { onExcessProperty: \"error\" }).pipe(\n Effect.mapError(() => configuration(\"context-create\")),\n );\n\n const raw = yield* client\n .json(\"POST\", \"/v1/contexts\", {\n projectId: client.projectId,\n ...(value.name === undefined ? {} : { name: value.name.trim() }),\n })\n .pipe(Effect.mapError((error) => fromClient(\"context-create\", error)));\n\n const created = yield* Schema.decodeUnknownEffect(Schema.Struct({ id: Identifier }))(\n raw,\n ).pipe(Effect.mapError(() => malformed(\"context-create\", true)));\n\n return ContextCreation.make({\n reference: ContextReference.make({\n provider: \"browserbase\",\n projectId: client.projectId,\n contextId: created.id,\n }),\n });\n });\n\n const retrieve = Effect.fn(\"BrowserbaseContexts.retrieve\")(function* (\n reference: ContextReference,\n ) {\n const ref = yield* validate(reference, \"context-retrieve\");\n\n const raw = yield* client\n .json(\"GET\", `/v1/contexts/${encodeURIComponent(ref.contextId)}`)\n .pipe(Effect.mapError((error) => fromClient(\"context-retrieve\", error)));\n\n const value = yield* Schema.decodeUnknownEffect(ProviderContext)(raw).pipe(\n Effect.mapError(() => malformed(\"context-retrieve\")),\n );\n\n if (value.id !== ref.contextId || value.projectId !== ref.projectId)\n return yield* malformed(\"context-retrieve\");\n\n return ContextMetadata.make({\n reference: ref,\n createdAt: value.createdAt,\n updatedAt: value.updatedAt,\n ...(value.name === undefined ? {} : { name: value.name }),\n });\n });\n\n const remove = Effect.fn(\"BrowserbaseContexts.delete\")(function* (\n reference: ContextReference,\n ) {\n const ref = yield* validate(reference, \"context-delete\");\n\n if (isContextWriterBusy(ref))\n return yield* ContextError.make({\n operation: \"context-delete\",\n reason: \"active\",\n outcome: \"undispatched\",\n });\n yield* client\n .noContent(\"DELETE\", `/v1/contexts/${encodeURIComponent(ref.contextId)}`)\n .pipe(Effect.mapError((error) => fromClient(\"context-delete\", error)));\n });\n\n return BrowserbaseContexts.of({ create, retrieve, delete: remove });\n }),\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Contexts.mjs","names":[],"sources":["../src/Contexts.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport type { ClientError } from \"./Errors.ts\";\nimport { ContextError } from \"./Errors.ts\";\nimport { isContextWriterBusy } from \"./internal/session/ContextWriter.ts\";\nimport { ContextReference, Identifier } from \"./References.ts\";\n\nconst Timestamp = Schema.String.check(Schema.isMaxLength(64));\n\nconst ContextName = Schema.NonEmptyString.check(\n Schema.isMaxLength(1024),\n Schema.makeFilter((value) => value.trim().length > 0),\n);\n\nconst ProviderContext = Schema.Struct({\n id: Identifier,\n projectId: Identifier,\n createdAt: Timestamp,\n updatedAt: Timestamp,\n name: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),\n});\n\nexport class ContextMetadata extends Schema.Class<ContextMetadata>(\"BrowserbaseContextMetadata\")({\n reference: ContextReference,\n createdAt: Timestamp,\n updatedAt: Timestamp,\n name: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),\n}) {}\n\nexport class ContextCreation extends Schema.Class<ContextCreation>(\"BrowserbaseContextCreation\")({\n reference: ContextReference,\n}) {}\n\nconst fromClient = (operation: ContextError[\"operation\"], error: ClientError): ContextError =>\n ContextError.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: ContextError[\"operation\"]) =>\n ContextError.make({ operation, reason: \"configuration\", outcome: \"undispatched\" });\n\nconst malformed = (operation: ContextError[\"operation\"], mutation = false) =>\n ContextError.make({\n operation,\n reason: \"malformed\",\n ...(mutation ? { outcome: \"unknown\" as const } : {}),\n });\n\n/** Context administration is independent of any live browser connection. */\nexport class BrowserbaseContexts extends Context.Service<\n BrowserbaseContexts,\n {\n readonly create: (options?: {\n readonly name?: string;\n }) => Effect.Effect<ContextCreation, ContextError>;\n readonly retrieve: (\n reference: ContextReference,\n ) => Effect.Effect<ContextMetadata, ContextError>;\n readonly delete: (reference: ContextReference) => Effect.Effect<void, ContextError>;\n }\n>()(\"effect-browserbase/Contexts\") {\n static readonly layer: Layer.Layer<BrowserbaseContexts, never, BrowserbaseClient> = Layer.effect(\n BrowserbaseContexts,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n\n const validate = Effect.fnUntraced(function* (\n reference: ContextReference,\n operation: ContextError[\"operation\"],\n ) {\n const ref = yield* Schema.decodeEffect(ContextReference)(reference, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => configuration(operation)));\n\n if (ref.projectId !== client.projectId)\n return yield* ContextError.make({\n operation,\n reason: \"authorization\",\n outcome: \"undispatched\",\n });\n\n return ref;\n });\n\n const create = Effect.fn(\"BrowserbaseContexts.create\")(function* (\n options: { readonly name?: string } = {},\n ) {\n const value = yield* Schema.decodeEffect(\n Schema.Struct({ name: Schema.optionalKey(ContextName) }),\n )(options, { onExcessProperty: \"error\" }).pipe(\n Effect.mapError(() => configuration(\"context-create\")),\n );\n\n const raw = yield* client\n .json(\"POST\", \"/v1/contexts\", {\n projectId: client.projectId,\n ...(value.name === undefined ? {} : { name: value.name.trim() }),\n })\n .pipe(Effect.mapError((error) => fromClient(\"context-create\", error)));\n\n const created = yield* Schema.decodeUnknownEffect(Schema.Struct({ id: Identifier }))(\n raw,\n ).pipe(Effect.mapError(() => malformed(\"context-create\", true)));\n\n return ContextCreation.make({\n reference: ContextReference.make({\n provider: \"browserbase\",\n projectId: client.projectId,\n contextId: created.id,\n }),\n });\n });\n\n const retrieve = Effect.fn(\"BrowserbaseContexts.retrieve\")(function* (\n reference: ContextReference,\n ) {\n const ref = yield* validate(reference, \"context-retrieve\");\n\n const raw = yield* client\n .json(\"GET\", `/v1/contexts/${encodeURIComponent(ref.contextId)}`)\n .pipe(Effect.mapError((error) => fromClient(\"context-retrieve\", error)));\n\n const value = yield* Schema.decodeUnknownEffect(ProviderContext)(raw).pipe(\n Effect.mapError(() => malformed(\"context-retrieve\")),\n );\n\n if (value.id !== ref.contextId || value.projectId !== ref.projectId)\n return yield* malformed(\"context-retrieve\");\n\n return ContextMetadata.make({\n reference: ref,\n createdAt: value.createdAt,\n updatedAt: value.updatedAt,\n ...(value.name === undefined ? {} : { name: value.name }),\n });\n });\n\n const remove = Effect.fn(\"BrowserbaseContexts.delete\")(function* (\n reference: ContextReference,\n ) {\n const ref = yield* validate(reference, \"context-delete\");\n\n if (isContextWriterBusy(ref))\n return yield* ContextError.make({\n operation: \"context-delete\",\n reason: \"active\",\n outcome: \"undispatched\",\n });\n yield* client\n .noContent(\"DELETE\", `/v1/contexts/${encodeURIComponent(ref.contextId)}`)\n .pipe(Effect.mapError((error) => fromClient(\"context-delete\", error)));\n });\n\n return BrowserbaseContexts.of({ create, retrieve, delete: remove });\n }),\n );\n}\n"],"mappings":";;;;;;AAQA,MAAM,YAAY,OAAO,OAAO,MAAM,OAAO,YAAY,EAAE,CAAC;AAE5D,MAAM,cAAc,OAAO,eAAe,MACxC,OAAO,YAAY,IAAI,GACvB,OAAO,YAAY,UAAU,MAAM,KAAK,CAAC,CAAC,SAAS,CAAC,CACtD;AAEA,MAAM,kBAAkB,OAAO,OAAO;CACpC,IAAI;CACJ,WAAW;CACX,WAAW;CACX,WAAW;CACX,MAAM,OAAO,YAAY,OAAO,OAAO,MAAM,OAAO,YAAY,IAAI,CAAC,CAAC;AACxE,CAAC;AAED,IAA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ACrD;GAEA,IAAI,MAAM,OAAO,IAAI,aAAa,MAAM,cAAc,IAAI,WACxD,OAAO,OAAO,UAAU,kBAAkB;GAE5C,OAAO,gBAAgB,KAAK;IAC1B,WAAW;IACX,WAAW,MAAM;IACjB,WAAW,MAAM;IACjB,GAAI,MAAM,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,MAAM,KAAK;GACzD,CAAC;EACH,CAAC;EAED,MAAM,SAAS,OAAO,GAAG,4BAA4B,CAAC,CAAC,WACrD,WACA;GACA,MAAM,MAAM,OAAO,SAAS,WAAW,gBAAgB;GAEvD,IAAI,oBAAoB,GAAG,GACzB,OAAO,OAAO,aAAa,KAAK;IAC9B,WAAW;IACX,QAAQ;IACR,SAAS;GACX,CAAC;GACH,OAAO,OACJ,UAAU,UAAU,gBAAgB,mBAAmB,IAAI,SAAS,GAAG,CAAC,CACxE,KAAK,OAAO,UAAU,UAAU,WAAW,kBAAkB,KAAK,CAAC,CAAC;EACzE,CAAC;EAED,OAAO,oBAAoB,GAAG;GAAE;GAAQ;GAAU,QAAQ;EAAO,CAAC;CACpE,CAAC,CACH;AACF"}
|
package/dist/Downloads.d.mts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SessionReference } from "./References-DOH3Wu44.mjs";
|
|
2
2
|
import { FileError } from "./Errors.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { t as BrowserbaseSessions } from "./Sessions-
|
|
5
|
-
import { n as DownloadMetadata, t as ArtifactTransferPolicy } from "./Transfers-
|
|
3
|
+
import { BrowserbaseClient } from "./Client.mjs";
|
|
4
|
+
import { t as BrowserbaseSessions } from "./Sessions-tFJYaXFq.mjs";
|
|
5
|
+
import { n as DownloadMetadata, t as ArtifactTransferPolicy } from "./Transfers-GVqzrDWl.mjs";
|
|
6
6
|
import { Context, Effect, Layer, Schema, Stream } from "effect";
|
|
7
|
-
|
|
8
|
-
export { BrowserbaseDownloads, DownloadListing, DownloadPolicy, DownloadQuery };
|
|
9
|
-
}
|
|
7
|
+
//#region src/Downloads.d.ts
|
|
10
8
|
export interface DownloadPolicy extends ArtifactTransferPolicy {
|
|
11
9
|
readonly mimeTypes: ReadonlyArray<string>;
|
|
12
10
|
}
|
|
@@ -40,5 +38,5 @@ export declare class BrowserbaseDownloads extends BrowserbaseDownloads_base {
|
|
|
40
38
|
static readonly layer: Layer.Layer<BrowserbaseDownloads, never, BrowserbaseClient | BrowserbaseSessions>;
|
|
41
39
|
}
|
|
42
40
|
//#endregion
|
|
43
|
-
export {
|
|
41
|
+
export {};
|
|
44
42
|
//# sourceMappingURL=Downloads.d.mts.map
|
package/dist/Downloads.mjs
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
1
|
import { Identifier } from "./References.mjs";
|
|
3
2
|
import { FileError } from "./Errors.mjs";
|
|
4
3
|
import { DownloadMetadata } from "./Transfers.mjs";
|
|
5
|
-
import { t as BrowserbaseClient } from "./Client-
|
|
4
|
+
import { t as BrowserbaseClient } from "./Client-BQteUePT.mjs";
|
|
6
5
|
import { t as downloadTransferPolicy } from "./TransferPolicy-DQ06i7SZ.mjs";
|
|
7
6
|
import { n as nowMillis, r as until, t as deadlineAfter } from "./Deadline-CrViaogr.mjs";
|
|
8
|
-
import { t as BrowserbaseSessions } from "./Sessions-
|
|
7
|
+
import { t as BrowserbaseSessions } from "./Sessions-DoQGg9nB.mjs";
|
|
9
8
|
import { Context, Effect, Layer, Schema, Stream } from "effect";
|
|
10
9
|
//#region src/Downloads.ts
|
|
11
|
-
var Downloads_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
-
BrowserbaseDownloads: () => BrowserbaseDownloads,
|
|
13
|
-
DownloadQuery: () => DownloadQuery
|
|
14
|
-
});
|
|
15
10
|
const Timestamp = Schema.String.check(Schema.isMaxLength(64));
|
|
16
11
|
/** Provider-side filters over one session's files; every bound is optional. */
|
|
17
12
|
const DownloadQuery = Schema.Struct({
|
|
@@ -137,6 +132,6 @@ var BrowserbaseDownloads = class BrowserbaseDownloads extends Context.Service()(
|
|
|
137
132
|
}));
|
|
138
133
|
};
|
|
139
134
|
//#endregion
|
|
140
|
-
export { BrowserbaseDownloads, DownloadQuery
|
|
135
|
+
export { BrowserbaseDownloads, DownloadQuery };
|
|
141
136
|
|
|
142
137
|
//# sourceMappingURL=Downloads.mjs.map
|
package/dist/Downloads.mjs.map
CHANGED
|
@@ -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, 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;AAC7C,CAAC;AAID,MAAM,UAAU,OAAO,OAAO;CAC5B,WAAW,OAAO,MAAM,gBAAg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O,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"}
|
|
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;AAC7C,CAAC;AAID,MAAM,UAAU,OAAO,OAAO;CAC5B,WAAW,OAAO,MAAM,gBAAgB,CAAC,CAAC,MAAM,OAAO,YAAY,GAAG,CAAC;CACvE,OAAO,OAAO;AAChB,CAAC;AAED,MAAM,WAAW,WAAmC,WAClD,UAAU,KAAK;CAAE;CAAW;AAAO,CAAC;AAEtC,MAAM,cAAc,eAAuC,UACzD,UAAU,KAAK;CACb;CACA,QAAQ,MAAM;CACd,GAAI,MAAM,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,MAAM,QAAQ;CAChE,GAAI,MAAM,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,MAAM,OAAO;CAC7D,GAAI,MAAM,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,kBAAkB,MAAM,iBAAiB;AAC7F,CAAC;AAEH,MAAM,UACJ,QACA,UACA,cACG,MAAM,QAAQ,gBAAgB,QAAQ,WAAW,SAAS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;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 {
|
|
1
|
+
import { a as SessionReference, t as AllocationAttempt } from "./References-DOH3Wu44.mjs";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
|
-
|
|
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 {
|
|
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,
|
|
191
|
+
export { AllocationError, ArtifactError, CertificateError, ClientError, ContextError, ExtensionError, FileError, PlatformError, ProjectError, SessionError };
|
|
328
192
|
|
|
329
193
|
//# sourceMappingURL=Errors.mjs.map
|
package/dist/Errors.mjs.map
CHANGED
|
@@ -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;C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ACF,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,CAAC,CAAC,kBAAkB;CACzF,GAAG,cAAc;EACf;EACA;EACA;EACA;CACF,CAAC;CACD,QAAQ,OAAO,SAAS,CAAC,GAAG,cAAc,UAAU,iBAAiB,CAAC;AACxE,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,eAAb,cAAkC,OAAO,YAA0B,CAAC,CAClE,gBACA,cAAc;CAAC;CAAgB;CAAoB;AAAe,CAAC,CACrE,CAAC,CAAC,CAAC;;AAGH,IAAa,mBAAb,cAAsC,OA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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-
|
|
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 {
|
|
229
|
+
export { ExtensionMetadata as n, ExtensionRegistration as r, BrowserbaseExtensions as t };
|
|
236
230
|
|
|
237
|
-
//# sourceMappingURL=Extensions-
|
|
231
|
+
//# sourceMappingURL=Extensions-nMNMPGCc.mjs.map
|