@mastra/ai-sdk 1.10.6 → 1.10.7-alpha.1
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/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +536 -0
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +488 -3
- package/dist/_types/@internal_ai-v7/dist/index.d.ts +1682 -253
- package/dist/chat-route.d.ts.map +1 -1
- package/dist/index.cjs +977 -831
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +977 -831
- package/dist/index.js.map +1 -1
- package/dist/transformers.d.ts +1 -5
- package/dist/transformers.d.ts.map +1 -1
- package/package.json +12 -12
|
@@ -143,6 +143,9 @@ declare namespace _ai_sdk_provider_utils {
|
|
|
143
143
|
Resolvable,
|
|
144
144
|
ResponseHandler,
|
|
145
145
|
Schema,
|
|
146
|
+
StreamingToolCallDelta,
|
|
147
|
+
StreamingToolCallTracker,
|
|
148
|
+
StreamingToolCallTrackerOptions,
|
|
146
149
|
SystemModelMessage,
|
|
147
150
|
TextPart,
|
|
148
151
|
Tool,
|
|
@@ -3868,6 +3871,107 @@ declare type LanguageModelV2CallOptions = {
|
|
|
3868
3871
|
providerOptions?: SharedV2ProviderOptions;
|
|
3869
3872
|
};
|
|
3870
3873
|
|
|
3874
|
+
declare type LanguageModelV2CallOptions_2 = {
|
|
3875
|
+
/**
|
|
3876
|
+
A language mode prompt is a standardized prompt type.
|
|
3877
|
+
|
|
3878
|
+
Note: This is **not** the user-facing prompt. The AI SDK methods will map the
|
|
3879
|
+
user-facing prompt types such as chat or instruction prompts to this format.
|
|
3880
|
+
That approach allows us to evolve the user facing prompts without breaking
|
|
3881
|
+
the language model interface.
|
|
3882
|
+
*/
|
|
3883
|
+
prompt: LanguageModelV2Prompt_2;
|
|
3884
|
+
/**
|
|
3885
|
+
Maximum number of tokens to generate.
|
|
3886
|
+
*/
|
|
3887
|
+
maxOutputTokens?: number;
|
|
3888
|
+
/**
|
|
3889
|
+
Temperature setting. The range depends on the provider and model.
|
|
3890
|
+
*/
|
|
3891
|
+
temperature?: number;
|
|
3892
|
+
/**
|
|
3893
|
+
Stop sequences.
|
|
3894
|
+
If set, the model will stop generating text when one of the stop sequences is generated.
|
|
3895
|
+
Providers may have limits on the number of stop sequences.
|
|
3896
|
+
*/
|
|
3897
|
+
stopSequences?: string[];
|
|
3898
|
+
/**
|
|
3899
|
+
Nucleus sampling.
|
|
3900
|
+
*/
|
|
3901
|
+
topP?: number;
|
|
3902
|
+
/**
|
|
3903
|
+
Only sample from the top K options for each subsequent token.
|
|
3904
|
+
|
|
3905
|
+
Used to remove "long tail" low probability responses.
|
|
3906
|
+
Recommended for advanced use cases only. You usually only need to use temperature.
|
|
3907
|
+
*/
|
|
3908
|
+
topK?: number;
|
|
3909
|
+
/**
|
|
3910
|
+
Presence penalty setting. It affects the likelihood of the model to
|
|
3911
|
+
repeat information that is already in the prompt.
|
|
3912
|
+
*/
|
|
3913
|
+
presencePenalty?: number;
|
|
3914
|
+
/**
|
|
3915
|
+
Frequency penalty setting. It affects the likelihood of the model
|
|
3916
|
+
to repeatedly use the same words or phrases.
|
|
3917
|
+
*/
|
|
3918
|
+
frequencyPenalty?: number;
|
|
3919
|
+
/**
|
|
3920
|
+
Response format. The output can either be text or JSON. Default is text.
|
|
3921
|
+
|
|
3922
|
+
If JSON is selected, a schema can optionally be provided to guide the LLM.
|
|
3923
|
+
*/
|
|
3924
|
+
responseFormat?: {
|
|
3925
|
+
type: 'text';
|
|
3926
|
+
} | {
|
|
3927
|
+
type: 'json';
|
|
3928
|
+
/**
|
|
3929
|
+
* JSON schema that the generated output should conform to.
|
|
3930
|
+
*/
|
|
3931
|
+
schema?: JSONSchema7;
|
|
3932
|
+
/**
|
|
3933
|
+
* Name of output that should be generated. Used by some providers for additional LLM guidance.
|
|
3934
|
+
*/
|
|
3935
|
+
name?: string;
|
|
3936
|
+
/**
|
|
3937
|
+
* Description of the output that should be generated. Used by some providers for additional LLM guidance.
|
|
3938
|
+
*/
|
|
3939
|
+
description?: string;
|
|
3940
|
+
};
|
|
3941
|
+
/**
|
|
3942
|
+
The seed (integer) to use for random sampling. If set and supported
|
|
3943
|
+
by the model, calls will generate deterministic results.
|
|
3944
|
+
*/
|
|
3945
|
+
seed?: number;
|
|
3946
|
+
/**
|
|
3947
|
+
The tools that are available for the model.
|
|
3948
|
+
*/
|
|
3949
|
+
tools?: Array<LanguageModelV2FunctionTool_2 | LanguageModelV2ProviderDefinedTool_2>;
|
|
3950
|
+
/**
|
|
3951
|
+
Specifies how the tool should be selected. Defaults to 'auto'.
|
|
3952
|
+
*/
|
|
3953
|
+
toolChoice?: LanguageModelV2ToolChoice_2;
|
|
3954
|
+
/**
|
|
3955
|
+
Include raw chunks in the stream. Only applicable for streaming calls.
|
|
3956
|
+
*/
|
|
3957
|
+
includeRawChunks?: boolean;
|
|
3958
|
+
/**
|
|
3959
|
+
Abort signal for cancelling the operation.
|
|
3960
|
+
*/
|
|
3961
|
+
abortSignal?: AbortSignal;
|
|
3962
|
+
/**
|
|
3963
|
+
Additional HTTP headers to be sent with the request.
|
|
3964
|
+
Only applicable for HTTP-based providers.
|
|
3965
|
+
*/
|
|
3966
|
+
headers?: Record<string, string | undefined>;
|
|
3967
|
+
/**
|
|
3968
|
+
* Additional provider-specific options. They are passed through
|
|
3969
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
3970
|
+
* functionality that can be fully encapsulated in the provider.
|
|
3971
|
+
*/
|
|
3972
|
+
providerOptions?: SharedV2ProviderOptions_2;
|
|
3973
|
+
};
|
|
3974
|
+
|
|
3871
3975
|
/**
|
|
3872
3976
|
Warning from the model provider for this call. The call will proceed, but e.g.
|
|
3873
3977
|
some settings might not be supported, which can lead to suboptimal results.
|
|
@@ -3885,6 +3989,23 @@ declare type LanguageModelV2CallWarning = {
|
|
|
3885
3989
|
message: string;
|
|
3886
3990
|
};
|
|
3887
3991
|
|
|
3992
|
+
/**
|
|
3993
|
+
Warning from the model provider for this call. The call will proceed, but e.g.
|
|
3994
|
+
some settings might not be supported, which can lead to suboptimal results.
|
|
3995
|
+
*/
|
|
3996
|
+
declare type LanguageModelV2CallWarning_2 = {
|
|
3997
|
+
type: 'unsupported-setting';
|
|
3998
|
+
setting: Omit<keyof LanguageModelV2CallOptions_2, 'prompt'>;
|
|
3999
|
+
details?: string;
|
|
4000
|
+
} | {
|
|
4001
|
+
type: 'unsupported-tool';
|
|
4002
|
+
tool: LanguageModelV2FunctionTool_2 | LanguageModelV2ProviderDefinedTool_2;
|
|
4003
|
+
details?: string;
|
|
4004
|
+
} | {
|
|
4005
|
+
type: 'other';
|
|
4006
|
+
message: string;
|
|
4007
|
+
};
|
|
4008
|
+
|
|
3888
4009
|
declare type LanguageModelV2Content = LanguageModelV2Text | LanguageModelV2Reasoning | LanguageModelV2File | LanguageModelV2Source | LanguageModelV2ToolCall | LanguageModelV2ToolResult;
|
|
3889
4010
|
|
|
3890
4011
|
/**
|
|
@@ -3921,6 +4042,30 @@ declare type LanguageModelV2File = {
|
|
|
3921
4042
|
data: string | Uint8Array;
|
|
3922
4043
|
};
|
|
3923
4044
|
|
|
4045
|
+
/**
|
|
4046
|
+
A file that has been generated by the model.
|
|
4047
|
+
Generated files as base64 encoded strings or binary data.
|
|
4048
|
+
The files should be returned without any unnecessary conversion.
|
|
4049
|
+
*/
|
|
4050
|
+
declare type LanguageModelV2File_2 = {
|
|
4051
|
+
type: 'file';
|
|
4052
|
+
/**
|
|
4053
|
+
The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
|
4054
|
+
|
|
4055
|
+
@see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
4056
|
+
*/
|
|
4057
|
+
mediaType: string;
|
|
4058
|
+
/**
|
|
4059
|
+
Generated file data as base64 encoded strings or binary data.
|
|
4060
|
+
|
|
4061
|
+
The file data should be returned without any unnecessary conversion.
|
|
4062
|
+
If the API returns base64 encoded strings, the file data should be returned
|
|
4063
|
+
as base64 encoded strings. If the API returns binary data, the file data should
|
|
4064
|
+
be returned as binary data.
|
|
4065
|
+
*/
|
|
4066
|
+
data: string | Uint8Array;
|
|
4067
|
+
};
|
|
4068
|
+
|
|
3924
4069
|
/**
|
|
3925
4070
|
File content part of a prompt. It contains a file.
|
|
3926
4071
|
*/
|
|
@@ -4000,6 +4145,20 @@ declare interface LanguageModelV2FilePart_2 {
|
|
|
4000
4145
|
*/
|
|
4001
4146
|
declare type LanguageModelV2FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
|
|
4002
4147
|
|
|
4148
|
+
/**
|
|
4149
|
+
Reason why a language model finished generating a response.
|
|
4150
|
+
|
|
4151
|
+
Can be one of the following:
|
|
4152
|
+
- `stop`: model generated stop sequence
|
|
4153
|
+
- `length`: model generated maximum number of tokens
|
|
4154
|
+
- `content-filter`: content filter violation stopped the model
|
|
4155
|
+
- `tool-calls`: model triggered tool calls
|
|
4156
|
+
- `error`: model stopped because of an error
|
|
4157
|
+
- `other`: model stopped for other reasons
|
|
4158
|
+
- `unknown`: the model has not transmitted a finish reason
|
|
4159
|
+
*/
|
|
4160
|
+
declare type LanguageModelV2FinishReason_2 = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other' | 'unknown';
|
|
4161
|
+
|
|
4003
4162
|
/**
|
|
4004
4163
|
A tool has a name, a description, and a set of parameters.
|
|
4005
4164
|
|
|
@@ -4031,6 +4190,37 @@ declare type LanguageModelV2FunctionTool = {
|
|
|
4031
4190
|
providerOptions?: SharedV2ProviderOptions;
|
|
4032
4191
|
};
|
|
4033
4192
|
|
|
4193
|
+
/**
|
|
4194
|
+
A tool has a name, a description, and a set of parameters.
|
|
4195
|
+
|
|
4196
|
+
Note: this is **not** the user-facing tool definition. The AI SDK methods will
|
|
4197
|
+
map the user-facing tool definitions to this format.
|
|
4198
|
+
*/
|
|
4199
|
+
declare type LanguageModelV2FunctionTool_2 = {
|
|
4200
|
+
/**
|
|
4201
|
+
The type of the tool (always 'function').
|
|
4202
|
+
*/
|
|
4203
|
+
type: 'function';
|
|
4204
|
+
/**
|
|
4205
|
+
The name of the tool. Unique within this model call.
|
|
4206
|
+
*/
|
|
4207
|
+
name: string;
|
|
4208
|
+
/**
|
|
4209
|
+
A description of the tool. The language model uses this to understand the
|
|
4210
|
+
tool's purpose and to provide better completion suggestions.
|
|
4211
|
+
*/
|
|
4212
|
+
description?: string;
|
|
4213
|
+
/**
|
|
4214
|
+
The parameters that the tool expects. The language model uses this to
|
|
4215
|
+
understand the tool's input requirements and to provide matching suggestions.
|
|
4216
|
+
*/
|
|
4217
|
+
inputSchema: JSONSchema7;
|
|
4218
|
+
/**
|
|
4219
|
+
The provider-specific options for the tool.
|
|
4220
|
+
*/
|
|
4221
|
+
providerOptions?: SharedV2ProviderOptions_2;
|
|
4222
|
+
};
|
|
4223
|
+
|
|
4034
4224
|
declare type LanguageModelV2Message = ({
|
|
4035
4225
|
role: 'system';
|
|
4036
4226
|
content: string;
|
|
@@ -4195,6 +4385,28 @@ declare type LanguageModelV2ProviderDefinedTool = {
|
|
|
4195
4385
|
args: Record<string, unknown>;
|
|
4196
4386
|
};
|
|
4197
4387
|
|
|
4388
|
+
/**
|
|
4389
|
+
The configuration of a tool that is defined by the provider.
|
|
4390
|
+
*/
|
|
4391
|
+
declare type LanguageModelV2ProviderDefinedTool_2 = {
|
|
4392
|
+
/**
|
|
4393
|
+
The type of the tool (always 'provider-defined').
|
|
4394
|
+
*/
|
|
4395
|
+
type: 'provider-defined';
|
|
4396
|
+
/**
|
|
4397
|
+
The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
|
|
4398
|
+
*/
|
|
4399
|
+
id: `${string}.${string}`;
|
|
4400
|
+
/**
|
|
4401
|
+
The name of the tool that the user must use in the tool set.
|
|
4402
|
+
*/
|
|
4403
|
+
name: string;
|
|
4404
|
+
/**
|
|
4405
|
+
The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
|
4406
|
+
*/
|
|
4407
|
+
args: Record<string, unknown>;
|
|
4408
|
+
};
|
|
4409
|
+
|
|
4198
4410
|
/**
|
|
4199
4411
|
Reasoning that the model has generated.
|
|
4200
4412
|
*/
|
|
@@ -4256,6 +4468,21 @@ declare interface LanguageModelV2ResponseMetadata {
|
|
|
4256
4468
|
modelId?: string;
|
|
4257
4469
|
}
|
|
4258
4470
|
|
|
4471
|
+
declare interface LanguageModelV2ResponseMetadata_2 {
|
|
4472
|
+
/**
|
|
4473
|
+
ID for the generated response, if the provider sends one.
|
|
4474
|
+
*/
|
|
4475
|
+
id?: string;
|
|
4476
|
+
/**
|
|
4477
|
+
Timestamp for the start of the generated response, if the provider sends one.
|
|
4478
|
+
*/
|
|
4479
|
+
timestamp?: Date;
|
|
4480
|
+
/**
|
|
4481
|
+
The ID of the response model that was used to generate the response, if the provider sends one.
|
|
4482
|
+
*/
|
|
4483
|
+
modelId?: string;
|
|
4484
|
+
}
|
|
4485
|
+
|
|
4259
4486
|
/**
|
|
4260
4487
|
A source that has been used as input to generate the response.
|
|
4261
4488
|
*/
|
|
@@ -4309,6 +4536,59 @@ declare type LanguageModelV2Source = {
|
|
|
4309
4536
|
providerMetadata?: SharedV2ProviderMetadata;
|
|
4310
4537
|
};
|
|
4311
4538
|
|
|
4539
|
+
/**
|
|
4540
|
+
A source that has been used as input to generate the response.
|
|
4541
|
+
*/
|
|
4542
|
+
declare type LanguageModelV2Source_2 = {
|
|
4543
|
+
type: 'source';
|
|
4544
|
+
/**
|
|
4545
|
+
* The type of source - URL sources reference web content.
|
|
4546
|
+
*/
|
|
4547
|
+
sourceType: 'url';
|
|
4548
|
+
/**
|
|
4549
|
+
* The ID of the source.
|
|
4550
|
+
*/
|
|
4551
|
+
id: string;
|
|
4552
|
+
/**
|
|
4553
|
+
* The URL of the source.
|
|
4554
|
+
*/
|
|
4555
|
+
url: string;
|
|
4556
|
+
/**
|
|
4557
|
+
* The title of the source.
|
|
4558
|
+
*/
|
|
4559
|
+
title?: string;
|
|
4560
|
+
/**
|
|
4561
|
+
* Additional provider metadata for the source.
|
|
4562
|
+
*/
|
|
4563
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4564
|
+
} | {
|
|
4565
|
+
type: 'source';
|
|
4566
|
+
/**
|
|
4567
|
+
* The type of source - document sources reference files/documents.
|
|
4568
|
+
*/
|
|
4569
|
+
sourceType: 'document';
|
|
4570
|
+
/**
|
|
4571
|
+
* The ID of the source.
|
|
4572
|
+
*/
|
|
4573
|
+
id: string;
|
|
4574
|
+
/**
|
|
4575
|
+
* IANA media type of the document (e.g., 'application/pdf').
|
|
4576
|
+
*/
|
|
4577
|
+
mediaType: string;
|
|
4578
|
+
/**
|
|
4579
|
+
* The title of the document.
|
|
4580
|
+
*/
|
|
4581
|
+
title: string;
|
|
4582
|
+
/**
|
|
4583
|
+
* Optional filename of the document.
|
|
4584
|
+
*/
|
|
4585
|
+
filename?: string;
|
|
4586
|
+
/**
|
|
4587
|
+
* Additional provider metadata for the source.
|
|
4588
|
+
*/
|
|
4589
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4590
|
+
};
|
|
4591
|
+
|
|
4312
4592
|
declare type LanguageModelV2StreamPart = {
|
|
4313
4593
|
type: 'text-start';
|
|
4314
4594
|
providerMetadata?: SharedV2ProviderMetadata;
|
|
@@ -4368,6 +4648,65 @@ declare type LanguageModelV2StreamPart = {
|
|
|
4368
4648
|
error: unknown;
|
|
4369
4649
|
};
|
|
4370
4650
|
|
|
4651
|
+
declare type LanguageModelV2StreamPart_2 = {
|
|
4652
|
+
type: 'text-start';
|
|
4653
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4654
|
+
id: string;
|
|
4655
|
+
} | {
|
|
4656
|
+
type: 'text-delta';
|
|
4657
|
+
id: string;
|
|
4658
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4659
|
+
delta: string;
|
|
4660
|
+
} | {
|
|
4661
|
+
type: 'text-end';
|
|
4662
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4663
|
+
id: string;
|
|
4664
|
+
} | {
|
|
4665
|
+
type: 'reasoning-start';
|
|
4666
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4667
|
+
id: string;
|
|
4668
|
+
} | {
|
|
4669
|
+
type: 'reasoning-delta';
|
|
4670
|
+
id: string;
|
|
4671
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4672
|
+
delta: string;
|
|
4673
|
+
} | {
|
|
4674
|
+
type: 'reasoning-end';
|
|
4675
|
+
id: string;
|
|
4676
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4677
|
+
} | {
|
|
4678
|
+
type: 'tool-input-start';
|
|
4679
|
+
id: string;
|
|
4680
|
+
toolName: string;
|
|
4681
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4682
|
+
providerExecuted?: boolean;
|
|
4683
|
+
} | {
|
|
4684
|
+
type: 'tool-input-delta';
|
|
4685
|
+
id: string;
|
|
4686
|
+
delta: string;
|
|
4687
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4688
|
+
} | {
|
|
4689
|
+
type: 'tool-input-end';
|
|
4690
|
+
id: string;
|
|
4691
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4692
|
+
} | LanguageModelV2ToolCall_2 | LanguageModelV2ToolResult_2 | LanguageModelV2File_2 | LanguageModelV2Source_2 | {
|
|
4693
|
+
type: 'stream-start';
|
|
4694
|
+
warnings: Array<LanguageModelV2CallWarning_2>;
|
|
4695
|
+
} | ({
|
|
4696
|
+
type: 'response-metadata';
|
|
4697
|
+
} & LanguageModelV2ResponseMetadata_2) | {
|
|
4698
|
+
type: 'finish';
|
|
4699
|
+
usage: LanguageModelV2Usage_2;
|
|
4700
|
+
finishReason: LanguageModelV2FinishReason_2;
|
|
4701
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4702
|
+
} | {
|
|
4703
|
+
type: 'raw';
|
|
4704
|
+
rawValue: unknown;
|
|
4705
|
+
} | {
|
|
4706
|
+
type: 'error';
|
|
4707
|
+
error: unknown;
|
|
4708
|
+
};
|
|
4709
|
+
|
|
4371
4710
|
/**
|
|
4372
4711
|
Text that the model has generated.
|
|
4373
4712
|
*/
|
|
@@ -4443,6 +4782,35 @@ declare type LanguageModelV2ToolCall = {
|
|
|
4443
4782
|
providerMetadata?: SharedV2ProviderMetadata;
|
|
4444
4783
|
};
|
|
4445
4784
|
|
|
4785
|
+
/**
|
|
4786
|
+
* Tool calls that the model has generated.
|
|
4787
|
+
*/
|
|
4788
|
+
declare type LanguageModelV2ToolCall_2 = {
|
|
4789
|
+
type: 'tool-call';
|
|
4790
|
+
/**
|
|
4791
|
+
* The identifier of the tool call. It must be unique across all tool calls.
|
|
4792
|
+
*/
|
|
4793
|
+
toolCallId: string;
|
|
4794
|
+
/**
|
|
4795
|
+
* The name of the tool that should be called.
|
|
4796
|
+
*/
|
|
4797
|
+
toolName: string;
|
|
4798
|
+
/**
|
|
4799
|
+
* Stringified JSON object with the tool call arguments. Must match the
|
|
4800
|
+
* parameters schema of the tool.
|
|
4801
|
+
*/
|
|
4802
|
+
input: string;
|
|
4803
|
+
/**
|
|
4804
|
+
* Whether the tool call will be executed by the provider.
|
|
4805
|
+
* If this flag is not set or is false, the tool call will be executed by the client.
|
|
4806
|
+
*/
|
|
4807
|
+
providerExecuted?: boolean;
|
|
4808
|
+
/**
|
|
4809
|
+
* Additional provider-specific metadata for the tool call.
|
|
4810
|
+
*/
|
|
4811
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4812
|
+
};
|
|
4813
|
+
|
|
4446
4814
|
/**
|
|
4447
4815
|
Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
|
4448
4816
|
*/
|
|
@@ -4514,6 +4882,17 @@ declare type LanguageModelV2ToolChoice = {
|
|
|
4514
4882
|
toolName: string;
|
|
4515
4883
|
};
|
|
4516
4884
|
|
|
4885
|
+
declare type LanguageModelV2ToolChoice_2 = {
|
|
4886
|
+
type: 'auto';
|
|
4887
|
+
} | {
|
|
4888
|
+
type: 'none';
|
|
4889
|
+
} | {
|
|
4890
|
+
type: 'required';
|
|
4891
|
+
} | {
|
|
4892
|
+
type: 'tool';
|
|
4893
|
+
toolName: string;
|
|
4894
|
+
};
|
|
4895
|
+
|
|
4517
4896
|
/**
|
|
4518
4897
|
Result of a tool call that has been executed by the provider.
|
|
4519
4898
|
*/
|
|
@@ -4547,6 +4926,39 @@ declare type LanguageModelV2ToolResult = {
|
|
|
4547
4926
|
providerMetadata?: SharedV2ProviderMetadata;
|
|
4548
4927
|
};
|
|
4549
4928
|
|
|
4929
|
+
/**
|
|
4930
|
+
Result of a tool call that has been executed by the provider.
|
|
4931
|
+
*/
|
|
4932
|
+
declare type LanguageModelV2ToolResult_2 = {
|
|
4933
|
+
type: 'tool-result';
|
|
4934
|
+
/**
|
|
4935
|
+
* The ID of the tool call that this result is associated with.
|
|
4936
|
+
*/
|
|
4937
|
+
toolCallId: string;
|
|
4938
|
+
/**
|
|
4939
|
+
* Name of the tool that generated this result.
|
|
4940
|
+
*/
|
|
4941
|
+
toolName: string;
|
|
4942
|
+
/**
|
|
4943
|
+
* Result of the tool call. This is a JSON-serializable object.
|
|
4944
|
+
*/
|
|
4945
|
+
result: unknown;
|
|
4946
|
+
/**
|
|
4947
|
+
* Optional flag if the result is an error or an error message.
|
|
4948
|
+
*/
|
|
4949
|
+
isError?: boolean;
|
|
4950
|
+
/**
|
|
4951
|
+
* Whether the tool result was generated by the provider.
|
|
4952
|
+
* If this flag is set to true, the tool result was generated by the provider.
|
|
4953
|
+
* If this flag is not set or is false, the tool result was generated by the client.
|
|
4954
|
+
*/
|
|
4955
|
+
providerExecuted?: boolean;
|
|
4956
|
+
/**
|
|
4957
|
+
* Additional provider-specific metadata for the tool result.
|
|
4958
|
+
*/
|
|
4959
|
+
providerMetadata?: SharedV2ProviderMetadata_2;
|
|
4960
|
+
};
|
|
4961
|
+
|
|
4550
4962
|
declare type LanguageModelV2ToolResultOutput = {
|
|
4551
4963
|
type: 'text';
|
|
4552
4964
|
value: string;
|
|
@@ -4696,6 +5108,37 @@ declare type LanguageModelV2Usage = {
|
|
|
4696
5108
|
cachedInputTokens?: number | undefined;
|
|
4697
5109
|
};
|
|
4698
5110
|
|
|
5111
|
+
/**
|
|
5112
|
+
Usage information for a language model call.
|
|
5113
|
+
|
|
5114
|
+
If your API return additional usage information, you can add it to the
|
|
5115
|
+
provider metadata under your provider's key.
|
|
5116
|
+
*/
|
|
5117
|
+
declare type LanguageModelV2Usage_2 = {
|
|
5118
|
+
/**
|
|
5119
|
+
The number of input (prompt) tokens used.
|
|
5120
|
+
*/
|
|
5121
|
+
inputTokens: number | undefined;
|
|
5122
|
+
/**
|
|
5123
|
+
The number of output (completion) tokens used.
|
|
5124
|
+
*/
|
|
5125
|
+
outputTokens: number | undefined;
|
|
5126
|
+
/**
|
|
5127
|
+
The total number of tokens as reported by the provider.
|
|
5128
|
+
This number might be different from the sum of `inputTokens` and `outputTokens`
|
|
5129
|
+
and e.g. include reasoning tokens or other overhead.
|
|
5130
|
+
*/
|
|
5131
|
+
totalTokens: number | undefined;
|
|
5132
|
+
/**
|
|
5133
|
+
The number of reasoning tokens used.
|
|
5134
|
+
*/
|
|
5135
|
+
reasoningTokens?: number | undefined;
|
|
5136
|
+
/**
|
|
5137
|
+
The number of cached input tokens.
|
|
5138
|
+
*/
|
|
5139
|
+
cachedInputTokens?: number | undefined;
|
|
5140
|
+
};
|
|
5141
|
+
|
|
4699
5142
|
/**
|
|
4700
5143
|
Check if the message is an assistant message with completed tool calls.
|
|
4701
5144
|
The last step of the message must have at least one tool invocation and
|
|
@@ -5965,6 +6408,29 @@ declare type SharedV2Headers = Record<string, string>;
|
|
|
5965
6408
|
*/
|
|
5966
6409
|
declare type SharedV2ProviderMetadata = Record<string, Record<string, JSONValue_2>>;
|
|
5967
6410
|
|
|
6411
|
+
/**
|
|
6412
|
+
* Additional provider-specific metadata.
|
|
6413
|
+
* Metadata are additional outputs from the provider.
|
|
6414
|
+
* They are passed through to the provider from the AI SDK
|
|
6415
|
+
* and enable provider-specific functionality
|
|
6416
|
+
* that can be fully encapsulated in the provider.
|
|
6417
|
+
*
|
|
6418
|
+
* This enables us to quickly ship provider-specific functionality
|
|
6419
|
+
* without affecting the core AI SDK.
|
|
6420
|
+
*
|
|
6421
|
+
* The outer record is keyed by the provider name, and the inner
|
|
6422
|
+
* record is keyed by the provider-specific metadata key.
|
|
6423
|
+
*
|
|
6424
|
+
* ```ts
|
|
6425
|
+
* {
|
|
6426
|
+
* "anthropic": {
|
|
6427
|
+
* "cacheControl": { "type": "ephemeral" }
|
|
6428
|
+
* }
|
|
6429
|
+
* }
|
|
6430
|
+
* ```
|
|
6431
|
+
*/
|
|
6432
|
+
declare type SharedV2ProviderMetadata_2 = Record<string, Record<string, JSONValue_3>>;
|
|
6433
|
+
|
|
5968
6434
|
/**
|
|
5969
6435
|
* Additional provider-specific options.
|
|
5970
6436
|
* Options are additional input to the provider.
|
|
@@ -6874,6 +7340,76 @@ export declare type StopCondition<TOOLS extends ToolSet> = (options: {
|
|
|
6874
7340
|
steps: Array<StepResult<TOOLS>>;
|
|
6875
7341
|
}) => PromiseLike<boolean> | boolean;
|
|
6876
7342
|
|
|
7343
|
+
/**
|
|
7344
|
+
* Minimal interface for a streaming tool call delta from an OpenAI-compatible API.
|
|
7345
|
+
*/
|
|
7346
|
+
declare interface StreamingToolCallDelta {
|
|
7347
|
+
index?: number | null;
|
|
7348
|
+
id?: string | null;
|
|
7349
|
+
type?: string | null;
|
|
7350
|
+
function?: {
|
|
7351
|
+
name?: string | null;
|
|
7352
|
+
arguments?: string | null;
|
|
7353
|
+
} | null;
|
|
7354
|
+
}
|
|
7355
|
+
|
|
7356
|
+
/**
|
|
7357
|
+
* Tracks streaming tool call state across multiple deltas from an
|
|
7358
|
+
* OpenAI-compatible chat completion stream.
|
|
7359
|
+
*/
|
|
7360
|
+
declare class StreamingToolCallTracker<DELTA extends StreamingToolCallDelta = StreamingToolCallDelta> {
|
|
7361
|
+
private toolCalls;
|
|
7362
|
+
private toolCallsById;
|
|
7363
|
+
private toolCallsByIndex;
|
|
7364
|
+
private usedToolCallIds;
|
|
7365
|
+
private nextGeneratedIdSuffixes;
|
|
7366
|
+
private readonly controller;
|
|
7367
|
+
private readonly _generateId;
|
|
7368
|
+
private readonly typeValidation;
|
|
7369
|
+
private readonly extractMetadata?;
|
|
7370
|
+
private readonly buildToolCallProviderMetadata?;
|
|
7371
|
+
constructor(controller: StreamingToolCallTrackerController, options?: StreamingToolCallTrackerOptions<DELTA>);
|
|
7372
|
+
processDelta(toolCallDelta: DELTA): void;
|
|
7373
|
+
flush(): void;
|
|
7374
|
+
private resolveToolCall;
|
|
7375
|
+
private filterToolCallsByName;
|
|
7376
|
+
private resolveMatchingToolCall;
|
|
7377
|
+
private processNewToolCall;
|
|
7378
|
+
private associateWireId;
|
|
7379
|
+
private associateIndex;
|
|
7380
|
+
private createToolCallId;
|
|
7381
|
+
private getNonBlankString;
|
|
7382
|
+
private processExistingToolCall;
|
|
7383
|
+
private finishToolCall;
|
|
7384
|
+
}
|
|
7385
|
+
|
|
7386
|
+
declare type StreamingToolCallTrackerController = Pick<TransformStreamDefaultController<LanguageModelV2StreamPart_2>, 'enqueue'>;
|
|
7387
|
+
|
|
7388
|
+
declare interface StreamingToolCallTrackerOptions<DELTA extends StreamingToolCallDelta = StreamingToolCallDelta> {
|
|
7389
|
+
/**
|
|
7390
|
+
* ID generator function for tool call IDs.
|
|
7391
|
+
* Blank or repeated outputs are converted to usable unique IDs.
|
|
7392
|
+
* Defaults to the standard generateId.
|
|
7393
|
+
*/
|
|
7394
|
+
generateId?: () => string;
|
|
7395
|
+
/**
|
|
7396
|
+
* How to validate the `type` field on new tool call deltas.
|
|
7397
|
+
* - `'none'`: no validation (default)
|
|
7398
|
+
* - `'if-present'`: throw if type is present and not `'function'`
|
|
7399
|
+
* - `'required'`: throw if type is not exactly `'function'`
|
|
7400
|
+
*/
|
|
7401
|
+
typeValidation?: 'none' | 'if-present' | 'required';
|
|
7402
|
+
/**
|
|
7403
|
+
* Extract provider-specific metadata from a tool call delta.
|
|
7404
|
+
* Called once when a new tool call is detected.
|
|
7405
|
+
*/
|
|
7406
|
+
extractMetadata?: (delta: DELTA) => SharedV2ProviderMetadata_2 | undefined;
|
|
7407
|
+
/**
|
|
7408
|
+
* Build the `providerMetadata` object for a `tool-call` event.
|
|
7409
|
+
*/
|
|
7410
|
+
buildToolCallProviderMetadata?: (metadata: SharedV2ProviderMetadata_2 | undefined) => SharedV2ProviderMetadata_2 | undefined;
|
|
7411
|
+
}
|
|
7412
|
+
|
|
6877
7413
|
/**
|
|
6878
7414
|
Generate a structured, typed object for a given prompt and schema using a language model.
|
|
6879
7415
|
|