ai 6.0.0-beta.157 → 6.0.0-beta.160

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __export = (target, all) => {
3
- for (var name15 in all)
4
- __defProp(target, name15, { get: all[name15], enumerable: true });
3
+ for (var name14 in all)
4
+ __defProp(target, name14, { get: all[name14], enumerable: true });
5
5
  };
6
6
 
7
7
  // src/index.ts
@@ -88,7 +88,7 @@ import { gateway } from "@ai-sdk/gateway";
88
88
 
89
89
  // src/error/index.ts
90
90
  import {
91
- AISDKError as AISDKError16,
91
+ AISDKError as AISDKError15,
92
92
  APICallError,
93
93
  EmptyResponseBodyError,
94
94
  InvalidPromptError,
@@ -380,55 +380,32 @@ var MessageConversionError = class extends AISDKError13 {
380
380
  };
381
381
  _a11 = symbol11;
382
382
 
383
- // src/util/download/download-error.ts
383
+ // src/error/index.ts
384
+ import { DownloadError } from "@ai-sdk/provider-utils";
385
+
386
+ // src/util/retry-error.ts
384
387
  import { AISDKError as AISDKError14 } from "@ai-sdk/provider";
385
- var name12 = "AI_DownloadError";
388
+ var name12 = "AI_RetryError";
386
389
  var marker12 = `vercel.ai.error.${name12}`;
387
390
  var symbol12 = Symbol.for(marker12);
388
391
  var _a12;
389
- var DownloadError = class extends AISDKError14 {
390
- constructor({
391
- url,
392
- statusCode,
393
- statusText,
394
- cause,
395
- message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}`
396
- }) {
397
- super({ name: name12, message, cause });
398
- this[_a12] = true;
399
- this.url = url;
400
- this.statusCode = statusCode;
401
- this.statusText = statusText;
402
- }
403
- static isInstance(error) {
404
- return AISDKError14.hasMarker(error, marker12);
405
- }
406
- };
407
- _a12 = symbol12;
408
-
409
- // src/util/retry-error.ts
410
- import { AISDKError as AISDKError15 } from "@ai-sdk/provider";
411
- var name13 = "AI_RetryError";
412
- var marker13 = `vercel.ai.error.${name13}`;
413
- var symbol13 = Symbol.for(marker13);
414
- var _a13;
415
- var RetryError = class extends AISDKError15 {
392
+ var RetryError = class extends AISDKError14 {
416
393
  constructor({
417
394
  message,
418
395
  reason,
419
396
  errors
420
397
  }) {
421
- super({ name: name13, message });
422
- this[_a13] = true;
398
+ super({ name: name12, message });
399
+ this[_a12] = true;
423
400
  this.reason = reason;
424
401
  this.errors = errors;
425
402
  this.lastError = errors[errors.length - 1];
426
403
  }
427
404
  static isInstance(error) {
428
- return AISDKError15.hasMarker(error, marker13);
405
+ return AISDKError14.hasMarker(error, marker12);
429
406
  }
430
407
  };
431
- _a13 = symbol13;
408
+ _a12 = symbol12;
432
409
 
433
410
  // src/util/log-v2-compatibility-warning.ts
434
411
  function logV2CompatibilityWarning({
@@ -621,7 +598,7 @@ function resolveEmbeddingModel(model) {
621
598
  return getGlobalProvider().embeddingModel(model);
622
599
  }
623
600
  function resolveTranscriptionModel(model) {
624
- var _a15, _b;
601
+ var _a14, _b;
625
602
  if (typeof model !== "string") {
626
603
  if (model.specificationVersion !== "v3" && model.specificationVersion !== "v2") {
627
604
  const unsupportedModel = model;
@@ -633,10 +610,10 @@ function resolveTranscriptionModel(model) {
633
610
  }
634
611
  return asTranscriptionModelV3(model);
635
612
  }
636
- return (_b = (_a15 = getGlobalProvider()).transcriptionModel) == null ? void 0 : _b.call(_a15, model);
613
+ return (_b = (_a14 = getGlobalProvider()).transcriptionModel) == null ? void 0 : _b.call(_a14, model);
637
614
  }
638
615
  function resolveSpeechModel(model) {
639
- var _a15, _b;
616
+ var _a14, _b;
640
617
  if (typeof model !== "string") {
641
618
  if (model.specificationVersion !== "v3" && model.specificationVersion !== "v2") {
642
619
  const unsupportedModel = model;
@@ -648,7 +625,7 @@ function resolveSpeechModel(model) {
648
625
  }
649
626
  return asSpeechModelV3(model);
650
627
  }
651
- return (_b = (_a15 = getGlobalProvider()).speechModel) == null ? void 0 : _b.call(_a15, model);
628
+ return (_b = (_a14 = getGlobalProvider()).speechModel) == null ? void 0 : _b.call(_a14, model);
652
629
  }
653
630
  function resolveImageModel(model) {
654
631
  if (typeof model !== "string") {
@@ -665,8 +642,8 @@ function resolveImageModel(model) {
665
642
  return getGlobalProvider().imageModel(model);
666
643
  }
667
644
  function getGlobalProvider() {
668
- var _a15;
669
- return (_a15 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a15 : gateway;
645
+ var _a14;
646
+ return (_a14 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a14 : gateway;
670
647
  }
671
648
 
672
649
  // src/prompt/convert-to-language-model-prompt.ts
@@ -860,17 +837,18 @@ function detectMediaType({
860
837
  }
861
838
 
862
839
  // src/util/download/download.ts
840
+ import { DownloadError as DownloadError2 } from "@ai-sdk/provider-utils";
863
841
  import {
864
842
  withUserAgentSuffix,
865
843
  getRuntimeEnvironmentUserAgent
866
844
  } from "@ai-sdk/provider-utils";
867
845
 
868
846
  // src/version.ts
869
- var VERSION = true ? "6.0.0-beta.157" : "0.0.0-test";
847
+ var VERSION = true ? "6.0.0-beta.160" : "0.0.0-test";
870
848
 
871
849
  // src/util/download/download.ts
872
850
  var download = async ({ url }) => {
873
- var _a15;
851
+ var _a14;
874
852
  const urlText = url.toString();
875
853
  try {
876
854
  const response = await fetch(urlText, {
@@ -881,7 +859,7 @@ var download = async ({ url }) => {
881
859
  )
882
860
  });
883
861
  if (!response.ok) {
884
- throw new DownloadError({
862
+ throw new DownloadError2({
885
863
  url: urlText,
886
864
  statusCode: response.status,
887
865
  statusText: response.statusText
@@ -889,13 +867,13 @@ var download = async ({ url }) => {
889
867
  }
890
868
  return {
891
869
  data: new Uint8Array(await response.arrayBuffer()),
892
- mediaType: (_a15 = response.headers.get("content-type")) != null ? _a15 : void 0
870
+ mediaType: (_a14 = response.headers.get("content-type")) != null ? _a14 : void 0
893
871
  };
894
872
  } catch (error) {
895
- if (DownloadError.isInstance(error)) {
873
+ if (DownloadError2.isInstance(error)) {
896
874
  throw error;
897
875
  }
898
- throw new DownloadError({ url: urlText, cause: error });
876
+ throw new DownloadError2({ url: urlText, cause: error });
899
877
  }
900
878
  };
901
879
 
@@ -907,7 +885,7 @@ var createDefaultDownloadFunction = (download2 = download) => (requestedDownload
907
885
  );
908
886
 
909
887
  // src/prompt/data-content.ts
910
- import { AISDKError as AISDKError17 } from "@ai-sdk/provider";
888
+ import { AISDKError as AISDKError16 } from "@ai-sdk/provider";
911
889
  import {
912
890
  convertBase64ToUint8Array as convertBase64ToUint8Array2,
913
891
  convertUint8ArrayToBase64
@@ -938,8 +916,8 @@ var dataContentSchema = z.union([
938
916
  z.custom(
939
917
  // Buffer might not be available in some environments such as CloudFlare:
940
918
  (value) => {
941
- var _a15, _b;
942
- return (_b = (_a15 = globalThis.Buffer) == null ? void 0 : _a15.isBuffer(value)) != null ? _b : false;
919
+ var _a14, _b;
920
+ return (_b = (_a14 = globalThis.Buffer) == null ? void 0 : _a14.isBuffer(value)) != null ? _b : false;
943
921
  },
944
922
  { message: "Must be a Buffer" }
945
923
  )
@@ -962,7 +940,7 @@ function convertToLanguageModelV3DataContent(content) {
962
940
  content.toString()
963
941
  );
964
942
  if (dataUrlMediaType == null || base64Content == null) {
965
- throw new AISDKError17({
943
+ throw new AISDKError16({
966
944
  name: "InvalidDataContentError",
967
945
  message: `Invalid data URL format in content ${content.toString()}`
968
946
  });
@@ -1162,8 +1140,8 @@ async function downloadAssets(messages, download2, supportedUrls) {
1162
1140
  ).flat().filter(
1163
1141
  (part) => part.type === "image" || part.type === "file"
1164
1142
  ).map((part) => {
1165
- var _a15;
1166
- const mediaType = (_a15 = part.mediaType) != null ? _a15 : part.type === "image" ? "image/*" : void 0;
1143
+ var _a14;
1144
+ const mediaType = (_a14 = part.mediaType) != null ? _a14 : part.type === "image" ? "image/*" : void 0;
1167
1145
  let data = part.type === "image" ? part.image : part.data;
1168
1146
  if (typeof data === "string") {
1169
1147
  try {
@@ -1193,7 +1171,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
1193
1171
  );
1194
1172
  }
1195
1173
  function convertPartToLanguageModelPart(part, downloadedAssets) {
1196
- var _a15;
1174
+ var _a14;
1197
1175
  if (part.type === "text") {
1198
1176
  return {
1199
1177
  type: "text",
@@ -1226,7 +1204,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
1226
1204
  switch (type) {
1227
1205
  case "image": {
1228
1206
  if (data instanceof Uint8Array || typeof data === "string") {
1229
- mediaType = (_a15 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a15 : mediaType;
1207
+ mediaType = (_a14 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a14 : mediaType;
1230
1208
  }
1231
1209
  return {
1232
1210
  type: "file",
@@ -1414,10 +1392,10 @@ async function prepareToolsAndToolChoice({
1414
1392
  };
1415
1393
  }
1416
1394
  const filteredTools = activeTools != null ? Object.entries(tools).filter(
1417
- ([name15]) => activeTools.includes(name15)
1395
+ ([name14]) => activeTools.includes(name14)
1418
1396
  ) : Object.entries(tools);
1419
1397
  const languageModelTools = [];
1420
- for (const [name15, tool2] of filteredTools) {
1398
+ for (const [name14, tool2] of filteredTools) {
1421
1399
  const toolType = tool2.type;
1422
1400
  switch (toolType) {
1423
1401
  case void 0:
@@ -1425,7 +1403,7 @@ async function prepareToolsAndToolChoice({
1425
1403
  case "function":
1426
1404
  languageModelTools.push({
1427
1405
  type: "function",
1428
- name: name15,
1406
+ name: name14,
1429
1407
  description: tool2.description,
1430
1408
  inputSchema: await asSchema(tool2.inputSchema).jsonSchema,
1431
1409
  ...tool2.inputExamples != null ? { inputExamples: tool2.inputExamples } : {},
@@ -1436,7 +1414,7 @@ async function prepareToolsAndToolChoice({
1436
1414
  case "provider":
1437
1415
  languageModelTools.push({
1438
1416
  type: "provider",
1439
- name: name15,
1417
+ name: name14,
1440
1418
  id: tool2.id,
1441
1419
  args: tool2.args
1442
1420
  });
@@ -1726,14 +1704,14 @@ async function standardizePrompt(prompt) {
1726
1704
 
1727
1705
  // src/prompt/wrap-gateway-error.ts
1728
1706
  import { GatewayAuthenticationError } from "@ai-sdk/gateway";
1729
- import { AISDKError as AISDKError18 } from "@ai-sdk/provider";
1707
+ import { AISDKError as AISDKError17 } from "@ai-sdk/provider";
1730
1708
  function wrapGatewayError(error) {
1731
1709
  if (!GatewayAuthenticationError.isInstance(error))
1732
1710
  return error;
1733
1711
  const isProductionEnv = (process == null ? void 0 : process.env.NODE_ENV) === "production";
1734
1712
  const moreInfoURL = "https://v6.ai-sdk.dev/unauthenticated-ai-gateway";
1735
1713
  if (isProductionEnv) {
1736
- return new AISDKError18({
1714
+ return new AISDKError17({
1737
1715
  name: "GatewayError",
1738
1716
  message: `Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${moreInfoURL}`
1739
1717
  });
@@ -1774,7 +1752,7 @@ function getBaseTelemetryAttributes({
1774
1752
  telemetry,
1775
1753
  headers
1776
1754
  }) {
1777
- var _a15;
1755
+ var _a14;
1778
1756
  return {
1779
1757
  "ai.model.provider": model.provider,
1780
1758
  "ai.model.id": model.modelId,
@@ -1784,7 +1762,7 @@ function getBaseTelemetryAttributes({
1784
1762
  return attributes;
1785
1763
  }, {}),
1786
1764
  // add metadata as attributes:
1787
- ...Object.entries((_a15 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a15 : {}).reduce(
1765
+ ...Object.entries((_a14 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a14 : {}).reduce(
1788
1766
  (attributes, [key, value]) => {
1789
1767
  attributes[`ai.telemetry.metadata.${key}`] = value;
1790
1768
  return attributes;
@@ -1809,7 +1787,7 @@ var noopTracer = {
1809
1787
  startSpan() {
1810
1788
  return noopSpan;
1811
1789
  },
1812
- startActiveSpan(name15, arg1, arg2, arg3) {
1790
+ startActiveSpan(name14, arg1, arg2, arg3) {
1813
1791
  if (typeof arg1 === "function") {
1814
1792
  return arg1(noopSpan);
1815
1793
  }
@@ -1879,14 +1857,14 @@ function getTracer({
1879
1857
  // src/telemetry/record-span.ts
1880
1858
  import { SpanStatusCode } from "@opentelemetry/api";
1881
1859
  async function recordSpan({
1882
- name: name15,
1860
+ name: name14,
1883
1861
  tracer,
1884
1862
  attributes,
1885
1863
  fn,
1886
1864
  endWhenDone = true
1887
1865
  }) {
1888
1866
  return tracer.startActiveSpan(
1889
- name15,
1867
+ name14,
1890
1868
  { attributes: await attributes },
1891
1869
  async (span) => {
1892
1870
  try {
@@ -2016,12 +1994,12 @@ function createNullLanguageModelUsage() {
2016
1994
  };
2017
1995
  }
2018
1996
  function addLanguageModelUsage(usage1, usage2) {
2019
- var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1997
+ var _a14, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2020
1998
  return {
2021
1999
  inputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),
2022
2000
  inputTokenDetails: {
2023
2001
  noCacheTokens: addTokenCounts(
2024
- (_a15 = usage1.inputTokenDetails) == null ? void 0 : _a15.noCacheTokens,
2002
+ (_a14 = usage1.inputTokenDetails) == null ? void 0 : _a14.noCacheTokens,
2025
2003
  (_b = usage2.inputTokenDetails) == null ? void 0 : _b.noCacheTokens
2026
2004
  ),
2027
2005
  cacheReadTokens: addTokenCounts(
@@ -2791,7 +2769,7 @@ var text = () => ({
2791
2769
  });
2792
2770
  var object = ({
2793
2771
  schema: inputSchema,
2794
- name: name15,
2772
+ name: name14,
2795
2773
  description
2796
2774
  }) => {
2797
2775
  const schema = asSchema2(inputSchema);
@@ -2799,7 +2777,7 @@ var object = ({
2799
2777
  responseFormat: resolve(schema.jsonSchema).then((jsonSchema2) => ({
2800
2778
  type: "json",
2801
2779
  schema: jsonSchema2,
2802
- ...name15 != null && { name: name15 },
2780
+ ...name14 != null && { name: name14 },
2803
2781
  ...description != null && { description }
2804
2782
  })),
2805
2783
  async parseCompleteOutput({ text: text2 }, context) {
@@ -2850,7 +2828,7 @@ var object = ({
2850
2828
  };
2851
2829
  var array = ({
2852
2830
  element: inputElementSchema,
2853
- name: name15,
2831
+ name: name14,
2854
2832
  description
2855
2833
  }) => {
2856
2834
  const elementSchema = asSchema2(inputElementSchema);
@@ -2869,7 +2847,7 @@ var array = ({
2869
2847
  required: ["elements"],
2870
2848
  additionalProperties: false
2871
2849
  },
2872
- ...name15 != null && { name: name15 },
2850
+ ...name14 != null && { name: name14 },
2873
2851
  ...description != null && { description }
2874
2852
  };
2875
2853
  }),
@@ -2949,7 +2927,7 @@ var array = ({
2949
2927
  };
2950
2928
  var choice = ({
2951
2929
  options: choiceOptions,
2952
- name: name15,
2930
+ name: name14,
2953
2931
  description
2954
2932
  }) => {
2955
2933
  return {
@@ -2965,7 +2943,7 @@ var choice = ({
2965
2943
  required: ["result"],
2966
2944
  additionalProperties: false
2967
2945
  },
2968
- ...name15 != null && { name: name15 },
2946
+ ...name14 != null && { name: name14 },
2969
2947
  ...description != null && { description }
2970
2948
  }),
2971
2949
  async parseCompleteOutput({ text: text2 }, context) {
@@ -3023,13 +3001,13 @@ var choice = ({
3023
3001
  };
3024
3002
  };
3025
3003
  var json = ({
3026
- name: name15,
3004
+ name: name14,
3027
3005
  description
3028
3006
  } = {}) => {
3029
3007
  return {
3030
3008
  responseFormat: Promise.resolve({
3031
3009
  type: "json",
3032
- ...name15 != null && { name: name15 },
3010
+ ...name14 != null && { name: name14 },
3033
3011
  ...description != null && { description }
3034
3012
  }),
3035
3013
  async parseCompleteOutput({ text: text2 }, context) {
@@ -3075,7 +3053,7 @@ async function parseToolCall({
3075
3053
  system,
3076
3054
  messages
3077
3055
  }) {
3078
- var _a15;
3056
+ var _a14;
3079
3057
  try {
3080
3058
  if (tools == null) {
3081
3059
  if (toolCall.providerExecuted && toolCall.dynamic) {
@@ -3124,7 +3102,7 @@ async function parseToolCall({
3124
3102
  dynamic: true,
3125
3103
  invalid: true,
3126
3104
  error,
3127
- title: (_a15 = tools == null ? void 0 : tools[toolCall.toolName]) == null ? void 0 : _a15.title,
3105
+ title: (_a14 = tools == null ? void 0 : tools[toolCall.toolName]) == null ? void 0 : _a14.title,
3128
3106
  providerExecuted: toolCall.providerExecuted,
3129
3107
  providerMetadata: toolCall.providerMetadata
3130
3108
  };
@@ -3261,8 +3239,8 @@ function stepCountIs(stepCount) {
3261
3239
  }
3262
3240
  function hasToolCall(toolName) {
3263
3241
  return ({ steps }) => {
3264
- var _a15, _b, _c;
3265
- return (_c = (_b = (_a15 = steps[steps.length - 1]) == null ? void 0 : _a15.toolCalls) == null ? void 0 : _b.some(
3242
+ var _a14, _b, _c;
3243
+ return (_c = (_b = (_a14 = steps[steps.length - 1]) == null ? void 0 : _a14.toolCalls) == null ? void 0 : _b.some(
3266
3244
  (toolCall) => toolCall.toolName === toolName
3267
3245
  )) != null ? _c : false;
3268
3246
  };
@@ -3476,7 +3454,7 @@ async function generateText({
3476
3454
  }),
3477
3455
  tracer,
3478
3456
  fn: async (span) => {
3479
- var _a15, _b, _c, _d, _e, _f, _g, _h;
3457
+ var _a14, _b, _c, _d, _e, _f, _g, _h;
3480
3458
  const initialMessages = initialPrompt.messages;
3481
3459
  const responseMessages = [];
3482
3460
  const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
@@ -3539,7 +3517,7 @@ async function generateText({
3539
3517
  experimental_context
3540
3518
  }));
3541
3519
  const stepModel = resolveLanguageModel(
3542
- (_a15 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a15 : model
3520
+ (_a14 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a14 : model
3543
3521
  );
3544
3522
  const promptMessages = await convertToLanguageModelPrompt({
3545
3523
  prompt: {
@@ -3557,7 +3535,7 @@ async function generateText({
3557
3535
  });
3558
3536
  currentModelResponse = await retry(
3559
3537
  () => {
3560
- var _a16;
3538
+ var _a15;
3561
3539
  return recordSpan({
3562
3540
  name: "ai.generateText.doGenerate",
3563
3541
  attributes: selectTelemetryAttributes({
@@ -3589,14 +3567,14 @@ async function generateText({
3589
3567
  "gen_ai.request.max_tokens": settings.maxOutputTokens,
3590
3568
  "gen_ai.request.presence_penalty": settings.presencePenalty,
3591
3569
  "gen_ai.request.stop_sequences": settings.stopSequences,
3592
- "gen_ai.request.temperature": (_a16 = settings.temperature) != null ? _a16 : void 0,
3570
+ "gen_ai.request.temperature": (_a15 = settings.temperature) != null ? _a15 : void 0,
3593
3571
  "gen_ai.request.top_k": settings.topK,
3594
3572
  "gen_ai.request.top_p": settings.topP
3595
3573
  }
3596
3574
  }),
3597
3575
  tracer,
3598
3576
  fn: async (span2) => {
3599
- var _a17, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
3577
+ var _a16, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
3600
3578
  const result = await stepModel.doGenerate({
3601
3579
  ...callSettings2,
3602
3580
  tools: stepTools,
@@ -3608,7 +3586,7 @@ async function generateText({
3608
3586
  headers: headersWithUserAgent
3609
3587
  });
3610
3588
  const responseData = {
3611
- id: (_b2 = (_a17 = result.response) == null ? void 0 : _a17.id) != null ? _b2 : generateId2(),
3589
+ id: (_b2 = (_a16 = result.response) == null ? void 0 : _a16.id) != null ? _b2 : generateId2(),
3612
3590
  timestamp: (_d2 = (_c2 = result.response) == null ? void 0 : _c2.timestamp) != null ? _d2 : currentDate(),
3613
3591
  modelId: (_f2 = (_e2 = result.response) == null ? void 0 : _e2.modelId) != null ? _f2 : stepModel.modelId,
3614
3592
  headers: (_g2 = result.response) == null ? void 0 : _g2.headers,
@@ -4064,7 +4042,12 @@ function writeToServerResponse({
4064
4042
  headers,
4065
4043
  stream
4066
4044
  }) {
4067
- response.writeHead(status != null ? status : 200, statusText, headers);
4045
+ const statusCode = status != null ? status : 200;
4046
+ if (statusText !== void 0) {
4047
+ response.writeHead(statusCode, statusText, headers);
4048
+ } else {
4049
+ response.writeHead(statusCode, headers);
4050
+ }
4068
4051
  const reader = stream.getReader();
4069
4052
  const read = async () => {
4070
4053
  try {
@@ -4433,7 +4416,7 @@ function processUIMessageStream({
4433
4416
  new TransformStream({
4434
4417
  async transform(chunk, controller) {
4435
4418
  await runUpdateMessageJob(async ({ state, write }) => {
4436
- var _a15, _b, _c, _d;
4419
+ var _a14, _b, _c, _d;
4437
4420
  function getToolInvocation(toolCallId) {
4438
4421
  const toolInvocations = state.message.parts.filter(isToolUIPart);
4439
4422
  const toolInvocation = toolInvocations.find(
@@ -4447,7 +4430,7 @@ function processUIMessageStream({
4447
4430
  return toolInvocation;
4448
4431
  }
4449
4432
  function updateToolPart(options) {
4450
- var _a16;
4433
+ var _a15;
4451
4434
  const part = state.message.parts.find(
4452
4435
  (part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId
4453
4436
  );
@@ -4463,7 +4446,7 @@ function processUIMessageStream({
4463
4446
  if (options.title !== void 0) {
4464
4447
  anyPart.title = options.title;
4465
4448
  }
4466
- anyPart.providerExecuted = (_a16 = anyOptions.providerExecuted) != null ? _a16 : part.providerExecuted;
4449
+ anyPart.providerExecuted = (_a15 = anyOptions.providerExecuted) != null ? _a15 : part.providerExecuted;
4467
4450
  if (anyOptions.providerMetadata != null && part.state === "input-available") {
4468
4451
  part.callProviderMetadata = anyOptions.providerMetadata;
4469
4452
  }
@@ -4484,7 +4467,7 @@ function processUIMessageStream({
4484
4467
  }
4485
4468
  }
4486
4469
  function updateDynamicToolPart(options) {
4487
- var _a16, _b2;
4470
+ var _a15, _b2;
4488
4471
  const part = state.message.parts.find(
4489
4472
  (part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
4490
4473
  );
@@ -4496,7 +4479,7 @@ function processUIMessageStream({
4496
4479
  anyPart.input = anyOptions.input;
4497
4480
  anyPart.output = anyOptions.output;
4498
4481
  anyPart.errorText = anyOptions.errorText;
4499
- anyPart.rawInput = (_a16 = anyOptions.rawInput) != null ? _a16 : anyPart.rawInput;
4482
+ anyPart.rawInput = (_a15 = anyOptions.rawInput) != null ? _a15 : anyPart.rawInput;
4500
4483
  anyPart.preliminary = anyOptions.preliminary;
4501
4484
  if (options.title !== void 0) {
4502
4485
  anyPart.title = options.title;
@@ -4549,7 +4532,7 @@ function processUIMessageStream({
4549
4532
  case "text-delta": {
4550
4533
  const textPart = state.activeTextParts[chunk.id];
4551
4534
  textPart.text += chunk.delta;
4552
- textPart.providerMetadata = (_a15 = chunk.providerMetadata) != null ? _a15 : textPart.providerMetadata;
4535
+ textPart.providerMetadata = (_a14 = chunk.providerMetadata) != null ? _a14 : textPart.providerMetadata;
4553
4536
  write();
4554
4537
  break;
4555
4538
  }
@@ -4988,11 +4971,11 @@ function createAsyncIterableStream(source) {
4988
4971
  const reader = this.getReader();
4989
4972
  let finished = false;
4990
4973
  async function cleanup(cancelStream) {
4991
- var _a15;
4974
+ var _a14;
4992
4975
  finished = true;
4993
4976
  try {
4994
4977
  if (cancelStream) {
4995
- await ((_a15 = reader.cancel) == null ? void 0 : _a15.call(reader));
4978
+ await ((_a14 = reader.cancel) == null ? void 0 : _a14.call(reader));
4996
4979
  }
4997
4980
  } finally {
4998
4981
  try {
@@ -5158,8 +5141,8 @@ function createStitchableStream() {
5158
5141
 
5159
5142
  // src/util/now.ts
5160
5143
  function now() {
5161
- var _a15, _b;
5162
- return (_b = (_a15 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a15.now()) != null ? _b : Date.now();
5144
+ var _a14, _b;
5145
+ return (_b = (_a14 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a14.now()) != null ? _b : Date.now();
5163
5146
  }
5164
5147
 
5165
5148
  // src/generate-text/run-tools-transformation.ts
@@ -5470,7 +5453,7 @@ function createOutputTransformStream(output) {
5470
5453
  }
5471
5454
  return new TransformStream({
5472
5455
  async transform(chunk, controller) {
5473
- var _a15;
5456
+ var _a14;
5474
5457
  if (chunk.type === "finish-step" && textChunk.length > 0) {
5475
5458
  publishTextChunk({ controller });
5476
5459
  }
@@ -5497,7 +5480,7 @@ function createOutputTransformStream(output) {
5497
5480
  }
5498
5481
  text2 += chunk.text;
5499
5482
  textChunk += chunk.text;
5500
- textProviderMetadata = (_a15 = chunk.providerMetadata) != null ? _a15 : textProviderMetadata;
5483
+ textProviderMetadata = (_a14 = chunk.providerMetadata) != null ? _a14 : textProviderMetadata;
5501
5484
  const result = await output.parsePartialOutput({ text: text2 });
5502
5485
  if (result !== void 0) {
5503
5486
  const currentJson = JSON.stringify(result.partial);
@@ -5560,7 +5543,7 @@ var DefaultStreamTextResult = class {
5560
5543
  let activeReasoningContent = {};
5561
5544
  const eventProcessor = new TransformStream({
5562
5545
  async transform(chunk, controller) {
5563
- var _a15, _b, _c, _d;
5546
+ var _a14, _b, _c, _d;
5564
5547
  controller.enqueue(chunk);
5565
5548
  const { part } = chunk;
5566
5549
  if (part.type === "text-delta" || part.type === "reasoning-delta" || part.type === "source" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-input-start" || part.type === "tool-input-delta" || part.type === "raw") {
@@ -5590,7 +5573,7 @@ var DefaultStreamTextResult = class {
5590
5573
  return;
5591
5574
  }
5592
5575
  activeText.text += part.text;
5593
- activeText.providerMetadata = (_a15 = part.providerMetadata) != null ? _a15 : activeText.providerMetadata;
5576
+ activeText.providerMetadata = (_a14 = part.providerMetadata) != null ? _a14 : activeText.providerMetadata;
5594
5577
  }
5595
5578
  if (part.type === "text-end") {
5596
5579
  const activeText = activeTextContent[part.id];
@@ -5750,8 +5733,8 @@ var DefaultStreamTextResult = class {
5750
5733
  "ai.response.text": { output: () => finalStep.text },
5751
5734
  "ai.response.toolCalls": {
5752
5735
  output: () => {
5753
- var _a15;
5754
- return ((_a15 = finalStep.toolCalls) == null ? void 0 : _a15.length) ? JSON.stringify(finalStep.toolCalls) : void 0;
5736
+ var _a14;
5737
+ return ((_a14 = finalStep.toolCalls) == null ? void 0 : _a14.length) ? JSON.stringify(finalStep.toolCalls) : void 0;
5755
5738
  }
5756
5739
  },
5757
5740
  "ai.response.providerMetadata": JSON.stringify(
@@ -5935,7 +5918,7 @@ var DefaultStreamTextResult = class {
5935
5918
  responseMessages,
5936
5919
  usage
5937
5920
  }) {
5938
- var _a15, _b, _c, _d, _e, _f;
5921
+ var _a14, _b, _c, _d, _e, _f;
5939
5922
  const includeRawChunks2 = self.includeRawChunks;
5940
5923
  stepFinish = new DelayedPromise();
5941
5924
  const stepInputMessages = [...initialMessages, ...responseMessages];
@@ -5947,7 +5930,7 @@ var DefaultStreamTextResult = class {
5947
5930
  experimental_context
5948
5931
  }));
5949
5932
  const stepModel = resolveLanguageModel(
5950
- (_a15 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a15 : model
5933
+ (_a14 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a14 : model
5951
5934
  );
5952
5935
  const promptMessages = await convertToLanguageModelPrompt({
5953
5936
  prompt: {
@@ -6055,7 +6038,7 @@ var DefaultStreamTextResult = class {
6055
6038
  streamWithToolResults.pipeThrough(
6056
6039
  new TransformStream({
6057
6040
  async transform(chunk, controller) {
6058
- var _a16, _b2, _c2, _d2, _e2;
6041
+ var _a15, _b2, _c2, _d2, _e2;
6059
6042
  if (chunk.type === "stream-start") {
6060
6043
  warnings = chunk.warnings;
6061
6044
  return;
@@ -6128,7 +6111,7 @@ var DefaultStreamTextResult = class {
6128
6111
  }
6129
6112
  case "response-metadata": {
6130
6113
  stepResponse = {
6131
- id: (_a16 = chunk.id) != null ? _a16 : stepResponse.id,
6114
+ id: (_a15 = chunk.id) != null ? _a15 : stepResponse.id,
6132
6115
  timestamp: (_b2 = chunk.timestamp) != null ? _b2 : stepResponse.timestamp,
6133
6116
  modelId: (_c2 = chunk.modelId) != null ? _c2 : stepResponse.modelId
6134
6117
  };
@@ -6427,14 +6410,14 @@ var DefaultStreamTextResult = class {
6427
6410
  );
6428
6411
  }
6429
6412
  async consumeStream(options) {
6430
- var _a15;
6413
+ var _a14;
6431
6414
  try {
6432
6415
  await consumeStream({
6433
6416
  stream: this.fullStream,
6434
6417
  onError: options == null ? void 0 : options.onError
6435
6418
  });
6436
6419
  } catch (error) {
6437
- (_a15 = options == null ? void 0 : options.onError) == null ? void 0 : _a15.call(options, error);
6420
+ (_a14 = options == null ? void 0 : options.onError) == null ? void 0 : _a14.call(options, error);
6438
6421
  }
6439
6422
  }
6440
6423
  get experimental_partialOutputStream() {
@@ -6455,8 +6438,8 @@ var DefaultStreamTextResult = class {
6455
6438
  }
6456
6439
  get output() {
6457
6440
  return this.finalStep.then((step) => {
6458
- var _a15;
6459
- const output = (_a15 = this.outputSpecification) != null ? _a15 : text();
6441
+ var _a14;
6442
+ const output = (_a14 = this.outputSpecification) != null ? _a14 : text();
6460
6443
  return output.parseCompleteOutput(
6461
6444
  { text: step.text },
6462
6445
  {
@@ -6483,8 +6466,8 @@ var DefaultStreamTextResult = class {
6483
6466
  responseMessageId: generateMessageId
6484
6467
  }) : void 0;
6485
6468
  const isDynamic = (part) => {
6486
- var _a15;
6487
- const tool2 = (_a15 = this.tools) == null ? void 0 : _a15[part.toolName];
6469
+ var _a14;
6470
+ const tool2 = (_a14 = this.tools) == null ? void 0 : _a14[part.toolName];
6488
6471
  if (tool2 == null) {
6489
6472
  return part.dynamic;
6490
6473
  }
@@ -6822,10 +6805,10 @@ var ToolLoopAgent = class {
6822
6805
  return this.settings.tools;
6823
6806
  }
6824
6807
  async prepareCall(options) {
6825
- var _a15, _b, _c, _d;
6808
+ var _a14, _b, _c, _d;
6826
6809
  const baseCallArgs = {
6827
6810
  ...this.settings,
6828
- stopWhen: (_a15 = this.settings.stopWhen) != null ? _a15 : stepCountIs(20),
6811
+ stopWhen: (_a14 = this.settings.stopWhen) != null ? _a14 : stepCountIs(20),
6829
6812
  ...options
6830
6813
  };
6831
6814
  const preparedCallArgs = (_d = await ((_c = (_b = this.settings).prepareCall) == null ? void 0 : _c.call(_b, baseCallArgs))) != null ? _d : baseCallArgs;
@@ -6960,7 +6943,7 @@ function readUIMessageStream({
6960
6943
  onError,
6961
6944
  terminateOnError = false
6962
6945
  }) {
6963
- var _a15;
6946
+ var _a14;
6964
6947
  let controller;
6965
6948
  let hasErrored = false;
6966
6949
  const outputStream = new ReadableStream({
@@ -6969,7 +6952,7 @@ function readUIMessageStream({
6969
6952
  }
6970
6953
  });
6971
6954
  const state = createStreamingUIMessageState({
6972
- messageId: (_a15 = message == null ? void 0 : message.id) != null ? _a15 : "",
6955
+ messageId: (_a14 = message == null ? void 0 : message.id) != null ? _a14 : "",
6973
6956
  lastMessage: message
6974
6957
  });
6975
6958
  const handleError = (error) => {
@@ -7038,7 +7021,7 @@ async function convertToModelMessages(messages, options) {
7038
7021
  modelMessages.push({
7039
7022
  role: "user",
7040
7023
  content: message.parts.map((part) => {
7041
- var _a15;
7024
+ var _a14;
7042
7025
  if (isTextUIPart(part)) {
7043
7026
  return {
7044
7027
  type: "text",
@@ -7056,7 +7039,7 @@ async function convertToModelMessages(messages, options) {
7056
7039
  };
7057
7040
  }
7058
7041
  if (isDataUIPart(part)) {
7059
- return (_a15 = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _a15.call(
7042
+ return (_a14 = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _a14.call(
7060
7043
  options,
7061
7044
  part
7062
7045
  );
@@ -7069,7 +7052,7 @@ async function convertToModelMessages(messages, options) {
7069
7052
  if (message.parts != null) {
7070
7053
  let block = [];
7071
7054
  async function processBlock() {
7072
- var _a15, _b, _c, _d, _e, _f;
7055
+ var _a14, _b, _c, _d, _e, _f;
7073
7056
  if (block.length === 0) {
7074
7057
  return;
7075
7058
  }
@@ -7101,7 +7084,7 @@ async function convertToModelMessages(messages, options) {
7101
7084
  type: "tool-call",
7102
7085
  toolCallId: part.toolCallId,
7103
7086
  toolName,
7104
- input: part.state === "output-error" ? (_a15 = part.input) != null ? _a15 : "rawInput" in part ? part.rawInput : void 0 : part.input,
7087
+ input: part.state === "output-error" ? (_a14 = part.input) != null ? _a14 : "rawInput" in part ? part.rawInput : void 0 : part.input,
7105
7088
  providerExecuted: part.providerExecuted,
7106
7089
  ...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
7107
7090
  });
@@ -7725,7 +7708,7 @@ async function embed({
7725
7708
  }),
7726
7709
  tracer,
7727
7710
  fn: async (doEmbedSpan) => {
7728
- var _a15;
7711
+ var _a14;
7729
7712
  const modelResponse = await model.doEmbed({
7730
7713
  values: [value],
7731
7714
  abortSignal,
@@ -7733,7 +7716,7 @@ async function embed({
7733
7716
  providerOptions
7734
7717
  });
7735
7718
  const embedding2 = modelResponse.embeddings[0];
7736
- const usage2 = (_a15 = modelResponse.usage) != null ? _a15 : { tokens: NaN };
7719
+ const usage2 = (_a14 = modelResponse.usage) != null ? _a14 : { tokens: NaN };
7737
7720
  doEmbedSpan.setAttributes(
7738
7721
  await selectTelemetryAttributes({
7739
7722
  telemetry,
@@ -7847,7 +7830,7 @@ async function embedMany({
7847
7830
  }),
7848
7831
  tracer,
7849
7832
  fn: async (span) => {
7850
- var _a15;
7833
+ var _a14;
7851
7834
  const [maxEmbeddingsPerCall, supportsParallelCalls] = await Promise.all([
7852
7835
  model.maxEmbeddingsPerCall,
7853
7836
  model.supportsParallelCalls
@@ -7872,7 +7855,7 @@ async function embedMany({
7872
7855
  }),
7873
7856
  tracer,
7874
7857
  fn: async (doEmbedSpan) => {
7875
- var _a16;
7858
+ var _a15;
7876
7859
  const modelResponse = await model.doEmbed({
7877
7860
  values,
7878
7861
  abortSignal,
@@ -7880,7 +7863,7 @@ async function embedMany({
7880
7863
  providerOptions
7881
7864
  });
7882
7865
  const embeddings3 = modelResponse.embeddings;
7883
- const usage2 = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };
7866
+ const usage2 = (_a15 = modelResponse.usage) != null ? _a15 : { tokens: NaN };
7884
7867
  doEmbedSpan.setAttributes(
7885
7868
  await selectTelemetryAttributes({
7886
7869
  telemetry,
@@ -7961,7 +7944,7 @@ async function embedMany({
7961
7944
  }),
7962
7945
  tracer,
7963
7946
  fn: async (doEmbedSpan) => {
7964
- var _a16;
7947
+ var _a15;
7965
7948
  const modelResponse = await model.doEmbed({
7966
7949
  values: chunk,
7967
7950
  abortSignal,
@@ -7969,7 +7952,7 @@ async function embedMany({
7969
7952
  providerOptions
7970
7953
  });
7971
7954
  const embeddings2 = modelResponse.embeddings;
7972
- const usage = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };
7955
+ const usage = (_a15 = modelResponse.usage) != null ? _a15 : { tokens: NaN };
7973
7956
  doEmbedSpan.setAttributes(
7974
7957
  await selectTelemetryAttributes({
7975
7958
  telemetry,
@@ -8008,7 +7991,7 @@ async function embedMany({
8008
7991
  result.providerMetadata
8009
7992
  )) {
8010
7993
  providerMetadata[providerName] = {
8011
- ...(_a15 = providerMetadata[providerName]) != null ? _a15 : {},
7994
+ ...(_a14 = providerMetadata[providerName]) != null ? _a14 : {},
8012
7995
  ...metadata
8013
7996
  };
8014
7997
  }
@@ -8055,10 +8038,13 @@ var DefaultEmbedManyResult = class {
8055
8038
  };
8056
8039
 
8057
8040
  // src/generate-image/generate-image.ts
8058
- import { withUserAgentSuffix as withUserAgentSuffix5 } from "@ai-sdk/provider-utils";
8041
+ import {
8042
+ convertBase64ToUint8Array as convertBase64ToUint8Array4,
8043
+ withUserAgentSuffix as withUserAgentSuffix5
8044
+ } from "@ai-sdk/provider-utils";
8059
8045
  async function generateImage({
8060
8046
  model: modelArg,
8061
- prompt,
8047
+ prompt: promptArg,
8062
8048
  n = 1,
8063
8049
  maxImagesPerCall,
8064
8050
  size,
@@ -8069,7 +8055,7 @@ async function generateImage({
8069
8055
  abortSignal,
8070
8056
  headers
8071
8057
  }) {
8072
- var _a15, _b;
8058
+ var _a14, _b;
8073
8059
  const model = resolveImageModel(modelArg);
8074
8060
  const headersWithUserAgent = withUserAgentSuffix5(
8075
8061
  headers != null ? headers : {},
@@ -8079,7 +8065,7 @@ async function generateImage({
8079
8065
  maxRetries: maxRetriesArg,
8080
8066
  abortSignal
8081
8067
  });
8082
- const maxImagesPerCallWithDefault = (_a15 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a15 : 1;
8068
+ const maxImagesPerCallWithDefault = (_a14 = maxImagesPerCall != null ? maxImagesPerCall : await invokeModelMaxImagesPerCall(model)) != null ? _a14 : 1;
8083
8069
  const callCount = Math.ceil(n / maxImagesPerCallWithDefault);
8084
8070
  const callImageCounts = Array.from({ length: callCount }, (_, i) => {
8085
8071
  if (i < callCount - 1) {
@@ -8090,9 +8076,12 @@ async function generateImage({
8090
8076
  });
8091
8077
  const results = await Promise.all(
8092
8078
  callImageCounts.map(
8093
- async (callImageCount) => retry(
8094
- () => model.doGenerate({
8079
+ async (callImageCount) => retry(() => {
8080
+ const { prompt, files, mask } = normalizePrompt(promptArg);
8081
+ return model.doGenerate({
8095
8082
  prompt,
8083
+ files,
8084
+ mask,
8096
8085
  n: callImageCount,
8097
8086
  abortSignal,
8098
8087
  headers: headersWithUserAgent,
@@ -8100,8 +8089,8 @@ async function generateImage({
8100
8089
  aspectRatio,
8101
8090
  seed,
8102
8091
  providerOptions: providerOptions != null ? providerOptions : {}
8103
- })
8104
- )
8092
+ });
8093
+ })
8105
8094
  )
8106
8095
  );
8107
8096
  const images = [];
@@ -8117,13 +8106,13 @@ async function generateImage({
8117
8106
  images.push(
8118
8107
  ...result.images.map(
8119
8108
  (image) => {
8120
- var _a16;
8109
+ var _a15;
8121
8110
  return new DefaultGeneratedFile({
8122
8111
  data: image,
8123
- mediaType: (_a16 = detectMediaType({
8112
+ mediaType: (_a15 = detectMediaType({
8124
8113
  data: image,
8125
8114
  signatures: imageMediaTypeSignatures
8126
- })) != null ? _a16 : "image/png"
8115
+ })) != null ? _a15 : "image/png"
8127
8116
  });
8128
8117
  }
8129
8118
  )
@@ -8191,6 +8180,50 @@ async function invokeModelMaxImagesPerCall(model) {
8191
8180
  modelId: model.modelId
8192
8181
  });
8193
8182
  }
8183
+ function normalizePrompt(prompt) {
8184
+ if (typeof prompt === "string") {
8185
+ return { prompt, files: void 0, mask: void 0 };
8186
+ }
8187
+ return {
8188
+ prompt: prompt.text,
8189
+ files: prompt.images.map(toImageModelV3File),
8190
+ mask: prompt.mask ? toImageModelV3File(prompt.mask) : void 0
8191
+ };
8192
+ }
8193
+ function toImageModelV3File(dataContent) {
8194
+ if (typeof dataContent === "string" && dataContent.startsWith("http")) {
8195
+ return {
8196
+ type: "url",
8197
+ url: dataContent
8198
+ };
8199
+ }
8200
+ if (typeof dataContent === "string" && dataContent.startsWith("data:")) {
8201
+ const { mediaType: dataUrlMediaType, base64Content } = splitDataUrl(dataContent);
8202
+ if (base64Content != null) {
8203
+ const uint8Data2 = convertBase64ToUint8Array4(base64Content);
8204
+ return {
8205
+ type: "file",
8206
+ data: uint8Data2,
8207
+ mediaType: dataUrlMediaType || detectMediaType({
8208
+ data: uint8Data2,
8209
+ signatures: imageMediaTypeSignatures
8210
+ }) || "image/png"
8211
+ };
8212
+ }
8213
+ }
8214
+ const uint8Data = convertDataContentToUint8Array(dataContent);
8215
+ return {
8216
+ type: "file",
8217
+ data: uint8Data,
8218
+ mediaType: detectMediaType({
8219
+ data: uint8Data,
8220
+ signatures: imageMediaTypeSignatures
8221
+ }) || "image/png"
8222
+ };
8223
+ }
8224
+
8225
+ // src/generate-image/index.ts
8226
+ var experimental_generateImage = generateImage;
8194
8227
 
8195
8228
  // src/generate-object/generate-object.ts
8196
8229
  import {
@@ -8287,7 +8320,7 @@ var arrayOutputStrategy = (schema) => {
8287
8320
  isFirstDelta,
8288
8321
  isFinalDelta
8289
8322
  }) {
8290
- var _a15;
8323
+ var _a14;
8291
8324
  if (!isJSONObject(value) || !isJSONArray(value.elements)) {
8292
8325
  return {
8293
8326
  success: false,
@@ -8310,7 +8343,7 @@ var arrayOutputStrategy = (schema) => {
8310
8343
  }
8311
8344
  resultArray.push(result.value);
8312
8345
  }
8313
- const publishedElementCount = (_a15 = latestObject == null ? void 0 : latestObject.length) != null ? _a15 : 0;
8346
+ const publishedElementCount = (_a14 = latestObject == null ? void 0 : latestObject.length) != null ? _a14 : 0;
8314
8347
  let textDelta = "";
8315
8348
  if (isFirstDelta) {
8316
8349
  textDelta += "[";
@@ -8730,7 +8763,7 @@ async function generateObject(options) {
8730
8763
  }),
8731
8764
  tracer,
8732
8765
  fn: async (span) => {
8733
- var _a15;
8766
+ var _a14;
8734
8767
  let result;
8735
8768
  let finishReason;
8736
8769
  let usage;
@@ -8776,7 +8809,7 @@ async function generateObject(options) {
8776
8809
  }),
8777
8810
  tracer,
8778
8811
  fn: async (span2) => {
8779
- var _a16, _b, _c, _d, _e, _f, _g, _h;
8812
+ var _a15, _b, _c, _d, _e, _f, _g, _h;
8780
8813
  const result2 = await model.doGenerate({
8781
8814
  responseFormat: {
8782
8815
  type: "json",
@@ -8791,7 +8824,7 @@ async function generateObject(options) {
8791
8824
  headers: headersWithUserAgent
8792
8825
  });
8793
8826
  const responseData = {
8794
- id: (_b = (_a16 = result2.response) == null ? void 0 : _a16.id) != null ? _b : generateId2(),
8827
+ id: (_b = (_a15 = result2.response) == null ? void 0 : _a15.id) != null ? _b : generateId2(),
8795
8828
  timestamp: (_d = (_c = result2.response) == null ? void 0 : _c.timestamp) != null ? _d : currentDate(),
8796
8829
  modelId: (_f = (_e = result2.response) == null ? void 0 : _e.modelId) != null ? _f : model.modelId,
8797
8830
  headers: (_g = result2.response) == null ? void 0 : _g.headers,
@@ -8845,7 +8878,7 @@ async function generateObject(options) {
8845
8878
  usage = asLanguageModelUsage(generateResult.usage);
8846
8879
  warnings = generateResult.warnings;
8847
8880
  resultProviderMetadata = generateResult.providerMetadata;
8848
- request = (_a15 = generateResult.request) != null ? _a15 : {};
8881
+ request = (_a14 = generateResult.request) != null ? _a14 : {};
8849
8882
  response = generateResult.responseData;
8850
8883
  reasoning = generateResult.reasoning;
8851
8884
  logWarnings({
@@ -8908,9 +8941,9 @@ var DefaultGenerateObjectResult = class {
8908
8941
  this.reasoning = options.reasoning;
8909
8942
  }
8910
8943
  toJsonResponse(init) {
8911
- var _a15;
8944
+ var _a14;
8912
8945
  return new Response(JSON.stringify(this.object), {
8913
- status: (_a15 = init == null ? void 0 : init.status) != null ? _a15 : 200,
8946
+ status: (_a14 = init == null ? void 0 : init.status) != null ? _a14 : 200,
8914
8947
  headers: prepareHeaders(init == null ? void 0 : init.headers, {
8915
8948
  "content-type": "application/json; charset=utf-8"
8916
8949
  })
@@ -9039,8 +9072,8 @@ function simulateReadableStream({
9039
9072
  chunkDelayInMs = 0,
9040
9073
  _internal
9041
9074
  }) {
9042
- var _a15;
9043
- const delay2 = (_a15 = _internal == null ? void 0 : _internal.delay) != null ? _a15 : delayFunction;
9075
+ var _a14;
9076
+ const delay2 = (_a14 = _internal == null ? void 0 : _internal.delay) != null ? _a14 : delayFunction;
9044
9077
  let index = 0;
9045
9078
  return new ReadableStream({
9046
9079
  async pull(controller) {
@@ -9298,7 +9331,7 @@ var DefaultStreamObjectResult = class {
9298
9331
  const transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(
9299
9332
  new TransformStream({
9300
9333
  async transform(chunk, controller) {
9301
- var _a15, _b, _c;
9334
+ var _a14, _b, _c;
9302
9335
  if (typeof chunk === "object" && chunk.type === "stream-start") {
9303
9336
  warnings = chunk.warnings;
9304
9337
  return;
@@ -9348,7 +9381,7 @@ var DefaultStreamObjectResult = class {
9348
9381
  switch (chunk.type) {
9349
9382
  case "response-metadata": {
9350
9383
  fullResponse = {
9351
- id: (_a15 = chunk.id) != null ? _a15 : fullResponse.id,
9384
+ id: (_a14 = chunk.id) != null ? _a14 : fullResponse.id,
9352
9385
  timestamp: (_b = chunk.timestamp) != null ? _b : fullResponse.timestamp,
9353
9386
  modelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId
9354
9387
  };
@@ -9619,7 +9652,7 @@ async function generateSpeech({
9619
9652
  abortSignal,
9620
9653
  headers
9621
9654
  }) {
9622
- var _a15;
9655
+ var _a14;
9623
9656
  const resolvedModel = resolveSpeechModel(model);
9624
9657
  if (!resolvedModel) {
9625
9658
  throw new Error("Model could not be resolved");
@@ -9656,10 +9689,10 @@ async function generateSpeech({
9656
9689
  return new DefaultSpeechResult({
9657
9690
  audio: new DefaultGeneratedAudioFile({
9658
9691
  data: result.audio,
9659
- mediaType: (_a15 = detectMediaType({
9692
+ mediaType: (_a14 = detectMediaType({
9660
9693
  data: result.audio,
9661
9694
  signatures: audioMediaTypeSignatures
9662
- })) != null ? _a15 : "audio/mp3"
9695
+ })) != null ? _a14 : "audio/mp3"
9663
9696
  }),
9664
9697
  warnings: result.warnings,
9665
9698
  responses: [result.response],
@@ -9668,11 +9701,11 @@ async function generateSpeech({
9668
9701
  }
9669
9702
  var DefaultSpeechResult = class {
9670
9703
  constructor(options) {
9671
- var _a15;
9704
+ var _a14;
9672
9705
  this.audio = options.audio;
9673
9706
  this.warnings = options.warnings;
9674
9707
  this.responses = options.responses;
9675
- this.providerMetadata = (_a15 = options.providerMetadata) != null ? _a15 : {};
9708
+ this.providerMetadata = (_a14 = options.providerMetadata) != null ? _a14 : {};
9676
9709
  }
9677
9710
  };
9678
9711
 
@@ -10104,13 +10137,13 @@ function addToolInputExamplesMiddleware({
10104
10137
  return {
10105
10138
  specificationVersion: "v3",
10106
10139
  transformParams: async ({ params }) => {
10107
- var _a15;
10108
- if (!((_a15 = params.tools) == null ? void 0 : _a15.length)) {
10140
+ var _a14;
10141
+ if (!((_a14 = params.tools) == null ? void 0 : _a14.length)) {
10109
10142
  return params;
10110
10143
  }
10111
10144
  const transformedTools = params.tools.map((tool2) => {
10112
- var _a16;
10113
- if (tool2.type !== "function" || !((_a16 = tool2.inputExamples) == null ? void 0 : _a16.length)) {
10145
+ var _a15;
10146
+ if (tool2.type !== "function" || !((_a15 = tool2.inputExamples) == null ? void 0 : _a15.length)) {
10114
10147
  return tool2;
10115
10148
  }
10116
10149
  const formattedExamples = tool2.inputExamples.map((example, index) => format(example, index)).join("\n");
@@ -10157,7 +10190,7 @@ var doWrap = ({
10157
10190
  modelId,
10158
10191
  providerId
10159
10192
  }) => {
10160
- var _a15, _b, _c;
10193
+ var _a14, _b, _c;
10161
10194
  async function doTransform({
10162
10195
  params,
10163
10196
  type
@@ -10166,7 +10199,7 @@ var doWrap = ({
10166
10199
  }
10167
10200
  return {
10168
10201
  specificationVersion: "v3",
10169
- provider: (_a15 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a15 : model.provider,
10202
+ provider: (_a14 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a14 : model.provider,
10170
10203
  modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
10171
10204
  supportedUrls: (_c = overrideSupportedUrls == null ? void 0 : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
10172
10205
  async doGenerate(params) {
@@ -10213,7 +10246,7 @@ var doWrap2 = ({
10213
10246
  modelId,
10214
10247
  providerId
10215
10248
  }) => {
10216
- var _a15, _b, _c, _d;
10249
+ var _a14, _b, _c, _d;
10217
10250
  async function doTransform({
10218
10251
  params
10219
10252
  }) {
@@ -10221,7 +10254,7 @@ var doWrap2 = ({
10221
10254
  }
10222
10255
  return {
10223
10256
  specificationVersion: "v3",
10224
- provider: (_a15 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a15 : model.provider,
10257
+ provider: (_a14 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a14 : model.provider,
10225
10258
  modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
10226
10259
  maxEmbeddingsPerCall: (_c = overrideMaxEmbeddingsPerCall == null ? void 0 : overrideMaxEmbeddingsPerCall({ model })) != null ? _c : model.maxEmbeddingsPerCall,
10227
10260
  supportsParallelCalls: (_d = overrideSupportsParallelCalls == null ? void 0 : overrideSupportsParallelCalls({ model })) != null ? _d : model.supportsParallelCalls,
@@ -10350,11 +10383,11 @@ function customProvider({
10350
10383
  var experimental_customProvider = customProvider;
10351
10384
 
10352
10385
  // src/registry/no-such-provider-error.ts
10353
- import { AISDKError as AISDKError19, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
10354
- var name14 = "AI_NoSuchProviderError";
10355
- var marker14 = `vercel.ai.error.${name14}`;
10356
- var symbol14 = Symbol.for(marker14);
10357
- var _a14;
10386
+ import { AISDKError as AISDKError18, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
10387
+ var name13 = "AI_NoSuchProviderError";
10388
+ var marker13 = `vercel.ai.error.${name13}`;
10389
+ var symbol13 = Symbol.for(marker13);
10390
+ var _a13;
10358
10391
  var NoSuchProviderError = class extends NoSuchModelError3 {
10359
10392
  constructor({
10360
10393
  modelId,
@@ -10363,16 +10396,16 @@ var NoSuchProviderError = class extends NoSuchModelError3 {
10363
10396
  availableProviders,
10364
10397
  message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})`
10365
10398
  }) {
10366
- super({ errorName: name14, modelId, modelType, message });
10367
- this[_a14] = true;
10399
+ super({ errorName: name13, modelId, modelType, message });
10400
+ this[_a13] = true;
10368
10401
  this.providerId = providerId;
10369
10402
  this.availableProviders = availableProviders;
10370
10403
  }
10371
10404
  static isInstance(error) {
10372
- return AISDKError19.hasMarker(error, marker14);
10405
+ return AISDKError18.hasMarker(error, marker13);
10373
10406
  }
10374
10407
  };
10375
- _a14 = symbol14;
10408
+ _a13 = symbol13;
10376
10409
 
10377
10410
  // src/registry/provider-registry.ts
10378
10411
  import {
@@ -10431,10 +10464,10 @@ var DefaultProviderRegistry = class {
10431
10464
  return [id.slice(0, index), id.slice(index + this.separator.length)];
10432
10465
  }
10433
10466
  languageModel(id) {
10434
- var _a15, _b;
10467
+ var _a14, _b;
10435
10468
  const [providerId, modelId] = this.splitId(id, "languageModel");
10436
- let model = (_b = (_a15 = this.getProvider(providerId, "languageModel")).languageModel) == null ? void 0 : _b.call(
10437
- _a15,
10469
+ let model = (_b = (_a14 = this.getProvider(providerId, "languageModel")).languageModel) == null ? void 0 : _b.call(
10470
+ _a14,
10438
10471
  modelId
10439
10472
  );
10440
10473
  if (model == null) {
@@ -10449,10 +10482,10 @@ var DefaultProviderRegistry = class {
10449
10482
  return model;
10450
10483
  }
10451
10484
  embeddingModel(id) {
10452
- var _a15;
10485
+ var _a14;
10453
10486
  const [providerId, modelId] = this.splitId(id, "embeddingModel");
10454
10487
  const provider = this.getProvider(providerId, "embeddingModel");
10455
- const model = (_a15 = provider.embeddingModel) == null ? void 0 : _a15.call(provider, modelId);
10488
+ const model = (_a14 = provider.embeddingModel) == null ? void 0 : _a14.call(provider, modelId);
10456
10489
  if (model == null) {
10457
10490
  throw new NoSuchModelError4({
10458
10491
  modelId: id,
@@ -10462,20 +10495,20 @@ var DefaultProviderRegistry = class {
10462
10495
  return model;
10463
10496
  }
10464
10497
  imageModel(id) {
10465
- var _a15;
10498
+ var _a14;
10466
10499
  const [providerId, modelId] = this.splitId(id, "imageModel");
10467
10500
  const provider = this.getProvider(providerId, "imageModel");
10468
- const model = (_a15 = provider.imageModel) == null ? void 0 : _a15.call(provider, modelId);
10501
+ const model = (_a14 = provider.imageModel) == null ? void 0 : _a14.call(provider, modelId);
10469
10502
  if (model == null) {
10470
10503
  throw new NoSuchModelError4({ modelId: id, modelType: "imageModel" });
10471
10504
  }
10472
10505
  return model;
10473
10506
  }
10474
10507
  transcriptionModel(id) {
10475
- var _a15;
10508
+ var _a14;
10476
10509
  const [providerId, modelId] = this.splitId(id, "transcriptionModel");
10477
10510
  const provider = this.getProvider(providerId, "transcriptionModel");
10478
- const model = (_a15 = provider.transcriptionModel) == null ? void 0 : _a15.call(provider, modelId);
10511
+ const model = (_a14 = provider.transcriptionModel) == null ? void 0 : _a14.call(provider, modelId);
10479
10512
  if (model == null) {
10480
10513
  throw new NoSuchModelError4({
10481
10514
  modelId: id,
@@ -10485,20 +10518,20 @@ var DefaultProviderRegistry = class {
10485
10518
  return model;
10486
10519
  }
10487
10520
  speechModel(id) {
10488
- var _a15;
10521
+ var _a14;
10489
10522
  const [providerId, modelId] = this.splitId(id, "speechModel");
10490
10523
  const provider = this.getProvider(providerId, "speechModel");
10491
- const model = (_a15 = provider.speechModel) == null ? void 0 : _a15.call(provider, modelId);
10524
+ const model = (_a14 = provider.speechModel) == null ? void 0 : _a14.call(provider, modelId);
10492
10525
  if (model == null) {
10493
10526
  throw new NoSuchModelError4({ modelId: id, modelType: "speechModel" });
10494
10527
  }
10495
10528
  return model;
10496
10529
  }
10497
10530
  rerankingModel(id) {
10498
- var _a15;
10531
+ var _a14;
10499
10532
  const [providerId, modelId] = this.splitId(id, "rerankingModel");
10500
10533
  const provider = this.getProvider(providerId, "rerankingModel");
10501
- const model = (_a15 = provider.rerankingModel) == null ? void 0 : _a15.call(provider, modelId);
10534
+ const model = (_a14 = provider.rerankingModel) == null ? void 0 : _a14.call(provider, modelId);
10502
10535
  if (model == null) {
10503
10536
  throw new NoSuchModelError4({ modelId: id, modelType: "rerankingModel" });
10504
10537
  }
@@ -10555,7 +10588,7 @@ async function rerank({
10555
10588
  }),
10556
10589
  tracer,
10557
10590
  fn: async () => {
10558
- var _a15, _b;
10591
+ var _a14, _b;
10559
10592
  const { ranking, response, providerMetadata, warnings } = await retry(
10560
10593
  () => recordSpan({
10561
10594
  name: "ai.rerank.doRerank",
@@ -10619,7 +10652,7 @@ async function rerank({
10619
10652
  providerMetadata,
10620
10653
  response: {
10621
10654
  id: response == null ? void 0 : response.id,
10622
- timestamp: (_a15 = response == null ? void 0 : response.timestamp) != null ? _a15 : /* @__PURE__ */ new Date(),
10655
+ timestamp: (_a14 = response == null ? void 0 : response.timestamp) != null ? _a14 : /* @__PURE__ */ new Date(),
10623
10656
  modelId: (_b = response == null ? void 0 : response.modelId) != null ? _b : model.modelId,
10624
10657
  headers: response == null ? void 0 : response.headers,
10625
10658
  body: response == null ? void 0 : response.body
@@ -10644,8 +10677,8 @@ var DefaultRerankResult = class {
10644
10677
  import { withUserAgentSuffix as withUserAgentSuffix8 } from "@ai-sdk/provider-utils";
10645
10678
 
10646
10679
  // src/error/no-transcript-generated-error.ts
10647
- import { AISDKError as AISDKError20 } from "@ai-sdk/provider";
10648
- var NoTranscriptGeneratedError = class extends AISDKError20 {
10680
+ import { AISDKError as AISDKError19 } from "@ai-sdk/provider";
10681
+ var NoTranscriptGeneratedError = class extends AISDKError19 {
10649
10682
  constructor(options) {
10650
10683
  super({
10651
10684
  name: "AI_NoTranscriptGeneratedError",
@@ -10679,16 +10712,16 @@ async function transcribe({
10679
10712
  const audioData = audio instanceof URL ? (await download({ url: audio })).data : convertDataContentToUint8Array(audio);
10680
10713
  const result = await retry(
10681
10714
  () => {
10682
- var _a15;
10715
+ var _a14;
10683
10716
  return resolvedModel.doGenerate({
10684
10717
  audio: audioData,
10685
10718
  abortSignal,
10686
10719
  headers: headersWithUserAgent,
10687
10720
  providerOptions,
10688
- mediaType: (_a15 = detectMediaType({
10721
+ mediaType: (_a14 = detectMediaType({
10689
10722
  data: audioData,
10690
10723
  signatures: audioMediaTypeSignatures
10691
- })) != null ? _a15 : "audio/wav"
10724
+ })) != null ? _a14 : "audio/wav"
10692
10725
  });
10693
10726
  }
10694
10727
  );
@@ -10712,14 +10745,14 @@ async function transcribe({
10712
10745
  }
10713
10746
  var DefaultTranscriptionResult = class {
10714
10747
  constructor(options) {
10715
- var _a15;
10748
+ var _a14;
10716
10749
  this.text = options.text;
10717
10750
  this.segments = options.segments;
10718
10751
  this.language = options.language;
10719
10752
  this.durationInSeconds = options.durationInSeconds;
10720
10753
  this.warnings = options.warnings;
10721
10754
  this.responses = options.responses;
10722
- this.providerMetadata = (_a15 = options.providerMetadata) != null ? _a15 : {};
10755
+ this.providerMetadata = (_a14 = options.providerMetadata) != null ? _a14 : {};
10723
10756
  }
10724
10757
  };
10725
10758
 
@@ -10762,7 +10795,7 @@ async function callCompletionApi({
10762
10795
  onError,
10763
10796
  fetch: fetch2 = getOriginalFetch()
10764
10797
  }) {
10765
- var _a15;
10798
+ var _a14;
10766
10799
  try {
10767
10800
  setLoading(true);
10768
10801
  setError(void 0);
@@ -10790,7 +10823,7 @@ async function callCompletionApi({
10790
10823
  });
10791
10824
  if (!response.ok) {
10792
10825
  throw new Error(
10793
- (_a15 = await response.text()) != null ? _a15 : "Failed to fetch the chat response."
10826
+ (_a14 = await response.text()) != null ? _a14 : "Failed to fetch the chat response."
10794
10827
  );
10795
10828
  }
10796
10829
  if (!response.body) {
@@ -10876,12 +10909,12 @@ async function convertFileListToFileUIParts(files) {
10876
10909
  }
10877
10910
  return Promise.all(
10878
10911
  Array.from(files).map(async (file) => {
10879
- const { name: name15, type } = file;
10912
+ const { name: name14, type } = file;
10880
10913
  const dataUrl = await new Promise((resolve3, reject) => {
10881
10914
  const reader = new FileReader();
10882
10915
  reader.onload = (readerEvent) => {
10883
- var _a15;
10884
- resolve3((_a15 = readerEvent.target) == null ? void 0 : _a15.result);
10916
+ var _a14;
10917
+ resolve3((_a14 = readerEvent.target) == null ? void 0 : _a14.result);
10885
10918
  };
10886
10919
  reader.onerror = (error) => reject(error);
10887
10920
  reader.readAsDataURL(file);
@@ -10889,7 +10922,7 @@ async function convertFileListToFileUIParts(files) {
10889
10922
  return {
10890
10923
  type: "file",
10891
10924
  mediaType: type,
10892
- filename: name15,
10925
+ filename: name14,
10893
10926
  url: dataUrl
10894
10927
  };
10895
10928
  })
@@ -10928,7 +10961,7 @@ var HttpChatTransport = class {
10928
10961
  abortSignal,
10929
10962
  ...options
10930
10963
  }) {
10931
- var _a15, _b, _c, _d, _e;
10964
+ var _a14, _b, _c, _d, _e;
10932
10965
  const resolvedBody = await resolve2(this.body);
10933
10966
  const resolvedHeaders = await resolve2(this.headers);
10934
10967
  const resolvedCredentials = await resolve2(this.credentials);
@@ -10936,7 +10969,7 @@ var HttpChatTransport = class {
10936
10969
  ...normalizeHeaders(resolvedHeaders),
10937
10970
  ...normalizeHeaders(options.headers)
10938
10971
  };
10939
- const preparedRequest = await ((_a15 = this.prepareSendMessagesRequest) == null ? void 0 : _a15.call(this, {
10972
+ const preparedRequest = await ((_a14 = this.prepareSendMessagesRequest) == null ? void 0 : _a14.call(this, {
10940
10973
  api: this.api,
10941
10974
  id: options.chatId,
10942
10975
  messages: options.messages,
@@ -10984,7 +11017,7 @@ var HttpChatTransport = class {
10984
11017
  return this.processResponseStream(response.body);
10985
11018
  }
10986
11019
  async reconnectToStream(options) {
10987
- var _a15, _b, _c, _d, _e;
11020
+ var _a14, _b, _c, _d, _e;
10988
11021
  const resolvedBody = await resolve2(this.body);
10989
11022
  const resolvedHeaders = await resolve2(this.headers);
10990
11023
  const resolvedCredentials = await resolve2(this.credentials);
@@ -10992,7 +11025,7 @@ var HttpChatTransport = class {
10992
11025
  ...normalizeHeaders(resolvedHeaders),
10993
11026
  ...normalizeHeaders(options.headers)
10994
11027
  };
10995
- const preparedRequest = await ((_a15 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a15.call(this, {
11028
+ const preparedRequest = await ((_a14 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a14.call(this, {
10996
11029
  api: this.api,
10997
11030
  id: options.chatId,
10998
11031
  body: { ...resolvedBody, ...options.body },
@@ -11074,11 +11107,11 @@ var AbstractChat = class {
11074
11107
  * If a messageId is provided, the message will be replaced.
11075
11108
  */
11076
11109
  this.sendMessage = async (message, options) => {
11077
- var _a15, _b, _c, _d;
11110
+ var _a14, _b, _c, _d;
11078
11111
  if (message == null) {
11079
11112
  await this.makeRequest({
11080
11113
  trigger: "submit-message",
11081
- messageId: (_a15 = this.lastMessage) == null ? void 0 : _a15.id,
11114
+ messageId: (_a14 = this.lastMessage) == null ? void 0 : _a14.id,
11082
11115
  ...options
11083
11116
  });
11084
11117
  return;
@@ -11171,7 +11204,7 @@ var AbstractChat = class {
11171
11204
  approved,
11172
11205
  reason
11173
11206
  }) => this.jobExecutor.run(async () => {
11174
- var _a15, _b;
11207
+ var _a14, _b;
11175
11208
  const messages = this.state.messages;
11176
11209
  const lastMessage = messages[messages.length - 1];
11177
11210
  const updatePart = (part) => isToolUIPart(part) && part.state === "approval-requested" && part.approval.id === id ? {
@@ -11186,7 +11219,7 @@ var AbstractChat = class {
11186
11219
  if (this.activeResponse) {
11187
11220
  this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(updatePart);
11188
11221
  }
11189
- if (this.status !== "streaming" && this.status !== "submitted" && ((_a15 = this.sendAutomaticallyWhen) == null ? void 0 : _a15.call(this, { messages: this.state.messages }))) {
11222
+ if (this.status !== "streaming" && this.status !== "submitted" && ((_a14 = this.sendAutomaticallyWhen) == null ? void 0 : _a14.call(this, { messages: this.state.messages }))) {
11190
11223
  this.makeRequest({
11191
11224
  trigger: "submit-message",
11192
11225
  messageId: (_b = this.lastMessage) == null ? void 0 : _b.id
@@ -11200,7 +11233,7 @@ var AbstractChat = class {
11200
11233
  output,
11201
11234
  errorText
11202
11235
  }) => this.jobExecutor.run(async () => {
11203
- var _a15, _b;
11236
+ var _a14, _b;
11204
11237
  const messages = this.state.messages;
11205
11238
  const lastMessage = messages[messages.length - 1];
11206
11239
  const updatePart = (part) => isToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state, output, errorText } : part;
@@ -11211,7 +11244,7 @@ var AbstractChat = class {
11211
11244
  if (this.activeResponse) {
11212
11245
  this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(updatePart);
11213
11246
  }
11214
- if (this.status !== "streaming" && this.status !== "submitted" && ((_a15 = this.sendAutomaticallyWhen) == null ? void 0 : _a15.call(this, { messages: this.state.messages }))) {
11247
+ if (this.status !== "streaming" && this.status !== "submitted" && ((_a14 = this.sendAutomaticallyWhen) == null ? void 0 : _a14.call(this, { messages: this.state.messages }))) {
11215
11248
  this.makeRequest({
11216
11249
  trigger: "submit-message",
11217
11250
  messageId: (_b = this.lastMessage) == null ? void 0 : _b.id
@@ -11224,10 +11257,10 @@ var AbstractChat = class {
11224
11257
  * Abort the current request immediately, keep the generated tokens if any.
11225
11258
  */
11226
11259
  this.stop = async () => {
11227
- var _a15;
11260
+ var _a14;
11228
11261
  if (this.status !== "streaming" && this.status !== "submitted")
11229
11262
  return;
11230
- if ((_a15 = this.activeResponse) == null ? void 0 : _a15.abortController) {
11263
+ if ((_a14 = this.activeResponse) == null ? void 0 : _a14.abortController) {
11231
11264
  this.activeResponse.abortController.abort();
11232
11265
  }
11233
11266
  };
@@ -11282,7 +11315,7 @@ var AbstractChat = class {
11282
11315
  body,
11283
11316
  messageId
11284
11317
  }) {
11285
- var _a15, _b, _c, _d;
11318
+ var _a14, _b, _c, _d;
11286
11319
  this.setStatus({ status: "submitted", error: void 0 });
11287
11320
  const lastMessage = this.lastMessage;
11288
11321
  let isAbort = false;
@@ -11331,9 +11364,9 @@ var AbstractChat = class {
11331
11364
  () => job({
11332
11365
  state: activeResponse.state,
11333
11366
  write: () => {
11334
- var _a16;
11367
+ var _a15;
11335
11368
  this.setStatus({ status: "streaming" });
11336
- const replaceLastMessage = activeResponse.state.message.id === ((_a16 = this.lastMessage) == null ? void 0 : _a16.id);
11369
+ const replaceLastMessage = activeResponse.state.message.id === ((_a15 = this.lastMessage) == null ? void 0 : _a15.id);
11337
11370
  if (replaceLastMessage) {
11338
11371
  this.state.replaceMessage(
11339
11372
  this.state.messages.length - 1,
@@ -11385,7 +11418,7 @@ var AbstractChat = class {
11385
11418
  isAbort,
11386
11419
  isDisconnect,
11387
11420
  isError,
11388
- finishReason: (_a15 = this.activeResponse) == null ? void 0 : _a15.state.finishReason
11421
+ finishReason: (_a14 = this.activeResponse) == null ? void 0 : _a14.state.finishReason
11389
11422
  });
11390
11423
  } catch (err) {
11391
11424
  console.error(err);
@@ -11483,7 +11516,7 @@ var TextStreamChatTransport = class extends HttpChatTransport {
11483
11516
  }
11484
11517
  };
11485
11518
  export {
11486
- AISDKError16 as AISDKError,
11519
+ AISDKError15 as AISDKError,
11487
11520
  APICallError,
11488
11521
  AbstractChat,
11489
11522
  DefaultChatTransport,
@@ -11546,12 +11579,13 @@ export {
11546
11579
  embedMany,
11547
11580
  experimental_createProviderRegistry,
11548
11581
  experimental_customProvider,
11549
- generateImage as experimental_generateImage,
11582
+ experimental_generateImage,
11550
11583
  generateSpeech as experimental_generateSpeech,
11551
11584
  transcribe as experimental_transcribe,
11552
11585
  extractReasoningMiddleware,
11553
11586
  gateway2 as gateway,
11554
11587
  generateId,
11588
+ generateImage,
11555
11589
  generateObject,
11556
11590
  generateText,
11557
11591
  getStaticToolName,