@voltagent/core 0.1.30 → 0.1.32
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.ts +751 -355
- package/dist/index.js +1180 -204
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1180 -205
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,246 @@ import { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
|
5
5
|
import { ClientCapabilities } from '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import { EventEmitter } from 'node:events';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Represents a collection of related tools with optional shared instructions.
|
|
10
|
+
*/
|
|
11
|
+
type Toolkit = {
|
|
12
|
+
/**
|
|
13
|
+
* Unique identifier name for the toolkit. Used for management and potentially logging.
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* A brief description of what the toolkit does or what tools it contains.
|
|
18
|
+
* Optional.
|
|
19
|
+
*/
|
|
20
|
+
description?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Shared instructions for the LLM on how to use the tools within this toolkit.
|
|
23
|
+
* These instructions are intended to be added to the system prompt if `addInstructions` is true.
|
|
24
|
+
* Optional.
|
|
25
|
+
*/
|
|
26
|
+
instructions?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Whether to automatically add the toolkit's `instructions` to the agent's system prompt.
|
|
29
|
+
* If true, the instructions from individual tools within this toolkit might be ignored
|
|
30
|
+
* by the Agent's system message generation logic to avoid redundancy.
|
|
31
|
+
* Defaults to false.
|
|
32
|
+
*/
|
|
33
|
+
addInstructions?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* An array of Tool instances that belong to this toolkit.
|
|
36
|
+
*/
|
|
37
|
+
tools: Tool<ToolSchema>[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Helper function for creating a new toolkit.
|
|
41
|
+
* Provides default values and ensures the basic structure is met.
|
|
42
|
+
*
|
|
43
|
+
* @param options - The configuration options for the toolkit.
|
|
44
|
+
* @returns A Toolkit object.
|
|
45
|
+
*/
|
|
46
|
+
declare const createToolkit: (options: Toolkit) => Toolkit;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Status of a tool at any given time
|
|
50
|
+
*/
|
|
51
|
+
type ToolStatus = "idle" | "working" | "error" | "completed";
|
|
52
|
+
/**
|
|
53
|
+
* Tool status information
|
|
54
|
+
*/
|
|
55
|
+
type ToolStatusInfo = {
|
|
56
|
+
name: string;
|
|
57
|
+
status: ToolStatus;
|
|
58
|
+
result?: any;
|
|
59
|
+
error?: any;
|
|
60
|
+
input?: any;
|
|
61
|
+
output?: any;
|
|
62
|
+
timestamp: Date;
|
|
63
|
+
parameters?: any;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Manager class to handle all tool-related operations, including Toolkits.
|
|
67
|
+
*/
|
|
68
|
+
declare class ToolManager {
|
|
69
|
+
/**
|
|
70
|
+
* Standalone tools managed by this manager.
|
|
71
|
+
*/
|
|
72
|
+
private tools;
|
|
73
|
+
/**
|
|
74
|
+
* Toolkits managed by this manager.
|
|
75
|
+
*/
|
|
76
|
+
private toolkits;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new ToolManager.
|
|
79
|
+
* Accepts both individual tools and toolkits.
|
|
80
|
+
*/
|
|
81
|
+
constructor(items?: (AgentTool | Toolkit)[]);
|
|
82
|
+
/**
|
|
83
|
+
* Get all individual tools and tools within toolkits as a flattened list.
|
|
84
|
+
*/
|
|
85
|
+
getTools(): BaseTool[];
|
|
86
|
+
/**
|
|
87
|
+
* Get all toolkits managed by this manager.
|
|
88
|
+
*/
|
|
89
|
+
getToolkits(): Toolkit[];
|
|
90
|
+
/**
|
|
91
|
+
* Add an individual tool to the manager.
|
|
92
|
+
* If a standalone tool with the same name already exists, it will be replaced.
|
|
93
|
+
* A warning is issued if the name conflicts with a tool inside a toolkit, but the standalone tool is still added/replaced.
|
|
94
|
+
* @returns true if the tool was successfully added or replaced.
|
|
95
|
+
*/
|
|
96
|
+
addTool(tool: AgentTool): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Add a toolkit to the manager.
|
|
99
|
+
* If a toolkit with the same name already exists, it will be replaced.
|
|
100
|
+
* Also checks if any tool within the toolkit conflicts with existing standalone tools or tools in other toolkits.
|
|
101
|
+
* @returns true if the toolkit was successfully added or replaced.
|
|
102
|
+
*/
|
|
103
|
+
addToolkit(toolkit: Toolkit): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Add multiple tools or toolkits to the manager.
|
|
106
|
+
*/
|
|
107
|
+
addItems(items: (AgentTool | Toolkit)[]): void;
|
|
108
|
+
/**
|
|
109
|
+
* Remove a standalone tool by name. Does not remove tools from toolkits.
|
|
110
|
+
* @returns true if the tool was removed, false if it wasn't found.
|
|
111
|
+
*/
|
|
112
|
+
removeTool(toolName: string): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Remove a toolkit by name.
|
|
115
|
+
* @returns true if the toolkit was removed, false if it wasn't found.
|
|
116
|
+
*/
|
|
117
|
+
removeToolkit(toolkitName: string): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Prepare tools for text generation (includes tools from toolkits).
|
|
120
|
+
*/
|
|
121
|
+
prepareToolsForGeneration(dynamicTools?: BaseTool[]): BaseTool[];
|
|
122
|
+
/**
|
|
123
|
+
* Get agent's tools (including those in toolkits) for API exposure.
|
|
124
|
+
*/
|
|
125
|
+
getToolsForApi(): {
|
|
126
|
+
name: string;
|
|
127
|
+
description: string;
|
|
128
|
+
parameters: any;
|
|
129
|
+
}[];
|
|
130
|
+
/**
|
|
131
|
+
* Check if a tool with the given name exists (either standalone or in a toolkit).
|
|
132
|
+
*/
|
|
133
|
+
hasTool(toolName: string): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Get a tool by name (searches standalone tools and tools within toolkits).
|
|
136
|
+
* @param toolName The name of the tool to get
|
|
137
|
+
* @returns The tool (as BaseTool) or undefined if not found
|
|
138
|
+
*/
|
|
139
|
+
getToolByName(toolName: string): BaseTool | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Execute a tool by name
|
|
142
|
+
* @param toolName The name of the tool to execute
|
|
143
|
+
* @param args The arguments to pass to the tool
|
|
144
|
+
* @param options Optional execution options like signal
|
|
145
|
+
* @returns The result of the tool execution
|
|
146
|
+
* @throws Error if the tool doesn't exist or fails to execute
|
|
147
|
+
*/
|
|
148
|
+
executeTool(toolName: string, args: any, options?: ToolExecuteOptions): Promise<any>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Tool definition compatible with Vercel AI SDK
|
|
153
|
+
*/
|
|
154
|
+
type AgentTool = BaseTool;
|
|
155
|
+
/**
|
|
156
|
+
* Tool options for creating a new tool
|
|
157
|
+
*/
|
|
158
|
+
type ToolOptions<T extends ToolSchema = ToolSchema> = {
|
|
159
|
+
/**
|
|
160
|
+
* Unique identifier for the tool
|
|
161
|
+
*/
|
|
162
|
+
id?: string;
|
|
163
|
+
/**
|
|
164
|
+
* Name of the tool
|
|
165
|
+
*/
|
|
166
|
+
name: string;
|
|
167
|
+
/**
|
|
168
|
+
* Description of the tool
|
|
169
|
+
*/
|
|
170
|
+
description: string;
|
|
171
|
+
/**
|
|
172
|
+
* Tool parameter schema
|
|
173
|
+
*/
|
|
174
|
+
parameters: T;
|
|
175
|
+
/**
|
|
176
|
+
* Function to execute when the tool is called
|
|
177
|
+
*/
|
|
178
|
+
execute: (args: z.infer<T>, options?: ToolExecuteOptions) => Promise<unknown>;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Tool class for defining tools that agents can use
|
|
182
|
+
*/
|
|
183
|
+
declare class Tool<T extends ToolSchema = ToolSchema> {
|
|
184
|
+
/**
|
|
185
|
+
* Unique identifier for the tool
|
|
186
|
+
*/
|
|
187
|
+
readonly id: string;
|
|
188
|
+
/**
|
|
189
|
+
* Name of the tool
|
|
190
|
+
*/
|
|
191
|
+
readonly name: string;
|
|
192
|
+
/**
|
|
193
|
+
* Description of the tool
|
|
194
|
+
*/
|
|
195
|
+
readonly description: string;
|
|
196
|
+
/**
|
|
197
|
+
* Tool parameter schema
|
|
198
|
+
*/
|
|
199
|
+
readonly parameters: T;
|
|
200
|
+
/**
|
|
201
|
+
* Function to execute when the tool is called
|
|
202
|
+
*/
|
|
203
|
+
readonly execute: (args: z.infer<T>, options?: ToolExecuteOptions) => Promise<unknown>;
|
|
204
|
+
/**
|
|
205
|
+
* Create a new tool
|
|
206
|
+
*/
|
|
207
|
+
constructor(options: ToolOptions<T>);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Helper function for creating a new tool
|
|
211
|
+
*/
|
|
212
|
+
declare const createTool: <T extends ToolSchema>(options: ToolOptions<T>) => Tool<T>;
|
|
213
|
+
/**
|
|
214
|
+
* Alias for createTool function
|
|
215
|
+
*/
|
|
216
|
+
declare const tool: <T extends ToolSchema>(options: ToolOptions<T>) => Tool<T>;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* An async iterable stream that can be read from.
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* const stream: AsyncIterableStream<string> = getStream();
|
|
223
|
+
* for await (const chunk of stream) {
|
|
224
|
+
* console.log(chunk);
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
|
|
229
|
+
/**
|
|
230
|
+
* Create an async iterable stream from a readable stream.
|
|
231
|
+
*
|
|
232
|
+
* This is useful for creating an async iterable stream from a readable stream.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```typescript
|
|
236
|
+
* const stream: AsyncIterableStream<string> = createAsyncIterableStream(new ReadableStream({
|
|
237
|
+
* start(controller) {
|
|
238
|
+
* controller.enqueue("Hello");
|
|
239
|
+
* controller.close();
|
|
240
|
+
* },
|
|
241
|
+
* }));
|
|
242
|
+
* ```
|
|
243
|
+
* @param source The readable stream to create an async iterable stream from.
|
|
244
|
+
* @returns The async iterable stream.
|
|
245
|
+
*/
|
|
246
|
+
declare function createAsyncIterableStream<T>(source: ReadableStream<T>): AsyncIterableStream<T>;
|
|
247
|
+
|
|
8
248
|
/**
|
|
9
249
|
* Memory options
|
|
10
250
|
*/
|
|
@@ -50,6 +290,7 @@ type MessageFilterOptions = {
|
|
|
50
290
|
type Conversation = {
|
|
51
291
|
id: string;
|
|
52
292
|
resourceId: string;
|
|
293
|
+
userId: string;
|
|
53
294
|
title: string;
|
|
54
295
|
metadata: Record<string, unknown>;
|
|
55
296
|
createdAt: string;
|
|
@@ -61,9 +302,21 @@ type Conversation = {
|
|
|
61
302
|
type CreateConversationInput = {
|
|
62
303
|
id: string;
|
|
63
304
|
resourceId: string;
|
|
305
|
+
userId: string;
|
|
64
306
|
title: string;
|
|
65
307
|
metadata: Record<string, unknown>;
|
|
66
308
|
};
|
|
309
|
+
/**
|
|
310
|
+
* Query builder options for conversations
|
|
311
|
+
*/
|
|
312
|
+
type ConversationQueryOptions = {
|
|
313
|
+
userId?: string;
|
|
314
|
+
resourceId?: string;
|
|
315
|
+
limit?: number;
|
|
316
|
+
offset?: number;
|
|
317
|
+
orderBy?: "created_at" | "updated_at" | "title";
|
|
318
|
+
orderDirection?: "ASC" | "DESC";
|
|
319
|
+
};
|
|
67
320
|
/**
|
|
68
321
|
* Memory interface for storing and retrieving messages
|
|
69
322
|
*/
|
|
@@ -95,6 +348,21 @@ type Memory = {
|
|
|
95
348
|
* Get conversations for a resource
|
|
96
349
|
*/
|
|
97
350
|
getConversations(resourceId: string): Promise<Conversation[]>;
|
|
351
|
+
/**
|
|
352
|
+
* Get conversations by user ID with query options
|
|
353
|
+
*/
|
|
354
|
+
getConversationsByUserId(userId: string, options?: Omit<ConversationQueryOptions, "userId">): Promise<Conversation[]>;
|
|
355
|
+
/**
|
|
356
|
+
* Get conversations with advanced query options
|
|
357
|
+
*/
|
|
358
|
+
queryConversations(options: ConversationQueryOptions): Promise<Conversation[]>;
|
|
359
|
+
/**
|
|
360
|
+
* Get all messages for a specific conversation
|
|
361
|
+
*/
|
|
362
|
+
getConversationMessages(conversationId: string, options?: {
|
|
363
|
+
limit?: number;
|
|
364
|
+
offset?: number;
|
|
365
|
+
}): Promise<MemoryMessage[]>;
|
|
98
366
|
/**
|
|
99
367
|
* Update a conversation
|
|
100
368
|
*/
|
|
@@ -312,358 +580,148 @@ declare class HistoryManager {
|
|
|
312
580
|
* Add steps to an existing history entry
|
|
313
581
|
*
|
|
314
582
|
* @param entryId - ID of the entry to update
|
|
315
|
-
* @param steps - Steps to add
|
|
316
|
-
* @returns The updated entry or undefined if not found
|
|
317
|
-
*/
|
|
318
|
-
addStepsToEntry(entryId: string, steps: StepWithContent[]): Promise<AgentHistoryEntry | undefined>;
|
|
319
|
-
/**
|
|
320
|
-
* Get history entry by ID
|
|
321
|
-
*
|
|
322
|
-
* @param id - ID of the entry to find
|
|
323
|
-
* @returns The history entry or undefined if not found
|
|
324
|
-
*/
|
|
325
|
-
getEntryById(id: string): Promise<AgentHistoryEntry | undefined>;
|
|
326
|
-
/**
|
|
327
|
-
* Get all history entries
|
|
328
|
-
*
|
|
329
|
-
* @returns Array of history entries
|
|
330
|
-
*/
|
|
331
|
-
getEntries(): Promise<AgentHistoryEntry[]>;
|
|
332
|
-
/**
|
|
333
|
-
* Clear all history entries
|
|
334
|
-
*/
|
|
335
|
-
clear(): Promise<void>;
|
|
336
|
-
/**
|
|
337
|
-
* Update an existing history entry
|
|
338
|
-
*
|
|
339
|
-
* @param id - ID of the entry to update
|
|
340
|
-
* @param updates - Partial entry with fields to update
|
|
341
|
-
* @returns The updated entry or undefined if not found
|
|
342
|
-
*/
|
|
343
|
-
updateEntry(id: string, updates: Partial<Omit<AgentHistoryEntry, "id" | "timestamp"> & {
|
|
344
|
-
metadata?: Record<string, unknown>;
|
|
345
|
-
}>): Promise<AgentHistoryEntry | undefined>;
|
|
346
|
-
/**
|
|
347
|
-
* Persists a timeline event for a history entry.
|
|
348
|
-
* This is used by the new immutable event system.
|
|
349
|
-
*
|
|
350
|
-
* @param historyId - ID of the history entry
|
|
351
|
-
* @param event - The NewTimelineEvent object to persist
|
|
352
|
-
* @returns A promise that resolves to the updated entry or undefined if an error occurs
|
|
353
|
-
*/
|
|
354
|
-
persistTimelineEvent(historyId: string, event: NewTimelineEvent): Promise<AgentHistoryEntry | undefined>;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
interface ExportAgentHistoryPayload {
|
|
358
|
-
agent_id: string;
|
|
359
|
-
project_id: string;
|
|
360
|
-
history_id: string;
|
|
361
|
-
startTime: string;
|
|
362
|
-
endTime?: string;
|
|
363
|
-
status: string;
|
|
364
|
-
input: Record<string, unknown>;
|
|
365
|
-
output?: Record<string, unknown>;
|
|
366
|
-
error?: Record<string, unknown>;
|
|
367
|
-
usage?: Record<string, unknown>;
|
|
368
|
-
metadata?: Record<string, unknown>;
|
|
369
|
-
steps?: HistoryStep[];
|
|
370
|
-
userId?: string;
|
|
371
|
-
conversationId?: string;
|
|
372
|
-
model?: string;
|
|
373
|
-
}
|
|
374
|
-
interface ExportTimelineEventPayload {
|
|
375
|
-
history_id: string;
|
|
376
|
-
event_id: string;
|
|
377
|
-
agent_id: string;
|
|
378
|
-
event: NewTimelineEvent;
|
|
379
|
-
}
|
|
380
|
-
interface AgentHistoryUpdatableFields {
|
|
381
|
-
input?: AgentHistoryEntry["input"];
|
|
382
|
-
output?: string;
|
|
383
|
-
status?: AgentStatus;
|
|
384
|
-
usage?: UsageInfo;
|
|
385
|
-
metadata?: Record<string, unknown>;
|
|
386
|
-
endTime?: string;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Options for configuring the VoltAgentExporter.
|
|
391
|
-
*/
|
|
392
|
-
interface VoltAgentExporterOptions {
|
|
393
|
-
/**
|
|
394
|
-
* The base URL for the VoltAgent Edge Functions.
|
|
395
|
-
*/
|
|
396
|
-
baseUrl: string;
|
|
397
|
-
/**
|
|
398
|
-
* The public API key for the project, used to identify the project
|
|
399
|
-
* when sending telemetry data.
|
|
400
|
-
*/
|
|
401
|
-
publicKey: string;
|
|
402
|
-
/**
|
|
403
|
-
* The client's secret key (obtained once during project creation)
|
|
404
|
-
* used for authenticating requests to the telemetry Edge Functions.
|
|
405
|
-
* This will be sent as 'clientSecretKey' in the request body.
|
|
406
|
-
*/
|
|
407
|
-
secretKey: string;
|
|
408
|
-
/**
|
|
409
|
-
* Optional fetch implementation. Defaults to global fetch.
|
|
410
|
-
* Useful for environments where global fetch might not be available or needs to be polyfilled (e.g., some Node.js versions).
|
|
411
|
-
*/
|
|
412
|
-
fetch?: typeof fetch;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
declare class VoltAgentExporter {
|
|
416
|
-
private apiClient;
|
|
417
|
-
readonly publicKey: string;
|
|
418
|
-
constructor(options: VoltAgentExporterOptions);
|
|
419
|
-
/**
|
|
420
|
-
* Exports a single agent history entry.
|
|
421
|
-
* @param historyEntryData - The agent history data to export.
|
|
422
|
-
* This should conform to ExportAgentHistoryPayload.
|
|
423
|
-
* @returns A promise that resolves with the response from the telemetry service,
|
|
424
|
-
* typically including the ID of the created history entry.
|
|
425
|
-
*/
|
|
426
|
-
exportHistoryEntry(historyEntryData: ExportAgentHistoryPayload): Promise<{
|
|
427
|
-
historyEntryId: string;
|
|
428
|
-
}>;
|
|
429
|
-
/**
|
|
430
|
-
* Exports a single timeline event.
|
|
431
|
-
* (Placeholder for when the 'export-timeline-event' Edge Function is ready)
|
|
432
|
-
* @param timelineEventData - The timeline event data to export.
|
|
433
|
-
* This should conform to ExportTimelineEventPayload.
|
|
434
|
-
* @returns A promise that resolves with the response from the telemetry service.
|
|
435
|
-
*/
|
|
436
|
-
exportTimelineEvent(timelineEventData: ExportTimelineEventPayload): Promise<{
|
|
437
|
-
timelineEventId: string;
|
|
438
|
-
}>;
|
|
439
|
-
/**
|
|
440
|
-
* Exports history steps for a specific agent history entry.
|
|
441
|
-
* @param project_id - The project ID associated with the history entry.
|
|
442
|
-
* @param history_id - The ID of the history entry to export steps for.
|
|
443
|
-
* @param steps - The steps data to export.
|
|
444
|
-
* @returns A promise that resolves with the response from the telemetry service.
|
|
445
|
-
*/
|
|
446
|
-
exportHistorySteps(history_id: string, steps: HistoryStep[]): Promise<void>;
|
|
447
|
-
/**
|
|
448
|
-
* Updates specific fields of an agent history entry.
|
|
449
|
-
* @param project_id - The project ID associated with the history entry.
|
|
450
|
-
* @param history_id - The ID of the history entry to update.
|
|
451
|
-
* @param updates - An object containing the fields to update.
|
|
452
|
-
* Should conform to Partial<AgentHistoryUpdatableFields>.
|
|
453
|
-
* @returns A promise that resolves with the response from the telemetry service.
|
|
454
|
-
*/
|
|
455
|
-
updateHistoryEntry(history_id: string, updates: Partial<AgentHistoryUpdatableFields>): Promise<void>;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Represents a collection of related tools with optional shared instructions.
|
|
460
|
-
*/
|
|
461
|
-
type Toolkit = {
|
|
462
|
-
/**
|
|
463
|
-
* Unique identifier name for the toolkit. Used for management and potentially logging.
|
|
464
|
-
*/
|
|
465
|
-
name: string;
|
|
466
|
-
/**
|
|
467
|
-
* A brief description of what the toolkit does or what tools it contains.
|
|
468
|
-
* Optional.
|
|
469
|
-
*/
|
|
470
|
-
description?: string;
|
|
471
|
-
/**
|
|
472
|
-
* Shared instructions for the LLM on how to use the tools within this toolkit.
|
|
473
|
-
* These instructions are intended to be added to the system prompt if `addInstructions` is true.
|
|
474
|
-
* Optional.
|
|
475
|
-
*/
|
|
476
|
-
instructions?: string;
|
|
477
|
-
/**
|
|
478
|
-
* Whether to automatically add the toolkit's `instructions` to the agent's system prompt.
|
|
479
|
-
* If true, the instructions from individual tools within this toolkit might be ignored
|
|
480
|
-
* by the Agent's system message generation logic to avoid redundancy.
|
|
481
|
-
* Defaults to false.
|
|
482
|
-
*/
|
|
483
|
-
addInstructions?: boolean;
|
|
484
|
-
/**
|
|
485
|
-
* An array of Tool instances that belong to this toolkit.
|
|
486
|
-
*/
|
|
487
|
-
tools: Tool<ToolSchema>[];
|
|
488
|
-
};
|
|
489
|
-
/**
|
|
490
|
-
* Helper function for creating a new toolkit.
|
|
491
|
-
* Provides default values and ensures the basic structure is met.
|
|
492
|
-
*
|
|
493
|
-
* @param options - The configuration options for the toolkit.
|
|
494
|
-
* @returns A Toolkit object.
|
|
495
|
-
*/
|
|
496
|
-
declare const createToolkit: (options: Toolkit) => Toolkit;
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* Status of a tool at any given time
|
|
500
|
-
*/
|
|
501
|
-
type ToolStatus = "idle" | "working" | "error" | "completed";
|
|
502
|
-
/**
|
|
503
|
-
* Tool status information
|
|
504
|
-
*/
|
|
505
|
-
type ToolStatusInfo = {
|
|
506
|
-
name: string;
|
|
507
|
-
status: ToolStatus;
|
|
508
|
-
result?: any;
|
|
509
|
-
error?: any;
|
|
510
|
-
input?: any;
|
|
511
|
-
output?: any;
|
|
512
|
-
timestamp: Date;
|
|
513
|
-
parameters?: any;
|
|
514
|
-
};
|
|
515
|
-
/**
|
|
516
|
-
* Manager class to handle all tool-related operations, including Toolkits.
|
|
517
|
-
*/
|
|
518
|
-
declare class ToolManager {
|
|
519
|
-
/**
|
|
520
|
-
* Standalone tools managed by this manager.
|
|
521
|
-
*/
|
|
522
|
-
private tools;
|
|
523
|
-
/**
|
|
524
|
-
* Toolkits managed by this manager.
|
|
525
|
-
*/
|
|
526
|
-
private toolkits;
|
|
527
|
-
/**
|
|
528
|
-
* Creates a new ToolManager.
|
|
529
|
-
* Accepts both individual tools and toolkits.
|
|
530
|
-
*/
|
|
531
|
-
constructor(items?: (AgentTool | Toolkit)[]);
|
|
532
|
-
/**
|
|
533
|
-
* Get all individual tools and tools within toolkits as a flattened list.
|
|
534
|
-
*/
|
|
535
|
-
getTools(): BaseTool[];
|
|
536
|
-
/**
|
|
537
|
-
* Get all toolkits managed by this manager.
|
|
538
|
-
*/
|
|
539
|
-
getToolkits(): Toolkit[];
|
|
540
|
-
/**
|
|
541
|
-
* Add an individual tool to the manager.
|
|
542
|
-
* If a standalone tool with the same name already exists, it will be replaced.
|
|
543
|
-
* A warning is issued if the name conflicts with a tool inside a toolkit, but the standalone tool is still added/replaced.
|
|
544
|
-
* @returns true if the tool was successfully added or replaced.
|
|
545
|
-
*/
|
|
546
|
-
addTool(tool: AgentTool): boolean;
|
|
547
|
-
/**
|
|
548
|
-
* Add a toolkit to the manager.
|
|
549
|
-
* If a toolkit with the same name already exists, it will be replaced.
|
|
550
|
-
* Also checks if any tool within the toolkit conflicts with existing standalone tools or tools in other toolkits.
|
|
551
|
-
* @returns true if the toolkit was successfully added or replaced.
|
|
552
|
-
*/
|
|
553
|
-
addToolkit(toolkit: Toolkit): boolean;
|
|
554
|
-
/**
|
|
555
|
-
* Add multiple tools or toolkits to the manager.
|
|
556
|
-
*/
|
|
557
|
-
addItems(items: (AgentTool | Toolkit)[]): void;
|
|
558
|
-
/**
|
|
559
|
-
* Remove a standalone tool by name. Does not remove tools from toolkits.
|
|
560
|
-
* @returns true if the tool was removed, false if it wasn't found.
|
|
561
|
-
*/
|
|
562
|
-
removeTool(toolName: string): boolean;
|
|
563
|
-
/**
|
|
564
|
-
* Remove a toolkit by name.
|
|
565
|
-
* @returns true if the toolkit was removed, false if it wasn't found.
|
|
566
|
-
*/
|
|
567
|
-
removeToolkit(toolkitName: string): boolean;
|
|
568
|
-
/**
|
|
569
|
-
* Prepare tools for text generation (includes tools from toolkits).
|
|
570
|
-
*/
|
|
571
|
-
prepareToolsForGeneration(dynamicTools?: BaseTool[]): BaseTool[];
|
|
572
|
-
/**
|
|
573
|
-
* Get agent's tools (including those in toolkits) for API exposure.
|
|
574
|
-
*/
|
|
575
|
-
getToolsForApi(): {
|
|
576
|
-
name: string;
|
|
577
|
-
description: string;
|
|
578
|
-
parameters: any;
|
|
579
|
-
}[];
|
|
580
|
-
/**
|
|
581
|
-
* Check if a tool with the given name exists (either standalone or in a toolkit).
|
|
582
|
-
*/
|
|
583
|
-
hasTool(toolName: string): boolean;
|
|
584
|
-
/**
|
|
585
|
-
* Get a tool by name (searches standalone tools and tools within toolkits).
|
|
586
|
-
* @param toolName The name of the tool to get
|
|
587
|
-
* @returns The tool (as BaseTool) or undefined if not found
|
|
588
|
-
*/
|
|
589
|
-
getToolByName(toolName: string): BaseTool | undefined;
|
|
590
|
-
/**
|
|
591
|
-
* Execute a tool by name
|
|
592
|
-
* @param toolName The name of the tool to execute
|
|
593
|
-
* @param args The arguments to pass to the tool
|
|
594
|
-
* @param options Optional execution options like signal
|
|
595
|
-
* @returns The result of the tool execution
|
|
596
|
-
* @throws Error if the tool doesn't exist or fails to execute
|
|
597
|
-
*/
|
|
598
|
-
executeTool(toolName: string, args: any, options?: ToolExecuteOptions): Promise<any>;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* Tool definition compatible with Vercel AI SDK
|
|
603
|
-
*/
|
|
604
|
-
type AgentTool = BaseTool;
|
|
605
|
-
/**
|
|
606
|
-
* Tool options for creating a new tool
|
|
607
|
-
*/
|
|
608
|
-
type ToolOptions<T extends ToolSchema = ToolSchema> = {
|
|
583
|
+
* @param steps - Steps to add
|
|
584
|
+
* @returns The updated entry or undefined if not found
|
|
585
|
+
*/
|
|
586
|
+
addStepsToEntry(entryId: string, steps: StepWithContent[]): Promise<AgentHistoryEntry | undefined>;
|
|
609
587
|
/**
|
|
610
|
-
*
|
|
588
|
+
* Get history entry by ID
|
|
589
|
+
*
|
|
590
|
+
* @param id - ID of the entry to find
|
|
591
|
+
* @returns The history entry or undefined if not found
|
|
611
592
|
*/
|
|
612
|
-
id
|
|
593
|
+
getEntryById(id: string): Promise<AgentHistoryEntry | undefined>;
|
|
613
594
|
/**
|
|
614
|
-
*
|
|
595
|
+
* Get all history entries
|
|
596
|
+
*
|
|
597
|
+
* @returns Array of history entries
|
|
615
598
|
*/
|
|
616
|
-
|
|
599
|
+
getEntries(): Promise<AgentHistoryEntry[]>;
|
|
617
600
|
/**
|
|
618
|
-
*
|
|
601
|
+
* Clear all history entries
|
|
619
602
|
*/
|
|
620
|
-
|
|
603
|
+
clear(): Promise<void>;
|
|
621
604
|
/**
|
|
622
|
-
*
|
|
605
|
+
* Update an existing history entry
|
|
606
|
+
*
|
|
607
|
+
* @param id - ID of the entry to update
|
|
608
|
+
* @param updates - Partial entry with fields to update
|
|
609
|
+
* @returns The updated entry or undefined if not found
|
|
623
610
|
*/
|
|
624
|
-
|
|
611
|
+
updateEntry(id: string, updates: Partial<Omit<AgentHistoryEntry, "id" | "timestamp"> & {
|
|
612
|
+
metadata?: Record<string, unknown>;
|
|
613
|
+
}>): Promise<AgentHistoryEntry | undefined>;
|
|
625
614
|
/**
|
|
626
|
-
*
|
|
615
|
+
* Persists a timeline event for a history entry.
|
|
616
|
+
* This is used by the new immutable event system.
|
|
617
|
+
*
|
|
618
|
+
* @param historyId - ID of the history entry
|
|
619
|
+
* @param event - The NewTimelineEvent object to persist
|
|
620
|
+
* @returns A promise that resolves to the updated entry or undefined if an error occurs
|
|
627
621
|
*/
|
|
628
|
-
|
|
629
|
-
}
|
|
622
|
+
persistTimelineEvent(historyId: string, event: NewTimelineEvent): Promise<AgentHistoryEntry | undefined>;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
interface ExportAgentHistoryPayload {
|
|
626
|
+
agent_id: string;
|
|
627
|
+
project_id: string;
|
|
628
|
+
history_id: string;
|
|
629
|
+
startTime: string;
|
|
630
|
+
endTime?: string;
|
|
631
|
+
status: string;
|
|
632
|
+
input: Record<string, unknown>;
|
|
633
|
+
output?: Record<string, unknown>;
|
|
634
|
+
error?: Record<string, unknown>;
|
|
635
|
+
usage?: Record<string, unknown>;
|
|
636
|
+
metadata?: Record<string, unknown>;
|
|
637
|
+
steps?: HistoryStep[];
|
|
638
|
+
userId?: string;
|
|
639
|
+
conversationId?: string;
|
|
640
|
+
model?: string;
|
|
641
|
+
}
|
|
642
|
+
interface ExportTimelineEventPayload {
|
|
643
|
+
history_id: string;
|
|
644
|
+
event_id: string;
|
|
645
|
+
agent_id: string;
|
|
646
|
+
event: NewTimelineEvent;
|
|
647
|
+
}
|
|
648
|
+
interface AgentHistoryUpdatableFields {
|
|
649
|
+
input?: AgentHistoryEntry["input"];
|
|
650
|
+
output?: string;
|
|
651
|
+
status?: AgentStatus;
|
|
652
|
+
usage?: UsageInfo;
|
|
653
|
+
metadata?: Record<string, unknown>;
|
|
654
|
+
endTime?: string;
|
|
655
|
+
}
|
|
656
|
+
|
|
630
657
|
/**
|
|
631
|
-
*
|
|
658
|
+
* Options for configuring the VoltAgentExporter.
|
|
632
659
|
*/
|
|
633
|
-
|
|
660
|
+
interface VoltAgentExporterOptions {
|
|
634
661
|
/**
|
|
635
|
-
*
|
|
662
|
+
* The base URL for the VoltAgent Edge Functions.
|
|
636
663
|
*/
|
|
637
|
-
|
|
664
|
+
baseUrl: string;
|
|
638
665
|
/**
|
|
639
|
-
*
|
|
666
|
+
* The public API key for the project, used to identify the project
|
|
667
|
+
* when sending telemetry data.
|
|
640
668
|
*/
|
|
641
|
-
|
|
669
|
+
publicKey: string;
|
|
642
670
|
/**
|
|
643
|
-
*
|
|
671
|
+
* The client's secret key (obtained once during project creation)
|
|
672
|
+
* used for authenticating requests to the telemetry Edge Functions.
|
|
673
|
+
* This will be sent as 'clientSecretKey' in the request body.
|
|
644
674
|
*/
|
|
645
|
-
|
|
675
|
+
secretKey: string;
|
|
646
676
|
/**
|
|
647
|
-
*
|
|
677
|
+
* Optional fetch implementation. Defaults to global fetch.
|
|
678
|
+
* Useful for environments where global fetch might not be available or needs to be polyfilled (e.g., some Node.js versions).
|
|
648
679
|
*/
|
|
649
|
-
|
|
680
|
+
fetch?: typeof fetch;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
declare class VoltAgentExporter {
|
|
684
|
+
private apiClient;
|
|
685
|
+
readonly publicKey: string;
|
|
686
|
+
constructor(options: VoltAgentExporterOptions);
|
|
650
687
|
/**
|
|
651
|
-
*
|
|
688
|
+
* Exports a single agent history entry.
|
|
689
|
+
* @param historyEntryData - The agent history data to export.
|
|
690
|
+
* This should conform to ExportAgentHistoryPayload.
|
|
691
|
+
* @returns A promise that resolves with the response from the telemetry service,
|
|
692
|
+
* typically including the ID of the created history entry.
|
|
652
693
|
*/
|
|
653
|
-
|
|
694
|
+
exportHistoryEntry(historyEntryData: ExportAgentHistoryPayload): Promise<{
|
|
695
|
+
historyEntryId: string;
|
|
696
|
+
}>;
|
|
654
697
|
/**
|
|
655
|
-
*
|
|
698
|
+
* Exports a single timeline event.
|
|
699
|
+
* (Placeholder for when the 'export-timeline-event' Edge Function is ready)
|
|
700
|
+
* @param timelineEventData - The timeline event data to export.
|
|
701
|
+
* This should conform to ExportTimelineEventPayload.
|
|
702
|
+
* @returns A promise that resolves with the response from the telemetry service.
|
|
656
703
|
*/
|
|
657
|
-
|
|
704
|
+
exportTimelineEvent(timelineEventData: ExportTimelineEventPayload): Promise<{
|
|
705
|
+
timelineEventId: string;
|
|
706
|
+
}>;
|
|
707
|
+
/**
|
|
708
|
+
* Exports history steps for a specific agent history entry.
|
|
709
|
+
* @param project_id - The project ID associated with the history entry.
|
|
710
|
+
* @param history_id - The ID of the history entry to export steps for.
|
|
711
|
+
* @param steps - The steps data to export.
|
|
712
|
+
* @returns A promise that resolves with the response from the telemetry service.
|
|
713
|
+
*/
|
|
714
|
+
exportHistorySteps(history_id: string, steps: HistoryStep[]): Promise<void>;
|
|
715
|
+
/**
|
|
716
|
+
* Updates specific fields of an agent history entry.
|
|
717
|
+
* @param project_id - The project ID associated with the history entry.
|
|
718
|
+
* @param history_id - The ID of the history entry to update.
|
|
719
|
+
* @param updates - An object containing the fields to update.
|
|
720
|
+
* Should conform to Partial<AgentHistoryUpdatableFields>.
|
|
721
|
+
* @returns A promise that resolves with the response from the telemetry service.
|
|
722
|
+
*/
|
|
723
|
+
updateHistoryEntry(history_id: string, updates: Partial<AgentHistoryUpdatableFields>): Promise<void>;
|
|
658
724
|
}
|
|
659
|
-
/**
|
|
660
|
-
* Helper function for creating a new tool
|
|
661
|
-
*/
|
|
662
|
-
declare const createTool: <T extends ToolSchema>(options: ToolOptions<T>) => Tool<T>;
|
|
663
|
-
/**
|
|
664
|
-
* Alias for createTool function
|
|
665
|
-
*/
|
|
666
|
-
declare const tool: <T extends ToolSchema>(options: ToolOptions<T>) => Tool<T>;
|
|
667
725
|
|
|
668
726
|
/**
|
|
669
727
|
* Provider options type for LLM configurations
|
|
@@ -765,27 +823,27 @@ type ModelType<T> = T extends {
|
|
|
765
823
|
/**
|
|
766
824
|
* Infer generate text response type
|
|
767
825
|
*/
|
|
768
|
-
type
|
|
826
|
+
type InferGenerateTextResponseFromProvider<TProvider extends {
|
|
769
827
|
llm: LLMProvider<any>;
|
|
770
|
-
}> =
|
|
828
|
+
}> = ProviderTextResponse<InferOriginalResponseFromProvider<TProvider, "generateText">>;
|
|
771
829
|
/**
|
|
772
830
|
* Infer stream text response type
|
|
773
831
|
*/
|
|
774
|
-
type
|
|
832
|
+
type InferStreamTextResponseFromProvider<TProvider extends {
|
|
775
833
|
llm: LLMProvider<any>;
|
|
776
|
-
}> =
|
|
834
|
+
}> = ProviderTextStreamResponse<InferOriginalResponseFromProvider<TProvider, "streamText">>;
|
|
777
835
|
/**
|
|
778
836
|
* Infer generate object response type
|
|
779
837
|
*/
|
|
780
|
-
type
|
|
838
|
+
type InferGenerateObjectResponseFromProvider<TProvider extends {
|
|
781
839
|
llm: LLMProvider<any>;
|
|
782
|
-
}> =
|
|
840
|
+
}, TSchema extends z.ZodType> = ProviderObjectResponse<InferOriginalResponseFromProvider<TProvider, "generateObject">, z.infer<TSchema>>;
|
|
783
841
|
/**
|
|
784
842
|
* Infer stream object response type
|
|
785
843
|
*/
|
|
786
|
-
type
|
|
844
|
+
type InferStreamObjectResponseFromProvider<TProvider extends {
|
|
787
845
|
llm: LLMProvider<any>;
|
|
788
|
-
}> =
|
|
846
|
+
}, TSchema extends z.ZodType> = ProviderObjectStreamResponse<InferOriginalResponseFromProvider<TProvider, "streamObject">, z.infer<TSchema>>;
|
|
789
847
|
/**
|
|
790
848
|
* Common generate options - internal version that includes historyEntryId
|
|
791
849
|
* Not exposed directly to users
|
|
@@ -945,6 +1003,8 @@ type OperationContext = {
|
|
|
945
1003
|
otelSpan?: Span;
|
|
946
1004
|
/** Map to store active OpenTelemetry spans for tool calls within this operation */
|
|
947
1005
|
toolSpans?: Map<string, Span>;
|
|
1006
|
+
/** Conversation steps for building full message history including tool calls/results */
|
|
1007
|
+
conversationSteps?: StepWithContent[];
|
|
948
1008
|
};
|
|
949
1009
|
/**
|
|
950
1010
|
* Tool execution context passed to tool.execute method
|
|
@@ -1009,6 +1069,8 @@ interface StreamTextFinishResult {
|
|
|
1009
1069
|
providerResponse?: unknown;
|
|
1010
1070
|
/** Any warnings generated during the completion (if available). */
|
|
1011
1071
|
warnings?: unknown[];
|
|
1072
|
+
/** User context containing any custom metadata from the operation. */
|
|
1073
|
+
userContext?: Map<string | symbol, unknown>;
|
|
1012
1074
|
}
|
|
1013
1075
|
/**
|
|
1014
1076
|
* Type for the onFinish callback function for streamText.
|
|
@@ -1030,6 +1092,8 @@ interface StreamObjectFinishResult<TObject> {
|
|
|
1030
1092
|
warnings?: unknown[];
|
|
1031
1093
|
/** The reason the stream finished (if available). Although less common for object streams. */
|
|
1032
1094
|
finishReason?: string;
|
|
1095
|
+
/** User context containing any custom metadata from the operation. */
|
|
1096
|
+
userContext?: Map<string | symbol, unknown>;
|
|
1033
1097
|
}
|
|
1034
1098
|
/**
|
|
1035
1099
|
* Type for the onFinish callback function for streamObject.
|
|
@@ -1050,6 +1114,8 @@ interface StandardizedTextResult {
|
|
|
1050
1114
|
finishReason?: string;
|
|
1051
1115
|
/** Warnings (if available from provider). */
|
|
1052
1116
|
warnings?: unknown[];
|
|
1117
|
+
/** User context containing any custom metadata from the operation. */
|
|
1118
|
+
userContext?: Map<string | symbol, unknown>;
|
|
1053
1119
|
}
|
|
1054
1120
|
/**
|
|
1055
1121
|
* Standardized success result structure for generateObject.
|
|
@@ -1066,6 +1132,8 @@ interface StandardizedObjectResult<TObject> {
|
|
|
1066
1132
|
finishReason?: string;
|
|
1067
1133
|
/** Warnings (if available from provider). */
|
|
1068
1134
|
warnings?: unknown[];
|
|
1135
|
+
/** User context containing any custom metadata from the operation. */
|
|
1136
|
+
userContext?: Map<string | symbol, unknown>;
|
|
1069
1137
|
}
|
|
1070
1138
|
/**
|
|
1071
1139
|
* Unified output type for the onEnd hook, representing the successful result
|
|
@@ -1074,6 +1142,12 @@ interface StandardizedObjectResult<TObject> {
|
|
|
1074
1142
|
* Object types are generalized to 'unknown' here for the union.
|
|
1075
1143
|
*/
|
|
1076
1144
|
type AgentOperationOutput = StandardizedTextResult | StreamTextFinishResult | StandardizedObjectResult<unknown> | StreamObjectFinishResult<unknown>;
|
|
1145
|
+
type InferResponseFromProvider<TProvider extends {
|
|
1146
|
+
llm: LLMProvider<any>;
|
|
1147
|
+
}, TMethod extends "generateText" | "streamText" | "generateObject" | "streamObject"> = Awaited<ReturnType<TProvider["llm"][TMethod]>>;
|
|
1148
|
+
type InferOriginalResponseFromProvider<TProvider extends {
|
|
1149
|
+
llm: LLMProvider<any>;
|
|
1150
|
+
}, TMethod extends "generateText" | "streamText" | "generateObject" | "streamObject"> = InferResponseFromProvider<TProvider, TMethod>["provider"];
|
|
1077
1151
|
|
|
1078
1152
|
/**
|
|
1079
1153
|
* Token usage information
|
|
@@ -1132,7 +1206,7 @@ type ProviderTextStreamResponse<TOriginalResponse> = {
|
|
|
1132
1206
|
/**
|
|
1133
1207
|
* Text stream for consuming the response
|
|
1134
1208
|
*/
|
|
1135
|
-
textStream:
|
|
1209
|
+
textStream: AsyncIterableStream<string>;
|
|
1136
1210
|
};
|
|
1137
1211
|
/**
|
|
1138
1212
|
* Response type for object generation operations
|
|
@@ -1166,7 +1240,7 @@ type ProviderObjectStreamResponse<TOriginalResponse, TObject> = {
|
|
|
1166
1240
|
/**
|
|
1167
1241
|
* Object stream for consuming partial objects
|
|
1168
1242
|
*/
|
|
1169
|
-
objectStream:
|
|
1243
|
+
objectStream: AsyncIterableStream<Partial<TObject>>;
|
|
1170
1244
|
};
|
|
1171
1245
|
/**
|
|
1172
1246
|
* Data content type for binary data
|
|
@@ -1354,6 +1428,11 @@ type LLMProvider<TProvider> = {
|
|
|
1354
1428
|
* @throws {VoltAgentError} If an error occurs during generation.
|
|
1355
1429
|
*/
|
|
1356
1430
|
generateText(options: GenerateTextOptions<InferModel<TProvider>>): Promise<ProviderTextResponse<InferGenerateTextResponse<TProvider>>>;
|
|
1431
|
+
/**
|
|
1432
|
+
* Streams a text response based on the provided options.
|
|
1433
|
+
* Implementers should catch underlying SDK/API errors and throw a VoltAgentError.
|
|
1434
|
+
* @throws {VoltAgentError} If an error occurs during streaming.
|
|
1435
|
+
*/
|
|
1357
1436
|
streamText(options: StreamTextOptions<InferModel<TProvider>>): Promise<ProviderTextStreamResponse<InferStreamResponse<TProvider>>>;
|
|
1358
1437
|
/**
|
|
1359
1438
|
* Generates a structured object response based on the provided options and schema.
|
|
@@ -1361,8 +1440,21 @@ type LLMProvider<TProvider> = {
|
|
|
1361
1440
|
* @throws {VoltAgentError} If an error occurs during generation.
|
|
1362
1441
|
*/
|
|
1363
1442
|
generateObject<TSchema extends z.ZodType>(options: GenerateObjectOptions<InferModel<TProvider>, TSchema>): Promise<ProviderObjectResponse<InferGenerateObjectResponse<TProvider>, z.infer<TSchema>>>;
|
|
1443
|
+
/**
|
|
1444
|
+
* Streams a structured object response based on the provided options and schema.
|
|
1445
|
+
* Implementers should catch underlying SDK/API errors and throw a VoltAgentError.
|
|
1446
|
+
* @throws {VoltAgentError} If an error occurs during streaming.
|
|
1447
|
+
*/
|
|
1364
1448
|
streamObject<TSchema extends z.ZodType>(options: StreamObjectOptions<InferModel<TProvider>, TSchema>): Promise<ProviderObjectStreamResponse<InferStreamResponse<TProvider>, z.infer<TSchema>>>;
|
|
1449
|
+
/**
|
|
1450
|
+
* Converts a base message to a provider-specific message.
|
|
1451
|
+
* @param message The base message to convert.
|
|
1452
|
+
* @returns The provider-specific message.
|
|
1453
|
+
*/
|
|
1365
1454
|
toMessage(message: BaseMessage): InferMessage<TProvider>;
|
|
1455
|
+
/**
|
|
1456
|
+
* Optional tool conversion method.
|
|
1457
|
+
*/
|
|
1366
1458
|
toTool?: (tool: BaseTool) => InferTool<TProvider>;
|
|
1367
1459
|
/**
|
|
1368
1460
|
* Returns a string representation of the model identifier.
|
|
@@ -1685,6 +1777,110 @@ declare class InMemoryStorage implements Memory {
|
|
|
1685
1777
|
* @returns Array of conversations
|
|
1686
1778
|
*/
|
|
1687
1779
|
getConversations(resourceId: string): Promise<Conversation[]>;
|
|
1780
|
+
/**
|
|
1781
|
+
* Get conversations by user ID with query options
|
|
1782
|
+
* @param userId User ID
|
|
1783
|
+
* @param options Query options
|
|
1784
|
+
* @returns Array of conversations
|
|
1785
|
+
*/
|
|
1786
|
+
getConversationsByUserId(userId: string, options?: Omit<ConversationQueryOptions, "userId">): Promise<Conversation[]>;
|
|
1787
|
+
/**
|
|
1788
|
+
* Query conversations with flexible filtering and pagination options
|
|
1789
|
+
*
|
|
1790
|
+
* This method provides a powerful way to search and filter conversations
|
|
1791
|
+
* with support for user-based filtering, resource filtering, pagination,
|
|
1792
|
+
* and custom sorting.
|
|
1793
|
+
*
|
|
1794
|
+
* @param options Query options for filtering and pagination
|
|
1795
|
+
* @param options.userId Optional user ID to filter conversations by specific user
|
|
1796
|
+
* @param options.resourceId Optional resource ID to filter conversations by specific resource
|
|
1797
|
+
* @param options.limit Maximum number of conversations to return (default: 50)
|
|
1798
|
+
* @param options.offset Number of conversations to skip for pagination (default: 0)
|
|
1799
|
+
* @param options.orderBy Field to sort by: 'created_at', 'updated_at', or 'title' (default: 'updated_at')
|
|
1800
|
+
* @param options.orderDirection Sort direction: 'ASC' or 'DESC' (default: 'DESC')
|
|
1801
|
+
*
|
|
1802
|
+
* @returns Promise that resolves to an array of conversations matching the criteria
|
|
1803
|
+
*
|
|
1804
|
+
* @example
|
|
1805
|
+
* ```typescript
|
|
1806
|
+
* // Get all conversations for a specific user
|
|
1807
|
+
* const userConversations = await storage.queryConversations({
|
|
1808
|
+
* userId: 'user123',
|
|
1809
|
+
* limit: 20
|
|
1810
|
+
* });
|
|
1811
|
+
*
|
|
1812
|
+
* // Get conversations for a resource with pagination
|
|
1813
|
+
* const resourceConversations = await storage.queryConversations({
|
|
1814
|
+
* resourceId: 'chatbot-v1',
|
|
1815
|
+
* limit: 10,
|
|
1816
|
+
* offset: 20,
|
|
1817
|
+
* orderBy: 'created_at',
|
|
1818
|
+
* orderDirection: 'ASC'
|
|
1819
|
+
* });
|
|
1820
|
+
*
|
|
1821
|
+
* // Get all conversations (admin view)
|
|
1822
|
+
* const allConversations = await storage.queryConversations({
|
|
1823
|
+
* limit: 100,
|
|
1824
|
+
* orderBy: 'updated_at'
|
|
1825
|
+
* });
|
|
1826
|
+
* ```
|
|
1827
|
+
*/
|
|
1828
|
+
queryConversations(options: ConversationQueryOptions): Promise<Conversation[]>;
|
|
1829
|
+
/**
|
|
1830
|
+
* Get messages for a specific conversation with pagination support
|
|
1831
|
+
*
|
|
1832
|
+
* This method retrieves all messages within a conversation, ordered chronologically
|
|
1833
|
+
* from oldest to newest. It supports pagination to handle large conversations
|
|
1834
|
+
* efficiently and avoid memory issues.
|
|
1835
|
+
*
|
|
1836
|
+
* @param conversationId The unique identifier of the conversation to retrieve messages from
|
|
1837
|
+
* @param options Optional pagination and filtering options
|
|
1838
|
+
* @param options.limit Maximum number of messages to return (default: 100)
|
|
1839
|
+
* @param options.offset Number of messages to skip for pagination (default: 0)
|
|
1840
|
+
*
|
|
1841
|
+
* @returns Promise that resolves to an array of messages in chronological order (oldest first)
|
|
1842
|
+
*
|
|
1843
|
+
* @example
|
|
1844
|
+
* ```typescript
|
|
1845
|
+
* // Get the first 50 messages in a conversation
|
|
1846
|
+
* const messages = await storage.getConversationMessages('conv-123', {
|
|
1847
|
+
* limit: 50
|
|
1848
|
+
* });
|
|
1849
|
+
*
|
|
1850
|
+
* // Get messages with pagination (skip first 20, get next 30)
|
|
1851
|
+
* const olderMessages = await storage.getConversationMessages('conv-123', {
|
|
1852
|
+
* limit: 30,
|
|
1853
|
+
* offset: 20
|
|
1854
|
+
* });
|
|
1855
|
+
*
|
|
1856
|
+
* // Get all messages (use with caution for large conversations)
|
|
1857
|
+
* const allMessages = await storage.getConversationMessages('conv-123');
|
|
1858
|
+
*
|
|
1859
|
+
* // Process messages in batches
|
|
1860
|
+
* const batchSize = 100;
|
|
1861
|
+
* let offset = 0;
|
|
1862
|
+
* let hasMore = true;
|
|
1863
|
+
*
|
|
1864
|
+
* while (hasMore) {
|
|
1865
|
+
* const batch = await storage.getConversationMessages('conv-123', {
|
|
1866
|
+
* limit: batchSize,
|
|
1867
|
+
* offset: offset
|
|
1868
|
+
* });
|
|
1869
|
+
*
|
|
1870
|
+
* // Process batch
|
|
1871
|
+
* processBatch(batch);
|
|
1872
|
+
*
|
|
1873
|
+
* hasMore = batch.length === batchSize;
|
|
1874
|
+
* offset += batchSize;
|
|
1875
|
+
* }
|
|
1876
|
+
* ```
|
|
1877
|
+
*
|
|
1878
|
+
* @throws {Error} If the conversation ID is invalid or operation fails
|
|
1879
|
+
*/
|
|
1880
|
+
getConversationMessages(conversationId: string, options?: {
|
|
1881
|
+
limit?: number;
|
|
1882
|
+
offset?: number;
|
|
1883
|
+
}): Promise<MemoryMessage[]>;
|
|
1688
1884
|
/**
|
|
1689
1885
|
* Update a conversation
|
|
1690
1886
|
* @param id Conversation ID
|
|
@@ -1784,6 +1980,11 @@ declare class LibSQLStorage implements Memory {
|
|
|
1784
1980
|
* @param conversationId Conversation identifier (optional, defaults to "default")
|
|
1785
1981
|
*/
|
|
1786
1982
|
addMessage(message: MemoryMessage, userId?: string, conversationId?: string): Promise<void>;
|
|
1983
|
+
/**
|
|
1984
|
+
* Prune old messages to respect storage limit
|
|
1985
|
+
* @param conversationId Conversation ID to prune messages for
|
|
1986
|
+
*/
|
|
1987
|
+
private pruneOldMessages;
|
|
1787
1988
|
/**
|
|
1788
1989
|
* Clear messages from memory
|
|
1789
1990
|
*/
|
|
@@ -1848,6 +2049,27 @@ declare class LibSQLStorage implements Memory {
|
|
|
1848
2049
|
createConversation(conversation: CreateConversationInput): Promise<Conversation>;
|
|
1849
2050
|
getConversation(id: string): Promise<Conversation | null>;
|
|
1850
2051
|
getConversations(resourceId: string): Promise<Conversation[]>;
|
|
2052
|
+
getConversationsByUserId(userId: string, options?: Omit<ConversationQueryOptions, "userId">): Promise<Conversation[]>;
|
|
2053
|
+
/**
|
|
2054
|
+
* Query conversations with filtering and pagination options
|
|
2055
|
+
*
|
|
2056
|
+
* @param options Query options for filtering and pagination
|
|
2057
|
+
* @returns Promise that resolves to an array of conversations matching the criteria
|
|
2058
|
+
* @see {@link https://voltagent.ai/docs/agents/memory/libsql#querying-conversations | Querying Conversations}
|
|
2059
|
+
*/
|
|
2060
|
+
queryConversations(options: ConversationQueryOptions): Promise<Conversation[]>;
|
|
2061
|
+
/**
|
|
2062
|
+
* Get messages for a specific conversation with pagination support
|
|
2063
|
+
*
|
|
2064
|
+
* @param conversationId The unique identifier of the conversation to retrieve messages from
|
|
2065
|
+
* @param options Optional pagination and filtering options
|
|
2066
|
+
* @returns Promise that resolves to an array of messages in chronological order (oldest first)
|
|
2067
|
+
* @see {@link https://voltagent.ai/docs/agents/memory/libsql#conversation-messages | Getting Conversation Messages}
|
|
2068
|
+
*/
|
|
2069
|
+
getConversationMessages(conversationId: string, options?: {
|
|
2070
|
+
limit?: number;
|
|
2071
|
+
offset?: number;
|
|
2072
|
+
}): Promise<MemoryMessage[]>;
|
|
1851
2073
|
updateConversation(id: string, updates: Partial<Omit<Conversation, "id" | "createdAt" | "updatedAt">>): Promise<Conversation>;
|
|
1852
2074
|
deleteConversation(id: string): Promise<void>;
|
|
1853
2075
|
/**
|
|
@@ -1877,6 +2099,159 @@ declare class LibSQLStorage implements Memory {
|
|
|
1877
2099
|
error?: Error;
|
|
1878
2100
|
backupCreated?: boolean;
|
|
1879
2101
|
}>;
|
|
2102
|
+
/**
|
|
2103
|
+
* Migrate conversation schema to add user_id and update messages table
|
|
2104
|
+
*
|
|
2105
|
+
* ⚠️ **CRITICAL WARNING: DESTRUCTIVE OPERATION** ⚠️
|
|
2106
|
+
*
|
|
2107
|
+
* This method performs a DESTRUCTIVE schema migration that:
|
|
2108
|
+
* - DROPS and recreates existing tables
|
|
2109
|
+
* - Creates temporary tables during migration
|
|
2110
|
+
* - Modifies the primary key structure of the messages table
|
|
2111
|
+
* - Can cause DATA LOSS if interrupted or if errors occur
|
|
2112
|
+
*
|
|
2113
|
+
* **IMPORTANT SAFETY REQUIREMENTS:**
|
|
2114
|
+
* - 🛑 STOP all application instances before running this migration
|
|
2115
|
+
* - 🛑 Ensure NO concurrent database operations are running
|
|
2116
|
+
* - 🛑 Take a full database backup before running (independent of built-in backup)
|
|
2117
|
+
* - 🛑 Test the migration on a copy of production data first
|
|
2118
|
+
* - 🛑 Plan for downtime during migration execution
|
|
2119
|
+
*
|
|
2120
|
+
* **What this migration does:**
|
|
2121
|
+
* 1. Creates backup tables (if createBackup=true)
|
|
2122
|
+
* 2. Creates temporary tables with new schema
|
|
2123
|
+
* 3. Migrates data from old tables to new schema
|
|
2124
|
+
* 4. DROPS original tables
|
|
2125
|
+
* 5. Renames temporary tables to original names
|
|
2126
|
+
* 6. All operations are wrapped in a transaction for atomicity
|
|
2127
|
+
*
|
|
2128
|
+
* @param options Migration configuration options
|
|
2129
|
+
* @param options.createBackup Whether to create backup tables before migration (default: true, HIGHLY RECOMMENDED)
|
|
2130
|
+
* @param options.restoreFromBackup Whether to restore from existing backup instead of migrating (default: false)
|
|
2131
|
+
* @param options.deleteBackupAfterSuccess Whether to delete backup tables after successful migration (default: false)
|
|
2132
|
+
*
|
|
2133
|
+
* @returns Promise resolving to migration result with success status, migrated count, and backup info
|
|
2134
|
+
*
|
|
2135
|
+
* @example
|
|
2136
|
+
* ```typescript
|
|
2137
|
+
* // RECOMMENDED: Run with backup creation (default)
|
|
2138
|
+
* const result = await storage.migrateConversationSchema({
|
|
2139
|
+
* createBackup: true,
|
|
2140
|
+
* deleteBackupAfterSuccess: false // Keep backup for safety
|
|
2141
|
+
* });
|
|
2142
|
+
*
|
|
2143
|
+
* if (result.success) {
|
|
2144
|
+
* console.log(`Migrated ${result.migratedCount} conversations successfully`);
|
|
2145
|
+
* } else {
|
|
2146
|
+
* console.error('Migration failed:', result.error);
|
|
2147
|
+
* // Consider restoring from backup
|
|
2148
|
+
* }
|
|
2149
|
+
*
|
|
2150
|
+
* // If migration fails, restore from backup:
|
|
2151
|
+
* const restoreResult = await storage.migrateConversationSchema({
|
|
2152
|
+
* restoreFromBackup: true
|
|
2153
|
+
* });
|
|
2154
|
+
* ```
|
|
2155
|
+
*
|
|
2156
|
+
* @throws {Error} If migration fails and transaction is rolled back
|
|
2157
|
+
*
|
|
2158
|
+
* @since This migration is typically only needed when upgrading from older schema versions
|
|
2159
|
+
*/
|
|
2160
|
+
private migrateConversationSchema;
|
|
2161
|
+
/**
|
|
2162
|
+
* Get conversations for a user with a fluent query builder interface
|
|
2163
|
+
* @param userId User ID to filter by
|
|
2164
|
+
* @returns Query builder object
|
|
2165
|
+
*/
|
|
2166
|
+
getUserConversations(userId: string): {
|
|
2167
|
+
/**
|
|
2168
|
+
* Limit the number of results
|
|
2169
|
+
* @param count Number of conversations to return
|
|
2170
|
+
* @returns Query builder
|
|
2171
|
+
*/
|
|
2172
|
+
limit: (count: number) => {
|
|
2173
|
+
/**
|
|
2174
|
+
* Order results by a specific field
|
|
2175
|
+
* @param field Field to order by
|
|
2176
|
+
* @param direction Sort direction
|
|
2177
|
+
* @returns Query builder
|
|
2178
|
+
*/
|
|
2179
|
+
orderBy: (field?: "created_at" | "updated_at" | "title", direction?: "ASC" | "DESC") => {
|
|
2180
|
+
/**
|
|
2181
|
+
* Execute the query and return results
|
|
2182
|
+
* @returns Promise of conversations
|
|
2183
|
+
*/
|
|
2184
|
+
execute: () => Promise<Conversation[]>;
|
|
2185
|
+
};
|
|
2186
|
+
/**
|
|
2187
|
+
* Execute the query with default ordering
|
|
2188
|
+
* @returns Promise of conversations
|
|
2189
|
+
*/
|
|
2190
|
+
execute: () => Promise<Conversation[]>;
|
|
2191
|
+
};
|
|
2192
|
+
/**
|
|
2193
|
+
* Order results by a specific field
|
|
2194
|
+
* @param field Field to order by
|
|
2195
|
+
* @param direction Sort direction
|
|
2196
|
+
* @returns Query builder
|
|
2197
|
+
*/
|
|
2198
|
+
orderBy: (field?: "created_at" | "updated_at" | "title", direction?: "ASC" | "DESC") => {
|
|
2199
|
+
/**
|
|
2200
|
+
* Limit the number of results
|
|
2201
|
+
* @param count Number of conversations to return
|
|
2202
|
+
* @returns Query builder
|
|
2203
|
+
*/
|
|
2204
|
+
limit: (count: number) => {
|
|
2205
|
+
/**
|
|
2206
|
+
* Execute the query and return results
|
|
2207
|
+
* @returns Promise of conversations
|
|
2208
|
+
*/
|
|
2209
|
+
execute: () => Promise<Conversation[]>;
|
|
2210
|
+
};
|
|
2211
|
+
/**
|
|
2212
|
+
* Execute the query without limit
|
|
2213
|
+
* @returns Promise of conversations
|
|
2214
|
+
*/
|
|
2215
|
+
execute: () => Promise<Conversation[]>;
|
|
2216
|
+
};
|
|
2217
|
+
/**
|
|
2218
|
+
* Execute the query with default options
|
|
2219
|
+
* @returns Promise of conversations
|
|
2220
|
+
*/
|
|
2221
|
+
execute: () => Promise<Conversation[]>;
|
|
2222
|
+
};
|
|
2223
|
+
/**
|
|
2224
|
+
* Get conversation by ID and ensure it belongs to the specified user
|
|
2225
|
+
* @param conversationId Conversation ID
|
|
2226
|
+
* @param userId User ID to validate ownership
|
|
2227
|
+
* @returns Conversation or null
|
|
2228
|
+
*/
|
|
2229
|
+
getUserConversation(conversationId: string, userId: string): Promise<Conversation | null>;
|
|
2230
|
+
/**
|
|
2231
|
+
* Get paginated conversations for a user
|
|
2232
|
+
* @param userId User ID
|
|
2233
|
+
* @param page Page number (1-based)
|
|
2234
|
+
* @param pageSize Number of items per page
|
|
2235
|
+
* @returns Object with conversations and pagination info
|
|
2236
|
+
*/
|
|
2237
|
+
getPaginatedUserConversations(userId: string, page?: number, pageSize?: number): Promise<{
|
|
2238
|
+
conversations: Conversation[];
|
|
2239
|
+
page: number;
|
|
2240
|
+
pageSize: number;
|
|
2241
|
+
hasMore: boolean;
|
|
2242
|
+
}>;
|
|
2243
|
+
/**
|
|
2244
|
+
* Check and create migration flag table, return if migration already completed
|
|
2245
|
+
* @param migrationType Type of migration to check
|
|
2246
|
+
* @returns Object with completion status and details
|
|
2247
|
+
*/
|
|
2248
|
+
private checkMigrationFlag;
|
|
2249
|
+
/**
|
|
2250
|
+
* Set migration flag after successful completion
|
|
2251
|
+
* @param migrationType Type of migration completed
|
|
2252
|
+
* @param migratedCount Number of records migrated
|
|
2253
|
+
*/
|
|
2254
|
+
private setMigrationFlag;
|
|
1880
2255
|
}
|
|
1881
2256
|
|
|
1882
2257
|
/**
|
|
@@ -2009,6 +2384,16 @@ type RetrieverOptions = {
|
|
|
2009
2384
|
*/
|
|
2010
2385
|
[key: string]: any;
|
|
2011
2386
|
};
|
|
2387
|
+
/**
|
|
2388
|
+
* Options passed to retrieve method
|
|
2389
|
+
*/
|
|
2390
|
+
interface RetrieveOptions {
|
|
2391
|
+
/**
|
|
2392
|
+
* User-managed context map for this specific retrieval operation
|
|
2393
|
+
* Can be used to store metadata, results, or any custom data
|
|
2394
|
+
*/
|
|
2395
|
+
userContext?: Map<string | symbol, unknown>;
|
|
2396
|
+
}
|
|
2012
2397
|
/**
|
|
2013
2398
|
* Retriever interface for retrieving relevant information
|
|
2014
2399
|
*/
|
|
@@ -2016,9 +2401,10 @@ type Retriever = {
|
|
|
2016
2401
|
/**
|
|
2017
2402
|
* Retrieve relevant documents based on input text
|
|
2018
2403
|
* @param text The text to use for retrieval
|
|
2019
|
-
* @
|
|
2404
|
+
* @param options Configuration and context for the retrieval
|
|
2405
|
+
* @returns Promise resolving to a string with the retrieved content
|
|
2020
2406
|
*/
|
|
2021
|
-
retrieve(text: string): Promise<string>;
|
|
2407
|
+
retrieve(text: string, options: RetrieveOptions): Promise<string>;
|
|
2022
2408
|
/**
|
|
2023
2409
|
* Configuration options for the retriever
|
|
2024
2410
|
* This is optional and may not be present in all implementations
|
|
@@ -2065,13 +2451,14 @@ declare abstract class BaseRetriever {
|
|
|
2065
2451
|
*/
|
|
2066
2452
|
constructor(options?: RetrieverOptions);
|
|
2067
2453
|
/**
|
|
2068
|
-
*
|
|
2069
|
-
*
|
|
2454
|
+
* Abstract method that must be implemented by concrete retriever classes.
|
|
2455
|
+
* Retrieves relevant information based on the input text or messages.
|
|
2070
2456
|
*
|
|
2071
|
-
* @param input - The input to
|
|
2072
|
-
* @
|
|
2457
|
+
* @param input - The input to use for retrieval (string or BaseMessage array)
|
|
2458
|
+
* @param options - Configuration and context for the retrieval
|
|
2459
|
+
* @returns Promise resolving to a string with the retrieved content
|
|
2073
2460
|
*/
|
|
2074
|
-
abstract retrieve(input: string | BaseMessage[]): Promise<string>;
|
|
2461
|
+
abstract retrieve(input: string | BaseMessage[], options: RetrieveOptions): Promise<string>;
|
|
2075
2462
|
}
|
|
2076
2463
|
|
|
2077
2464
|
/**
|
|
@@ -2187,11 +2574,19 @@ interface OnStartHookArgs {
|
|
|
2187
2574
|
context: OperationContext;
|
|
2188
2575
|
}
|
|
2189
2576
|
interface OnEndHookArgs {
|
|
2577
|
+
/**
|
|
2578
|
+
* The conversation ID.
|
|
2579
|
+
*/
|
|
2580
|
+
conversationId: string;
|
|
2581
|
+
/**
|
|
2582
|
+
* The agent that generated the output.
|
|
2583
|
+
*/
|
|
2190
2584
|
agent: Agent<any>;
|
|
2191
2585
|
/** The standardized successful output object. Undefined on error. */
|
|
2192
2586
|
output: AgentOperationOutput | undefined;
|
|
2193
2587
|
/** The VoltAgentError object if the operation failed. Undefined on success. */
|
|
2194
2588
|
error: VoltAgentError | undefined;
|
|
2589
|
+
/** The complete conversation messages including user input and assistant responses (Vercel AI SDK compatible) */
|
|
2195
2590
|
context: OperationContext;
|
|
2196
2591
|
}
|
|
2197
2592
|
interface OnHandoffHookArgs {
|
|
@@ -2387,10 +2782,11 @@ declare class Agent<TProvider extends {
|
|
|
2387
2782
|
/**
|
|
2388
2783
|
* Get the system message for the agent
|
|
2389
2784
|
*/
|
|
2390
|
-
protected getSystemMessage({ input, historyEntryId, contextMessages, }: {
|
|
2785
|
+
protected getSystemMessage({ input, historyEntryId, contextMessages, operationContext, }: {
|
|
2391
2786
|
input?: string | BaseMessage[];
|
|
2392
2787
|
historyEntryId: string;
|
|
2393
2788
|
contextMessages: BaseMessage[];
|
|
2789
|
+
operationContext?: OperationContext;
|
|
2394
2790
|
}): Promise<BaseMessage>;
|
|
2395
2791
|
/**
|
|
2396
2792
|
* Prepare agents memory for the supervisor system message
|
|
@@ -2454,7 +2850,7 @@ declare class Agent<TProvider extends {
|
|
|
2454
2850
|
*/
|
|
2455
2851
|
getHistory(): Promise<AgentHistoryEntry[]>;
|
|
2456
2852
|
/**
|
|
2457
|
-
* Add step to history immediately
|
|
2853
|
+
* Add step to history immediately and to conversation steps
|
|
2458
2854
|
*/
|
|
2459
2855
|
private addStepToHistory;
|
|
2460
2856
|
/**
|
|
@@ -2476,19 +2872,19 @@ declare class Agent<TProvider extends {
|
|
|
2476
2872
|
/**
|
|
2477
2873
|
* Generate a text response without streaming
|
|
2478
2874
|
*/
|
|
2479
|
-
generateText(input: string | BaseMessage[], options?: PublicGenerateOptions): Promise<
|
|
2875
|
+
generateText(input: string | BaseMessage[], options?: PublicGenerateOptions): Promise<InferGenerateTextResponseFromProvider<TProvider>>;
|
|
2480
2876
|
/**
|
|
2481
2877
|
* Stream a text response
|
|
2482
2878
|
*/
|
|
2483
|
-
streamText(input: string | BaseMessage[], options?: PublicGenerateOptions): Promise<
|
|
2879
|
+
streamText(input: string | BaseMessage[], options?: PublicGenerateOptions): Promise<InferStreamTextResponseFromProvider<TProvider>>;
|
|
2484
2880
|
/**
|
|
2485
2881
|
* Generate a structured object response
|
|
2486
2882
|
*/
|
|
2487
|
-
generateObject<
|
|
2883
|
+
generateObject<TSchema extends z.ZodType>(input: string | BaseMessage[], schema: TSchema, options?: PublicGenerateOptions): Promise<InferGenerateObjectResponseFromProvider<TProvider, TSchema>>;
|
|
2488
2884
|
/**
|
|
2489
2885
|
* Stream a structured object response
|
|
2490
2886
|
*/
|
|
2491
|
-
streamObject<
|
|
2887
|
+
streamObject<TSchema extends z.ZodType>(input: string | BaseMessage[], schema: TSchema, options?: PublicGenerateOptions): Promise<InferStreamObjectResponseFromProvider<TProvider, TSchema>>;
|
|
2492
2888
|
/**
|
|
2493
2889
|
* Add a sub-agent that this agent can delegate tasks to
|
|
2494
2890
|
*/
|
|
@@ -2609,10 +3005,10 @@ declare const ReasoningStepSchema: z.ZodObject<{
|
|
|
2609
3005
|
historyEntryId: z.ZodString;
|
|
2610
3006
|
agentId: z.ZodString;
|
|
2611
3007
|
}, "strip", z.ZodTypeAny, {
|
|
2612
|
-
|
|
3008
|
+
type: "thought" | "analysis";
|
|
2613
3009
|
title: string;
|
|
3010
|
+
id: string;
|
|
2614
3011
|
historyEntryId: string;
|
|
2615
|
-
type: "thought" | "analysis";
|
|
2616
3012
|
agentId: string;
|
|
2617
3013
|
timestamp: string;
|
|
2618
3014
|
reasoning: string;
|
|
@@ -2621,10 +3017,10 @@ declare const ReasoningStepSchema: z.ZodObject<{
|
|
|
2621
3017
|
result?: string | undefined;
|
|
2622
3018
|
next_action?: NextAction | undefined;
|
|
2623
3019
|
}, {
|
|
2624
|
-
|
|
3020
|
+
type: "thought" | "analysis";
|
|
2625
3021
|
title: string;
|
|
3022
|
+
id: string;
|
|
2626
3023
|
historyEntryId: string;
|
|
2627
|
-
type: "thought" | "analysis";
|
|
2628
3024
|
agentId: string;
|
|
2629
3025
|
timestamp: string;
|
|
2630
3026
|
reasoning: string;
|
|
@@ -3366,4 +3762,4 @@ declare class VoltAgent {
|
|
|
3366
3762
|
shutdownTelemetry(): Promise<void>;
|
|
3367
3763
|
}
|
|
3368
3764
|
|
|
3369
|
-
export { Agent, AgentErrorEvent, AgentHistoryEntry, AgentHookOnEnd, AgentHookOnHandoff, AgentHookOnStart, AgentHookOnToolEnd, AgentHookOnToolStart, AgentHooks, AgentOptions, AgentRegistry, AgentResponse, AgentStartEvent, AgentStartEventMetadata, AgentSuccessEvent, AgentSuccessEventMetadata, AgentTool, AllowedVariableValue, AnyToolConfig, BaseEventMetadata, BaseLLMOptions, BaseMessage, BaseRetriever, BaseTimelineEvent, BaseTool, BaseToolCall, ClientInfo, Conversation, CreateConversationInput, CreateReasoningToolsOptions, CustomEndpointDefinition, CustomEndpointError, CustomEndpointHandler, DEFAULT_INSTRUCTIONS, DataContent, EventStatus, ExtractVariableNames, FEW_SHOT_EXAMPLES, FilePart, GenerateObjectOptions, GenerateTextOptions, HTTPServerConfig, HistoryStatus, HttpMethod, ImagePart, InMemoryStorage, InferGenerateObjectResponse, InferGenerateTextResponse, InferMessage, InferModel, InferProviderParams, InferStreamResponse, InferTool, LLMProvider, LibSQLStorage, MCPClient, MCPClientConfig, MCPClientEvents, MCPConfiguration, MCPOptions, MCPServerConfig, MCPToolCall, MCPToolResult, Memory, MemoryEventMetadata, MemoryManager, MemoryMessage, MemoryOptions, MemoryReadErrorEvent, MemoryReadStartEvent, MemoryReadSuccessEvent, MemoryWriteErrorEvent, MemoryWriteStartEvent, MemoryWriteSuccessEvent, MessageContent, MessageFilterOptions, MessageRole, ModelToolCall, NewTimelineEvent, NextAction, NodeType, OnEndHookArgs, OnHandoffHookArgs, OnStartHookArgs, OnToolEndHookArgs, OnToolStartHookArgs, OperationContext, PackageUpdateInfo, PromptCreator, PromptTemplate, ProviderObjectResponse, ProviderObjectStreamResponse, ProviderParams, ProviderResponse, ProviderTextResponse, ProviderTextStreamResponse, ReadableStreamType, ReasoningStep, ReasoningStepSchema, ReasoningToolExecuteOptions, Retriever, RetrieverErrorEvent, RetrieverOptions, RetrieverStartEvent, RetrieverSuccessEvent, RetryConfig, StandardEventData, StandardTimelineEvent, StdioServerConfig, StepChunkCallback, StepFinishCallback, StepWithContent, StreamObjectFinishResult, StreamObjectOnFinishCallback, StreamObjectOptions, StreamTextFinishResult, StreamTextOnFinishCallback, StreamTextOptions, TemplateVariables, TextPart, TimelineEventCoreLevel, TimelineEventCoreStatus, TimelineEventCoreType, Tool, ToolCall, ToolErrorEvent, ToolErrorInfo, ToolExecuteOptions, ToolExecutionContext, ToolManager, ToolOptions, ToolSchema, ToolStartEvent, ToolStatus, ToolStatusInfo, ToolSuccessEvent, Toolkit, ToolsetMap, ToolsetWithTools, TransportError, Usage, UsageInfo, Voice, VoiceEventData, VoiceEventType, VoiceMetadata, VoiceOptions, VoltAgent, VoltAgentError, VoltAgentExporter, VoltAgentExporterOptions, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createTool, createToolkit, VoltAgent as default, getNodeTypeFromNodeId, registerCustomEndpoint, registerCustomEndpoints, safeJsonParse, serializeValueForDebug, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
|
|
3765
|
+
export { Agent, AgentErrorEvent, AgentHistoryEntry, AgentHookOnEnd, AgentHookOnHandoff, AgentHookOnStart, AgentHookOnToolEnd, AgentHookOnToolStart, AgentHooks, AgentOptions, AgentRegistry, AgentResponse, AgentStartEvent, AgentStartEventMetadata, AgentSuccessEvent, AgentSuccessEventMetadata, AgentTool, AllowedVariableValue, AnyToolConfig, AsyncIterableStream, BaseEventMetadata, BaseLLMOptions, BaseMessage, BaseRetriever, BaseTimelineEvent, BaseTool, BaseToolCall, ClientInfo, Conversation, ConversationQueryOptions, CreateConversationInput, CreateReasoningToolsOptions, CustomEndpointDefinition, CustomEndpointError, CustomEndpointHandler, DEFAULT_INSTRUCTIONS, DataContent, EventStatus, ExtractVariableNames, FEW_SHOT_EXAMPLES, FilePart, GenerateObjectOptions, GenerateTextOptions, HTTPServerConfig, HistoryStatus, HttpMethod, ImagePart, InMemoryStorage, InferGenerateObjectResponse, InferGenerateTextResponse, InferMessage, InferModel, InferProviderParams, InferStreamResponse, InferTool, LLMProvider, LibSQLStorage, MCPClient, MCPClientConfig, MCPClientEvents, MCPConfiguration, MCPOptions, MCPServerConfig, MCPToolCall, MCPToolResult, Memory, MemoryEventMetadata, MemoryManager, MemoryMessage, MemoryOptions, MemoryReadErrorEvent, MemoryReadStartEvent, MemoryReadSuccessEvent, MemoryWriteErrorEvent, MemoryWriteStartEvent, MemoryWriteSuccessEvent, MessageContent, MessageFilterOptions, MessageRole, ModelToolCall, NewTimelineEvent, NextAction, NodeType, OnEndHookArgs, OnHandoffHookArgs, OnStartHookArgs, OnToolEndHookArgs, OnToolStartHookArgs, OperationContext, PackageUpdateInfo, PromptCreator, PromptTemplate, ProviderObjectResponse, ProviderObjectStreamResponse, ProviderParams, ProviderResponse, ProviderTextResponse, ProviderTextStreamResponse, ReadableStreamType, ReasoningStep, ReasoningStepSchema, ReasoningToolExecuteOptions, RetrieveOptions, Retriever, RetrieverErrorEvent, RetrieverOptions, RetrieverStartEvent, RetrieverSuccessEvent, RetryConfig, StandardEventData, StandardTimelineEvent, StdioServerConfig, StepChunkCallback, StepFinishCallback, StepWithContent, StreamObjectFinishResult, StreamObjectOnFinishCallback, StreamObjectOptions, StreamTextFinishResult, StreamTextOnFinishCallback, StreamTextOptions, TemplateVariables, TextPart, TimelineEventCoreLevel, TimelineEventCoreStatus, TimelineEventCoreType, Tool, ToolCall, ToolErrorEvent, ToolErrorInfo, ToolExecuteOptions, ToolExecutionContext, ToolManager, ToolOptions, ToolSchema, ToolStartEvent, ToolStatus, ToolStatusInfo, ToolSuccessEvent, Toolkit, ToolsetMap, ToolsetWithTools, TransportError, Usage, UsageInfo, Voice, VoiceEventData, VoiceEventType, VoiceMetadata, VoiceOptions, VoltAgent, VoltAgentError, VoltAgentExporter, VoltAgentExporterOptions, checkForUpdates, createAsyncIterableStream, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createTool, createToolkit, VoltAgent as default, getNodeTypeFromNodeId, registerCustomEndpoint, registerCustomEndpoints, safeJsonParse, serializeValueForDebug, tool, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
|