@voltagent/core 0.1.83 → 1.0.0-next.0
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/README.md +27 -8
- package/dist/index.d.mts +5 -529
- package/dist/index.d.ts +5 -529
- package/dist/index.js +8026 -11026
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8491 -11490
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -96,17 +96,30 @@ You'll see the starter code in `src/index.ts`, which now registers both an agent
|
|
|
96
96
|
|
|
97
97
|
```typescript
|
|
98
98
|
import { VoltAgent, Agent } from "@voltagent/core";
|
|
99
|
+
import { LibSQLStorage } from "@voltagent/libsql";
|
|
100
|
+
import { createPinoLogger } from "@voltagent/logger";
|
|
99
101
|
import { VercelAIProvider } from "@voltagent/vercel-ai";
|
|
100
102
|
import { openai } from "@ai-sdk/openai";
|
|
101
|
-
import {
|
|
103
|
+
import { expenseApprovalWorkflow } from "./workflows";
|
|
104
|
+
import { weatherTool } from "./tools";
|
|
105
|
+
|
|
106
|
+
// Create a logger instance
|
|
107
|
+
const logger = createPinoLogger({
|
|
108
|
+
name: "my-agent-app",
|
|
109
|
+
level: "info",
|
|
110
|
+
});
|
|
102
111
|
|
|
103
112
|
// A simple, general-purpose agent for the project.
|
|
104
113
|
const agent = new Agent({
|
|
105
114
|
name: "my-agent",
|
|
106
|
-
instructions: "A helpful assistant that
|
|
115
|
+
instructions: "A helpful assistant that can check weather and help with various tasks",
|
|
107
116
|
llm: new VercelAIProvider(),
|
|
108
117
|
model: openai("gpt-4o-mini"),
|
|
109
|
-
tools: [],
|
|
118
|
+
tools: [weatherTool],
|
|
119
|
+
memory: new LibSQLStorage({
|
|
120
|
+
url: "file:./.voltagent/memory.db",
|
|
121
|
+
logger: logger.child({ component: "libsql" }),
|
|
122
|
+
}),
|
|
110
123
|
});
|
|
111
124
|
|
|
112
125
|
// Initialize VoltAgent with your agent(s) and workflow(s)
|
|
@@ -115,8 +128,9 @@ new VoltAgent({
|
|
|
115
128
|
agent,
|
|
116
129
|
},
|
|
117
130
|
workflows: {
|
|
118
|
-
|
|
131
|
+
expenseApprovalWorkflow,
|
|
119
132
|
},
|
|
133
|
+
logger,
|
|
120
134
|
});
|
|
121
135
|
```
|
|
122
136
|
|
|
@@ -150,16 +164,21 @@ Your agent is now running! To interact with it:
|
|
|
150
164
|
|
|
151
165
|
### Running Your First Workflow
|
|
152
166
|
|
|
153
|
-
Your new project also includes a powerful workflow engine. You can test the pre-built `
|
|
167
|
+
Your new project also includes a powerful workflow engine. You can test the pre-built `expenseApprovalWorkflow` directly from the VoltOps console:
|
|
154
168
|
|
|
155
169
|

|
|
156
170
|
|
|
157
171
|
1. **Go to the Workflows Page:** After starting your server, go directly to the [Workflows page](https://console.voltagent.dev/workflows).
|
|
158
172
|
2. **Select Your Project:** Use the project selector to choose your project (e.g., "my-agent-app").
|
|
159
|
-
3. **Find and Run:** You will see **"
|
|
160
|
-
4. **Provide Input:** The workflow expects a JSON object with
|
|
173
|
+
3. **Find and Run:** You will see **"Expense Approval Workflow"** listed. Click it, then click the **"Run"** button.
|
|
174
|
+
4. **Provide Input:** The workflow expects a JSON object with expense details. Try a small expense for automatic approval:
|
|
161
175
|
```json
|
|
162
|
-
{
|
|
176
|
+
{
|
|
177
|
+
"employeeId": "EMP-123",
|
|
178
|
+
"amount": 250,
|
|
179
|
+
"category": "office-supplies",
|
|
180
|
+
"description": "New laptop mouse and keyboard"
|
|
181
|
+
}
|
|
163
182
|
```
|
|
164
183
|
5. **View the Results:** After execution, you can inspect the detailed logs for each step and see the final output directly in the console.
|
|
165
184
|
|
package/dist/index.d.mts
CHANGED
|
@@ -8,7 +8,6 @@ import { Span } from '@opentelemetry/api';
|
|
|
8
8
|
import * as TF from 'type-fest';
|
|
9
9
|
import { Simplify, LiteralUnion, MergeDeep } from 'type-fest';
|
|
10
10
|
import { EventEmitter } from 'node:events';
|
|
11
|
-
import { Client } from '@libsql/client';
|
|
12
11
|
import { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
13
12
|
import { Context } from 'hono';
|
|
14
13
|
import { ClientCapabilities } from '@modelcontextprotocol/sdk/types.js';
|
|
@@ -3652,529 +3651,6 @@ declare class InMemoryStorage implements Memory {
|
|
|
3652
3651
|
cleanupOldWorkflowHistories(workflowId: string, maxEntries: number): Promise<number>;
|
|
3653
3652
|
}
|
|
3654
3653
|
|
|
3655
|
-
/**
|
|
3656
|
-
* LibSQL extension for workflow memory operations
|
|
3657
|
-
* This class provides workflow-specific storage operations for LibSQL
|
|
3658
|
-
*/
|
|
3659
|
-
declare class LibSQLWorkflowExtension {
|
|
3660
|
-
private client;
|
|
3661
|
-
private _tablePrefix;
|
|
3662
|
-
private logger;
|
|
3663
|
-
constructor(client: Client, _tablePrefix?: string);
|
|
3664
|
-
/**
|
|
3665
|
-
* Store a workflow history entry
|
|
3666
|
-
*/
|
|
3667
|
-
storeWorkflowHistory(entry: WorkflowHistoryEntry): Promise<void>;
|
|
3668
|
-
/**
|
|
3669
|
-
* Get a workflow history entry by ID
|
|
3670
|
-
*/
|
|
3671
|
-
getWorkflowHistory(id: string): Promise<WorkflowHistoryEntry | null>;
|
|
3672
|
-
/**
|
|
3673
|
-
* Get all workflow history entries for a specific workflow
|
|
3674
|
-
*/
|
|
3675
|
-
getWorkflowHistoryByWorkflowId(workflowId: string): Promise<WorkflowHistoryEntry[]>;
|
|
3676
|
-
/**
|
|
3677
|
-
* Update a workflow history entry
|
|
3678
|
-
*/
|
|
3679
|
-
updateWorkflowHistory(id: string, updates: Partial<WorkflowHistoryEntry>): Promise<void>;
|
|
3680
|
-
/**
|
|
3681
|
-
* Delete a workflow history entry
|
|
3682
|
-
*/
|
|
3683
|
-
deleteWorkflowHistory(id: string): Promise<void>;
|
|
3684
|
-
/**
|
|
3685
|
-
* Store a workflow step entry
|
|
3686
|
-
*/
|
|
3687
|
-
storeWorkflowStep(step: WorkflowStepHistoryEntry): Promise<void>;
|
|
3688
|
-
/**
|
|
3689
|
-
* Get a workflow step by ID
|
|
3690
|
-
*/
|
|
3691
|
-
getWorkflowStep(id: string): Promise<WorkflowStepHistoryEntry | null>;
|
|
3692
|
-
/**
|
|
3693
|
-
* Get all workflow steps for a specific workflow history
|
|
3694
|
-
*/
|
|
3695
|
-
getWorkflowSteps(workflowHistoryId: string): Promise<WorkflowStepHistoryEntry[]>;
|
|
3696
|
-
/**
|
|
3697
|
-
* Update a workflow step
|
|
3698
|
-
*/
|
|
3699
|
-
updateWorkflowStep(id: string, updates: Partial<WorkflowStepHistoryEntry>): Promise<void>;
|
|
3700
|
-
/**
|
|
3701
|
-
* Delete a workflow step
|
|
3702
|
-
*/
|
|
3703
|
-
deleteWorkflowStep(id: string): Promise<void>;
|
|
3704
|
-
/**
|
|
3705
|
-
* Store a workflow timeline event
|
|
3706
|
-
*/
|
|
3707
|
-
storeWorkflowTimelineEvent(event: WorkflowTimelineEvent$1): Promise<void>;
|
|
3708
|
-
/**
|
|
3709
|
-
* Get a workflow timeline event by ID
|
|
3710
|
-
*/
|
|
3711
|
-
getWorkflowTimelineEvent(id: string): Promise<WorkflowTimelineEvent$1 | null>;
|
|
3712
|
-
/**
|
|
3713
|
-
* Get all workflow timeline events for a specific workflow history
|
|
3714
|
-
*/
|
|
3715
|
-
getWorkflowTimelineEvents(workflowHistoryId: string): Promise<WorkflowTimelineEvent$1[]>;
|
|
3716
|
-
/**
|
|
3717
|
-
* Delete a workflow timeline event
|
|
3718
|
-
*/
|
|
3719
|
-
deleteWorkflowTimelineEvent(id: string): Promise<void>;
|
|
3720
|
-
/**
|
|
3721
|
-
* Get all workflow IDs
|
|
3722
|
-
*/
|
|
3723
|
-
getAllWorkflowIds(): Promise<string[]>;
|
|
3724
|
-
/**
|
|
3725
|
-
* Get workflow statistics
|
|
3726
|
-
*/
|
|
3727
|
-
getWorkflowStats(workflowId: string): Promise<WorkflowStats>;
|
|
3728
|
-
/**
|
|
3729
|
-
* Get workflow history with all related data (steps and events)
|
|
3730
|
-
*/
|
|
3731
|
-
getWorkflowHistoryWithStepsAndEvents(id: string): Promise<WorkflowHistoryEntry | null>;
|
|
3732
|
-
/**
|
|
3733
|
-
* Delete workflow history and all related data
|
|
3734
|
-
*/
|
|
3735
|
-
deleteWorkflowHistoryWithRelated(id: string): Promise<void>;
|
|
3736
|
-
/**
|
|
3737
|
-
* Clean up old workflow histories
|
|
3738
|
-
*/
|
|
3739
|
-
cleanupOldWorkflowHistories(workflowId: string, maxEntries: number): Promise<number>;
|
|
3740
|
-
/**
|
|
3741
|
-
* Parse workflow history row from database
|
|
3742
|
-
*/
|
|
3743
|
-
private parseWorkflowHistoryRow;
|
|
3744
|
-
/**
|
|
3745
|
-
* Parse workflow step row from database
|
|
3746
|
-
*/
|
|
3747
|
-
private parseWorkflowStepRow;
|
|
3748
|
-
/**
|
|
3749
|
-
* Parse workflow timeline event row from database
|
|
3750
|
-
*/
|
|
3751
|
-
private parseWorkflowTimelineEventRow;
|
|
3752
|
-
}
|
|
3753
|
-
|
|
3754
|
-
/**
|
|
3755
|
-
* Options for configuring the LibSQLStorage
|
|
3756
|
-
*/
|
|
3757
|
-
interface LibSQLStorageOptions extends MemoryOptions {
|
|
3758
|
-
/**
|
|
3759
|
-
* LibSQL connection URL
|
|
3760
|
-
* Can be either a remote Turso URL or a local file path
|
|
3761
|
-
* @example "libsql://your-database.turso.io" for remote Turso
|
|
3762
|
-
* @example "file:memory.db" for local SQLite in current directory
|
|
3763
|
-
* @example "file:.voltagent/memory.db" for local SQLite in .voltagent folder
|
|
3764
|
-
*/
|
|
3765
|
-
url: string;
|
|
3766
|
-
/**
|
|
3767
|
-
* Auth token for LibSQL/Turso
|
|
3768
|
-
* Not needed for local SQLite
|
|
3769
|
-
*/
|
|
3770
|
-
authToken?: string;
|
|
3771
|
-
/**
|
|
3772
|
-
* Prefix for table names
|
|
3773
|
-
* @default "voltagent_memory"
|
|
3774
|
-
*/
|
|
3775
|
-
tablePrefix?: string;
|
|
3776
|
-
/**
|
|
3777
|
-
* Whether to enable debug logging
|
|
3778
|
-
* @default false
|
|
3779
|
-
*/
|
|
3780
|
-
debug?: boolean;
|
|
3781
|
-
/**
|
|
3782
|
-
* Storage limit for the LibSQLStorage
|
|
3783
|
-
* @default 100
|
|
3784
|
-
*/
|
|
3785
|
-
storageLimit?: number;
|
|
3786
|
-
/**
|
|
3787
|
-
* Number of retry attempts for database operations when encountering busy/locked errors
|
|
3788
|
-
* @default 3
|
|
3789
|
-
*/
|
|
3790
|
-
retryAttempts?: number;
|
|
3791
|
-
/**
|
|
3792
|
-
* Base delay in milliseconds before retrying a failed operation
|
|
3793
|
-
* Uses a jittered exponential backoff strategy for better load distribution
|
|
3794
|
-
* @default 50
|
|
3795
|
-
*/
|
|
3796
|
-
baseDelayMs?: number;
|
|
3797
|
-
}
|
|
3798
|
-
/**
|
|
3799
|
-
* A LibSQL storage implementation of the Memory and WorkflowMemory interfaces
|
|
3800
|
-
* Uses libsql/Turso to store and retrieve conversation history and workflow data
|
|
3801
|
-
*
|
|
3802
|
-
* This implementation automatically handles both:
|
|
3803
|
-
* - Remote Turso databases (with libsql:// URLs)
|
|
3804
|
-
* - Local SQLite databases (with file: URLs)
|
|
3805
|
-
*/
|
|
3806
|
-
declare class LibSQLStorage implements Memory {
|
|
3807
|
-
private client;
|
|
3808
|
-
private options;
|
|
3809
|
-
private initialized;
|
|
3810
|
-
private workflowExtension;
|
|
3811
|
-
private logger;
|
|
3812
|
-
private retryAttempts;
|
|
3813
|
-
private baseDelayMs;
|
|
3814
|
-
/**
|
|
3815
|
-
* Create a new LibSQL storage
|
|
3816
|
-
* @param options Configuration options
|
|
3817
|
-
*/
|
|
3818
|
-
constructor(options: LibSQLStorageOptions);
|
|
3819
|
-
/**
|
|
3820
|
-
* Normalize the URL for SQLite database
|
|
3821
|
-
* - Ensures local files exist in the correct directory
|
|
3822
|
-
* - Creates the .voltagent directory if needed for default storage
|
|
3823
|
-
*/
|
|
3824
|
-
private normalizeUrl;
|
|
3825
|
-
/**
|
|
3826
|
-
* Log a debug message if debug is enabled
|
|
3827
|
-
* @param message Message to log
|
|
3828
|
-
* @param data Additional data to log
|
|
3829
|
-
*/
|
|
3830
|
-
private debug;
|
|
3831
|
-
/**
|
|
3832
|
-
* Calculate delay with jitter for better load distribution
|
|
3833
|
-
* @param attempt Current retry attempt number
|
|
3834
|
-
* @returns Delay in milliseconds
|
|
3835
|
-
*/
|
|
3836
|
-
private calculateRetryDelay;
|
|
3837
|
-
/**
|
|
3838
|
-
* Execute a database operation with retry strategy
|
|
3839
|
-
* Implements jittered exponential backoff
|
|
3840
|
-
* @param operationFn The operation function to execute
|
|
3841
|
-
* @param operationName Operation name for logging
|
|
3842
|
-
* @returns The result of the operation
|
|
3843
|
-
*/
|
|
3844
|
-
private executeWithRetryStrategy;
|
|
3845
|
-
/**
|
|
3846
|
-
* Initialize workflow tables
|
|
3847
|
-
*/
|
|
3848
|
-
private initializeWorkflowTables;
|
|
3849
|
-
/**
|
|
3850
|
-
* Initialize the database tables
|
|
3851
|
-
* @returns Promise that resolves when initialization is complete
|
|
3852
|
-
*/
|
|
3853
|
-
private initializeDatabase;
|
|
3854
|
-
/**
|
|
3855
|
-
* Generate a unique ID for a message
|
|
3856
|
-
* @returns Unique ID
|
|
3857
|
-
*/
|
|
3858
|
-
private generateId;
|
|
3859
|
-
/**
|
|
3860
|
-
* Get messages with filtering options
|
|
3861
|
-
* @param options Filtering options
|
|
3862
|
-
* @returns Filtered messages
|
|
3863
|
-
*/
|
|
3864
|
-
getMessages(options?: MessageFilterOptions): Promise<MemoryMessage[]>;
|
|
3865
|
-
/**
|
|
3866
|
-
* Add a message to the conversation history
|
|
3867
|
-
* @param message Message to add
|
|
3868
|
-
* @param userId User identifier (optional, defaults to "default")
|
|
3869
|
-
* @param conversationId Conversation identifier (optional, defaults to "default")
|
|
3870
|
-
*/
|
|
3871
|
-
addMessage(message: MemoryMessage, conversationId?: string): Promise<void>;
|
|
3872
|
-
/**
|
|
3873
|
-
* Prune old messages to respect storage limit
|
|
3874
|
-
* @param conversationId Conversation ID to prune messages for
|
|
3875
|
-
*/
|
|
3876
|
-
private pruneOldMessages;
|
|
3877
|
-
/**
|
|
3878
|
-
* Clear messages from memory
|
|
3879
|
-
*/
|
|
3880
|
-
clearMessages(options: {
|
|
3881
|
-
userId: string;
|
|
3882
|
-
conversationId?: string;
|
|
3883
|
-
}): Promise<void>;
|
|
3884
|
-
/**
|
|
3885
|
-
* Close the database connection
|
|
3886
|
-
*/
|
|
3887
|
-
close(): Promise<void>;
|
|
3888
|
-
/**
|
|
3889
|
-
* Add or update a history entry
|
|
3890
|
-
* @param key Entry ID
|
|
3891
|
-
* @param value Entry data
|
|
3892
|
-
* @param agentId Agent ID for filtering
|
|
3893
|
-
*/
|
|
3894
|
-
addHistoryEntry(key: string, value: any, agentId: string): Promise<void>;
|
|
3895
|
-
/**
|
|
3896
|
-
* Update an existing history entry
|
|
3897
|
-
* @param key Entry ID
|
|
3898
|
-
* @param value Updated entry data
|
|
3899
|
-
* @param agentId Agent ID for filtering
|
|
3900
|
-
*/
|
|
3901
|
-
updateHistoryEntry(key: string, value: any, agentId: string): Promise<void>;
|
|
3902
|
-
/**
|
|
3903
|
-
* Add a history step
|
|
3904
|
-
* @param key Step ID
|
|
3905
|
-
* @param value Step data
|
|
3906
|
-
* @param historyId Related history entry ID
|
|
3907
|
-
* @param agentId Agent ID for filtering
|
|
3908
|
-
*/
|
|
3909
|
-
addHistoryStep(key: string, value: any, historyId: string, agentId: string): Promise<void>;
|
|
3910
|
-
/**
|
|
3911
|
-
* Update a history step
|
|
3912
|
-
* @param key Step ID
|
|
3913
|
-
* @param value Updated step data
|
|
3914
|
-
* @param historyId Related history entry ID
|
|
3915
|
-
* @param agentId Agent ID for filtering
|
|
3916
|
-
*/
|
|
3917
|
-
updateHistoryStep(key: string, value: any, historyId: string, agentId: string): Promise<void>;
|
|
3918
|
-
/**
|
|
3919
|
-
* Add a timeline event
|
|
3920
|
-
* @param key Event ID (UUID)
|
|
3921
|
-
* @param value Timeline event data
|
|
3922
|
-
* @param historyId Related history entry ID
|
|
3923
|
-
* @param agentId Agent ID for filtering
|
|
3924
|
-
*/
|
|
3925
|
-
addTimelineEvent(key: string, value: NewTimelineEvent, historyId: string, agentId: string): Promise<void>;
|
|
3926
|
-
/**
|
|
3927
|
-
* Get a history entry by ID
|
|
3928
|
-
* @param key Entry ID
|
|
3929
|
-
* @returns The history entry or undefined if not found
|
|
3930
|
-
*/
|
|
3931
|
-
getHistoryEntry(key: string): Promise<any | undefined>;
|
|
3932
|
-
/**
|
|
3933
|
-
* Get a history step by ID
|
|
3934
|
-
* @param key Step ID
|
|
3935
|
-
* @returns The history step or undefined if not found
|
|
3936
|
-
*/
|
|
3937
|
-
getHistoryStep(key: string): Promise<any | undefined>;
|
|
3938
|
-
createConversation(conversation: CreateConversationInput): Promise<Conversation>;
|
|
3939
|
-
getConversation(id: string): Promise<Conversation | null>;
|
|
3940
|
-
getConversations(resourceId: string): Promise<Conversation[]>;
|
|
3941
|
-
getConversationsByUserId(userId: string, options?: Omit<ConversationQueryOptions, "userId">): Promise<Conversation[]>;
|
|
3942
|
-
/**
|
|
3943
|
-
* Query conversations with filtering and pagination options
|
|
3944
|
-
*
|
|
3945
|
-
* @param options Query options for filtering and pagination
|
|
3946
|
-
* @returns Promise that resolves to an array of conversations matching the criteria
|
|
3947
|
-
* @see {@link https://voltagent.dev/docs/agents/memory/libsql#querying-conversations | Querying Conversations}
|
|
3948
|
-
*/
|
|
3949
|
-
queryConversations(options: ConversationQueryOptions): Promise<Conversation[]>;
|
|
3950
|
-
/**
|
|
3951
|
-
* Get messages for a specific conversation with pagination support
|
|
3952
|
-
*
|
|
3953
|
-
* @param conversationId The unique identifier of the conversation to retrieve messages from
|
|
3954
|
-
* @param options Optional pagination and filtering options
|
|
3955
|
-
* @returns Promise that resolves to an array of messages in chronological order (oldest first)
|
|
3956
|
-
* @see {@link https://voltagent.dev/docs/agents/memory/libsql#conversation-messages | Getting Conversation Messages}
|
|
3957
|
-
*/
|
|
3958
|
-
getConversationMessages(conversationId: string, options?: {
|
|
3959
|
-
limit?: number;
|
|
3960
|
-
offset?: number;
|
|
3961
|
-
}): Promise<MemoryMessage[]>;
|
|
3962
|
-
updateConversation(id: string, updates: Partial<Omit<Conversation, "id" | "createdAt" | "updatedAt">>): Promise<Conversation>;
|
|
3963
|
-
deleteConversation(id: string): Promise<void>;
|
|
3964
|
-
/**
|
|
3965
|
-
* Get all history entries for an agent with pagination
|
|
3966
|
-
* @param agentId Agent ID
|
|
3967
|
-
* @param page Page number (0-based)
|
|
3968
|
-
* @param limit Number of entries per page
|
|
3969
|
-
* @returns Object with entries array and total count
|
|
3970
|
-
*/
|
|
3971
|
-
getAllHistoryEntriesByAgent(agentId: string, page: number, limit: number): Promise<{
|
|
3972
|
-
entries: any[];
|
|
3973
|
-
total: number;
|
|
3974
|
-
}>;
|
|
3975
|
-
/**
|
|
3976
|
-
* Migrates agent history data from old structure to new structure.
|
|
3977
|
-
* If migration fails, it can be rolled back using the backup mechanism.
|
|
3978
|
-
*
|
|
3979
|
-
* Old database structure:
|
|
3980
|
-
* CREATE TABLE voltagent_memory_agent_history (
|
|
3981
|
-
* key TEXT PRIMARY KEY,
|
|
3982
|
-
* value TEXT NOT NULL,
|
|
3983
|
-
* agent_id TEXT
|
|
3984
|
-
* );
|
|
3985
|
-
*/
|
|
3986
|
-
migrateAgentHistoryData(options?: {
|
|
3987
|
-
createBackup?: boolean;
|
|
3988
|
-
restoreFromBackup?: boolean;
|
|
3989
|
-
deleteBackupAfterSuccess?: boolean;
|
|
3990
|
-
}): Promise<{
|
|
3991
|
-
success: boolean;
|
|
3992
|
-
migratedCount?: number;
|
|
3993
|
-
error?: Error;
|
|
3994
|
-
backupCreated?: boolean;
|
|
3995
|
-
}>;
|
|
3996
|
-
/**
|
|
3997
|
-
* Migrate conversation schema to add user_id and update messages table
|
|
3998
|
-
*
|
|
3999
|
-
* ⚠️ **CRITICAL WARNING: DESTRUCTIVE OPERATION** ⚠️
|
|
4000
|
-
*
|
|
4001
|
-
* This method performs a DESTRUCTIVE schema migration that:
|
|
4002
|
-
* - DROPS and recreates existing tables
|
|
4003
|
-
* - Creates temporary tables during migration
|
|
4004
|
-
* - Modifies the primary key structure of the messages table
|
|
4005
|
-
* - Can cause DATA LOSS if interrupted or if errors occur
|
|
4006
|
-
*
|
|
4007
|
-
* **IMPORTANT SAFETY REQUIREMENTS:**
|
|
4008
|
-
* - 🛑 STOP all application instances before running this migration
|
|
4009
|
-
* - 🛑 Ensure NO concurrent database operations are running
|
|
4010
|
-
* - 🛑 Take a full database backup before running (independent of built-in backup)
|
|
4011
|
-
* - 🛑 Test the migration on a copy of production data first
|
|
4012
|
-
* - 🛑 Plan for downtime during migration execution
|
|
4013
|
-
*
|
|
4014
|
-
* **What this migration does:**
|
|
4015
|
-
* 1. Creates backup tables (if createBackup=true)
|
|
4016
|
-
* 2. Creates temporary tables with new schema
|
|
4017
|
-
* 3. Migrates data from old tables to new schema
|
|
4018
|
-
* 4. DROPS original tables
|
|
4019
|
-
* 5. Renames temporary tables to original names
|
|
4020
|
-
* 6. All operations are wrapped in a transaction for atomicity
|
|
4021
|
-
*
|
|
4022
|
-
* @param options Migration configuration options
|
|
4023
|
-
* @param options.createBackup Whether to create backup tables before migration (default: true, HIGHLY RECOMMENDED)
|
|
4024
|
-
* @param options.restoreFromBackup Whether to restore from existing backup instead of migrating (default: false)
|
|
4025
|
-
* @param options.deleteBackupAfterSuccess Whether to delete backup tables after successful migration (default: false)
|
|
4026
|
-
*
|
|
4027
|
-
* @returns Promise resolving to migration result with success status, migrated count, and backup info
|
|
4028
|
-
*
|
|
4029
|
-
* @example
|
|
4030
|
-
* ```typescript
|
|
4031
|
-
* // RECOMMENDED: Run with backup creation (default)
|
|
4032
|
-
* const result = await storage.migrateConversationSchema({
|
|
4033
|
-
* createBackup: true,
|
|
4034
|
-
* deleteBackupAfterSuccess: false // Keep backup for safety
|
|
4035
|
-
* });
|
|
4036
|
-
*
|
|
4037
|
-
* if (result.success) {
|
|
4038
|
-
* console.log(`Migrated ${result.migratedCount} conversations successfully`);
|
|
4039
|
-
* } else {
|
|
4040
|
-
* console.error('Migration failed:', result.error);
|
|
4041
|
-
* // Consider restoring from backup
|
|
4042
|
-
* }
|
|
4043
|
-
*
|
|
4044
|
-
* // If migration fails, restore from backup:
|
|
4045
|
-
* const restoreResult = await storage.migrateConversationSchema({
|
|
4046
|
-
* restoreFromBackup: true
|
|
4047
|
-
* });
|
|
4048
|
-
* ```
|
|
4049
|
-
*
|
|
4050
|
-
* @throws {Error} If migration fails and transaction is rolled back
|
|
4051
|
-
*
|
|
4052
|
-
* @since This migration is typically only needed when upgrading from older schema versions
|
|
4053
|
-
*/
|
|
4054
|
-
private migrateConversationSchema;
|
|
4055
|
-
/**
|
|
4056
|
-
* Get conversations for a user with a fluent query builder interface
|
|
4057
|
-
* @param userId User ID to filter by
|
|
4058
|
-
* @returns Query builder object
|
|
4059
|
-
*/
|
|
4060
|
-
getUserConversations(userId: string): {
|
|
4061
|
-
/**
|
|
4062
|
-
* Limit the number of results
|
|
4063
|
-
* @param count Number of conversations to return
|
|
4064
|
-
* @returns Query builder
|
|
4065
|
-
*/
|
|
4066
|
-
limit: (count: number) => {
|
|
4067
|
-
/**
|
|
4068
|
-
* Order results by a specific field
|
|
4069
|
-
* @param field Field to order by
|
|
4070
|
-
* @param direction Sort direction
|
|
4071
|
-
* @returns Query builder
|
|
4072
|
-
*/
|
|
4073
|
-
orderBy: (field?: "created_at" | "updated_at" | "title", direction?: "ASC" | "DESC") => {
|
|
4074
|
-
/**
|
|
4075
|
-
* Execute the query and return results
|
|
4076
|
-
* @returns Promise of conversations
|
|
4077
|
-
*/
|
|
4078
|
-
execute: () => Promise<Conversation[]>;
|
|
4079
|
-
};
|
|
4080
|
-
/**
|
|
4081
|
-
* Execute the query with default ordering
|
|
4082
|
-
* @returns Promise of conversations
|
|
4083
|
-
*/
|
|
4084
|
-
execute: () => Promise<Conversation[]>;
|
|
4085
|
-
};
|
|
4086
|
-
/**
|
|
4087
|
-
* Order results by a specific field
|
|
4088
|
-
* @param field Field to order by
|
|
4089
|
-
* @param direction Sort direction
|
|
4090
|
-
* @returns Query builder
|
|
4091
|
-
*/
|
|
4092
|
-
orderBy: (field?: "created_at" | "updated_at" | "title", direction?: "ASC" | "DESC") => {
|
|
4093
|
-
/**
|
|
4094
|
-
* Limit the number of results
|
|
4095
|
-
* @param count Number of conversations to return
|
|
4096
|
-
* @returns Query builder
|
|
4097
|
-
*/
|
|
4098
|
-
limit: (count: number) => {
|
|
4099
|
-
/**
|
|
4100
|
-
* Execute the query and return results
|
|
4101
|
-
* @returns Promise of conversations
|
|
4102
|
-
*/
|
|
4103
|
-
execute: () => Promise<Conversation[]>;
|
|
4104
|
-
};
|
|
4105
|
-
/**
|
|
4106
|
-
* Execute the query without limit
|
|
4107
|
-
* @returns Promise of conversations
|
|
4108
|
-
*/
|
|
4109
|
-
execute: () => Promise<Conversation[]>;
|
|
4110
|
-
};
|
|
4111
|
-
/**
|
|
4112
|
-
* Execute the query with default options
|
|
4113
|
-
* @returns Promise of conversations
|
|
4114
|
-
*/
|
|
4115
|
-
execute: () => Promise<Conversation[]>;
|
|
4116
|
-
};
|
|
4117
|
-
/**
|
|
4118
|
-
* Get conversation by ID and ensure it belongs to the specified user
|
|
4119
|
-
* @param conversationId Conversation ID
|
|
4120
|
-
* @param userId User ID to validate ownership
|
|
4121
|
-
* @returns Conversation or null
|
|
4122
|
-
*/
|
|
4123
|
-
getUserConversation(conversationId: string, userId: string): Promise<Conversation | null>;
|
|
4124
|
-
/**
|
|
4125
|
-
* Get paginated conversations for a user
|
|
4126
|
-
* @param userId User ID
|
|
4127
|
-
* @param page Page number (1-based)
|
|
4128
|
-
* @param pageSize Number of items per page
|
|
4129
|
-
* @returns Object with conversations and pagination info
|
|
4130
|
-
*/
|
|
4131
|
-
getPaginatedUserConversations(userId: string, page?: number, pageSize?: number): Promise<{
|
|
4132
|
-
conversations: Conversation[];
|
|
4133
|
-
page: number;
|
|
4134
|
-
pageSize: number;
|
|
4135
|
-
hasMore: boolean;
|
|
4136
|
-
}>;
|
|
4137
|
-
/**
|
|
4138
|
-
* Check and create migration flag table, return if migration already completed
|
|
4139
|
-
* @param migrationType Type of migration to check
|
|
4140
|
-
* @returns Object with completion status and details
|
|
4141
|
-
*/
|
|
4142
|
-
private checkMigrationFlag;
|
|
4143
|
-
/**
|
|
4144
|
-
* Set migration flag after successful completion
|
|
4145
|
-
* @param migrationType Type of migration completed
|
|
4146
|
-
* @param migratedCount Number of records migrated
|
|
4147
|
-
*/
|
|
4148
|
-
private setMigrationFlag;
|
|
4149
|
-
/**
|
|
4150
|
-
* Migrate agent history schema to add userId and conversationId columns
|
|
4151
|
-
*/
|
|
4152
|
-
private migrateAgentHistorySchema;
|
|
4153
|
-
storeWorkflowHistory(entry: any): Promise<void>;
|
|
4154
|
-
getWorkflowHistory(id: string): Promise<any>;
|
|
4155
|
-
getWorkflowHistoryByWorkflowId(workflowId: string): Promise<any[]>;
|
|
4156
|
-
updateWorkflowHistory(id: string, updates: any): Promise<void>;
|
|
4157
|
-
deleteWorkflowHistory(id: string): Promise<void>;
|
|
4158
|
-
storeWorkflowStep(step: any): Promise<void>;
|
|
4159
|
-
getWorkflowStep(id: string): Promise<any>;
|
|
4160
|
-
getWorkflowSteps(workflowHistoryId: string): Promise<any[]>;
|
|
4161
|
-
updateWorkflowStep(id: string, updates: any): Promise<void>;
|
|
4162
|
-
deleteWorkflowStep(id: string): Promise<void>;
|
|
4163
|
-
storeWorkflowTimelineEvent(event: any): Promise<void>;
|
|
4164
|
-
getWorkflowTimelineEvent(id: string): Promise<any>;
|
|
4165
|
-
getWorkflowTimelineEvents(workflowHistoryId: string): Promise<any[]>;
|
|
4166
|
-
deleteWorkflowTimelineEvent(id: string): Promise<void>;
|
|
4167
|
-
getAllWorkflowIds(): Promise<string[]>;
|
|
4168
|
-
getWorkflowStats(workflowId: string): Promise<any>;
|
|
4169
|
-
getWorkflowHistoryWithStepsAndEvents(id: string): Promise<any>;
|
|
4170
|
-
deleteWorkflowHistoryWithRelated(id: string): Promise<void>;
|
|
4171
|
-
cleanupOldWorkflowHistories(workflowId: string, maxEntries: number): Promise<number>;
|
|
4172
|
-
/**
|
|
4173
|
-
* Get the workflow extension for advanced workflow operations
|
|
4174
|
-
*/
|
|
4175
|
-
getWorkflowExtension(): LibSQLWorkflowExtension;
|
|
4176
|
-
}
|
|
4177
|
-
|
|
4178
3654
|
/**
|
|
4179
3655
|
* Manager class to handle all memory-related operations
|
|
4180
3656
|
*/
|
|
@@ -5443,7 +4919,7 @@ declare function andWorkflow<INPUT, DATA, RESULT, SUSPEND_DATA = any, RESUME_DAT
|
|
|
5443
4919
|
* purpose: "Process user data and generate personalized content",
|
|
5444
4920
|
* input: z.object({ userId: z.string(), userType: z.enum(["admin", "user"]) }),
|
|
5445
4921
|
* result: z.object({ processed: z.boolean(), content: z.string() }),
|
|
5446
|
-
* memory: new
|
|
4922
|
+
* memory: new InMemoryStorage() // Optional workflow-specific memory
|
|
5447
4923
|
* },
|
|
5448
4924
|
* andThen({
|
|
5449
4925
|
* id: "fetch-user",
|
|
@@ -5474,7 +4950,7 @@ declare function andWorkflow<INPUT, DATA, RESULT, SUSPEND_DATA = any, RESUME_DAT
|
|
|
5474
4950
|
* // Run with optional memory override
|
|
5475
4951
|
* const result = await workflow.run(
|
|
5476
4952
|
* { userId: "123", userType: "admin" },
|
|
5477
|
-
* { memory: new
|
|
4953
|
+
* { memory: new InMemoryStorage() }
|
|
5478
4954
|
* );
|
|
5479
4955
|
* ```
|
|
5480
4956
|
*
|
|
@@ -6389,8 +5865,8 @@ declare const ReasoningStepSchema: z.ZodObject<{
|
|
|
6389
5865
|
id: string;
|
|
6390
5866
|
title: string;
|
|
6391
5867
|
agentId: string;
|
|
6392
|
-
reasoning: string;
|
|
6393
5868
|
timestamp: string;
|
|
5869
|
+
reasoning: string;
|
|
6394
5870
|
historyEntryId: string;
|
|
6395
5871
|
confidence: number;
|
|
6396
5872
|
result?: string | undefined;
|
|
@@ -6401,8 +5877,8 @@ declare const ReasoningStepSchema: z.ZodObject<{
|
|
|
6401
5877
|
id: string;
|
|
6402
5878
|
title: string;
|
|
6403
5879
|
agentId: string;
|
|
6404
|
-
reasoning: string;
|
|
6405
5880
|
timestamp: string;
|
|
5881
|
+
reasoning: string;
|
|
6406
5882
|
historyEntryId: string;
|
|
6407
5883
|
result?: string | undefined;
|
|
6408
5884
|
action?: string | undefined;
|
|
@@ -7745,4 +7221,4 @@ declare class VoltAgent {
|
|
|
7745
7221
|
shutdownTelemetry(): Promise<void>;
|
|
7746
7222
|
}
|
|
7747
7223
|
|
|
7748
|
-
export { type AbortError, Agent, type AgentErrorEvent, AgentEventEmitter, type AgentHistoryEntry, type AgentHookOnEnd, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, type AgentHookOnStart, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStartEvent, type AgentStartEventMetadata, type AgentSuccessEvent, type AgentSuccessEventMetadata, type AgentTimelineEvent, type AgentTool, type AllowedVariableValue, type AnyToolConfig, type BaseEventMetadata, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTimelineEvent, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, type ClientInfo, type Conversation, type ConversationQueryOptions, type CreateConversationInput, type CreateReasoningToolsOptions, type CustomEndpointDefinition, CustomEndpointError, type CustomEndpointHandler, DEFAULT_INSTRUCTIONS, type DataContent, type DynamicValue, type DynamicValueOptions, type ErrorStreamPart, type EventStatus, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type FilePart, type FinishStreamPart, type GenerateObjectOptions, type GenerateTextOptions, type HTTPServerConfig, type HistoryStatus, type HttpMethod, type VoltOpsClient$1 as IVoltOpsClient, type ImagePart, InMemoryStorage, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider,
|
|
7224
|
+
export { type AbortError, Agent, type AgentErrorEvent, AgentEventEmitter, type AgentHistoryEntry, type AgentHookOnEnd, type AgentHookOnHandoff, type AgentHookOnPrepareMessages, type AgentHookOnStart, type AgentHookOnToolEnd, type AgentHookOnToolStart, type AgentHooks, type AgentOptions, AgentRegistry, type AgentResponse, type AgentStartEvent, type AgentStartEventMetadata, type AgentSuccessEvent, type AgentSuccessEventMetadata, type AgentTimelineEvent, type AgentTool, type AllowedVariableValue, type AnyToolConfig, type BaseEventMetadata, type BaseLLMOptions, type BaseMessage, BaseRetriever, type BaseTimelineEvent, type BaseTool, type BaseToolCall, type CachedPrompt, type ChatMessage, type ClientInfo, type Conversation, type ConversationQueryOptions, type CreateConversationInput, type CreateReasoningToolsOptions, type CustomEndpointDefinition, CustomEndpointError, type CustomEndpointHandler, DEFAULT_INSTRUCTIONS, type DataContent, type DynamicValue, type DynamicValueOptions, type ErrorStreamPart, type EventStatus, type ExtractVariableNames, FEW_SHOT_EXAMPLES, type FilePart, type FinishStreamPart, type GenerateObjectOptions, type GenerateTextOptions, type HTTPServerConfig, type HistoryStatus, type HttpMethod, type VoltOpsClient$1 as IVoltOpsClient, type ImagePart, InMemoryStorage, type InferGenerateObjectResponse, type InferGenerateTextResponse, type InferMessage, type InferModel, type InferProviderParams, type InferStreamResponse, type InferTool, type LLMProvider, MCPClient, type MCPClientConfig, type MCPClientEvents, MCPConfiguration, type MCPOptions, type MCPServerConfig, type MCPToolCall, type MCPToolResult, type Memory, type MemoryEventMetadata, MemoryManager, type MemoryMessage, type MemoryOptions, type MemoryReadErrorEvent, type MemoryReadStartEvent, type MemoryReadSuccessEvent, type MemoryWriteErrorEvent, type MemoryWriteStartEvent, type MemoryWriteSuccessEvent, type MessageContent, MessageContentBuilder, type MessageFilterOptions, type MessageRole, type ModelToolCall, type NewTimelineEvent, NextAction, NodeType, type ObjectSubAgentConfig, type OnEndHookArgs, type OnHandoffHookArgs, type OnPrepareMessagesHookArgs, type OnPrepareMessagesHookResult, type OnStartHookArgs, type OnToolEndHookArgs, type OnToolStartHookArgs, type OperationContext, type PackageUpdateInfo, type PromptApiClient, type PromptApiResponse, type PromptContent, type PromptCreator, type PromptHelper, type PromptReference, type PromptTemplate, type ProviderObjectResponse, type ProviderObjectStreamResponse, type ProviderParams, type ProviderResponse, type ProviderTextResponse, type ProviderTextStreamResponse, type ReadableStreamType, type ReasoningStep, ReasoningStepSchema, type ReasoningStreamPart, type ReasoningToolExecuteOptions, type RetrieveOptions, type Retriever, type RetrieverErrorEvent, type RetrieverOptions, type RetrieverStartEvent, type RetrieverSuccessEvent, type SSEServerConfig, type ServerOptions, type SourceStreamPart, type StandardEventData, type StandardTimelineEvent, type StdioServerConfig, type StepChunkCallback, type StepFinishCallback, type StepWithContent, type StreamEventForwarderOptions, type StreamObjectFinishResult, type StreamObjectOnFinishCallback, type StreamObjectOptions, type StreamPart, type StreamTextFinishResult, type StreamTextOnFinishCallback, type StreamTextOptions, type StreamableHTTPServerConfig, type SubAgentConfig, type SubAgentConfigObject, type SubAgentMethod, type TemplateVariables, type TextDeltaStreamPart, type TextPart, type TextSubAgentConfig, type TimelineEventCoreLevel, type TimelineEventCoreStatus, type TimelineEventCoreType, Tool, type ToolCall, type ToolCallStreamPart, type ToolErrorEvent, type ToolErrorInfo, type ToolExecuteOptions, type ToolExecutionContext, ToolManager, type ToolOptions, type ToolResultStreamPart, type ToolSchema, type ToolStartEvent, type ToolStatus, type ToolStatusInfo, type ToolSuccessEvent, type Toolkit, type ToolsetMap, type ToolsetWithTools, type TransportError, type Usage, type UsageInfo, type Voice, type VoiceEventData, type VoiceEventType, type VoiceMetadata, type VoiceOptions, VoltAgent, type VoltAgentError, VoltAgentExporter, type VoltAgentExporterOptions, type VoltAgentOptions, VoltOpsClient, type VoltOpsClientOptions, VoltOpsPromptApiClient, type VoltOpsPromptManager, VoltOpsPromptManagerImpl, type Workflow, type WorkflowConfig, type WorkflowErrorEvent, type WorkflowEvent, WorkflowEventEmitter, type WorkflowEventMetadata, type WorkflowExecutionContext, type WorkflowHistoryEntry, WorkflowRegistry, type WorkflowStartEvent, type WorkflowStats, type WorkflowStepContext, type WorkflowStepErrorEvent, type WorkflowStepEventMetadata, type WorkflowStepHistoryEntry, type WorkflowStepStartEvent, type WorkflowStepSuccessEvent, type WorkflowStepSuspendEvent, type WorkflowStepType, type WorkflowSuccessEvent, type WorkflowSuspendEvent, type WorkflowTimelineEvent$1 as WorkflowTimelineEvent, addTimestampToMessage, andAgent, andAll, andRace, andTap, andThen, andWhen, andWorkflow, appendToMessage, buildRetrieverLogMessage, checkForUpdates, createHooks, createNodeId, createPrompt, createReasoningTools, createRetrieverTool, createSimpleTemplateEngine, createStreamEventForwarder, createSubagent, createSuspendController, createTool, createToolkit, createVoltOpsClient, createWorkflow, createWorkflowChain, createWorkflowStepNodeId, VoltAgent as default, extractFileParts, extractImageParts, extractText, extractTextParts, extractWorkflowStepInfo, filterContentParts, getContentLength, getNodeTypeFromNodeId, getWorkflowStepNodeType, hasContent, hasFilePart, hasImagePart, hasTextPart, isAbortError, isStructuredContent, isTextContent, isVoltAgentError, mapMessageContent, messageHelpers, normalizeContent, normalizeToArray, prependToMessage, registerCustomEndpoint, registerCustomEndpoints, safeJsonParse, serializeValueForDebug, streamEventForwarder, tool, transformTextContent, updateAllPackages, updateSinglePackage, zodSchemaToJsonUI };
|