@voltagent/libsql 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +6 -10
- package/dist/index.d.ts +6 -10
- package/dist/index.js +9 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,6 @@ var LibSQLMemoryAdapter = class {
|
|
|
17
17
|
__name(this, "LibSQLMemoryAdapter");
|
|
18
18
|
}
|
|
19
19
|
client;
|
|
20
|
-
storageLimit;
|
|
21
20
|
tablePrefix;
|
|
22
21
|
initialized = false;
|
|
23
22
|
logger;
|
|
@@ -25,7 +24,6 @@ var LibSQLMemoryAdapter = class {
|
|
|
25
24
|
retryDelayMs;
|
|
26
25
|
url;
|
|
27
26
|
constructor(options = {}) {
|
|
28
|
-
this.storageLimit = options.storageLimit ?? 100;
|
|
29
27
|
this.tablePrefix = options.tablePrefix ?? "voltagent_memory";
|
|
30
28
|
this.maxRetries = options.maxRetries ?? 3;
|
|
31
29
|
this.retryDelayMs = options.retryDelayMs ?? 100;
|
|
@@ -319,7 +317,6 @@ var LibSQLMemoryAdapter = class {
|
|
|
319
317
|
]
|
|
320
318
|
});
|
|
321
319
|
}, "add message");
|
|
322
|
-
await this.applyStorageLimit(conversationId);
|
|
323
320
|
}
|
|
324
321
|
/**
|
|
325
322
|
* Add multiple messages
|
|
@@ -351,26 +348,6 @@ var LibSQLMemoryAdapter = class {
|
|
|
351
348
|
}))
|
|
352
349
|
);
|
|
353
350
|
}, "add batch messages");
|
|
354
|
-
await this.applyStorageLimit(conversationId);
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Apply storage limit to a conversation
|
|
358
|
-
*/
|
|
359
|
-
async applyStorageLimit(conversationId) {
|
|
360
|
-
const messagesTable = `${this.tablePrefix}_messages`;
|
|
361
|
-
await this.executeWithRetry(async () => {
|
|
362
|
-
await this.client.execute({
|
|
363
|
-
sql: `DELETE FROM ${messagesTable}
|
|
364
|
-
WHERE conversation_id = ?
|
|
365
|
-
AND message_id NOT IN (
|
|
366
|
-
SELECT message_id FROM ${messagesTable}
|
|
367
|
-
WHERE conversation_id = ?
|
|
368
|
-
ORDER BY created_at DESC
|
|
369
|
-
LIMIT ?
|
|
370
|
-
)`,
|
|
371
|
-
args: [conversationId, conversationId, this.storageLimit]
|
|
372
|
-
});
|
|
373
|
-
}, "apply storage limit");
|
|
374
351
|
}
|
|
375
352
|
/**
|
|
376
353
|
* Get messages with optional filtering
|
|
@@ -378,7 +355,7 @@ var LibSQLMemoryAdapter = class {
|
|
|
378
355
|
async getMessages(userId, conversationId, options) {
|
|
379
356
|
await this.initialize();
|
|
380
357
|
const messagesTable = `${this.tablePrefix}_messages`;
|
|
381
|
-
const { limit
|
|
358
|
+
const { limit, before, after, roles } = options || {};
|
|
382
359
|
let sql = `SELECT * FROM ${messagesTable}
|
|
383
360
|
WHERE conversation_id = ? AND user_id = ?`;
|
|
384
361
|
const args = [conversationId, userId];
|
|
@@ -1631,6 +1608,14 @@ var LibSQLObservabilityAdapter = class {
|
|
|
1631
1608
|
}
|
|
1632
1609
|
return log;
|
|
1633
1610
|
}
|
|
1611
|
+
getInfo() {
|
|
1612
|
+
return {
|
|
1613
|
+
adapter: this.constructor.name,
|
|
1614
|
+
displayName: "LibSQL Observability Storage",
|
|
1615
|
+
persistent: true,
|
|
1616
|
+
description: "Persists spans and logs to a LibSQL/Turso database for long-term retention."
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1634
1619
|
/**
|
|
1635
1620
|
* Close the database connection
|
|
1636
1621
|
*/
|