ai 5.0.221 → 5.0.223

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
@@ -72,6 +72,16 @@ function formatWarning(warning) {
72
72
  }
73
73
  var FIRST_WARNING_INFO_MESSAGE = "AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.";
74
74
  var hasLoggedBefore = false;
75
+ function emitWarning({
76
+ message,
77
+ type
78
+ }) {
79
+ if (typeof process !== "undefined" && typeof process.emitWarning === "function") {
80
+ process.emitWarning(message, { type });
81
+ } else {
82
+ console.warn(message);
83
+ }
84
+ }
75
85
  var logWarnings = (warnings) => {
76
86
  if (warnings.length === 0) {
77
87
  return;
@@ -86,10 +96,16 @@ var logWarnings = (warnings) => {
86
96
  }
87
97
  if (!hasLoggedBefore) {
88
98
  hasLoggedBefore = true;
89
- console.info(FIRST_WARNING_INFO_MESSAGE);
99
+ emitWarning({
100
+ message: FIRST_WARNING_INFO_MESSAGE,
101
+ type: "Warning"
102
+ });
90
103
  }
91
104
  for (const warning of warnings) {
92
- console.warn(formatWarning(warning));
105
+ emitWarning({
106
+ message: formatWarning(warning),
107
+ type: "Warning"
108
+ });
93
109
  }
94
110
  };
95
111
 
@@ -711,7 +727,7 @@ import {
711
727
  } from "@ai-sdk/provider-utils";
712
728
 
713
729
  // src/version.ts
714
- var VERSION = true ? "5.0.221" : "0.0.0-test";
730
+ var VERSION = true ? "5.0.223" : "0.0.0-test";
715
731
 
716
732
  // src/util/download/download.ts
717
733
  var download = async ({
@@ -4724,6 +4740,10 @@ function createOutputTransformStream(output) {
4724
4740
  }
4725
4741
  text2 += chunk.text;
4726
4742
  textChunk += chunk.text;
4743
+ if (chunk.text.length === 0 && chunk.providerMetadata != null) {
4744
+ controller.enqueue({ part: chunk, partialOutput: void 0 });
4745
+ return;
4746
+ }
4727
4747
  const result = await output.parsePartial({ text: text2 });
4728
4748
  if (result != null) {
4729
4749
  const currentJson = JSON.stringify(result.partial);
@@ -5248,7 +5268,7 @@ var DefaultStreamTextResult = class {
5248
5268
  break;
5249
5269
  }
5250
5270
  case "text-delta": {
5251
- if (chunk.delta.length > 0) {
5271
+ if (chunk.delta.length > 0 || chunk.providerMetadata != null) {
5252
5272
  controller.enqueue({
5253
5273
  type: "text-delta",
5254
5274
  id: chunk.id,