@mastra/mongodb 1.24.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.
- package/dist/_types/@internal_core/dist/memory/index.d.ts +12 -15
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-semantic-recall.md +7 -3
- package/dist/docs/references/docs-memory-working-memory.md +2 -2
- package/dist/docs/references/docs-storage.md +1 -1
- package/dist/docs/references/integrations-databases-mongodb.md +1 -1
- package/dist/docs/references/reference-rag-retrieval.md +24 -13
- package/dist/docs/references/reference-storage-retention.md +1 -1
- package/dist/docs/references/reference-vectors-mongodb.md +3 -3
- package/dist/index.cjs +30 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -59
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +12 -11
|
@@ -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
|
|
@@ -9,18 +8,18 @@
|
|
|
9
8
|
* into the table schema they get from `@mastra/core`, so the columns exist even when the
|
|
10
9
|
* installed core predates them.
|
|
11
10
|
*/
|
|
12
|
-
declare const OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS: {
|
|
11
|
+
export declare const OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS: {
|
|
13
12
|
readonly supersededBy: {
|
|
14
13
|
readonly type: 'text';
|
|
15
14
|
readonly nullable: true;
|
|
16
15
|
};
|
|
17
16
|
};
|
|
18
17
|
/** `schema` plus {@link OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS}; `undefined` when `schema` is. */
|
|
19
|
-
declare function withObservationalMemoryLifecycleColumns<T extends object>(schema: T | undefined): (T & typeof OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS) | undefined;
|
|
18
|
+
export declare function withObservationalMemoryLifecycleColumns<T extends object>(schema: T | undefined): (T & typeof OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS) | undefined;
|
|
20
19
|
/**
|
|
21
20
|
* Result of `commitActiveObservations`.
|
|
22
21
|
*/
|
|
23
|
-
interface UpdateActiveObservationsResult {
|
|
22
|
+
export interface UpdateActiveObservationsResult {
|
|
24
23
|
/** Whether the observations were written. */
|
|
25
24
|
applied: boolean;
|
|
26
25
|
/**
|
|
@@ -38,14 +37,14 @@ interface UpdateActiveObservationsResult {
|
|
|
38
37
|
* the head's cursor. Chunks carry `lastObservedAt = max message time + 1ms`, so a chunk is
|
|
39
38
|
* wholly covered iff `head.lastObservedAt >= chunk.lastObservedAt - 1ms`.
|
|
40
39
|
*/
|
|
41
|
-
interface UpdateBufferedObservationsResult {
|
|
40
|
+
export interface UpdateBufferedObservationsResult {
|
|
42
41
|
/** Whether the chunk was stored. */
|
|
43
42
|
persisted: boolean;
|
|
44
43
|
/** The record the chunk was written to (or would have been written to). */
|
|
45
44
|
recordId: string;
|
|
46
45
|
}
|
|
47
46
|
/** The fields of an observational memory record that decide head order. */
|
|
48
|
-
interface ObservationalMemoryHeadOrderFields {
|
|
47
|
+
export interface ObservationalMemoryHeadOrderFields {
|
|
49
48
|
generationCount: number;
|
|
50
49
|
createdAt: Date | string;
|
|
51
50
|
id: string;
|
|
@@ -54,16 +53,16 @@ interface ObservationalMemoryHeadOrderFields {
|
|
|
54
53
|
* Canonical head order: `generationCount DESC, createdAt ASC, id ASC`.
|
|
55
54
|
* Returns a negative number when `a` sorts before `b` (i.e. `a` is the better head candidate).
|
|
56
55
|
*/
|
|
57
|
-
declare function compareObservationalMemoryHeadOrder(a: ObservationalMemoryHeadOrderFields, b: ObservationalMemoryHeadOrderFields): number;
|
|
56
|
+
export declare function compareObservationalMemoryHeadOrder(a: ObservationalMemoryHeadOrderFields, b: ObservationalMemoryHeadOrderFields): number;
|
|
58
57
|
/**
|
|
59
58
|
* A buffered chunk stores `lastObservedAt = max message time + 1ms`. It is wholly covered
|
|
60
59
|
* (every message it observed is already at or before the cursor) iff
|
|
61
60
|
* `cursor >= chunk.lastObservedAt - 1ms`.
|
|
62
61
|
*/
|
|
63
|
-
declare function isBufferedChunkCoveredByCursor(chunkLastObservedAt: Date | string, cursor: Date | string | null | undefined): boolean;
|
|
62
|
+
export declare function isBufferedChunkCoveredByCursor(chunkLastObservedAt: Date | string, cursor: Date | string | null | undefined): boolean;
|
|
64
63
|
/** The later of two cursors; `undefined` only when both are absent. */
|
|
65
|
-
declare function maxObservationCursor(a: Date | string | null | undefined, b: Date | string | null | undefined): Date | undefined;
|
|
66
|
-
interface ReflectionTextPlan {
|
|
64
|
+
export declare function maxObservationCursor(a: Date | string | null | undefined, b: Date | string | null | undefined): Date | undefined;
|
|
65
|
+
export interface ReflectionTextPlan {
|
|
67
66
|
/** `equal`: stored text equals the snapshot. `append`: observations were appended after the snapshot. */
|
|
68
67
|
mode: 'equal' | 'append';
|
|
69
68
|
observations: string;
|
|
@@ -78,7 +77,7 @@ interface ReflectionTextPlan {
|
|
|
78
77
|
* after the reflection, and its tokens are added.
|
|
79
78
|
* - Anything else (a non-append rewrite): `null` — the reflection must not be applied.
|
|
80
79
|
*/
|
|
81
|
-
declare function planReflectionGenerationText(input: {
|
|
80
|
+
export declare function planReflectionGenerationText(input: {
|
|
82
81
|
storedObservations: string;
|
|
83
82
|
storedObservationTokenCount: number;
|
|
84
83
|
snapshotObservations: string;
|
|
@@ -91,12 +90,10 @@ declare function planReflectionGenerationText(input: {
|
|
|
91
90
|
* Callers of `updateActiveObservations` (which resolves `void`) can't see a commit result, so a
|
|
92
91
|
* write that was not applied throws instead of resolving as if it had committed.
|
|
93
92
|
*/
|
|
94
|
-
declare function assertActiveObservationsApplied(result: UpdateActiveObservationsResult, id: string): void;
|
|
93
|
+
export declare function assertActiveObservationsApplied(result: UpdateActiveObservationsResult, id: string): void;
|
|
95
94
|
/**
|
|
96
95
|
* Whether the stored text can still accept a reflection built from `snapshot`
|
|
97
96
|
* (equal, or only appended to since).
|
|
98
97
|
*/
|
|
99
|
-
declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
|
|
100
|
-
//#endregion
|
|
101
|
-
export { OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS, ObservationalMemoryHeadOrderFields, ReflectionTextPlan, UpdateActiveObservationsResult, UpdateBufferedObservationsResult, assertActiveObservationsApplied, compareObservationalMemoryHeadOrder, isAppendOnlySince, isBufferedChunkCoveredByCursor, maxObservationCursor, planReflectionGenerationText, withObservationalMemoryLifecycleColumns };
|
|
98
|
+
export declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
|
|
102
99
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
# Semantic recall
|
|
6
6
|
|
|
7
|
-
|
|
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
|
|
|
@@ -34,7 +38,7 @@ const agent = new Agent({
|
|
|
34
38
|
id: 'support-agent',
|
|
35
39
|
name: 'SupportAgent',
|
|
36
40
|
instructions: 'You are a helpful support agent.',
|
|
37
|
-
model: 'openai/gpt-
|
|
41
|
+
model: 'openai/gpt-6.1-sol',
|
|
38
42
|
memory: new Memory({
|
|
39
43
|
storage: new LibSQLStore({
|
|
40
44
|
id: 'agent-storage',
|
|
@@ -64,7 +68,7 @@ const agent = new Agent({
|
|
|
64
68
|
id: 'support-agent',
|
|
65
69
|
name: 'SupportAgent',
|
|
66
70
|
instructions: 'You are a helpful support agent.',
|
|
67
|
-
model: 'openai/gpt-
|
|
71
|
+
model: 'openai/gpt-6.1-sol',
|
|
68
72
|
memory: new Memory({
|
|
69
73
|
storage: new MongoDBStore({
|
|
70
74
|
id: 'agent-storage',
|
|
@@ -34,7 +34,7 @@ const agent = new Agent({
|
|
|
34
34
|
id: 'personal-assistant',
|
|
35
35
|
name: 'PersonalAssistant',
|
|
36
36
|
instructions: 'You are a helpful personal assistant.',
|
|
37
|
-
model: 'openai/gpt-
|
|
37
|
+
model: 'openai/gpt-6.1-sol',
|
|
38
38
|
memory: new Memory({
|
|
39
39
|
options: {
|
|
40
40
|
workingMemory: {
|
|
@@ -418,7 +418,7 @@ const response = await agent.generate('What do you know about me?', {
|
|
|
418
418
|
|
|
419
419
|
## Opt in to state signals (experimental)
|
|
420
420
|
|
|
421
|
-
By default, working memory reaches the model as part of the system message. You can opt into delivering it as a [state signal](https://mastra.ai/docs/
|
|
421
|
+
By default, working memory reaches the model as part of the system message. You can opt into delivering it as a [state signal](https://mastra.ai/docs/signals/state-signals) instead by setting `useStateSignals: true`:
|
|
422
422
|
|
|
423
423
|
```typescript
|
|
424
424
|
const memory = new Memory({
|
|
@@ -146,7 +146,7 @@ export const supportAgent = new Agent({
|
|
|
146
146
|
id: 'support-agent',
|
|
147
147
|
name: 'Support agent',
|
|
148
148
|
instructions: 'Answer customer support questions.',
|
|
149
|
-
model: 'openai/gpt-
|
|
149
|
+
model: 'openai/gpt-6.1-sol',
|
|
150
150
|
memory: new Memory({
|
|
151
151
|
storage: new PostgresStore({
|
|
152
152
|
id: 'support-agent-storage',
|
|
@@ -212,7 +212,7 @@ export const mongodbAgent = new Agent({
|
|
|
212
212
|
name: 'mongodb-agent',
|
|
213
213
|
instructions:
|
|
214
214
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
215
|
-
model: 'openai/gpt-
|
|
215
|
+
model: 'openai/gpt-6.1-sol',
|
|
216
216
|
memory: new Memory({
|
|
217
217
|
storage: new MongoDBStore({
|
|
218
218
|
id: 'mongodb-storage',
|
|
@@ -382,11 +382,12 @@ 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',
|
|
388
389
|
name: 'RAG Agent',
|
|
389
|
-
model: 'openai/gpt-
|
|
390
|
+
model: 'openai/gpt-6.1-sol',
|
|
390
391
|
instructions: `
|
|
391
392
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
392
393
|
${MONGODB_PROMPT}
|
|
@@ -403,7 +404,7 @@ import { PGVECTOR_PROMPT } from '@mastra/pg'
|
|
|
403
404
|
export const ragAgent = new Agent({
|
|
404
405
|
id: 'rag-agent',
|
|
405
406
|
name: 'RAG Agent',
|
|
406
|
-
model: 'openai/gpt-
|
|
407
|
+
model: 'openai/gpt-6.1-sol',
|
|
407
408
|
instructions: `
|
|
408
409
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
409
410
|
${PGVECTOR_PROMPT}
|
|
@@ -416,11 +417,12 @@ 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',
|
|
422
424
|
name: 'RAG Agent',
|
|
423
|
-
model: 'openai/gpt-
|
|
425
|
+
model: 'openai/gpt-6.1-sol',
|
|
424
426
|
instructions: `
|
|
425
427
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
426
428
|
${PINECONE_PROMPT}
|
|
@@ -433,11 +435,12 @@ 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',
|
|
439
442
|
name: 'RAG Agent',
|
|
440
|
-
model: 'openai/gpt-
|
|
443
|
+
model: 'openai/gpt-6.1-sol',
|
|
441
444
|
instructions: `
|
|
442
445
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
443
446
|
${QDRANT_PROMPT}
|
|
@@ -450,11 +453,12 @@ 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',
|
|
456
460
|
name: 'RAG Agent',
|
|
457
|
-
model: 'openai/gpt-
|
|
461
|
+
model: 'openai/gpt-6.1-sol',
|
|
458
462
|
instructions: `
|
|
459
463
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
460
464
|
${CHROMA_PROMPT}
|
|
@@ -467,11 +471,12 @@ 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',
|
|
473
478
|
name: 'RAG Agent',
|
|
474
|
-
model: 'openai/gpt-
|
|
479
|
+
model: 'openai/gpt-6.1-sol',
|
|
475
480
|
instructions: `
|
|
476
481
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
477
482
|
${ASTRA_PROMPT}
|
|
@@ -484,11 +489,12 @@ 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',
|
|
490
496
|
name: 'RAG Agent',
|
|
491
|
-
model: 'openai/gpt-
|
|
497
|
+
model: 'openai/gpt-6.1-sol',
|
|
492
498
|
instructions: `
|
|
493
499
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
494
500
|
${LIBSQL_PROMPT}
|
|
@@ -501,11 +507,12 @@ 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',
|
|
507
514
|
name: 'RAG Agent',
|
|
508
|
-
model: 'openai/gpt-
|
|
515
|
+
model: 'openai/gpt-6.1-sol',
|
|
509
516
|
instructions: `
|
|
510
517
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
511
518
|
${UPSTASH_PROMPT}
|
|
@@ -518,11 +525,12 @@ 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',
|
|
524
532
|
name: 'RAG Agent',
|
|
525
|
-
model: 'openai/gpt-
|
|
533
|
+
model: 'openai/gpt-6.1-sol',
|
|
526
534
|
instructions: `
|
|
527
535
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
528
536
|
${VECTORIZE_PROMPT}
|
|
@@ -535,11 +543,12 @@ 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',
|
|
541
550
|
name: 'RAG Agent',
|
|
542
|
-
model: 'openai/gpt-
|
|
551
|
+
model: 'openai/gpt-6.1-sol',
|
|
543
552
|
instructions: `
|
|
544
553
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
545
554
|
${OPENSEARCH_PROMPT}
|
|
@@ -552,11 +561,12 @@ 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',
|
|
558
568
|
name: 'RAG Agent',
|
|
559
|
-
model: 'openai/gpt-
|
|
569
|
+
model: 'openai/gpt-6.1-sol',
|
|
560
570
|
instructions: `
|
|
561
571
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
562
572
|
${ORACLEDB_PROMPT}
|
|
@@ -569,11 +579,12 @@ 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',
|
|
575
586
|
name: 'RAG Agent',
|
|
576
|
-
model: 'openai/gpt-
|
|
587
|
+
model: 'openai/gpt-6.1-sol',
|
|
577
588
|
instructions: `
|
|
578
589
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
579
590
|
${S3VECTORS_PROMPT}
|
|
@@ -605,7 +616,7 @@ const initialResults = await pgVector.query({
|
|
|
605
616
|
// Create a relevance scorer
|
|
606
617
|
const relevanceProvider = new MastraAgentRelevanceScorer(
|
|
607
618
|
'relevance-scorer',
|
|
608
|
-
'openai/gpt-
|
|
619
|
+
'openai/gpt-6.1-sol',
|
|
609
620
|
)
|
|
610
621
|
|
|
611
622
|
// Re-rank the results
|
|
@@ -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
|
|
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}\
|
|
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
|
|
|
@@ -558,7 +558,7 @@ export const mongodbAgent = new Agent({
|
|
|
558
558
|
name: 'mongodb-agent',
|
|
559
559
|
instructions:
|
|
560
560
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
561
|
-
model: 'openai/gpt-
|
|
561
|
+
model: 'openai/gpt-6.1-sol',
|
|
562
562
|
memory: new Memory({
|
|
563
563
|
storage: new MongoDBStore({
|
|
564
564
|
id: 'mongodb-storage',
|
|
@@ -623,7 +623,7 @@ export const mongodbVoyageAgent = new Agent({
|
|
|
623
623
|
id: 'mongodb-voyage-agent',
|
|
624
624
|
name: 'MongoDB VoyageAI Agent',
|
|
625
625
|
instructions: 'You are an AI agent with semantic recall powered by VoyageAI and MongoDB.',
|
|
626
|
-
model: 'openai/gpt-
|
|
626
|
+
model: 'openai/gpt-6.1-sol',
|
|
627
627
|
memory: new Memory({
|
|
628
628
|
storage: new MongoDBStore({
|
|
629
629
|
id: 'mongodb-storage',
|
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
|
-
|
|
13
|
-
var version = "1.24.
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|