ai 5.0.0-canary.6 → 5.0.0-canary.7
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 +20 -0
- package/dist/index.d.mts +166 -446
- package/dist/index.d.ts +166 -446
- package/dist/index.js +283 -297
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +203 -217
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +259 -311
- package/dist/internal/index.d.ts +259 -311
- package/dist/internal/index.js +139 -155
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +129 -145
- package/dist/internal/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
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';
|
3
|
+
import { EmbeddingModelV1, EmbeddingModelV1Embedding, ImageModelV1, ImageModelV1CallWarning, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2LogProbs, LanguageModelV2CallWarning, LanguageModelV2Source, LanguageModelV2ProviderMetadata, JSONValue as JSONValue$1, JSONObject, LanguageModelV2CallOptions, AISDKError, LanguageModelV2FunctionToolCall, JSONSchema7 as JSONSchema7$1, JSONParseError, TypeValidationError, TranscriptionModelV1CallWarning, TranscriptionModelV1, LanguageModelV2ProviderOptions, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
4
4
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Prompt, LanguageModelV2StreamPart, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
5
5
|
import { ServerResponse } from 'node:http';
|
6
6
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
@@ -83,7 +83,7 @@ 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
88
|
/**
|
89
89
|
* @deprecated Use `ToolChoice` instead.
|
@@ -870,7 +870,7 @@ declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7, { validat
|
|
870
870
|
error: Error;
|
871
871
|
};
|
872
872
|
}): Schema<OBJECT>;
|
873
|
-
declare function asSchema<OBJECT>(schema: z.Schema<OBJECT, z.ZodTypeDef, any> | Schema<OBJECT>): Schema<OBJECT>;
|
873
|
+
declare function asSchema<OBJECT>(schema: z.Schema<OBJECT, z.ZodTypeDef, any> | Schema<OBJECT> | undefined): Schema<OBJECT>;
|
874
874
|
|
875
875
|
declare function shouldResubmitMessages({ originalMaxToolInvocationStep, originalMessageCount, maxSteps, messages, }: {
|
876
876
|
originalMaxToolInvocationStep: number | undefined;
|
@@ -1131,7 +1131,7 @@ type CallSettings = {
|
|
1131
1131
|
/**
|
1132
1132
|
Maximum number of tokens to generate.
|
1133
1133
|
*/
|
1134
|
-
|
1134
|
+
maxOutputTokens?: number;
|
1135
1135
|
/**
|
1136
1136
|
Temperature setting. This is a number between 0 (almost no randomness) and
|
1137
1137
|
1 (very random).
|
@@ -1234,10 +1234,6 @@ interface TextPart {
|
|
1234
1234
|
functionality that can be fully encapsulated in the provider.
|
1235
1235
|
*/
|
1236
1236
|
providerOptions?: ProviderOptions;
|
1237
|
-
/**
|
1238
|
-
@deprecated Use `providerOptions` instead.
|
1239
|
-
*/
|
1240
|
-
experimental_providerMetadata?: ProviderMetadata;
|
1241
1237
|
}
|
1242
1238
|
/**
|
1243
1239
|
Image content part of a prompt. It contains an image.
|
@@ -1267,10 +1263,6 @@ interface ImagePart {
|
|
1267
1263
|
functionality that can be fully encapsulated in the provider.
|
1268
1264
|
*/
|
1269
1265
|
providerOptions?: ProviderOptions;
|
1270
|
-
/**
|
1271
|
-
@deprecated Use `providerOptions` instead.
|
1272
|
-
*/
|
1273
|
-
experimental_providerMetadata?: ProviderMetadata;
|
1274
1266
|
}
|
1275
1267
|
/**
|
1276
1268
|
File content part of a prompt. It contains a file.
|
@@ -1304,10 +1296,6 @@ interface FilePart {
|
|
1304
1296
|
functionality that can be fully encapsulated in the provider.
|
1305
1297
|
*/
|
1306
1298
|
providerOptions?: ProviderOptions;
|
1307
|
-
/**
|
1308
|
-
@deprecated Use `providerOptions` instead.
|
1309
|
-
*/
|
1310
|
-
experimental_providerMetadata?: ProviderMetadata;
|
1311
1299
|
}
|
1312
1300
|
/**
|
1313
1301
|
* Reasoning content part of a prompt. It contains a reasoning.
|
@@ -1328,10 +1316,6 @@ interface ReasoningPart {
|
|
1328
1316
|
functionality that can be fully encapsulated in the provider.
|
1329
1317
|
*/
|
1330
1318
|
providerOptions?: ProviderOptions;
|
1331
|
-
/**
|
1332
|
-
@deprecated Use `providerOptions` instead.
|
1333
|
-
*/
|
1334
|
-
experimental_providerMetadata?: ProviderMetadata;
|
1335
1319
|
}
|
1336
1320
|
/**
|
1337
1321
|
Redacted reasoning content part of a prompt.
|
@@ -1348,10 +1332,6 @@ interface RedactedReasoningPart {
|
|
1348
1332
|
functionality that can be fully encapsulated in the provider.
|
1349
1333
|
*/
|
1350
1334
|
providerOptions?: ProviderOptions;
|
1351
|
-
/**
|
1352
|
-
@deprecated Use `providerOptions` instead.
|
1353
|
-
*/
|
1354
|
-
experimental_providerMetadata?: ProviderMetadata;
|
1355
1335
|
}
|
1356
1336
|
/**
|
1357
1337
|
Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
@@ -1376,10 +1356,6 @@ interface ToolCallPart {
|
|
1376
1356
|
functionality that can be fully encapsulated in the provider.
|
1377
1357
|
*/
|
1378
1358
|
providerOptions?: ProviderOptions;
|
1379
|
-
/**
|
1380
|
-
@deprecated Use `providerOptions` instead.
|
1381
|
-
*/
|
1382
|
-
experimental_providerMetadata?: ProviderMetadata;
|
1383
1359
|
}
|
1384
1360
|
/**
|
1385
1361
|
Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
@@ -1412,10 +1388,6 @@ interface ToolResultPart {
|
|
1412
1388
|
functionality that can be fully encapsulated in the provider.
|
1413
1389
|
*/
|
1414
1390
|
providerOptions?: ProviderOptions;
|
1415
|
-
/**
|
1416
|
-
@deprecated Use `providerOptions` instead.
|
1417
|
-
*/
|
1418
|
-
experimental_providerMetadata?: ProviderMetadata;
|
1419
1391
|
}
|
1420
1392
|
|
1421
1393
|
/**
|
@@ -1434,10 +1406,6 @@ type CoreSystemMessage = {
|
|
1434
1406
|
functionality that can be fully encapsulated in the provider.
|
1435
1407
|
*/
|
1436
1408
|
providerOptions?: ProviderOptions;
|
1437
|
-
/**
|
1438
|
-
@deprecated Use `providerOptions` instead.
|
1439
|
-
*/
|
1440
|
-
experimental_providerMetadata?: ProviderMetadata;
|
1441
1409
|
};
|
1442
1410
|
declare const coreSystemMessageSchema: z.ZodType<CoreSystemMessage>;
|
1443
1411
|
/**
|
@@ -1452,10 +1420,6 @@ type CoreUserMessage = {
|
|
1452
1420
|
functionality that can be fully encapsulated in the provider.
|
1453
1421
|
*/
|
1454
1422
|
providerOptions?: ProviderOptions;
|
1455
|
-
/**
|
1456
|
-
@deprecated Use `providerOptions` instead.
|
1457
|
-
*/
|
1458
|
-
experimental_providerMetadata?: ProviderMetadata;
|
1459
1423
|
};
|
1460
1424
|
declare const coreUserMessageSchema: z.ZodType<CoreUserMessage>;
|
1461
1425
|
/**
|
@@ -1474,10 +1438,6 @@ type CoreAssistantMessage = {
|
|
1474
1438
|
functionality that can be fully encapsulated in the provider.
|
1475
1439
|
*/
|
1476
1440
|
providerOptions?: ProviderOptions;
|
1477
|
-
/**
|
1478
|
-
@deprecated Use `providerOptions` instead.
|
1479
|
-
*/
|
1480
|
-
experimental_providerMetadata?: ProviderMetadata;
|
1481
1441
|
};
|
1482
1442
|
declare const coreAssistantMessageSchema: z.ZodType<CoreAssistantMessage>;
|
1483
1443
|
/**
|
@@ -1497,10 +1457,6 @@ type CoreToolMessage = {
|
|
1497
1457
|
functionality that can be fully encapsulated in the provider.
|
1498
1458
|
*/
|
1499
1459
|
providerOptions?: ProviderOptions;
|
1500
|
-
/**
|
1501
|
-
@deprecated Use `providerOptions` instead.
|
1502
|
-
*/
|
1503
|
-
experimental_providerMetadata?: ProviderMetadata;
|
1504
1460
|
};
|
1505
1461
|
declare const coreToolMessageSchema: z.ZodType<CoreToolMessage>;
|
1506
1462
|
/**
|
@@ -1562,133 +1518,6 @@ type ReasoningDetail = {
|
|
1562
1518
|
data: string;
|
1563
1519
|
};
|
1564
1520
|
|
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
1521
|
declare const JSONRPCRequestSchema: z.ZodObject<z.objectUtil.extendShape<{
|
1693
1522
|
jsonrpc: z.ZodLiteral<"2.0">;
|
1694
1523
|
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
@@ -1957,20 +1786,98 @@ type MCPTransportConfig = {
|
|
1957
1786
|
headers?: Record<string, string>;
|
1958
1787
|
};
|
1959
1788
|
|
1789
|
+
type ToolParameters<T = JSONObject> = z.Schema<T> | Schema<T>;
|
1790
|
+
interface ToolExecutionOptions {
|
1791
|
+
/**
|
1792
|
+
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
1793
|
+
*/
|
1794
|
+
toolCallId: string;
|
1795
|
+
/**
|
1796
|
+
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
1797
|
+
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
1798
|
+
*/
|
1799
|
+
messages: CoreMessage[];
|
1800
|
+
/**
|
1801
|
+
* An optional abort signal that indicates that the overall operation should be aborted.
|
1802
|
+
*/
|
1803
|
+
abortSignal?: AbortSignal;
|
1804
|
+
}
|
1805
|
+
type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
|
1806
|
+
/**
|
1807
|
+
A tool contains the description and the schema of the input that the tool expects.
|
1808
|
+
This enables the language model to generate the input.
|
1809
|
+
|
1810
|
+
The tool can also contain an optional execute function for the actual execution function of the tool.
|
1811
|
+
*/
|
1812
|
+
type Tool<PARAMETERS extends JSONValue$1 | unknown | never = any, RESULT = any> = {
|
1813
|
+
/**
|
1814
|
+
An optional description of what the tool does.
|
1815
|
+
Will be used by the language model to decide whether to use the tool.
|
1816
|
+
Not used for provider-defined tools.
|
1817
|
+
*/
|
1818
|
+
description?: string;
|
1819
|
+
} & NeverOptional<PARAMETERS, {
|
1820
|
+
/**
|
1821
|
+
The schema of the input that the tool expects. The language model will use this to generate the input.
|
1822
|
+
It is also used to validate the output of the language model.
|
1823
|
+
Use descriptions to make the input understandable for the language model.
|
1824
|
+
*/
|
1825
|
+
parameters: ToolParameters<PARAMETERS>;
|
1826
|
+
}> & NeverOptional<RESULT, {
|
1827
|
+
/**
|
1828
|
+
An async function that is called with the arguments from the tool call and produces a result.
|
1829
|
+
If not provided, the tool will not be executed automatically.
|
1830
|
+
|
1831
|
+
@args is the input of the tool call.
|
1832
|
+
@options.abortSignal is a signal that can be used to abort the tool call.
|
1833
|
+
*/
|
1834
|
+
execute: (args: [PARAMETERS] extends [never] ? undefined : PARAMETERS, options: ToolExecutionOptions) => PromiseLike<RESULT>;
|
1835
|
+
/**
|
1836
|
+
Optional conversion function that maps the tool result to multi-part tool content for LLMs.
|
1837
|
+
*/
|
1838
|
+
experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
|
1839
|
+
}> & ({
|
1840
|
+
/**
|
1841
|
+
Function tool.
|
1842
|
+
*/
|
1843
|
+
type?: undefined | 'function';
|
1844
|
+
} | {
|
1845
|
+
/**
|
1846
|
+
Provider-defined tool.
|
1847
|
+
*/
|
1848
|
+
type: 'provider-defined';
|
1849
|
+
/**
|
1850
|
+
The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
|
1851
|
+
*/
|
1852
|
+
id: `${string}.${string}`;
|
1853
|
+
/**
|
1854
|
+
The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
1855
|
+
*/
|
1856
|
+
args: Record<string, unknown>;
|
1857
|
+
});
|
1858
|
+
/**
|
1859
|
+
* @deprecated Use `Tool` instead.
|
1860
|
+
*/
|
1861
|
+
type CoreTool<PARAMETERS extends ToolParameters = any, RESULT = any> = Tool<PARAMETERS, RESULT>;
|
1862
|
+
/**
|
1863
|
+
Helper function for inferring the execute args of a tool.
|
1864
|
+
*/
|
1865
|
+
declare function tool(tool: Tool<never, never>): Tool<never, never>;
|
1866
|
+
declare function tool<PARAMETERS>(tool: Tool<PARAMETERS, never>): Tool<PARAMETERS, never>;
|
1867
|
+
declare function tool<RESULT>(tool: Tool<never, RESULT>): Tool<never, RESULT>;
|
1868
|
+
declare function tool<PARAMETERS, RESULT>(tool: Tool<PARAMETERS, RESULT>): Tool<PARAMETERS, RESULT>;
|
1869
|
+
type MappedTool<T extends Tool | JSONObject, RESULT extends any> = T extends Tool<infer P> ? Tool<P, RESULT> : T extends JSONObject ? Tool<T, RESULT> : never;
|
1870
|
+
|
1960
1871
|
type ToolSchemas = Record<string, {
|
1961
|
-
parameters: ToolParameters
|
1872
|
+
parameters: ToolParameters<JSONObject | unknown>;
|
1962
1873
|
}> | 'automatic' | undefined;
|
1963
1874
|
type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
|
1964
|
-
parameters: ToolParameters
|
1875
|
+
parameters: ToolParameters<any>;
|
1965
1876
|
}> ? {
|
1966
|
-
[K in keyof TOOL_SCHEMAS]:
|
1967
|
-
|
1968
|
-
|
1969
|
-
}
|
1970
|
-
[k: string]: Tool<z.ZodUnknown, CallToolResult> & {
|
1971
|
-
execute: (args: unknown, options: ToolExecutionOptions) => PromiseLike<CallToolResult>;
|
1972
|
-
};
|
1973
|
-
};
|
1877
|
+
[K in keyof TOOL_SCHEMAS]: MappedTool<TOOL_SCHEMAS[K], CallToolResult> & Required<Pick<MappedTool<TOOL_SCHEMAS[K], CallToolResult>, 'execute'>>;
|
1878
|
+
} : McpToolSet<Record<string, {
|
1879
|
+
parameters: ToolParameters<unknown>;
|
1880
|
+
}>>;
|
1974
1881
|
declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
|
1975
1882
|
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
1976
1883
|
}, {
|
@@ -2734,14 +2641,56 @@ declare class MCPClient {
|
|
2734
2641
|
private onResponse;
|
2735
2642
|
}
|
2736
2643
|
|
2737
|
-
|
2644
|
+
/**
|
2645
|
+
Create a union of the given object's values, and optionally specify which keys to get the values from.
|
2646
|
+
|
2647
|
+
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
|
2648
|
+
|
2649
|
+
@example
|
2650
|
+
```
|
2651
|
+
// data.json
|
2652
|
+
{
|
2653
|
+
'foo': 1,
|
2654
|
+
'bar': 2,
|
2655
|
+
'biz': 3
|
2656
|
+
}
|
2657
|
+
|
2658
|
+
// main.ts
|
2659
|
+
import type {ValueOf} from 'type-fest';
|
2660
|
+
import data = require('./data.json');
|
2661
|
+
|
2662
|
+
export function getData(name: string): ValueOf<typeof data> {
|
2663
|
+
return data[name];
|
2664
|
+
}
|
2665
|
+
|
2666
|
+
export function onlyBar(name: string): ValueOf<typeof data, 'bar'> {
|
2667
|
+
return data[name];
|
2668
|
+
}
|
2669
|
+
|
2670
|
+
// file.ts
|
2671
|
+
import {getData, onlyBar} from './main';
|
2672
|
+
|
2673
|
+
getData('foo');
|
2674
|
+
//=> 1
|
2675
|
+
|
2676
|
+
onlyBar('foo');
|
2677
|
+
//=> TypeError ...
|
2678
|
+
|
2679
|
+
onlyBar('bar');
|
2680
|
+
//=> 2
|
2681
|
+
```
|
2682
|
+
* @see https://github.com/sindresorhus/type-fest/blob/main/source/value-of.d.ts
|
2683
|
+
*/
|
2684
|
+
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
2685
|
+
|
2686
|
+
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute'>>;
|
2738
2687
|
|
2739
2688
|
type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
|
2740
2689
|
[NAME in keyof TOOLS]: {
|
2741
2690
|
type: 'tool-call';
|
2742
2691
|
toolCallId: string;
|
2743
2692
|
toolName: NAME & string;
|
2744
|
-
args:
|
2693
|
+
args: TOOLS[NAME] extends Tool<infer PARAMETERS> ? PARAMETERS : never;
|
2745
2694
|
};
|
2746
2695
|
}>;
|
2747
2696
|
/**
|
@@ -2750,11 +2699,6 @@ type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
|
|
2750
2699
|
type CoreToolCallUnion<TOOLS extends ToolSet> = ToolCallUnion<ToolSet>;
|
2751
2700
|
type ToolCallArray<TOOLS extends ToolSet> = Array<ToolCallUnion<TOOLS>>;
|
2752
2701
|
|
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
2702
|
type ToToolsWithDefinedExecute<TOOLS extends ToolSet> = {
|
2759
2703
|
[K in keyof TOOLS as TOOLS[K]['execute'] extends undefined ? never : K]: TOOLS[K];
|
2760
2704
|
};
|
@@ -2763,11 +2707,11 @@ type ToToolResultObject<TOOLS extends ToolSet> = ValueOf<{
|
|
2763
2707
|
type: 'tool-result';
|
2764
2708
|
toolCallId: string;
|
2765
2709
|
toolName: NAME & string;
|
2766
|
-
args:
|
2710
|
+
args: TOOLS[NAME] extends Tool<infer P> ? P : never;
|
2767
2711
|
result: Awaited<ReturnType<Exclude<TOOLS[NAME]['execute'], undefined>>>;
|
2768
2712
|
};
|
2769
2713
|
}>;
|
2770
|
-
type ToolResultUnion<TOOLS extends ToolSet> = ToToolResultObject<ToToolsWithDefinedExecute<
|
2714
|
+
type ToolResultUnion<TOOLS extends ToolSet> = ToToolResultObject<ToToolsWithDefinedExecute<TOOLS>>;
|
2771
2715
|
/**
|
2772
2716
|
* @deprecated Use `ToolResultUnion` instead.
|
2773
2717
|
*/
|
@@ -2856,10 +2800,6 @@ type StepResult<TOOLS extends ToolSet> = {
|
|
2856
2800
|
*/
|
2857
2801
|
readonly providerMetadata: ProviderMetadata | undefined;
|
2858
2802
|
/**
|
2859
|
-
@deprecated Use `providerMetadata` instead.
|
2860
|
-
*/
|
2861
|
-
readonly experimental_providerMetadata: ProviderMetadata | undefined;
|
2862
|
-
/**
|
2863
2803
|
The type of step that this result is for. The first step is always
|
2864
2804
|
an "initial" step, and subsequent steps are either "continue" steps
|
2865
2805
|
or "tool-result" steps.
|
@@ -2963,13 +2903,9 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
|
|
2963
2903
|
results that can be fully encapsulated in the provider.
|
2964
2904
|
*/
|
2965
2905
|
readonly providerMetadata: ProviderMetadata | undefined;
|
2966
|
-
/**
|
2967
|
-
@deprecated Use `providerMetadata` instead.
|
2968
|
-
*/
|
2969
|
-
readonly experimental_providerMetadata: ProviderMetadata | undefined;
|
2970
2906
|
}
|
2971
2907
|
|
2972
|
-
interface Output<OUTPUT, PARTIAL> {
|
2908
|
+
interface Output$1<OUTPUT, PARTIAL> {
|
2973
2909
|
readonly type: 'object' | 'text';
|
2974
2910
|
injectIntoSystemPrompt(options: {
|
2975
2911
|
system: string | undefined;
|
@@ -2991,17 +2927,16 @@ interface Output<OUTPUT, PARTIAL> {
|
|
2991
2927
|
finishReason: FinishReason;
|
2992
2928
|
}): OUTPUT;
|
2993
2929
|
}
|
2994
|
-
declare const text: () => Output<string, string>;
|
2930
|
+
declare const text: () => Output$1<string, string>;
|
2995
2931
|
declare const object: <OUTPUT>({ schema: inputSchema, }: {
|
2996
2932
|
schema: z.Schema<OUTPUT, z.ZodTypeDef, any> | Schema<OUTPUT>;
|
2997
|
-
}) => Output<OUTPUT, DeepPartial<OUTPUT>>;
|
2933
|
+
}) => Output$1<OUTPUT, DeepPartial<OUTPUT>>;
|
2998
2934
|
|
2999
|
-
type output_Output<OUTPUT, PARTIAL> = Output<OUTPUT, PARTIAL>;
|
3000
2935
|
declare const output_object: typeof object;
|
3001
2936
|
declare const output_text: typeof text;
|
3002
2937
|
declare namespace output {
|
3003
2938
|
export {
|
3004
|
-
|
2939
|
+
Output$1 as Output,
|
3005
2940
|
output_object as object,
|
3006
2941
|
output_text as text,
|
3007
2942
|
};
|
@@ -3114,7 +3049,7 @@ This function does not stream the output. If you want to stream the output, use
|
|
3114
3049
|
@param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
3115
3050
|
@param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
3116
3051
|
|
3117
|
-
@param
|
3052
|
+
@param maxOutputTokens - Maximum number of tokens to generate.
|
3118
3053
|
@param temperature - Temperature setting.
|
3119
3054
|
The value is passed through to the provider. The range depends on the provider and model.
|
3120
3055
|
It is recommended to set either `temperature` or `topP`, but not both.
|
@@ -3147,7 +3082,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
3147
3082
|
@returns
|
3148
3083
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
3149
3084
|
*/
|
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,
|
3085
|
+
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
3086
|
/**
|
3152
3087
|
The language model to use.
|
3153
3088
|
*/
|
@@ -3189,10 +3124,6 @@ functionality that can be fully encapsulated in the provider.
|
|
3189
3124
|
*/
|
3190
3125
|
providerOptions?: ProviderOptions;
|
3191
3126
|
/**
|
3192
|
-
@deprecated Use `providerOptions` instead.
|
3193
|
-
*/
|
3194
|
-
experimental_providerMetadata?: ProviderMetadata;
|
3195
|
-
/**
|
3196
3127
|
Limits the tools that are available for the model to call without
|
3197
3128
|
changing the tool call and result types in the result.
|
3198
3129
|
*/
|
@@ -3200,7 +3131,7 @@ changing the tool call and result types in the result.
|
|
3200
3131
|
/**
|
3201
3132
|
Optional specification for parsing structured outputs from the LLM response.
|
3202
3133
|
*/
|
3203
|
-
experimental_output?: Output<OUTPUT, OUTPUT_PARTIAL>;
|
3134
|
+
experimental_output?: Output$1<OUTPUT, OUTPUT_PARTIAL>;
|
3204
3135
|
/**
|
3205
3136
|
A function that attempts to repair a tool call that failed to parse.
|
3206
3137
|
*/
|
@@ -3317,10 +3248,6 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
|
3317
3248
|
*/
|
3318
3249
|
readonly providerMetadata: Promise<ProviderMetadata | undefined>;
|
3319
3250
|
/**
|
3320
|
-
@deprecated Use `providerMetadata` instead.
|
3321
|
-
*/
|
3322
|
-
readonly experimental_providerMetadata: Promise<ProviderMetadata | undefined>;
|
3323
|
-
/**
|
3324
3251
|
The full text that has been generated by the last step.
|
3325
3252
|
|
3326
3253
|
Resolved when the response is finished.
|
@@ -3518,20 +3445,12 @@ type TextStreamPart<TOOLS extends ToolSet> = {
|
|
3518
3445
|
usage: LanguageModelUsage$1;
|
3519
3446
|
finishReason: FinishReason;
|
3520
3447
|
providerMetadata: ProviderMetadata | undefined;
|
3521
|
-
/**
|
3522
|
-
* @deprecated Use `providerMetadata` instead.
|
3523
|
-
*/
|
3524
|
-
experimental_providerMetadata?: ProviderMetadata;
|
3525
3448
|
isContinued: boolean;
|
3526
3449
|
} | {
|
3527
3450
|
type: 'finish';
|
3528
3451
|
finishReason: FinishReason;
|
3529
3452
|
usage: LanguageModelUsage$1;
|
3530
3453
|
providerMetadata: ProviderMetadata | undefined;
|
3531
|
-
/**
|
3532
|
-
* @deprecated Use `providerMetadata` instead.
|
3533
|
-
*/
|
3534
|
-
experimental_providerMetadata?: ProviderMetadata;
|
3535
3454
|
/**
|
3536
3455
|
* @deprecated will be moved into provider metadata
|
3537
3456
|
*/
|
@@ -3631,7 +3550,7 @@ This function streams the output. If you do not want to stream the output, use `
|
|
3631
3550
|
@param prompt - A simple text prompt. You can either use `prompt` or `messages` but not both.
|
3632
3551
|
@param messages - A list of messages. You can either use `prompt` or `messages` but not both.
|
3633
3552
|
|
3634
|
-
@param
|
3553
|
+
@param maxOutputTokens - Maximum number of tokens to generate.
|
3635
3554
|
@param temperature - Temperature setting.
|
3636
3555
|
The value is passed through to the provider. The range depends on the provider and model.
|
3637
3556
|
It is recommended to set either `temperature` or `topP`, but not both.
|
@@ -3668,7 +3587,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
3668
3587
|
@return
|
3669
3588
|
A result object for accessing different stream types and additional information.
|
3670
3589
|
*/
|
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,
|
3590
|
+
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
3591
|
/**
|
3673
3592
|
The language model to use.
|
3674
3593
|
*/
|
@@ -3710,10 +3629,6 @@ functionality that can be fully encapsulated in the provider.
|
|
3710
3629
|
*/
|
3711
3630
|
providerOptions?: ProviderOptions;
|
3712
3631
|
/**
|
3713
|
-
@deprecated Use `providerOptions` instead.
|
3714
|
-
*/
|
3715
|
-
experimental_providerMetadata?: ProviderMetadata;
|
3716
|
-
/**
|
3717
3632
|
Limits the tools that are available for the model to call without
|
3718
3633
|
changing the tool call and result types in the result.
|
3719
3634
|
*/
|
@@ -3721,7 +3636,7 @@ changing the tool call and result types in the result.
|
|
3721
3636
|
/**
|
3722
3637
|
Optional specification for parsing structured outputs from the LLM response.
|
3723
3638
|
*/
|
3724
|
-
experimental_output?: Output<OUTPUT, PARTIAL_OUTPUT>;
|
3639
|
+
experimental_output?: Output$1<OUTPUT, PARTIAL_OUTPUT>;
|
3725
3640
|
/**
|
3726
3641
|
A function that attempts to repair a tool call that failed to parse.
|
3727
3642
|
*/
|
@@ -3916,10 +3831,6 @@ interface GenerateObjectResult<OBJECT> {
|
|
3916
3831
|
*/
|
3917
3832
|
readonly providerMetadata: ProviderMetadata | undefined;
|
3918
3833
|
/**
|
3919
|
-
@deprecated Use `providerMetadata` instead.
|
3920
|
-
*/
|
3921
|
-
readonly experimental_providerMetadata: ProviderMetadata | undefined;
|
3922
|
-
/**
|
3923
3834
|
Converts the object to a JSON response.
|
3924
3835
|
The response will have a status code of 200 and a content type of `application/json; charset=utf-8`.
|
3925
3836
|
*/
|
@@ -3944,98 +3855,29 @@ This function does not stream the output. If you want to stream the output, use
|
|
3944
3855
|
@returns
|
3945
3856
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
3946
3857
|
*/
|
3947
|
-
declare function generateObject<
|
3948
|
-
output?: 'object' | undefined;
|
3858
|
+
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
3859
|
/**
|
3950
|
-
The
|
3951
|
-
|
3952
|
-
|
3860
|
+
The enum values that the model should use.
|
3861
|
+
*/
|
3862
|
+
enum: Array<TYPE>;
|
3863
|
+
mode?: 'json';
|
3864
|
+
output: 'enum';
|
3865
|
+
} : Output extends 'no-schema' ? {} : {
|
3953
3866
|
/**
|
3954
3867
|
The schema of the object that the model should generate.
|
3955
|
-
|
3956
|
-
schema:
|
3868
|
+
*/
|
3869
|
+
schema: SCHEMA;
|
3957
3870
|
/**
|
3958
3871
|
Optional name of the output that should be generated.
|
3959
3872
|
Used by some providers for additional LLM guidance, e.g.
|
3960
3873
|
via tool or schema name.
|
3961
|
-
|
3874
|
+
*/
|
3962
3875
|
schemaName?: string;
|
3963
3876
|
/**
|
3964
3877
|
Optional description of the output that should be generated.
|
3965
3878
|
Used by some providers for additional LLM guidance, e.g.
|
3966
3879
|
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
|
-
*/
|
3880
|
+
*/
|
4039
3881
|
schemaDescription?: string;
|
4040
3882
|
/**
|
4041
3883
|
The mode to use for object generation.
|
@@ -4049,113 +3891,15 @@ The schema is converted into a JSON schema and used in one of the following ways
|
|
4049
3891
|
Please note that most providers do not support all modes.
|
4050
3892
|
|
4051
3893
|
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
|
-
*/
|
3894
|
+
*/
|
4112
3895
|
mode?: 'auto' | 'json' | 'tool';
|
4113
|
-
|
4114
|
-
|
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';
|
3896
|
+
}) & {
|
3897
|
+
output?: Output;
|
4150
3898
|
/**
|
4151
3899
|
The language model to use.
|
4152
3900
|
*/
|
4153
3901
|
model: LanguageModel;
|
4154
3902
|
/**
|
4155
|
-
The mode to use for object generation. Must be "json" for no-schema output.
|
4156
|
-
*/
|
4157
|
-
mode?: 'json';
|
4158
|
-
/**
|
4159
3903
|
A function that attempts to repair the raw output of the mode
|
4160
3904
|
to enable JSON parsing.
|
4161
3905
|
*/
|
@@ -4171,17 +3915,13 @@ functionality that can be fully encapsulated in the provider.
|
|
4171
3915
|
*/
|
4172
3916
|
providerOptions?: ProviderOptions;
|
4173
3917
|
/**
|
4174
|
-
@deprecated Use `providerOptions` instead.
|
4175
|
-
*/
|
4176
|
-
experimental_providerMetadata?: ProviderMetadata;
|
4177
|
-
/**
|
4178
3918
|
* Internal. For test use only. May change without notice.
|
4179
3919
|
*/
|
4180
3920
|
_internal?: {
|
4181
3921
|
generateId?: () => string;
|
4182
3922
|
currentDate?: () => Date;
|
4183
3923
|
};
|
4184
|
-
}): Promise<GenerateObjectResult<
|
3924
|
+
}): Promise<GenerateObjectResult<TYPE>>;
|
4185
3925
|
|
4186
3926
|
/**
|
4187
3927
|
The result of a `streamObject` call that contains the partial object stream and additional information.
|
@@ -4202,10 +3942,6 @@ interface StreamObjectResult<PARTIAL, RESULT, ELEMENT_STREAM> {
|
|
4202
3942
|
*/
|
4203
3943
|
readonly providerMetadata: Promise<ProviderMetadata | undefined>;
|
4204
3944
|
/**
|
4205
|
-
@deprecated Use `providerMetadata` instead.
|
4206
|
-
*/
|
4207
|
-
readonly experimental_providerMetadata: Promise<ProviderMetadata | undefined>;
|
4208
|
-
/**
|
4209
3945
|
Additional request information from the last step.
|
4210
3946
|
*/
|
4211
3947
|
readonly request: Promise<LanguageModelRequestMetadata>;
|
@@ -4315,10 +4051,6 @@ type StreamObjectOnFinishCallback<RESULT> = (event: {
|
|
4315
4051
|
functionality that can be fully encapsulated in the provider.
|
4316
4052
|
*/
|
4317
4053
|
providerMetadata: ProviderMetadata | undefined;
|
4318
|
-
/**
|
4319
|
-
@deprecated Use `providerMetadata` instead.
|
4320
|
-
*/
|
4321
|
-
experimental_providerMetadata?: ProviderMetadata;
|
4322
4054
|
}) => Promise<void> | void;
|
4323
4055
|
/**
|
4324
4056
|
Generate a structured, typed object for a given prompt and schema using a language model.
|
@@ -4375,10 +4107,6 @@ functionality that can be fully encapsulated in the provider.
|
|
4375
4107
|
*/
|
4376
4108
|
providerOptions?: ProviderOptions;
|
4377
4109
|
/**
|
4378
|
-
@deprecated Use `providerOptions` instead.
|
4379
|
-
*/
|
4380
|
-
experimental_providerMetadata?: ProviderMetadata;
|
4381
|
-
/**
|
4382
4110
|
Callback that is invoked when an error occurs during streaming.
|
4383
4111
|
You can use it to log errors.
|
4384
4112
|
The stream processing will pause until the callback promise is resolved.
|
@@ -4452,10 +4180,6 @@ functionality that can be fully encapsulated in the provider.
|
|
4452
4180
|
*/
|
4453
4181
|
providerOptions?: ProviderOptions;
|
4454
4182
|
/**
|
4455
|
-
@deprecated Use `providerOptions` instead.
|
4456
|
-
*/
|
4457
|
-
experimental_providerMetadata?: ProviderMetadata;
|
4458
|
-
/**
|
4459
4183
|
Callback that is invoked when an error occurs during streaming.
|
4460
4184
|
You can use it to log errors.
|
4461
4185
|
The stream processing will pause until the callback promise is resolved.
|
@@ -4503,10 +4227,6 @@ functionality that can be fully encapsulated in the provider.
|
|
4503
4227
|
*/
|
4504
4228
|
providerOptions?: ProviderOptions;
|
4505
4229
|
/**
|
4506
|
-
@deprecated Use `providerOptions` instead.
|
4507
|
-
*/
|
4508
|
-
experimental_providerMetadata?: ProviderMetadata;
|
4509
|
-
/**
|
4510
4230
|
Callback that is invoked when an error occurs during streaming.
|
4511
4231
|
You can use it to log errors.
|
4512
4232
|
The stream processing will pause until the callback promise is resolved.
|
@@ -4864,7 +4584,7 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
|
|
4864
4584
|
finishReason: FinishReason;
|
4865
4585
|
logprobs?: LogProbs;
|
4866
4586
|
usage: LanguageModelUsage$1;
|
4867
|
-
|
4587
|
+
providerMetadata?: ProviderMetadata;
|
4868
4588
|
} | {
|
4869
4589
|
type: 'error';
|
4870
4590
|
error: unknown;
|
@@ -4971,11 +4691,11 @@ declare const symbol$6: unique symbol;
|
|
4971
4691
|
declare class ToolExecutionError extends AISDKError {
|
4972
4692
|
private readonly [symbol$6];
|
4973
4693
|
readonly toolName: string;
|
4974
|
-
readonly toolArgs: JSONValue$1;
|
4694
|
+
readonly toolArgs: JSONValue$1 | unknown;
|
4975
4695
|
readonly toolCallId: string;
|
4976
4696
|
constructor({ toolArgs, toolName, toolCallId, cause, message, }: {
|
4977
4697
|
message?: string;
|
4978
|
-
toolArgs: JSONValue$1;
|
4698
|
+
toolArgs: JSONValue$1 | unknown;
|
4979
4699
|
toolName: string;
|
4980
4700
|
toolCallId: string;
|
4981
4701
|
cause: unknown;
|