@mastra/mongodb 1.24.1-alpha.0 → 1.24.1-alpha.1

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.
@@ -1,4 +1,3 @@
1
- //#region src/memory/index.d.ts
2
1
  /**
3
2
  * Shared rules for observational memory lifecycle writes. Every storage adapter applies
4
3
  * these inside its own atomic section (lock, transaction, or conditional update), so the
@@ -97,5 +96,4 @@ export declare function assertActiveObservationsApplied(result: UpdateActiveObse
97
96
  * (equal, or only appended to since).
98
97
  */
99
98
  export declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
100
- //#endregion
101
99
  //# sourceMappingURL=index.d.ts.map
@@ -3,7 +3,7 @@ name: mastra-mongodb
3
3
  description: Documentation for @mastra/mongodb. Use when working with @mastra/mongodb APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mongodb"
6
- version: "1.24.1-alpha.0"
6
+ version: "1.24.1-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.24.1-alpha.0",
2
+ "version": "1.24.1-alpha.1",
3
3
  "package": "@mastra/mongodb",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -4,7 +4,11 @@
4
4
 
5
5
  # Semantic recall
6
6
 
7
- If you ask your friend what they did last weekend, they will search in their memory for events associated with "last weekend" and then tell you what they did. That's sort of like how semantic recall works in Mastra.
7
+ Semantic recall is a built-in form of Retrieval-Augmented Generation (RAG) for agent memory. When a user sends a message, Mastra searches earlier messages for ones with a similar meaning and adds the most relevant ones to the agent's context.
8
+
9
+ Matching on meaning matters because people often remember the idea behind something, not the exact words they used. A user might ask "What did we decide about the refund?" after originally writing "Let's give them their money back." A keyword search misses that connection, but semantic recall finds it.
10
+
11
+ Use semantic recall when your agent needs details from earlier in a long conversation, or from a user's other conversations, that are no longer in [recent message history](https://mastra.ai/docs/memory/message-history).
8
12
 
9
13
  > **📹 Watch:** Watch [Mastra semantic recall](https://www.youtube.com/watch?v=UVZtK8cK8xQ\&pp=ygUVbWFzdHJhIHdvcmtpbmcgbWVtb3J5) to see how agents retrieve relevant messages from past conversations.
10
14
 
@@ -382,6 +382,7 @@ Vector store prompts define query patterns and filtering capabilities for each v
382
382
 
383
383
  ```ts
384
384
  import { MONGODB_PROMPT } from '@mastra/mongodb'
385
+ import { Agent } from '@mastra/core/agent'
385
386
 
386
387
  export const ragAgent = new Agent({
387
388
  id: 'rag-agent',
@@ -416,6 +417,7 @@ export const ragAgent = new Agent({
416
417
 
417
418
  ```ts
418
419
  import { PINECONE_PROMPT } from '@mastra/pinecone'
420
+ import { Agent } from '@mastra/core/agent'
419
421
 
420
422
  export const ragAgent = new Agent({
421
423
  id: 'rag-agent',
@@ -433,6 +435,7 @@ export const ragAgent = new Agent({
433
435
 
434
436
  ```ts
435
437
  import { QDRANT_PROMPT } from '@mastra/qdrant'
438
+ import { Agent } from '@mastra/core/agent'
436
439
 
437
440
  export const ragAgent = new Agent({
438
441
  id: 'rag-agent',
@@ -450,6 +453,7 @@ export const ragAgent = new Agent({
450
453
 
451
454
  ```ts
452
455
  import { CHROMA_PROMPT } from '@mastra/chroma'
456
+ import { Agent } from '@mastra/core/agent'
453
457
 
454
458
  export const ragAgent = new Agent({
455
459
  id: 'rag-agent',
@@ -467,6 +471,7 @@ export const ragAgent = new Agent({
467
471
 
468
472
  ```ts
469
473
  import { ASTRA_PROMPT } from '@mastra/astra'
474
+ import { Agent } from '@mastra/core/agent'
470
475
 
471
476
  export const ragAgent = new Agent({
472
477
  id: 'rag-agent',
@@ -484,6 +489,7 @@ export const ragAgent = new Agent({
484
489
 
485
490
  ```ts
486
491
  import { LIBSQL_PROMPT } from '@mastra/libsql'
492
+ import { Agent } from '@mastra/core/agent'
487
493
 
488
494
  export const ragAgent = new Agent({
489
495
  id: 'rag-agent',
@@ -501,6 +507,7 @@ export const ragAgent = new Agent({
501
507
 
502
508
  ```ts
503
509
  import { UPSTASH_PROMPT } from '@mastra/upstash'
510
+ import { Agent } from '@mastra/core/agent'
504
511
 
505
512
  export const ragAgent = new Agent({
506
513
  id: 'rag-agent',
@@ -518,6 +525,7 @@ export const ragAgent = new Agent({
518
525
 
519
526
  ```ts
520
527
  import { VECTORIZE_PROMPT } from '@mastra/vectorize'
528
+ import { Agent } from '@mastra/core/agent'
521
529
 
522
530
  export const ragAgent = new Agent({
523
531
  id: 'rag-agent',
@@ -535,6 +543,7 @@ export const ragAgent = new Agent({
535
543
 
536
544
  ```ts
537
545
  import { OPENSEARCH_PROMPT } from '@mastra/opensearch'
546
+ import { Agent } from '@mastra/core/agent'
538
547
 
539
548
  export const ragAgent = new Agent({
540
549
  id: 'rag-agent',
@@ -552,6 +561,7 @@ export const ragAgent = new Agent({
552
561
 
553
562
  ```ts
554
563
  import { ORACLEDB_PROMPT } from '@mastra/oracledb'
564
+ import { Agent } from '@mastra/core/agent'
555
565
 
556
566
  export const ragAgent = new Agent({
557
567
  id: 'rag-agent',
@@ -569,6 +579,7 @@ export const ragAgent = new Agent({
569
579
 
570
580
  ```ts
571
581
  import { S3VECTORS_PROMPT } from '@mastra/s3vectors'
582
+ import { Agent } from '@mastra/core/agent'
572
583
 
573
584
  export const ragAgent = new Agent({
574
585
  id: 'rag-agent',
@@ -294,7 +294,7 @@ const storage = new MongoDBStore({
294
294
 
295
295
  ## Reclaiming disk
296
296
 
297
- `prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist and are reused by future writes, so the file stops growing: for most users this alone solves the unbounded-growth problem.
297
+ `prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist for reuse by future writes. Reusing these pages prevents unbounded file growth for most users.
298
298
 
299
299
  Handing that free space back to the OS is a separate concern that Mastra doesn't manage. If you specifically need to shrink the file, run the underlying database's compaction (for example `VACUUM` on self-hosted libSQL) yourself in a maintenance window. A full `VACUUM` locks the file and needs roughly twice the file size in free disk. On PostgreSQL, autovacuum reclaims dead tuples for reuse automatically. A manual `VACUUM FULL` is only needed if you must return disk to the OS.
300
300
 
@@ -97,7 +97,7 @@ Creates a new vector index (collection) in MongoDB.
97
97
 
98
98
  **collectionName** (`string`): Store the vectors on an existing (operational) collection instead of a managed collection named after the index. The collection is never created or dropped by this store when set. Defaults to indexName.
99
99
 
100
- **searchIndexName** (`string`): Name for the MongoDB vectorSearch index created on the collection. Defaults to ${indexName}\_vector\_index.
100
+ **searchIndexName** (`string`): Name for the MongoDB vectorSearch index created on the collection. Defaults to ${indexName}\_vector_index.
101
101
 
102
102
  **allowWrites** (`boolean`): Opt-in to write operations (upsert, updateVector, deleteVector, deleteVectors) on a bring-your-own collection. By default a BYO index is read-only: the store never modifies or deletes caller-owned operational documents. Ignored for managed collections, which are always writable. The policy is persisted with the index registration and survives restarts. (Default: `false`)
103
103
 
package/dist/index.cjs CHANGED
@@ -9,10 +9,9 @@ let crypto$1 = require("crypto");
9
9
  let _mastra_core_agent = require("@mastra/core/agent");
10
10
  let _mastra_core_evals = require("@mastra/core/evals");
11
11
  let _mastra_core_storage_domains_skills = require("@mastra/core/storage/domains/skills");
12
- //#region package.json
13
- var version = "1.24.1-alpha.0";
14
- //#endregion
15
- //#region src/vector/filter.ts
12
+ // package.json
13
+ var version = "1.24.1-alpha.1";
14
+ // src/vector/filter.ts
16
15
  /**
17
16
  * Translator for MongoDB filter queries.
18
17
  * Maintains MongoDB-compatible syntax while ensuring proper validation
@@ -82,8 +81,7 @@ var MongoDBFilterTranslator = class extends _mastra_core_vector_filter.BaseFilte
82
81
  return filter === void 0 || filter === null || typeof filter === "object" && Object.keys(filter).length === 0;
83
82
  }
84
83
  };
85
- //#endregion
86
- //#region src/vector/index.ts
84
+ // src/vector/index.ts
87
85
  /** Name an index's embedding mode for a conflict message. */
88
86
  function describeEmbedding(config) {
89
87
  return config ? `autoEmbed (path "${config.path}", model "${config.model}")` : "client-side vectors";
@@ -1566,8 +1564,7 @@ var MongoDBVector = class MongoDBVector extends _mastra_core_vector.MastraVector
1566
1564
  return true;
1567
1565
  }
1568
1566
  };
1569
- //#endregion
1570
- //#region src/storage/connectors/MongoDBConnector.ts
1567
+ // src/storage/connectors/MongoDBConnector.ts
1571
1568
  var MongoDBConnector = class MongoDBConnector {
1572
1569
  #client;
1573
1570
  #dbName;
@@ -1678,8 +1675,7 @@ var MongoDBConnector = class MongoDBConnector {
1678
1675
  if (this.#handler) await this.#handler.close();
1679
1676
  }
1680
1677
  };
1681
- //#endregion
1682
- //#region src/storage/db/index.ts
1678
+ // src/storage/db/index.ts
1683
1679
  /**
1684
1680
  * Resolves a config to a MongoDBConnector instance.
1685
1681
  * Accepts both MongoDBConfig (main store) and MongoDBDomainConfig (domains).
@@ -1724,8 +1720,7 @@ function resolveMongoDBConfig(config) {
1724
1720
  }, error);
1725
1721
  }
1726
1722
  }
1727
- //#endregion
1728
- //#region src/storage/domains/agents/index.ts
1723
+ // src/storage/domains/agents/index.ts
1729
1724
  /**
1730
1725
  * The set of fields from StorageAgentSnapshotType that live on version rows.
1731
1726
  * Used to strip snapshot config from version documents when transforming.
@@ -2423,8 +2418,7 @@ function resolveTargets({ policies, descriptor, order, encodings }) {
2423
2418
  }
2424
2419
  return targets;
2425
2420
  }
2426
- //#endregion
2427
- //#region src/storage/domains/background-tasks/index.ts
2421
+ // src/storage/domains/background-tasks/index.ts
2428
2422
  function toDoc(task) {
2429
2423
  return {
2430
2424
  id: task.id,
@@ -2674,8 +2668,7 @@ var BackgroundTasksStorageMongoDB = class BackgroundTasksStorageMongoDB extends
2674
2668
  });
2675
2669
  }
2676
2670
  };
2677
- //#endregion
2678
- //#region src/storage/domains/blobs/index.ts
2671
+ // src/storage/domains/blobs/index.ts
2679
2672
  var MongoDBBlobStore = class MongoDBBlobStore extends _mastra_core_storage.BlobStore {
2680
2673
  #connector;
2681
2674
  #skipDefaultIndexes;
@@ -2832,8 +2825,7 @@ var MongoDBBlobStore = class MongoDBBlobStore extends _mastra_core_storage.BlobS
2832
2825
  };
2833
2826
  }
2834
2827
  };
2835
- //#endregion
2836
- //#region src/storage/domains/utils.ts
2828
+ // src/storage/domains/utils.ts
2837
2829
  function formatDateForMongoDB(date) {
2838
2830
  return typeof date === "string" ? new Date(date) : date;
2839
2831
  }
@@ -2850,8 +2842,7 @@ function applyTenancyFilter(filter, filters) {
2850
2842
  if (filters.organizationId !== void 0) filter.organizationId = filters.organizationId;
2851
2843
  if (filters.projectId !== void 0) filter.projectId = filters.projectId;
2852
2844
  }
2853
- //#endregion
2854
- //#region src/storage/domains/datasets/index.ts
2845
+ // src/storage/domains/datasets/index.ts
2855
2846
  const MANAGED_COLLECTIONS = [
2856
2847
  _mastra_core_storage.TABLE_DATASETS,
2857
2848
  _mastra_core_storage.TABLE_DATASET_ITEMS,
@@ -4037,8 +4028,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
4037
4028
  }, failures[0].reason);
4038
4029
  }
4039
4030
  };
4040
- //#endregion
4041
- //#region src/storage/domains/experiments/index.ts
4031
+ // src/storage/domains/experiments/index.ts
4042
4032
  function toDate(value) {
4043
4033
  if (value instanceof Date) return value;
4044
4034
  if (typeof value === "string" || typeof value === "number") return new Date(value);
@@ -4770,8 +4760,7 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends _mastra_
4770
4760
  } catch {}
4771
4761
  }
4772
4762
  };
4773
- //#endregion
4774
- //#region src/storage/domains/knowledge/index.ts
4763
+ // src/storage/domains/knowledge/index.ts
4775
4764
  let assertDescriptionWithinBound;
4776
4765
  async function assertKnowledgeDescriptionWithinBoundCompat(description) {
4777
4766
  let assertWithinBound = assertDescriptionWithinBound;
@@ -5612,8 +5601,7 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
5612
5601
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5613
5602
  }
5614
5603
  };
5615
- //#endregion
5616
- //#region src/storage/domains/mcp-clients/index.ts
5604
+ // src/storage/domains/mcp-clients/index.ts
5617
5605
  /**
5618
5606
  * Snapshot config fields that live on MCP client version documents.
5619
5607
  */
@@ -6058,8 +6046,7 @@ var MongoDBMCPClientsStorage = class MongoDBMCPClientsStorage extends _mastra_co
6058
6046
  return result;
6059
6047
  }
6060
6048
  };
6061
- //#endregion
6062
- //#region src/storage/domains/mcp-servers/index.ts
6049
+ // src/storage/domains/mcp-servers/index.ts
6063
6050
  /**
6064
6051
  * Snapshot config fields that live on MCP server version documents.
6065
6052
  */
@@ -6514,8 +6501,7 @@ var MongoDBMCPServersStorage = class MongoDBMCPServersStorage extends _mastra_co
6514
6501
  return result;
6515
6502
  }
6516
6503
  };
6517
- //#endregion
6518
- //#region ../../packages/_internal-core/dist/memory/index.js
6504
+ // ../../packages/_internal-core/dist/memory/index.js
6519
6505
  /**
6520
6506
  * A buffered chunk stores `lastObservedAt = max message time + 1ms`. It is wholly covered
6521
6507
  * (every message it observed is already at or before the cursor) iff
@@ -6579,8 +6565,7 @@ function isAppendOnlySince(storedObservations, snapshotObservations) {
6579
6565
  const snapshot = snapshotObservations ?? "";
6580
6566
  return stored === snapshot || stored.startsWith(snapshot);
6581
6567
  }
6582
- //#endregion
6583
- //#region src/storage/domains/run-fencing.ts
6568
+ // src/storage/domains/run-fencing.ts
6584
6569
  async function getRunClaims(connector, name) {
6585
6570
  return await connector.getCollection(name);
6586
6571
  }
@@ -6613,8 +6598,7 @@ async function withRunFence(connector, check, write) {
6613
6598
  return write(session);
6614
6599
  });
6615
6600
  }
6616
- //#endregion
6617
- //#region src/storage/domains/memory/index.ts
6601
+ // src/storage/domains/memory/index.ts
6618
6602
  /**
6619
6603
  * Local constant for the observational memory table name.
6620
6604
  * Defined locally to avoid a static import that crashes on older @mastra/core
@@ -8731,8 +8715,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends _mastra_core_stora
8731
8715
  }
8732
8716
  }
8733
8717
  };
8734
- //#endregion
8735
- //#region src/storage/domains/notifications/index.ts
8718
+ // src/storage/domains/notifications/index.ts
8736
8719
  /** Ids per updateMany/find command — keeps the `$in` filter far below MongoDB's 16 MiB BSON limit. */
8737
8720
  const BULK_ID_BATCH_SIZE = 500;
8738
8721
  const statusTimestamp = (status, now) => {
@@ -9110,8 +9093,7 @@ const dueTime = (record) => {
9110
9093
  if (deliverAt !== void 0 && summaryAt !== void 0) return Math.min(deliverAt, summaryAt);
9111
9094
  return deliverAt ?? summaryAt ?? Number.POSITIVE_INFINITY;
9112
9095
  };
9113
- //#endregion
9114
- //#region src/storage/domains/observability/index.ts
9096
+ // src/storage/domains/observability/index.ts
9115
9097
  var ObservabilityMongoDB = class ObservabilityMongoDB extends _mastra_core_storage.ObservabilityStorage {
9116
9098
  #connector;
9117
9099
  #skipDefaultIndexes;
@@ -9783,8 +9765,7 @@ MIGRATION REQUIRED: Duplicate spans detected in ${_mastra_core_storage.TABLE_SPA
9783
9765
  return span;
9784
9766
  }
9785
9767
  };
9786
- //#endregion
9787
- //#region src/storage/domains/prompt-blocks/index.ts
9768
+ // src/storage/domains/prompt-blocks/index.ts
9788
9769
  /**
9789
9770
  * Snapshot config fields that live on prompt block version documents.
9790
9771
  */
@@ -10231,8 +10212,7 @@ var MongoDBPromptBlocksStorage = class MongoDBPromptBlocksStorage extends _mastr
10231
10212
  return result;
10232
10213
  }
10233
10214
  };
10234
- //#endregion
10235
- //#region src/storage/domains/schedules/index.ts
10215
+ // src/storage/domains/schedules/index.ts
10236
10216
  function scheduleToDoc(schedule) {
10237
10217
  return {
10238
10218
  id: schedule.id,
@@ -10486,8 +10466,7 @@ var SchedulesMongoDB = class SchedulesMongoDB extends _mastra_core_storage.Sched
10486
10466
  return (await cursor.toArray()).map(docToTrigger);
10487
10467
  }
10488
10468
  };
10489
- //#endregion
10490
- //#region src/storage/domains/scorer-definitions/index.ts
10469
+ // src/storage/domains/scorer-definitions/index.ts
10491
10470
  /**
10492
10471
  * Snapshot config fields that live on scorer definition version documents.
10493
10472
  */
@@ -10937,8 +10916,7 @@ var MongoDBScorerDefinitionsStorage = class MongoDBScorerDefinitionsStorage exte
10937
10916
  return result;
10938
10917
  }
10939
10918
  };
10940
- //#endregion
10941
- //#region src/storage/domains/scores/index.ts
10919
+ // src/storage/domains/scores/index.ts
10942
10920
  /**
10943
10921
  * MongoDB-specific score row transformation.
10944
10922
  * Converts timestamp strings to Date objects.
@@ -11314,8 +11292,7 @@ var ScoresStorageMongoDB = class ScoresStorageMongoDB extends _mastra_core_stora
11314
11292
  }
11315
11293
  }
11316
11294
  };
11317
- //#endregion
11318
- //#region src/storage/domains/skills/index.ts
11295
+ // src/storage/domains/skills/index.ts
11319
11296
  /**
11320
11297
  * Snapshot config fields that live on skill version documents.
11321
11298
  */
@@ -11814,8 +11791,7 @@ var MongoDBSkillsStorage = class MongoDBSkillsStorage extends _mastra_core_stora
11814
11791
  return result;
11815
11792
  }
11816
11793
  };
11817
- //#endregion
11818
- //#region src/storage/domains/workflow-definitions/index.ts
11794
+ // src/storage/domains/workflow-definitions/index.ts
11819
11795
  function docToDefinition(doc) {
11820
11796
  const def = {
11821
11797
  id: String(doc.id),
@@ -11952,8 +11928,7 @@ var MongoDBWorkflowDefinitionsStore = class MongoDBWorkflowDefinitionsStore exte
11952
11928
  await (await this.getCollection(_mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS)).deleteOne({ id });
11953
11929
  }
11954
11930
  };
11955
- //#endregion
11956
- //#region src/storage/domains/workflows/index.ts
11931
+ // src/storage/domains/workflows/index.ts
11957
11932
  const RUN_OWNER_PROJECTION = {
11958
11933
  generation: 1,
11959
11934
  ownerId: 1,
@@ -12463,8 +12438,7 @@ var WorkflowsStorageMongoDB = class WorkflowsStorageMongoDB extends _mastra_core
12463
12438
  };
12464
12439
  }
12465
12440
  };
12466
- //#endregion
12467
- //#region src/storage/domains/workspaces/index.ts
12441
+ // src/storage/domains/workspaces/index.ts
12468
12442
  /**
12469
12443
  * Snapshot config fields that live on workspace version documents.
12470
12444
  */
@@ -12963,8 +12937,7 @@ var MongoDBWorkspacesStorage = class MongoDBWorkspacesStorage extends _mastra_co
12963
12937
  return result;
12964
12938
  }
12965
12939
  };
12966
- //#endregion
12967
- //#region src/storage/index.ts
12940
+ // src/storage/index.ts
12968
12941
  /**
12969
12942
  * MongoDB storage adapter for Mastra.
12970
12943
  *
@@ -13057,8 +13030,7 @@ var MongoDBStore = class extends _mastra_core_storage.MastraCompositeStore {
13057
13030
  }
13058
13031
  }
13059
13032
  };
13060
- //#endregion
13061
- //#region src/vector/prompt.ts
13033
+ // src/vector/prompt.ts
13062
13034
  /**
13063
13035
  * Vector store specific prompt that details supported operators and examples.
13064
13036
  * This prompt helps users construct valid filters for MongoDB Vector.
@@ -13156,7 +13128,6 @@ Example Complex Query:
13156
13128
  { "$not": { "status": "discontinued" } }
13157
13129
  ]
13158
13130
  }`;
13159
- //#endregion
13160
13131
  exports.BackgroundTasksStorageMongoDB = BackgroundTasksStorageMongoDB;
13161
13132
  exports.KnowledgeMongoDB = KnowledgeMongoDB;
13162
13133
  exports.MONGODB_PROMPT = MONGODB_PROMPT;