ai 6.0.0-beta.159 → 6.0.0-beta.161

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.159" : "0.0.0-test";
847
+ var VERSION = true ? "6.0.0-beta.161" : "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,
@@ -4438,7 +4416,7 @@ function processUIMessageStream({
4438
4416
  new TransformStream({
4439
4417
  async transform(chunk, controller) {
4440
4418
  await runUpdateMessageJob(async ({ state, write }) => {
4441
- var _a15, _b, _c, _d;
4419
+ var _a14, _b, _c, _d;
4442
4420
  function getToolInvocation(toolCallId) {
4443
4421
  const toolInvocations = state.message.parts.filter(isToolUIPart);
4444
4422
  const toolInvocation = toolInvocations.find(
@@ -4452,7 +4430,7 @@ function processUIMessageStream({
4452
4430
  return toolInvocation;
4453
4431
  }
4454
4432
  function updateToolPart(options) {
4455
- var _a16;
4433
+ var _a15;
4456
4434
  const part = state.message.parts.find(
4457
4435
  (part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId
4458
4436
  );
@@ -4468,7 +4446,7 @@ function processUIMessageStream({
4468
4446
  if (options.title !== void 0) {
4469
4447
  anyPart.title = options.title;
4470
4448
  }
4471
- anyPart.providerExecuted = (_a16 = anyOptions.providerExecuted) != null ? _a16 : part.providerExecuted;
4449
+ anyPart.providerExecuted = (_a15 = anyOptions.providerExecuted) != null ? _a15 : part.providerExecuted;
4472
4450
  if (anyOptions.providerMetadata != null && part.state === "input-available") {
4473
4451
  part.callProviderMetadata = anyOptions.providerMetadata;
4474
4452
  }
@@ -4489,7 +4467,7 @@ function processUIMessageStream({
4489
4467
  }
4490
4468
  }
4491
4469
  function updateDynamicToolPart(options) {
4492
- var _a16, _b2;
4470
+ var _a15, _b2;
4493
4471
  const part = state.message.parts.find(
4494
4472
  (part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
4495
4473
  );
@@ -4501,7 +4479,7 @@ function processUIMessageStream({
4501
4479
  anyPart.input = anyOptions.input;
4502
4480
  anyPart.output = anyOptions.output;
4503
4481
  anyPart.errorText = anyOptions.errorText;
4504
- anyPart.rawInput = (_a16 = anyOptions.rawInput) != null ? _a16 : anyPart.rawInput;
4482
+ anyPart.rawInput = (_a15 = anyOptions.rawInput) != null ? _a15 : anyPart.rawInput;
4505
4483
  anyPart.preliminary = anyOptions.preliminary;
4506
4484
  if (options.title !== void 0) {
4507
4485
  anyPart.title = options.title;
@@ -4554,7 +4532,7 @@ function processUIMessageStream({
4554
4532
  case "text-delta": {
4555
4533
  const textPart = state.activeTextParts[chunk.id];
4556
4534
  textPart.text += chunk.delta;
4557
- textPart.providerMetadata = (_a15 = chunk.providerMetadata) != null ? _a15 : textPart.providerMetadata;
4535
+ textPart.providerMetadata = (_a14 = chunk.providerMetadata) != null ? _a14 : textPart.providerMetadata;
4558
4536
  write();
4559
4537
  break;
4560
4538
  }
@@ -4993,11 +4971,11 @@ function createAsyncIterableStream(source) {
4993
4971
  const reader = this.getReader();
4994
4972
  let finished = false;
4995
4973
  async function cleanup(cancelStream) {
4996
- var _a15;
4974
+ var _a14;
4997
4975
  finished = true;
4998
4976
  try {
4999
4977
  if (cancelStream) {
5000
- await ((_a15 = reader.cancel) == null ? void 0 : _a15.call(reader));
4978
+ await ((_a14 = reader.cancel) == null ? void 0 : _a14.call(reader));
5001
4979
  }
5002
4980
  } finally {
5003
4981
  try {
@@ -5163,8 +5141,8 @@ function createStitchableStream() {
5163
5141
 
5164
5142
  // src/util/now.ts
5165
5143
  function now() {
5166
- var _a15, _b;
5167
- 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();
5168
5146
  }
5169
5147
 
5170
5148
  // src/generate-text/run-tools-transformation.ts
@@ -5475,7 +5453,7 @@ function createOutputTransformStream(output) {
5475
5453
  }
5476
5454
  return new TransformStream({
5477
5455
  async transform(chunk, controller) {
5478
- var _a15;
5456
+ var _a14;
5479
5457
  if (chunk.type === "finish-step" && textChunk.length > 0) {
5480
5458
  publishTextChunk({ controller });
5481
5459
  }
@@ -5502,7 +5480,7 @@ function createOutputTransformStream(output) {
5502
5480
  }
5503
5481
  text2 += chunk.text;
5504
5482
  textChunk += chunk.text;
5505
- textProviderMetadata = (_a15 = chunk.providerMetadata) != null ? _a15 : textProviderMetadata;
5483
+ textProviderMetadata = (_a14 = chunk.providerMetadata) != null ? _a14 : textProviderMetadata;
5506
5484
  const result = await output.parsePartialOutput({ text: text2 });
5507
5485
  if (result !== void 0) {
5508
5486
  const currentJson = JSON.stringify(result.partial);
@@ -5565,7 +5543,7 @@ var DefaultStreamTextResult = class {
5565
5543
  let activeReasoningContent = {};
5566
5544
  const eventProcessor = new TransformStream({
5567
5545
  async transform(chunk, controller) {
5568
- var _a15, _b, _c, _d;
5546
+ var _a14, _b, _c, _d;
5569
5547
  controller.enqueue(chunk);
5570
5548
  const { part } = chunk;
5571
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") {
@@ -5595,7 +5573,7 @@ var DefaultStreamTextResult = class {
5595
5573
  return;
5596
5574
  }
5597
5575
  activeText.text += part.text;
5598
- activeText.providerMetadata = (_a15 = part.providerMetadata) != null ? _a15 : activeText.providerMetadata;
5576
+ activeText.providerMetadata = (_a14 = part.providerMetadata) != null ? _a14 : activeText.providerMetadata;
5599
5577
  }
5600
5578
  if (part.type === "text-end") {
5601
5579
  const activeText = activeTextContent[part.id];
@@ -5755,8 +5733,8 @@ var DefaultStreamTextResult = class {
5755
5733
  "ai.response.text": { output: () => finalStep.text },
5756
5734
  "ai.response.toolCalls": {
5757
5735
  output: () => {
5758
- var _a15;
5759
- 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;
5760
5738
  }
5761
5739
  },
5762
5740
  "ai.response.providerMetadata": JSON.stringify(
@@ -5940,7 +5918,7 @@ var DefaultStreamTextResult = class {
5940
5918
  responseMessages,
5941
5919
  usage
5942
5920
  }) {
5943
- var _a15, _b, _c, _d, _e, _f;
5921
+ var _a14, _b, _c, _d, _e, _f;
5944
5922
  const includeRawChunks2 = self.includeRawChunks;
5945
5923
  stepFinish = new DelayedPromise();
5946
5924
  const stepInputMessages = [...initialMessages, ...responseMessages];
@@ -5952,7 +5930,7 @@ var DefaultStreamTextResult = class {
5952
5930
  experimental_context
5953
5931
  }));
5954
5932
  const stepModel = resolveLanguageModel(
5955
- (_a15 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a15 : model
5933
+ (_a14 = prepareStepResult == null ? void 0 : prepareStepResult.model) != null ? _a14 : model
5956
5934
  );
5957
5935
  const promptMessages = await convertToLanguageModelPrompt({
5958
5936
  prompt: {
@@ -6060,7 +6038,7 @@ var DefaultStreamTextResult = class {
6060
6038
  streamWithToolResults.pipeThrough(
6061
6039
  new TransformStream({
6062
6040
  async transform(chunk, controller) {
6063
- var _a16, _b2, _c2, _d2, _e2;
6041
+ var _a15, _b2, _c2, _d2, _e2;
6064
6042
  if (chunk.type === "stream-start") {
6065
6043
  warnings = chunk.warnings;
6066
6044
  return;
@@ -6133,7 +6111,7 @@ var DefaultStreamTextResult = class {
6133
6111
  }
6134
6112
  case "response-metadata": {
6135
6113
  stepResponse = {
6136
- id: (_a16 = chunk.id) != null ? _a16 : stepResponse.id,
6114
+ id: (_a15 = chunk.id) != null ? _a15 : stepResponse.id,
6137
6115
  timestamp: (_b2 = chunk.timestamp) != null ? _b2 : stepResponse.timestamp,
6138
6116
  modelId: (_c2 = chunk.modelId) != null ? _c2 : stepResponse.modelId
6139
6117
  };
@@ -6432,14 +6410,14 @@ var DefaultStreamTextResult = class {
6432
6410
  );
6433
6411
  }
6434
6412
  async consumeStream(options) {
6435
- var _a15;
6413
+ var _a14;
6436
6414
  try {
6437
6415
  await consumeStream({
6438
6416
  stream: this.fullStream,
6439
6417
  onError: options == null ? void 0 : options.onError
6440
6418
  });
6441
6419
  } catch (error) {
6442
- (_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);
6443
6421
  }
6444
6422
  }
6445
6423
  get experimental_partialOutputStream() {
@@ -6460,8 +6438,8 @@ var DefaultStreamTextResult = class {
6460
6438
  }
6461
6439
  get output() {
6462
6440
  return this.finalStep.then((step) => {
6463
- var _a15;
6464
- const output = (_a15 = this.outputSpecification) != null ? _a15 : text();
6441
+ var _a14;
6442
+ const output = (_a14 = this.outputSpecification) != null ? _a14 : text();
6465
6443
  return output.parseCompleteOutput(
6466
6444
  { text: step.text },
6467
6445
  {
@@ -6488,8 +6466,8 @@ var DefaultStreamTextResult = class {
6488
6466
  responseMessageId: generateMessageId
6489
6467
  }) : void 0;
6490
6468
  const isDynamic = (part) => {
6491
- var _a15;
6492
- 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];
6493
6471
  if (tool2 == null) {
6494
6472
  return part.dynamic;
6495
6473
  }
@@ -6827,10 +6805,10 @@ var ToolLoopAgent = class {
6827
6805
  return this.settings.tools;
6828
6806
  }
6829
6807
  async prepareCall(options) {
6830
- var _a15, _b, _c, _d;
6808
+ var _a14, _b, _c, _d;
6831
6809
  const baseCallArgs = {
6832
6810
  ...this.settings,
6833
- stopWhen: (_a15 = this.settings.stopWhen) != null ? _a15 : stepCountIs(20),
6811
+ stopWhen: (_a14 = this.settings.stopWhen) != null ? _a14 : stepCountIs(20),
6834
6812
  ...options
6835
6813
  };
6836
6814
  const preparedCallArgs = (_d = await ((_c = (_b = this.settings).prepareCall) == null ? void 0 : _c.call(_b, baseCallArgs))) != null ? _d : baseCallArgs;
@@ -6965,7 +6943,7 @@ function readUIMessageStream({
6965
6943
  onError,
6966
6944
  terminateOnError = false
6967
6945
  }) {
6968
- var _a15;
6946
+ var _a14;
6969
6947
  let controller;
6970
6948
  let hasErrored = false;
6971
6949
  const outputStream = new ReadableStream({
@@ -6974,7 +6952,7 @@ function readUIMessageStream({
6974
6952
  }
6975
6953
  });
6976
6954
  const state = createStreamingUIMessageState({
6977
- messageId: (_a15 = message == null ? void 0 : message.id) != null ? _a15 : "",
6955
+ messageId: (_a14 = message == null ? void 0 : message.id) != null ? _a14 : "",
6978
6956
  lastMessage: message
6979
6957
  });
6980
6958
  const handleError = (error) => {
@@ -7043,7 +7021,7 @@ async function convertToModelMessages(messages, options) {
7043
7021
  modelMessages.push({
7044
7022
  role: "user",
7045
7023
  content: message.parts.map((part) => {
7046
- var _a15;
7024
+ var _a14;
7047
7025
  if (isTextUIPart(part)) {
7048
7026
  return {
7049
7027
  type: "text",
@@ -7061,7 +7039,7 @@ async function convertToModelMessages(messages, options) {
7061
7039
  };
7062
7040
  }
7063
7041
  if (isDataUIPart(part)) {
7064
- 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(
7065
7043
  options,
7066
7044
  part
7067
7045
  );
@@ -7074,7 +7052,7 @@ async function convertToModelMessages(messages, options) {
7074
7052
  if (message.parts != null) {
7075
7053
  let block = [];
7076
7054
  async function processBlock() {
7077
- var _a15, _b, _c, _d, _e, _f;
7055
+ var _a14, _b, _c, _d, _e, _f;
7078
7056
  if (block.length === 0) {
7079
7057
  return;
7080
7058
  }
@@ -7106,7 +7084,7 @@ async function convertToModelMessages(messages, options) {
7106
7084
  type: "tool-call",
7107
7085
  toolCallId: part.toolCallId,
7108
7086
  toolName,
7109
- 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,
7110
7088
  providerExecuted: part.providerExecuted,
7111
7089
  ...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
7112
7090
  });
@@ -7730,7 +7708,7 @@ async function embed({
7730
7708
  }),
7731
7709
  tracer,
7732
7710
  fn: async (doEmbedSpan) => {
7733
- var _a15;
7711
+ var _a14;
7734
7712
  const modelResponse = await model.doEmbed({
7735
7713
  values: [value],
7736
7714
  abortSignal,
@@ -7738,7 +7716,7 @@ async function embed({
7738
7716
  providerOptions
7739
7717
  });
7740
7718
  const embedding2 = modelResponse.embeddings[0];
7741
- const usage2 = (_a15 = modelResponse.usage) != null ? _a15 : { tokens: NaN };
7719
+ const usage2 = (_a14 = modelResponse.usage) != null ? _a14 : { tokens: NaN };
7742
7720
  doEmbedSpan.setAttributes(
7743
7721
  await selectTelemetryAttributes({
7744
7722
  telemetry,
@@ -7852,7 +7830,7 @@ async function embedMany({
7852
7830
  }),
7853
7831
  tracer,
7854
7832
  fn: async (span) => {
7855
- var _a15;
7833
+ var _a14;
7856
7834
  const [maxEmbeddingsPerCall, supportsParallelCalls] = await Promise.all([
7857
7835
  model.maxEmbeddingsPerCall,
7858
7836
  model.supportsParallelCalls
@@ -7877,7 +7855,7 @@ async function embedMany({
7877
7855
  }),
7878
7856
  tracer,
7879
7857
  fn: async (doEmbedSpan) => {
7880
- var _a16;
7858
+ var _a15;
7881
7859
  const modelResponse = await model.doEmbed({
7882
7860
  values,
7883
7861
  abortSignal,
@@ -7885,7 +7863,7 @@ async function embedMany({
7885
7863
  providerOptions
7886
7864
  });
7887
7865
  const embeddings3 = modelResponse.embeddings;
7888
- const usage2 = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };
7866
+ const usage2 = (_a15 = modelResponse.usage) != null ? _a15 : { tokens: NaN };
7889
7867
  doEmbedSpan.setAttributes(
7890
7868
  await selectTelemetryAttributes({
7891
7869
  telemetry,
@@ -7966,7 +7944,7 @@ async function embedMany({
7966
7944
  }),
7967
7945
  tracer,
7968
7946
  fn: async (doEmbedSpan) => {
7969
- var _a16;
7947
+ var _a15;
7970
7948
  const modelResponse = await model.doEmbed({
7971
7949
  values: chunk,
7972
7950
  abortSignal,
@@ -7974,7 +7952,7 @@ async function embedMany({
7974
7952
  providerOptions
7975
7953
  });
7976
7954
  const embeddings2 = modelResponse.embeddings;
7977
- const usage = (_a16 = modelResponse.usage) != null ? _a16 : { tokens: NaN };
7955
+ const usage = (_a15 = modelResponse.usage) != null ? _a15 : { tokens: NaN };
7978
7956
  doEmbedSpan.setAttributes(
7979
7957
  await selectTelemetryAttributes({
7980
7958
  telemetry,
@@ -8013,7 +7991,7 @@ async function embedMany({
8013
7991
  result.providerMetadata
8014
7992
  )) {
8015
7993
  providerMetadata[providerName] = {
8016
- ...(_a15 = providerMetadata[providerName]) != null ? _a15 : {},
7994
+ ...(_a14 = providerMetadata[providerName]) != null ? _a14 : {},
8017
7995
  ...metadata
8018
7996
  };
8019
7997
  }
@@ -8060,10 +8038,13 @@ var DefaultEmbedManyResult = class {
8060
8038
  };
8061
8039
 
8062
8040
  // src/generate-image/generate-image.ts
8063
- 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";
8064
8045
  async function generateImage({
8065
8046
  model: modelArg,
8066
- prompt,
8047
+ prompt: promptArg,
8067
8048
  n = 1,
8068
8049
  maxImagesPerCall,
8069
8050
  size,
@@ -8074,7 +8055,7 @@ async function generateImage({
8074
8055
  abortSignal,
8075
8056
  headers
8076
8057
  }) {
8077
- var _a15, _b;
8058
+ var _a14, _b;
8078
8059
  const model = resolveImageModel(modelArg);
8079
8060
  const headersWithUserAgent = withUserAgentSuffix5(
8080
8061
  headers != null ? headers : {},
@@ -8084,7 +8065,7 @@ async function generateImage({
8084
8065
  maxRetries: maxRetriesArg,
8085
8066
  abortSignal
8086
8067
  });
8087
- 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;
8088
8069
  const callCount = Math.ceil(n / maxImagesPerCallWithDefault);
8089
8070
  const callImageCounts = Array.from({ length: callCount }, (_, i) => {
8090
8071
  if (i < callCount - 1) {
@@ -8095,9 +8076,12 @@ async function generateImage({
8095
8076
  });
8096
8077
  const results = await Promise.all(
8097
8078
  callImageCounts.map(
8098
- async (callImageCount) => retry(
8099
- () => model.doGenerate({
8079
+ async (callImageCount) => retry(() => {
8080
+ const { prompt, files, mask } = normalizePrompt(promptArg);
8081
+ return model.doGenerate({
8100
8082
  prompt,
8083
+ files,
8084
+ mask,
8101
8085
  n: callImageCount,
8102
8086
  abortSignal,
8103
8087
  headers: headersWithUserAgent,
@@ -8105,8 +8089,8 @@ async function generateImage({
8105
8089
  aspectRatio,
8106
8090
  seed,
8107
8091
  providerOptions: providerOptions != null ? providerOptions : {}
8108
- })
8109
- )
8092
+ });
8093
+ })
8110
8094
  )
8111
8095
  );
8112
8096
  const images = [];
@@ -8122,13 +8106,13 @@ async function generateImage({
8122
8106
  images.push(
8123
8107
  ...result.images.map(
8124
8108
  (image) => {
8125
- var _a16;
8109
+ var _a15;
8126
8110
  return new DefaultGeneratedFile({
8127
8111
  data: image,
8128
- mediaType: (_a16 = detectMediaType({
8112
+ mediaType: (_a15 = detectMediaType({
8129
8113
  data: image,
8130
8114
  signatures: imageMediaTypeSignatures
8131
- })) != null ? _a16 : "image/png"
8115
+ })) != null ? _a15 : "image/png"
8132
8116
  });
8133
8117
  }
8134
8118
  )
@@ -8196,6 +8180,50 @@ async function invokeModelMaxImagesPerCall(model) {
8196
8180
  modelId: model.modelId
8197
8181
  });
8198
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;
8199
8227
 
8200
8228
  // src/generate-object/generate-object.ts
8201
8229
  import {
@@ -8292,7 +8320,7 @@ var arrayOutputStrategy = (schema) => {
8292
8320
  isFirstDelta,
8293
8321
  isFinalDelta
8294
8322
  }) {
8295
- var _a15;
8323
+ var _a14;
8296
8324
  if (!isJSONObject(value) || !isJSONArray(value.elements)) {
8297
8325
  return {
8298
8326
  success: false,
@@ -8315,7 +8343,7 @@ var arrayOutputStrategy = (schema) => {
8315
8343
  }
8316
8344
  resultArray.push(result.value);
8317
8345
  }
8318
- 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;
8319
8347
  let textDelta = "";
8320
8348
  if (isFirstDelta) {
8321
8349
  textDelta += "[";
@@ -8735,7 +8763,7 @@ async function generateObject(options) {
8735
8763
  }),
8736
8764
  tracer,
8737
8765
  fn: async (span) => {
8738
- var _a15;
8766
+ var _a14;
8739
8767
  let result;
8740
8768
  let finishReason;
8741
8769
  let usage;
@@ -8781,7 +8809,7 @@ async function generateObject(options) {
8781
8809
  }),
8782
8810
  tracer,
8783
8811
  fn: async (span2) => {
8784
- var _a16, _b, _c, _d, _e, _f, _g, _h;
8812
+ var _a15, _b, _c, _d, _e, _f, _g, _h;
8785
8813
  const result2 = await model.doGenerate({
8786
8814
  responseFormat: {
8787
8815
  type: "json",
@@ -8796,7 +8824,7 @@ async function generateObject(options) {
8796
8824
  headers: headersWithUserAgent
8797
8825
  });
8798
8826
  const responseData = {
8799
- 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(),
8800
8828
  timestamp: (_d = (_c = result2.response) == null ? void 0 : _c.timestamp) != null ? _d : currentDate(),
8801
8829
  modelId: (_f = (_e = result2.response) == null ? void 0 : _e.modelId) != null ? _f : model.modelId,
8802
8830
  headers: (_g = result2.response) == null ? void 0 : _g.headers,
@@ -8850,7 +8878,7 @@ async function generateObject(options) {
8850
8878
  usage = asLanguageModelUsage(generateResult.usage);
8851
8879
  warnings = generateResult.warnings;
8852
8880
  resultProviderMetadata = generateResult.providerMetadata;
8853
- request = (_a15 = generateResult.request) != null ? _a15 : {};
8881
+ request = (_a14 = generateResult.request) != null ? _a14 : {};
8854
8882
  response = generateResult.responseData;
8855
8883
  reasoning = generateResult.reasoning;
8856
8884
  logWarnings({
@@ -8913,9 +8941,9 @@ var DefaultGenerateObjectResult = class {
8913
8941
  this.reasoning = options.reasoning;
8914
8942
  }
8915
8943
  toJsonResponse(init) {
8916
- var _a15;
8944
+ var _a14;
8917
8945
  return new Response(JSON.stringify(this.object), {
8918
- status: (_a15 = init == null ? void 0 : init.status) != null ? _a15 : 200,
8946
+ status: (_a14 = init == null ? void 0 : init.status) != null ? _a14 : 200,
8919
8947
  headers: prepareHeaders(init == null ? void 0 : init.headers, {
8920
8948
  "content-type": "application/json; charset=utf-8"
8921
8949
  })
@@ -9044,8 +9072,8 @@ function simulateReadableStream({
9044
9072
  chunkDelayInMs = 0,
9045
9073
  _internal
9046
9074
  }) {
9047
- var _a15;
9048
- 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;
9049
9077
  let index = 0;
9050
9078
  return new ReadableStream({
9051
9079
  async pull(controller) {
@@ -9303,7 +9331,7 @@ var DefaultStreamObjectResult = class {
9303
9331
  const transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(
9304
9332
  new TransformStream({
9305
9333
  async transform(chunk, controller) {
9306
- var _a15, _b, _c;
9334
+ var _a14, _b, _c;
9307
9335
  if (typeof chunk === "object" && chunk.type === "stream-start") {
9308
9336
  warnings = chunk.warnings;
9309
9337
  return;
@@ -9353,7 +9381,7 @@ var DefaultStreamObjectResult = class {
9353
9381
  switch (chunk.type) {
9354
9382
  case "response-metadata": {
9355
9383
  fullResponse = {
9356
- id: (_a15 = chunk.id) != null ? _a15 : fullResponse.id,
9384
+ id: (_a14 = chunk.id) != null ? _a14 : fullResponse.id,
9357
9385
  timestamp: (_b = chunk.timestamp) != null ? _b : fullResponse.timestamp,
9358
9386
  modelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId
9359
9387
  };
@@ -9624,7 +9652,7 @@ async function generateSpeech({
9624
9652
  abortSignal,
9625
9653
  headers
9626
9654
  }) {
9627
- var _a15;
9655
+ var _a14;
9628
9656
  const resolvedModel = resolveSpeechModel(model);
9629
9657
  if (!resolvedModel) {
9630
9658
  throw new Error("Model could not be resolved");
@@ -9661,10 +9689,10 @@ async function generateSpeech({
9661
9689
  return new DefaultSpeechResult({
9662
9690
  audio: new DefaultGeneratedAudioFile({
9663
9691
  data: result.audio,
9664
- mediaType: (_a15 = detectMediaType({
9692
+ mediaType: (_a14 = detectMediaType({
9665
9693
  data: result.audio,
9666
9694
  signatures: audioMediaTypeSignatures
9667
- })) != null ? _a15 : "audio/mp3"
9695
+ })) != null ? _a14 : "audio/mp3"
9668
9696
  }),
9669
9697
  warnings: result.warnings,
9670
9698
  responses: [result.response],
@@ -9673,11 +9701,11 @@ async function generateSpeech({
9673
9701
  }
9674
9702
  var DefaultSpeechResult = class {
9675
9703
  constructor(options) {
9676
- var _a15;
9704
+ var _a14;
9677
9705
  this.audio = options.audio;
9678
9706
  this.warnings = options.warnings;
9679
9707
  this.responses = options.responses;
9680
- this.providerMetadata = (_a15 = options.providerMetadata) != null ? _a15 : {};
9708
+ this.providerMetadata = (_a14 = options.providerMetadata) != null ? _a14 : {};
9681
9709
  }
9682
9710
  };
9683
9711
 
@@ -10109,13 +10137,13 @@ function addToolInputExamplesMiddleware({
10109
10137
  return {
10110
10138
  specificationVersion: "v3",
10111
10139
  transformParams: async ({ params }) => {
10112
- var _a15;
10113
- if (!((_a15 = params.tools) == null ? void 0 : _a15.length)) {
10140
+ var _a14;
10141
+ if (!((_a14 = params.tools) == null ? void 0 : _a14.length)) {
10114
10142
  return params;
10115
10143
  }
10116
10144
  const transformedTools = params.tools.map((tool2) => {
10117
- var _a16;
10118
- 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)) {
10119
10147
  return tool2;
10120
10148
  }
10121
10149
  const formattedExamples = tool2.inputExamples.map((example, index) => format(example, index)).join("\n");
@@ -10162,7 +10190,7 @@ var doWrap = ({
10162
10190
  modelId,
10163
10191
  providerId
10164
10192
  }) => {
10165
- var _a15, _b, _c;
10193
+ var _a14, _b, _c;
10166
10194
  async function doTransform({
10167
10195
  params,
10168
10196
  type
@@ -10171,7 +10199,7 @@ var doWrap = ({
10171
10199
  }
10172
10200
  return {
10173
10201
  specificationVersion: "v3",
10174
- 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,
10175
10203
  modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
10176
10204
  supportedUrls: (_c = overrideSupportedUrls == null ? void 0 : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
10177
10205
  async doGenerate(params) {
@@ -10218,7 +10246,7 @@ var doWrap2 = ({
10218
10246
  modelId,
10219
10247
  providerId
10220
10248
  }) => {
10221
- var _a15, _b, _c, _d;
10249
+ var _a14, _b, _c, _d;
10222
10250
  async function doTransform({
10223
10251
  params
10224
10252
  }) {
@@ -10226,7 +10254,7 @@ var doWrap2 = ({
10226
10254
  }
10227
10255
  return {
10228
10256
  specificationVersion: "v3",
10229
- 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,
10230
10258
  modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
10231
10259
  maxEmbeddingsPerCall: (_c = overrideMaxEmbeddingsPerCall == null ? void 0 : overrideMaxEmbeddingsPerCall({ model })) != null ? _c : model.maxEmbeddingsPerCall,
10232
10260
  supportsParallelCalls: (_d = overrideSupportsParallelCalls == null ? void 0 : overrideSupportsParallelCalls({ model })) != null ? _d : model.supportsParallelCalls,
@@ -10355,11 +10383,11 @@ function customProvider({
10355
10383
  var experimental_customProvider = customProvider;
10356
10384
 
10357
10385
  // src/registry/no-such-provider-error.ts
10358
- import { AISDKError as AISDKError19, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
10359
- var name14 = "AI_NoSuchProviderError";
10360
- var marker14 = `vercel.ai.error.${name14}`;
10361
- var symbol14 = Symbol.for(marker14);
10362
- 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;
10363
10391
  var NoSuchProviderError = class extends NoSuchModelError3 {
10364
10392
  constructor({
10365
10393
  modelId,
@@ -10368,16 +10396,16 @@ var NoSuchProviderError = class extends NoSuchModelError3 {
10368
10396
  availableProviders,
10369
10397
  message = `No such provider: ${providerId} (available providers: ${availableProviders.join()})`
10370
10398
  }) {
10371
- super({ errorName: name14, modelId, modelType, message });
10372
- this[_a14] = true;
10399
+ super({ errorName: name13, modelId, modelType, message });
10400
+ this[_a13] = true;
10373
10401
  this.providerId = providerId;
10374
10402
  this.availableProviders = availableProviders;
10375
10403
  }
10376
10404
  static isInstance(error) {
10377
- return AISDKError19.hasMarker(error, marker14);
10405
+ return AISDKError18.hasMarker(error, marker13);
10378
10406
  }
10379
10407
  };
10380
- _a14 = symbol14;
10408
+ _a13 = symbol13;
10381
10409
 
10382
10410
  // src/registry/provider-registry.ts
10383
10411
  import {
@@ -10436,10 +10464,10 @@ var DefaultProviderRegistry = class {
10436
10464
  return [id.slice(0, index), id.slice(index + this.separator.length)];
10437
10465
  }
10438
10466
  languageModel(id) {
10439
- var _a15, _b;
10467
+ var _a14, _b;
10440
10468
  const [providerId, modelId] = this.splitId(id, "languageModel");
10441
- let model = (_b = (_a15 = this.getProvider(providerId, "languageModel")).languageModel) == null ? void 0 : _b.call(
10442
- _a15,
10469
+ let model = (_b = (_a14 = this.getProvider(providerId, "languageModel")).languageModel) == null ? void 0 : _b.call(
10470
+ _a14,
10443
10471
  modelId
10444
10472
  );
10445
10473
  if (model == null) {
@@ -10454,10 +10482,10 @@ var DefaultProviderRegistry = class {
10454
10482
  return model;
10455
10483
  }
10456
10484
  embeddingModel(id) {
10457
- var _a15;
10485
+ var _a14;
10458
10486
  const [providerId, modelId] = this.splitId(id, "embeddingModel");
10459
10487
  const provider = this.getProvider(providerId, "embeddingModel");
10460
- 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);
10461
10489
  if (model == null) {
10462
10490
  throw new NoSuchModelError4({
10463
10491
  modelId: id,
@@ -10467,20 +10495,20 @@ var DefaultProviderRegistry = class {
10467
10495
  return model;
10468
10496
  }
10469
10497
  imageModel(id) {
10470
- var _a15;
10498
+ var _a14;
10471
10499
  const [providerId, modelId] = this.splitId(id, "imageModel");
10472
10500
  const provider = this.getProvider(providerId, "imageModel");
10473
- 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);
10474
10502
  if (model == null) {
10475
10503
  throw new NoSuchModelError4({ modelId: id, modelType: "imageModel" });
10476
10504
  }
10477
10505
  return model;
10478
10506
  }
10479
10507
  transcriptionModel(id) {
10480
- var _a15;
10508
+ var _a14;
10481
10509
  const [providerId, modelId] = this.splitId(id, "transcriptionModel");
10482
10510
  const provider = this.getProvider(providerId, "transcriptionModel");
10483
- 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);
10484
10512
  if (model == null) {
10485
10513
  throw new NoSuchModelError4({
10486
10514
  modelId: id,
@@ -10490,20 +10518,20 @@ var DefaultProviderRegistry = class {
10490
10518
  return model;
10491
10519
  }
10492
10520
  speechModel(id) {
10493
- var _a15;
10521
+ var _a14;
10494
10522
  const [providerId, modelId] = this.splitId(id, "speechModel");
10495
10523
  const provider = this.getProvider(providerId, "speechModel");
10496
- 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);
10497
10525
  if (model == null) {
10498
10526
  throw new NoSuchModelError4({ modelId: id, modelType: "speechModel" });
10499
10527
  }
10500
10528
  return model;
10501
10529
  }
10502
10530
  rerankingModel(id) {
10503
- var _a15;
10531
+ var _a14;
10504
10532
  const [providerId, modelId] = this.splitId(id, "rerankingModel");
10505
10533
  const provider = this.getProvider(providerId, "rerankingModel");
10506
- 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);
10507
10535
  if (model == null) {
10508
10536
  throw new NoSuchModelError4({ modelId: id, modelType: "rerankingModel" });
10509
10537
  }
@@ -10560,7 +10588,7 @@ async function rerank({
10560
10588
  }),
10561
10589
  tracer,
10562
10590
  fn: async () => {
10563
- var _a15, _b;
10591
+ var _a14, _b;
10564
10592
  const { ranking, response, providerMetadata, warnings } = await retry(
10565
10593
  () => recordSpan({
10566
10594
  name: "ai.rerank.doRerank",
@@ -10624,7 +10652,7 @@ async function rerank({
10624
10652
  providerMetadata,
10625
10653
  response: {
10626
10654
  id: response == null ? void 0 : response.id,
10627
- 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(),
10628
10656
  modelId: (_b = response == null ? void 0 : response.modelId) != null ? _b : model.modelId,
10629
10657
  headers: response == null ? void 0 : response.headers,
10630
10658
  body: response == null ? void 0 : response.body
@@ -10649,8 +10677,8 @@ var DefaultRerankResult = class {
10649
10677
  import { withUserAgentSuffix as withUserAgentSuffix8 } from "@ai-sdk/provider-utils";
10650
10678
 
10651
10679
  // src/error/no-transcript-generated-error.ts
10652
- import { AISDKError as AISDKError20 } from "@ai-sdk/provider";
10653
- var NoTranscriptGeneratedError = class extends AISDKError20 {
10680
+ import { AISDKError as AISDKError19 } from "@ai-sdk/provider";
10681
+ var NoTranscriptGeneratedError = class extends AISDKError19 {
10654
10682
  constructor(options) {
10655
10683
  super({
10656
10684
  name: "AI_NoTranscriptGeneratedError",
@@ -10684,16 +10712,16 @@ async function transcribe({
10684
10712
  const audioData = audio instanceof URL ? (await download({ url: audio })).data : convertDataContentToUint8Array(audio);
10685
10713
  const result = await retry(
10686
10714
  () => {
10687
- var _a15;
10715
+ var _a14;
10688
10716
  return resolvedModel.doGenerate({
10689
10717
  audio: audioData,
10690
10718
  abortSignal,
10691
10719
  headers: headersWithUserAgent,
10692
10720
  providerOptions,
10693
- mediaType: (_a15 = detectMediaType({
10721
+ mediaType: (_a14 = detectMediaType({
10694
10722
  data: audioData,
10695
10723
  signatures: audioMediaTypeSignatures
10696
- })) != null ? _a15 : "audio/wav"
10724
+ })) != null ? _a14 : "audio/wav"
10697
10725
  });
10698
10726
  }
10699
10727
  );
@@ -10717,14 +10745,14 @@ async function transcribe({
10717
10745
  }
10718
10746
  var DefaultTranscriptionResult = class {
10719
10747
  constructor(options) {
10720
- var _a15;
10748
+ var _a14;
10721
10749
  this.text = options.text;
10722
10750
  this.segments = options.segments;
10723
10751
  this.language = options.language;
10724
10752
  this.durationInSeconds = options.durationInSeconds;
10725
10753
  this.warnings = options.warnings;
10726
10754
  this.responses = options.responses;
10727
- this.providerMetadata = (_a15 = options.providerMetadata) != null ? _a15 : {};
10755
+ this.providerMetadata = (_a14 = options.providerMetadata) != null ? _a14 : {};
10728
10756
  }
10729
10757
  };
10730
10758
 
@@ -10767,7 +10795,7 @@ async function callCompletionApi({
10767
10795
  onError,
10768
10796
  fetch: fetch2 = getOriginalFetch()
10769
10797
  }) {
10770
- var _a15;
10798
+ var _a14;
10771
10799
  try {
10772
10800
  setLoading(true);
10773
10801
  setError(void 0);
@@ -10795,7 +10823,7 @@ async function callCompletionApi({
10795
10823
  });
10796
10824
  if (!response.ok) {
10797
10825
  throw new Error(
10798
- (_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."
10799
10827
  );
10800
10828
  }
10801
10829
  if (!response.body) {
@@ -10881,12 +10909,12 @@ async function convertFileListToFileUIParts(files) {
10881
10909
  }
10882
10910
  return Promise.all(
10883
10911
  Array.from(files).map(async (file) => {
10884
- const { name: name15, type } = file;
10912
+ const { name: name14, type } = file;
10885
10913
  const dataUrl = await new Promise((resolve3, reject) => {
10886
10914
  const reader = new FileReader();
10887
10915
  reader.onload = (readerEvent) => {
10888
- var _a15;
10889
- resolve3((_a15 = readerEvent.target) == null ? void 0 : _a15.result);
10916
+ var _a14;
10917
+ resolve3((_a14 = readerEvent.target) == null ? void 0 : _a14.result);
10890
10918
  };
10891
10919
  reader.onerror = (error) => reject(error);
10892
10920
  reader.readAsDataURL(file);
@@ -10894,7 +10922,7 @@ async function convertFileListToFileUIParts(files) {
10894
10922
  return {
10895
10923
  type: "file",
10896
10924
  mediaType: type,
10897
- filename: name15,
10925
+ filename: name14,
10898
10926
  url: dataUrl
10899
10927
  };
10900
10928
  })
@@ -10933,7 +10961,7 @@ var HttpChatTransport = class {
10933
10961
  abortSignal,
10934
10962
  ...options
10935
10963
  }) {
10936
- var _a15, _b, _c, _d, _e;
10964
+ var _a14, _b, _c, _d, _e;
10937
10965
  const resolvedBody = await resolve2(this.body);
10938
10966
  const resolvedHeaders = await resolve2(this.headers);
10939
10967
  const resolvedCredentials = await resolve2(this.credentials);
@@ -10941,7 +10969,7 @@ var HttpChatTransport = class {
10941
10969
  ...normalizeHeaders(resolvedHeaders),
10942
10970
  ...normalizeHeaders(options.headers)
10943
10971
  };
10944
- 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, {
10945
10973
  api: this.api,
10946
10974
  id: options.chatId,
10947
10975
  messages: options.messages,
@@ -10989,7 +11017,7 @@ var HttpChatTransport = class {
10989
11017
  return this.processResponseStream(response.body);
10990
11018
  }
10991
11019
  async reconnectToStream(options) {
10992
- var _a15, _b, _c, _d, _e;
11020
+ var _a14, _b, _c, _d, _e;
10993
11021
  const resolvedBody = await resolve2(this.body);
10994
11022
  const resolvedHeaders = await resolve2(this.headers);
10995
11023
  const resolvedCredentials = await resolve2(this.credentials);
@@ -10997,7 +11025,7 @@ var HttpChatTransport = class {
10997
11025
  ...normalizeHeaders(resolvedHeaders),
10998
11026
  ...normalizeHeaders(options.headers)
10999
11027
  };
11000
- 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, {
11001
11029
  api: this.api,
11002
11030
  id: options.chatId,
11003
11031
  body: { ...resolvedBody, ...options.body },
@@ -11079,11 +11107,11 @@ var AbstractChat = class {
11079
11107
  * If a messageId is provided, the message will be replaced.
11080
11108
  */
11081
11109
  this.sendMessage = async (message, options) => {
11082
- var _a15, _b, _c, _d;
11110
+ var _a14, _b, _c, _d;
11083
11111
  if (message == null) {
11084
11112
  await this.makeRequest({
11085
11113
  trigger: "submit-message",
11086
- messageId: (_a15 = this.lastMessage) == null ? void 0 : _a15.id,
11114
+ messageId: (_a14 = this.lastMessage) == null ? void 0 : _a14.id,
11087
11115
  ...options
11088
11116
  });
11089
11117
  return;
@@ -11176,7 +11204,7 @@ var AbstractChat = class {
11176
11204
  approved,
11177
11205
  reason
11178
11206
  }) => this.jobExecutor.run(async () => {
11179
- var _a15, _b;
11207
+ var _a14, _b;
11180
11208
  const messages = this.state.messages;
11181
11209
  const lastMessage = messages[messages.length - 1];
11182
11210
  const updatePart = (part) => isToolUIPart(part) && part.state === "approval-requested" && part.approval.id === id ? {
@@ -11191,7 +11219,7 @@ var AbstractChat = class {
11191
11219
  if (this.activeResponse) {
11192
11220
  this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(updatePart);
11193
11221
  }
11194
- 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 }))) {
11195
11223
  this.makeRequest({
11196
11224
  trigger: "submit-message",
11197
11225
  messageId: (_b = this.lastMessage) == null ? void 0 : _b.id
@@ -11205,7 +11233,7 @@ var AbstractChat = class {
11205
11233
  output,
11206
11234
  errorText
11207
11235
  }) => this.jobExecutor.run(async () => {
11208
- var _a15, _b;
11236
+ var _a14, _b;
11209
11237
  const messages = this.state.messages;
11210
11238
  const lastMessage = messages[messages.length - 1];
11211
11239
  const updatePart = (part) => isToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state, output, errorText } : part;
@@ -11216,7 +11244,7 @@ var AbstractChat = class {
11216
11244
  if (this.activeResponse) {
11217
11245
  this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(updatePart);
11218
11246
  }
11219
- 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 }))) {
11220
11248
  this.makeRequest({
11221
11249
  trigger: "submit-message",
11222
11250
  messageId: (_b = this.lastMessage) == null ? void 0 : _b.id
@@ -11229,10 +11257,10 @@ var AbstractChat = class {
11229
11257
  * Abort the current request immediately, keep the generated tokens if any.
11230
11258
  */
11231
11259
  this.stop = async () => {
11232
- var _a15;
11260
+ var _a14;
11233
11261
  if (this.status !== "streaming" && this.status !== "submitted")
11234
11262
  return;
11235
- if ((_a15 = this.activeResponse) == null ? void 0 : _a15.abortController) {
11263
+ if ((_a14 = this.activeResponse) == null ? void 0 : _a14.abortController) {
11236
11264
  this.activeResponse.abortController.abort();
11237
11265
  }
11238
11266
  };
@@ -11287,7 +11315,7 @@ var AbstractChat = class {
11287
11315
  body,
11288
11316
  messageId
11289
11317
  }) {
11290
- var _a15, _b, _c, _d;
11318
+ var _a14, _b, _c, _d;
11291
11319
  this.setStatus({ status: "submitted", error: void 0 });
11292
11320
  const lastMessage = this.lastMessage;
11293
11321
  let isAbort = false;
@@ -11336,9 +11364,9 @@ var AbstractChat = class {
11336
11364
  () => job({
11337
11365
  state: activeResponse.state,
11338
11366
  write: () => {
11339
- var _a16;
11367
+ var _a15;
11340
11368
  this.setStatus({ status: "streaming" });
11341
- 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);
11342
11370
  if (replaceLastMessage) {
11343
11371
  this.state.replaceMessage(
11344
11372
  this.state.messages.length - 1,
@@ -11390,7 +11418,7 @@ var AbstractChat = class {
11390
11418
  isAbort,
11391
11419
  isDisconnect,
11392
11420
  isError,
11393
- finishReason: (_a15 = this.activeResponse) == null ? void 0 : _a15.state.finishReason
11421
+ finishReason: (_a14 = this.activeResponse) == null ? void 0 : _a14.state.finishReason
11394
11422
  });
11395
11423
  } catch (err) {
11396
11424
  console.error(err);
@@ -11488,7 +11516,7 @@ var TextStreamChatTransport = class extends HttpChatTransport {
11488
11516
  }
11489
11517
  };
11490
11518
  export {
11491
- AISDKError16 as AISDKError,
11519
+ AISDKError15 as AISDKError,
11492
11520
  APICallError,
11493
11521
  AbstractChat,
11494
11522
  DefaultChatTransport,
@@ -11551,12 +11579,13 @@ export {
11551
11579
  embedMany,
11552
11580
  experimental_createProviderRegistry,
11553
11581
  experimental_customProvider,
11554
- generateImage as experimental_generateImage,
11582
+ experimental_generateImage,
11555
11583
  generateSpeech as experimental_generateSpeech,
11556
11584
  transcribe as experimental_transcribe,
11557
11585
  extractReasoningMiddleware,
11558
11586
  gateway2 as gateway,
11559
11587
  generateId,
11588
+ generateImage,
11560
11589
  generateObject,
11561
11590
  generateText,
11562
11591
  getStaticToolName,