ai 5.0.10 → 5.0.12

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.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [eefa730]
8
+ - Updated dependencies [034e229]
9
+ - Updated dependencies [f25040d]
10
+ - @ai-sdk/gateway@1.0.6
11
+ - @ai-sdk/provider-utils@3.0.3
12
+
13
+ ## 5.0.11
14
+
15
+ ### Patch Changes
16
+
17
+ - 38ac190: feat(ai): preliminary tool results
18
+ - e3a63cb: fix(ai): streamText promises reject when stream has errors
19
+ - Updated dependencies [38ac190]
20
+ - Updated dependencies [cf7b2ad]
21
+ - @ai-sdk/provider-utils@3.0.2
22
+ - @ai-sdk/gateway@1.0.5
23
+
3
24
  ## 5.0.10
4
25
 
5
26
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -484,6 +484,7 @@ type StaticToolResult<TOOLS extends ToolSet> = ValueOf<{
484
484
  output: InferToolOutput<TOOLS[NAME]>;
485
485
  providerExecuted?: boolean;
486
486
  dynamic?: false | undefined;
487
+ preliminary?: boolean;
487
488
  };
488
489
  }>;
489
490
  type DynamicToolResult = {
@@ -494,6 +495,7 @@ type DynamicToolResult = {
494
495
  output: unknown;
495
496
  providerExecuted?: boolean;
496
497
  dynamic: true;
498
+ preliminary?: boolean;
497
499
  };
498
500
  type TypedToolResult<TOOLS extends ToolSet> = StaticToolResult<TOOLS> | DynamicToolResult;
499
501
 
@@ -814,9 +816,9 @@ type StopCondition<TOOLS extends ToolSet> = (options: {
814
816
  declare function stepCountIs(stepCount: number): StopCondition<any>;
815
817
  declare function hasToolCall(toolName: string): StopCondition<any>;
816
818
 
817
- declare const symbol$e: unique symbol;
819
+ declare const symbol$f: unique symbol;
818
820
  declare class InvalidToolInputError extends AISDKError {
819
- private readonly [symbol$e];
821
+ private readonly [symbol$f];
820
822
  readonly toolName: string;
821
823
  readonly toolInput: string;
822
824
  constructor({ toolInput, toolName, cause, message, }: {
@@ -828,9 +830,9 @@ declare class InvalidToolInputError extends AISDKError {
828
830
  static isInstance(error: unknown): error is InvalidToolInputError;
829
831
  }
830
832
 
831
- declare const symbol$d: unique symbol;
833
+ declare const symbol$e: unique symbol;
832
834
  declare class NoSuchToolError extends AISDKError {
833
- private readonly [symbol$d];
835
+ private readonly [symbol$e];
834
836
  readonly toolName: string;
835
837
  readonly availableTools: string[] | undefined;
836
838
  constructor({ toolName, availableTools, message, }: {
@@ -1459,6 +1461,7 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
1459
1461
  errorText?: never;
1460
1462
  providerExecuted?: boolean;
1461
1463
  callProviderMetadata?: ProviderMetadata;
1464
+ preliminary?: boolean;
1462
1465
  } | {
1463
1466
  state: 'output-error';
1464
1467
  input: TOOLS[NAME]['input'] | undefined;
@@ -1490,6 +1493,7 @@ type DynamicToolUIPart = {
1490
1493
  output: unknown;
1491
1494
  errorText?: never;
1492
1495
  callProviderMetadata?: ProviderMetadata;
1496
+ preliminary?: boolean;
1493
1497
  } | {
1494
1498
  state: 'output-error';
1495
1499
  input: unknown;
@@ -1572,6 +1576,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
1572
1576
  output: unknown;
1573
1577
  providerExecuted?: boolean;
1574
1578
  dynamic?: boolean;
1579
+ preliminary?: boolean;
1575
1580
  } | {
1576
1581
  type: 'tool-output-error';
1577
1582
  toolCallId: string;
@@ -1718,110 +1723,118 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
1718
1723
  /**
1719
1724
  The content that was generated in the last step.
1720
1725
 
1721
- Resolved when the response is finished.
1726
+ Automatically consumes the stream.
1722
1727
  */
1723
1728
  readonly content: Promise<Array<ContentPart<TOOLS>>>;
1724
1729
  /**
1725
1730
  The full text that has been generated by the last step.
1726
1731
 
1727
- Resolved when the response is finished.
1732
+ Automatically consumes the stream.
1728
1733
  */
1729
1734
  readonly text: Promise<string>;
1730
1735
  /**
1731
1736
  The full reasoning that the model has generated.
1732
1737
 
1733
- Resolved when the response is finished.
1738
+ Automatically consumes the stream.
1734
1739
  */
1735
1740
  readonly reasoning: Promise<Array<ReasoningPart>>;
1736
1741
  /**
1737
1742
  The reasoning that has been generated by the last step.
1738
1743
 
1739
- Resolved when the response is finished.
1744
+ Automatically consumes the stream.
1740
1745
  */
1741
1746
  readonly reasoningText: Promise<string | undefined>;
1742
1747
  /**
1743
1748
  Files that have been generated by the model in the last step.
1744
1749
 
1745
- Resolved when the response is finished.
1750
+ Automatically consumes the stream.
1746
1751
  */
1747
1752
  readonly files: Promise<GeneratedFile[]>;
1748
1753
  /**
1749
1754
  Sources that have been used as references in the last step.
1750
1755
 
1751
- Resolved when the response is finished.
1756
+ Automatically consumes the stream.
1752
1757
  */
1753
1758
  readonly sources: Promise<Source[]>;
1754
1759
  /**
1755
1760
  The tool calls that have been executed in the last step.
1756
1761
 
1757
- Resolved when the response is finished.
1762
+ Automatically consumes the stream.
1758
1763
  */
1759
1764
  readonly toolCalls: Promise<TypedToolCall<TOOLS>[]>;
1760
1765
  /**
1761
1766
  The static tool calls that have been executed in the last step.
1762
1767
 
1763
- Resolved when the response is finished.
1768
+ Automatically consumes the stream.
1764
1769
  */
1765
1770
  readonly staticToolCalls: Promise<StaticToolCall<TOOLS>[]>;
1766
1771
  /**
1767
1772
  The dynamic tool calls that have been executed in the last step.
1768
1773
 
1769
- Resolved when the response is finished.
1774
+ Automatically consumes the stream.
1770
1775
  */
1771
1776
  readonly dynamicToolCalls: Promise<DynamicToolCall[]>;
1772
1777
  /**
1773
1778
  The static tool results that have been generated in the last step.
1774
1779
 
1775
- Resolved when the response is finished.
1780
+ Automatically consumes the stream.
1776
1781
  */
1777
1782
  readonly staticToolResults: Promise<StaticToolResult<TOOLS>[]>;
1778
1783
  /**
1779
1784
  The dynamic tool results that have been generated in the last step.
1780
1785
 
1781
- Resolved when the response is finished.
1786
+ Automatically consumes the stream.
1782
1787
  */
1783
1788
  readonly dynamicToolResults: Promise<DynamicToolResult[]>;
1784
1789
  /**
1785
1790
  The tool results that have been generated in the last step.
1786
1791
 
1787
- Resolved when the all tool executions are finished.
1792
+ Automatically consumes the stream.
1788
1793
  */
1789
1794
  readonly toolResults: Promise<TypedToolResult<TOOLS>[]>;
1790
1795
  /**
1791
1796
  The reason why the generation finished. Taken from the last step.
1792
1797
 
1793
- Resolved when the response is finished.
1798
+ Automatically consumes the stream.
1794
1799
  */
1795
1800
  readonly finishReason: Promise<FinishReason>;
1796
1801
  /**
1797
1802
  The token usage of the last step.
1798
1803
 
1799
- Resolved when the response is finished.
1804
+ Automatically consumes the stream.
1800
1805
  */
1801
1806
  readonly usage: Promise<LanguageModelUsage>;
1802
1807
  /**
1803
1808
  The total token usage of the generated response.
1804
1809
  When there are multiple steps, the usage is the sum of all step usages.
1805
1810
 
1806
- Resolved when the response is finished.
1811
+ Automatically consumes the stream.
1807
1812
  */
1808
1813
  readonly totalUsage: Promise<LanguageModelUsage>;
1809
1814
  /**
1810
1815
  Warnings from the model provider (e.g. unsupported settings) for the first step.
1816
+
1817
+ Automatically consumes the stream.
1811
1818
  */
1812
1819
  readonly warnings: Promise<CallWarning[] | undefined>;
1813
1820
  /**
1814
1821
  Details for all steps.
1815
1822
  You can use this to get information about intermediate steps,
1816
1823
  such as the tool calls or the response headers.
1824
+
1825
+ Automatically consumes the stream.
1817
1826
  */
1818
1827
  readonly steps: Promise<Array<StepResult<TOOLS>>>;
1819
1828
  /**
1820
1829
  Additional request information from the last step.
1830
+
1831
+ Automatically consumes the stream.
1821
1832
  */
1822
1833
  readonly request: Promise<LanguageModelRequestMetadata>;
1823
1834
  /**
1824
1835
  Additional response information from the last step.
1836
+
1837
+ Automatically consumes the stream.
1825
1838
  */
1826
1839
  readonly response: Promise<LanguageModelResponseMetadata & {
1827
1840
  /**
@@ -2265,9 +2278,9 @@ declare function embedMany<VALUE = string>({ model: modelArg, values, maxParalle
2265
2278
  maxParallelCalls?: number;
2266
2279
  }): Promise<EmbedManyResult<VALUE>>;
2267
2280
 
2268
- declare const symbol$c: unique symbol;
2281
+ declare const symbol$d: unique symbol;
2269
2282
  declare class InvalidArgumentError extends AISDKError {
2270
- private readonly [symbol$c];
2283
+ private readonly [symbol$d];
2271
2284
  readonly parameter: string;
2272
2285
  readonly value: unknown;
2273
2286
  constructor({ parameter, value, message, }: {
@@ -2353,9 +2366,9 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
2353
2366
  rawValue: unknown;
2354
2367
  };
2355
2368
 
2356
- declare const symbol$b: unique symbol;
2369
+ declare const symbol$c: unique symbol;
2357
2370
  declare class InvalidStreamPartError extends AISDKError {
2358
- private readonly [symbol$b];
2371
+ private readonly [symbol$c];
2359
2372
  readonly chunk: SingleRequestTextStreamPart<any>;
2360
2373
  constructor({ chunk, message, }: {
2361
2374
  chunk: SingleRequestTextStreamPart<any>;
@@ -2364,12 +2377,12 @@ declare class InvalidStreamPartError extends AISDKError {
2364
2377
  static isInstance(error: unknown): error is InvalidStreamPartError;
2365
2378
  }
2366
2379
 
2367
- declare const symbol$a: unique symbol;
2380
+ declare const symbol$b: unique symbol;
2368
2381
  /**
2369
2382
  * An error occurred with the MCP client.
2370
2383
  */
2371
2384
  declare class MCPClientError extends AISDKError {
2372
- private readonly [symbol$a];
2385
+ private readonly [symbol$b];
2373
2386
  constructor({ name, message, cause, }: {
2374
2387
  name?: string;
2375
2388
  message: string;
@@ -2378,7 +2391,7 @@ declare class MCPClientError extends AISDKError {
2378
2391
  static isInstance(error: unknown): error is MCPClientError;
2379
2392
  }
2380
2393
 
2381
- declare const symbol$9: unique symbol;
2394
+ declare const symbol$a: unique symbol;
2382
2395
  /**
2383
2396
  Thrown when no image could be generated. This can have multiple causes:
2384
2397
 
@@ -2386,7 +2399,7 @@ Thrown when no image could be generated. This can have multiple causes:
2386
2399
  - The model generated a response that could not be parsed.
2387
2400
  */
2388
2401
  declare class NoImageGeneratedError extends AISDKError {
2389
- private readonly [symbol$9];
2402
+ private readonly [symbol$a];
2390
2403
  /**
2391
2404
  The response metadata for each call.
2392
2405
  */
@@ -2399,7 +2412,7 @@ declare class NoImageGeneratedError extends AISDKError {
2399
2412
  static isInstance(error: unknown): error is NoImageGeneratedError;
2400
2413
  }
2401
2414
 
2402
- declare const symbol$8: unique symbol;
2415
+ declare const symbol$9: unique symbol;
2403
2416
  /**
2404
2417
  Thrown when no object could be generated. This can have several causes:
2405
2418
 
@@ -2412,7 +2425,7 @@ The error contains the following properties:
2412
2425
  - `text`: The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
2413
2426
  */
2414
2427
  declare class NoObjectGeneratedError extends AISDKError {
2415
- private readonly [symbol$8];
2428
+ private readonly [symbol$9];
2416
2429
  /**
2417
2430
  The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
2418
2431
  */
@@ -2440,6 +2453,19 @@ declare class NoObjectGeneratedError extends AISDKError {
2440
2453
  static isInstance(error: unknown): error is NoObjectGeneratedError;
2441
2454
  }
2442
2455
 
2456
+ declare const symbol$8: unique symbol;
2457
+ /**
2458
+ Thrown when no LLM output was generated, e.g. because of errors.
2459
+ */
2460
+ declare class NoOutputGeneratedError extends AISDKError {
2461
+ private readonly [symbol$8];
2462
+ constructor({ message, cause, }?: {
2463
+ message?: string;
2464
+ cause?: Error;
2465
+ });
2466
+ static isInstance(error: unknown): error is NoOutputGeneratedError;
2467
+ }
2468
+
2443
2469
  declare const symbol$7: unique symbol;
2444
2470
  /**
2445
2471
  Thrown when no output type is specified and output-related methods are called.
@@ -4291,4 +4317,4 @@ declare global {
4291
4317
  var AI_SDK_DEFAULT_PROVIDER: ProviderV2 | undefined;
4292
4318
  }
4293
4319
 
4294
- export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };
4320
+ export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };
package/dist/index.d.ts CHANGED
@@ -484,6 +484,7 @@ type StaticToolResult<TOOLS extends ToolSet> = ValueOf<{
484
484
  output: InferToolOutput<TOOLS[NAME]>;
485
485
  providerExecuted?: boolean;
486
486
  dynamic?: false | undefined;
487
+ preliminary?: boolean;
487
488
  };
488
489
  }>;
489
490
  type DynamicToolResult = {
@@ -494,6 +495,7 @@ type DynamicToolResult = {
494
495
  output: unknown;
495
496
  providerExecuted?: boolean;
496
497
  dynamic: true;
498
+ preliminary?: boolean;
497
499
  };
498
500
  type TypedToolResult<TOOLS extends ToolSet> = StaticToolResult<TOOLS> | DynamicToolResult;
499
501
 
@@ -814,9 +816,9 @@ type StopCondition<TOOLS extends ToolSet> = (options: {
814
816
  declare function stepCountIs(stepCount: number): StopCondition<any>;
815
817
  declare function hasToolCall(toolName: string): StopCondition<any>;
816
818
 
817
- declare const symbol$e: unique symbol;
819
+ declare const symbol$f: unique symbol;
818
820
  declare class InvalidToolInputError extends AISDKError {
819
- private readonly [symbol$e];
821
+ private readonly [symbol$f];
820
822
  readonly toolName: string;
821
823
  readonly toolInput: string;
822
824
  constructor({ toolInput, toolName, cause, message, }: {
@@ -828,9 +830,9 @@ declare class InvalidToolInputError extends AISDKError {
828
830
  static isInstance(error: unknown): error is InvalidToolInputError;
829
831
  }
830
832
 
831
- declare const symbol$d: unique symbol;
833
+ declare const symbol$e: unique symbol;
832
834
  declare class NoSuchToolError extends AISDKError {
833
- private readonly [symbol$d];
835
+ private readonly [symbol$e];
834
836
  readonly toolName: string;
835
837
  readonly availableTools: string[] | undefined;
836
838
  constructor({ toolName, availableTools, message, }: {
@@ -1459,6 +1461,7 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
1459
1461
  errorText?: never;
1460
1462
  providerExecuted?: boolean;
1461
1463
  callProviderMetadata?: ProviderMetadata;
1464
+ preliminary?: boolean;
1462
1465
  } | {
1463
1466
  state: 'output-error';
1464
1467
  input: TOOLS[NAME]['input'] | undefined;
@@ -1490,6 +1493,7 @@ type DynamicToolUIPart = {
1490
1493
  output: unknown;
1491
1494
  errorText?: never;
1492
1495
  callProviderMetadata?: ProviderMetadata;
1496
+ preliminary?: boolean;
1493
1497
  } | {
1494
1498
  state: 'output-error';
1495
1499
  input: unknown;
@@ -1572,6 +1576,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
1572
1576
  output: unknown;
1573
1577
  providerExecuted?: boolean;
1574
1578
  dynamic?: boolean;
1579
+ preliminary?: boolean;
1575
1580
  } | {
1576
1581
  type: 'tool-output-error';
1577
1582
  toolCallId: string;
@@ -1718,110 +1723,118 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
1718
1723
  /**
1719
1724
  The content that was generated in the last step.
1720
1725
 
1721
- Resolved when the response is finished.
1726
+ Automatically consumes the stream.
1722
1727
  */
1723
1728
  readonly content: Promise<Array<ContentPart<TOOLS>>>;
1724
1729
  /**
1725
1730
  The full text that has been generated by the last step.
1726
1731
 
1727
- Resolved when the response is finished.
1732
+ Automatically consumes the stream.
1728
1733
  */
1729
1734
  readonly text: Promise<string>;
1730
1735
  /**
1731
1736
  The full reasoning that the model has generated.
1732
1737
 
1733
- Resolved when the response is finished.
1738
+ Automatically consumes the stream.
1734
1739
  */
1735
1740
  readonly reasoning: Promise<Array<ReasoningPart>>;
1736
1741
  /**
1737
1742
  The reasoning that has been generated by the last step.
1738
1743
 
1739
- Resolved when the response is finished.
1744
+ Automatically consumes the stream.
1740
1745
  */
1741
1746
  readonly reasoningText: Promise<string | undefined>;
1742
1747
  /**
1743
1748
  Files that have been generated by the model in the last step.
1744
1749
 
1745
- Resolved when the response is finished.
1750
+ Automatically consumes the stream.
1746
1751
  */
1747
1752
  readonly files: Promise<GeneratedFile[]>;
1748
1753
  /**
1749
1754
  Sources that have been used as references in the last step.
1750
1755
 
1751
- Resolved when the response is finished.
1756
+ Automatically consumes the stream.
1752
1757
  */
1753
1758
  readonly sources: Promise<Source[]>;
1754
1759
  /**
1755
1760
  The tool calls that have been executed in the last step.
1756
1761
 
1757
- Resolved when the response is finished.
1762
+ Automatically consumes the stream.
1758
1763
  */
1759
1764
  readonly toolCalls: Promise<TypedToolCall<TOOLS>[]>;
1760
1765
  /**
1761
1766
  The static tool calls that have been executed in the last step.
1762
1767
 
1763
- Resolved when the response is finished.
1768
+ Automatically consumes the stream.
1764
1769
  */
1765
1770
  readonly staticToolCalls: Promise<StaticToolCall<TOOLS>[]>;
1766
1771
  /**
1767
1772
  The dynamic tool calls that have been executed in the last step.
1768
1773
 
1769
- Resolved when the response is finished.
1774
+ Automatically consumes the stream.
1770
1775
  */
1771
1776
  readonly dynamicToolCalls: Promise<DynamicToolCall[]>;
1772
1777
  /**
1773
1778
  The static tool results that have been generated in the last step.
1774
1779
 
1775
- Resolved when the response is finished.
1780
+ Automatically consumes the stream.
1776
1781
  */
1777
1782
  readonly staticToolResults: Promise<StaticToolResult<TOOLS>[]>;
1778
1783
  /**
1779
1784
  The dynamic tool results that have been generated in the last step.
1780
1785
 
1781
- Resolved when the response is finished.
1786
+ Automatically consumes the stream.
1782
1787
  */
1783
1788
  readonly dynamicToolResults: Promise<DynamicToolResult[]>;
1784
1789
  /**
1785
1790
  The tool results that have been generated in the last step.
1786
1791
 
1787
- Resolved when the all tool executions are finished.
1792
+ Automatically consumes the stream.
1788
1793
  */
1789
1794
  readonly toolResults: Promise<TypedToolResult<TOOLS>[]>;
1790
1795
  /**
1791
1796
  The reason why the generation finished. Taken from the last step.
1792
1797
 
1793
- Resolved when the response is finished.
1798
+ Automatically consumes the stream.
1794
1799
  */
1795
1800
  readonly finishReason: Promise<FinishReason>;
1796
1801
  /**
1797
1802
  The token usage of the last step.
1798
1803
 
1799
- Resolved when the response is finished.
1804
+ Automatically consumes the stream.
1800
1805
  */
1801
1806
  readonly usage: Promise<LanguageModelUsage>;
1802
1807
  /**
1803
1808
  The total token usage of the generated response.
1804
1809
  When there are multiple steps, the usage is the sum of all step usages.
1805
1810
 
1806
- Resolved when the response is finished.
1811
+ Automatically consumes the stream.
1807
1812
  */
1808
1813
  readonly totalUsage: Promise<LanguageModelUsage>;
1809
1814
  /**
1810
1815
  Warnings from the model provider (e.g. unsupported settings) for the first step.
1816
+
1817
+ Automatically consumes the stream.
1811
1818
  */
1812
1819
  readonly warnings: Promise<CallWarning[] | undefined>;
1813
1820
  /**
1814
1821
  Details for all steps.
1815
1822
  You can use this to get information about intermediate steps,
1816
1823
  such as the tool calls or the response headers.
1824
+
1825
+ Automatically consumes the stream.
1817
1826
  */
1818
1827
  readonly steps: Promise<Array<StepResult<TOOLS>>>;
1819
1828
  /**
1820
1829
  Additional request information from the last step.
1830
+
1831
+ Automatically consumes the stream.
1821
1832
  */
1822
1833
  readonly request: Promise<LanguageModelRequestMetadata>;
1823
1834
  /**
1824
1835
  Additional response information from the last step.
1836
+
1837
+ Automatically consumes the stream.
1825
1838
  */
1826
1839
  readonly response: Promise<LanguageModelResponseMetadata & {
1827
1840
  /**
@@ -2265,9 +2278,9 @@ declare function embedMany<VALUE = string>({ model: modelArg, values, maxParalle
2265
2278
  maxParallelCalls?: number;
2266
2279
  }): Promise<EmbedManyResult<VALUE>>;
2267
2280
 
2268
- declare const symbol$c: unique symbol;
2281
+ declare const symbol$d: unique symbol;
2269
2282
  declare class InvalidArgumentError extends AISDKError {
2270
- private readonly [symbol$c];
2283
+ private readonly [symbol$d];
2271
2284
  readonly parameter: string;
2272
2285
  readonly value: unknown;
2273
2286
  constructor({ parameter, value, message, }: {
@@ -2353,9 +2366,9 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
2353
2366
  rawValue: unknown;
2354
2367
  };
2355
2368
 
2356
- declare const symbol$b: unique symbol;
2369
+ declare const symbol$c: unique symbol;
2357
2370
  declare class InvalidStreamPartError extends AISDKError {
2358
- private readonly [symbol$b];
2371
+ private readonly [symbol$c];
2359
2372
  readonly chunk: SingleRequestTextStreamPart<any>;
2360
2373
  constructor({ chunk, message, }: {
2361
2374
  chunk: SingleRequestTextStreamPart<any>;
@@ -2364,12 +2377,12 @@ declare class InvalidStreamPartError extends AISDKError {
2364
2377
  static isInstance(error: unknown): error is InvalidStreamPartError;
2365
2378
  }
2366
2379
 
2367
- declare const symbol$a: unique symbol;
2380
+ declare const symbol$b: unique symbol;
2368
2381
  /**
2369
2382
  * An error occurred with the MCP client.
2370
2383
  */
2371
2384
  declare class MCPClientError extends AISDKError {
2372
- private readonly [symbol$a];
2385
+ private readonly [symbol$b];
2373
2386
  constructor({ name, message, cause, }: {
2374
2387
  name?: string;
2375
2388
  message: string;
@@ -2378,7 +2391,7 @@ declare class MCPClientError extends AISDKError {
2378
2391
  static isInstance(error: unknown): error is MCPClientError;
2379
2392
  }
2380
2393
 
2381
- declare const symbol$9: unique symbol;
2394
+ declare const symbol$a: unique symbol;
2382
2395
  /**
2383
2396
  Thrown when no image could be generated. This can have multiple causes:
2384
2397
 
@@ -2386,7 +2399,7 @@ Thrown when no image could be generated. This can have multiple causes:
2386
2399
  - The model generated a response that could not be parsed.
2387
2400
  */
2388
2401
  declare class NoImageGeneratedError extends AISDKError {
2389
- private readonly [symbol$9];
2402
+ private readonly [symbol$a];
2390
2403
  /**
2391
2404
  The response metadata for each call.
2392
2405
  */
@@ -2399,7 +2412,7 @@ declare class NoImageGeneratedError extends AISDKError {
2399
2412
  static isInstance(error: unknown): error is NoImageGeneratedError;
2400
2413
  }
2401
2414
 
2402
- declare const symbol$8: unique symbol;
2415
+ declare const symbol$9: unique symbol;
2403
2416
  /**
2404
2417
  Thrown when no object could be generated. This can have several causes:
2405
2418
 
@@ -2412,7 +2425,7 @@ The error contains the following properties:
2412
2425
  - `text`: The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
2413
2426
  */
2414
2427
  declare class NoObjectGeneratedError extends AISDKError {
2415
- private readonly [symbol$8];
2428
+ private readonly [symbol$9];
2416
2429
  /**
2417
2430
  The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
2418
2431
  */
@@ -2440,6 +2453,19 @@ declare class NoObjectGeneratedError extends AISDKError {
2440
2453
  static isInstance(error: unknown): error is NoObjectGeneratedError;
2441
2454
  }
2442
2455
 
2456
+ declare const symbol$8: unique symbol;
2457
+ /**
2458
+ Thrown when no LLM output was generated, e.g. because of errors.
2459
+ */
2460
+ declare class NoOutputGeneratedError extends AISDKError {
2461
+ private readonly [symbol$8];
2462
+ constructor({ message, cause, }?: {
2463
+ message?: string;
2464
+ cause?: Error;
2465
+ });
2466
+ static isInstance(error: unknown): error is NoOutputGeneratedError;
2467
+ }
2468
+
2443
2469
  declare const symbol$7: unique symbol;
2444
2470
  /**
2445
2471
  Thrown when no output type is specified and output-related methods are called.
@@ -4291,4 +4317,4 @@ declare global {
4291
4317
  var AI_SDK_DEFAULT_PROVIDER: ProviderV2 | undefined;
4292
4318
  }
4293
4319
 
4294
- export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };
4320
+ export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };