@mastra/mongodb 1.24.0-alpha.1 → 1.24.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/_types/@internal_core/dist/memory/index.d.ts +12 -13
- 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 +24 -2
- package/dist/docs/references/docs-memory-working-memory.md +3 -3
- 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 +13 -13
- package/dist/docs/references/reference-vectors-mongodb.md +2 -2
- package/dist/index.cjs +31 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -27
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +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 -12
|
@@ -9,18 +9,18 @@
|
|
|
9
9
|
* into the table schema they get from `@mastra/core`, so the columns exist even when the
|
|
10
10
|
* installed core predates them.
|
|
11
11
|
*/
|
|
12
|
-
declare const OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS: {
|
|
12
|
+
export declare const OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS: {
|
|
13
13
|
readonly supersededBy: {
|
|
14
14
|
readonly type: 'text';
|
|
15
15
|
readonly nullable: true;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
/** `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;
|
|
19
|
+
export declare function withObservationalMemoryLifecycleColumns<T extends object>(schema: T | undefined): (T & typeof OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS) | undefined;
|
|
20
20
|
/**
|
|
21
21
|
* Result of `commitActiveObservations`.
|
|
22
22
|
*/
|
|
23
|
-
interface UpdateActiveObservationsResult {
|
|
23
|
+
export interface UpdateActiveObservationsResult {
|
|
24
24
|
/** Whether the observations were written. */
|
|
25
25
|
applied: boolean;
|
|
26
26
|
/**
|
|
@@ -38,14 +38,14 @@ interface UpdateActiveObservationsResult {
|
|
|
38
38
|
* the head's cursor. Chunks carry `lastObservedAt = max message time + 1ms`, so a chunk is
|
|
39
39
|
* wholly covered iff `head.lastObservedAt >= chunk.lastObservedAt - 1ms`.
|
|
40
40
|
*/
|
|
41
|
-
interface UpdateBufferedObservationsResult {
|
|
41
|
+
export interface UpdateBufferedObservationsResult {
|
|
42
42
|
/** Whether the chunk was stored. */
|
|
43
43
|
persisted: boolean;
|
|
44
44
|
/** The record the chunk was written to (or would have been written to). */
|
|
45
45
|
recordId: string;
|
|
46
46
|
}
|
|
47
47
|
/** The fields of an observational memory record that decide head order. */
|
|
48
|
-
interface ObservationalMemoryHeadOrderFields {
|
|
48
|
+
export interface ObservationalMemoryHeadOrderFields {
|
|
49
49
|
generationCount: number;
|
|
50
50
|
createdAt: Date | string;
|
|
51
51
|
id: string;
|
|
@@ -54,16 +54,16 @@ interface ObservationalMemoryHeadOrderFields {
|
|
|
54
54
|
* Canonical head order: `generationCount DESC, createdAt ASC, id ASC`.
|
|
55
55
|
* Returns a negative number when `a` sorts before `b` (i.e. `a` is the better head candidate).
|
|
56
56
|
*/
|
|
57
|
-
declare function compareObservationalMemoryHeadOrder(a: ObservationalMemoryHeadOrderFields, b: ObservationalMemoryHeadOrderFields): number;
|
|
57
|
+
export declare function compareObservationalMemoryHeadOrder(a: ObservationalMemoryHeadOrderFields, b: ObservationalMemoryHeadOrderFields): number;
|
|
58
58
|
/**
|
|
59
59
|
* A buffered chunk stores `lastObservedAt = max message time + 1ms`. It is wholly covered
|
|
60
60
|
* (every message it observed is already at or before the cursor) iff
|
|
61
61
|
* `cursor >= chunk.lastObservedAt - 1ms`.
|
|
62
62
|
*/
|
|
63
|
-
declare function isBufferedChunkCoveredByCursor(chunkLastObservedAt: Date | string, cursor: Date | string | null | undefined): boolean;
|
|
63
|
+
export declare function isBufferedChunkCoveredByCursor(chunkLastObservedAt: Date | string, cursor: Date | string | null | undefined): boolean;
|
|
64
64
|
/** 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 {
|
|
65
|
+
export declare function maxObservationCursor(a: Date | string | null | undefined, b: Date | string | null | undefined): Date | undefined;
|
|
66
|
+
export interface ReflectionTextPlan {
|
|
67
67
|
/** `equal`: stored text equals the snapshot. `append`: observations were appended after the snapshot. */
|
|
68
68
|
mode: 'equal' | 'append';
|
|
69
69
|
observations: string;
|
|
@@ -78,7 +78,7 @@ interface ReflectionTextPlan {
|
|
|
78
78
|
* after the reflection, and its tokens are added.
|
|
79
79
|
* - Anything else (a non-append rewrite): `null` — the reflection must not be applied.
|
|
80
80
|
*/
|
|
81
|
-
declare function planReflectionGenerationText(input: {
|
|
81
|
+
export declare function planReflectionGenerationText(input: {
|
|
82
82
|
storedObservations: string;
|
|
83
83
|
storedObservationTokenCount: number;
|
|
84
84
|
snapshotObservations: string;
|
|
@@ -91,12 +91,11 @@ declare function planReflectionGenerationText(input: {
|
|
|
91
91
|
* Callers of `updateActiveObservations` (which resolves `void`) can't see a commit result, so a
|
|
92
92
|
* write that was not applied throws instead of resolving as if it had committed.
|
|
93
93
|
*/
|
|
94
|
-
declare function assertActiveObservationsApplied(result: UpdateActiveObservationsResult, id: string): void;
|
|
94
|
+
export declare function assertActiveObservationsApplied(result: UpdateActiveObservationsResult, id: string): void;
|
|
95
95
|
/**
|
|
96
96
|
* Whether the stored text can still accept a reflection built from `snapshot`
|
|
97
97
|
* (equal, or only appended to since).
|
|
98
98
|
*/
|
|
99
|
-
declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
|
|
99
|
+
export declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
|
|
100
100
|
//#endregion
|
|
101
|
-
export { OBSERVATIONAL_MEMORY_LIFECYCLE_COLUMNS, ObservationalMemoryHeadOrderFields, ReflectionTextPlan, UpdateActiveObservationsResult, UpdateBufferedObservationsResult, assertActiveObservationsApplied, compareObservationalMemoryHeadOrder, isAppendOnlySince, isBufferedChunkCoveredByCursor, maxObservationCursor, planReflectionGenerationText, withObservationalMemoryLifecycleColumns };
|
|
102
101
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -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.
|
|
6
|
+
version: "1.24.1-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -34,7 +34,7 @@ const agent = new Agent({
|
|
|
34
34
|
id: 'support-agent',
|
|
35
35
|
name: 'SupportAgent',
|
|
36
36
|
instructions: 'You are a helpful support agent.',
|
|
37
|
-
model: 'openai/gpt-
|
|
37
|
+
model: 'openai/gpt-6.1-sol',
|
|
38
38
|
memory: new Memory({
|
|
39
39
|
storage: new LibSQLStore({
|
|
40
40
|
id: 'agent-storage',
|
|
@@ -64,7 +64,7 @@ const agent = new Agent({
|
|
|
64
64
|
id: 'support-agent',
|
|
65
65
|
name: 'SupportAgent',
|
|
66
66
|
instructions: 'You are a helpful support agent.',
|
|
67
|
-
model: 'openai/gpt-
|
|
67
|
+
model: 'openai/gpt-6.1-sol',
|
|
68
68
|
memory: new Memory({
|
|
69
69
|
storage: new MongoDBStore({
|
|
70
70
|
id: 'agent-storage',
|
|
@@ -403,6 +403,28 @@ Memory uses a single embedder for both storing and recalling messages, so pick o
|
|
|
403
403
|
|
|
404
404
|
Multilingual E5 produces 1024-dimensional vectors. Your vector index must be created with matching dimensions, and E5 vectors can't be mixed with vectors from another embedder in the same index.
|
|
405
405
|
|
|
406
|
+
FastEmbed models embed at most 512 tokens per input (roughly 2,000 to 2,500 characters of English text). Longer inputs are truncated, so text past the limit doesn't affect the embedding and can't be found by semantic recall. The AI SDK v3 FastEmbed models return a warning when this happens. The legacy v1 and v2 models don't. If you embed long documents with FastEmbed, chunk them to fit the window, for example with `maxSize: 1500` in `MDocument.chunk()`.
|
|
407
|
+
|
|
408
|
+
### Setting the embedding dimension
|
|
409
|
+
|
|
410
|
+
To name the vector index, Memory needs the embedder's output dimension. By default it finds the dimension by embedding a short probe string the first time semantic recall is set up, once per `Memory` instance. If you already know the dimension, set `embeddingDimension`. Memory then skips the probe, so startup makes no embedding call and doesn't depend on the embedding provider being reachable:
|
|
411
|
+
|
|
412
|
+
```ts
|
|
413
|
+
import { Memory } from '@mastra/memory'
|
|
414
|
+
|
|
415
|
+
const memory = new Memory({
|
|
416
|
+
embedder: 'openai/text-embedding-3-small',
|
|
417
|
+
embeddingDimension: 1536,
|
|
418
|
+
options: {
|
|
419
|
+
semanticRecall: true,
|
|
420
|
+
},
|
|
421
|
+
})
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
The index name is the same whether the dimension is configured or probed, so existing indexes keep working.
|
|
425
|
+
|
|
426
|
+
The value must match the vectors the embedder returns. Memory compares it with the first real embedding, and on a mismatch it throws a `MASTRA_MEMORY_EMBEDDING_DIMENSION_MISMATCH` error naming both values before creating or querying any index. Update `embeddingDimension` whenever you change the embedding model or its output dimension.
|
|
427
|
+
|
|
406
428
|
## PostgreSQL index optimization
|
|
407
429
|
|
|
408
430
|
When using PostgreSQL as your vector store, you can optimize semantic recall performance by configuring the vector index. This is particularly important for large-scale deployments with thousands of messages.
|
|
@@ -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: {
|
|
@@ -217,7 +217,7 @@ const paragraphMemory = new Memory({
|
|
|
217
217
|
|
|
218
218
|
Working memory can also be defined using a structured schema instead of a Markdown template. A [Standard JSON Schema](https://standardschema.dev/json-schema) ([Zod](https://zod.dev/), [Valibot](https://valibot.dev/), [ArkType](https://arktype.io/), etc.). When using a schema, the agent will see and update working memory as a JSON object matching your schema.
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
You can specify either `template` or `schema`, but not both. If you omit both, Mastra uses the default working memory template.
|
|
221
221
|
|
|
222
222
|
### Example: Schema-Based Working Memory
|
|
223
223
|
|
|
@@ -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',
|
|
@@ -386,7 +386,7 @@ import { MONGODB_PROMPT } from '@mastra/mongodb'
|
|
|
386
386
|
export const ragAgent = new Agent({
|
|
387
387
|
id: 'rag-agent',
|
|
388
388
|
name: 'RAG Agent',
|
|
389
|
-
model: 'openai/gpt-
|
|
389
|
+
model: 'openai/gpt-6.1-sol',
|
|
390
390
|
instructions: `
|
|
391
391
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
392
392
|
${MONGODB_PROMPT}
|
|
@@ -403,7 +403,7 @@ import { PGVECTOR_PROMPT } from '@mastra/pg'
|
|
|
403
403
|
export const ragAgent = new Agent({
|
|
404
404
|
id: 'rag-agent',
|
|
405
405
|
name: 'RAG Agent',
|
|
406
|
-
model: 'openai/gpt-
|
|
406
|
+
model: 'openai/gpt-6.1-sol',
|
|
407
407
|
instructions: `
|
|
408
408
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
409
409
|
${PGVECTOR_PROMPT}
|
|
@@ -420,7 +420,7 @@ import { PINECONE_PROMPT } from '@mastra/pinecone'
|
|
|
420
420
|
export const ragAgent = new Agent({
|
|
421
421
|
id: 'rag-agent',
|
|
422
422
|
name: 'RAG Agent',
|
|
423
|
-
model: 'openai/gpt-
|
|
423
|
+
model: 'openai/gpt-6.1-sol',
|
|
424
424
|
instructions: `
|
|
425
425
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
426
426
|
${PINECONE_PROMPT}
|
|
@@ -437,7 +437,7 @@ import { QDRANT_PROMPT } from '@mastra/qdrant'
|
|
|
437
437
|
export const ragAgent = new Agent({
|
|
438
438
|
id: 'rag-agent',
|
|
439
439
|
name: 'RAG Agent',
|
|
440
|
-
model: 'openai/gpt-
|
|
440
|
+
model: 'openai/gpt-6.1-sol',
|
|
441
441
|
instructions: `
|
|
442
442
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
443
443
|
${QDRANT_PROMPT}
|
|
@@ -454,7 +454,7 @@ import { CHROMA_PROMPT } from '@mastra/chroma'
|
|
|
454
454
|
export const ragAgent = new Agent({
|
|
455
455
|
id: 'rag-agent',
|
|
456
456
|
name: 'RAG Agent',
|
|
457
|
-
model: 'openai/gpt-
|
|
457
|
+
model: 'openai/gpt-6.1-sol',
|
|
458
458
|
instructions: `
|
|
459
459
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
460
460
|
${CHROMA_PROMPT}
|
|
@@ -471,7 +471,7 @@ import { ASTRA_PROMPT } from '@mastra/astra'
|
|
|
471
471
|
export const ragAgent = new Agent({
|
|
472
472
|
id: 'rag-agent',
|
|
473
473
|
name: 'RAG Agent',
|
|
474
|
-
model: 'openai/gpt-
|
|
474
|
+
model: 'openai/gpt-6.1-sol',
|
|
475
475
|
instructions: `
|
|
476
476
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
477
477
|
${ASTRA_PROMPT}
|
|
@@ -488,7 +488,7 @@ import { LIBSQL_PROMPT } from '@mastra/libsql'
|
|
|
488
488
|
export const ragAgent = new Agent({
|
|
489
489
|
id: 'rag-agent',
|
|
490
490
|
name: 'RAG Agent',
|
|
491
|
-
model: 'openai/gpt-
|
|
491
|
+
model: 'openai/gpt-6.1-sol',
|
|
492
492
|
instructions: `
|
|
493
493
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
494
494
|
${LIBSQL_PROMPT}
|
|
@@ -505,7 +505,7 @@ import { UPSTASH_PROMPT } from '@mastra/upstash'
|
|
|
505
505
|
export const ragAgent = new Agent({
|
|
506
506
|
id: 'rag-agent',
|
|
507
507
|
name: 'RAG Agent',
|
|
508
|
-
model: 'openai/gpt-
|
|
508
|
+
model: 'openai/gpt-6.1-sol',
|
|
509
509
|
instructions: `
|
|
510
510
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
511
511
|
${UPSTASH_PROMPT}
|
|
@@ -522,7 +522,7 @@ import { VECTORIZE_PROMPT } from '@mastra/vectorize'
|
|
|
522
522
|
export const ragAgent = new Agent({
|
|
523
523
|
id: 'rag-agent',
|
|
524
524
|
name: 'RAG Agent',
|
|
525
|
-
model: 'openai/gpt-
|
|
525
|
+
model: 'openai/gpt-6.1-sol',
|
|
526
526
|
instructions: `
|
|
527
527
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
528
528
|
${VECTORIZE_PROMPT}
|
|
@@ -539,7 +539,7 @@ import { OPENSEARCH_PROMPT } from '@mastra/opensearch'
|
|
|
539
539
|
export const ragAgent = new Agent({
|
|
540
540
|
id: 'rag-agent',
|
|
541
541
|
name: 'RAG Agent',
|
|
542
|
-
model: 'openai/gpt-
|
|
542
|
+
model: 'openai/gpt-6.1-sol',
|
|
543
543
|
instructions: `
|
|
544
544
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
545
545
|
${OPENSEARCH_PROMPT}
|
|
@@ -556,7 +556,7 @@ import { ORACLEDB_PROMPT } from '@mastra/oracledb'
|
|
|
556
556
|
export const ragAgent = new Agent({
|
|
557
557
|
id: 'rag-agent',
|
|
558
558
|
name: 'RAG Agent',
|
|
559
|
-
model: 'openai/gpt-
|
|
559
|
+
model: 'openai/gpt-6.1-sol',
|
|
560
560
|
instructions: `
|
|
561
561
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
562
562
|
${ORACLEDB_PROMPT}
|
|
@@ -573,7 +573,7 @@ import { S3VECTORS_PROMPT } from '@mastra/s3vectors'
|
|
|
573
573
|
export const ragAgent = new Agent({
|
|
574
574
|
id: 'rag-agent',
|
|
575
575
|
name: 'RAG Agent',
|
|
576
|
-
model: 'openai/gpt-
|
|
576
|
+
model: 'openai/gpt-6.1-sol',
|
|
577
577
|
instructions: `
|
|
578
578
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
579
579
|
${S3VECTORS_PROMPT}
|
|
@@ -605,7 +605,7 @@ const initialResults = await pgVector.query({
|
|
|
605
605
|
// Create a relevance scorer
|
|
606
606
|
const relevanceProvider = new MastraAgentRelevanceScorer(
|
|
607
607
|
'relevance-scorer',
|
|
608
|
-
'openai/gpt-
|
|
608
|
+
'openai/gpt-6.1-sol',
|
|
609
609
|
)
|
|
610
610
|
|
|
611
611
|
// Re-rank the results
|
|
@@ -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
|
@@ -10,7 +10,7 @@ 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
12
|
//#region package.json
|
|
13
|
-
var version = "1.24.
|
|
13
|
+
var version = "1.24.1-alpha.0";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/vector/filter.ts
|
|
16
16
|
/**
|
|
@@ -42,13 +42,15 @@ var MongoDBFilterTranslator = class extends _mastra_core_vector_filter.BaseFilte
|
|
|
42
42
|
return Object.fromEntries(translatedEntries);
|
|
43
43
|
}
|
|
44
44
|
translateOperatorValue(operator, value) {
|
|
45
|
-
if (this.isLogicalOperator(operator))
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
if (this.isLogicalOperator(operator)) {
|
|
46
|
+
if (operator === "$not") {
|
|
47
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("$not operator requires an object");
|
|
48
|
+
if (this.isEmpty(value)) throw new Error("$not operator cannot be empty");
|
|
49
|
+
return this.translateNode(value);
|
|
50
|
+
} else {
|
|
51
|
+
if (!Array.isArray(value)) throw new Error(`Value for logical operator ${operator} must be an array`);
|
|
52
|
+
return value.map((item) => this.translateNode(item));
|
|
53
|
+
}
|
|
52
54
|
}
|
|
53
55
|
if (this.isBasicOperator(operator) || this.isNumericOperator(operator)) {
|
|
54
56
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -1532,17 +1534,19 @@ var MongoDBVector = class MongoDBVector extends _mastra_core_vector.MastraVector
|
|
|
1532
1534
|
if (Array.isArray(filter)) return filter.map((item) => this.transformMetadataFilter(item, metadataMode));
|
|
1533
1535
|
if (metadataMode === "document") {
|
|
1534
1536
|
const transformed = {};
|
|
1535
|
-
for (const [key, value] of Object.entries(filter)) if (key.startsWith("$"))
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1537
|
+
for (const [key, value] of Object.entries(filter)) if (key.startsWith("$")) {
|
|
1538
|
+
if (Array.isArray(value)) transformed[key] = value.map((item) => this.transformMetadataFilter(item, metadataMode));
|
|
1539
|
+
else if (typeof value === "object" && value !== null) transformed[key] = this.transformMetadataFilter(value, metadataMode);
|
|
1540
|
+
else transformed[key] = value;
|
|
1541
|
+
} else transformed[key] = value;
|
|
1539
1542
|
return transformed;
|
|
1540
1543
|
}
|
|
1541
1544
|
const transformed = {};
|
|
1542
|
-
for (const [key, value] of Object.entries(filter)) if (key.startsWith("$"))
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1545
|
+
for (const [key, value] of Object.entries(filter)) if (key.startsWith("$")) {
|
|
1546
|
+
if (Array.isArray(value)) transformed[key] = value.map((item) => this.transformMetadataFilter(item, metadataMode));
|
|
1547
|
+
else if (typeof value === "object" && value !== null) transformed[key] = this.transformMetadataFilter(value, metadataMode);
|
|
1548
|
+
else transformed[key] = value;
|
|
1549
|
+
} else if (key.startsWith("metadata.")) transformed[key] = value;
|
|
1546
1550
|
else if (this.isMetadataField(key)) transformed[`metadata.${key}`] = value;
|
|
1547
1551
|
else transformed[key] = value;
|
|
1548
1552
|
return transformed;
|
|
@@ -9577,15 +9581,13 @@ MIGRATION REQUIRED: Duplicate spans detected in ${_mastra_core_storage.TABLE_SPA
|
|
|
9577
9581
|
error: null
|
|
9578
9582
|
});
|
|
9579
9583
|
break;
|
|
9580
|
-
case _mastra_core_storage.TraceStatus.SUCCESS:
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
});
|
|
9588
|
-
break;
|
|
9584
|
+
case _mastra_core_storage.TraceStatus.SUCCESS: andConditions.push({
|
|
9585
|
+
endedAt: {
|
|
9586
|
+
$exists: true,
|
|
9587
|
+
$ne: null
|
|
9588
|
+
},
|
|
9589
|
+
error: null
|
|
9590
|
+
});
|
|
9589
9591
|
}
|
|
9590
9592
|
}
|
|
9591
9593
|
if (andConditions.length) mongoFilter.$and = andConditions;
|
|
@@ -12367,8 +12369,10 @@ var WorkflowsStorageMongoDB = class WorkflowsStorageMongoDB extends _mastra_core
|
|
|
12367
12369
|
if (options.workflowName) query["workflow_name"] = options.workflowName;
|
|
12368
12370
|
if (options.status) query["snapshot.status"] = options.status;
|
|
12369
12371
|
if (options.fromDate) query["createdAt"] = { $gte: options.fromDate };
|
|
12370
|
-
if (options.toDate)
|
|
12371
|
-
|
|
12372
|
+
if (options.toDate) {
|
|
12373
|
+
if (query["createdAt"]) query["createdAt"].$lte = options.toDate;
|
|
12374
|
+
else query["createdAt"] = { $lte: options.toDate };
|
|
12375
|
+
}
|
|
12372
12376
|
if (options.resourceId) query["resourceId"] = options.resourceId;
|
|
12373
12377
|
const collection = await this.getCollection(_mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT);
|
|
12374
12378
|
let total = 0;
|