ai 6.0.231 → 6.0.232

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
@@ -1171,7 +1171,7 @@ import {
1171
1171
  } from "@ai-sdk/provider-utils";
1172
1172
 
1173
1173
  // src/version.ts
1174
- var VERSION = true ? "6.0.231" : "0.0.0-test";
1174
+ var VERSION = true ? "6.0.232" : "0.0.0-test";
1175
1175
 
1176
1176
  // src/util/download/download.ts
1177
1177
  var download = async ({
@@ -1224,6 +1224,42 @@ var createDefaultDownloadFunction = (download2 = download) => (requestedDownload
1224
1224
  )
1225
1225
  );
1226
1226
 
1227
+ // src/util/merge-objects.ts
1228
+ function mergeObjects(base, overrides) {
1229
+ if (base === void 0 && overrides === void 0) {
1230
+ return void 0;
1231
+ }
1232
+ if (base === void 0) {
1233
+ return overrides;
1234
+ }
1235
+ if (overrides === void 0) {
1236
+ return base;
1237
+ }
1238
+ const result = { ...base };
1239
+ for (const key in overrides) {
1240
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
1241
+ continue;
1242
+ }
1243
+ if (Object.prototype.hasOwnProperty.call(overrides, key)) {
1244
+ const overridesValue = overrides[key];
1245
+ if (overridesValue === void 0)
1246
+ continue;
1247
+ const baseValue = key in base ? base[key] : void 0;
1248
+ const isSourceObject = overridesValue !== null && typeof overridesValue === "object" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);
1249
+ const isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === "object" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);
1250
+ if (isSourceObject && isTargetObject) {
1251
+ result[key] = mergeObjects(
1252
+ baseValue,
1253
+ overridesValue
1254
+ );
1255
+ } else {
1256
+ result[key] = overridesValue;
1257
+ }
1258
+ }
1259
+ }
1260
+ return result;
1261
+ }
1262
+
1227
1263
  // src/prompt/data-content.ts
1228
1264
  import { AISDKError as AISDKError23 } from "@ai-sdk/provider";
1229
1265
  import {
@@ -1374,7 +1410,15 @@ async function convertToLanguageModelPrompt({
1374
1410
  }
1375
1411
  const lastCombinedMessage = combinedMessages.at(-1);
1376
1412
  if ((lastCombinedMessage == null ? void 0 : lastCombinedMessage.role) === "tool") {
1413
+ const lastContentPart = lastCombinedMessage.content.at(-1);
1414
+ if (lastContentPart != null && lastCombinedMessage.providerOptions != null) {
1415
+ lastContentPart.providerOptions = mergeObjects(
1416
+ lastCombinedMessage.providerOptions,
1417
+ lastContentPart.providerOptions
1418
+ );
1419
+ }
1377
1420
  lastCombinedMessage.content.push(...message.content);
1421
+ lastCombinedMessage.providerOptions = message.providerOptions;
1378
1422
  } else {
1379
1423
  combinedMessages.push(message);
1380
1424
  }
@@ -2636,42 +2680,6 @@ function addImageModelUsage(usage1, usage2) {
2636
2680
  };
2637
2681
  }
2638
2682
 
2639
- // src/util/merge-objects.ts
2640
- function mergeObjects(base, overrides) {
2641
- if (base === void 0 && overrides === void 0) {
2642
- return void 0;
2643
- }
2644
- if (base === void 0) {
2645
- return overrides;
2646
- }
2647
- if (overrides === void 0) {
2648
- return base;
2649
- }
2650
- const result = { ...base };
2651
- for (const key in overrides) {
2652
- if (key === "__proto__" || key === "constructor" || key === "prototype") {
2653
- continue;
2654
- }
2655
- if (Object.prototype.hasOwnProperty.call(overrides, key)) {
2656
- const overridesValue = overrides[key];
2657
- if (overridesValue === void 0)
2658
- continue;
2659
- const baseValue = key in base ? base[key] : void 0;
2660
- const isSourceObject = overridesValue !== null && typeof overridesValue === "object" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);
2661
- const isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === "object" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);
2662
- if (isSourceObject && isTargetObject) {
2663
- result[key] = mergeObjects(
2664
- baseValue,
2665
- overridesValue
2666
- );
2667
- } else {
2668
- result[key] = overridesValue;
2669
- }
2670
- }
2671
- }
2672
- return result;
2673
- }
2674
-
2675
2683
  // src/util/retry-with-exponential-backoff.ts
2676
2684
  import { APICallError as APICallError2 } from "@ai-sdk/provider";
2677
2685
  import { GatewayError } from "@ai-sdk/gateway";