ai 6.0.310 → 6.0.311

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.
@@ -164,7 +164,7 @@ function detectMediaType({
164
164
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
165
165
 
166
166
  // src/version.ts
167
- var VERSION = true ? "6.0.310" : "0.0.0-test";
167
+ var VERSION = true ? "6.0.311" : "0.0.0-test";
168
168
 
169
169
  // src/util/download/download.ts
170
170
  var download = async ({
@@ -144,7 +144,7 @@ import {
144
144
  } from "@ai-sdk/provider-utils";
145
145
 
146
146
  // src/version.ts
147
- var VERSION = true ? "6.0.310" : "0.0.0-test";
147
+ var VERSION = true ? "6.0.311" : "0.0.0-test";
148
148
 
149
149
  // src/util/download/download.ts
150
150
  var download = async ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "6.0.310",
3
+ "version": "6.0.311",
4
4
  "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -1411,6 +1411,19 @@ class DefaultStreamTextResult<
1411
1411
  },
1412
1412
  });
1413
1413
 
1414
+ // introduce a gate that prevent further tokens from
1415
+ // being emitted after a transform calls stopStream
1416
+ let isRunning = true;
1417
+ stream = stream.pipeThrough(
1418
+ new TransformStream({
1419
+ async transform(chunk, controller) {
1420
+ if (isRunning) {
1421
+ controller.enqueue(chunk);
1422
+ }
1423
+ },
1424
+ }),
1425
+ );
1426
+
1414
1427
  // transform the stream before output parsing
1415
1428
  // to enable replacement of stream segments:
1416
1429
  for (const transform of transforms) {
@@ -1419,6 +1432,7 @@ class DefaultStreamTextResult<
1419
1432
  tools: tools as TOOLS,
1420
1433
  stopStream() {
1421
1434
  stitchableStream.terminate();
1435
+ isRunning = false;
1422
1436
  },
1423
1437
  }),
1424
1438
  );