ai 7.0.111 → 7.0.112

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.
@@ -91,7 +91,7 @@ import {
91
91
  } from "@ai-sdk/provider-utils";
92
92
 
93
93
  // src/version.ts
94
- var VERSION = true ? "7.0.111" : "0.0.0-test";
94
+ var VERSION = true ? "7.0.112" : "0.0.0-test";
95
95
 
96
96
  // src/util/download/download.ts
97
97
  var download = async ({
@@ -241,6 +241,13 @@ function convertUrlToFilePartData(url) {
241
241
  }
242
242
  return { data: { type: "url", url }, mediaType: void 0 };
243
243
  }
244
+ function convertUrlStringToFilePartData(content) {
245
+ const result = convertUrlToFilePartData(new URL(content));
246
+ if (result.data.type === "url" && result.data.url.toString() !== content) {
247
+ result.data.originalUrl = content;
248
+ }
249
+ return result;
250
+ }
244
251
  function convertInlineDataToFilePartData(content) {
245
252
  if (content instanceof Uint8Array) {
246
253
  return { data: { type: "data", data: content }, mediaType: void 0 };
@@ -292,7 +299,7 @@ function convertToLanguageModelV4FilePart(content) {
292
299
  }
293
300
  if (typeof content === "string") {
294
301
  try {
295
- return convertUrlToFilePartData(new URL(content));
302
+ return convertUrlStringToFilePartData(content);
296
303
  } catch (e) {
297
304
  return convertInlineDataToFilePartData(content);
298
305
  }
@@ -893,6 +900,7 @@ function mapToolResultOutput({
893
900
  }
894
901
  case "file-url": {
895
902
  const mediaType = (_a12 = item.mediaType) != null ? _a12 : getMediaTypeFromUrl(item.url);
903
+ const url = new URL(item.url);
896
904
  let message = `The "file-url" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'url', url } instead.`;
897
905
  if (!item.mediaType) {
898
906
  const inferenceSuffix = mediaType === "application/octet-stream" ? `Unable to infer media type from URL. Defaulting to 'application/octet-stream'.` : `Inferred media type '${mediaType}' from URL.`;
@@ -905,7 +913,11 @@ function mapToolResultOutput({
905
913
  });
906
914
  return {
907
915
  type: "file",
908
- data: { type: "url", url: new URL(item.url) },
916
+ data: {
917
+ type: "url",
918
+ url,
919
+ ...url.toString() !== item.url ? { originalUrl: item.url } : {}
920
+ },
909
921
  mediaType,
910
922
  providerOptions: item.providerOptions
911
923
  };
@@ -961,6 +973,7 @@ function mapToolResultOutput({
961
973
  };
962
974
  }
963
975
  case "image-url": {
976
+ const url = new URL(item.url);
964
977
  warnings.push({
965
978
  type: "deprecated",
966
979
  setting: '"tool-result" content of type "image-url"',
@@ -968,7 +981,11 @@ function mapToolResultOutput({
968
981
  });
969
982
  return {
970
983
  type: "file",
971
- data: { type: "url", url: new URL(item.url) },
984
+ data: {
985
+ type: "url",
986
+ url,
987
+ ...url.toString() !== item.url ? { originalUrl: item.url } : {}
988
+ },
972
989
  mediaType: "image",
973
990
  providerOptions: item.providerOptions
974
991
  };