agents 0.32.0 → 0.34.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 (187) hide show
  1. package/README.md +1 -1
  2. package/dist/{agent-routing-vVMA7m8Y.d.ts → agent-routing-BSoZzNiP.d.ts} +537 -373
  3. package/dist/agent-routing.d.ts +1 -1
  4. package/dist/agent-tool-types.d.ts +1 -1
  5. package/dist/{agent-tools-gGXXkf1z.d.ts → agent-tools-Be-hpRpH.d.ts} +2 -2
  6. package/dist/agent-tools.d.ts +1 -1
  7. package/dist/{ai-sdk-Kon40i0q.js → ai-sdk-CRMlEBX7.js} +75 -44
  8. package/dist/ai-sdk-CRMlEBX7.js.map +1 -0
  9. package/dist/browser/ai.js +2 -3
  10. package/dist/browser/ai.js.map +1 -1
  11. package/dist/browser/index.d.ts +33 -21
  12. package/dist/browser/index.js +937 -4
  13. package/dist/browser/index.js.map +1 -0
  14. package/dist/browser/tools/ai-sdk.d.ts +4 -4
  15. package/dist/browser/tools/ai-sdk.js +9 -3
  16. package/dist/browser/tools/ai-sdk.js.map +1 -1
  17. package/dist/browser/tools/pi.d.ts +11 -8
  18. package/dist/browser/tools/pi.js +58 -11
  19. package/dist/browser/tools/pi.js.map +1 -1
  20. package/dist/browser/tools/tanstack-ai.d.ts +4 -4
  21. package/dist/browser/tools/tanstack-ai.js +3 -3
  22. package/dist/browser/tools/tanstack-ai.js.map +1 -1
  23. package/dist/{browser-D9RNpJuT.d.ts → browser-C9T74n4c.d.ts} +302 -95
  24. package/dist/browser-tool-DOqT1oSD.js +360 -0
  25. package/dist/browser-tool-DOqT1oSD.js.map +1 -0
  26. package/dist/{browser-tool-BhjCcNVE.d.ts → browser-tool-DxAYQY9T.d.ts} +2 -2
  27. package/dist/capability-DBAKc6UZ.js.map +1 -1
  28. package/dist/{capability-runner-BiVUtjqC.d.ts → capability-runner-uFOdSANC.d.ts} +3 -2
  29. package/dist/chat/index.d.ts +37 -6
  30. package/dist/chat/index.js +39 -3
  31. package/dist/chat/index.js.map +1 -1
  32. package/dist/chat/react.js +1 -0
  33. package/dist/chat/react.js.map +1 -1
  34. package/dist/chat-sdk/index.d.ts +3 -3
  35. package/dist/chat-sdk/index.js +1 -1
  36. package/dist/cli.js +62 -60
  37. package/dist/client-CkT8voRY.js +3740 -0
  38. package/dist/client-CkT8voRY.js.map +1 -0
  39. package/dist/{client-eSfgYvd3.d.ts → client-DqS6oequ.d.ts} +2 -2
  40. package/dist/client.d.ts +1 -1
  41. package/dist/{connector-CM-uuxKM.js → connector-Bphz6wIw.js} +414 -3
  42. package/dist/connector-Bphz6wIw.js.map +1 -0
  43. package/dist/{conversations-FjHDRZyD.d.ts → conversations-CoAYNW_q.d.ts} +4 -4
  44. package/dist/{current-agent-CKgT5d1O.d.ts → current-agent-DShbQHDO.d.ts} +24 -3
  45. package/dist/current-agent-DhoDkSnH.js.map +1 -1
  46. package/dist/{do-oauth-client-provider-DtNqv7oj.d.ts → do-oauth-client-provider-BsT8-vtd.d.ts} +22 -2
  47. package/dist/{durable-object-lifecycle-DOI_bzCH.d.ts → durable-object-lifecycle-CRCA6O0W.d.ts} +2 -2
  48. package/dist/experimental/channels/index.d.ts +2 -2
  49. package/dist/experimental/channels/web/index.d.ts +2 -2
  50. package/dist/experimental/channels/web/index.js +1 -1
  51. package/dist/{gateway-BFO6vRDn.d.ts → gateway-Dz8zyZBJ.d.ts} +2 -2
  52. package/dist/harness/ai-sdk/index.d.ts +2 -2
  53. package/dist/harness/container/index.d.ts +2 -2
  54. package/dist/harness/container/index.js +1 -1
  55. package/dist/harness/container/index.js.map +1 -1
  56. package/dist/harness/opencode/index.d.ts +1 -1
  57. package/dist/harness/pi/index.d.ts +200 -37
  58. package/dist/harness/pi/index.js +202 -100
  59. package/dist/harness/pi/index.js.map +1 -1
  60. package/dist/harness/think/index.d.ts +2 -2
  61. package/dist/{images-CfuRCjwq.js → images-D4gtE06D.js} +119 -27
  62. package/dist/images-D4gtE06D.js.map +1 -0
  63. package/dist/{index-8k4qsX1T.d.ts → index-BXVgv6tp.d.ts} +4 -4
  64. package/dist/{index-BEL3ZV-s.d.ts → index-Cs7Ed9la.d.ts} +2 -2
  65. package/dist/{index-CBt8oRJt.d.ts → index-XiZxauMU.d.ts} +3 -3
  66. package/dist/index.d.ts +21 -21
  67. package/dist/index.js +2 -2
  68. package/dist/{input-schema-BQykTEp_.js → input-schema-D6GilRXI.js} +3 -3
  69. package/dist/input-schema-D6GilRXI.js.map +1 -0
  70. package/dist/{input-schema-B0Etuo-o.js → input-schema-y8W5bOdM.js} +3 -3
  71. package/dist/input-schema-y8W5bOdM.js.map +1 -0
  72. package/dist/internal_context.d.ts +1 -1
  73. package/dist/lifecycle/index.d.ts +3 -3
  74. package/dist/lifecycle/index.js +1 -1
  75. package/dist/{lifecycle-v1rKHV2C.js → lifecycle-CB5Dmtrt.js} +126 -38
  76. package/dist/lifecycle-CB5Dmtrt.js.map +1 -0
  77. package/dist/mcp/client/do-oauth-client-provider.d.ts +1 -1
  78. package/dist/mcp/client/do-oauth-client-provider.js +45 -2
  79. package/dist/mcp/client/do-oauth-client-provider.js.map +1 -1
  80. package/dist/mcp/client/index.d.ts +42 -36
  81. package/dist/mcp/client/index.js +2 -2
  82. package/dist/mcp/index.d.ts +16 -16
  83. package/dist/mcp/index.js +2 -2
  84. package/dist/models/ai-sdk/index.d.ts +9 -5
  85. package/dist/models/ai-sdk/index.js +1 -1
  86. package/dist/models/opencode/index.d.ts +3 -3
  87. package/dist/models/opencode/index.js +2 -2
  88. package/dist/models/opencode/index.js.map +1 -1
  89. package/dist/models/pi-ai/index.d.ts +4 -4
  90. package/dist/models/pi-ai/index.js +64 -170
  91. package/dist/models/pi-ai/index.js.map +1 -1
  92. package/dist/{options-CiIsJHXR.d.ts → options-CiXaymmZ.d.ts} +2 -2
  93. package/dist/queue/index.d.ts +1 -1
  94. package/dist/queue/index.js +1 -1
  95. package/dist/{queue-CcIjVYTE.js → queue-B_wl6K0Z.js} +24 -5
  96. package/dist/queue-B_wl6K0Z.js.map +1 -0
  97. package/dist/react.d.ts +2 -2
  98. package/dist/routing/index.d.ts +2 -2
  99. package/dist/{scheduler-BCLESHSC.d.ts → scheduler-CTpR0Ct0.d.ts} +2 -2
  100. package/dist/{scheduler-FIHv2-kJ.js → scheduler-DGNEmxQR.js} +2 -1
  101. package/dist/scheduler-DGNEmxQR.js.map +1 -0
  102. package/dist/schedules/index.d.ts +1 -1
  103. package/dist/schedules/index.js +1 -1
  104. package/dist/serializable.d.ts +1 -1
  105. package/dist/{session-7CDgVE0z.js → session-CRY0bGiI.js} +423 -411
  106. package/dist/session-CRY0bGiI.js.map +1 -0
  107. package/dist/sessions/index.d.ts +1 -1
  108. package/dist/{settings-Dk2il2Hf.js → settings-D2F_qONv.js} +11 -2
  109. package/dist/settings-D2F_qONv.js.map +1 -0
  110. package/dist/{src-DoGNJ4Ud.js → src-BO1FdLK1.js} +145 -86
  111. package/dist/src-BO1FdLK1.js.map +1 -0
  112. package/dist/state/index.d.ts +1 -1
  113. package/dist/streams/index.d.ts +1 -1
  114. package/dist/{streams-vrCtbUIn.d.ts → streams-CAZxZBDg.d.ts} +2 -2
  115. package/dist/sub-routing.d.ts +12 -12
  116. package/dist/tasks/index.d.ts +1 -1
  117. package/dist/tasks/index.js +1 -1
  118. package/dist/{tasks-BN_5AWqI.js → tasks-Cf_UfEO4.js} +2 -1
  119. package/dist/{tasks-BN_5AWqI.js.map → tasks-Cf_UfEO4.js.map} +1 -1
  120. package/dist/{tasks-E89KdwkS.d.ts → tasks-Cs8ilctE.d.ts} +2 -2
  121. package/dist/{tool-DkT_DJBm.js → tool-CmAGY6Fo.js} +24 -3
  122. package/dist/tool-CmAGY6Fo.js.map +1 -0
  123. package/dist/{tool-CxKsvxjm.js → tool-Kxcj8_22.js} +24 -4
  124. package/dist/tool-Kxcj8_22.js.map +1 -0
  125. package/dist/{tool-helpers-BI7ifO2S.js → tool-helpers-F3_Wy2YX.js} +2 -2
  126. package/dist/{tool-helpers-BI7ifO2S.js.map → tool-helpers-F3_Wy2YX.js.map} +1 -1
  127. package/dist/{transport-5moD2pW5.d.ts → transport-hV8AW4Bv.d.ts} +45 -12
  128. package/dist/voice/index.d.ts +2 -2
  129. package/dist/web/fetch/index.js +1 -1
  130. package/dist/web/fetch/tools/ai-sdk.js +2 -2
  131. package/dist/web/fetch/tools/pi.d.ts +9 -7
  132. package/dist/web/fetch/tools/pi.js +31 -7
  133. package/dist/web/fetch/tools/pi.js.map +1 -1
  134. package/dist/web/fetch/tools/tanstack-ai.js +2 -2
  135. package/dist/web/search/index.js +1 -1
  136. package/dist/web/search/tools/ai-sdk.js +2 -2
  137. package/dist/web/search/tools/pi.d.ts +9 -4
  138. package/dist/web/search/tools/pi.js +27 -11
  139. package/dist/web/search/tools/pi.js.map +1 -1
  140. package/dist/web/search/tools/tanstack-ai.js +2 -2
  141. package/dist/websockets/index.d.ts +2 -2
  142. package/dist/websockets/index.js +1 -1
  143. package/dist/{websockets-C6SJtWCJ.js → websockets-W4uhRg4-.js} +68 -5
  144. package/dist/websockets-W4uhRg4-.js.map +1 -0
  145. package/dist/workflow-types.d.ts +1 -1
  146. package/dist/workflows.d.ts +1 -1
  147. package/docs/agent-class.md +30 -4
  148. package/docs/browse-the-web.md +50 -3
  149. package/docs/chat-agents.md +13 -10
  150. package/docs/client-tools-continuation.md +1 -1
  151. package/docs/codemode.md +1 -1
  152. package/docs/configuration.md +6 -3
  153. package/docs/cross-domain-authentication.md +1 -1
  154. package/docs/fetch-the-web.md +20 -0
  155. package/docs/harnesses/pi.md +242 -33
  156. package/docs/harnesses/think.md +1 -1
  157. package/docs/http-websockets.md +40 -32
  158. package/docs/human-in-the-loop.md +2 -2
  159. package/docs/lifecycle.md +56 -0
  160. package/docs/mcp-client.md +104 -7
  161. package/docs/models-pi-ai.md +24 -10
  162. package/docs/models.md +42 -17
  163. package/docs/resumable-streaming.md +1 -1
  164. package/docs/retries.md +3 -6
  165. package/docs/search-the-web.md +10 -0
  166. package/docs/voice.md +1 -1
  167. package/package.json +16 -9
  168. package/dist/ai-sdk-Kon40i0q.js.map +0 -1
  169. package/dist/browser-1eUbPvC2.js +0 -931
  170. package/dist/browser-1eUbPvC2.js.map +0 -1
  171. package/dist/browser-tool-DRan7Lk6.js +0 -497
  172. package/dist/browser-tool-DRan7Lk6.js.map +0 -1
  173. package/dist/client-DMWujQJ1.js +0 -2325
  174. package/dist/client-DMWujQJ1.js.map +0 -1
  175. package/dist/connector-CM-uuxKM.js.map +0 -1
  176. package/dist/images-CfuRCjwq.js.map +0 -1
  177. package/dist/input-schema-B0Etuo-o.js.map +0 -1
  178. package/dist/input-schema-BQykTEp_.js.map +0 -1
  179. package/dist/lifecycle-v1rKHV2C.js.map +0 -1
  180. package/dist/queue-CcIjVYTE.js.map +0 -1
  181. package/dist/scheduler-FIHv2-kJ.js.map +0 -1
  182. package/dist/session-7CDgVE0z.js.map +0 -1
  183. package/dist/settings-Dk2il2Hf.js.map +0 -1
  184. package/dist/src-DoGNJ4Ud.js.map +0 -1
  185. package/dist/tool-CxKsvxjm.js.map +0 -1
  186. package/dist/tool-DkT_DJBm.js.map +0 -1
  187. package/dist/websockets-C6SJtWCJ.js.map +0 -1
@@ -4,7 +4,7 @@ import {
4
4
  n as AgentOptions,
5
5
  r as RoutingRetryOptions,
6
6
  t as AgentGetOptions
7
- } from "./agent-routing-vVMA7m8Y.js";
7
+ } from "./agent-routing-BSoZzNiP.js";
8
8
  export {
9
9
  AgentGetOptions,
10
10
  AgentOptions,
@@ -27,7 +27,7 @@ import {
27
27
  rt as RunAgentToolResult,
28
28
  tt as DetachedRunAgentToolResult,
29
29
  z as AgentToolEventState
30
- } from "./agent-routing-vVMA7m8Y.js";
30
+ } from "./agent-routing-BSoZzNiP.js";
31
31
  export {
32
32
  AGENT_TOOL_MILESTONE_PART,
33
33
  AGENT_TOOL_PROGRESS_PART,
@@ -4,7 +4,7 @@ import {
4
4
  W as AgentToolProgress,
5
5
  Z as AgentToolStoredChunk,
6
6
  z as AgentToolEventState
7
- } from "./agent-routing-vVMA7m8Y.js";
7
+ } from "./agent-routing-BSoZzNiP.js";
8
8
 
9
9
  //#region src/chat/agent-tools.d.ts
10
10
  type AgentToolProgressEmitResult = "emitted" | "coalesced" | "inactive";
@@ -144,4 +144,4 @@ export {
144
144
  interceptAgentToolBroadcast as s,
145
145
  AgentToolBroadcastHooks as t
146
146
  };
147
- //# sourceMappingURL=agent-tools-gGXXkf1z.d.ts.map
147
+ //# sourceMappingURL=agent-tools-Be-hpRpH.d.ts.map
@@ -20,7 +20,7 @@ import {
20
20
  rt as RunAgentToolResult,
21
21
  tt as DetachedRunAgentToolResult,
22
22
  z as AgentToolEventState
23
- } from "./agent-routing-vVMA7m8Y.js";
23
+ } from "./agent-routing-BSoZzNiP.js";
24
24
  import { FlexibleSchema, InferSchema, Tool } from "ai";
25
25
 
26
26
  //#region src/agent-tools.d.ts
@@ -1,7 +1,7 @@
1
1
  import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "./classPrivateFieldGet2-DZBYAB34.js";
2
2
  import { t as _classPrivateMethodInitSpec } from "./classPrivateMethodInitSpec-qMjJ6sHQ.js";
3
- import { C as isCatalogModelId, S as isRetryableStatus, T as isRunPathLanguageModelId, _ as isGatewayErrorEnvelope, a as normalizeChatCompletion, b as classifyStatus, f as createTransport$1, g as headersToObject, h as errorFromResponse$1, i as normalizeChatCompletionsStream, m as errorFromGatewayEnvelope$1, n as imageMediaTypeOf, o as prepareChatCompletionsRequest, p as definedHeaders, r as sseDataStream, t as buildImageInput, u as requireGatewayProvider, v as unwrapEnvelope$1, w as isDynamicRouteId, x as isAbortError, y as CloudflareAIError$1 } from "./images-CfuRCjwq.js";
4
- import { a as parseModelOptions, i as mergeModelOptions, n as PROVIDER_OPTIONS_KEY, o as resolveOptions, r as gatewayLayerOf } from "./settings-Dk2il2Hf.js";
3
+ import { C as isRetryableStatus, E as isRunPathLanguageModelId, S as isAbortError, T as isDynamicRouteId, _ as headersToObject, a as normalizeChatCompletionsStream, b as CloudflareAIError$1, d as requireGatewayProvider, g as errorFromResponse$1, h as errorFromGatewayEnvelope$1, i as sseDataStream, m as definedHeaders, n as imageMediaTypeOf, o as normalizeChatCompletion, p as createTransport$1, r as imageMultipartFields, s as prepareChatCompletionsRequest, t as buildImageInput, v as isGatewayErrorEnvelope, w as isCatalogModelId, x as classifyStatus, y as unwrapEnvelope$1 } from "./images-D4gtE06D.js";
4
+ import { a as mergeModelOptions, i as isGatewayConfigured, n as PROVIDER_OPTIONS_KEY, o as parseModelOptions, r as gatewayLayerOf, s as resolveOptions } from "./settings-D2F_qONv.js";
5
5
  import { APICallError, TooManyEmbeddingValuesForCallError } from "@ai-sdk/provider";
6
6
  //#region src/models/ai-sdk/errors.ts
7
7
  /**
@@ -10,7 +10,7 @@ import { APICallError, TooManyEmbeddingValuesForCallError } from "@ai-sdk/provid
10
10
  * routes; the modality methods take Workers AI ids only.
11
11
  */
12
12
  function notAModelId(modelId, accepts) {
13
- return /* @__PURE__ */ new TypeError(accepts === "language" ? `"${modelId}" is not a model id this provider knows. Use a Workers AI id ("@cf/zai-org/glm-4.7-flash"), an AI Gateway catalog id ("<author>/<model>", e.g. "openai/gpt-5.5" or "anthropic/claude-opus-4.8"), or a dynamic route ("dynamic/<route>").` : `"${modelId}" is not a Workers AI model id. The embedding, image, speech, transcription and reranking methods take Workers AI ids, which start with "@cf/".`);
13
+ return /* @__PURE__ */ new TypeError(accepts === "language" ? `"${modelId}" is not a model id this provider knows. Use a Workers AI id ("@cf/deepseek-ai/deepseek-v4.1-flash-1017"), an AI Gateway catalog id ("<author>/<model>", e.g. "openai/gpt-5.5" or "anthropic/claude-opus-4.8"), or a dynamic route ("dynamic/<route>").` : `"${modelId}" is not a Workers AI model id. The embedding, image, speech, transcription and reranking methods take Workers AI ids, which start with "@cf/".`);
14
14
  }
15
15
  /**
16
16
  * The gate for the modality methods — embedding, image, speech,
@@ -461,12 +461,31 @@ function defaultFinishReason() {
461
461
  * @see https://developers.cloudflare.com/workers-ai/platform/limits/
462
462
  */
463
463
  const MAX_EMBEDDINGS_PER_CALL = 3e3;
464
+ /**
465
+ * Embedding ids that take the OpenAI shape: `{ input: string[] }`, answered
466
+ * with `{ data: [{ embedding }] }`. They refuse `{ text }` (`400 required
467
+ * properties at '/' are 'input'`, verified live).
468
+ *
469
+ * @see https://developers.cloudflare.com/workers-ai/models/embeddinggemma-2/
470
+ */
471
+ const OPENAI_INPUT = /* @__PURE__ */ new Set(["@cf/google/embeddinggemma-2"]);
472
+ /** The run-path body for one embedding leg. */
473
+ function embeddingInput(modelId, values) {
474
+ return OPENAI_INPUT.has(modelId) ? { input: values } : { text: values };
475
+ }
476
+ /**
477
+ * One row of `data`: a bare vector, or an OpenAI `{ embedding }` object.
478
+ */
479
+ function vectorOf(row) {
480
+ return (array(row) ?? array(record(row)?.embedding) ?? []).filter((value) => typeof value === "number");
481
+ }
464
482
  var _config$3 = /* @__PURE__ */ new WeakMap();
465
483
  var _options$3 = /* @__PURE__ */ new WeakMap();
466
484
  /**
467
485
  * An `EmbeddingModelV4` over the Workers AI text-embedding catalog. The run
468
486
  * path takes `{ text: string[] }` and answers `{ data, shape, usage }`,
469
- * sometimes inside the Cloudflare envelope.
487
+ * sometimes inside the Cloudflare envelope; the {@link OPENAI_INPUT} models
488
+ * take and answer the OpenAI shape instead.
470
489
  */
471
490
  var CloudflareEmbeddingModel = class {
472
491
  constructor(modelId, options, config) {
@@ -491,9 +510,9 @@ var CloudflareEmbeddingModel = class {
491
510
  values: options.values
492
511
  });
493
512
  const resolved = resolveOptions(_classPrivateFieldGet2(_config$3, this).providerGateway, _classPrivateFieldGet2(_options$3, this), parseModalityCallOptions(options.providerOptions));
494
- const input = { text: options.values };
495
513
  const transport = _classPrivateFieldGet2(_config$3, this).transport;
496
514
  return withFallback(this.modelId, resolved.fallback, transport.url, async (modelId) => {
515
+ const input = embeddingInput(modelId, options.values);
497
516
  const response = await transport.run({
498
517
  gateway: resolved.gateway,
499
518
  headers: {
@@ -515,7 +534,7 @@ var CloudflareEmbeddingModel = class {
515
534
  status: response.status,
516
535
  url: transport.url
517
536
  })) ?? {};
518
- const embeddings = (array(body.data) ?? []).map((row) => (array(row) ?? []).filter((value) => typeof value === "number"));
537
+ const embeddings = (array(body.data) ?? []).map(vectorOf);
519
538
  const tokens = count(record(body.usage)?.prompt_tokens);
520
539
  return {
521
540
  embeddings,
@@ -783,7 +802,6 @@ function buildOpenAIRequest(options, context) {
783
802
  }, context.modelId);
784
803
  return {
785
804
  body: prepared.body,
786
- reasoningOff: prepared.reasoningOff,
787
805
  warnings: [...warnings, ...prepared.warnings.map(fromCompat)]
788
806
  };
789
807
  }
@@ -1320,7 +1338,7 @@ var CloudflareLanguageModel = class {
1320
1338
  const decorate = decorateStream(request.warnings, providerMetadata);
1321
1339
  let parts;
1322
1340
  if (!contentType.includes("event-stream") || response.body === null) parts = oneShotStream(parseOpenAIGeneration(await _assertClassBrand(_CloudflareLanguageModel_brand, this, _readBody).call(this, modelId, request, response), modelId));
1323
- else parts = response.body.pipeThrough(sseDataStream()).pipeThrough(normalizeChatCompletionsStream(modelId, { reasoningOff: request.reasoningOff })).pipeThrough(openAIStreamParser());
1341
+ else parts = response.body.pipeThrough(sseDataStream()).pipeThrough(normalizeChatCompletionsStream(modelId)).pipeThrough(openAIStreamParser());
1324
1342
  return {
1325
1343
  request: { body: request.body },
1326
1344
  response: { headers: headersToObject(response.headers) },
@@ -1784,10 +1802,24 @@ function routed(model, options, config) {
1784
1802
  }
1785
1803
  //#endregion
1786
1804
  //#region src/models/ai-sdk/models/modality.ts
1787
- /** Whether the caller set any gateway option, the id included. */
1788
- function gatewayConfigured(gateway) {
1789
- const { id, ...options } = gateway;
1790
- return id !== "default" || Object.keys(options).length > 0;
1805
+ /**
1806
+ * The body a request reports as sent (`request.body`, error
1807
+ * `requestBodyValues`): raw audio and form files as base64, since bytes do
1808
+ * not survive JSON.
1809
+ */
1810
+ function sentBody(request) {
1811
+ if (request.multipart !== void 0) return { multipart: Object.fromEntries(Object.entries(request.multipart).map(([name, value]) => [name, typeof value === "string" ? value : {
1812
+ body: toBase64(value.bytes),
1813
+ contentType: value.contentType
1814
+ }])) };
1815
+ if (request.audio !== void 0) return {
1816
+ ...request.input,
1817
+ audio: {
1818
+ body: toBase64(request.audio.bytes),
1819
+ contentType: request.audio.contentType
1820
+ }
1821
+ };
1822
+ return request.input;
1791
1823
  }
1792
1824
  /** The `unsupported` warning shape, which every modality needs. */
1793
1825
  function unsupported(feature, details) {
@@ -1840,17 +1872,12 @@ var CloudflareModalityModel = class {
1840
1872
  const transport = _classPrivateFieldGet2(_config, this).transport;
1841
1873
  return withFallback(this.modelId, resolved.fallback, transport.url, async (modelId) => {
1842
1874
  const request = call.build(modelId);
1843
- const direct = request.audio !== void 0;
1844
- const sent = request.audio === void 0 ? request.input : {
1845
- ...request.input,
1846
- audio: {
1847
- body: toBase64(request.audio.bytes),
1848
- contentType: request.audio.contentType
1849
- }
1850
- };
1851
- const warnings = direct && gatewayConfigured(resolved.gateway) ? [...request.warnings, unsupported("gateway", `${modelId} goes to Workers AI directly, so the gateway options do not apply.`)] : request.warnings;
1875
+ const direct = request.audio !== void 0 || request.multipart !== void 0;
1876
+ const sent = sentBody(request);
1877
+ const warnings = direct && isGatewayConfigured(resolved.gateway) ? [...request.warnings, unsupported("gateway", `${modelId} goes to Workers AI directly, so the gateway options do not apply.`)] : request.warnings;
1852
1878
  const response = await transport.run({
1853
1879
  ...request.audio === void 0 ? {} : { audio: request.audio },
1880
+ ...request.multipart === void 0 ? {} : { multipart: request.multipart },
1854
1881
  gateway: resolved.gateway,
1855
1882
  headers: {
1856
1883
  ...definedHeaders(call.headers),
@@ -1944,6 +1971,22 @@ function fileData(file) {
1944
1971
  if (file.type === "file") return toBase64(file.data);
1945
1972
  }
1946
1973
  /**
1974
+ * The reference images for a multipart request, as form files. URLs cannot
1975
+ * be sent and images past the model's limit are dropped, each with a warning.
1976
+ */
1977
+ function multipartImages(files, warnings) {
1978
+ const images = [];
1979
+ for (const file of files ?? []) if (file.type !== "file") warnings.push(unsupported("files", "Image URLs are not supported; send the bytes."));
1980
+ else if (images.length === 4) {
1981
+ warnings.push(unsupported("files", `Only the first 4 images are used.`));
1982
+ break;
1983
+ } else images.push({
1984
+ bytes: toBytes(file.data),
1985
+ contentType: file.mediaType
1986
+ });
1987
+ return images;
1988
+ }
1989
+ /**
1947
1990
  * Builds the run-path body. The knobs and the flux-1 subset rule live in
1948
1991
  * `core/images.ts`, shared with the pi-ai module so the two cannot drift; the
1949
1992
  * AI SDK call options and the `files`/`mask` byte handling are mapped here.
@@ -1976,8 +2019,13 @@ function buildImageRequest(modelId, options) {
1976
2019
  });
1977
2020
  const input = built.input;
1978
2021
  for (const warning of built.warnings) warnings.push(unsupported(warning.feature, warning.message));
1979
- if (built.minimal) return {
2022
+ if (built.body === "prompt-and-steps") return {
2023
+ input,
2024
+ warnings
2025
+ };
2026
+ if (built.body === "multipart") return {
1980
2027
  input,
2028
+ multipart: imageMultipartFields(input, multipartImages(options.files, warnings)),
1981
2029
  warnings
1982
2030
  };
1983
2031
  const source = options.files?.[0];
@@ -2136,13 +2184,6 @@ var CloudflareRerankingModel = class extends CloudflareModalityModel {
2136
2184
  //#endregion
2137
2185
  //#region src/models/ai-sdk/models/speech.ts
2138
2186
  /**
2139
- * MeloTTS is the odd one out: the prompt key is `prompt`, the language key is
2140
- * `lang`, and there is no voice.
2141
- *
2142
- * @see https://developers.cloudflare.com/workers-ai/models/melotts/
2143
- */
2144
- const MELOTTS = "@cf/myshell-ai/melotts";
2145
- /**
2146
2187
  * Output encodings Aura accepts. `outputFormat` maps onto this; anything else
2147
2188
  * is warned about rather than sent, because the run path validates the enum.
2148
2189
  *
@@ -2158,20 +2199,10 @@ const AURA_ENCODINGS = /* @__PURE__ */ new Set([
2158
2199
  "aac"
2159
2200
  ]);
2160
2201
  /** Builds the run-path body for one speech leg. */
2161
- function buildSpeechRequest(modelId, options) {
2202
+ function buildSpeechRequest(options) {
2162
2203
  const warnings = [];
2163
2204
  if (options.speed !== void 0) warnings.push(unsupported("speed", "Workers AI speech models do not take a speed."));
2164
2205
  if (options.instructions !== void 0) warnings.push(unsupported("instructions", "Workers AI speech models take text, not instructions."));
2165
- if (modelId === MELOTTS) {
2166
- const input = { prompt: options.text };
2167
- if (options.language !== void 0) input.lang = options.language;
2168
- if (options.voice !== void 0) warnings.push(unsupported("voice", `${MELOTTS} has a single voice.`));
2169
- if (options.outputFormat !== void 0) warnings.push(unsupported("outputFormat", `${MELOTTS} picks its own audio format.`));
2170
- return {
2171
- input,
2172
- warnings
2173
- };
2174
- }
2175
2206
  const input = { text: options.text };
2176
2207
  if (options.voice !== void 0) input.speaker = options.voice;
2177
2208
  if (options.outputFormat !== void 0) if (AURA_ENCODINGS.has(options.outputFormat)) input.encoding = options.outputFormat;
@@ -2211,7 +2242,7 @@ var CloudflareSpeechModel = class extends CloudflareModalityModel {
2211
2242
  async doGenerate(options) {
2212
2243
  const answer = await this.send({
2213
2244
  abortSignal: options.abortSignal,
2214
- build: (modelId) => buildSpeechRequest(modelId, options),
2245
+ build: () => buildSpeechRequest(options),
2215
2246
  check: (answer) => {
2216
2247
  readAudio(answer);
2217
2248
  },
@@ -2239,7 +2270,7 @@ var CloudflareSpeechModel = class extends CloudflareModalityModel {
2239
2270
  *
2240
2271
  * @see https://developers.cloudflare.com/workers-ai/models/whisper/
2241
2272
  */
2242
- const BYTE_ARRAY_AUDIO = /* @__PURE__ */ new Set(["@cf/openai/whisper", "@cf/openai/whisper-tiny-en"]);
2273
+ const BYTE_ARRAY_AUDIO = /* @__PURE__ */ new Set(["@cf/openai/whisper"]);
2243
2274
  /**
2244
2275
  * Models that declare `audio: { body, contentType }`. JSON cannot carry that
2245
2276
  * body (base64 and byte arrays answer `400 required properties at '/audio' are
@@ -2427,7 +2458,7 @@ function isModel(value) {
2427
2458
  * ```ts
2428
2459
  * const ai = createAI({ binding: env.AI, id: "prod", cacheTtl: 60 });
2429
2460
  *
2430
- * ai("@cf/zai-org/glm-4.7-flash");
2461
+ * ai("@cf/deepseek-ai/deepseek-v4.1-flash-1017");
2431
2462
  * ai("anthropic/claude-opus-4.8", { fallback: ["openai/gpt-5.5"] });
2432
2463
  * ai.embedding("@cf/baai/bge-base-en-v1.5");
2433
2464
  * ```
@@ -2493,4 +2524,4 @@ function createAI(settings) {
2493
2524
  //#endregion
2494
2525
  export { GatewayLanguageModel as n, CloudflareAIError as r, createAI as t };
2495
2526
 
2496
- //# sourceMappingURL=ai-sdk-Kon40i0q.js.map
2527
+ //# sourceMappingURL=ai-sdk-CRMlEBX7.js.map