@voltagent/core 1.2.4 → 1.2.5
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/dist/index.d.mts +42 -9
- package/dist/index.d.ts +42 -9
- package/dist/index.js +86 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ToolCallOptions, ProviderOptions as ProviderOptions$1, ModelMessage, DataContent as DataContent$1, UserContent, AssistantContent, ToolContent } from '@ai-sdk/provider-utils';
|
|
2
2
|
export { AssistantContent, FilePart, ImagePart, ProviderOptions, TextPart, ToolContent, UserContent } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { Tool as Tool$1, TextStreamPart, generateText, UIMessage, StreamTextResult, LanguageModel, CallSettings, Output, ToolSet, GenerateTextResult, GenerateObjectResult, AsyncIterableStream as AsyncIterableStream$1, CallWarning, LanguageModelUsage, FinishReason, EmbeddingModel } from 'ai';
|
|
3
|
+
import { Tool as Tool$1, TextStreamPart, generateText, UIMessage, StreamTextResult, LanguageModel, CallSettings, Output, ToolSet, GenerateTextResult, GenerateObjectResult, AsyncIterableStream as AsyncIterableStream$1, CallWarning, LanguageModelUsage, FinishReason, EmbeddingModel, TextUIPart, FileUIPart } from 'ai';
|
|
4
4
|
export { LanguageModel, Tool as VercelTool, hasToolCall, stepCountIs } from 'ai';
|
|
5
5
|
import * as zod from 'zod';
|
|
6
6
|
import { z } from 'zod';
|
|
@@ -8239,36 +8239,65 @@ declare function isTextContent(content: MessageContent): content is string;
|
|
|
8239
8239
|
*/
|
|
8240
8240
|
declare function isStructuredContent(content: MessageContent): content is Array<any>;
|
|
8241
8241
|
/**
|
|
8242
|
-
* Check if content has any text parts
|
|
8242
|
+
* Check if content or message has any text parts
|
|
8243
|
+
* @param input - MessageContent or UIMessage
|
|
8244
|
+
* @returns True if has text parts
|
|
8243
8245
|
*/
|
|
8244
8246
|
declare function hasTextPart(content: MessageContent): boolean;
|
|
8247
|
+
declare function hasTextPart(message: UIMessage): boolean;
|
|
8245
8248
|
/**
|
|
8246
|
-
* Check if content has any image parts
|
|
8249
|
+
* Check if content or message has any image parts
|
|
8250
|
+
* @param input - MessageContent or UIMessage
|
|
8251
|
+
* @returns True if has image parts
|
|
8247
8252
|
*/
|
|
8248
8253
|
declare function hasImagePart(content: MessageContent): boolean;
|
|
8254
|
+
declare function hasImagePart(message: UIMessage): boolean;
|
|
8249
8255
|
/**
|
|
8250
|
-
* Check if content has any file parts
|
|
8256
|
+
* Check if content or message has any file parts
|
|
8257
|
+
* @param input - MessageContent or UIMessage
|
|
8258
|
+
* @returns True if has file parts
|
|
8251
8259
|
*/
|
|
8252
8260
|
declare function hasFilePart(content: MessageContent): boolean;
|
|
8261
|
+
declare function hasFilePart(message: UIMessage): boolean;
|
|
8253
8262
|
/**
|
|
8254
|
-
* Extract text from message content
|
|
8263
|
+
* Extract text from message content or UIMessage
|
|
8264
|
+
* @param input - MessageContent (from ModelMessage.content) or UIMessage object
|
|
8265
|
+
* @returns All text content joined together
|
|
8266
|
+
* @example
|
|
8267
|
+
* // From MessageContent
|
|
8268
|
+
* const content = [{ type: "text", text: "Hello" }];
|
|
8269
|
+
* extractText(content); // "Hello"
|
|
8270
|
+
*
|
|
8271
|
+
* // From UIMessage
|
|
8272
|
+
* const message = { id: "1", role: "user", parts: [{ type: "text", text: "Hi" }] };
|
|
8273
|
+
* extractText(message); // "Hi"
|
|
8255
8274
|
*/
|
|
8256
8275
|
declare function extractText(content: MessageContent): string;
|
|
8276
|
+
declare function extractText(message: UIMessage): string;
|
|
8257
8277
|
/**
|
|
8258
|
-
* Extract all text parts from structured content
|
|
8278
|
+
* Extract all text parts from structured content or UIMessage
|
|
8279
|
+
* @param input - MessageContent or UIMessage
|
|
8280
|
+
* @returns Array of text parts
|
|
8259
8281
|
*/
|
|
8260
8282
|
declare function extractTextParts(content: MessageContent): Array<{
|
|
8261
8283
|
type: "text";
|
|
8262
8284
|
text: string;
|
|
8263
8285
|
}>;
|
|
8286
|
+
declare function extractTextParts(message: UIMessage): TextUIPart[];
|
|
8264
8287
|
/**
|
|
8265
|
-
* Extract image parts from message content
|
|
8288
|
+
* Extract image parts from message content or UIMessage
|
|
8289
|
+
* @param input - MessageContent or UIMessage
|
|
8290
|
+
* @returns Array of image parts (FileUIPart for UIMessage)
|
|
8266
8291
|
*/
|
|
8267
8292
|
declare function extractImageParts(content: MessageContent): Array<any>;
|
|
8293
|
+
declare function extractImageParts(message: UIMessage): FileUIPart[];
|
|
8268
8294
|
/**
|
|
8269
|
-
* Extract file parts from message content
|
|
8295
|
+
* Extract file parts from message content or UIMessage
|
|
8296
|
+
* @param input - MessageContent or UIMessage
|
|
8297
|
+
* @returns Array of file parts
|
|
8270
8298
|
*/
|
|
8271
8299
|
declare function extractFileParts(content: MessageContent): Array<any>;
|
|
8300
|
+
declare function extractFileParts(message: UIMessage): FileUIPart[];
|
|
8272
8301
|
/**
|
|
8273
8302
|
* Transform text content in a message
|
|
8274
8303
|
*/
|
|
@@ -8344,11 +8373,15 @@ declare function appendToMessage(message: UIMessage, suffix: string): UIMessage;
|
|
|
8344
8373
|
*/
|
|
8345
8374
|
declare function hasContent(message: UIMessage): boolean;
|
|
8346
8375
|
/**
|
|
8347
|
-
* Get content length (text characters or
|
|
8376
|
+
* Get content length (text characters, array items, or UIMessage parts count)
|
|
8377
|
+
* @param input - MessageContent or UIMessage
|
|
8378
|
+
* @returns Length/count of content
|
|
8348
8379
|
*/
|
|
8349
8380
|
declare function getContentLength(content: MessageContent): number;
|
|
8381
|
+
declare function getContentLength(message: UIMessage): number;
|
|
8350
8382
|
/**
|
|
8351
8383
|
* Combined message helpers object for easy importing
|
|
8384
|
+
* All functions now support both MessageContent and UIMessage formats
|
|
8352
8385
|
*/
|
|
8353
8386
|
declare const messageHelpers: {
|
|
8354
8387
|
isTextContent: typeof isTextContent;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ToolCallOptions, ProviderOptions as ProviderOptions$1, ModelMessage, DataContent as DataContent$1, UserContent, AssistantContent, ToolContent } from '@ai-sdk/provider-utils';
|
|
2
2
|
export { AssistantContent, FilePart, ImagePart, ProviderOptions, TextPart, ToolContent, UserContent } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { Tool as Tool$1, TextStreamPart, generateText, UIMessage, StreamTextResult, LanguageModel, CallSettings, Output, ToolSet, GenerateTextResult, GenerateObjectResult, AsyncIterableStream as AsyncIterableStream$1, CallWarning, LanguageModelUsage, FinishReason, EmbeddingModel } from 'ai';
|
|
3
|
+
import { Tool as Tool$1, TextStreamPart, generateText, UIMessage, StreamTextResult, LanguageModel, CallSettings, Output, ToolSet, GenerateTextResult, GenerateObjectResult, AsyncIterableStream as AsyncIterableStream$1, CallWarning, LanguageModelUsage, FinishReason, EmbeddingModel, TextUIPart, FileUIPart } from 'ai';
|
|
4
4
|
export { LanguageModel, Tool as VercelTool, hasToolCall, stepCountIs } from 'ai';
|
|
5
5
|
import * as zod from 'zod';
|
|
6
6
|
import { z } from 'zod';
|
|
@@ -8239,36 +8239,65 @@ declare function isTextContent(content: MessageContent): content is string;
|
|
|
8239
8239
|
*/
|
|
8240
8240
|
declare function isStructuredContent(content: MessageContent): content is Array<any>;
|
|
8241
8241
|
/**
|
|
8242
|
-
* Check if content has any text parts
|
|
8242
|
+
* Check if content or message has any text parts
|
|
8243
|
+
* @param input - MessageContent or UIMessage
|
|
8244
|
+
* @returns True if has text parts
|
|
8243
8245
|
*/
|
|
8244
8246
|
declare function hasTextPart(content: MessageContent): boolean;
|
|
8247
|
+
declare function hasTextPart(message: UIMessage): boolean;
|
|
8245
8248
|
/**
|
|
8246
|
-
* Check if content has any image parts
|
|
8249
|
+
* Check if content or message has any image parts
|
|
8250
|
+
* @param input - MessageContent or UIMessage
|
|
8251
|
+
* @returns True if has image parts
|
|
8247
8252
|
*/
|
|
8248
8253
|
declare function hasImagePart(content: MessageContent): boolean;
|
|
8254
|
+
declare function hasImagePart(message: UIMessage): boolean;
|
|
8249
8255
|
/**
|
|
8250
|
-
* Check if content has any file parts
|
|
8256
|
+
* Check if content or message has any file parts
|
|
8257
|
+
* @param input - MessageContent or UIMessage
|
|
8258
|
+
* @returns True if has file parts
|
|
8251
8259
|
*/
|
|
8252
8260
|
declare function hasFilePart(content: MessageContent): boolean;
|
|
8261
|
+
declare function hasFilePart(message: UIMessage): boolean;
|
|
8253
8262
|
/**
|
|
8254
|
-
* Extract text from message content
|
|
8263
|
+
* Extract text from message content or UIMessage
|
|
8264
|
+
* @param input - MessageContent (from ModelMessage.content) or UIMessage object
|
|
8265
|
+
* @returns All text content joined together
|
|
8266
|
+
* @example
|
|
8267
|
+
* // From MessageContent
|
|
8268
|
+
* const content = [{ type: "text", text: "Hello" }];
|
|
8269
|
+
* extractText(content); // "Hello"
|
|
8270
|
+
*
|
|
8271
|
+
* // From UIMessage
|
|
8272
|
+
* const message = { id: "1", role: "user", parts: [{ type: "text", text: "Hi" }] };
|
|
8273
|
+
* extractText(message); // "Hi"
|
|
8255
8274
|
*/
|
|
8256
8275
|
declare function extractText(content: MessageContent): string;
|
|
8276
|
+
declare function extractText(message: UIMessage): string;
|
|
8257
8277
|
/**
|
|
8258
|
-
* Extract all text parts from structured content
|
|
8278
|
+
* Extract all text parts from structured content or UIMessage
|
|
8279
|
+
* @param input - MessageContent or UIMessage
|
|
8280
|
+
* @returns Array of text parts
|
|
8259
8281
|
*/
|
|
8260
8282
|
declare function extractTextParts(content: MessageContent): Array<{
|
|
8261
8283
|
type: "text";
|
|
8262
8284
|
text: string;
|
|
8263
8285
|
}>;
|
|
8286
|
+
declare function extractTextParts(message: UIMessage): TextUIPart[];
|
|
8264
8287
|
/**
|
|
8265
|
-
* Extract image parts from message content
|
|
8288
|
+
* Extract image parts from message content or UIMessage
|
|
8289
|
+
* @param input - MessageContent or UIMessage
|
|
8290
|
+
* @returns Array of image parts (FileUIPart for UIMessage)
|
|
8266
8291
|
*/
|
|
8267
8292
|
declare function extractImageParts(content: MessageContent): Array<any>;
|
|
8293
|
+
declare function extractImageParts(message: UIMessage): FileUIPart[];
|
|
8268
8294
|
/**
|
|
8269
|
-
* Extract file parts from message content
|
|
8295
|
+
* Extract file parts from message content or UIMessage
|
|
8296
|
+
* @param input - MessageContent or UIMessage
|
|
8297
|
+
* @returns Array of file parts
|
|
8270
8298
|
*/
|
|
8271
8299
|
declare function extractFileParts(content: MessageContent): Array<any>;
|
|
8300
|
+
declare function extractFileParts(message: UIMessage): FileUIPart[];
|
|
8272
8301
|
/**
|
|
8273
8302
|
* Transform text content in a message
|
|
8274
8303
|
*/
|
|
@@ -8344,11 +8373,15 @@ declare function appendToMessage(message: UIMessage, suffix: string): UIMessage;
|
|
|
8344
8373
|
*/
|
|
8345
8374
|
declare function hasContent(message: UIMessage): boolean;
|
|
8346
8375
|
/**
|
|
8347
|
-
* Get content length (text characters or
|
|
8376
|
+
* Get content length (text characters, array items, or UIMessage parts count)
|
|
8377
|
+
* @param input - MessageContent or UIMessage
|
|
8378
|
+
* @returns Length/count of content
|
|
8348
8379
|
*/
|
|
8349
8380
|
declare function getContentLength(content: MessageContent): number;
|
|
8381
|
+
declare function getContentLength(message: UIMessage): number;
|
|
8350
8382
|
/**
|
|
8351
8383
|
* Combined message helpers object for easy importing
|
|
8384
|
+
* All functions now support both MessageContent and UIMessage formats
|
|
8352
8385
|
*/
|
|
8353
8386
|
declare const messageHelpers: {
|
|
8354
8387
|
isTextContent: typeof isTextContent;
|
package/dist/index.js
CHANGED
|
@@ -12846,58 +12846,104 @@ function isStructuredContent(content) {
|
|
|
12846
12846
|
return Array.isArray(content);
|
|
12847
12847
|
}
|
|
12848
12848
|
__name(isStructuredContent, "isStructuredContent");
|
|
12849
|
-
function hasTextPart(
|
|
12850
|
-
if (
|
|
12851
|
-
|
|
12852
|
-
|
|
12849
|
+
function hasTextPart(input) {
|
|
12850
|
+
if (isUIMessage(input)) {
|
|
12851
|
+
if (!input.parts || !Array.isArray(input.parts)) {
|
|
12852
|
+
return false;
|
|
12853
|
+
}
|
|
12854
|
+
return input.parts.some((part) => part?.type === "text");
|
|
12855
|
+
}
|
|
12856
|
+
if (isTextContent(input)) return true;
|
|
12857
|
+
if (isStructuredContent(input)) {
|
|
12858
|
+
return input.some((part) => part.type === "text");
|
|
12853
12859
|
}
|
|
12854
12860
|
return false;
|
|
12855
12861
|
}
|
|
12856
12862
|
__name(hasTextPart, "hasTextPart");
|
|
12857
|
-
function hasImagePart(
|
|
12858
|
-
if (
|
|
12859
|
-
|
|
12863
|
+
function hasImagePart(input) {
|
|
12864
|
+
if (isUIMessage(input)) {
|
|
12865
|
+
if (!input.parts || !Array.isArray(input.parts)) {
|
|
12866
|
+
return false;
|
|
12867
|
+
}
|
|
12868
|
+
return input.parts.some(
|
|
12869
|
+
(part) => part?.type === "file" && typeof part.mediaType === "string" && part.mediaType.startsWith("image/")
|
|
12870
|
+
);
|
|
12871
|
+
}
|
|
12872
|
+
if (isStructuredContent(input)) {
|
|
12873
|
+
return input.some((part) => part.type === "image");
|
|
12860
12874
|
}
|
|
12861
12875
|
return false;
|
|
12862
12876
|
}
|
|
12863
12877
|
__name(hasImagePart, "hasImagePart");
|
|
12864
|
-
function hasFilePart(
|
|
12865
|
-
if (
|
|
12866
|
-
|
|
12878
|
+
function hasFilePart(input) {
|
|
12879
|
+
if (isUIMessage(input)) {
|
|
12880
|
+
if (!input.parts || !Array.isArray(input.parts)) {
|
|
12881
|
+
return false;
|
|
12882
|
+
}
|
|
12883
|
+
return input.parts.some((part) => part?.type === "file");
|
|
12884
|
+
}
|
|
12885
|
+
if (isStructuredContent(input)) {
|
|
12886
|
+
return input.some((part) => part.type === "file");
|
|
12867
12887
|
}
|
|
12868
12888
|
return false;
|
|
12869
12889
|
}
|
|
12870
12890
|
__name(hasFilePart, "hasFilePart");
|
|
12871
|
-
function extractText(
|
|
12872
|
-
if (
|
|
12873
|
-
|
|
12891
|
+
function extractText(input) {
|
|
12892
|
+
if (isUIMessage(input)) {
|
|
12893
|
+
if (!input.parts || !Array.isArray(input.parts)) {
|
|
12894
|
+
return "";
|
|
12895
|
+
}
|
|
12896
|
+
return input.parts.filter((part) => part?.type === "text").map((part) => part.text).join("");
|
|
12874
12897
|
}
|
|
12875
|
-
if (
|
|
12876
|
-
return
|
|
12898
|
+
if (isTextContent(input)) {
|
|
12899
|
+
return input;
|
|
12900
|
+
}
|
|
12901
|
+
if (isStructuredContent(input)) {
|
|
12902
|
+
return input.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
12877
12903
|
}
|
|
12878
12904
|
return "";
|
|
12879
12905
|
}
|
|
12880
12906
|
__name(extractText, "extractText");
|
|
12881
|
-
function extractTextParts(
|
|
12882
|
-
if (
|
|
12883
|
-
|
|
12907
|
+
function extractTextParts(input) {
|
|
12908
|
+
if (isUIMessage(input)) {
|
|
12909
|
+
if (!input.parts || !Array.isArray(input.parts)) {
|
|
12910
|
+
return [];
|
|
12911
|
+
}
|
|
12912
|
+
return input.parts.filter((part) => part?.type === "text");
|
|
12884
12913
|
}
|
|
12885
|
-
if (
|
|
12886
|
-
return
|
|
12914
|
+
if (isStructuredContent(input)) {
|
|
12915
|
+
return input.filter((part) => part.type === "text");
|
|
12916
|
+
}
|
|
12917
|
+
if (isTextContent(input)) {
|
|
12918
|
+
return [{ type: "text", text: input }];
|
|
12887
12919
|
}
|
|
12888
12920
|
return [];
|
|
12889
12921
|
}
|
|
12890
12922
|
__name(extractTextParts, "extractTextParts");
|
|
12891
|
-
function extractImageParts(
|
|
12892
|
-
if (
|
|
12893
|
-
|
|
12923
|
+
function extractImageParts(input) {
|
|
12924
|
+
if (isUIMessage(input)) {
|
|
12925
|
+
if (!input.parts || !Array.isArray(input.parts)) {
|
|
12926
|
+
return [];
|
|
12927
|
+
}
|
|
12928
|
+
return input.parts.filter(
|
|
12929
|
+
(part) => part?.type === "file" && typeof part.mediaType === "string" && part.mediaType.startsWith("image/")
|
|
12930
|
+
);
|
|
12931
|
+
}
|
|
12932
|
+
if (isStructuredContent(input)) {
|
|
12933
|
+
return input.filter((part) => part.type === "image");
|
|
12894
12934
|
}
|
|
12895
12935
|
return [];
|
|
12896
12936
|
}
|
|
12897
12937
|
__name(extractImageParts, "extractImageParts");
|
|
12898
|
-
function extractFileParts(
|
|
12899
|
-
if (
|
|
12900
|
-
|
|
12938
|
+
function extractFileParts(input) {
|
|
12939
|
+
if (isUIMessage(input)) {
|
|
12940
|
+
if (!input.parts || !Array.isArray(input.parts)) {
|
|
12941
|
+
return [];
|
|
12942
|
+
}
|
|
12943
|
+
return input.parts.filter((part) => part?.type === "file");
|
|
12944
|
+
}
|
|
12945
|
+
if (isStructuredContent(input)) {
|
|
12946
|
+
return input.filter((part) => part.type === "file");
|
|
12901
12947
|
}
|
|
12902
12948
|
return [];
|
|
12903
12949
|
}
|
|
@@ -13066,12 +13112,22 @@ function hasContent(message) {
|
|
|
13066
13112
|
return false;
|
|
13067
13113
|
}
|
|
13068
13114
|
__name(hasContent, "hasContent");
|
|
13069
|
-
function getContentLength(
|
|
13070
|
-
if (
|
|
13071
|
-
|
|
13115
|
+
function getContentLength(input) {
|
|
13116
|
+
if (isUIMessage(input)) {
|
|
13117
|
+
if (!input.parts || !Array.isArray(input.parts)) {
|
|
13118
|
+
return 0;
|
|
13119
|
+
}
|
|
13120
|
+
return input.parts.length;
|
|
13121
|
+
}
|
|
13122
|
+
if (isTextContent(input)) return input.length;
|
|
13123
|
+
if (isStructuredContent(input)) return input.length;
|
|
13072
13124
|
return 0;
|
|
13073
13125
|
}
|
|
13074
13126
|
__name(getContentLength, "getContentLength");
|
|
13127
|
+
function isUIMessage(input) {
|
|
13128
|
+
return input && typeof input === "object" && "parts" in input && "role" in input && Array.isArray(input.parts);
|
|
13129
|
+
}
|
|
13130
|
+
__name(isUIMessage, "isUIMessage");
|
|
13075
13131
|
var messageHelpers = {
|
|
13076
13132
|
// Type guards
|
|
13077
13133
|
isTextContent,
|
|
@@ -13079,7 +13135,7 @@ var messageHelpers = {
|
|
|
13079
13135
|
hasTextPart,
|
|
13080
13136
|
hasImagePart,
|
|
13081
13137
|
hasFilePart,
|
|
13082
|
-
// Extractors
|
|
13138
|
+
// Extractors - work with both MessageContent and UIMessage
|
|
13083
13139
|
extractText,
|
|
13084
13140
|
extractTextParts,
|
|
13085
13141
|
extractImageParts,
|