ai 6.0.0-beta.48 → 6.0.0-beta.50
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 +70 -12
- package/dist/index.d.ts +70 -12
- package/dist/index.js +154 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +155 -78
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +5 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +5 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.0-beta.50
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4812235: fix(ai): add missing export for `LoadSettingError`
|
|
8
|
+
- 81d4308: feat: provider-executed dynamic tools
|
|
9
|
+
- Updated dependencies [81d4308]
|
|
10
|
+
- @ai-sdk/provider@3.0.0-beta.7
|
|
11
|
+
- @ai-sdk/gateway@2.0.0-beta.32
|
|
12
|
+
- @ai-sdk/provider-utils@4.0.0-beta.18
|
|
13
|
+
|
|
14
|
+
## 6.0.0-beta.49
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 703459a: feat: tool execution approval for dynamic tools
|
|
19
|
+
- Updated dependencies [703459a]
|
|
20
|
+
- @ai-sdk/provider-utils@4.0.0-beta.17
|
|
21
|
+
- @ai-sdk/gateway@2.0.0-beta.31
|
|
22
|
+
|
|
3
23
|
## 6.0.0-beta.48
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModel
|
|
|
4
4
|
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
5
5
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
6
6
|
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, LanguageModelV3FinishReason, LanguageModelV3CallWarning, LanguageModelV3Source, LanguageModelV3Middleware, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, SpeechModelV3CallWarning, TranscriptionModelV3, TranscriptionModelV2, TranscriptionModelV3CallWarning, LanguageModelV3Usage, LanguageModelV3CallOptions, AISDKError, LanguageModelV3ToolCall, JSONSchema7, JSONParseError, TypeValidationError, ProviderV3, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
|
|
7
|
-
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
7
|
+
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
8
8
|
import { ServerResponse } from 'node:http';
|
|
9
9
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
|
10
10
|
import { ServerResponse as ServerResponse$1 } from 'http';
|
|
@@ -291,7 +291,7 @@ onlyBar('bar');
|
|
|
291
291
|
*/
|
|
292
292
|
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
|
293
293
|
|
|
294
|
-
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta'>>;
|
|
294
|
+
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta' | 'needsApproval'>>;
|
|
295
295
|
|
|
296
296
|
type BaseToolCall = {
|
|
297
297
|
type: 'tool-call';
|
|
@@ -1580,18 +1580,23 @@ type asUITool<TOOL extends UITool | Tool> = TOOL extends Tool ? InferUITool<TOOL
|
|
|
1580
1580
|
* UI components for the tool.
|
|
1581
1581
|
*/
|
|
1582
1582
|
type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
1583
|
+
/**
|
|
1584
|
+
* ID of the tool call.
|
|
1585
|
+
*/
|
|
1583
1586
|
toolCallId: string;
|
|
1587
|
+
/**
|
|
1588
|
+
* Whether the tool call was executed by the provider.
|
|
1589
|
+
*/
|
|
1590
|
+
providerExecuted?: boolean;
|
|
1584
1591
|
} & ({
|
|
1585
1592
|
state: 'input-streaming';
|
|
1586
1593
|
input: DeepPartial<asUITool<TOOL>['input']> | undefined;
|
|
1587
|
-
providerExecuted?: boolean;
|
|
1588
1594
|
output?: never;
|
|
1589
1595
|
errorText?: never;
|
|
1590
1596
|
approval?: never;
|
|
1591
1597
|
} | {
|
|
1592
1598
|
state: 'input-available';
|
|
1593
1599
|
input: asUITool<TOOL>['input'];
|
|
1594
|
-
providerExecuted?: boolean;
|
|
1595
1600
|
output?: never;
|
|
1596
1601
|
errorText?: never;
|
|
1597
1602
|
callProviderMetadata?: ProviderMetadata;
|
|
@@ -1599,7 +1604,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1599
1604
|
} | {
|
|
1600
1605
|
state: 'approval-requested';
|
|
1601
1606
|
input: asUITool<TOOL>['input'];
|
|
1602
|
-
providerExecuted?: boolean;
|
|
1603
1607
|
output?: never;
|
|
1604
1608
|
errorText?: never;
|
|
1605
1609
|
callProviderMetadata?: ProviderMetadata;
|
|
@@ -1611,7 +1615,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1611
1615
|
} | {
|
|
1612
1616
|
state: 'approval-responded';
|
|
1613
1617
|
input: asUITool<TOOL>['input'];
|
|
1614
|
-
providerExecuted?: boolean;
|
|
1615
1618
|
output?: never;
|
|
1616
1619
|
errorText?: never;
|
|
1617
1620
|
callProviderMetadata?: ProviderMetadata;
|
|
@@ -1625,7 +1628,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1625
1628
|
input: asUITool<TOOL>['input'];
|
|
1626
1629
|
output: asUITool<TOOL>['output'];
|
|
1627
1630
|
errorText?: never;
|
|
1628
|
-
providerExecuted?: boolean;
|
|
1629
1631
|
callProviderMetadata?: ProviderMetadata;
|
|
1630
1632
|
preliminary?: boolean;
|
|
1631
1633
|
approval?: {
|
|
@@ -1639,7 +1641,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1639
1641
|
rawInput?: unknown;
|
|
1640
1642
|
output?: never;
|
|
1641
1643
|
errorText: string;
|
|
1642
|
-
providerExecuted?: boolean;
|
|
1643
1644
|
callProviderMetadata?: ProviderMetadata;
|
|
1644
1645
|
approval?: {
|
|
1645
1646
|
id: string;
|
|
@@ -1649,7 +1650,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1649
1650
|
} | {
|
|
1650
1651
|
state: 'output-denied';
|
|
1651
1652
|
input: asUITool<TOOL>['input'];
|
|
1652
|
-
providerExecuted?: boolean;
|
|
1653
1653
|
output?: never;
|
|
1654
1654
|
errorText?: never;
|
|
1655
1655
|
callProviderMetadata?: ProviderMetadata;
|
|
@@ -1666,19 +1666,53 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
|
|
|
1666
1666
|
}>;
|
|
1667
1667
|
type DynamicToolUIPart = {
|
|
1668
1668
|
type: 'dynamic-tool';
|
|
1669
|
+
/**
|
|
1670
|
+
* Name of the tool that is being called.
|
|
1671
|
+
*/
|
|
1669
1672
|
toolName: string;
|
|
1673
|
+
/**
|
|
1674
|
+
* ID of the tool call.
|
|
1675
|
+
*/
|
|
1670
1676
|
toolCallId: string;
|
|
1677
|
+
/**
|
|
1678
|
+
* Whether the tool call was executed by the provider.
|
|
1679
|
+
*/
|
|
1680
|
+
providerExecuted?: boolean;
|
|
1671
1681
|
} & ({
|
|
1672
1682
|
state: 'input-streaming';
|
|
1673
1683
|
input: unknown | undefined;
|
|
1674
1684
|
output?: never;
|
|
1675
1685
|
errorText?: never;
|
|
1686
|
+
approval?: never;
|
|
1676
1687
|
} | {
|
|
1677
1688
|
state: 'input-available';
|
|
1678
1689
|
input: unknown;
|
|
1679
1690
|
output?: never;
|
|
1680
1691
|
errorText?: never;
|
|
1681
1692
|
callProviderMetadata?: ProviderMetadata;
|
|
1693
|
+
approval?: never;
|
|
1694
|
+
} | {
|
|
1695
|
+
state: 'approval-requested';
|
|
1696
|
+
input: unknown;
|
|
1697
|
+
output?: never;
|
|
1698
|
+
errorText?: never;
|
|
1699
|
+
callProviderMetadata?: ProviderMetadata;
|
|
1700
|
+
approval: {
|
|
1701
|
+
id: string;
|
|
1702
|
+
approved?: never;
|
|
1703
|
+
reason?: never;
|
|
1704
|
+
};
|
|
1705
|
+
} | {
|
|
1706
|
+
state: 'approval-responded';
|
|
1707
|
+
input: unknown;
|
|
1708
|
+
output?: never;
|
|
1709
|
+
errorText?: never;
|
|
1710
|
+
callProviderMetadata?: ProviderMetadata;
|
|
1711
|
+
approval: {
|
|
1712
|
+
id: string;
|
|
1713
|
+
approved: boolean;
|
|
1714
|
+
reason?: string;
|
|
1715
|
+
};
|
|
1682
1716
|
} | {
|
|
1683
1717
|
state: 'output-available';
|
|
1684
1718
|
input: unknown;
|
|
@@ -1686,12 +1720,33 @@ type DynamicToolUIPart = {
|
|
|
1686
1720
|
errorText?: never;
|
|
1687
1721
|
callProviderMetadata?: ProviderMetadata;
|
|
1688
1722
|
preliminary?: boolean;
|
|
1723
|
+
approval?: {
|
|
1724
|
+
id: string;
|
|
1725
|
+
approved: true;
|
|
1726
|
+
reason?: string;
|
|
1727
|
+
};
|
|
1689
1728
|
} | {
|
|
1690
1729
|
state: 'output-error';
|
|
1691
1730
|
input: unknown;
|
|
1692
1731
|
output?: never;
|
|
1693
1732
|
errorText: string;
|
|
1694
1733
|
callProviderMetadata?: ProviderMetadata;
|
|
1734
|
+
approval?: {
|
|
1735
|
+
id: string;
|
|
1736
|
+
approved: true;
|
|
1737
|
+
reason?: string;
|
|
1738
|
+
};
|
|
1739
|
+
} | {
|
|
1740
|
+
state: 'output-denied';
|
|
1741
|
+
input: unknown;
|
|
1742
|
+
output?: never;
|
|
1743
|
+
errorText?: never;
|
|
1744
|
+
callProviderMetadata?: ProviderMetadata;
|
|
1745
|
+
approval: {
|
|
1746
|
+
id: string;
|
|
1747
|
+
approved: false;
|
|
1748
|
+
reason?: string;
|
|
1749
|
+
};
|
|
1695
1750
|
});
|
|
1696
1751
|
declare function isToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS>;
|
|
1697
1752
|
declare function isToolOrDynamicToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS> | DynamicToolUIPart;
|
|
@@ -2715,6 +2770,7 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
|
|
|
2715
2770
|
id: string;
|
|
2716
2771
|
toolName: string;
|
|
2717
2772
|
providerMetadata?: ProviderMetadata;
|
|
2773
|
+
dynamic?: boolean;
|
|
2718
2774
|
} | {
|
|
2719
2775
|
type: 'tool-input-delta';
|
|
2720
2776
|
id: string;
|
|
@@ -4556,12 +4612,14 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
4556
4612
|
declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
|
|
4557
4613
|
|
|
4558
4614
|
/**
|
|
4559
|
-
Converts an array of messages from useChat into an array of
|
|
4560
|
-
with the AI
|
|
4615
|
+
Converts an array of UI messages from useChat into an array of ModelMessages that can be used
|
|
4616
|
+
with the AI functions (e.g. `streamText`, `generateText`).
|
|
4561
4617
|
|
|
4562
|
-
@param messages - The messages to convert.
|
|
4618
|
+
@param messages - The UI messages to convert.
|
|
4563
4619
|
@param options.tools - The tools to use.
|
|
4564
4620
|
@param options.ignoreIncompleteToolCalls - Whether to ignore incomplete tool calls. Default is `false`.
|
|
4621
|
+
|
|
4622
|
+
@returns An array of ModelMessages.
|
|
4565
4623
|
*/
|
|
4566
4624
|
declare function convertToModelMessages(messages: Array<Omit<UIMessage, 'id'>>, options?: {
|
|
4567
4625
|
tools?: ToolSet;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModel
|
|
|
4
4
|
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
5
5
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
6
6
|
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, LanguageModelV3FinishReason, LanguageModelV3CallWarning, LanguageModelV3Source, LanguageModelV3Middleware, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, SpeechModelV3CallWarning, TranscriptionModelV3, TranscriptionModelV2, TranscriptionModelV3CallWarning, LanguageModelV3Usage, LanguageModelV3CallOptions, AISDKError, LanguageModelV3ToolCall, JSONSchema7, JSONParseError, TypeValidationError, ProviderV3, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
|
|
7
|
-
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
7
|
+
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
8
8
|
import { ServerResponse } from 'node:http';
|
|
9
9
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
|
10
10
|
import { ServerResponse as ServerResponse$1 } from 'http';
|
|
@@ -291,7 +291,7 @@ onlyBar('bar');
|
|
|
291
291
|
*/
|
|
292
292
|
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
|
293
293
|
|
|
294
|
-
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta'>>;
|
|
294
|
+
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta' | 'needsApproval'>>;
|
|
295
295
|
|
|
296
296
|
type BaseToolCall = {
|
|
297
297
|
type: 'tool-call';
|
|
@@ -1580,18 +1580,23 @@ type asUITool<TOOL extends UITool | Tool> = TOOL extends Tool ? InferUITool<TOOL
|
|
|
1580
1580
|
* UI components for the tool.
|
|
1581
1581
|
*/
|
|
1582
1582
|
type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
1583
|
+
/**
|
|
1584
|
+
* ID of the tool call.
|
|
1585
|
+
*/
|
|
1583
1586
|
toolCallId: string;
|
|
1587
|
+
/**
|
|
1588
|
+
* Whether the tool call was executed by the provider.
|
|
1589
|
+
*/
|
|
1590
|
+
providerExecuted?: boolean;
|
|
1584
1591
|
} & ({
|
|
1585
1592
|
state: 'input-streaming';
|
|
1586
1593
|
input: DeepPartial<asUITool<TOOL>['input']> | undefined;
|
|
1587
|
-
providerExecuted?: boolean;
|
|
1588
1594
|
output?: never;
|
|
1589
1595
|
errorText?: never;
|
|
1590
1596
|
approval?: never;
|
|
1591
1597
|
} | {
|
|
1592
1598
|
state: 'input-available';
|
|
1593
1599
|
input: asUITool<TOOL>['input'];
|
|
1594
|
-
providerExecuted?: boolean;
|
|
1595
1600
|
output?: never;
|
|
1596
1601
|
errorText?: never;
|
|
1597
1602
|
callProviderMetadata?: ProviderMetadata;
|
|
@@ -1599,7 +1604,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1599
1604
|
} | {
|
|
1600
1605
|
state: 'approval-requested';
|
|
1601
1606
|
input: asUITool<TOOL>['input'];
|
|
1602
|
-
providerExecuted?: boolean;
|
|
1603
1607
|
output?: never;
|
|
1604
1608
|
errorText?: never;
|
|
1605
1609
|
callProviderMetadata?: ProviderMetadata;
|
|
@@ -1611,7 +1615,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1611
1615
|
} | {
|
|
1612
1616
|
state: 'approval-responded';
|
|
1613
1617
|
input: asUITool<TOOL>['input'];
|
|
1614
|
-
providerExecuted?: boolean;
|
|
1615
1618
|
output?: never;
|
|
1616
1619
|
errorText?: never;
|
|
1617
1620
|
callProviderMetadata?: ProviderMetadata;
|
|
@@ -1625,7 +1628,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1625
1628
|
input: asUITool<TOOL>['input'];
|
|
1626
1629
|
output: asUITool<TOOL>['output'];
|
|
1627
1630
|
errorText?: never;
|
|
1628
|
-
providerExecuted?: boolean;
|
|
1629
1631
|
callProviderMetadata?: ProviderMetadata;
|
|
1630
1632
|
preliminary?: boolean;
|
|
1631
1633
|
approval?: {
|
|
@@ -1639,7 +1641,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1639
1641
|
rawInput?: unknown;
|
|
1640
1642
|
output?: never;
|
|
1641
1643
|
errorText: string;
|
|
1642
|
-
providerExecuted?: boolean;
|
|
1643
1644
|
callProviderMetadata?: ProviderMetadata;
|
|
1644
1645
|
approval?: {
|
|
1645
1646
|
id: string;
|
|
@@ -1649,7 +1650,6 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
|
|
|
1649
1650
|
} | {
|
|
1650
1651
|
state: 'output-denied';
|
|
1651
1652
|
input: asUITool<TOOL>['input'];
|
|
1652
|
-
providerExecuted?: boolean;
|
|
1653
1653
|
output?: never;
|
|
1654
1654
|
errorText?: never;
|
|
1655
1655
|
callProviderMetadata?: ProviderMetadata;
|
|
@@ -1666,19 +1666,53 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
|
|
|
1666
1666
|
}>;
|
|
1667
1667
|
type DynamicToolUIPart = {
|
|
1668
1668
|
type: 'dynamic-tool';
|
|
1669
|
+
/**
|
|
1670
|
+
* Name of the tool that is being called.
|
|
1671
|
+
*/
|
|
1669
1672
|
toolName: string;
|
|
1673
|
+
/**
|
|
1674
|
+
* ID of the tool call.
|
|
1675
|
+
*/
|
|
1670
1676
|
toolCallId: string;
|
|
1677
|
+
/**
|
|
1678
|
+
* Whether the tool call was executed by the provider.
|
|
1679
|
+
*/
|
|
1680
|
+
providerExecuted?: boolean;
|
|
1671
1681
|
} & ({
|
|
1672
1682
|
state: 'input-streaming';
|
|
1673
1683
|
input: unknown | undefined;
|
|
1674
1684
|
output?: never;
|
|
1675
1685
|
errorText?: never;
|
|
1686
|
+
approval?: never;
|
|
1676
1687
|
} | {
|
|
1677
1688
|
state: 'input-available';
|
|
1678
1689
|
input: unknown;
|
|
1679
1690
|
output?: never;
|
|
1680
1691
|
errorText?: never;
|
|
1681
1692
|
callProviderMetadata?: ProviderMetadata;
|
|
1693
|
+
approval?: never;
|
|
1694
|
+
} | {
|
|
1695
|
+
state: 'approval-requested';
|
|
1696
|
+
input: unknown;
|
|
1697
|
+
output?: never;
|
|
1698
|
+
errorText?: never;
|
|
1699
|
+
callProviderMetadata?: ProviderMetadata;
|
|
1700
|
+
approval: {
|
|
1701
|
+
id: string;
|
|
1702
|
+
approved?: never;
|
|
1703
|
+
reason?: never;
|
|
1704
|
+
};
|
|
1705
|
+
} | {
|
|
1706
|
+
state: 'approval-responded';
|
|
1707
|
+
input: unknown;
|
|
1708
|
+
output?: never;
|
|
1709
|
+
errorText?: never;
|
|
1710
|
+
callProviderMetadata?: ProviderMetadata;
|
|
1711
|
+
approval: {
|
|
1712
|
+
id: string;
|
|
1713
|
+
approved: boolean;
|
|
1714
|
+
reason?: string;
|
|
1715
|
+
};
|
|
1682
1716
|
} | {
|
|
1683
1717
|
state: 'output-available';
|
|
1684
1718
|
input: unknown;
|
|
@@ -1686,12 +1720,33 @@ type DynamicToolUIPart = {
|
|
|
1686
1720
|
errorText?: never;
|
|
1687
1721
|
callProviderMetadata?: ProviderMetadata;
|
|
1688
1722
|
preliminary?: boolean;
|
|
1723
|
+
approval?: {
|
|
1724
|
+
id: string;
|
|
1725
|
+
approved: true;
|
|
1726
|
+
reason?: string;
|
|
1727
|
+
};
|
|
1689
1728
|
} | {
|
|
1690
1729
|
state: 'output-error';
|
|
1691
1730
|
input: unknown;
|
|
1692
1731
|
output?: never;
|
|
1693
1732
|
errorText: string;
|
|
1694
1733
|
callProviderMetadata?: ProviderMetadata;
|
|
1734
|
+
approval?: {
|
|
1735
|
+
id: string;
|
|
1736
|
+
approved: true;
|
|
1737
|
+
reason?: string;
|
|
1738
|
+
};
|
|
1739
|
+
} | {
|
|
1740
|
+
state: 'output-denied';
|
|
1741
|
+
input: unknown;
|
|
1742
|
+
output?: never;
|
|
1743
|
+
errorText?: never;
|
|
1744
|
+
callProviderMetadata?: ProviderMetadata;
|
|
1745
|
+
approval: {
|
|
1746
|
+
id: string;
|
|
1747
|
+
approved: false;
|
|
1748
|
+
reason?: string;
|
|
1749
|
+
};
|
|
1695
1750
|
});
|
|
1696
1751
|
declare function isToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS>;
|
|
1697
1752
|
declare function isToolOrDynamicToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS> | DynamicToolUIPart;
|
|
@@ -2715,6 +2770,7 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
|
|
|
2715
2770
|
id: string;
|
|
2716
2771
|
toolName: string;
|
|
2717
2772
|
providerMetadata?: ProviderMetadata;
|
|
2773
|
+
dynamic?: boolean;
|
|
2718
2774
|
} | {
|
|
2719
2775
|
type: 'tool-input-delta';
|
|
2720
2776
|
id: string;
|
|
@@ -4556,12 +4612,14 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
4556
4612
|
declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
|
|
4557
4613
|
|
|
4558
4614
|
/**
|
|
4559
|
-
Converts an array of messages from useChat into an array of
|
|
4560
|
-
with the AI
|
|
4615
|
+
Converts an array of UI messages from useChat into an array of ModelMessages that can be used
|
|
4616
|
+
with the AI functions (e.g. `streamText`, `generateText`).
|
|
4561
4617
|
|
|
4562
|
-
@param messages - The messages to convert.
|
|
4618
|
+
@param messages - The UI messages to convert.
|
|
4563
4619
|
@param options.tools - The tools to use.
|
|
4564
4620
|
@param options.ignoreIncompleteToolCalls - Whether to ignore incomplete tool calls. Default is `false`.
|
|
4621
|
+
|
|
4622
|
+
@returns An array of ModelMessages.
|
|
4565
4623
|
*/
|
|
4566
4624
|
declare function convertToModelMessages(messages: Array<Omit<UIMessage, 'id'>>, options?: {
|
|
4567
4625
|
tools?: ToolSet;
|