@zenning/ai 5.0.42-patch → 5.0.42

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.
@@ -0,0 +1,198 @@
1
+ import { ModelMessage, Tool } from '@ai-sdk/provider-utils';
2
+ export { convertAsyncIteratorToReadableStream } from '@ai-sdk/provider-utils';
3
+ import { LanguageModelV2Prompt, LanguageModelV2FunctionTool, LanguageModelV2ProviderDefinedTool, LanguageModelV2ToolChoice } from '@ai-sdk/provider';
4
+
5
+ /**
6
+ * Experimental. Can change in patch versions without warning.
7
+ *
8
+ * Download function. Called with the array of URLs and a boolean indicating
9
+ * whether the URL is supported by the model.
10
+ *
11
+ * The download function can decide for each URL:
12
+ * - to return null (which means that the URL should be passed to the model)
13
+ * - to download the asset and return the data (incl. retries, authentication, etc.)
14
+ *
15
+ * Should throw DownloadError if the download fails.
16
+ *
17
+ * Should return an array of objects sorted by the order of the requested downloads.
18
+ * For each object, the data should be a Uint8Array if the URL was downloaded.
19
+ * For each object, the mediaType should be the media type of the downloaded asset.
20
+ * For each object, the data should be null if the URL should be passed through as is.
21
+ */
22
+ type DownloadFunction = (options: Array<{
23
+ url: URL;
24
+ isUrlSupportedByModel: boolean;
25
+ }>) => PromiseLike<Array<{
26
+ data: Uint8Array;
27
+ mediaType: string | undefined;
28
+ } | null>>;
29
+
30
+ /**
31
+ Prompt part of the AI function options.
32
+ It contains a system message, a simple text prompt, or a list of messages.
33
+ */
34
+ type Prompt = {
35
+ /**
36
+ System message to include in the prompt. Can be used with `prompt` or `messages`.
37
+ */
38
+ system?: string;
39
+ } & ({
40
+ /**
41
+ A prompt. It can be either a text prompt or a list of messages.
42
+
43
+ You can either use `prompt` or `messages` but not both.
44
+ */
45
+ prompt: string | Array<ModelMessage>;
46
+ /**
47
+ A list of messages.
48
+
49
+ You can either use `prompt` or `messages` but not both.
50
+ */
51
+ messages?: never;
52
+ } | {
53
+ /**
54
+ A list of messages.
55
+
56
+ You can either use `prompt` or `messages` but not both.
57
+ */
58
+ messages: Array<ModelMessage>;
59
+ /**
60
+ A prompt. It can be either a text prompt or a list of messages.
61
+
62
+ You can either use `prompt` or `messages` but not both.
63
+ */
64
+ prompt?: never;
65
+ });
66
+
67
+ type StandardizedPrompt = {
68
+ /**
69
+ * System message.
70
+ */
71
+ system?: string;
72
+ /**
73
+ * Messages.
74
+ */
75
+ messages: ModelMessage[];
76
+ };
77
+ declare function standardizePrompt(prompt: Prompt): Promise<StandardizedPrompt>;
78
+
79
+ declare function convertToLanguageModelPrompt({ prompt, supportedUrls, download, }: {
80
+ prompt: StandardizedPrompt;
81
+ supportedUrls: Record<string, RegExp[]>;
82
+ download: DownloadFunction | undefined;
83
+ }): Promise<LanguageModelV2Prompt>;
84
+
85
+ type CallSettings = {
86
+ /**
87
+ Maximum number of tokens to generate.
88
+ */
89
+ maxOutputTokens?: number;
90
+ /**
91
+ Temperature setting. The range depends on the provider and model.
92
+
93
+ It is recommended to set either `temperature` or `topP`, but not both.
94
+ */
95
+ temperature?: number;
96
+ /**
97
+ Nucleus sampling. This is a number between 0 and 1.
98
+
99
+ E.g. 0.1 would mean that only tokens with the top 10% probability mass
100
+ are considered.
101
+
102
+ It is recommended to set either `temperature` or `topP`, but not both.
103
+ */
104
+ topP?: number;
105
+ /**
106
+ Only sample from the top K options for each subsequent token.
107
+
108
+ Used to remove "long tail" low probability responses.
109
+ Recommended for advanced use cases only. You usually only need to use temperature.
110
+ */
111
+ topK?: number;
112
+ /**
113
+ Presence penalty setting. It affects the likelihood of the model to
114
+ repeat information that is already in the prompt.
115
+
116
+ The presence penalty is a number between -1 (increase repetition)
117
+ and 1 (maximum penalty, decrease repetition). 0 means no penalty.
118
+ */
119
+ presencePenalty?: number;
120
+ /**
121
+ Frequency penalty setting. It affects the likelihood of the model
122
+ to repeatedly use the same words or phrases.
123
+
124
+ The frequency penalty is a number between -1 (increase repetition)
125
+ and 1 (maximum penalty, decrease repetition). 0 means no penalty.
126
+ */
127
+ frequencyPenalty?: number;
128
+ /**
129
+ Stop sequences.
130
+ If set, the model will stop generating text when one of the stop sequences is generated.
131
+ Providers may have limits on the number of stop sequences.
132
+ */
133
+ stopSequences?: string[];
134
+ /**
135
+ The seed (integer) to use for random sampling. If set and supported
136
+ by the model, calls will generate deterministic results.
137
+ */
138
+ seed?: number;
139
+ /**
140
+ Maximum number of retries. Set to 0 to disable retries.
141
+
142
+ @default 2
143
+ */
144
+ maxRetries?: number;
145
+ /**
146
+ Abort signal.
147
+ */
148
+ abortSignal?: AbortSignal;
149
+ /**
150
+ Additional HTTP headers to be sent with the request.
151
+ Only applicable for HTTP-based providers.
152
+ */
153
+ headers?: Record<string, string | undefined>;
154
+ };
155
+
156
+ /**
157
+ Tool choice for the generation. It supports the following settings:
158
+
159
+ - `auto` (default): the model can choose whether and which tools to call.
160
+ - `required`: the model must call a tool. It can choose which tool to call.
161
+ - `none`: the model must not call tools
162
+ - `{ type: 'tool', toolName: string (typed) }`: the model must call the specified tool
163
+ */
164
+ type ToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | 'required' | {
165
+ type: 'tool';
166
+ toolName: Extract<keyof TOOLS, string>;
167
+ };
168
+
169
+ type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta'>>;
170
+
171
+ declare function prepareToolsAndToolChoice<TOOLS extends ToolSet>({ tools, toolChoice, activeTools, }: {
172
+ tools: TOOLS | undefined;
173
+ toolChoice: ToolChoice<TOOLS> | undefined;
174
+ activeTools: Array<keyof TOOLS> | undefined;
175
+ }): {
176
+ tools: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool> | undefined;
177
+ toolChoice: LanguageModelV2ToolChoice | undefined;
178
+ };
179
+
180
+ /**
181
+ * Validates call settings and returns a new object with limited values.
182
+ */
183
+ declare function prepareCallSettings({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, seed, stopSequences, }: Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries'>): Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries'>;
184
+
185
+ type RetryFunction = <OUTPUT>(fn: () => PromiseLike<OUTPUT>) => PromiseLike<OUTPUT>;
186
+
187
+ /**
188
+ * Validate and prepare retries.
189
+ */
190
+ declare function prepareRetries({ maxRetries, abortSignal, }: {
191
+ maxRetries: number | undefined;
192
+ abortSignal: AbortSignal | undefined;
193
+ }): {
194
+ maxRetries: number;
195
+ retry: RetryFunction;
196
+ };
197
+
198
+ export { convertToLanguageModelPrompt, prepareCallSettings, prepareRetries, prepareToolsAndToolChoice, standardizePrompt };
@@ -0,0 +1,198 @@
1
+ import { ModelMessage, Tool } from '@ai-sdk/provider-utils';
2
+ export { convertAsyncIteratorToReadableStream } from '@ai-sdk/provider-utils';
3
+ import { LanguageModelV2Prompt, LanguageModelV2FunctionTool, LanguageModelV2ProviderDefinedTool, LanguageModelV2ToolChoice } from '@ai-sdk/provider';
4
+
5
+ /**
6
+ * Experimental. Can change in patch versions without warning.
7
+ *
8
+ * Download function. Called with the array of URLs and a boolean indicating
9
+ * whether the URL is supported by the model.
10
+ *
11
+ * The download function can decide for each URL:
12
+ * - to return null (which means that the URL should be passed to the model)
13
+ * - to download the asset and return the data (incl. retries, authentication, etc.)
14
+ *
15
+ * Should throw DownloadError if the download fails.
16
+ *
17
+ * Should return an array of objects sorted by the order of the requested downloads.
18
+ * For each object, the data should be a Uint8Array if the URL was downloaded.
19
+ * For each object, the mediaType should be the media type of the downloaded asset.
20
+ * For each object, the data should be null if the URL should be passed through as is.
21
+ */
22
+ type DownloadFunction = (options: Array<{
23
+ url: URL;
24
+ isUrlSupportedByModel: boolean;
25
+ }>) => PromiseLike<Array<{
26
+ data: Uint8Array;
27
+ mediaType: string | undefined;
28
+ } | null>>;
29
+
30
+ /**
31
+ Prompt part of the AI function options.
32
+ It contains a system message, a simple text prompt, or a list of messages.
33
+ */
34
+ type Prompt = {
35
+ /**
36
+ System message to include in the prompt. Can be used with `prompt` or `messages`.
37
+ */
38
+ system?: string;
39
+ } & ({
40
+ /**
41
+ A prompt. It can be either a text prompt or a list of messages.
42
+
43
+ You can either use `prompt` or `messages` but not both.
44
+ */
45
+ prompt: string | Array<ModelMessage>;
46
+ /**
47
+ A list of messages.
48
+
49
+ You can either use `prompt` or `messages` but not both.
50
+ */
51
+ messages?: never;
52
+ } | {
53
+ /**
54
+ A list of messages.
55
+
56
+ You can either use `prompt` or `messages` but not both.
57
+ */
58
+ messages: Array<ModelMessage>;
59
+ /**
60
+ A prompt. It can be either a text prompt or a list of messages.
61
+
62
+ You can either use `prompt` or `messages` but not both.
63
+ */
64
+ prompt?: never;
65
+ });
66
+
67
+ type StandardizedPrompt = {
68
+ /**
69
+ * System message.
70
+ */
71
+ system?: string;
72
+ /**
73
+ * Messages.
74
+ */
75
+ messages: ModelMessage[];
76
+ };
77
+ declare function standardizePrompt(prompt: Prompt): Promise<StandardizedPrompt>;
78
+
79
+ declare function convertToLanguageModelPrompt({ prompt, supportedUrls, download, }: {
80
+ prompt: StandardizedPrompt;
81
+ supportedUrls: Record<string, RegExp[]>;
82
+ download: DownloadFunction | undefined;
83
+ }): Promise<LanguageModelV2Prompt>;
84
+
85
+ type CallSettings = {
86
+ /**
87
+ Maximum number of tokens to generate.
88
+ */
89
+ maxOutputTokens?: number;
90
+ /**
91
+ Temperature setting. The range depends on the provider and model.
92
+
93
+ It is recommended to set either `temperature` or `topP`, but not both.
94
+ */
95
+ temperature?: number;
96
+ /**
97
+ Nucleus sampling. This is a number between 0 and 1.
98
+
99
+ E.g. 0.1 would mean that only tokens with the top 10% probability mass
100
+ are considered.
101
+
102
+ It is recommended to set either `temperature` or `topP`, but not both.
103
+ */
104
+ topP?: number;
105
+ /**
106
+ Only sample from the top K options for each subsequent token.
107
+
108
+ Used to remove "long tail" low probability responses.
109
+ Recommended for advanced use cases only. You usually only need to use temperature.
110
+ */
111
+ topK?: number;
112
+ /**
113
+ Presence penalty setting. It affects the likelihood of the model to
114
+ repeat information that is already in the prompt.
115
+
116
+ The presence penalty is a number between -1 (increase repetition)
117
+ and 1 (maximum penalty, decrease repetition). 0 means no penalty.
118
+ */
119
+ presencePenalty?: number;
120
+ /**
121
+ Frequency penalty setting. It affects the likelihood of the model
122
+ to repeatedly use the same words or phrases.
123
+
124
+ The frequency penalty is a number between -1 (increase repetition)
125
+ and 1 (maximum penalty, decrease repetition). 0 means no penalty.
126
+ */
127
+ frequencyPenalty?: number;
128
+ /**
129
+ Stop sequences.
130
+ If set, the model will stop generating text when one of the stop sequences is generated.
131
+ Providers may have limits on the number of stop sequences.
132
+ */
133
+ stopSequences?: string[];
134
+ /**
135
+ The seed (integer) to use for random sampling. If set and supported
136
+ by the model, calls will generate deterministic results.
137
+ */
138
+ seed?: number;
139
+ /**
140
+ Maximum number of retries. Set to 0 to disable retries.
141
+
142
+ @default 2
143
+ */
144
+ maxRetries?: number;
145
+ /**
146
+ Abort signal.
147
+ */
148
+ abortSignal?: AbortSignal;
149
+ /**
150
+ Additional HTTP headers to be sent with the request.
151
+ Only applicable for HTTP-based providers.
152
+ */
153
+ headers?: Record<string, string | undefined>;
154
+ };
155
+
156
+ /**
157
+ Tool choice for the generation. It supports the following settings:
158
+
159
+ - `auto` (default): the model can choose whether and which tools to call.
160
+ - `required`: the model must call a tool. It can choose which tool to call.
161
+ - `none`: the model must not call tools
162
+ - `{ type: 'tool', toolName: string (typed) }`: the model must call the specified tool
163
+ */
164
+ type ToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | 'required' | {
165
+ type: 'tool';
166
+ toolName: Extract<keyof TOOLS, string>;
167
+ };
168
+
169
+ type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta'>>;
170
+
171
+ declare function prepareToolsAndToolChoice<TOOLS extends ToolSet>({ tools, toolChoice, activeTools, }: {
172
+ tools: TOOLS | undefined;
173
+ toolChoice: ToolChoice<TOOLS> | undefined;
174
+ activeTools: Array<keyof TOOLS> | undefined;
175
+ }): {
176
+ tools: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool> | undefined;
177
+ toolChoice: LanguageModelV2ToolChoice | undefined;
178
+ };
179
+
180
+ /**
181
+ * Validates call settings and returns a new object with limited values.
182
+ */
183
+ declare function prepareCallSettings({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, seed, stopSequences, }: Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries'>): Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries'>;
184
+
185
+ type RetryFunction = <OUTPUT>(fn: () => PromiseLike<OUTPUT>) => PromiseLike<OUTPUT>;
186
+
187
+ /**
188
+ * Validate and prepare retries.
189
+ */
190
+ declare function prepareRetries({ maxRetries, abortSignal, }: {
191
+ maxRetries: number | undefined;
192
+ abortSignal: AbortSignal | undefined;
193
+ }): {
194
+ maxRetries: number;
195
+ retry: RetryFunction;
196
+ };
197
+
198
+ export { convertToLanguageModelPrompt, prepareCallSettings, prepareRetries, prepareToolsAndToolChoice, standardizePrompt };
@@ -0,0 +1,89 @@
1
+ import { IOType } from 'node:child_process';
2
+ import { Stream } from 'node:stream';
3
+ import { z } from 'zod/v4';
4
+
5
+ declare const JSONRPCMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
6
+ jsonrpc: z.ZodLiteral<"2.0">;
7
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
8
+ method: z.ZodString;
9
+ params: z.ZodOptional<z.ZodObject<{
10
+ _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
11
+ }, z.core.$loose>>;
12
+ }, z.core.$strict>, z.ZodObject<{
13
+ jsonrpc: z.ZodLiteral<"2.0">;
14
+ method: z.ZodString;
15
+ params: z.ZodOptional<z.ZodObject<{
16
+ _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
17
+ }, z.core.$loose>>;
18
+ }, z.core.$strict>, z.ZodObject<{
19
+ jsonrpc: z.ZodLiteral<"2.0">;
20
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
21
+ result: z.ZodObject<{
22
+ _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
23
+ }, z.core.$loose>;
24
+ }, z.core.$strict>, z.ZodObject<{
25
+ jsonrpc: z.ZodLiteral<"2.0">;
26
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
27
+ error: z.ZodObject<{
28
+ code: z.ZodNumber;
29
+ message: z.ZodString;
30
+ data: z.ZodOptional<z.ZodUnknown>;
31
+ }, z.core.$strip>;
32
+ }, z.core.$strict>]>;
33
+ type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
34
+
35
+ /**
36
+ * Transport interface for MCP (Model Context Protocol) communication.
37
+ * Maps to the `Transport` interface in the MCP spec.
38
+ */
39
+ interface MCPTransport {
40
+ /**
41
+ * Initialize and start the transport
42
+ */
43
+ start(): Promise<void>;
44
+ /**
45
+ * Send a JSON-RPC message through the transport
46
+ * @param message The JSON-RPC message to send
47
+ */
48
+ send(message: JSONRPCMessage): Promise<void>;
49
+ /**
50
+ * Clean up and close the transport
51
+ */
52
+ close(): Promise<void>;
53
+ /**
54
+ * Event handler for transport closure
55
+ */
56
+ onclose?: () => void;
57
+ /**
58
+ * Event handler for transport errors
59
+ */
60
+ onerror?: (error: Error) => void;
61
+ /**
62
+ * Event handler for received messages
63
+ */
64
+ onmessage?: (message: JSONRPCMessage) => void;
65
+ }
66
+
67
+ interface StdioConfig {
68
+ command: string;
69
+ args?: string[];
70
+ env?: Record<string, string>;
71
+ stderr?: IOType | Stream | number;
72
+ cwd?: string;
73
+ }
74
+ declare class StdioMCPTransport implements MCPTransport {
75
+ private process?;
76
+ private abortController;
77
+ private readBuffer;
78
+ private serverParams;
79
+ onclose?: () => void;
80
+ onerror?: (error: unknown) => void;
81
+ onmessage?: (message: JSONRPCMessage) => void;
82
+ constructor(server: StdioConfig);
83
+ start(): Promise<void>;
84
+ private processReadBuffer;
85
+ close(): Promise<void>;
86
+ send(message: JSONRPCMessage): Promise<void>;
87
+ }
88
+
89
+ export { StdioMCPTransport as Experimental_StdioMCPTransport, StdioConfig };
@@ -0,0 +1,89 @@
1
+ import { IOType } from 'node:child_process';
2
+ import { Stream } from 'node:stream';
3
+ import { z } from 'zod/v4';
4
+
5
+ declare const JSONRPCMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
6
+ jsonrpc: z.ZodLiteral<"2.0">;
7
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
8
+ method: z.ZodString;
9
+ params: z.ZodOptional<z.ZodObject<{
10
+ _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
11
+ }, z.core.$loose>>;
12
+ }, z.core.$strict>, z.ZodObject<{
13
+ jsonrpc: z.ZodLiteral<"2.0">;
14
+ method: z.ZodString;
15
+ params: z.ZodOptional<z.ZodObject<{
16
+ _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
17
+ }, z.core.$loose>>;
18
+ }, z.core.$strict>, z.ZodObject<{
19
+ jsonrpc: z.ZodLiteral<"2.0">;
20
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
21
+ result: z.ZodObject<{
22
+ _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
23
+ }, z.core.$loose>;
24
+ }, z.core.$strict>, z.ZodObject<{
25
+ jsonrpc: z.ZodLiteral<"2.0">;
26
+ id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
27
+ error: z.ZodObject<{
28
+ code: z.ZodNumber;
29
+ message: z.ZodString;
30
+ data: z.ZodOptional<z.ZodUnknown>;
31
+ }, z.core.$strip>;
32
+ }, z.core.$strict>]>;
33
+ type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
34
+
35
+ /**
36
+ * Transport interface for MCP (Model Context Protocol) communication.
37
+ * Maps to the `Transport` interface in the MCP spec.
38
+ */
39
+ interface MCPTransport {
40
+ /**
41
+ * Initialize and start the transport
42
+ */
43
+ start(): Promise<void>;
44
+ /**
45
+ * Send a JSON-RPC message through the transport
46
+ * @param message The JSON-RPC message to send
47
+ */
48
+ send(message: JSONRPCMessage): Promise<void>;
49
+ /**
50
+ * Clean up and close the transport
51
+ */
52
+ close(): Promise<void>;
53
+ /**
54
+ * Event handler for transport closure
55
+ */
56
+ onclose?: () => void;
57
+ /**
58
+ * Event handler for transport errors
59
+ */
60
+ onerror?: (error: Error) => void;
61
+ /**
62
+ * Event handler for received messages
63
+ */
64
+ onmessage?: (message: JSONRPCMessage) => void;
65
+ }
66
+
67
+ interface StdioConfig {
68
+ command: string;
69
+ args?: string[];
70
+ env?: Record<string, string>;
71
+ stderr?: IOType | Stream | number;
72
+ cwd?: string;
73
+ }
74
+ declare class StdioMCPTransport implements MCPTransport {
75
+ private process?;
76
+ private abortController;
77
+ private readBuffer;
78
+ private serverParams;
79
+ onclose?: () => void;
80
+ onerror?: (error: unknown) => void;
81
+ onmessage?: (message: JSONRPCMessage) => void;
82
+ constructor(server: StdioConfig);
83
+ start(): Promise<void>;
84
+ private processReadBuffer;
85
+ close(): Promise<void>;
86
+ send(message: JSONRPCMessage): Promise<void>;
87
+ }
88
+
89
+ export { StdioMCPTransport as Experimental_StdioMCPTransport, StdioConfig };
@@ -0,0 +1,117 @@
1
+ export { convertArrayToAsyncIterable, convertArrayToReadableStream, convertReadableStreamToArray, mockId } from '@ai-sdk/provider-utils/test';
2
+ import { EmbeddingModelV2, ImageModelV2, LanguageModelV2, ProviderV2, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
3
+
4
+ declare class MockEmbeddingModelV2<VALUE> implements EmbeddingModelV2<VALUE> {
5
+ readonly specificationVersion = "v2";
6
+ readonly provider: EmbeddingModelV2<VALUE>['provider'];
7
+ readonly modelId: EmbeddingModelV2<VALUE>['modelId'];
8
+ readonly maxEmbeddingsPerCall: EmbeddingModelV2<VALUE>['maxEmbeddingsPerCall'];
9
+ readonly supportsParallelCalls: EmbeddingModelV2<VALUE>['supportsParallelCalls'];
10
+ doEmbed: EmbeddingModelV2<VALUE>['doEmbed'];
11
+ constructor({ provider, modelId, maxEmbeddingsPerCall, supportsParallelCalls, doEmbed, }?: {
12
+ provider?: EmbeddingModelV2<VALUE>['provider'];
13
+ modelId?: EmbeddingModelV2<VALUE>['modelId'];
14
+ maxEmbeddingsPerCall?: EmbeddingModelV2<VALUE>['maxEmbeddingsPerCall'] | null;
15
+ supportsParallelCalls?: EmbeddingModelV2<VALUE>['supportsParallelCalls'];
16
+ doEmbed?: EmbeddingModelV2<VALUE>['doEmbed'];
17
+ });
18
+ }
19
+
20
+ declare class MockImageModelV2 implements ImageModelV2 {
21
+ readonly specificationVersion = "v2";
22
+ readonly provider: ImageModelV2['provider'];
23
+ readonly modelId: ImageModelV2['modelId'];
24
+ readonly maxImagesPerCall: ImageModelV2['maxImagesPerCall'];
25
+ doGenerate: ImageModelV2['doGenerate'];
26
+ constructor({ provider, modelId, maxImagesPerCall, doGenerate, }?: {
27
+ provider?: ImageModelV2['provider'];
28
+ modelId?: ImageModelV2['modelId'];
29
+ maxImagesPerCall?: ImageModelV2['maxImagesPerCall'];
30
+ doGenerate?: ImageModelV2['doGenerate'];
31
+ });
32
+ }
33
+
34
+ declare class MockLanguageModelV2 implements LanguageModelV2 {
35
+ readonly specificationVersion = "v2";
36
+ private _supportedUrls;
37
+ readonly provider: LanguageModelV2['provider'];
38
+ readonly modelId: LanguageModelV2['modelId'];
39
+ doGenerate: LanguageModelV2['doGenerate'];
40
+ doStream: LanguageModelV2['doStream'];
41
+ doGenerateCalls: Parameters<LanguageModelV2['doGenerate']>[0][];
42
+ doStreamCalls: Parameters<LanguageModelV2['doStream']>[0][];
43
+ constructor({ provider, modelId, supportedUrls, doGenerate, doStream, }?: {
44
+ provider?: LanguageModelV2['provider'];
45
+ modelId?: LanguageModelV2['modelId'];
46
+ supportedUrls?: LanguageModelV2['supportedUrls'] | (() => LanguageModelV2['supportedUrls']);
47
+ doGenerate?: LanguageModelV2['doGenerate'] | Awaited<ReturnType<LanguageModelV2['doGenerate']>> | Awaited<ReturnType<LanguageModelV2['doGenerate']>>[];
48
+ doStream?: LanguageModelV2['doStream'] | Awaited<ReturnType<LanguageModelV2['doStream']>> | Awaited<ReturnType<LanguageModelV2['doStream']>>[];
49
+ });
50
+ get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
51
+ }
52
+
53
+ declare class MockProviderV2 implements ProviderV2 {
54
+ languageModel: ProviderV2['languageModel'];
55
+ textEmbeddingModel: ProviderV2['textEmbeddingModel'];
56
+ imageModel: ProviderV2['imageModel'];
57
+ transcriptionModel: ProviderV2['transcriptionModel'];
58
+ speechModel: ProviderV2['speechModel'];
59
+ constructor({ languageModels, embeddingModels, imageModels, transcriptionModels, speechModels, }?: {
60
+ languageModels?: Record<string, LanguageModelV2>;
61
+ embeddingModels?: Record<string, EmbeddingModelV2<string>>;
62
+ imageModels?: Record<string, ImageModelV2>;
63
+ transcriptionModels?: Record<string, TranscriptionModelV2>;
64
+ speechModels?: Record<string, SpeechModelV2>;
65
+ });
66
+ }
67
+
68
+ declare class MockSpeechModelV2 implements SpeechModelV2 {
69
+ readonly specificationVersion = "v2";
70
+ readonly provider: SpeechModelV2['provider'];
71
+ readonly modelId: SpeechModelV2['modelId'];
72
+ doGenerate: SpeechModelV2['doGenerate'];
73
+ constructor({ provider, modelId, doGenerate, }?: {
74
+ provider?: SpeechModelV2['provider'];
75
+ modelId?: SpeechModelV2['modelId'];
76
+ doGenerate?: SpeechModelV2['doGenerate'];
77
+ });
78
+ }
79
+
80
+ declare class MockTranscriptionModelV2 implements TranscriptionModelV2 {
81
+ readonly specificationVersion = "v2";
82
+ readonly provider: TranscriptionModelV2['provider'];
83
+ readonly modelId: TranscriptionModelV2['modelId'];
84
+ doGenerate: TranscriptionModelV2['doGenerate'];
85
+ constructor({ provider, modelId, doGenerate, }?: {
86
+ provider?: TranscriptionModelV2['provider'];
87
+ modelId?: TranscriptionModelV2['modelId'];
88
+ doGenerate?: TranscriptionModelV2['doGenerate'];
89
+ });
90
+ }
91
+
92
+ declare function mockValues<T>(...values: T[]): () => T;
93
+
94
+ /**
95
+ * Creates a ReadableStream that emits the provided values with an optional delay between each value.
96
+ *
97
+ * @param options - The configuration options
98
+ * @param options.chunks - Array of values to be emitted by the stream
99
+ * @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
100
+ * @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
101
+ * @returns A ReadableStream that emits the provided values
102
+ */
103
+ declare function simulateReadableStream$1<T>({ chunks, initialDelayInMs, chunkDelayInMs, _internal, }: {
104
+ chunks: T[];
105
+ initialDelayInMs?: number | null;
106
+ chunkDelayInMs?: number | null;
107
+ _internal?: {
108
+ delay?: (ms: number | null) => Promise<void>;
109
+ };
110
+ }): ReadableStream<T>;
111
+
112
+ /**
113
+ * @deprecated Use `simulateReadableStream` from `ai` instead.
114
+ */
115
+ declare const simulateReadableStream: typeof simulateReadableStream$1;
116
+
117
+ export { MockEmbeddingModelV2, MockImageModelV2, MockLanguageModelV2, MockProviderV2, MockSpeechModelV2, MockTranscriptionModelV2, mockValues, simulateReadableStream };