@voltagent/libsql 2.0.2 → 2.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 +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/edge.js +38 -3
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +38 -3
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +38 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{vector-core-CKn8FNVK.d.mts → vector-core-J7BkPuy8.d.mts} +2 -0
- package/dist/{vector-core-CKn8FNVK.d.ts → vector-core-J7BkPuy8.d.ts} +2 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@voltagent/logger';
|
|
2
|
-
import { L as LibSQLMemoryCore, a as LibSQLMemoryCoreOptions, b as LibSQLObservabilityCore, c as LibSQLObservabilityCoreOptions, d as LibSQLVectorCore, e as LibSQLVectorCoreOptions } from './vector-core-
|
|
2
|
+
import { L as LibSQLMemoryCore, a as LibSQLMemoryCoreOptions, b as LibSQLObservabilityCore, c as LibSQLObservabilityCoreOptions, d as LibSQLVectorCore, e as LibSQLVectorCoreOptions } from './vector-core-J7BkPuy8.mjs';
|
|
3
3
|
import '@libsql/client';
|
|
4
4
|
import '@voltagent/core';
|
|
5
5
|
import 'ai';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@voltagent/logger';
|
|
2
|
-
import { L as LibSQLMemoryCore, a as LibSQLMemoryCoreOptions, b as LibSQLObservabilityCore, c as LibSQLObservabilityCoreOptions, d as LibSQLVectorCore, e as LibSQLVectorCoreOptions } from './vector-core-
|
|
2
|
+
import { L as LibSQLMemoryCore, a as LibSQLMemoryCoreOptions, b as LibSQLObservabilityCore, c as LibSQLObservabilityCoreOptions, d as LibSQLVectorCore, e as LibSQLVectorCoreOptions } from './vector-core-J7BkPuy8.js';
|
|
3
3
|
import '@libsql/client';
|
|
4
4
|
import '@voltagent/core';
|
|
5
5
|
import 'ai';
|
package/dist/index.js
CHANGED
|
@@ -492,8 +492,12 @@ var LibSQLMemoryCore = class {
|
|
|
492
492
|
await this.initialize();
|
|
493
493
|
const messagesTable = `${this.tablePrefix}_messages`;
|
|
494
494
|
const { limit, before, after, roles } = options || {};
|
|
495
|
-
let sql = `
|
|
496
|
-
|
|
495
|
+
let sql = `
|
|
496
|
+
SELECT * FROM (
|
|
497
|
+
SELECT *
|
|
498
|
+
FROM ${messagesTable}
|
|
499
|
+
WHERE conversation_id = ? AND user_id = ?
|
|
500
|
+
`;
|
|
497
501
|
const args = [conversationId, userId];
|
|
498
502
|
if (roles && roles.length > 0) {
|
|
499
503
|
const placeholders = roles.map(() => "?").join(",");
|
|
@@ -508,11 +512,12 @@ var LibSQLMemoryCore = class {
|
|
|
508
512
|
sql += " AND created_at > ?";
|
|
509
513
|
args.push(after.toISOString());
|
|
510
514
|
}
|
|
511
|
-
sql += " ORDER BY created_at
|
|
515
|
+
sql += " ORDER BY created_at DESC";
|
|
512
516
|
if (limit && limit > 0) {
|
|
513
517
|
sql += " LIMIT ?";
|
|
514
518
|
args.push(limit);
|
|
515
519
|
}
|
|
520
|
+
sql += " ) AS subq ORDER BY created_at ASC";
|
|
516
521
|
const result = await this.client.execute({ sql, args });
|
|
517
522
|
return result.rows.map((row) => {
|
|
518
523
|
let parts;
|
|
@@ -626,6 +631,19 @@ var LibSQLMemoryCore = class {
|
|
|
626
631
|
});
|
|
627
632
|
}
|
|
628
633
|
}
|
|
634
|
+
async deleteMessages(messageIds, userId, conversationId) {
|
|
635
|
+
await this.initialize();
|
|
636
|
+
if (messageIds.length === 0) {
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
const messagesTable = `${this.tablePrefix}_messages`;
|
|
640
|
+
const placeholders = messageIds.map(() => "?").join(",");
|
|
641
|
+
const sql = `DELETE FROM ${messagesTable} WHERE conversation_id = ? AND user_id = ? AND message_id IN (${placeholders})`;
|
|
642
|
+
await this.client.execute({
|
|
643
|
+
sql,
|
|
644
|
+
args: [conversationId, userId, ...messageIds]
|
|
645
|
+
});
|
|
646
|
+
}
|
|
629
647
|
// ============================================================================
|
|
630
648
|
// Conversation Operations
|
|
631
649
|
// ============================================================================
|
|
@@ -738,6 +756,23 @@ var LibSQLMemoryCore = class {
|
|
|
738
756
|
updatedAt: row.updated_at
|
|
739
757
|
}));
|
|
740
758
|
}
|
|
759
|
+
async countConversations(options) {
|
|
760
|
+
await this.initialize();
|
|
761
|
+
const conversationsTable = `${this.tablePrefix}_conversations`;
|
|
762
|
+
let sql = `SELECT COUNT(*) as count FROM ${conversationsTable} WHERE 1=1`;
|
|
763
|
+
const args = [];
|
|
764
|
+
if (options.userId) {
|
|
765
|
+
sql += " AND user_id = ?";
|
|
766
|
+
args.push(options.userId);
|
|
767
|
+
}
|
|
768
|
+
if (options.resourceId) {
|
|
769
|
+
sql += " AND resource_id = ?";
|
|
770
|
+
args.push(options.resourceId);
|
|
771
|
+
}
|
|
772
|
+
const result = await this.client.execute({ sql, args });
|
|
773
|
+
const count = Number(result.rows[0]?.count ?? 0);
|
|
774
|
+
return Number.isNaN(count) ? 0 : count;
|
|
775
|
+
}
|
|
741
776
|
async updateConversation(id, updates) {
|
|
742
777
|
await this.initialize();
|
|
743
778
|
const conversationsTable = `${this.tablePrefix}_conversations`;
|