@o-zakstam/voltagent-convex 1.1.1 → 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.
Files changed (96) hide show
  1. package/dist/client/defineVoltAgentAPI.d.ts +191 -0
  2. package/dist/client/defineVoltAgentAPI.d.ts.map +1 -0
  3. package/dist/client/defineVoltAgentAPI.js +318 -0
  4. package/dist/client/defineVoltAgentAPI.js.map +1 -0
  5. package/dist/client/index.d.ts +6 -563
  6. package/dist/client/index.d.ts.map +1 -0
  7. package/dist/client/index.js +8 -285
  8. package/dist/client/index.js.map +1 -1
  9. package/dist/client/types.d.ts +13 -0
  10. package/dist/client/types.d.ts.map +1 -0
  11. package/dist/client/types.js +8 -0
  12. package/dist/client/types.js.map +1 -0
  13. package/dist/component/_generated/api.d.ts +44 -0
  14. package/dist/component/_generated/api.d.ts.map +1 -0
  15. package/dist/component/_generated/api.js +31 -0
  16. package/dist/component/_generated/api.js.map +1 -0
  17. package/dist/component/_generated/component.d.ts +352 -0
  18. package/dist/component/_generated/component.d.ts.map +1 -0
  19. package/dist/component/_generated/component.js +11 -0
  20. package/dist/component/_generated/component.js.map +1 -0
  21. package/dist/component/_generated/dataModel.d.ts +46 -0
  22. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  23. package/dist/component/_generated/dataModel.js +11 -0
  24. package/dist/component/_generated/dataModel.js.map +1 -0
  25. package/dist/component/_generated/server.d.ts +121 -0
  26. package/dist/component/_generated/server.d.ts.map +1 -0
  27. package/dist/component/_generated/server.js +78 -0
  28. package/dist/component/_generated/server.js.map +1 -0
  29. package/dist/component/conversations.d.ts +108 -0
  30. package/dist/component/conversations.d.ts.map +1 -0
  31. package/dist/component/conversations.js +278 -0
  32. package/dist/component/conversations.js.map +1 -0
  33. package/dist/component/convex.config.d.ts +13 -0
  34. package/dist/component/convex.config.d.ts.map +1 -0
  35. package/dist/component/convex.config.js +21 -0
  36. package/dist/component/convex.config.js.map +1 -0
  37. package/dist/component/messages.d.ts +235 -0
  38. package/dist/component/messages.d.ts.map +1 -0
  39. package/dist/component/messages.js +186 -0
  40. package/dist/component/messages.js.map +1 -0
  41. package/dist/component/schema.d.ts +535 -0
  42. package/dist/component/schema.d.ts.map +1 -0
  43. package/dist/component/schema.js +113 -0
  44. package/dist/component/schema.js.map +1 -0
  45. package/dist/component/steps.d.ts +65 -0
  46. package/dist/component/steps.d.ts.map +1 -0
  47. package/dist/component/steps.js +120 -0
  48. package/dist/component/steps.js.map +1 -0
  49. package/dist/component/validators.d.ts +633 -0
  50. package/dist/component/validators.d.ts.map +1 -0
  51. package/dist/component/validators.js +124 -0
  52. package/dist/component/validators.js.map +1 -0
  53. package/dist/component/workflows.d.ts +234 -0
  54. package/dist/component/workflows.d.ts.map +1 -0
  55. package/dist/component/workflows.js +229 -0
  56. package/dist/component/workflows.js.map +1 -0
  57. package/dist/component/workingMemory.d.ts +30 -0
  58. package/dist/component/workingMemory.d.ts.map +1 -0
  59. package/dist/component/workingMemory.js +131 -0
  60. package/dist/component/workingMemory.js.map +1 -0
  61. package/dist/index.d.ts +7 -318
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +10 -434
  64. package/dist/index.js.map +1 -1
  65. package/dist/memory-adapter.d.ts +153 -0
  66. package/dist/memory-adapter.d.ts.map +1 -0
  67. package/dist/memory-adapter.js +462 -0
  68. package/dist/memory-adapter.js.map +1 -0
  69. package/dist/types.d.ts +167 -0
  70. package/dist/types.d.ts.map +1 -0
  71. package/dist/types.js +5 -0
  72. package/dist/types.js.map +1 -0
  73. package/package.json +25 -26
  74. package/src/client/defineVoltAgentAPI.ts +365 -0
  75. package/src/client/index.ts +8 -0
  76. package/src/client/types.ts +14 -0
  77. package/src/component/_generated/api.ts +60 -0
  78. package/src/component/_generated/component.ts +466 -0
  79. package/src/component/_generated/dataModel.ts +60 -0
  80. package/src/component/_generated/server.ts +156 -0
  81. package/src/index.ts +24 -0
  82. package/{dist/index.cjs → src/memory-adapter.ts} +345 -106
  83. package/src/types.ts +178 -0
  84. package/dist/client/index.cjs +0 -288
  85. package/dist/client/index.cjs.map +0 -1
  86. package/dist/client/index.d.cts +0 -566
  87. package/dist/index.cjs.map +0 -1
  88. package/dist/index.d.cts +0 -322
  89. /package/{convex → src/component}/conversations.ts +0 -0
  90. /package/{convex → src/component}/convex.config.ts +0 -0
  91. /package/{convex → src/component}/messages.ts +0 -0
  92. /package/{convex → src/component}/schema.ts +0 -0
  93. /package/{convex → src/component}/steps.ts +0 -0
  94. /package/{convex → src/component}/validators.ts +0 -0
  95. /package/{convex → src/component}/workflows.ts +0 -0
  96. /package/{convex → src/component}/workingMemory.ts +0 -0
package/dist/index.d.cts DELETED
@@ -1,322 +0,0 @@
1
- import { StorageAdapter, OperationContext, GetMessagesOptions, ConversationStepRecord, GetConversationStepsOptions, CreateConversationInput, Conversation, ConversationQueryOptions, WorkingMemoryScope, WorkflowStateEntry } from '@voltagent/core';
2
- import { UIMessage } from 'ai';
3
-
4
- /**
5
- * Type definitions for VoltAgent Convex Memory Adapter
6
- */
7
- /**
8
- * Logger interface for the adapter
9
- */
10
- interface Logger {
11
- debug: (message: string, ...args: unknown[]) => void;
12
- info: (message: string, ...args: unknown[]) => void;
13
- warn: (message: string, ...args: unknown[]) => void;
14
- error: (message: string, ...args: unknown[]) => void;
15
- }
16
- /**
17
- * Convex client interface - compatible with ConvexHttpClient and ConvexReactClient.
18
- *
19
- * This interface is intentionally loose to accommodate different Convex client
20
- * implementations (ConvexHttpClient, ConvexReactClient) which have slightly
21
- * different method signatures.
22
- */
23
- interface ConvexClient {
24
- query: (functionReference: any, ...args: any[]) => Promise<any>;
25
- mutation: (functionReference: any, ...args: any[]) => Promise<any>;
26
- }
27
- /**
28
- * The VoltAgent API structure.
29
- * This matches the wrapper functions exported from the convex/api.ts file.
30
- */
31
- interface VoltAgentApi {
32
- createConversation: unknown;
33
- getConversation: unknown;
34
- getConversations: unknown;
35
- getConversationsByUserId: unknown;
36
- queryConversations: unknown;
37
- updateConversation: unknown;
38
- deleteConversation: unknown;
39
- addMessage: unknown;
40
- addMessages: unknown;
41
- getMessages: unknown;
42
- clearMessages: unknown;
43
- saveConversationSteps: unknown;
44
- getConversationSteps: unknown;
45
- getWorkingMemory: unknown;
46
- setWorkingMemory: unknown;
47
- deleteWorkingMemory: unknown;
48
- getWorkflowState: unknown;
49
- queryWorkflowRuns: unknown;
50
- setWorkflowState: unknown;
51
- updateWorkflowState: unknown;
52
- getSuspendedWorkflowStates: unknown;
53
- }
54
- /**
55
- * Configuration options for ConvexMemoryAdapter
56
- */
57
- interface ConvexMemoryAdapterOptions {
58
- /**
59
- * The Convex client instance to use for queries and mutations.
60
- * Can be a ConvexHttpClient or ConvexReactClient.
61
- */
62
- client: ConvexClient;
63
- /**
64
- * Whether to enable debug logging.
65
- * @default false
66
- */
67
- debug?: boolean;
68
- /**
69
- * Custom logger instance.
70
- * If not provided, a default console logger will be used when debug is enabled.
71
- */
72
- logger?: Logger;
73
- /**
74
- * The VoltAgent API from your Convex generated code.
75
- *
76
- * After adding the voltagent.ts file to your convex folder that re-exports
77
- * the wrapper functions, import the api and pass api.voltagent here.
78
- *
79
- * @example
80
- * ```ts
81
- * import { api } from "./convex/_generated/api";
82
- *
83
- * const adapter = new ConvexMemoryAdapter({
84
- * client,
85
- * api: api.voltagent,
86
- * });
87
- * ```
88
- */
89
- api: VoltAgentApi;
90
- }
91
- /**
92
- * Internal representation of a conversation in Convex
93
- */
94
- interface ConvexConversation {
95
- _id: string;
96
- visibleId: string;
97
- resourceId: string;
98
- userId: string;
99
- title: string;
100
- metadata: Record<string, unknown>;
101
- createdAt: string;
102
- updatedAt: string;
103
- }
104
- /**
105
- * Internal representation of a message in Convex
106
- */
107
- interface ConvexMessage {
108
- _id: string;
109
- visibleId: string;
110
- conversationId: string;
111
- userId: string;
112
- role: string;
113
- parts: unknown[];
114
- metadata?: Record<string, unknown>;
115
- createdAt: string;
116
- }
117
- /**
118
- * Internal representation of a user in Convex
119
- */
120
- interface ConvexUser {
121
- _id: string;
122
- visibleId: string;
123
- metadata?: Record<string, unknown>;
124
- createdAt: string;
125
- updatedAt: string;
126
- }
127
- /**
128
- * Internal representation of a workflow state in Convex
129
- */
130
- interface ConvexWorkflowState {
131
- _id: string;
132
- visibleId: string;
133
- workflowId: string;
134
- workflowName: string;
135
- status: string;
136
- input?: unknown;
137
- context?: unknown;
138
- suspension?: unknown;
139
- events?: unknown[];
140
- output?: unknown;
141
- cancellation?: unknown;
142
- userId?: string;
143
- conversationId?: string;
144
- metadata?: Record<string, unknown>;
145
- createdAt: string;
146
- updatedAt: string;
147
- }
148
- /**
149
- * Internal representation of a conversation step in Convex
150
- */
151
- interface ConvexConversationStep {
152
- _id: string;
153
- visibleId: string;
154
- conversationId: string;
155
- userId: string;
156
- agentId: string;
157
- agentName?: string;
158
- operationId?: string;
159
- stepIndex: number;
160
- type: string;
161
- role: string;
162
- content?: string;
163
- arguments?: Record<string, unknown>;
164
- result?: Record<string, unknown>;
165
- usage?: Record<string, unknown>;
166
- subAgentId?: string;
167
- subAgentName?: string;
168
- createdAt: string;
169
- }
170
-
171
- /**
172
- * Convex Memory Adapter for VoltAgent
173
- *
174
- * A StorageAdapter implementation that persists conversation data
175
- * to Convex database using the VoltAgent Convex component.
176
- */
177
-
178
- /**
179
- * Convex Memory Adapter for VoltAgent
180
- *
181
- * Implements the StorageAdapter interface to persist conversation history,
182
- * working memory, and workflow state to a Convex database.
183
- *
184
- * @example
185
- * ```ts
186
- * import { ConvexHttpClient } from "convex/browser";
187
- * import { api } from "./convex/_generated/api";
188
- * import { ConvexMemoryAdapter } from "@voltagent/convex";
189
- *
190
- * const client = new ConvexHttpClient(process.env.CONVEX_URL);
191
- *
192
- * const adapter = new ConvexMemoryAdapter({
193
- * client,
194
- * api: api.voltagent,
195
- * });
196
- *
197
- * const memory = new Memory({ storage: adapter });
198
- * ```
199
- */
200
- declare class ConvexMemoryAdapter implements StorageAdapter {
201
- private client;
202
- private api;
203
- private debug;
204
- private logger;
205
- constructor(options: ConvexMemoryAdapterOptions);
206
- /**
207
- * Log debug messages
208
- */
209
- private log;
210
- /**
211
- * Generate a cryptographically secure random ID
212
- */
213
- private generateId;
214
- /**
215
- * Add a single message to a conversation
216
- */
217
- addMessage(message: UIMessage, userId: string, conversationId: string, _context?: OperationContext): Promise<void>;
218
- /**
219
- * Add multiple messages to a conversation
220
- */
221
- addMessages(messages: UIMessage[], userId: string, conversationId: string, _context?: OperationContext): Promise<void>;
222
- /**
223
- * Get messages from a conversation with optional filtering
224
- */
225
- getMessages(userId: string, conversationId: string, options?: GetMessagesOptions, _context?: OperationContext): Promise<UIMessage<{
226
- createdAt: Date;
227
- }>[]>;
228
- /**
229
- * Clear messages for a user (optionally for a specific conversation)
230
- */
231
- clearMessages(userId: string, conversationId?: string, _context?: OperationContext): Promise<void>;
232
- /**
233
- * Save conversation steps for observability
234
- */
235
- saveConversationSteps(steps: ConversationStepRecord[]): Promise<void>;
236
- /**
237
- * Get conversation steps for observability
238
- */
239
- getConversationSteps(userId: string, conversationId: string, options?: GetConversationStepsOptions): Promise<ConversationStepRecord[]>;
240
- /**
241
- * Create a new conversation
242
- */
243
- createConversation(input: CreateConversationInput): Promise<Conversation>;
244
- /**
245
- * Get a conversation by ID
246
- */
247
- getConversation(id: string): Promise<Conversation | null>;
248
- /**
249
- * Get conversations by resource ID
250
- */
251
- getConversations(resourceId: string): Promise<Conversation[]>;
252
- /**
253
- * Get conversations by user ID with optional query options
254
- */
255
- getConversationsByUserId(userId: string, options?: Omit<ConversationQueryOptions, "userId">): Promise<Conversation[]>;
256
- /**
257
- * Query conversations with filters
258
- */
259
- queryConversations(options: ConversationQueryOptions): Promise<Conversation[]>;
260
- /**
261
- * Update a conversation
262
- */
263
- updateConversation(id: string, updates: Partial<Omit<Conversation, "id" | "createdAt" | "updatedAt">>): Promise<Conversation>;
264
- /**
265
- * Delete a conversation and its associated data
266
- */
267
- deleteConversation(id: string): Promise<void>;
268
- /**
269
- * Get working memory content
270
- */
271
- getWorkingMemory(params: {
272
- conversationId?: string;
273
- userId?: string;
274
- scope: WorkingMemoryScope;
275
- }): Promise<string | null>;
276
- /**
277
- * Set working memory content
278
- */
279
- setWorkingMemory(params: {
280
- conversationId?: string;
281
- userId?: string;
282
- content: string;
283
- scope: WorkingMemoryScope;
284
- }): Promise<void>;
285
- /**
286
- * Delete working memory content
287
- */
288
- deleteWorkingMemory(params: {
289
- conversationId?: string;
290
- userId?: string;
291
- scope: WorkingMemoryScope;
292
- }): Promise<void>;
293
- /**
294
- * Get workflow state by execution ID
295
- */
296
- getWorkflowState(executionId: string): Promise<WorkflowStateEntry | null>;
297
- /**
298
- * Query workflow runs with optional filters
299
- */
300
- queryWorkflowRuns(query: {
301
- workflowId?: string;
302
- status?: WorkflowStateEntry["status"];
303
- from?: Date;
304
- to?: Date;
305
- limit?: number;
306
- offset?: number;
307
- }): Promise<WorkflowStateEntry[]>;
308
- /**
309
- * Set workflow state
310
- */
311
- setWorkflowState(executionId: string, state: WorkflowStateEntry): Promise<void>;
312
- /**
313
- * Update workflow state
314
- */
315
- updateWorkflowState(executionId: string, updates: Partial<WorkflowStateEntry>): Promise<void>;
316
- /**
317
- * Get suspended workflow states for a workflow
318
- */
319
- getSuspendedWorkflowStates(workflowId: string): Promise<WorkflowStateEntry[]>;
320
- }
321
-
322
- export { type ConvexClient, type ConvexConversation, type ConvexConversationStep, ConvexMemoryAdapter, type ConvexMemoryAdapterOptions, type ConvexMessage, type ConvexUser, type ConvexWorkflowState, type Logger, type VoltAgentApi };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes