@effect-agent/platform-cloudflare 0.1.0-beta.26 → 0.1.0-beta.28

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/package.json CHANGED
@@ -1,18 +1,22 @@
1
1
  {
2
2
  "name": "@effect-agent/platform-cloudflare",
3
- "version": "0.1.0-beta.26",
3
+ "version": "0.1.0-beta.28",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.mts",
7
7
  "default": "./dist/index.mjs"
8
+ },
9
+ "./browser-quick-action": {
10
+ "types": "./dist/browser-quick-action.d.mts",
11
+ "default": "./dist/browser-quick-action.mjs"
8
12
  }
9
13
  },
10
14
  "dependencies": {
11
- "@effect-agent/core": "0.1.0-beta.26",
12
- "@effect-agent/engine": "0.1.0-beta.26",
13
- "@effect-agent/sandbox": "0.1.0-beta.26",
14
- "@effect-agent/session": "0.1.0-beta.26",
15
- "@effect-agent/storage-cloudflare": "0.1.0-beta.26",
15
+ "@effect-agent/core": "0.1.0-beta.28",
16
+ "@effect-agent/engine": "0.1.0-beta.28",
17
+ "@effect-agent/sandbox": "0.1.0-beta.28",
18
+ "@effect-agent/session": "0.1.0-beta.28",
19
+ "@effect-agent/storage-cloudflare": "0.1.0-beta.28",
16
20
  "@effect/platform-browser": "4.0.0-rc.110",
17
21
  "@effect/sql-sqlite-do": "4.0.0-rc.110",
18
22
  "effect": "4.0.0-rc.110"
@@ -43,8 +47,8 @@
43
47
  "devDependencies": {
44
48
  "@cloudflare/vitest-pool-workers": "0.21.3",
45
49
  "@cloudflare/workers-types": "5.20260813.1",
46
- "@effect-agent/capabilities": "0.1.0-beta.23",
47
- "@effect-agent/testing": "0.1.0-beta.23",
50
+ "@effect-agent/capabilities": "0.1.0-beta.24",
51
+ "@effect-agent/testing": "0.1.0-beta.24",
48
52
  "@effect/vitest": "4.0.0-rc.110",
49
53
  "effect-cf": "0.27.0",
50
54
  "esbuild": "0.28.1",
@@ -0,0 +1,514 @@
1
+ /// <reference types="@cloudflare/workers-types" />
2
+
3
+ import {
4
+ PageCapture,
5
+ PageCaptureInferenceUse,
6
+ PageCaptureInferencePolicyError,
7
+ PageCaptureNavigationError,
8
+ PageCaptureOutputLimitError,
9
+ PageCaptureProtocolError,
10
+ PageCaptureRateLimitedError,
11
+ PageCaptureResourceUse,
12
+ PageCaptureResult,
13
+ PageCaptureUnsupportedError,
14
+ PageContentCaptured,
15
+ PageLinksCaptured,
16
+ PageMarkdownCaptured,
17
+ PageStructuredCaptured,
18
+ SandboxImplementation,
19
+ type PageCaptureAction,
20
+ type PageCaptureCapture,
21
+ type PageCaptureError,
22
+ type PageCaptureOutput,
23
+ type PageCaptureRequest,
24
+ } from "@effect-agent/sandbox";
25
+ import { Context, Effect, Layer, Option, Schema } from "effect";
26
+
27
+ /**
28
+ * The Cloudflare Browser Run Quick Action `PageCapture` adapter (capability
29
+ * spec §9.2). Each capture is one stateless `quickAction()` RPC on the
30
+ * Wrangler `browser` binding: the platform renders the target in a managed
31
+ * headless browser and returns one bounded output; the adapter holds no
32
+ * session and no state between passes. The binding requires a Worker
33
+ * compatibility date of `2026-03-24` or later, and local `wrangler dev` needs
34
+ * remote mode (`"remote": true` on the binding) because `quickAction` has no
35
+ * local implementation.
36
+ *
37
+ * Rendered output is untrusted, attacker-influenced content; this adapter
38
+ * only bounds and types it. Deployment class `E` only: no durability claim.
39
+ */
40
+ export const browserQuickActionImplementation = SandboxImplementation.make({
41
+ isolation: "isolated",
42
+ identity: "cloudflare-browser-quick-action",
43
+ });
44
+
45
+ /**
46
+ * Effect-native client captured by the binding service. Its option types come
47
+ * directly from the pinned Workers declarations rather than a local copy.
48
+ */
49
+ export interface BrowserQuickActionClient {
50
+ readonly content: (
51
+ options: BrowserRunContentOptions,
52
+ ) => Effect.Effect<Response, BrowserQuickActionRpcError>;
53
+ readonly markdown: (
54
+ options: BrowserRunMarkdownOptions,
55
+ ) => Effect.Effect<Response, BrowserQuickActionRpcError>;
56
+ readonly links: (
57
+ options: BrowserRunLinksOptions,
58
+ ) => Effect.Effect<Response, BrowserQuickActionRpcError>;
59
+ readonly json: (
60
+ options: BrowserRunJsonOptions,
61
+ ) => Effect.Effect<Response, BrowserQuickActionRpcError>;
62
+ }
63
+
64
+ /** A native binding RPC rejected before it returned an HTTP response. */
65
+ export class BrowserQuickActionRpcError extends Schema.TaggedError<BrowserQuickActionRpcError>()(
66
+ "BrowserQuickActionRpcError",
67
+ {
68
+ action: Schema.Literals(["content", "markdown", "links", "json"]),
69
+ cause: Schema.Defect(),
70
+ },
71
+ ) {}
72
+
73
+ export interface BrowserQuickActionCaptureOptions {
74
+ /** The resolved Wrangler `browser` binding (DEPLOY-014: supplied, never ambient). */
75
+ readonly browser: BrowserRun;
76
+ }
77
+
78
+ /** Host-owned browser binding authority, supplied explicitly at the composition root. */
79
+ export class BrowserQuickActionBrowserBinding extends Context.Service<
80
+ BrowserQuickActionBrowserBinding,
81
+ BrowserQuickActionClient
82
+ >()("@effect-agent/platform-cloudflare/BrowserQuickActionBrowserBinding") {
83
+ static layer(
84
+ options: BrowserQuickActionCaptureOptions,
85
+ ): Layer.Layer<BrowserQuickActionBrowserBinding> {
86
+ const browser = options.browser;
87
+ const invoke = Effect.fn("BrowserQuickActionBrowserBinding.invoke")(function* (
88
+ action: "content" | "markdown" | "links" | "json",
89
+ evaluate: () => Promise<Response>,
90
+ ): Effect.fn.Return<Response, BrowserQuickActionRpcError> {
91
+ return yield* Effect.tryPromise({
92
+ try: evaluate,
93
+ catch: (cause) => BrowserQuickActionRpcError.make({ action, cause }),
94
+ });
95
+ });
96
+ return Layer.succeed(BrowserQuickActionBrowserBinding)({
97
+ content: (request) => invoke("content", () => browser.quickAction("content", request)),
98
+ markdown: (request) => invoke("markdown", () => browser.quickAction("markdown", request)),
99
+ links: (request) => invoke("links", () => browser.quickAction("links", request)),
100
+ json: (request) => invoke("json", () => browser.quickAction("json", request)),
101
+ });
102
+ }
103
+ }
104
+
105
+ /** Host-owned authorization and accounting for one Workers AI extraction. */
106
+ export interface BrowserQuickActionWorkersAiPolicy {
107
+ readonly authorizeAndAccount: (
108
+ request: PageCaptureRequest,
109
+ ) => Effect.Effect<void, BrowserQuickActionWorkersAiPolicyError>;
110
+ }
111
+
112
+ /** Host-only diagnostic for a denied or unaccounted Workers AI extraction. */
113
+ export class BrowserQuickActionWorkersAiPolicyError extends Schema.TaggedError<BrowserQuickActionWorkersAiPolicyError>()(
114
+ "BrowserQuickActionWorkersAiPolicyError",
115
+ {
116
+ reason: Schema.Literals(["authorization", "accounting"]),
117
+ message: Schema.String.check(Schema.isMaxLength(8_000)),
118
+ cause: Schema.optionalKey(Schema.Defect()),
119
+ },
120
+ ) {}
121
+
122
+ /** Explicit host-owned authority and accounting for separately billed Workers AI extraction. */
123
+ export class BrowserQuickActionWorkersAi extends Context.Service<
124
+ BrowserQuickActionWorkersAi,
125
+ BrowserQuickActionWorkersAiPolicy
126
+ >()("@effect-agent/platform-cloudflare/BrowserQuickActionWorkersAi") {
127
+ static layer(
128
+ policy: BrowserQuickActionWorkersAiPolicy,
129
+ ): Layer.Layer<BrowserQuickActionWorkersAi> {
130
+ return Layer.succeed(BrowserQuickActionWorkersAi)(policy);
131
+ }
132
+ }
133
+
134
+ const MAX_DIAGNOSTIC_LENGTH = 8_000;
135
+ const boundedDiagnostic = (message: string): string => message.slice(0, MAX_DIAGNOSTIC_LENGTH);
136
+
137
+ const QuickActionSuccessEnvelope = Schema.Struct({
138
+ success: Schema.Literal(true),
139
+ result: Schema.Json,
140
+ });
141
+
142
+ const QuickActionErrorEnvelope = Schema.Struct({
143
+ success: Schema.Literal(false),
144
+ errors: Schema.Array(
145
+ Schema.Struct({
146
+ message: Schema.String,
147
+ code: Schema.optionalKey(Schema.Number),
148
+ detail: Schema.optionalKey(Schema.String),
149
+ path: Schema.optionalKey(Schema.String),
150
+ }),
151
+ ),
152
+ rawAiResponse: Schema.optionalKey(Schema.String),
153
+ });
154
+
155
+ const QuickActionEnvelope = Schema.Union([QuickActionSuccessEnvelope, QuickActionErrorEnvelope]);
156
+ const decodeEnvelope = Schema.decodeUnknownOption(Schema.fromJsonString(QuickActionEnvelope));
157
+
158
+ /** Project the schema-validated request onto Cloudflare's native common options. */
159
+ const quickActionCommonOptions = (request: PageCaptureRequest): BrowserRunCommonOptions => {
160
+ const options: BrowserRunBaseOptions = {};
161
+ const navigation = request.navigation;
162
+ if (navigation !== undefined) {
163
+ const goto: NonNullable<BrowserRunBaseOptions["gotoOptions"]> = {};
164
+ if (navigation.waitUntil !== undefined) goto.waitUntil = navigation.waitUntil;
165
+ if (navigation.timeoutMillis !== undefined) goto.timeout = navigation.timeoutMillis;
166
+ if (Object.keys(goto).length > 0) options.gotoOptions = goto;
167
+ if (navigation.waitForSelector !== undefined) {
168
+ options.waitForSelector = {
169
+ selector: navigation.waitForSelector.selector,
170
+ ...(navigation.waitForSelector.timeoutMillis === undefined
171
+ ? {}
172
+ : { timeout: navigation.waitForSelector.timeoutMillis }),
173
+ };
174
+ }
175
+ }
176
+ if (request.viewport !== undefined) {
177
+ options.viewport = { width: request.viewport.width, height: request.viewport.height };
178
+ }
179
+ if (request.resourcePolicy !== undefined) {
180
+ if (request.resourcePolicy.rejectResourceTypes !== undefined) {
181
+ options.rejectResourceTypes = [...request.resourcePolicy.rejectResourceTypes];
182
+ }
183
+ if (request.resourcePolicy.allowRequestPatterns !== undefined) {
184
+ options.allowRequestPattern = [...request.resourcePolicy.allowRequestPatterns];
185
+ }
186
+ }
187
+ return request.target._tag === "PageUrlTarget"
188
+ ? { ...options, url: request.target.url }
189
+ : { ...options, html: request.target.html };
190
+ };
191
+
192
+ /** Dispatch through Cloudflare's native action-specific overloads. */
193
+ const executeQuickAction = (
194
+ browser: BrowserQuickActionClient,
195
+ request: PageCaptureRequest,
196
+ ): Effect.Effect<Response, BrowserQuickActionRpcError> => {
197
+ const options = quickActionCommonOptions(request);
198
+ switch (request.action._tag) {
199
+ case "CapturePageContent": {
200
+ return browser.content(options);
201
+ }
202
+ case "CapturePageMarkdown": {
203
+ return browser.markdown(options);
204
+ }
205
+ case "CapturePageLinks": {
206
+ return browser.links({
207
+ ...options,
208
+ ...(request.action.visibleLinksOnly === undefined
209
+ ? {}
210
+ : { visibleLinksOnly: request.action.visibleLinksOnly }),
211
+ });
212
+ }
213
+ case "CapturePageStructured": {
214
+ return browser.json({
215
+ ...options,
216
+ response_format: {
217
+ type: "json_schema",
218
+ json_schema: request.action.responseFormat,
219
+ },
220
+ ...(request.action.prompt === undefined ? {} : { prompt: request.action.prompt }),
221
+ });
222
+ }
223
+ }
224
+ };
225
+
226
+ const protocolError = (message: string, cause?: unknown): PageCaptureProtocolError =>
227
+ PageCaptureProtocolError.make({
228
+ implementation: browserQuickActionImplementation,
229
+ message: boundedDiagnostic(message),
230
+ ...(cause === undefined ? {} : { cause }),
231
+ });
232
+
233
+ const navigationError = (message: string, cause?: unknown): PageCaptureNavigationError =>
234
+ PageCaptureNavigationError.make({
235
+ implementation: browserQuickActionImplementation,
236
+ message: boundedDiagnostic(message),
237
+ ...(cause === undefined ? {} : { cause }),
238
+ });
239
+
240
+ /** Preserve bounded remote diagnostics for the host without exposing their text to a model. */
241
+ const privateResponseCause = (bodyText: string): Error | undefined =>
242
+ bodyText.length === 0 ? undefined : new Error(boundedDiagnostic(bodyText));
243
+
244
+ const releaseResponseReader = (
245
+ reader: ReadableStreamDefaultReader<Uint8Array>,
246
+ ): Effect.Effect<void> =>
247
+ Effect.tryPromise({
248
+ try: () => reader.cancel(),
249
+ catch: (cause) => protocolError("Canceling the Quick Action response failed", cause),
250
+ }).pipe(
251
+ Effect.catch((error) => Effect.logWarning(error.message)),
252
+ Effect.ensuring(
253
+ Effect.try({
254
+ try: () => reader.releaseLock(),
255
+ catch: (cause) => protocolError("Releasing the Quick Action response failed", cause),
256
+ }).pipe(Effect.catch((error) => Effect.logWarning(error.message))),
257
+ ),
258
+ );
259
+
260
+ const readBoundedResponse = Effect.fn("BrowserQuickActionCapture.readResponse")(function* (
261
+ response: Response,
262
+ request: PageCaptureRequest,
263
+ ) {
264
+ const body = response.body;
265
+ if (body === null) return "";
266
+
267
+ const reader = yield* Effect.acquireRelease(
268
+ Effect.try({
269
+ try: () => body.getReader(),
270
+ catch: (cause) => protocolError("Opening the Quick Action response failed", cause),
271
+ }),
272
+ releaseResponseReader,
273
+ );
274
+ const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: false });
275
+ let observedBytes = 0;
276
+ let bodyText = "";
277
+
278
+ while (true) {
279
+ const chunk = yield* Effect.tryPromise({
280
+ try: () => reader.read(),
281
+ catch: (cause) => protocolError("Reading the Quick Action response failed", cause),
282
+ });
283
+ if (chunk.done) break;
284
+
285
+ observedBytes += chunk.value.byteLength;
286
+ if (observedBytes > request.limits.maxOutputBytes) {
287
+ return yield* PageCaptureOutputLimitError.make({
288
+ implementation: browserQuickActionImplementation,
289
+ limit: request.limits.maxOutputBytes,
290
+ observed: observedBytes,
291
+ });
292
+ }
293
+
294
+ bodyText += yield* Effect.try({
295
+ try: () => decoder.decode(chunk.value, { stream: true }),
296
+ catch: (cause) => protocolError("Decoding the Quick Action response failed", cause),
297
+ });
298
+ }
299
+
300
+ return (
301
+ bodyText +
302
+ (yield* Effect.try({
303
+ try: () => decoder.decode(),
304
+ catch: (cause) => protocolError("Decoding the Quick Action response failed", cause),
305
+ }))
306
+ );
307
+ }, Effect.scoped);
308
+
309
+ /**
310
+ * Retry-After arrives in whole seconds; a non-integer form (an HTTP date) is
311
+ * dropped rather than guessed at.
312
+ */
313
+ const retryAfterMillis = (response: Response): number | undefined => {
314
+ const header = response.headers.get("Retry-After");
315
+ if (header === null) return undefined;
316
+ const seconds = Number(header);
317
+ if (!Number.isSafeInteger(seconds) || seconds < 0) return undefined;
318
+ const millis = seconds * 1_000;
319
+ return Number.isSafeInteger(millis) ? millis : undefined;
320
+ };
321
+
322
+ const browserMillis = (response: Response): number | undefined => {
323
+ const header = response.headers.get("X-Browser-Ms-Used");
324
+ if (header === null) return undefined;
325
+ const millis = Number(header);
326
+ return Number.isSafeInteger(millis) && millis >= 0 ? millis : undefined;
327
+ };
328
+
329
+ /** Only trusted response metadata chooses transport framing; page text never does. */
330
+ const isJsonResponse = (response: Response): boolean => {
331
+ const contentType = response.headers.get("Content-Type");
332
+ if (contentType === null) return false;
333
+ const mediaType = contentType.split(";", 1)[0]?.trim().toLowerCase();
334
+ return mediaType === "application/json" || mediaType?.endsWith("+json") === true;
335
+ };
336
+
337
+ const parseOutput = (
338
+ action: PageCaptureAction,
339
+ bodyText: string,
340
+ response: Response,
341
+ ): PageCaptureOutput | PageCaptureNavigationError | PageCaptureProtocolError => {
342
+ if (!isJsonResponse(response)) {
343
+ return protocolError(
344
+ "The Quick Action success response was not a JSON response envelope",
345
+ privateResponseCause(bodyText),
346
+ );
347
+ }
348
+ const envelope = decodeEnvelope(bodyText);
349
+ if (Option.isNone(envelope)) {
350
+ return protocolError(
351
+ "The JSON Quick Action response did not carry a valid response envelope",
352
+ privateResponseCause(bodyText),
353
+ );
354
+ }
355
+ if (!envelope.value.success) {
356
+ return navigationError(
357
+ "The Quick Action reported a navigation failure",
358
+ privateResponseCause(bodyText),
359
+ );
360
+ }
361
+ switch (action._tag) {
362
+ case "CapturePageContent":
363
+ case "CapturePageMarkdown": {
364
+ if (typeof envelope.value.result !== "string") {
365
+ return protocolError("The Quick Action envelope carried a non-text result");
366
+ }
367
+ return action._tag === "CapturePageContent"
368
+ ? PageContentCaptured.make({ html: envelope.value.result })
369
+ : PageMarkdownCaptured.make({ markdown: envelope.value.result });
370
+ }
371
+ case "CapturePageLinks": {
372
+ const decoded = Schema.decodeUnknownOption(PageLinksCaptured)({
373
+ _tag: "PageLinksCaptured",
374
+ links: envelope.value.result,
375
+ });
376
+ if (Option.isNone(decoded)) {
377
+ return protocolError("The links Quick Action did not return a bounded array of valid URLs");
378
+ }
379
+ return decoded.value;
380
+ }
381
+ case "CapturePageStructured": {
382
+ return PageStructuredCaptured.make({ value: envelope.value.result });
383
+ }
384
+ }
385
+ };
386
+
387
+ const isQuotaMessage = (text: string): boolean => /time limit|daily|quota/i.test(text);
388
+
389
+ const makeCapture = (
390
+ browser: BrowserQuickActionClient,
391
+ workersAi?: BrowserQuickActionWorkersAiPolicy,
392
+ ): PageCaptureCapture =>
393
+ Effect.fn("BrowserQuickActionCapture.capture")(function* (
394
+ request: PageCaptureRequest,
395
+ ): Effect.fn.Return<PageCaptureResult, PageCaptureError> {
396
+ if (request.engine !== "chromium") {
397
+ return yield* PageCaptureUnsupportedError.make({
398
+ implementation: browserQuickActionImplementation,
399
+ feature: "engine",
400
+ message:
401
+ "The browser binding's quickAction() exposes no engine selector; kitesurf requires the REST or CDP surface",
402
+ });
403
+ }
404
+
405
+ const usesWorkersAi = request.action._tag === "CapturePageStructured";
406
+ if (usesWorkersAi) {
407
+ if (workersAi === undefined) {
408
+ return yield* PageCaptureUnsupportedError.make({
409
+ implementation: browserQuickActionImplementation,
410
+ feature: "action",
411
+ message:
412
+ "Structured capture invokes separately billed Workers AI and requires an explicit authorization and accounting policy",
413
+ });
414
+ }
415
+ yield* workersAi.authorizeAndAccount(request).pipe(
416
+ Effect.mapError((cause) =>
417
+ PageCaptureInferencePolicyError.make({
418
+ implementation: browserQuickActionImplementation,
419
+ provider: "cloudflare-workers-ai",
420
+ reason: cause.reason,
421
+ message:
422
+ cause.reason === "authorization"
423
+ ? "Workers AI extraction was not authorized"
424
+ : "Workers AI extraction could not be accounted for",
425
+ cause,
426
+ }),
427
+ ),
428
+ );
429
+ }
430
+
431
+ const response = yield* executeQuickAction(browser, request).pipe(
432
+ Effect.mapError((error) =>
433
+ protocolError("The browser binding rejected the Quick Action", error.cause),
434
+ ),
435
+ );
436
+ const bodyText = yield* readBoundedResponse(response, request);
437
+ if (response.status === 429) {
438
+ const retryAfter = retryAfterMillis(response);
439
+ const reason = isQuotaMessage(bodyText) ? "quota" : "rate";
440
+ const cause = privateResponseCause(bodyText);
441
+ return yield* PageCaptureRateLimitedError.make({
442
+ implementation: browserQuickActionImplementation,
443
+ reason,
444
+ ...(retryAfter === undefined ? {} : { retryAfterMillis: retryAfter }),
445
+ ...(cause === undefined ? {} : { cause }),
446
+ message:
447
+ reason === "quota"
448
+ ? "The Quick Action exceeded its browser quota"
449
+ : "The Quick Action was rate limited",
450
+ });
451
+ }
452
+ if (!response.ok) {
453
+ const message = `The Quick Action answered HTTP ${response.status}`;
454
+ const cause = privateResponseCause(bodyText);
455
+ if (response.status >= 500) {
456
+ return yield* protocolError(message, cause);
457
+ }
458
+ return yield* navigationError(message, cause);
459
+ }
460
+ const output = parseOutput(request.action, bodyText, response);
461
+ if (
462
+ output._tag === "PageCaptureNavigationError" ||
463
+ output._tag === "PageCaptureProtocolError"
464
+ ) {
465
+ return yield* output;
466
+ }
467
+ const millis = browserMillis(response);
468
+ return PageCaptureResult.make({
469
+ implementation: browserQuickActionImplementation,
470
+ output,
471
+ resourceUse: PageCaptureResourceUse.make({
472
+ ...(millis === undefined ? {} : { browserMillis: millis }),
473
+ ...(usesWorkersAi
474
+ ? {
475
+ inference: PageCaptureInferenceUse.make({
476
+ provider: "cloudflare-workers-ai",
477
+ modelCalls: 1,
478
+ }),
479
+ }
480
+ : {}),
481
+ }),
482
+ });
483
+ });
484
+
485
+ /**
486
+ * Ordinary Quick Actions require host-owned browser binding authority. Workers
487
+ * AI stays unavailable unless the host deliberately selects its separate Layer.
488
+ */
489
+ export const browserQuickActionCaptureLayer = (): Layer.Layer<
490
+ PageCapture,
491
+ never,
492
+ BrowserQuickActionBrowserBinding
493
+ > =>
494
+ Layer.effect(
495
+ PageCapture,
496
+ Effect.map(BrowserQuickActionBrowserBinding, (browser) =>
497
+ PageCapture.of({ capture: makeCapture(browser) }),
498
+ ),
499
+ );
500
+
501
+ /** Structured Quick Actions require host-owned browser and Workers AI authority. */
502
+ export const browserQuickActionWorkersAiCaptureLayer = (): Layer.Layer<
503
+ PageCapture,
504
+ never,
505
+ BrowserQuickActionBrowserBinding | BrowserQuickActionWorkersAi
506
+ > =>
507
+ Layer.effect(
508
+ PageCapture,
509
+ Effect.gen(function* () {
510
+ const browser = yield* BrowserQuickActionBrowserBinding;
511
+ const workersAi = yield* BrowserQuickActionWorkersAi;
512
+ return PageCapture.of({ capture: makeCapture(browser, workersAi) });
513
+ }),
514
+ );
package/src/index.ts CHANGED
@@ -23,3 +23,4 @@ export * from "./layers.ts";
23
23
  export * from "./conversation-object.ts";
24
24
  export * from "./client.ts";
25
25
  export * from "./code-mode-executor.ts";
26
+ export * from "./browser-quick-action.ts";
package/src/layers.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ConversationId } from "@effect-agent/core";
2
- import type { RunContextPreparation } from "@effect-agent/engine";
2
+ import type { RunContextPreparation, RunCostEstimator } from "@effect-agent/engine";
3
3
  import { RunContextPreparationPassthrough } from "@effect-agent/engine";
4
4
  import {
5
5
  AgentBindingResolver,
@@ -80,6 +80,8 @@ export interface CloudflareDurableRuntimeOptions {
80
80
  readonly leaseRenewalInterval?: number | undefined;
81
81
  /** Milliseconds; default 500. */
82
82
  readonly abortPollInterval?: number | undefined;
83
+ /** Deployment-owned pricing authority used by durable cost budgets and settlements. */
84
+ readonly estimateCostMicrousd?: RunCostEstimator | undefined;
83
85
  /** Milliseconds; default 25. */
84
86
  readonly observationPollInterval?: number | undefined;
85
87
  /** Bytes; default just under the 2 MB platform value limit. */
@@ -359,6 +361,9 @@ export class CloudflareDurableRuntime {
359
361
  settlementPollInterval: Duration.millis(config.settlementPollInterval),
360
362
  leaseRenewalInterval: Duration.millis(config.leaseRenewalInterval),
361
363
  abortPollInterval: Duration.millis(config.abortPollInterval),
364
+ ...(options.estimateCostMicrousd === undefined
365
+ ? {}
366
+ : { estimateCostMicrousd: options.estimateCostMicrousd }),
362
367
  }),
363
368
  );
364
369