ai 6.0.220 → 6.0.222
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 +37 -0
- package/dist/index.d.mts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +102 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -44
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +5 -0
- package/docs/03-ai-sdk-core/38-video-generation.mdx +35 -16
- package/docs/07-reference/01-ai-sdk-core/13-generate-video.mdx +3 -2
- package/package.json +4 -4
- package/src/generate-text/generate-text.ts +6 -4
- package/src/generate-text/output.ts +4 -1
- package/src/generate-text/run-tools-transformation.ts +3 -7
- package/src/generate-text/stream-text.ts +24 -13
- package/src/generate-video/generate-video.ts +97 -25
- package/src/ui/chat.ts +1 -1
- package/src/ui/convert-to-model-messages.ts +7 -5
- package/src/ui/index.ts +1 -0
- package/src/util/set-abort-timeout.ts +37 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.222
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e1af05f: feat (video): support video (not just image) reference inputs in `inputReferences` for reference-to-video generation
|
|
8
|
+
- Updated dependencies [2bfb16a]
|
|
9
|
+
- Updated dependencies [34b5acc]
|
|
10
|
+
- Updated dependencies [e1af05f]
|
|
11
|
+
- Updated dependencies [1ce0d1c]
|
|
12
|
+
- @ai-sdk/gateway@3.0.146
|
|
13
|
+
- @ai-sdk/provider@3.0.14
|
|
14
|
+
- @ai-sdk/provider-utils@4.0.38
|
|
15
|
+
|
|
16
|
+
## 6.0.221
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 2958540: fix(ui): export `isDynamicToolUIPart` from `ai` package
|
|
21
|
+
- aa2dbe6: Fix: `convertToModelMessages` no longer emits an empty assistant message when a block contains only unknown data parts (e.g. a data part before `step-start` with no `convertDataPart` provided)
|
|
22
|
+
- faaef7c: fix(ai): enforce `timeout.stepMs` for the whole step in `streamText`
|
|
23
|
+
|
|
24
|
+
Previously `streamText`'s step timer was cleared synchronously right after the step's stream was registered, before the stream produced anything, so `stepMs` never aborted a step that stalled before emitting content. The step timer now survives until the step's stream finishes or aborts, matching `generateText`. `chunkMs`/`totalMs` and normal step-finish cleanup are unchanged.
|
|
25
|
+
|
|
26
|
+
- 45a9cbf: Return validated elements from generateText array output
|
|
27
|
+
- 2706461: fix(ai): include tool input on tool result for provider executed dynamic tools
|
|
28
|
+
- 327642b: fix: more precise default message for tool execution denial
|
|
29
|
+
- 89df298: Preserve signed tool approval metadata when recording approval responses.
|
|
30
|
+
- 8ed1f83: fix(ai): tag step/chunk timeout aborts with `TimeoutError` reason
|
|
31
|
+
|
|
32
|
+
When `timeout: { stepMs }` or `timeout: { chunkMs }` fires, the abort reason is now a `TimeoutError` `DOMException`, matching what `AbortSignal.timeout()` produces natively. Consumers can distinguish a framework timeout from a user-initiated cancel via `signal.reason.name === 'TimeoutError'`.
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [d559de9]
|
|
35
|
+
- Updated dependencies [9c54a9f]
|
|
36
|
+
- Updated dependencies [bbc4bd5]
|
|
37
|
+
- @ai-sdk/provider-utils@4.0.37
|
|
38
|
+
- @ai-sdk/gateway@3.0.145
|
|
39
|
+
|
|
3
40
|
## 6.0.220
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1915,6 +1915,12 @@ declare function isReasoningUIPart(part: UIMessagePart<UIDataTypes, UITools>): p
|
|
|
1915
1915
|
* Static tools are tools for which the types are known at development time.
|
|
1916
1916
|
*/
|
|
1917
1917
|
declare function isStaticToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS>;
|
|
1918
|
+
/**
|
|
1919
|
+
* Check if a message part is a dynamic tool part.
|
|
1920
|
+
*
|
|
1921
|
+
* Dynamic tools are tools for which the input and output types are unknown.
|
|
1922
|
+
*/
|
|
1923
|
+
declare function isDynamicToolUIPart(part: UIMessagePart<UIDataTypes, UITools>): part is DynamicToolUIPart;
|
|
1918
1924
|
/**
|
|
1919
1925
|
* Check if a message part is a tool part.
|
|
1920
1926
|
*
|
|
@@ -5924,9 +5930,22 @@ declare function experimental_generateVideo({ model: modelArg, prompt: promptArg
|
|
|
5924
5930
|
frameType: Experimental_VideoModelV3FrameType;
|
|
5925
5931
|
}>;
|
|
5926
5932
|
/**
|
|
5927
|
-
* Reference
|
|
5933
|
+
* Reference inputs for reference-to-video generation.
|
|
5934
|
+
*
|
|
5935
|
+
* Each entry may be a plain image/video ({@link DataContent}), or an object
|
|
5936
|
+
* form that carries an explicit `mediaType`.
|
|
5928
5937
|
*/
|
|
5929
|
-
inputReferences?: Array<DataContent
|
|
5938
|
+
inputReferences?: Array<DataContent | {
|
|
5939
|
+
/**
|
|
5940
|
+
* The reference image or video.
|
|
5941
|
+
*/
|
|
5942
|
+
data: DataContent;
|
|
5943
|
+
/**
|
|
5944
|
+
* The media type of the reference (e.g. 'image/png',
|
|
5945
|
+
* 'video/mp4').
|
|
5946
|
+
*/
|
|
5947
|
+
mediaType?: string;
|
|
5948
|
+
}>;
|
|
5930
5949
|
/**
|
|
5931
5950
|
* Whether the model should generate audio alongside the video.
|
|
5932
5951
|
*/
|
|
@@ -6517,4 +6536,4 @@ declare function bindTelemetryIntegration(integration: TelemetryIntegration): Te
|
|
|
6517
6536
|
*/
|
|
6518
6537
|
declare function registerTelemetryIntegration(integration: TelemetryIntegration): void;
|
|
6519
6538
|
|
|
6520
|
-
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, 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, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, 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, 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 };
|
|
6539
|
+
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, 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, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, 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
|
@@ -1915,6 +1915,12 @@ declare function isReasoningUIPart(part: UIMessagePart<UIDataTypes, UITools>): p
|
|
|
1915
1915
|
* Static tools are tools for which the types are known at development time.
|
|
1916
1916
|
*/
|
|
1917
1917
|
declare function isStaticToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS>;
|
|
1918
|
+
/**
|
|
1919
|
+
* Check if a message part is a dynamic tool part.
|
|
1920
|
+
*
|
|
1921
|
+
* Dynamic tools are tools for which the input and output types are unknown.
|
|
1922
|
+
*/
|
|
1923
|
+
declare function isDynamicToolUIPart(part: UIMessagePart<UIDataTypes, UITools>): part is DynamicToolUIPart;
|
|
1918
1924
|
/**
|
|
1919
1925
|
* Check if a message part is a tool part.
|
|
1920
1926
|
*
|
|
@@ -5924,9 +5930,22 @@ declare function experimental_generateVideo({ model: modelArg, prompt: promptArg
|
|
|
5924
5930
|
frameType: Experimental_VideoModelV3FrameType;
|
|
5925
5931
|
}>;
|
|
5926
5932
|
/**
|
|
5927
|
-
* Reference
|
|
5933
|
+
* Reference inputs for reference-to-video generation.
|
|
5934
|
+
*
|
|
5935
|
+
* Each entry may be a plain image/video ({@link DataContent}), or an object
|
|
5936
|
+
* form that carries an explicit `mediaType`.
|
|
5928
5937
|
*/
|
|
5929
|
-
inputReferences?: Array<DataContent
|
|
5938
|
+
inputReferences?: Array<DataContent | {
|
|
5939
|
+
/**
|
|
5940
|
+
* The reference image or video.
|
|
5941
|
+
*/
|
|
5942
|
+
data: DataContent;
|
|
5943
|
+
/**
|
|
5944
|
+
* The media type of the reference (e.g. 'image/png',
|
|
5945
|
+
* 'video/mp4').
|
|
5946
|
+
*/
|
|
5947
|
+
mediaType?: string;
|
|
5948
|
+
}>;
|
|
5930
5949
|
/**
|
|
5931
5950
|
* Whether the model should generate audio alongside the video.
|
|
5932
5951
|
*/
|
|
@@ -6517,4 +6536,4 @@ declare function bindTelemetryIntegration(integration: TelemetryIntegration): Te
|
|
|
6517
6536
|
*/
|
|
6518
6537
|
declare function registerTelemetryIntegration(integration: TelemetryIntegration): void;
|
|
6519
6538
|
|
|
6520
|
-
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, 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, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, 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, 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 };
|
|
6539
|
+
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, 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, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, 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
|
@@ -112,6 +112,7 @@ __export(src_exports, {
|
|
|
112
112
|
hasToolCall: () => hasToolCall,
|
|
113
113
|
isDataUIPart: () => isDataUIPart,
|
|
114
114
|
isDeepEqualData: () => isDeepEqualData,
|
|
115
|
+
isDynamicToolUIPart: () => isDynamicToolUIPart,
|
|
115
116
|
isFileUIPart: () => isFileUIPart,
|
|
116
117
|
isLoopFinished: () => isLoopFinished,
|
|
117
118
|
isReasoningUIPart: () => isReasoningUIPart,
|
|
@@ -1281,7 +1282,7 @@ function detectMediaType({
|
|
|
1281
1282
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1282
1283
|
|
|
1283
1284
|
// src/version.ts
|
|
1284
|
-
var VERSION = true ? "6.0.
|
|
1285
|
+
var VERSION = true ? "6.0.222" : "0.0.0-test";
|
|
1285
1286
|
|
|
1286
1287
|
// src/util/download/download.ts
|
|
1287
1288
|
var download = async ({
|
|
@@ -2856,6 +2857,26 @@ function prepareRetries({
|
|
|
2856
2857
|
};
|
|
2857
2858
|
}
|
|
2858
2859
|
|
|
2860
|
+
// src/util/set-abort-timeout.ts
|
|
2861
|
+
function setAbortTimeout({
|
|
2862
|
+
abortController,
|
|
2863
|
+
label,
|
|
2864
|
+
timeoutMs
|
|
2865
|
+
}) {
|
|
2866
|
+
if (abortController == null || timeoutMs == null) {
|
|
2867
|
+
return void 0;
|
|
2868
|
+
}
|
|
2869
|
+
return setTimeout(
|
|
2870
|
+
() => abortController.abort(
|
|
2871
|
+
new DOMException(
|
|
2872
|
+
`${label} timeout of ${timeoutMs}ms exceeded`,
|
|
2873
|
+
"TimeoutError"
|
|
2874
|
+
)
|
|
2875
|
+
),
|
|
2876
|
+
timeoutMs
|
|
2877
|
+
);
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2859
2880
|
// src/generate-text/collect-tool-approvals.ts
|
|
2860
2881
|
function collectToolApprovals({
|
|
2861
2882
|
messages
|
|
@@ -3808,6 +3829,7 @@ var array = ({
|
|
|
3808
3829
|
finishReason: context2.finishReason
|
|
3809
3830
|
});
|
|
3810
3831
|
}
|
|
3832
|
+
const validatedElements = [];
|
|
3811
3833
|
for (const element of outerValue.elements) {
|
|
3812
3834
|
const validationResult = await (0, import_provider_utils14.safeValidateTypes)({
|
|
3813
3835
|
value: element,
|
|
@@ -3823,8 +3845,9 @@ var array = ({
|
|
|
3823
3845
|
finishReason: context2.finishReason
|
|
3824
3846
|
});
|
|
3825
3847
|
}
|
|
3848
|
+
validatedElements.push(validationResult.value);
|
|
3826
3849
|
}
|
|
3827
|
-
return
|
|
3850
|
+
return validatedElements;
|
|
3828
3851
|
},
|
|
3829
3852
|
async parsePartialOutput({ text: text2 }) {
|
|
3830
3853
|
const result = await parsePartialJson(text2);
|
|
@@ -4627,7 +4650,11 @@ async function generateText({
|
|
|
4627
4650
|
const steps = [];
|
|
4628
4651
|
const pendingDeferredToolCalls = /* @__PURE__ */ new Map();
|
|
4629
4652
|
do {
|
|
4630
|
-
const stepTimeoutId =
|
|
4653
|
+
const stepTimeoutId = setAbortTimeout({
|
|
4654
|
+
abortController: stepAbortController,
|
|
4655
|
+
label: "Step",
|
|
4656
|
+
timeoutMs: stepTimeoutMs
|
|
4657
|
+
});
|
|
4631
4658
|
try {
|
|
4632
4659
|
const stepInputMessages = [...initialMessages, ...responseMessages];
|
|
4633
4660
|
const prepareStepResult = await (prepareStep == null ? void 0 : prepareStep({
|
|
@@ -6590,7 +6617,6 @@ function runToolsTransformation({
|
|
|
6590
6617
|
}
|
|
6591
6618
|
});
|
|
6592
6619
|
const outstandingToolResults = /* @__PURE__ */ new Set();
|
|
6593
|
-
const toolInputs = /* @__PURE__ */ new Map();
|
|
6594
6620
|
const toolCallsByToolCallId = /* @__PURE__ */ new Map();
|
|
6595
6621
|
let canClose = false;
|
|
6596
6622
|
let finishChunk = void 0;
|
|
@@ -6722,7 +6748,6 @@ function runToolsTransformation({
|
|
|
6722
6748
|
});
|
|
6723
6749
|
break;
|
|
6724
6750
|
}
|
|
6725
|
-
toolInputs.set(toolCall.toolCallId, toolCall.input);
|
|
6726
6751
|
if (tool2.execute != null && toolCall.providerExecuted !== true) {
|
|
6727
6752
|
const toolExecutionId = generateId2();
|
|
6728
6753
|
outstandingToolResults.add(toolExecutionId);
|
|
@@ -6766,7 +6791,7 @@ function runToolsTransformation({
|
|
|
6766
6791
|
type: "tool-error",
|
|
6767
6792
|
toolCallId: chunk.toolCallId,
|
|
6768
6793
|
toolName,
|
|
6769
|
-
input:
|
|
6794
|
+
input: toolCall == null ? void 0 : toolCall.input,
|
|
6770
6795
|
providerExecuted: true,
|
|
6771
6796
|
error: chunk.result,
|
|
6772
6797
|
dynamic: chunk.dynamic,
|
|
@@ -6778,7 +6803,7 @@ function runToolsTransformation({
|
|
|
6778
6803
|
type: "tool-result",
|
|
6779
6804
|
toolCallId: chunk.toolCallId,
|
|
6780
6805
|
toolName,
|
|
6781
|
-
input:
|
|
6806
|
+
input: toolCall == null ? void 0 : toolCall.input,
|
|
6782
6807
|
output: chunk.result,
|
|
6783
6808
|
providerExecuted: true,
|
|
6784
6809
|
dynamic: chunk.dynamic,
|
|
@@ -7578,18 +7603,21 @@ var DefaultStreamTextResult = class {
|
|
|
7578
7603
|
}) {
|
|
7579
7604
|
var _a22, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
7580
7605
|
const includeRawChunks2 = self.includeRawChunks;
|
|
7581
|
-
const stepTimeoutId =
|
|
7606
|
+
const stepTimeoutId = setAbortTimeout({
|
|
7607
|
+
abortController: stepAbortController,
|
|
7608
|
+
label: "Step",
|
|
7609
|
+
timeoutMs: stepTimeoutMs
|
|
7610
|
+
});
|
|
7582
7611
|
let chunkTimeoutId = void 0;
|
|
7583
7612
|
function resetChunkTimeout() {
|
|
7584
|
-
if (
|
|
7585
|
-
|
|
7586
|
-
clearTimeout(chunkTimeoutId);
|
|
7587
|
-
}
|
|
7588
|
-
chunkTimeoutId = setTimeout(
|
|
7589
|
-
() => chunkAbortController.abort(),
|
|
7590
|
-
chunkTimeoutMs
|
|
7591
|
-
);
|
|
7613
|
+
if (chunkTimeoutId != null) {
|
|
7614
|
+
clearTimeout(chunkTimeoutId);
|
|
7592
7615
|
}
|
|
7616
|
+
chunkTimeoutId = setAbortTimeout({
|
|
7617
|
+
abortController: chunkAbortController,
|
|
7618
|
+
label: "Chunk",
|
|
7619
|
+
timeoutMs: chunkTimeoutMs
|
|
7620
|
+
});
|
|
7593
7621
|
}
|
|
7594
7622
|
function clearChunkTimeout() {
|
|
7595
7623
|
if (chunkTimeoutId != null) {
|
|
@@ -7602,6 +7630,8 @@ var DefaultStreamTextResult = class {
|
|
|
7602
7630
|
clearTimeout(stepTimeoutId);
|
|
7603
7631
|
}
|
|
7604
7632
|
}
|
|
7633
|
+
abortSignal == null ? void 0 : abortSignal.addEventListener("abort", clearStepTimeout);
|
|
7634
|
+
abortSignal == null ? void 0 : abortSignal.addEventListener("abort", clearChunkTimeout);
|
|
7605
7635
|
try {
|
|
7606
7636
|
stepFinish = new import_provider_utils20.DelayedPromise();
|
|
7607
7637
|
const stepInputMessages = [...initialMessages, ...responseMessages];
|
|
@@ -8097,9 +8127,10 @@ var DefaultStreamTextResult = class {
|
|
|
8097
8127
|
})
|
|
8098
8128
|
)
|
|
8099
8129
|
);
|
|
8100
|
-
}
|
|
8130
|
+
} catch (error) {
|
|
8101
8131
|
clearStepTimeout();
|
|
8102
8132
|
clearChunkTimeout();
|
|
8133
|
+
throw error;
|
|
8103
8134
|
}
|
|
8104
8135
|
}
|
|
8105
8136
|
await streamStep({
|
|
@@ -9017,10 +9048,12 @@ async function convertToModelMessages(messages, options) {
|
|
|
9017
9048
|
throw new Error(`Unsupported part: ${_exhaustiveCheck}`);
|
|
9018
9049
|
}
|
|
9019
9050
|
}
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9051
|
+
if (content.length > 0) {
|
|
9052
|
+
modelMessages.push({
|
|
9053
|
+
role: "assistant",
|
|
9054
|
+
content
|
|
9055
|
+
});
|
|
9056
|
+
}
|
|
9024
9057
|
const toolParts = block.filter(
|
|
9025
9058
|
(part) => {
|
|
9026
9059
|
var _a23;
|
|
@@ -9051,7 +9084,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
9051
9084
|
toolName: getToolName(toolPart),
|
|
9052
9085
|
output: {
|
|
9053
9086
|
type: "error-text",
|
|
9054
|
-
value: (_g = (_f = toolPart.approval) == null ? void 0 : _f.reason) != null ? _g : "Tool execution denied."
|
|
9087
|
+
value: (_g = (_f = toolPart.approval) == null ? void 0 : _f.reason) != null ? _g : "Tool call execution denied."
|
|
9055
9088
|
},
|
|
9056
9089
|
...toolPart.callProviderMetadata != null ? { providerOptions: toolPart.callProviderMetadata } : {}
|
|
9057
9090
|
});
|
|
@@ -11894,13 +11927,14 @@ async function experimental_generateVideo({
|
|
|
11894
11927
|
abortSignal
|
|
11895
11928
|
});
|
|
11896
11929
|
const { prompt, image } = normalizePrompt2(promptArg);
|
|
11897
|
-
const normalizedFrameImages = frameImages == null ? void 0 : frameImages.
|
|
11898
|
-
|
|
11899
|
-
frameType: frame.frameType
|
|
11900
|
-
})
|
|
11901
|
-
const normalizedInputReferences = inputReferences == null ? void 0 : inputReferences.
|
|
11902
|
-
|
|
11903
|
-
|
|
11930
|
+
const normalizedFrameImages = frameImages == null ? void 0 : frameImages.flatMap((frame) => {
|
|
11931
|
+
const normalizedImage = normalizeImageData(frame.image);
|
|
11932
|
+
return normalizedImage != null ? [{ image: normalizedImage, frameType: frame.frameType }] : [];
|
|
11933
|
+
});
|
|
11934
|
+
const normalizedInputReferences = inputReferences == null ? void 0 : inputReferences.flatMap((reference) => {
|
|
11935
|
+
const normalized = normalizeReferenceData(reference);
|
|
11936
|
+
return normalized != null ? [normalized] : [];
|
|
11937
|
+
});
|
|
11904
11938
|
const effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? void 0 : normalizedInputReferences;
|
|
11905
11939
|
const warnings = [];
|
|
11906
11940
|
if (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) {
|
|
@@ -12054,8 +12088,12 @@ function normalizePrompt2(promptArg) {
|
|
|
12054
12088
|
image: promptArg.image != null ? normalizeImageData(promptArg.image) : void 0
|
|
12055
12089
|
};
|
|
12056
12090
|
}
|
|
12057
|
-
function
|
|
12058
|
-
var _a22
|
|
12091
|
+
function detectFileMediaType(data, restrictToImages) {
|
|
12092
|
+
var _a22;
|
|
12093
|
+
const detected = restrictToImages ? detectMediaType({ data, signatures: imageMediaTypeSignatures }) : (_a22 = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _a22 : detectMediaType({ data, signatures: videoMediaTypeSignatures });
|
|
12094
|
+
return detected != null ? detected : "image/png";
|
|
12095
|
+
}
|
|
12096
|
+
function normalizeImageData(dataContent, { restrictToImages = true } = {}) {
|
|
12059
12097
|
if (typeof dataContent === "string") {
|
|
12060
12098
|
if (dataContent.startsWith("http://") || dataContent.startsWith("https://")) {
|
|
12061
12099
|
return {
|
|
@@ -12065,27 +12103,46 @@ function normalizeImageData(dataContent) {
|
|
|
12065
12103
|
}
|
|
12066
12104
|
if (dataContent.startsWith("data:")) {
|
|
12067
12105
|
const { mediaType, base64Content } = splitDataUrl(dataContent);
|
|
12106
|
+
const data = (0, import_provider_utils35.convertBase64ToUint8Array)(base64Content != null ? base64Content : "");
|
|
12068
12107
|
return {
|
|
12069
12108
|
type: "file",
|
|
12070
|
-
mediaType: mediaType != null ? mediaType :
|
|
12071
|
-
data
|
|
12109
|
+
mediaType: mediaType != null ? mediaType : detectFileMediaType(data, restrictToImages),
|
|
12110
|
+
data
|
|
12072
12111
|
};
|
|
12073
12112
|
}
|
|
12074
|
-
const
|
|
12113
|
+
const bytes = (0, import_provider_utils35.convertBase64ToUint8Array)(dataContent);
|
|
12075
12114
|
return {
|
|
12076
12115
|
type: "file",
|
|
12077
|
-
mediaType: (
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12116
|
+
mediaType: detectFileMediaType(bytes, restrictToImages),
|
|
12117
|
+
data: bytes
|
|
12118
|
+
};
|
|
12119
|
+
}
|
|
12120
|
+
if (dataContent instanceof Uint8Array || dataContent instanceof ArrayBuffer) {
|
|
12121
|
+
const bytes = dataContent instanceof Uint8Array ? dataContent : new Uint8Array(dataContent);
|
|
12122
|
+
return {
|
|
12123
|
+
type: "file",
|
|
12124
|
+
mediaType: detectFileMediaType(bytes, restrictToImages),
|
|
12125
|
+
data: bytes
|
|
12082
12126
|
};
|
|
12083
12127
|
}
|
|
12084
|
-
|
|
12128
|
+
return void 0;
|
|
12129
|
+
}
|
|
12130
|
+
function normalizeReferenceData(reference) {
|
|
12131
|
+
const isObjectForm = typeof reference === "object" && reference != null && !(reference instanceof Uint8Array) && !(reference instanceof ArrayBuffer) && "data" in reference;
|
|
12132
|
+
if (!isObjectForm) {
|
|
12133
|
+
return normalizeImageData(reference, {
|
|
12134
|
+
restrictToImages: false
|
|
12135
|
+
});
|
|
12136
|
+
}
|
|
12137
|
+
const normalized = normalizeImageData(reference.data, {
|
|
12138
|
+
restrictToImages: false
|
|
12139
|
+
});
|
|
12140
|
+
if (normalized == null) {
|
|
12141
|
+
return normalized;
|
|
12142
|
+
}
|
|
12085
12143
|
return {
|
|
12086
|
-
|
|
12087
|
-
mediaType
|
|
12088
|
-
data: bytes
|
|
12144
|
+
...normalized,
|
|
12145
|
+
...reference.mediaType != null ? { mediaType: reference.mediaType } : {}
|
|
12089
12146
|
};
|
|
12090
12147
|
}
|
|
12091
12148
|
async function invokeModelMaxVideosPerCall(model) {
|
|
@@ -13617,7 +13674,7 @@ var AbstractChat = class {
|
|
|
13617
13674
|
const updatePart = (part) => isToolUIPart(part) && part.state === "approval-requested" && part.approval.id === id ? {
|
|
13618
13675
|
...part,
|
|
13619
13676
|
state: "approval-responded",
|
|
13620
|
-
approval: { id, approved, reason }
|
|
13677
|
+
approval: { ...part.approval, id, approved, reason }
|
|
13621
13678
|
} : part;
|
|
13622
13679
|
this.state.replaceMessage(messages.length - 1, {
|
|
13623
13680
|
...lastMessage,
|
|
@@ -14089,6 +14146,7 @@ var TextStreamChatTransport = class extends HttpChatTransport {
|
|
|
14089
14146
|
hasToolCall,
|
|
14090
14147
|
isDataUIPart,
|
|
14091
14148
|
isDeepEqualData,
|
|
14149
|
+
isDynamicToolUIPart,
|
|
14092
14150
|
isFileUIPart,
|
|
14093
14151
|
isLoopFinished,
|
|
14094
14152
|
isReasoningUIPart,
|