ai 5.0.44 → 5.0.46

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.js CHANGED
@@ -58,7 +58,7 @@ __export(src_exports, {
58
58
  UI_MESSAGE_STREAM_HEADERS: () => UI_MESSAGE_STREAM_HEADERS,
59
59
  UnsupportedFunctionalityError: () => import_provider17.UnsupportedFunctionalityError,
60
60
  UnsupportedModelVersionError: () => UnsupportedModelVersionError,
61
- asSchema: () => import_provider_utils34.asSchema,
61
+ asSchema: () => import_provider_utils35.asSchema,
62
62
  assistantModelMessageSchema: () => assistantModelMessageSchema,
63
63
  callCompletionApi: () => callCompletionApi,
64
64
  consumeStream: () => consumeStream,
@@ -72,14 +72,14 @@ __export(src_exports, {
72
72
  coreUserMessageSchema: () => coreUserMessageSchema,
73
73
  cosineSimilarity: () => cosineSimilarity,
74
74
  createGateway: () => import_gateway3.createGateway,
75
- createIdGenerator: () => import_provider_utils34.createIdGenerator,
75
+ createIdGenerator: () => import_provider_utils35.createIdGenerator,
76
76
  createProviderRegistry: () => createProviderRegistry,
77
77
  createTextStreamResponse: () => createTextStreamResponse,
78
78
  createUIMessageStream: () => createUIMessageStream,
79
79
  createUIMessageStreamResponse: () => createUIMessageStreamResponse,
80
80
  customProvider: () => customProvider,
81
81
  defaultSettingsMiddleware: () => defaultSettingsMiddleware,
82
- dynamicTool: () => import_provider_utils34.dynamicTool,
82
+ dynamicTool: () => import_provider_utils35.dynamicTool,
83
83
  embed: () => embed,
84
84
  embedMany: () => embedMany,
85
85
  experimental_createMCPClient: () => createMCPClient,
@@ -90,7 +90,7 @@ __export(src_exports, {
90
90
  experimental_transcribe: () => transcribe,
91
91
  extractReasoningMiddleware: () => extractReasoningMiddleware,
92
92
  gateway: () => import_gateway3.gateway,
93
- generateId: () => import_provider_utils34.generateId,
93
+ generateId: () => import_provider_utils35.generateId,
94
94
  generateObject: () => generateObject,
95
95
  generateText: () => generateText,
96
96
  getTextFromDataUrl: () => getTextFromDataUrl,
@@ -100,13 +100,14 @@ __export(src_exports, {
100
100
  isDeepEqualData: () => isDeepEqualData,
101
101
  isToolOrDynamicToolUIPart: () => isToolOrDynamicToolUIPart,
102
102
  isToolUIPart: () => isToolUIPart,
103
- jsonSchema: () => import_provider_utils34.jsonSchema,
103
+ jsonSchema: () => import_provider_utils35.jsonSchema,
104
104
  lastAssistantMessageIsCompleteWithToolCalls: () => lastAssistantMessageIsCompleteWithToolCalls,
105
105
  modelMessageSchema: () => modelMessageSchema,
106
106
  parsePartialJson: () => parsePartialJson,
107
107
  pipeTextStreamToResponse: () => pipeTextStreamToResponse,
108
108
  pipeUIMessageStreamToResponse: () => pipeUIMessageStreamToResponse,
109
109
  readUIMessageStream: () => readUIMessageStream,
110
+ safeValidateUIMessages: () => safeValidateUIMessages,
110
111
  simulateReadableStream: () => simulateReadableStream,
111
112
  simulateStreamingMiddleware: () => simulateStreamingMiddleware,
112
113
  smoothStream: () => smoothStream,
@@ -114,20 +115,20 @@ __export(src_exports, {
114
115
  streamObject: () => streamObject,
115
116
  streamText: () => streamText,
116
117
  systemModelMessageSchema: () => systemModelMessageSchema,
117
- tool: () => import_provider_utils34.tool,
118
+ tool: () => import_provider_utils35.tool,
118
119
  toolModelMessageSchema: () => toolModelMessageSchema,
119
120
  userModelMessageSchema: () => userModelMessageSchema,
120
121
  validateUIMessages: () => validateUIMessages,
121
122
  wrapLanguageModel: () => wrapLanguageModel,
122
123
  wrapProvider: () => wrapProvider,
123
- zodSchema: () => import_provider_utils34.zodSchema
124
+ zodSchema: () => import_provider_utils35.zodSchema
124
125
  });
125
126
  module.exports = __toCommonJS(src_exports);
126
127
  var import_gateway3 = require("@ai-sdk/gateway");
127
- var import_provider_utils34 = require("@ai-sdk/provider-utils");
128
+ var import_provider_utils35 = require("@ai-sdk/provider-utils");
128
129
 
129
130
  // src/generate-text/generate-text.ts
130
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
131
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
131
132
 
132
133
  // src/error/no-output-specified-error.ts
133
134
  var import_provider = require("@ai-sdk/provider");
@@ -574,45 +575,57 @@ function getGlobalProvider() {
574
575
  }
575
576
 
576
577
  // src/prompt/convert-to-language-model-prompt.ts
577
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
578
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
578
579
 
579
580
  // src/util/detect-media-type.ts
580
581
  var import_provider_utils = require("@ai-sdk/provider-utils");
581
582
  var imageMediaTypeSignatures = [
582
583
  {
583
584
  mediaType: "image/gif",
584
- bytesPrefix: [71, 73, 70],
585
- base64Prefix: "R0lG"
585
+ bytesPrefix: [71, 73, 70]
586
+ // GIF
586
587
  },
587
588
  {
588
589
  mediaType: "image/png",
589
- bytesPrefix: [137, 80, 78, 71],
590
- base64Prefix: "iVBORw"
590
+ bytesPrefix: [137, 80, 78, 71]
591
+ // PNG
591
592
  },
592
593
  {
593
594
  mediaType: "image/jpeg",
594
- bytesPrefix: [255, 216],
595
- base64Prefix: "/9j/"
595
+ bytesPrefix: [255, 216]
596
+ // JPEG
596
597
  },
597
598
  {
598
599
  mediaType: "image/webp",
599
- bytesPrefix: [82, 73, 70, 70],
600
- base64Prefix: "UklGRg"
600
+ bytesPrefix: [
601
+ 82,
602
+ 73,
603
+ 70,
604
+ 70,
605
+ // "RIFF"
606
+ null,
607
+ null,
608
+ null,
609
+ null,
610
+ // file size (variable)
611
+ 87,
612
+ 69,
613
+ 66,
614
+ 80
615
+ // "WEBP"
616
+ ]
601
617
  },
602
618
  {
603
619
  mediaType: "image/bmp",
604
- bytesPrefix: [66, 77],
605
- base64Prefix: "Qk"
620
+ bytesPrefix: [66, 77]
606
621
  },
607
622
  {
608
623
  mediaType: "image/tiff",
609
- bytesPrefix: [73, 73, 42, 0],
610
- base64Prefix: "SUkqAA"
624
+ bytesPrefix: [73, 73, 42, 0]
611
625
  },
612
626
  {
613
627
  mediaType: "image/tiff",
614
- bytesPrefix: [77, 77, 0, 42],
615
- base64Prefix: "TU0AKg"
628
+ bytesPrefix: [77, 77, 0, 42]
616
629
  },
617
630
  {
618
631
  mediaType: "image/avif",
@@ -629,8 +642,7 @@ var imageMediaTypeSignatures = [
629
642
  118,
630
643
  105,
631
644
  102
632
- ],
633
- base64Prefix: "AAAAIGZ0eXBhdmlm"
645
+ ]
634
646
  },
635
647
  {
636
648
  mediaType: "image/heic",
@@ -647,70 +659,78 @@ var imageMediaTypeSignatures = [
647
659
  101,
648
660
  105,
649
661
  99
650
- ],
651
- base64Prefix: "AAAAIGZ0eXBoZWlj"
662
+ ]
652
663
  }
653
664
  ];
654
665
  var audioMediaTypeSignatures = [
655
666
  {
656
667
  mediaType: "audio/mpeg",
657
- bytesPrefix: [255, 251],
658
- base64Prefix: "//s="
668
+ bytesPrefix: [255, 251]
659
669
  },
660
670
  {
661
671
  mediaType: "audio/mpeg",
662
- bytesPrefix: [255, 250],
663
- base64Prefix: "//o="
672
+ bytesPrefix: [255, 250]
664
673
  },
665
674
  {
666
675
  mediaType: "audio/mpeg",
667
- bytesPrefix: [255, 243],
668
- base64Prefix: "//M="
676
+ bytesPrefix: [255, 243]
669
677
  },
670
678
  {
671
679
  mediaType: "audio/mpeg",
672
- bytesPrefix: [255, 242],
673
- base64Prefix: "//I="
680
+ bytesPrefix: [255, 242]
674
681
  },
675
682
  {
676
683
  mediaType: "audio/mpeg",
677
- bytesPrefix: [255, 227],
678
- base64Prefix: "/+M="
684
+ bytesPrefix: [255, 227]
679
685
  },
680
686
  {
681
687
  mediaType: "audio/mpeg",
682
- bytesPrefix: [255, 226],
683
- base64Prefix: "/+I="
688
+ bytesPrefix: [255, 226]
684
689
  },
685
690
  {
686
691
  mediaType: "audio/wav",
687
- bytesPrefix: [82, 73, 70, 70],
688
- base64Prefix: "UklGR"
692
+ bytesPrefix: [
693
+ 82,
694
+ // R
695
+ 73,
696
+ // I
697
+ 70,
698
+ // F
699
+ 70,
700
+ // F
701
+ null,
702
+ null,
703
+ null,
704
+ null,
705
+ 87,
706
+ // W
707
+ 65,
708
+ // A
709
+ 86,
710
+ // V
711
+ 69
712
+ // E
713
+ ]
689
714
  },
690
715
  {
691
716
  mediaType: "audio/ogg",
692
- bytesPrefix: [79, 103, 103, 83],
693
- base64Prefix: "T2dnUw"
717
+ bytesPrefix: [79, 103, 103, 83]
694
718
  },
695
719
  {
696
720
  mediaType: "audio/flac",
697
- bytesPrefix: [102, 76, 97, 67],
698
- base64Prefix: "ZkxhQw"
721
+ bytesPrefix: [102, 76, 97, 67]
699
722
  },
700
723
  {
701
724
  mediaType: "audio/aac",
702
- bytesPrefix: [64, 21, 0, 0],
703
- base64Prefix: "QBUA"
725
+ bytesPrefix: [64, 21, 0, 0]
704
726
  },
705
727
  {
706
728
  mediaType: "audio/mp4",
707
- bytesPrefix: [102, 116, 121, 112],
708
- base64Prefix: "ZnR5cA"
729
+ bytesPrefix: [102, 116, 121, 112]
709
730
  },
710
731
  {
711
732
  mediaType: "audio/webm",
712
- bytesPrefix: [26, 69, 223, 163],
713
- base64Prefix: "GkXf"
733
+ bytesPrefix: [26, 69, 223, 163]
714
734
  }
715
735
  ];
716
736
  var stripID3 = (data) => {
@@ -729,9 +749,12 @@ function detectMediaType({
729
749
  signatures
730
750
  }) {
731
751
  const processedData = stripID3TagsIfPresent(data);
752
+ const bytes = typeof processedData === "string" ? (0, import_provider_utils.convertBase64ToUint8Array)(
753
+ processedData.substring(0, Math.min(processedData.length, 24))
754
+ ) : processedData;
732
755
  for (const signature of signatures) {
733
- if (typeof processedData === "string" ? processedData.startsWith(signature.base64Prefix) : processedData.length >= signature.bytesPrefix.length && signature.bytesPrefix.every(
734
- (byte, index) => processedData[index] === byte
756
+ if (bytes.length >= signature.bytesPrefix.length && signature.bytesPrefix.every(
757
+ (byte, index) => byte === null || bytes[index] === byte
735
758
  )) {
736
759
  return signature.mediaType;
737
760
  }
@@ -739,12 +762,24 @@ function detectMediaType({
739
762
  return void 0;
740
763
  }
741
764
 
765
+ // src/util/download/download.ts
766
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
767
+
768
+ // src/version.ts
769
+ var VERSION = true ? "5.0.46" : "0.0.0-test";
770
+
742
771
  // src/util/download/download.ts
743
772
  var download = async ({ url }) => {
744
773
  var _a17;
745
774
  const urlText = url.toString();
746
775
  try {
747
- const response = await fetch(urlText);
776
+ const response = await fetch(urlText, {
777
+ headers: (0, import_provider_utils2.withUserAgentSuffix)(
778
+ {},
779
+ `ai-sdk/${VERSION}`,
780
+ (0, import_provider_utils2.getRuntimeEnvironmentUserAgent)()
781
+ )
782
+ });
748
783
  if (!response.ok) {
749
784
  throw new DownloadError({
750
785
  url: urlText,
@@ -773,7 +808,7 @@ var createDefaultDownloadFunction = (download2 = download) => (requestedDownload
773
808
 
774
809
  // src/prompt/data-content.ts
775
810
  var import_provider18 = require("@ai-sdk/provider");
776
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
811
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
777
812
  var import_v4 = require("zod/v4");
778
813
 
779
814
  // src/prompt/split-data-url.ts
@@ -838,9 +873,9 @@ function convertDataContentToBase64String(content) {
838
873
  return content;
839
874
  }
840
875
  if (content instanceof ArrayBuffer) {
841
- return (0, import_provider_utils2.convertUint8ArrayToBase64)(new Uint8Array(content));
876
+ return (0, import_provider_utils3.convertUint8ArrayToBase64)(new Uint8Array(content));
842
877
  }
843
- return (0, import_provider_utils2.convertUint8ArrayToBase64)(content);
878
+ return (0, import_provider_utils3.convertUint8ArrayToBase64)(content);
844
879
  }
845
880
  function convertDataContentToUint8Array(content) {
846
881
  if (content instanceof Uint8Array) {
@@ -848,7 +883,7 @@ function convertDataContentToUint8Array(content) {
848
883
  }
849
884
  if (typeof content === "string") {
850
885
  try {
851
- return (0, import_provider_utils2.convertBase64ToUint8Array)(content);
886
+ return (0, import_provider_utils3.convertBase64ToUint8Array)(content);
852
887
  } catch (error) {
853
888
  throw new InvalidDataContentError({
854
889
  message: "Invalid data content. Content string is not a base64-encoded media.",
@@ -919,8 +954,8 @@ function convertToLanguageModelMessage({
919
954
  return {
920
955
  role: "assistant",
921
956
  content: message.content.filter(
922
- // remove empty text parts:
923
- (part) => part.type !== "text" || part.text !== ""
957
+ // remove empty text parts (no text, and no provider options):
958
+ (part) => part.type !== "text" || part.text !== "" || part.providerOptions != null
924
959
  ).map((part) => {
925
960
  const providerOptions = part.providerOptions;
926
961
  switch (part.type) {
@@ -1013,7 +1048,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
1013
1048
  (part) => part.data instanceof URL
1014
1049
  ).map((part) => ({
1015
1050
  url: part.data,
1016
- isUrlSupportedByModel: part.mediaType != null && (0, import_provider_utils3.isUrlSupported)({
1051
+ isUrlSupportedByModel: part.mediaType != null && (0, import_provider_utils4.isUrlSupported)({
1017
1052
  url: part.data.toString(),
1018
1053
  mediaType: part.mediaType,
1019
1054
  supportedUrls
@@ -1183,7 +1218,7 @@ function prepareCallSettings({
1183
1218
  }
1184
1219
 
1185
1220
  // src/prompt/prepare-tools-and-tool-choice.ts
1186
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
1221
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
1187
1222
 
1188
1223
  // src/util/is-non-empty-object.ts
1189
1224
  function isNonEmptyObject(object2) {
@@ -1216,7 +1251,7 @@ function prepareToolsAndToolChoice({
1216
1251
  type: "function",
1217
1252
  name: name17,
1218
1253
  description: tool3.description,
1219
- inputSchema: (0, import_provider_utils4.asSchema)(tool3.inputSchema).jsonSchema,
1254
+ inputSchema: (0, import_provider_utils5.asSchema)(tool3.inputSchema).jsonSchema,
1220
1255
  providerOptions: tool3.providerOptions
1221
1256
  };
1222
1257
  case "provider-defined":
@@ -1238,7 +1273,7 @@ function prepareToolsAndToolChoice({
1238
1273
 
1239
1274
  // src/prompt/standardize-prompt.ts
1240
1275
  var import_provider19 = require("@ai-sdk/provider");
1241
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
1276
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
1242
1277
  var import_v46 = require("zod/v4");
1243
1278
 
1244
1279
  // src/prompt/message.ts
@@ -1429,7 +1464,7 @@ async function standardizePrompt(prompt) {
1429
1464
  message: "messages must not be empty"
1430
1465
  });
1431
1466
  }
1432
- const validationResult = await (0, import_provider_utils5.safeValidateTypes)({
1467
+ const validationResult = await (0, import_provider_utils6.safeValidateTypes)({
1433
1468
  value: messages,
1434
1469
  schema: import_v46.z.array(modelMessageSchema)
1435
1470
  });
@@ -1698,7 +1733,7 @@ function asArray(value) {
1698
1733
 
1699
1734
  // src/util/retry-with-exponential-backoff.ts
1700
1735
  var import_provider21 = require("@ai-sdk/provider");
1701
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1736
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1702
1737
  function getRetryDelayInMs({
1703
1738
  error,
1704
1739
  exponentialBackoffDelay
@@ -1748,13 +1783,13 @@ async function _retryWithExponentialBackoff(f, {
1748
1783
  try {
1749
1784
  return await f();
1750
1785
  } catch (error) {
1751
- if ((0, import_provider_utils6.isAbortError)(error)) {
1786
+ if ((0, import_provider_utils7.isAbortError)(error)) {
1752
1787
  throw error;
1753
1788
  }
1754
1789
  if (maxRetries === 0) {
1755
1790
  throw error;
1756
1791
  }
1757
- const errorMessage = (0, import_provider_utils6.getErrorMessage)(error);
1792
+ const errorMessage = (0, import_provider_utils7.getErrorMessage)(error);
1758
1793
  const newErrors = [...errors, error];
1759
1794
  const tryNumber = newErrors.length;
1760
1795
  if (tryNumber > maxRetries) {
@@ -1765,7 +1800,7 @@ async function _retryWithExponentialBackoff(f, {
1765
1800
  });
1766
1801
  }
1767
1802
  if (error instanceof Error && import_provider21.APICallError.isInstance(error) && error.isRetryable === true && tryNumber <= maxRetries) {
1768
- await (0, import_provider_utils6.delay)(
1803
+ await (0, import_provider_utils7.delay)(
1769
1804
  getRetryDelayInMs({
1770
1805
  error,
1771
1806
  exponentialBackoffDelay: delayInMs
@@ -1837,7 +1872,7 @@ function extractTextContent(content) {
1837
1872
  }
1838
1873
 
1839
1874
  // src/generate-text/generated-file.ts
1840
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1875
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1841
1876
  var DefaultGeneratedFile = class {
1842
1877
  constructor({
1843
1878
  data,
@@ -1851,14 +1886,14 @@ var DefaultGeneratedFile = class {
1851
1886
  // lazy conversion with caching to avoid unnecessary conversion overhead:
1852
1887
  get base64() {
1853
1888
  if (this.base64Data == null) {
1854
- this.base64Data = (0, import_provider_utils7.convertUint8ArrayToBase64)(this.uint8ArrayData);
1889
+ this.base64Data = (0, import_provider_utils8.convertUint8ArrayToBase64)(this.uint8ArrayData);
1855
1890
  }
1856
1891
  return this.base64Data;
1857
1892
  }
1858
1893
  // lazy conversion with caching to avoid unnecessary conversion overhead:
1859
1894
  get uint8Array() {
1860
1895
  if (this.uint8ArrayData == null) {
1861
- this.uint8ArrayData = (0, import_provider_utils7.convertBase64ToUint8Array)(this.base64Data);
1896
+ this.uint8ArrayData = (0, import_provider_utils8.convertBase64ToUint8Array)(this.base64Data);
1862
1897
  }
1863
1898
  return this.uint8ArrayData;
1864
1899
  }
@@ -1871,7 +1906,7 @@ var DefaultGeneratedFileWithType = class extends DefaultGeneratedFile {
1871
1906
  };
1872
1907
 
1873
1908
  // src/generate-text/parse-tool-call.ts
1874
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1909
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1875
1910
  async function parseToolCall({
1876
1911
  toolCall,
1877
1912
  tools,
@@ -1896,7 +1931,7 @@ async function parseToolCall({
1896
1931
  tools,
1897
1932
  inputSchema: ({ toolName }) => {
1898
1933
  const { inputSchema } = tools[toolName];
1899
- return (0, import_provider_utils8.asSchema)(inputSchema).jsonSchema;
1934
+ return (0, import_provider_utils9.asSchema)(inputSchema).jsonSchema;
1900
1935
  },
1901
1936
  system,
1902
1937
  messages,
@@ -1914,7 +1949,7 @@ async function parseToolCall({
1914
1949
  return await doParseToolCall({ toolCall: repairedToolCall, tools });
1915
1950
  }
1916
1951
  } catch (error) {
1917
- const parsedInput = await (0, import_provider_utils8.safeParseJSON)({ text: toolCall.input });
1952
+ const parsedInput = await (0, import_provider_utils9.safeParseJSON)({ text: toolCall.input });
1918
1953
  const input = parsedInput.success ? parsedInput.value : toolCall.input;
1919
1954
  return {
1920
1955
  type: "tool-call",
@@ -1939,8 +1974,8 @@ async function doParseToolCall({
1939
1974
  availableTools: Object.keys(tools)
1940
1975
  });
1941
1976
  }
1942
- const schema = (0, import_provider_utils8.asSchema)(tool3.inputSchema);
1943
- const parseResult = toolCall.input.trim() === "" ? await (0, import_provider_utils8.safeValidateTypes)({ value: {}, schema }) : await (0, import_provider_utils8.safeParseJSON)({ text: toolCall.input, schema });
1977
+ const schema = (0, import_provider_utils9.asSchema)(tool3.inputSchema);
1978
+ const parseResult = toolCall.input.trim() === "" ? await (0, import_provider_utils9.safeValidateTypes)({ value: {}, schema }) : await (0, import_provider_utils9.safeParseJSON)({ text: toolCall.input, schema });
1944
1979
  if (parseResult.success === false) {
1945
1980
  throw new InvalidToolInputError({
1946
1981
  toolName,
@@ -2005,7 +2040,7 @@ var DefaultStepResult = class {
2005
2040
  }
2006
2041
  get staticToolCalls() {
2007
2042
  return this.toolCalls.filter(
2008
- (toolCall) => toolCall.dynamic === false
2043
+ (toolCall) => toolCall.dynamic !== true
2009
2044
  );
2010
2045
  }
2011
2046
  get dynamicToolCalls() {
@@ -2018,7 +2053,7 @@ var DefaultStepResult = class {
2018
2053
  }
2019
2054
  get staticToolResults() {
2020
2055
  return this.toolResults.filter(
2021
- (toolResult) => toolResult.dynamic === false
2056
+ (toolResult) => toolResult.dynamic !== true
2022
2057
  );
2023
2058
  }
2024
2059
  get dynamicToolResults() {
@@ -2158,11 +2193,8 @@ function toResponseMessages({
2158
2193
  return responseMessages;
2159
2194
  }
2160
2195
 
2161
- // src/version.ts
2162
- var VERSION = true ? "5.0.44" : "0.0.0-test";
2163
-
2164
2196
  // src/generate-text/generate-text.ts
2165
- var originalGenerateId = (0, import_provider_utils9.createIdGenerator)({
2197
+ var originalGenerateId = (0, import_provider_utils10.createIdGenerator)({
2166
2198
  prefix: "aitxt",
2167
2199
  size: 24
2168
2200
  });
@@ -2201,7 +2233,7 @@ async function generateText({
2201
2233
  abortSignal
2202
2234
  });
2203
2235
  const callSettings = prepareCallSettings(settings);
2204
- const headersWithUserAgent = (0, import_provider_utils9.withUserAgentSuffix)(
2236
+ const headersWithUserAgent = (0, import_provider_utils10.withUserAgentSuffix)(
2205
2237
  headers != null ? headers : {},
2206
2238
  `ai/${VERSION}`
2207
2239
  );
@@ -2407,7 +2439,7 @@ async function generateText({
2407
2439
  toolCallId: toolCall.toolCallId,
2408
2440
  toolName: toolCall.toolName,
2409
2441
  input: toolCall.input,
2410
- error: (0, import_provider_utils9.getErrorMessage)(toolCall.error),
2442
+ error: (0, import_provider_utils10.getErrorMessage)(toolCall.error),
2411
2443
  dynamic: true
2412
2444
  });
2413
2445
  }
@@ -2537,7 +2569,7 @@ async function executeTools({
2537
2569
  tracer,
2538
2570
  fn: async (span) => {
2539
2571
  try {
2540
- const stream = (0, import_provider_utils9.executeTool)({
2572
+ const stream = (0, import_provider_utils10.executeTool)({
2541
2573
  execute: tool3.execute.bind(tool3),
2542
2574
  input,
2543
2575
  options: {
@@ -2748,7 +2780,7 @@ function asContent({
2748
2780
 
2749
2781
  // src/generate-text/stream-text.ts
2750
2782
  var import_provider23 = require("@ai-sdk/provider");
2751
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
2783
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
2752
2784
 
2753
2785
  // src/util/prepare-headers.ts
2754
2786
  function prepareHeaders(headers, defaultHeaders) {
@@ -2885,7 +2917,7 @@ function getResponseUIMessageId({
2885
2917
  }
2886
2918
 
2887
2919
  // src/ui/process-ui-message-stream.ts
2888
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
2920
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
2889
2921
 
2890
2922
  // src/ui-message-stream/ui-message-chunks.ts
2891
2923
  var import_v47 = require("zod/v4");
@@ -3068,7 +3100,7 @@ function mergeObjects(base, overrides) {
3068
3100
  }
3069
3101
 
3070
3102
  // src/util/parse-partial-json.ts
3071
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
3103
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
3072
3104
 
3073
3105
  // src/util/fix-json.ts
3074
3106
  function fixJson(input) {
@@ -3393,11 +3425,11 @@ async function parsePartialJson(jsonText) {
3393
3425
  if (jsonText === void 0) {
3394
3426
  return { value: void 0, state: "undefined-input" };
3395
3427
  }
3396
- let result = await (0, import_provider_utils10.safeParseJSON)({ text: jsonText });
3428
+ let result = await (0, import_provider_utils11.safeParseJSON)({ text: jsonText });
3397
3429
  if (result.success) {
3398
3430
  return { value: result.value, state: "successful-parse" };
3399
3431
  }
3400
- result = await (0, import_provider_utils10.safeParseJSON)({ text: fixJson(jsonText) });
3432
+ result = await (0, import_provider_utils11.safeParseJSON)({ text: fixJson(jsonText) });
3401
3433
  if (result.success) {
3402
3434
  return { value: result.value, state: "repaired-parse" };
3403
3435
  }
@@ -3547,7 +3579,7 @@ function processUIMessageStream({
3547
3579
  if (metadata != null) {
3548
3580
  const mergedMetadata = state.message.metadata != null ? mergeObjects(state.message.metadata, metadata) : metadata;
3549
3581
  if (messageMetadataSchema != null) {
3550
- await (0, import_provider_utils11.validateTypes)({
3582
+ await (0, import_provider_utils12.validateTypes)({
3551
3583
  value: mergedMetadata,
3552
3584
  schema: messageMetadataSchema
3553
3585
  });
@@ -3839,7 +3871,7 @@ function processUIMessageStream({
3839
3871
  default: {
3840
3872
  if (isDataUIMessageChunk(chunk)) {
3841
3873
  if ((dataPartSchemas == null ? void 0 : dataPartSchemas[chunk.type]) != null) {
3842
- await (0, import_provider_utils11.validateTypes)({
3874
+ await (0, import_provider_utils12.validateTypes)({
3843
3875
  value: chunk.data,
3844
3876
  schema: dataPartSchemas[chunk.type]
3845
3877
  });
@@ -4195,7 +4227,7 @@ function now() {
4195
4227
  }
4196
4228
 
4197
4229
  // src/generate-text/run-tools-transformation.ts
4198
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
4230
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
4199
4231
  function runToolsTransformation({
4200
4232
  tools,
4201
4233
  generatorStream,
@@ -4281,7 +4313,7 @@ function runToolsTransformation({
4281
4313
  toolCallId: toolCall.toolCallId,
4282
4314
  toolName: toolCall.toolName,
4283
4315
  input: toolCall.input,
4284
- error: (0, import_provider_utils12.getErrorMessage)(toolCall.error),
4316
+ error: (0, import_provider_utils13.getErrorMessage)(toolCall.error),
4285
4317
  dynamic: true
4286
4318
  });
4287
4319
  break;
@@ -4298,7 +4330,7 @@ function runToolsTransformation({
4298
4330
  });
4299
4331
  }
4300
4332
  if (tool3.execute != null && toolCall.providerExecuted !== true) {
4301
- const toolExecutionId = (0, import_provider_utils12.generateId)();
4333
+ const toolExecutionId = (0, import_provider_utils13.generateId)();
4302
4334
  outstandingToolResults.add(toolExecutionId);
4303
4335
  recordSpan({
4304
4336
  name: "ai.toolCall",
@@ -4320,7 +4352,7 @@ function runToolsTransformation({
4320
4352
  fn: async (span) => {
4321
4353
  let output;
4322
4354
  try {
4323
- const stream = (0, import_provider_utils12.executeTool)({
4355
+ const stream = (0, import_provider_utils13.executeTool)({
4324
4356
  execute: tool3.execute.bind(tool3),
4325
4357
  input: toolCall.input,
4326
4358
  options: {
@@ -4439,7 +4471,7 @@ function runToolsTransformation({
4439
4471
  }
4440
4472
 
4441
4473
  // src/generate-text/stream-text.ts
4442
- var originalGenerateId2 = (0, import_provider_utils13.createIdGenerator)({
4474
+ var originalGenerateId2 = (0, import_provider_utils14.createIdGenerator)({
4443
4475
  prefix: "aitxt",
4444
4476
  size: 24
4445
4477
  });
@@ -4849,7 +4881,7 @@ var DefaultStreamTextResult = class {
4849
4881
  }
4850
4882
  controller.enqueue(value);
4851
4883
  } catch (error) {
4852
- if ((0, import_provider_utils13.isAbortError)(error) && (abortSignal == null ? void 0 : abortSignal.aborted)) {
4884
+ if ((0, import_provider_utils14.isAbortError)(error) && (abortSignal == null ? void 0 : abortSignal.aborted)) {
4853
4885
  abort();
4854
4886
  } else {
4855
4887
  controller.error(error);
@@ -5969,7 +6001,7 @@ var Agent = class {
5969
6001
  };
5970
6002
 
5971
6003
  // src/embed/embed.ts
5972
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
6004
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
5973
6005
  async function embed({
5974
6006
  model: modelArg,
5975
6007
  value,
@@ -5984,7 +6016,7 @@ async function embed({
5984
6016
  maxRetries: maxRetriesArg,
5985
6017
  abortSignal
5986
6018
  });
5987
- const headersWithUserAgent = (0, import_provider_utils14.withUserAgentSuffix)(
6019
+ const headersWithUserAgent = (0, import_provider_utils15.withUserAgentSuffix)(
5988
6020
  headers != null ? headers : {},
5989
6021
  `ai/${VERSION}`
5990
6022
  );
@@ -6088,7 +6120,7 @@ var DefaultEmbedResult = class {
6088
6120
  };
6089
6121
 
6090
6122
  // src/embed/embed-many.ts
6091
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
6123
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
6092
6124
 
6093
6125
  // src/util/split-array.ts
6094
6126
  function splitArray(array, chunkSize) {
@@ -6118,7 +6150,7 @@ async function embedMany({
6118
6150
  maxRetries: maxRetriesArg,
6119
6151
  abortSignal
6120
6152
  });
6121
- const headersWithUserAgent = (0, import_provider_utils15.withUserAgentSuffix)(
6153
+ const headersWithUserAgent = (0, import_provider_utils16.withUserAgentSuffix)(
6122
6154
  headers != null ? headers : {},
6123
6155
  `ai/${VERSION}`
6124
6156
  );
@@ -6337,7 +6369,7 @@ var DefaultEmbedManyResult = class {
6337
6369
  };
6338
6370
 
6339
6371
  // src/generate-image/generate-image.ts
6340
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
6372
+ var import_provider_utils17 = require("@ai-sdk/provider-utils");
6341
6373
  async function generateImage({
6342
6374
  model,
6343
6375
  prompt,
@@ -6359,7 +6391,7 @@ async function generateImage({
6359
6391
  modelId: model.modelId
6360
6392
  });
6361
6393
  }
6362
- const headersWithUserAgent = (0, import_provider_utils16.withUserAgentSuffix)(
6394
+ const headersWithUserAgent = (0, import_provider_utils17.withUserAgentSuffix)(
6363
6395
  headers != null ? headers : {},
6364
6396
  `ai/${VERSION}`
6365
6397
  );
@@ -6455,7 +6487,7 @@ async function invokeModelMaxImagesPerCall(model) {
6455
6487
  }
6456
6488
 
6457
6489
  // src/generate-object/generate-object.ts
6458
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
6490
+ var import_provider_utils20 = require("@ai-sdk/provider-utils");
6459
6491
 
6460
6492
  // src/generate-text/extract-reasoning-content.ts
6461
6493
  function extractReasoningContent(content) {
@@ -6467,7 +6499,7 @@ function extractReasoningContent(content) {
6467
6499
 
6468
6500
  // src/generate-object/output-strategy.ts
6469
6501
  var import_provider24 = require("@ai-sdk/provider");
6470
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
6502
+ var import_provider_utils18 = require("@ai-sdk/provider-utils");
6471
6503
  var noSchemaOutputStrategy = {
6472
6504
  type: "no-schema",
6473
6505
  jsonSchema: void 0,
@@ -6506,7 +6538,7 @@ var objectOutputStrategy = (schema) => ({
6506
6538
  };
6507
6539
  },
6508
6540
  async validateFinalResult(value) {
6509
- return (0, import_provider_utils17.safeValidateTypes)({ value, schema });
6541
+ return (0, import_provider_utils18.safeValidateTypes)({ value, schema });
6510
6542
  },
6511
6543
  createElementStream() {
6512
6544
  throw new import_provider24.UnsupportedFunctionalityError({
@@ -6550,7 +6582,7 @@ var arrayOutputStrategy = (schema) => {
6550
6582
  const resultArray = [];
6551
6583
  for (let i = 0; i < inputArray.length; i++) {
6552
6584
  const element = inputArray[i];
6553
- const result = await (0, import_provider_utils17.safeValidateTypes)({ value: element, schema });
6585
+ const result = await (0, import_provider_utils18.safeValidateTypes)({ value: element, schema });
6554
6586
  if (i === inputArray.length - 1 && !isFinalDelta) {
6555
6587
  continue;
6556
6588
  }
@@ -6591,7 +6623,7 @@ var arrayOutputStrategy = (schema) => {
6591
6623
  }
6592
6624
  const inputArray = value.elements;
6593
6625
  for (const element of inputArray) {
6594
- const result = await (0, import_provider_utils17.safeValidateTypes)({ value: element, schema });
6626
+ const result = await (0, import_provider_utils18.safeValidateTypes)({ value: element, schema });
6595
6627
  if (!result.success) {
6596
6628
  return result;
6597
6629
  }
@@ -6709,9 +6741,9 @@ function getOutputStrategy({
6709
6741
  }) {
6710
6742
  switch (output) {
6711
6743
  case "object":
6712
- return objectOutputStrategy((0, import_provider_utils17.asSchema)(schema));
6744
+ return objectOutputStrategy((0, import_provider_utils18.asSchema)(schema));
6713
6745
  case "array":
6714
- return arrayOutputStrategy((0, import_provider_utils17.asSchema)(schema));
6746
+ return arrayOutputStrategy((0, import_provider_utils18.asSchema)(schema));
6715
6747
  case "enum":
6716
6748
  return enumOutputStrategy(enumValues);
6717
6749
  case "no-schema":
@@ -6725,9 +6757,9 @@ function getOutputStrategy({
6725
6757
 
6726
6758
  // src/generate-object/parse-and-validate-object-result.ts
6727
6759
  var import_provider25 = require("@ai-sdk/provider");
6728
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
6760
+ var import_provider_utils19 = require("@ai-sdk/provider-utils");
6729
6761
  async function parseAndValidateObjectResult(result, outputStrategy, context) {
6730
- const parseResult = await (0, import_provider_utils18.safeParseJSON)({ text: result });
6762
+ const parseResult = await (0, import_provider_utils19.safeParseJSON)({ text: result });
6731
6763
  if (!parseResult.success) {
6732
6764
  throw new NoObjectGeneratedError({
6733
6765
  message: "No object generated: could not parse the response.",
@@ -6899,7 +6931,7 @@ function validateObjectGenerationInput({
6899
6931
  }
6900
6932
 
6901
6933
  // src/generate-object/generate-object.ts
6902
- var originalGenerateId3 = (0, import_provider_utils19.createIdGenerator)({ prefix: "aiobj", size: 24 });
6934
+ var originalGenerateId3 = (0, import_provider_utils20.createIdGenerator)({ prefix: "aiobj", size: 24 });
6903
6935
  async function generateObject(options) {
6904
6936
  const {
6905
6937
  model: modelArg,
@@ -6944,7 +6976,7 @@ async function generateObject(options) {
6944
6976
  enumValues
6945
6977
  });
6946
6978
  const callSettings = prepareCallSettings(settings);
6947
- const headersWithUserAgent = (0, import_provider_utils19.withUserAgentSuffix)(
6979
+ const headersWithUserAgent = (0, import_provider_utils20.withUserAgentSuffix)(
6948
6980
  headers != null ? headers : {},
6949
6981
  `ai/${VERSION}`
6950
6982
  );
@@ -7163,7 +7195,7 @@ var DefaultGenerateObjectResult = class {
7163
7195
  };
7164
7196
 
7165
7197
  // src/generate-object/stream-object.ts
7166
- var import_provider_utils21 = require("@ai-sdk/provider-utils");
7198
+ var import_provider_utils22 = require("@ai-sdk/provider-utils");
7167
7199
 
7168
7200
  // src/util/cosine-similarity.ts
7169
7201
  function cosineSimilarity(vector1, vector2) {
@@ -7273,7 +7305,7 @@ var SerialJobExecutor = class {
7273
7305
  };
7274
7306
 
7275
7307
  // src/util/simulate-readable-stream.ts
7276
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
7308
+ var import_provider_utils21 = require("@ai-sdk/provider-utils");
7277
7309
  function simulateReadableStream({
7278
7310
  chunks,
7279
7311
  initialDelayInMs = 0,
@@ -7281,7 +7313,7 @@ function simulateReadableStream({
7281
7313
  _internal
7282
7314
  }) {
7283
7315
  var _a17;
7284
- const delay2 = (_a17 = _internal == null ? void 0 : _internal.delay) != null ? _a17 : import_provider_utils20.delay;
7316
+ const delay2 = (_a17 = _internal == null ? void 0 : _internal.delay) != null ? _a17 : import_provider_utils21.delay;
7285
7317
  let index = 0;
7286
7318
  return new ReadableStream({
7287
7319
  async pull(controller) {
@@ -7296,7 +7328,7 @@ function simulateReadableStream({
7296
7328
  }
7297
7329
 
7298
7330
  // src/generate-object/stream-object.ts
7299
- var originalGenerateId4 = (0, import_provider_utils21.createIdGenerator)({ prefix: "aiobj", size: 24 });
7331
+ var originalGenerateId4 = (0, import_provider_utils22.createIdGenerator)({ prefix: "aiobj", size: 24 });
7300
7332
  function streamObject(options) {
7301
7333
  const {
7302
7334
  model,
@@ -7817,7 +7849,7 @@ var DefaultStreamObjectResult = class {
7817
7849
  };
7818
7850
 
7819
7851
  // src/generate-speech/generate-speech.ts
7820
- var import_provider_utils22 = require("@ai-sdk/provider-utils");
7852
+ var import_provider_utils23 = require("@ai-sdk/provider-utils");
7821
7853
 
7822
7854
  // src/error/no-speech-generated-error.ts
7823
7855
  var import_provider26 = require("@ai-sdk/provider");
@@ -7878,7 +7910,7 @@ async function generateSpeech({
7878
7910
  modelId: model.modelId
7879
7911
  });
7880
7912
  }
7881
- const headersWithUserAgent = (0, import_provider_utils22.withUserAgentSuffix)(
7913
+ const headersWithUserAgent = (0, import_provider_utils23.withUserAgentSuffix)(
7882
7914
  headers != null ? headers : {},
7883
7915
  `ai/${VERSION}`
7884
7916
  );
@@ -7932,7 +7964,7 @@ __export(output_exports, {
7932
7964
  object: () => object,
7933
7965
  text: () => text
7934
7966
  });
7935
- var import_provider_utils23 = require("@ai-sdk/provider-utils");
7967
+ var import_provider_utils24 = require("@ai-sdk/provider-utils");
7936
7968
  var text = () => ({
7937
7969
  type: "text",
7938
7970
  responseFormat: { type: "text" },
@@ -7946,7 +7978,7 @@ var text = () => ({
7946
7978
  var object = ({
7947
7979
  schema: inputSchema
7948
7980
  }) => {
7949
- const schema = (0, import_provider_utils23.asSchema)(inputSchema);
7981
+ const schema = (0, import_provider_utils24.asSchema)(inputSchema);
7950
7982
  return {
7951
7983
  type: "object",
7952
7984
  responseFormat: {
@@ -7972,7 +8004,7 @@ var object = ({
7972
8004
  }
7973
8005
  },
7974
8006
  async parseOutput({ text: text2 }, context) {
7975
- const parseResult = await (0, import_provider_utils23.safeParseJSON)({ text: text2 });
8007
+ const parseResult = await (0, import_provider_utils24.safeParseJSON)({ text: text2 });
7976
8008
  if (!parseResult.success) {
7977
8009
  throw new NoObjectGeneratedError({
7978
8010
  message: "No object generated: could not parse the response.",
@@ -7983,7 +8015,7 @@ var object = ({
7983
8015
  finishReason: context.finishReason
7984
8016
  });
7985
8017
  }
7986
- const validationResult = await (0, import_provider_utils23.safeValidateTypes)({
8018
+ const validationResult = await (0, import_provider_utils24.safeValidateTypes)({
7987
8019
  value: parseResult.value,
7988
8020
  schema
7989
8021
  });
@@ -8003,7 +8035,7 @@ var object = ({
8003
8035
  };
8004
8036
 
8005
8037
  // src/generate-text/smooth-stream.ts
8006
- var import_provider_utils24 = require("@ai-sdk/provider-utils");
8038
+ var import_provider_utils25 = require("@ai-sdk/provider-utils");
8007
8039
  var import_provider27 = require("@ai-sdk/provider");
8008
8040
  var CHUNKING_REGEXPS = {
8009
8041
  word: /\S+\s+/m,
@@ -8012,7 +8044,7 @@ var CHUNKING_REGEXPS = {
8012
8044
  function smoothStream({
8013
8045
  delayInMs = 10,
8014
8046
  chunking = "word",
8015
- _internal: { delay: delay2 = import_provider_utils24.delay } = {}
8047
+ _internal: { delay: delay2 = import_provider_utils25.delay } = {}
8016
8048
  } = {}) {
8017
8049
  let detectChunk;
8018
8050
  if (typeof chunking === "function") {
@@ -8611,10 +8643,10 @@ var DefaultProviderRegistry = class {
8611
8643
  };
8612
8644
 
8613
8645
  // src/tool/mcp/mcp-client.ts
8614
- var import_provider_utils26 = require("@ai-sdk/provider-utils");
8646
+ var import_provider_utils27 = require("@ai-sdk/provider-utils");
8615
8647
 
8616
8648
  // src/tool/mcp/mcp-sse-transport.ts
8617
- var import_provider_utils25 = require("@ai-sdk/provider-utils");
8649
+ var import_provider_utils26 = require("@ai-sdk/provider-utils");
8618
8650
 
8619
8651
  // src/tool/mcp/json-rpc-message.ts
8620
8652
  var import_v49 = require("zod/v4");
@@ -8773,8 +8805,14 @@ var SseMCPTransport = class {
8773
8805
  const establishConnection = async () => {
8774
8806
  var _a17, _b, _c;
8775
8807
  try {
8776
- const headers = new Headers(this.headers);
8777
- headers.set("Accept", "text/event-stream");
8808
+ const headers = (0, import_provider_utils26.withUserAgentSuffix)(
8809
+ {
8810
+ ...this.headers,
8811
+ Accept: "text/event-stream"
8812
+ },
8813
+ `ai-sdk/${VERSION}`,
8814
+ (0, import_provider_utils26.getRuntimeEnvironmentUserAgent)()
8815
+ );
8778
8816
  const response = await fetch(this.url.href, {
8779
8817
  headers,
8780
8818
  signal: (_a17 = this.abortController) == null ? void 0 : _a17.signal
@@ -8786,7 +8824,7 @@ var SseMCPTransport = class {
8786
8824
  (_b = this.onerror) == null ? void 0 : _b.call(this, error);
8787
8825
  return reject(error);
8788
8826
  }
8789
- const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_provider_utils25.EventSourceParserStream());
8827
+ const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new import_provider_utils26.EventSourceParserStream());
8790
8828
  const reader = stream.getReader();
8791
8829
  const processEvents = async () => {
8792
8830
  var _a18, _b2, _c2;
@@ -8865,8 +8903,14 @@ var SseMCPTransport = class {
8865
8903
  });
8866
8904
  }
8867
8905
  try {
8868
- const headers = new Headers(this.headers);
8869
- headers.set("Content-Type", "application/json");
8906
+ const headers = (0, import_provider_utils26.withUserAgentSuffix)(
8907
+ {
8908
+ ...this.headers,
8909
+ "Content-Type": "application/json"
8910
+ },
8911
+ `ai-sdk/${VERSION}`,
8912
+ (0, import_provider_utils26.getRuntimeEnvironmentUserAgent)()
8913
+ );
8870
8914
  const init = {
8871
8915
  method: "POST",
8872
8916
  headers,
@@ -9116,15 +9160,15 @@ var DefaultMCPClient = class {
9116
9160
  (_a18 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a18.throwIfAborted();
9117
9161
  return self.callTool({ name: name17, args, options });
9118
9162
  };
9119
- const toolWithExecute = schemas === "automatic" ? (0, import_provider_utils26.dynamicTool)({
9163
+ const toolWithExecute = schemas === "automatic" ? (0, import_provider_utils27.dynamicTool)({
9120
9164
  description,
9121
- inputSchema: (0, import_provider_utils26.jsonSchema)({
9165
+ inputSchema: (0, import_provider_utils27.jsonSchema)({
9122
9166
  ...inputSchema,
9123
9167
  properties: (_a17 = inputSchema.properties) != null ? _a17 : {},
9124
9168
  additionalProperties: false
9125
9169
  }),
9126
9170
  execute
9127
- }) : (0, import_provider_utils26.tool)({
9171
+ }) : (0, import_provider_utils27.tool)({
9128
9172
  description,
9129
9173
  inputSchema: schemas[name17].inputSchema,
9130
9174
  execute
@@ -9174,7 +9218,7 @@ var DefaultMCPClient = class {
9174
9218
  };
9175
9219
 
9176
9220
  // src/transcribe/transcribe.ts
9177
- var import_provider_utils27 = require("@ai-sdk/provider-utils");
9221
+ var import_provider_utils28 = require("@ai-sdk/provider-utils");
9178
9222
 
9179
9223
  // src/error/no-transcript-generated-error.ts
9180
9224
  var import_provider31 = require("@ai-sdk/provider");
@@ -9208,7 +9252,7 @@ async function transcribe({
9208
9252
  maxRetries: maxRetriesArg,
9209
9253
  abortSignal
9210
9254
  });
9211
- const headersWithUserAgent = (0, import_provider_utils27.withUserAgentSuffix)(
9255
+ const headersWithUserAgent = (0, import_provider_utils28.withUserAgentSuffix)(
9212
9256
  headers != null ? headers : {},
9213
9257
  `ai/${VERSION}`
9214
9258
  );
@@ -9256,7 +9300,7 @@ var DefaultTranscriptionResult = class {
9256
9300
  };
9257
9301
 
9258
9302
  // src/ui/call-completion-api.ts
9259
- var import_provider_utils28 = require("@ai-sdk/provider-utils");
9303
+ var import_provider_utils29 = require("@ai-sdk/provider-utils");
9260
9304
 
9261
9305
  // src/ui/process-text-stream.ts
9262
9306
  async function processTextStream({
@@ -9304,10 +9348,14 @@ async function callCompletionApi({
9304
9348
  ...body
9305
9349
  }),
9306
9350
  credentials,
9307
- headers: {
9308
- "Content-Type": "application/json",
9309
- ...headers
9310
- },
9351
+ headers: (0, import_provider_utils29.withUserAgentSuffix)(
9352
+ {
9353
+ "Content-Type": "application/json",
9354
+ ...headers
9355
+ },
9356
+ `ai-sdk/${VERSION}`,
9357
+ (0, import_provider_utils29.getRuntimeEnvironmentUserAgent)()
9358
+ ),
9311
9359
  signal: abortController.signal
9312
9360
  }).catch((err) => {
9313
9361
  throw err;
@@ -9334,7 +9382,7 @@ async function callCompletionApi({
9334
9382
  }
9335
9383
  case "data": {
9336
9384
  await consumeStream({
9337
- stream: (0, import_provider_utils28.parseJsonEventStream)({
9385
+ stream: (0, import_provider_utils29.parseJsonEventStream)({
9338
9386
  stream: response.body,
9339
9387
  schema: uiMessageChunkSchema
9340
9388
  }).pipeThrough(
@@ -9386,7 +9434,7 @@ async function callCompletionApi({
9386
9434
  }
9387
9435
 
9388
9436
  // src/ui/chat.ts
9389
- var import_provider_utils31 = require("@ai-sdk/provider-utils");
9437
+ var import_provider_utils32 = require("@ai-sdk/provider-utils");
9390
9438
 
9391
9439
  // src/ui/convert-file-list-to-file-ui-parts.ts
9392
9440
  async function convertFileListToFileUIParts(files) {
@@ -9419,10 +9467,10 @@ async function convertFileListToFileUIParts(files) {
9419
9467
  }
9420
9468
 
9421
9469
  // src/ui/default-chat-transport.ts
9422
- var import_provider_utils30 = require("@ai-sdk/provider-utils");
9470
+ var import_provider_utils31 = require("@ai-sdk/provider-utils");
9423
9471
 
9424
9472
  // src/ui/http-chat-transport.ts
9425
- var import_provider_utils29 = require("@ai-sdk/provider-utils");
9473
+ var import_provider_utils30 = require("@ai-sdk/provider-utils");
9426
9474
  var HttpChatTransport = class {
9427
9475
  constructor({
9428
9476
  api = "/api/chat",
@@ -9446,9 +9494,9 @@ var HttpChatTransport = class {
9446
9494
  ...options
9447
9495
  }) {
9448
9496
  var _a17, _b, _c, _d, _e;
9449
- const resolvedBody = await (0, import_provider_utils29.resolve)(this.body);
9450
- const resolvedHeaders = await (0, import_provider_utils29.resolve)(this.headers);
9451
- const resolvedCredentials = await (0, import_provider_utils29.resolve)(this.credentials);
9497
+ const resolvedBody = await (0, import_provider_utils30.resolve)(this.body);
9498
+ const resolvedHeaders = await (0, import_provider_utils30.resolve)(this.headers);
9499
+ const resolvedCredentials = await (0, import_provider_utils30.resolve)(this.credentials);
9452
9500
  const preparedRequest = await ((_a17 = this.prepareSendMessagesRequest) == null ? void 0 : _a17.call(this, {
9453
9501
  api: this.api,
9454
9502
  id: options.chatId,
@@ -9474,10 +9522,14 @@ var HttpChatTransport = class {
9474
9522
  const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
9475
9523
  const response = await fetch2(api, {
9476
9524
  method: "POST",
9477
- headers: {
9478
- "Content-Type": "application/json",
9479
- ...headers
9480
- },
9525
+ headers: (0, import_provider_utils30.withUserAgentSuffix)(
9526
+ {
9527
+ "Content-Type": "application/json",
9528
+ ...headers
9529
+ },
9530
+ `ai-sdk/${VERSION}`,
9531
+ (0, import_provider_utils30.getRuntimeEnvironmentUserAgent)()
9532
+ ),
9481
9533
  body: JSON.stringify(body),
9482
9534
  credentials,
9483
9535
  signal: abortSignal
@@ -9494,9 +9546,9 @@ var HttpChatTransport = class {
9494
9546
  }
9495
9547
  async reconnectToStream(options) {
9496
9548
  var _a17, _b, _c, _d, _e;
9497
- const resolvedBody = await (0, import_provider_utils29.resolve)(this.body);
9498
- const resolvedHeaders = await (0, import_provider_utils29.resolve)(this.headers);
9499
- const resolvedCredentials = await (0, import_provider_utils29.resolve)(this.credentials);
9549
+ const resolvedBody = await (0, import_provider_utils30.resolve)(this.body);
9550
+ const resolvedHeaders = await (0, import_provider_utils30.resolve)(this.headers);
9551
+ const resolvedCredentials = await (0, import_provider_utils30.resolve)(this.credentials);
9500
9552
  const preparedRequest = await ((_a17 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a17.call(this, {
9501
9553
  api: this.api,
9502
9554
  id: options.chatId,
@@ -9511,7 +9563,11 @@ var HttpChatTransport = class {
9511
9563
  const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
9512
9564
  const response = await fetch2(api, {
9513
9565
  method: "GET",
9514
- headers,
9566
+ headers: (0, import_provider_utils30.withUserAgentSuffix)(
9567
+ headers,
9568
+ `ai-sdk/${VERSION}`,
9569
+ (0, import_provider_utils30.getRuntimeEnvironmentUserAgent)()
9570
+ ),
9515
9571
  credentials
9516
9572
  });
9517
9573
  if (response.status === 204) {
@@ -9535,7 +9591,7 @@ var DefaultChatTransport = class extends HttpChatTransport {
9535
9591
  super(options);
9536
9592
  }
9537
9593
  processResponseStream(stream) {
9538
- return (0, import_provider_utils30.parseJsonEventStream)({
9594
+ return (0, import_provider_utils31.parseJsonEventStream)({
9539
9595
  stream,
9540
9596
  schema: uiMessageChunkSchema
9541
9597
  }).pipeThrough(
@@ -9554,7 +9610,7 @@ var DefaultChatTransport = class extends HttpChatTransport {
9554
9610
  // src/ui/chat.ts
9555
9611
  var AbstractChat = class {
9556
9612
  constructor({
9557
- generateId: generateId3 = import_provider_utils31.generateId,
9613
+ generateId: generateId3 = import_provider_utils32.generateId,
9558
9614
  id = generateId3(),
9559
9615
  transport = new DefaultChatTransport(),
9560
9616
  messageMetadataSchema,
@@ -9936,7 +9992,7 @@ var TextStreamChatTransport = class extends HttpChatTransport {
9936
9992
 
9937
9993
  // src/ui/validate-ui-messages.ts
9938
9994
  var import_provider32 = require("@ai-sdk/provider");
9939
- var import_provider_utils32 = require("@ai-sdk/provider-utils");
9995
+ var import_provider_utils33 = require("@ai-sdk/provider-utils");
9940
9996
  var import_v410 = require("zod/v4");
9941
9997
  var textUIPartSchema = import_v410.z.object({
9942
9998
  type: import_v410.z.literal("text"),
@@ -10082,92 +10138,128 @@ var uiMessageSchema = import_v410.z.object({
10082
10138
  ])
10083
10139
  )
10084
10140
  });
10085
- async function validateUIMessages({
10141
+ async function safeValidateUIMessages({
10086
10142
  messages,
10087
10143
  metadataSchema,
10088
10144
  dataSchemas,
10089
10145
  tools
10090
10146
  }) {
10091
- if (messages == null) {
10092
- throw new InvalidArgumentError({
10093
- parameter: "messages",
10147
+ try {
10148
+ if (messages == null) {
10149
+ return {
10150
+ success: false,
10151
+ error: new InvalidArgumentError({
10152
+ parameter: "messages",
10153
+ value: messages,
10154
+ message: "messages parameter must be provided"
10155
+ })
10156
+ };
10157
+ }
10158
+ const validatedMessages = await (0, import_provider_utils33.validateTypes)({
10094
10159
  value: messages,
10095
- message: "messages parameter must be provided"
10160
+ schema: import_v410.z.array(uiMessageSchema)
10096
10161
  });
10097
- }
10098
- const validatedMessages = await (0, import_provider_utils32.validateTypes)({
10099
- value: messages,
10100
- schema: import_v410.z.array(uiMessageSchema)
10101
- });
10102
- if (metadataSchema) {
10103
- for (const message of validatedMessages) {
10104
- await (0, import_provider_utils32.validateTypes)({
10105
- value: message.metadata,
10106
- schema: metadataSchema
10107
- });
10162
+ if (metadataSchema) {
10163
+ for (const message of validatedMessages) {
10164
+ await (0, import_provider_utils33.validateTypes)({
10165
+ value: message.metadata,
10166
+ schema: metadataSchema
10167
+ });
10168
+ }
10108
10169
  }
10109
- }
10110
- if (dataSchemas) {
10111
- for (const message of validatedMessages) {
10112
- const dataParts = message.parts.filter(
10113
- (part) => part.type.startsWith("data-")
10114
- );
10115
- for (const dataPart of dataParts) {
10116
- const dataName = dataPart.type.slice(5);
10117
- const dataSchema = dataSchemas[dataName];
10118
- if (!dataSchema) {
10119
- throw new import_provider32.TypeValidationError({
10170
+ if (dataSchemas) {
10171
+ for (const message of validatedMessages) {
10172
+ const dataParts = message.parts.filter(
10173
+ (part) => part.type.startsWith("data-")
10174
+ );
10175
+ for (const dataPart of dataParts) {
10176
+ const dataName = dataPart.type.slice(5);
10177
+ const dataSchema = dataSchemas[dataName];
10178
+ if (!dataSchema) {
10179
+ return {
10180
+ success: false,
10181
+ error: new import_provider32.TypeValidationError({
10182
+ value: dataPart.data,
10183
+ cause: `No data schema found for data part ${dataName}`
10184
+ })
10185
+ };
10186
+ }
10187
+ await (0, import_provider_utils33.validateTypes)({
10120
10188
  value: dataPart.data,
10121
- cause: `No data schema found for data part ${dataName}`
10189
+ schema: dataSchema
10122
10190
  });
10123
10191
  }
10124
- await (0, import_provider_utils32.validateTypes)({
10125
- value: dataPart.data,
10126
- schema: dataSchema
10127
- });
10128
10192
  }
10129
10193
  }
10130
- }
10131
- if (tools) {
10132
- for (const message of validatedMessages) {
10133
- const toolParts = message.parts.filter(
10134
- (part) => part.type.startsWith("tool-")
10135
- );
10136
- for (const toolPart of toolParts) {
10137
- const toolName = toolPart.type.slice(5);
10138
- const tool3 = tools[toolName];
10139
- if (!tool3) {
10140
- throw new import_provider32.TypeValidationError({
10141
- value: toolPart.input,
10142
- cause: `No tool schema found for tool part ${toolName}`
10143
- });
10144
- }
10145
- if (toolPart.state === "input-available" || toolPart.state === "output-available" || toolPart.state === "output-error") {
10146
- await (0, import_provider_utils32.validateTypes)({
10147
- value: toolPart.input,
10148
- schema: tool3.inputSchema
10149
- });
10150
- }
10151
- if (toolPart.state === "output-available" && tool3.outputSchema) {
10152
- await (0, import_provider_utils32.validateTypes)({
10153
- value: toolPart.output,
10154
- schema: tool3.outputSchema
10155
- });
10194
+ if (tools) {
10195
+ for (const message of validatedMessages) {
10196
+ const toolParts = message.parts.filter(
10197
+ (part) => part.type.startsWith("tool-")
10198
+ );
10199
+ for (const toolPart of toolParts) {
10200
+ const toolName = toolPart.type.slice(5);
10201
+ const tool3 = tools[toolName];
10202
+ if (!tool3) {
10203
+ return {
10204
+ success: false,
10205
+ error: new import_provider32.TypeValidationError({
10206
+ value: toolPart.input,
10207
+ cause: `No tool schema found for tool part ${toolName}`
10208
+ })
10209
+ };
10210
+ }
10211
+ if (toolPart.state === "input-available" || toolPart.state === "output-available" || toolPart.state === "output-error") {
10212
+ await (0, import_provider_utils33.validateTypes)({
10213
+ value: toolPart.input,
10214
+ schema: tool3.inputSchema
10215
+ });
10216
+ }
10217
+ if (toolPart.state === "output-available" && tool3.outputSchema) {
10218
+ await (0, import_provider_utils33.validateTypes)({
10219
+ value: toolPart.output,
10220
+ schema: tool3.outputSchema
10221
+ });
10222
+ }
10156
10223
  }
10157
10224
  }
10158
10225
  }
10226
+ return {
10227
+ success: true,
10228
+ data: validatedMessages
10229
+ };
10230
+ } catch (error) {
10231
+ const err = error;
10232
+ return {
10233
+ success: false,
10234
+ error: err
10235
+ };
10159
10236
  }
10160
- return validatedMessages;
10237
+ }
10238
+ async function validateUIMessages({
10239
+ messages,
10240
+ metadataSchema,
10241
+ dataSchemas,
10242
+ tools
10243
+ }) {
10244
+ const response = await safeValidateUIMessages({
10245
+ messages,
10246
+ metadataSchema,
10247
+ dataSchemas,
10248
+ tools
10249
+ });
10250
+ if (!response.success)
10251
+ throw response.error;
10252
+ return response.data;
10161
10253
  }
10162
10254
 
10163
10255
  // src/ui-message-stream/create-ui-message-stream.ts
10164
- var import_provider_utils33 = require("@ai-sdk/provider-utils");
10256
+ var import_provider_utils34 = require("@ai-sdk/provider-utils");
10165
10257
  function createUIMessageStream({
10166
10258
  execute,
10167
- onError = import_provider_utils33.getErrorMessage,
10259
+ onError = import_provider_utils34.getErrorMessage,
10168
10260
  originalMessages,
10169
10261
  onFinish,
10170
- generateId: generateId3 = import_provider_utils33.generateId
10262
+ generateId: generateId3 = import_provider_utils34.generateId
10171
10263
  }) {
10172
10264
  let controller;
10173
10265
  const ongoingStreamPromises = [];
@@ -10382,6 +10474,7 @@ function readUIMessageStream({
10382
10474
  pipeTextStreamToResponse,
10383
10475
  pipeUIMessageStreamToResponse,
10384
10476
  readUIMessageStream,
10477
+ safeValidateUIMessages,
10385
10478
  simulateReadableStream,
10386
10479
  simulateStreamingMiddleware,
10387
10480
  smoothStream,