@mastra/mongodb 1.5.3 → 1.5.4-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/CHANGELOG.md +9 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-mongodb.md +5 -5
- package/dist/docs/references/reference-vectors-mongodb.md +32 -32
- package/dist/index.cjs +13 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/mongodb
|
|
2
2
|
|
|
3
|
+
## 1.5.4-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed MongoDB observational memory buffering so legacy records with `bufferedObservationChunks: null` can append chunks safely and continue storing chunk buffers as arrays after activation. ([#13803](https://github.com/mastra-ai/mastra/pull/13803))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`41e48c1`](https://github.com/mastra-ai/mastra/commit/41e48c198eee846478e60c02ec432c19d322a517), [`82469d3`](https://github.com/mastra-ai/mastra/commit/82469d3135d5a49dd8dc8feec0ff398b4e0225a0), [`33e2fd5`](https://github.com/mastra-ai/mastra/commit/33e2fd5088f83666df17401e2da68c943dbc0448), [`7ef6e2c`](https://github.com/mastra-ai/mastra/commit/7ef6e2c61be5a42e26f55d15b5902866fc76634f), [`b12d2a5`](https://github.com/mastra-ai/mastra/commit/b12d2a59a48be0477cabae66eb6cf0fc94a7d40d), [`fa37d39`](https://github.com/mastra-ai/mastra/commit/fa37d39910421feaf8847716292e3d65dd4f30c2), [`b12d2a5`](https://github.com/mastra-ai/mastra/commit/b12d2a59a48be0477cabae66eb6cf0fc94a7d40d), [`71c38bf`](https://github.com/mastra-ai/mastra/commit/71c38bf905905148ecd0e75c07c1f9825d299b76), [`f993c38`](https://github.com/mastra-ai/mastra/commit/f993c3848c97479b813231be872443bedeced6ab), [`f51849a`](https://github.com/mastra-ai/mastra/commit/f51849a568935122b5100b7ee69704e6d680cf7b), [`9bf3a0d`](https://github.com/mastra-ai/mastra/commit/9bf3a0dac602787925f1762f1f0387d7b4a59620), [`cafa045`](https://github.com/mastra-ai/mastra/commit/cafa0453c9de141ad50c09a13894622dffdd9978), [`1fd9ddb`](https://github.com/mastra-ai/mastra/commit/1fd9ddbb3fe83b281b12bd2e27e426ae86288266), [`6135ef4`](https://github.com/mastra-ai/mastra/commit/6135ef4f5288652bf45f616ec590607e4c95f443), [`d9d228c`](https://github.com/mastra-ai/mastra/commit/d9d228c0c6ae82ae6ce3b540a3a56b2b1c2b8d98), [`5576507`](https://github.com/mastra-ai/mastra/commit/55765071e360fb97e443aa0a91ccf7e1cd8d92aa), [`79d69c9`](https://github.com/mastra-ai/mastra/commit/79d69c9d5f842ff1c31352fb6026f04c1f6190f3), [`94f44b8`](https://github.com/mastra-ai/mastra/commit/94f44b827ce57b179e50f4916a84c0fa6e7f3b8c), [`13187db`](https://github.com/mastra-ai/mastra/commit/13187dbac880174232dedc5a501ff6c5d0fe59bc), [`2ae5311`](https://github.com/mastra-ai/mastra/commit/2ae531185fff66a80fa165c0999e3d801900e89d), [`6135ef4`](https://github.com/mastra-ai/mastra/commit/6135ef4f5288652bf45f616ec590607e4c95f443)]:
|
|
10
|
+
- @mastra/core@1.10.0-alpha.0
|
|
11
|
+
|
|
3
12
|
## 1.5.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -44,15 +44,15 @@ const storage = new MongoDBStore({
|
|
|
44
44
|
|
|
45
45
|
## Parameters
|
|
46
46
|
|
|
47
|
-
**id
|
|
47
|
+
**id** (`string`): Unique identifier for this storage instance.
|
|
48
48
|
|
|
49
|
-
**uri
|
|
49
|
+
**uri** (`string`): MongoDB connection string (e.g., mongodb+srv://user:password\@cluster.mongodb.net)
|
|
50
50
|
|
|
51
|
-
**url
|
|
51
|
+
**url** (`string`): Deprecated. Use uri instead. MongoDB connection string (supported for backward compatibility).
|
|
52
52
|
|
|
53
|
-
**dbName
|
|
53
|
+
**dbName** (`string`): The name of the database you want the storage to use.
|
|
54
54
|
|
|
55
|
-
**options
|
|
55
|
+
**options** (`MongoClientOptions`): MongoDB client options for advanced configuration (SSL, connection pooling, etc.).
|
|
56
56
|
|
|
57
57
|
> **Deprecation Notice:** The `url` parameter is deprecated but still supported for backward compatibility. Please use `uri` instead in all new code.
|
|
58
58
|
|
|
@@ -57,15 +57,15 @@ const store = new MongoDBVector({
|
|
|
57
57
|
|
|
58
58
|
## Constructor Options
|
|
59
59
|
|
|
60
|
-
**id
|
|
60
|
+
**id** (`string`): Unique identifier for this vector store instance
|
|
61
61
|
|
|
62
|
-
**uri
|
|
62
|
+
**uri** (`string`): MongoDB connection string
|
|
63
63
|
|
|
64
|
-
**dbName
|
|
64
|
+
**dbName** (`string`): Name of the MongoDB database to use
|
|
65
65
|
|
|
66
|
-
**options
|
|
66
|
+
**options** (`MongoClientOptions`): Optional MongoDB client options
|
|
67
67
|
|
|
68
|
-
**embeddingFieldPath
|
|
68
|
+
**embeddingFieldPath** (`string`): Path to the field that stores vector embeddings. Supports nested paths using dot notation (e.g., 'text.contentEmbedding'). (Default: `embedding`)
|
|
69
69
|
|
|
70
70
|
## Methods
|
|
71
71
|
|
|
@@ -73,47 +73,47 @@ const store = new MongoDBVector({
|
|
|
73
73
|
|
|
74
74
|
Creates a new vector index (collection) in MongoDB.
|
|
75
75
|
|
|
76
|
-
**indexName
|
|
76
|
+
**indexName** (`string`): Name of the collection to create
|
|
77
77
|
|
|
78
|
-
**dimension
|
|
78
|
+
**dimension** (`number`): Vector dimension (must match your embedding model)
|
|
79
79
|
|
|
80
|
-
**metric
|
|
80
|
+
**metric** (`'cosine' | 'euclidean' | 'dotproduct'`): Distance metric for similarity search (Default: `cosine`)
|
|
81
81
|
|
|
82
82
|
### upsert()
|
|
83
83
|
|
|
84
84
|
Adds or updates vectors and their metadata in the collection.
|
|
85
85
|
|
|
86
|
-
**indexName
|
|
86
|
+
**indexName** (`string`): Name of the collection to insert into
|
|
87
87
|
|
|
88
|
-
**vectors
|
|
88
|
+
**vectors** (`number[][]`): Array of embedding vectors
|
|
89
89
|
|
|
90
|
-
**metadata
|
|
90
|
+
**metadata** (`Record<string, any>[]`): Metadata for each vector
|
|
91
91
|
|
|
92
|
-
**ids
|
|
92
|
+
**ids** (`string[]`): Optional vector IDs (auto-generated if not provided)
|
|
93
93
|
|
|
94
94
|
### query()
|
|
95
95
|
|
|
96
96
|
Searches for similar vectors with optional metadata filtering.
|
|
97
97
|
|
|
98
|
-
**indexName
|
|
98
|
+
**indexName** (`string`): Name of the collection to search in
|
|
99
99
|
|
|
100
|
-
**queryVector
|
|
100
|
+
**queryVector** (`number[]`): Query vector to find similar vectors for
|
|
101
101
|
|
|
102
|
-
**topK
|
|
102
|
+
**topK** (`number`): Number of results to return (Default: `10`)
|
|
103
103
|
|
|
104
|
-
**filter
|
|
104
|
+
**filter** (`Record<string, any>`): Metadata filters (applies to the \`metadata\` field)
|
|
105
105
|
|
|
106
|
-
**documentFilter
|
|
106
|
+
**documentFilter** (`Record<string, any>`): Filters on original document fields (not just metadata)
|
|
107
107
|
|
|
108
|
-
**includeVector
|
|
108
|
+
**includeVector** (`boolean`): Whether to include vector data in results (Default: `false`)
|
|
109
109
|
|
|
110
|
-
**minScore
|
|
110
|
+
**minScore** (`number`): Minimum similarity score threshold (Default: `0`)
|
|
111
111
|
|
|
112
112
|
### describeIndex()
|
|
113
113
|
|
|
114
114
|
Returns information about the index (collection).
|
|
115
115
|
|
|
116
|
-
**indexName
|
|
116
|
+
**indexName** (`string`): Name of the collection to describe
|
|
117
117
|
|
|
118
118
|
Returns:
|
|
119
119
|
|
|
@@ -129,7 +129,7 @@ interface IndexStats {
|
|
|
129
129
|
|
|
130
130
|
Deletes a collection and all its data.
|
|
131
131
|
|
|
132
|
-
**indexName
|
|
132
|
+
**indexName** (`string`): Name of the collection to delete
|
|
133
133
|
|
|
134
134
|
### listIndexes()
|
|
135
135
|
|
|
@@ -141,35 +141,35 @@ Returns: `Promise<string[]>`
|
|
|
141
141
|
|
|
142
142
|
Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
|
|
143
143
|
|
|
144
|
-
**indexName
|
|
144
|
+
**indexName** (`string`): Name of the collection containing the vector
|
|
145
145
|
|
|
146
|
-
**id
|
|
146
|
+
**id** (`string`): ID of the vector entry to update (mutually exclusive with filter)
|
|
147
147
|
|
|
148
|
-
**filter
|
|
148
|
+
**filter** (`Record<string, any>`): Metadata filter to identify vector(s) to update (mutually exclusive with id)
|
|
149
149
|
|
|
150
|
-
**update
|
|
150
|
+
**update** (`object`): Update data containing vector and/or metadata
|
|
151
151
|
|
|
152
|
-
**update.vector
|
|
152
|
+
**update.vector** (`number[]`): New vector data to update
|
|
153
153
|
|
|
154
|
-
**update.metadata
|
|
154
|
+
**update.metadata** (`Record<string, any>`): New metadata to update
|
|
155
155
|
|
|
156
156
|
### deleteVector()
|
|
157
157
|
|
|
158
158
|
Deletes a specific vector entry from an index by its ID.
|
|
159
159
|
|
|
160
|
-
**indexName
|
|
160
|
+
**indexName** (`string`): Name of the collection containing the vector
|
|
161
161
|
|
|
162
|
-
**id
|
|
162
|
+
**id** (`string`): ID of the vector entry to delete
|
|
163
163
|
|
|
164
164
|
### deleteVectors()
|
|
165
165
|
|
|
166
166
|
Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
|
|
167
167
|
|
|
168
|
-
**indexName
|
|
168
|
+
**indexName** (`string`): Name of the collection containing the vectors to delete
|
|
169
169
|
|
|
170
|
-
**ids
|
|
170
|
+
**ids** (`string[]`): Array of vector IDs to delete (mutually exclusive with filter)
|
|
171
171
|
|
|
172
|
-
**filter
|
|
172
|
+
**filter** (`Record<string, any>`): Metadata filter to identify vectors to delete (mutually exclusive with ids)
|
|
173
173
|
|
|
174
174
|
### disconnect()
|
|
175
175
|
|
package/dist/index.cjs
CHANGED
|
@@ -14,7 +14,7 @@ var evals = require('@mastra/core/evals');
|
|
|
14
14
|
|
|
15
15
|
// package.json
|
|
16
16
|
var package_default = {
|
|
17
|
-
version: "1.5.
|
|
17
|
+
version: "1.5.4-alpha.0"};
|
|
18
18
|
var MongoDBFilterTranslator = class extends filter.BaseFilterTranslator {
|
|
19
19
|
getSupportedOperators() {
|
|
20
20
|
return {
|
|
@@ -3796,7 +3796,7 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends storage.MemorySto
|
|
|
3796
3796
|
generationCount: Number(doc.generationCount || 0),
|
|
3797
3797
|
activeObservations: doc.activeObservations || "",
|
|
3798
3798
|
// Handle new chunk-based structure
|
|
3799
|
-
bufferedObservationChunks: doc.bufferedObservationChunks
|
|
3799
|
+
bufferedObservationChunks: Array.isArray(doc.bufferedObservationChunks) ? doc.bufferedObservationChunks : void 0,
|
|
3800
3800
|
// Deprecated fields (for backward compatibility)
|
|
3801
3801
|
bufferedObservations: doc.activeObservationsPendingUpdate || void 0,
|
|
3802
3802
|
bufferedObservationTokens: doc.bufferedObservationTokens ? Number(doc.bufferedObservationTokens) : void 0,
|
|
@@ -3947,7 +3947,7 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends storage.MemorySto
|
|
|
3947
3947
|
totalTokensObserved: record.totalTokensObserved || 0,
|
|
3948
3948
|
observationTokenCount: record.observationTokenCount || 0,
|
|
3949
3949
|
observedMessageIds: record.observedMessageIds || null,
|
|
3950
|
-
bufferedObservationChunks: record.bufferedObservationChunks
|
|
3950
|
+
bufferedObservationChunks: Array.isArray(record.bufferedObservationChunks) ? record.bufferedObservationChunks : [],
|
|
3951
3951
|
bufferedReflection: record.bufferedReflection || null,
|
|
3952
3952
|
bufferedReflectionTokens: record.bufferedReflectionTokens ?? null,
|
|
3953
3953
|
bufferedReflectionInputTokens: record.bufferedReflectionInputTokens ?? null,
|
|
@@ -4288,17 +4288,17 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends storage.MemorySto
|
|
|
4288
4288
|
suggestedContinuation: input.chunk.suggestedContinuation,
|
|
4289
4289
|
currentTask: input.chunk.currentTask
|
|
4290
4290
|
};
|
|
4291
|
-
const
|
|
4291
|
+
const now = /* @__PURE__ */ new Date();
|
|
4292
|
+
const setStage = {
|
|
4293
|
+
updatedAt: now,
|
|
4294
|
+
bufferedObservationChunks: {
|
|
4295
|
+
$concatArrays: [{ $ifNull: ["$bufferedObservationChunks", []] }, [newChunk]]
|
|
4296
|
+
}
|
|
4297
|
+
};
|
|
4292
4298
|
if (input.lastBufferedAtTime) {
|
|
4293
|
-
|
|
4299
|
+
setStage.lastBufferedAtTime = input.lastBufferedAtTime;
|
|
4294
4300
|
}
|
|
4295
|
-
const result = await collection.updateOne(
|
|
4296
|
-
{ id: input.id },
|
|
4297
|
-
{
|
|
4298
|
-
$push: { bufferedObservationChunks: newChunk },
|
|
4299
|
-
$set
|
|
4300
|
-
}
|
|
4301
|
-
);
|
|
4301
|
+
const result = await collection.updateOne({ id: input.id }, [{ $set: setStage }]);
|
|
4302
4302
|
if (result.matchedCount === 0) {
|
|
4303
4303
|
throw new error.MastraError({
|
|
4304
4304
|
id: storage.createStorageErrorId("MONGODB", "UPDATE_BUFFERED_OBSERVATIONS", "NOT_FOUND"),
|
|
@@ -4411,7 +4411,7 @@ ${activatedContent}` : activatedContent;
|
|
|
4411
4411
|
activeObservations: newActive,
|
|
4412
4412
|
observationTokenCount: newTokenCount,
|
|
4413
4413
|
pendingMessageTokens: newPending,
|
|
4414
|
-
bufferedObservationChunks: remainingChunks
|
|
4414
|
+
bufferedObservationChunks: remainingChunks,
|
|
4415
4415
|
lastObservedAt,
|
|
4416
4416
|
updatedAt: /* @__PURE__ */ new Date()
|
|
4417
4417
|
}
|