ai 5.0.197 → 5.0.199

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,19 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.199
4
+
5
+ ### Patch Changes
6
+
7
+ - 040dc83: fix(ai): return schema-transformed elements in array output mode
8
+
9
+ Previously final array output validation checked each element against the schema but returned the raw model output. Array output now returns the validated values so Zod transforms, coercions, defaults, and pipes are applied consistently with object output.
10
+
11
+ ## 5.0.198
12
+
13
+ ### Patch Changes
14
+
15
+ - b02267c: Harden UI message stream processing against prototype pollution from chunk IDs.
16
+
3
17
  ## 5.0.197
4
18
 
5
19
  ### Patch Changes
package/dist/index.js CHANGED
@@ -778,7 +778,7 @@ function detectMediaType({
778
778
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
779
779
 
780
780
  // src/version.ts
781
- var VERSION = true ? "5.0.197" : "0.0.0-test";
781
+ var VERSION = true ? "5.0.199" : "0.0.0-test";
782
782
 
783
783
  // src/util/download/download.ts
784
784
  var download = async ({
@@ -3145,6 +3145,11 @@ function isDataUIMessageChunk(chunk) {
3145
3145
  return chunk.type.startsWith("data-");
3146
3146
  }
3147
3147
 
3148
+ // src/util/create-id-map.ts
3149
+ function createIdMap() {
3150
+ return /* @__PURE__ */ Object.create(null);
3151
+ }
3152
+
3148
3153
  // src/util/merge-objects.ts
3149
3154
  function mergeObjects(base, overrides) {
3150
3155
  if (base === void 0 && overrides === void 0) {
@@ -3559,9 +3564,9 @@ function createStreamingUIMessageState({
3559
3564
  role: "assistant",
3560
3565
  parts: []
3561
3566
  },
3562
- activeTextParts: {},
3563
- activeReasoningParts: {},
3564
- partialToolCalls: {}
3567
+ activeTextParts: createIdMap(),
3568
+ activeReasoningParts: createIdMap(),
3569
+ partialToolCalls: createIdMap()
3565
3570
  };
3566
3571
  }
3567
3572
  function processUIMessageStream({
@@ -3937,8 +3942,8 @@ function processUIMessageStream({
3937
3942
  break;
3938
3943
  }
3939
3944
  case "finish-step": {
3940
- state.activeTextParts = {};
3941
- state.activeReasoningParts = {};
3945
+ state.activeTextParts = createIdMap();
3946
+ state.activeReasoningParts = createIdMap();
3942
3947
  break;
3943
3948
  }
3944
3949
  case "start": {
@@ -6731,13 +6736,15 @@ var arrayOutputStrategy = (schema) => {
6731
6736
  };
6732
6737
  }
6733
6738
  const inputArray = value.elements;
6739
+ const resultArray = [];
6734
6740
  for (const element of inputArray) {
6735
6741
  const result = await (0, import_provider_utils19.safeValidateTypes)({ value: element, schema });
6736
6742
  if (!result.success) {
6737
6743
  return result;
6738
6744
  }
6745
+ resultArray.push(result.value);
6739
6746
  }
6740
- return { success: true, value: inputArray };
6747
+ return { success: true, value: resultArray };
6741
6748
  },
6742
6749
  createElementStream(originalStream) {
6743
6750
  let publishedElements = 0;