@mastra/libsql 1.7.4 → 1.8.0-alpha.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/CHANGELOG.md +11 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +55 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -6
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +3 -2
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -6555,14 +6555,26 @@ var MemoryLibSQL = class extends MemoryStorage {
|
|
|
6555
6555
|
);
|
|
6556
6556
|
}
|
|
6557
6557
|
}
|
|
6558
|
-
async getObservationalMemoryHistory(threadId, resourceId, limit = 10) {
|
|
6558
|
+
async getObservationalMemoryHistory(threadId, resourceId, limit = 10, options) {
|
|
6559
6559
|
try {
|
|
6560
6560
|
const lookupKey = this.getOMKey(threadId, resourceId);
|
|
6561
|
-
const
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6561
|
+
const conditions = [`"lookupKey" = ?`];
|
|
6562
|
+
const args = [lookupKey];
|
|
6563
|
+
if (options?.from) {
|
|
6564
|
+
conditions.push(`"createdAt" >= ?`);
|
|
6565
|
+
args.push(options.from.toISOString());
|
|
6566
|
+
}
|
|
6567
|
+
if (options?.to) {
|
|
6568
|
+
conditions.push(`"createdAt" <= ?`);
|
|
6569
|
+
args.push(options.to.toISOString());
|
|
6570
|
+
}
|
|
6571
|
+
args.push(limit);
|
|
6572
|
+
let sql = `SELECT * FROM "${OM_TABLE}" WHERE ${conditions.join(" AND ")} ORDER BY "generationCount" DESC LIMIT ?`;
|
|
6573
|
+
if (options?.offset != null) {
|
|
6574
|
+
args.push(options.offset);
|
|
6575
|
+
sql += ` OFFSET ?`;
|
|
6576
|
+
}
|
|
6577
|
+
const result = await this.#client.execute({ sql, args });
|
|
6566
6578
|
if (!result.rows) return [];
|
|
6567
6579
|
return result.rows.map((row) => this.parseOMRow(row));
|
|
6568
6580
|
} catch (error) {
|
|
@@ -7032,6 +7044,43 @@ var MemoryLibSQL = class extends MemoryStorage {
|
|
|
7032
7044
|
);
|
|
7033
7045
|
}
|
|
7034
7046
|
}
|
|
7047
|
+
async updateObservationalMemoryConfig(input) {
|
|
7048
|
+
try {
|
|
7049
|
+
const selectResult = await this.#client.execute({
|
|
7050
|
+
sql: `SELECT config FROM "${OM_TABLE}" WHERE id = ?`,
|
|
7051
|
+
args: [input.id]
|
|
7052
|
+
});
|
|
7053
|
+
if (selectResult.rows.length === 0) {
|
|
7054
|
+
throw new MastraError({
|
|
7055
|
+
id: createStorageErrorId("LIBSQL", "UPDATE_OM_CONFIG", "NOT_FOUND"),
|
|
7056
|
+
text: `Observational memory record not found: ${input.id}`,
|
|
7057
|
+
domain: ErrorDomain.STORAGE,
|
|
7058
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
7059
|
+
details: { id: input.id }
|
|
7060
|
+
});
|
|
7061
|
+
}
|
|
7062
|
+
const row = selectResult.rows[0];
|
|
7063
|
+
const existing = row.config ? JSON.parse(row.config) : {};
|
|
7064
|
+
const merged = this.deepMergeConfig(existing, input.config);
|
|
7065
|
+
await this.#client.execute({
|
|
7066
|
+
sql: `UPDATE "${OM_TABLE}" SET config = ?, "updatedAt" = ? WHERE id = ?`,
|
|
7067
|
+
args: [JSON.stringify(merged), (/* @__PURE__ */ new Date()).toISOString(), input.id]
|
|
7068
|
+
});
|
|
7069
|
+
} catch (error) {
|
|
7070
|
+
if (error instanceof MastraError) {
|
|
7071
|
+
throw error;
|
|
7072
|
+
}
|
|
7073
|
+
throw new MastraError(
|
|
7074
|
+
{
|
|
7075
|
+
id: createStorageErrorId("LIBSQL", "UPDATE_OM_CONFIG", "FAILED"),
|
|
7076
|
+
domain: ErrorDomain.STORAGE,
|
|
7077
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
7078
|
+
details: { id: input.id }
|
|
7079
|
+
},
|
|
7080
|
+
error
|
|
7081
|
+
);
|
|
7082
|
+
}
|
|
7083
|
+
}
|
|
7035
7084
|
// ============================================
|
|
7036
7085
|
// Async Buffering Methods
|
|
7037
7086
|
// ============================================
|