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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.223
4
+
5
+ ### Patch Changes
6
+
7
+ - 7a6bdbc: Prevent validated downloads on Node.js from reaching private or internal services through DNS aliases or DNS rebinding by validating and pinning every resolved address at connection time.
8
+ - c5e11c6: Preserve provider metadata from empty text deltas in `streamText`.
9
+ - Updated dependencies [7a6bdbc]
10
+ - Updated dependencies [5bd6d2c]
11
+ - @ai-sdk/provider-utils@3.0.31
12
+ - @ai-sdk/gateway@2.0.122
13
+
14
+ ## 5.0.222
15
+
16
+ ### Patch Changes
17
+
18
+ - d38a1d5: Route the warning system information banner to stderr so it does not corrupt application output written to stdout.
19
+ - Updated dependencies [b408f1d]
20
+ - @ai-sdk/gateway@2.0.121
21
+
3
22
  ## 5.0.221
4
23
 
5
24
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -675,7 +675,8 @@ type StepResult<TOOLS extends ToolSet> = {
675
675
  */
676
676
  readonly content: Array<ContentPart<TOOLS>>;
677
677
  /**
678
- The generated text.
678
+ The concatenation of all text parts generated in this step.
679
+ It is an empty string if the step contains no text parts.
679
680
  */
680
681
  readonly text: string;
681
682
  /**
@@ -767,7 +768,9 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
767
768
  */
768
769
  readonly content: Array<ContentPart<TOOLS>>;
769
770
  /**
770
- The text that was generated in the last step.
771
+ The concatenation of all text parts generated in the last step.
772
+ It is an empty string if the last step contains no text parts.
773
+ Inspect `content` to distinguish that case.
771
774
  */
772
775
  readonly text: string;
773
776
  /**
@@ -2075,8 +2078,8 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
2075
2078
  readonly providerMetadata: Promise<ProviderMetadata | undefined>;
2076
2079
  /**
2077
2080
  A text stream that returns only the generated text deltas. You can use it
2078
- as either an AsyncIterable or a ReadableStream. When an error occurs, the
2079
- stream will throw the error.
2081
+ as either an AsyncIterable or a ReadableStream. Error parts are not surfaced
2082
+ in this stream. Use the `onError` callback or `fullStream` to observe them.
2080
2083
  */
2081
2084
  readonly textStream: AsyncIterableStream<string>;
2082
2085
  /**
package/dist/index.d.ts CHANGED
@@ -675,7 +675,8 @@ type StepResult<TOOLS extends ToolSet> = {
675
675
  */
676
676
  readonly content: Array<ContentPart<TOOLS>>;
677
677
  /**
678
- The generated text.
678
+ The concatenation of all text parts generated in this step.
679
+ It is an empty string if the step contains no text parts.
679
680
  */
680
681
  readonly text: string;
681
682
  /**
@@ -767,7 +768,9 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
767
768
  */
768
769
  readonly content: Array<ContentPart<TOOLS>>;
769
770
  /**
770
- The text that was generated in the last step.
771
+ The concatenation of all text parts generated in the last step.
772
+ It is an empty string if the last step contains no text parts.
773
+ Inspect `content` to distinguish that case.
771
774
  */
772
775
  readonly text: string;
773
776
  /**
@@ -2075,8 +2078,8 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
2075
2078
  readonly providerMetadata: Promise<ProviderMetadata | undefined>;
2076
2079
  /**
2077
2080
  A text stream that returns only the generated text deltas. You can use it
2078
- as either an AsyncIterable or a ReadableStream. When an error occurs, the
2079
- stream will throw the error.
2081
+ as either an AsyncIterable or a ReadableStream. Error parts are not surfaced
2082
+ in this stream. Use the `onError` callback or `fullStream` to observe them.
2080
2083
  */
2081
2084
  readonly textStream: AsyncIterableStream<string>;
2082
2085
  /**
package/dist/index.js CHANGED
@@ -185,6 +185,16 @@ function formatWarning(warning) {
185
185
  }
186
186
  var FIRST_WARNING_INFO_MESSAGE = "AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.";
187
187
  var hasLoggedBefore = false;
188
+ function emitWarning({
189
+ message,
190
+ type
191
+ }) {
192
+ if (typeof process !== "undefined" && typeof process.emitWarning === "function") {
193
+ process.emitWarning(message, { type });
194
+ } else {
195
+ console.warn(message);
196
+ }
197
+ }
188
198
  var logWarnings = (warnings) => {
189
199
  if (warnings.length === 0) {
190
200
  return;
@@ -199,10 +209,16 @@ var logWarnings = (warnings) => {
199
209
  }
200
210
  if (!hasLoggedBefore) {
201
211
  hasLoggedBefore = true;
202
- console.info(FIRST_WARNING_INFO_MESSAGE);
212
+ emitWarning({
213
+ message: FIRST_WARNING_INFO_MESSAGE,
214
+ type: "Warning"
215
+ });
203
216
  }
204
217
  for (const warning of warnings) {
205
- console.warn(formatWarning(warning));
218
+ emitWarning({
219
+ message: formatWarning(warning),
220
+ type: "Warning"
221
+ });
206
222
  }
207
223
  };
208
224
 
@@ -800,7 +816,7 @@ function detectMediaType({
800
816
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
801
817
 
802
818
  // src/version.ts
803
- var VERSION = true ? "5.0.221" : "0.0.0-test";
819
+ var VERSION = true ? "5.0.223" : "0.0.0-test";
804
820
 
805
821
  // src/util/download/download.ts
806
822
  var download = async ({
@@ -4789,6 +4805,10 @@ function createOutputTransformStream(output) {
4789
4805
  }
4790
4806
  text2 += chunk.text;
4791
4807
  textChunk += chunk.text;
4808
+ if (chunk.text.length === 0 && chunk.providerMetadata != null) {
4809
+ controller.enqueue({ part: chunk, partialOutput: void 0 });
4810
+ return;
4811
+ }
4792
4812
  const result = await output.parsePartial({ text: text2 });
4793
4813
  if (result != null) {
4794
4814
  const currentJson = JSON.stringify(result.partial);
@@ -5313,7 +5333,7 @@ var DefaultStreamTextResult = class {
5313
5333
  break;
5314
5334
  }
5315
5335
  case "text-delta": {
5316
- if (chunk.delta.length > 0) {
5336
+ if (chunk.delta.length > 0 || chunk.providerMetadata != null) {
5317
5337
  controller.enqueue({
5318
5338
  type: "text-delta",
5319
5339
  id: chunk.id,