ai 5.0.0-canary.6 → 5.0.0-canary.8

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ToolCall, ToolResult, FetchFunction, Validator, IDGenerator } from '@ai-sdk/provider-utils';
2
2
  export { CoreToolCall, CoreToolResult, IDGenerator, ToolCall, ToolResult, createIdGenerator, generateId } from '@ai-sdk/provider-utils';
3
- import { EmbeddingModelV1, EmbeddingModelV1Embedding, ImageModelV1, ImageModelV1CallWarning, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2LogProbs, LanguageModelV2CallWarning, LanguageModelV2Source, LanguageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2CallOptions, AISDKError, LanguageModelV2FunctionToolCall, JSONSchema7 as JSONSchema7$1, JSONParseError, TypeValidationError, TranscriptionModelV1CallWarning, TranscriptionModelV1, LanguageModelV2ProviderOptions, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
4
- export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Prompt, LanguageModelV2StreamPart, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
3
+ import { EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV1, ImageModelV1CallWarning, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2LogProbs, LanguageModelV2CallWarning, LanguageModelV2Source, SharedV2ProviderMetadata, SharedV2ProviderOptions, JSONValue as JSONValue$1, JSONObject, LanguageModelV2CallOptions, AISDKError, LanguageModelV2ToolCall, JSONSchema7 as JSONSchema7$1, JSONParseError, TypeValidationError, TranscriptionModelV1CallWarning, TranscriptionModelV1, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
4
+ export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
5
5
  import { ServerResponse } from 'node:http';
6
6
  import { AttributeValue, Tracer } from '@opentelemetry/api';
7
7
  import { z } from 'zod';
@@ -11,11 +11,11 @@ import { ServerResponse as ServerResponse$1 } from 'http';
11
11
  /**
12
12
  Embedding model that is used by the AI SDK Core functions.
13
13
  */
14
- type EmbeddingModel<VALUE> = EmbeddingModelV1<VALUE>;
14
+ type EmbeddingModel<VALUE> = EmbeddingModelV2<VALUE>;
15
15
  /**
16
16
  Embedding.
17
17
  */
18
- type Embedding = EmbeddingModelV1Embedding;
18
+ type Embedding = EmbeddingModelV2Embedding;
19
19
 
20
20
  /**
21
21
  Image model that is used by the AI SDK Core functions.
@@ -83,12 +83,8 @@ Tool choice for the generation. It supports the following settings:
83
83
  */
84
84
  type ToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | 'required' | {
85
85
  type: 'tool';
86
- toolName: keyof TOOLS;
86
+ toolName: Extract<keyof TOOLS, string>;
87
87
  };
88
- /**
89
- * @deprecated Use `ToolChoice` instead.
90
- */
91
- type CoreToolChoice<TOOLS extends Record<string, unknown>> = ToolChoice<TOOLS>;
92
88
 
93
89
  type LanguageModelRequestMetadata = {
94
90
  /**
@@ -159,14 +155,14 @@ Additional provider-specific metadata that is returned from the provider.
159
155
  This is needed to enable provider-specific functionality that can be
160
156
  fully encapsulated in the provider.
161
157
  */
162
- type ProviderMetadata = LanguageModelV2ProviderMetadata;
158
+ type ProviderMetadata = SharedV2ProviderMetadata;
163
159
  /**
164
160
  Additional provider-specific options.
165
161
 
166
162
  They are passed through to the provider from the AI SDK and enable
167
163
  provider-specific functionality that can be fully encapsulated in the provider.
168
164
  */
169
- type ProviderOptions = LanguageModelV2ProviderMetadata;
165
+ type ProviderOptions = SharedV2ProviderOptions;
170
166
 
171
167
  /**
172
168
  Represents the number of tokens used in a prompt and completion.
@@ -870,7 +866,7 @@ declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7, { validat
870
866
  error: Error;
871
867
  };
872
868
  }): Schema<OBJECT>;
873
- declare function asSchema<OBJECT>(schema: z.Schema<OBJECT, z.ZodTypeDef, any> | Schema<OBJECT>): Schema<OBJECT>;
869
+ declare function asSchema<OBJECT>(schema: z.Schema<OBJECT, z.ZodTypeDef, any> | Schema<OBJECT> | undefined): Schema<OBJECT>;
874
870
 
875
871
  declare function shouldResubmitMessages({ originalMaxToolInvocationStep, originalMessageCount, maxSteps, messages, }: {
876
872
  originalMaxToolInvocationStep: number | undefined;
@@ -1010,13 +1006,17 @@ interface EmbedResult<VALUE> {
1010
1006
  */
1011
1007
  readonly usage: EmbeddingModelUsage;
1012
1008
  /**
1013
- Optional raw response data.
1009
+ Optional response data.
1014
1010
  */
1015
- readonly rawResponse?: {
1011
+ readonly response?: {
1016
1012
  /**
1017
1013
  Response headers.
1018
1014
  */
1019
1015
  headers?: Record<string, string>;
1016
+ /**
1017
+ The response body.
1018
+ */
1019
+ body?: unknown;
1020
1020
  };
1021
1021
  }
1022
1022
 
@@ -1032,7 +1032,7 @@ Embed a value using an embedding model. The type of the value is defined by the
1032
1032
 
1033
1033
  @returns A result object that contains the embedding, the value, and additional information.
1034
1034
  */
1035
- declare function embed<VALUE>({ model, value, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry, }: {
1035
+ declare function embed<VALUE>({ model, value, providerOptions, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry, }: {
1036
1036
  /**
1037
1037
  The embedding model to use.
1038
1038
  */
@@ -1056,6 +1056,12 @@ declare function embed<VALUE>({ model, value, maxRetries: maxRetriesArg, abortSi
1056
1056
  Only applicable for HTTP-based providers.
1057
1057
  */
1058
1058
  headers?: Record<string, string>;
1059
+ /**
1060
+ Additional provider-specific options. They are passed through
1061
+ to the provider from the AI SDK and enable provider-specific
1062
+ functionality that can be fully encapsulated in the provider.
1063
+ */
1064
+ providerOptions?: ProviderOptions;
1059
1065
  /**
1060
1066
  * Optional telemetry configuration (experimental).
1061
1067
  */
@@ -1079,6 +1085,19 @@ interface EmbedManyResult<VALUE> {
1079
1085
  The embedding token usage.
1080
1086
  */
1081
1087
  readonly usage: EmbeddingModelUsage;
1088
+ /**
1089
+ Optional raw response data.
1090
+ */
1091
+ readonly responses?: Array<{
1092
+ /**
1093
+ Response headers.
1094
+ */
1095
+ headers?: Record<string, string>;
1096
+ /**
1097
+ The response body.
1098
+ */
1099
+ body?: unknown;
1100
+ } | undefined>;
1082
1101
  }
1083
1102
 
1084
1103
  /**
@@ -1097,7 +1116,7 @@ has a limit on how many embeddings can be generated in a single call.
1097
1116
 
1098
1117
  @returns A result object that contains the embeddings, the value, and additional information.
1099
1118
  */
1100
- declare function embedMany<VALUE>({ model, values, maxRetries: maxRetriesArg, abortSignal, headers, experimental_telemetry: telemetry, }: {
1119
+ declare function embedMany<VALUE>({ model, values, maxRetries: maxRetriesArg, abortSignal, headers, providerOptions, experimental_telemetry: telemetry, }: {
1101
1120
  /**
1102
1121
  The embedding model to use.
1103
1122
  */
@@ -1125,13 +1144,19 @@ declare function embedMany<VALUE>({ model, values, maxRetries: maxRetriesArg, ab
1125
1144
  * Optional telemetry configuration (experimental).
1126
1145
  */
1127
1146
  experimental_telemetry?: TelemetrySettings;
1147
+ /**
1148
+ Additional provider-specific options. They are passed through
1149
+ to the provider from the AI SDK and enable provider-specific
1150
+ functionality that can be fully encapsulated in the provider.
1151
+ */
1152
+ providerOptions?: ProviderOptions;
1128
1153
  }): Promise<EmbedManyResult<VALUE>>;
1129
1154
 
1130
1155
  type CallSettings = {
1131
1156
  /**
1132
1157
  Maximum number of tokens to generate.
1133
1158
  */
1134
- maxTokens?: number;
1159
+ maxOutputTokens?: number;
1135
1160
  /**
1136
1161
  Temperature setting. This is a number between 0 (almost no randomness) and
1137
1162
  1 (very random).
@@ -1234,10 +1259,6 @@ interface TextPart {
1234
1259
  functionality that can be fully encapsulated in the provider.
1235
1260
  */
1236
1261
  providerOptions?: ProviderOptions;
1237
- /**
1238
- @deprecated Use `providerOptions` instead.
1239
- */
1240
- experimental_providerMetadata?: ProviderMetadata;
1241
1262
  }
1242
1263
  /**
1243
1264
  Image content part of a prompt. It contains an image.
@@ -1267,10 +1288,6 @@ interface ImagePart {
1267
1288
  functionality that can be fully encapsulated in the provider.
1268
1289
  */
1269
1290
  providerOptions?: ProviderOptions;
1270
- /**
1271
- @deprecated Use `providerOptions` instead.
1272
- */
1273
- experimental_providerMetadata?: ProviderMetadata;
1274
1291
  }
1275
1292
  /**
1276
1293
  File content part of a prompt. It contains a file.
@@ -1304,10 +1321,6 @@ interface FilePart {
1304
1321
  functionality that can be fully encapsulated in the provider.
1305
1322
  */
1306
1323
  providerOptions?: ProviderOptions;
1307
- /**
1308
- @deprecated Use `providerOptions` instead.
1309
- */
1310
- experimental_providerMetadata?: ProviderMetadata;
1311
1324
  }
1312
1325
  /**
1313
1326
  * Reasoning content part of a prompt. It contains a reasoning.
@@ -1328,10 +1341,6 @@ interface ReasoningPart {
1328
1341
  functionality that can be fully encapsulated in the provider.
1329
1342
  */
1330
1343
  providerOptions?: ProviderOptions;
1331
- /**
1332
- @deprecated Use `providerOptions` instead.
1333
- */
1334
- experimental_providerMetadata?: ProviderMetadata;
1335
1344
  }
1336
1345
  /**
1337
1346
  Redacted reasoning content part of a prompt.
@@ -1348,10 +1357,6 @@ interface RedactedReasoningPart {
1348
1357
  functionality that can be fully encapsulated in the provider.
1349
1358
  */
1350
1359
  providerOptions?: ProviderOptions;
1351
- /**
1352
- @deprecated Use `providerOptions` instead.
1353
- */
1354
- experimental_providerMetadata?: ProviderMetadata;
1355
1360
  }
1356
1361
  /**
1357
1362
  Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
@@ -1376,10 +1381,6 @@ interface ToolCallPart {
1376
1381
  functionality that can be fully encapsulated in the provider.
1377
1382
  */
1378
1383
  providerOptions?: ProviderOptions;
1379
- /**
1380
- @deprecated Use `providerOptions` instead.
1381
- */
1382
- experimental_providerMetadata?: ProviderMetadata;
1383
1384
  }
1384
1385
  /**
1385
1386
  Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
@@ -1412,10 +1413,6 @@ interface ToolResultPart {
1412
1413
  functionality that can be fully encapsulated in the provider.
1413
1414
  */
1414
1415
  providerOptions?: ProviderOptions;
1415
- /**
1416
- @deprecated Use `providerOptions` instead.
1417
- */
1418
- experimental_providerMetadata?: ProviderMetadata;
1419
1416
  }
1420
1417
 
1421
1418
  /**
@@ -1434,10 +1431,6 @@ type CoreSystemMessage = {
1434
1431
  functionality that can be fully encapsulated in the provider.
1435
1432
  */
1436
1433
  providerOptions?: ProviderOptions;
1437
- /**
1438
- @deprecated Use `providerOptions` instead.
1439
- */
1440
- experimental_providerMetadata?: ProviderMetadata;
1441
1434
  };
1442
1435
  declare const coreSystemMessageSchema: z.ZodType<CoreSystemMessage>;
1443
1436
  /**
@@ -1452,10 +1445,6 @@ type CoreUserMessage = {
1452
1445
  functionality that can be fully encapsulated in the provider.
1453
1446
  */
1454
1447
  providerOptions?: ProviderOptions;
1455
- /**
1456
- @deprecated Use `providerOptions` instead.
1457
- */
1458
- experimental_providerMetadata?: ProviderMetadata;
1459
1448
  };
1460
1449
  declare const coreUserMessageSchema: z.ZodType<CoreUserMessage>;
1461
1450
  /**
@@ -1474,10 +1463,6 @@ type CoreAssistantMessage = {
1474
1463
  functionality that can be fully encapsulated in the provider.
1475
1464
  */
1476
1465
  providerOptions?: ProviderOptions;
1477
- /**
1478
- @deprecated Use `providerOptions` instead.
1479
- */
1480
- experimental_providerMetadata?: ProviderMetadata;
1481
1466
  };
1482
1467
  declare const coreAssistantMessageSchema: z.ZodType<CoreAssistantMessage>;
1483
1468
  /**
@@ -1497,10 +1482,6 @@ type CoreToolMessage = {
1497
1482
  functionality that can be fully encapsulated in the provider.
1498
1483
  */
1499
1484
  providerOptions?: ProviderOptions;
1500
- /**
1501
- @deprecated Use `providerOptions` instead.
1502
- */
1503
- experimental_providerMetadata?: ProviderMetadata;
1504
1485
  };
1505
1486
  declare const coreToolMessageSchema: z.ZodType<CoreToolMessage>;
1506
1487
  /**
@@ -1562,133 +1543,6 @@ type ReasoningDetail = {
1562
1543
  data: string;
1563
1544
  };
1564
1545
 
1565
- type ToolParameters = z.ZodTypeAny | Schema<any>;
1566
- type inferParameters<PARAMETERS extends ToolParameters> = PARAMETERS extends Schema<any> ? PARAMETERS['_type'] : PARAMETERS extends z.ZodTypeAny ? z.infer<PARAMETERS> : never;
1567
- interface ToolExecutionOptions {
1568
- /**
1569
- * The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
1570
- */
1571
- toolCallId: string;
1572
- /**
1573
- * Messages that were sent to the language model to initiate the response that contained the tool call.
1574
- * The messages **do not** include the system prompt nor the assistant response that contained the tool call.
1575
- */
1576
- messages: CoreMessage[];
1577
- /**
1578
- * An optional abort signal that indicates that the overall operation should be aborted.
1579
- */
1580
- abortSignal?: AbortSignal;
1581
- }
1582
- /**
1583
- A tool contains the description and the schema of the input that the tool expects.
1584
- This enables the language model to generate the input.
1585
-
1586
- The tool can also contain an optional execute function for the actual execution function of the tool.
1587
- */
1588
- type Tool<PARAMETERS extends ToolParameters = any, RESULT = any> = {
1589
- /**
1590
- The schema of the input that the tool expects. The language model will use this to generate the input.
1591
- It is also used to validate the output of the language model.
1592
- Use descriptions to make the input understandable for the language model.
1593
- */
1594
- parameters: PARAMETERS;
1595
- /**
1596
- An optional description of what the tool does.
1597
- Will be used by the language model to decide whether to use the tool.
1598
- Not used for provider-defined tools.
1599
- */
1600
- description?: string;
1601
- /**
1602
- Optional conversion function that maps the tool result to multi-part tool content for LLMs.
1603
- */
1604
- experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
1605
- /**
1606
- An async function that is called with the arguments from the tool call and produces a result.
1607
- If not provided, the tool will not be executed automatically.
1608
-
1609
- @args is the input of the tool call.
1610
- @options.abortSignal is a signal that can be used to abort the tool call.
1611
- */
1612
- execute?: (args: inferParameters<PARAMETERS>, options: ToolExecutionOptions) => PromiseLike<RESULT>;
1613
- } & ({
1614
- /**
1615
- Function tool.
1616
- */
1617
- type?: undefined | 'function';
1618
- } | {
1619
- /**
1620
- Provider-defined tool.
1621
- */
1622
- type: 'provider-defined';
1623
- /**
1624
- The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
1625
- */
1626
- id: `${string}.${string}`;
1627
- /**
1628
- The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
1629
- */
1630
- args: Record<string, unknown>;
1631
- });
1632
- /**
1633
- * @deprecated Use `Tool` instead.
1634
- */
1635
- type CoreTool<PARAMETERS extends ToolParameters = any, RESULT = any> = Tool<PARAMETERS, RESULT>;
1636
- /**
1637
- Helper function for inferring the execute args of a tool.
1638
- */
1639
- declare function tool<PARAMETERS extends ToolParameters, RESULT>(tool: Tool<PARAMETERS, RESULT> & {
1640
- execute: (args: inferParameters<PARAMETERS>, options: ToolExecutionOptions) => PromiseLike<RESULT>;
1641
- }): Tool<PARAMETERS, RESULT> & {
1642
- execute: (args: inferParameters<PARAMETERS>, options: ToolExecutionOptions) => PromiseLike<RESULT>;
1643
- };
1644
- declare function tool<PARAMETERS extends ToolParameters, RESULT>(tool: Tool<PARAMETERS, RESULT> & {
1645
- execute?: undefined;
1646
- }): Tool<PARAMETERS, RESULT> & {
1647
- execute: undefined;
1648
- };
1649
-
1650
- /**
1651
- Create a union of the given object's values, and optionally specify which keys to get the values from.
1652
-
1653
- Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
1654
-
1655
- @example
1656
- ```
1657
- // data.json
1658
- {
1659
- 'foo': 1,
1660
- 'bar': 2,
1661
- 'biz': 3
1662
- }
1663
-
1664
- // main.ts
1665
- import type {ValueOf} from 'type-fest';
1666
- import data = require('./data.json');
1667
-
1668
- export function getData(name: string): ValueOf<typeof data> {
1669
- return data[name];
1670
- }
1671
-
1672
- export function onlyBar(name: string): ValueOf<typeof data, 'bar'> {
1673
- return data[name];
1674
- }
1675
-
1676
- // file.ts
1677
- import {getData, onlyBar} from './main';
1678
-
1679
- getData('foo');
1680
- //=> 1
1681
-
1682
- onlyBar('foo');
1683
- //=> TypeError ...
1684
-
1685
- onlyBar('bar');
1686
- //=> 2
1687
- ```
1688
- * @see https://github.com/sindresorhus/type-fest/blob/main/source/value-of.d.ts
1689
- */
1690
- type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
1691
-
1692
1546
  declare const JSONRPCRequestSchema: z.ZodObject<z.objectUtil.extendShape<{
1693
1547
  jsonrpc: z.ZodLiteral<"2.0">;
1694
1548
  id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
@@ -1957,20 +1811,94 @@ type MCPTransportConfig = {
1957
1811
  headers?: Record<string, string>;
1958
1812
  };
1959
1813
 
1814
+ type ToolParameters<T = JSONObject> = z.Schema<T> | Schema<T>;
1815
+ interface ToolExecutionOptions {
1816
+ /**
1817
+ * The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
1818
+ */
1819
+ toolCallId: string;
1820
+ /**
1821
+ * Messages that were sent to the language model to initiate the response that contained the tool call.
1822
+ * The messages **do not** include the system prompt nor the assistant response that contained the tool call.
1823
+ */
1824
+ messages: CoreMessage[];
1825
+ /**
1826
+ * An optional abort signal that indicates that the overall operation should be aborted.
1827
+ */
1828
+ abortSignal?: AbortSignal;
1829
+ }
1830
+ type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
1831
+ /**
1832
+ A tool contains the description and the schema of the input that the tool expects.
1833
+ This enables the language model to generate the input.
1834
+
1835
+ The tool can also contain an optional execute function for the actual execution function of the tool.
1836
+ */
1837
+ type Tool<PARAMETERS extends JSONValue$1 | unknown | never = any, RESULT = any> = {
1838
+ /**
1839
+ An optional description of what the tool does.
1840
+ Will be used by the language model to decide whether to use the tool.
1841
+ Not used for provider-defined tools.
1842
+ */
1843
+ description?: string;
1844
+ } & NeverOptional<PARAMETERS, {
1845
+ /**
1846
+ The schema of the input that the tool expects. The language model will use this to generate the input.
1847
+ It is also used to validate the output of the language model.
1848
+ Use descriptions to make the input understandable for the language model.
1849
+ */
1850
+ parameters: ToolParameters<PARAMETERS>;
1851
+ }> & NeverOptional<RESULT, {
1852
+ /**
1853
+ An async function that is called with the arguments from the tool call and produces a result.
1854
+ If not provided, the tool will not be executed automatically.
1855
+
1856
+ @args is the input of the tool call.
1857
+ @options.abortSignal is a signal that can be used to abort the tool call.
1858
+ */
1859
+ execute: (args: [PARAMETERS] extends [never] ? undefined : PARAMETERS, options: ToolExecutionOptions) => PromiseLike<RESULT>;
1860
+ /**
1861
+ Optional conversion function that maps the tool result to multi-part tool content for LLMs.
1862
+ */
1863
+ experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
1864
+ }> & ({
1865
+ /**
1866
+ Function tool.
1867
+ */
1868
+ type?: undefined | 'function';
1869
+ } | {
1870
+ /**
1871
+ Provider-defined tool.
1872
+ */
1873
+ type: 'provider-defined';
1874
+ /**
1875
+ The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
1876
+ */
1877
+ id: `${string}.${string}`;
1878
+ /**
1879
+ The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
1880
+ */
1881
+ args: Record<string, unknown>;
1882
+ });
1883
+ /**
1884
+ Helper function for inferring the execute args of a tool.
1885
+ */
1886
+ declare function tool(tool: Tool<never, never>): Tool<never, never>;
1887
+ declare function tool<PARAMETERS>(tool: Tool<PARAMETERS, never>): Tool<PARAMETERS, never>;
1888
+ declare function tool<RESULT>(tool: Tool<never, RESULT>): Tool<never, RESULT>;
1889
+ declare function tool<PARAMETERS, RESULT>(tool: Tool<PARAMETERS, RESULT>): Tool<PARAMETERS, RESULT>;
1890
+ type MappedTool<T extends Tool | JSONObject, RESULT extends any> = T extends Tool<infer P> ? Tool<P, RESULT> : T extends JSONObject ? Tool<T, RESULT> : never;
1891
+
1960
1892
  type ToolSchemas = Record<string, {
1961
- parameters: ToolParameters;
1893
+ parameters: ToolParameters<JSONObject | unknown>;
1962
1894
  }> | 'automatic' | undefined;
1963
1895
  type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
1964
- parameters: ToolParameters;
1896
+ parameters: ToolParameters<any>;
1965
1897
  }> ? {
1966
- [K in keyof TOOL_SCHEMAS]: Tool<TOOL_SCHEMAS[K]['parameters'], CallToolResult> & {
1967
- execute: (args: inferParameters<TOOL_SCHEMAS[K]['parameters']>, options: ToolExecutionOptions) => PromiseLike<CallToolResult>;
1968
- };
1969
- } : {
1970
- [k: string]: Tool<z.ZodUnknown, CallToolResult> & {
1971
- execute: (args: unknown, options: ToolExecutionOptions) => PromiseLike<CallToolResult>;
1972
- };
1973
- };
1898
+ [K in keyof TOOL_SCHEMAS]: MappedTool<TOOL_SCHEMAS[K], CallToolResult> & Required<Pick<MappedTool<TOOL_SCHEMAS[K], CallToolResult>, 'execute'>>;
1899
+ } : McpToolSet<Record<string, {
1900
+ parameters: ToolParameters<unknown>;
1901
+ }>>;
1974
1902
  declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
1975
1903
  _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
1976
1904
  }, {
@@ -2734,27 +2662,60 @@ declare class MCPClient {
2734
2662
  private onResponse;
2735
2663
  }
2736
2664
 
2737
- type ToolSet = Record<string, Tool>;
2665
+ /**
2666
+ Create a union of the given object's values, and optionally specify which keys to get the values from.
2667
+
2668
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
2669
+
2670
+ @example
2671
+ ```
2672
+ // data.json
2673
+ {
2674
+ 'foo': 1,
2675
+ 'bar': 2,
2676
+ 'biz': 3
2677
+ }
2678
+
2679
+ // main.ts
2680
+ import type {ValueOf} from 'type-fest';
2681
+ import data = require('./data.json');
2682
+
2683
+ export function getData(name: string): ValueOf<typeof data> {
2684
+ return data[name];
2685
+ }
2686
+
2687
+ export function onlyBar(name: string): ValueOf<typeof data, 'bar'> {
2688
+ return data[name];
2689
+ }
2690
+
2691
+ // file.ts
2692
+ import {getData, onlyBar} from './main';
2693
+
2694
+ getData('foo');
2695
+ //=> 1
2696
+
2697
+ onlyBar('foo');
2698
+ //=> TypeError ...
2699
+
2700
+ onlyBar('bar');
2701
+ //=> 2
2702
+ ```
2703
+ * @see https://github.com/sindresorhus/type-fest/blob/main/source/value-of.d.ts
2704
+ */
2705
+ type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
2706
+
2707
+ type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute'>>;
2738
2708
 
2739
2709
  type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
2740
2710
  [NAME in keyof TOOLS]: {
2741
2711
  type: 'tool-call';
2742
2712
  toolCallId: string;
2743
2713
  toolName: NAME & string;
2744
- args: inferParameters<TOOLS[NAME]['parameters']>;
2714
+ args: TOOLS[NAME] extends Tool<infer PARAMETERS> ? PARAMETERS : never;
2745
2715
  };
2746
2716
  }>;
2747
- /**
2748
- * @deprecated Use `ToolCallUnion` instead.
2749
- */
2750
- type CoreToolCallUnion<TOOLS extends ToolSet> = ToolCallUnion<ToolSet>;
2751
2717
  type ToolCallArray<TOOLS extends ToolSet> = Array<ToolCallUnion<TOOLS>>;
2752
2718
 
2753
- type ToToolsWithExecute<TOOLS extends ToolSet> = {
2754
- [K in keyof TOOLS as TOOLS[K] extends {
2755
- execute: any;
2756
- } ? K : never]: TOOLS[K];
2757
- };
2758
2719
  type ToToolsWithDefinedExecute<TOOLS extends ToolSet> = {
2759
2720
  [K in keyof TOOLS as TOOLS[K]['execute'] extends undefined ? never : K]: TOOLS[K];
2760
2721
  };
@@ -2763,15 +2724,11 @@ type ToToolResultObject<TOOLS extends ToolSet> = ValueOf<{
2763
2724
  type: 'tool-result';
2764
2725
  toolCallId: string;
2765
2726
  toolName: NAME & string;
2766
- args: inferParameters<TOOLS[NAME]['parameters']>;
2727
+ args: TOOLS[NAME] extends Tool<infer P> ? P : never;
2767
2728
  result: Awaited<ReturnType<Exclude<TOOLS[NAME]['execute'], undefined>>>;
2768
2729
  };
2769
2730
  }>;
2770
- type ToolResultUnion<TOOLS extends ToolSet> = ToToolResultObject<ToToolsWithDefinedExecute<ToToolsWithExecute<TOOLS>>>;
2771
- /**
2772
- * @deprecated Use `ToolResultUnion` instead.
2773
- */
2774
- type CoreToolResultUnion<TOOLS extends ToolSet> = ToolResultUnion<TOOLS>;
2731
+ type ToolResultUnion<TOOLS extends ToolSet> = ToToolResultObject<ToToolsWithDefinedExecute<TOOLS>>;
2775
2732
  type ToolResultArray<TOOLS extends ToolSet> = Array<ToolResultUnion<TOOLS>>;
2776
2733
 
2777
2734
  /**
@@ -2856,10 +2813,6 @@ type StepResult<TOOLS extends ToolSet> = {
2856
2813
  */
2857
2814
  readonly providerMetadata: ProviderMetadata | undefined;
2858
2815
  /**
2859
- @deprecated Use `providerMetadata` instead.
2860
- */
2861
- readonly experimental_providerMetadata: ProviderMetadata | undefined;
2862
- /**
2863
2816
  The type of step that this result is for. The first step is always
2864
2817
  an "initial" step, and subsequent steps are either "continue" steps
2865
2818
  or "tool-result" steps.
@@ -2963,13 +2916,9 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
2963
2916
  results that can be fully encapsulated in the provider.
2964
2917
  */
2965
2918
  readonly providerMetadata: ProviderMetadata | undefined;
2966
- /**
2967
- @deprecated Use `providerMetadata` instead.
2968
- */
2969
- readonly experimental_providerMetadata: ProviderMetadata | undefined;
2970
2919
  }
2971
2920
 
2972
- interface Output<OUTPUT, PARTIAL> {
2921
+ interface Output$1<OUTPUT, PARTIAL> {
2973
2922
  readonly type: 'object' | 'text';
2974
2923
  injectIntoSystemPrompt(options: {
2975
2924
  system: string | undefined;
@@ -2991,17 +2940,16 @@ interface Output<OUTPUT, PARTIAL> {
2991
2940
  finishReason: FinishReason;
2992
2941
  }): OUTPUT;
2993
2942
  }
2994
- declare const text: () => Output<string, string>;
2943
+ declare const text: () => Output$1<string, string>;
2995
2944
  declare const object: <OUTPUT>({ schema: inputSchema, }: {
2996
2945
  schema: z.Schema<OUTPUT, z.ZodTypeDef, any> | Schema<OUTPUT>;
2997
- }) => Output<OUTPUT, DeepPartial<OUTPUT>>;
2946
+ }) => Output$1<OUTPUT, DeepPartial<OUTPUT>>;
2998
2947
 
2999
- type output_Output<OUTPUT, PARTIAL> = Output<OUTPUT, PARTIAL>;
3000
2948
  declare const output_object: typeof object;
3001
2949
  declare const output_text: typeof text;
3002
2950
  declare namespace output {
3003
2951
  export {
3004
- output_Output as Output,
2952
+ Output$1 as Output,
3005
2953
  output_object as object,
3006
2954
  output_text as text,
3007
2955
  };
@@ -3086,13 +3034,13 @@ declare function convertToCoreMessages<TOOLS extends ToolSet = never>(messages:
3086
3034
  type ToolCallRepairFunction<TOOLS extends ToolSet> = (options: {
3087
3035
  system: string | undefined;
3088
3036
  messages: CoreMessage[];
3089
- toolCall: LanguageModelV2FunctionToolCall;
3037
+ toolCall: LanguageModelV2ToolCall;
3090
3038
  tools: TOOLS;
3091
3039
  parameterSchema: (options: {
3092
3040
  toolName: string;
3093
3041
  }) => JSONSchema7$1;
3094
3042
  error: NoSuchToolError | InvalidToolArgumentsError;
3095
- }) => Promise<LanguageModelV2FunctionToolCall | null>;
3043
+ }) => Promise<LanguageModelV2ToolCall | null>;
3096
3044
 
3097
3045
  /**
3098
3046
  Callback that is set using the `onStepFinish` option.
@@ -3114,7 +3062,7 @@ This function does not stream the output. If you want to stream the output, use
3114
3062
  @param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
3115
3063
  @param messages - A list of messages. You can either use `prompt` or `messages` but not both.
3116
3064
 
3117
- @param maxTokens - Maximum number of tokens to generate.
3065
+ @param maxOutputTokens - Maximum number of tokens to generate.
3118
3066
  @param temperature - Temperature setting.
3119
3067
  The value is passed through to the provider. The range depends on the provider and model.
3120
3068
  It is recommended to set either `temperature` or `topP`, but not both.
@@ -3147,7 +3095,7 @@ If set and supported by the model, calls will generate deterministic results.
3147
3095
  @returns
3148
3096
  A result object that contains the generated text, the results of the tool calls, and additional information.
3149
3097
  */
3150
- declare function generateText<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never>({ model, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, headers, maxSteps, experimental_generateMessageId: generateMessageId, experimental_output: output, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata, providerOptions, experimental_activeTools: activeTools, experimental_repairToolCall: repairToolCall, _internal: { generateId, currentDate, }, onStepFinish, ...settings }: CallSettings & Prompt & {
3098
+ declare function generateText<TOOLS extends ToolSet, OUTPUT = never, OUTPUT_PARTIAL = never>({ model, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, headers, maxSteps, experimental_generateMessageId: generateMessageId, experimental_output: output, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, providerOptions, experimental_activeTools: activeTools, experimental_repairToolCall: repairToolCall, _internal: { generateId, currentDate, }, onStepFinish, ...settings }: CallSettings & Prompt & {
3151
3099
  /**
3152
3100
  The language model to use.
3153
3101
  */
@@ -3189,10 +3137,6 @@ functionality that can be fully encapsulated in the provider.
3189
3137
  */
3190
3138
  providerOptions?: ProviderOptions;
3191
3139
  /**
3192
- @deprecated Use `providerOptions` instead.
3193
- */
3194
- experimental_providerMetadata?: ProviderMetadata;
3195
- /**
3196
3140
  Limits the tools that are available for the model to call without
3197
3141
  changing the tool call and result types in the result.
3198
3142
  */
@@ -3200,7 +3144,7 @@ changing the tool call and result types in the result.
3200
3144
  /**
3201
3145
  Optional specification for parsing structured outputs from the LLM response.
3202
3146
  */
3203
- experimental_output?: Output<OUTPUT, OUTPUT_PARTIAL>;
3147
+ experimental_output?: Output$1<OUTPUT, OUTPUT_PARTIAL>;
3204
3148
  /**
3205
3149
  A function that attempts to repair a tool call that failed to parse.
3206
3150
  */
@@ -3317,10 +3261,6 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
3317
3261
  */
3318
3262
  readonly providerMetadata: Promise<ProviderMetadata | undefined>;
3319
3263
  /**
3320
- @deprecated Use `providerMetadata` instead.
3321
- */
3322
- readonly experimental_providerMetadata: Promise<ProviderMetadata | undefined>;
3323
- /**
3324
3264
  The full text that has been generated by the last step.
3325
3265
 
3326
3266
  Resolved when the response is finished.
@@ -3474,23 +3414,26 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
3474
3414
  toTextStreamResponse(init?: ResponseInit): Response;
3475
3415
  }
3476
3416
  type TextStreamPart<TOOLS extends ToolSet> = {
3477
- type: 'text-delta';
3478
- textDelta: string;
3417
+ type: 'text';
3418
+ text: string;
3479
3419
  } | {
3480
3420
  type: 'reasoning';
3481
- textDelta: string;
3421
+ reasoningType: 'text';
3422
+ text: string;
3482
3423
  } | {
3483
- type: 'reasoning-signature';
3424
+ type: 'reasoning';
3425
+ reasoningType: 'signature';
3484
3426
  signature: string;
3485
3427
  } | {
3486
- type: 'redacted-reasoning';
3428
+ type: 'reasoning';
3429
+ reasoningType: 'redacted';
3487
3430
  data: string;
3488
- } | {
3489
- type: 'source';
3490
- source: Source;
3491
3431
  } | ({
3432
+ type: 'source';
3433
+ } & Source) | {
3492
3434
  type: 'file';
3493
- } & GeneratedFile) | ({
3435
+ file: GeneratedFile;
3436
+ } | ({
3494
3437
  type: 'tool-call';
3495
3438
  } & ToolCallUnion<TOOLS>) | {
3496
3439
  type: 'tool-call-streaming-start';
@@ -3518,20 +3461,12 @@ type TextStreamPart<TOOLS extends ToolSet> = {
3518
3461
  usage: LanguageModelUsage$1;
3519
3462
  finishReason: FinishReason;
3520
3463
  providerMetadata: ProviderMetadata | undefined;
3521
- /**
3522
- * @deprecated Use `providerMetadata` instead.
3523
- */
3524
- experimental_providerMetadata?: ProviderMetadata;
3525
3464
  isContinued: boolean;
3526
3465
  } | {
3527
3466
  type: 'finish';
3528
3467
  finishReason: FinishReason;
3529
3468
  usage: LanguageModelUsage$1;
3530
3469
  providerMetadata: ProviderMetadata | undefined;
3531
- /**
3532
- * @deprecated Use `providerMetadata` instead.
3533
- */
3534
- experimental_providerMetadata?: ProviderMetadata;
3535
3470
  /**
3536
3471
  * @deprecated will be moved into provider metadata
3537
3472
  */
@@ -3605,7 +3540,7 @@ Callback that is set using the `onChunk` option.
3605
3540
  */
3606
3541
  type StreamTextOnChunkCallback<TOOLS extends ToolSet> = (event: {
3607
3542
  chunk: Extract<TextStreamPart<TOOLS>, {
3608
- type: 'text-delta' | 'reasoning' | 'source' | 'tool-call' | 'tool-call-streaming-start' | 'tool-call-delta' | 'tool-result';
3543
+ type: 'text' | 'reasoning' | 'source' | 'tool-call' | 'tool-call-streaming-start' | 'tool-call-delta' | 'tool-result';
3609
3544
  }>;
3610
3545
  }) => Promise<void> | void;
3611
3546
  /**
@@ -3631,7 +3566,7 @@ This function streams the output. If you do not want to stream the output, use `
3631
3566
  @param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
3632
3567
  @param messages - A list of messages. You can either use `prompt` or `messages` but not both.
3633
3568
 
3634
- @param maxTokens - Maximum number of tokens to generate.
3569
+ @param maxOutputTokens - Maximum number of tokens to generate.
3635
3570
  @param temperature - Temperature setting.
3636
3571
  The value is passed through to the provider. The range depends on the provider and model.
3637
3572
  It is recommended to set either `temperature` or `topP`, but not both.
@@ -3668,7 +3603,7 @@ If set and supported by the model, calls will generate deterministic results.
3668
3603
  @return
3669
3604
  A result object for accessing different stream types and additional information.
3670
3605
  */
3671
- declare function streamText<TOOLS extends ToolSet, OUTPUT = never, PARTIAL_OUTPUT = never>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxSteps, experimental_generateMessageId: generateMessageId, experimental_output: output, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, experimental_providerMetadata, providerOptions, experimental_toolCallStreaming, toolCallStreaming, experimental_activeTools: activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, onChunk, onError, onFinish, onStepFinish, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
3606
+ declare function streamText<TOOLS extends ToolSet, OUTPUT = never, PARTIAL_OUTPUT = never>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxSteps, experimental_generateMessageId: generateMessageId, experimental_output: output, experimental_continueSteps: continueSteps, experimental_telemetry: telemetry, providerOptions, experimental_toolCallStreaming, toolCallStreaming, experimental_activeTools: activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, onChunk, onError, onFinish, onStepFinish, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
3672
3607
  /**
3673
3608
  The language model to use.
3674
3609
  */
@@ -3710,10 +3645,6 @@ functionality that can be fully encapsulated in the provider.
3710
3645
  */
3711
3646
  providerOptions?: ProviderOptions;
3712
3647
  /**
3713
- @deprecated Use `providerOptions` instead.
3714
- */
3715
- experimental_providerMetadata?: ProviderMetadata;
3716
- /**
3717
3648
  Limits the tools that are available for the model to call without
3718
3649
  changing the tool call and result types in the result.
3719
3650
  */
@@ -3721,7 +3652,7 @@ changing the tool call and result types in the result.
3721
3652
  /**
3722
3653
  Optional specification for parsing structured outputs from the LLM response.
3723
3654
  */
3724
- experimental_output?: Output<OUTPUT, PARTIAL_OUTPUT>;
3655
+ experimental_output?: Output$1<OUTPUT, PARTIAL_OUTPUT>;
3725
3656
  /**
3726
3657
  A function that attempts to repair a tool call that failed to parse.
3727
3658
  */
@@ -3916,10 +3847,6 @@ interface GenerateObjectResult<OBJECT> {
3916
3847
  */
3917
3848
  readonly providerMetadata: ProviderMetadata | undefined;
3918
3849
  /**
3919
- @deprecated Use `providerMetadata` instead.
3920
- */
3921
- readonly experimental_providerMetadata: ProviderMetadata | undefined;
3922
- /**
3923
3850
  Converts the object to a JSON response.
3924
3851
  The response will have a status code of 200 and a content type of `application/json; charset=utf-8`.
3925
3852
  */
@@ -3944,98 +3871,29 @@ This function does not stream the output. If you want to stream the output, use
3944
3871
  @returns
3945
3872
  A result object that contains the generated object, the finish reason, the token usage, and additional information.
3946
3873
  */
3947
- declare function generateObject<OBJECT>(options: Omit<CallSettings, 'stopSequences'> & Prompt & {
3948
- output?: 'object' | undefined;
3874
+ declare function generateObject<TYPE extends SCHEMA extends z.Schema ? Output extends 'array' ? Array<z.infer<SCHEMA>> : z.infer<SCHEMA> : SCHEMA extends Schema<infer T> ? Output extends 'array' ? Array<T> : T : never, SCHEMA extends z.Schema | Schema = z.Schema<JSONValue$1>, Output extends 'object' | 'array' | 'enum' | 'no-schema' = TYPE extends string ? 'enum' : 'object'>(options: Omit<CallSettings, 'stopSequences'> & Prompt & (Output extends 'enum' ? {
3949
3875
  /**
3950
- The language model to use.
3951
- */
3952
- model: LanguageModel;
3876
+ The enum values that the model should use.
3877
+ */
3878
+ enum: Array<TYPE>;
3879
+ mode?: 'json';
3880
+ output: 'enum';
3881
+ } : Output extends 'no-schema' ? {} : {
3953
3882
  /**
3954
3883
  The schema of the object that the model should generate.
3955
- */
3956
- schema: z.Schema<OBJECT, z.ZodTypeDef, any> | Schema<OBJECT>;
3884
+ */
3885
+ schema: SCHEMA;
3957
3886
  /**
3958
3887
  Optional name of the output that should be generated.
3959
3888
  Used by some providers for additional LLM guidance, e.g.
3960
3889
  via tool or schema name.
3961
- */
3890
+ */
3962
3891
  schemaName?: string;
3963
3892
  /**
3964
3893
  Optional description of the output that should be generated.
3965
3894
  Used by some providers for additional LLM guidance, e.g.
3966
3895
  via tool or schema description.
3967
- */
3968
- schemaDescription?: string;
3969
- /**
3970
- The mode to use for object generation.
3971
-
3972
- The schema is converted into a JSON schema and used in one of the following ways
3973
-
3974
- - 'auto': The provider will choose the best mode for the model.
3975
- - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
3976
- - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
3977
-
3978
- Please note that most providers do not support all modes.
3979
-
3980
- Default and recommended: 'auto' (best mode for the model).
3981
- */
3982
- mode?: 'auto' | 'json' | 'tool';
3983
- /**
3984
- A function that attempts to repair the raw output of the mode
3985
- to enable JSON parsing.
3986
- */
3987
- experimental_repairText?: RepairTextFunction;
3988
- /**
3989
- Optional telemetry configuration (experimental).
3990
- */
3991
- experimental_telemetry?: TelemetrySettings;
3992
- /**
3993
- Additional provider-specific options. They are passed through
3994
- to the provider from the AI SDK and enable provider-specific
3995
- functionality that can be fully encapsulated in the provider.
3996
- */
3997
- providerOptions?: ProviderOptions;
3998
- /**
3999
- @deprecated Use `providerOptions` instead.
4000
- */
4001
- experimental_providerMetadata?: ProviderMetadata;
4002
- /**
4003
- * Internal. For test use only. May change without notice.
4004
- */
4005
- _internal?: {
4006
- generateId?: () => string;
4007
- currentDate?: () => Date;
4008
- };
4009
- }): Promise<GenerateObjectResult<OBJECT>>;
4010
- /**
4011
- Generate an array with structured, typed elements for a given prompt and element schema using a language model.
4012
-
4013
- This function does not stream the output. If you want to stream the output, use `streamObject` instead.
4014
-
4015
- @return
4016
- A result object that contains the generated object, the finish reason, the token usage, and additional information.
4017
- */
4018
- declare function generateObject<ELEMENT>(options: Omit<CallSettings, 'stopSequences'> & Prompt & {
4019
- output: 'array';
4020
- /**
4021
- The language model to use.
4022
- */
4023
- model: LanguageModel;
4024
- /**
4025
- The element schema of the array that the model should generate.
4026
- */
4027
- schema: z.Schema<ELEMENT, z.ZodTypeDef, any> | Schema<ELEMENT>;
4028
- /**
4029
- Optional name of the array that should be generated.
4030
- Used by some providers for additional LLM guidance, e.g.
4031
- via tool or schema name.
4032
- */
4033
- schemaName?: string;
4034
- /**
4035
- Optional description of the array that should be generated.
4036
- Used by some providers for additional LLM guidance, e.g.
4037
- via tool or schema description.
4038
- */
3896
+ */
4039
3897
  schemaDescription?: string;
4040
3898
  /**
4041
3899
  The mode to use for object generation.
@@ -4049,113 +3907,15 @@ The schema is converted into a JSON schema and used in one of the following ways
4049
3907
  Please note that most providers do not support all modes.
4050
3908
 
4051
3909
  Default and recommended: 'auto' (best mode for the model).
4052
- */
4053
- mode?: 'auto' | 'json' | 'tool';
4054
- /**
4055
- A function that attempts to repair the raw output of the mode
4056
- to enable JSON parsing.
4057
- */
4058
- experimental_repairText?: RepairTextFunction;
4059
- /**
4060
- Optional telemetry configuration (experimental).
4061
- */
4062
- experimental_telemetry?: TelemetrySettings;
4063
- /**
4064
- Additional provider-specific options. They are passed through
4065
- to the provider from the AI SDK and enable provider-specific
4066
- functionality that can be fully encapsulated in the provider.
4067
- */
4068
- providerOptions?: ProviderOptions;
4069
- /**
4070
- @deprecated Use `providerOptions` instead.
4071
- */
4072
- experimental_providerMetadata?: ProviderMetadata;
4073
- /**
4074
- * Internal. For test use only. May change without notice.
4075
- */
4076
- _internal?: {
4077
- generateId?: () => string;
4078
- currentDate?: () => Date;
4079
- };
4080
- }): Promise<GenerateObjectResult<Array<ELEMENT>>>;
4081
- /**
4082
- Generate a value from an enum (limited list of string values) using a language model.
4083
-
4084
- This function does not stream the output.
4085
-
4086
- @return
4087
- A result object that contains the generated value, the finish reason, the token usage, and additional information.
4088
- */
4089
- declare function generateObject<ENUM extends string>(options: Omit<CallSettings, 'stopSequences'> & Prompt & {
4090
- output: 'enum';
4091
- /**
4092
- The language model to use.
4093
- */
4094
- model: LanguageModel;
4095
- /**
4096
- The enum values that the model should use.
4097
- */
4098
- enum: Array<ENUM>;
4099
- /**
4100
- The mode to use for object generation.
4101
-
4102
- The schema is converted into a JSON schema and used in one of the following ways
4103
-
4104
- - 'auto': The provider will choose the best mode for the model.
4105
- - 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
4106
- - 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
4107
-
4108
- Please note that most providers do not support all modes.
4109
-
4110
- Default and recommended: 'auto' (best mode for the model).
4111
- */
3910
+ */
4112
3911
  mode?: 'auto' | 'json' | 'tool';
4113
- /**
4114
- A function that attempts to repair the raw output of the mode
4115
- to enable JSON parsing.
4116
- */
4117
- experimental_repairText?: RepairTextFunction;
4118
- /**
4119
- Optional telemetry configuration (experimental).
4120
- */
4121
- experimental_telemetry?: TelemetrySettings;
4122
- /**
4123
- Additional provider-specific options. They are passed through
4124
- to the provider from the AI SDK and enable provider-specific
4125
- functionality that can be fully encapsulated in the provider.
4126
- */
4127
- providerOptions?: ProviderOptions;
4128
- /**
4129
- @deprecated Use `providerOptions` instead.
4130
- */
4131
- experimental_providerMetadata?: ProviderMetadata;
4132
- /**
4133
- * Internal. For test use only. May change without notice.
4134
- */
4135
- _internal?: {
4136
- generateId?: () => string;
4137
- currentDate?: () => Date;
4138
- };
4139
- }): Promise<GenerateObjectResult<ENUM>>;
4140
- /**
4141
- Generate JSON with any schema for a given prompt using a language model.
4142
-
4143
- This function does not stream the output. If you want to stream the output, use `streamObject` instead.
4144
-
4145
- @returns
4146
- A result object that contains the generated object, the finish reason, the token usage, and additional information.
4147
- */
4148
- declare function generateObject(options: Omit<CallSettings, 'stopSequences'> & Prompt & {
4149
- output: 'no-schema';
3912
+ }) & {
3913
+ output?: Output;
4150
3914
  /**
4151
3915
  The language model to use.
4152
3916
  */
4153
3917
  model: LanguageModel;
4154
3918
  /**
4155
- The mode to use for object generation. Must be "json" for no-schema output.
4156
- */
4157
- mode?: 'json';
4158
- /**
4159
3919
  A function that attempts to repair the raw output of the mode
4160
3920
  to enable JSON parsing.
4161
3921
  */
@@ -4171,17 +3931,13 @@ functionality that can be fully encapsulated in the provider.
4171
3931
  */
4172
3932
  providerOptions?: ProviderOptions;
4173
3933
  /**
4174
- @deprecated Use `providerOptions` instead.
4175
- */
4176
- experimental_providerMetadata?: ProviderMetadata;
4177
- /**
4178
3934
  * Internal. For test use only. May change without notice.
4179
3935
  */
4180
3936
  _internal?: {
4181
3937
  generateId?: () => string;
4182
3938
  currentDate?: () => Date;
4183
3939
  };
4184
- }): Promise<GenerateObjectResult<JSONValue$1>>;
3940
+ }): Promise<GenerateObjectResult<TYPE>>;
4185
3941
 
4186
3942
  /**
4187
3943
  The result of a `streamObject` call that contains the partial object stream and additional information.
@@ -4202,10 +3958,6 @@ interface StreamObjectResult<PARTIAL, RESULT, ELEMENT_STREAM> {
4202
3958
  */
4203
3959
  readonly providerMetadata: Promise<ProviderMetadata | undefined>;
4204
3960
  /**
4205
- @deprecated Use `providerMetadata` instead.
4206
- */
4207
- readonly experimental_providerMetadata: Promise<ProviderMetadata | undefined>;
4208
- /**
4209
3961
  Additional request information from the last step.
4210
3962
  */
4211
3963
  readonly request: Promise<LanguageModelRequestMetadata>;
@@ -4315,10 +4067,6 @@ type StreamObjectOnFinishCallback<RESULT> = (event: {
4315
4067
  functionality that can be fully encapsulated in the provider.
4316
4068
  */
4317
4069
  providerMetadata: ProviderMetadata | undefined;
4318
- /**
4319
- @deprecated Use `providerMetadata` instead.
4320
- */
4321
- experimental_providerMetadata?: ProviderMetadata;
4322
4070
  }) => Promise<void> | void;
4323
4071
  /**
4324
4072
  Generate a structured, typed object for a given prompt and schema using a language model.
@@ -4375,10 +4123,6 @@ functionality that can be fully encapsulated in the provider.
4375
4123
  */
4376
4124
  providerOptions?: ProviderOptions;
4377
4125
  /**
4378
- @deprecated Use `providerOptions` instead.
4379
- */
4380
- experimental_providerMetadata?: ProviderMetadata;
4381
- /**
4382
4126
  Callback that is invoked when an error occurs during streaming.
4383
4127
  You can use it to log errors.
4384
4128
  The stream processing will pause until the callback promise is resolved.
@@ -4452,10 +4196,6 @@ functionality that can be fully encapsulated in the provider.
4452
4196
  */
4453
4197
  providerOptions?: ProviderOptions;
4454
4198
  /**
4455
- @deprecated Use `providerOptions` instead.
4456
- */
4457
- experimental_providerMetadata?: ProviderMetadata;
4458
- /**
4459
4199
  Callback that is invoked when an error occurs during streaming.
4460
4200
  You can use it to log errors.
4461
4201
  The stream processing will pause until the callback promise is resolved.
@@ -4503,10 +4243,6 @@ functionality that can be fully encapsulated in the provider.
4503
4243
  */
4504
4244
  providerOptions?: ProviderOptions;
4505
4245
  /**
4506
- @deprecated Use `providerOptions` instead.
4507
- */
4508
- experimental_providerMetadata?: ProviderMetadata;
4509
- /**
4510
4246
  Callback that is invoked when an error occurs during streaming.
4511
4247
  You can use it to log errors.
4512
4248
  The stream processing will pause until the callback promise is resolved.
@@ -4657,7 +4393,7 @@ declare function transcribe({ model, audio, providerOptions, maxRetries: maxRetr
4657
4393
  */
4658
4394
  declare function defaultSettingsMiddleware({ settings, }: {
4659
4395
  settings: Partial<LanguageModelV2CallOptions & {
4660
- providerOptions?: LanguageModelV2ProviderOptions;
4396
+ providerOptions?: SharedV2ProviderOptions;
4661
4397
  }>;
4662
4398
  }): LanguageModelV2Middleware;
4663
4399
 
@@ -4777,21 +4513,13 @@ declare const experimental_createProviderRegistry: typeof createProviderRegistry
4777
4513
  *
4778
4514
  * @param vector1 - The first vector.
4779
4515
  * @param vector2 - The second vector.
4780
- * @param options - Optional configuration.
4781
- * @param options.throwErrorForEmptyVectors - If true, throws an error for empty vectors. Default: false.
4782
4516
  *
4783
4517
  * @returns The cosine similarity between vector1 and vector2.
4784
4518
  * @returns 0 if either vector is the zero vector.
4785
4519
  *
4786
- * @throws {InvalidArgumentError} If throwErrorForEmptyVectors is true and vectors are empty.
4787
4520
  * @throws {InvalidArgumentError} If the vectors do not have the same length.
4788
4521
  */
4789
- declare function cosineSimilarity(vector1: number[], vector2: number[], options?: {
4790
- /**
4791
- * @deprecated will be removed in 5.0
4792
- */
4793
- throwErrorForEmptyVectors?: boolean;
4794
- }): number;
4522
+ declare function cosineSimilarity(vector1: number[], vector2: number[]): number;
4795
4523
 
4796
4524
  /**
4797
4525
  * Creates a ReadableStream that emits the provided values with an optional delay between each value.
@@ -4825,23 +4553,26 @@ declare class InvalidArgumentError extends AISDKError {
4825
4553
  }
4826
4554
 
4827
4555
  type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
4828
- type: 'text-delta';
4829
- textDelta: string;
4556
+ type: 'text';
4557
+ text: string;
4830
4558
  } | {
4831
4559
  type: 'reasoning';
4832
- textDelta: string;
4560
+ reasoningType: 'text';
4561
+ text: string;
4833
4562
  } | {
4834
- type: 'reasoning-signature';
4563
+ type: 'reasoning';
4564
+ reasoningType: 'signature';
4835
4565
  signature: string;
4836
4566
  } | {
4837
- type: 'redacted-reasoning';
4567
+ type: 'reasoning';
4568
+ reasoningType: 'redacted';
4838
4569
  data: string;
4839
- } | ({
4570
+ } | {
4840
4571
  type: 'file';
4841
- } & GeneratedFile) | {
4842
- type: 'source';
4843
- source: Source;
4572
+ file: GeneratedFile;
4844
4573
  } | ({
4574
+ type: 'source';
4575
+ } & Source) | ({
4845
4576
  type: 'tool-call';
4846
4577
  } & ToolCallUnion<TOOLS>) | {
4847
4578
  type: 'tool-call-streaming-start';
@@ -4864,7 +4595,7 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
4864
4595
  finishReason: FinishReason;
4865
4596
  logprobs?: LogProbs;
4866
4597
  usage: LanguageModelUsage$1;
4867
- experimental_providerMetadata?: ProviderMetadata;
4598
+ providerMetadata?: ProviderMetadata;
4868
4599
  } | {
4869
4600
  type: 'error';
4870
4601
  error: unknown;
@@ -4971,11 +4702,11 @@ declare const symbol$6: unique symbol;
4971
4702
  declare class ToolExecutionError extends AISDKError {
4972
4703
  private readonly [symbol$6];
4973
4704
  readonly toolName: string;
4974
- readonly toolArgs: JSONValue$1;
4705
+ readonly toolArgs: JSONValue$1 | unknown;
4975
4706
  readonly toolCallId: string;
4976
4707
  constructor({ toolArgs, toolName, toolCallId, cause, message, }: {
4977
4708
  message?: string;
4978
- toolArgs: JSONValue$1;
4709
+ toolArgs: JSONValue$1 | unknown;
4979
4710
  toolName: string;
4980
4711
  toolCallId: string;
4981
4712
  cause: unknown;
@@ -5158,4 +4889,4 @@ declare namespace llamaindexAdapter {
5158
4889
  };
5159
4890
  }
5160
4891
 
5161
- export { AssistantContent, Attachment, CallSettings, CallWarning, ChatRequest, ChatRequestOptions, ChunkDetector, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolCallUnion, CoreToolChoice, CoreToolMessage, CoreToolResultUnion, CoreUserMessage, CreateMessage, DataContent, DataStreamOptions, DataStreamPart, DataStreamString, DataStreamWriter, DeepPartial, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedFile, IdGenerator, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelResponseMetadata, ImagePart, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, langchainAdapter as LangChainAdapter, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage$1 as LanguageModelUsage, llamaindexAdapter as LlamaIndexAdapter, LogProbs, MCPClientError, MCPTransport, Message, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RequestOptions, RetryError, Schema, SourceUIPart, StepResult, StepStartUIPart, StreamData, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextPart, TextStreamPart, TextUIPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolResultPart, ToolResultUnion, ToolSet, UIMessage, UseChatOptions, UseCompletionOptions, UserContent, appendClientMessage, appendResponseMessages, asSchema, callChatApi, callCompletionApi, convertToCoreMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDataStream, createDataStreamResponse, createProviderRegistry, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, transcribe as experimental_transcribe, experimental_wrapLanguageModel, extractMaxToolInvocationStep, extractReasoningMiddleware, fillMessageParts, formatDataStreamPart, generateObject, generateText, getMessageParts, getTextFromDataUrl, isAssistantMessageWithCompletedToolCalls, isDeepEqualData, jsonSchema, parseDataStreamPart, parsePartialJson, pipeDataStreamToResponse, prepareAttachmentsForRequest, processDataStream, processTextStream, shouldResubmitMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, streamObject, streamText, tool, updateToolCallResult, wrapLanguageModel, zodSchema };
4892
+ export { AssistantContent, Attachment, CallSettings, CallWarning, ChatRequest, ChatRequestOptions, ChunkDetector, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateMessage, DataContent, DataStreamOptions, DataStreamPart, DataStreamString, DataStreamWriter, DeepPartial, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedFile, IdGenerator, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelResponseMetadata, ImagePart, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, langchainAdapter as LangChainAdapter, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage$1 as LanguageModelUsage, llamaindexAdapter as LlamaIndexAdapter, LogProbs, MCPClientError, MCPTransport, Message, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RequestOptions, RetryError, Schema, SourceUIPart, StepResult, StepStartUIPart, StreamData, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextPart, TextStreamPart, TextUIPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolResultPart, ToolResultUnion, ToolSet, UIMessage, UseChatOptions, UseCompletionOptions, UserContent, appendClientMessage, appendResponseMessages, asSchema, callChatApi, callCompletionApi, convertToCoreMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDataStream, createDataStreamResponse, createProviderRegistry, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, transcribe as experimental_transcribe, experimental_wrapLanguageModel, extractMaxToolInvocationStep, extractReasoningMiddleware, fillMessageParts, formatDataStreamPart, generateObject, generateText, getMessageParts, getTextFromDataUrl, isAssistantMessageWithCompletedToolCalls, isDeepEqualData, jsonSchema, parseDataStreamPart, parsePartialJson, pipeDataStreamToResponse, prepareAttachmentsForRequest, processDataStream, processTextStream, shouldResubmitMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, streamObject, streamText, tool, updateToolCallResult, wrapLanguageModel, zodSchema };