@yielded/agent-platform-cloudflare 0.1.0-beta.185 → 0.1.0-beta.186

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/{Alarm-C257DCAJ.mjs → Alarm-BN-ADYcu.mjs} +87 -47
  2. package/dist/Alarm-BN-ADYcu.mjs.map +1 -0
  3. package/dist/Alarm.d.mts +10 -3
  4. package/dist/Alarm.mjs +1 -1
  5. package/dist/BrowserRestCapture.d.mts +2 -2
  6. package/dist/BrowserRestCapture.mjs +2 -2
  7. package/dist/BrowserRestCrawl.d.mts +1 -1
  8. package/dist/BrowserRestCrawl.mjs +1 -1
  9. package/dist/{BrowserSession-CfivQ5JY.mjs → BrowserSession-CTgTFKPh.mjs} +2 -2
  10. package/dist/{BrowserSession-CfivQ5JY.mjs.map → BrowserSession-CTgTFKPh.mjs.map} +1 -1
  11. package/dist/{BrowserSession-mKnLSc3p.d.mts → BrowserSession-DJ1Ey4Zv.d.mts} +2 -2
  12. package/dist/BrowserSession.d.mts +2 -2
  13. package/dist/BrowserSession.mjs +2 -2
  14. package/dist/BrowserUse.d.mts +1 -1
  15. package/dist/CloudflareBindings.d.mts +4 -1
  16. package/dist/CloudflareBindings.mjs +5 -1
  17. package/dist/CloudflareBindings.mjs.map +1 -1
  18. package/dist/{CloudflareBrowser-gu7gma0Y.d.mts → CloudflareBrowser-DS6GodKz.d.mts} +2 -2
  19. package/dist/{CloudflareBrowser-Vt8qTdYW.mjs → CloudflareBrowser-DrZQwovV.mjs} +2 -2
  20. package/dist/{CloudflareBrowser-Vt8qTdYW.mjs.map → CloudflareBrowser-DrZQwovV.mjs.map} +1 -1
  21. package/dist/CloudflareBrowser.d.mts +1 -1
  22. package/dist/CloudflareBrowser.mjs +1 -1
  23. package/dist/CloudflareCodeMode.d.mts +1 -1
  24. package/dist/CloudflareCodeMode.mjs +2 -2
  25. package/dist/{CloudflareConfig-C9MvPbX8.d.mts → CloudflareConfig-D_-BMp4q.d.mts} +12 -6
  26. package/dist/CloudflareConfig.d.mts +2 -2
  27. package/dist/CloudflareConfig.mjs +12 -5
  28. package/dist/CloudflareConfig.mjs.map +1 -1
  29. package/dist/CloudflareMemory.d.mts +1 -1
  30. package/dist/CloudflareMemory.mjs +1 -1
  31. package/dist/CloudflareScheduling.d.mts +1 -1
  32. package/dist/CloudflareScheduling.mjs +3 -3
  33. package/dist/CloudflareSubscriptions.d.mts +1 -1
  34. package/dist/CloudflareSubscriptions.mjs +3 -3
  35. package/dist/{CloudflareThreadClient-CnvMXPmV.mjs → CloudflareThreadClient-DgV_RBtF.mjs} +11 -3
  36. package/dist/CloudflareThreadClient-DgV_RBtF.mjs.map +1 -0
  37. package/dist/{CloudflareThreadClient-CmlojpjC.d.mts → CloudflareThreadClient-_RWtjnqM.d.mts} +188 -183
  38. package/dist/CloudflareThreadClient.d.mts +1 -1
  39. package/dist/CloudflareThreadClient.mjs +1 -1
  40. package/dist/{InteractiveBrowser-wV2Bti5e.d.mts → InteractiveBrowser-BJX3d8cP.d.mts} +2 -2
  41. package/dist/{InteractiveBrowser-nukKxc87.mjs → InteractiveBrowser-M887Mt3D.mjs} +2 -2
  42. package/dist/{InteractiveBrowser-nukKxc87.mjs.map → InteractiveBrowser-M887Mt3D.mjs.map} +1 -1
  43. package/dist/InteractiveBrowser.d.mts +1 -1
  44. package/dist/InteractiveBrowser.mjs +1 -1
  45. package/dist/{ThreadObject-Cr1CFWXb.mjs → ThreadObject-AP5CFiOw.mjs} +30 -9
  46. package/dist/ThreadObject-AP5CFiOw.mjs.map +1 -0
  47. package/dist/{ThreadObject-Osn-FmcF.d.mts → ThreadObject-CXUcI8j5.d.mts} +14 -6
  48. package/dist/ThreadObject.d.mts +1 -1
  49. package/dist/ThreadObject.mjs +1 -1
  50. package/dist/WakeScheduler.d.mts +1 -1
  51. package/dist/WakeScheduler.mjs +7 -3
  52. package/dist/WakeScheduler.mjs.map +1 -1
  53. package/dist/{boundary-BguazVkh.mjs → boundary-BLbZMBl2.mjs} +2 -2
  54. package/dist/boundary-BLbZMBl2.mjs.map +1 -0
  55. package/dist/index.d.mts +5 -5
  56. package/dist/index.mjs +5 -5
  57. package/dist/{prepared-admission-w2Kq32_k.mjs → prepared-admission-DSuWZ5qK.mjs} +4 -3
  58. package/dist/prepared-admission-DSuWZ5qK.mjs.map +1 -0
  59. package/package.json +1 -1
  60. package/src/Alarm.ts +110 -64
  61. package/src/CloudflareBindings.ts +5 -1
  62. package/src/CloudflareConfig.ts +10 -3
  63. package/src/CloudflareThreadClient.ts +8 -1
  64. package/src/ThreadObject.ts +13 -8
  65. package/src/WakeScheduler.ts +5 -1
  66. package/src/internal/boundary.ts +1 -1
  67. package/src/internal/crypto.ts +4 -1
  68. package/src/internal/due-queue.ts +2 -1
  69. package/src/internal/layers.ts +29 -16
  70. package/src/internal/live-text-protocol.ts +1 -1
  71. package/src/internal/live-text.ts +4 -1
  72. package/src/internal/message-delivery.ts +7 -1
  73. package/src/internal/prepared-admission.ts +2 -1
  74. package/src/internal/progress-wait.ts +6 -1
  75. package/src/internal/transport.ts +2 -1
  76. package/dist/Alarm-C257DCAJ.mjs.map +0 -1
  77. package/dist/CloudflareThreadClient-CnvMXPmV.mjs.map +0 -1
  78. package/dist/ThreadObject-Cr1CFWXb.mjs.map +0 -1
  79. package/dist/boundary-BguazVkh.mjs.map +0 -1
  80. package/dist/prepared-admission-w2Kq32_k.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CloudflareBrowser-Vt8qTdYW.mjs","names":[],"sources":["../src/internal/browser-quick-action.ts","../src/CloudflareBrowser.ts"],"sourcesContent":["/// <reference types=\"@cloudflare/workers-types\" />\n\nimport {\n PageCapture,\n PageCaptureInferenceUse,\n PageCaptureInferencePolicyError,\n PageCaptureNavigationError,\n PageCaptureOutputLimitError,\n PageCaptureProtocolError,\n PageCaptureRateLimitedError,\n PageCaptureResourceUse,\n PageCaptureResult,\n PageCaptureUnsupportedError,\n PageContentCaptured,\n PageLinksCaptured,\n PageMarkdownCaptured,\n PageScrapeCaptured,\n PageStructuredCaptured,\n type PageCaptureAction,\n type PageCaptureCapture,\n type PageCaptureError,\n type PageCaptureOutput,\n type PageCaptureRequest,\n} from \"@yielded/agent/page-capture\";\nimport {\n PageScreenshot,\n PageScreenshotOutputLimitError,\n PageScreenshotResult,\n type PageScreenshotCapture,\n type PageScreenshotError,\n type PageScreenshotRequest,\n} from \"@yielded/agent/page-screenshot\";\nimport { SandboxImplementation } from \"@yielded/agent/sandbox\";\nimport { Context, Effect, Layer, Option, Schema } from \"effect\";\n\n/**\n * The Cloudflare Browser Run Quick Action `PageCapture` adapter (capability\n * spec §9.2). Each capture is one stateless `quickAction()` RPC on the\n * Wrangler `browser` binding: the platform renders the target in a managed\n * headless browser and returns one bounded output; the adapter holds no\n * session and no state between passes. The binding requires a Worker\n * compatibility date of `2026-03-24` or later, and local `wrangler dev` needs\n * remote mode (`\"remote\": true` on the binding) because `quickAction` has no\n * local implementation.\n *\n * Rendered output is untrusted, attacker-influenced content; this adapter\n * only bounds and types it. Deployment class `E` only: no durability claim.\n */\nexport const browserQuickActionImplementation = SandboxImplementation.make({\n isolation: \"isolated\",\n identity: \"cloudflare-browser-quick-action\",\n});\n\n/**\n * Effect-native client captured by the binding service. Its option types come\n * directly from the pinned Workers declarations rather than a local copy.\n */\nexport interface BrowserQuickActionClient {\n readonly screenshot: (\n options: BrowserRunScreenshotOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n readonly content: (\n options: BrowserRunContentOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n readonly markdown: (\n options: BrowserRunMarkdownOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n readonly links: (\n options: BrowserRunLinksOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n readonly scrape: (\n options: BrowserRunScrapeOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n readonly json: (\n options: BrowserRunJsonOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n}\n\n/** A native binding RPC rejected before it returned an HTTP response. */\nexport class BrowserQuickActionRpcError extends Schema.TaggedError<BrowserQuickActionRpcError>()(\n \"BrowserQuickActionRpcError\",\n {\n action: Schema.Literals([\"screenshot\", \"content\", \"markdown\", \"links\", \"scrape\", \"json\"]),\n cause: Schema.Defect(),\n },\n) {}\n\nexport interface BrowserQuickActionCaptureOptions {\n /** The resolved Wrangler `browser` binding (DEPLOY-014: supplied, never ambient). */\n readonly browser: BrowserRun;\n}\n\n/** Host-owned browser binding authority, supplied explicitly at the composition root. */\nexport class BrowserQuickActionBrowserBinding extends Context.Service<\n BrowserQuickActionBrowserBinding,\n BrowserQuickActionClient\n>()(\"@effect-agent/platform-cloudflare/BrowserQuickActionBrowserBinding\") {\n static layer(\n options: BrowserQuickActionCaptureOptions,\n ): Layer.Layer<BrowserQuickActionBrowserBinding> {\n const browser = options.browser;\n\n const invoke = (\n action: \"screenshot\" | \"content\" | \"markdown\" | \"links\" | \"scrape\" | \"json\",\n evaluate: () => Promise<Response>,\n ): Effect.Effect<Response, BrowserQuickActionRpcError> =>\n Effect.tryPromise({\n try: evaluate,\n catch: (cause) => BrowserQuickActionRpcError.make({ action, cause }),\n });\n\n return Layer.succeed(BrowserQuickActionBrowserBinding)({\n screenshot: (request) =>\n invoke(\"screenshot\", () => browser.quickAction(\"screenshot\", request)),\n content: (request) => invoke(\"content\", () => browser.quickAction(\"content\", request)),\n markdown: (request) => invoke(\"markdown\", () => browser.quickAction(\"markdown\", request)),\n links: (request) => invoke(\"links\", () => browser.quickAction(\"links\", request)),\n scrape: (request) => invoke(\"scrape\", () => browser.quickAction(\"scrape\", request)),\n json: (request) => invoke(\"json\", () => browser.quickAction(\"json\", request)),\n });\n }\n}\n\n/** Host-owned authorization and accounting for one Workers AI extraction. */\nexport interface BrowserQuickActionWorkersAiPolicy {\n readonly authorizeAndAccount: (\n request: PageCaptureRequest,\n ) => Effect.Effect<void, BrowserQuickActionWorkersAiPolicyError>;\n}\n\n/** Host-only diagnostic for a denied or unaccounted Workers AI extraction. */\nexport class BrowserQuickActionWorkersAiPolicyError extends Schema.TaggedError<BrowserQuickActionWorkersAiPolicyError>()(\n \"BrowserQuickActionWorkersAiPolicyError\",\n {\n reason: Schema.Literals([\"authorization\", \"accounting\"]),\n message: Schema.String.check(Schema.isMaxLength(8_000)),\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/** Explicit host-owned authority and accounting for separately billed Workers AI extraction. */\nexport class BrowserQuickActionWorkersAi extends Context.Service<\n BrowserQuickActionWorkersAi,\n BrowserQuickActionWorkersAiPolicy\n>()(\"@effect-agent/platform-cloudflare/BrowserQuickActionWorkersAi\") {\n static layer(\n policy: BrowserQuickActionWorkersAiPolicy,\n ): Layer.Layer<BrowserQuickActionWorkersAi> {\n return Layer.succeed(BrowserQuickActionWorkersAi)(policy);\n }\n}\n\nconst MAX_DIAGNOSTIC_LENGTH = 8_000;\nconst boundedDiagnostic = (message: string): string => message.slice(0, MAX_DIAGNOSTIC_LENGTH);\n\nconst QuickActionSuccessEnvelope = Schema.Struct({\n success: Schema.Literal(true),\n result: Schema.Json,\n});\n\nconst QuickActionErrorEnvelope = Schema.Struct({\n success: Schema.Literal(false),\n errors: Schema.Array(\n Schema.Struct({\n message: Schema.String,\n code: Schema.optionalKey(Schema.Number),\n detail: Schema.optionalKey(Schema.String),\n path: Schema.optionalKey(Schema.String),\n }),\n ),\n rawAiResponse: Schema.optionalKey(Schema.String),\n});\n\nconst QuickActionEnvelope = Schema.Union([QuickActionSuccessEnvelope, QuickActionErrorEnvelope]);\nconst decodeEnvelope = Schema.decodeUnknownOption(Schema.fromJsonString(QuickActionEnvelope));\n\n/** Recognize only the provider's exact timeout grammar; never forward arbitrary error text. */\nconst navigationFailureMessage = (bodyText: string, response: Response): string => {\n const fallback = `The Browser Run Quick Action API answered HTTP ${response.status}; the destination status is unknown`;\n\n if (!isJsonResponse(response)) return fallback;\n const envelope = decodeEnvelope(bodyText);\n\n if (Option.isNone(envelope) || envelope.value.success) return fallback;\n for (const error of envelope.value.errors) {\n if (error.code !== 6002) continue;\n\n const timeout = /^Navigation timeout of ([1-9][0-9]{0,5}) ms exceeded$/.exec(\n error.detail ?? \"\",\n );\n\n if (timeout !== null)\n return `Browser Run navigation timed out after ${timeout[1]} ms (Quick Action API HTTP ${response.status}); the destination status is unknown`;\n }\n\n return fallback;\n};\n\n/** Project the schema-validated request onto Cloudflare's native common options. */\nconst quickActionCommonOptions = (request: PageCaptureRequest): BrowserRunCommonOptions => {\n const options: BrowserRunBaseOptions = {};\n const navigation = request.navigation;\n\n if (navigation !== undefined) {\n const goto: NonNullable<BrowserRunBaseOptions[\"gotoOptions\"]> = {};\n\n if (navigation.waitUntil !== undefined) goto.waitUntil = navigation.waitUntil;\n if (navigation.timeoutMillis !== undefined) goto.timeout = navigation.timeoutMillis;\n if (Object.keys(goto).length > 0) options.gotoOptions = goto;\n if (navigation.waitForSelector !== undefined) {\n options.waitForSelector = {\n selector: navigation.waitForSelector.selector,\n ...(navigation.waitForSelector.timeoutMillis === undefined\n ? {}\n : { timeout: navigation.waitForSelector.timeoutMillis }),\n };\n }\n }\n if (request.viewport !== undefined) {\n options.viewport = { width: request.viewport.width, height: request.viewport.height };\n }\n if (request.resourcePolicy !== undefined) {\n if (request.resourcePolicy.rejectResourceTypes !== undefined) {\n options.rejectResourceTypes = [...request.resourcePolicy.rejectResourceTypes];\n }\n if (request.resourcePolicy.allowRequestPatterns !== undefined) {\n options.allowRequestPattern = [...request.resourcePolicy.allowRequestPatterns];\n }\n }\n\n return request.target._tag === \"PageUrlTarget\"\n ? { ...options, url: request.target.url }\n : { ...options, html: request.target.html };\n};\n\n/** Dispatch through Cloudflare's native action-specific overloads. */\nconst executeQuickAction = (\n browser: BrowserQuickActionClient,\n request: PageCaptureRequest,\n): Effect.Effect<Response, BrowserQuickActionRpcError> => {\n const options = quickActionCommonOptions(request);\n\n switch (request.action._tag) {\n case \"CapturePageContent\": {\n return browser.content(options);\n }\n case \"CapturePageMarkdown\": {\n return browser.markdown(options);\n }\n case \"CapturePageLinks\": {\n return browser.links({\n ...options,\n ...(request.action.visibleLinksOnly === undefined\n ? {}\n : { visibleLinksOnly: request.action.visibleLinksOnly }),\n });\n }\n case \"CapturePageScrape\": {\n return browser.scrape({\n ...options,\n elements: request.action.selectors.map((selector) => ({ selector })),\n });\n }\n case \"CapturePageStructured\": {\n return browser.json({\n ...options,\n response_format: {\n type: \"json_schema\",\n json_schema: request.action.responseFormat,\n },\n ...(request.action.prompt === undefined ? {} : { prompt: request.action.prompt }),\n });\n }\n }\n};\n\nconst protocolError = (message: string, cause?: unknown): PageCaptureProtocolError =>\n PageCaptureProtocolError.make({\n implementation: browserQuickActionImplementation,\n message: boundedDiagnostic(message),\n ...(cause === undefined ? {} : { cause }),\n });\n\nconst navigationError = (message: string, cause?: unknown): PageCaptureNavigationError =>\n PageCaptureNavigationError.make({\n implementation: browserQuickActionImplementation,\n message: boundedDiagnostic(message),\n ...(cause === undefined ? {} : { cause }),\n });\n\n/** Preserve bounded remote diagnostics for the host without exposing their text to a model. */\nconst privateResponseCause = (bodyText: string, response: Response): Error =>\n // oxlint-disable-next-line effect/no-native-error -- Bounded foreign response diagnostic retains host metadata as cause, never as the Effect failure.\n new Error(boundedDiagnostic(bodyText), {\n cause: {\n provider: \"cloudflare-browser-run\",\n httpStatus: response.status,\n httpStatusSource: \"browser-api\",\n headers: Object.fromEntries(\n [\"content-type\", \"cf-ray\", \"x-request-id\", \"retry-after\", \"x-browser-ms-used\"].flatMap(\n (name) => {\n const value = response.headers.get(name);\n\n return value === null ? [] : [[name, boundedDiagnostic(value)]];\n },\n ),\n ),\n bodyCharacters: bodyText.length,\n bodyTruncated: bodyText.length > MAX_DIAGNOSTIC_LENGTH,\n },\n });\n\n/** Foreign cancellation must not keep a response Scope open indefinitely. */\nconst cancelResponse = (cancel: () => Promise<void>, warning: string): Effect.Effect<void> =>\n Effect.tryPromise({ try: cancel, catch: () => undefined }).pipe(\n Effect.interruptible,\n Effect.timeoutOrElse({\n duration: \"1 second\",\n orElse: () => Effect.fail(undefined),\n }),\n Effect.catch(() => Effect.logWarning(warning)),\n );\n\nconst releaseResponseReader = (\n reader: ReadableStreamDefaultReader<Uint8Array>,\n): Effect.Effect<void> =>\n cancelResponse(() => reader.cancel(), \"Canceling the Quick Action response failed\").pipe(\n Effect.ensuring(\n Effect.try({\n try: () => reader.releaseLock(),\n catch: (cause) => protocolError(\"Releasing the Quick Action response failed\", cause),\n }).pipe(Effect.catch((error) => Effect.logWarning(error.message))),\n ),\n );\n\nconst readBoundedResponse = Effect.fnUntraced(function* (\n response: Response,\n request: PageCaptureRequest,\n) {\n const body = response.body;\n\n if (body === null) return \"\";\n\n const reader = yield* Effect.acquireRelease(\n Effect.try({\n try: () => body.getReader(),\n catch: (cause) => protocolError(\"Opening the Quick Action response failed\", cause),\n }),\n releaseResponseReader,\n );\n\n const decoder = new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: false });\n let observedBytes = 0;\n let bodyText = \"\";\n\n while (true) {\n const chunk = yield* Effect.tryPromise({\n try: () => reader.read(),\n catch: (cause) => protocolError(\"Reading the Quick Action response failed\", cause),\n });\n\n if (chunk.done) break;\n\n observedBytes += chunk.value.byteLength;\n if (observedBytes > request.limits.maxOutputBytes) {\n return yield* PageCaptureOutputLimitError.make({\n implementation: browserQuickActionImplementation,\n limit: request.limits.maxOutputBytes,\n observed: observedBytes,\n });\n }\n\n bodyText += yield* Effect.try({\n try: () => decoder.decode(chunk.value, { stream: true }),\n catch: (cause) => protocolError(\"Decoding the Quick Action response failed\", cause),\n });\n }\n\n return (\n bodyText +\n (yield* Effect.try({\n try: () => decoder.decode(),\n catch: (cause) => protocolError(\"Decoding the Quick Action response failed\", cause),\n }))\n );\n}, Effect.scoped);\n\n/**\n * Retry-After arrives in whole seconds; a non-integer form (an HTTP date) is\n * dropped rather than guessed at.\n */\nconst retryAfterMillis = (response: Response): number | undefined => {\n const header = response.headers.get(\"Retry-After\");\n\n if (header === null) return undefined;\n const seconds = Number(header);\n\n if (!Number.isSafeInteger(seconds) || seconds < 0) return undefined;\n const millis = seconds * 1_000;\n\n return Number.isSafeInteger(millis) ? millis : undefined;\n};\n\nconst browserMillis = (response: Response): number | undefined => {\n const header = response.headers.get(\"X-Browser-Ms-Used\");\n\n if (header === null) return undefined;\n const millis = Number(header);\n\n return Number.isSafeInteger(millis) && millis >= 0 ? millis : undefined;\n};\n\n/** Only trusted response metadata chooses transport framing; page text never does. */\nconst isJsonResponse = (response: Response): boolean => {\n const contentType = response.headers.get(\"Content-Type\");\n\n if (contentType === null) return false;\n const mediaType = contentType.split(\";\", 1)[0]?.trim().toLowerCase();\n\n return mediaType === \"application/json\" || mediaType?.endsWith(\"+json\") === true;\n};\n\nconst parseOutput = (\n action: PageCaptureAction,\n bodyText: string,\n response: Response,\n): PageCaptureOutput | PageCaptureNavigationError | PageCaptureProtocolError => {\n if (!isJsonResponse(response)) {\n return protocolError(\n \"The Quick Action success response was not a JSON response envelope\",\n privateResponseCause(bodyText, response),\n );\n }\n const envelope = decodeEnvelope(bodyText);\n\n if (Option.isNone(envelope)) {\n return protocolError(\n \"The JSON Quick Action response did not carry a valid response envelope\",\n privateResponseCause(bodyText, response),\n );\n }\n if (!envelope.value.success) {\n return navigationError(\n navigationFailureMessage(bodyText, response),\n privateResponseCause(bodyText, response),\n );\n }\n switch (action._tag) {\n case \"CapturePageContent\":\n case \"CapturePageMarkdown\": {\n if (typeof envelope.value.result !== \"string\") {\n return protocolError(\"The Quick Action envelope carried a non-text result\");\n }\n\n return action._tag === \"CapturePageContent\"\n ? PageContentCaptured.make({ html: envelope.value.result })\n : PageMarkdownCaptured.make({ markdown: envelope.value.result });\n }\n case \"CapturePageLinks\": {\n const decoded = Schema.decodeUnknownOption(PageLinksCaptured)({\n _tag: \"PageLinksCaptured\",\n links: envelope.value.result,\n });\n\n if (Option.isNone(decoded)) {\n return protocolError(\"The links Quick Action did not return a bounded array of valid URLs\");\n }\n\n return decoded.value;\n }\n case \"CapturePageScrape\": {\n const decoded = Schema.decodeUnknownOption(PageScrapeCaptured)({\n _tag: \"PageScrapeCaptured\",\n groups: envelope.value.result,\n });\n\n if (Option.isNone(decoded)) {\n return protocolError(\n \"The scrape Quick Action did not return bounded grouped element records\",\n );\n }\n\n return decoded.value;\n }\n case \"CapturePageStructured\": {\n return PageStructuredCaptured.make({ value: envelope.value.result });\n }\n }\n};\n\nconst isQuotaMessage = (text: string): boolean => /time limit|daily|quota/i.test(text);\n\nconst makeCapture = (\n browser: BrowserQuickActionClient,\n workersAi?: BrowserQuickActionWorkersAiPolicy,\n): PageCaptureCapture =>\n Effect.fnUntraced(function* (\n request: PageCaptureRequest,\n ): Effect.fn.Return<PageCaptureResult, PageCaptureError> {\n if (request.engine !== \"chromium\") {\n return yield* PageCaptureUnsupportedError.make({\n implementation: browserQuickActionImplementation,\n feature: \"engine\",\n message:\n \"The browser binding's quickAction() exposes no engine selector; kitesurf requires the REST or CDP surface\",\n });\n }\n\n const usesWorkersAi = request.action._tag === \"CapturePageStructured\";\n\n if (usesWorkersAi) {\n if (workersAi === undefined) {\n return yield* PageCaptureUnsupportedError.make({\n implementation: browserQuickActionImplementation,\n feature: \"action\",\n message:\n \"Structured capture invokes separately billed Workers AI and requires an explicit authorization and accounting policy\",\n });\n }\n yield* workersAi.authorizeAndAccount(request).pipe(\n Effect.mapError((cause) =>\n PageCaptureInferencePolicyError.make({\n implementation: browserQuickActionImplementation,\n provider: \"cloudflare-workers-ai\",\n reason: cause.reason,\n message:\n cause.reason === \"authorization\"\n ? \"Workers AI extraction was not authorized\"\n : \"Workers AI extraction could not be accounted for\",\n cause,\n }),\n ),\n );\n }\n\n const response = yield* executeQuickAction(browser, request).pipe(\n Effect.mapError((error) =>\n protocolError(\"The browser binding rejected the Quick Action\", error.cause),\n ),\n );\n\n const bodyText = yield* readBoundedResponse(response, request);\n\n if (response.status === 429) {\n const retryAfter = retryAfterMillis(response);\n const reason = isQuotaMessage(bodyText) ? \"quota\" : \"rate\";\n const cause = privateResponseCause(bodyText, response);\n\n return yield* PageCaptureRateLimitedError.make({\n implementation: browserQuickActionImplementation,\n reason,\n ...(retryAfter === undefined ? {} : { retryAfterMillis: retryAfter }),\n ...(cause === undefined ? {} : { cause }),\n message:\n reason === \"quota\"\n ? \"The Quick Action exceeded its browser quota\"\n : \"The Quick Action was rate limited\",\n });\n }\n if (!response.ok) {\n const message = navigationFailureMessage(bodyText, response);\n const cause = privateResponseCause(bodyText, response);\n\n if (response.status >= 500) {\n return yield* protocolError(message, cause);\n }\n\n return yield* navigationError(message, cause);\n }\n const output = parseOutput(request.action, bodyText, response);\n\n if (\n output._tag === \"PageCaptureNavigationError\" ||\n output._tag === \"PageCaptureProtocolError\"\n ) {\n return yield* output;\n }\n const millis = browserMillis(response);\n\n return PageCaptureResult.make({\n implementation: browserQuickActionImplementation,\n output,\n resourceUse: PageCaptureResourceUse.make({\n ...(millis === undefined ? {} : { browserMillis: millis }),\n ...(usesWorkersAi\n ? {\n inference: PageCaptureInferenceUse.make({\n provider: \"cloudflare-workers-ai\",\n modelCalls: 1,\n }),\n }\n : {}),\n }),\n });\n });\n\n/**\n * Ordinary Quick Actions require host-owned browser binding authority. Workers\n * AI stays unavailable unless the host deliberately selects its separate Layer.\n */\nexport const browserQuickActionCaptureLayer = (): Layer.Layer<\n PageCapture,\n never,\n BrowserQuickActionBrowserBinding\n> =>\n Layer.effect(\n PageCapture,\n Effect.map(BrowserQuickActionBrowserBinding, (browser) =>\n PageCapture.of({ capture: makeCapture(browser) }),\n ),\n );\n\n/** Structured Quick Actions require host-owned browser and Workers AI authority. */\nexport const browserQuickActionWorkersAiCaptureLayer = (): Layer.Layer<\n PageCapture,\n never,\n BrowserQuickActionBrowserBinding | BrowserQuickActionWorkersAi\n> =>\n Layer.effect(\n PageCapture,\n Effect.gen(function* () {\n const browser = yield* BrowserQuickActionBrowserBinding;\n const workersAi = yield* BrowserQuickActionWorkersAi;\n\n return PageCapture.of({ capture: makeCapture(browser, workersAi) });\n }),\n );\n\n/** Host-owned Quick Action binding and optional, separately billed extraction authority. */\nexport interface CloudflareBrowserOptions extends BrowserQuickActionCaptureOptions {\n readonly workersAi?: BrowserQuickActionWorkersAiPolicy;\n}\n\n/** Compose WebCapture handlers with the Cloudflare Quick Action adapter. */\nexport const CloudflareBrowser = {\n /**\n * Supply a WebCapture definition and the resolved Worker browser binding.\n * Supports capture, scrape, and extraction definitions without importing capabilities.\n * Only PageCapture is provided; other handler requirements and errors stay visible.\n * Extraction fails closed unless workersAi explicitly authorizes and accounts for it.\n * Capture limits, typed failures, tracing, and scoped response cleanup are unchanged.\n */\n layer: <A, E, R>(\n definition: { readonly handlers: Layer.Layer<A, E, R> },\n options: CloudflareBrowserOptions,\n ): Layer.Layer<A, E, Exclude<R, PageCapture>> => {\n const capture =\n options.workersAi === undefined\n ? browserQuickActionCaptureLayer()\n : browserQuickActionWorkersAiCaptureLayer().pipe(\n Layer.provide(BrowserQuickActionWorkersAi.layer(options.workersAi)),\n );\n\n return definition.handlers.pipe(\n Layer.provide(capture.pipe(Layer.provide(BrowserQuickActionBrowserBinding.layer(options)))),\n );\n },\n};\n\nconst screenshotOptions = (request: PageScreenshotRequest): BrowserRunScreenshotOptions => {\n const options: BrowserRunBaseOptions = {};\n\n if (\n request.navigation?.waitUntil !== undefined ||\n request.navigation?.timeoutMillis !== undefined\n ) {\n options.gotoOptions = {\n ...(request.navigation.waitUntil === undefined\n ? {}\n : { waitUntil: request.navigation.waitUntil }),\n ...(request.navigation.timeoutMillis === undefined\n ? {}\n : { timeout: request.navigation.timeoutMillis }),\n };\n }\n if (request.navigation?.waitForSelector !== undefined) {\n options.waitForSelector = {\n selector: request.navigation.waitForSelector.selector,\n ...(request.navigation.waitForSelector.timeoutMillis === undefined\n ? {}\n : { timeout: request.navigation.waitForSelector.timeoutMillis }),\n };\n }\n if (request.viewport !== undefined) {\n options.viewport = { width: request.viewport.width, height: request.viewport.height };\n }\n if (request.resourcePolicy?.rejectResourceTypes !== undefined) {\n options.rejectResourceTypes = [...request.resourcePolicy.rejectResourceTypes];\n }\n if (request.resourcePolicy?.allowRequestPatterns !== undefined) {\n options.allowRequestPattern = [...request.resourcePolicy.allowRequestPatterns];\n }\n\n return {\n ...options,\n ...(request.target._tag === \"PageUrlTarget\"\n ? { url: request.target.url }\n : { html: request.target.html }),\n screenshotOptions: { type: \"png\", encoding: \"binary\", fullPage: request.fullPage },\n };\n};\n\nconst cancelBody = (body: ReadableStream<Uint8Array>): Effect.Effect<void> =>\n cancelResponse(() => body.cancel(), \"Canceling the screenshot response failed\");\n\nconst releaseScreenshotReader = (\n reader: ReadableStreamDefaultReader<Uint8Array>,\n): Effect.Effect<void> =>\n cancelResponse(() => reader.cancel(), \"Canceling the screenshot response failed\").pipe(\n Effect.ensuring(\n Effect.try({\n try: () => reader.releaseLock(),\n catch: () => undefined,\n }).pipe(Effect.catch(() => Effect.logWarning(\"Releasing the screenshot response failed\"))),\n ),\n );\n\nconst pngResponse = (response: Response): boolean =>\n response.headers.get(\"Content-Type\")?.split(\";\", 1)[0]?.trim().toLowerCase() === \"image/png\";\n\nconst declaredLength = (response: Response): number | undefined => {\n const raw = response.headers.get(\"Content-Length\");\n\n if (raw === null || !/^(0|[1-9][0-9]*)$/.test(raw)) return undefined;\n const length = Number(raw);\n\n return Number.isSafeInteger(length) ? length : undefined;\n};\n\nconst readScreenshot = Effect.fnUntraced(function* (\n response: Response,\n request: PageScreenshotRequest,\n) {\n const body = response.body;\n\n if (body === null) {\n return yield* protocolError(\"The screenshot response had no body\");\n }\n if (!pngResponse(response)) {\n yield* cancelBody(body);\n\n return yield* protocolError(\"The screenshot response was not image/png\");\n }\n const length = declaredLength(response);\n\n if (length !== undefined && length > request.limits.maxOutputBytes) {\n yield* cancelBody(body);\n\n return yield* PageScreenshotOutputLimitError.make({\n implementation: browserQuickActionImplementation,\n limit: request.limits.maxOutputBytes,\n observed: length,\n });\n }\n\n const reader = yield* Effect.acquireRelease(\n Effect.try({\n try: () => body.getReader(),\n catch: (cause) => protocolError(\"Opening the screenshot response failed\", cause),\n }),\n releaseScreenshotReader,\n );\n\n const chunks: Array<Uint8Array> = [];\n let observed = 0;\n\n while (true) {\n const next = yield* Effect.tryPromise({\n try: () => reader.read(),\n catch: (cause) => protocolError(\"Reading the screenshot response failed\", cause),\n });\n\n if (next.done) break;\n observed += next.value.byteLength;\n if (observed > request.limits.maxOutputBytes) {\n return yield* PageScreenshotOutputLimitError.make({\n implementation: browserQuickActionImplementation,\n limit: request.limits.maxOutputBytes,\n observed,\n });\n }\n chunks.push(next.value);\n }\n const bytes = new Uint8Array(observed);\n let offset = 0;\n\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n\n return bytes;\n}, Effect.scoped);\n\nconst makeScreenshot = (browser: BrowserQuickActionClient): PageScreenshotCapture =>\n Effect.fnUntraced(function* (\n request: PageScreenshotRequest,\n ): Effect.fn.Return<PageScreenshotResult, PageScreenshotError> {\n if (request.engine !== \"chromium\") {\n return yield* PageCaptureUnsupportedError.make({\n implementation: browserQuickActionImplementation,\n feature: \"engine\",\n message: \"The browser binding's screenshot action exposes no engine selector\",\n });\n }\n\n const response = yield* browser\n .screenshot(screenshotOptions(request))\n .pipe(\n Effect.mapError((error) =>\n protocolError(\"The browser binding rejected the screenshot\", error.cause),\n ),\n );\n\n if (response.status === 429) {\n const body = response.body;\n\n if (body !== null) yield* cancelBody(body);\n\n return yield* PageCaptureRateLimitedError.make({\n implementation: browserQuickActionImplementation,\n reason: \"rate\",\n ...(retryAfterMillis(response) === undefined\n ? {}\n : { retryAfterMillis: retryAfterMillis(response) }),\n message: \"The screenshot Quick Action was rate limited\",\n });\n }\n if (!response.ok) {\n const body = response.body;\n\n if (body !== null) yield* cancelBody(body);\n const message = `The screenshot Quick Action answered HTTP ${response.status}`;\n\n return yield* response.status >= 500 ? protocolError(message) : navigationError(message);\n }\n const bytes = yield* readScreenshot(response, request);\n\n return PageScreenshotResult.make({\n implementation: browserQuickActionImplementation,\n mediaType: \"image/png\",\n bytes,\n });\n });\n\n/** Native Browser Run screenshot adapter. It retains PNG bytes only for the caller's result. */\nexport const browserQuickActionScreenshotLayer = (): Layer.Layer<\n PageScreenshot,\n never,\n BrowserQuickActionBrowserBinding\n> =>\n Layer.effect(\n PageScreenshot,\n Effect.map(BrowserQuickActionBrowserBinding, (browser) =>\n PageScreenshot.of({ capture: makeScreenshot(browser) }),\n ),\n );\n","/** Public CloudflareBrowser API. Implementation helpers remain private. */\nexport {\n BrowserQuickActionBrowserBinding,\n BrowserQuickActionRpcError,\n BrowserQuickActionWorkersAi,\n BrowserQuickActionWorkersAiPolicyError,\n browserQuickActionCaptureLayer,\n browserQuickActionWorkersAiCaptureLayer,\n browserQuickActionScreenshotLayer,\n CloudflareBrowser,\n type BrowserQuickActionCaptureOptions,\n type BrowserQuickActionClient,\n type BrowserQuickActionWorkersAiPolicy,\n type CloudflareBrowserOptions,\n} from \"./internal/browser-quick-action.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgDA,MAAa,mCAAmC,sBAAsB,KAAK;CACzE,WAAW;CACX,UAAU;AACZ,CAAC;;AA4BD,IAAa,6BAAb,cAAgD,OAAO,YAAwC,CAAC,CAC9F,8BACA;CACE,QAAQ,OAAO,SAAS;EAAC;EAAc;EAAW;EAAY;EAAS;EAAU;CAAM,CAAC;CACxF,OAAO,OAAO,OAAO;AACvB,CACF,CAAC,CAAC,CAAC;;AAQH,IAAa,mCAAb,MAAa,yCAAyC,QAAQ,QAG5D,CAAC,CAAC,oEAAoE,CAAC,CAAC;CACxE,OAAO,MACL,SAC+C;EAC/C,MAAM,UAAU,QAAQ;EAExB,MAAM,UACJ,QACA,aAEA,OAAO,WAAW;GAChB,KAAK;GACL,QAAQ,UAAU,2BAA2B,KAAK;IAAE;IAAQ;GAAM,CAAC;EACrE,CAAC;EAE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D,OAAO,qBAAqB,KAAK;EAC/B,gBAAgB;EAChB,WAAW;EACX;CACF,CAAC;AACH,CAAC;;AAGH,MAAa,0CAKX,MAAM,OACJ,gBACA,OAAO,IAAI,mCAAmC,YAC5C,eAAe,GAAG,EAAE,SAAS,eAAe,OAAO,EAAE,CAAC,CACxD,CACF"}
1
+ {"version":3,"file":"CloudflareBrowser-DrZQwovV.mjs","names":[],"sources":["../src/internal/browser-quick-action.ts","../src/CloudflareBrowser.ts"],"sourcesContent":["/// <reference types=\"@cloudflare/workers-types\" />\n\nimport {\n PageCapture,\n PageCaptureInferenceUse,\n PageCaptureInferencePolicyError,\n PageCaptureNavigationError,\n PageCaptureOutputLimitError,\n PageCaptureProtocolError,\n PageCaptureRateLimitedError,\n PageCaptureResourceUse,\n PageCaptureResult,\n PageCaptureUnsupportedError,\n PageContentCaptured,\n PageLinksCaptured,\n PageMarkdownCaptured,\n PageScrapeCaptured,\n PageStructuredCaptured,\n type PageCaptureAction,\n type PageCaptureCapture,\n type PageCaptureError,\n type PageCaptureOutput,\n type PageCaptureRequest,\n} from \"@yielded/agent/page-capture\";\nimport {\n PageScreenshot,\n PageScreenshotOutputLimitError,\n PageScreenshotResult,\n type PageScreenshotCapture,\n type PageScreenshotError,\n type PageScreenshotRequest,\n} from \"@yielded/agent/page-screenshot\";\nimport { SandboxImplementation } from \"@yielded/agent/sandbox\";\nimport { Context, Effect, Layer, Option, Schema } from \"effect\";\n\n/**\n * The Cloudflare Browser Run Quick Action `PageCapture` adapter (capability\n * spec §9.2). Each capture is one stateless `quickAction()` RPC on the\n * Wrangler `browser` binding: the platform renders the target in a managed\n * headless browser and returns one bounded output; the adapter holds no\n * session and no state between passes. The binding requires a Worker\n * compatibility date of `2026-03-24` or later, and local `wrangler dev` needs\n * remote mode (`\"remote\": true` on the binding) because `quickAction` has no\n * local implementation.\n *\n * Rendered output is untrusted, attacker-influenced content; this adapter\n * only bounds and types it. Deployment class `E` only: no durability claim.\n */\nexport const browserQuickActionImplementation = SandboxImplementation.make({\n isolation: \"isolated\",\n identity: \"cloudflare-browser-quick-action\",\n});\n\n/**\n * Effect-native client captured by the binding service. Its option types come\n * directly from the pinned Workers declarations rather than a local copy.\n */\nexport interface BrowserQuickActionClient {\n readonly screenshot: (\n options: BrowserRunScreenshotOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n readonly content: (\n options: BrowserRunContentOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n readonly markdown: (\n options: BrowserRunMarkdownOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n readonly links: (\n options: BrowserRunLinksOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n readonly scrape: (\n options: BrowserRunScrapeOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n readonly json: (\n options: BrowserRunJsonOptions,\n ) => Effect.Effect<Response, BrowserQuickActionRpcError>;\n}\n\n/** A native binding RPC rejected before it returned an HTTP response. */\nexport class BrowserQuickActionRpcError extends Schema.TaggedError<BrowserQuickActionRpcError>()(\n \"BrowserQuickActionRpcError\",\n {\n action: Schema.Literals([\"screenshot\", \"content\", \"markdown\", \"links\", \"scrape\", \"json\"]),\n cause: Schema.Defect(),\n },\n) {}\n\nexport interface BrowserQuickActionCaptureOptions {\n /** The resolved Wrangler `browser` binding (DEPLOY-014: supplied, never ambient). */\n readonly browser: BrowserRun;\n}\n\n/** Host-owned browser binding authority, supplied explicitly at the composition root. */\nexport class BrowserQuickActionBrowserBinding extends Context.Service<\n BrowserQuickActionBrowserBinding,\n BrowserQuickActionClient\n>()(\"@effect-agent/platform-cloudflare/BrowserQuickActionBrowserBinding\") {\n static layer(\n options: BrowserQuickActionCaptureOptions,\n ): Layer.Layer<BrowserQuickActionBrowserBinding> {\n const browser = options.browser;\n\n const invoke = (\n action: \"screenshot\" | \"content\" | \"markdown\" | \"links\" | \"scrape\" | \"json\",\n evaluate: () => Promise<Response>,\n ): Effect.Effect<Response, BrowserQuickActionRpcError> =>\n Effect.tryPromise({\n try: evaluate,\n catch: (cause) => BrowserQuickActionRpcError.make({ action, cause }),\n });\n\n return Layer.succeed(BrowserQuickActionBrowserBinding)({\n screenshot: (request) =>\n invoke(\"screenshot\", () => browser.quickAction(\"screenshot\", request)),\n content: (request) => invoke(\"content\", () => browser.quickAction(\"content\", request)),\n markdown: (request) => invoke(\"markdown\", () => browser.quickAction(\"markdown\", request)),\n links: (request) => invoke(\"links\", () => browser.quickAction(\"links\", request)),\n scrape: (request) => invoke(\"scrape\", () => browser.quickAction(\"scrape\", request)),\n json: (request) => invoke(\"json\", () => browser.quickAction(\"json\", request)),\n });\n }\n}\n\n/** Host-owned authorization and accounting for one Workers AI extraction. */\nexport interface BrowserQuickActionWorkersAiPolicy {\n readonly authorizeAndAccount: (\n request: PageCaptureRequest,\n ) => Effect.Effect<void, BrowserQuickActionWorkersAiPolicyError>;\n}\n\n/** Host-only diagnostic for a denied or unaccounted Workers AI extraction. */\nexport class BrowserQuickActionWorkersAiPolicyError extends Schema.TaggedError<BrowserQuickActionWorkersAiPolicyError>()(\n \"BrowserQuickActionWorkersAiPolicyError\",\n {\n reason: Schema.Literals([\"authorization\", \"accounting\"]),\n message: Schema.String.check(Schema.isMaxLength(8_000)),\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/** Explicit host-owned authority and accounting for separately billed Workers AI extraction. */\nexport class BrowserQuickActionWorkersAi extends Context.Service<\n BrowserQuickActionWorkersAi,\n BrowserQuickActionWorkersAiPolicy\n>()(\"@effect-agent/platform-cloudflare/BrowserQuickActionWorkersAi\") {\n static layer(\n policy: BrowserQuickActionWorkersAiPolicy,\n ): Layer.Layer<BrowserQuickActionWorkersAi> {\n return Layer.succeed(BrowserQuickActionWorkersAi)(policy);\n }\n}\n\nconst MAX_DIAGNOSTIC_LENGTH = 8_000;\nconst boundedDiagnostic = (message: string): string => message.slice(0, MAX_DIAGNOSTIC_LENGTH);\n\nconst QuickActionSuccessEnvelope = Schema.Struct({\n success: Schema.Literal(true),\n result: Schema.Json,\n});\n\nconst QuickActionErrorEnvelope = Schema.Struct({\n success: Schema.Literal(false),\n errors: Schema.Array(\n Schema.Struct({\n message: Schema.String,\n code: Schema.optionalKey(Schema.Number),\n detail: Schema.optionalKey(Schema.String),\n path: Schema.optionalKey(Schema.String),\n }),\n ),\n rawAiResponse: Schema.optionalKey(Schema.String),\n});\n\nconst QuickActionEnvelope = Schema.Union([QuickActionSuccessEnvelope, QuickActionErrorEnvelope]);\nconst decodeEnvelope = Schema.decodeUnknownOption(Schema.fromJsonString(QuickActionEnvelope));\n\n/** Recognize only the provider's exact timeout grammar; never forward arbitrary error text. */\nconst navigationFailureMessage = (bodyText: string, response: Response): string => {\n const fallback = `The Browser Run Quick Action API answered HTTP ${response.status}; the destination status is unknown`;\n\n if (!isJsonResponse(response)) return fallback;\n const envelope = decodeEnvelope(bodyText);\n\n if (Option.isNone(envelope) || envelope.value.success) return fallback;\n for (const error of envelope.value.errors) {\n if (error.code !== 6002) continue;\n\n const timeout = /^Navigation timeout of ([1-9][0-9]{0,5}) ms exceeded$/.exec(\n error.detail ?? \"\",\n );\n\n if (timeout !== null)\n return `Browser Run navigation timed out after ${timeout[1]} ms (Quick Action API HTTP ${response.status}); the destination status is unknown`;\n }\n\n return fallback;\n};\n\n/** Project the schema-validated request onto Cloudflare's native common options. */\nconst quickActionCommonOptions = (request: PageCaptureRequest): BrowserRunCommonOptions => {\n const options: BrowserRunBaseOptions = {};\n const navigation = request.navigation;\n\n if (navigation !== undefined) {\n const goto: NonNullable<BrowserRunBaseOptions[\"gotoOptions\"]> = {};\n\n if (navigation.waitUntil !== undefined) goto.waitUntil = navigation.waitUntil;\n if (navigation.timeoutMillis !== undefined) goto.timeout = navigation.timeoutMillis;\n if (Object.keys(goto).length > 0) options.gotoOptions = goto;\n if (navigation.waitForSelector !== undefined) {\n options.waitForSelector = {\n selector: navigation.waitForSelector.selector,\n ...(navigation.waitForSelector.timeoutMillis === undefined\n ? {}\n : { timeout: navigation.waitForSelector.timeoutMillis }),\n };\n }\n }\n if (request.viewport !== undefined) {\n options.viewport = { width: request.viewport.width, height: request.viewport.height };\n }\n if (request.resourcePolicy !== undefined) {\n if (request.resourcePolicy.rejectResourceTypes !== undefined) {\n options.rejectResourceTypes = [...request.resourcePolicy.rejectResourceTypes];\n }\n if (request.resourcePolicy.allowRequestPatterns !== undefined) {\n options.allowRequestPattern = [...request.resourcePolicy.allowRequestPatterns];\n }\n }\n\n return request.target._tag === \"PageUrlTarget\"\n ? { ...options, url: request.target.url }\n : { ...options, html: request.target.html };\n};\n\n/** Dispatch through Cloudflare's native action-specific overloads. */\nconst executeQuickAction = (\n browser: BrowserQuickActionClient,\n request: PageCaptureRequest,\n): Effect.Effect<Response, BrowserQuickActionRpcError> => {\n const options = quickActionCommonOptions(request);\n\n switch (request.action._tag) {\n case \"CapturePageContent\": {\n return browser.content(options);\n }\n case \"CapturePageMarkdown\": {\n return browser.markdown(options);\n }\n case \"CapturePageLinks\": {\n return browser.links({\n ...options,\n ...(request.action.visibleLinksOnly === undefined\n ? {}\n : { visibleLinksOnly: request.action.visibleLinksOnly }),\n });\n }\n case \"CapturePageScrape\": {\n return browser.scrape({\n ...options,\n elements: request.action.selectors.map((selector) => ({ selector })),\n });\n }\n case \"CapturePageStructured\": {\n return browser.json({\n ...options,\n response_format: {\n type: \"json_schema\",\n json_schema: request.action.responseFormat,\n },\n ...(request.action.prompt === undefined ? {} : { prompt: request.action.prompt }),\n });\n }\n }\n};\n\nconst protocolError = (message: string, cause?: unknown): PageCaptureProtocolError =>\n PageCaptureProtocolError.make({\n implementation: browserQuickActionImplementation,\n message: boundedDiagnostic(message),\n ...(cause === undefined ? {} : { cause }),\n });\n\nconst navigationError = (message: string, cause?: unknown): PageCaptureNavigationError =>\n PageCaptureNavigationError.make({\n implementation: browserQuickActionImplementation,\n message: boundedDiagnostic(message),\n ...(cause === undefined ? {} : { cause }),\n });\n\n/** Preserve bounded remote diagnostics for the host without exposing their text to a model. */\nconst privateResponseCause = (bodyText: string, response: Response): Error =>\n // oxlint-disable-next-line effect/no-native-error -- Bounded foreign response diagnostic retains host metadata as cause, never as the Effect failure.\n new Error(boundedDiagnostic(bodyText), {\n cause: {\n provider: \"cloudflare-browser-run\",\n httpStatus: response.status,\n httpStatusSource: \"browser-api\",\n headers: Object.fromEntries(\n [\"content-type\", \"cf-ray\", \"x-request-id\", \"retry-after\", \"x-browser-ms-used\"].flatMap(\n (name) => {\n const value = response.headers.get(name);\n\n return value === null ? [] : [[name, boundedDiagnostic(value)]];\n },\n ),\n ),\n bodyCharacters: bodyText.length,\n bodyTruncated: bodyText.length > MAX_DIAGNOSTIC_LENGTH,\n },\n });\n\n/** Foreign cancellation must not keep a response Scope open indefinitely. */\nconst cancelResponse = (cancel: () => Promise<void>, warning: string): Effect.Effect<void> =>\n Effect.tryPromise({ try: cancel, catch: () => undefined }).pipe(\n Effect.interruptible,\n Effect.timeoutOrElse({\n duration: \"1 second\",\n orElse: () => Effect.fail(undefined),\n }),\n Effect.catch(() => Effect.logWarning(warning)),\n );\n\nconst releaseResponseReader = (\n reader: ReadableStreamDefaultReader<Uint8Array>,\n): Effect.Effect<void> =>\n cancelResponse(() => reader.cancel(), \"Canceling the Quick Action response failed\").pipe(\n Effect.ensuring(\n Effect.try({\n try: () => reader.releaseLock(),\n catch: (cause) => protocolError(\"Releasing the Quick Action response failed\", cause),\n }).pipe(Effect.catch((error) => Effect.logWarning(error.message))),\n ),\n );\n\nconst readBoundedResponse = Effect.fnUntraced(function* (\n response: Response,\n request: PageCaptureRequest,\n) {\n const body = response.body;\n\n if (body === null) return \"\";\n\n const reader = yield* Effect.acquireRelease(\n Effect.try({\n try: () => body.getReader(),\n catch: (cause) => protocolError(\"Opening the Quick Action response failed\", cause),\n }),\n releaseResponseReader,\n );\n\n const decoder = new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: false });\n let observedBytes = 0;\n let bodyText = \"\";\n\n while (true) {\n const chunk = yield* Effect.tryPromise({\n try: () => reader.read(),\n catch: (cause) => protocolError(\"Reading the Quick Action response failed\", cause),\n });\n\n if (chunk.done) break;\n\n observedBytes += chunk.value.byteLength;\n if (observedBytes > request.limits.maxOutputBytes) {\n return yield* PageCaptureOutputLimitError.make({\n implementation: browserQuickActionImplementation,\n limit: request.limits.maxOutputBytes,\n observed: observedBytes,\n });\n }\n\n bodyText += yield* Effect.try({\n try: () => decoder.decode(chunk.value, { stream: true }),\n catch: (cause) => protocolError(\"Decoding the Quick Action response failed\", cause),\n });\n }\n\n return (\n bodyText +\n (yield* Effect.try({\n try: () => decoder.decode(),\n catch: (cause) => protocolError(\"Decoding the Quick Action response failed\", cause),\n }))\n );\n}, Effect.scoped);\n\n/**\n * Retry-After arrives in whole seconds; a non-integer form (an HTTP date) is\n * dropped rather than guessed at.\n */\nconst retryAfterMillis = (response: Response): number | undefined => {\n const header = response.headers.get(\"Retry-After\");\n\n if (header === null) return undefined;\n const seconds = Number(header);\n\n if (!Number.isSafeInteger(seconds) || seconds < 0) return undefined;\n const millis = seconds * 1_000;\n\n return Number.isSafeInteger(millis) ? millis : undefined;\n};\n\nconst browserMillis = (response: Response): number | undefined => {\n const header = response.headers.get(\"X-Browser-Ms-Used\");\n\n if (header === null) return undefined;\n const millis = Number(header);\n\n return Number.isSafeInteger(millis) && millis >= 0 ? millis : undefined;\n};\n\n/** Only trusted response metadata chooses transport framing; page text never does. */\nconst isJsonResponse = (response: Response): boolean => {\n const contentType = response.headers.get(\"Content-Type\");\n\n if (contentType === null) return false;\n const mediaType = contentType.split(\";\", 1)[0]?.trim().toLowerCase();\n\n return mediaType === \"application/json\" || mediaType?.endsWith(\"+json\") === true;\n};\n\nconst parseOutput = (\n action: PageCaptureAction,\n bodyText: string,\n response: Response,\n): PageCaptureOutput | PageCaptureNavigationError | PageCaptureProtocolError => {\n if (!isJsonResponse(response)) {\n return protocolError(\n \"The Quick Action success response was not a JSON response envelope\",\n privateResponseCause(bodyText, response),\n );\n }\n const envelope = decodeEnvelope(bodyText);\n\n if (Option.isNone(envelope)) {\n return protocolError(\n \"The JSON Quick Action response did not carry a valid response envelope\",\n privateResponseCause(bodyText, response),\n );\n }\n if (!envelope.value.success) {\n return navigationError(\n navigationFailureMessage(bodyText, response),\n privateResponseCause(bodyText, response),\n );\n }\n switch (action._tag) {\n case \"CapturePageContent\":\n case \"CapturePageMarkdown\": {\n if (typeof envelope.value.result !== \"string\") {\n return protocolError(\"The Quick Action envelope carried a non-text result\");\n }\n\n return action._tag === \"CapturePageContent\"\n ? PageContentCaptured.make({ html: envelope.value.result })\n : PageMarkdownCaptured.make({ markdown: envelope.value.result });\n }\n case \"CapturePageLinks\": {\n const decoded = Schema.decodeUnknownOption(PageLinksCaptured)({\n _tag: \"PageLinksCaptured\",\n links: envelope.value.result,\n });\n\n if (Option.isNone(decoded)) {\n return protocolError(\"The links Quick Action did not return a bounded array of valid URLs\");\n }\n\n return decoded.value;\n }\n case \"CapturePageScrape\": {\n const decoded = Schema.decodeUnknownOption(PageScrapeCaptured)({\n _tag: \"PageScrapeCaptured\",\n groups: envelope.value.result,\n });\n\n if (Option.isNone(decoded)) {\n return protocolError(\n \"The scrape Quick Action did not return bounded grouped element records\",\n );\n }\n\n return decoded.value;\n }\n case \"CapturePageStructured\": {\n return PageStructuredCaptured.make({ value: envelope.value.result });\n }\n }\n};\n\nconst isQuotaMessage = (text: string): boolean => /time limit|daily|quota/i.test(text);\n\nconst makeCapture = (\n browser: BrowserQuickActionClient,\n workersAi?: BrowserQuickActionWorkersAiPolicy,\n): PageCaptureCapture =>\n Effect.fnUntraced(function* (\n request: PageCaptureRequest,\n ): Effect.fn.Return<PageCaptureResult, PageCaptureError> {\n if (request.engine !== \"chromium\") {\n return yield* PageCaptureUnsupportedError.make({\n implementation: browserQuickActionImplementation,\n feature: \"engine\",\n message:\n \"The browser binding's quickAction() exposes no engine selector; kitesurf requires the REST or CDP surface\",\n });\n }\n\n const usesWorkersAi = request.action._tag === \"CapturePageStructured\";\n\n if (usesWorkersAi) {\n if (workersAi === undefined) {\n return yield* PageCaptureUnsupportedError.make({\n implementation: browserQuickActionImplementation,\n feature: \"action\",\n message:\n \"Structured capture invokes separately billed Workers AI and requires an explicit authorization and accounting policy\",\n });\n }\n yield* workersAi.authorizeAndAccount(request).pipe(\n Effect.mapError((cause) =>\n PageCaptureInferencePolicyError.make({\n implementation: browserQuickActionImplementation,\n provider: \"cloudflare-workers-ai\",\n reason: cause.reason,\n message:\n cause.reason === \"authorization\"\n ? \"Workers AI extraction was not authorized\"\n : \"Workers AI extraction could not be accounted for\",\n cause,\n }),\n ),\n );\n }\n\n const response = yield* executeQuickAction(browser, request).pipe(\n Effect.mapError((error) =>\n protocolError(\"The browser binding rejected the Quick Action\", error.cause),\n ),\n );\n\n const bodyText = yield* readBoundedResponse(response, request);\n\n if (response.status === 429) {\n const retryAfter = retryAfterMillis(response);\n const reason = isQuotaMessage(bodyText) ? \"quota\" : \"rate\";\n const cause = privateResponseCause(bodyText, response);\n\n return yield* PageCaptureRateLimitedError.make({\n implementation: browserQuickActionImplementation,\n reason,\n ...(retryAfter === undefined ? {} : { retryAfterMillis: retryAfter }),\n ...(cause === undefined ? {} : { cause }),\n message:\n reason === \"quota\"\n ? \"The Quick Action exceeded its browser quota\"\n : \"The Quick Action was rate limited\",\n });\n }\n if (!response.ok) {\n const message = navigationFailureMessage(bodyText, response);\n const cause = privateResponseCause(bodyText, response);\n\n if (response.status >= 500) {\n return yield* protocolError(message, cause);\n }\n\n return yield* navigationError(message, cause);\n }\n const output = parseOutput(request.action, bodyText, response);\n\n if (\n output._tag === \"PageCaptureNavigationError\" ||\n output._tag === \"PageCaptureProtocolError\"\n ) {\n return yield* output;\n }\n const millis = browserMillis(response);\n\n return PageCaptureResult.make({\n implementation: browserQuickActionImplementation,\n output,\n resourceUse: PageCaptureResourceUse.make({\n ...(millis === undefined ? {} : { browserMillis: millis }),\n ...(usesWorkersAi\n ? {\n inference: PageCaptureInferenceUse.make({\n provider: \"cloudflare-workers-ai\",\n modelCalls: 1,\n }),\n }\n : {}),\n }),\n });\n });\n\n/**\n * Ordinary Quick Actions require host-owned browser binding authority. Workers\n * AI stays unavailable unless the host deliberately selects its separate Layer.\n */\nexport const browserQuickActionCaptureLayer = (): Layer.Layer<\n PageCapture,\n never,\n BrowserQuickActionBrowserBinding\n> =>\n Layer.effect(\n PageCapture,\n Effect.map(BrowserQuickActionBrowserBinding, (browser) =>\n PageCapture.of({ capture: makeCapture(browser) }),\n ),\n );\n\n/** Structured Quick Actions require host-owned browser and Workers AI authority. */\nexport const browserQuickActionWorkersAiCaptureLayer = (): Layer.Layer<\n PageCapture,\n never,\n BrowserQuickActionBrowserBinding | BrowserQuickActionWorkersAi\n> =>\n Layer.effect(\n PageCapture,\n Effect.gen(function* () {\n const browser = yield* BrowserQuickActionBrowserBinding;\n const workersAi = yield* BrowserQuickActionWorkersAi;\n\n return PageCapture.of({ capture: makeCapture(browser, workersAi) });\n }),\n );\n\n/** Host-owned Quick Action binding and optional, separately billed extraction authority. */\nexport interface CloudflareBrowserOptions extends BrowserQuickActionCaptureOptions {\n readonly workersAi?: BrowserQuickActionWorkersAiPolicy;\n}\n\n/** Compose WebCapture handlers with the Cloudflare Quick Action adapter. */\nexport const CloudflareBrowser = {\n /**\n * Supply a WebCapture definition and the resolved Worker browser binding.\n * Supports capture, scrape, and extraction definitions without importing capabilities.\n * Only PageCapture is provided; other handler requirements and errors stay visible.\n * Extraction fails closed unless workersAi explicitly authorizes and accounts for it.\n * Capture limits, typed failures, tracing, and scoped response cleanup are unchanged.\n */\n layer: <A, E, R>(\n definition: { readonly handlers: Layer.Layer<A, E, R> },\n options: CloudflareBrowserOptions,\n ): Layer.Layer<A, E, Exclude<R, PageCapture>> => {\n const capture =\n options.workersAi === undefined\n ? browserQuickActionCaptureLayer()\n : browserQuickActionWorkersAiCaptureLayer().pipe(\n Layer.provide(BrowserQuickActionWorkersAi.layer(options.workersAi)),\n );\n\n return definition.handlers.pipe(\n Layer.provide(capture.pipe(Layer.provide(BrowserQuickActionBrowserBinding.layer(options)))),\n );\n },\n};\n\nconst screenshotOptions = (request: PageScreenshotRequest): BrowserRunScreenshotOptions => {\n const options: BrowserRunBaseOptions = {};\n\n if (\n request.navigation?.waitUntil !== undefined ||\n request.navigation?.timeoutMillis !== undefined\n ) {\n options.gotoOptions = {\n ...(request.navigation.waitUntil === undefined\n ? {}\n : { waitUntil: request.navigation.waitUntil }),\n ...(request.navigation.timeoutMillis === undefined\n ? {}\n : { timeout: request.navigation.timeoutMillis }),\n };\n }\n if (request.navigation?.waitForSelector !== undefined) {\n options.waitForSelector = {\n selector: request.navigation.waitForSelector.selector,\n ...(request.navigation.waitForSelector.timeoutMillis === undefined\n ? {}\n : { timeout: request.navigation.waitForSelector.timeoutMillis }),\n };\n }\n if (request.viewport !== undefined) {\n options.viewport = { width: request.viewport.width, height: request.viewport.height };\n }\n if (request.resourcePolicy?.rejectResourceTypes !== undefined) {\n options.rejectResourceTypes = [...request.resourcePolicy.rejectResourceTypes];\n }\n if (request.resourcePolicy?.allowRequestPatterns !== undefined) {\n options.allowRequestPattern = [...request.resourcePolicy.allowRequestPatterns];\n }\n\n return {\n ...options,\n ...(request.target._tag === \"PageUrlTarget\"\n ? { url: request.target.url }\n : { html: request.target.html }),\n screenshotOptions: { type: \"png\", encoding: \"binary\", fullPage: request.fullPage },\n };\n};\n\nconst cancelBody = (body: ReadableStream<Uint8Array>): Effect.Effect<void> =>\n cancelResponse(() => body.cancel(), \"Canceling the screenshot response failed\");\n\nconst releaseScreenshotReader = (\n reader: ReadableStreamDefaultReader<Uint8Array>,\n): Effect.Effect<void> =>\n cancelResponse(() => reader.cancel(), \"Canceling the screenshot response failed\").pipe(\n Effect.ensuring(\n Effect.try({\n try: () => reader.releaseLock(),\n catch: () => undefined,\n }).pipe(Effect.catch(() => Effect.logWarning(\"Releasing the screenshot response failed\"))),\n ),\n );\n\nconst pngResponse = (response: Response): boolean =>\n response.headers.get(\"Content-Type\")?.split(\";\", 1)[0]?.trim().toLowerCase() === \"image/png\";\n\nconst declaredLength = (response: Response): number | undefined => {\n const raw = response.headers.get(\"Content-Length\");\n\n if (raw === null || !/^(0|[1-9][0-9]*)$/.test(raw)) return undefined;\n const length = Number(raw);\n\n return Number.isSafeInteger(length) ? length : undefined;\n};\n\nconst readScreenshot = Effect.fnUntraced(function* (\n response: Response,\n request: PageScreenshotRequest,\n) {\n const body = response.body;\n\n if (body === null) {\n return yield* protocolError(\"The screenshot response had no body\");\n }\n if (!pngResponse(response)) {\n yield* cancelBody(body);\n\n return yield* protocolError(\"The screenshot response was not image/png\");\n }\n const length = declaredLength(response);\n\n if (length !== undefined && length > request.limits.maxOutputBytes) {\n yield* cancelBody(body);\n\n return yield* PageScreenshotOutputLimitError.make({\n implementation: browserQuickActionImplementation,\n limit: request.limits.maxOutputBytes,\n observed: length,\n });\n }\n\n const reader = yield* Effect.acquireRelease(\n Effect.try({\n try: () => body.getReader(),\n catch: (cause) => protocolError(\"Opening the screenshot response failed\", cause),\n }),\n releaseScreenshotReader,\n );\n\n const chunks: Array<Uint8Array> = [];\n let observed = 0;\n\n while (true) {\n const next = yield* Effect.tryPromise({\n try: () => reader.read(),\n catch: (cause) => protocolError(\"Reading the screenshot response failed\", cause),\n });\n\n if (next.done) break;\n observed += next.value.byteLength;\n if (observed > request.limits.maxOutputBytes) {\n return yield* PageScreenshotOutputLimitError.make({\n implementation: browserQuickActionImplementation,\n limit: request.limits.maxOutputBytes,\n observed,\n });\n }\n chunks.push(next.value);\n }\n const bytes = new Uint8Array(observed);\n let offset = 0;\n\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n\n return bytes;\n}, Effect.scoped);\n\nconst makeScreenshot = (browser: BrowserQuickActionClient): PageScreenshotCapture =>\n Effect.fnUntraced(function* (\n request: PageScreenshotRequest,\n ): Effect.fn.Return<PageScreenshotResult, PageScreenshotError> {\n if (request.engine !== \"chromium\") {\n return yield* PageCaptureUnsupportedError.make({\n implementation: browserQuickActionImplementation,\n feature: \"engine\",\n message: \"The browser binding's screenshot action exposes no engine selector\",\n });\n }\n\n const response = yield* browser\n .screenshot(screenshotOptions(request))\n .pipe(\n Effect.mapError((error) =>\n protocolError(\"The browser binding rejected the screenshot\", error.cause),\n ),\n );\n\n if (response.status === 429) {\n const body = response.body;\n\n if (body !== null) yield* cancelBody(body);\n\n return yield* PageCaptureRateLimitedError.make({\n implementation: browserQuickActionImplementation,\n reason: \"rate\",\n ...(retryAfterMillis(response) === undefined\n ? {}\n : { retryAfterMillis: retryAfterMillis(response) }),\n message: \"The screenshot Quick Action was rate limited\",\n });\n }\n if (!response.ok) {\n const body = response.body;\n\n if (body !== null) yield* cancelBody(body);\n const message = `The screenshot Quick Action answered HTTP ${response.status}`;\n\n return yield* response.status >= 500 ? protocolError(message) : navigationError(message);\n }\n const bytes = yield* readScreenshot(response, request);\n\n return PageScreenshotResult.make({\n implementation: browserQuickActionImplementation,\n mediaType: \"image/png\",\n bytes,\n });\n });\n\n/** Native Browser Run screenshot adapter. It retains PNG bytes only for the caller's result. */\nexport const browserQuickActionScreenshotLayer = (): Layer.Layer<\n PageScreenshot,\n never,\n BrowserQuickActionBrowserBinding\n> =>\n Layer.effect(\n PageScreenshot,\n Effect.map(BrowserQuickActionBrowserBinding, (browser) =>\n PageScreenshot.of({ capture: makeScreenshot(browser) }),\n ),\n );\n","/** Public CloudflareBrowser API. Implementation helpers remain private. */\nexport {\n BrowserQuickActionBrowserBinding,\n BrowserQuickActionRpcError,\n BrowserQuickActionWorkersAi,\n BrowserQuickActionWorkersAiPolicyError,\n browserQuickActionCaptureLayer,\n browserQuickActionWorkersAiCaptureLayer,\n browserQuickActionScreenshotLayer,\n CloudflareBrowser,\n type BrowserQuickActionCaptureOptions,\n type BrowserQuickActionClient,\n type BrowserQuickActionWorkersAiPolicy,\n type CloudflareBrowserOptions,\n} from \"./internal/browser-quick-action.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;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S,WAAW,KAAK;EAC3B,MAAM,OAAO,SAAS;EAEtB,IAAI,SAAS,MAAM,OAAO,WAAW,IAAI;EAEzC,OAAO,OAAO,4BAA4B,KAAK;GAC7C,gBAAgB;GAChB,QAAQ;GACR,GAAI,iBAAiB,QAAQ,MAAM,KAAA,IAC/B,CAAC,IACD,EAAE,kBAAkB,iBAAiB,QAAQ,EAAE;GACnD,SAAS;EACX,CAAC;CACH;CACA,IAAI,CAAC,SAAS,IAAI;EAChB,MAAM,OAAO,SAAS;EAEtB,IAAI,SAAS,MAAM,OAAO,WAAW,IAAI;EACzC,MAAM,UAAU,6CAA6C,SAAS;EAEtE,OAAO,OAAO,SAAS,UAAU,MAAM,cAAc,OAAO,IAAI,gBAAgB,OAAO;CACzF;CACA,MAAM,QAAQ,OAAO,eAAe,UAAU,OAAO;CAErD,OAAO,qBAAqB,KAAK;EAC/B,gBAAgB;EAChB,WAAW;EACX;CACF,CAAC;AACH,CAAC;;AAGH,MAAa,0CAKX,MAAM,OACJ,gBACA,OAAO,IAAI,mCAAmC,YAC5C,eAAe,GAAG,EAAE,SAAS,eAAe,OAAO,EAAE,CAAC,CACxD,CACF"}
@@ -1,2 +1,2 @@
1
- import { a as BrowserQuickActionRpcError, c as BrowserQuickActionWorkersAiPolicyError, d as browserQuickActionCaptureLayer, f as browserQuickActionScreenshotLayer, i as BrowserQuickActionClient, l as CloudflareBrowser, n as BrowserQuickActionBrowserBinding, o as BrowserQuickActionWorkersAi, p as browserQuickActionWorkersAiCaptureLayer, r as BrowserQuickActionCaptureOptions, s as BrowserQuickActionWorkersAiPolicy, u as CloudflareBrowserOptions } from "./CloudflareBrowser-gu7gma0Y.mjs";
1
+ import { a as BrowserQuickActionRpcError, c as BrowserQuickActionWorkersAiPolicyError, d as browserQuickActionCaptureLayer, f as browserQuickActionScreenshotLayer, i as BrowserQuickActionClient, l as CloudflareBrowser, n as BrowserQuickActionBrowserBinding, o as BrowserQuickActionWorkersAi, p as browserQuickActionWorkersAiCaptureLayer, r as BrowserQuickActionCaptureOptions, s as BrowserQuickActionWorkersAiPolicy, u as CloudflareBrowserOptions } from "./CloudflareBrowser-DS6GodKz.mjs";
2
2
  export { BrowserQuickActionBrowserBinding, type BrowserQuickActionCaptureOptions, type BrowserQuickActionClient, BrowserQuickActionRpcError, BrowserQuickActionWorkersAi, type BrowserQuickActionWorkersAiPolicy, BrowserQuickActionWorkersAiPolicyError, CloudflareBrowser, type CloudflareBrowserOptions, browserQuickActionCaptureLayer, browserQuickActionScreenshotLayer, browserQuickActionWorkersAiCaptureLayer };
@@ -1,2 +1,2 @@
1
- import { a as BrowserQuickActionWorkersAiPolicyError, c as browserQuickActionScreenshotLayer, i as BrowserQuickActionWorkersAi, l as browserQuickActionWorkersAiCaptureLayer, n as BrowserQuickActionBrowserBinding, o as CloudflareBrowser, r as BrowserQuickActionRpcError, s as browserQuickActionCaptureLayer } from "./CloudflareBrowser-Vt8qTdYW.mjs";
1
+ import { a as BrowserQuickActionWorkersAiPolicyError, c as browserQuickActionScreenshotLayer, i as BrowserQuickActionWorkersAi, l as browserQuickActionWorkersAiCaptureLayer, n as BrowserQuickActionBrowserBinding, o as CloudflareBrowser, r as BrowserQuickActionRpcError, s as browserQuickActionCaptureLayer } from "./CloudflareBrowser-DrZQwovV.mjs";
2
2
  export { BrowserQuickActionBrowserBinding, BrowserQuickActionRpcError, BrowserQuickActionWorkersAi, BrowserQuickActionWorkersAiPolicyError, CloudflareBrowser, browserQuickActionCaptureLayer, browserQuickActionScreenshotLayer, browserQuickActionWorkersAiCaptureLayer };
@@ -1,5 +1,5 @@
1
- import { Effect, Layer } from "effect";
2
1
  import { SandboxImplementation } from "@yielded/agent/sandbox";
2
+ import { Effect, Layer } from "effect";
3
3
  import { CodeExecutor } from "@yielded/agent/code-executor";
4
4
  declare namespace CloudflareCodeMode_d_exports {
5
5
  export { CloudflareCodeMode, DynamicWorkerCodeExecutorOptions, disposeRpcHandle, dynamicWorkerCodeExecutorLayer, dynamicWorkerImplementation };
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { n as safeCauseDiagnostic, r as safeCauseMessage } from "./boundary-BguazVkh.mjs";
3
- import { Clock, Duration, Effect, Exit, Fiber, Layer, Option, Queue, Schema } from "effect";
2
+ import { n as safeCauseDiagnostic, r as safeCauseMessage } from "./boundary-BLbZMBl2.mjs";
4
3
  import { SandboxImplementation } from "@yielded/agent/sandbox";
4
+ import { Clock, Duration, Effect, Exit, Fiber, Layer, Option, Queue, Schema } from "effect";
5
5
  import { CodeExecutionHost, CodeExecutionProtocolError, CodeExecutionResourceUse, CodeExecutionResult, CodeExecutionTimeoutError, CodeExecutor, CodeExecutorStartError, CodeExecutorTerminatedError, CodeExecutorUnsupportedError, CodeHostCall, CodeHostCallLimitError, CodeHostCallResult, CodeOutputLimitError, CodeProgramFailedError, CodeSourceError } from "@yielded/agent/code-executor";
6
6
  import { RpcTarget } from "cloudflare:workers";
7
7
  //#region src/CloudflareCodeMode.ts
@@ -1,9 +1,12 @@
1
- import { Context, Schema } from "effect";
1
+ import * as Context from "effect/Context";
2
+ import * as Schema from "effect/Schema";
2
3
  declare namespace CloudflareConfig_d_exports {
3
- export { AdmissionLimitExceeded, AuxiliaryDispatchMillis, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, CloudflareAdmissionLimitsValue, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflarePlatformConfigError, DEFAULT_MAX_DATABASE_BYTES };
4
+ export { AdmissionLimitExceeded, AuxiliaryDispatchMillis, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, CloudflareAdmissionLimitsValue, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflarePlatformConfigError, DEFAULT_MAX_DATABASE_BYTES, DEFAULT_RECOVERY_WINDOW_MILLIS };
4
5
  }
5
6
  /** Maximum supported auxiliary wave equals the native message policy's five-minute ceiling. */
6
7
  declare const AuxiliaryDispatchMillis: Schema.Int;
8
+ /** Recovery coverage retained after activity; independent of work-start and retry deadlines. */
9
+ declare const DEFAULT_RECOVERY_WINDOW_MILLIS = 60000;
7
10
  declare const CloudflarePlatformConfigError_base: Schema.Class<CloudflarePlatformConfigError, Schema.TaggedStruct<"CloudflarePlatformConfigError", {
8
11
  readonly message: Schema.String;
9
12
  readonly cause: Schema.optionalKey<Schema.Defect>;
@@ -47,10 +50,12 @@ declare const CloudflareDurableRuntimeConfigValue_base: Schema.Class<CloudflareD
47
50
  readonly deploymentId: Schema.brand<Schema.NonEmptyString, "@effect-agent/thread/DeploymentId">;
48
51
  /** Head of the minted producer identity `{producerPrefix}:{threadId}`. */
49
52
  readonly producerPrefix: Schema.NonEmptyString;
53
+ /** Recovery-only window. Zero restores immediate idle cancellation and the short guards. */
54
+ readonly recoveryWindowMillis: Schema.Int;
50
55
  /**
51
56
  * Base delay of exponential backoff when a pass fails or makes no progress.
52
- * Half this delay (rounded up, at least 1ms) also pre-arms mutations, including
53
- * healthy admissions. `alarmBackoffCap` does not cap that pre-arm delay.
57
+ * Half this delay (rounded up, at least 1ms) starts alarm-driven work and recovers
58
+ * startup work. It also pre-arms mutations when the recovery window is disabled.
54
59
  */
55
60
  readonly alarmBackoffBase: Schema.Int;
56
61
  /** Ceiling of exponential backoff after failed or no-progress maintenance passes. */
@@ -81,6 +86,7 @@ declare const CloudflareDurableRuntimeConfig_base: Context.ServiceClass<Cloudfla
81
86
  declare class CloudflareDurableRuntimeConfig extends CloudflareDurableRuntimeConfig_base {}
82
87
  /** Documented production defaults applied by `ThreadObject.layer`. */
83
88
  declare const CLOUDFLARE_RUNTIME_DEFAULTS: {
89
+ readonly recoveryWindowMillis: 60000;
84
90
  readonly alarmBackoffBase: 100;
85
91
  readonly alarmBackoffCap: 5000;
86
92
  readonly settlementPollInterval: 500;
@@ -94,5 +100,5 @@ declare const CLOUDFLARE_RUNTIME_DEFAULTS: {
94
100
  readonly maxDatabaseBytes: 9000000000;
95
101
  };
96
102
  //#endregion
97
- export { CloudflareAdmissionLimitsValue as a, CloudflareDurableRuntimeConfigValue as c, CLOUDFLARE_RUNTIME_DEFAULTS as i, CloudflarePlatformConfigError as l, AuxiliaryDispatchMillis as n, CloudflareConfig_d_exports as o, CLOUDFLARE_DATABASE_CAP_BYTES as r, CloudflareDurableRuntimeConfig as s, AdmissionLimitExceeded as t, DEFAULT_MAX_DATABASE_BYTES as u };
98
- //# sourceMappingURL=CloudflareConfig-C9MvPbX8.d.mts.map
103
+ export { CloudflareAdmissionLimitsValue as a, CloudflareDurableRuntimeConfigValue as c, DEFAULT_RECOVERY_WINDOW_MILLIS as d, CLOUDFLARE_RUNTIME_DEFAULTS as i, CloudflarePlatformConfigError as l, AuxiliaryDispatchMillis as n, CloudflareConfig_d_exports as o, CLOUDFLARE_DATABASE_CAP_BYTES as r, CloudflareDurableRuntimeConfig as s, AdmissionLimitExceeded as t, DEFAULT_MAX_DATABASE_BYTES as u };
104
+ //# sourceMappingURL=CloudflareConfig-D_-BMp4q.d.mts.map
@@ -1,2 +1,2 @@
1
- import { a as CloudflareAdmissionLimitsValue, c as CloudflareDurableRuntimeConfigValue, i as CLOUDFLARE_RUNTIME_DEFAULTS, l as CloudflarePlatformConfigError, n as AuxiliaryDispatchMillis, r as CLOUDFLARE_DATABASE_CAP_BYTES, s as CloudflareDurableRuntimeConfig, t as AdmissionLimitExceeded, u as DEFAULT_MAX_DATABASE_BYTES } from "./CloudflareConfig-C9MvPbX8.mjs";
2
- export { AdmissionLimitExceeded, AuxiliaryDispatchMillis, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, CloudflareAdmissionLimitsValue, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflarePlatformConfigError, DEFAULT_MAX_DATABASE_BYTES };
1
+ import { a as CloudflareAdmissionLimitsValue, c as CloudflareDurableRuntimeConfigValue, d as DEFAULT_RECOVERY_WINDOW_MILLIS, i as CLOUDFLARE_RUNTIME_DEFAULTS, l as CloudflarePlatformConfigError, n as AuxiliaryDispatchMillis, r as CLOUDFLARE_DATABASE_CAP_BYTES, s as CloudflareDurableRuntimeConfig, t as AdmissionLimitExceeded, u as DEFAULT_MAX_DATABASE_BYTES } from "./CloudflareConfig-D_-BMp4q.mjs";
2
+ export { AdmissionLimitExceeded, AuxiliaryDispatchMillis, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, CloudflareAdmissionLimitsValue, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflarePlatformConfigError, DEFAULT_MAX_DATABASE_BYTES, DEFAULT_RECOVERY_WINDOW_MILLIS };
@@ -1,5 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { Context, Schema } from "effect";
2
+ import * as Context from "effect/Context";
3
+ import * as Schema from "effect/Schema";
3
4
  import { DeploymentId } from "@yielded/agent/records";
4
5
  import { DEFAULT_MAX_STORED_VALUE_BYTES } from "@yielded/agent-storage-cloudflare/do-storage-config";
5
6
  //#region src/CloudflareConfig.ts
@@ -12,7 +13,8 @@ var CloudflareConfig_exports = /* @__PURE__ */ __exportAll({
12
13
  CloudflareDurableRuntimeConfig: () => CloudflareDurableRuntimeConfig,
13
14
  CloudflareDurableRuntimeConfigValue: () => CloudflareDurableRuntimeConfigValue,
14
15
  CloudflarePlatformConfigError: () => CloudflarePlatformConfigError,
15
- DEFAULT_MAX_DATABASE_BYTES: () => DEFAULT_MAX_DATABASE_BYTES
16
+ DEFAULT_MAX_DATABASE_BYTES: () => DEFAULT_MAX_DATABASE_BYTES,
17
+ DEFAULT_RECOVERY_WINDOW_MILLIS: () => DEFAULT_RECOVERY_WINDOW_MILLIS
16
18
  });
17
19
  /**
18
20
  * Schema-validated configuration for the Cloudflare durable runtime (deployment spec §4:
@@ -23,6 +25,8 @@ const PositiveMillis = Schema.Int.check(Schema.isGreaterThan(0));
23
25
  /** Maximum supported auxiliary wave equals the native message policy's five-minute ceiling. */
24
26
  const AuxiliaryDispatchMillis = PositiveMillis.check(Schema.isLessThanOrEqualTo(3e5));
25
27
  const NonNegativeMillis = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
28
+ /** Recovery coverage retained after activity; independent of work-start and retry deadlines. */
29
+ const DEFAULT_RECOVERY_WINDOW_MILLIS = 6e4;
26
30
  /** The supplied Cloudflare durable runtime configuration failed validation (DEPLOY-003). */
27
31
  var CloudflarePlatformConfigError = class extends Schema.TaggedError()("CloudflarePlatformConfigError", {
28
32
  message: Schema.String,
@@ -75,10 +79,12 @@ var CloudflareDurableRuntimeConfigValue = class extends Schema.Class("@effect-ag
75
79
  deploymentId: DeploymentId,
76
80
  /** Head of the minted producer identity `{producerPrefix}:{threadId}`. */
77
81
  producerPrefix: Schema.NonEmptyString.check(Schema.isMaxLength(256)),
82
+ /** Recovery-only window. Zero restores immediate idle cancellation and the short guards. */
83
+ recoveryWindowMillis: NonNegativeMillis,
78
84
  /**
79
85
  * Base delay of exponential backoff when a pass fails or makes no progress.
80
- * Half this delay (rounded up, at least 1ms) also pre-arms mutations, including
81
- * healthy admissions. `alarmBackoffCap` does not cap that pre-arm delay.
86
+ * Half this delay (rounded up, at least 1ms) starts alarm-driven work and recovers
87
+ * startup work. It also pre-arms mutations when the recovery window is disabled.
82
88
  */
83
89
  alarmBackoffBase: PositiveMillis,
84
90
  /** Ceiling of exponential backoff after failed or no-progress maintenance passes. */
@@ -101,6 +107,7 @@ var CloudflareDurableRuntimeConfigValue = class extends Schema.Class("@effect-ag
101
107
  var CloudflareDurableRuntimeConfig = class extends Context.Service()("@effect-agent/platform-cloudflare/CloudflareDurableRuntimeConfig") {};
102
108
  /** Documented production defaults applied by `ThreadObject.layer`. */
103
109
  const CLOUDFLARE_RUNTIME_DEFAULTS = {
110
+ recoveryWindowMillis: DEFAULT_RECOVERY_WINDOW_MILLIS,
104
111
  alarmBackoffBase: 100,
105
112
  alarmBackoffCap: 5e3,
106
113
  settlementPollInterval: 500,
@@ -114,6 +121,6 @@ const CLOUDFLARE_RUNTIME_DEFAULTS = {
114
121
  maxDatabaseBytes: DEFAULT_MAX_DATABASE_BYTES
115
122
  };
116
123
  //#endregion
117
- export { AdmissionLimitExceeded, AuxiliaryDispatchMillis, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, CloudflareAdmissionLimitsValue, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflarePlatformConfigError, DEFAULT_MAX_DATABASE_BYTES, CloudflareConfig_exports as t };
124
+ export { AdmissionLimitExceeded, AuxiliaryDispatchMillis, CLOUDFLARE_DATABASE_CAP_BYTES, CLOUDFLARE_RUNTIME_DEFAULTS, CloudflareAdmissionLimitsValue, CloudflareDurableRuntimeConfig, CloudflareDurableRuntimeConfigValue, CloudflarePlatformConfigError, DEFAULT_MAX_DATABASE_BYTES, DEFAULT_RECOVERY_WINDOW_MILLIS, CloudflareConfig_exports as t };
118
125
 
119
126
  //# sourceMappingURL=CloudflareConfig.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CloudflareConfig.mjs","names":[],"sources":["../src/CloudflareConfig.ts"],"sourcesContent":["import { DEFAULT_MAX_STORED_VALUE_BYTES } from \"@yielded/agent-storage-cloudflare/do-storage-config\";\nimport { DeploymentId } from \"@yielded/agent/records\";\nimport { Context, Schema } from \"effect\";\n\n/**\n * Schema-validated configuration for the Cloudflare durable runtime (deployment spec §4:\n * decoded once during Layer construction, exposed as a typed service; DEPLOY-003). Every\n * cadence is in milliseconds; every bound is finite and checked before any resource opens.\n */\n\nconst PositiveMillis = Schema.Int.check(Schema.isGreaterThan(0));\n\n/** Maximum supported auxiliary wave equals the native message policy's five-minute ceiling. */\nexport const AuxiliaryDispatchMillis = PositiveMillis.check(Schema.isLessThanOrEqualTo(300_000));\nconst NonNegativeMillis = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));\n\n/** The supplied Cloudflare durable runtime configuration failed validation (DEPLOY-003). */\nexport class CloudflarePlatformConfigError extends Schema.TaggedError<CloudflarePlatformConfigError>()(\n \"CloudflarePlatformConfigError\",\n {\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/**\n * An admission was refused by a host resource limit BEFORE any ledger row existed\n * (deployment spec §8, DEPLOY-007: \"Admission has explicit bounded quota and overload\n * behavior... a typed rejection\"). This is the DC analogue of `NodeDurableHost`'s\n * `AdmissionClosed` host gate: the port surface stays untouched, the refusal happens in the\n * Thread Object's submit entry point before `DurableAgentRuntime.submit` runs, and\n * nothing was admitted or written.\n */\nexport class AdmissionLimitExceeded extends Schema.TaggedError<AdmissionLimitExceeded>()(\n \"AdmissionLimitExceeded\",\n {\n limit: Schema.Literals([\"queue-depth\", \"input-bytes\", \"database-bytes\"]),\n actual: Schema.Int,\n maximum: Schema.Int,\n },\n) {\n override get message() {\n return (\n `Admission refused before any ledger row existed: ${this.limit} ${this.actual} exceeds ` +\n `the configured maximum ${this.maximum}. Accepted work is unaffected; retry after the ` +\n \"lane drains or raise the limit (DEPLOY-007).\"\n );\n }\n}\n\n/** The platform's hard per-Object database cap (10 GB, developers.cloudflare.com limits). */\nexport const CLOUDFLARE_DATABASE_CAP_BYTES = 10_000_000_000;\n\n/** Default database-size admission ceiling: a 1 GB safety margin under the platform cap. */\nexport const DEFAULT_MAX_DATABASE_BYTES = 9_000_000_000;\n\n/**\n * Explicit bounded admission quotas checked by the Thread Object BEFORE admission\n * (exit gate \"resource limits are checked before admission\").\n */\nexport class CloudflareAdmissionLimitsValue extends Schema.Class<CloudflareAdmissionLimitsValue>(\n \"@effect-agent/platform-cloudflare/CloudflareAdmissionLimitsValue\",\n)({\n /** Maximum nonterminal Submissions per Thread lane before new admissions refuse. */\n maxQueueDepthPerLane: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(100_000),\n ),\n /** Maximum encoded input bytes; never above the storage per-value bound. */\n maxInputBytes: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(2_000_000)),\n /** Maximum `ctx.storage.sql.databaseSize` at admission; stays under the 10 GB platform cap. */\n maxDatabaseBytes: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(CLOUDFLARE_DATABASE_CAP_BYTES),\n ),\n}) {}\n\n/**\n * Validated Cloudflare durable runtime configuration. The producer identity of one\n * Thread Object is `{producerPrefix}:{threadId}` — stable across incarnations of\n * the same deployment, distinct across deployments. The Object owns its Thread exclusively;\n * scoped local generations reject callbacks from an earlier Run owner.\n */\nexport class CloudflareDurableRuntimeConfigValue extends Schema.Class<CloudflareDurableRuntimeConfigValue>(\n \"@effect-agent/platform-cloudflare/CloudflareDurableRuntimeConfigValue\",\n)({\n deploymentId: DeploymentId,\n /** Head of the minted producer identity `{producerPrefix}:{threadId}`. */\n producerPrefix: Schema.NonEmptyString.check(Schema.isMaxLength(256)),\n /**\n * Base delay of exponential backoff when a pass fails or makes no progress.\n * Half this delay (rounded up, at least 1ms) also pre-arms mutations, including\n * healthy admissions. `alarmBackoffCap` does not cap that pre-arm delay.\n */\n alarmBackoffBase: PositiveMillis,\n /** Ceiling of exponential backoff after failed or no-progress maintenance passes. */\n alarmBackoffCap: PositiveMillis,\n /** `awaitSettlement` ledger re-check cadence when no wake arrives. */\n settlementPollInterval: PositiveMillis,\n /** Active-Run abort-intent poll cadence. */\n abortPollInterval: PositiveMillis,\n /** Canonical observation poll cadence of the Durable Object store. */\n observationPollInterval: NonNegativeMillis,\n /** One disposable projection backfill wave; independent of required live applyCommitted. */\n projectionDispatchTimeoutMillis: AuxiliaryDispatchMillis,\n /** Per-value byte bound; must stay under the platform's 2 MB SQLite value limit. */\n maxStoredValueBytes: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(2_000_000),\n ),\n /** Opt-in full history and active-state validation while opening the store. */\n verifyOnOpen: Schema.Boolean,\n limits: CloudflareAdmissionLimitsValue,\n}) {}\n\n/** Explicit configuration authority for the assembled Cloudflare durable runtime. */\nexport class CloudflareDurableRuntimeConfig extends Context.Service<\n CloudflareDurableRuntimeConfig,\n CloudflareDurableRuntimeConfigValue\n>()(\"@effect-agent/platform-cloudflare/CloudflareDurableRuntimeConfig\") {}\n\n/** Documented production defaults applied by `ThreadObject.layer`. */\nexport const CLOUDFLARE_RUNTIME_DEFAULTS = {\n alarmBackoffBase: 100,\n alarmBackoffCap: 5_000,\n settlementPollInterval: 500,\n abortPollInterval: 500,\n observationPollInterval: 25,\n projectionDispatchTimeoutMillis: 30_000,\n maxStoredValueBytes: DEFAULT_MAX_STORED_VALUE_BYTES,\n verifyOnOpen: false,\n maxQueueDepthPerLane: 256,\n maxInputBytes: DEFAULT_MAX_STORED_VALUE_BYTES,\n maxDatabaseBytes: DEFAULT_MAX_DATABASE_BYTES,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,iBAAiB,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC;;AAG/D,MAAa,0BAA0B,eAAe,MAAM,OAAO,oBAAoB,GAAO,CAAC;AAC/F,MAAM,oBAAoB,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;;AAG3E,IAAa,gCAAb,cAAmD,OAAO,YAA2C,CAAC,CACpG,iCACA;CACE,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CACF,CAAC,CAAC,CAAC;;;;;;;;;AAUH,IAAa,yBAAb,cAA4C,OAAO,YAAoC,CAAC,CACtF,0BACA;CACE,OAAO,OAAO,SAAS;EAAC;EAAe;EAAe;CAAgB,CAAC;CACvE,QAAQ,OAAO;CACf,SAAS,OAAO;AAClB,CACF,CAAC,CAAC;CACA,IAAa,UAAU;EACrB,OACE,oDAAoD,KAAK,MAAM,GAAG,KAAK,OAAO,kCACpD,KAAK,QAAQ;CAG3C;AACF;;AAGA,MAAa,gCAAgC;;AAG7C,MAAa,6BAA6B;;;;;AAM1C,IAAa,iCAAb,cAAoD,OAAO,MACzD,kEACF,CAAC,CAAC;;CAEA,sBAAsB,OAAO,IAAI,MAC/B,OAAO,cAAc,CAAC,GACtB,OAAO,oBAAoB,GAAO,CACpC;;CAEA,eAAe,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,GAAG,OAAO,oBAAoB,GAAS,CAAC;;CAE9F,kBAAkB,OAAO,IAAI,MAC3B,OAAO,cAAc,CAAC,GACtB,OAAO,oBAAoB,6BAA6B,CAC1D;AACF,CAAC,CAAC,CAAC,CAAC;;;;;;;AAQJ,IAAa,sCAAb,cAAyD,OAAO,MAC9D,uEACF,CAAC,CAAC;CACA,cAAc;;CAEd,gBAAgB,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;;;;;;CAMnE,kBAAkB;;CAElB,iBAAiB;;CAEjB,wBAAwB;;CAExB,mBAAmB;;CAEnB,yBAAyB;;CAEzB,iCAAiC;;CAEjC,qBAAqB,OAAO,IAAI,MAC9B,OAAO,cAAc,CAAC,GACtB,OAAO,oBAAoB,GAAS,CACtC;;CAEA,cAAc,OAAO;CACrB,QAAQ;AACV,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,iCAAb,cAAoD,QAAQ,QAG1D,CAAC,CAAC,kEAAkE,CAAC,CAAC,CAAC;;AAGzE,MAAa,8BAA8B;CACzC,kBAAkB;CAClB,iBAAiB;CACjB,wBAAwB;CACxB,mBAAmB;CACnB,yBAAyB;CACzB,iCAAiC;CACjC,qBAAqB;CACrB,cAAc;CACd,sBAAsB;CACtB,eAAe;CACf,kBAAkB;AACpB"}
1
+ {"version":3,"file":"CloudflareConfig.mjs","names":[],"sources":["../src/CloudflareConfig.ts"],"sourcesContent":["import { DEFAULT_MAX_STORED_VALUE_BYTES } from \"@yielded/agent-storage-cloudflare/do-storage-config\";\nimport { DeploymentId } from \"@yielded/agent/records\";\nimport * as Context from \"effect/Context\";\nimport * as Schema from \"effect/Schema\";\n\n/**\n * Schema-validated configuration for the Cloudflare durable runtime (deployment spec §4:\n * decoded once during Layer construction, exposed as a typed service; DEPLOY-003). Every\n * cadence is in milliseconds; every bound is finite and checked before any resource opens.\n */\n\nconst PositiveMillis = Schema.Int.check(Schema.isGreaterThan(0));\n\n/** Maximum supported auxiliary wave equals the native message policy's five-minute ceiling. */\nexport const AuxiliaryDispatchMillis = PositiveMillis.check(Schema.isLessThanOrEqualTo(300_000));\nconst NonNegativeMillis = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));\n\n/** Recovery coverage retained after activity; independent of work-start and retry deadlines. */\nexport const DEFAULT_RECOVERY_WINDOW_MILLIS = 60_000;\n\n/** The supplied Cloudflare durable runtime configuration failed validation (DEPLOY-003). */\nexport class CloudflarePlatformConfigError extends Schema.TaggedError<CloudflarePlatformConfigError>()(\n \"CloudflarePlatformConfigError\",\n {\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/**\n * An admission was refused by a host resource limit BEFORE any ledger row existed\n * (deployment spec §8, DEPLOY-007: \"Admission has explicit bounded quota and overload\n * behavior... a typed rejection\"). This is the DC analogue of `NodeDurableHost`'s\n * `AdmissionClosed` host gate: the port surface stays untouched, the refusal happens in the\n * Thread Object's submit entry point before `DurableAgentRuntime.submit` runs, and\n * nothing was admitted or written.\n */\nexport class AdmissionLimitExceeded extends Schema.TaggedError<AdmissionLimitExceeded>()(\n \"AdmissionLimitExceeded\",\n {\n limit: Schema.Literals([\"queue-depth\", \"input-bytes\", \"database-bytes\"]),\n actual: Schema.Int,\n maximum: Schema.Int,\n },\n) {\n override get message() {\n return (\n `Admission refused before any ledger row existed: ${this.limit} ${this.actual} exceeds ` +\n `the configured maximum ${this.maximum}. Accepted work is unaffected; retry after the ` +\n \"lane drains or raise the limit (DEPLOY-007).\"\n );\n }\n}\n\n/** The platform's hard per-Object database cap (10 GB, developers.cloudflare.com limits). */\nexport const CLOUDFLARE_DATABASE_CAP_BYTES = 10_000_000_000;\n\n/** Default database-size admission ceiling: a 1 GB safety margin under the platform cap. */\nexport const DEFAULT_MAX_DATABASE_BYTES = 9_000_000_000;\n\n/**\n * Explicit bounded admission quotas checked by the Thread Object BEFORE admission\n * (exit gate \"resource limits are checked before admission\").\n */\nexport class CloudflareAdmissionLimitsValue extends Schema.Class<CloudflareAdmissionLimitsValue>(\n \"@effect-agent/platform-cloudflare/CloudflareAdmissionLimitsValue\",\n)({\n /** Maximum nonterminal Submissions per Thread lane before new admissions refuse. */\n maxQueueDepthPerLane: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(100_000),\n ),\n /** Maximum encoded input bytes; never above the storage per-value bound. */\n maxInputBytes: Schema.Int.check(Schema.isGreaterThan(0), Schema.isLessThanOrEqualTo(2_000_000)),\n /** Maximum `ctx.storage.sql.databaseSize` at admission; stays under the 10 GB platform cap. */\n maxDatabaseBytes: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(CLOUDFLARE_DATABASE_CAP_BYTES),\n ),\n}) {}\n\n/**\n * Validated Cloudflare durable runtime configuration. The producer identity of one\n * Thread Object is `{producerPrefix}:{threadId}` — stable across incarnations of\n * the same deployment, distinct across deployments. The Object owns its Thread exclusively;\n * scoped local generations reject callbacks from an earlier Run owner.\n */\nexport class CloudflareDurableRuntimeConfigValue extends Schema.Class<CloudflareDurableRuntimeConfigValue>(\n \"@effect-agent/platform-cloudflare/CloudflareDurableRuntimeConfigValue\",\n)({\n deploymentId: DeploymentId,\n /** Head of the minted producer identity `{producerPrefix}:{threadId}`. */\n producerPrefix: Schema.NonEmptyString.check(Schema.isMaxLength(256)),\n /** Recovery-only window. Zero restores immediate idle cancellation and the short guards. */\n recoveryWindowMillis: NonNegativeMillis,\n /**\n * Base delay of exponential backoff when a pass fails or makes no progress.\n * Half this delay (rounded up, at least 1ms) starts alarm-driven work and recovers\n * startup work. It also pre-arms mutations when the recovery window is disabled.\n */\n alarmBackoffBase: PositiveMillis,\n /** Ceiling of exponential backoff after failed or no-progress maintenance passes. */\n alarmBackoffCap: PositiveMillis,\n /** `awaitSettlement` ledger re-check cadence when no wake arrives. */\n settlementPollInterval: PositiveMillis,\n /** Active-Run abort-intent poll cadence. */\n abortPollInterval: PositiveMillis,\n /** Canonical observation poll cadence of the Durable Object store. */\n observationPollInterval: NonNegativeMillis,\n /** One disposable projection backfill wave; independent of required live applyCommitted. */\n projectionDispatchTimeoutMillis: AuxiliaryDispatchMillis,\n /** Per-value byte bound; must stay under the platform's 2 MB SQLite value limit. */\n maxStoredValueBytes: Schema.Int.check(\n Schema.isGreaterThan(0),\n Schema.isLessThanOrEqualTo(2_000_000),\n ),\n /** Opt-in full history and active-state validation while opening the store. */\n verifyOnOpen: Schema.Boolean,\n limits: CloudflareAdmissionLimitsValue,\n}) {}\n\n/** Explicit configuration authority for the assembled Cloudflare durable runtime. */\nexport class CloudflareDurableRuntimeConfig extends Context.Service<\n CloudflareDurableRuntimeConfig,\n CloudflareDurableRuntimeConfigValue\n>()(\"@effect-agent/platform-cloudflare/CloudflareDurableRuntimeConfig\") {}\n\n/** Documented production defaults applied by `ThreadObject.layer`. */\nexport const CLOUDFLARE_RUNTIME_DEFAULTS = {\n recoveryWindowMillis: DEFAULT_RECOVERY_WINDOW_MILLIS,\n alarmBackoffBase: 100,\n alarmBackoffCap: 5_000,\n settlementPollInterval: 500,\n abortPollInterval: 500,\n observationPollInterval: 25,\n projectionDispatchTimeoutMillis: 30_000,\n maxStoredValueBytes: DEFAULT_MAX_STORED_VALUE_BYTES,\n verifyOnOpen: false,\n maxQueueDepthPerLane: 256,\n maxInputBytes: DEFAULT_MAX_STORED_VALUE_BYTES,\n maxDatabaseBytes: DEFAULT_MAX_DATABASE_BYTES,\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAWA,MAAM,iBAAiB,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC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EjC,qBAAqB,OAAO,IAAI,MAC9B,OAAO,cAAc,CAAC,GACtB,OAAO,oBAAoB,GAAS,CACtC;;CAEA,cAAc,OAAO;CACrB,QAAQ;AACV,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,iCAAb,cAAoD,QAAQ,QAG1D,CAAC,CAAC,kEAAkE,CAAC,CAAC,CAAC;;AAGzE,MAAa,8BAA8B;CACzC,sBAAsB;CACtB,kBAAkB;CAClB,iBAAiB;CACjB,wBAAwB;CACxB,mBAAmB;CACnB,yBAAyB;CACzB,iCAAiC;CACjC,qBAAqB;CACrB,cAAc;CACd,sBAAsB;CACtB,eAAe;CACf,kBAAkB;AACpB"}
@@ -1,6 +1,6 @@
1
1
  import { Principal } from "@yielded/agent/submission-ledger";
2
- import { Context, Effect, Layer } from "effect";
3
2
  import { DurableObject, DurableObjectState, WorkerEnvironment } from "effect-cf";
3
+ import { Context, Effect, Layer } from "effect";
4
4
  import { DoMemoryStorageLimits } from "@yielded/agent-storage-cloudflare/do-memory-store";
5
5
  import { MemoryOwnerAuthorizer, MemoryOwnerIdentity, MemoryRpcError, MemoryRpcLimits } from "@yielded/agent-storage-cloudflare/memory-protocol";
6
6
  import * as Memory from "@yielded/agent/memory";
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { Principal } from "@yielded/agent/submission-ledger";
3
- import { Clock, Context, Effect, Layer, Schema } from "effect";
4
3
  import { DurableObject, DurableObjectState, RpcTargets } from "effect-cf";
4
+ import { Clock, Context, Effect, Layer, Schema } from "effect";
5
5
  import { defaultDoMemoryStorageLimits, doMemoryStoreLayerWithFailpoints } from "@yielded/agent-storage-cloudflare/do-memory-store";
6
6
  import { MemoryOwnerIdentity, MemoryOwnerRequest, MemoryOwnerResponse, MemoryRpcError, MemoryRpcLimits, decodeMemoryWire, defaultMemoryRpcLimits, encodeMemoryWire, handleMemoryOwnerRequest } from "@yielded/agent-storage-cloudflare/memory-protocol";
7
7
  import * as Memory from "@yielded/agent/memory";
@@ -1,6 +1,6 @@
1
1
  import { ThreadObjectNamespace } from "./CloudflareBindings.mjs";
2
- import { Context, Effect, Layer, Schema } from "effect";
3
2
  import { DurableObject, DurableObjectAlarm, DurableObjectState as DurableObjectState$1, WorkerEnvironment } from "effect-cf";
3
+ import { Context, Effect, Layer, Schema } from "effect";
4
4
  import { DoScheduleAlarmControl } from "@yielded/agent-storage-cloudflare/do-schedule-store";
5
5
  import { ScheduleAuthorizer, ScheduleFailpointError, ScheduleOwner, ScheduleStorageError, SchedulingLimits } from "@yielded/agent/schedule";
6
6
  import { ScheduleDriver, Scheduling } from "@yielded/agent/scheduling";
@@ -1,12 +1,12 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { Q as cloudflareCryptoLayer, o as CloudflareThreadClient } from "./CloudflareThreadClient-CnvMXPmV.mjs";
3
- import { n as cloudflareScheduledInputAdmissionLayer, t as cloudflarePreparedInputAdmissionLayer } from "./prepared-admission-w2Kq32_k.mjs";
2
+ import { Q as cloudflareCryptoLayer, o as CloudflareThreadClient } from "./CloudflareThreadClient-DgV_RBtF.mjs";
3
+ import { n as cloudflareScheduledInputAdmissionLayer, t as cloudflarePreparedInputAdmissionLayer } from "./prepared-admission-DSuWZ5qK.mjs";
4
4
  import "@yielded/agent/durable-agent-runtime";
5
5
  import { AgentId } from "@yielded/agent/identifiers";
6
6
  import { AdmissionFence } from "@yielded/agent/submission-ledger";
7
- import { Clock, Context, DateTime, Effect, Layer, Schema } from "effect";
8
7
  import { DurableObject, DurableObjectAlarm, DurableObjectState, RpcTargets } from "effect-cf";
9
8
  import { DefinitionDigests, PersistedJson } from "@yielded/agent/records";
9
+ import { Clock, Context, DateTime, Effect, Layer, Schema } from "effect";
10
10
  import { SqliteClient } from "@effect/sql-sqlite-do";
11
11
  import { DoScheduleAlarmControl, DoScheduleTransaction, scheduleStoreLayer } from "@yielded/agent-storage-cloudflare/do-schedule-store";
12
12
  import { ScheduleAuthorizationError, ScheduleCapacityError, ScheduleConflict, ScheduleDestination, ScheduleFailpointError, ScheduleId, ScheduleNotFound, ScheduleOwner, ScheduleScope, ScheduleSnapshot, ScheduleSnapshotPage, ScheduleStorageError, ScheduleTimingRequest, ScheduleValidationError, defaultSchedulingLimits } from "@yielded/agent/schedule";
@@ -1,6 +1,6 @@
1
1
  import { ThreadObjectNamespace } from "./CloudflareBindings.mjs";
2
- import { Cause, Context, Effect, Layer, Schema, Scope } from "effect";
3
2
  import { DurableObject, DurableObjectAlarm, DurableObjectState as DurableObjectState$1, WorkerEnvironment } from "effect-cf";
3
+ import { Cause, Context, Effect, Layer, Schema, Scope } from "effect";
4
4
  import { SourcePartition, SubscriptionAuthorizer, SubscriptionLimits } from "@yielded/agent/subscription";
5
5
  import { DoSubscriptionAlarmControl } from "@yielded/agent-storage-cloudflare/do-subscription-store";
6
6
  import { EventSources } from "@yielded/agent/event-source";
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { Q as cloudflareCryptoLayer, o as CloudflareThreadClient } from "./CloudflareThreadClient-CnvMXPmV.mjs";
3
- import { t as cloudflarePreparedInputAdmissionLayer } from "./prepared-admission-w2Kq32_k.mjs";
2
+ import { Q as cloudflareCryptoLayer, o as CloudflareThreadClient } from "./CloudflareThreadClient-DgV_RBtF.mjs";
3
+ import { t as cloudflarePreparedInputAdmissionLayer } from "./prepared-admission-DSuWZ5qK.mjs";
4
4
  import { Principal } from "@yielded/agent/submission-ledger";
5
- import { Cause, Clock, Context, DateTime, Effect, Layer, Schema } from "effect";
6
5
  import { DurableObject, DurableObjectAlarm, DurableObjectState } from "effect-cf";
7
6
  import { PersistedJson } from "@yielded/agent/records";
7
+ import { Cause, Clock, Context, DateTime, Effect, Layer, Schema } from "effect";
8
8
  import { SqliteClient } from "@effect/sql-sqlite-do";
9
9
  import { EventAcknowledgement, EventSourceVersion, SourcePartition, SubscriptionConfiguration, SubscriptionDeliveryKey, SubscriptionDeliverySnapshot, SubscriptionError, SubscriptionFailpointError, SubscriptionKey, SubscriptionScope, SubscriptionSnapshot, SubscriptionSourceError, defaultSubscriptionLimits } from "@yielded/agent/subscription";
10
10
  import { DoSubscriptionAlarmControl, DoSubscriptionTransaction, doSubscriptionStoreLayer } from "@yielded/agent-storage-cloudflare/do-subscription-store";
@@ -1,13 +1,18 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { DurableAlarmError, ThreadObjectNamespace, callThreadObject } from "./CloudflareBindings.mjs";
3
3
  import { AdmissionLimitExceeded } from "./CloudflareConfig.mjs";
4
- import { r as safeCauseMessage, t as cloudflareFailureSignals } from "./boundary-BguazVkh.mjs";
4
+ import { r as safeCauseMessage, t as cloudflareFailureSignals } from "./boundary-BLbZMBl2.mjs";
5
5
  import "@yielded/agent/durable-agent-runtime";
6
6
  import { AgentId, ThreadId } from "@yielded/agent/identifiers";
7
7
  import { AbortCommand, AbortIntent, AdmissionConflict, AdmissionFence, AdmissionGroup, AdmissionPolicyError, ApprovalConflict, ApprovalDecisionCommand, ApprovalDecisionIntent, IdempotencyKey, JoinedToHost, LedgerError, OwnershipLost, Principal, Settlement, SettlementConflict, UnknownResolutionCommand, UnknownResolutionConflict, UnknownResolutionIntent } from "@yielded/agent/submission-ledger";
8
- import { Context, Crypto, Duration, Effect, Layer, PlatformError, Predicate, Schema, Stream } from "effect";
9
8
  import { Rpc, RpcTargets, RpcTracing } from "effect-cf";
9
+ import * as Context from "effect/Context";
10
+ import * as Effect from "effect/Effect";
11
+ import * as Layer from "effect/Layer";
12
+ import * as Schema from "effect/Schema";
13
+ import * as Stream from "effect/Stream";
10
14
  import { CanonicalRecordEnvelope, CanonicalSequence, DefinitionDigests, PersistedJson, SubmissionSettledRecord, WorkerAdmission } from "@yielded/agent/records";
15
+ import * as Predicate from "effect/Predicate";
11
16
  import { AgentInputError } from "@yielded/agent/agent-error";
12
17
  import { DigestError } from "@yielded/agent/digest";
13
18
  import { DurableRuntimeFailpointError } from "@yielded/agent/durable-failpoint";
@@ -16,8 +21,11 @@ import { OperationDenied } from "@yielded/agent/operation-authorizer";
16
21
  import { Receipt } from "@yielded/agent/receipt";
17
22
  import { SubmissionStatus } from "@yielded/agent/submission-status";
18
23
  import { AppendConflict, ThreadNotMaterialized, ThreadStoreError } from "@yielded/agent/thread-store";
24
+ import * as Crypto from "effect/Crypto";
25
+ import * as Duration from "effect/Duration";
19
26
  import { createHash } from "node:crypto";
20
27
  import { BrowserCrypto } from "@effect/platform-browser";
28
+ import * as PlatformError from "effect/PlatformError";
21
29
  import { Event } from "@yielded/agent/provisional-text";
22
30
  //#region src/internal/crypto.ts
23
31
  /** Workers use native SHA-256 while retaining BrowserCrypto's services and overrides. */
@@ -619,4 +627,4 @@ var CloudflareThreadClient = class CloudflareThreadClient extends Context.Servic
619
627
  //#endregion
620
628
  export { decodeLiveText as A, encodeHostResponse as B, boundHostDiagnostic as C, decodeAwaitSettlementRequest as D, decodeAwaitProgressRequest as E, encodeAbortCommand as F, Frame as G, encodeReceipt as H, encodeApprovalDecisionCommand as I, MAX_FRAME_BYTES as J, MAX_DELTA_LENGTH as K, encodeAwaitProgressRequest as L, decodeReceipt as M, decodeSubmitRequest as N, decodeCancelProgressRequest as O, decodeUnknownResolutionCommand as P, cloudflareCryptoLayer as Q, encodeAwaitSettlementRequest as R, UnknownResolutionRecorded as S, decodeApprovalDecisionCommand as T, encodeSubmitRequest as U, encodeObservePageRequest as V, encodeUnknownResolutionCommand as W, Request as X, Observation as Y, isBoundedEvent as Z, SettlementRecordReached as _, CancelProgressRequest as a, SubmitSucceeded as b, HostFailed as c, HostResponse as d, ObservePageRequest as f, SettlementReached as g, ProgressObserved as h, AwaitSettlementRequest as i, decodeObservePageRequest as j, decodeHostResponse as k, HostFailure as l, ProgressCancelled as m, ApprovalRecorded as n, CloudflareThreadClient as o, ObservedPage as p, MAX_DRAFT_LENGTH as q, AwaitProgressRequest as r, CloudflareThreadClient_exports as s, AbortRecorded as t, HostProtocolError as u, SubmissionStatusResponse as v, decodeAbortCommand as w, ThreadClientError as x, SubmitRequest as y, encodeCancelProgressRequest as z };
621
629
 
622
- //# sourceMappingURL=CloudflareThreadClient-CnvMXPmV.mjs.map
630
+ //# sourceMappingURL=CloudflareThreadClient-DgV_RBtF.mjs.map