ai 5.0.0-alpha.12 → 5.0.0-alpha.14
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 +32 -0
- package/dist/index.d.mts +177 -175
- package/dist/index.d.ts +177 -175
- package/dist/index.js +354 -344
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +301 -290
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +33 -20
- package/dist/internal/index.d.ts +33 -20
- package/dist/internal/index.js +14 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +14 -7
- package/dist/internal/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.d.mts +3 -3
- package/dist/mcp-stdio/index.d.ts +3 -3
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ToolResultContent, Schema,
|
1
|
+
import { ToolResultContent, Schema, IdGenerator, Validator, StandardSchemaV1, ToolCall, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
2
2
|
export { IdGenerator, Schema, ToolCall, ToolResult, asSchema, createIdGenerator, generateId, jsonSchema } from '@ai-sdk/provider-utils';
|
3
3
|
import { AISDKError, SharedV2ProviderMetadata, SharedV2ProviderOptions, EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SpeechModelV1, SpeechModelV1CallWarning, TranscriptionModelV1, TranscriptionModelV1CallWarning, LanguageModelV2Usage, JSONObject, LanguageModelV2ToolCall, JSONSchema7, LanguageModelV2CallOptions, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
4
4
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
@@ -144,7 +144,7 @@ interface ToolCallPart {
|
|
144
144
|
/**
|
145
145
|
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
146
146
|
*/
|
147
|
-
|
147
|
+
input: unknown;
|
148
148
|
/**
|
149
149
|
Additional provider-specific metadata. They are passed through
|
150
150
|
to the provider from the AI SDK and enable provider-specific
|
@@ -168,7 +168,7 @@ interface ToolResultPart {
|
|
168
168
|
/**
|
169
169
|
Result of the tool call. This is a JSON-serializable object.
|
170
170
|
*/
|
171
|
-
|
171
|
+
output: unknown;
|
172
172
|
/**
|
173
173
|
Multi-part content of the tool result. Only for tools that support multipart results.
|
174
174
|
*/
|
@@ -651,21 +651,21 @@ declare const JSONRPCResponseSchema: z.ZodObject<{
|
|
651
651
|
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
652
652
|
}, z.ZodTypeAny, "passthrough">>;
|
653
653
|
}, "strict", z.ZodTypeAny, {
|
654
|
+
id: string | number;
|
655
|
+
jsonrpc: "2.0";
|
654
656
|
result: {
|
655
657
|
_meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
656
658
|
} & {
|
657
659
|
[k: string]: unknown;
|
658
660
|
};
|
661
|
+
}, {
|
659
662
|
id: string | number;
|
660
663
|
jsonrpc: "2.0";
|
661
|
-
}, {
|
662
664
|
result: {
|
663
665
|
_meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
664
666
|
} & {
|
665
667
|
[k: string]: unknown;
|
666
668
|
};
|
667
|
-
id: string | number;
|
668
|
-
jsonrpc: "2.0";
|
669
669
|
}>;
|
670
670
|
type JSONRPCResponse = z.infer<typeof JSONRPCResponseSchema>;
|
671
671
|
declare const JSONRPCErrorSchema: z.ZodObject<{
|
@@ -787,21 +787,21 @@ declare const JSONRPCMessageSchema: z.ZodUnion<[z.ZodObject<{
|
|
787
787
|
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
788
788
|
}, z.ZodTypeAny, "passthrough">>;
|
789
789
|
}, "strict", z.ZodTypeAny, {
|
790
|
+
id: string | number;
|
791
|
+
jsonrpc: "2.0";
|
790
792
|
result: {
|
791
793
|
_meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
792
794
|
} & {
|
793
795
|
[k: string]: unknown;
|
794
796
|
};
|
797
|
+
}, {
|
795
798
|
id: string | number;
|
796
799
|
jsonrpc: "2.0";
|
797
|
-
}, {
|
798
800
|
result: {
|
799
801
|
_meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
800
802
|
} & {
|
801
803
|
[k: string]: unknown;
|
802
804
|
};
|
803
|
-
id: string | number;
|
804
|
-
jsonrpc: "2.0";
|
805
805
|
}>, z.ZodObject<{
|
806
806
|
jsonrpc: z.ZodLiteral<"2.0">;
|
807
807
|
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
@@ -880,7 +880,7 @@ type MCPTransportConfig = {
|
|
880
880
|
headers?: Record<string, string>;
|
881
881
|
};
|
882
882
|
|
883
|
-
type
|
883
|
+
type ToolInputSchema<T = JSONObject> = z4.$ZodType<T> | z3.Schema<T> | Schema<T>;
|
884
884
|
interface ToolCallOptions {
|
885
885
|
/**
|
886
886
|
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
@@ -903,21 +903,21 @@ This enables the language model to generate the input.
|
|
903
903
|
|
904
904
|
The tool can also contain an optional execute function for the actual execution function of the tool.
|
905
905
|
*/
|
906
|
-
type Tool<
|
906
|
+
type Tool<INPUT extends JSONValue$1 | unknown | never = any, OUTPUT = any> = {
|
907
907
|
/**
|
908
908
|
An optional description of what the tool does.
|
909
909
|
Will be used by the language model to decide whether to use the tool.
|
910
|
-
Not used for provider-defined tools.
|
910
|
+
Not used for provider-defined-client tools.
|
911
911
|
*/
|
912
912
|
description?: string;
|
913
|
-
} & NeverOptional<
|
913
|
+
} & NeverOptional<INPUT, {
|
914
914
|
/**
|
915
915
|
The schema of the input that the tool expects. The language model will use this to generate the input.
|
916
916
|
It is also used to validate the output of the language model.
|
917
917
|
Use descriptions to make the input understandable for the language model.
|
918
918
|
*/
|
919
|
-
|
920
|
-
}> & NeverOptional<
|
919
|
+
inputSchema: ToolInputSchema<INPUT>;
|
920
|
+
}> & NeverOptional<OUTPUT, {
|
921
921
|
/**
|
922
922
|
An async function that is called with the arguments from the tool call and produces a result.
|
923
923
|
If not provided, the tool will not be executed automatically.
|
@@ -925,29 +925,29 @@ If not provided, the tool will not be executed automatically.
|
|
925
925
|
@args is the input of the tool call.
|
926
926
|
@options.abortSignal is a signal that can be used to abort the tool call.
|
927
927
|
*/
|
928
|
-
execute: (
|
928
|
+
execute: (input: [INPUT] extends [never] ? undefined : INPUT, options: ToolCallOptions) => PromiseLike<OUTPUT>;
|
929
929
|
/**
|
930
930
|
Optional conversion function that maps the tool result to multi-part tool content for LLMs.
|
931
931
|
*/
|
932
|
-
experimental_toToolResultContent?: (
|
932
|
+
experimental_toToolResultContent?: (output: OUTPUT) => ToolResultContent;
|
933
933
|
/**
|
934
934
|
* Optional function that is called when the argument streaming starts.
|
935
935
|
* Only called when the tool is used in a streaming context.
|
936
936
|
*/
|
937
|
-
|
937
|
+
onInputStart?: (options: ToolCallOptions) => void | PromiseLike<void>;
|
938
938
|
/**
|
939
939
|
* Optional function that is called when an argument streaming delta is available.
|
940
940
|
* Only called when the tool is used in a streaming context.
|
941
941
|
*/
|
942
|
-
|
943
|
-
|
942
|
+
onInputDelta?: (options: {
|
943
|
+
inputTextDelta: string;
|
944
944
|
} & ToolCallOptions) => void | PromiseLike<void>;
|
945
945
|
/**
|
946
946
|
* Optional function that is called when a tool call can be started,
|
947
947
|
* even if the execute function is not provided.
|
948
948
|
*/
|
949
|
-
|
950
|
-
|
949
|
+
onInputAvailable?: (options: {
|
950
|
+
input: [INPUT] extends [never] ? undefined : INPUT;
|
951
951
|
} & ToolCallOptions) => void | PromiseLike<void>;
|
952
952
|
}> & ({
|
953
953
|
/**
|
@@ -956,9 +956,22 @@ Function tool.
|
|
956
956
|
type?: undefined | 'function';
|
957
957
|
} | {
|
958
958
|
/**
|
959
|
-
Provider-defined tool.
|
959
|
+
Provider-defined-client tool.
|
960
|
+
*/
|
961
|
+
type: 'provider-defined-client';
|
962
|
+
/**
|
963
|
+
The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
|
964
|
+
*/
|
965
|
+
id: `${string}.${string}`;
|
966
|
+
/**
|
967
|
+
The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
968
|
+
*/
|
969
|
+
args: Record<string, unknown>;
|
970
|
+
} | {
|
971
|
+
/**
|
972
|
+
Provider-defined-server tool.
|
960
973
|
*/
|
961
|
-
type: 'provider-defined';
|
974
|
+
type: 'provider-defined-server';
|
962
975
|
/**
|
963
976
|
The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
|
964
977
|
*/
|
@@ -971,21 +984,21 @@ The arguments for configuring the tool. Must match the expected arguments define
|
|
971
984
|
/**
|
972
985
|
Helper function for inferring the execute args of a tool.
|
973
986
|
*/
|
974
|
-
declare function tool<
|
975
|
-
declare function tool<
|
976
|
-
declare function tool<
|
987
|
+
declare function tool<INPUT, OUTPUT>(tool: Tool<INPUT, OUTPUT>): Tool<INPUT, OUTPUT>;
|
988
|
+
declare function tool<INPUT>(tool: Tool<INPUT, never>): Tool<INPUT, never>;
|
989
|
+
declare function tool<OUTPUT>(tool: Tool<never, OUTPUT>): Tool<never, OUTPUT>;
|
977
990
|
declare function tool(tool: Tool<never, never>): Tool<never, never>;
|
978
|
-
type MappedTool<T extends Tool | JSONObject,
|
991
|
+
type MappedTool<T extends Tool | JSONObject, OUTPUT extends any> = T extends Tool<infer INPUT> ? Tool<INPUT, OUTPUT> : T extends JSONObject ? Tool<T, OUTPUT> : never;
|
979
992
|
|
980
993
|
type ToolSchemas = Record<string, {
|
981
|
-
|
994
|
+
inputSchema: ToolInputSchema<JSONObject | unknown>;
|
982
995
|
}> | 'automatic' | undefined;
|
983
996
|
type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
|
984
|
-
|
997
|
+
inputSchema: ToolInputSchema<unknown>;
|
985
998
|
}> ? {
|
986
999
|
[K in keyof TOOL_SCHEMAS]: MappedTool<TOOL_SCHEMAS[K], CallToolResult> & Required<Pick<MappedTool<TOOL_SCHEMAS[K], CallToolResult>, 'execute'>>;
|
987
1000
|
} : McpToolSet<Record<string, {
|
988
|
-
|
1001
|
+
inputSchema: ToolInputSchema<unknown>;
|
989
1002
|
}>>;
|
990
1003
|
declare const CallToolResultSchema: z.ZodUnion<[z.ZodObject<{
|
991
1004
|
_meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
@@ -1755,14 +1768,14 @@ declare class MCPClient {
|
|
1755
1768
|
private onResponse;
|
1756
1769
|
}
|
1757
1770
|
|
1758
|
-
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | '
|
1771
|
+
type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta'>>;
|
1759
1772
|
|
1760
1773
|
type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
|
1761
1774
|
[NAME in keyof TOOLS]: {
|
1762
1775
|
type: 'tool-call';
|
1763
1776
|
toolCallId: string;
|
1764
1777
|
toolName: NAME & string;
|
1765
|
-
|
1778
|
+
input: TOOLS[NAME] extends Tool<infer PARAMETERS> ? PARAMETERS : never;
|
1766
1779
|
};
|
1767
1780
|
}>;
|
1768
1781
|
type ToolCallArray<TOOLS extends ToolSet> = Array<ToolCallUnion<TOOLS>>;
|
@@ -1775,8 +1788,8 @@ type ToToolResultObject<TOOLS extends ToolSet> = ValueOf<{
|
|
1775
1788
|
type: 'tool-result';
|
1776
1789
|
toolCallId: string;
|
1777
1790
|
toolName: NAME & string;
|
1778
|
-
|
1779
|
-
|
1791
|
+
input: TOOLS[NAME] extends Tool<infer P> ? P : never;
|
1792
|
+
output: Awaited<ReturnType<Exclude<TOOLS[NAME]['execute'], undefined>>>;
|
1780
1793
|
};
|
1781
1794
|
}>;
|
1782
1795
|
type ToolResultUnion<TOOLS extends ToolSet> = ToToolResultObject<ToToolsWithDefinedExecute<TOOLS>>;
|
@@ -1801,17 +1814,17 @@ type ContentPart<TOOLS extends ToolSet> = {
|
|
1801
1814
|
} & ToolResultUnion<TOOLS>);
|
1802
1815
|
|
1803
1816
|
declare const symbol$e: unique symbol;
|
1804
|
-
declare class
|
1817
|
+
declare class InvalidToolInputError extends AISDKError {
|
1805
1818
|
private readonly [symbol$e];
|
1806
1819
|
readonly toolName: string;
|
1807
|
-
readonly
|
1808
|
-
constructor({
|
1820
|
+
readonly toolInput: string;
|
1821
|
+
constructor({ toolInput, toolName, cause, message, }: {
|
1809
1822
|
message?: string;
|
1810
|
-
|
1823
|
+
toolInput: string;
|
1811
1824
|
toolName: string;
|
1812
1825
|
cause: unknown;
|
1813
1826
|
});
|
1814
|
-
static isInstance(error: unknown): error is
|
1827
|
+
static isInstance(error: unknown): error is InvalidToolInputError;
|
1815
1828
|
}
|
1816
1829
|
|
1817
1830
|
declare const symbol$d: unique symbol;
|
@@ -1933,7 +1946,7 @@ declare const GLOBAL_DEFAULT_PROVIDER: unique symbol;
|
|
1933
1946
|
* @param options.messages - The messages in the current generation step.
|
1934
1947
|
* @param options.toolCall - The tool call that failed to parse.
|
1935
1948
|
* @param options.tools - The tools that are available.
|
1936
|
-
* @param options.
|
1949
|
+
* @param options.inputSchema - A function that returns the JSON Schema for a tool.
|
1937
1950
|
* @param options.error - The error that occurred while parsing the tool call.
|
1938
1951
|
*/
|
1939
1952
|
type ToolCallRepairFunction<TOOLS extends ToolSet> = (options: {
|
@@ -1941,10 +1954,10 @@ type ToolCallRepairFunction<TOOLS extends ToolSet> = (options: {
|
|
1941
1954
|
messages: ModelMessage[];
|
1942
1955
|
toolCall: LanguageModelV2ToolCall;
|
1943
1956
|
tools: TOOLS;
|
1944
|
-
|
1957
|
+
inputSchema: (options: {
|
1945
1958
|
toolName: string;
|
1946
1959
|
}) => JSONSchema7;
|
1947
|
-
error: NoSuchToolError |
|
1960
|
+
error: NoSuchToolError | InvalidToolInputError;
|
1948
1961
|
}) => Promise<LanguageModelV2ToolCall | null>;
|
1949
1962
|
|
1950
1963
|
type SingleRequestTextStreamPart<TOOLS extends ToolSet> = ContentPart<TOOLS> | {
|
@@ -1960,7 +1973,7 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = ContentPart<TOOLS> | {
|
|
1960
1973
|
type: 'tool-call-delta';
|
1961
1974
|
toolCallId: string;
|
1962
1975
|
toolName: string;
|
1963
|
-
|
1976
|
+
inputTextDelta: string;
|
1964
1977
|
} | {
|
1965
1978
|
type: 'response-metadata';
|
1966
1979
|
id?: string;
|
@@ -2081,11 +2094,11 @@ declare class NoOutputSpecifiedError extends AISDKError {
|
|
2081
2094
|
declare const symbol$7: unique symbol;
|
2082
2095
|
declare class ToolCallRepairError extends AISDKError {
|
2083
2096
|
private readonly [symbol$7];
|
2084
|
-
readonly originalError: NoSuchToolError |
|
2097
|
+
readonly originalError: NoSuchToolError | InvalidToolInputError;
|
2085
2098
|
constructor({ cause, originalError, message, }: {
|
2086
2099
|
message?: string;
|
2087
2100
|
cause: unknown;
|
2088
|
-
originalError: NoSuchToolError |
|
2101
|
+
originalError: NoSuchToolError | InvalidToolInputError;
|
2089
2102
|
});
|
2090
2103
|
static isInstance(error: unknown): error is ToolCallRepairError;
|
2091
2104
|
}
|
@@ -2094,11 +2107,11 @@ declare const symbol$6: unique symbol;
|
|
2094
2107
|
declare class ToolExecutionError extends AISDKError {
|
2095
2108
|
private readonly [symbol$6];
|
2096
2109
|
readonly toolName: string;
|
2097
|
-
readonly
|
2110
|
+
readonly toolInput: JSONValue$1 | unknown;
|
2098
2111
|
readonly toolCallId: string;
|
2099
|
-
constructor({
|
2112
|
+
constructor({ toolInput, toolName, toolCallId, cause, message, }: {
|
2100
2113
|
message?: string;
|
2101
|
-
|
2114
|
+
toolInput: JSONValue$1 | unknown;
|
2102
2115
|
toolName: string;
|
2103
2116
|
toolCallId: string;
|
2104
2117
|
cause: unknown;
|
@@ -2130,29 +2143,34 @@ declare class InvalidMessageRoleError extends AISDKError {
|
|
2130
2143
|
}
|
2131
2144
|
|
2132
2145
|
/**
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2146
|
+
Create a type from an object with all keys and nested keys set to optional.
|
2147
|
+
The helper supports normal objects and Zod schemas (which are resolved automatically).
|
2148
|
+
It always recurses into arrays.
|
2136
2149
|
|
2137
|
-
|
2138
|
-
back to a sequence of LLM assistant/tool result message pairs.
|
2139
|
-
It is optional for backwards compatibility.
|
2150
|
+
Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
2140
2151
|
*/
|
2141
|
-
type
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2152
|
+
type DeepPartial<T> = T extends z3.ZodTypeAny ? DeepPartialInternal<z3.infer<T>> : T extends z4.$ZodType ? DeepPartialInternal<z4.infer<T>> : DeepPartialInternal<T>;
|
2153
|
+
type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
|
2154
|
+
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
2155
|
+
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
2156
|
+
type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
2157
|
+
type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
|
2158
|
+
type PartialObject<ObjectType extends object> = {
|
2159
|
+
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
2160
|
+
};
|
2161
|
+
|
2148
2162
|
/**
|
2149
2163
|
The data types that can be used in the UI message for the UI message data parts.
|
2150
2164
|
*/
|
2151
2165
|
type UIDataTypes = Record<string, unknown>;
|
2166
|
+
type UITools = Record<string, {
|
2167
|
+
input: unknown;
|
2168
|
+
output: unknown | undefined;
|
2169
|
+
}>;
|
2152
2170
|
/**
|
2153
2171
|
AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
|
2154
2172
|
*/
|
2155
|
-
interface UIMessage<METADATA = unknown, DATA_PARTS extends UIDataTypes = UIDataTypes> {
|
2173
|
+
interface UIMessage<METADATA = unknown, DATA_PARTS extends UIDataTypes = UIDataTypes, TOOLS extends UITools = UITools> {
|
2156
2174
|
/**
|
2157
2175
|
A unique identifier for the message.
|
2158
2176
|
*/
|
@@ -2175,22 +2193,9 @@ interface UIMessage<METADATA = unknown, DATA_PARTS extends UIDataTypes = UIDataT
|
|
2175
2193
|
|
2176
2194
|
Assistant messages can have text, reasoning, tool invocation, and file parts.
|
2177
2195
|
*/
|
2178
|
-
parts: Array<UIMessagePart<DATA_PARTS>>;
|
2196
|
+
parts: Array<UIMessagePart<DATA_PARTS, TOOLS>>;
|
2179
2197
|
}
|
2180
|
-
type UIMessagePart<DATA_TYPES extends UIDataTypes> = TextUIPart | ReasoningUIPart |
|
2181
|
-
type DataUIPart<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
2182
|
-
[NAME in keyof DATA_TYPES & string]: {
|
2183
|
-
type: `data-${NAME}`;
|
2184
|
-
id?: string;
|
2185
|
-
data: DATA_TYPES[NAME];
|
2186
|
-
};
|
2187
|
-
}>;
|
2188
|
-
type UIDataPartSchemas = Record<string, Validator<any> | StandardSchemaV1<any>>;
|
2189
|
-
type InferUIDataParts<T extends UIDataPartSchemas> = {
|
2190
|
-
[K in keyof T]: T[K] extends Validator<infer U> ? U : T[K] extends StandardSchemaV1<infer U> ? U : unknown;
|
2191
|
-
};
|
2192
|
-
type InferUIMessageData<T extends UIMessage> = T extends UIMessage<unknown, infer DATA_TYPES> ? DATA_TYPES : UIDataTypes;
|
2193
|
-
type InferUIMessageMetadata<T extends UIMessage> = T extends UIMessage<infer METADATA, UIDataTypes> ? METADATA : unknown;
|
2198
|
+
type UIMessagePart<DATA_TYPES extends UIDataTypes, TOOLS extends UITools> = TextUIPart | ReasoningUIPart | ToolUIPart<TOOLS> | SourceUrlUIPart | SourceDocumentUIPart | FileUIPart | DataUIPart<DATA_TYPES> | StepStartUIPart;
|
2194
2199
|
/**
|
2195
2200
|
* A text part of a message.
|
2196
2201
|
*/
|
@@ -2215,16 +2220,6 @@ type ReasoningUIPart = {
|
|
2215
2220
|
*/
|
2216
2221
|
providerMetadata?: Record<string, any>;
|
2217
2222
|
};
|
2218
|
-
/**
|
2219
|
-
* A tool invocation part of a message.
|
2220
|
-
*/
|
2221
|
-
type ToolInvocationUIPart = {
|
2222
|
-
type: 'tool-invocation';
|
2223
|
-
/**
|
2224
|
-
* The tool invocation.
|
2225
|
-
*/
|
2226
|
-
toolInvocation: ToolInvocation;
|
2227
|
-
};
|
2228
2223
|
/**
|
2229
2224
|
* A source part of a message.
|
2230
2225
|
*/
|
@@ -2273,10 +2268,33 @@ type FileUIPart = {
|
|
2273
2268
|
type StepStartUIPart = {
|
2274
2269
|
type: 'step-start';
|
2275
2270
|
};
|
2276
|
-
type
|
2277
|
-
|
2278
|
-
|
2279
|
-
|
2271
|
+
type DataUIPart<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
2272
|
+
[NAME in keyof DATA_TYPES & string]: {
|
2273
|
+
type: `data-${NAME}`;
|
2274
|
+
id?: string;
|
2275
|
+
data: DATA_TYPES[NAME];
|
2276
|
+
};
|
2277
|
+
}>;
|
2278
|
+
type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
|
2279
|
+
[NAME in keyof TOOLS & string]: {
|
2280
|
+
type: `tool-${NAME}`;
|
2281
|
+
toolCallId: string;
|
2282
|
+
} & ({
|
2283
|
+
state: 'input-streaming';
|
2284
|
+
input: DeepPartial<TOOLS[NAME]['input']>;
|
2285
|
+
} | {
|
2286
|
+
state: 'input-available';
|
2287
|
+
input: TOOLS[NAME]['input'];
|
2288
|
+
} | {
|
2289
|
+
state: 'output-available';
|
2290
|
+
input: TOOLS[NAME]['input'];
|
2291
|
+
output: TOOLS[NAME]['output'];
|
2292
|
+
});
|
2293
|
+
}>;
|
2294
|
+
declare function isToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS>;
|
2295
|
+
declare function getToolName<TOOLS extends UITools>(part: ToolUIPart<TOOLS>): keyof TOOLS;
|
2296
|
+
type InferUIMessageMetadata<T extends UIMessage> = T extends UIMessage<infer METADATA> ? METADATA : unknown;
|
2297
|
+
type InferUIMessageData<T extends UIMessage> = T extends UIMessage<unknown, infer DATA_TYPES> ? DATA_TYPES : UIDataTypes;
|
2280
2298
|
|
2281
2299
|
declare const symbol$3: unique symbol;
|
2282
2300
|
declare class MessageConversionError extends AISDKError {
|
@@ -2360,27 +2378,29 @@ type UIMessageStreamPart<METADATA = unknown, DATA_TYPES extends UIDataTypes = UI
|
|
2360
2378
|
type: 'error';
|
2361
2379
|
errorText: string;
|
2362
2380
|
} | {
|
2363
|
-
type: 'tool-
|
2381
|
+
type: 'tool-input-available';
|
2364
2382
|
toolCallId: string;
|
2365
2383
|
toolName: string;
|
2366
|
-
|
2384
|
+
input: unknown;
|
2367
2385
|
} | {
|
2368
|
-
type: 'tool-
|
2386
|
+
type: 'tool-output-available';
|
2369
2387
|
toolCallId: string;
|
2370
|
-
|
2388
|
+
output: unknown;
|
2371
2389
|
providerMetadata?: ProviderMetadata;
|
2372
2390
|
} | {
|
2373
|
-
type: 'tool-
|
2391
|
+
type: 'tool-input-start';
|
2374
2392
|
toolCallId: string;
|
2375
2393
|
toolName: string;
|
2376
2394
|
} | {
|
2377
|
-
type: 'tool-
|
2395
|
+
type: 'tool-input-delta';
|
2378
2396
|
toolCallId: string;
|
2379
|
-
|
2397
|
+
inputTextDelta: string;
|
2380
2398
|
} | {
|
2381
2399
|
type: 'reasoning';
|
2382
2400
|
text: string;
|
2383
2401
|
providerMetadata?: ProviderMetadata;
|
2402
|
+
} | {
|
2403
|
+
type: 'reasoning-part-finish';
|
2384
2404
|
} | {
|
2385
2405
|
type: 'source-url';
|
2386
2406
|
sourceId: string;
|
@@ -2399,23 +2419,19 @@ type UIMessageStreamPart<METADATA = unknown, DATA_TYPES extends UIDataTypes = UI
|
|
2399
2419
|
url: string;
|
2400
2420
|
mediaType: string;
|
2401
2421
|
} | DataUIMessageStreamPart<DATA_TYPES> | {
|
2402
|
-
type: 'metadata';
|
2403
|
-
metadata: METADATA;
|
2404
|
-
} | {
|
2405
2422
|
type: 'start-step';
|
2406
|
-
metadata?: METADATA;
|
2407
2423
|
} | {
|
2408
2424
|
type: 'finish-step';
|
2409
|
-
metadata?: METADATA;
|
2410
2425
|
} | {
|
2411
2426
|
type: 'start';
|
2412
2427
|
messageId?: string;
|
2413
|
-
|
2428
|
+
messageMetadata?: METADATA;
|
2414
2429
|
} | {
|
2415
2430
|
type: 'finish';
|
2416
|
-
|
2431
|
+
messageMetadata?: METADATA;
|
2417
2432
|
} | {
|
2418
|
-
type: '
|
2433
|
+
type: 'message-metadata';
|
2434
|
+
messageMetadata: METADATA;
|
2419
2435
|
};
|
2420
2436
|
type InferUIMessageStreamPart<T extends UIMessage> = UIMessageStreamPart<InferUIMessageMetadata<T>, InferUIMessageData<T>>;
|
2421
2437
|
|
@@ -2437,13 +2453,14 @@ interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
|
2437
2453
|
}
|
2438
2454
|
|
2439
2455
|
declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, // mask error messages for safety by default
|
2440
|
-
originalMessages, onFinish, }: {
|
2456
|
+
originalMessages, onFinish, generateId, }: {
|
2441
2457
|
execute: (options: {
|
2442
2458
|
writer: UIMessageStreamWriter<UI_MESSAGE>;
|
2443
2459
|
}) => Promise<void> | void;
|
2444
2460
|
onError?: (error: unknown) => string;
|
2445
2461
|
/**
|
2446
|
-
* The original messages.
|
2462
|
+
* The original messages. If they are provided, persistence mode is assumed,
|
2463
|
+
* and a message ID is provided for the response message.
|
2447
2464
|
*/
|
2448
2465
|
originalMessages?: UI_MESSAGE[];
|
2449
2466
|
onFinish?: (options: {
|
@@ -2462,6 +2479,7 @@ originalMessages, onFinish, }: {
|
|
2462
2479
|
*/
|
2463
2480
|
responseMessage: UI_MESSAGE;
|
2464
2481
|
}) => void;
|
2482
|
+
generateId?: IdGenerator;
|
2465
2483
|
}): ReadableStream<InferUIMessageStreamPart<UI_MESSAGE>>;
|
2466
2484
|
|
2467
2485
|
declare function createUIMessageStreamResponse({ status, statusText, headers, stream, }: ResponseInit & {
|
@@ -2477,15 +2495,26 @@ declare class JsonToSseTransformStream extends TransformStream<unknown, string>
|
|
2477
2495
|
constructor();
|
2478
2496
|
}
|
2479
2497
|
|
2480
|
-
interface ChatTransport<
|
2498
|
+
interface ChatTransport<UI_MESSAGE extends UIMessage> {
|
2481
2499
|
submitMessages: (options: {
|
2482
2500
|
chatId: string;
|
2483
|
-
messages:
|
2501
|
+
messages: UI_MESSAGE[];
|
2484
2502
|
abortSignal: AbortSignal | undefined;
|
2485
2503
|
requestType: 'generate' | 'resume';
|
2486
2504
|
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageStreamPart>>;
|
2487
2505
|
}
|
2488
2506
|
|
2507
|
+
type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESSAGE, 'id' | 'role'> & {
|
2508
|
+
id?: UI_MESSAGE['id'];
|
2509
|
+
role?: UI_MESSAGE['role'];
|
2510
|
+
};
|
2511
|
+
type UIDataPartSchemas = Record<string, Validator<any> | StandardSchemaV1<any>>;
|
2512
|
+
type UIDataTypesToSchemas<T extends UIDataTypes> = {
|
2513
|
+
[K in keyof T]: Validator<T[K]> | StandardSchemaV1<T[K]>;
|
2514
|
+
};
|
2515
|
+
type InferUIDataParts<T extends UIDataPartSchemas> = {
|
2516
|
+
[K in keyof T]: T[K] extends Validator<infer U> ? U : T[K] extends StandardSchemaV1<infer U> ? U : unknown;
|
2517
|
+
};
|
2489
2518
|
type ChatRequestOptions = {
|
2490
2519
|
/**
|
2491
2520
|
Additional headers that should be to be passed to the API endpoint.
|
@@ -2498,30 +2527,30 @@ type ChatRequestOptions = {
|
|
2498
2527
|
metadata?: unknown;
|
2499
2528
|
};
|
2500
2529
|
type ChatStatus = 'submitted' | 'streaming' | 'ready' | 'error';
|
2501
|
-
interface ChatState<
|
2530
|
+
interface ChatState<UI_MESSAGE extends UIMessage> {
|
2502
2531
|
status: ChatStatus;
|
2503
2532
|
error: Error | undefined;
|
2504
|
-
messages:
|
2505
|
-
pushMessage: (message:
|
2533
|
+
messages: UI_MESSAGE[];
|
2534
|
+
pushMessage: (message: UI_MESSAGE) => void;
|
2506
2535
|
popMessage: () => void;
|
2507
|
-
replaceMessage: (index: number, message:
|
2536
|
+
replaceMessage: (index: number, message: UI_MESSAGE) => void;
|
2508
2537
|
snapshot: <T>(thing: T) => T;
|
2509
2538
|
}
|
2510
|
-
interface ChatInit<
|
2539
|
+
interface ChatInit<UI_MESSAGE extends UIMessage> {
|
2511
2540
|
/**
|
2512
2541
|
* A unique identifier for the chat. If not provided, a random one will be
|
2513
2542
|
* generated.
|
2514
2543
|
*/
|
2515
2544
|
id?: string;
|
2516
|
-
messageMetadataSchema?: Validator<
|
2517
|
-
dataPartSchemas?:
|
2518
|
-
messages?:
|
2545
|
+
messageMetadataSchema?: Validator<InferUIMessageMetadata<UI_MESSAGE>> | StandardSchemaV1<InferUIMessageMetadata<UI_MESSAGE>>;
|
2546
|
+
dataPartSchemas?: UIDataTypesToSchemas<InferUIMessageData<UI_MESSAGE>>;
|
2547
|
+
messages?: UI_MESSAGE[];
|
2519
2548
|
/**
|
2520
2549
|
* A way to provide a function that is going to be used for ids for messages and the chat.
|
2521
2550
|
* If not provided the default AI SDK `generateId` is used.
|
2522
2551
|
*/
|
2523
2552
|
generateId?: IdGenerator;
|
2524
|
-
transport?: ChatTransport<
|
2553
|
+
transport?: ChatTransport<UI_MESSAGE>;
|
2525
2554
|
maxSteps?: number;
|
2526
2555
|
/**
|
2527
2556
|
* Callback function to be called when an error is encountered.
|
@@ -2543,13 +2572,13 @@ interface ChatInit<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends UIDa
|
|
2543
2572
|
* @param message The message that was streamed.
|
2544
2573
|
*/
|
2545
2574
|
onFinish?: (options: {
|
2546
|
-
message:
|
2575
|
+
message: UI_MESSAGE;
|
2547
2576
|
}) => void;
|
2548
2577
|
}
|
2549
|
-
declare abstract class AbstractChat<
|
2578
|
+
declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
2550
2579
|
readonly id: string;
|
2551
2580
|
readonly generateId: IdGenerator;
|
2552
|
-
protected state: ChatState<
|
2581
|
+
protected state: ChatState<UI_MESSAGE>;
|
2553
2582
|
private messageMetadataSchema;
|
2554
2583
|
private dataPartSchemas;
|
2555
2584
|
private readonly transport;
|
@@ -2559,8 +2588,8 @@ declare abstract class AbstractChat<MESSAGE_METADATA = unknown, UI_DATA_PART_SCH
|
|
2559
2588
|
private onFinish?;
|
2560
2589
|
private activeResponse;
|
2561
2590
|
private jobExecutor;
|
2562
|
-
constructor({ generateId, id, transport, maxSteps, messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, }: Omit<ChatInit<
|
2563
|
-
state: ChatState<
|
2591
|
+
constructor({ generateId, id, transport, maxSteps, messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, }: Omit<ChatInit<UI_MESSAGE>, 'messages'> & {
|
2592
|
+
state: ChatState<UI_MESSAGE>;
|
2564
2593
|
});
|
2565
2594
|
/**
|
2566
2595
|
* Hook status:
|
@@ -2576,25 +2605,25 @@ declare abstract class AbstractChat<MESSAGE_METADATA = unknown, UI_DATA_PART_SCH
|
|
2576
2605
|
error?: Error;
|
2577
2606
|
}): void;
|
2578
2607
|
get error(): Error | undefined;
|
2579
|
-
get messages():
|
2580
|
-
get lastMessage():
|
2581
|
-
set messages(messages:
|
2608
|
+
get messages(): UI_MESSAGE[];
|
2609
|
+
get lastMessage(): UI_MESSAGE | undefined;
|
2610
|
+
set messages(messages: UI_MESSAGE[]);
|
2582
2611
|
removeAssistantResponse: () => void;
|
2583
2612
|
/**
|
2584
2613
|
* Append a user message to the chat list. This triggers the API call to fetch
|
2585
2614
|
* the assistant's response.
|
2586
2615
|
*/
|
2587
|
-
sendMessage: (message: (CreateUIMessage<
|
2616
|
+
sendMessage: (message: (CreateUIMessage<UI_MESSAGE> & {
|
2588
2617
|
text?: never;
|
2589
2618
|
files?: never;
|
2590
2619
|
}) | {
|
2591
2620
|
text: string;
|
2592
2621
|
files?: FileList | FileUIPart[];
|
2593
|
-
metadata?:
|
2622
|
+
metadata?: InferUIMessageMetadata<UI_MESSAGE>;
|
2594
2623
|
parts?: never;
|
2595
2624
|
} | {
|
2596
2625
|
files: FileList | FileUIPart[];
|
2597
|
-
metadata?:
|
2626
|
+
metadata?: InferUIMessageMetadata<UI_MESSAGE>;
|
2598
2627
|
parts?: never;
|
2599
2628
|
}, options?: ChatRequestOptions) => Promise<void>;
|
2600
2629
|
/**
|
@@ -2605,9 +2634,9 @@ declare abstract class AbstractChat<MESSAGE_METADATA = unknown, UI_DATA_PART_SCH
|
|
2605
2634
|
* Resume an ongoing chat generation stream. This does not resume an aborted generation.
|
2606
2635
|
*/
|
2607
2636
|
experimental_resume: (options?: ChatRequestOptions) => Promise<void>;
|
2608
|
-
addToolResult: ({ toolCallId,
|
2637
|
+
addToolResult: ({ toolCallId, output, }: {
|
2609
2638
|
toolCallId: string;
|
2610
|
-
|
2639
|
+
output: unknown;
|
2611
2640
|
}) => Promise<void>;
|
2612
2641
|
/**
|
2613
2642
|
* Abort the current request immediately, keep the generated tokens if any.
|
@@ -2630,9 +2659,9 @@ declare function convertToModelMessages<TOOLS extends ToolSet = never>(messages:
|
|
2630
2659
|
*/
|
2631
2660
|
declare const convertToCoreMessages: typeof convertToModelMessages;
|
2632
2661
|
|
2633
|
-
type PrepareRequest<
|
2662
|
+
type PrepareRequest<UI_MESSAGE extends UIMessage> = (options: {
|
2634
2663
|
id: string;
|
2635
|
-
messages:
|
2664
|
+
messages: UI_MESSAGE[];
|
2636
2665
|
requestMetadata: unknown;
|
2637
2666
|
body: Record<string, any> | undefined;
|
2638
2667
|
credentials: RequestCredentials | undefined;
|
@@ -2643,7 +2672,7 @@ type PrepareRequest<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> = (options
|
|
2643
2672
|
credentials?: RequestCredentials;
|
2644
2673
|
};
|
2645
2674
|
|
2646
|
-
declare class DefaultChatTransport<
|
2675
|
+
declare class DefaultChatTransport<UI_MESSAGE extends UIMessage> implements ChatTransport<UI_MESSAGE> {
|
2647
2676
|
private api;
|
2648
2677
|
private credentials?;
|
2649
2678
|
private headers?;
|
@@ -2689,14 +2718,12 @@ declare class DefaultChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTy
|
|
2689
2718
|
* @param messages The current messages in the chat.
|
2690
2719
|
* @param requestBody The request body object passed in the chat request.
|
2691
2720
|
*/
|
2692
|
-
prepareRequest?: PrepareRequest<
|
2721
|
+
prepareRequest?: PrepareRequest<UI_MESSAGE>;
|
2693
2722
|
});
|
2694
|
-
submitMessages({ chatId, messages, abortSignal, metadata, headers, body, requestType, }: Parameters<ChatTransport<
|
2723
|
+
submitMessages({ chatId, messages, abortSignal, metadata, headers, body, requestType, }: Parameters<ChatTransport<UI_MESSAGE>['submitMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart>>;
|
2695
2724
|
}
|
2696
2725
|
|
2697
|
-
declare
|
2698
|
-
|
2699
|
-
declare class TextStreamChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> implements ChatTransport<MESSAGE_METADATA, DATA_TYPES> {
|
2726
|
+
declare class TextStreamChatTransport<UI_MESSAGE extends UIMessage> implements ChatTransport<UI_MESSAGE> {
|
2700
2727
|
private api;
|
2701
2728
|
private credentials?;
|
2702
2729
|
private headers?;
|
@@ -2742,9 +2769,9 @@ declare class TextStreamChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDat
|
|
2742
2769
|
* @param messages The current messages in the chat.
|
2743
2770
|
* @param requestBody The request body object passed in the chat request.
|
2744
2771
|
*/
|
2745
|
-
prepareRequest?: NoInfer<PrepareRequest<
|
2772
|
+
prepareRequest?: NoInfer<PrepareRequest<UI_MESSAGE>>;
|
2746
2773
|
});
|
2747
|
-
submitMessages({ chatId, messages, abortSignal, metadata, headers, body, requestType, }: Parameters<ChatTransport<
|
2774
|
+
submitMessages({ chatId, messages, abortSignal, metadata, headers, body, requestType, }: Parameters<ChatTransport<UI_MESSAGE>['submitMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart<never, never>>>;
|
2748
2775
|
}
|
2749
2776
|
|
2750
2777
|
type CompletionRequestOptions = {
|
@@ -2838,23 +2865,6 @@ declare function cosineSimilarity(vector1: number[], vector2: number[]): number;
|
|
2838
2865
|
*/
|
2839
2866
|
declare function getTextFromDataUrl(dataUrl: string): string;
|
2840
2867
|
|
2841
|
-
/**
|
2842
|
-
Create a type from an object with all keys and nested keys set to optional.
|
2843
|
-
The helper supports normal objects and Zod schemas (which are resolved automatically).
|
2844
|
-
It always recurses into arrays.
|
2845
|
-
|
2846
|
-
Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
2847
|
-
*/
|
2848
|
-
type DeepPartial<T> = T extends z3.ZodTypeAny ? DeepPartialInternal<z3.infer<T>> : T extends z4.$ZodType ? DeepPartialInternal<z4.infer<T>> : DeepPartialInternal<T>;
|
2849
|
-
type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
|
2850
|
-
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
2851
|
-
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
2852
|
-
type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
2853
|
-
type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
|
2854
|
-
type PartialObject<ObjectType extends object> = {
|
2855
|
-
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
2856
|
-
};
|
2857
|
-
|
2858
2868
|
/**
|
2859
2869
|
* Performs a deep-equal comparison of two parsed JSON objects.
|
2860
2870
|
*
|
@@ -3428,14 +3438,8 @@ type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
|
|
3428
3438
|
|
3429
3439
|
type UIMessageStreamOptions<UI_MESSAGE extends UIMessage> = {
|
3430
3440
|
/**
|
3431
|
-
*
|
3432
|
-
*
|
3433
|
-
* if the last original message is not an assistant message
|
3434
|
-
* (in which case that message ID is used).
|
3435
|
-
*/
|
3436
|
-
newMessageId?: string;
|
3437
|
-
/**
|
3438
|
-
* The original messages.
|
3441
|
+
* The original messages. If they are provided, persistence mode is assumed,
|
3442
|
+
* and a message ID is provided for the response message.
|
3439
3443
|
*/
|
3440
3444
|
originalMessages?: UI_MESSAGE[];
|
3441
3445
|
onFinish?: (options: {
|
@@ -3460,13 +3464,11 @@ type UIMessageStreamOptions<UI_MESSAGE extends UIMessage> = {
|
|
3460
3464
|
* Called on `start` and `finish` events.
|
3461
3465
|
*/
|
3462
3466
|
messageMetadata?: (options: {
|
3463
|
-
part: TextStreamPart<ToolSet
|
3464
|
-
type: 'start' | 'finish' | 'start-step' | 'finish-step';
|
3465
|
-
};
|
3467
|
+
part: TextStreamPart<ToolSet>;
|
3466
3468
|
}) => InferUIMessageMetadata<UI_MESSAGE> | undefined;
|
3467
3469
|
/**
|
3468
3470
|
* Send reasoning parts to the client.
|
3469
|
-
* Default to
|
3471
|
+
* Default to true.
|
3470
3472
|
*/
|
3471
3473
|
sendReasoning?: boolean;
|
3472
3474
|
/**
|
@@ -3696,7 +3698,7 @@ type TextStreamPart<TOOLS extends ToolSet> = ContentPart<TOOLS> | {
|
|
3696
3698
|
type: 'tool-call-delta';
|
3697
3699
|
toolCallId: string;
|
3698
3700
|
toolName: string;
|
3699
|
-
|
3701
|
+
inputTextDelta: string;
|
3700
3702
|
} | {
|
3701
3703
|
type: 'start-step';
|
3702
3704
|
request: LanguageModelRequestMetadata;
|
@@ -3781,7 +3783,7 @@ Callback that is set using the `onChunk` option.
|
|
3781
3783
|
*/
|
3782
3784
|
type StreamTextOnChunkCallback<TOOLS extends ToolSet> = (event: {
|
3783
3785
|
chunk: Extract<TextStreamPart<TOOLS>, {
|
3784
|
-
type: 'text' | 'reasoning' | 'source' | 'tool-call' | 'tool-call-streaming-start' | 'tool-call-delta' | 'tool-result';
|
3786
|
+
type: 'text' | 'reasoning' | 'source' | 'tool-call' | 'tool-call-streaming-start' | 'tool-call-delta' | 'tool-result' | 'raw';
|
3785
3787
|
}>;
|
3786
3788
|
}) => Promise<void> | void;
|
3787
3789
|
/**
|
@@ -4840,4 +4842,4 @@ declare function transcribe({ model, audio, providerOptions, maxRetries: maxRetr
|
|
4840
4842
|
headers?: Record<string, string>;
|
4841
4843
|
}): Promise<TranscriptionResult>;
|
4842
4844
|
|
4843
|
-
export { AbstractChat, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, ChatInit, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GLOBAL_DEFAULT_PROVIDER, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, ImagePart, InferUIDataParts, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError,
|
4845
|
+
export { AbstractChat, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, ChatInit, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GLOBAL_DEFAULT_PROVIDER, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, ImagePart, InferUIDataParts, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, ModelMessage, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, SystemModelMessage, TelemetrySettings, TextPart, TextStreamChatTransport, TextStreamPart, TextUIPart, Tool, ToolCallOptions, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseCompletionOptions, UserContent, UserModelMessage, assistantModelMessageSchema, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel };
|