@mastra/mysql 0.11.1-alpha.1 → 0.12.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
@@ -6120,6 +6120,7 @@ function addMySQLMessageMetadataFilter(conditions, params, metadataFilter) {
6120
6120
  var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
6121
6121
  supportsPartialThreadUpdate = true;
6122
6122
  supportsObservationalMemory = true;
6123
+ supportsObservationalMemoryHistorySearch = true;
6123
6124
  pool;
6124
6125
  operations;
6125
6126
  #skipDefaultIndexes;
@@ -7322,6 +7323,10 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
7322
7323
  const safeLimit = Math.max(1, Math.floor(Number(limit)) || 10);
7323
7324
  const conditions = [`${omCol("lookupKey")} = ?`];
7324
7325
  const params = [lookupKey];
7326
+ if (options?.recordId !== void 0) {
7327
+ conditions.push(`${omCol("id")} = ?`);
7328
+ params.push(options.recordId);
7329
+ }
7325
7330
  if (options?.from) {
7326
7331
  conditions.push(`${omCol("createdAt")} >= ?`);
7327
7332
  params.push(transformToSqlValue(options.from));
@@ -7330,8 +7335,26 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
7330
7335
  conditions.push(`${omCol("createdAt")} <= ?`);
7331
7336
  params.push(transformToSqlValue(options.to));
7332
7337
  }
7338
+ if (options?.groupId !== void 0) {
7339
+ conditions.push(`(LOCATE(CAST(? AS BINARY), CAST(${omCol("activeObservations")} AS BINARY)) > 0 OR EXISTS (
7340
+ SELECT 1 FROM JSON_TABLE(${omCol("bufferedObservationChunks")}, '$[*]'
7341
+ COLUMNS (observations LONGTEXT PATH '$.observations')) AS chunk
7342
+ WHERE LOCATE(CAST(? AS BINARY), CAST(chunk.observations AS BINARY)) > 0
7343
+ ))`);
7344
+ const prefix = `<observation-group id="${options.groupId}"`;
7345
+ params.push(prefix, prefix);
7346
+ }
7347
+ if (options?.beforeGeneration !== void 0) {
7348
+ conditions.push(`${omCol("generationCount")} < ?`);
7349
+ params.push(options.beforeGeneration);
7350
+ }
7351
+ if (options?.afterGeneration !== void 0) {
7352
+ conditions.push(`${omCol("generationCount")} > ?`);
7353
+ params.push(options.afterGeneration);
7354
+ }
7355
+ const direction = options?.sortDirection === "ASC" ? "ASC" : "DESC";
7333
7356
  const whereClause = conditions.join(" AND ");
7334
- let sql = `SELECT * FROM ${OM_TABLE_QUOTED} WHERE ${whereClause} ORDER BY ${omCol("generationCount")} DESC LIMIT ${safeLimit}`;
7357
+ let sql = `SELECT * FROM ${OM_TABLE_QUOTED} WHERE ${whereClause} ORDER BY ${omCol("generationCount")} ${direction}, ${omCol("createdAt")} ASC, id ASC LIMIT ${safeLimit}`;
7335
7358
  if (options?.offset != null && options.offset > 0) sql += ` OFFSET ${options.offset}`;
7336
7359
  const [rows] = await this.pool.execute(sql, params);
7337
7360
  if (!rows) return [];