@voltagent/libsql 1.0.13 → 1.1.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/dist/edge.d.mts +111 -0
- package/dist/edge.d.ts +111 -0
- package/dist/edge.js +2183 -0
- package/dist/edge.js.map +1 -0
- package/dist/edge.mjs +2155 -0
- package/dist/edge.mjs.map +1 -0
- package/dist/index.d.mts +24 -380
- package/dist/index.d.ts +24 -380
- package/dist/index.js +263 -337
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +262 -340
- package/dist/index.mjs.map +1 -1
- package/dist/vector-core-CKn8FNVK.d.mts +274 -0
- package/dist/vector-core-CKn8FNVK.d.ts +274 -0
- package/package.json +12 -2
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { Client } from '@libsql/client';
|
|
2
|
+
import { StorageAdapter, ConversationStepRecord, GetMessagesOptions, GetConversationStepsOptions, CreateConversationInput, Conversation, ConversationQueryOptions, WorkingMemoryScope, WorkflowStateEntry, ObservabilityStorageAdapter, ObservabilitySpan, ObservabilityLogRecord, LogFilter, VectorAdapter, VectorItem, VectorSearchOptions, SearchResult } from '@voltagent/core';
|
|
3
|
+
import { Logger } from '@voltagent/logger';
|
|
4
|
+
import { UIMessage } from 'ai';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* LibSQL Memory Adapter Core
|
|
8
|
+
* Contains shared logic for both Node.js and Edge environments
|
|
9
|
+
* Environment-specific adapters extend this class
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Core configuration options for LibSQL Memory adapter
|
|
14
|
+
*/
|
|
15
|
+
interface LibSQLMemoryCoreOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Prefix for table names
|
|
18
|
+
* @default "voltagent_memory"
|
|
19
|
+
*/
|
|
20
|
+
tablePrefix?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum number of retries for database operations
|
|
23
|
+
* @default 3
|
|
24
|
+
*/
|
|
25
|
+
maxRetries?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Initial retry delay in milliseconds
|
|
28
|
+
* @default 100
|
|
29
|
+
*/
|
|
30
|
+
retryDelayMs?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* LibSQL Memory Adapter Core
|
|
34
|
+
* Implements all storage operations, receives client via dependency injection
|
|
35
|
+
*/
|
|
36
|
+
declare class LibSQLMemoryCore implements StorageAdapter {
|
|
37
|
+
protected client: Client;
|
|
38
|
+
protected tablePrefix: string;
|
|
39
|
+
protected initialized: boolean;
|
|
40
|
+
protected logger: Logger;
|
|
41
|
+
protected maxRetries: number;
|
|
42
|
+
protected retryDelayMs: number;
|
|
43
|
+
protected url: string;
|
|
44
|
+
constructor(client: Client, url: string, options: LibSQLMemoryCoreOptions, logger: Logger);
|
|
45
|
+
/**
|
|
46
|
+
* Execute a database operation with retry logic
|
|
47
|
+
*/
|
|
48
|
+
protected executeWithRetry<T>(operation: () => Promise<T>, operationName: string): Promise<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Initialize database schema
|
|
51
|
+
*/
|
|
52
|
+
protected initialize(): Promise<void>;
|
|
53
|
+
private addV2ColumnsToMessagesTable;
|
|
54
|
+
private migrateDefaultUserIds;
|
|
55
|
+
private addWorkflowStateColumns;
|
|
56
|
+
addMessage(message: UIMessage, userId: string, conversationId: string): Promise<void>;
|
|
57
|
+
addMessages(messages: UIMessage[], userId: string, conversationId: string): Promise<void>;
|
|
58
|
+
saveConversationSteps(steps: ConversationStepRecord[]): Promise<void>;
|
|
59
|
+
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions): Promise<UIMessage<{
|
|
60
|
+
createdAt: Date;
|
|
61
|
+
}>[]>;
|
|
62
|
+
getConversationSteps(userId: string, conversationId: string, options?: GetConversationStepsOptions): Promise<ConversationStepRecord[]>;
|
|
63
|
+
clearMessages(userId: string, conversationId?: string): Promise<void>;
|
|
64
|
+
createConversation(input: CreateConversationInput): Promise<Conversation>;
|
|
65
|
+
getConversation(id: string): Promise<Conversation | null>;
|
|
66
|
+
getConversations(resourceId: string): Promise<Conversation[]>;
|
|
67
|
+
getConversationsByUserId(userId: string, options?: Omit<ConversationQueryOptions, "userId">): Promise<Conversation[]>;
|
|
68
|
+
queryConversations(options: ConversationQueryOptions): Promise<Conversation[]>;
|
|
69
|
+
updateConversation(id: string, updates: Partial<Omit<Conversation, "id" | "createdAt" | "updatedAt">>): Promise<Conversation>;
|
|
70
|
+
deleteConversation(id: string): Promise<void>;
|
|
71
|
+
getWorkingMemory(params: {
|
|
72
|
+
conversationId?: string;
|
|
73
|
+
userId?: string;
|
|
74
|
+
scope: WorkingMemoryScope;
|
|
75
|
+
}): Promise<string | null>;
|
|
76
|
+
setWorkingMemory(params: {
|
|
77
|
+
conversationId?: string;
|
|
78
|
+
userId?: string;
|
|
79
|
+
content: string;
|
|
80
|
+
scope: WorkingMemoryScope;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
deleteWorkingMemory(params: {
|
|
83
|
+
conversationId?: string;
|
|
84
|
+
userId?: string;
|
|
85
|
+
scope: WorkingMemoryScope;
|
|
86
|
+
}): Promise<void>;
|
|
87
|
+
getWorkflowState(executionId: string): Promise<WorkflowStateEntry | null>;
|
|
88
|
+
queryWorkflowRuns(query: {
|
|
89
|
+
workflowId?: string;
|
|
90
|
+
status?: WorkflowStateEntry["status"];
|
|
91
|
+
from?: Date;
|
|
92
|
+
to?: Date;
|
|
93
|
+
limit?: number;
|
|
94
|
+
offset?: number;
|
|
95
|
+
}): Promise<WorkflowStateEntry[]>;
|
|
96
|
+
setWorkflowState(executionId: string, state: WorkflowStateEntry): Promise<void>;
|
|
97
|
+
updateWorkflowState(executionId: string, updates: Partial<WorkflowStateEntry>): Promise<void>;
|
|
98
|
+
getSuspendedWorkflowStates(workflowId: string): Promise<WorkflowStateEntry[]>;
|
|
99
|
+
close(): Promise<void>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* LibSQL Observability Adapter Core
|
|
104
|
+
* Contains shared logic for both Node.js and Edge environments
|
|
105
|
+
* Environment-specific adapters extend this class
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Core configuration options for LibSQL Observability adapter
|
|
110
|
+
*/
|
|
111
|
+
interface LibSQLObservabilityCoreOptions {
|
|
112
|
+
/**
|
|
113
|
+
* Prefix for table names
|
|
114
|
+
* @default "observability"
|
|
115
|
+
*/
|
|
116
|
+
tablePrefix?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Whether to enable debug logging
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
debug?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Maximum number of spans to return in a single query
|
|
124
|
+
* @default 1000
|
|
125
|
+
*/
|
|
126
|
+
maxSpansPerQuery?: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* LibSQL Observability Adapter Core
|
|
130
|
+
* Implements all observability storage operations, receives client via dependency injection
|
|
131
|
+
*/
|
|
132
|
+
declare class LibSQLObservabilityCore implements ObservabilityStorageAdapter {
|
|
133
|
+
protected client: Client;
|
|
134
|
+
protected tablePrefix: string;
|
|
135
|
+
protected debug: boolean;
|
|
136
|
+
protected logger: Logger;
|
|
137
|
+
protected initialized: Promise<void>;
|
|
138
|
+
protected maxSpansPerQuery: number;
|
|
139
|
+
constructor(client: Client, options: LibSQLObservabilityCoreOptions, logger: Logger);
|
|
140
|
+
protected debugLog(message: string, data?: unknown): void;
|
|
141
|
+
private initializeDatabase;
|
|
142
|
+
protected ensureInitialized(): Promise<void>;
|
|
143
|
+
addSpan(span: ObservabilitySpan): Promise<void>;
|
|
144
|
+
updateSpan(spanId: string, updates: Partial<ObservabilitySpan>): Promise<void>;
|
|
145
|
+
getSpan(spanId: string): Promise<ObservabilitySpan | null>;
|
|
146
|
+
getTrace(traceId: string): Promise<ObservabilitySpan[]>;
|
|
147
|
+
listTraces(limit?: number, offset?: number, filter?: {
|
|
148
|
+
entityId?: string;
|
|
149
|
+
entityType?: "agent" | "workflow";
|
|
150
|
+
}): Promise<string[]>;
|
|
151
|
+
deleteOldSpans(beforeTimestamp: number): Promise<number>;
|
|
152
|
+
clear(): Promise<void>;
|
|
153
|
+
private rowToSpan;
|
|
154
|
+
getStats(): Promise<{
|
|
155
|
+
spanCount: number;
|
|
156
|
+
traceCount: number;
|
|
157
|
+
oldestSpan?: Date;
|
|
158
|
+
newestSpan?: Date;
|
|
159
|
+
}>;
|
|
160
|
+
saveLogRecord(logRecord: any): Promise<void>;
|
|
161
|
+
getLogsByTraceId(traceId: string): Promise<ObservabilityLogRecord[]>;
|
|
162
|
+
getLogsBySpanId(spanId: string): Promise<ObservabilityLogRecord[]>;
|
|
163
|
+
queryLogs(filter: LogFilter): Promise<ObservabilityLogRecord[]>;
|
|
164
|
+
deleteOldLogs(beforeTimestamp: number): Promise<number>;
|
|
165
|
+
private rowToLogRecord;
|
|
166
|
+
getInfo(): {
|
|
167
|
+
adapter: string;
|
|
168
|
+
displayName: string;
|
|
169
|
+
persistent: boolean;
|
|
170
|
+
description: string;
|
|
171
|
+
};
|
|
172
|
+
close(): Promise<void>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* LibSQL Vector Adapter Core
|
|
177
|
+
* Contains shared logic for both Node.js and Edge environments
|
|
178
|
+
* Environment-specific adapters extend this class
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Core configuration options for LibSQL Vector adapter
|
|
183
|
+
*/
|
|
184
|
+
interface LibSQLVectorCoreOptions {
|
|
185
|
+
/**
|
|
186
|
+
* Prefix for table names
|
|
187
|
+
* @default "voltagent"
|
|
188
|
+
*/
|
|
189
|
+
tablePrefix?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Maximum vector dimensions allowed
|
|
192
|
+
* @default 1536
|
|
193
|
+
*/
|
|
194
|
+
maxVectorDimensions?: number;
|
|
195
|
+
/**
|
|
196
|
+
* Size of the LRU cache for frequently accessed vectors
|
|
197
|
+
* @default 100
|
|
198
|
+
*/
|
|
199
|
+
cacheSize?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Batch size for bulk operations
|
|
202
|
+
* @default 100
|
|
203
|
+
*/
|
|
204
|
+
batchSize?: number;
|
|
205
|
+
/**
|
|
206
|
+
* Enable debug logging
|
|
207
|
+
* @default false
|
|
208
|
+
*/
|
|
209
|
+
debug?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Maximum number of retries for database operations
|
|
212
|
+
* @default 3
|
|
213
|
+
*/
|
|
214
|
+
maxRetries?: number;
|
|
215
|
+
/**
|
|
216
|
+
* Initial retry delay in milliseconds
|
|
217
|
+
* @default 100
|
|
218
|
+
*/
|
|
219
|
+
retryDelayMs?: number;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* LibSQL Vector Adapter Core
|
|
223
|
+
* Implements all vector storage operations, receives client via dependency injection
|
|
224
|
+
*/
|
|
225
|
+
declare class LibSQLVectorCore implements VectorAdapter {
|
|
226
|
+
protected client: Client;
|
|
227
|
+
protected tablePrefix: string;
|
|
228
|
+
protected maxVectorDimensions: number;
|
|
229
|
+
protected cacheSize: number;
|
|
230
|
+
protected batchSize: number;
|
|
231
|
+
protected debug: boolean;
|
|
232
|
+
protected logger: Logger;
|
|
233
|
+
protected maxRetries: number;
|
|
234
|
+
protected retryDelayMs: number;
|
|
235
|
+
protected initialized: boolean;
|
|
236
|
+
protected vectorCache: Map<string, VectorItem>;
|
|
237
|
+
protected dimensions: number | null;
|
|
238
|
+
constructor(client: Client, options: LibSQLVectorCoreOptions, logger: Logger);
|
|
239
|
+
/**
|
|
240
|
+
* Serialize a vector to binary format
|
|
241
|
+
* Uses ArrayBuffer/DataView for cross-platform compatibility
|
|
242
|
+
*/
|
|
243
|
+
protected serializeVector(vector: number[]): Uint8Array;
|
|
244
|
+
/**
|
|
245
|
+
* Deserialize a vector from binary format
|
|
246
|
+
*/
|
|
247
|
+
protected deserializeVector(data: Uint8Array | ArrayBuffer): number[];
|
|
248
|
+
/**
|
|
249
|
+
* Initialize the database schema
|
|
250
|
+
*/
|
|
251
|
+
protected initialize(): Promise<void>;
|
|
252
|
+
/**
|
|
253
|
+
* Execute a database operation with retries
|
|
254
|
+
*/
|
|
255
|
+
protected executeWithRetry<T>(operation: () => Promise<T>, context: string): Promise<T>;
|
|
256
|
+
store(id: string, vector: number[], metadata?: Record<string, unknown>): Promise<void>;
|
|
257
|
+
storeBatch(items: VectorItem[]): Promise<void>;
|
|
258
|
+
search(queryVector: number[], options?: VectorSearchOptions): Promise<SearchResult[]>;
|
|
259
|
+
private matchesFilter;
|
|
260
|
+
delete(id: string): Promise<void>;
|
|
261
|
+
deleteBatch(ids: string[]): Promise<void>;
|
|
262
|
+
clear(): Promise<void>;
|
|
263
|
+
count(): Promise<number>;
|
|
264
|
+
get(id: string): Promise<VectorItem | null>;
|
|
265
|
+
close(): Promise<void>;
|
|
266
|
+
getStats(): Promise<{
|
|
267
|
+
count: number;
|
|
268
|
+
dimensions: number | null;
|
|
269
|
+
cacheSize: number;
|
|
270
|
+
tableSizeBytes: number;
|
|
271
|
+
}>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export { LibSQLMemoryCore as L, type LibSQLMemoryCoreOptions as a, LibSQLObservabilityCore as b, type LibSQLObservabilityCoreOptions as c, LibSQLVectorCore as d, type LibSQLVectorCoreOptions as e };
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { Client } from '@libsql/client';
|
|
2
|
+
import { StorageAdapter, ConversationStepRecord, GetMessagesOptions, GetConversationStepsOptions, CreateConversationInput, Conversation, ConversationQueryOptions, WorkingMemoryScope, WorkflowStateEntry, ObservabilityStorageAdapter, ObservabilitySpan, ObservabilityLogRecord, LogFilter, VectorAdapter, VectorItem, VectorSearchOptions, SearchResult } from '@voltagent/core';
|
|
3
|
+
import { Logger } from '@voltagent/logger';
|
|
4
|
+
import { UIMessage } from 'ai';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* LibSQL Memory Adapter Core
|
|
8
|
+
* Contains shared logic for both Node.js and Edge environments
|
|
9
|
+
* Environment-specific adapters extend this class
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Core configuration options for LibSQL Memory adapter
|
|
14
|
+
*/
|
|
15
|
+
interface LibSQLMemoryCoreOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Prefix for table names
|
|
18
|
+
* @default "voltagent_memory"
|
|
19
|
+
*/
|
|
20
|
+
tablePrefix?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum number of retries for database operations
|
|
23
|
+
* @default 3
|
|
24
|
+
*/
|
|
25
|
+
maxRetries?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Initial retry delay in milliseconds
|
|
28
|
+
* @default 100
|
|
29
|
+
*/
|
|
30
|
+
retryDelayMs?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* LibSQL Memory Adapter Core
|
|
34
|
+
* Implements all storage operations, receives client via dependency injection
|
|
35
|
+
*/
|
|
36
|
+
declare class LibSQLMemoryCore implements StorageAdapter {
|
|
37
|
+
protected client: Client;
|
|
38
|
+
protected tablePrefix: string;
|
|
39
|
+
protected initialized: boolean;
|
|
40
|
+
protected logger: Logger;
|
|
41
|
+
protected maxRetries: number;
|
|
42
|
+
protected retryDelayMs: number;
|
|
43
|
+
protected url: string;
|
|
44
|
+
constructor(client: Client, url: string, options: LibSQLMemoryCoreOptions, logger: Logger);
|
|
45
|
+
/**
|
|
46
|
+
* Execute a database operation with retry logic
|
|
47
|
+
*/
|
|
48
|
+
protected executeWithRetry<T>(operation: () => Promise<T>, operationName: string): Promise<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Initialize database schema
|
|
51
|
+
*/
|
|
52
|
+
protected initialize(): Promise<void>;
|
|
53
|
+
private addV2ColumnsToMessagesTable;
|
|
54
|
+
private migrateDefaultUserIds;
|
|
55
|
+
private addWorkflowStateColumns;
|
|
56
|
+
addMessage(message: UIMessage, userId: string, conversationId: string): Promise<void>;
|
|
57
|
+
addMessages(messages: UIMessage[], userId: string, conversationId: string): Promise<void>;
|
|
58
|
+
saveConversationSteps(steps: ConversationStepRecord[]): Promise<void>;
|
|
59
|
+
getMessages(userId: string, conversationId: string, options?: GetMessagesOptions): Promise<UIMessage<{
|
|
60
|
+
createdAt: Date;
|
|
61
|
+
}>[]>;
|
|
62
|
+
getConversationSteps(userId: string, conversationId: string, options?: GetConversationStepsOptions): Promise<ConversationStepRecord[]>;
|
|
63
|
+
clearMessages(userId: string, conversationId?: string): Promise<void>;
|
|
64
|
+
createConversation(input: CreateConversationInput): Promise<Conversation>;
|
|
65
|
+
getConversation(id: string): Promise<Conversation | null>;
|
|
66
|
+
getConversations(resourceId: string): Promise<Conversation[]>;
|
|
67
|
+
getConversationsByUserId(userId: string, options?: Omit<ConversationQueryOptions, "userId">): Promise<Conversation[]>;
|
|
68
|
+
queryConversations(options: ConversationQueryOptions): Promise<Conversation[]>;
|
|
69
|
+
updateConversation(id: string, updates: Partial<Omit<Conversation, "id" | "createdAt" | "updatedAt">>): Promise<Conversation>;
|
|
70
|
+
deleteConversation(id: string): Promise<void>;
|
|
71
|
+
getWorkingMemory(params: {
|
|
72
|
+
conversationId?: string;
|
|
73
|
+
userId?: string;
|
|
74
|
+
scope: WorkingMemoryScope;
|
|
75
|
+
}): Promise<string | null>;
|
|
76
|
+
setWorkingMemory(params: {
|
|
77
|
+
conversationId?: string;
|
|
78
|
+
userId?: string;
|
|
79
|
+
content: string;
|
|
80
|
+
scope: WorkingMemoryScope;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
deleteWorkingMemory(params: {
|
|
83
|
+
conversationId?: string;
|
|
84
|
+
userId?: string;
|
|
85
|
+
scope: WorkingMemoryScope;
|
|
86
|
+
}): Promise<void>;
|
|
87
|
+
getWorkflowState(executionId: string): Promise<WorkflowStateEntry | null>;
|
|
88
|
+
queryWorkflowRuns(query: {
|
|
89
|
+
workflowId?: string;
|
|
90
|
+
status?: WorkflowStateEntry["status"];
|
|
91
|
+
from?: Date;
|
|
92
|
+
to?: Date;
|
|
93
|
+
limit?: number;
|
|
94
|
+
offset?: number;
|
|
95
|
+
}): Promise<WorkflowStateEntry[]>;
|
|
96
|
+
setWorkflowState(executionId: string, state: WorkflowStateEntry): Promise<void>;
|
|
97
|
+
updateWorkflowState(executionId: string, updates: Partial<WorkflowStateEntry>): Promise<void>;
|
|
98
|
+
getSuspendedWorkflowStates(workflowId: string): Promise<WorkflowStateEntry[]>;
|
|
99
|
+
close(): Promise<void>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* LibSQL Observability Adapter Core
|
|
104
|
+
* Contains shared logic for both Node.js and Edge environments
|
|
105
|
+
* Environment-specific adapters extend this class
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Core configuration options for LibSQL Observability adapter
|
|
110
|
+
*/
|
|
111
|
+
interface LibSQLObservabilityCoreOptions {
|
|
112
|
+
/**
|
|
113
|
+
* Prefix for table names
|
|
114
|
+
* @default "observability"
|
|
115
|
+
*/
|
|
116
|
+
tablePrefix?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Whether to enable debug logging
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
debug?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Maximum number of spans to return in a single query
|
|
124
|
+
* @default 1000
|
|
125
|
+
*/
|
|
126
|
+
maxSpansPerQuery?: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* LibSQL Observability Adapter Core
|
|
130
|
+
* Implements all observability storage operations, receives client via dependency injection
|
|
131
|
+
*/
|
|
132
|
+
declare class LibSQLObservabilityCore implements ObservabilityStorageAdapter {
|
|
133
|
+
protected client: Client;
|
|
134
|
+
protected tablePrefix: string;
|
|
135
|
+
protected debug: boolean;
|
|
136
|
+
protected logger: Logger;
|
|
137
|
+
protected initialized: Promise<void>;
|
|
138
|
+
protected maxSpansPerQuery: number;
|
|
139
|
+
constructor(client: Client, options: LibSQLObservabilityCoreOptions, logger: Logger);
|
|
140
|
+
protected debugLog(message: string, data?: unknown): void;
|
|
141
|
+
private initializeDatabase;
|
|
142
|
+
protected ensureInitialized(): Promise<void>;
|
|
143
|
+
addSpan(span: ObservabilitySpan): Promise<void>;
|
|
144
|
+
updateSpan(spanId: string, updates: Partial<ObservabilitySpan>): Promise<void>;
|
|
145
|
+
getSpan(spanId: string): Promise<ObservabilitySpan | null>;
|
|
146
|
+
getTrace(traceId: string): Promise<ObservabilitySpan[]>;
|
|
147
|
+
listTraces(limit?: number, offset?: number, filter?: {
|
|
148
|
+
entityId?: string;
|
|
149
|
+
entityType?: "agent" | "workflow";
|
|
150
|
+
}): Promise<string[]>;
|
|
151
|
+
deleteOldSpans(beforeTimestamp: number): Promise<number>;
|
|
152
|
+
clear(): Promise<void>;
|
|
153
|
+
private rowToSpan;
|
|
154
|
+
getStats(): Promise<{
|
|
155
|
+
spanCount: number;
|
|
156
|
+
traceCount: number;
|
|
157
|
+
oldestSpan?: Date;
|
|
158
|
+
newestSpan?: Date;
|
|
159
|
+
}>;
|
|
160
|
+
saveLogRecord(logRecord: any): Promise<void>;
|
|
161
|
+
getLogsByTraceId(traceId: string): Promise<ObservabilityLogRecord[]>;
|
|
162
|
+
getLogsBySpanId(spanId: string): Promise<ObservabilityLogRecord[]>;
|
|
163
|
+
queryLogs(filter: LogFilter): Promise<ObservabilityLogRecord[]>;
|
|
164
|
+
deleteOldLogs(beforeTimestamp: number): Promise<number>;
|
|
165
|
+
private rowToLogRecord;
|
|
166
|
+
getInfo(): {
|
|
167
|
+
adapter: string;
|
|
168
|
+
displayName: string;
|
|
169
|
+
persistent: boolean;
|
|
170
|
+
description: string;
|
|
171
|
+
};
|
|
172
|
+
close(): Promise<void>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* LibSQL Vector Adapter Core
|
|
177
|
+
* Contains shared logic for both Node.js and Edge environments
|
|
178
|
+
* Environment-specific adapters extend this class
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Core configuration options for LibSQL Vector adapter
|
|
183
|
+
*/
|
|
184
|
+
interface LibSQLVectorCoreOptions {
|
|
185
|
+
/**
|
|
186
|
+
* Prefix for table names
|
|
187
|
+
* @default "voltagent"
|
|
188
|
+
*/
|
|
189
|
+
tablePrefix?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Maximum vector dimensions allowed
|
|
192
|
+
* @default 1536
|
|
193
|
+
*/
|
|
194
|
+
maxVectorDimensions?: number;
|
|
195
|
+
/**
|
|
196
|
+
* Size of the LRU cache for frequently accessed vectors
|
|
197
|
+
* @default 100
|
|
198
|
+
*/
|
|
199
|
+
cacheSize?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Batch size for bulk operations
|
|
202
|
+
* @default 100
|
|
203
|
+
*/
|
|
204
|
+
batchSize?: number;
|
|
205
|
+
/**
|
|
206
|
+
* Enable debug logging
|
|
207
|
+
* @default false
|
|
208
|
+
*/
|
|
209
|
+
debug?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Maximum number of retries for database operations
|
|
212
|
+
* @default 3
|
|
213
|
+
*/
|
|
214
|
+
maxRetries?: number;
|
|
215
|
+
/**
|
|
216
|
+
* Initial retry delay in milliseconds
|
|
217
|
+
* @default 100
|
|
218
|
+
*/
|
|
219
|
+
retryDelayMs?: number;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* LibSQL Vector Adapter Core
|
|
223
|
+
* Implements all vector storage operations, receives client via dependency injection
|
|
224
|
+
*/
|
|
225
|
+
declare class LibSQLVectorCore implements VectorAdapter {
|
|
226
|
+
protected client: Client;
|
|
227
|
+
protected tablePrefix: string;
|
|
228
|
+
protected maxVectorDimensions: number;
|
|
229
|
+
protected cacheSize: number;
|
|
230
|
+
protected batchSize: number;
|
|
231
|
+
protected debug: boolean;
|
|
232
|
+
protected logger: Logger;
|
|
233
|
+
protected maxRetries: number;
|
|
234
|
+
protected retryDelayMs: number;
|
|
235
|
+
protected initialized: boolean;
|
|
236
|
+
protected vectorCache: Map<string, VectorItem>;
|
|
237
|
+
protected dimensions: number | null;
|
|
238
|
+
constructor(client: Client, options: LibSQLVectorCoreOptions, logger: Logger);
|
|
239
|
+
/**
|
|
240
|
+
* Serialize a vector to binary format
|
|
241
|
+
* Uses ArrayBuffer/DataView for cross-platform compatibility
|
|
242
|
+
*/
|
|
243
|
+
protected serializeVector(vector: number[]): Uint8Array;
|
|
244
|
+
/**
|
|
245
|
+
* Deserialize a vector from binary format
|
|
246
|
+
*/
|
|
247
|
+
protected deserializeVector(data: Uint8Array | ArrayBuffer): number[];
|
|
248
|
+
/**
|
|
249
|
+
* Initialize the database schema
|
|
250
|
+
*/
|
|
251
|
+
protected initialize(): Promise<void>;
|
|
252
|
+
/**
|
|
253
|
+
* Execute a database operation with retries
|
|
254
|
+
*/
|
|
255
|
+
protected executeWithRetry<T>(operation: () => Promise<T>, context: string): Promise<T>;
|
|
256
|
+
store(id: string, vector: number[], metadata?: Record<string, unknown>): Promise<void>;
|
|
257
|
+
storeBatch(items: VectorItem[]): Promise<void>;
|
|
258
|
+
search(queryVector: number[], options?: VectorSearchOptions): Promise<SearchResult[]>;
|
|
259
|
+
private matchesFilter;
|
|
260
|
+
delete(id: string): Promise<void>;
|
|
261
|
+
deleteBatch(ids: string[]): Promise<void>;
|
|
262
|
+
clear(): Promise<void>;
|
|
263
|
+
count(): Promise<number>;
|
|
264
|
+
get(id: string): Promise<VectorItem | null>;
|
|
265
|
+
close(): Promise<void>;
|
|
266
|
+
getStats(): Promise<{
|
|
267
|
+
count: number;
|
|
268
|
+
dimensions: number | null;
|
|
269
|
+
cacheSize: number;
|
|
270
|
+
tableSizeBytes: number;
|
|
271
|
+
}>;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export { LibSQLMemoryCore as L, type LibSQLMemoryCoreOptions as a, LibSQLObservabilityCore as b, type LibSQLObservabilityCoreOptions as c, LibSQLVectorCore as d, type LibSQLVectorCoreOptions as e };
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltagent/libsql",
|
|
3
3
|
"description": "VoltAgent LibSQL - LibSQL/Turso Memory provider integration for VoltAgent",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@libsql/client": "^0.15.0",
|
|
7
7
|
"@voltagent/internal": "^0.0.12"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@vitest/coverage-v8": "^3.2.4",
|
|
11
|
-
"@voltagent/core": "^1.2
|
|
11
|
+
"@voltagent/core": "^1.5.2",
|
|
12
12
|
"@voltagent/logger": "^1.0.3",
|
|
13
13
|
"ai": "^5.0.76"
|
|
14
14
|
},
|
|
@@ -22,6 +22,16 @@
|
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
23
|
"default": "./dist/index.js"
|
|
24
24
|
}
|
|
25
|
+
},
|
|
26
|
+
"./edge": {
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./dist/edge.d.mts",
|
|
29
|
+
"default": "./dist/edge.mjs"
|
|
30
|
+
},
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./dist/edge.d.ts",
|
|
33
|
+
"default": "./dist/edge.js"
|
|
34
|
+
}
|
|
25
35
|
}
|
|
26
36
|
},
|
|
27
37
|
"files": [
|