ai 7.0.34 → 7.0.35
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 +9 -0
- package/dist/index.d.ts +26 -10
- package/dist/index.js +119 -45
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +5 -2
- package/dist/internal/index.js +1 -1
- package/docs/03-ai-sdk-core/25-settings.mdx +15 -2
- package/docs/03-ai-sdk-core/65-devtools.mdx +6 -0
- package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +42 -0
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +4 -4
- package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +10 -8
- package/docs/07-reference/02-ai-sdk-ui/42-pipe-ui-message-stream-to-response.mdx +6 -1
- package/package.json +2 -2
- package/src/agent/agent.ts +4 -1
- package/src/agent/pipe-agent-ui-stream-to-response.ts +1 -1
- package/src/generate-object/stream-object-result.ts +4 -1
- package/src/generate-object/stream-object.ts +1 -1
- package/src/generate-text/generate-text-events.ts +2 -1
- package/src/generate-text/stream-text-result.ts +5 -2
- package/src/generate-text/stream-text.ts +113 -33
- package/src/prompt/index.ts +1 -0
- package/src/prompt/request-options.ts +20 -2
- package/src/text-stream/pipe-text-stream-to-response.ts +3 -2
- package/src/ui-message-stream/pipe-ui-message-stream-to-response.ts +3 -2
- package/src/util/create-stitchable-stream.ts +41 -15
- package/src/util/write-to-server-response.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.35
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7f6650b: Return response piping promises so callers can catch stream read and write errors.
|
|
8
|
+
- 106ea59: feat(ai): add per-step first content timeout for streaming generations
|
|
9
|
+
- Updated dependencies [2112ff1]
|
|
10
|
+
- @ai-sdk/gateway@4.0.27
|
|
11
|
+
|
|
3
12
|
## 7.0.34
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -589,13 +589,15 @@ type LanguageModelCallOptions = {
|
|
|
589
589
|
* - A number representing milliseconds
|
|
590
590
|
* - An object with `totalMs` property for the total timeout in milliseconds
|
|
591
591
|
* - An object with `stepMs` property for the timeout of each step in milliseconds
|
|
592
|
-
* - An object with `
|
|
592
|
+
* - An object with `firstChunkMs` property for the timeout until the first content chunk of each step (streaming only)
|
|
593
|
+
* - An object with `chunkMs` property for the timeout between content chunks (streaming only)
|
|
593
594
|
* - An object with `toolMs` property for the default timeout for all tool executions
|
|
594
595
|
* - An object with `tools` property for per-tool timeout overrides using `{toolName}Ms` keys
|
|
595
596
|
*/
|
|
596
597
|
type TimeoutConfiguration<TOOLS extends ToolSet> = number | {
|
|
597
598
|
totalMs?: number;
|
|
598
599
|
stepMs?: number;
|
|
600
|
+
firstChunkMs?: number;
|
|
599
601
|
chunkMs?: number;
|
|
600
602
|
toolMs?: number;
|
|
601
603
|
tools?: Partial<Record<`${keyof TOOLS & string}Ms`, number>>;
|
|
@@ -614,9 +616,17 @@ declare function getTotalTimeoutMs(timeout: TimeoutConfiguration<any> | undefine
|
|
|
614
616
|
* @returns The step timeout in milliseconds, or undefined if no step timeout is configured.
|
|
615
617
|
*/
|
|
616
618
|
declare function getStepTimeoutMs(timeout: TimeoutConfiguration<any> | undefined): number | undefined;
|
|
619
|
+
/**
|
|
620
|
+
* Extracts the first chunk timeout value in milliseconds from a TimeoutConfiguration.
|
|
621
|
+
* This timeout is for streaming only - it aborts if no content chunk is received within the specified duration.
|
|
622
|
+
*
|
|
623
|
+
* @param timeout - The timeout configuration.
|
|
624
|
+
* @returns The first chunk timeout in milliseconds, or undefined if no first chunk timeout is configured.
|
|
625
|
+
*/
|
|
626
|
+
declare function getFirstChunkTimeoutMs(timeout: TimeoutConfiguration<any> | undefined): number | undefined;
|
|
617
627
|
/**
|
|
618
628
|
* Extracts the chunk timeout value in milliseconds from a TimeoutConfiguration.
|
|
619
|
-
* This timeout is for streaming only - it aborts if no new chunk is received within the specified duration.
|
|
629
|
+
* This timeout is for streaming only - it aborts if no new content chunk is received within the specified duration.
|
|
620
630
|
*
|
|
621
631
|
* @param timeout - The timeout configuration.
|
|
622
632
|
* @returns The chunk timeout in milliseconds, or undefined if no chunk timeout is configured.
|
|
@@ -2758,7 +2768,7 @@ interface StreamTextResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Contex
|
|
|
2758
2768
|
* `pipeUIMessageStreamToResponse` helpers from `'ai'` with `result.stream`
|
|
2759
2769
|
* instead. This method will be removed in the next major release.
|
|
2760
2770
|
*/
|
|
2761
|
-
pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(response: ServerResponse, options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): void
|
|
2771
|
+
pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(response: ServerResponse, options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): Promise<void>;
|
|
2762
2772
|
/**
|
|
2763
2773
|
* Writes text delta output to a Node.js response-like object.
|
|
2764
2774
|
* It sets a `Content-Type` header to `text/plain; charset=utf-8` and
|
|
@@ -2771,7 +2781,7 @@ interface StreamTextResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Contex
|
|
|
2771
2781
|
* `pipeTextStreamToResponse` helpers from `'ai'` with `result.stream`
|
|
2772
2782
|
* instead. This method will be removed in the next major release.
|
|
2773
2783
|
*/
|
|
2774
|
-
pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): void
|
|
2784
|
+
pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): Promise<void>;
|
|
2775
2785
|
/**
|
|
2776
2786
|
* Converts the result to a streamed response object with a stream data part stream.
|
|
2777
2787
|
*
|
|
@@ -3778,7 +3788,8 @@ type GenerateTextStartEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT ext
|
|
|
3778
3788
|
readonly maxRetries: number;
|
|
3779
3789
|
/**
|
|
3780
3790
|
* Timeout configuration for the generation.
|
|
3781
|
-
* Can be a number (milliseconds) or an object with totalMs, stepMs,
|
|
3791
|
+
* Can be a number (milliseconds) or an object with totalMs, stepMs,
|
|
3792
|
+
* firstChunkMs (streaming only), chunkMs, toolMs, and per-tool overrides via tools.
|
|
3782
3793
|
*/
|
|
3783
3794
|
readonly timeout: TimeoutConfiguration<TOOLS> | undefined;
|
|
3784
3795
|
/** Additional HTTP headers sent with the request. */
|
|
@@ -4474,7 +4485,10 @@ type AgentCallParameters<CALL_OPTIONS, TOOLS extends ToolSet = {}, RUNTIME_CONTE
|
|
|
4474
4485
|
*/
|
|
4475
4486
|
abortSignal?: AbortSignal;
|
|
4476
4487
|
/**
|
|
4477
|
-
* Timeout in milliseconds. Can be specified as a number or as an object
|
|
4488
|
+
* Timeout in milliseconds. Can be specified as a number or as an object
|
|
4489
|
+
* with total, per-step, first-content, inter-content, and tool timeouts.
|
|
4490
|
+
* First-content and inter-content timeouts are only enforced by streaming
|
|
4491
|
+
* calls.
|
|
4478
4492
|
*/
|
|
4479
4493
|
timeout?: TimeoutConfiguration<TOOLS>;
|
|
4480
4494
|
/**
|
|
@@ -5915,11 +5929,12 @@ declare class JsonToSseTransformStream extends TransformStream<unknown, string>
|
|
|
5915
5929
|
* @param options.headers - Additional HTTP headers to include in the response.
|
|
5916
5930
|
* @param options.stream - The UI message chunk stream to send.
|
|
5917
5931
|
* @param options.consumeSseStream - Optional callback to consume a copy of the SSE stream independently.
|
|
5932
|
+
* @returns A promise that resolves when the stream has been written.
|
|
5918
5933
|
*/
|
|
5919
5934
|
declare function pipeUIMessageStreamToResponse({ response, status, statusText, headers, stream, consumeSseStream, }: {
|
|
5920
5935
|
response: ServerResponse;
|
|
5921
5936
|
stream: ReadableStream<UIMessageChunk>;
|
|
5922
|
-
} & UIMessageStreamResponseInit): void
|
|
5937
|
+
} & UIMessageStreamResponseInit): Promise<void>;
|
|
5923
5938
|
|
|
5924
5939
|
/**
|
|
5925
5940
|
* Transforms a stream of `UIMessageChunk`s into an `AsyncIterableStream` of `UIMessage`s.
|
|
@@ -7369,7 +7384,7 @@ interface StreamObjectResult<PARTIAL, RESULT, ELEMENT_STREAM> {
|
|
|
7369
7384
|
* @param response A Node.js response-like object (ServerResponse).
|
|
7370
7385
|
* @param init Optional headers, status code, and status text.
|
|
7371
7386
|
*/
|
|
7372
|
-
pipeTextStreamToResponse(response: ServerResponse$1, init?: ResponseInit): void
|
|
7387
|
+
pipeTextStreamToResponse(response: ServerResponse$1, init?: ResponseInit): Promise<void>;
|
|
7373
7388
|
/**
|
|
7374
7389
|
* Creates a simple text stream response.
|
|
7375
7390
|
* The response has a `Content-Type` header set to `text/plain; charset=utf-8`.
|
|
@@ -8512,11 +8527,12 @@ declare function createTextStreamResponse({ status, statusText, headers, stream,
|
|
|
8512
8527
|
* @param options.statusText - Optional HTTP status text.
|
|
8513
8528
|
* @param options.headers - Optional response headers.
|
|
8514
8529
|
* @param options.stream - The text stream to pipe.
|
|
8530
|
+
* @returns A promise that resolves when the stream has been written.
|
|
8515
8531
|
*/
|
|
8516
8532
|
declare function pipeTextStreamToResponse({ response, status, statusText, headers, stream, }: {
|
|
8517
8533
|
response: ServerResponse;
|
|
8518
8534
|
stream: ReadableStream<string>;
|
|
8519
|
-
} & ResponseInit): void
|
|
8535
|
+
} & ResponseInit): Promise<void>;
|
|
8520
8536
|
|
|
8521
8537
|
/**
|
|
8522
8538
|
* Converts a stream of `TextStreamPart` chunks into a stream of text deltas.
|
|
@@ -8827,4 +8843,4 @@ declare function uploadSkill({ api, files, displayTitle, providerOptions, }: {
|
|
|
8827
8843
|
files: UploadSkillFile[];
|
|
8828
8844
|
}): Promise<UploadSkillResult>;
|
|
8829
8845
|
|
|
8830
|
-
export { AI_SDK_TELEMETRY_TRACING_CHANNEL, AbstractChat, ActiveTools, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, CustomContentUIPart, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedEndEvent, EmbedManyResult, EmbedResult, EmbedStartEvent, Embedding, EmbeddingModel, EmbeddingModelCallEndEvent, EmbeddingModelCallStartEvent, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, AbstractRealtimeSession as Experimental_AbstractRealtimeSession, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LanguageModelStreamPart as Experimental_LanguageModelStreamPart, LogWarningsFunction as Experimental_LogWarningsFunction, RealtimeClientEvent as Experimental_RealtimeClientEvent, RealtimeFactory as Experimental_RealtimeFactory, RealtimeFactoryGetTokenOptions as Experimental_RealtimeFactoryGetTokenOptions, RealtimeFactoryGetTokenResult as Experimental_RealtimeFactoryGetTokenResult, RealtimeModel as Experimental_RealtimeModel, RealtimeServerEvent as Experimental_RealtimeServerEvent, RealtimeSessionConfig as Experimental_RealtimeSessionConfig, RealtimeSessionOptions as Experimental_RealtimeSessionOptions, RealtimeSetupResponse as Experimental_RealtimeSetupResponse, RealtimeState as Experimental_RealtimeState, RealtimeStatus as Experimental_RealtimeStatus, RealtimeToolDefinition as Experimental_RealtimeToolDefinition, Experimental_SpeechResult, Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectEndEvent, GenerateObjectResult, GenerateObjectStartEvent, GenerateObjectStepEndEvent, GenerateObjectStepStartEvent, GenerateTextAbortEvent, GenerateTextEndEvent, GenerateTextInclude, GenerateTextOnAbortCallback, GenerateTextOnEndCallback, GenerateTextOnFinishCallback, GenerateTextOnStartCallback, GenerateTextOnStepEndCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextResult, GenerateTextStartEvent, GenerateTextStepEndEvent, GenerateTextStepStartEvent, GenerateVideoPrompt, GenerateVideoResult, GeneratedAudioFile, GeneratedFile, GenericToolApprovalFunction, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferTelemetryEvent, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, Instructions, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelCallEndEvent, LanguageModelCallOptions, LanguageModelCallStartEvent, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, ModelInfo, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnLanguageModelCallEndCallback, OnLanguageModelCallStartCallback, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, OnToolExecutionEndCallback, OnToolExecutionStartCallback, output as Output, OutputChunkTimingStats, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderReference, ProviderRegistryProvider, ReasoningFileOutput, ReasoningFileUIPart, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RequestOptions, RerankEndEvent, RerankResult, RerankStartEvent, RerankingModel, RerankingModelCallEndEvent, RerankingModelCallStartEvent, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SingleToolApprovalFunction, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechResult, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepResultPerformance, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextInclude, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextResult, StreamTextTransform, StreamTranscriptionResult, Telemetry, TelemetryOptions, TelemetryTracingChannelMessage, TelemetryTracingEventType, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToUIMessageChunkOptions, ToolApprovalConfiguration, ToolApprovalRequestOutput, ToolApprovalResponseOutput, ToolApprovalStatus, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolExecutionEndEvent, ToolExecutionStartEvent, ToolInputRefinement, ToolLoopAgent, ToolLoopAgentSettings, ToolOrder, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionResult, TranscriptionStreamPart, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnEndCallback, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepEndCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UploadFileResult, UploadSkillResult, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, callCompletionApi, consumeStream, convertDataContentToBase64String, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, detectToolDrift, embed, embedMany, experimental_createProviderRegistry, decodeRealtimeAudio as experimental_decodeRealtimeAudio, encodeRealtimeAudio as experimental_encodeRealtimeAudio, filterActiveTools as experimental_filterActiveTools, experimental_generateSpeech, experimental_generateVideo, getRealtimeToolDefinitions as experimental_getRealtimeToolDefinitions, resampleAudio as experimental_resampleAudio, streamLanguageModelCall as experimental_streamLanguageModelCall, streamTranscribe as experimental_streamTranscribe, experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, fingerprintTools, generateImage, generateObject, generateSpeech, generateText, getChunkTimeoutMs, getStaticToolName, getStepTimeoutMs, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, getToolTimeoutMs, getTotalTimeoutMs, hasToolCall, isCustomContentUIPart, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isLoopFinished, isReasoningFileUIPart, isReasoningUIPart, isStaticToolUIPart, isStepCount, isTextUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetry, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, isStepCount as stepCountIs, streamObject, streamText, systemModelMessageSchema, toTextStream, toUIMessageChunk, toUIMessageStream, toolModelMessageSchema, transcribe, uiMessageChunkSchema, uploadFile, uploadSkill, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
|
|
8846
|
+
export { AI_SDK_TELEMETRY_TRACING_CHANNEL, AbstractChat, ActiveTools, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, CustomContentUIPart, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedEndEvent, EmbedManyResult, EmbedResult, EmbedStartEvent, Embedding, EmbeddingModel, EmbeddingModelCallEndEvent, EmbeddingModelCallStartEvent, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, AbstractRealtimeSession as Experimental_AbstractRealtimeSession, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LanguageModelStreamPart as Experimental_LanguageModelStreamPart, LogWarningsFunction as Experimental_LogWarningsFunction, RealtimeClientEvent as Experimental_RealtimeClientEvent, RealtimeFactory as Experimental_RealtimeFactory, RealtimeFactoryGetTokenOptions as Experimental_RealtimeFactoryGetTokenOptions, RealtimeFactoryGetTokenResult as Experimental_RealtimeFactoryGetTokenResult, RealtimeModel as Experimental_RealtimeModel, RealtimeServerEvent as Experimental_RealtimeServerEvent, RealtimeSessionConfig as Experimental_RealtimeSessionConfig, RealtimeSessionOptions as Experimental_RealtimeSessionOptions, RealtimeSetupResponse as Experimental_RealtimeSetupResponse, RealtimeState as Experimental_RealtimeState, RealtimeStatus as Experimental_RealtimeStatus, RealtimeToolDefinition as Experimental_RealtimeToolDefinition, Experimental_SpeechResult, Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectEndEvent, GenerateObjectResult, GenerateObjectStartEvent, GenerateObjectStepEndEvent, GenerateObjectStepStartEvent, GenerateTextAbortEvent, GenerateTextEndEvent, GenerateTextInclude, GenerateTextOnAbortCallback, GenerateTextOnEndCallback, GenerateTextOnFinishCallback, GenerateTextOnStartCallback, GenerateTextOnStepEndCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextResult, GenerateTextStartEvent, GenerateTextStepEndEvent, GenerateTextStepStartEvent, GenerateVideoPrompt, GenerateVideoResult, GeneratedAudioFile, GeneratedFile, GenericToolApprovalFunction, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferTelemetryEvent, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, Instructions, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelCallEndEvent, LanguageModelCallOptions, LanguageModelCallStartEvent, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, ModelInfo, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnLanguageModelCallEndCallback, OnLanguageModelCallStartCallback, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, OnToolExecutionEndCallback, OnToolExecutionStartCallback, output as Output, OutputChunkTimingStats, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderReference, ProviderRegistryProvider, ReasoningFileOutput, ReasoningFileUIPart, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RequestOptions, RerankEndEvent, RerankResult, RerankStartEvent, RerankingModel, RerankingModelCallEndEvent, RerankingModelCallStartEvent, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SingleToolApprovalFunction, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechResult, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepResultPerformance, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextInclude, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextResult, StreamTextTransform, StreamTranscriptionResult, Telemetry, TelemetryOptions, TelemetryTracingChannelMessage, TelemetryTracingEventType, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToUIMessageChunkOptions, ToolApprovalConfiguration, ToolApprovalRequestOutput, ToolApprovalResponseOutput, ToolApprovalStatus, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolExecutionEndEvent, ToolExecutionStartEvent, ToolInputRefinement, ToolLoopAgent, ToolLoopAgentSettings, ToolOrder, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionResult, TranscriptionStreamPart, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnEndCallback, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepEndCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UploadFileResult, UploadSkillResult, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, callCompletionApi, consumeStream, convertDataContentToBase64String, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, detectToolDrift, embed, embedMany, experimental_createProviderRegistry, decodeRealtimeAudio as experimental_decodeRealtimeAudio, encodeRealtimeAudio as experimental_encodeRealtimeAudio, filterActiveTools as experimental_filterActiveTools, experimental_generateSpeech, experimental_generateVideo, getRealtimeToolDefinitions as experimental_getRealtimeToolDefinitions, resampleAudio as experimental_resampleAudio, streamLanguageModelCall as experimental_streamLanguageModelCall, streamTranscribe as experimental_streamTranscribe, experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, fingerprintTools, generateImage, generateObject, generateSpeech, generateText, getChunkTimeoutMs, getFirstChunkTimeoutMs, getStaticToolName, getStepTimeoutMs, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, getToolTimeoutMs, getTotalTimeoutMs, hasToolCall, isCustomContentUIPart, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isLoopFinished, isReasoningFileUIPart, isReasoningUIPart, isStaticToolUIPart, isStepCount, isTextUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetry, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, isStepCount as stepCountIs, streamObject, streamText, systemModelMessageSchema, toTextStream, toUIMessageChunk, toUIMessageStream, toolModelMessageSchema, transcribe, uiMessageChunkSchema, uploadFile, uploadSkill, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
|
package/dist/index.js
CHANGED
|
@@ -1089,7 +1089,7 @@ import {
|
|
|
1089
1089
|
} from "@ai-sdk/provider-utils";
|
|
1090
1090
|
|
|
1091
1091
|
// src/version.ts
|
|
1092
|
-
var VERSION = true ? "7.0.
|
|
1092
|
+
var VERSION = true ? "7.0.35" : "0.0.0-test";
|
|
1093
1093
|
|
|
1094
1094
|
// src/util/download/download.ts
|
|
1095
1095
|
var download = async ({
|
|
@@ -2147,6 +2147,12 @@ function getStepTimeoutMs(timeout) {
|
|
|
2147
2147
|
}
|
|
2148
2148
|
return timeout.stepMs;
|
|
2149
2149
|
}
|
|
2150
|
+
function getFirstChunkTimeoutMs(timeout) {
|
|
2151
|
+
if (timeout == null || typeof timeout === "number") {
|
|
2152
|
+
return void 0;
|
|
2153
|
+
}
|
|
2154
|
+
return timeout.firstChunkMs;
|
|
2155
|
+
}
|
|
2150
2156
|
function getChunkTimeoutMs(timeout) {
|
|
2151
2157
|
if (timeout == null || typeof timeout === "number") {
|
|
2152
2158
|
return void 0;
|
|
@@ -6128,7 +6134,7 @@ function writeToServerResponse({
|
|
|
6128
6134
|
response.end();
|
|
6129
6135
|
}
|
|
6130
6136
|
};
|
|
6131
|
-
read();
|
|
6137
|
+
return read();
|
|
6132
6138
|
}
|
|
6133
6139
|
|
|
6134
6140
|
// src/text-stream/pipe-text-stream-to-response.ts
|
|
@@ -6139,7 +6145,7 @@ function pipeTextStreamToResponse({
|
|
|
6139
6145
|
headers,
|
|
6140
6146
|
stream
|
|
6141
6147
|
}) {
|
|
6142
|
-
writeToServerResponse({
|
|
6148
|
+
return writeToServerResponse({
|
|
6143
6149
|
response,
|
|
6144
6150
|
status,
|
|
6145
6151
|
statusText,
|
|
@@ -6229,7 +6235,7 @@ function pipeUIMessageStreamToResponse({
|
|
|
6229
6235
|
sseStream = stream1;
|
|
6230
6236
|
consumeSseStream({ stream: stream2 });
|
|
6231
6237
|
}
|
|
6232
|
-
writeToServerResponse({
|
|
6238
|
+
return writeToServerResponse({
|
|
6233
6239
|
response,
|
|
6234
6240
|
status,
|
|
6235
6241
|
statusText,
|
|
@@ -7665,32 +7671,37 @@ function createResolvablePromise() {
|
|
|
7665
7671
|
|
|
7666
7672
|
// src/util/create-stitchable-stream.ts
|
|
7667
7673
|
function createStitchableStream() {
|
|
7668
|
-
let
|
|
7674
|
+
let innerStreams = [];
|
|
7669
7675
|
let controller = null;
|
|
7670
7676
|
let isClosed = false;
|
|
7671
7677
|
let waitForNewStream = createResolvablePromise();
|
|
7672
7678
|
const terminate = () => {
|
|
7673
7679
|
isClosed = true;
|
|
7674
7680
|
waitForNewStream.resolve();
|
|
7675
|
-
|
|
7676
|
-
|
|
7681
|
+
innerStreams.forEach(({ reader, onCancel }) => {
|
|
7682
|
+
onCancel == null ? void 0 : onCancel();
|
|
7683
|
+
reader.cancel();
|
|
7684
|
+
});
|
|
7685
|
+
innerStreams = [];
|
|
7677
7686
|
controller == null ? void 0 : controller.close();
|
|
7678
7687
|
};
|
|
7679
7688
|
const processPull = async () => {
|
|
7680
|
-
|
|
7689
|
+
var _a22;
|
|
7690
|
+
if (isClosed && innerStreams.length === 0) {
|
|
7681
7691
|
controller == null ? void 0 : controller.close();
|
|
7682
7692
|
return;
|
|
7683
7693
|
}
|
|
7684
|
-
if (
|
|
7694
|
+
if (innerStreams.length === 0) {
|
|
7685
7695
|
waitForNewStream = createResolvablePromise();
|
|
7686
7696
|
await waitForNewStream.promise;
|
|
7687
7697
|
return await processPull();
|
|
7688
7698
|
}
|
|
7699
|
+
const currentStream = innerStreams[0];
|
|
7689
7700
|
try {
|
|
7690
|
-
const { value, done } = await
|
|
7701
|
+
const { value, done } = await currentStream.reader.read();
|
|
7691
7702
|
if (done) {
|
|
7692
|
-
|
|
7693
|
-
if (
|
|
7703
|
+
innerStreams.shift();
|
|
7704
|
+
if (innerStreams.length === 0 && isClosed) {
|
|
7694
7705
|
controller == null ? void 0 : controller.close();
|
|
7695
7706
|
} else {
|
|
7696
7707
|
await processPull();
|
|
@@ -7699,8 +7710,9 @@ function createStitchableStream() {
|
|
|
7699
7710
|
controller == null ? void 0 : controller.enqueue(value);
|
|
7700
7711
|
}
|
|
7701
7712
|
} catch (error) {
|
|
7713
|
+
(_a22 = currentStream.onError) == null ? void 0 : _a22.call(currentStream, error);
|
|
7702
7714
|
controller == null ? void 0 : controller.error(error);
|
|
7703
|
-
|
|
7715
|
+
innerStreams.shift();
|
|
7704
7716
|
terminate();
|
|
7705
7717
|
}
|
|
7706
7718
|
};
|
|
@@ -7711,18 +7723,22 @@ function createStitchableStream() {
|
|
|
7711
7723
|
},
|
|
7712
7724
|
pull: processPull,
|
|
7713
7725
|
async cancel() {
|
|
7714
|
-
for (const reader of
|
|
7726
|
+
for (const { reader, onCancel } of innerStreams) {
|
|
7727
|
+
onCancel == null ? void 0 : onCancel();
|
|
7715
7728
|
await reader.cancel();
|
|
7716
7729
|
}
|
|
7717
|
-
|
|
7730
|
+
innerStreams = [];
|
|
7718
7731
|
isClosed = true;
|
|
7719
7732
|
}
|
|
7720
7733
|
}),
|
|
7721
|
-
addStream: (innerStream) => {
|
|
7734
|
+
addStream: (innerStream, callbacks) => {
|
|
7722
7735
|
if (isClosed) {
|
|
7723
7736
|
throw new Error("Cannot add inner stream: outer stream is closed");
|
|
7724
7737
|
}
|
|
7725
|
-
|
|
7738
|
+
innerStreams.push({
|
|
7739
|
+
reader: innerStream.getReader(),
|
|
7740
|
+
...callbacks
|
|
7741
|
+
});
|
|
7726
7742
|
waitForNewStream.resolve();
|
|
7727
7743
|
},
|
|
7728
7744
|
/**
|
|
@@ -7732,7 +7748,7 @@ function createStitchableStream() {
|
|
|
7732
7748
|
close: () => {
|
|
7733
7749
|
isClosed = true;
|
|
7734
7750
|
waitForNewStream.resolve();
|
|
7735
|
-
if (
|
|
7751
|
+
if (innerStreams.length === 0) {
|
|
7736
7752
|
controller == null ? void 0 : controller.close();
|
|
7737
7753
|
}
|
|
7738
7754
|
},
|
|
@@ -8443,23 +8459,23 @@ var originalGenerateCallId3 = createIdGenerator3({
|
|
|
8443
8459
|
});
|
|
8444
8460
|
var isOutputChunkType = {
|
|
8445
8461
|
file: true,
|
|
8446
|
-
custom:
|
|
8447
|
-
source:
|
|
8448
|
-
"text-start":
|
|
8449
|
-
"text-end":
|
|
8462
|
+
custom: false,
|
|
8463
|
+
source: false,
|
|
8464
|
+
"text-start": false,
|
|
8465
|
+
"text-end": false,
|
|
8450
8466
|
"text-delta": true,
|
|
8451
|
-
"reasoning-start":
|
|
8452
|
-
"reasoning-end":
|
|
8467
|
+
"reasoning-start": false,
|
|
8468
|
+
"reasoning-end": false,
|
|
8453
8469
|
"reasoning-delta": true,
|
|
8454
8470
|
"reasoning-file": true,
|
|
8455
|
-
"tool-input-start":
|
|
8456
|
-
"tool-input-end":
|
|
8471
|
+
"tool-input-start": false,
|
|
8472
|
+
"tool-input-end": false,
|
|
8457
8473
|
"tool-input-delta": true,
|
|
8458
|
-
"tool-approval-request":
|
|
8459
|
-
"tool-approval-response":
|
|
8474
|
+
"tool-approval-request": false,
|
|
8475
|
+
"tool-approval-response": false,
|
|
8460
8476
|
"tool-call": true,
|
|
8461
|
-
"tool-result":
|
|
8462
|
-
"tool-error":
|
|
8477
|
+
"tool-result": false,
|
|
8478
|
+
"tool-error": false,
|
|
8463
8479
|
"tool-execution-end": false,
|
|
8464
8480
|
"model-call-start": false,
|
|
8465
8481
|
"model-call-response-metadata": false,
|
|
@@ -8467,6 +8483,24 @@ var isOutputChunkType = {
|
|
|
8467
8483
|
error: false,
|
|
8468
8484
|
raw: false
|
|
8469
8485
|
};
|
|
8486
|
+
function isOutputChunk2(chunk) {
|
|
8487
|
+
if (!isOutputChunkType[chunk.type]) {
|
|
8488
|
+
return false;
|
|
8489
|
+
}
|
|
8490
|
+
switch (chunk.type) {
|
|
8491
|
+
case "text-delta":
|
|
8492
|
+
case "reasoning-delta":
|
|
8493
|
+
return chunk.text.length > 0;
|
|
8494
|
+
case "tool-input-delta":
|
|
8495
|
+
return chunk.delta.length > 0;
|
|
8496
|
+
case "file":
|
|
8497
|
+
case "reasoning-file":
|
|
8498
|
+
case "tool-call":
|
|
8499
|
+
return true;
|
|
8500
|
+
default:
|
|
8501
|
+
return false;
|
|
8502
|
+
}
|
|
8503
|
+
}
|
|
8470
8504
|
function streamText({
|
|
8471
8505
|
model,
|
|
8472
8506
|
tools,
|
|
@@ -8532,8 +8566,10 @@ function streamText({
|
|
|
8532
8566
|
var _a22, _b, _c, _d;
|
|
8533
8567
|
const totalTimeoutMs = getTotalTimeoutMs(timeout);
|
|
8534
8568
|
const stepTimeoutMs = getStepTimeoutMs(timeout);
|
|
8569
|
+
const firstChunkTimeoutMs = getFirstChunkTimeoutMs(timeout);
|
|
8535
8570
|
const chunkTimeoutMs = getChunkTimeoutMs(timeout);
|
|
8536
8571
|
const stepAbortController = stepTimeoutMs != null ? new AbortController() : void 0;
|
|
8572
|
+
const firstChunkAbortController = firstChunkTimeoutMs != null ? new AbortController() : void 0;
|
|
8537
8573
|
const chunkAbortController = chunkTimeoutMs != null ? new AbortController() : void 0;
|
|
8538
8574
|
const resolvedOnStart = onStart != null ? onStart : experimental_onStart;
|
|
8539
8575
|
const resolvedOnStepStart = onStepStart != null ? onStepStart : experimental_onStepStart;
|
|
@@ -8552,10 +8588,13 @@ function streamText({
|
|
|
8552
8588
|
abortSignal,
|
|
8553
8589
|
totalTimeoutMs,
|
|
8554
8590
|
stepAbortController == null ? void 0 : stepAbortController.signal,
|
|
8591
|
+
firstChunkAbortController == null ? void 0 : firstChunkAbortController.signal,
|
|
8555
8592
|
chunkAbortController == null ? void 0 : chunkAbortController.signal
|
|
8556
8593
|
),
|
|
8557
8594
|
stepTimeoutMs,
|
|
8558
8595
|
stepAbortController,
|
|
8596
|
+
firstChunkTimeoutMs,
|
|
8597
|
+
firstChunkAbortController,
|
|
8559
8598
|
chunkTimeoutMs,
|
|
8560
8599
|
chunkAbortController,
|
|
8561
8600
|
instructions,
|
|
@@ -8681,6 +8720,8 @@ var DefaultStreamTextResult = class {
|
|
|
8681
8720
|
abortSignal,
|
|
8682
8721
|
stepTimeoutMs,
|
|
8683
8722
|
stepAbortController,
|
|
8723
|
+
firstChunkTimeoutMs,
|
|
8724
|
+
firstChunkAbortController,
|
|
8684
8725
|
chunkTimeoutMs,
|
|
8685
8726
|
chunkAbortController,
|
|
8686
8727
|
instructions,
|
|
@@ -9246,6 +9287,23 @@ var DefaultStreamTextResult = class {
|
|
|
9246
9287
|
label: "Step",
|
|
9247
9288
|
timeoutMs: stepTimeoutMs
|
|
9248
9289
|
});
|
|
9290
|
+
let firstChunkTimeoutId = void 0;
|
|
9291
|
+
function startFirstChunkTimeout() {
|
|
9292
|
+
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
9293
|
+
return;
|
|
9294
|
+
}
|
|
9295
|
+
firstChunkTimeoutId = setAbortTimeout({
|
|
9296
|
+
abortController: firstChunkAbortController,
|
|
9297
|
+
label: "First chunk",
|
|
9298
|
+
timeoutMs: firstChunkTimeoutMs
|
|
9299
|
+
});
|
|
9300
|
+
}
|
|
9301
|
+
function clearFirstChunkTimeout() {
|
|
9302
|
+
if (firstChunkTimeoutId != null) {
|
|
9303
|
+
clearTimeout(firstChunkTimeoutId);
|
|
9304
|
+
firstChunkTimeoutId = void 0;
|
|
9305
|
+
}
|
|
9306
|
+
}
|
|
9249
9307
|
let chunkTimeoutId = void 0;
|
|
9250
9308
|
function resetChunkTimeout() {
|
|
9251
9309
|
if (chunkTimeoutId != null) {
|
|
@@ -9268,8 +9326,18 @@ var DefaultStreamTextResult = class {
|
|
|
9268
9326
|
clearTimeout(stepTimeoutId);
|
|
9269
9327
|
}
|
|
9270
9328
|
}
|
|
9271
|
-
|
|
9272
|
-
|
|
9329
|
+
function clearStepTimeouts() {
|
|
9330
|
+
clearStepTimeout();
|
|
9331
|
+
clearFirstChunkTimeout();
|
|
9332
|
+
clearChunkTimeout();
|
|
9333
|
+
}
|
|
9334
|
+
function cleanupStepTimeouts() {
|
|
9335
|
+
abortSignal == null ? void 0 : abortSignal.removeEventListener("abort", cleanupStepTimeouts);
|
|
9336
|
+
clearStepTimeouts();
|
|
9337
|
+
}
|
|
9338
|
+
abortSignal == null ? void 0 : abortSignal.addEventListener("abort", cleanupStepTimeouts, {
|
|
9339
|
+
once: true
|
|
9340
|
+
});
|
|
9273
9341
|
try {
|
|
9274
9342
|
stepFinish = new DelayedPromise();
|
|
9275
9343
|
const stepTracingChannelContext = (_a23 = telemetryDispatcher.startTracingChannelContext) == null ? void 0 : _a23.call(telemetryDispatcher, {
|
|
@@ -9406,6 +9474,7 @@ var DefaultStreamTextResult = class {
|
|
|
9406
9474
|
}
|
|
9407
9475
|
)
|
|
9408
9476
|
);
|
|
9477
|
+
startFirstChunkTimeout();
|
|
9409
9478
|
const streamAfterToolCallbackInvocation = invokeToolCallbacksFromStream({
|
|
9410
9479
|
stream: languageModelStream,
|
|
9411
9480
|
tools,
|
|
@@ -9479,7 +9548,6 @@ var DefaultStreamTextResult = class {
|
|
|
9479
9548
|
new TransformStream({
|
|
9480
9549
|
async transform(chunk, controller) {
|
|
9481
9550
|
var _a24, _b2, _c2;
|
|
9482
|
-
resetChunkTimeout();
|
|
9483
9551
|
if (chunk.type === "model-call-start") {
|
|
9484
9552
|
warnings = chunk.warnings;
|
|
9485
9553
|
return;
|
|
@@ -9493,8 +9561,12 @@ var DefaultStreamTextResult = class {
|
|
|
9493
9561
|
});
|
|
9494
9562
|
}
|
|
9495
9563
|
const chunkType = chunk.type;
|
|
9496
|
-
if (
|
|
9564
|
+
if (isOutputChunk2(chunk)) {
|
|
9565
|
+
if (!hasReceivedOutputChunk) {
|
|
9566
|
+
clearFirstChunkTimeout();
|
|
9567
|
+
}
|
|
9497
9568
|
hasReceivedOutputChunk = true;
|
|
9569
|
+
resetChunkTimeout();
|
|
9498
9570
|
}
|
|
9499
9571
|
switch (chunkType) {
|
|
9500
9572
|
case "file":
|
|
@@ -9589,8 +9661,7 @@ var DefaultStreamTextResult = class {
|
|
|
9589
9661
|
message: "No output generated. The model stream ended without a finish chunk."
|
|
9590
9662
|
})
|
|
9591
9663
|
});
|
|
9592
|
-
|
|
9593
|
-
clearChunkTimeout();
|
|
9664
|
+
cleanupStepTimeouts();
|
|
9594
9665
|
self.closeStream();
|
|
9595
9666
|
return;
|
|
9596
9667
|
}
|
|
@@ -9643,8 +9714,7 @@ var DefaultStreamTextResult = class {
|
|
|
9643
9714
|
pendingDeferredToolCalls.delete(output2.toolCallId);
|
|
9644
9715
|
}
|
|
9645
9716
|
}
|
|
9646
|
-
|
|
9647
|
-
clearChunkTimeout();
|
|
9717
|
+
cleanupStepTimeouts();
|
|
9648
9718
|
if (
|
|
9649
9719
|
// Continue if:
|
|
9650
9720
|
// 1. There are client tool calls that have all been executed or denied, OR
|
|
@@ -9680,11 +9750,14 @@ var DefaultStreamTextResult = class {
|
|
|
9680
9750
|
}
|
|
9681
9751
|
}
|
|
9682
9752
|
})
|
|
9683
|
-
)
|
|
9753
|
+
),
|
|
9754
|
+
{
|
|
9755
|
+
onError: cleanupStepTimeouts,
|
|
9756
|
+
onCancel: cleanupStepTimeouts
|
|
9757
|
+
}
|
|
9684
9758
|
);
|
|
9685
9759
|
} catch (error) {
|
|
9686
|
-
|
|
9687
|
-
clearChunkTimeout();
|
|
9760
|
+
cleanupStepTimeouts();
|
|
9688
9761
|
throw error;
|
|
9689
9762
|
}
|
|
9690
9763
|
}
|
|
@@ -9951,7 +10024,7 @@ var DefaultStreamTextResult = class {
|
|
|
9951
10024
|
onError,
|
|
9952
10025
|
...init
|
|
9953
10026
|
} = {}) {
|
|
9954
|
-
pipeUIMessageStreamToResponse({
|
|
10027
|
+
return pipeUIMessageStreamToResponse({
|
|
9955
10028
|
response,
|
|
9956
10029
|
stream: this.toUIMessageStream({
|
|
9957
10030
|
originalMessages,
|
|
@@ -9968,7 +10041,7 @@ var DefaultStreamTextResult = class {
|
|
|
9968
10041
|
});
|
|
9969
10042
|
}
|
|
9970
10043
|
pipeTextStreamToResponse(response, init) {
|
|
9971
|
-
pipeTextStreamToResponse({
|
|
10044
|
+
return pipeTextStreamToResponse({
|
|
9972
10045
|
response,
|
|
9973
10046
|
stream: this.textStream,
|
|
9974
10047
|
...init
|
|
@@ -11175,7 +11248,7 @@ async function pipeAgentUIStreamToResponse({
|
|
|
11175
11248
|
consumeSseStream,
|
|
11176
11249
|
...options
|
|
11177
11250
|
}) {
|
|
11178
|
-
pipeUIMessageStreamToResponse({
|
|
11251
|
+
return pipeUIMessageStreamToResponse({
|
|
11179
11252
|
response,
|
|
11180
11253
|
headers,
|
|
11181
11254
|
status,
|
|
@@ -13182,7 +13255,7 @@ var DefaultStreamObjectResult = class {
|
|
|
13182
13255
|
return createAsyncIterableStream(this.baseStream);
|
|
13183
13256
|
}
|
|
13184
13257
|
pipeTextStreamToResponse(response, init) {
|
|
13185
|
-
pipeTextStreamToResponse({
|
|
13258
|
+
return pipeTextStreamToResponse({
|
|
13186
13259
|
response,
|
|
13187
13260
|
stream: this.textStream,
|
|
13188
13261
|
...init
|
|
@@ -17236,6 +17309,7 @@ export {
|
|
|
17236
17309
|
generateSpeech,
|
|
17237
17310
|
generateText,
|
|
17238
17311
|
getChunkTimeoutMs,
|
|
17312
|
+
getFirstChunkTimeoutMs,
|
|
17239
17313
|
getStaticToolName,
|
|
17240
17314
|
getStepTimeoutMs,
|
|
17241
17315
|
getTextFromDataUrl,
|