ai 5.0.0-canary.1 → 5.0.0-canary.11

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +146 -0
  2. package/dist/index.d.mts +1465 -727
  3. package/dist/index.d.ts +1465 -727
  4. package/dist/index.js +2802 -1263
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +2692 -1190
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/internal/index.d.mts +732 -0
  9. package/dist/internal/index.d.ts +732 -0
  10. package/dist/internal/index.js +1490 -0
  11. package/dist/internal/index.js.map +1 -0
  12. package/{rsc/dist/rsc-server.mjs → dist/internal/index.mjs} +860 -1552
  13. package/dist/internal/index.mjs.map +1 -0
  14. package/{mcp-stdio/dist → dist/mcp-stdio}/index.js +4 -4
  15. package/dist/mcp-stdio/index.js.map +1 -0
  16. package/{mcp-stdio/dist → dist/mcp-stdio}/index.mjs +4 -4
  17. package/dist/mcp-stdio/index.mjs.map +1 -0
  18. package/{test/dist → dist/test}/index.d.mts +21 -23
  19. package/{test/dist → dist/test}/index.d.ts +21 -23
  20. package/{test/dist → dist/test}/index.js +31 -15
  21. package/dist/test/index.js.map +1 -0
  22. package/{test/dist → dist/test}/index.mjs +30 -14
  23. package/dist/test/index.mjs.map +1 -0
  24. package/package.json +28 -47
  25. package/mcp-stdio/create-child-process.test.ts +0 -92
  26. package/mcp-stdio/create-child-process.ts +0 -21
  27. package/mcp-stdio/dist/index.js.map +0 -1
  28. package/mcp-stdio/dist/index.mjs.map +0 -1
  29. package/mcp-stdio/get-environment.ts +0 -43
  30. package/mcp-stdio/index.ts +0 -4
  31. package/mcp-stdio/mcp-stdio-transport.test.ts +0 -262
  32. package/mcp-stdio/mcp-stdio-transport.ts +0 -157
  33. package/rsc/dist/index.d.ts +0 -813
  34. package/rsc/dist/index.mjs +0 -18
  35. package/rsc/dist/rsc-client.d.mts +0 -1
  36. package/rsc/dist/rsc-client.mjs +0 -18
  37. package/rsc/dist/rsc-client.mjs.map +0 -1
  38. package/rsc/dist/rsc-server.d.mts +0 -748
  39. package/rsc/dist/rsc-server.mjs.map +0 -1
  40. package/rsc/dist/rsc-shared.d.mts +0 -101
  41. package/rsc/dist/rsc-shared.mjs +0 -308
  42. package/rsc/dist/rsc-shared.mjs.map +0 -1
  43. package/test/dist/index.js.map +0 -1
  44. package/test/dist/index.mjs.map +0 -1
  45. package/{mcp-stdio/dist → dist/mcp-stdio}/index.d.mts +6 -6
  46. package/{mcp-stdio/dist → dist/mcp-stdio}/index.d.ts +6 -6
@@ -0,0 +1,732 @@
1
+ import { SharedV2ProviderOptions, LanguageModelV2Usage, LanguageModelV2Source, JSONValue as JSONValue$1, JSONObject, LanguageModelV2FunctionTool, LanguageModelV2ProviderDefinedTool, LanguageModelV2ToolChoice, LanguageModelV2Prompt } from '@ai-sdk/provider';
2
+ import { z } from 'zod';
3
+ import { ToolCall, ToolResult, Validator } from '@ai-sdk/provider-utils';
4
+ import { JSONSchema7 } from 'json-schema';
5
+
6
+ type ToolResultContent = Array<{
7
+ type: 'text';
8
+ text: string;
9
+ } | {
10
+ type: 'image';
11
+ data: string;
12
+ mediaType?: string;
13
+ /**
14
+ * @deprecated Use `mediaType` instead.
15
+ */
16
+ mimeType?: string;
17
+ }>;
18
+
19
+ /**
20
+ Additional provider-specific options.
21
+
22
+ They are passed through to the provider from the AI SDK and enable
23
+ provider-specific functionality that can be fully encapsulated in the provider.
24
+ */
25
+ type ProviderOptions = SharedV2ProviderOptions;
26
+
27
+ /**
28
+ Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.
29
+ */
30
+ type DataContent = string | Uint8Array | ArrayBuffer | Buffer;
31
+
32
+ /**
33
+ Text content part of a prompt. It contains a string of text.
34
+ */
35
+ interface TextPart {
36
+ type: 'text';
37
+ /**
38
+ The text content.
39
+ */
40
+ text: string;
41
+ /**
42
+ Additional provider-specific metadata. They are passed through
43
+ to the provider from the AI SDK and enable provider-specific
44
+ functionality that can be fully encapsulated in the provider.
45
+ */
46
+ providerOptions?: ProviderOptions;
47
+ }
48
+ /**
49
+ Image content part of a prompt. It contains an image.
50
+ */
51
+ interface ImagePart {
52
+ type: 'image';
53
+ /**
54
+ Image data. Can either be:
55
+
56
+ - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
57
+ - URL: a URL that points to the image
58
+ */
59
+ image: DataContent | URL;
60
+ /**
61
+ Optional IANA media type of the image.
62
+
63
+ @see https://www.iana.org/assignments/media-types/media-types.xhtml
64
+ */
65
+ mediaType?: string;
66
+ /**
67
+ @deprecated Use `mediaType` instead.
68
+ */
69
+ mimeType?: string;
70
+ /**
71
+ Additional provider-specific metadata. They are passed through
72
+ to the provider from the AI SDK and enable provider-specific
73
+ functionality that can be fully encapsulated in the provider.
74
+ */
75
+ providerOptions?: ProviderOptions;
76
+ }
77
+ /**
78
+ File content part of a prompt. It contains a file.
79
+ */
80
+ interface FilePart {
81
+ type: 'file';
82
+ /**
83
+ File data. Can either be:
84
+
85
+ - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
86
+ - URL: a URL that points to the image
87
+ */
88
+ data: DataContent | URL;
89
+ /**
90
+ Optional filename of the file.
91
+ */
92
+ filename?: string;
93
+ /**
94
+ IANA media type of the file.
95
+
96
+ @see https://www.iana.org/assignments/media-types/media-types.xhtml
97
+ */
98
+ mediaType: string;
99
+ /**
100
+ @deprecated Use `mediaType` instead.
101
+ */
102
+ mimeType?: string;
103
+ /**
104
+ Additional provider-specific metadata. They are passed through
105
+ to the provider from the AI SDK and enable provider-specific
106
+ functionality that can be fully encapsulated in the provider.
107
+ */
108
+ providerOptions?: ProviderOptions;
109
+ }
110
+ /**
111
+ * Reasoning content part of a prompt. It contains a reasoning.
112
+ */
113
+ interface ReasoningPart {
114
+ type: 'reasoning';
115
+ /**
116
+ The reasoning text.
117
+ */
118
+ text: string;
119
+ /**
120
+ An optional signature for verifying that the reasoning originated from the model.
121
+ */
122
+ signature?: string;
123
+ /**
124
+ Additional provider-specific metadata. They are passed through
125
+ to the provider from the AI SDK and enable provider-specific
126
+ functionality that can be fully encapsulated in the provider.
127
+ */
128
+ providerOptions?: ProviderOptions;
129
+ }
130
+ /**
131
+ Redacted reasoning content part of a prompt.
132
+ */
133
+ interface RedactedReasoningPart {
134
+ type: 'redacted-reasoning';
135
+ /**
136
+ Redacted reasoning data.
137
+ */
138
+ data: string;
139
+ /**
140
+ Additional provider-specific metadata. They are passed through
141
+ to the provider from the AI SDK and enable provider-specific
142
+ functionality that can be fully encapsulated in the provider.
143
+ */
144
+ providerOptions?: ProviderOptions;
145
+ }
146
+ /**
147
+ Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
148
+ */
149
+ interface ToolCallPart {
150
+ type: 'tool-call';
151
+ /**
152
+ ID of the tool call. This ID is used to match the tool call with the tool result.
153
+ */
154
+ toolCallId: string;
155
+ /**
156
+ Name of the tool that is being called.
157
+ */
158
+ toolName: string;
159
+ /**
160
+ Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
161
+ */
162
+ args: unknown;
163
+ /**
164
+ Additional provider-specific metadata. They are passed through
165
+ to the provider from the AI SDK and enable provider-specific
166
+ functionality that can be fully encapsulated in the provider.
167
+ */
168
+ providerOptions?: ProviderOptions;
169
+ }
170
+ /**
171
+ Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
172
+ */
173
+ interface ToolResultPart {
174
+ type: 'tool-result';
175
+ /**
176
+ ID of the tool call that this result is associated with.
177
+ */
178
+ toolCallId: string;
179
+ /**
180
+ Name of the tool that generated this result.
181
+ */
182
+ toolName: string;
183
+ /**
184
+ Result of the tool call. This is a JSON-serializable object.
185
+ */
186
+ result: unknown;
187
+ /**
188
+ Multi-part content of the tool result. Only for tools that support multipart results.
189
+ */
190
+ experimental_content?: ToolResultContent;
191
+ /**
192
+ Optional flag if the result is an error or an error message.
193
+ */
194
+ isError?: boolean;
195
+ /**
196
+ Additional provider-specific metadata. They are passed through
197
+ to the provider from the AI SDK and enable provider-specific
198
+ functionality that can be fully encapsulated in the provider.
199
+ */
200
+ providerOptions?: ProviderOptions;
201
+ }
202
+
203
+ /**
204
+ A system message. It can contain system information.
205
+
206
+ Note: using the "system" part of the prompt is strongly preferred
207
+ to increase the resilience against prompt injection attacks,
208
+ and because not all providers support several system messages.
209
+ */
210
+ type CoreSystemMessage = {
211
+ role: 'system';
212
+ content: string;
213
+ /**
214
+ Additional provider-specific metadata. They are passed through
215
+ to the provider from the AI SDK and enable provider-specific
216
+ functionality that can be fully encapsulated in the provider.
217
+ */
218
+ providerOptions?: ProviderOptions;
219
+ };
220
+ /**
221
+ A user message. It can contain text or a combination of text and images.
222
+ */
223
+ type CoreUserMessage = {
224
+ role: 'user';
225
+ content: UserContent;
226
+ /**
227
+ Additional provider-specific metadata. They are passed through
228
+ to the provider from the AI SDK and enable provider-specific
229
+ functionality that can be fully encapsulated in the provider.
230
+ */
231
+ providerOptions?: ProviderOptions;
232
+ };
233
+ /**
234
+ Content of a user message. It can be a string or an array of text and image parts.
235
+ */
236
+ type UserContent = string | Array<TextPart | ImagePart | FilePart>;
237
+ /**
238
+ An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
239
+ */
240
+ type CoreAssistantMessage = {
241
+ role: 'assistant';
242
+ content: AssistantContent;
243
+ /**
244
+ Additional provider-specific metadata. They are passed through
245
+ to the provider from the AI SDK and enable provider-specific
246
+ functionality that can be fully encapsulated in the provider.
247
+ */
248
+ providerOptions?: ProviderOptions;
249
+ };
250
+ /**
251
+ Content of an assistant message.
252
+ It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
253
+ */
254
+ type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | RedactedReasoningPart | ToolCallPart>;
255
+ /**
256
+ A tool message. It contains the result of one or more tool calls.
257
+ */
258
+ type CoreToolMessage = {
259
+ role: 'tool';
260
+ content: ToolContent;
261
+ /**
262
+ Additional provider-specific metadata. They are passed through
263
+ to the provider from the AI SDK and enable provider-specific
264
+ functionality that can be fully encapsulated in the provider.
265
+ */
266
+ providerOptions?: ProviderOptions;
267
+ };
268
+ /**
269
+ Content of a tool message. It is an array of tool result parts.
270
+ */
271
+ type ToolContent = Array<ToolResultPart>;
272
+ /**
273
+ A message that can be used in the `messages` field of a prompt.
274
+ It can be a user message, an assistant message, or a tool message.
275
+ */
276
+ type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage | CoreToolMessage;
277
+
278
+ /**
279
+ Tool choice for the generation. It supports the following settings:
280
+
281
+ - `auto` (default): the model can choose whether and which tools to call.
282
+ - `required`: the model must call a tool. It can choose which tool to call.
283
+ - `none`: the model must not call tools
284
+ - `{ type: 'tool', toolName: string (typed) }`: the model must call the specified tool
285
+ */
286
+ type ToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | 'required' | {
287
+ type: 'tool';
288
+ toolName: Extract<keyof TOOLS, string>;
289
+ };
290
+
291
+ /**
292
+ Represents the number of tokens used in a prompt and completion.
293
+ */
294
+ type LanguageModelUsage = {
295
+ /**
296
+ The number of tokens used in the prompt.
297
+ */
298
+ promptTokens: number;
299
+ /**
300
+ The number of tokens used in the completion.
301
+ */
302
+ completionTokens: number;
303
+ /**
304
+ The total number of tokens used (promptTokens + completionTokens).
305
+ */
306
+ totalTokens: number;
307
+ };
308
+ declare function calculateLanguageModelUsage({ inputTokens, outputTokens, }: LanguageModelV2Usage): LanguageModelUsage;
309
+
310
+ /**
311
+ Tool invocations are either tool calls or tool results. For each assistant tool call,
312
+ there is one tool invocation. While the call is in progress, the invocation is a tool call.
313
+ Once the call is complete, the invocation is a tool result.
314
+
315
+ The step is used to track how to map an assistant UI message with many tool invocations
316
+ back to a sequence of LLM assistant/tool result message pairs.
317
+ It is optional for backwards compatibility.
318
+ */
319
+ type ToolInvocation = ({
320
+ state: 'partial-call';
321
+ step?: number;
322
+ } & ToolCall<string, any>) | ({
323
+ state: 'call';
324
+ step?: number;
325
+ } & ToolCall<string, any>) | ({
326
+ state: 'result';
327
+ step?: number;
328
+ } & ToolResult<string, any, any>);
329
+ /**
330
+ * An attachment that can be sent along with a message.
331
+ */
332
+ interface Attachment {
333
+ /**
334
+ * The name of the attachment, usually the file name.
335
+ */
336
+ name?: string;
337
+ /**
338
+ * A string indicating the [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type).
339
+ * By default, it's extracted from the pathname's extension.
340
+ */
341
+ contentType?: string;
342
+ /**
343
+ * The URL of the attachment. It can either be a URL to a hosted file or a [Data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs).
344
+ */
345
+ url: string;
346
+ }
347
+ /**
348
+ * AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
349
+ */
350
+ interface Message {
351
+ /**
352
+ A unique identifier for the message.
353
+ */
354
+ id: string;
355
+ /**
356
+ The timestamp of the message.
357
+ */
358
+ createdAt?: Date;
359
+ /**
360
+ Text content of the message. Use parts when possible.
361
+ */
362
+ content: string;
363
+ /**
364
+ Reasoning for the message.
365
+
366
+ @deprecated Use `parts` instead.
367
+ */
368
+ reasoning?: string;
369
+ /**
370
+ * Additional attachments to be sent along with the message.
371
+ */
372
+ experimental_attachments?: Attachment[];
373
+ /**
374
+ The 'data' role is deprecated.
375
+ */
376
+ role: 'system' | 'user' | 'assistant' | 'data';
377
+ /**
378
+ For data messages.
379
+
380
+ @deprecated Data messages will be removed.
381
+ */
382
+ data?: JSONValue;
383
+ /**
384
+ * Additional message-specific information added on the server via StreamData
385
+ */
386
+ annotations?: JSONValue[] | undefined;
387
+ /**
388
+ Tool invocations (that can be tool calls or tool results, depending on whether or not the invocation has finished)
389
+ that the assistant made as part of this message.
390
+
391
+ @deprecated Use `parts` instead.
392
+ */
393
+ toolInvocations?: Array<ToolInvocation>;
394
+ /**
395
+ * The parts of the message. Use this for rendering the message in the UI.
396
+ *
397
+ * Assistant messages can have text, reasoning and tool invocation parts.
398
+ * User messages can have text parts.
399
+ */
400
+ parts?: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart>;
401
+ }
402
+ /**
403
+ * A text part of a message.
404
+ */
405
+ type TextUIPart = {
406
+ type: 'text';
407
+ /**
408
+ * The text content.
409
+ */
410
+ text: string;
411
+ };
412
+ /**
413
+ * A reasoning part of a message.
414
+ */
415
+ type ReasoningUIPart = {
416
+ type: 'reasoning';
417
+ /**
418
+ * The reasoning text.
419
+ */
420
+ reasoning: string;
421
+ details: Array<{
422
+ type: 'text';
423
+ text: string;
424
+ signature?: string;
425
+ } | {
426
+ type: 'redacted';
427
+ data: string;
428
+ }>;
429
+ };
430
+ /**
431
+ * A tool invocation part of a message.
432
+ */
433
+ type ToolInvocationUIPart = {
434
+ type: 'tool-invocation';
435
+ /**
436
+ * The tool invocation.
437
+ */
438
+ toolInvocation: ToolInvocation;
439
+ };
440
+ /**
441
+ * A source part of a message.
442
+ */
443
+ type SourceUIPart = {
444
+ type: 'source';
445
+ /**
446
+ * The source.
447
+ */
448
+ source: LanguageModelV2Source;
449
+ };
450
+ /**
451
+ * A file part of a message.
452
+ */
453
+ type FileUIPart = {
454
+ type: 'file';
455
+ /**
456
+ * IANA media type of the file.
457
+ *
458
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
459
+ */
460
+ mediaType: string;
461
+ /**
462
+ * The base64 encoded data.
463
+ */
464
+ data: string;
465
+ };
466
+ /**
467
+ * A step boundary part of a message.
468
+ */
469
+ type StepStartUIPart = {
470
+ type: 'step-start';
471
+ };
472
+ /**
473
+ A JSON value can be a string, number, boolean, object, array, or null.
474
+ JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods.
475
+ */
476
+ type JSONValue = null | string | number | boolean | {
477
+ [value: string]: JSONValue;
478
+ } | Array<JSONValue>;
479
+
480
+ /**
481
+ * Used to mark schemas so we can support both Zod and custom schemas.
482
+ */
483
+ declare const schemaSymbol: unique symbol;
484
+ type Schema<OBJECT = unknown> = Validator<OBJECT> & {
485
+ /**
486
+ * Used to mark schemas so we can support both Zod and custom schemas.
487
+ */
488
+ [schemaSymbol]: true;
489
+ /**
490
+ * Schema type for inference.
491
+ */
492
+ _type: OBJECT;
493
+ /**
494
+ * The JSON Schema for the schema. It is passed to the providers.
495
+ */
496
+ readonly jsonSchema: JSONSchema7;
497
+ };
498
+
499
+ type ToolParameters<T = JSONObject> = z.Schema<T> | Schema<T>;
500
+ interface ToolExecutionOptions {
501
+ /**
502
+ * The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
503
+ */
504
+ toolCallId: string;
505
+ /**
506
+ * Messages that were sent to the language model to initiate the response that contained the tool call.
507
+ * The messages **do not** include the system prompt nor the assistant response that contained the tool call.
508
+ */
509
+ messages: CoreMessage[];
510
+ /**
511
+ * An optional abort signal that indicates that the overall operation should be aborted.
512
+ */
513
+ abortSignal?: AbortSignal;
514
+ }
515
+ type NeverOptional<N, T> = 0 extends 1 & N ? Partial<T> : [N] extends [never] ? Partial<Record<keyof T, undefined>> : T;
516
+ /**
517
+ A tool contains the description and the schema of the input that the tool expects.
518
+ This enables the language model to generate the input.
519
+
520
+ The tool can also contain an optional execute function for the actual execution function of the tool.
521
+ */
522
+ type Tool<PARAMETERS extends JSONValue$1 | unknown | never = any, RESULT = any> = {
523
+ /**
524
+ An optional description of what the tool does.
525
+ Will be used by the language model to decide whether to use the tool.
526
+ Not used for provider-defined tools.
527
+ */
528
+ description?: string;
529
+ } & NeverOptional<PARAMETERS, {
530
+ /**
531
+ The schema of the input that the tool expects. The language model will use this to generate the input.
532
+ It is also used to validate the output of the language model.
533
+ Use descriptions to make the input understandable for the language model.
534
+ */
535
+ parameters: ToolParameters<PARAMETERS>;
536
+ }> & NeverOptional<RESULT, {
537
+ /**
538
+ An async function that is called with the arguments from the tool call and produces a result.
539
+ If not provided, the tool will not be executed automatically.
540
+
541
+ @args is the input of the tool call.
542
+ @options.abortSignal is a signal that can be used to abort the tool call.
543
+ */
544
+ execute: (args: [PARAMETERS] extends [never] ? undefined : PARAMETERS, options: ToolExecutionOptions) => PromiseLike<RESULT>;
545
+ /**
546
+ Optional conversion function that maps the tool result to multi-part tool content for LLMs.
547
+ */
548
+ experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
549
+ }> & ({
550
+ /**
551
+ Function tool.
552
+ */
553
+ type?: undefined | 'function';
554
+ } | {
555
+ /**
556
+ Provider-defined tool.
557
+ */
558
+ type: 'provider-defined';
559
+ /**
560
+ The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
561
+ */
562
+ id: `${string}.${string}`;
563
+ /**
564
+ The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
565
+ */
566
+ args: Record<string, unknown>;
567
+ });
568
+
569
+ type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute'>>;
570
+
571
+ /**
572
+ Prompt part of the AI function options.
573
+ It contains a system message, a simple text prompt, or a list of messages.
574
+ */
575
+ type Prompt = {
576
+ /**
577
+ System message to include in the prompt. Can be used with `prompt` or `messages`.
578
+ */
579
+ system?: string;
580
+ /**
581
+ A simple text prompt. You can either use `prompt` or `messages` but not both.
582
+ */
583
+ prompt?: string;
584
+ /**
585
+ A list of messages. You can either use `prompt` or `messages` but not both.
586
+ */
587
+ messages?: Array<CoreMessage> | Array<Omit<Message, 'id'>>;
588
+ };
589
+
590
+ type StandardizedPrompt = {
591
+ /**
592
+ * Original prompt type. This is forwarded to the providers and can be used
593
+ * to write send raw text to providers that support it.
594
+ */
595
+ type: 'prompt' | 'messages';
596
+ /**
597
+ * System message.
598
+ */
599
+ system?: string;
600
+ /**
601
+ * Messages.
602
+ */
603
+ messages: CoreMessage[];
604
+ };
605
+ declare function standardizePrompt<TOOLS extends ToolSet>({ prompt, tools, }: {
606
+ prompt: Prompt;
607
+ tools: undefined | TOOLS;
608
+ }): StandardizedPrompt;
609
+
610
+ type CallSettings = {
611
+ /**
612
+ Maximum number of tokens to generate.
613
+ */
614
+ maxOutputTokens?: number;
615
+ /**
616
+ Temperature setting. This is a number between 0 (almost no randomness) and
617
+ 1 (very random).
618
+
619
+ It is recommended to set either `temperature` or `topP`, but not both.
620
+ Use `null` to use the provider's default temperature.
621
+
622
+ @default 0
623
+ */
624
+ temperature?: number | null;
625
+ /**
626
+ Nucleus sampling. This is a number between 0 and 1.
627
+
628
+ E.g. 0.1 would mean that only tokens with the top 10% probability mass
629
+ are considered.
630
+
631
+ It is recommended to set either `temperature` or `topP`, but not both.
632
+ */
633
+ topP?: number;
634
+ /**
635
+ Only sample from the top K options for each subsequent token.
636
+
637
+ Used to remove "long tail" low probability responses.
638
+ Recommended for advanced use cases only. You usually only need to use temperature.
639
+ */
640
+ topK?: number;
641
+ /**
642
+ Presence penalty setting. It affects the likelihood of the model to
643
+ repeat information that is already in the prompt.
644
+
645
+ The presence penalty is a number between -1 (increase repetition)
646
+ and 1 (maximum penalty, decrease repetition). 0 means no penalty.
647
+ */
648
+ presencePenalty?: number;
649
+ /**
650
+ Frequency penalty setting. It affects the likelihood of the model
651
+ to repeatedly use the same words or phrases.
652
+
653
+ The frequency penalty is a number between -1 (increase repetition)
654
+ and 1 (maximum penalty, decrease repetition). 0 means no penalty.
655
+ */
656
+ frequencyPenalty?: number;
657
+ /**
658
+ Stop sequences.
659
+ If set, the model will stop generating text when one of the stop sequences is generated.
660
+ Providers may have limits on the number of stop sequences.
661
+ */
662
+ stopSequences?: string[];
663
+ /**
664
+ The seed (integer) to use for random sampling. If set and supported
665
+ by the model, calls will generate deterministic results.
666
+ */
667
+ seed?: number;
668
+ /**
669
+ Maximum number of retries. Set to 0 to disable retries.
670
+
671
+ @default 2
672
+ */
673
+ maxRetries?: number;
674
+ /**
675
+ Abort signal.
676
+ */
677
+ abortSignal?: AbortSignal;
678
+ /**
679
+ Additional HTTP headers to be sent with the request.
680
+ Only applicable for HTTP-based providers.
681
+ */
682
+ headers?: Record<string, string | undefined>;
683
+ };
684
+
685
+ declare function prepareToolsAndToolChoice<TOOLS extends ToolSet>({ tools, toolChoice, activeTools, }: {
686
+ tools: TOOLS | undefined;
687
+ toolChoice: ToolChoice<TOOLS> | undefined;
688
+ activeTools: Array<keyof TOOLS> | undefined;
689
+ }): {
690
+ tools: Array<LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool> | undefined;
691
+ toolChoice: LanguageModelV2ToolChoice | undefined;
692
+ };
693
+
694
+ type RetryFunction = <OUTPUT>(fn: () => PromiseLike<OUTPUT>) => PromiseLike<OUTPUT>;
695
+
696
+ /**
697
+ * Validate and prepare retries.
698
+ */
699
+ declare function prepareRetries({ maxRetries, }: {
700
+ maxRetries: number | undefined;
701
+ }): {
702
+ maxRetries: number;
703
+ retry: RetryFunction;
704
+ };
705
+
706
+ /**
707
+ * Validates call settings and sets default values.
708
+ */
709
+ declare function prepareCallSettings({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, stopSequences, seed, }: Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries'>): Omit<CallSettings, 'abortSignal' | 'headers' | 'maxRetries' | 'temperature'> & {
710
+ temperature?: number;
711
+ };
712
+
713
+ declare function download({ url }: {
714
+ url: URL;
715
+ }): Promise<{
716
+ data: Uint8Array;
717
+ mediaType: string | undefined;
718
+ }>;
719
+
720
+ declare function convertToLanguageModelPrompt({ prompt, supportedUrls, downloadImplementation, }: {
721
+ prompt: StandardizedPrompt;
722
+ supportedUrls: Record<string, RegExp[]>;
723
+ downloadImplementation?: typeof download;
724
+ }): Promise<LanguageModelV2Prompt>;
725
+
726
+ /**
727
+ * Warning time for notifying developers that a stream is hanging in dev mode
728
+ * using a console.warn.
729
+ */
730
+ declare const HANGING_STREAM_WARNING_TIME_MS: number;
731
+
732
+ export { HANGING_STREAM_WARNING_TIME_MS, calculateLanguageModelUsage, convertToLanguageModelPrompt, prepareCallSettings, prepareRetries, prepareToolsAndToolChoice, standardizePrompt };