@o-zakstam/voltagent-convex 1.1.2 → 1.1.3
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/client/{index.d.cts → defineVoltAgentAPI.d.ts} +59 -92
- package/dist/client/defineVoltAgentAPI.d.ts.map +1 -0
- package/dist/client/defineVoltAgentAPI.js +318 -0
- package/dist/client/defineVoltAgentAPI.js.map +1 -0
- package/dist/client/index.d.ts +6 -221
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +8 -285
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts +13 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +8 -0
- package/dist/client/types.js.map +1 -0
- package/dist/component/_generated/api.d.ts +44 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +352 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/conversations.d.ts +108 -0
- package/dist/component/conversations.d.ts.map +1 -0
- package/dist/component/conversations.js +278 -0
- package/dist/component/conversations.js.map +1 -0
- package/dist/component/convex.config.d.ts +13 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +21 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/messages.d.ts +235 -0
- package/dist/component/messages.d.ts.map +1 -0
- package/dist/component/messages.js +186 -0
- package/dist/component/messages.js.map +1 -0
- package/dist/component/schema.d.ts +535 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +113 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/steps.d.ts +65 -0
- package/dist/component/steps.d.ts.map +1 -0
- package/dist/component/steps.js +120 -0
- package/dist/component/steps.js.map +1 -0
- package/dist/component/validators.d.ts +633 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +124 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/component/workflows.d.ts +234 -0
- package/dist/component/workflows.d.ts.map +1 -0
- package/dist/component/workflows.js +229 -0
- package/dist/component/workflows.js.map +1 -0
- package/dist/component/workingMemory.d.ts +30 -0
- package/dist/component/workingMemory.d.ts.map +1 -0
- package/dist/component/workingMemory.js +131 -0
- package/dist/component/workingMemory.js.map +1 -0
- package/dist/index.d.ts +7 -318
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -434
- package/dist/index.js.map +1 -1
- package/dist/memory-adapter.d.ts +153 -0
- package/dist/memory-adapter.d.ts.map +1 -0
- package/dist/memory-adapter.js +462 -0
- package/dist/memory-adapter.js.map +1 -0
- package/dist/types.d.ts +167 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +25 -26
- package/src/client/defineVoltAgentAPI.ts +365 -0
- package/src/client/index.ts +8 -0
- package/src/client/types.ts +14 -0
- package/src/component/_generated/api.ts +60 -0
- package/src/component/_generated/component.ts +466 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/index.ts +24 -0
- package/{dist/index.cjs → src/memory-adapter.ts} +345 -106
- package/src/types.ts +178 -0
- package/dist/client/index.cjs +0 -288
- package/dist/client/index.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -322
- /package/{convex → src/component}/conversations.ts +0 -0
- /package/{convex → src/component}/convex.config.ts +0 -0
- /package/{convex → src/component}/messages.ts +0 -0
- /package/{convex → src/component}/schema.ts +0 -0
- /package/{convex → src/component}/steps.ts +0 -0
- /package/{convex → src/component}/validators.ts +0 -0
- /package/{convex → src/component}/workflows.ts +0 -0
- /package/{convex → src/component}/workingMemory.ts +0 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convex Memory Adapter for VoltAgent
|
|
3
|
+
*
|
|
4
|
+
* A StorageAdapter implementation that persists conversation data
|
|
5
|
+
* to Convex database using the VoltAgent Convex component.
|
|
6
|
+
*/
|
|
7
|
+
import { ConversationAlreadyExistsError, ConversationNotFoundError, } from "@voltagent/core";
|
|
8
|
+
/**
|
|
9
|
+
* Default console logger implementation
|
|
10
|
+
*/
|
|
11
|
+
const defaultLogger = {
|
|
12
|
+
debug: (message, ...args) => console.debug(`[ConvexMemory] ${message}`, ...args),
|
|
13
|
+
info: (message, ...args) => console.info(`[ConvexMemory] ${message}`, ...args),
|
|
14
|
+
warn: (message, ...args) => console.warn(`[ConvexMemory] ${message}`, ...args),
|
|
15
|
+
error: (message, ...args) => console.error(`[ConvexMemory] ${message}`, ...args),
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Convex Memory Adapter for VoltAgent
|
|
19
|
+
*
|
|
20
|
+
* Implements the StorageAdapter interface to persist conversation history,
|
|
21
|
+
* working memory, and workflow state to a Convex database.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { ConvexHttpClient } from "convex/browser";
|
|
26
|
+
* import { api } from "./convex/_generated/api";
|
|
27
|
+
* import { ConvexMemoryAdapter } from "@voltagent/convex";
|
|
28
|
+
*
|
|
29
|
+
* const client = new ConvexHttpClient(process.env.CONVEX_URL);
|
|
30
|
+
*
|
|
31
|
+
* const adapter = new ConvexMemoryAdapter({
|
|
32
|
+
* client,
|
|
33
|
+
* api: api.voltagent,
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* const memory = new Memory({ storage: adapter });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export class ConvexMemoryAdapter {
|
|
40
|
+
client;
|
|
41
|
+
api;
|
|
42
|
+
debug;
|
|
43
|
+
logger;
|
|
44
|
+
constructor(options) {
|
|
45
|
+
if (!options.client) {
|
|
46
|
+
throw new Error("Convex client is required");
|
|
47
|
+
}
|
|
48
|
+
if (!options.api) {
|
|
49
|
+
throw new Error("Convex API is required");
|
|
50
|
+
}
|
|
51
|
+
this.client = options.client;
|
|
52
|
+
this.api = options.api;
|
|
53
|
+
this.debug = options.debug ?? false;
|
|
54
|
+
this.logger = options.logger ?? defaultLogger;
|
|
55
|
+
this.log("Convex Memory adapter initialized");
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Log debug messages
|
|
59
|
+
*/
|
|
60
|
+
log(message, ...args) {
|
|
61
|
+
if (this.debug) {
|
|
62
|
+
this.logger.debug(message, ...args);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Generate a cryptographically secure random ID
|
|
67
|
+
*/
|
|
68
|
+
generateId() {
|
|
69
|
+
return crypto.randomUUID();
|
|
70
|
+
}
|
|
71
|
+
// ============================================================================
|
|
72
|
+
// Message Operations
|
|
73
|
+
// ============================================================================
|
|
74
|
+
/**
|
|
75
|
+
* Add a single message to a conversation
|
|
76
|
+
*/
|
|
77
|
+
async addMessage(message, userId, conversationId, _context) {
|
|
78
|
+
await this.client.mutation(this.api.addMessage, {
|
|
79
|
+
id: message.id || this.generateId(),
|
|
80
|
+
conversationId,
|
|
81
|
+
userId,
|
|
82
|
+
role: message.role,
|
|
83
|
+
parts: message.parts,
|
|
84
|
+
metadata: message.metadata || null,
|
|
85
|
+
});
|
|
86
|
+
this.log(`Added message to conversation ${conversationId}`);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Add multiple messages to a conversation
|
|
90
|
+
*/
|
|
91
|
+
async addMessages(messages, userId, conversationId, _context) {
|
|
92
|
+
const messagesToAdd = messages.map((message) => ({
|
|
93
|
+
id: message.id || this.generateId(),
|
|
94
|
+
conversationId,
|
|
95
|
+
userId,
|
|
96
|
+
role: message.role,
|
|
97
|
+
parts: message.parts,
|
|
98
|
+
metadata: message.metadata || null,
|
|
99
|
+
}));
|
|
100
|
+
await this.client.mutation(this.api.addMessages, {
|
|
101
|
+
messages: messagesToAdd,
|
|
102
|
+
});
|
|
103
|
+
this.log(`Added ${messages.length} messages to conversation ${conversationId}`);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get messages from a conversation with optional filtering
|
|
107
|
+
*/
|
|
108
|
+
async getMessages(userId, conversationId, options, _context) {
|
|
109
|
+
const { limit, before, after, roles } = options || {};
|
|
110
|
+
const messages = await this.client.query(this.api.getMessages, {
|
|
111
|
+
userId,
|
|
112
|
+
conversationId,
|
|
113
|
+
limit,
|
|
114
|
+
before: before?.toISOString(),
|
|
115
|
+
after: after?.toISOString(),
|
|
116
|
+
roles,
|
|
117
|
+
});
|
|
118
|
+
return messages.map((msg) => ({
|
|
119
|
+
id: msg.id,
|
|
120
|
+
role: msg.role,
|
|
121
|
+
parts: msg.parts,
|
|
122
|
+
metadata: {
|
|
123
|
+
...msg.metadata,
|
|
124
|
+
createdAt: msg.metadata?.createdAt
|
|
125
|
+
? new Date(msg.metadata.createdAt)
|
|
126
|
+
: new Date(),
|
|
127
|
+
},
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Clear messages for a user (optionally for a specific conversation)
|
|
132
|
+
*/
|
|
133
|
+
async clearMessages(userId, conversationId, _context) {
|
|
134
|
+
await this.client.mutation(this.api.clearMessages, {
|
|
135
|
+
userId,
|
|
136
|
+
conversationId,
|
|
137
|
+
});
|
|
138
|
+
this.log(`Cleared messages for user ${userId}`);
|
|
139
|
+
}
|
|
140
|
+
// ============================================================================
|
|
141
|
+
// Conversation Steps Operations
|
|
142
|
+
// ============================================================================
|
|
143
|
+
/**
|
|
144
|
+
* Save conversation steps for observability
|
|
145
|
+
*/
|
|
146
|
+
async saveConversationSteps(steps) {
|
|
147
|
+
if (steps.length === 0) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
await this.client.mutation(this.api.saveConversationSteps, {
|
|
151
|
+
steps: steps.map((step) => ({
|
|
152
|
+
id: step.id,
|
|
153
|
+
conversationId: step.conversationId,
|
|
154
|
+
userId: step.userId,
|
|
155
|
+
agentId: step.agentId,
|
|
156
|
+
agentName: step.agentName,
|
|
157
|
+
operationId: step.operationId,
|
|
158
|
+
stepIndex: step.stepIndex,
|
|
159
|
+
type: step.type,
|
|
160
|
+
role: step.role,
|
|
161
|
+
content: step.content,
|
|
162
|
+
arguments: step.arguments,
|
|
163
|
+
result: step.result,
|
|
164
|
+
usage: step.usage,
|
|
165
|
+
subAgentId: step.subAgentId,
|
|
166
|
+
subAgentName: step.subAgentName,
|
|
167
|
+
createdAt: step.createdAt,
|
|
168
|
+
})),
|
|
169
|
+
});
|
|
170
|
+
this.log(`Saved ${steps.length} conversation steps`);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get conversation steps for observability
|
|
174
|
+
*/
|
|
175
|
+
async getConversationSteps(userId, conversationId, options) {
|
|
176
|
+
const steps = await this.client.query(this.api.getConversationSteps, {
|
|
177
|
+
userId,
|
|
178
|
+
conversationId,
|
|
179
|
+
limit: options?.limit,
|
|
180
|
+
operationId: options?.operationId,
|
|
181
|
+
});
|
|
182
|
+
return steps;
|
|
183
|
+
}
|
|
184
|
+
// ============================================================================
|
|
185
|
+
// Conversation Operations
|
|
186
|
+
// ============================================================================
|
|
187
|
+
/**
|
|
188
|
+
* Create a new conversation
|
|
189
|
+
*/
|
|
190
|
+
async createConversation(input) {
|
|
191
|
+
try {
|
|
192
|
+
const result = await this.client.mutation(this.api.createConversation, {
|
|
193
|
+
id: input.id,
|
|
194
|
+
resourceId: input.resourceId,
|
|
195
|
+
userId: input.userId,
|
|
196
|
+
title: input.title,
|
|
197
|
+
metadata: input.metadata || {},
|
|
198
|
+
});
|
|
199
|
+
this.log(`Created conversation ${input.id}`);
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
if (error instanceof Error && error.message.includes("already exists")) {
|
|
204
|
+
throw new ConversationAlreadyExistsError(input.id);
|
|
205
|
+
}
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get a conversation by ID
|
|
211
|
+
*/
|
|
212
|
+
async getConversation(id) {
|
|
213
|
+
const conversation = await this.client.query(this.api.getConversation, {
|
|
214
|
+
id,
|
|
215
|
+
});
|
|
216
|
+
return conversation;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Get conversations by resource ID
|
|
220
|
+
*/
|
|
221
|
+
async getConversations(resourceId) {
|
|
222
|
+
const conversations = await this.client.query(this.api.getConversations, {
|
|
223
|
+
resourceId,
|
|
224
|
+
});
|
|
225
|
+
return conversations;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Get conversations by user ID with optional query options
|
|
229
|
+
*/
|
|
230
|
+
async getConversationsByUserId(userId, options) {
|
|
231
|
+
const conversations = await this.client.query(this.api.getConversationsByUserId, {
|
|
232
|
+
userId,
|
|
233
|
+
limit: options?.limit,
|
|
234
|
+
offset: options?.offset,
|
|
235
|
+
orderBy: options?.orderBy,
|
|
236
|
+
orderDirection: options?.orderDirection,
|
|
237
|
+
});
|
|
238
|
+
return conversations;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Query conversations with filters
|
|
242
|
+
*/
|
|
243
|
+
async queryConversations(options) {
|
|
244
|
+
const conversations = await this.client.query(this.api.queryConversations, {
|
|
245
|
+
userId: options.userId,
|
|
246
|
+
resourceId: options.resourceId,
|
|
247
|
+
limit: options.limit,
|
|
248
|
+
offset: options.offset,
|
|
249
|
+
orderBy: options.orderBy,
|
|
250
|
+
orderDirection: options.orderDirection,
|
|
251
|
+
});
|
|
252
|
+
return conversations;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Update a conversation
|
|
256
|
+
*/
|
|
257
|
+
async updateConversation(id, updates) {
|
|
258
|
+
try {
|
|
259
|
+
const result = await this.client.mutation(this.api.updateConversation, {
|
|
260
|
+
id,
|
|
261
|
+
title: updates.title,
|
|
262
|
+
resourceId: updates.resourceId,
|
|
263
|
+
metadata: updates.metadata,
|
|
264
|
+
});
|
|
265
|
+
this.log(`Updated conversation ${id}`);
|
|
266
|
+
return result;
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
if (error instanceof Error && error.message.includes("not found")) {
|
|
270
|
+
throw new ConversationNotFoundError(id);
|
|
271
|
+
}
|
|
272
|
+
throw error;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Delete a conversation and its associated data
|
|
277
|
+
*/
|
|
278
|
+
async deleteConversation(id) {
|
|
279
|
+
try {
|
|
280
|
+
await this.client.mutation(this.api.deleteConversation, { id });
|
|
281
|
+
this.log(`Deleted conversation ${id}`);
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
if (error instanceof Error && error.message.includes("not found")) {
|
|
285
|
+
throw new ConversationNotFoundError(id);
|
|
286
|
+
}
|
|
287
|
+
throw error;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// ============================================================================
|
|
291
|
+
// Working Memory Operations
|
|
292
|
+
// ============================================================================
|
|
293
|
+
/**
|
|
294
|
+
* Get working memory content
|
|
295
|
+
*/
|
|
296
|
+
async getWorkingMemory(params) {
|
|
297
|
+
const result = await this.client.query(this.api.getWorkingMemory, {
|
|
298
|
+
conversationId: params.conversationId,
|
|
299
|
+
userId: params.userId,
|
|
300
|
+
scope: params.scope,
|
|
301
|
+
});
|
|
302
|
+
return result;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Set working memory content
|
|
306
|
+
*/
|
|
307
|
+
async setWorkingMemory(params) {
|
|
308
|
+
try {
|
|
309
|
+
await this.client.mutation(this.api.setWorkingMemory, {
|
|
310
|
+
conversationId: params.conversationId,
|
|
311
|
+
userId: params.userId,
|
|
312
|
+
content: params.content,
|
|
313
|
+
scope: params.scope,
|
|
314
|
+
});
|
|
315
|
+
this.log(`Set working memory for ${params.scope}`);
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
if (error instanceof Error &&
|
|
319
|
+
error.message.includes("not found") &&
|
|
320
|
+
params.conversationId) {
|
|
321
|
+
throw new ConversationNotFoundError(params.conversationId);
|
|
322
|
+
}
|
|
323
|
+
throw error;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Delete working memory content
|
|
328
|
+
*/
|
|
329
|
+
async deleteWorkingMemory(params) {
|
|
330
|
+
await this.client.mutation(this.api.deleteWorkingMemory, {
|
|
331
|
+
conversationId: params.conversationId,
|
|
332
|
+
userId: params.userId,
|
|
333
|
+
scope: params.scope,
|
|
334
|
+
});
|
|
335
|
+
this.log(`Deleted working memory for ${params.scope}`);
|
|
336
|
+
}
|
|
337
|
+
// ============================================================================
|
|
338
|
+
// Workflow State Operations
|
|
339
|
+
// ============================================================================
|
|
340
|
+
/**
|
|
341
|
+
* Get workflow state by execution ID
|
|
342
|
+
*/
|
|
343
|
+
async getWorkflowState(executionId) {
|
|
344
|
+
const state = await this.client.query(this.api.getWorkflowState, {
|
|
345
|
+
executionId,
|
|
346
|
+
});
|
|
347
|
+
if (!state)
|
|
348
|
+
return null;
|
|
349
|
+
const typedState = state;
|
|
350
|
+
return {
|
|
351
|
+
id: typedState.id,
|
|
352
|
+
workflowId: typedState.workflowId,
|
|
353
|
+
workflowName: typedState.workflowName,
|
|
354
|
+
status: typedState.status,
|
|
355
|
+
input: typedState.input,
|
|
356
|
+
context: typedState.context,
|
|
357
|
+
suspension: typedState.suspension,
|
|
358
|
+
events: typedState.events,
|
|
359
|
+
output: typedState.output,
|
|
360
|
+
cancellation: typedState.cancellation,
|
|
361
|
+
userId: typedState.userId,
|
|
362
|
+
conversationId: typedState.conversationId,
|
|
363
|
+
metadata: typedState.metadata,
|
|
364
|
+
createdAt: new Date(typedState.createdAt),
|
|
365
|
+
updatedAt: new Date(typedState.updatedAt),
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Query workflow runs with optional filters
|
|
370
|
+
*/
|
|
371
|
+
async queryWorkflowRuns(query) {
|
|
372
|
+
const states = await this.client.query(this.api.queryWorkflowRuns, {
|
|
373
|
+
workflowId: query.workflowId,
|
|
374
|
+
status: query.status,
|
|
375
|
+
from: query.from?.toISOString(),
|
|
376
|
+
to: query.to?.toISOString(),
|
|
377
|
+
limit: query.limit,
|
|
378
|
+
offset: query.offset,
|
|
379
|
+
});
|
|
380
|
+
return states.map((s) => ({
|
|
381
|
+
id: s.id,
|
|
382
|
+
workflowId: s.workflowId,
|
|
383
|
+
workflowName: s.workflowName,
|
|
384
|
+
status: s.status,
|
|
385
|
+
input: s.input,
|
|
386
|
+
context: s.context,
|
|
387
|
+
suspension: s.suspension,
|
|
388
|
+
events: s.events,
|
|
389
|
+
output: s.output,
|
|
390
|
+
cancellation: s.cancellation,
|
|
391
|
+
userId: s.userId,
|
|
392
|
+
conversationId: s.conversationId,
|
|
393
|
+
metadata: s.metadata,
|
|
394
|
+
createdAt: new Date(s.createdAt),
|
|
395
|
+
updatedAt: new Date(s.updatedAt),
|
|
396
|
+
}));
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Set workflow state
|
|
400
|
+
*/
|
|
401
|
+
async setWorkflowState(executionId, state) {
|
|
402
|
+
await this.client.mutation(this.api.setWorkflowState, {
|
|
403
|
+
executionId,
|
|
404
|
+
workflowId: state.workflowId,
|
|
405
|
+
workflowName: state.workflowName,
|
|
406
|
+
status: state.status,
|
|
407
|
+
input: state.input,
|
|
408
|
+
context: state.context,
|
|
409
|
+
suspension: state.suspension,
|
|
410
|
+
events: state.events,
|
|
411
|
+
output: state.output,
|
|
412
|
+
cancellation: state.cancellation,
|
|
413
|
+
userId: state.userId,
|
|
414
|
+
conversationId: state.conversationId,
|
|
415
|
+
metadata: state.metadata,
|
|
416
|
+
createdAt: state.createdAt.toISOString(),
|
|
417
|
+
updatedAt: state.updatedAt.toISOString(),
|
|
418
|
+
});
|
|
419
|
+
this.log(`Set workflow state ${executionId}`);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Update workflow state
|
|
423
|
+
*/
|
|
424
|
+
async updateWorkflowState(executionId, updates) {
|
|
425
|
+
await this.client.mutation(this.api.updateWorkflowState, {
|
|
426
|
+
executionId,
|
|
427
|
+
status: updates.status,
|
|
428
|
+
suspension: updates.suspension,
|
|
429
|
+
events: updates.events,
|
|
430
|
+
output: updates.output,
|
|
431
|
+
cancellation: updates.cancellation,
|
|
432
|
+
metadata: updates.metadata,
|
|
433
|
+
});
|
|
434
|
+
this.log(`Updated workflow state ${executionId}`);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Get suspended workflow states for a workflow
|
|
438
|
+
*/
|
|
439
|
+
async getSuspendedWorkflowStates(workflowId) {
|
|
440
|
+
const states = await this.client.query(this.api.getSuspendedWorkflowStates, {
|
|
441
|
+
workflowId,
|
|
442
|
+
});
|
|
443
|
+
return states.map((s) => ({
|
|
444
|
+
id: s.id,
|
|
445
|
+
workflowId: s.workflowId,
|
|
446
|
+
workflowName: s.workflowName,
|
|
447
|
+
status: s.status,
|
|
448
|
+
input: s.input,
|
|
449
|
+
context: s.context,
|
|
450
|
+
suspension: s.suspension,
|
|
451
|
+
events: s.events,
|
|
452
|
+
output: s.output,
|
|
453
|
+
cancellation: s.cancellation,
|
|
454
|
+
userId: s.userId,
|
|
455
|
+
conversationId: s.conversationId,
|
|
456
|
+
metadata: s.metadata,
|
|
457
|
+
createdAt: new Date(s.createdAt),
|
|
458
|
+
updatedAt: new Date(s.updatedAt),
|
|
459
|
+
}));
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
//# sourceMappingURL=memory-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-adapter.js","sourceRoot":"","sources":["../src/memory-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AAqBzB;;GAEG;AACH,MAAM,aAAa,GAAW;IAC5B,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAC7C,OAAO,CAAC,KAAK,CAAC,kBAAkB,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC;IACrD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAC5C,OAAO,CAAC,IAAI,CAAC,kBAAkB,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC;IACpD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAC5C,OAAO,CAAC,IAAI,CAAC,kBAAkB,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC;IACpD,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAC7C,OAAO,CAAC,KAAK,CAAC,kBAAkB,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC;CACtD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAAe;IACrB,GAAG,CAAe;IAClB,KAAK,CAAU;IACf,MAAM,CAAS;IAEvB,YAAY,OAAmC;QAC7C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,C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B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CACpC,IAAI,CAAC,GAAG,CAAC,0BAA0B,EACnC;YACE,UAAU;SACX,CACF,CAAC;QAEF,OACE,MAiBD,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACZ,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,YAAY,EAAE,CAAC,CAAC,YAAY;YAC5B,MAAM,EAAE,CAAC,CAAC,MAAsC;YAChD,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,OAAO,EAAE,CAAC,CAAC,OAAwC;YACnD,UAAU,EAAE,CAAC,CAAC,UAA8C;YAC5D,MAAM,EAAE,CAAC,CAAC,MAAsC;YAChD,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,YAAY,EAAE,CAAC,CAAC,YAAkD;YAClE,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,cAAc,EAAE,CAAC,CAAC,cAAc;YAChC,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;YAChC,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;SACjC,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for VoltAgent Convex Memory Adapter
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Logger interface for the adapter
|
|
6
|
+
*/
|
|
7
|
+
export interface Logger {
|
|
8
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
9
|
+
info: (message: string, ...args: unknown[]) => void;
|
|
10
|
+
warn: (message: string, ...args: unknown[]) => void;
|
|
11
|
+
error: (message: string, ...args: unknown[]) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Convex client interface - compatible with ConvexHttpClient and ConvexReactClient.
|
|
15
|
+
*
|
|
16
|
+
* This interface is intentionally loose to accommodate different Convex client
|
|
17
|
+
* implementations (ConvexHttpClient, ConvexReactClient) which have slightly
|
|
18
|
+
* different method signatures.
|
|
19
|
+
*/
|
|
20
|
+
export interface ConvexClient {
|
|
21
|
+
query: (functionReference: any, ...args: any[]) => Promise<any>;
|
|
22
|
+
mutation: (functionReference: any, ...args: any[]) => Promise<any>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The VoltAgent API structure.
|
|
26
|
+
* This matches the wrapper functions exported from the convex/api.ts file.
|
|
27
|
+
*/
|
|
28
|
+
export interface VoltAgentApi {
|
|
29
|
+
createConversation: unknown;
|
|
30
|
+
getConversation: unknown;
|
|
31
|
+
getConversations: unknown;
|
|
32
|
+
getConversationsByUserId: unknown;
|
|
33
|
+
queryConversations: unknown;
|
|
34
|
+
updateConversation: unknown;
|
|
35
|
+
deleteConversation: unknown;
|
|
36
|
+
addMessage: unknown;
|
|
37
|
+
addMessages: unknown;
|
|
38
|
+
getMessages: unknown;
|
|
39
|
+
clearMessages: unknown;
|
|
40
|
+
saveConversationSteps: unknown;
|
|
41
|
+
getConversationSteps: unknown;
|
|
42
|
+
getWorkingMemory: unknown;
|
|
43
|
+
setWorkingMemory: unknown;
|
|
44
|
+
deleteWorkingMemory: unknown;
|
|
45
|
+
getWorkflowState: unknown;
|
|
46
|
+
queryWorkflowRuns: unknown;
|
|
47
|
+
setWorkflowState: unknown;
|
|
48
|
+
updateWorkflowState: unknown;
|
|
49
|
+
getSuspendedWorkflowStates: unknown;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Configuration options for ConvexMemoryAdapter
|
|
53
|
+
*/
|
|
54
|
+
export interface ConvexMemoryAdapterOptions {
|
|
55
|
+
/**
|
|
56
|
+
* The Convex client instance to use for queries and mutations.
|
|
57
|
+
* Can be a ConvexHttpClient or ConvexReactClient.
|
|
58
|
+
*/
|
|
59
|
+
client: ConvexClient;
|
|
60
|
+
/**
|
|
61
|
+
* Whether to enable debug logging.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
debug?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Custom logger instance.
|
|
67
|
+
* If not provided, a default console logger will be used when debug is enabled.
|
|
68
|
+
*/
|
|
69
|
+
logger?: Logger;
|
|
70
|
+
/**
|
|
71
|
+
* The VoltAgent API from your Convex generated code.
|
|
72
|
+
*
|
|
73
|
+
* After adding the voltagent.ts file to your convex folder that re-exports
|
|
74
|
+
* the wrapper functions, import the api and pass api.voltagent here.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { api } from "./convex/_generated/api";
|
|
79
|
+
*
|
|
80
|
+
* const adapter = new ConvexMemoryAdapter({
|
|
81
|
+
* client,
|
|
82
|
+
* api: api.voltagent,
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
api: VoltAgentApi;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Internal representation of a conversation in Convex
|
|
90
|
+
*/
|
|
91
|
+
export interface ConvexConversation {
|
|
92
|
+
_id: string;
|
|
93
|
+
visibleId: string;
|
|
94
|
+
resourceId: string;
|
|
95
|
+
userId: string;
|
|
96
|
+
title: string;
|
|
97
|
+
metadata: Record<string, unknown>;
|
|
98
|
+
createdAt: string;
|
|
99
|
+
updatedAt: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Internal representation of a message in Convex
|
|
103
|
+
*/
|
|
104
|
+
export interface ConvexMessage {
|
|
105
|
+
_id: string;
|
|
106
|
+
visibleId: string;
|
|
107
|
+
conversationId: string;
|
|
108
|
+
userId: string;
|
|
109
|
+
role: string;
|
|
110
|
+
parts: unknown[];
|
|
111
|
+
metadata?: Record<string, unknown>;
|
|
112
|
+
createdAt: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Internal representation of a user in Convex
|
|
116
|
+
*/
|
|
117
|
+
export interface ConvexUser {
|
|
118
|
+
_id: string;
|
|
119
|
+
visibleId: string;
|
|
120
|
+
metadata?: Record<string, unknown>;
|
|
121
|
+
createdAt: string;
|
|
122
|
+
updatedAt: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Internal representation of a workflow state in Convex
|
|
126
|
+
*/
|
|
127
|
+
export interface ConvexWorkflowState {
|
|
128
|
+
_id: string;
|
|
129
|
+
visibleId: string;
|
|
130
|
+
workflowId: string;
|
|
131
|
+
workflowName: string;
|
|
132
|
+
status: string;
|
|
133
|
+
input?: unknown;
|
|
134
|
+
context?: unknown;
|
|
135
|
+
suspension?: unknown;
|
|
136
|
+
events?: unknown[];
|
|
137
|
+
output?: unknown;
|
|
138
|
+
cancellation?: unknown;
|
|
139
|
+
userId?: string;
|
|
140
|
+
conversationId?: string;
|
|
141
|
+
metadata?: Record<string, unknown>;
|
|
142
|
+
createdAt: string;
|
|
143
|
+
updatedAt: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Internal representation of a conversation step in Convex
|
|
147
|
+
*/
|
|
148
|
+
export interface ConvexConversationStep {
|
|
149
|
+
_id: string;
|
|
150
|
+
visibleId: string;
|
|
151
|
+
conversationId: string;
|
|
152
|
+
userId: string;
|
|
153
|
+
agentId: string;
|
|
154
|
+
agentName?: string;
|
|
155
|
+
operationId?: string;
|
|
156
|
+
stepIndex: number;
|
|
157
|
+
type: string;
|
|
158
|
+
role: string;
|
|
159
|
+
content?: string;
|
|
160
|
+
arguments?: Record<string, unknown>;
|
|
161
|
+
result?: Record<string, unknown>;
|
|
162
|
+
usage?: Record<string, unknown>;
|
|
163
|
+
subAgentId?: string;
|
|
164
|
+
subAgentName?: string;
|
|
165
|
+
createdAt: string;
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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