ai 6.0.270 → 6.0.272
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 +22 -0
- package/dist/index.d.mts +126 -49
- package/dist/index.d.ts +126 -49
- package/dist/index.js +609 -394
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +545 -328
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +26 -1
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +2 -2
- package/docs/07-reference/02-ai-sdk-ui/40-create-ui-message-stream.mdx +33 -5
- package/docs/07-reference/05-ai-sdk-errors/ai-tool-choice-violation-error.mdx +38 -0
- package/docs/07-reference/05-ai-sdk-errors/index.mdx +1 -0
- package/package.json +3 -3
- package/src/agent/create-agent-ui-stream.ts +2 -2
- package/src/agent/tool-loop-agent-settings.ts +9 -0
- package/src/error/index.ts +1 -0
- package/src/error/tool-choice-violation-error.ts +80 -0
- package/src/generate-text/generate-text.ts +25 -1
- package/src/generate-text/stream-text.ts +84 -1
- package/src/ui/direct-chat-transport.ts +2 -2
- package/src/ui/validate-ui-messages.ts +136 -55
- package/src/ui-message-stream/create-ui-message-stream.ts +47 -17
- package/src/ui-message-stream/handle-ui-message-stream-finish.ts +58 -15
- package/src/ui-message-stream/index.ts +5 -1
- package/src/ui-message-stream/ui-message-stream-on-finish-callback.ts +7 -0
- package/src/ui-message-stream/ui-message-stream-outcome.ts +12 -0
- package/src/ui-message-stream/ui-message-stream-writer.ts +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.272
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e822a1d: Reject `generateText` responses that do not satisfy a required or specifically selected tool choice, and expose the normalized response content on `ToolChoiceViolationError` for opt-in recovery.
|
|
8
|
+
- 8c51a25: fix(ai): allow tool approval secrets in ToolLoopAgent settings and prepareCall
|
|
9
|
+
- Updated dependencies [cc23556]
|
|
10
|
+
- Updated dependencies [823cc03]
|
|
11
|
+
- Updated dependencies [3f96cf8]
|
|
12
|
+
- @ai-sdk/provider-utils@4.0.50
|
|
13
|
+
- @ai-sdk/gateway@3.0.185
|
|
14
|
+
|
|
15
|
+
## 6.0.271
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 9310140: Validate persisted typed tool calls against current input and output schemas.
|
|
20
|
+
Schema-incompatible empty or error inputs and terminal history from unavailable
|
|
21
|
+
tools remain loadable as dynamic tool parts instead of exposing unvalidated
|
|
22
|
+
values under current static tool types.
|
|
23
|
+
- b503790: add operation-level outcomes to UI message stream end callbacks
|
|
24
|
+
|
|
3
25
|
## 6.0.270
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, EmbeddingModelV3Middleware, ImageModelV3, ImageModelV2, ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV3Middleware, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, SharedV3Warning, LanguageModelV3Source, LanguageModelV3Middleware, RerankingModelV3, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV3Usage, AISDKError, LanguageModelV3ToolCall, JSONSchema7, LanguageModelV3CallOptions, LanguageModelV3ToolChoice, ProviderV3, JSONParseError, TypeValidationError, Experimental_VideoModelV3, Experimental_VideoModelV3FrameType, EmbeddingModelV3CallOptions, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
|
1
|
+
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, EmbeddingModelV3Middleware, ImageModelV3, ImageModelV2, ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV3Middleware, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, SharedV3Warning, LanguageModelV3Source, LanguageModelV3Middleware, RerankingModelV3, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV3Usage, AISDKError, LanguageModelV3ToolCall, JSONSchema7, LanguageModelV3CallOptions, LanguageModelV3ToolChoice, ProviderV3, LanguageModelV3Content, JSONParseError, TypeValidationError, Experimental_VideoModelV3, Experimental_VideoModelV3FrameType, EmbeddingModelV3CallOptions, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
|
2
2
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
3
3
|
import { GatewayModelId } from '@ai-sdk/gateway';
|
|
4
4
|
export { GatewayModelId, createGateway, gateway } from '@ai-sdk/gateway';
|
|
@@ -1179,9 +1179,9 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
|
1179
1179
|
readonly output: InferCompleteOutput<OUTPUT>;
|
|
1180
1180
|
}
|
|
1181
1181
|
|
|
1182
|
-
declare const symbol$
|
|
1182
|
+
declare const symbol$l: unique symbol;
|
|
1183
1183
|
declare class InvalidToolInputError extends AISDKError {
|
|
1184
|
-
private readonly [symbol$
|
|
1184
|
+
private readonly [symbol$l];
|
|
1185
1185
|
readonly toolName: string;
|
|
1186
1186
|
readonly toolInput: string;
|
|
1187
1187
|
constructor({ toolInput, toolName, cause, message, }: {
|
|
@@ -1193,9 +1193,9 @@ declare class InvalidToolInputError extends AISDKError {
|
|
|
1193
1193
|
static isInstance(error: unknown): error is InvalidToolInputError;
|
|
1194
1194
|
}
|
|
1195
1195
|
|
|
1196
|
-
declare const symbol$
|
|
1196
|
+
declare const symbol$k: unique symbol;
|
|
1197
1197
|
declare class NoSuchToolError extends AISDKError {
|
|
1198
|
-
private readonly [symbol$
|
|
1198
|
+
private readonly [symbol$k];
|
|
1199
1199
|
readonly toolName: string;
|
|
1200
1200
|
readonly availableTools: string[] | undefined;
|
|
1201
1201
|
constructor({ toolName, availableTools, message, }: {
|
|
@@ -2113,6 +2113,24 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
2113
2113
|
};
|
|
2114
2114
|
type InferUIMessageChunk<T extends UIMessage> = UIMessageChunk<InferUIMessageMetadata<T>, InferUIMessageData<T>>;
|
|
2115
2115
|
|
|
2116
|
+
/**
|
|
2117
|
+
* The operation-level outcome of a UI message stream.
|
|
2118
|
+
*
|
|
2119
|
+
* This is separate from model finish reasons and individual stream chunks.
|
|
2120
|
+
* Fatal stream-processing failures override outcomes declared by the stream
|
|
2121
|
+
* owner.
|
|
2122
|
+
*/
|
|
2123
|
+
type UIMessageStreamOutcome = {
|
|
2124
|
+
status: 'completed';
|
|
2125
|
+
} | {
|
|
2126
|
+
status: 'failed';
|
|
2127
|
+
error?: unknown;
|
|
2128
|
+
} | {
|
|
2129
|
+
status: 'aborted';
|
|
2130
|
+
} | {
|
|
2131
|
+
status: 'unknown';
|
|
2132
|
+
};
|
|
2133
|
+
|
|
2116
2134
|
type UIMessageStreamOnFinishCallback<UI_MESSAGE extends UIMessage> = (event: {
|
|
2117
2135
|
/**
|
|
2118
2136
|
* The updated list of UI messages.
|
|
@@ -2127,6 +2145,11 @@ type UIMessageStreamOnFinishCallback<UI_MESSAGE extends UIMessage> = (event: {
|
|
|
2127
2145
|
* Indicates whether the stream was aborted.
|
|
2128
2146
|
*/
|
|
2129
2147
|
isAborted: boolean;
|
|
2148
|
+
/**
|
|
2149
|
+
* The operation-level outcome of the stream. Fatal stream-processing
|
|
2150
|
+
* failures override outcomes declared by the stream owner.
|
|
2151
|
+
*/
|
|
2152
|
+
outcome: UIMessageStreamOutcome;
|
|
2130
2153
|
/**
|
|
2131
2154
|
* The message that was sent to the client as a response
|
|
2132
2155
|
* (including the original message if it was extended).
|
|
@@ -3323,6 +3346,12 @@ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUT
|
|
|
3323
3346
|
* Callback that is called when all steps are finished and the response is complete.
|
|
3324
3347
|
*/
|
|
3325
3348
|
onFinish?: ToolLoopAgentOnFinishCallback<NoInfer<TOOLS>>;
|
|
3349
|
+
/**
|
|
3350
|
+
* Secret for HMAC-signing tool approval requests. When set, the server
|
|
3351
|
+
* signs each approval request at issuance and verifies the signature when
|
|
3352
|
+
* the approval is replayed, preventing client-forged approvals.
|
|
3353
|
+
*/
|
|
3354
|
+
experimental_toolApprovalSecret?: string | Uint8Array;
|
|
3326
3355
|
/**
|
|
3327
3356
|
* Additional provider-specific options. They are passed through
|
|
3328
3357
|
* to the provider from the AI SDK and enable provider-specific
|
|
@@ -3362,7 +3391,7 @@ type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUT
|
|
|
3362
3391
|
* }),
|
|
3363
3392
|
* ```
|
|
3364
3393
|
*/
|
|
3365
|
-
prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'timeout' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'providerOptions' | 'experimental_context' | 'experimental_download'> & Omit<Prompt, 'system'>>;
|
|
3394
|
+
prepareCall?: (options: Omit<AgentCallParameters<CALL_OPTIONS, NoInfer<TOOLS>>, 'onStepFinish'> & Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'experimental_toolApprovalSecret' | 'providerOptions' | 'experimental_context' | 'experimental_download'>) => MaybePromiseLike<Pick<ToolLoopAgentSettings<CALL_OPTIONS, TOOLS, OUTPUT>, 'model' | 'tools' | 'maxOutputTokens' | 'temperature' | 'topP' | 'topK' | 'presencePenalty' | 'frequencyPenalty' | 'stopSequences' | 'seed' | 'timeout' | 'headers' | 'instructions' | 'allowSystemInMessages' | 'stopWhen' | 'experimental_telemetry' | 'activeTools' | 'experimental_toolApprovalSecret' | 'providerOptions' | 'experimental_context' | 'experimental_download'> & Omit<Prompt, 'system'>>;
|
|
3366
3395
|
};
|
|
3367
3396
|
|
|
3368
3397
|
/**
|
|
@@ -4148,12 +4177,7 @@ type SafeValidateUIMessagesResult<UI_MESSAGE extends UIMessage> = {
|
|
|
4148
4177
|
success: false;
|
|
4149
4178
|
error: Error;
|
|
4150
4179
|
};
|
|
4151
|
-
|
|
4152
|
-
* Validates a list of UI messages like `validateUIMessages`,
|
|
4153
|
-
* but instead of throwing it returns `{ success: true, data }`
|
|
4154
|
-
* or `{ success: false, error }`.
|
|
4155
|
-
*/
|
|
4156
|
-
declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({ messages, metadataSchema, dataSchemas, tools, }: {
|
|
4180
|
+
type ValidateUIMessagesOptions<UI_MESSAGE extends UIMessage> = {
|
|
4157
4181
|
messages: unknown;
|
|
4158
4182
|
metadataSchema?: FlexibleSchema<UIMessage['metadata']>;
|
|
4159
4183
|
dataSchemas?: {
|
|
@@ -4162,7 +4186,13 @@ declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({ messages
|
|
|
4162
4186
|
tools?: {
|
|
4163
4187
|
[NAME in keyof InferUIMessageTools<UI_MESSAGE> & string]?: Tool<InferUIMessageTools<UI_MESSAGE>[NAME]['input'], InferUIMessageTools<UI_MESSAGE>[NAME]['output']>;
|
|
4164
4188
|
};
|
|
4165
|
-
}
|
|
4189
|
+
};
|
|
4190
|
+
/**
|
|
4191
|
+
* Validates a list of UI messages like `validateUIMessages`,
|
|
4192
|
+
* but instead of throwing it returns `{ success: true, data }`
|
|
4193
|
+
* or `{ success: false, error }`.
|
|
4194
|
+
*/
|
|
4195
|
+
declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>(options: ValidateUIMessagesOptions<UI_MESSAGE>): Promise<SafeValidateUIMessagesResult<UI_MESSAGE>>;
|
|
4166
4196
|
/**
|
|
4167
4197
|
* Validates a list of UI messages.
|
|
4168
4198
|
*
|
|
@@ -4170,16 +4200,7 @@ declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({ messages
|
|
|
4170
4200
|
* the corresponding schemas are provided. Otherwise, they are assumed to be
|
|
4171
4201
|
* valid.
|
|
4172
4202
|
*/
|
|
4173
|
-
declare function validateUIMessages<UI_MESSAGE extends UIMessage>(
|
|
4174
|
-
messages: unknown;
|
|
4175
|
-
metadataSchema?: FlexibleSchema<UIMessage['metadata']>;
|
|
4176
|
-
dataSchemas?: {
|
|
4177
|
-
[NAME in keyof InferUIMessageData<UI_MESSAGE> & string]?: FlexibleSchema<InferUIMessageData<UI_MESSAGE>[NAME]>;
|
|
4178
|
-
};
|
|
4179
|
-
tools?: {
|
|
4180
|
-
[NAME in keyof InferUIMessageTools<UI_MESSAGE> & string]?: Tool<InferUIMessageTools<UI_MESSAGE>[NAME]['input'], InferUIMessageTools<UI_MESSAGE>[NAME]['output']>;
|
|
4181
|
-
};
|
|
4182
|
-
}): Promise<Array<UI_MESSAGE>>;
|
|
4203
|
+
declare function validateUIMessages<UI_MESSAGE extends UIMessage>(options: ValidateUIMessagesOptions<UI_MESSAGE>): Promise<Array<UI_MESSAGE>>;
|
|
4183
4204
|
|
|
4184
4205
|
interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
|
4185
4206
|
/**
|
|
@@ -4197,6 +4218,17 @@ interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
|
|
4197
4218
|
*/
|
|
4198
4219
|
onError: ErrorHandler | undefined;
|
|
4199
4220
|
}
|
|
4221
|
+
interface UIMessageStreamWriterWithOutcome<UI_MESSAGE extends UIMessage = UIMessage> extends UIMessageStreamWriter<UI_MESSAGE> {
|
|
4222
|
+
/**
|
|
4223
|
+
* Declares the operation-level outcome of the composed stream.
|
|
4224
|
+
*
|
|
4225
|
+
* The first outcome declared through this method is retained. Fatal
|
|
4226
|
+
* execution, merge, error-handling, or downstream processing failures
|
|
4227
|
+
* override declared outcomes. Declaring an outcome does not write a chunk or
|
|
4228
|
+
* close the stream.
|
|
4229
|
+
*/
|
|
4230
|
+
setOutcome(outcome: UIMessageStreamOutcome): void;
|
|
4231
|
+
}
|
|
4200
4232
|
|
|
4201
4233
|
/**
|
|
4202
4234
|
* Creates a UI message stream that can be used to send messages to the client.
|
|
@@ -4214,7 +4246,7 @@ interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
|
|
4214
4246
|
declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, // prevent leaking server error details to the client by default
|
|
4215
4247
|
originalMessages, onStepFinish, onFinish, generateId, }: {
|
|
4216
4248
|
execute: (options: {
|
|
4217
|
-
writer:
|
|
4249
|
+
writer: UIMessageStreamWriterWithOutcome<UI_MESSAGE>;
|
|
4218
4250
|
}) => Promise<void> | void;
|
|
4219
4251
|
onError?: (error: unknown) => string;
|
|
4220
4252
|
/**
|
|
@@ -4549,9 +4581,9 @@ declare function embedMany({ model: modelArg, values, maxParallelCalls, maxRetri
|
|
|
4549
4581
|
maxParallelCalls?: number;
|
|
4550
4582
|
}): Promise<EmbedManyResult>;
|
|
4551
4583
|
|
|
4552
|
-
declare const symbol$
|
|
4584
|
+
declare const symbol$j: unique symbol;
|
|
4553
4585
|
declare class InvalidArgumentError extends AISDKError {
|
|
4554
|
-
private readonly [symbol$
|
|
4586
|
+
private readonly [symbol$j];
|
|
4555
4587
|
readonly parameter: string;
|
|
4556
4588
|
readonly value: unknown;
|
|
4557
4589
|
constructor({ parameter, value, message, }: {
|
|
@@ -4638,9 +4670,9 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
|
|
|
4638
4670
|
rawValue: unknown;
|
|
4639
4671
|
};
|
|
4640
4672
|
|
|
4641
|
-
declare const symbol$
|
|
4673
|
+
declare const symbol$i: unique symbol;
|
|
4642
4674
|
declare class InvalidStreamPartError extends AISDKError {
|
|
4643
|
-
private readonly [symbol$
|
|
4675
|
+
private readonly [symbol$i];
|
|
4644
4676
|
readonly chunk: SingleRequestTextStreamPart<any>;
|
|
4645
4677
|
constructor({ chunk, message, }: {
|
|
4646
4678
|
chunk: SingleRequestTextStreamPart<any>;
|
|
@@ -4649,9 +4681,9 @@ declare class InvalidStreamPartError extends AISDKError {
|
|
|
4649
4681
|
static isInstance(error: unknown): error is InvalidStreamPartError;
|
|
4650
4682
|
}
|
|
4651
4683
|
|
|
4652
|
-
declare const symbol$
|
|
4684
|
+
declare const symbol$h: unique symbol;
|
|
4653
4685
|
declare class InvalidToolApprovalError extends AISDKError {
|
|
4654
|
-
private readonly [symbol$
|
|
4686
|
+
private readonly [symbol$h];
|
|
4655
4687
|
readonly approvalId: string;
|
|
4656
4688
|
constructor({ approvalId }: {
|
|
4657
4689
|
approvalId: string;
|
|
@@ -4659,9 +4691,9 @@ declare class InvalidToolApprovalError extends AISDKError {
|
|
|
4659
4691
|
static isInstance(error: unknown): error is InvalidToolApprovalError;
|
|
4660
4692
|
}
|
|
4661
4693
|
|
|
4662
|
-
declare const symbol$
|
|
4694
|
+
declare const symbol$g: unique symbol;
|
|
4663
4695
|
declare class InvalidToolApprovalSignatureError extends AISDKError {
|
|
4664
|
-
private readonly [symbol$
|
|
4696
|
+
private readonly [symbol$g];
|
|
4665
4697
|
readonly approvalId: string;
|
|
4666
4698
|
readonly toolCallId: string;
|
|
4667
4699
|
constructor({ approvalId, toolCallId, reason, }: {
|
|
@@ -4672,9 +4704,9 @@ declare class InvalidToolApprovalSignatureError extends AISDKError {
|
|
|
4672
4704
|
static isInstance(error: unknown): error is InvalidToolApprovalSignatureError;
|
|
4673
4705
|
}
|
|
4674
4706
|
|
|
4675
|
-
declare const symbol$
|
|
4707
|
+
declare const symbol$f: unique symbol;
|
|
4676
4708
|
declare class ToolCallNotFoundForApprovalError extends AISDKError {
|
|
4677
|
-
private readonly [symbol$
|
|
4709
|
+
private readonly [symbol$f];
|
|
4678
4710
|
readonly toolCallId: string;
|
|
4679
4711
|
readonly approvalId: string;
|
|
4680
4712
|
constructor({ toolCallId, approvalId, }: {
|
|
@@ -4684,9 +4716,9 @@ declare class ToolCallNotFoundForApprovalError extends AISDKError {
|
|
|
4684
4716
|
static isInstance(error: unknown): error is ToolCallNotFoundForApprovalError;
|
|
4685
4717
|
}
|
|
4686
4718
|
|
|
4687
|
-
declare const symbol$
|
|
4719
|
+
declare const symbol$e: unique symbol;
|
|
4688
4720
|
declare class MissingToolResultsError extends AISDKError {
|
|
4689
|
-
private readonly [symbol$
|
|
4721
|
+
private readonly [symbol$e];
|
|
4690
4722
|
readonly toolCallIds: string[];
|
|
4691
4723
|
constructor({ toolCallIds }: {
|
|
4692
4724
|
toolCallIds: string[];
|
|
@@ -4694,7 +4726,7 @@ declare class MissingToolResultsError extends AISDKError {
|
|
|
4694
4726
|
static isInstance(error: unknown): error is MissingToolResultsError;
|
|
4695
4727
|
}
|
|
4696
4728
|
|
|
4697
|
-
declare const symbol$
|
|
4729
|
+
declare const symbol$d: unique symbol;
|
|
4698
4730
|
/**
|
|
4699
4731
|
* Thrown when no image could be generated. This can have multiple causes:
|
|
4700
4732
|
*
|
|
@@ -4702,7 +4734,7 @@ declare const symbol$c: unique symbol;
|
|
|
4702
4734
|
* - The model generated a response that could not be parsed.
|
|
4703
4735
|
*/
|
|
4704
4736
|
declare class NoImageGeneratedError extends AISDKError {
|
|
4705
|
-
private readonly [symbol$
|
|
4737
|
+
private readonly [symbol$d];
|
|
4706
4738
|
/**
|
|
4707
4739
|
* The response metadata for each call.
|
|
4708
4740
|
*/
|
|
@@ -4715,7 +4747,7 @@ declare class NoImageGeneratedError extends AISDKError {
|
|
|
4715
4747
|
static isInstance(error: unknown): error is NoImageGeneratedError;
|
|
4716
4748
|
}
|
|
4717
4749
|
|
|
4718
|
-
declare const symbol$
|
|
4750
|
+
declare const symbol$c: unique symbol;
|
|
4719
4751
|
/**
|
|
4720
4752
|
* Thrown when no object could be generated. This can have several causes:
|
|
4721
4753
|
*
|
|
@@ -4728,7 +4760,7 @@ declare const symbol$b: unique symbol;
|
|
|
4728
4760
|
* - `text`: The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
|
|
4729
4761
|
*/
|
|
4730
4762
|
declare class NoObjectGeneratedError extends AISDKError {
|
|
4731
|
-
private readonly [symbol$
|
|
4763
|
+
private readonly [symbol$c];
|
|
4732
4764
|
/**
|
|
4733
4765
|
* The text that was generated by the model. This can be the raw text or the tool call text, depending on the model.
|
|
4734
4766
|
*/
|
|
@@ -4756,12 +4788,12 @@ declare class NoObjectGeneratedError extends AISDKError {
|
|
|
4756
4788
|
static isInstance(error: unknown): error is NoObjectGeneratedError;
|
|
4757
4789
|
}
|
|
4758
4790
|
|
|
4759
|
-
declare const symbol$
|
|
4791
|
+
declare const symbol$b: unique symbol;
|
|
4760
4792
|
/**
|
|
4761
4793
|
* Thrown when no LLM output was generated, e.g. because of errors.
|
|
4762
4794
|
*/
|
|
4763
4795
|
declare class NoOutputGeneratedError extends AISDKError {
|
|
4764
|
-
private readonly [symbol$
|
|
4796
|
+
private readonly [symbol$b];
|
|
4765
4797
|
constructor({ message, cause, }?: {
|
|
4766
4798
|
message?: string;
|
|
4767
4799
|
cause?: Error;
|
|
@@ -4769,12 +4801,12 @@ declare class NoOutputGeneratedError extends AISDKError {
|
|
|
4769
4801
|
static isInstance(error: unknown): error is NoOutputGeneratedError;
|
|
4770
4802
|
}
|
|
4771
4803
|
|
|
4772
|
-
declare const symbol$
|
|
4804
|
+
declare const symbol$a: unique symbol;
|
|
4773
4805
|
/**
|
|
4774
4806
|
* Error that is thrown when no speech audio was generated.
|
|
4775
4807
|
*/
|
|
4776
4808
|
declare class NoSpeechGeneratedError extends AISDKError {
|
|
4777
|
-
private readonly [symbol$
|
|
4809
|
+
private readonly [symbol$a];
|
|
4778
4810
|
readonly responses: Array<SpeechModelResponseMetadata>;
|
|
4779
4811
|
constructor(options: {
|
|
4780
4812
|
responses: Array<SpeechModelResponseMetadata>;
|
|
@@ -4782,12 +4814,12 @@ declare class NoSpeechGeneratedError extends AISDKError {
|
|
|
4782
4814
|
static isInstance(error: unknown): error is NoSpeechGeneratedError;
|
|
4783
4815
|
}
|
|
4784
4816
|
|
|
4785
|
-
declare const symbol$
|
|
4817
|
+
declare const symbol$9: unique symbol;
|
|
4786
4818
|
/**
|
|
4787
4819
|
* Error that is thrown when no transcript was generated.
|
|
4788
4820
|
*/
|
|
4789
4821
|
declare class NoTranscriptGeneratedError extends AISDKError {
|
|
4790
|
-
private readonly [symbol$
|
|
4822
|
+
private readonly [symbol$9];
|
|
4791
4823
|
readonly responses: Array<TranscriptionModelResponseMetadata>;
|
|
4792
4824
|
constructor(options: {
|
|
4793
4825
|
responses: Array<TranscriptionModelResponseMetadata>;
|
|
@@ -4819,9 +4851,9 @@ type VideoModelResponseMetadata = {
|
|
|
4819
4851
|
providerMetadata?: SharedV3ProviderMetadata;
|
|
4820
4852
|
};
|
|
4821
4853
|
|
|
4822
|
-
declare const symbol$
|
|
4854
|
+
declare const symbol$8: unique symbol;
|
|
4823
4855
|
declare class NoVideoGeneratedError extends AISDKError {
|
|
4824
|
-
private readonly [symbol$
|
|
4856
|
+
private readonly [symbol$8];
|
|
4825
4857
|
readonly responses: Array<VideoModelResponseMetadata>;
|
|
4826
4858
|
constructor({ message, cause, responses, }: {
|
|
4827
4859
|
message?: string;
|
|
@@ -4845,6 +4877,51 @@ declare class NoVideoGeneratedError extends AISDKError {
|
|
|
4845
4877
|
};
|
|
4846
4878
|
}
|
|
4847
4879
|
|
|
4880
|
+
declare const symbol$7: unique symbol;
|
|
4881
|
+
type EnforcedToolChoice = Extract<LanguageModelV3ToolChoice, {
|
|
4882
|
+
type: 'required';
|
|
4883
|
+
} | {
|
|
4884
|
+
type: 'tool';
|
|
4885
|
+
}>;
|
|
4886
|
+
/**
|
|
4887
|
+
* Thrown when a model response does not satisfy an enforced tool choice.
|
|
4888
|
+
*/
|
|
4889
|
+
declare class ToolChoiceViolationError extends AISDKError {
|
|
4890
|
+
private readonly [symbol$7];
|
|
4891
|
+
/**
|
|
4892
|
+
* The tool choice that the model response did not satisfy.
|
|
4893
|
+
*/
|
|
4894
|
+
readonly toolChoice: EnforcedToolChoice;
|
|
4895
|
+
/**
|
|
4896
|
+
* Reason why the model finished generating the response.
|
|
4897
|
+
*/
|
|
4898
|
+
readonly finishReason: FinishReason;
|
|
4899
|
+
/**
|
|
4900
|
+
* The provider that returned the response.
|
|
4901
|
+
*/
|
|
4902
|
+
readonly provider: string;
|
|
4903
|
+
/**
|
|
4904
|
+
* The model that returned the response.
|
|
4905
|
+
*/
|
|
4906
|
+
readonly modelId: string;
|
|
4907
|
+
/**
|
|
4908
|
+
* The normalized content returned by the model.
|
|
4909
|
+
*
|
|
4910
|
+
* This can be inspected to recover a tool call that the provider returned as
|
|
4911
|
+
* text or reasoning instead of a structured tool call.
|
|
4912
|
+
*/
|
|
4913
|
+
readonly content: Array<LanguageModelV3Content>;
|
|
4914
|
+
constructor({ toolChoice, finishReason, provider, modelId, content, message, }: {
|
|
4915
|
+
toolChoice: EnforcedToolChoice;
|
|
4916
|
+
finishReason: FinishReason;
|
|
4917
|
+
provider: string;
|
|
4918
|
+
modelId: string;
|
|
4919
|
+
content: Array<LanguageModelV3Content>;
|
|
4920
|
+
message?: string;
|
|
4921
|
+
});
|
|
4922
|
+
static isInstance(error: unknown): error is ToolChoiceViolationError;
|
|
4923
|
+
}
|
|
4924
|
+
|
|
4848
4925
|
declare const symbol$6: unique symbol;
|
|
4849
4926
|
declare class ToolCallRepairError extends AISDKError {
|
|
4850
4927
|
private readonly [symbol$6];
|
|
@@ -6431,4 +6508,4 @@ declare function bindTelemetryIntegration(integration: TelemetryIntegration): Te
|
|
|
6431
6508
|
*/
|
|
6432
6509
|
declare function registerTelemetryIntegration(integration: TelemetryIntegration): void;
|
|
6433
6510
|
|
|
6434
|
-
export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStartCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextOnToolCallFinishCallback, GenerateTextOnToolCallStartCallback, GenerateTextResult, GenerateVideoPrompt, GenerateVideoResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, Output as OutputInterface, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStartCallback, StreamTextOnStepFinishCallback, StreamTextOnStepStartCallback, StreamTextOnToolCallFinishCallback, StreamTextOnToolCallStartCallback, StreamTextResult, StreamTextTransform, TelemetryIntegration, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, 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 };
|
|
6511
|
+
export { AbstractChat, Agent, AgentCallParameters, AgentStreamParameters, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatAddToolOutputFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DefaultGeneratedFile, DirectChatTransport, DirectChatTransportOptions, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateImageResult, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStartCallback, GenerateTextOnStepFinishCallback, GenerateTextOnStepStartCallback, GenerateTextOnToolCallFinishCallback, GenerateTextOnToolCallStartCallback, GenerateTextResult, GenerateVideoPrompt, GenerateVideoResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageModelMiddleware, ImageModelProviderMetadata, ImageModelResponseMetadata, ImageModelUsage, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolApprovalError, InvalidToolApprovalSignatureError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LogWarningsFunction, MessageConversionError, MissingToolResultsError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, NoTranscriptGeneratedError, NoVideoGeneratedError, ObjectStreamPart, OnFinishEvent, OnStartEvent, OnStepFinishEvent, OnStepStartEvent, OnToolCallFinishEvent, OnToolCallStartEvent, output as Output, Output as OutputInterface, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStartCallback, StreamTextOnStepFinishCallback, StreamTextOnStepStartCallback, StreamTextOnToolCallFinishCallback, StreamTextOnToolCallStartCallback, StreamTextResult, StreamTextTransform, TelemetryIntegration, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, TimeoutConfiguration, ToolApprovalRequestOutput, ToolCallNotFoundForApprovalError, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolChoiceViolationError, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamError, UIMessageStreamOnFinishCallback, UIMessageStreamOnStepFinishCallback, UIMessageStreamOptions, UIMessageStreamOutcome, UIMessageStreamWriter, UIMessageStreamWriterWithOutcome, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, Warning, addToolInputExamplesMiddleware, assistantModelMessageSchema, bindTelemetryIntegration, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToModelMessages, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, experimental_generateImage, generateSpeech as experimental_generateSpeech, experimental_generateVideo, transcribe as experimental_transcribe, extractJsonMiddleware, extractReasoningMiddleware, generateImage, generateObject, generateText, getStaticToolName, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isLoopFinished, isReasoningUIPart, isStaticToolUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, registerTelemetryIntegration, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapImageModel, wrapLanguageModel, wrapProvider };
|