ai 6.0.14 → 6.0.16

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
+ ## 6.0.16
4
+
5
+ ### Patch Changes
6
+
7
+ - 81adf59: feat(ai): introduce timeout configuration object
8
+
9
+ ## 6.0.15
10
+
11
+ ### Patch Changes
12
+
13
+ - 3a73fb3: Include abort reason in stream chunks and document the new field
14
+
3
15
  ## 6.0.14
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -941,6 +941,21 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
941
941
  readonly output: InferCompleteOutput<OUTPUT>;
942
942
  }
943
943
 
944
+ /**
945
+ Timeout configuration for API calls. Can be specified as:
946
+ - A number representing milliseconds
947
+ - An object with `totalMs` property for the total timeout in milliseconds
948
+ */
949
+ type TimeoutConfiguration = number | {
950
+ totalMs?: number;
951
+ };
952
+ /**
953
+ Extracts the total timeout value in milliseconds from a TimeoutConfiguration.
954
+
955
+ @param timeout - The timeout configuration.
956
+ @returns The total timeout in milliseconds, or undefined if no timeout is configured.
957
+ */
958
+ declare function getTotalTimeoutMs(timeout: TimeoutConfiguration | undefined): number | undefined;
944
959
  type CallSettings = {
945
960
  /**
946
961
  Maximum number of tokens to generate.
@@ -1008,8 +1023,10 @@ type CallSettings = {
1008
1023
  /**
1009
1024
  Timeout in milliseconds. The call will be aborted if it takes longer
1010
1025
  than the specified timeout. Can be used alongside abortSignal.
1026
+
1027
+ Can be specified as a number (milliseconds) or as an object with `totalMs`.
1011
1028
  */
1012
- timeout?: number;
1029
+ timeout?: TimeoutConfiguration;
1013
1030
  /**
1014
1031
  Additional HTTP headers to be sent with the request.
1015
1032
  Only applicable for HTTP-based providers.
@@ -1994,6 +2011,7 @@ declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazySchema<{
1994
2011
  messageMetadata?: unknown;
1995
2012
  } | {
1996
2013
  type: "abort";
2014
+ reason?: string | undefined;
1997
2015
  } | {
1998
2016
  type: "message-metadata";
1999
2017
  messageMetadata: unknown;
@@ -2117,6 +2135,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
2117
2135
  messageMetadata?: METADATA;
2118
2136
  } | {
2119
2137
  type: 'abort';
2138
+ reason?: string;
2120
2139
  } | {
2121
2140
  type: 'message-metadata';
2122
2141
  messageMetadata: METADATA;
@@ -2506,6 +2525,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2506
2525
  totalUsage: LanguageModelUsage;
2507
2526
  } | {
2508
2527
  type: 'abort';
2528
+ reason?: string;
2509
2529
  } | {
2510
2530
  type: 'error';
2511
2531
  error: unknown;
@@ -2792,9 +2812,9 @@ type AgentCallParameters<CALL_OPTIONS> = ([CALL_OPTIONS] extends [never] ? {
2792
2812
  */
2793
2813
  abortSignal?: AbortSignal;
2794
2814
  /**
2795
- * Timeout in milliseconds.
2815
+ * Timeout in milliseconds. Can be specified as a number or as an object with `totalMs`.
2796
2816
  */
2797
- timeout?: number;
2817
+ timeout?: TimeoutConfiguration;
2798
2818
  };
2799
2819
  /**
2800
2820
  * Parameters for streaming an output from an agent.
@@ -3019,7 +3039,7 @@ declare function createAgentUIStreamResponse<CALL_OPTIONS = never, TOOLS extends
3019
3039
  agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
3020
3040
  uiMessages: unknown[];
3021
3041
  abortSignal?: AbortSignal;
3022
- timeout?: number;
3042
+ timeout?: TimeoutConfiguration;
3023
3043
  options?: CALL_OPTIONS;
3024
3044
  experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
3025
3045
  } & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<Response>;
@@ -3740,7 +3760,7 @@ declare function createAgentUIStream<CALL_OPTIONS = never, TOOLS extends ToolSet
3740
3760
  agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
3741
3761
  uiMessages: unknown[];
3742
3762
  abortSignal?: AbortSignal;
3743
- timeout?: number;
3763
+ timeout?: TimeoutConfiguration;
3744
3764
  options?: CALL_OPTIONS;
3745
3765
  experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
3746
3766
  } & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<AsyncIterableStream<InferUIMessageChunk<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>>>;
@@ -3756,7 +3776,7 @@ declare function pipeAgentUIStreamToResponse<CALL_OPTIONS = never, TOOLS extends
3756
3776
  agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
3757
3777
  uiMessages: unknown[];
3758
3778
  abortSignal?: AbortSignal;
3759
- timeout?: number;
3779
+ timeout?: TimeoutConfiguration;
3760
3780
  options?: CALL_OPTIONS;
3761
3781
  experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
3762
3782
  } & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<void>;
@@ -5533,4 +5553,4 @@ declare global {
5533
5553
  var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
5534
5554
  }
5535
5555
 
5536
- export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
5556
+ export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, getTotalTimeoutMs, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
package/dist/index.d.ts CHANGED
@@ -941,6 +941,21 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
941
941
  readonly output: InferCompleteOutput<OUTPUT>;
942
942
  }
943
943
 
944
+ /**
945
+ Timeout configuration for API calls. Can be specified as:
946
+ - A number representing milliseconds
947
+ - An object with `totalMs` property for the total timeout in milliseconds
948
+ */
949
+ type TimeoutConfiguration = number | {
950
+ totalMs?: number;
951
+ };
952
+ /**
953
+ Extracts the total timeout value in milliseconds from a TimeoutConfiguration.
954
+
955
+ @param timeout - The timeout configuration.
956
+ @returns The total timeout in milliseconds, or undefined if no timeout is configured.
957
+ */
958
+ declare function getTotalTimeoutMs(timeout: TimeoutConfiguration | undefined): number | undefined;
944
959
  type CallSettings = {
945
960
  /**
946
961
  Maximum number of tokens to generate.
@@ -1008,8 +1023,10 @@ type CallSettings = {
1008
1023
  /**
1009
1024
  Timeout in milliseconds. The call will be aborted if it takes longer
1010
1025
  than the specified timeout. Can be used alongside abortSignal.
1026
+
1027
+ Can be specified as a number (milliseconds) or as an object with `totalMs`.
1011
1028
  */
1012
- timeout?: number;
1029
+ timeout?: TimeoutConfiguration;
1013
1030
  /**
1014
1031
  Additional HTTP headers to be sent with the request.
1015
1032
  Only applicable for HTTP-based providers.
@@ -1994,6 +2011,7 @@ declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazySchema<{
1994
2011
  messageMetadata?: unknown;
1995
2012
  } | {
1996
2013
  type: "abort";
2014
+ reason?: string | undefined;
1997
2015
  } | {
1998
2016
  type: "message-metadata";
1999
2017
  messageMetadata: unknown;
@@ -2117,6 +2135,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
2117
2135
  messageMetadata?: METADATA;
2118
2136
  } | {
2119
2137
  type: 'abort';
2138
+ reason?: string;
2120
2139
  } | {
2121
2140
  type: 'message-metadata';
2122
2141
  messageMetadata: METADATA;
@@ -2506,6 +2525,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2506
2525
  totalUsage: LanguageModelUsage;
2507
2526
  } | {
2508
2527
  type: 'abort';
2528
+ reason?: string;
2509
2529
  } | {
2510
2530
  type: 'error';
2511
2531
  error: unknown;
@@ -2792,9 +2812,9 @@ type AgentCallParameters<CALL_OPTIONS> = ([CALL_OPTIONS] extends [never] ? {
2792
2812
  */
2793
2813
  abortSignal?: AbortSignal;
2794
2814
  /**
2795
- * Timeout in milliseconds.
2815
+ * Timeout in milliseconds. Can be specified as a number or as an object with `totalMs`.
2796
2816
  */
2797
- timeout?: number;
2817
+ timeout?: TimeoutConfiguration;
2798
2818
  };
2799
2819
  /**
2800
2820
  * Parameters for streaming an output from an agent.
@@ -3019,7 +3039,7 @@ declare function createAgentUIStreamResponse<CALL_OPTIONS = never, TOOLS extends
3019
3039
  agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
3020
3040
  uiMessages: unknown[];
3021
3041
  abortSignal?: AbortSignal;
3022
- timeout?: number;
3042
+ timeout?: TimeoutConfiguration;
3023
3043
  options?: CALL_OPTIONS;
3024
3044
  experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
3025
3045
  } & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<Response>;
@@ -3740,7 +3760,7 @@ declare function createAgentUIStream<CALL_OPTIONS = never, TOOLS extends ToolSet
3740
3760
  agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
3741
3761
  uiMessages: unknown[];
3742
3762
  abortSignal?: AbortSignal;
3743
- timeout?: number;
3763
+ timeout?: TimeoutConfiguration;
3744
3764
  options?: CALL_OPTIONS;
3745
3765
  experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
3746
3766
  } & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<AsyncIterableStream<InferUIMessageChunk<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>>>;
@@ -3756,7 +3776,7 @@ declare function pipeAgentUIStreamToResponse<CALL_OPTIONS = never, TOOLS extends
3756
3776
  agent: Agent<CALL_OPTIONS, TOOLS, OUTPUT>;
3757
3777
  uiMessages: unknown[];
3758
3778
  abortSignal?: AbortSignal;
3759
- timeout?: number;
3779
+ timeout?: TimeoutConfiguration;
3760
3780
  options?: CALL_OPTIONS;
3761
3781
  experimental_transform?: StreamTextTransform<TOOLS> | Array<StreamTextTransform<TOOLS>>;
3762
3782
  } & UIMessageStreamResponseInit & UIMessageStreamOptions<UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>>): Promise<void>;
@@ -5533,4 +5553,4 @@ declare global {
5533
5553
  var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
5534
5554
  }
5535
5555
 
5536
- export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
5556
+ export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, getTotalTimeoutMs, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
package/dist/index.js CHANGED
@@ -99,6 +99,7 @@ __export(src_exports, {
99
99
  getTextFromDataUrl: () => getTextFromDataUrl,
100
100
  getToolName: () => getToolName,
101
101
  getToolOrDynamicToolName: () => getToolOrDynamicToolName,
102
+ getTotalTimeoutMs: () => getTotalTimeoutMs,
102
103
  hasToolCall: () => hasToolCall,
103
104
  isDataUIPart: () => isDataUIPart,
104
105
  isDeepEqualData: () => isDeepEqualData,
@@ -808,6 +809,17 @@ function getGlobalProvider() {
808
809
  return (_a16 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a16 : import_gateway.gateway;
809
810
  }
810
811
 
812
+ // src/prompt/call-settings.ts
813
+ function getTotalTimeoutMs(timeout) {
814
+ if (timeout == null) {
815
+ return void 0;
816
+ }
817
+ if (typeof timeout === "number") {
818
+ return timeout;
819
+ }
820
+ return timeout.totalMs;
821
+ }
822
+
811
823
  // src/prompt/convert-to-language-model-prompt.ts
812
824
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
813
825
 
@@ -1001,7 +1013,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
1001
1013
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
1002
1014
 
1003
1015
  // src/version.ts
1004
- var VERSION = true ? "6.0.14" : "0.0.0-test";
1016
+ var VERSION = true ? "6.0.16" : "0.0.0-test";
1005
1017
 
1006
1018
  // src/util/download/download.ts
1007
1019
  var download = async ({ url }) => {
@@ -1927,7 +1939,16 @@ function getBaseTelemetryAttributes({
1927
1939
  "ai.model.id": model.modelId,
1928
1940
  // settings:
1929
1941
  ...Object.entries(settings).reduce((attributes, [key, value]) => {
1930
- attributes[`ai.settings.${key}`] = value;
1942
+ if (key === "timeout") {
1943
+ const totalTimeoutMs = getTotalTimeoutMs(
1944
+ value
1945
+ );
1946
+ if (totalTimeoutMs != null) {
1947
+ attributes[`ai.settings.${key}`] = totalTimeoutMs;
1948
+ }
1949
+ } else {
1950
+ attributes[`ai.settings.${key}`] = value;
1951
+ }
1931
1952
  return attributes;
1932
1953
  }, {}),
1933
1954
  // add metadata as attributes:
@@ -3648,9 +3669,10 @@ async function generateText({
3648
3669
  }) {
3649
3670
  const model = resolveLanguageModel(modelArg);
3650
3671
  const stopConditions = asArray(stopWhen);
3672
+ const totalTimeoutMs = getTotalTimeoutMs(timeout);
3651
3673
  const mergedAbortSignal = mergeAbortSignals(
3652
3674
  abortSignal,
3653
- timeout != null ? AbortSignal.timeout(timeout) : void 0
3675
+ totalTimeoutMs != null ? AbortSignal.timeout(totalTimeoutMs) : void 0
3654
3676
  );
3655
3677
  const { maxRetries, retry } = prepareRetries({
3656
3678
  maxRetries: maxRetriesArg,
@@ -4653,7 +4675,8 @@ var uiMessageChunkSchema = (0, import_provider_utils16.lazySchema)(
4653
4675
  messageMetadata: import_v47.z.unknown().optional()
4654
4676
  }),
4655
4677
  import_v47.z.strictObject({
4656
- type: import_v47.z.literal("abort")
4678
+ type: import_v47.z.literal("abort"),
4679
+ reason: import_v47.z.string().optional()
4657
4680
  }),
4658
4681
  import_v47.z.strictObject({
4659
4682
  type: import_v47.z.literal("message-metadata"),
@@ -5736,6 +5759,7 @@ function streamText({
5736
5759
  } = {},
5737
5760
  ...settings
5738
5761
  }) {
5762
+ const totalTimeoutMs = getTotalTimeoutMs(timeout);
5739
5763
  return new DefaultStreamTextResult({
5740
5764
  model: resolveLanguageModel(model),
5741
5765
  telemetry,
@@ -5744,7 +5768,7 @@ function streamText({
5744
5768
  maxRetries,
5745
5769
  abortSignal: mergeAbortSignals(
5746
5770
  abortSignal,
5747
- timeout != null ? AbortSignal.timeout(timeout) : void 0
5771
+ totalTimeoutMs != null ? AbortSignal.timeout(totalTimeoutMs) : void 0
5748
5772
  ),
5749
5773
  system,
5750
5774
  prompt,
@@ -6115,7 +6139,13 @@ var DefaultStreamTextResult = class {
6115
6139
  async pull(controller) {
6116
6140
  function abort() {
6117
6141
  onAbort == null ? void 0 : onAbort({ steps: recordedSteps });
6118
- controller.enqueue({ type: "abort" });
6142
+ controller.enqueue({
6143
+ type: "abort",
6144
+ // The `reason` is usually of type DOMException, but it can also be of any type,
6145
+ // so we use getErrorMessage for serialization because it is already designed to accept values of the unknown type.
6146
+ // See: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/reason
6147
+ ...(abortSignal == null ? void 0 : abortSignal.reason) !== void 0 ? { reason: (0, import_provider24.getErrorMessage)(abortSignal.reason) } : {}
6148
+ });
6119
6149
  controller.close();
6120
6150
  }
6121
6151
  try {
@@ -12097,6 +12127,7 @@ var TextStreamChatTransport = class extends HttpChatTransport {
12097
12127
  getTextFromDataUrl,
12098
12128
  getToolName,
12099
12129
  getToolOrDynamicToolName,
12130
+ getTotalTimeoutMs,
12100
12131
  hasToolCall,
12101
12132
  isDataUIPart,
12102
12133
  isDeepEqualData,