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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.232
4
+
5
+ ### Patch Changes
6
+
7
+ - 7644a61: Preserve provider options when combining consecutive tool messages.
8
+
3
9
  ## 6.0.231
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1282,7 +1282,7 @@ function detectMediaType({
1282
1282
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
1283
1283
 
1284
1284
  // src/version.ts
1285
- var VERSION = true ? "6.0.231" : "0.0.0-test";
1285
+ var VERSION = true ? "6.0.232" : "0.0.0-test";
1286
1286
 
1287
1287
  // src/util/download/download.ts
1288
1288
  var download = async ({
@@ -1335,6 +1335,42 @@ var createDefaultDownloadFunction = (download2 = download) => (requestedDownload
1335
1335
  )
1336
1336
  );
1337
1337
 
1338
+ // src/util/merge-objects.ts
1339
+ function mergeObjects(base, overrides) {
1340
+ if (base === void 0 && overrides === void 0) {
1341
+ return void 0;
1342
+ }
1343
+ if (base === void 0) {
1344
+ return overrides;
1345
+ }
1346
+ if (overrides === void 0) {
1347
+ return base;
1348
+ }
1349
+ const result = { ...base };
1350
+ for (const key in overrides) {
1351
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
1352
+ continue;
1353
+ }
1354
+ if (Object.prototype.hasOwnProperty.call(overrides, key)) {
1355
+ const overridesValue = overrides[key];
1356
+ if (overridesValue === void 0)
1357
+ continue;
1358
+ const baseValue = key in base ? base[key] : void 0;
1359
+ const isSourceObject = overridesValue !== null && typeof overridesValue === "object" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);
1360
+ const isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === "object" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);
1361
+ if (isSourceObject && isTargetObject) {
1362
+ result[key] = mergeObjects(
1363
+ baseValue,
1364
+ overridesValue
1365
+ );
1366
+ } else {
1367
+ result[key] = overridesValue;
1368
+ }
1369
+ }
1370
+ }
1371
+ return result;
1372
+ }
1373
+
1338
1374
  // src/prompt/data-content.ts
1339
1375
  var import_provider23 = require("@ai-sdk/provider");
1340
1376
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
@@ -1482,7 +1518,15 @@ async function convertToLanguageModelPrompt({
1482
1518
  }
1483
1519
  const lastCombinedMessage = combinedMessages.at(-1);
1484
1520
  if ((lastCombinedMessage == null ? void 0 : lastCombinedMessage.role) === "tool") {
1521
+ const lastContentPart = lastCombinedMessage.content.at(-1);
1522
+ if (lastContentPart != null && lastCombinedMessage.providerOptions != null) {
1523
+ lastContentPart.providerOptions = mergeObjects(
1524
+ lastCombinedMessage.providerOptions,
1525
+ lastContentPart.providerOptions
1526
+ );
1527
+ }
1485
1528
  lastCombinedMessage.content.push(...message.content);
1529
+ lastCombinedMessage.providerOptions = message.providerOptions;
1486
1530
  } else {
1487
1531
  combinedMessages.push(message);
1488
1532
  }
@@ -2739,42 +2783,6 @@ function addImageModelUsage(usage1, usage2) {
2739
2783
  };
2740
2784
  }
2741
2785
 
2742
- // src/util/merge-objects.ts
2743
- function mergeObjects(base, overrides) {
2744
- if (base === void 0 && overrides === void 0) {
2745
- return void 0;
2746
- }
2747
- if (base === void 0) {
2748
- return overrides;
2749
- }
2750
- if (overrides === void 0) {
2751
- return base;
2752
- }
2753
- const result = { ...base };
2754
- for (const key in overrides) {
2755
- if (key === "__proto__" || key === "constructor" || key === "prototype") {
2756
- continue;
2757
- }
2758
- if (Object.prototype.hasOwnProperty.call(overrides, key)) {
2759
- const overridesValue = overrides[key];
2760
- if (overridesValue === void 0)
2761
- continue;
2762
- const baseValue = key in base ? base[key] : void 0;
2763
- const isSourceObject = overridesValue !== null && typeof overridesValue === "object" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);
2764
- const isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === "object" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);
2765
- if (isSourceObject && isTargetObject) {
2766
- result[key] = mergeObjects(
2767
- baseValue,
2768
- overridesValue
2769
- );
2770
- } else {
2771
- result[key] = overridesValue;
2772
- }
2773
- }
2774
- }
2775
- return result;
2776
- }
2777
-
2778
2786
  // src/util/retry-with-exponential-backoff.ts
2779
2787
  var import_provider27 = require("@ai-sdk/provider");
2780
2788
  var import_gateway3 = require("@ai-sdk/gateway");