@mastra/libsql 1.24.1 → 1.25.1-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/dist/index.js CHANGED
@@ -7826,6 +7826,7 @@ function addSqliteMetadataValuePredicate(conditions, params, path, value) {
7826
7826
  var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
7827
7827
  supportsPartialThreadUpdate = true;
7828
7828
  supportsObservationalMemory = true;
7829
+ supportsObservationalMemoryHistorySearch = true;
7829
7830
  /**
7830
7831
  * Retention-eligible tables. `threads`, `messages`, and `resources` all anchor
7831
7832
  * on `createdAt` and are indexed for fast batched deletes. Cascade order is
@@ -8997,6 +8998,10 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
8997
8998
  const lookupKey = this.getOMKey(threadId, resourceId);
8998
8999
  const conditions = [`"lookupKey" = ?`];
8999
9000
  const args = [lookupKey];
9001
+ if (options?.recordId !== void 0) {
9002
+ conditions.push(`id = ?`);
9003
+ args.push(options.recordId);
9004
+ }
9000
9005
  if (options?.from) {
9001
9006
  conditions.push(`"createdAt" >= ?`);
9002
9007
  args.push(options.from.toISOString());
@@ -9005,8 +9010,25 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
9005
9010
  conditions.push(`"createdAt" <= ?`);
9006
9011
  args.push(options.to.toISOString());
9007
9012
  }
9013
+ if (options?.groupId !== void 0) {
9014
+ conditions.push(`(instr("activeObservations", ?) > 0 OR EXISTS (
9015
+ SELECT 1 FROM json_each("bufferedObservationChunks") AS chunk
9016
+ WHERE instr(json_extract(chunk.value, '$.observations'), ?) > 0
9017
+ ))`);
9018
+ const prefix = `<observation-group id="${options.groupId}"`;
9019
+ args.push(prefix, prefix);
9020
+ }
9021
+ if (options?.beforeGeneration !== void 0) {
9022
+ conditions.push(`"generationCount" < ?`);
9023
+ args.push(options.beforeGeneration);
9024
+ }
9025
+ if (options?.afterGeneration !== void 0) {
9026
+ conditions.push(`"generationCount" > ?`);
9027
+ args.push(options.afterGeneration);
9028
+ }
9029
+ const direction = options?.sortDirection === "ASC" ? "ASC" : "DESC";
9008
9030
  args.push(limit);
9009
- let sql = `SELECT * FROM "${OM_TABLE}" WHERE ${conditions.join(" AND ")} ORDER BY "generationCount" DESC LIMIT ?`;
9031
+ let sql = `SELECT * FROM "${OM_TABLE}" WHERE ${conditions.join(" AND ")} ORDER BY "generationCount" ${direction}, "createdAt" ASC, id ASC LIMIT ?`;
9010
9032
  if (options?.offset != null) {
9011
9033
  args.push(options.offset);
9012
9034
  sql += ` OFFSET ?`;
@@ -11432,16 +11454,17 @@ var SchedulesLibSQL = class SchedulesLibSQL extends SchedulesStorage {
11432
11454
  if (!updated) throw new Error(`Schedule ${id} not found`);
11433
11455
  return updated;
11434
11456
  }
11435
- async updateScheduleNextFire(id, expectedNextFireAt, newNextFireAt, lastFireAt, lastRunId) {
11457
+ async updateScheduleNextFire(id, expectedNextFireAt, newNextFireAt, lastFireAt, lastRunId, newStatus) {
11436
11458
  return ((await this.#client.execute({
11437
11459
  sql: `UPDATE ${TABLE_SCHEDULES}
11438
- SET next_fire_at = ?, last_fire_at = ?, last_run_id = ?, updated_at = ?
11460
+ SET next_fire_at = ?, last_fire_at = ?, last_run_id = ?, updated_at = ?, status = COALESCE(?, status)
11439
11461
  WHERE id = ? AND next_fire_at = ? AND status = ?`,
11440
11462
  args: [
11441
11463
  newNextFireAt,
11442
11464
  lastFireAt,
11443
11465
  lastRunId,
11444
11466
  Date.now(),
11467
+ newStatus ?? null,
11445
11468
  id,
11446
11469
  expectedNextFireAt,
11447
11470
  "active"