ai 7.0.0-beta.97 → 7.0.0-beta.99
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 +13 -0
- package/dist/index.d.ts +35 -7
- package/dist/index.js +149 -143
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1 -1
- package/docs/03-agents/02-building-agents.mdx +22 -0
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +39 -7
- package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +7 -0
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +7 -0
- package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +43 -9
- package/package.json +2 -2
- package/src/agent/tool-loop-agent-settings.ts +13 -0
- package/src/agent/tool-loop-agent.ts +1 -1
- package/src/generate-text/create-execute-tools-transformation.ts +7 -3
- package/src/generate-text/generate-text.ts +18 -8
- package/src/generate-text/index.ts +1 -0
- package/src/generate-text/is-tool-approval-needed.ts +60 -0
- package/src/generate-text/stream-text.ts +15 -0
- package/src/generate-text/tool-needs-approval-configuration.ts +25 -0
- package/src/generate-text/is-approval-needed.ts +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.0-beta.99
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2a9c144: feat(ai): add toolNeedsApproval option
|
|
8
|
+
|
|
9
|
+
## 7.0.0-beta.98
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [5df9b6f]
|
|
14
|
+
- @ai-sdk/gateway@4.0.0-beta.54
|
|
15
|
+
|
|
3
16
|
## 7.0.0-beta.97
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GatewayModelId } from '@ai-sdk/gateway';
|
|
2
2
|
export { GatewayModelId, createGateway, gateway } from '@ai-sdk/gateway';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
|
-
import { ToolSet, InferToolInput, InferToolOutput, FlexibleSchema, InferSchema, SystemModelMessage, ModelMessage, ProviderOptions, AssistantModelMessage, ToolModelMessage, Context, InferToolSetContext, ReasoningPart, ReasoningFilePart, Tool, ToolCall, IdGenerator, HasRequiredKey, UserModelMessage, DataContent, MaybePromiseLike, TextPart, FilePart, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
+
import { ToolSet, InferToolInput, InferToolOutput, FlexibleSchema, InferSchema, SystemModelMessage, ModelMessage, ProviderOptions, AssistantModelMessage, ToolModelMessage, Context, InferToolSetContext, ReasoningPart, ReasoningFilePart, Tool, ToolCall, IdGenerator, HasRequiredKey, UserModelMessage, DataContent, ToolNeedsApprovalFunction, MaybePromiseLike, TextPart, FilePart, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
export { AssistantContent, AssistantModelMessage, DataContent, DownloadError, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallPart, ToolContent, ToolExecuteFunction, ToolExecutionOptions, ToolModelMessage, ToolResultPart, ToolSet, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
6
6
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
7
7
|
import { EmbeddingModelV4, EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV4Embedding, EmbeddingModelV4Middleware, ImageModelV4, ImageModelV3, ImageModelV2, ImageModelV4ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV4Middleware, JSONValue as JSONValue$1, LanguageModelV4, LanguageModelV3, LanguageModelV2, SharedV4Warning, LanguageModelV4Source, LanguageModelV4Middleware, RerankingModelV4, RerankingModelV3, SharedV4ProviderMetadata, SharedV4ProviderReference, SpeechModelV4, SpeechModelV3, SpeechModelV2, TranscriptionModelV4, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV4Usage, LanguageModelV4CallOptions, LanguageModelV4Prompt, AISDKError, LanguageModelV4ToolCall, JSONSchema7, SharedV4Headers, JSONParseError, TypeValidationError, Experimental_VideoModelV4, Experimental_VideoModelV3, EmbeddingModelV4CallOptions, ProviderV4, ProviderV3, ProviderV2, FilesV4, SkillsV4, NoSuchModelError, SkillsV4UploadSkillResult, SkillsV4File } from '@ai-sdk/provider';
|
|
@@ -3181,6 +3181,16 @@ type ToolCallRepairFunction<TOOLS extends ToolSet> = (options: {
|
|
|
3181
3181
|
error: NoSuchToolError | InvalidToolInputError;
|
|
3182
3182
|
}) => Promise<LanguageModelV4ToolCall | null>;
|
|
3183
3183
|
|
|
3184
|
+
/**
|
|
3185
|
+
* Configure whether individual tools require approval before they can run.
|
|
3186
|
+
*
|
|
3187
|
+
* Each tool can be assigned either a boolean or a function that decides at
|
|
3188
|
+
* runtime whether approval is needed.
|
|
3189
|
+
*/
|
|
3190
|
+
type ToolNeedsApprovalConfiguration<TOOLS extends ToolSet, USER_CONTEXT extends Context = Context> = {
|
|
3191
|
+
[key in keyof TOOLS]?: boolean | ToolNeedsApprovalFunction<InferToolInput<TOOLS[key]>, InferToolSetContext<TOOLS> & USER_CONTEXT>;
|
|
3192
|
+
};
|
|
3193
|
+
|
|
3184
3194
|
/**
|
|
3185
3195
|
* A transformation that is applied to the stream.
|
|
3186
3196
|
*
|
|
@@ -3302,7 +3312,7 @@ type StreamTextOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = Callb
|
|
|
3302
3312
|
* @returns
|
|
3303
3313
|
* A result object for accessing different stream types and additional information.
|
|
3304
3314
|
*/
|
|
3305
|
-
declare function streamText<TOOLS extends ToolSet, USER_CONTEXT extends Context = Context, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, context: contextArg, experimental_include: include, _internal: { now, generateId, generateCallId, }, ...settings }: LanguageModelCallOptions & RequestOptions<TOOLS> & Prompt & ContextParameter<TOOLS, USER_CONTEXT> & {
|
|
3315
|
+
declare function streamText<TOOLS extends ToolSet, USER_CONTEXT extends Context = Context, OUTPUT extends Output = Output<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, toolNeedsApproval, experimental_telemetry: telemetry, prepareStep, providerOptions, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, context: contextArg, experimental_include: include, _internal: { now, generateId, generateCallId, }, ...settings }: LanguageModelCallOptions & RequestOptions<TOOLS> & Prompt & ContextParameter<TOOLS, USER_CONTEXT> & {
|
|
3306
3316
|
/**
|
|
3307
3317
|
* The language model to use.
|
|
3308
3318
|
*/
|
|
@@ -3343,6 +3353,12 @@ declare function streamText<TOOLS extends ToolSet, USER_CONTEXT extends Context
|
|
|
3343
3353
|
* @deprecated Use `output` instead.
|
|
3344
3354
|
*/
|
|
3345
3355
|
experimental_output?: OUTPUT;
|
|
3356
|
+
/**
|
|
3357
|
+
* Optional tool approval configuration.
|
|
3358
|
+
*
|
|
3359
|
+
* This configuration takes precedence over tool-defined approval settings.
|
|
3360
|
+
*/
|
|
3361
|
+
toolNeedsApproval?: ToolNeedsApprovalConfiguration<TOOLS, USER_CONTEXT>;
|
|
3346
3362
|
/**
|
|
3347
3363
|
* Optional function that you can use to provide different settings for a step.
|
|
3348
3364
|
*
|
|
@@ -3766,6 +3782,12 @@ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, USE
|
|
|
3766
3782
|
* Optional specification for generating structured outputs.
|
|
3767
3783
|
*/
|
|
3768
3784
|
output?: OUTPUT;
|
|
3785
|
+
/**
|
|
3786
|
+
* Optional tool approval configuration.
|
|
3787
|
+
*
|
|
3788
|
+
* This configuration takes precedence over tool-defined approval settings.
|
|
3789
|
+
*/
|
|
3790
|
+
toolNeedsApproval?: ToolNeedsApprovalConfiguration<NoInfer<TOOLS>, USER_CONTEXT>;
|
|
3769
3791
|
/**
|
|
3770
3792
|
* Optional function that you can use to provide different settings for a step.
|
|
3771
3793
|
*/
|
|
@@ -3819,9 +3841,9 @@ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, USE
|
|
|
3819
3841
|
*
|
|
3820
3842
|
* You can use this to have templates based on call options.
|
|
3821
3843
|
*/
|
|
3822
|
-
prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>, NoInfer<USER_CONTEXT>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, USER_CONTEXT, NoInfer<OUTPUT>>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_download'> & {
|
|
3844
|
+
prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>, NoInfer<USER_CONTEXT>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, USER_CONTEXT, NoInfer<OUTPUT>>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'toolNeedsApproval' | 'providerOptions' | 'experimental_download'> & {
|
|
3823
3845
|
context: InferToolSetContext<TOOLS> & USER_CONTEXT;
|
|
3824
|
-
}) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, USER_CONTEXT, NoInfer<OUTPUT>>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_download'> & Omit<Prompt, 'system'> & {
|
|
3846
|
+
}) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, USER_CONTEXT, NoInfer<OUTPUT>>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'toolNeedsApproval' | 'providerOptions' | 'experimental_download'> & Omit<Prompt, 'system'> & {
|
|
3825
3847
|
context: InferToolSetContext<TOOLS> & USER_CONTEXT;
|
|
3826
3848
|
}>;
|
|
3827
3849
|
};
|
|
@@ -3943,7 +3965,7 @@ interface Agent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, USER_CONTEXT e
|
|
|
3943
3965
|
* The loop continues until:
|
|
3944
3966
|
* - A finish reasoning other than tool-calls is returned, or
|
|
3945
3967
|
* - A tool that is invoked does not have an execute function, or
|
|
3946
|
-
* - A tool call needs approval
|
|
3968
|
+
* - A tool call needs approval via `toolNeedsApproval` or tool-level `needsApproval`, or
|
|
3947
3969
|
* - A stop condition is met (default stop condition is isStepCount(20))
|
|
3948
3970
|
*/
|
|
3949
3971
|
declare class ToolLoopAgent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, USER_CONTEXT extends Context = Context, OUTPUT extends Output = never> implements Agent<CALL_OPTIONS, TOOLS, USER_CONTEXT, OUTPUT> {
|
|
@@ -4109,7 +4131,7 @@ type GenerateTextOnFinishCallback<TOOLS extends ToolSet = ToolSet, USER_CONTEXT
|
|
|
4109
4131
|
* @returns
|
|
4110
4132
|
* A result object that contains the generated text, the results of the tool calls, and additional information.
|
|
4111
4133
|
*/
|
|
4112
|
-
declare function generateText<TOOLS extends ToolSet, USER_CONTEXT extends Context = Context, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, context: contextArg, experimental_include: include, _internal: { generateId, generateCallId, }, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }: LanguageModelCallOptions & RequestOptions<TOOLS> & Prompt & ContextParameter<TOOLS, USER_CONTEXT> & {
|
|
4134
|
+
declare function generateText<TOOLS extends ToolSet, USER_CONTEXT extends Context = Context, OUTPUT extends Output = Output<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, toolNeedsApproval, experimental_telemetry: telemetry, providerOptions, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, context: contextArg, experimental_include: include, _internal: { generateId, generateCallId, }, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }: LanguageModelCallOptions & RequestOptions<TOOLS> & Prompt & ContextParameter<TOOLS, USER_CONTEXT> & {
|
|
4113
4135
|
/**
|
|
4114
4136
|
* The language model to use.
|
|
4115
4137
|
*/
|
|
@@ -4150,6 +4172,12 @@ declare function generateText<TOOLS extends ToolSet, USER_CONTEXT extends Contex
|
|
|
4150
4172
|
* @deprecated Use `output` instead.
|
|
4151
4173
|
*/
|
|
4152
4174
|
experimental_output?: OUTPUT;
|
|
4175
|
+
/**
|
|
4176
|
+
* Optional tool approval configuration.
|
|
4177
|
+
*
|
|
4178
|
+
* This configuration takes precedence over tool-defined approval settings.
|
|
4179
|
+
*/
|
|
4180
|
+
toolNeedsApproval?: ToolNeedsApprovalConfiguration<TOOLS, USER_CONTEXT>;
|
|
4153
4181
|
/**
|
|
4154
4182
|
* Custom download function to use for URLs.
|
|
4155
4183
|
*
|
|
@@ -7379,4 +7407,4 @@ declare global {
|
|
|
7379
7407
|
var AI_SDK_TELEMETRY_INTEGRATIONS: TelemetryIntegration[] | undefined;
|
|
7380
7408
|
}
|
|
7381
7409
|
|
|
7382
|
-
export { AbstractChat, 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, EmbedFinishEvent, EmbedManyResult, EmbedOnFinishEvent, EmbedOnStartEvent, EmbedResult, EmbedStartEvent, 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, LanguageModelStreamPart as Experimental_LanguageModelStreamPart, 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, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelCallOptions, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectOnFinishEvent, ObjectOnStartEvent, ObjectOnStepFinishEvent, ObjectOnStepStartEvent, ObjectStreamPart, OnChunkEvent, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, Output as OutputInterface, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderReference, ProviderRegistryProvider, ReasoningFileOutput, ReasoningFileUIPart, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RequestOptions, RerankFinishEvent, RerankOnFinishEvent, RerankOnStartEvent, RerankResult, RerankStartEvent, 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, ToolLoopAgentOnStartCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentOnStepStartCallback, ToolLoopAgentOnToolCallFinishCallback, ToolLoopAgentOnToolCallStartCallback, ToolLoopAgentSettings, 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, UploadFileResult, UploadSkillResult, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, callCompletionApi, consumeStream, convertDataContentToBase64String, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, filterActiveTools as experimental_filterActiveTools, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, streamLanguageModelCall as experimental_streamLanguageModelCall, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, 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, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, isStepCount as stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, uploadFile, uploadSkill, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
|
|
7410
|
+
export { AbstractChat, 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, EmbedFinishEvent, EmbedManyResult, EmbedOnFinishEvent, EmbedOnStartEvent, EmbedResult, EmbedStartEvent, 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, LanguageModelStreamPart as Experimental_LanguageModelStreamPart, 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, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelCallOptions, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectOnFinishEvent, ObjectOnStartEvent, ObjectOnStepFinishEvent, ObjectOnStepStartEvent, ObjectStreamPart, OnChunkEvent, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, Output as OutputInterface, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderReference, ProviderRegistryProvider, ReasoningFileOutput, ReasoningFileUIPart, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RequestOptions, RerankFinishEvent, RerankOnFinishEvent, RerankOnStartEvent, RerankResult, RerankStartEvent, 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, ToolLoopAgentOnStartCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentOnStepStartCallback, ToolLoopAgentOnToolCallFinishCallback, ToolLoopAgentOnToolCallStartCallback, ToolLoopAgentSettings, ToolNeedsApprovalConfiguration, 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, UploadFileResult, UploadSkillResult, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, callCompletionApi, consumeStream, convertDataContentToBase64String, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, filterActiveTools as experimental_filterActiveTools, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, streamLanguageModelCall as experimental_streamLanguageModelCall, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, 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, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, isStepCount as stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, uploadFile, uploadSkill, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
|
package/dist/index.js
CHANGED
|
@@ -1002,131 +1002,6 @@ function getGlobalProvider() {
|
|
|
1002
1002
|
return asProviderV4(provider);
|
|
1003
1003
|
}
|
|
1004
1004
|
|
|
1005
|
-
// src/prompt/prepare-language-model-call-options.ts
|
|
1006
|
-
function prepareLanguageModelCallOptions({
|
|
1007
|
-
maxOutputTokens,
|
|
1008
|
-
temperature,
|
|
1009
|
-
topP,
|
|
1010
|
-
topK,
|
|
1011
|
-
presencePenalty,
|
|
1012
|
-
frequencyPenalty,
|
|
1013
|
-
seed,
|
|
1014
|
-
stopSequences,
|
|
1015
|
-
reasoning
|
|
1016
|
-
}) {
|
|
1017
|
-
if (maxOutputTokens != null) {
|
|
1018
|
-
if (!Number.isInteger(maxOutputTokens)) {
|
|
1019
|
-
throw new InvalidArgumentError({
|
|
1020
|
-
parameter: "maxOutputTokens",
|
|
1021
|
-
value: maxOutputTokens,
|
|
1022
|
-
message: "maxOutputTokens must be an integer"
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
if (maxOutputTokens < 1) {
|
|
1026
|
-
throw new InvalidArgumentError({
|
|
1027
|
-
parameter: "maxOutputTokens",
|
|
1028
|
-
value: maxOutputTokens,
|
|
1029
|
-
message: "maxOutputTokens must be >= 1"
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
if (temperature != null) {
|
|
1034
|
-
if (typeof temperature !== "number") {
|
|
1035
|
-
throw new InvalidArgumentError({
|
|
1036
|
-
parameter: "temperature",
|
|
1037
|
-
value: temperature,
|
|
1038
|
-
message: "temperature must be a number"
|
|
1039
|
-
});
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
if (topP != null) {
|
|
1043
|
-
if (typeof topP !== "number") {
|
|
1044
|
-
throw new InvalidArgumentError({
|
|
1045
|
-
parameter: "topP",
|
|
1046
|
-
value: topP,
|
|
1047
|
-
message: "topP must be a number"
|
|
1048
|
-
});
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
if (topK != null) {
|
|
1052
|
-
if (typeof topK !== "number") {
|
|
1053
|
-
throw new InvalidArgumentError({
|
|
1054
|
-
parameter: "topK",
|
|
1055
|
-
value: topK,
|
|
1056
|
-
message: "topK must be a number"
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
if (presencePenalty != null) {
|
|
1061
|
-
if (typeof presencePenalty !== "number") {
|
|
1062
|
-
throw new InvalidArgumentError({
|
|
1063
|
-
parameter: "presencePenalty",
|
|
1064
|
-
value: presencePenalty,
|
|
1065
|
-
message: "presencePenalty must be a number"
|
|
1066
|
-
});
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
if (frequencyPenalty != null) {
|
|
1070
|
-
if (typeof frequencyPenalty !== "number") {
|
|
1071
|
-
throw new InvalidArgumentError({
|
|
1072
|
-
parameter: "frequencyPenalty",
|
|
1073
|
-
value: frequencyPenalty,
|
|
1074
|
-
message: "frequencyPenalty must be a number"
|
|
1075
|
-
});
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
if (seed != null) {
|
|
1079
|
-
if (!Number.isInteger(seed)) {
|
|
1080
|
-
throw new InvalidArgumentError({
|
|
1081
|
-
parameter: "seed",
|
|
1082
|
-
value: seed,
|
|
1083
|
-
message: "seed must be an integer"
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
return {
|
|
1088
|
-
maxOutputTokens,
|
|
1089
|
-
temperature,
|
|
1090
|
-
topP,
|
|
1091
|
-
topK,
|
|
1092
|
-
presencePenalty,
|
|
1093
|
-
frequencyPenalty,
|
|
1094
|
-
stopSequences,
|
|
1095
|
-
seed,
|
|
1096
|
-
reasoning
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
// src/prompt/request-options.ts
|
|
1101
|
-
function getTotalTimeoutMs(timeout) {
|
|
1102
|
-
if (timeout == null) {
|
|
1103
|
-
return void 0;
|
|
1104
|
-
}
|
|
1105
|
-
if (typeof timeout === "number") {
|
|
1106
|
-
return timeout;
|
|
1107
|
-
}
|
|
1108
|
-
return timeout.totalMs;
|
|
1109
|
-
}
|
|
1110
|
-
function getStepTimeoutMs(timeout) {
|
|
1111
|
-
if (timeout == null || typeof timeout === "number") {
|
|
1112
|
-
return void 0;
|
|
1113
|
-
}
|
|
1114
|
-
return timeout.stepMs;
|
|
1115
|
-
}
|
|
1116
|
-
function getChunkTimeoutMs(timeout) {
|
|
1117
|
-
if (timeout == null || typeof timeout === "number") {
|
|
1118
|
-
return void 0;
|
|
1119
|
-
}
|
|
1120
|
-
return timeout.chunkMs;
|
|
1121
|
-
}
|
|
1122
|
-
function getToolTimeoutMs(timeout, toolName) {
|
|
1123
|
-
var _a21, _b;
|
|
1124
|
-
if (timeout == null || typeof timeout === "number") {
|
|
1125
|
-
return void 0;
|
|
1126
|
-
}
|
|
1127
|
-
return (_b = (_a21 = timeout.tools) == null ? void 0 : _a21[`${toolName}Ms`]) != null ? _b : timeout.toolMs;
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
1005
|
// src/prompt/convert-to-language-model-prompt.ts
|
|
1131
1006
|
import {
|
|
1132
1007
|
isProviderReference,
|
|
@@ -1380,7 +1255,7 @@ import {
|
|
|
1380
1255
|
} from "@ai-sdk/provider-utils";
|
|
1381
1256
|
|
|
1382
1257
|
// src/version.ts
|
|
1383
|
-
var VERSION = true ? "7.0.0-beta.
|
|
1258
|
+
var VERSION = true ? "7.0.0-beta.99" : "0.0.0-test";
|
|
1384
1259
|
|
|
1385
1260
|
// src/util/download/download.ts
|
|
1386
1261
|
var download = async ({
|
|
@@ -2057,6 +1932,101 @@ function toJSONValue(value) {
|
|
|
2057
1932
|
return value === void 0 ? null : value;
|
|
2058
1933
|
}
|
|
2059
1934
|
|
|
1935
|
+
// src/prompt/prepare-language-model-call-options.ts
|
|
1936
|
+
function prepareLanguageModelCallOptions({
|
|
1937
|
+
maxOutputTokens,
|
|
1938
|
+
temperature,
|
|
1939
|
+
topP,
|
|
1940
|
+
topK,
|
|
1941
|
+
presencePenalty,
|
|
1942
|
+
frequencyPenalty,
|
|
1943
|
+
seed,
|
|
1944
|
+
stopSequences,
|
|
1945
|
+
reasoning
|
|
1946
|
+
}) {
|
|
1947
|
+
if (maxOutputTokens != null) {
|
|
1948
|
+
if (!Number.isInteger(maxOutputTokens)) {
|
|
1949
|
+
throw new InvalidArgumentError({
|
|
1950
|
+
parameter: "maxOutputTokens",
|
|
1951
|
+
value: maxOutputTokens,
|
|
1952
|
+
message: "maxOutputTokens must be an integer"
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
if (maxOutputTokens < 1) {
|
|
1956
|
+
throw new InvalidArgumentError({
|
|
1957
|
+
parameter: "maxOutputTokens",
|
|
1958
|
+
value: maxOutputTokens,
|
|
1959
|
+
message: "maxOutputTokens must be >= 1"
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
if (temperature != null) {
|
|
1964
|
+
if (typeof temperature !== "number") {
|
|
1965
|
+
throw new InvalidArgumentError({
|
|
1966
|
+
parameter: "temperature",
|
|
1967
|
+
value: temperature,
|
|
1968
|
+
message: "temperature must be a number"
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
if (topP != null) {
|
|
1973
|
+
if (typeof topP !== "number") {
|
|
1974
|
+
throw new InvalidArgumentError({
|
|
1975
|
+
parameter: "topP",
|
|
1976
|
+
value: topP,
|
|
1977
|
+
message: "topP must be a number"
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
if (topK != null) {
|
|
1982
|
+
if (typeof topK !== "number") {
|
|
1983
|
+
throw new InvalidArgumentError({
|
|
1984
|
+
parameter: "topK",
|
|
1985
|
+
value: topK,
|
|
1986
|
+
message: "topK must be a number"
|
|
1987
|
+
});
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
if (presencePenalty != null) {
|
|
1991
|
+
if (typeof presencePenalty !== "number") {
|
|
1992
|
+
throw new InvalidArgumentError({
|
|
1993
|
+
parameter: "presencePenalty",
|
|
1994
|
+
value: presencePenalty,
|
|
1995
|
+
message: "presencePenalty must be a number"
|
|
1996
|
+
});
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
if (frequencyPenalty != null) {
|
|
2000
|
+
if (typeof frequencyPenalty !== "number") {
|
|
2001
|
+
throw new InvalidArgumentError({
|
|
2002
|
+
parameter: "frequencyPenalty",
|
|
2003
|
+
value: frequencyPenalty,
|
|
2004
|
+
message: "frequencyPenalty must be a number"
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
if (seed != null) {
|
|
2009
|
+
if (!Number.isInteger(seed)) {
|
|
2010
|
+
throw new InvalidArgumentError({
|
|
2011
|
+
parameter: "seed",
|
|
2012
|
+
value: seed,
|
|
2013
|
+
message: "seed must be an integer"
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
return {
|
|
2018
|
+
maxOutputTokens,
|
|
2019
|
+
temperature,
|
|
2020
|
+
topP,
|
|
2021
|
+
topK,
|
|
2022
|
+
presencePenalty,
|
|
2023
|
+
frequencyPenalty,
|
|
2024
|
+
stopSequences,
|
|
2025
|
+
seed,
|
|
2026
|
+
reasoning
|
|
2027
|
+
};
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2060
2030
|
// src/prompt/prepare-tool-choice.ts
|
|
2061
2031
|
function prepareToolChoice({
|
|
2062
2032
|
toolChoice
|
|
@@ -2113,6 +2083,36 @@ async function prepareTools({
|
|
|
2113
2083
|
return languageModelTools;
|
|
2114
2084
|
}
|
|
2115
2085
|
|
|
2086
|
+
// src/prompt/request-options.ts
|
|
2087
|
+
function getTotalTimeoutMs(timeout) {
|
|
2088
|
+
if (timeout == null) {
|
|
2089
|
+
return void 0;
|
|
2090
|
+
}
|
|
2091
|
+
if (typeof timeout === "number") {
|
|
2092
|
+
return timeout;
|
|
2093
|
+
}
|
|
2094
|
+
return timeout.totalMs;
|
|
2095
|
+
}
|
|
2096
|
+
function getStepTimeoutMs(timeout) {
|
|
2097
|
+
if (timeout == null || typeof timeout === "number") {
|
|
2098
|
+
return void 0;
|
|
2099
|
+
}
|
|
2100
|
+
return timeout.stepMs;
|
|
2101
|
+
}
|
|
2102
|
+
function getChunkTimeoutMs(timeout) {
|
|
2103
|
+
if (timeout == null || typeof timeout === "number") {
|
|
2104
|
+
return void 0;
|
|
2105
|
+
}
|
|
2106
|
+
return timeout.chunkMs;
|
|
2107
|
+
}
|
|
2108
|
+
function getToolTimeoutMs(timeout, toolName) {
|
|
2109
|
+
var _a21, _b;
|
|
2110
|
+
if (timeout == null || typeof timeout === "number") {
|
|
2111
|
+
return void 0;
|
|
2112
|
+
}
|
|
2113
|
+
return (_b = (_a21 = timeout.tools) == null ? void 0 : _a21[`${toolName}Ms`]) != null ? _b : timeout.toolMs;
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
2116
|
// src/prompt/standardize-prompt.ts
|
|
2117
2117
|
import { InvalidPromptError as InvalidPromptError2 } from "@ai-sdk/provider";
|
|
2118
2118
|
import {
|
|
@@ -3052,24 +3052,22 @@ var DefaultGeneratedFileWithType = class extends DefaultGeneratedFile {
|
|
|
3052
3052
|
}
|
|
3053
3053
|
};
|
|
3054
3054
|
|
|
3055
|
-
// src/generate-text/is-approval-needed.ts
|
|
3056
|
-
async function
|
|
3057
|
-
|
|
3055
|
+
// src/generate-text/is-tool-approval-needed.ts
|
|
3056
|
+
async function isToolApprovalNeeded({
|
|
3057
|
+
tools,
|
|
3058
3058
|
toolCall,
|
|
3059
|
+
toolNeedsApproval,
|
|
3059
3060
|
messages,
|
|
3060
3061
|
context
|
|
3061
3062
|
}) {
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
if (
|
|
3066
|
-
return
|
|
3063
|
+
const input = toolCall.input;
|
|
3064
|
+
const options = { toolCallId: toolCall.toolCallId, messages, context };
|
|
3065
|
+
const userDefinedToolNeedsApproval = toolNeedsApproval == null ? void 0 : toolNeedsApproval[toolCall.toolName];
|
|
3066
|
+
if (userDefinedToolNeedsApproval != null) {
|
|
3067
|
+
return typeof userDefinedToolNeedsApproval === "boolean" ? userDefinedToolNeedsApproval : await userDefinedToolNeedsApproval(input, options);
|
|
3067
3068
|
}
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
messages,
|
|
3071
|
-
context
|
|
3072
|
-
});
|
|
3069
|
+
const tool2 = tools == null ? void 0 : tools[toolCall.toolName];
|
|
3070
|
+
return (tool2 == null ? void 0 : tool2.needsApproval) == null ? false : typeof tool2.needsApproval === "boolean" ? tool2.needsApproval : await tool2.needsApproval(input, options);
|
|
3073
3071
|
}
|
|
3074
3072
|
|
|
3075
3073
|
// src/generate-text/output.ts
|
|
@@ -4182,6 +4180,7 @@ async function generateText({
|
|
|
4182
4180
|
stopWhen = isStepCount(1),
|
|
4183
4181
|
experimental_output,
|
|
4184
4182
|
output = experimental_output,
|
|
4183
|
+
toolNeedsApproval,
|
|
4185
4184
|
experimental_telemetry: telemetry,
|
|
4186
4185
|
providerOptions,
|
|
4187
4186
|
activeTools,
|
|
@@ -4476,8 +4475,9 @@ async function generateText({
|
|
|
4476
4475
|
context
|
|
4477
4476
|
});
|
|
4478
4477
|
}
|
|
4479
|
-
if (await
|
|
4480
|
-
|
|
4478
|
+
if (await isToolApprovalNeeded({
|
|
4479
|
+
tools,
|
|
4480
|
+
toolNeedsApproval,
|
|
4481
4481
|
toolCall,
|
|
4482
4482
|
messages: stepInputMessages,
|
|
4483
4483
|
context
|
|
@@ -6168,6 +6168,7 @@ function createExecuteToolsTransformation({
|
|
|
6168
6168
|
abortSignal,
|
|
6169
6169
|
timeout,
|
|
6170
6170
|
context,
|
|
6171
|
+
toolNeedsApproval,
|
|
6171
6172
|
generateId: generateId2,
|
|
6172
6173
|
stepNumber,
|
|
6173
6174
|
provider,
|
|
@@ -6190,9 +6191,10 @@ function createExecuteToolsTransformation({
|
|
|
6190
6191
|
if (tool2 == null) {
|
|
6191
6192
|
break;
|
|
6192
6193
|
}
|
|
6193
|
-
if (await
|
|
6194
|
-
|
|
6194
|
+
if (await isToolApprovalNeeded({
|
|
6195
|
+
tools,
|
|
6195
6196
|
toolCall: chunk,
|
|
6197
|
+
toolNeedsApproval,
|
|
6196
6198
|
messages,
|
|
6197
6199
|
context
|
|
6198
6200
|
})) {
|
|
@@ -6562,6 +6564,7 @@ function streamText({
|
|
|
6562
6564
|
stopWhen = isStepCount(1),
|
|
6563
6565
|
experimental_output,
|
|
6564
6566
|
output = experimental_output,
|
|
6567
|
+
toolNeedsApproval,
|
|
6565
6568
|
experimental_telemetry: telemetry,
|
|
6566
6569
|
prepareStep,
|
|
6567
6570
|
providerOptions,
|
|
@@ -6622,6 +6625,7 @@ function streamText({
|
|
|
6622
6625
|
repairToolCall,
|
|
6623
6626
|
stopConditions: asArray(stopWhen),
|
|
6624
6627
|
output,
|
|
6628
|
+
toolNeedsApproval,
|
|
6625
6629
|
providerOptions,
|
|
6626
6630
|
prepareStep,
|
|
6627
6631
|
includeRawChunks,
|
|
@@ -6728,6 +6732,7 @@ var DefaultStreamTextResult = class {
|
|
|
6728
6732
|
repairToolCall,
|
|
6729
6733
|
stopConditions,
|
|
6730
6734
|
output,
|
|
6735
|
+
toolNeedsApproval,
|
|
6731
6736
|
providerOptions,
|
|
6732
6737
|
prepareStep,
|
|
6733
6738
|
includeRawChunks,
|
|
@@ -7349,6 +7354,7 @@ var DefaultStreamTextResult = class {
|
|
|
7349
7354
|
abortSignal,
|
|
7350
7355
|
timeout,
|
|
7351
7356
|
context,
|
|
7357
|
+
toolNeedsApproval,
|
|
7352
7358
|
generateId: generateId2,
|
|
7353
7359
|
stepNumber: recordedSteps.length,
|
|
7354
7360
|
provider: stepModel.provider,
|