@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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mastra/libsql
2
2
 
3
+ ## 1.8.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Implemented `updateObservationalMemoryConfig()` in Postgres, LibSQL, and MongoDB storage adapters. This enables per-record config overrides for observational memory thresholds, supporting the new `memory.updateObservationalMemoryConfig()` API in `@mastra/memory`. ([#15115](https://github.com/mastra-ai/mastra/pull/15115))
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`a50d220`](https://github.com/mastra-ai/mastra/commit/a50d220b01ecbc5644d489a3d446c3bd4ab30245)]:
12
+ - @mastra/core@1.23.0-alpha.9
13
+
3
14
  ## 1.7.4
4
15
 
5
16
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-libsql
3
3
  description: Documentation for @mastra/libsql. Use when working with @mastra/libsql APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/libsql"
6
- version: "1.7.4"
6
+ version: "1.8.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.4",
2
+ "version": "1.8.0-alpha.0",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -6557,14 +6557,26 @@ var MemoryLibSQL = class extends storage.MemoryStorage {
6557
6557
  );
6558
6558
  }
6559
6559
  }
6560
- async getObservationalMemoryHistory(threadId, resourceId, limit = 10) {
6560
+ async getObservationalMemoryHistory(threadId, resourceId, limit = 10, options) {
6561
6561
  try {
6562
6562
  const lookupKey = this.getOMKey(threadId, resourceId);
6563
- const result = await this.#client.execute({
6564
- // Use generationCount DESC for reliable ordering (incremented for each new record)
6565
- sql: `SELECT * FROM "${OM_TABLE}" WHERE "lookupKey" = ? ORDER BY "generationCount" DESC LIMIT ?`,
6566
- args: [lookupKey, limit]
6567
- });
6563
+ const conditions = [`"lookupKey" = ?`];
6564
+ const args = [lookupKey];
6565
+ if (options?.from) {
6566
+ conditions.push(`"createdAt" >= ?`);
6567
+ args.push(options.from.toISOString());
6568
+ }
6569
+ if (options?.to) {
6570
+ conditions.push(`"createdAt" <= ?`);
6571
+ args.push(options.to.toISOString());
6572
+ }
6573
+ args.push(limit);
6574
+ let sql = `SELECT * FROM "${OM_TABLE}" WHERE ${conditions.join(" AND ")} ORDER BY "generationCount" DESC LIMIT ?`;
6575
+ if (options?.offset != null) {
6576
+ args.push(options.offset);
6577
+ sql += ` OFFSET ?`;
6578
+ }
6579
+ const result = await this.#client.execute({ sql, args });
6568
6580
  if (!result.rows) return [];
6569
6581
  return result.rows.map((row) => this.parseOMRow(row));
6570
6582
  } catch (error$1) {
@@ -7034,6 +7046,43 @@ var MemoryLibSQL = class extends storage.MemoryStorage {
7034
7046
  );
7035
7047
  }
7036
7048
  }
7049
+ async updateObservationalMemoryConfig(input) {
7050
+ try {
7051
+ const selectResult = await this.#client.execute({
7052
+ sql: `SELECT config FROM "${OM_TABLE}" WHERE id = ?`,
7053
+ args: [input.id]
7054
+ });
7055
+ if (selectResult.rows.length === 0) {
7056
+ throw new error.MastraError({
7057
+ id: storage.createStorageErrorId("LIBSQL", "UPDATE_OM_CONFIG", "NOT_FOUND"),
7058
+ text: `Observational memory record not found: ${input.id}`,
7059
+ domain: error.ErrorDomain.STORAGE,
7060
+ category: error.ErrorCategory.THIRD_PARTY,
7061
+ details: { id: input.id }
7062
+ });
7063
+ }
7064
+ const row = selectResult.rows[0];
7065
+ const existing = row.config ? JSON.parse(row.config) : {};
7066
+ const merged = this.deepMergeConfig(existing, input.config);
7067
+ await this.#client.execute({
7068
+ sql: `UPDATE "${OM_TABLE}" SET config = ?, "updatedAt" = ? WHERE id = ?`,
7069
+ args: [JSON.stringify(merged), (/* @__PURE__ */ new Date()).toISOString(), input.id]
7070
+ });
7071
+ } catch (error$1) {
7072
+ if (error$1 instanceof error.MastraError) {
7073
+ throw error$1;
7074
+ }
7075
+ throw new error.MastraError(
7076
+ {
7077
+ id: storage.createStorageErrorId("LIBSQL", "UPDATE_OM_CONFIG", "FAILED"),
7078
+ domain: error.ErrorDomain.STORAGE,
7079
+ category: error.ErrorCategory.THIRD_PARTY,
7080
+ details: { id: input.id }
7081
+ },
7082
+ error$1
7083
+ );
7084
+ }
7085
+ }
7037
7086
  // ============================================
7038
7087
  // Async Buffering Methods
7039
7088
  // ============================================