@mastra/mongodb 1.20.1 → 1.21.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
@@ -8,7 +8,7 @@ import { MessageList } from "@mastra/core/agent";
8
8
  import { saveScorePayloadSchema } from "@mastra/core/evals";
9
9
  import { skillSnapshotFieldValuesEqual } from "@mastra/core/storage/domains/skills";
10
10
  //#region package.json
11
- var version = "1.20.1";
11
+ var version = "1.21.0";
12
12
  //#endregion
13
13
  //#region src/vector/filter.ts
14
14
  /**
@@ -6464,6 +6464,7 @@ const OM_TABLE = "mastra_observational_memory";
6464
6464
  var MemoryStorageMongoDB = class MemoryStorageMongoDB extends MemoryStorage {
6465
6465
  supportsPartialThreadUpdate = true;
6466
6466
  supportsObservationalMemory = true;
6467
+ supportsObservationalMemoryHistorySearch = true;
6467
6468
  #connector;
6468
6469
  #skipDefaultIndexes;
6469
6470
  #indexes;
@@ -7504,13 +7505,34 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends MemoryStorage {
7504
7505
  const lookupKey = this.getOMKey(threadId, resourceId);
7505
7506
  const collection = await this.getCollection(OM_TABLE);
7506
7507
  const filter = { lookupKey };
7508
+ if (options?.recordId !== void 0) filter["id"] = options.recordId;
7507
7509
  if (options?.from || options?.to) {
7508
7510
  const createdAtFilter = {};
7509
7511
  if (options.from) createdAtFilter["$gte"] = options.from;
7510
7512
  if (options.to) createdAtFilter["$lte"] = options.to;
7511
7513
  filter["createdAt"] = createdAtFilter;
7512
7514
  }
7513
- let cursor = collection.find(filter).sort({ generationCount: -1 });
7515
+ if (options?.groupId !== void 0) {
7516
+ const prefix = { $literal: `<observation-group id="${options.groupId}"` };
7517
+ filter["$expr"] = { $or: [{ $gte: [{ $indexOfCP: [{ $ifNull: ["$activeObservations", ""] }, prefix] }, 0] }, { $anyElementTrue: [{ $map: {
7518
+ input: { $cond: [
7519
+ { $isArray: "$bufferedObservationChunks" },
7520
+ "$bufferedObservationChunks",
7521
+ []
7522
+ ] },
7523
+ as: "chunk",
7524
+ in: { $gte: [{ $indexOfCP: [{ $ifNull: ["$$chunk.observations", ""] }, prefix] }, 0] }
7525
+ } }] }] };
7526
+ }
7527
+ if (options?.beforeGeneration !== void 0 || options?.afterGeneration !== void 0) filter["generationCount"] = {
7528
+ ...options.beforeGeneration !== void 0 ? { $lt: options.beforeGeneration } : {},
7529
+ ...options.afterGeneration !== void 0 ? { $gt: options.afterGeneration } : {}
7530
+ };
7531
+ let cursor = collection.find(filter).sort({
7532
+ generationCount: options?.sortDirection === "ASC" ? 1 : -1,
7533
+ createdAt: 1,
7534
+ id: 1
7535
+ });
7514
7536
  if (options?.offset != null) cursor = cursor.skip(options.offset);
7515
7537
  return (await cursor.limit(limit).toArray()).map((doc) => this.parseOMDocument(doc));
7516
7538
  } catch (error) {