ai 4.0.15 → 4.0.17

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
+ ## 4.0.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 54bbf21: fix (ai/core): change streamText.experimental_transform signature to support tool type inference
8
+
9
+ ## 4.0.16
10
+
11
+ ### Patch Changes
12
+
13
+ - e3fac3f: fix (ai/core): change smoothStream default delay to 10ms
14
+
3
15
  ## 4.0.15
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2090,7 +2090,9 @@ Enable streaming of tool call deltas as they are generated. Disabled by default.
2090
2090
  /**
2091
2091
  Optional transformation that is applied to the stream.
2092
2092
  */
2093
- experimental_transform?: TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
2093
+ experimental_transform?: (options: {
2094
+ tools: TOOLS;
2095
+ }) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
2094
2096
  /**
2095
2097
  Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
2096
2098
  */
@@ -2125,6 +2127,12 @@ Details for all steps.
2125
2127
  };
2126
2128
  }): StreamTextResult<TOOLS>;
2127
2129
 
2130
+ /**
2131
+ * Smooths text streaming output.
2132
+ *
2133
+ * @param delayInMs - The delay in milliseconds between each chunk. Defaults to 10ms.
2134
+ * @returns A transform stream that smooths text streaming output.
2135
+ */
2128
2136
  declare function smoothStream<TOOLS extends Record<string, CoreTool>>({ delayInMs, _internal: { delay }, }?: {
2129
2137
  delayInMs?: number;
2130
2138
  /**
@@ -2133,7 +2141,9 @@ declare function smoothStream<TOOLS extends Record<string, CoreTool>>({ delayInM
2133
2141
  _internal?: {
2134
2142
  delay?: (delayInMs: number) => Promise<void>;
2135
2143
  };
2136
- }): TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
2144
+ }): (options: {
2145
+ tools: TOOLS;
2146
+ }) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
2137
2147
 
2138
2148
  /**
2139
2149
  * Experimental middleware for LanguageModelV1.
package/dist/index.d.ts CHANGED
@@ -2090,7 +2090,9 @@ Enable streaming of tool call deltas as they are generated. Disabled by default.
2090
2090
  /**
2091
2091
  Optional transformation that is applied to the stream.
2092
2092
  */
2093
- experimental_transform?: TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
2093
+ experimental_transform?: (options: {
2094
+ tools: TOOLS;
2095
+ }) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
2094
2096
  /**
2095
2097
  Callback that is called for each chunk of the stream. The stream processing will pause until the callback promise is resolved.
2096
2098
  */
@@ -2125,6 +2127,12 @@ Details for all steps.
2125
2127
  };
2126
2128
  }): StreamTextResult<TOOLS>;
2127
2129
 
2130
+ /**
2131
+ * Smooths text streaming output.
2132
+ *
2133
+ * @param delayInMs - The delay in milliseconds between each chunk. Defaults to 10ms.
2134
+ * @returns A transform stream that smooths text streaming output.
2135
+ */
2128
2136
  declare function smoothStream<TOOLS extends Record<string, CoreTool>>({ delayInMs, _internal: { delay }, }?: {
2129
2137
  delayInMs?: number;
2130
2138
  /**
@@ -2133,7 +2141,9 @@ declare function smoothStream<TOOLS extends Record<string, CoreTool>>({ delayInM
2133
2141
  _internal?: {
2134
2142
  delay?: (delayInMs: number) => Promise<void>;
2135
2143
  };
2136
- }): TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
2144
+ }): (options: {
2145
+ tools: TOOLS;
2146
+ }) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
2137
2147
 
2138
2148
  /**
2139
2149
  * Experimental middleware for LanguageModelV1.
package/dist/index.js CHANGED
@@ -4268,7 +4268,7 @@ function streamText({
4268
4268
  tools,
4269
4269
  toolChoice,
4270
4270
  toolCallStreaming,
4271
- transform,
4271
+ transform: transform == null ? void 0 : transform({ tools }),
4272
4272
  activeTools,
4273
4273
  repairToolCall,
4274
4274
  maxSteps,
@@ -5046,11 +5046,11 @@ var DefaultStreamTextResult = class {
5046
5046
 
5047
5047
  // core/generate-text/smooth-stream.ts
5048
5048
  function smoothStream({
5049
- delayInMs = 40,
5049
+ delayInMs = 10,
5050
5050
  _internal: { delay: delay2 = delay } = {}
5051
5051
  } = {}) {
5052
5052
  let buffer = "";
5053
- return new TransformStream({
5053
+ return () => new TransformStream({
5054
5054
  async transform(chunk, controller) {
5055
5055
  if (chunk.type === "step-finish") {
5056
5056
  if (buffer.length > 0) {