ai 5.0.54 → 5.0.56

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,17 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.56
4
+
5
+ ### Patch Changes
6
+
7
+ - b1d8458: fix(ai): align logic of text-end with reasoning-end
8
+
9
+ ## 5.0.55
10
+
11
+ ### Patch Changes
12
+
13
+ - 85da29e: fix(ai): remove outdated jsdoc param descriptions
14
+
3
15
  ## 5.0.54
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2072,47 +2072,28 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
2072
2072
  */
2073
2073
  consumeStream(options?: ConsumeStreamOptions): Promise<void>;
2074
2074
  /**
2075
- Converts the result to a UI message stream.
2075
+ Converts the result to a UI message stream.
2076
2076
 
2077
- @param options.getErrorMessage an optional function that converts an error to an error message.
2078
- @param options.sendUsage whether to send the usage information to the client. Defaults to true.
2079
- @param options.sendReasoning whether to send the reasoning information to the client. Defaults to false.
2080
- @param options.sendSources whether to send the sources information to the client. Defaults to false.
2081
- @param options.experimental_sendFinish whether to send the finish information to the client. Defaults to true.
2082
- @param options.experimental_sendStart whether to send the start information to the client. Defaults to true.
2083
-
2084
- @return A UI message stream.
2077
+ @return A UI message stream.
2085
2078
  */
2086
2079
  toUIMessageStream<UI_MESSAGE extends UIMessage>(options?: UIMessageStreamOptions<UI_MESSAGE>): AsyncIterableStream<InferUIMessageChunk<UI_MESSAGE>>;
2087
2080
  /**
2088
- Writes UI message stream output to a Node.js response-like object.
2089
- @param response A Node.js response-like object (ServerResponse).
2090
- @param options.status The status code.
2091
- @param options.statusText The status text.
2092
- @param options.headers The headers.
2093
- @param options.getErrorMessage An optional function that converts an error to an error message.
2094
- @param options.sendUsage Whether to send the usage information to the client. Defaults to true.
2095
- @param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
2096
- */
2081
+ *Writes UI message stream output to a Node.js response-like object.
2082
+ */
2097
2083
  pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(response: ServerResponse, options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): void;
2098
2084
  /**
2099
- Writes text delta output to a Node.js response-like object.
2100
- It sets a `Content-Type` header to `text/plain; charset=utf-8` and
2101
- writes each text delta as a separate chunk.
2102
- @param response A Node.js response-like object (ServerResponse).
2103
- @param init Optional headers, status code, and status text.
2085
+ Writes text delta output to a Node.js response-like object.
2086
+ It sets a `Content-Type` header to `text/plain; charset=utf-8` and
2087
+ writes each text delta as a separate chunk.
2088
+
2089
+ @param response A Node.js response-like object (ServerResponse).
2090
+ @param init Optional headers, status code, and status text.
2104
2091
  */
2105
2092
  pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): void;
2106
2093
  /**
2107
- Converts the result to a streamed response object with a stream data part stream.
2094
+ Converts the result to a streamed response object with a stream data part stream.
2108
2095
 
2109
- @param options.status The status code.
2110
- @param options.statusText The status text.
2111
- @param options.headers The headers.
2112
- @param options.getErrorMessage An optional function that converts an error to an error message.
2113
- @param options.sendUsage Whether to send the usage information to the client. Defaults to true.
2114
- @param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
2115
- @return A response object.
2096
+ @return A response object.
2116
2097
  */
2117
2098
  toUIMessageStreamResponse<UI_MESSAGE extends UIMessage>(options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): Response;
2118
2099
  /**
package/dist/index.d.ts CHANGED
@@ -2072,47 +2072,28 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
2072
2072
  */
2073
2073
  consumeStream(options?: ConsumeStreamOptions): Promise<void>;
2074
2074
  /**
2075
- Converts the result to a UI message stream.
2075
+ Converts the result to a UI message stream.
2076
2076
 
2077
- @param options.getErrorMessage an optional function that converts an error to an error message.
2078
- @param options.sendUsage whether to send the usage information to the client. Defaults to true.
2079
- @param options.sendReasoning whether to send the reasoning information to the client. Defaults to false.
2080
- @param options.sendSources whether to send the sources information to the client. Defaults to false.
2081
- @param options.experimental_sendFinish whether to send the finish information to the client. Defaults to true.
2082
- @param options.experimental_sendStart whether to send the start information to the client. Defaults to true.
2083
-
2084
- @return A UI message stream.
2077
+ @return A UI message stream.
2085
2078
  */
2086
2079
  toUIMessageStream<UI_MESSAGE extends UIMessage>(options?: UIMessageStreamOptions<UI_MESSAGE>): AsyncIterableStream<InferUIMessageChunk<UI_MESSAGE>>;
2087
2080
  /**
2088
- Writes UI message stream output to a Node.js response-like object.
2089
- @param response A Node.js response-like object (ServerResponse).
2090
- @param options.status The status code.
2091
- @param options.statusText The status text.
2092
- @param options.headers The headers.
2093
- @param options.getErrorMessage An optional function that converts an error to an error message.
2094
- @param options.sendUsage Whether to send the usage information to the client. Defaults to true.
2095
- @param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
2096
- */
2081
+ *Writes UI message stream output to a Node.js response-like object.
2082
+ */
2097
2083
  pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(response: ServerResponse, options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): void;
2098
2084
  /**
2099
- Writes text delta output to a Node.js response-like object.
2100
- It sets a `Content-Type` header to `text/plain; charset=utf-8` and
2101
- writes each text delta as a separate chunk.
2102
- @param response A Node.js response-like object (ServerResponse).
2103
- @param init Optional headers, status code, and status text.
2085
+ Writes text delta output to a Node.js response-like object.
2086
+ It sets a `Content-Type` header to `text/plain; charset=utf-8` and
2087
+ writes each text delta as a separate chunk.
2088
+
2089
+ @param response A Node.js response-like object (ServerResponse).
2090
+ @param init Optional headers, status code, and status text.
2104
2091
  */
2105
2092
  pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): void;
2106
2093
  /**
2107
- Converts the result to a streamed response object with a stream data part stream.
2094
+ Converts the result to a streamed response object with a stream data part stream.
2108
2095
 
2109
- @param options.status The status code.
2110
- @param options.statusText The status text.
2111
- @param options.headers The headers.
2112
- @param options.getErrorMessage An optional function that converts an error to an error message.
2113
- @param options.sendUsage Whether to send the usage information to the client. Defaults to true.
2114
- @param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
2115
- @return A response object.
2096
+ @return A response object.
2116
2097
  */
2117
2098
  toUIMessageStreamResponse<UI_MESSAGE extends UIMessage>(options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): Response;
2118
2099
  /**
package/dist/index.js CHANGED
@@ -768,7 +768,7 @@ function detectMediaType({
768
768
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
769
769
 
770
770
  // src/version.ts
771
- var VERSION = true ? "5.0.54" : "0.0.0-test";
771
+ var VERSION = true ? "5.0.56" : "0.0.0-test";
772
772
 
773
773
  // src/util/download/download.ts
774
774
  var download = async ({ url }) => {
@@ -4656,7 +4656,7 @@ var DefaultStreamTextResult = class {
4656
4656
  let activeReasoningContent = {};
4657
4657
  const eventProcessor = new TransformStream({
4658
4658
  async transform(chunk, controller) {
4659
- var _a17, _b, _c;
4659
+ var _a17, _b, _c, _d;
4660
4660
  controller.enqueue(chunk);
4661
4661
  const { part } = chunk;
4662
4662
  if (part.type === "text-delta" || part.type === "reasoning-delta" || part.type === "source" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-input-start" || part.type === "tool-input-delta" || part.type === "raw") {
@@ -4689,6 +4689,18 @@ var DefaultStreamTextResult = class {
4689
4689
  activeText.providerMetadata = (_a17 = part.providerMetadata) != null ? _a17 : activeText.providerMetadata;
4690
4690
  }
4691
4691
  if (part.type === "text-end") {
4692
+ const activeText = activeTextContent[part.id];
4693
+ if (activeText == null) {
4694
+ controller.enqueue({
4695
+ part: {
4696
+ type: "error",
4697
+ error: `text part ${part.id} not found`
4698
+ },
4699
+ partialOutput: void 0
4700
+ });
4701
+ return;
4702
+ }
4703
+ activeText.providerMetadata = (_b = part.providerMetadata) != null ? _b : activeText.providerMetadata;
4692
4704
  delete activeTextContent[part.id];
4693
4705
  }
4694
4706
  if (part.type === "reasoning-start") {
@@ -4712,7 +4724,7 @@ var DefaultStreamTextResult = class {
4712
4724
  return;
4713
4725
  }
4714
4726
  activeReasoning.text += part.text;
4715
- activeReasoning.providerMetadata = (_b = part.providerMetadata) != null ? _b : activeReasoning.providerMetadata;
4727
+ activeReasoning.providerMetadata = (_c = part.providerMetadata) != null ? _c : activeReasoning.providerMetadata;
4716
4728
  }
4717
4729
  if (part.type === "reasoning-end") {
4718
4730
  const activeReasoning = activeReasoningContent[part.id];
@@ -4726,7 +4738,7 @@ var DefaultStreamTextResult = class {
4726
4738
  });
4727
4739
  return;
4728
4740
  }
4729
- activeReasoning.providerMetadata = (_c = part.providerMetadata) != null ? _c : activeReasoning.providerMetadata;
4741
+ activeReasoning.providerMetadata = (_d = part.providerMetadata) != null ? _d : activeReasoning.providerMetadata;
4730
4742
  delete activeReasoningContent[part.id];
4731
4743
  }
4732
4744
  if (part.type === "file") {