ai 6.0.272 → 6.0.274

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,19 @@
1
1
  # ai
2
2
 
3
+ ## 6.0.274
4
+
5
+ ### Patch Changes
6
+
7
+ - 0b790f3: fix(ai): preserve approval descriptors in UI message streams
8
+
9
+ ## 6.0.273
10
+
11
+ ### Patch Changes
12
+
13
+ - 6e632b8: Expose parsed structured output in `streamText` end callbacks.
14
+ - Updated dependencies [5ab6f63]
15
+ - @ai-sdk/gateway@3.0.186
16
+
3
17
  ## 6.0.272
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -590,6 +590,19 @@ type DownloadFunction = (options: Array<{
590
590
  mediaType: string | undefined;
591
591
  } | null>>;
592
592
 
593
+ /**
594
+ * Infers the complete output type from the output specification.
595
+ */
596
+ type InferCompleteOutput<OUTPUT extends Output> = OUTPUT extends Output<infer COMPLETE_OUTPUT, any, any> ? COMPLETE_OUTPUT : never;
597
+ /**
598
+ * Infers the partial output type from the output specification.
599
+ */
600
+ type InferPartialOutput<OUTPUT extends Output> = OUTPUT extends Output<any, infer PARTIAL_OUTPUT, any> ? PARTIAL_OUTPUT : never;
601
+ /**
602
+ * Infers the element type from an array output specification.
603
+ */
604
+ type InferElementOutput<OUTPUT extends Output> = OUTPUT extends Output<any, any, infer ELEMENT> ? ELEMENT : never;
605
+
593
606
  /**
594
607
  * Reasoning output of a text generation. It contains a reasoning.
595
608
  */
@@ -1038,19 +1051,6 @@ declare function stepCountIs(stepCount: number): StopCondition<any>;
1038
1051
  declare function isLoopFinished(): StopCondition<any>;
1039
1052
  declare function hasToolCall(toolName: string): StopCondition<any>;
1040
1053
 
1041
- /**
1042
- * Infers the complete output type from the output specification.
1043
- */
1044
- type InferCompleteOutput<OUTPUT extends Output> = OUTPUT extends Output<infer COMPLETE_OUTPUT, any, any> ? COMPLETE_OUTPUT : never;
1045
- /**
1046
- * Infers the partial output type from the output specification.
1047
- */
1048
- type InferPartialOutput<OUTPUT extends Output> = OUTPUT extends Output<any, infer PARTIAL_OUTPUT, any> ? PARTIAL_OUTPUT : never;
1049
- /**
1050
- * Infers the element type from an array output specification.
1051
- */
1052
- type InferElementOutput<OUTPUT extends Output> = OUTPUT extends Output<any, any, infer ELEMENT> ? ELEMENT : never;
1053
-
1054
1054
  /**
1055
1055
  * The result of a `generateText` call.
1056
1056
  * It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
@@ -1756,6 +1756,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1756
1756
  approval: {
1757
1757
  id: string;
1758
1758
  approved?: never;
1759
+ descriptor?: unknown;
1759
1760
  reason?: never;
1760
1761
  signature?: string;
1761
1762
  };
@@ -1768,6 +1769,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1768
1769
  approval: {
1769
1770
  id: string;
1770
1771
  approved: boolean;
1772
+ descriptor?: unknown;
1771
1773
  reason?: string;
1772
1774
  signature?: string;
1773
1775
  };
@@ -1782,6 +1784,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1782
1784
  approval?: {
1783
1785
  id: string;
1784
1786
  approved: true;
1787
+ descriptor?: unknown;
1785
1788
  reason?: string;
1786
1789
  signature?: string;
1787
1790
  };
@@ -1796,6 +1799,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1796
1799
  approval?: {
1797
1800
  id: string;
1798
1801
  approved: true;
1802
+ descriptor?: unknown;
1799
1803
  reason?: string;
1800
1804
  signature?: string;
1801
1805
  };
@@ -1808,6 +1812,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1808
1812
  approval: {
1809
1813
  id: string;
1810
1814
  approved: false;
1815
+ descriptor?: unknown;
1811
1816
  reason?: string;
1812
1817
  signature?: string;
1813
1818
  };
@@ -1856,6 +1861,7 @@ type DynamicToolUIPart = {
1856
1861
  approval: {
1857
1862
  id: string;
1858
1863
  approved?: never;
1864
+ descriptor?: unknown;
1859
1865
  reason?: never;
1860
1866
  signature?: string;
1861
1867
  };
@@ -1868,6 +1874,7 @@ type DynamicToolUIPart = {
1868
1874
  approval: {
1869
1875
  id: string;
1870
1876
  approved: boolean;
1877
+ descriptor?: unknown;
1871
1878
  reason?: string;
1872
1879
  signature?: string;
1873
1880
  };
@@ -1882,6 +1889,7 @@ type DynamicToolUIPart = {
1882
1889
  approval?: {
1883
1890
  id: string;
1884
1891
  approved: true;
1892
+ descriptor?: unknown;
1885
1893
  reason?: string;
1886
1894
  signature?: string;
1887
1895
  };
@@ -1895,6 +1903,7 @@ type DynamicToolUIPart = {
1895
1903
  approval?: {
1896
1904
  id: string;
1897
1905
  approved: true;
1906
+ descriptor?: unknown;
1898
1907
  reason?: string;
1899
1908
  signature?: string;
1900
1909
  };
@@ -1907,6 +1916,7 @@ type DynamicToolUIPart = {
1907
1916
  approval: {
1908
1917
  id: string;
1909
1918
  approved: false;
1919
+ descriptor?: unknown;
1910
1920
  reason?: string;
1911
1921
  signature?: string;
1912
1922
  };
@@ -2040,6 +2050,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
2040
2050
  type: 'tool-approval-request';
2041
2051
  approvalId: string;
2042
2052
  toolCallId: string;
2053
+ approvalDescriptor?: unknown;
2043
2054
  signature?: string;
2044
2055
  } | {
2045
2056
  type: 'tool-output-available';
@@ -2579,12 +2590,20 @@ type StreamTextOnChunkCallback<TOOLS extends ToolSet> = (event: {
2579
2590
  type: 'text-delta' | 'reasoning-delta' | 'source' | 'tool-call' | 'tool-input-start' | 'tool-input-delta' | 'tool-result' | 'raw';
2580
2591
  }>;
2581
2592
  }) => PromiseLike<void> | void;
2593
+ type StreamTextEndEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output = Output> = OnFinishEvent<TOOLS> & {
2594
+ /**
2595
+ * The parsed output when an output setting was provided and parsing
2596
+ * succeeded.
2597
+ */
2598
+ readonly output?: InferCompleteOutput<OUTPUT>;
2599
+ };
2600
+ type StreamTextOnEndCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output = Output> = (event: StreamTextEndEvent<TOOLS, OUTPUT>) => PromiseLike<void> | void;
2582
2601
  /**
2583
2602
  * Callback that is set using the `onFinish` option.
2584
2603
  *
2585
2604
  * @param event - The event that is passed to the callback.
2586
2605
  */
2587
- type StreamTextOnFinishCallback<TOOLS extends ToolSet> = (event: OnFinishEvent<TOOLS>) => PromiseLike<void> | void;
2606
+ type StreamTextOnFinishCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output = Output> = StreamTextOnEndCallback<TOOLS, OUTPUT>;
2588
2607
  /**
2589
2608
  * Callback that is set using the `onAbort` option.
2590
2609
  *
@@ -2772,7 +2791,7 @@ declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Outpu
2772
2791
  *
2773
2792
  * The usage is the combined usage of all steps.
2774
2793
  */
2775
- onFinish?: StreamTextOnFinishCallback<TOOLS>;
2794
+ onFinish?: StreamTextOnFinishCallback<NoInfer<TOOLS>, NoInfer<OUTPUT>>;
2776
2795
  onAbort?: StreamTextOnAbortCallback<TOOLS>;
2777
2796
  /**
2778
2797
  * Callback that is called when each step (LLM call) is finished, including intermediate steps.
@@ -6508,4 +6527,4 @@ declare function bindTelemetryIntegration(integration: TelemetryIntegration): Te
6508
6527
  */
6509
6528
  declare function registerTelemetryIntegration(integration: TelemetryIntegration): void;
6510
6529
 
6511
- export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, 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, GenerateTextOnStartCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextOnToolCallFinishCallback, GenerateTextOnToolCallStartCallback, GenerateTextResult, GenerateVideoPrompt, GenerateVideoResult, 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, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, Output as OutputInterface, 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, StreamTextOnStartCallback, StreamTextOnStepFinishCallback, StreamTextOnStepStartCallback, StreamTextOnToolCallFinishCallback, StreamTextOnToolCallStartCallback, StreamTextResult, StreamTextTransform, TelemetryIntegration, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolChoiceViolationError, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamOutcome, UIMessageStreamWriter, UIMessageStreamWriterWithOutcome, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, bindTelemetryIntegration, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isLoopFinished, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
6530
+ export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, 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, GenerateTextOnStartCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextOnToolCallFinishCallback, GenerateTextOnToolCallStartCallback, GenerateTextResult, GenerateVideoPrompt, GenerateVideoResult, 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, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, Output as OutputInterface, 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, StreamTextEndEvent, StreamTextOnChunkCallback, StreamTextOnEndCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStartCallback, StreamTextOnStepFinishCallback, StreamTextOnStepStartCallback, StreamTextOnToolCallFinishCallback, StreamTextOnToolCallStartCallback, StreamTextResult, StreamTextTransform, TelemetryIntegration, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolChoiceViolationError, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamOutcome, UIMessageStreamWriter, UIMessageStreamWriterWithOutcome, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, bindTelemetryIntegration, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isLoopFinished, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
package/dist/index.d.ts CHANGED
@@ -590,6 +590,19 @@ type DownloadFunction = (options: Array<{
590
590
  mediaType: string | undefined;
591
591
  } | null>>;
592
592
 
593
+ /**
594
+ * Infers the complete output type from the output specification.
595
+ */
596
+ type InferCompleteOutput<OUTPUT extends Output> = OUTPUT extends Output<infer COMPLETE_OUTPUT, any, any> ? COMPLETE_OUTPUT : never;
597
+ /**
598
+ * Infers the partial output type from the output specification.
599
+ */
600
+ type InferPartialOutput<OUTPUT extends Output> = OUTPUT extends Output<any, infer PARTIAL_OUTPUT, any> ? PARTIAL_OUTPUT : never;
601
+ /**
602
+ * Infers the element type from an array output specification.
603
+ */
604
+ type InferElementOutput<OUTPUT extends Output> = OUTPUT extends Output<any, any, infer ELEMENT> ? ELEMENT : never;
605
+
593
606
  /**
594
607
  * Reasoning output of a text generation. It contains a reasoning.
595
608
  */
@@ -1038,19 +1051,6 @@ declare function stepCountIs(stepCount: number): StopCondition<any>;
1038
1051
  declare function isLoopFinished(): StopCondition<any>;
1039
1052
  declare function hasToolCall(toolName: string): StopCondition<any>;
1040
1053
 
1041
- /**
1042
- * Infers the complete output type from the output specification.
1043
- */
1044
- type InferCompleteOutput<OUTPUT extends Output> = OUTPUT extends Output<infer COMPLETE_OUTPUT, any, any> ? COMPLETE_OUTPUT : never;
1045
- /**
1046
- * Infers the partial output type from the output specification.
1047
- */
1048
- type InferPartialOutput<OUTPUT extends Output> = OUTPUT extends Output<any, infer PARTIAL_OUTPUT, any> ? PARTIAL_OUTPUT : never;
1049
- /**
1050
- * Infers the element type from an array output specification.
1051
- */
1052
- type InferElementOutput<OUTPUT extends Output> = OUTPUT extends Output<any, any, infer ELEMENT> ? ELEMENT : never;
1053
-
1054
1054
  /**
1055
1055
  * The result of a `generateText` call.
1056
1056
  * It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
@@ -1756,6 +1756,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1756
1756
  approval: {
1757
1757
  id: string;
1758
1758
  approved?: never;
1759
+ descriptor?: unknown;
1759
1760
  reason?: never;
1760
1761
  signature?: string;
1761
1762
  };
@@ -1768,6 +1769,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1768
1769
  approval: {
1769
1770
  id: string;
1770
1771
  approved: boolean;
1772
+ descriptor?: unknown;
1771
1773
  reason?: string;
1772
1774
  signature?: string;
1773
1775
  };
@@ -1782,6 +1784,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1782
1784
  approval?: {
1783
1785
  id: string;
1784
1786
  approved: true;
1787
+ descriptor?: unknown;
1785
1788
  reason?: string;
1786
1789
  signature?: string;
1787
1790
  };
@@ -1796,6 +1799,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1796
1799
  approval?: {
1797
1800
  id: string;
1798
1801
  approved: true;
1802
+ descriptor?: unknown;
1799
1803
  reason?: string;
1800
1804
  signature?: string;
1801
1805
  };
@@ -1808,6 +1812,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
1808
1812
  approval: {
1809
1813
  id: string;
1810
1814
  approved: false;
1815
+ descriptor?: unknown;
1811
1816
  reason?: string;
1812
1817
  signature?: string;
1813
1818
  };
@@ -1856,6 +1861,7 @@ type DynamicToolUIPart = {
1856
1861
  approval: {
1857
1862
  id: string;
1858
1863
  approved?: never;
1864
+ descriptor?: unknown;
1859
1865
  reason?: never;
1860
1866
  signature?: string;
1861
1867
  };
@@ -1868,6 +1874,7 @@ type DynamicToolUIPart = {
1868
1874
  approval: {
1869
1875
  id: string;
1870
1876
  approved: boolean;
1877
+ descriptor?: unknown;
1871
1878
  reason?: string;
1872
1879
  signature?: string;
1873
1880
  };
@@ -1882,6 +1889,7 @@ type DynamicToolUIPart = {
1882
1889
  approval?: {
1883
1890
  id: string;
1884
1891
  approved: true;
1892
+ descriptor?: unknown;
1885
1893
  reason?: string;
1886
1894
  signature?: string;
1887
1895
  };
@@ -1895,6 +1903,7 @@ type DynamicToolUIPart = {
1895
1903
  approval?: {
1896
1904
  id: string;
1897
1905
  approved: true;
1906
+ descriptor?: unknown;
1898
1907
  reason?: string;
1899
1908
  signature?: string;
1900
1909
  };
@@ -1907,6 +1916,7 @@ type DynamicToolUIPart = {
1907
1916
  approval: {
1908
1917
  id: string;
1909
1918
  approved: false;
1919
+ descriptor?: unknown;
1910
1920
  reason?: string;
1911
1921
  signature?: string;
1912
1922
  };
@@ -2040,6 +2050,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
2040
2050
  type: 'tool-approval-request';
2041
2051
  approvalId: string;
2042
2052
  toolCallId: string;
2053
+ approvalDescriptor?: unknown;
2043
2054
  signature?: string;
2044
2055
  } | {
2045
2056
  type: 'tool-output-available';
@@ -2579,12 +2590,20 @@ type StreamTextOnChunkCallback<TOOLS extends ToolSet> = (event: {
2579
2590
  type: 'text-delta' | 'reasoning-delta' | 'source' | 'tool-call' | 'tool-input-start' | 'tool-input-delta' | 'tool-result' | 'raw';
2580
2591
  }>;
2581
2592
  }) => PromiseLike<void> | void;
2593
+ type StreamTextEndEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output = Output> = OnFinishEvent<TOOLS> & {
2594
+ /**
2595
+ * The parsed output when an output setting was provided and parsing
2596
+ * succeeded.
2597
+ */
2598
+ readonly output?: InferCompleteOutput<OUTPUT>;
2599
+ };
2600
+ type StreamTextOnEndCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output = Output> = (event: StreamTextEndEvent<TOOLS, OUTPUT>) => PromiseLike<void> | void;
2582
2601
  /**
2583
2602
  * Callback that is set using the `onFinish` option.
2584
2603
  *
2585
2604
  * @param event - The event that is passed to the callback.
2586
2605
  */
2587
- type StreamTextOnFinishCallback<TOOLS extends ToolSet> = (event: OnFinishEvent<TOOLS>) => PromiseLike<void> | void;
2606
+ type StreamTextOnFinishCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output = Output> = StreamTextOnEndCallback<TOOLS, OUTPUT>;
2588
2607
  /**
2589
2608
  * Callback that is set using the `onAbort` option.
2590
2609
  *
@@ -2772,7 +2791,7 @@ declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = Outpu
2772
2791
  *
2773
2792
  * The usage is the combined usage of all steps.
2774
2793
  */
2775
- onFinish?: StreamTextOnFinishCallback<TOOLS>;
2794
+ onFinish?: StreamTextOnFinishCallback<NoInfer<TOOLS>, NoInfer<OUTPUT>>;
2776
2795
  onAbort?: StreamTextOnAbortCallback<TOOLS>;
2777
2796
  /**
2778
2797
  * Callback that is called when each step (LLM call) is finished, including intermediate steps.
@@ -6508,4 +6527,4 @@ declare function bindTelemetryIntegration(integration: TelemetryIntegration): Te
6508
6527
  */
6509
6528
  declare function registerTelemetryIntegration(integration: TelemetryIntegration): void;
6510
6529
 
6511
- export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, 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, GenerateTextOnStartCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextOnToolCallFinishCallback, GenerateTextOnToolCallStartCallback, GenerateTextResult, GenerateVideoPrompt, GenerateVideoResult, 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, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, Output as OutputInterface, 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, StreamTextOnStartCallback, StreamTextOnStepFinishCallback, StreamTextOnStepStartCallback, StreamTextOnToolCallFinishCallback, StreamTextOnToolCallStartCallback, StreamTextResult, StreamTextTransform, TelemetryIntegration, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolChoiceViolationError, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamOutcome, UIMessageStreamWriter, UIMessageStreamWriterWithOutcome, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, bindTelemetryIntegration, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isLoopFinished, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
6530
+ export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, 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, GenerateTextOnStartCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextOnToolCallFinishCallback, GenerateTextOnToolCallStartCallback, GenerateTextResult, GenerateVideoPrompt, GenerateVideoResult, 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, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, Output as OutputInterface, 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, StreamTextEndEvent, StreamTextOnChunkCallback, StreamTextOnEndCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStartCallback, StreamTextOnStepFinishCallback, StreamTextOnStepStartCallback, StreamTextOnToolCallFinishCallback, StreamTextOnToolCallStartCallback, StreamTextResult, StreamTextTransform, TelemetryIntegration, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolChoiceViolationError, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamOutcome, UIMessageStreamWriter, UIMessageStreamWriterWithOutcome, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, bindTelemetryIntegration, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isLoopFinished, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
package/dist/index.js CHANGED
@@ -1334,7 +1334,7 @@ function detectMediaType({
1334
1334
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
1335
1335
 
1336
1336
  // src/version.ts
1337
- var VERSION = true ? "6.0.272" : "0.0.0-test";
1337
+ var VERSION = true ? "6.0.274" : "0.0.0-test";
1338
1338
 
1339
1339
  // src/util/download/download.ts
1340
1340
  var download = async ({
@@ -5734,6 +5734,7 @@ var uiMessageChunkSchema = (0, import_provider_utils17.lazySchema)(
5734
5734
  type: import_v47.z.literal("tool-approval-request"),
5735
5735
  approvalId: import_v47.z.string(),
5736
5736
  toolCallId: import_v47.z.string(),
5737
+ approvalDescriptor: import_v47.z.unknown().optional(),
5737
5738
  signature: import_v47.z.string().optional()
5738
5739
  }),
5739
5740
  import_v47.z.looseObject({
@@ -6313,6 +6314,7 @@ function processUIMessageStream({
6313
6314
  toolInvocation.state = "approval-requested";
6314
6315
  toolInvocation.approval = {
6315
6316
  id: chunk.approvalId,
6317
+ ...chunk.approvalDescriptor != null ? { descriptor: chunk.approvalDescriptor } : {},
6316
6318
  ...chunk.signature != null ? { signature: chunk.signature } : {}
6317
6319
  };
6318
6320
  write();
@@ -7625,40 +7627,51 @@ var DefaultStreamTextResult = class {
7625
7627
  self._totalUsage.resolve(totalUsage);
7626
7628
  self._steps.resolve(recordedSteps);
7627
7629
  const finalStep = recordedSteps[recordedSteps.length - 1];
7628
- await notify({
7629
- event: {
7630
- stepNumber: finalStep.stepNumber,
7631
- model: finalStep.model,
7632
- functionId: finalStep.functionId,
7633
- metadata: finalStep.metadata,
7634
- experimental_context: finalStep.experimental_context,
7635
- finishReason: finalStep.finishReason,
7636
- rawFinishReason: finalStep.rawFinishReason,
7637
- totalUsage,
7638
- usage: finalStep.usage,
7639
- content: finalStep.content,
7640
- text: finalStep.text,
7641
- reasoningText: finalStep.reasoningText,
7642
- reasoning: finalStep.reasoning,
7643
- files: finalStep.files,
7644
- sources: finalStep.sources,
7645
- toolCalls: finalStep.toolCalls,
7646
- staticToolCalls: finalStep.staticToolCalls,
7647
- dynamicToolCalls: finalStep.dynamicToolCalls,
7648
- toolResults: finalStep.toolResults,
7649
- staticToolResults: finalStep.staticToolResults,
7650
- dynamicToolResults: finalStep.dynamicToolResults,
7651
- request: finalStep.request,
7652
- response: finalStep.response,
7653
- warnings: finalStep.warnings,
7654
- providerMetadata: finalStep.providerMetadata,
7655
- steps: recordedSteps
7656
- },
7657
- callbacks: [
7658
- onFinish,
7659
- globalTelemetry.onFinish
7660
- ]
7661
- });
7630
+ const onFinishEvent = {
7631
+ stepNumber: finalStep.stepNumber,
7632
+ model: finalStep.model,
7633
+ functionId: finalStep.functionId,
7634
+ metadata: finalStep.metadata,
7635
+ experimental_context: finalStep.experimental_context,
7636
+ finishReason: finalStep.finishReason,
7637
+ rawFinishReason: finalStep.rawFinishReason,
7638
+ totalUsage,
7639
+ usage: finalStep.usage,
7640
+ content: finalStep.content,
7641
+ text: finalStep.text,
7642
+ reasoningText: finalStep.reasoningText,
7643
+ reasoning: finalStep.reasoning,
7644
+ files: finalStep.files,
7645
+ sources: finalStep.sources,
7646
+ toolCalls: finalStep.toolCalls,
7647
+ staticToolCalls: finalStep.staticToolCalls,
7648
+ dynamicToolCalls: finalStep.dynamicToolCalls,
7649
+ toolResults: finalStep.toolResults,
7650
+ staticToolResults: finalStep.staticToolResults,
7651
+ dynamicToolResults: finalStep.dynamicToolResults,
7652
+ request: finalStep.request,
7653
+ response: finalStep.response,
7654
+ warnings: finalStep.warnings,
7655
+ providerMetadata: finalStep.providerMetadata,
7656
+ steps: recordedSteps
7657
+ };
7658
+ const onFinishWithOutput = onFinish == null ? void 0 : async (event) => {
7659
+ const parsedOutput = output == null ? void 0 : await self.getOutputPromise().catch(() => void 0);
7660
+ await onFinish({
7661
+ ...event,
7662
+ ...output != null ? { output: parsedOutput } : {}
7663
+ });
7664
+ };
7665
+ await Promise.all([
7666
+ notify({
7667
+ event: onFinishEvent,
7668
+ callbacks: onFinishWithOutput
7669
+ }),
7670
+ notify({
7671
+ event: onFinishEvent,
7672
+ callbacks: globalTelemetry.onFinish
7673
+ })
7674
+ ]);
7662
7675
  rootSpan.setAttributes(
7663
7676
  await selectTelemetryAttributes({
7664
7677
  telemetry,
@@ -8720,19 +8733,25 @@ var DefaultStreamTextResult = class {
8720
8733
  }
8721
8734
  return createAsyncIterableStream(this.teeStream().pipeThrough(transform));
8722
8735
  }
8736
+ getOutputPromise() {
8737
+ if (this.outputPromise == null) {
8738
+ this.outputPromise = this.finalStep.then((step) => {
8739
+ var _a23;
8740
+ const output = (_a23 = this.outputSpecification) != null ? _a23 : text();
8741
+ return output.parseCompleteOutput(
8742
+ { text: step.text },
8743
+ {
8744
+ response: step.response,
8745
+ usage: step.usage,
8746
+ finishReason: step.finishReason
8747
+ }
8748
+ );
8749
+ });
8750
+ }
8751
+ return this.outputPromise;
8752
+ }
8723
8753
  get output() {
8724
- return this.finalStep.then((step) => {
8725
- var _a23;
8726
- const output = (_a23 = this.outputSpecification) != null ? _a23 : text();
8727
- return output.parseCompleteOutput(
8728
- { text: step.text },
8729
- {
8730
- response: step.response,
8731
- usage: step.usage,
8732
- finishReason: step.finishReason
8733
- }
8734
- );
8735
- });
8754
+ return this.getOutputPromise();
8736
8755
  }
8737
8756
  toUIMessageStream({
8738
8757
  originalMessages,
@@ -9774,6 +9793,7 @@ var uiMessagesSchema = (0, import_provider_utils24.lazySchema)(
9774
9793
  approval: import_v48.z.object({
9775
9794
  id: import_v48.z.string(),
9776
9795
  approved: import_v48.z.never().optional(),
9796
+ descriptor: import_v48.z.unknown().optional(),
9777
9797
  reason: import_v48.z.never().optional(),
9778
9798
  signature: import_v48.z.string().optional()
9779
9799
  })
@@ -9792,6 +9812,7 @@ var uiMessagesSchema = (0, import_provider_utils24.lazySchema)(
9792
9812
  approval: import_v48.z.object({
9793
9813
  id: import_v48.z.string(),
9794
9814
  approved: import_v48.z.boolean(),
9815
+ descriptor: import_v48.z.unknown().optional(),
9795
9816
  reason: import_v48.z.string().optional(),
9796
9817
  signature: import_v48.z.string().optional()
9797
9818
  })
@@ -9812,6 +9833,7 @@ var uiMessagesSchema = (0, import_provider_utils24.lazySchema)(
9812
9833
  approval: import_v48.z.object({
9813
9834
  id: import_v48.z.string(),
9814
9835
  approved: import_v48.z.literal(true),
9836
+ descriptor: import_v48.z.unknown().optional(),
9815
9837
  reason: import_v48.z.string().optional(),
9816
9838
  signature: import_v48.z.string().optional()
9817
9839
  }).optional()
@@ -9832,6 +9854,7 @@ var uiMessagesSchema = (0, import_provider_utils24.lazySchema)(
9832
9854
  approval: import_v48.z.object({
9833
9855
  id: import_v48.z.string(),
9834
9856
  approved: import_v48.z.literal(true),
9857
+ descriptor: import_v48.z.unknown().optional(),
9835
9858
  reason: import_v48.z.string().optional(),
9836
9859
  signature: import_v48.z.string().optional()
9837
9860
  }).optional()
@@ -9850,6 +9873,7 @@ var uiMessagesSchema = (0, import_provider_utils24.lazySchema)(
9850
9873
  approval: import_v48.z.object({
9851
9874
  id: import_v48.z.string(),
9852
9875
  approved: import_v48.z.literal(false),
9876
+ descriptor: import_v48.z.unknown().optional(),
9853
9877
  reason: import_v48.z.string().optional(),
9854
9878
  signature: import_v48.z.string().optional()
9855
9879
  })
@@ -9891,6 +9915,7 @@ var uiMessagesSchema = (0, import_provider_utils24.lazySchema)(
9891
9915
  approval: import_v48.z.object({
9892
9916
  id: import_v48.z.string(),
9893
9917
  approved: import_v48.z.never().optional(),
9918
+ descriptor: import_v48.z.unknown().optional(),
9894
9919
  reason: import_v48.z.never().optional(),
9895
9920
  signature: import_v48.z.string().optional()
9896
9921
  })
@@ -9908,6 +9933,7 @@ var uiMessagesSchema = (0, import_provider_utils24.lazySchema)(
9908
9933
  approval: import_v48.z.object({
9909
9934
  id: import_v48.z.string(),
9910
9935
  approved: import_v48.z.boolean(),
9936
+ descriptor: import_v48.z.unknown().optional(),
9911
9937
  reason: import_v48.z.string().optional(),
9912
9938
  signature: import_v48.z.string().optional()
9913
9939
  })
@@ -9927,6 +9953,7 @@ var uiMessagesSchema = (0, import_provider_utils24.lazySchema)(
9927
9953
  approval: import_v48.z.object({
9928
9954
  id: import_v48.z.string(),
9929
9955
  approved: import_v48.z.literal(true),
9956
+ descriptor: import_v48.z.unknown().optional(),
9930
9957
  reason: import_v48.z.string().optional(),
9931
9958
  signature: import_v48.z.string().optional()
9932
9959
  }).optional()
@@ -9946,6 +9973,7 @@ var uiMessagesSchema = (0, import_provider_utils24.lazySchema)(
9946
9973
  approval: import_v48.z.object({
9947
9974
  id: import_v48.z.string(),
9948
9975
  approved: import_v48.z.literal(true),
9976
+ descriptor: import_v48.z.unknown().optional(),
9949
9977
  reason: import_v48.z.string().optional(),
9950
9978
  signature: import_v48.z.string().optional()
9951
9979
  }).optional()
@@ -9963,6 +9991,7 @@ var uiMessagesSchema = (0, import_provider_utils24.lazySchema)(
9963
9991
  approval: import_v48.z.object({
9964
9992
  id: import_v48.z.string(),
9965
9993
  approved: import_v48.z.literal(false),
9994
+ descriptor: import_v48.z.unknown().optional(),
9966
9995
  reason: import_v48.z.string().optional(),
9967
9996
  signature: import_v48.z.string().optional()
9968
9997
  })