ai 5.0.11 → 5.0.13

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,26 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.13
4
+
5
+ ### Patch Changes
6
+
7
+ - a7b2e66: Added providerOptions to agent stream and generate calls
8
+ - 9bed210: ### `extractReasoningMiddleware()`: delay sending `text-start` chunk to prevent rendering final text before reasoning
9
+
10
+ When wrapping a text stream in `extractReasoningMiddleware()`, delay queing the `text-start` chunk until either `reasoning-start` chunk was queued or the first `text-delta` chunk is about to be queued, whichever comes first.
11
+
12
+ https://github.com/vercel/ai/pull/8036
13
+
14
+ ## 5.0.12
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [eefa730]
19
+ - Updated dependencies [034e229]
20
+ - Updated dependencies [f25040d]
21
+ - @ai-sdk/gateway@1.0.6
22
+ - @ai-sdk/provider-utils@3.0.3
23
+
3
24
  ## 5.0.11
4
25
 
5
26
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2089,6 +2089,12 @@ declare class Agent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = neve
2089
2089
  results that can be fully encapsulated in the provider.
2090
2090
  */
2091
2091
  providerMetadata?: ProviderMetadata;
2092
+ /**
2093
+ Additional provider-specific metadata. They are passed through
2094
+ to the provider from the AI SDK and enable provider-specific
2095
+ functionality that can be fully encapsulated in the provider.
2096
+ */
2097
+ providerOptions?: ProviderOptions;
2092
2098
  }): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
2093
2099
  stream(options: Prompt & {
2094
2100
  /**
@@ -2097,6 +2103,12 @@ declare class Agent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = neve
2097
2103
  results that can be fully encapsulated in the provider.
2098
2104
  */
2099
2105
  providerMetadata?: ProviderMetadata;
2106
+ /**
2107
+ Additional provider-specific metadata. They are passed through
2108
+ to the provider from the AI SDK and enable provider-specific
2109
+ functionality that can be fully encapsulated in the provider.
2110
+ */
2111
+ providerOptions?: ProviderOptions;
2100
2112
  }): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
2101
2113
  }
2102
2114
 
package/dist/index.d.ts CHANGED
@@ -2089,6 +2089,12 @@ declare class Agent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = neve
2089
2089
  results that can be fully encapsulated in the provider.
2090
2090
  */
2091
2091
  providerMetadata?: ProviderMetadata;
2092
+ /**
2093
+ Additional provider-specific metadata. They are passed through
2094
+ to the provider from the AI SDK and enable provider-specific
2095
+ functionality that can be fully encapsulated in the provider.
2096
+ */
2097
+ providerOptions?: ProviderOptions;
2092
2098
  }): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
2093
2099
  stream(options: Prompt & {
2094
2100
  /**
@@ -2097,6 +2103,12 @@ declare class Agent<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = neve
2097
2103
  results that can be fully encapsulated in the provider.
2098
2104
  */
2099
2105
  providerMetadata?: ProviderMetadata;
2106
+ /**
2107
+ Additional provider-specific metadata. They are passed through
2108
+ to the provider from the AI SDK and enable provider-specific
2109
+ functionality that can be fully encapsulated in the provider.
2110
+ */
2111
+ providerOptions?: ProviderOptions;
2100
2112
  }): StreamTextResult<TOOLS, OUTPUT_PARTIAL>;
2101
2113
  }
2102
2114
 
package/dist/index.js CHANGED
@@ -7730,10 +7730,19 @@ function extractReasoningMiddleware({
7730
7730
  wrapStream: async ({ doStream }) => {
7731
7731
  const { stream, ...rest } = await doStream();
7732
7732
  const reasoningExtractions = {};
7733
+ let delayedTextStart;
7733
7734
  return {
7734
7735
  stream: stream.pipeThrough(
7735
7736
  new TransformStream({
7736
7737
  transform: (chunk, controller) => {
7738
+ if (chunk.type === "text-start") {
7739
+ delayedTextStart = chunk;
7740
+ return;
7741
+ }
7742
+ if (chunk.type === "text-end" && delayedTextStart) {
7743
+ controller.enqueue(delayedTextStart);
7744
+ delayedTextStart = void 0;
7745
+ }
7737
7746
  if (chunk.type !== "text-delta") {
7738
7747
  controller.enqueue(chunk);
7739
7748
  return;
@@ -7760,17 +7769,23 @@ function extractReasoningMiddleware({
7760
7769
  id: `reasoning-${activeExtraction.idCounter}`
7761
7770
  });
7762
7771
  }
7763
- controller.enqueue(
7764
- activeExtraction.isReasoning ? {
7772
+ if (activeExtraction.isReasoning) {
7773
+ controller.enqueue({
7765
7774
  type: "reasoning-delta",
7766
7775
  delta: prefix + text2,
7767
7776
  id: `reasoning-${activeExtraction.idCounter}`
7768
- } : {
7777
+ });
7778
+ } else {
7779
+ if (delayedTextStart) {
7780
+ controller.enqueue(delayedTextStart);
7781
+ delayedTextStart = void 0;
7782
+ }
7783
+ controller.enqueue({
7769
7784
  type: "text-delta",
7770
7785
  delta: prefix + text2,
7771
7786
  id: activeExtraction.textId
7772
- }
7773
- );
7787
+ });
7788
+ }
7774
7789
  activeExtraction.afterSwitch = false;
7775
7790
  if (activeExtraction.isReasoning) {
7776
7791
  activeExtraction.isFirstReasoning = false;