agents 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/dist/{agent-routing-B2XLNMxq.d.ts → agent-routing-0DR0Tk2v.d.ts} +205 -132
  2. package/dist/agent-routing.d.ts +1 -1
  3. package/dist/agent-routing.js.map +1 -1
  4. package/dist/agent-tool-types.d.ts +28 -22
  5. package/dist/agent-tool-types.js +23 -1
  6. package/dist/agent-tool-types.js.map +1 -1
  7. package/dist/{agent-tools-y7zLfw4Q.js → agent-tools-CdJC-8Dc.js} +72 -9
  8. package/dist/agent-tools-CdJC-8Dc.js.map +1 -0
  9. package/dist/{agent-tools-Dj5Mzlw7.d.ts → agent-tools-YrATZJu2.d.ts} +34 -20
  10. package/dist/agent-tools.d.ts +20 -18
  11. package/dist/agent-tools.js.map +1 -1
  12. package/dist/ai-fm7xx1BK.js +312 -0
  13. package/dist/ai-fm7xx1BK.js.map +1 -0
  14. package/dist/base64-redaction-C1Uu29t5.js +59 -0
  15. package/dist/base64-redaction-C1Uu29t5.js.map +1 -0
  16. package/dist/browser/ai-sdk.d.ts +90 -0
  17. package/dist/browser/ai-sdk.js +51 -0
  18. package/dist/browser/ai-sdk.js.map +1 -0
  19. package/dist/browser/ai.d.ts +4 -4
  20. package/dist/browser/ai.js +1 -347
  21. package/dist/browser/index.d.ts +81 -79
  22. package/dist/browser/index.js +361 -2
  23. package/dist/browser/index.js.map +1 -0
  24. package/dist/browser/tanstack-ai.d.ts +96 -1
  25. package/dist/browser/tanstack-ai.js +62 -2
  26. package/dist/browser/tanstack-ai.js.map +1 -1
  27. package/dist/browser-DE3d-RLk.d.ts +275 -0
  28. package/dist/browser-tool-CQ10e6Kj.js +480 -0
  29. package/dist/browser-tool-CQ10e6Kj.js.map +1 -0
  30. package/dist/browser-tool-DuNdlwZ9.d.ts +73 -0
  31. package/dist/capability-B4WbF81e.js.map +1 -1
  32. package/dist/{capability-runner-BUBa6Ake.d.ts → capability-runner-DBAnGr6L.d.ts} +7 -2
  33. package/dist/chat/index.d.ts +340 -234
  34. package/dist/chat/index.js +592 -66
  35. package/dist/chat/index.js.map +1 -1
  36. package/dist/chat/react.d.ts +42 -2
  37. package/dist/chat/react.js +191 -35
  38. package/dist/chat/react.js.map +1 -1
  39. package/dist/chat/transport.d.ts +1 -1
  40. package/dist/chat/transport.js +1 -1
  41. package/dist/chat-sdk/index.d.ts +17 -3
  42. package/dist/chat-sdk/index.js +28 -2
  43. package/dist/chat-sdk/index.js.map +1 -1
  44. package/dist/{client-C9DAjZIY.js → client-4OlMIJx-.js} +102 -29
  45. package/dist/client-4OlMIJx-.js.map +1 -0
  46. package/dist/{client-BxdkCuVy.d.ts → client-je3koD9Z.d.ts} +45 -10
  47. package/dist/client.d.ts +7 -5
  48. package/dist/client.js +2 -2
  49. package/dist/{connector-CptFKzRh.js → connector-58XDGvc3.js} +251 -120
  50. package/dist/connector-58XDGvc3.js.map +1 -0
  51. package/dist/{connector-CkQD4MK3.d.ts → connector-Cl-VqPmA.d.ts} +244 -146
  52. package/dist/context/index.d.ts +29 -0
  53. package/dist/context/index.js +64 -17
  54. package/dist/context/index.js.map +1 -1
  55. package/dist/current-agent-DhoDkSnH.js.map +1 -1
  56. package/dist/{current-agent-C4w86kcN.d.ts → current-agent-vAk_5JMt.d.ts} +4 -4
  57. package/dist/{durable-object-lifecycle-ei7M7lqB.d.ts → durable-object-lifecycle-HhgOMWq9.d.ts} +15 -7
  58. package/dist/harnesses/pi/index.d.ts +348 -0
  59. package/dist/harnesses/pi/index.js +754 -0
  60. package/dist/harnesses/pi/index.js.map +1 -0
  61. package/dist/images-iiTDSyRu.js +1631 -0
  62. package/dist/images-iiTDSyRu.js.map +1 -0
  63. package/dist/{index-Dlgtd3Mj.d.ts → index-BreL0YrQ.d.ts} +2 -2
  64. package/dist/index-kbSUIer3.d.ts +343 -0
  65. package/dist/index.d.ts +46 -44
  66. package/dist/index.js +1 -1
  67. package/dist/internal_context.d.ts +1 -1
  68. package/dist/lifecycle/index.d.ts +3 -3
  69. package/dist/lifecycle/index.js +1 -1
  70. package/dist/{lifecycle-Mm_jQh7r.js → lifecycle-CFu6OV03.js} +39 -10
  71. package/dist/{lifecycle-Mm_jQh7r.js.map → lifecycle-CFu6OV03.js.map} +1 -1
  72. package/dist/mcp/client/index.d.ts +20 -20
  73. package/dist/mcp/client/x402.js +21 -19
  74. package/dist/mcp/client/x402.js.map +1 -1
  75. package/dist/mcp/index.d.ts +35 -35
  76. package/dist/mcp/index.js +1 -1
  77. package/dist/{message-builder-BymO4N_D.js → message-builder-DAl9AhHH.js} +89 -4
  78. package/dist/message-builder-DAl9AhHH.js.map +1 -0
  79. package/dist/models/ai-sdk/index.d.ts +353 -0
  80. package/dist/models/ai-sdk/index.js +2443 -0
  81. package/dist/models/ai-sdk/index.js.map +1 -0
  82. package/dist/models/pi-ai/index.d.ts +313 -0
  83. package/dist/models/pi-ai/index.js +1795 -0
  84. package/dist/models/pi-ai/index.js.map +1 -0
  85. package/dist/observability/ai/index.js +20 -4
  86. package/dist/observability/ai/index.js.map +1 -1
  87. package/dist/{protocol-B0nh6KNf.js → protocol-kHsr-f0X.js} +26 -12
  88. package/dist/{protocol-B0nh6KNf.js.map → protocol-kHsr-f0X.js.map} +1 -1
  89. package/dist/queue/index.d.ts +3 -3
  90. package/dist/queue/index.js +1 -1
  91. package/dist/{queue-BC9F5cUo.js → queue-BB-zfIYF.js} +2 -2
  92. package/dist/{queue-BC9F5cUo.js.map → queue-BB-zfIYF.js.map} +1 -1
  93. package/dist/react.d.ts +6 -6
  94. package/dist/react.js +160 -64
  95. package/dist/react.js.map +1 -1
  96. package/dist/{retries-D9B2UCq3.d.ts → retries-CV6AkXmQ.d.ts} +18 -9
  97. package/dist/retries.d.ts +11 -9
  98. package/dist/retries.js +11 -1
  99. package/dist/retries.js.map +1 -1
  100. package/dist/routing/index.d.ts +2 -2
  101. package/dist/routing/index.js +1 -1
  102. package/dist/{scheduler-D_KHqxBa.js → scheduler-DZ3xQfeK.js} +2 -2
  103. package/dist/{scheduler-D_KHqxBa.js.map → scheduler-DZ3xQfeK.js.map} +1 -1
  104. package/dist/{scheduler-BGq6M5Kd.d.ts → scheduler-RdACNXDP.d.ts} +3 -3
  105. package/dist/schedules/index.d.ts +1 -1
  106. package/dist/schedules/index.js +1 -1
  107. package/dist/serializable.d.ts +1 -1
  108. package/dist/sessions/index.d.ts +70 -3
  109. package/dist/sessions/index.js +276 -67
  110. package/dist/sessions/index.js.map +1 -1
  111. package/dist/skills/index.d.ts +29 -314
  112. package/dist/socket-address.d.ts +16 -0
  113. package/dist/socket-address.js +19 -0
  114. package/dist/socket-address.js.map +1 -0
  115. package/dist/{src-BNU3ZiJM.js → src-BZeu-SCD.js} +423 -115
  116. package/dist/src-BZeu-SCD.js.map +1 -0
  117. package/dist/state/index.d.ts +1 -1
  118. package/dist/state/index.js +1 -1
  119. package/dist/streams/index.d.ts +1 -1
  120. package/dist/streams/index.js +1 -1
  121. package/dist/{streams-BcE8JP2X.d.ts → streams-Cmkj9QfW.d.ts} +4 -2
  122. package/dist/{streams-CCPRV6dt.js → streams-DW-UCOUc.js} +9 -2
  123. package/dist/streams-DW-UCOUc.js.map +1 -0
  124. package/dist/sub-routing.d.ts +12 -12
  125. package/dist/tasks/index.d.ts +1 -1
  126. package/dist/tasks/index.js +1 -1
  127. package/dist/{tasks-D4nLqVSI.js → tasks-68DESxf0.js} +2 -2
  128. package/dist/{tasks-D4nLqVSI.js.map → tasks-68DESxf0.js.map} +1 -1
  129. package/dist/{tasks-V2lCT8ZV.d.ts → tasks-9YxYtByh.d.ts} +2 -2
  130. package/dist/transport-PfFnt-Ld.d.ts +525 -0
  131. package/dist/{types-DCD6BNZH.d.ts → types-BA4anrjI.d.ts} +2 -2
  132. package/dist/voice/index.d.ts +2 -2
  133. package/dist/websockets/index.d.ts +23 -6
  134. package/dist/websockets/index.js +1 -1
  135. package/dist/{websockets-D7IzWbZb.js → websockets-Ci-LZFHH.js} +45 -20
  136. package/dist/{websockets-D7IzWbZb.js.map → websockets-Ci-LZFHH.js.map} +1 -1
  137. package/dist/wire-types-CnMt6_HR.js.map +1 -1
  138. package/dist/wire-types-CrjKvDyi.d.ts +300 -0
  139. package/dist/workflow-types.d.ts +25 -25
  140. package/dist/workflows.d.ts +21 -21
  141. package/dist/workflows.js +1 -1
  142. package/dist/{ws-chat-transport-UNRIS2xl.d.ts → ws-chat-transport-BbT1A5Lc.d.ts} +51 -2
  143. package/dist/{ws-chat-transport-rWwta645.js → ws-chat-transport-cqMKq3IY.js} +143 -16
  144. package/dist/ws-chat-transport-cqMKq3IY.js.map +1 -0
  145. package/docs/agent-tools.md +29 -4
  146. package/docs/browse-the-web.md +87 -5
  147. package/docs/chat-agents.md +124 -16
  148. package/docs/context.md +27 -0
  149. package/docs/durable-execution.md +2 -0
  150. package/docs/harnesses/pi.md +91 -0
  151. package/docs/human-in-the-loop.md +4 -0
  152. package/docs/index.md +3 -0
  153. package/docs/lifecycle.md +20 -4
  154. package/docs/models-pi-ai.md +325 -0
  155. package/docs/models.md +504 -0
  156. package/docs/resumable-streaming.md +2 -0
  157. package/docs/routing.md +13 -13
  158. package/docs/sessions.md +36 -1
  159. package/docs/state.md +1 -0
  160. package/docs/sub-agents.md +9 -0
  161. package/package.json +40 -2
  162. package/dist/agent-tools-y7zLfw4Q.js.map +0 -1
  163. package/dist/browser/ai.js.map +0 -1
  164. package/dist/client-C9DAjZIY.js.map +0 -1
  165. package/dist/client-tools-aIBO0Fk7.d.ts +0 -53
  166. package/dist/connector-CptFKzRh.js.map +0 -1
  167. package/dist/message-builder-BymO4N_D.js.map +0 -1
  168. package/dist/src-BNU3ZiJM.js.map +0 -1
  169. package/dist/streams-CCPRV6dt.js.map +0 -1
  170. package/dist/ws-chat-transport-rWwta645.js.map +0 -1
@@ -4,7 +4,7 @@ import {
4
4
  o as MemoryLimitContext,
5
5
  s as LifecycleCapability,
6
6
  v as LifecycleJobOutcome
7
- } from "./capability-runner-BUBa6Ake.js";
7
+ } from "./capability-runner-DBAnGr6L.js";
8
8
 
9
9
  //#region src/tasks/duration.d.ts
10
10
  /**
@@ -514,4 +514,4 @@ export {
514
514
  TaskWaitReason as x,
515
515
  TaskStepConfig as y
516
516
  };
517
- //# sourceMappingURL=tasks-V2lCT8ZV.d.ts.map
517
+ //# sourceMappingURL=tasks-9YxYtByh.d.ts.map
@@ -0,0 +1,525 @@
1
+ //#region src/models/core/catalog.d.ts
2
+ /**
3
+ * Keys of the ambient `AiModels` interface (from `@cloudflare/workers-types`)
4
+ * whose model type extends `T`. Kept in step with the installed workers-types
5
+ * version rather than hand-maintained here.
6
+ */
7
+ type WorkersAIModelIdsExtending<T> = {
8
+ [K in keyof AiModels]: AiModels[K] extends T ? K : never;
9
+ }[keyof AiModels];
10
+ /** The `inputs` shape a catalog entry declares. */
11
+ type InputsOf<K extends keyof AiModels> = AiModels[K] extends {
12
+ inputs: infer I;
13
+ }
14
+ ? I
15
+ : never;
16
+ /** The `postProcessedOutputs` shape a catalog entry declares. */
17
+ type OutputsOf<K extends keyof AiModels> = AiModels[K] extends {
18
+ postProcessedOutputs: infer O;
19
+ }
20
+ ? O
21
+ : never;
22
+ /**
23
+ * Catalog keys whose input takes a required `messages` array — every current
24
+ * chat model. Newer entries get their own generated class rather than
25
+ * extending `BaseAiTextGeneration`, so the base-class arm alone misses them.
26
+ */
27
+ type ChatCatalogId = {
28
+ [K in keyof AiModels]: Extract<
29
+ InputsOf<K>,
30
+ {
31
+ messages: unknown;
32
+ }
33
+ > extends never
34
+ ? never
35
+ : K;
36
+ }[keyof AiModels];
37
+ /**
38
+ * Catalog keys that take text and answer with embedding vectors. Both halves
39
+ * matter: the input test alone also matches translation, classification and
40
+ * speech models, which take `text` but return something else entirely.
41
+ */
42
+ type EmbeddingCatalogId = {
43
+ [K in keyof AiModels]: Extract<
44
+ InputsOf<K>,
45
+ {
46
+ text: unknown;
47
+ }
48
+ > extends never
49
+ ? never
50
+ : Extract<
51
+ OutputsOf<K>,
52
+ {
53
+ data?: number[][];
54
+ }
55
+ > extends never
56
+ ? never
57
+ : K;
58
+ }[keyof AiModels];
59
+ /**
60
+ * Catalog keys that take audio to transcribe. The `audio` key is required on
61
+ * every speech-recognition input and on no other input shape, so the test is
62
+ * exact rather than heuristic.
63
+ */
64
+ type TranscriptionCatalogId = {
65
+ [K in keyof AiModels]: Extract<
66
+ InputsOf<K>,
67
+ {
68
+ audio: unknown;
69
+ }
70
+ > extends never
71
+ ? never
72
+ : K;
73
+ }[keyof AiModels];
74
+ /**
75
+ * Catalog keys that score a list of contexts against a query — rerankers.
76
+ * `contexts` is required on exactly those inputs.
77
+ */
78
+ type RerankingCatalogId = {
79
+ [K in keyof AiModels]: Extract<
80
+ InputsOf<K>,
81
+ {
82
+ contexts: unknown;
83
+ }
84
+ > extends never
85
+ ? never
86
+ : K;
87
+ }[keyof AiModels];
88
+ /**
89
+ * A Workers AI model id.
90
+ *
91
+ * Workers AI is the one catalog this package keeps up with, so this is the
92
+ * only id shape it accepts: `@cf/<author>/<model>`. Autocomplete covers the
93
+ * text-generation catalog from the installed `@cloudflare/workers-types`; the
94
+ * template arm keeps every other `@cf/` slug assignable, because the catalog
95
+ * lives server-side and moves independently of these types.
96
+ *
97
+ * Third-party models are not ids here — they are model objects built by their
98
+ * own provider package and routed through AI Gateway.
99
+ *
100
+ * @experimental This surface is experimental and may change.
101
+ */
102
+ type WorkersAIModelId =
103
+ | Extract<
104
+ | ChatCatalogId
105
+ | Exclude<
106
+ WorkersAIModelIdsExtending<BaseAiTextGeneration>,
107
+ WorkersAIModelIdsExtending<BaseAiTextToImage>
108
+ >,
109
+ `@cf/${string}`
110
+ >
111
+ | (`@cf/${string}` & {});
112
+ /**
113
+ * A text-embedding model id accepted by `ai.embedding()`.
114
+ *
115
+ * The modality methods are Workers AI only — there is no vendor route for them
116
+ * — so, like {@link WorkersAIModelId}, they take `@cf/` ids and nothing else.
117
+ *
118
+ * @experimental This surface is experimental and may change.
119
+ */
120
+ type CloudflareEmbeddingModelId =
121
+ | Extract<
122
+ EmbeddingCatalogId | WorkersAIModelIdsExtending<BaseAiTextEmbeddings>,
123
+ `@cf/${string}`
124
+ >
125
+ | (`@cf/${string}` & {});
126
+ /**
127
+ * Workers AI text-to-image ids that the generated `AiModels` entries do not
128
+ * classify as {@link BaseAiTextToImage} — the newer partner models get their
129
+ * own generated class instead. Curated for autocomplete only; the catalog
130
+ * lives server-side and any slug is accepted.
131
+ *
132
+ * The FLUX.2 family (`flux-2-dev`, `flux-2-klein-4b`, `flux-2-klein-9b`) is
133
+ * deliberately absent, for the reason {@link UnsupportedTranscriptionId}
134
+ * records for the Deepgram recognisers: its generated input takes a required
135
+ * `multipart` object body (`{ multipart: { body, contentType } }`) and no
136
+ * `prompt`, which the JSON run path cannot carry — live, the run path answers
137
+ * `400 Bad input: required properties at "/" are 'multipart'`. Suggesting an
138
+ * id that always 400s is worse than not suggesting it.
139
+ *
140
+ * @experimental This surface is experimental and may change.
141
+ */
142
+ type KnownImageModelId =
143
+ | "@cf/black-forest-labs/flux-1-schnell"
144
+ | "@cf/leonardo/lucid-origin"
145
+ | "@cf/leonardo/phoenix-1.0";
146
+ /**
147
+ * An image model id accepted by `ai.image()`.
148
+ *
149
+ * @experimental This surface is experimental and may change.
150
+ */
151
+ type CloudflareImageModelId =
152
+ | Extract<
153
+ WorkersAIModelIdsExtending<BaseAiTextToImage> | KnownImageModelId,
154
+ `@cf/${string}`
155
+ >
156
+ | (`@cf/${string}` & {});
157
+ /**
158
+ * Workers AI text-to-speech ids without a {@link BaseAiTextToSpeech} entry.
159
+ * Curated for autocomplete only.
160
+ *
161
+ * @experimental This surface is experimental and may change.
162
+ */
163
+ type KnownSpeechModelId =
164
+ | "@cf/deepgram/aura-1"
165
+ | "@cf/deepgram/aura-2-en"
166
+ | "@cf/deepgram/aura-2-es";
167
+ /**
168
+ * A text-to-speech model id accepted by `ai.speech()`.
169
+ *
170
+ * @experimental This surface is experimental and may change.
171
+ */
172
+ type CloudflareSpeechModelId =
173
+ | Extract<
174
+ WorkersAIModelIdsExtending<BaseAiTextToSpeech> | KnownSpeechModelId,
175
+ `@cf/${string}`
176
+ >
177
+ | (`@cf/${string}` & {});
178
+ /**
179
+ * Deepgram's recognition models want the audio as an object body
180
+ * (`audio: { body, contentType }`) rather than as base64, which the JSON run
181
+ * path cannot carry — every documented variant answered `400` live. They stay
182
+ * out of the suggested arm, and the transcription model answers a clear error
183
+ * for them.
184
+ */
185
+ type UnsupportedTranscriptionId = "@cf/deepgram/nova-3" | "@cf/deepgram/flux";
186
+ /**
187
+ * A speech-recognition model id accepted by `ai.transcription()`.
188
+ *
189
+ * Deepgram's recognition models (`@cf/deepgram/nova-3`, `@cf/deepgram/flux`)
190
+ * are deliberately not suggested: the run path rejects their documented input
191
+ * shape, so this provider answers a clear error for them rather than a 400.
192
+ *
193
+ * @experimental This surface is experimental and may change.
194
+ */
195
+ type CloudflareTranscriptionModelId =
196
+ | Extract<
197
+ | Exclude<TranscriptionCatalogId, UnsupportedTranscriptionId>
198
+ | Exclude<
199
+ WorkersAIModelIdsExtending<BaseAiAutomaticSpeechRecognition>,
200
+ UnsupportedTranscriptionId
201
+ >,
202
+ `@cf/${string}`
203
+ >
204
+ | (`@cf/${string}` & {});
205
+ /**
206
+ * A reranking model id accepted by `ai.reranking()`.
207
+ *
208
+ * @experimental This surface is experimental and may change.
209
+ */
210
+ type CloudflareRerankingModelId =
211
+ | Extract<RerankingCatalogId, `@cf/${string}`>
212
+ | (`@cf/${string}` & {});
213
+ //#endregion
214
+ //#region src/models/core/settings.d.ts
215
+ /**
216
+ * AI Gateway settings for a request. The gateway is an option, not a separate
217
+ * product: every call goes through one, and `id` defaults to `"default"`,
218
+ * which Cloudflare creates on first use.
219
+ *
220
+ * @experimental This surface is experimental and may change.
221
+ */
222
+ interface GatewayOptions {
223
+ /** Gateway id. Defaults to `"default"` (auto-created on first use). */
224
+ id?: string;
225
+ /** Bypass the cache for this request. */
226
+ skipCache?: boolean;
227
+ /** Cache lifetime in seconds. */
228
+ cacheTtl?: number;
229
+ /** Explicit cache key, instead of the request-derived one. */
230
+ cacheKey?: string;
231
+ /** Whether the gateway stores the request/response in its log. */
232
+ collectLog?: boolean;
233
+ /** Arbitrary key/values attached to the gateway log entry. */
234
+ metadata?: Record<string, string | number | boolean | null>;
235
+ /** Correlates several requests into one gateway event. */
236
+ eventId?: string;
237
+ /** Upstream request timeout in milliseconds. */
238
+ requestTimeoutMs?: number;
239
+ /** Server-side retry policy for the upstream provider call. */
240
+ retries?: {
241
+ maxAttempts?: 1 | 2 | 3 | 4 | 5;
242
+ retryDelayMs?: number;
243
+ backoff?: "constant" | "linear" | "exponential";
244
+ };
245
+ }
246
+ /**
247
+ * How `createAI` reaches Cloudflare: the Workers AI binding, and nothing else.
248
+ * Workers AI models go through `env.AI.run`, vendor models through
249
+ * `env.AI.gateway(id).run` — both are the binding, so there is no HTTP
250
+ * transport, no account id and no API token to hold.
251
+ *
252
+ * @experimental This surface is experimental and may change.
253
+ */
254
+ type AISettings = {
255
+ /** The `AI` binding from a Worker's env. */ binding: Ai;
256
+ } & ProviderGatewaySettings;
257
+ /**
258
+ * Provider-wide gateway defaults, in either spelling: nested under `gateway`,
259
+ * or flat (`{ id: "prod", cacheTtl: 60 }`). Both merge, the flat key winning.
260
+ *
261
+ * @experimental This surface is experimental and may change.
262
+ */
263
+ interface ProviderGatewaySettings extends GatewayOptions {
264
+ /** Gateway id or full gateway options. */
265
+ gateway?: string | GatewayOptions;
266
+ }
267
+ /**
268
+ * Per-model and per-call options. The flat gateway keys are sugar for
269
+ * `gateway: { ... }`; both forms merge, with the flat key winning.
270
+ *
271
+ * The same shape is accepted per call under
272
+ * `providerOptions.cloudflare`, where it takes precedence over the per-model
273
+ * options, which in turn take precedence over the `createAI` settings.
274
+ *
275
+ * `Leg` is what a framework module accepts as a fallback leg. Workers AI ids
276
+ * are the only kind this module can resolve on its own, so they are the
277
+ * default; a module whose legs may also be model objects says so
278
+ * (`ModelOptions<WorkersAIModelId | LanguageModelV4>`) rather than rebuilding
279
+ * the type.
280
+ *
281
+ * @experimental This surface is experimental and may change.
282
+ */
283
+ interface ModelOptions<Leg = WorkersAIModelId> extends ProviderGatewaySettings {
284
+ /**
285
+ * Models to try, in order, if the primary fails before any output is
286
+ * produced. A leg travels with the chain's gateway options — those win over
287
+ * a leg's own, and `metadata` merges — while everything a leg was built with
288
+ * itself stays its own. Client-side today; becomes server-side when the
289
+ * platform ships model-first routing.
290
+ */
291
+ fallback?: Leg[];
292
+ /** Extra request headers, merged last. */
293
+ headers?: Record<string, string>;
294
+ /**
295
+ * Workers AI only: route same-key requests to the same replica for
296
+ * prefix-cache hits. Sent as the `x-session-affinity` header.
297
+ */
298
+ sessionAffinity?: string;
299
+ /**
300
+ * Explicit reasoning effort. `null` disables reasoning on models that
301
+ * support toggling it. The unified AI SDK `reasoning` call option maps onto
302
+ * this when this is not set.
303
+ */
304
+ reasoningEffort?: "low" | "medium" | "high" | null;
305
+ /**
306
+ * Workers AI only: forwarded verbatim as `chat_template_kwargs`, e.g.
307
+ * `{ enable_thinking: false }`.
308
+ */
309
+ chatTemplateKwargs?: Record<string, unknown>;
310
+ }
311
+ /** A gateway config with the id filled in. */
312
+ interface ResolvedGateway extends GatewayOptions {
313
+ id: string;
314
+ }
315
+ //#endregion
316
+ //#region src/models/core/errors.d.ts
317
+ /**
318
+ * Coarse classification of a failed Cloudflare AI call.
319
+ *
320
+ * @experimental This surface is experimental and may change.
321
+ */
322
+ type CloudflareAIErrorCode =
323
+ | "auth"
324
+ | "rate-limit"
325
+ | "not-found"
326
+ | "bad-request"
327
+ | "provider-error"
328
+ | "gateway-error"
329
+ | "unknown";
330
+ /**
331
+ * One leg of a {@link CloudflareAIError} fallback chain.
332
+ *
333
+ * @experimental This surface is experimental and may change.
334
+ */
335
+ interface CloudflareAIAttempt {
336
+ /** The model id that was tried. */
337
+ model: string;
338
+ /** The error that leg failed with. */
339
+ error: unknown;
340
+ }
341
+ /**
342
+ * Error thrown for every failed Cloudflare AI call, whether it came back as a
343
+ * non-2xx `Response` or as a thrown Workers AI binding error. Framework
344
+ * modules wrap it into their own error type at their boundary (the AI SDK
345
+ * module into an `APICallError`, so `ai`'s retry loop honours
346
+ * {@link CloudflareAIError.isRetryable}).
347
+ *
348
+ * @experimental This surface is experimental and may change.
349
+ */
350
+ declare class CloudflareAIError extends Error {
351
+ /** HTTP status, when the failure carried one. */
352
+ readonly status: number | undefined;
353
+ /** Coarse classification used for routing and fallback decisions. */
354
+ readonly code: CloudflareAIErrorCode;
355
+ /** `cf-aig-log-id` of the failed request, when the response carried one. */
356
+ readonly logId: string | undefined;
357
+ /** The model id that produced this error. */
358
+ readonly model: string;
359
+ /** Which binding path the request went down, for error reporting. */
360
+ readonly url: string;
361
+ /** The request body that failed. */
362
+ readonly requestBodyValues: unknown;
363
+ /** Response headers, when there was a response. */
364
+ readonly responseHeaders: Record<string, string> | undefined;
365
+ /** Raw response body text, when there was a response. */
366
+ readonly responseBody: string | undefined;
367
+ /** Whether a retry is worth attempting. */
368
+ readonly isRetryable: boolean;
369
+ /** Parsed error envelope, or other structured detail. */
370
+ readonly data: unknown;
371
+ /** Every leg tried, when this error ends a fallback chain. */
372
+ readonly attempts: CloudflareAIAttempt[] | undefined;
373
+ readonly cause: unknown;
374
+ constructor(options: {
375
+ message: string;
376
+ model: string;
377
+ url: string;
378
+ requestBodyValues: unknown;
379
+ status?: number;
380
+ code: CloudflareAIErrorCode;
381
+ logId?: string;
382
+ responseHeaders?: Record<string, string>;
383
+ responseBody?: string;
384
+ isRetryable?: boolean;
385
+ data?: unknown;
386
+ cause?: unknown;
387
+ attempts?: CloudflareAIAttempt[];
388
+ });
389
+ }
390
+ //#endregion
391
+ //#region src/models/core/gateway-providers.d.ts
392
+ /**
393
+ * The AI Gateway provider table: which gateway provider slug a vendor's own
394
+ * base URL belongs to, and what the universal request's `endpoint` is for a
395
+ * given upstream URL.
396
+ *
397
+ * This is platform knowledge, not vendor knowledge — the gateway publishes the
398
+ * list, and every entry here appears in `AIGatewayProviders` from
399
+ * `@cloudflare/workers-types`. Nothing about a vendor's wire format, model ids
400
+ * or capabilities lives here: the vendor's own provider package builds the
401
+ * request, and this table only says where it goes.
402
+ *
403
+ * Adapted from `@cloudflare/ai-gateway-provider`'s `providers.ts`.
404
+ *
405
+ * @experimental This surface is experimental and may change.
406
+ */
407
+ /**
408
+ * The gateway provider slugs this table maps onto. A subset of the ambient
409
+ * `AIGatewayProviders` union; {@link GatewayProviderNameCheck} keeps it one.
410
+ *
411
+ * @experimental This surface is experimental and may change.
412
+ */
413
+ declare const GATEWAY_PROVIDER_NAMES: readonly [
414
+ "workers-ai",
415
+ "anthropic",
416
+ "openai",
417
+ "azure-openai",
418
+ "google-ai-studio",
419
+ "google-vertex-ai",
420
+ "grok",
421
+ "mistral",
422
+ "perplexity-ai",
423
+ "replicate",
424
+ "groq",
425
+ "deepseek",
426
+ "openrouter",
427
+ "cerebras",
428
+ "cohere",
429
+ "huggingface",
430
+ "aws-bedrock",
431
+ "elevenlabs",
432
+ "cartesia"
433
+ ];
434
+ /**
435
+ * A gateway provider slug.
436
+ *
437
+ * @experimental This surface is experimental and may change.
438
+ */
439
+ type GatewayProviderName = (typeof GATEWAY_PROVIDER_NAMES)[number];
440
+ //#endregion
441
+ //#region src/models/core/transport.d.ts
442
+ /** One request on the Cloudflare run path. */
443
+ interface TransportRequest {
444
+ /** Model id — Workers AI slug or catalog `<author>/<model>`. */
445
+ model: string;
446
+ /** The provider-shaped request body (`input` on the run path). */
447
+ input: Record<string, unknown>;
448
+ /** Gateway options for this request. */
449
+ gateway: ResolvedGateway;
450
+ /** Extra request headers, merged last. */
451
+ headers: Record<string, string>;
452
+ /** Abort signal, forwarded to the binding or to `fetch`. */
453
+ signal?: AbortSignal;
454
+ }
455
+ /**
456
+ * One request on the universal AI Gateway path: a vendor's own request, routed
457
+ * by the gateway to that vendor. The body is the vendor's, untouched — nothing
458
+ * here knows the vendor's wire format.
459
+ *
460
+ * @experimental This surface is experimental and may change.
461
+ */
462
+ interface UniversalRequest {
463
+ /** The gateway provider slug the request is routed to. */
464
+ provider: GatewayProviderName | string;
465
+ /** The vendor path the gateway appends to that provider's base URL. */
466
+ endpoint: string;
467
+ /** The vendor's own request headers, minus its credential header. */
468
+ headers: Record<string, string>;
469
+ /** The vendor's request body, verbatim. */
470
+ query: unknown;
471
+ /** Gateway options for this request. */
472
+ gateway: ResolvedGateway;
473
+ /** Extra headers merged last, outside the vendor's own set. */
474
+ extraHeaders?: Record<string, string>;
475
+ /** Abort signal, forwarded to the binding or to `fetch`. */
476
+ signal?: AbortSignal;
477
+ }
478
+ /**
479
+ * The single code path both backends implement. Always resolves to a raw
480
+ * `Response`, so streaming and non-streaming calls share one path and nothing
481
+ * is buffered on the caller's behalf.
482
+ *
483
+ * @experimental This surface is experimental and may change.
484
+ */
485
+ interface Transport {
486
+ /** A stable identifier for the endpoint, used in error reporting. */
487
+ readonly url: string;
488
+ run(request: TransportRequest): Promise<Response>;
489
+ /**
490
+ * Sends a vendor's own request through the gateway's universal endpoint.
491
+ * Always resolves to the vendor's raw `Response`, error responses included:
492
+ * only the gateway's own failures (a missing gateway, an unpaid account) are
493
+ * lifted into a {@link CloudflareAIError}, because the vendor's provider
494
+ * knows how to read its own errors and we do not.
495
+ */
496
+ universal(request: UniversalRequest): Promise<Response>;
497
+ /**
498
+ * A log id read off the backend itself when the response carried none. The
499
+ * Workers AI binding exposes the last gateway log id as a mutable property,
500
+ * so it is captured per response rather than read late.
501
+ */
502
+ logIdFallback(response: Response): string | undefined;
503
+ }
504
+ //#endregion
505
+ export {
506
+ KnownSpeechModelId as _,
507
+ CloudflareAIError as a,
508
+ GatewayOptions as c,
509
+ CloudflareEmbeddingModelId as d,
510
+ CloudflareImageModelId as f,
511
+ KnownImageModelId as g,
512
+ CloudflareTranscriptionModelId as h,
513
+ CloudflareAIAttempt as i,
514
+ ModelOptions as l,
515
+ CloudflareSpeechModelId as m,
516
+ GATEWAY_PROVIDER_NAMES as n,
517
+ CloudflareAIErrorCode as o,
518
+ CloudflareRerankingModelId as p,
519
+ GatewayProviderName as r,
520
+ AISettings as s,
521
+ Transport as t,
522
+ ProviderGatewaySettings as u,
523
+ WorkersAIModelId as v
524
+ };
525
+ //# sourceMappingURL=transport-PfFnt-Ld.d.ts.map
@@ -1,4 +1,4 @@
1
- import { t as RetryOptions } from "./retries-D9B2UCq3.js";
1
+ import { t as RetryOptions } from "./retries-CV6AkXmQ.js";
2
2
 
3
3
  //#region src/queue/types.d.ts
4
4
  /**
@@ -67,4 +67,4 @@ export {
67
67
  QueueHandlers as r,
68
68
  QueueCallbacks as t
69
69
  };
70
- //# sourceMappingURL=types-DCD6BNZH.d.ts.map
70
+ //# sourceMappingURL=types-BA4anrjI.d.ts.map
@@ -1,5 +1,5 @@
1
- import { x as Connection } from "../capability-runner-BUBa6Ake.js";
2
- import { c as Agent } from "../agent-routing-B2XLNMxq.js";
1
+ import { x as Connection } from "../capability-runner-DBAnGr6L.js";
2
+ import { c as Agent } from "../agent-routing-0DR0Tk2v.js";
3
3
  import {
4
4
  C as VoiceTransport,
5
5
  D as VoiceTurnSource,
@@ -4,7 +4,7 @@ import {
4
4
  r as CapabilityWebSocketUpgradeContext,
5
5
  s as LifecycleCapability,
6
6
  x as Connection
7
- } from "../capability-runner-BUBa6Ake.js";
7
+ } from "../capability-runner-DBAnGr6L.js";
8
8
  import {
9
9
  a as capnWebTransportUrl,
10
10
  n as CAPNWEB_TRANSPORT_QUERY,
@@ -84,7 +84,8 @@ interface WebSocketsOptions {
84
84
  * connect or via `broadcastState()`, but can still send and receive
85
85
  * ordinary messages and use callables. For binary-only clients.
86
86
  * - `false`: the host drives the connect sequence itself with
87
- * `sendIdentity()` and `sendState()`, and applies client state frames
87
+ * `sendConnectFrames()` (or `sendIdentity()` and `sendState()`
88
+ * separately), and applies client state frames
88
89
  * with `applyStateFrame()` — `Agent` does this, since it must decide
89
90
  * whether a connection belongs to a facet before any frame is sent.
90
91
  */
@@ -211,10 +212,26 @@ declare class WebSockets extends LifecycleCapability {
211
212
  /** One connection on either wire, by id. */
212
213
  getConnection<TState = unknown>(id: string): Connection<TState> | undefined;
213
214
  /**
214
- * Send the identity frame, unless the connection is no-protocol. The
215
- * defaults are the Durable Object's routed name and host class; a host
216
- * whose public identity differs — an `Agent` facet, whose routed name
217
- * is an internal encoding of its logical name — passes its own.
215
+ * Send the connect sequence: the identity frame, then the current state
216
+ * when one is stored. The identity carries `stateFollows` in that case,
217
+ * so clients resolve `ready` only once the state has landed. Nothing is
218
+ * sent to a no-protocol connection. Identity defaults as for
219
+ * `sendIdentity()`.
220
+ */
221
+ sendConnectFrames(
222
+ connection: Connection,
223
+ identity?: {
224
+ name: string;
225
+ agent: string;
226
+ }
227
+ ): void;
228
+ /**
229
+ * Send the identity frame alone, unless the connection is no-protocol.
230
+ * Clients resolve `ready` on it, so a host that also pushes state on
231
+ * connect should use `sendConnectFrames()`. The defaults are the Durable
232
+ * Object's routed name and host class; a host whose public identity
233
+ * differs — an `Agent` facet, whose routed name is an internal encoding
234
+ * of its logical name — passes its own.
218
235
  */
219
236
  sendIdentity(
220
237
  connection: Connection,
@@ -1,3 +1,3 @@
1
1
  import { a as isCapnWebTransportUpgrade, i as capnWebTransportUrl, r as CAPNWEB_TRANSPORT_VALUE, t as CAPNWEB_TRANSPORT_QUERY } from "../transport-protocol-BxyngQ_R.js";
2
- import { l as registerInternalConnectionKeys, n as CF_NO_PROTOCOL_KEY, r as CF_READONLY_KEY, t as WebSockets } from "../websockets-D7IzWbZb.js";
2
+ import { l as registerInternalConnectionKeys, n as CF_NO_PROTOCOL_KEY, r as CF_READONLY_KEY, t as WebSockets } from "../websockets-Ci-LZFHH.js";
3
3
  export { CAPNWEB_TRANSPORT_QUERY, CAPNWEB_TRANSPORT_VALUE, CF_NO_PROTOCOL_KEY, CF_READONLY_KEY, WebSockets, capnWebTransportUrl, isCapnWebTransportUpgrade, registerInternalConnectionKeys };