@systemfsoftware/agent-platform-cloudflare 0.0.0-stage → 0.1.0-beta.192

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 (143) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Alarm-CbhflIzz.mjs +1931 -0
  3. package/dist/Alarm-CbhflIzz.mjs.map +1 -0
  4. package/dist/Alarm-Nz1gIjfv.d.mts +252 -0
  5. package/dist/Alarm.d.mts +3 -0
  6. package/dist/Alarm.mjs +3 -0
  7. package/dist/BrowserCredentials-BWC4RqRn.d.mts +116 -0
  8. package/dist/BrowserCredentials-CktBoPgE.mjs +140 -0
  9. package/dist/BrowserCredentials-CktBoPgE.mjs.map +1 -0
  10. package/dist/BrowserCredentials.d.mts +2 -0
  11. package/dist/BrowserCredentials.mjs +1 -0
  12. package/dist/BrowserRestCapture.d.mts +14 -0
  13. package/dist/BrowserRestCapture.mjs +195 -0
  14. package/dist/BrowserRestCapture.mjs.map +1 -0
  15. package/dist/BrowserSession-5bdpqPIT.d.mts +152 -0
  16. package/dist/BrowserSession-Ce8cWN1A.mjs +673 -0
  17. package/dist/BrowserSession-Ce8cWN1A.mjs.map +1 -0
  18. package/dist/BrowserSession.d.mts +3 -0
  19. package/dist/BrowserSession.mjs +4 -0
  20. package/dist/BrowserUse-Bsi830Yv.mjs +263 -0
  21. package/dist/BrowserUse-Bsi830Yv.mjs.map +1 -0
  22. package/dist/BrowserUse-DF8afbNt.d.mts +59 -0
  23. package/dist/BrowserUse.d.mts +2 -0
  24. package/dist/BrowserUse.mjs +1 -0
  25. package/dist/CloudflareAiGateway-By8C8c5z.mjs +79 -0
  26. package/dist/CloudflareAiGateway-By8C8c5z.mjs.map +1 -0
  27. package/dist/CloudflareAiGateway-ukN34014.d.mts +63 -0
  28. package/dist/CloudflareAiGateway.d.mts +2 -0
  29. package/dist/CloudflareAiGateway.mjs +1 -0
  30. package/dist/CloudflareBindings-Dylkir84.mjs +123 -0
  31. package/dist/CloudflareBindings-Dylkir84.mjs.map +1 -0
  32. package/dist/CloudflareBindings-E1Sty9Vq.d.mts +134 -0
  33. package/dist/CloudflareBindings.d.mts +2 -0
  34. package/dist/CloudflareBindings.mjs +1 -0
  35. package/dist/CloudflareBrowser-CmiQpslZ.d.mts +41 -0
  36. package/dist/CloudflareBrowser-DmMCFeIQ.mjs +397 -0
  37. package/dist/CloudflareBrowser-DmMCFeIQ.mjs.map +1 -0
  38. package/dist/CloudflareBrowser.d.mts +3 -0
  39. package/dist/CloudflareBrowser.mjs +1 -0
  40. package/dist/CloudflareCodeMode-BMva6dCs.mjs +627 -0
  41. package/dist/CloudflareCodeMode-BMva6dCs.mjs.map +1 -0
  42. package/dist/CloudflareCodeMode-CeGXZtHv.d.mts +43 -0
  43. package/dist/CloudflareCodeMode.d.mts +2 -0
  44. package/dist/CloudflareCodeMode.mjs +1 -0
  45. package/dist/CloudflareConfig-BFWgEyhH.d.mts +102 -0
  46. package/dist/CloudflareConfig-rBlbPSIZ.mjs +125 -0
  47. package/dist/CloudflareConfig-rBlbPSIZ.mjs.map +1 -0
  48. package/dist/CloudflareConfig.d.mts +2 -0
  49. package/dist/CloudflareConfig.mjs +1 -0
  50. package/dist/CloudflareMemory-Bzp32ZpR.d.mts +120 -0
  51. package/dist/CloudflareMemory-DejIVKBT.mjs +207 -0
  52. package/dist/CloudflareMemory-DejIVKBT.mjs.map +1 -0
  53. package/dist/CloudflareMemory.d.mts +2 -0
  54. package/dist/CloudflareMemory.mjs +1 -0
  55. package/dist/CloudflareScheduling-BleqfC44.mjs +395 -0
  56. package/dist/CloudflareScheduling-BleqfC44.mjs.map +1 -0
  57. package/dist/CloudflareScheduling-vZ7iSR57.d.mts +54 -0
  58. package/dist/CloudflareScheduling.d.mts +2 -0
  59. package/dist/CloudflareScheduling.mjs +1 -0
  60. package/dist/CloudflareSubscriptions-IHSo19MU.d.mts +91 -0
  61. package/dist/CloudflareSubscriptions-S3fZF-Jo.mjs +529 -0
  62. package/dist/CloudflareSubscriptions-S3fZF-Jo.mjs.map +1 -0
  63. package/dist/CloudflareSubscriptions.d.mts +2 -0
  64. package/dist/CloudflareSubscriptions.mjs +1 -0
  65. package/dist/CloudflareThreadClient-BUv9Te1s.d.mts +2141 -0
  66. package/dist/CloudflareThreadClient-K7QJHYpK.mjs +496 -0
  67. package/dist/CloudflareThreadClient-K7QJHYpK.mjs.map +1 -0
  68. package/dist/CloudflareThreadClient.d.mts +3 -0
  69. package/dist/CloudflareThreadClient.mjs +3 -0
  70. package/dist/InteractiveBrowser-CMbA7YPP.d.mts +228 -0
  71. package/dist/InteractiveBrowser-e8ZvxC1C.mjs +2013 -0
  72. package/dist/InteractiveBrowser-e8ZvxC1C.mjs.map +1 -0
  73. package/dist/InteractiveBrowser.d.mts +2 -0
  74. package/dist/InteractiveBrowser.mjs +1 -0
  75. package/dist/LiveText-CfpcZaGb.d.mts +91 -0
  76. package/dist/LiveText-DaF0tN_p.mjs +148 -0
  77. package/dist/LiveText-DaF0tN_p.mjs.map +1 -0
  78. package/dist/LiveText.d.mts +2 -0
  79. package/dist/LiveText.mjs +1 -0
  80. package/dist/R2ToolResultStorage.d.mts +27 -0
  81. package/dist/R2ToolResultStorage.mjs +84 -0
  82. package/dist/R2ToolResultStorage.mjs.map +1 -0
  83. package/dist/ThreadObject-B2-PqnpT.d.mts +390 -0
  84. package/dist/ThreadObject-D1pCeNrq.mjs +1225 -0
  85. package/dist/ThreadObject-D1pCeNrq.mjs.map +1 -0
  86. package/dist/ThreadObject.d.mts +2 -0
  87. package/dist/ThreadObject.mjs +1 -0
  88. package/dist/WakeScheduler-67UeXBYK.d.mts +22 -0
  89. package/dist/WakeScheduler-DV4J4TRe.mjs +69 -0
  90. package/dist/WakeScheduler-DV4J4TRe.mjs.map +1 -0
  91. package/dist/WakeScheduler.d.mts +2 -0
  92. package/dist/WakeScheduler.mjs +1 -0
  93. package/dist/boundary-YrOnE2zO.mjs +41 -0
  94. package/dist/boundary-YrOnE2zO.mjs.map +1 -0
  95. package/dist/browser-failure-CWBBnf1j.mjs +70 -0
  96. package/dist/browser-failure-CWBBnf1j.mjs.map +1 -0
  97. package/dist/index.d.mts +17 -0
  98. package/dist/index.mjs +17 -0
  99. package/dist/prepared-admission-DngoYN74.mjs +57 -0
  100. package/dist/prepared-admission-DngoYN74.mjs.map +1 -0
  101. package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
  102. package/package.json +134 -3
  103. package/src/Alarm.ts +3402 -0
  104. package/src/BrowserCredentials.ts +181 -0
  105. package/src/BrowserRestCapture.ts +383 -0
  106. package/src/BrowserSession.ts +993 -0
  107. package/src/BrowserUse.ts +438 -0
  108. package/src/CloudflareAiGateway.ts +176 -0
  109. package/src/CloudflareBindings.ts +225 -0
  110. package/src/CloudflareBrowser.ts +9 -0
  111. package/src/CloudflareCodeMode.ts +896 -0
  112. package/src/CloudflareConfig.ts +142 -0
  113. package/src/CloudflareMemory.ts +418 -0
  114. package/src/CloudflareScheduling.ts +736 -0
  115. package/src/CloudflareSubscriptions.ts +1032 -0
  116. package/src/CloudflareThreadClient.ts +980 -0
  117. package/src/InteractiveBrowser.ts +3300 -0
  118. package/src/LiveText.ts +145 -0
  119. package/src/R2ToolResultStorage.ts +131 -0
  120. package/src/ThreadObject.ts +1348 -0
  121. package/src/WakeScheduler.ts +102 -0
  122. package/src/index.ts +16 -0
  123. package/src/internal/boundary.ts +53 -0
  124. package/src/internal/browser-binding.ts +483 -0
  125. package/src/internal/browser-credentials.ts +481 -0
  126. package/src/internal/browser-failure.ts +145 -0
  127. package/src/internal/browser-file-selection.ts +146 -0
  128. package/src/internal/browser-quick-action.ts +666 -0
  129. package/src/internal/browser-readonly-live-view.ts +121 -0
  130. package/src/internal/browser-session-lifecycle.ts +200 -0
  131. package/src/internal/crypto.ts +44 -0
  132. package/src/internal/due-queue.ts +452 -0
  133. package/src/internal/host-protocol-error.ts +23 -0
  134. package/src/internal/layers.ts +1181 -0
  135. package/src/internal/live-text-observation.ts +8 -0
  136. package/src/internal/live-text-protocol.ts +59 -0
  137. package/src/internal/live-text.ts +339 -0
  138. package/src/internal/message-delivery.ts +149 -0
  139. package/src/internal/page-function.ts +12 -0
  140. package/src/internal/prepared-admission.ts +83 -0
  141. package/src/internal/progress-wait.ts +121 -0
  142. package/src/internal/transport.ts +53 -0
  143. package/README.md +0 -3
@@ -0,0 +1,79 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
2
+ import * as Context from "effect/Context";
3
+ import * as Effect from "effect/Effect";
4
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
5
+ import * as Headers from "effect/http/Headers";
6
+ import * as HttpClient from "effect/http/HttpClient";
7
+ import * as HttpClientError from "effect/http/HttpClientError";
8
+ import * as HttpClientRequest from "effect/http/HttpClientRequest";
9
+ import * as Layer from "effect/Layer";
10
+ import * as Option from "effect/Option";
11
+ import * as Redactable from "effect/Redactable";
12
+ import * as Redacted from "effect/Redacted";
13
+ import * as Schema from "effect/Schema";
14
+ // src/CloudflareAiGateway.ts
15
+ var CloudflareAiGateway_exports = /* @__PURE__ */ __exportAll({
16
+ provide: () => provide,
17
+ provider: () => provider,
18
+ rest: () => rest
19
+ });
20
+ const Segment = Schema.NonEmptyString.check(Schema.isMaxLength(256), Schema.isPattern(/^[a-zA-Z0-9_-]+$/));
21
+ const decodeSegment = Schema.decodeUnknownSync(Segment);
22
+ const redactGatewayToken = (headers, tokenHeader) => {
23
+ Object.defineProperty(headers, Redactable.symbolRedactable, {
24
+ configurable: true,
25
+ value: (context) => Headers.redact(headers, [...Context.get(context, Headers.CurrentRedactedNames), tokenHeader])
26
+ });
27
+ };
28
+ const clientOptions = (apiUrl, tokenHeader, apiToken, gatewayId) => Object.freeze({
29
+ apiUrl,
30
+ transformClient: (client) => client.pipe(HttpClient.mapRequestEffect((request) => {
31
+ const url = URL.parse(request.url);
32
+ if (url === null || url.username !== "" || url.password !== "" || !(url.href === apiUrl || url.href.startsWith(`${apiUrl}/`))) return Effect.fail(new HttpClientError.HttpClientError({ reason: new HttpClientError.InvalidUrlError({
33
+ request,
34
+ description: "Request is outside the configured Cloudflare AI Gateway endpoint"
35
+ }) }));
36
+ let prepared = request;
37
+ if (apiToken !== void 0) prepared = HttpClientRequest.setHeader(prepared, tokenHeader, `Bearer ${Redacted.value(apiToken)}`);
38
+ if (gatewayId !== void 0) prepared = HttpClientRequest.setHeader(prepared, "cf-aig-gateway-id", gatewayId);
39
+ return Effect.succeed(prepared);
40
+ }), HttpClient.transformResponse((effect) => Effect.gen(function* () {
41
+ const defaults = yield* Effect.serviceOption(FetchHttpClient.RequestInit);
42
+ return yield* effect.pipe(Effect.provideService(FetchHttpClient.RequestInit, {
43
+ ...Option.getOrElse(defaults, () => ({})),
44
+ redirect: "error"
45
+ }));
46
+ })), HttpClient.transformResponse((effect) => effect.pipe(Effect.tap((response) => Effect.sync(() => redactGatewayToken(response.request.headers, tokenHeader))), Effect.tapError((error) => Effect.sync(() => redactGatewayToken(error.reason.request.headers, tokenHeader))), Effect.updateService(Headers.CurrentRedactedNames, (names) => [...names, tokenHeader]))))
47
+ });
48
+ /**
49
+ * Provider-native proxy for model calls, streaming, embeddings, and hosted tools supported
50
+ * by that provider. Pass the result to the upstream client's layer along with its apiKey
51
+ * for BYOK-in-request, or omit apiKey for Gateway stored keys / Unified Billing.
52
+ * Provider model names and request bodies pass through unchanged. This module is Node-safe.
53
+ * Custom transforms and redirect policies must retain this endpoint and credential boundary.
54
+ */
55
+ const provider = (options) => clientOptions(`https://gateway.ai.cloudflare.com/v1/${decodeSegment(options.accountId)}/${decodeSegment(options.gatewayId)}/${decodeSegment(options.provider)}`, "cf-aig-authorization", options.apiToken);
56
+ /**
57
+ * Cloudflare's account REST API (not the deprecated /compat API). Use provider-qualified
58
+ * model names, e.g. openai/gpt-6-sol or anthropic/claude-haiku-4.5, and omit provider apiKey.
59
+ * OpenAI clients append /responses or /chat/completions; Anthropic appends /v1/messages.
60
+ * Compatibility remains the responsibility of the selected upstream client and model.
61
+ */
62
+ const rest = (options) => clientOptions(`https://api.cloudflare.com/client/v4/accounts/${decodeSegment(options.accountId)}/ai${options.protocol === "messages" ? "" : "/v1"}`, "authorization", options.apiToken, decodeSegment(options.gatewayId));
63
+ /**
64
+ * Provide a Gateway-configured upstream client directly in a Layer pipeline.
65
+ * Pass the client's `layer` factory, or a callback adding client-specific options.
66
+ * The factory's errors and remaining services (such as HttpClient) stay visible.
67
+ * Model selection and resource ownership remain with the supplied upstream Layers.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * AnthropicLanguageModel.model("claude-haiku-4-5").pipe(
72
+ * Gateway.provide(AnthropicClient.layer, { ...options, provider: "anthropic" }),
73
+ * )
74
+ * ```
75
+ */
76
+ const provide = (clientLayer, options) => Layer.provide(clientLayer(options.provider !== void 0 ? provider(options) : rest(options)));
77
+ export { rest as i, provide as n, provider as r, CloudflareAiGateway_exports as t };
78
+
79
+ //# sourceMappingURL=CloudflareAiGateway-By8C8c5z.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudflareAiGateway-By8C8c5z.mjs","names":[],"sources":["../src/CloudflareAiGateway.ts"],"sourcesContent":["import * as Context from 'effect/Context'\nimport * as Effect from 'effect/Effect'\nimport * as FetchHttpClient from 'effect/http/FetchHttpClient'\nimport * as Headers from 'effect/http/Headers'\nimport * as HttpClient from 'effect/http/HttpClient'\nimport * as HttpClientError from 'effect/http/HttpClientError'\nimport * as HttpClientRequest from 'effect/http/HttpClientRequest'\nimport * as Layer from 'effect/Layer'\nimport * as Option from 'effect/Option'\nimport * as Redactable from 'effect/Redactable'\nimport * as Redacted from 'effect/Redacted'\nimport * as Schema from 'effect/Schema'\n\nconst Segment = Schema.NonEmptyString.check(\n Schema.isMaxLength(256),\n Schema.isPattern(/^[a-zA-Z0-9_-]+$/),\n)\n\nconst decodeSegment = Schema.decodeUnknownSync(Segment)\n\n/** Options understood by upstream Effect AI clients; no model or provider wrapper is created. */\nexport interface ClientOptions {\n readonly apiUrl: string\n readonly transformClient: (client: HttpClient.HttpClient) => HttpClient.HttpClient\n}\n\nexport interface ProviderOptions {\n readonly accountId: string\n readonly gatewayId: string\n /** Cloudflare's provider path, such as openai, anthropic, google-ai-studio, or perplexity-ai. */\n readonly provider: string\n /** Omit only for an unauthenticated gateway with a separately supplied provider key. */\n readonly apiToken?: Redacted.Redacted<string>\n}\n\nexport interface RestOptions {\n readonly accountId: string\n readonly gatewayId: string\n /** Cloudflare API token with Workers AI Read permission. */\n readonly apiToken: Redacted.Redacted<string>\n /** Matches the paths appended by the upstream Effect client. */\n readonly protocol: 'responses' | 'chat-completions' | 'messages'\n}\n\n/** Choose exactly one route: a native provider path or an account REST protocol. */\nexport type RouteOptions =\n | (ProviderOptions & { readonly protocol?: never })\n | (RestOptions & { readonly provider?: never })\n\nconst redactGatewayToken = (headers: Headers.Headers, tokenHeader: string): void => {\n // HTTP tracing can copy headers after preprocessing. Attach the public redaction\n // protocol to the final request as well, before a provider builds error details.\n Object.defineProperty(headers, Redactable.symbolRedactable, {\n configurable: true,\n value: (context: Context.Context<never>) =>\n Headers.redact(headers, [...Context.get(context, Headers.CurrentRedactedNames), tokenHeader]),\n })\n}\n\nconst clientOptions = (\n apiUrl: string,\n tokenHeader: 'authorization' | 'cf-aig-authorization',\n apiToken: Redacted.Redacted<string> | undefined,\n gatewayId?: string,\n): ClientOptions =>\n Object.freeze({\n apiUrl,\n transformClient: (client: HttpClient.HttpClient) =>\n client.pipe(\n HttpClient.mapRequestEffect((request) => {\n const url = URL.parse(request.url)\n\n // Check the normalized URL too: dot segments must not escape this account or gateway.\n if (\n url === null ||\n url.username !== '' ||\n url.password !== '' ||\n !(url.href === apiUrl || url.href.startsWith(`${apiUrl}/`))\n ) {\n return Effect.fail(\n new HttpClientError.HttpClientError({\n reason: new HttpClientError.InvalidUrlError({\n request,\n description: 'Request is outside the configured Cloudflare AI Gateway endpoint',\n }),\n }),\n )\n }\n let prepared = request\n\n if (apiToken !== undefined) {\n prepared = HttpClientRequest.setHeader(\n prepared,\n tokenHeader,\n `Bearer ${Redacted.value(apiToken)}`,\n )\n }\n if (gatewayId !== undefined) {\n prepared = HttpClientRequest.setHeader(prepared, 'cf-aig-gateway-id', gatewayId)\n }\n\n return Effect.succeed(prepared)\n }),\n HttpClient.transformResponse((effect) =>\n Effect.gen(function*() {\n const defaults = yield* Effect.serviceOption(FetchHttpClient.RequestInit)\n\n return yield* effect.pipe(\n Effect.provideService(FetchHttpClient.RequestInit, {\n ...Option.getOrElse(defaults, () => ({})),\n redirect: 'error',\n }),\n )\n })\n ),\n HttpClient.transformResponse((effect) =>\n effect.pipe(\n Effect.tap((response) => Effect.sync(() => redactGatewayToken(response.request.headers, tokenHeader))),\n Effect.tapError((error) =>\n Effect.sync(() => redactGatewayToken(error.reason.request.headers, tokenHeader))\n ),\n Effect.updateService(Headers.CurrentRedactedNames, (names) => [...names, tokenHeader]),\n )\n ),\n ),\n })\n\n/**\n * Provider-native proxy for model calls, streaming, embeddings, and hosted tools supported\n * by that provider. Pass the result to the upstream client's layer along with its apiKey\n * for BYOK-in-request, or omit apiKey for Gateway stored keys / Unified Billing.\n * Provider model names and request bodies pass through unchanged. This module is Node-safe.\n * Custom transforms and redirect policies must retain this endpoint and credential boundary.\n */\nexport const provider = (options: ProviderOptions): ClientOptions =>\n clientOptions(\n `https://gateway.ai.cloudflare.com/v1/${decodeSegment(options.accountId)}/${decodeSegment(options.gatewayId)}/${\n decodeSegment(options.provider)\n }`,\n 'cf-aig-authorization',\n options.apiToken,\n )\n\n/**\n * Cloudflare's account REST API (not the deprecated /compat API). Use provider-qualified\n * model names, e.g. openai/gpt-6-sol or anthropic/claude-haiku-4.5, and omit provider apiKey.\n * OpenAI clients append /responses or /chat/completions; Anthropic appends /v1/messages.\n * Compatibility remains the responsibility of the selected upstream client and model.\n */\nexport const rest = (options: RestOptions): ClientOptions =>\n clientOptions(\n `https://api.cloudflare.com/client/v4/accounts/${decodeSegment(options.accountId)}/ai${\n options.protocol === 'messages' ? '' : '/v1'\n }`,\n 'authorization',\n options.apiToken,\n decodeSegment(options.gatewayId),\n )\n\n/**\n * Provide a Gateway-configured upstream client directly in a Layer pipeline.\n * Pass the client's `layer` factory, or a callback adding client-specific options.\n * The factory's errors and remaining services (such as HttpClient) stay visible.\n * Model selection and resource ownership remain with the supplied upstream Layers.\n *\n * @example\n * ```ts\n * AnthropicLanguageModel.model(\"claude-haiku-4-5\").pipe(\n * Gateway.provide(AnthropicClient.layer, { ...options, provider: \"anthropic\" }),\n * )\n * ```\n */\nexport const provide = <Client, E, R>(\n clientLayer: (options: ClientOptions) => Layer.Layer<Client, E, R>,\n options: RouteOptions,\n) => Layer.provide(clientLayer(options.provider !== undefined ? provider(options) : rest(options)))\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,MAAM,UAAU,OAAO,eAAe,MACpC,OAAO,YAAY,GAAG,GACtB,OAAO,UAAU,kBAAkB,CACrC;AAEA,MAAM,gBAAgB,OAAO,kBAAkB,OAAO;AA+BtD,MAAM,sBAAsB,SAA0B,gBAA8B;CAGlF,OAAO,eAAe,SAAS,WAAW,kBAAkB;EAC1D,cAAc;EACd,QAAQ,YACN,QAAQ,OAAO,SAAS,CAAC,GAAG,QAAQ,IAAI,SAAS,QAAQ,oBAAoB,GAAG,WAAW,CAAC;CAChG,CAAC;AACH;AAEA,MAAM,iBACJ,QACA,aACA,UACA,cAEA,OAAO,OAAO;CACZ;CACA,kBAAkB,WAChB,OAAO,KACL,WAAW,kBAAkB,YAAY;EACvC,MAAM,MAAM,IAAI,MAAM,QAAQ,GAAG;EAGjC,IACE,QAAQ,QACR,IAAI,aAAa,MACjB,IAAI,aAAa,MACjB,EAAE,IAAI,SAAS,UAAU,IAAI,KAAK,WAAW,GAAG,OAAO,EAAE,IAEzD,OAAO,OAAO,KACZ,IAAI,gBAAgB,gBAAgB,EAClC,QAAQ,IAAI,gBAAgB,gBAAgB;GAC1C;GACA,aAAa;EACf,CAAC,EACH,CAAC,CACH;EAEF,IAAI,WAAW;EAEf,IAAI,aAAa,KAAA,GACf,WAAW,kBAAkB,UAC3B,UACA,aACA,UAAU,SAAS,MAAM,QAAQ,GACnC;EAEF,IAAI,cAAc,KAAA,GAChB,WAAW,kBAAkB,UAAU,UAAU,qBAAqB,SAAS;EAGjF,OAAO,OAAO,QAAQ,QAAQ;CAChC,CAAC,GACD,WAAW,mBAAmB,WAC5B,OAAO,IAAI,aAAY;EACrB,MAAM,WAAW,OAAO,OAAO,cAAc,gBAAgB,WAAW;EAExE,OAAO,OAAO,OAAO,KACnB,OAAO,eAAe,gBAAgB,aAAa;GACjD,GAAG,OAAO,UAAU,iBAAiB,CAAC,EAAE;GACxC,UAAU;EACZ,CAAC,CACH;CACF,CAAC,CACH,GACA,WAAW,mBAAmB,WAC5B,OAAO,KACL,OAAO,KAAK,aAAa,OAAO,WAAW,mBAAmB,SAAS,QAAQ,SAAS,WAAW,CAAC,CAAC,GACrG,OAAO,UAAU,UACf,OAAO,WAAW,mBAAmB,MAAM,OAAO,QAAQ,SAAS,WAAW,CAAC,CACjF,GACA,OAAO,cAAc,QAAQ,uBAAuB,UAAU,CAAC,GAAG,OAAO,WAAW,CAAC,CACvF,CACF,CACF;AACJ,CAAC;;;;;;;;AASH,MAAa,YAAY,YACvB,cACE,wCAAwC,cAAc,QAAQ,SAAS,EAAE,GAAG,cAAc,QAAQ,SAAS,EAAE,GAC3G,cAAc,QAAQ,QAAQ,KAEhC,wBACA,QAAQ,QACV;;;;;;;AAQF,MAAa,QAAQ,YACnB,cACE,iDAAiD,cAAc,QAAQ,SAAS,EAAE,KAChF,QAAQ,aAAa,aAAa,KAAK,SAEzC,iBACA,QAAQ,UACR,cAAc,QAAQ,SAAS,CACjC;;;;;;;;;;;;;;AAeF,MAAa,WACX,aACA,YACG,MAAM,QAAQ,YAAY,QAAQ,aAAa,KAAA,IAAY,SAAS,OAAO,IAAI,KAAK,OAAO,CAAC,CAAC"}
@@ -0,0 +1,63 @@
1
+ import * as HttpClient from "effect/http/HttpClient";
2
+ import * as Layer from "effect/Layer";
3
+ import * as Redacted from "effect/Redacted";
4
+ declare namespace CloudflareAiGateway_d_exports {
5
+ export { ClientOptions, ProviderOptions, RestOptions, RouteOptions, provide, provider, rest };
6
+ }
7
+ /** Options understood by upstream Effect AI clients; no model or provider wrapper is created. */
8
+ interface ClientOptions {
9
+ readonly apiUrl: string;
10
+ readonly transformClient: (client: HttpClient.HttpClient) => HttpClient.HttpClient;
11
+ }
12
+ interface ProviderOptions {
13
+ readonly accountId: string;
14
+ readonly gatewayId: string;
15
+ /** Cloudflare's provider path, such as openai, anthropic, google-ai-studio, or perplexity-ai. */
16
+ readonly provider: string;
17
+ /** Omit only for an unauthenticated gateway with a separately supplied provider key. */
18
+ readonly apiToken?: Redacted.Redacted<string>;
19
+ }
20
+ interface RestOptions {
21
+ readonly accountId: string;
22
+ readonly gatewayId: string;
23
+ /** Cloudflare API token with Workers AI Read permission. */
24
+ readonly apiToken: Redacted.Redacted<string>;
25
+ /** Matches the paths appended by the upstream Effect client. */
26
+ readonly protocol: 'responses' | 'chat-completions' | 'messages';
27
+ }
28
+ /** Choose exactly one route: a native provider path or an account REST protocol. */
29
+ type RouteOptions = (ProviderOptions & {
30
+ readonly protocol?: never;
31
+ }) | (RestOptions & {
32
+ readonly provider?: never;
33
+ });
34
+ /**
35
+ * Provider-native proxy for model calls, streaming, embeddings, and hosted tools supported
36
+ * by that provider. Pass the result to the upstream client's layer along with its apiKey
37
+ * for BYOK-in-request, or omit apiKey for Gateway stored keys / Unified Billing.
38
+ * Provider model names and request bodies pass through unchanged. This module is Node-safe.
39
+ * Custom transforms and redirect policies must retain this endpoint and credential boundary.
40
+ */
41
+ declare const provider: (options: ProviderOptions) => ClientOptions;
42
+ /**
43
+ * Cloudflare's account REST API (not the deprecated /compat API). Use provider-qualified
44
+ * model names, e.g. openai/gpt-6-sol or anthropic/claude-haiku-4.5, and omit provider apiKey.
45
+ * OpenAI clients append /responses or /chat/completions; Anthropic appends /v1/messages.
46
+ * Compatibility remains the responsibility of the selected upstream client and model.
47
+ */
48
+ declare const rest: (options: RestOptions) => ClientOptions;
49
+ /**
50
+ * Provide a Gateway-configured upstream client directly in a Layer pipeline.
51
+ * Pass the client's `layer` factory, or a callback adding client-specific options.
52
+ * The factory's errors and remaining services (such as HttpClient) stay visible.
53
+ * Model selection and resource ownership remain with the supplied upstream Layers.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * AnthropicLanguageModel.model("claude-haiku-4-5").pipe(
58
+ * Gateway.provide(AnthropicClient.layer, { ...options, provider: "anthropic" }),
59
+ * )
60
+ * ```
61
+ */
62
+ declare const provide: <Client, E, R>(clientLayer: (options: ClientOptions) => Layer.Layer<Client, E, R>, options: RouteOptions) => <RIn2, E2, ROut2>(self: Layer.Layer<ROut2, E2, RIn2>) => Layer.Layer<ROut2, E | E2, R | Exclude<RIn2, Client>>;
63
+ export { RouteOptions as a, rest as c, RestOptions as i, CloudflareAiGateway_d_exports as n, provide as o, ProviderOptions as r, provider as s, ClientOptions as t };
@@ -0,0 +1,2 @@
1
+ import { a as RouteOptions, c as rest, i as RestOptions, o as provide, r as ProviderOptions, s as provider, t as ClientOptions } from "./CloudflareAiGateway-ukN34014.mjs";
2
+ export { ClientOptions, ProviderOptions, RestOptions, RouteOptions, provide, provider, rest };
@@ -0,0 +1 @@
1
+ export { n as provide, r as provider, i as rest } from "./CloudflareAiGateway-By8C8c5z.mjs";
@@ -0,0 +1,123 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
2
+ import "@systemfsoftware/agent/identifiers";
3
+ import "@systemfsoftware/agent/records";
4
+ import { RpcTargets } from "effect-cf";
5
+ import * as Context from "effect/Context";
6
+ import * as Effect from "effect/Effect";
7
+ import * as Layer from "effect/Layer";
8
+ import * as Predicate from "effect/Predicate";
9
+ import * as Schema from "effect/Schema";
10
+ // src/CloudflareBindings.ts
11
+ var CloudflareBindings_exports = /* @__PURE__ */ __exportAll({
12
+ CloudflareBindingError: () => CloudflareBindingError,
13
+ DurableAlarmError: () => DurableAlarmError,
14
+ DurableObjectContext: () => DurableObjectContext,
15
+ ThreadObjectIdentity: () => ThreadObjectIdentity,
16
+ ThreadObjectNamespace: () => ThreadObjectNamespace,
17
+ ThreadObjectPlacement: () => ThreadObjectPlacement,
18
+ callThreadObject: () => callThreadObject,
19
+ threadNamespaceFromEnv: () => threadNamespaceFromEnv,
20
+ threadNamespaceLayer: () => threadNamespaceLayer
21
+ });
22
+ /**
23
+ * Cloudflare platform bindings as Effect services (DEPLOY-010: "Cloudflare platform bindings
24
+ * are supplied as Effect services/Layers"). Application code never reads `env` or touches a
25
+ * `DurableObjectState` directly — the Thread Object class constructs these Layers once
26
+ * per incarnation and everything downstream consumes the services.
27
+ */
28
+ /** A Cloudflare platform binding was missing or carried the wrong shape (DEPLOY-003/010). */
29
+ var CloudflareBindingError = class extends Schema.TaggedError()("CloudflareBindingError", {
30
+ binding: Schema.String,
31
+ message: Schema.String
32
+ }) {};
33
+ /**
34
+ * Deterministic logical Thread placement. The native adapter uses `idFromName(threadId)`;
35
+ * a shared application owner can bind that logical identity into its RPC adapter instead.
36
+ * Lookup performs no I/O and grants no authority. Calls reuse a native target within
37
+ * one invocation; incoming requests and durable retries acquire their own targets.
38
+ */
39
+ var ThreadObjectNamespace = class ThreadObjectNamespace extends Context.Service()("@effect-agent/platform-cloudflare/ThreadObjectNamespace") {
40
+ static layer(namespace, options = {}) {
41
+ return Layer.succeed(ThreadObjectNamespace)({
42
+ get: (threadId) => namespace.get(namespace.idFromName(threadId)),
43
+ ...options.rpcTracing === void 0 ? {} : { rpcTracing: options.rpcTracing }
44
+ });
45
+ }
46
+ };
47
+ /** Invoke a placed Thread using the current invocation's native RPC channel. */
48
+ const callThreadObject = Effect.fnUntraced(function* (threadId, invoke, onError) {
49
+ const namespace = yield* ThreadObjectNamespace;
50
+ const target = yield* RpcTargets.get(namespace, threadId, () => namespace.get(threadId)).pipe(Effect.mapError(onError));
51
+ return yield* Effect.tryPromise({
52
+ try: () => invoke(target),
53
+ catch: onError
54
+ }).pipe(Effect.tapCause(() => RpcTargets.invalidate(target)));
55
+ });
56
+ /**
57
+ * Narrow one `env` member to a `DurableObjectNamespace`. `env` is an untyped platform value,
58
+ * and a namespace binding is a host object no Schema can decode, so this is the documented
59
+ * narrowest-boundary check (structural probe for the namespace surface the transport uses);
60
+ * a missing or misshaped binding fails typed before any Layer is built.
61
+ */
62
+ const threadNamespaceFromEnv = Effect.fnUntraced(function* (env, binding) {
63
+ if (!Predicate.isObjectKeyword(env)) return yield* CloudflareBindingError.make({
64
+ binding,
65
+ message: "The Worker environment is not an object; no bindings are available."
66
+ });
67
+ const candidate = yield* Effect.try({
68
+ try: () => {
69
+ const value = Reflect.get(env, binding);
70
+ if (!Predicate.isObjectKeyword(value)) return void 0;
71
+ const idFromName = Reflect.get(value, "idFromName");
72
+ const get = Reflect.get(value, "get");
73
+ return typeof idFromName === "function" && typeof get === "function" ? value : void 0;
74
+ },
75
+ catch: () => CloudflareBindingError.make({
76
+ binding,
77
+ message: `env.${binding} could not be inspected as a DurableObjectNamespace binding.`
78
+ })
79
+ });
80
+ if (candidate !== void 0) return candidate;
81
+ return yield* CloudflareBindingError.make({
82
+ binding,
83
+ message: `env.${binding} is not a DurableObjectNamespace binding; declare the Thread Object class under this binding in the Worker configuration.`
84
+ });
85
+ });
86
+ /**
87
+ * Build the namespace from Worker `env` (fails typed). Enable `rpcTracing` only when the
88
+ * receiver also opts into the effect-cf native RPC trace-context contract.
89
+ */
90
+ const threadNamespaceLayer = (env, binding, options = {}) => Layer.effect(ThreadObjectNamespace)(Effect.map(threadNamespaceFromEnv(env, binding), (namespace) => ({
91
+ get: (threadId) => namespace.get(namespace.idFromName(threadId)),
92
+ ...options.rpcTracing === true ? { rpcTracing: binding } : {}
93
+ })));
94
+ /**
95
+ * The live Durable Object execution context of THIS incarnation. Only Layer construction and
96
+ * the alarm service consume it; important state never lives on it (`ctx.storage` is truth,
97
+ * everything in memory is a cache — deployment spec §11).
98
+ */
99
+ var DurableObjectContext = class DurableObjectContext extends Context.Service()("@effect-agent/platform-cloudflare/DurableObjectContext") {
100
+ static layer(ctx, env) {
101
+ return Layer.succeed(DurableObjectContext)({
102
+ ctx,
103
+ env
104
+ });
105
+ }
106
+ };
107
+ /**
108
+ * The Thread identity this Object serializes and the producer identity its Attempts
109
+ * write with (`{producerPrefix}:{threadId}`, plan §1.4). Derived once per incarnation
110
+ * from `ctx.id.name` — the Object identity rule guarantees the name IS the Thread ID.
111
+ */
112
+ var ThreadObjectIdentity = class extends Context.Service()("@effect-agent/platform-cloudflare/ThreadObjectIdentity") {};
113
+ /** Logical Threads whose canonical stores and admission ledger live in this physical Object. */
114
+ var ThreadObjectPlacement = class extends Context.Service()("@effect-agent/platform-cloudflare/ThreadObjectPlacement") {};
115
+ /** The Durable Object alarm API failed; surfaces on host entry points as a typed refusal. */
116
+ var DurableAlarmError = class extends Schema.TaggedError()("DurableAlarmError", {
117
+ operation: Schema.String,
118
+ message: Schema.String,
119
+ cause: Schema.optionalKey(Schema.Defect())
120
+ }) {};
121
+ export { ThreadObjectIdentity as a, callThreadObject as c, DurableObjectContext as i, threadNamespaceFromEnv as l, CloudflareBindings_exports as n, ThreadObjectNamespace as o, DurableAlarmError as r, ThreadObjectPlacement as s, CloudflareBindingError as t, threadNamespaceLayer as u };
122
+
123
+ //# sourceMappingURL=CloudflareBindings-Dylkir84.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudflareBindings-Dylkir84.mjs","names":[],"sources":["../src/CloudflareBindings.ts"],"sourcesContent":["import { type ThreadId } from '@systemfsoftware/agent/identifiers'\nimport { type ProducerId } from '@systemfsoftware/agent/records'\nimport { RpcTargets } from 'effect-cf'\nimport * as Context from 'effect/Context'\nimport * as Effect from 'effect/Effect'\nimport * as Layer from 'effect/Layer'\nimport * as Predicate from 'effect/Predicate'\nimport * as Schema from 'effect/Schema'\n\n/**\n * Cloudflare platform bindings as Effect services (DEPLOY-010: \"Cloudflare platform bindings\n * are supplied as Effect services/Layers\"). Application code never reads `env` or touches a\n * `DurableObjectState` directly — the Thread Object class constructs these Layers once\n * per incarnation and everything downstream consumes the services.\n */\n\n/** A Cloudflare platform binding was missing or carried the wrong shape (DEPLOY-003/010). */\nexport class CloudflareBindingError extends Schema.TaggedError<CloudflareBindingError>()(\n 'CloudflareBindingError',\n {\n binding: Schema.String,\n message: Schema.String,\n },\n) {}\n\n/**\n * The RPC surface one Thread Durable Object exposes to Workers and to sibling\n * Thread Objects. `ThreadObject.make` implements it; the Worker-side client\n * and the cross-Object transport call it through `DurableObjectNamespace` stubs. Every\n * `encoded` value is a Schema-encoded envelope (`client.ts` wire schemas for host entry\n * points, `@systemfsoftware/agent-storage-cloudflare` port envelopes for `portCall`), so the RPC\n * boundary carries structured-cloneable JSON, except `watchTextEncoded`, which can return\n * a bounded byte stream with a disposable RPC lifetime. The optional trailing trace context is\n * transient native RPC metadata, stripped by an opted-in effect-cf receiver before decoding\n * the host or port envelope. It never enters durable state.\n */\nexport interface ThreadObjectRpc extends Rpc.DurableObjectBranded {\n /** Admission-limits gate + `DurableAgentRuntime.submit`; answers a `SubmitResponse`. */\n submitEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>\n /** Wake-hinted, poll-guaranteed settlement wait; answers an `AwaitSettlementResponse`. */\n submissionStatusEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>\n awaitSettlementEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>\n /** Finalized canonical settlement record; requires settlement and observation authority. */\n awaitSettlementRecordEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>\n /** Event-driven durable progress wait; answers a `ProgressObserved` host response. */\n awaitProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>\n /** Best-effort cancellation for one in-flight progress wait. */\n cancelProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>\n /**\n * Authorized provisional text; stream with RPC lifetime, or encoded HostFailed.\n * Direct callers must dispose the RPC result; canceling an idle stream alone may not\n * reach its source. CloudflareThreadClient owns both lifetimes for callers.\n */\n watchTextEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>\n /** One bounded page of canonical records; answers an `ObservePageResponse`. */\n observePage(encoded: unknown, traceContext?: unknown): Promise<unknown>\n /** Durable abort intent; answers an `AbortResponse`. */\n abortEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>\n /** Durable approval decision (plan §2.6); answers a `ResolveApprovalResponse`. */\n resolveApprovalEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>\n /** Authorized DUR-017 Unknown-Outcome resolution; answers a `ResolveUnknownResponse`. */\n resolveUnknownEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>\n /** Owner-side cross-Object port endpoint (WP2 envelopes, executed on LOCAL facets). */\n portCall(encoded: unknown, traceContext?: unknown): Promise<unknown>\n /** Droppable liveness hint from another Object: arms an immediate alarm. */\n wake(): Promise<void>\n}\n\n/** A logical Thread endpoint may be bound to an application Object without forging its brand. */\nexport type ThreadObjectClient = Omit<ThreadObjectRpc, keyof Rpc.DurableObjectBranded>\n\n/**\n * Deterministic logical Thread placement. The native adapter uses `idFromName(threadId)`;\n * a shared application owner can bind that logical identity into its RPC adapter instead.\n * Lookup performs no I/O and grants no authority. Calls reuse a native target within\n * one invocation; incoming requests and durable retries acquire their own targets.\n */\nexport class ThreadObjectNamespace extends Context.Service<\n ThreadObjectNamespace,\n {\n readonly get: (threadId: ThreadId) => ThreadObjectClient\n /** Stable binding name for opted-in native RPC tracing; absent by default. */\n readonly rpcTracing?: string\n }\n>()('@effect-agent/platform-cloudflare/ThreadObjectNamespace') {\n static layer(\n namespace: DurableObjectNamespace<ThreadObjectRpc>,\n options: { readonly rpcTracing?: string } = {},\n ): Layer.Layer<ThreadObjectNamespace> {\n return Layer.succeed(ThreadObjectNamespace)({\n get: (threadId) => namespace.get(namespace.idFromName(threadId)),\n ...(options.rpcTracing === undefined ? {} : { rpcTracing: options.rpcTracing }),\n })\n }\n}\n\n/** Invoke a placed Thread using the current invocation's native RPC channel. */\nexport const callThreadObject = Effect.fnUntraced(function*<A, E>(\n threadId: ThreadId,\n invoke: (target: ThreadObjectClient) => Promise<A>,\n onError: (cause: unknown) => E,\n): Effect.fn.Return<A, E, ThreadObjectNamespace> {\n const namespace = yield* ThreadObjectNamespace\n\n const target = yield* RpcTargets.get(namespace, threadId, () => namespace.get(threadId)).pipe(\n Effect.mapError(onError),\n )\n\n return yield* Effect.tryPromise({ try: () => invoke(target), catch: onError }).pipe(\n Effect.tapCause(() => RpcTargets.invalidate(target)),\n )\n})\n\n/**\n * Narrow one `env` member to a `DurableObjectNamespace`. `env` is an untyped platform value,\n * and a namespace binding is a host object no Schema can decode, so this is the documented\n * narrowest-boundary check (structural probe for the namespace surface the transport uses);\n * a missing or misshaped binding fails typed before any Layer is built.\n */\nexport const threadNamespaceFromEnv = Effect.fnUntraced(function*(\n env: unknown,\n binding: string,\n): Effect.fn.Return<DurableObjectNamespace<ThreadObjectRpc>, CloudflareBindingError> {\n if (!Predicate.isObjectKeyword(env)) {\n return yield* CloudflareBindingError.make({\n binding,\n message: 'The Worker environment is not an object; no bindings are available.',\n })\n }\n\n const candidate = yield* Effect.try({\n try: () => {\n const value: unknown = Reflect.get(env, binding)\n\n if (!Predicate.isObjectKeyword(value)) return undefined\n const idFromName: unknown = Reflect.get(value, 'idFromName')\n const get: unknown = Reflect.get(value, 'get')\n\n return typeof idFromName === 'function' && typeof get === 'function' ? value : undefined\n },\n catch: () =>\n CloudflareBindingError.make({\n binding,\n message: `env.${binding} could not be inspected as a DurableObjectNamespace binding.`,\n }),\n })\n\n if (candidate !== undefined) {\n // The structural probe above is the entire runtime contract this package relies on;\n // the assertion records that `idFromName`/`get` name a DurableObjectNamespace.\n return candidate as unknown as DurableObjectNamespace<ThreadObjectRpc>\n }\n\n return yield* CloudflareBindingError.make({\n binding,\n message: `env.${binding} is not a DurableObjectNamespace binding; declare the Thread ` +\n 'Object class under this binding in the Worker configuration.',\n })\n})\n\n/**\n * Build the namespace from Worker `env` (fails typed). Enable `rpcTracing` only when the\n * receiver also opts into the effect-cf native RPC trace-context contract.\n */\nexport const threadNamespaceLayer = (\n env: unknown,\n binding: string,\n options: { readonly rpcTracing?: boolean } = {},\n): Layer.Layer<ThreadObjectNamespace, CloudflareBindingError> =>\n Layer.effect(ThreadObjectNamespace)(\n Effect.map(threadNamespaceFromEnv(env, binding), (namespace) => ({\n get: (threadId) => namespace.get(namespace.idFromName(threadId)),\n ...(options.rpcTracing === true ? { rpcTracing: binding } : {}),\n })),\n )\n\n/**\n * The live Durable Object execution context of THIS incarnation. Only Layer construction and\n * the alarm service consume it; important state never lives on it (`ctx.storage` is truth,\n * everything in memory is a cache — deployment spec §11).\n */\nexport class DurableObjectContext extends Context.Service<\n DurableObjectContext,\n {\n readonly ctx: DurableObjectState\n readonly env: unknown\n }\n>()('@effect-agent/platform-cloudflare/DurableObjectContext') {\n static layer(ctx: DurableObjectState, env: unknown): Layer.Layer<DurableObjectContext> {\n return Layer.succeed(DurableObjectContext)({ ctx, env })\n }\n}\n\n/**\n * The Thread identity this Object serializes and the producer identity its Attempts\n * write with (`{producerPrefix}:{threadId}`, plan §1.4). Derived once per incarnation\n * from `ctx.id.name` — the Object identity rule guarantees the name IS the Thread ID.\n */\nexport class ThreadObjectIdentity extends Context.Service<\n ThreadObjectIdentity,\n {\n readonly threadId: ThreadId\n readonly producerId: ProducerId\n }\n>()('@effect-agent/platform-cloudflare/ThreadObjectIdentity') {}\n\n/** Logical Threads whose canonical stores and admission ledger live in this physical Object. */\nexport class ThreadObjectPlacement extends Context.Service<\n ThreadObjectPlacement,\n {\n readonly ownsThread: (threadId: ThreadId) => boolean\n /** Present only when this physical Object owns exactly this one Thread. */\n readonly threadId?: ThreadId\n }\n>()('@effect-agent/platform-cloudflare/ThreadObjectPlacement') {}\n\n/** The Durable Object alarm API failed; surfaces on host entry points as a typed refusal. */\nexport class DurableAlarmError extends Schema.TaggedError<DurableAlarmError>()(\n 'DurableAlarmError',\n {\n operation: Schema.String,\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAa,yBAAb,cAA4C,OAAO,YAAoC,CAAC,CACtF,0BACA;CACE,SAAS,OAAO;CAChB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;;;;;;;AAsDH,IAAa,wBAAb,MAAa,8BAA8B,QAAQ,QAOjD,CAAC,CAAC,yDAAyD,CAAC,CAAC;CAC7D,OAAO,MACL,WACA,UAA4C,CAAC,GACT;EACpC,OAAO,MAAM,QAAQ,qBAAqB,CAAC,CAAC;GAC1C,MAAM,aAAa,UAAU,IAAI,UAAU,WAAW,QAAQ,CAAC;GAC/D,GAAI,QAAQ,eAAe,KAAA,IAAY,CAAC,IAAI,EAAE,YAAY,QAAQ,WAAW;EAC/E,CAAC;CACH;AACF;;AAGA,MAAa,mBAAmB,OAAO,WAAW,WAChD,UACA,QACA,SAC+C;CAC/C,MAAM,YAAY,OAAO;CAEzB,MAAM,SAAS,OAAO,WAAW,IAAI,WAAW,gBAAgB,UAAU,IAAI,QAAQ,CAAC,CAAC,CAAC,KACvF,OAAO,SAAS,OAAO,CACzB;CAEA,OAAO,OAAO,OAAO,WAAW;EAAE,WAAW,OAAO,MAAM;EAAG,OAAO;CAAQ,CAAC,CAAC,CAAC,KAC7E,OAAO,eAAe,WAAW,WAAW,MAAM,CAAC,CACrD;AACF,CAAC;;;;;;;AAQD,MAAa,yBAAyB,OAAO,WAAW,WACtD,KACA,SACmF;CACnF,IAAI,CAAC,UAAU,gBAAgB,GAAG,GAChC,OAAO,OAAO,uBAAuB,KAAK;EACxC;EACA,SAAS;CACX,CAAC;CAGH,MAAM,YAAY,OAAO,OAAO,IAAI;EAClC,WAAW;GACT,MAAM,QAAiB,QAAQ,IAAI,KAAK,OAAO;GAE/C,IAAI,CAAC,UAAU,gBAAgB,KAAK,GAAG,OAAO,KAAA;GAC9C,MAAM,aAAsB,QAAQ,IAAI,OAAO,YAAY;GAC3D,MAAM,MAAe,QAAQ,IAAI,OAAO,KAAK;GAE7C,OAAO,OAAO,eAAe,cAAc,OAAO,QAAQ,aAAa,QAAQ,KAAA;EACjF;EACA,aACE,uBAAuB,KAAK;GAC1B;GACA,SAAS,OAAO,QAAQ;EAC1B,CAAC;CACL,CAAC;CAED,IAAI,cAAc,KAAA,GAGhB,OAAO;CAGT,OAAO,OAAO,uBAAuB,KAAK;EACxC;EACA,SAAS,OAAO,QAAQ;CAE1B,CAAC;AACH,CAAC;;;;;AAMD,MAAa,wBACX,KACA,SACA,UAA6C,CAAC,MAE9C,MAAM,OAAO,qBAAqB,CAAC,CACjC,OAAO,IAAI,uBAAuB,KAAK,OAAO,IAAI,eAAe;CAC/D,MAAM,aAAa,UAAU,IAAI,UAAU,WAAW,QAAQ,CAAC;CAC/D,GAAI,QAAQ,eAAe,OAAO,EAAE,YAAY,QAAQ,IAAI,CAAC;AAC/D,EAAE,CACJ;;;;;;AAOF,IAAa,uBAAb,MAAa,6BAA6B,QAAQ,QAMhD,CAAC,CAAC,wDAAwD,CAAC,CAAC;CAC5D,OAAO,MAAM,KAAyB,KAAiD;EACrF,OAAO,MAAM,QAAQ,oBAAoB,CAAC,CAAC;GAAE;GAAK;EAAI,CAAC;CACzD;AACF;;;;;;AAOA,IAAa,uBAAb,cAA0C,QAAQ,QAMhD,CAAC,CAAC,wDAAwD,CAAC,CAAC,CAAC;;AAG/D,IAAa,wBAAb,cAA2C,QAAQ,QAOjD,CAAC,CAAC,yDAAyD,CAAC,CAAC,CAAC;;AAGhE,IAAa,oBAAb,cAAuC,OAAO,YAA+B,CAAC,CAC5E,qBACA;CACE,WAAW,OAAO;CAClB,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CACF,CAAC,CAAC,CAAC"}
@@ -0,0 +1,134 @@
1
+ import { ThreadId } from "@systemfsoftware/agent/identifiers";
2
+ import { ProducerId } from "@systemfsoftware/agent/records";
3
+ import * as Context from "effect/Context";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Layer from "effect/Layer";
6
+ import * as Schema from "effect/Schema";
7
+ declare namespace CloudflareBindings_d_exports {
8
+ export { CloudflareBindingError, DurableAlarmError, DurableObjectContext, ThreadObjectClient, ThreadObjectIdentity, ThreadObjectNamespace, ThreadObjectPlacement, ThreadObjectRpc, callThreadObject, threadNamespaceFromEnv, threadNamespaceLayer };
9
+ }
10
+ declare const CloudflareBindingError_base: Schema.Class<CloudflareBindingError, Schema.TaggedStruct<"CloudflareBindingError", {
11
+ readonly binding: Schema.String;
12
+ readonly message: Schema.String;
13
+ }>, import("effect/Cause").YieldableError>;
14
+ /**
15
+ * Cloudflare platform bindings as Effect services (DEPLOY-010: "Cloudflare platform bindings
16
+ * are supplied as Effect services/Layers"). Application code never reads `env` or touches a
17
+ * `DurableObjectState` directly — the Thread Object class constructs these Layers once
18
+ * per incarnation and everything downstream consumes the services.
19
+ */
20
+ /** A Cloudflare platform binding was missing or carried the wrong shape (DEPLOY-003/010). */
21
+ declare class CloudflareBindingError extends CloudflareBindingError_base {}
22
+ /**
23
+ * The RPC surface one Thread Durable Object exposes to Workers and to sibling
24
+ * Thread Objects. `ThreadObject.make` implements it; the Worker-side client
25
+ * and the cross-Object transport call it through `DurableObjectNamespace` stubs. Every
26
+ * `encoded` value is a Schema-encoded envelope (`client.ts` wire schemas for host entry
27
+ * points, `@systemfsoftware/agent-storage-cloudflare` port envelopes for `portCall`), so the RPC
28
+ * boundary carries structured-cloneable JSON, except `watchTextEncoded`, which can return
29
+ * a bounded byte stream with a disposable RPC lifetime. The optional trailing trace context is
30
+ * transient native RPC metadata, stripped by an opted-in effect-cf receiver before decoding
31
+ * the host or port envelope. It never enters durable state.
32
+ */
33
+ interface ThreadObjectRpc extends Rpc.DurableObjectBranded {
34
+ /** Admission-limits gate + `DurableAgentRuntime.submit`; answers a `SubmitResponse`. */
35
+ submitEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
36
+ /** Wake-hinted, poll-guaranteed settlement wait; answers an `AwaitSettlementResponse`. */
37
+ submissionStatusEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
38
+ awaitSettlementEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
39
+ /** Finalized canonical settlement record; requires settlement and observation authority. */
40
+ awaitSettlementRecordEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
41
+ /** Event-driven durable progress wait; answers a `ProgressObserved` host response. */
42
+ awaitProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
43
+ /** Best-effort cancellation for one in-flight progress wait. */
44
+ cancelProgressEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
45
+ /**
46
+ * Authorized provisional text; stream with RPC lifetime, or encoded HostFailed.
47
+ * Direct callers must dispose the RPC result; canceling an idle stream alone may not
48
+ * reach its source. CloudflareThreadClient owns both lifetimes for callers.
49
+ */
50
+ watchTextEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
51
+ /** One bounded page of canonical records; answers an `ObservePageResponse`. */
52
+ observePage(encoded: unknown, traceContext?: unknown): Promise<unknown>;
53
+ /** Durable abort intent; answers an `AbortResponse`. */
54
+ abortEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
55
+ /** Durable approval decision (plan §2.6); answers a `ResolveApprovalResponse`. */
56
+ resolveApprovalEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
57
+ /** Authorized DUR-017 Unknown-Outcome resolution; answers a `ResolveUnknownResponse`. */
58
+ resolveUnknownEncoded(encoded: unknown, traceContext?: unknown): Promise<unknown>;
59
+ /** Owner-side cross-Object port endpoint (WP2 envelopes, executed on LOCAL facets). */
60
+ portCall(encoded: unknown, traceContext?: unknown): Promise<unknown>;
61
+ /** Droppable liveness hint from another Object: arms an immediate alarm. */
62
+ wake(): Promise<void>;
63
+ }
64
+ /** A logical Thread endpoint may be bound to an application Object without forging its brand. */
65
+ type ThreadObjectClient = Omit<ThreadObjectRpc, keyof Rpc.DurableObjectBranded>;
66
+ declare const ThreadObjectNamespace_base: Context.ServiceClass<ThreadObjectNamespace, "@effect-agent/platform-cloudflare/ThreadObjectNamespace", {
67
+ readonly get: (threadId: ThreadId) => ThreadObjectClient;
68
+ /** Stable binding name for opted-in native RPC tracing; absent by default. */
69
+ readonly rpcTracing?: string;
70
+ }>;
71
+ /**
72
+ * Deterministic logical Thread placement. The native adapter uses `idFromName(threadId)`;
73
+ * a shared application owner can bind that logical identity into its RPC adapter instead.
74
+ * Lookup performs no I/O and grants no authority. Calls reuse a native target within
75
+ * one invocation; incoming requests and durable retries acquire their own targets.
76
+ */
77
+ declare class ThreadObjectNamespace extends ThreadObjectNamespace_base {
78
+ static layer(namespace: DurableObjectNamespace<ThreadObjectRpc>, options?: {
79
+ readonly rpcTracing?: string;
80
+ }): Layer.Layer<ThreadObjectNamespace>;
81
+ }
82
+ /** Invoke a placed Thread using the current invocation's native RPC channel. */
83
+ declare const callThreadObject: <A, E>(threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">, invoke: (target: ThreadObjectClient) => Promise<A>, onError: (cause: unknown) => E) => Effect.Effect<A, E, ThreadObjectNamespace>;
84
+ /**
85
+ * Narrow one `env` member to a `DurableObjectNamespace`. `env` is an untyped platform value,
86
+ * and a namespace binding is a host object no Schema can decode, so this is the documented
87
+ * narrowest-boundary check (structural probe for the namespace surface the transport uses);
88
+ * a missing or misshaped binding fails typed before any Layer is built.
89
+ */
90
+ declare const threadNamespaceFromEnv: (env: unknown, binding: string) => Effect.Effect<DurableObjectNamespace<ThreadObjectRpc>, CloudflareBindingError, never>;
91
+ /**
92
+ * Build the namespace from Worker `env` (fails typed). Enable `rpcTracing` only when the
93
+ * receiver also opts into the effect-cf native RPC trace-context contract.
94
+ */
95
+ declare const threadNamespaceLayer: (env: unknown, binding: string, options?: {
96
+ readonly rpcTracing?: boolean;
97
+ }) => Layer.Layer<ThreadObjectNamespace, CloudflareBindingError>;
98
+ declare const DurableObjectContext_base: Context.ServiceClass<DurableObjectContext, "@effect-agent/platform-cloudflare/DurableObjectContext", {
99
+ readonly ctx: DurableObjectState;
100
+ readonly env: unknown;
101
+ }>;
102
+ /**
103
+ * The live Durable Object execution context of THIS incarnation. Only Layer construction and
104
+ * the alarm service consume it; important state never lives on it (`ctx.storage` is truth,
105
+ * everything in memory is a cache — deployment spec §11).
106
+ */
107
+ declare class DurableObjectContext extends DurableObjectContext_base {
108
+ static layer(ctx: DurableObjectState, env: unknown): Layer.Layer<DurableObjectContext>;
109
+ }
110
+ declare const ThreadObjectIdentity_base: Context.ServiceClass<ThreadObjectIdentity, "@effect-agent/platform-cloudflare/ThreadObjectIdentity", {
111
+ readonly threadId: ThreadId;
112
+ readonly producerId: ProducerId;
113
+ }>;
114
+ /**
115
+ * The Thread identity this Object serializes and the producer identity its Attempts
116
+ * write with (`{producerPrefix}:{threadId}`, plan §1.4). Derived once per incarnation
117
+ * from `ctx.id.name` — the Object identity rule guarantees the name IS the Thread ID.
118
+ */
119
+ declare class ThreadObjectIdentity extends ThreadObjectIdentity_base {}
120
+ declare const ThreadObjectPlacement_base: Context.ServiceClass<ThreadObjectPlacement, "@effect-agent/platform-cloudflare/ThreadObjectPlacement", {
121
+ readonly ownsThread: (threadId: ThreadId) => boolean;
122
+ /** Present only when this physical Object owns exactly this one Thread. */
123
+ readonly threadId?: ThreadId;
124
+ }>;
125
+ /** Logical Threads whose canonical stores and admission ledger live in this physical Object. */
126
+ declare class ThreadObjectPlacement extends ThreadObjectPlacement_base {}
127
+ declare const DurableAlarmError_base: Schema.Class<DurableAlarmError, Schema.TaggedStruct<"DurableAlarmError", {
128
+ readonly operation: Schema.String;
129
+ readonly message: Schema.String;
130
+ readonly cause: Schema.optionalKey<Schema.Defect>;
131
+ }>, import("effect/Cause").YieldableError>;
132
+ /** The Durable Object alarm API failed; surfaces on host entry points as a typed refusal. */
133
+ declare class DurableAlarmError extends DurableAlarmError_base {}
134
+ export { ThreadObjectClient as a, ThreadObjectPlacement as c, threadNamespaceFromEnv as d, threadNamespaceLayer as f, DurableObjectContext as i, ThreadObjectRpc as l, CloudflareBindings_d_exports as n, ThreadObjectIdentity as o, DurableAlarmError as r, ThreadObjectNamespace as s, CloudflareBindingError as t, callThreadObject as u };
@@ -0,0 +1,2 @@
1
+ import { a as ThreadObjectClient, c as ThreadObjectPlacement, d as threadNamespaceFromEnv, f as threadNamespaceLayer, i as DurableObjectContext, l as ThreadObjectRpc, o as ThreadObjectIdentity, r as DurableAlarmError, s as ThreadObjectNamespace, t as CloudflareBindingError, u as callThreadObject } from "./CloudflareBindings-E1Sty9Vq.mjs";
2
+ export { CloudflareBindingError, DurableAlarmError, DurableObjectContext, ThreadObjectClient, ThreadObjectIdentity, ThreadObjectNamespace, ThreadObjectPlacement, ThreadObjectRpc, callThreadObject, threadNamespaceFromEnv, threadNamespaceLayer };
@@ -0,0 +1 @@
1
+ export { t as CloudflareBindingError, r as DurableAlarmError, i as DurableObjectContext, a as ThreadObjectIdentity, o as ThreadObjectNamespace, s as ThreadObjectPlacement, c as callThreadObject, l as threadNamespaceFromEnv, u as threadNamespaceLayer } from "./CloudflareBindings-Dylkir84.mjs";
@@ -0,0 +1,41 @@
1
+ import { PageCapture } from "@systemfsoftware/agent/page-capture";
2
+ import { PageScreenshot } from "@systemfsoftware/agent/page-screenshot";
3
+ import "@systemfsoftware/agent/sandbox";
4
+ import * as Context from "effect/Context";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Layer from "effect/Layer";
7
+ import * as Schema from "effect/Schema";
8
+ /**
9
+ * Effect-native client captured by the binding service. Compose the pinned
10
+ * action types with the documented Kitesurf selector for links and scrape.
11
+ */
12
+ interface BrowserQuickActionClient {
13
+ readonly screenshot: (options: BrowserRunScreenshotOptions) => Effect.Effect<Response, BrowserQuickActionRpcError>;
14
+ readonly content: (options: BrowserRunContentOptions) => Effect.Effect<Response, BrowserQuickActionRpcError>;
15
+ readonly markdown: (options: BrowserRunMarkdownOptions) => Effect.Effect<Response, BrowserQuickActionRpcError>;
16
+ readonly links: (options: BrowserRunLinksOptions & BrowserRunAlternateBackendOptions) => Effect.Effect<Response, BrowserQuickActionRpcError>;
17
+ readonly scrape: (options: BrowserRunScrapeOptions & BrowserRunAlternateBackendOptions) => Effect.Effect<Response, BrowserQuickActionRpcError>;
18
+ }
19
+ declare const BrowserQuickActionRpcError_base: Schema.Class<BrowserQuickActionRpcError, Schema.TaggedStruct<"BrowserQuickActionRpcError", {
20
+ readonly action: Schema.Literals<readonly ["screenshot", "content", "markdown", "links", "scrape"]>;
21
+ readonly cause: Schema.Defect;
22
+ }>, import("effect/Cause").YieldableError>;
23
+ /** A native binding RPC rejected before it returned an HTTP response. */
24
+ declare class BrowserQuickActionRpcError extends BrowserQuickActionRpcError_base {}
25
+ interface BrowserQuickActionCaptureOptions {
26
+ /** The resolved Wrangler `browser` binding (DEPLOY-014: supplied, never ambient). */
27
+ readonly browser: BrowserRun;
28
+ }
29
+ declare const BrowserQuickActionBrowserBinding_base: Context.ServiceClass<BrowserQuickActionBrowserBinding, "@effect-agent/platform-cloudflare/BrowserQuickActionBrowserBinding", BrowserQuickActionClient>;
30
+ /** Host-owned browser binding authority, supplied explicitly at the composition root. */
31
+ declare class BrowserQuickActionBrowserBinding extends BrowserQuickActionBrowserBinding_base {
32
+ static layer(options: BrowserQuickActionCaptureOptions): Layer.Layer<BrowserQuickActionBrowserBinding>;
33
+ }
34
+ /** Stateless captures require explicit host-owned browser binding authority. */
35
+ declare const browserQuickActionCaptureLayer: Layer.Layer<PageCapture, never, BrowserQuickActionBrowserBinding>;
36
+ /** Native Browser Run screenshot adapter. It retains PNG bytes only for the caller's result. */
37
+ declare const browserQuickActionScreenshotLayer: Layer.Layer<PageScreenshot, never, BrowserQuickActionBrowserBinding>;
38
+ declare namespace CloudflareBrowser_d_exports {
39
+ export { BrowserQuickActionBrowserBinding, BrowserQuickActionCaptureOptions, BrowserQuickActionClient, BrowserQuickActionRpcError, browserQuickActionCaptureLayer, browserQuickActionScreenshotLayer };
40
+ }
41
+ export { BrowserQuickActionRpcError as a, BrowserQuickActionClient as i, BrowserQuickActionBrowserBinding as n, browserQuickActionCaptureLayer as o, BrowserQuickActionCaptureOptions as r, browserQuickActionScreenshotLayer as s, CloudflareBrowser_d_exports as t };