ai 5.0.0-canary.15 → 5.0.0-canary.17
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 +55 -0
- package/dist/index.d.mts +145 -120
- package/dist/index.d.ts +145 -120
- package/dist/index.js +276 -391
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +270 -390
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +32 -59
- package/dist/internal/index.d.ts +32 -59
- package/dist/internal/index.js +193 -387
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +186 -380
- package/dist/internal/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.d.mts +2 -2
- package/dist/mcp-stdio/index.d.ts +2 -2
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ToolCall, ToolResult, FetchFunction, Schema, IDGenerator } from '@ai-sdk/provider-utils';
|
2
2
|
export { IDGenerator, Schema, ToolCall, ToolResult, asSchema, createIdGenerator, generateId, jsonSchema } from '@ai-sdk/provider-utils';
|
3
3
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
4
|
-
import { EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SharedV2ProviderMetadata, SharedV2ProviderOptions, SpeechModelV1, SpeechModelV1CallWarning, TranscriptionModelV1, TranscriptionModelV1CallWarning, JSONObject, LanguageModelV2CallOptions, AISDKError, LanguageModelV2ToolCall, JSONSchema7, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
4
|
+
import { EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SharedV2ProviderMetadata, SharedV2ProviderOptions, SpeechModelV1, SpeechModelV1CallWarning, TranscriptionModelV1, TranscriptionModelV1CallWarning, JSONObject, LanguageModelV2CallOptions, AISDKError, LanguageModelV2ToolCall, JSONSchema7, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
5
5
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
6
6
|
import { ServerResponse } from 'node:http';
|
7
7
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
@@ -26,6 +26,10 @@ Warning from the model provider for this call. The call will proceed, but e.g.
|
|
26
26
|
some settings might not be supported, which can lead to suboptimal results.
|
27
27
|
*/
|
28
28
|
type ImageGenerationWarning = ImageModelV2CallWarning;
|
29
|
+
/**
|
30
|
+
Metadata from the model provider for this call
|
31
|
+
*/
|
32
|
+
type ImageModelProviderMetadata = ImageModelV2ProviderMetadata;
|
29
33
|
|
30
34
|
type ImageModelResponseMetadata = {
|
31
35
|
/**
|
@@ -252,28 +256,10 @@ type ToolInvocation = ({
|
|
252
256
|
state: 'result';
|
253
257
|
step?: number;
|
254
258
|
} & ToolResult<string, any, any>);
|
255
|
-
/**
|
256
|
-
* An attachment that can be sent along with a message.
|
257
|
-
*/
|
258
|
-
interface Attachment {
|
259
|
-
/**
|
260
|
-
* The name of the attachment, usually the file name.
|
261
|
-
*/
|
262
|
-
name?: string;
|
263
|
-
/**
|
264
|
-
* A string indicating the [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type).
|
265
|
-
* By default, it's extracted from the pathname's extension.
|
266
|
-
*/
|
267
|
-
contentType?: string;
|
268
|
-
/**
|
269
|
-
* 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).
|
270
|
-
*/
|
271
|
-
url: string;
|
272
|
-
}
|
273
259
|
/**
|
274
260
|
* AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
|
275
261
|
*/
|
276
|
-
interface
|
262
|
+
interface UIMessage {
|
277
263
|
/**
|
278
264
|
A unique identifier for the message.
|
279
265
|
*/
|
@@ -287,41 +273,26 @@ interface Message {
|
|
287
273
|
*/
|
288
274
|
content: string;
|
289
275
|
/**
|
290
|
-
|
291
|
-
*/
|
292
|
-
experimental_attachments?: Attachment[];
|
293
|
-
/**
|
294
|
-
The 'data' role is deprecated.
|
276
|
+
The role of the message.
|
295
277
|
*/
|
296
|
-
role: 'system' | 'user' | 'assistant'
|
278
|
+
role: 'system' | 'user' | 'assistant';
|
297
279
|
/**
|
298
|
-
|
280
|
+
Additional message-specific information added on the server via StreamData
|
299
281
|
*/
|
300
282
|
annotations?: JSONValue$1[] | undefined;
|
301
283
|
/**
|
302
|
-
|
303
|
-
that the assistant made as part of this message.
|
284
|
+
The parts of the message. Use this for rendering the message in the UI.
|
304
285
|
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
* Assistant messages can have text, reasoning and tool invocation parts.
|
312
|
-
* User messages can have text parts.
|
286
|
+
System messages should be avoided (set the system prompt on the server instead).
|
287
|
+
They can have text parts.
|
288
|
+
|
289
|
+
User messages can have text parts and file parts.
|
290
|
+
|
291
|
+
Assistant messages can have text, reasoning, tool invocation, and file parts.
|
313
292
|
*/
|
314
|
-
parts
|
293
|
+
parts: Array<UIMessagePart>;
|
315
294
|
}
|
316
|
-
type
|
317
|
-
/**
|
318
|
-
* The parts of the message. Use this for rendering the message in the UI.
|
319
|
-
*
|
320
|
-
* Assistant messages can have text, reasoning and tool invocation parts.
|
321
|
-
* User messages can have text parts.
|
322
|
-
*/
|
323
|
-
parts: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart>;
|
324
|
-
};
|
295
|
+
type UIMessagePart = TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart;
|
325
296
|
/**
|
326
297
|
* A text part of a message.
|
327
298
|
*/
|
@@ -340,7 +311,7 @@ type ReasoningUIPart = {
|
|
340
311
|
/**
|
341
312
|
* The reasoning text.
|
342
313
|
*/
|
343
|
-
|
314
|
+
text: string;
|
344
315
|
/**
|
345
316
|
* The provider metadata.
|
346
317
|
*/
|
@@ -378,9 +349,14 @@ type FileUIPart = {
|
|
378
349
|
*/
|
379
350
|
mediaType: string;
|
380
351
|
/**
|
381
|
-
*
|
352
|
+
* Optional filename of the file.
|
382
353
|
*/
|
383
|
-
|
354
|
+
filename?: string;
|
355
|
+
/**
|
356
|
+
* The URL of the file.
|
357
|
+
* 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).
|
358
|
+
*/
|
359
|
+
url: string;
|
384
360
|
};
|
385
361
|
/**
|
386
362
|
* A step boundary part of a message.
|
@@ -388,8 +364,8 @@ type FileUIPart = {
|
|
388
364
|
type StepStartUIPart = {
|
389
365
|
type: 'step-start';
|
390
366
|
};
|
391
|
-
type
|
392
|
-
id?:
|
367
|
+
type CreateUIMessage = Omit<UIMessage, 'id'> & {
|
368
|
+
id?: UIMessage['id'];
|
393
369
|
};
|
394
370
|
type ChatRequest = {
|
395
371
|
/**
|
@@ -403,7 +379,7 @@ type ChatRequest = {
|
|
403
379
|
/**
|
404
380
|
The messages of the chat.
|
405
381
|
*/
|
406
|
-
messages:
|
382
|
+
messages: UIMessage[];
|
407
383
|
/**
|
408
384
|
Additional data to be sent to the server.
|
409
385
|
*/
|
@@ -432,10 +408,6 @@ type ChatRequestOptions = {
|
|
432
408
|
Additional data to be sent to the API endpoint.
|
433
409
|
*/
|
434
410
|
data?: JSONValue$1;
|
435
|
-
/**
|
436
|
-
* Additional files to be sent to the server.
|
437
|
-
*/
|
438
|
-
experimental_attachments?: FileList | Array<Attachment>;
|
439
411
|
/**
|
440
412
|
* Allow submitting an empty message. Defaults to `false`.
|
441
413
|
*/
|
@@ -462,7 +434,7 @@ type UseChatOptions = {
|
|
462
434
|
/**
|
463
435
|
* Initial messages of the chat. Useful to load an existing chat history.
|
464
436
|
*/
|
465
|
-
initialMessages?:
|
437
|
+
initialMessages?: UIMessage[];
|
466
438
|
/**
|
467
439
|
* Initial input of the chat.
|
468
440
|
*/
|
@@ -488,7 +460,7 @@ type UseChatOptions = {
|
|
488
460
|
* @param options.usage The token usage of the message.
|
489
461
|
* @param options.finishReason The finish reason of the message.
|
490
462
|
*/
|
491
|
-
onFinish?: (message:
|
463
|
+
onFinish?: (message: UIMessage, options: {
|
492
464
|
usage: LanguageModelUsage$1;
|
493
465
|
finishReason: LanguageModelV2FinishReason;
|
494
466
|
}) => void;
|
@@ -634,7 +606,7 @@ type EmbeddingModelUsage = {
|
|
634
606
|
};
|
635
607
|
|
636
608
|
declare const getOriginalFetch$1: () => typeof fetch;
|
637
|
-
declare function callChatApi({ api, body, streamProtocol, credentials, headers, abortController, restoreMessagesOnFailure, onResponse, onUpdate, onFinish, onToolCall, generateId, fetch, lastMessage, }: {
|
609
|
+
declare function callChatApi({ api, body, streamProtocol, credentials, headers, abortController, restoreMessagesOnFailure, onResponse, onUpdate, onFinish, onToolCall, generateId, fetch, lastMessage, getCurrentDate, requestType, }: {
|
638
610
|
api: string;
|
639
611
|
body: Record<string, any>;
|
640
612
|
streamProtocol: 'data' | 'text' | undefined;
|
@@ -653,6 +625,8 @@ declare function callChatApi({ api, body, streamProtocol, credentials, headers,
|
|
653
625
|
generateId: IdGenerator;
|
654
626
|
fetch: ReturnType<typeof getOriginalFetch$1> | undefined;
|
655
627
|
lastMessage: UIMessage | undefined;
|
628
|
+
getCurrentDate: () => Date;
|
629
|
+
requestType?: 'generate' | 'resume';
|
656
630
|
}): Promise<void>;
|
657
631
|
|
658
632
|
declare const getOriginalFetch: () => typeof fetch;
|
@@ -674,6 +648,8 @@ declare function callCompletionApi({ api, prompt, credentials, headers, body, st
|
|
674
648
|
fetch: ReturnType<typeof getOriginalFetch> | undefined;
|
675
649
|
}): Promise<string | null | undefined>;
|
676
650
|
|
651
|
+
declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
|
652
|
+
|
677
653
|
type DataStreamString = `${(typeof DataStreamStringPrefixes)[keyof typeof DataStreamStringPrefixes]}:${string}\n`;
|
678
654
|
interface DataStreamPart<CODE extends string, NAME extends string, TYPE> {
|
679
655
|
code: CODE;
|
@@ -708,8 +684,8 @@ declare const dataStreamParts: readonly [DataStreamPart<"0", "text", string>, Da
|
|
708
684
|
text: string;
|
709
685
|
providerMetadata?: Record<string, any> | undefined;
|
710
686
|
}>, DataStreamPart<"h", "source", LanguageModelV2Source>, DataStreamPart<"l", "reasoning_part_finish", {}>, DataStreamPart<"k", "file", {
|
711
|
-
|
712
|
-
|
687
|
+
url: string;
|
688
|
+
mediaType: string;
|
713
689
|
}>];
|
714
690
|
type DataStreamParts = (typeof dataStreamParts)[number];
|
715
691
|
/**
|
@@ -751,7 +727,7 @@ Parses a stream part from a string.
|
|
751
727
|
*/
|
752
728
|
declare const parseDataStreamPart: (line: string) => DataStreamPartType;
|
753
729
|
/**
|
754
|
-
Prepends a string with a prefix from the `StreamChunkPrefixes`,
|
730
|
+
Prepends a string with a prefix from the `StreamChunkPrefixes`, converts it to JSON,
|
755
731
|
and appends a new line.
|
756
732
|
|
757
733
|
It ensures type-safety for the part type and value.
|
@@ -782,10 +758,6 @@ type PartialObject<ObjectType extends object> = {
|
|
782
758
|
|
783
759
|
declare function extractMaxToolInvocationStep(toolInvocations: ToolInvocation[] | undefined): number | undefined;
|
784
760
|
|
785
|
-
declare function fillMessageParts(messages: Message[]): UIMessage[];
|
786
|
-
|
787
|
-
declare function getMessageParts(message: Message | CreateMessage | UIMessage): (TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart)[];
|
788
|
-
|
789
761
|
/**
|
790
762
|
* Performs a deep-equal comparison of two parsed JSON objects.
|
791
763
|
*
|
@@ -800,8 +772,6 @@ declare function parsePartialJson(jsonText: string | undefined): Promise<{
|
|
800
772
|
state: 'undefined-input' | 'successful-parse' | 'repaired-parse' | 'failed-parse';
|
801
773
|
}>;
|
802
774
|
|
803
|
-
declare function prepareAttachmentsForRequest(attachmentsFromOptions: FileList | Array<Attachment> | undefined): Promise<Attachment[]>;
|
804
|
-
|
805
775
|
declare function processDataStream({ stream, onTextPart, onReasoningPart, onReasoningPartFinish, onSourcePart, onFilePart, onDataPart, onErrorPart, onToolCallStreamingStartPart, onToolCallDeltaPart, onToolCallPart, onToolResultPart, onMessageAnnotationsPart, onFinishMessagePart, onFinishStepPart, onStartStepPart, }: {
|
806
776
|
stream: ReadableStream<Uint8Array>;
|
807
777
|
onTextPart?: (streamPart: (DataStreamPartType & {
|
@@ -856,21 +826,6 @@ declare function processTextStream({ stream, onTextPart, }: {
|
|
856
826
|
onTextPart: (chunk: string) => Promise<void> | void;
|
857
827
|
}): Promise<void>;
|
858
828
|
|
859
|
-
/**
|
860
|
-
* Updates the result of a specific tool invocation in the last message of the given messages array.
|
861
|
-
*
|
862
|
-
* @param {object} params - The parameters object.
|
863
|
-
* @param {UIMessage[]} params.messages - An array of messages, from which the last one is updated.
|
864
|
-
* @param {string} params.toolCallId - The unique identifier for the tool invocation to update.
|
865
|
-
* @param {unknown} params.toolResult - The result object to attach to the tool invocation.
|
866
|
-
* @returns {void} This function does not return anything.
|
867
|
-
*/
|
868
|
-
declare function updateToolCallResult({ messages, toolCallId, toolResult: result, }: {
|
869
|
-
messages: UIMessage[];
|
870
|
-
toolCallId: string;
|
871
|
-
toolResult: unknown;
|
872
|
-
}): void;
|
873
|
-
|
874
829
|
declare function shouldResubmitMessages({ originalMaxToolInvocationStep, originalMessageCount, maxSteps, messages, }: {
|
875
830
|
originalMaxToolInvocationStep: number | undefined;
|
876
831
|
originalMessageCount: number;
|
@@ -886,6 +841,21 @@ declare function isAssistantMessageWithCompletedToolCalls(message: UIMessage): m
|
|
886
841
|
role: 'assistant';
|
887
842
|
};
|
888
843
|
|
844
|
+
/**
|
845
|
+
* Updates the result of a specific tool invocation in the last message of the given messages array.
|
846
|
+
*
|
847
|
+
* @param {object} params - The parameters object.
|
848
|
+
* @param {UIMessage[]} params.messages - An array of messages, from which the last one is updated.
|
849
|
+
* @param {string} params.toolCallId - The unique identifier for the tool invocation to update.
|
850
|
+
* @param {unknown} params.toolResult - The result object to attach to the tool invocation.
|
851
|
+
* @returns {void} This function does not return anything.
|
852
|
+
*/
|
853
|
+
declare function updateToolCallResult({ messages, toolCallId, toolResult: result, }: {
|
854
|
+
messages: UIMessage[];
|
855
|
+
toolCallId: string;
|
856
|
+
toolResult: unknown;
|
857
|
+
}): void;
|
858
|
+
|
889
859
|
interface DataStreamWriter {
|
890
860
|
/**
|
891
861
|
* Appends a data part to the stream.
|
@@ -1258,10 +1228,6 @@ interface ImagePart {
|
|
1258
1228
|
*/
|
1259
1229
|
mediaType?: string;
|
1260
1230
|
/**
|
1261
|
-
@deprecated Use `mediaType` instead.
|
1262
|
-
*/
|
1263
|
-
mimeType?: string;
|
1264
|
-
/**
|
1265
1231
|
Additional provider-specific metadata. They are passed through
|
1266
1232
|
to the provider from the AI SDK and enable provider-specific
|
1267
1233
|
functionality that can be fully encapsulated in the provider.
|
@@ -1291,10 +1257,6 @@ interface FilePart {
|
|
1291
1257
|
*/
|
1292
1258
|
mediaType: string;
|
1293
1259
|
/**
|
1294
|
-
@deprecated Use `mediaType` instead.
|
1295
|
-
*/
|
1296
|
-
mimeType?: string;
|
1297
|
-
/**
|
1298
1260
|
Additional provider-specific metadata. They are passed through
|
1299
1261
|
to the provider from the AI SDK and enable provider-specific
|
1300
1262
|
functionality that can be fully encapsulated in the provider.
|
@@ -1381,7 +1343,7 @@ interface ToolResultPart {
|
|
1381
1343
|
to increase the resilience against prompt injection attacks,
|
1382
1344
|
and because not all providers support several system messages.
|
1383
1345
|
*/
|
1384
|
-
type
|
1346
|
+
type SystemModelMessage = {
|
1385
1347
|
role: 'system';
|
1386
1348
|
content: string;
|
1387
1349
|
/**
|
@@ -1391,11 +1353,19 @@ type CoreSystemMessage = {
|
|
1391
1353
|
*/
|
1392
1354
|
providerOptions?: ProviderOptions;
|
1393
1355
|
};
|
1394
|
-
|
1356
|
+
/**
|
1357
|
+
@deprecated Use `SystemModelMessage` instead.
|
1358
|
+
*/
|
1359
|
+
type CoreSystemMessage = SystemModelMessage;
|
1360
|
+
declare const systemModelMessageSchema: z.ZodType<SystemModelMessage>;
|
1361
|
+
/**
|
1362
|
+
@deprecated Use `systemModelMessageSchema` instead.
|
1363
|
+
*/
|
1364
|
+
declare const coreSystemMessageSchema: z.ZodType<SystemModelMessage, z.ZodTypeDef, SystemModelMessage>;
|
1395
1365
|
/**
|
1396
1366
|
A user message. It can contain text or a combination of text and images.
|
1397
1367
|
*/
|
1398
|
-
type
|
1368
|
+
type UserModelMessage = {
|
1399
1369
|
role: 'user';
|
1400
1370
|
content: UserContent;
|
1401
1371
|
/**
|
@@ -1405,7 +1375,15 @@ type CoreUserMessage = {
|
|
1405
1375
|
*/
|
1406
1376
|
providerOptions?: ProviderOptions;
|
1407
1377
|
};
|
1408
|
-
|
1378
|
+
/**
|
1379
|
+
@deprecated Use `UserModelMessage` instead.
|
1380
|
+
*/
|
1381
|
+
type CoreUserMessage = UserModelMessage;
|
1382
|
+
declare const userModelMessageSchema: z.ZodType<UserModelMessage>;
|
1383
|
+
/**
|
1384
|
+
@deprecated Use `userModelMessageSchema` instead.
|
1385
|
+
*/
|
1386
|
+
declare const coreUserMessageSchema: z.ZodType<UserModelMessage, z.ZodTypeDef, UserModelMessage>;
|
1409
1387
|
/**
|
1410
1388
|
Content of a user message. It can be a string or an array of text and image parts.
|
1411
1389
|
*/
|
@@ -1413,7 +1391,7 @@ type UserContent = string | Array<TextPart | ImagePart | FilePart>;
|
|
1413
1391
|
/**
|
1414
1392
|
An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
|
1415
1393
|
*/
|
1416
|
-
type
|
1394
|
+
type AssistantModelMessage = {
|
1417
1395
|
role: 'assistant';
|
1418
1396
|
content: AssistantContent;
|
1419
1397
|
/**
|
@@ -1423,7 +1401,15 @@ type CoreAssistantMessage = {
|
|
1423
1401
|
*/
|
1424
1402
|
providerOptions?: ProviderOptions;
|
1425
1403
|
};
|
1426
|
-
|
1404
|
+
/**
|
1405
|
+
@deprecated Use `AssistantModelMessage` instead.
|
1406
|
+
*/
|
1407
|
+
type CoreAssistantMessage = AssistantModelMessage;
|
1408
|
+
declare const assistantModelMessageSchema: z.ZodType<AssistantModelMessage>;
|
1409
|
+
/**
|
1410
|
+
@deprecated Use `assistantModelMessageSchema` instead.
|
1411
|
+
*/
|
1412
|
+
declare const coreAssistantMessageSchema: z.ZodType<AssistantModelMessage, z.ZodTypeDef, AssistantModelMessage>;
|
1427
1413
|
/**
|
1428
1414
|
Content of an assistant message.
|
1429
1415
|
It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
|
@@ -1432,7 +1418,7 @@ type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | Too
|
|
1432
1418
|
/**
|
1433
1419
|
A tool message. It contains the result of one or more tool calls.
|
1434
1420
|
*/
|
1435
|
-
type
|
1421
|
+
type ToolModelMessage = {
|
1436
1422
|
role: 'tool';
|
1437
1423
|
content: ToolContent;
|
1438
1424
|
/**
|
@@ -1442,7 +1428,15 @@ type CoreToolMessage = {
|
|
1442
1428
|
*/
|
1443
1429
|
providerOptions?: ProviderOptions;
|
1444
1430
|
};
|
1445
|
-
|
1431
|
+
/**
|
1432
|
+
@deprecated Use `ToolModelMessage` instead.
|
1433
|
+
*/
|
1434
|
+
type CoreToolMessage = ToolModelMessage;
|
1435
|
+
declare const toolModelMessageSchema: z.ZodType<ToolModelMessage>;
|
1436
|
+
/**
|
1437
|
+
@deprecated Use `toolModelMessageSchema` instead.
|
1438
|
+
*/
|
1439
|
+
declare const coreToolMessageSchema: z.ZodType<ToolModelMessage, z.ZodTypeDef, ToolModelMessage>;
|
1446
1440
|
/**
|
1447
1441
|
Content of a tool message. It is an array of tool result parts.
|
1448
1442
|
*/
|
@@ -1451,7 +1445,15 @@ type ToolContent = Array<ToolResultPart>;
|
|
1451
1445
|
A message that can be used in the `messages` field of a prompt.
|
1452
1446
|
It can be a user message, an assistant message, or a tool message.
|
1453
1447
|
*/
|
1454
|
-
type
|
1448
|
+
type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;
|
1449
|
+
/**
|
1450
|
+
@deprecated Use `ModelMessage` instead.
|
1451
|
+
*/
|
1452
|
+
type CoreMessage = ModelMessage;
|
1453
|
+
declare const modelMessageSchema: z.ZodType<ModelMessage>;
|
1454
|
+
/**
|
1455
|
+
@deprecated Use `modelMessageSchema` instead.
|
1456
|
+
*/
|
1455
1457
|
declare const coreMessageSchema: z.ZodType<CoreMessage>;
|
1456
1458
|
|
1457
1459
|
/**
|
@@ -1470,7 +1472,7 @@ type Prompt = {
|
|
1470
1472
|
/**
|
1471
1473
|
A list of messages. You can either use `prompt` or `messages` but not both.
|
1472
1474
|
*/
|
1473
|
-
messages?: Array<
|
1475
|
+
messages?: Array<ModelMessage> | Array<Omit<UIMessage, 'id'>>;
|
1474
1476
|
};
|
1475
1477
|
|
1476
1478
|
/**
|
@@ -1566,20 +1568,20 @@ declare const JSONRPCErrorSchema: z.ZodObject<{
|
|
1566
1568
|
data?: unknown;
|
1567
1569
|
}>;
|
1568
1570
|
}, "strict", z.ZodTypeAny, {
|
1571
|
+
id: string | number;
|
1569
1572
|
error: {
|
1570
1573
|
code: number;
|
1571
1574
|
message: string;
|
1572
1575
|
data?: unknown;
|
1573
1576
|
};
|
1574
|
-
id: string | number;
|
1575
1577
|
jsonrpc: "2.0";
|
1576
1578
|
}, {
|
1579
|
+
id: string | number;
|
1577
1580
|
error: {
|
1578
1581
|
code: number;
|
1579
1582
|
message: string;
|
1580
1583
|
data?: unknown;
|
1581
1584
|
};
|
1582
|
-
id: string | number;
|
1583
1585
|
jsonrpc: "2.0";
|
1584
1586
|
}>;
|
1585
1587
|
type JSONRPCError = z.infer<typeof JSONRPCErrorSchema>;
|
@@ -1700,20 +1702,20 @@ declare const JSONRPCMessageSchema: z.ZodUnion<[z.ZodObject<z.objectUtil.extendS
|
|
1700
1702
|
data?: unknown;
|
1701
1703
|
}>;
|
1702
1704
|
}, "strict", z.ZodTypeAny, {
|
1705
|
+
id: string | number;
|
1703
1706
|
error: {
|
1704
1707
|
code: number;
|
1705
1708
|
message: string;
|
1706
1709
|
data?: unknown;
|
1707
1710
|
};
|
1708
|
-
id: string | number;
|
1709
1711
|
jsonrpc: "2.0";
|
1710
1712
|
}, {
|
1713
|
+
id: string | number;
|
1711
1714
|
error: {
|
1712
1715
|
code: number;
|
1713
1716
|
message: string;
|
1714
1717
|
data?: unknown;
|
1715
1718
|
};
|
1716
|
-
id: string | number;
|
1717
1719
|
jsonrpc: "2.0";
|
1718
1720
|
}>]>;
|
1719
1721
|
type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
|
@@ -1771,7 +1773,7 @@ interface ToolExecutionOptions {
|
|
1771
1773
|
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
1772
1774
|
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
1773
1775
|
*/
|
1774
|
-
messages:
|
1776
|
+
messages: ModelMessage[];
|
1775
1777
|
/**
|
1776
1778
|
* An optional abort signal that indicates that the overall operation should be aborted.
|
1777
1779
|
*/
|
@@ -2581,9 +2583,13 @@ declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
|
|
2581
2583
|
* Tool parameters are automatically inferred from the server's JSON schema
|
2582
2584
|
* if not explicitly provided in the tools configuration
|
2583
2585
|
*
|
2586
|
+
* This client is meant to be used to communicate with a single server. To communicate and fetch tools across multiple servers, it's recommended to create a new client instance per server.
|
2587
|
+
*
|
2584
2588
|
* Not supported:
|
2585
2589
|
* - Client options (e.g. sampling, roots) as they are not needed for tool conversion
|
2586
2590
|
* - Accepting notifications
|
2591
|
+
* - Session management (when passing a sessionId to an instance of the Streamable HTTP transport)
|
2592
|
+
* - Resumable SSE streams
|
2587
2593
|
*/
|
2588
2594
|
declare class MCPClient {
|
2589
2595
|
private transport;
|
@@ -2596,6 +2602,7 @@ declare class MCPClient {
|
|
2596
2602
|
constructor({ transport: transportConfig, name, onUncaughtError, }: MCPClientConfig);
|
2597
2603
|
init(): Promise<this>;
|
2598
2604
|
close(): Promise<void>;
|
2605
|
+
private assertCapability;
|
2599
2606
|
private request;
|
2600
2607
|
private listTools;
|
2601
2608
|
private callTool;
|
@@ -2923,9 +2930,9 @@ declare class NoSuchToolError extends AISDKError {
|
|
2923
2930
|
* Otherwise, the new message will be appended.
|
2924
2931
|
*/
|
2925
2932
|
declare function appendClientMessage({ messages, message, }: {
|
2926
|
-
messages:
|
2927
|
-
message:
|
2928
|
-
}):
|
2933
|
+
messages: UIMessage[];
|
2934
|
+
message: UIMessage;
|
2935
|
+
}): UIMessage[];
|
2929
2936
|
|
2930
2937
|
/**
|
2931
2938
|
* Appends the ResponseMessage[] from the response to a Message[] (for useChat).
|
@@ -2935,7 +2942,7 @@ declare function appendClientMessage({ messages, message, }: {
|
|
2935
2942
|
* @returns A new Message[] with the response messages appended.
|
2936
2943
|
*/
|
2937
2944
|
declare function appendResponseMessages({ messages, responseMessages, _internal: { currentDate }, }: {
|
2938
|
-
messages:
|
2945
|
+
messages: UIMessage[];
|
2939
2946
|
responseMessages: ResponseMessage[];
|
2940
2947
|
/**
|
2941
2948
|
Internal. For test use only. May change without notice.
|
@@ -2943,15 +2950,19 @@ declare function appendResponseMessages({ messages, responseMessages, _internal:
|
|
2943
2950
|
_internal?: {
|
2944
2951
|
currentDate?: () => Date;
|
2945
2952
|
};
|
2946
|
-
}):
|
2953
|
+
}): UIMessage[];
|
2947
2954
|
|
2948
2955
|
/**
|
2949
2956
|
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
2950
2957
|
with the AI core functions (e.g. `streamText`).
|
2951
2958
|
*/
|
2952
|
-
declare function
|
2959
|
+
declare function convertToModelMessages<TOOLS extends ToolSet = never>(messages: Array<Omit<UIMessage, 'id'>>, options?: {
|
2953
2960
|
tools?: TOOLS;
|
2954
|
-
}):
|
2961
|
+
}): ModelMessage[];
|
2962
|
+
/**
|
2963
|
+
@deprecated Use `convertToModelMessages` instead.
|
2964
|
+
*/
|
2965
|
+
declare const convertToCoreMessages: typeof convertToModelMessages;
|
2955
2966
|
|
2956
2967
|
/**
|
2957
2968
|
* A function that attempts to repair a tool call that failed to parse.
|
@@ -2968,7 +2979,7 @@ declare function convertToCoreMessages<TOOLS extends ToolSet = never>(messages:
|
|
2968
2979
|
*/
|
2969
2980
|
type ToolCallRepairFunction<TOOLS extends ToolSet> = (options: {
|
2970
2981
|
system: string | undefined;
|
2971
|
-
messages:
|
2982
|
+
messages: ModelMessage[];
|
2972
2983
|
toolCall: LanguageModelV2ToolCall;
|
2973
2984
|
tools: TOOLS;
|
2974
2985
|
parameterSchema: (options: {
|
@@ -3670,6 +3681,11 @@ interface GenerateImageResult {
|
|
3670
3681
|
Response metadata from the provider. There may be multiple responses if we made multiple calls to the model.
|
3671
3682
|
*/
|
3672
3683
|
readonly responses: Array<ImageModelResponseMetadata>;
|
3684
|
+
/**
|
3685
|
+
* Provider-specific metadata. They are passed through from the provider to the AI SDK and enable provider-specific
|
3686
|
+
* results that can be fully encapsulated in the provider.
|
3687
|
+
*/
|
3688
|
+
readonly providerMetadata: ImageModelProviderMetadata;
|
3673
3689
|
}
|
3674
3690
|
|
3675
3691
|
/**
|
@@ -4012,7 +4028,14 @@ This function streams the output. If you do not want to stream the output, use `
|
|
4012
4028
|
@return
|
4013
4029
|
A result object for accessing the partial object stream and additional information.
|
4014
4030
|
*/
|
4015
|
-
declare function streamObject<RESULT extends SCHEMA extends z.Schema ? Output extends 'array' ? Array<z.infer<SCHEMA>> : z.infer<SCHEMA> : SCHEMA extends Schema<infer T> ? Output extends 'array' ? Array<T> : T : never, SCHEMA extends z.Schema | Schema = z.Schema<JSONValue$1>, Output extends 'object' | 'array' | 'no-schema' = 'object'>(options: Omit<CallSettings, 'stopSequences'> & Prompt & (Output extends '
|
4031
|
+
declare function streamObject<RESULT extends SCHEMA extends z.Schema ? Output extends 'array' ? Array<z.infer<SCHEMA>> : z.infer<SCHEMA> : SCHEMA extends Schema<infer T> ? Output extends 'array' ? Array<T> : T : never, SCHEMA extends z.Schema | Schema = z.Schema<JSONValue$1>, Output extends 'object' | 'array' | 'enum' | 'no-schema' = RESULT extends string ? 'enum' : 'object'>(options: Omit<CallSettings, 'stopSequences'> & Prompt & (Output extends 'enum' ? {
|
4032
|
+
/**
|
4033
|
+
The enum values that the model should use.
|
4034
|
+
*/
|
4035
|
+
enum: Array<RESULT>;
|
4036
|
+
mode?: 'json';
|
4037
|
+
output: 'enum';
|
4038
|
+
} : Output extends 'no-schema' ? {} : {
|
4016
4039
|
/**
|
4017
4040
|
The schema of the object that the model should generate.
|
4018
4041
|
*/
|
@@ -4077,7 +4100,7 @@ Callback that is called when the LLM response and the final object validation ar
|
|
4077
4100
|
currentDate?: () => Date;
|
4078
4101
|
now?: () => number;
|
4079
4102
|
};
|
4080
|
-
}): StreamObjectResult<Output extends 'array' ? RESULT : DeepPartial<RESULT>, Output extends 'array' ? RESULT : RESULT, Output extends 'array' ? RESULT extends Array<infer U> ? AsyncIterableStream<U> : never : never>;
|
4103
|
+
}): StreamObjectResult<Output extends 'enum' ? string : Output extends 'array' ? RESULT : DeepPartial<RESULT>, Output extends 'array' ? RESULT : RESULT, Output extends 'array' ? RESULT extends Array<infer U> ? AsyncIterableStream<U> : never : never>;
|
4081
4104
|
|
4082
4105
|
/**
|
4083
4106
|
* A generated audio file.
|
@@ -4411,6 +4434,8 @@ declare function createProviderRegistry<PROVIDERS extends Record<string, Provide
|
|
4411
4434
|
*/
|
4412
4435
|
declare const experimental_createProviderRegistry: typeof createProviderRegistry;
|
4413
4436
|
|
4437
|
+
declare function getToolInvocations(message: UIMessage): ToolInvocation[];
|
4438
|
+
|
4414
4439
|
/**
|
4415
4440
|
* Calculates the cosine similarity between two vectors. This is a useful metric for
|
4416
4441
|
* comparing the similarity of two vectors such as embeddings.
|
@@ -4654,9 +4679,9 @@ declare class InvalidMessageRoleError extends AISDKError {
|
|
4654
4679
|
declare const symbol$2: unique symbol;
|
4655
4680
|
declare class MessageConversionError extends AISDKError {
|
4656
4681
|
private readonly [symbol$2];
|
4657
|
-
readonly originalMessage: Omit<
|
4682
|
+
readonly originalMessage: Omit<UIMessage, 'id'>;
|
4658
4683
|
constructor({ originalMessage, message, }: {
|
4659
|
-
originalMessage: Omit<
|
4684
|
+
originalMessage: Omit<UIMessage, 'id'>;
|
4660
4685
|
message: string;
|
4661
4686
|
});
|
4662
4687
|
static isInstance(error: unknown): error is MessageConversionError;
|
@@ -4693,4 +4718,4 @@ declare class RetryError extends AISDKError {
|
|
4693
4718
|
static isInstance(error: unknown): error is RetryError;
|
4694
4719
|
}
|
4695
4720
|
|
4696
|
-
export { AssistantContent,
|
4721
|
+
export { AssistantContent, AssistantModelMessage, CallSettings, CallWarning, ChatRequest, ChatRequestOptions, ChunkDetector, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataStreamOptions, DataStreamPart, DataStreamString, DataStreamWriter, DeepPartial, 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, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, IdGenerator, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, ImagePart, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, ModelMessage, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RequestOptions, RetryError, SourceUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StreamData, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, SystemModelMessage, TelemetrySettings, TextPart, TextStreamPart, TextUIPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIMessage, UIMessagePart, UseChatOptions, UseCompletionOptions, UserContent, UserModelMessage, appendClientMessage, appendResponseMessages, assistantModelMessageSchema, callChatApi, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDataStream, createDataStreamResponse, createProviderRegistry, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractMaxToolInvocationStep, extractReasoningMiddleware, formatDataStreamPart, generateObject, generateText, getTextFromDataUrl, getToolInvocations, isAssistantMessageWithCompletedToolCalls, isDeepEqualData, modelMessageSchema, parseDataStreamPart, parsePartialJson, pipeDataStreamToResponse, processDataStream, processTextStream, shouldResubmitMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, updateToolCallResult, userModelMessageSchema, wrapLanguageModel };
|