ai 6.0.23 → 6.0.24

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/dist/index.mjs CHANGED
@@ -716,6 +716,12 @@ function getStepTimeoutMs(timeout) {
716
716
  }
717
717
  return timeout.stepMs;
718
718
  }
719
+ function getChunkTimeoutMs(timeout) {
720
+ if (timeout == null || typeof timeout === "number") {
721
+ return void 0;
722
+ }
723
+ return timeout.chunkMs;
724
+ }
719
725
 
720
726
  // src/prompt/convert-to-language-model-prompt.ts
721
727
  import {
@@ -915,7 +921,7 @@ import {
915
921
  } from "@ai-sdk/provider-utils";
916
922
 
917
923
  // src/version.ts
918
- var VERSION = true ? "6.0.23" : "0.0.0-test";
924
+ var VERSION = true ? "6.0.24" : "0.0.0-test";
919
925
 
920
926
  // src/util/download/download.ts
921
927
  var download = async ({ url }) => {
@@ -5693,7 +5699,9 @@ function streamText({
5693
5699
  }) {
5694
5700
  const totalTimeoutMs = getTotalTimeoutMs(timeout);
5695
5701
  const stepTimeoutMs = getStepTimeoutMs(timeout);
5702
+ const chunkTimeoutMs = getChunkTimeoutMs(timeout);
5696
5703
  const stepAbortController = stepTimeoutMs != null ? new AbortController() : void 0;
5704
+ const chunkAbortController = chunkTimeoutMs != null ? new AbortController() : void 0;
5697
5705
  return new DefaultStreamTextResult({
5698
5706
  model: resolveLanguageModel(model),
5699
5707
  telemetry,
@@ -5703,10 +5711,13 @@ function streamText({
5703
5711
  abortSignal: mergeAbortSignals(
5704
5712
  abortSignal,
5705
5713
  totalTimeoutMs != null ? AbortSignal.timeout(totalTimeoutMs) : void 0,
5706
- stepAbortController == null ? void 0 : stepAbortController.signal
5714
+ stepAbortController == null ? void 0 : stepAbortController.signal,
5715
+ chunkAbortController == null ? void 0 : chunkAbortController.signal
5707
5716
  ),
5708
5717
  stepTimeoutMs,
5709
5718
  stepAbortController,
5719
+ chunkTimeoutMs,
5720
+ chunkAbortController,
5710
5721
  system,
5711
5722
  prompt,
5712
5723
  messages,
@@ -5803,6 +5814,8 @@ var DefaultStreamTextResult = class {
5803
5814
  abortSignal,
5804
5815
  stepTimeoutMs,
5805
5816
  stepAbortController,
5817
+ chunkTimeoutMs,
5818
+ chunkAbortController,
5806
5819
  system,
5807
5820
  prompt,
5808
5821
  messages,
@@ -6269,6 +6282,29 @@ var DefaultStreamTextResult = class {
6269
6282
  var _a16, _b, _c, _d, _e, _f;
6270
6283
  const includeRawChunks2 = self.includeRawChunks;
6271
6284
  const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : void 0;
6285
+ let chunkTimeoutId = void 0;
6286
+ function resetChunkTimeout() {
6287
+ if (chunkTimeoutMs != null) {
6288
+ if (chunkTimeoutId != null) {
6289
+ clearTimeout(chunkTimeoutId);
6290
+ }
6291
+ chunkTimeoutId = setTimeout(
6292
+ () => chunkAbortController.abort(),
6293
+ chunkTimeoutMs
6294
+ );
6295
+ }
6296
+ }
6297
+ function clearChunkTimeout() {
6298
+ if (chunkTimeoutId != null) {
6299
+ clearTimeout(chunkTimeoutId);
6300
+ chunkTimeoutId = void 0;
6301
+ }
6302
+ }
6303
+ function clearStepTimeout() {
6304
+ if (stepTimeoutId != null) {
6305
+ clearTimeout(stepTimeoutId);
6306
+ }
6307
+ }
6272
6308
  stepFinish = new DelayedPromise();
6273
6309
  const stepInputMessages = [...initialMessages, ...responseMessages];
6274
6310
  const prepareStepResult = await (prepareStep == null ? void 0 : prepareStep({
@@ -6393,6 +6429,7 @@ var DefaultStreamTextResult = class {
6393
6429
  new TransformStream({
6394
6430
  async transform(chunk, controller) {
6395
6431
  var _a17, _b2, _c2, _d2, _e2;
6432
+ resetChunkTimeout();
6396
6433
  if (chunk.type === "stream-start") {
6397
6434
  warnings = chunk.warnings;
6398
6435
  return;
@@ -6623,9 +6660,8 @@ var DefaultStreamTextResult = class {
6623
6660
  pendingDeferredToolCalls.delete(output2.toolCallId);
6624
6661
  }
6625
6662
  }
6626
- if (stepTimeoutId != null) {
6627
- clearTimeout(stepTimeoutId);
6628
- }
6663
+ clearStepTimeout();
6664
+ clearChunkTimeout();
6629
6665
  if (
6630
6666
  // Continue if:
6631
6667
  // 1. There are client tool calls that have all been executed, OR
@@ -12116,11 +12152,9 @@ export {
12116
12152
  generateObject,
12117
12153
  generateText,
12118
12154
  getStaticToolName,
12119
- getStepTimeoutMs,
12120
12155
  getTextFromDataUrl,
12121
12156
  getToolName,
12122
12157
  getToolOrDynamicToolName,
12123
- getTotalTimeoutMs,
12124
12158
  hasToolCall,
12125
12159
  isDataUIPart,
12126
12160
  isDeepEqualData,