ai 6.0.207 → 6.0.208

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,12 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.208
4
+
5
+ ### Patch Changes
6
+
7
+ - 8261640: fix(ai): handle partial unicode escapes in fixJson
8
+ - f994df3: Serialize `undefined` tool output to `null` in UI message chunks
9
+
3
10
  ## 6.0.207
4
11
 
5
12
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1281,7 +1281,7 @@ function detectMediaType({
1281
1281
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
1282
1282
 
1283
1283
  // src/version.ts
1284
- var VERSION = true ? "6.0.207" : "0.0.0-test";
1284
+ var VERSION = true ? "6.0.208" : "0.0.0-test";
1285
1285
 
1286
1286
  // src/util/download/download.ts
1287
1287
  var download = async ({
@@ -3349,6 +3349,10 @@ function fixJson(input) {
3349
3349
  const stack = ["ROOT"];
3350
3350
  let lastValidIndex = -1;
3351
3351
  let literalStart = null;
3352
+ let unicodeEscapeDigits = 0;
3353
+ function isHexDigit(char) {
3354
+ return char >= "0" && char <= "9" || char >= "A" && char <= "F" || char >= "a" && char <= "f";
3355
+ }
3352
3356
  function processValueStart(char, i, swapState) {
3353
3357
  {
3354
3358
  switch (char) {
@@ -3553,7 +3557,22 @@ function fixJson(input) {
3553
3557
  }
3554
3558
  case "INSIDE_STRING_ESCAPE": {
3555
3559
  stack.pop();
3556
- lastValidIndex = i;
3560
+ if (char === "u") {
3561
+ unicodeEscapeDigits = 0;
3562
+ stack.push("INSIDE_STRING_UNICODE_ESCAPE");
3563
+ } else {
3564
+ lastValidIndex = i;
3565
+ }
3566
+ break;
3567
+ }
3568
+ case "INSIDE_STRING_UNICODE_ESCAPE": {
3569
+ if (isHexDigit(char)) {
3570
+ unicodeEscapeDigits++;
3571
+ if (unicodeEscapeDigits === 4) {
3572
+ stack.pop();
3573
+ lastValidIndex = i;
3574
+ }
3575
+ }
3557
3576
  break;
3558
3577
  }
3559
3578
  case "INSIDE_NUMBER": {
@@ -8436,7 +8455,9 @@ var DefaultStreamTextResult = class {
8436
8455
  controller.enqueue({
8437
8456
  type: "tool-output-available",
8438
8457
  toolCallId: part.toolCallId,
8439
- output: part.output,
8458
+ // UI stream chunks are serialized as JSON, which drops undefined
8459
+ // properties. Use null so tool outputs always keep the output field.
8460
+ output: part.output === void 0 ? null : part.output,
8440
8461
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
8441
8462
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
8442
8463
  ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},