@mastra/mongodb 1.28.0-alpha.1 → 1.28.0-alpha.3
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.
|
@@ -96,4 +96,29 @@ export declare function assertActiveObservationsApplied(result: UpdateActiveObse
|
|
|
96
96
|
* (equal, or only appended to since).
|
|
97
97
|
*/
|
|
98
98
|
export declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
|
|
99
|
+
/** The buffered-reflection fields a `swapBufferedReflectionToActive` caller read, and the stored ones. */
|
|
100
|
+
export interface BufferedReflectionState {
|
|
101
|
+
bufferedReflection?: string | null;
|
|
102
|
+
reflectedObservationLineCount?: number | null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Whether the stored buffered reflection and reflected line count are still the ones in
|
|
106
|
+
* `snapshot`, so a buffered-reflection swap activates exactly the buffer the caller read.
|
|
107
|
+
*
|
|
108
|
+
* Another writer can extend the buffer (`updateBufferedReflection` appends and moves the line
|
|
109
|
+
* count) after the caller's read. The activated text alone cannot tell the two apart: an
|
|
110
|
+
* extension that repeats the unreflected tail and moves the cut past it produces the same text.
|
|
111
|
+
* A snapshot without a buffered reflection (callers that never read one) is not checked.
|
|
112
|
+
*/
|
|
113
|
+
export declare function isBufferedReflectionUnchangedSince(stored: BufferedReflectionState, snapshot: BufferedReflectionState): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* The generation a buffered-reflection swap just created, marked with
|
|
116
|
+
* `bufferedReflectionVerified: true` when the swap checked the caller's buffered reflection with
|
|
117
|
+
* `isBufferedReflectionUnchangedSince` in the same atomic step. A snapshot without a buffered
|
|
118
|
+
* reflection was not checked, so its successor is returned unmarked. Always returns a new object,
|
|
119
|
+
* so a store's own record is never handed out or mutated.
|
|
120
|
+
*/
|
|
121
|
+
export declare function withBufferedReflectionVerified<T extends object>(successor: T, snapshot: BufferedReflectionState): T & {
|
|
122
|
+
bufferedReflectionVerified?: true;
|
|
123
|
+
};
|
|
99
124
|
//# 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.28.0-alpha.
|
|
6
|
+
version: "1.28.0-alpha.3"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -1,76 +1,76 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.28.0-alpha.
|
|
2
|
+
"version": "1.28.0-alpha.3",
|
|
3
3
|
"package": "@mastra/mongodb",
|
|
4
4
|
"exports": {
|
|
5
5
|
"BackgroundTasksStorageMongoDB": {
|
|
6
6
|
"types": "dist/storage/domains/background-tasks/index.d.ts",
|
|
7
7
|
"implementation": "dist/index.js",
|
|
8
|
-
"line":
|
|
8
|
+
"line": 4692
|
|
9
9
|
},
|
|
10
10
|
"KnowledgeMongoDB": {
|
|
11
11
|
"types": "dist/storage/domains/knowledge/index.d.ts",
|
|
12
12
|
"implementation": "dist/index.js",
|
|
13
|
-
"line":
|
|
13
|
+
"line": 9076
|
|
14
14
|
},
|
|
15
15
|
"MONGODB_PROMPT": {
|
|
16
16
|
"types": "dist/vector/prompt.d.ts",
|
|
17
17
|
"implementation": "dist/index.js",
|
|
18
|
-
"line":
|
|
18
|
+
"line": 16765
|
|
19
19
|
},
|
|
20
20
|
"MemoryStorageMongoDB": {
|
|
21
21
|
"types": "dist/storage/domains/memory/index.d.ts",
|
|
22
22
|
"implementation": "dist/index.js",
|
|
23
|
-
"line":
|
|
23
|
+
"line": 10343
|
|
24
24
|
},
|
|
25
25
|
"MongoDBAgentsStorage": {
|
|
26
26
|
"types": "dist/storage/domains/agents/index.d.ts",
|
|
27
27
|
"implementation": "dist/index.js",
|
|
28
|
-
"line":
|
|
28
|
+
"line": 3966
|
|
29
29
|
},
|
|
30
30
|
"MongoDBBlobStore": {
|
|
31
31
|
"types": "dist/storage/domains/blobs/index.d.ts",
|
|
32
32
|
"implementation": "dist/index.js",
|
|
33
|
-
"line":
|
|
33
|
+
"line": 4898
|
|
34
34
|
},
|
|
35
35
|
"MongoDBDatasetsStorage": {
|
|
36
36
|
"types": "dist/storage/domains/datasets/index.d.ts",
|
|
37
37
|
"implementation": "dist/index.js",
|
|
38
|
-
"line":
|
|
38
|
+
"line": 5077
|
|
39
39
|
},
|
|
40
40
|
"MongoDBExperimentsStorage": {
|
|
41
41
|
"types": "dist/storage/domains/experiments/index.d.ts",
|
|
42
42
|
"implementation": "dist/index.js",
|
|
43
|
-
"line":
|
|
43
|
+
"line": 6328
|
|
44
44
|
},
|
|
45
45
|
"MongoDBMCPClientsStorage": {
|
|
46
46
|
"types": "dist/storage/domains/mcp-clients/index.d.ts",
|
|
47
47
|
"implementation": "dist/index.js",
|
|
48
|
-
"line":
|
|
48
|
+
"line": 9230
|
|
49
49
|
},
|
|
50
50
|
"MongoDBMCPServersStorage": {
|
|
51
51
|
"types": "dist/storage/domains/mcp-servers/index.d.ts",
|
|
52
52
|
"implementation": "dist/index.js",
|
|
53
|
-
"line":
|
|
53
|
+
"line": 9683
|
|
54
54
|
},
|
|
55
55
|
"MongoDBPromptBlocksStorage": {
|
|
56
56
|
"types": "dist/storage/domains/prompt-blocks/index.d.ts",
|
|
57
57
|
"implementation": "dist/index.js",
|
|
58
|
-
"line":
|
|
58
|
+
"line": 13435
|
|
59
59
|
},
|
|
60
60
|
"MongoDBScorerDefinitionsStorage": {
|
|
61
61
|
"types": "dist/storage/domains/scorer-definitions/index.d.ts",
|
|
62
62
|
"implementation": "dist/index.js",
|
|
63
|
-
"line":
|
|
63
|
+
"line": 14145
|
|
64
64
|
},
|
|
65
65
|
"MongoDBSkillsStorage": {
|
|
66
66
|
"types": "dist/storage/domains/skills/index.d.ts",
|
|
67
67
|
"implementation": "dist/index.js",
|
|
68
|
-
"line":
|
|
68
|
+
"line": 14975
|
|
69
69
|
},
|
|
70
70
|
"MongoDBStore": {
|
|
71
71
|
"types": "dist/storage/index.d.ts",
|
|
72
72
|
"implementation": "dist/index.js",
|
|
73
|
-
"line":
|
|
73
|
+
"line": 16686
|
|
74
74
|
},
|
|
75
75
|
"MongoDBVector": {
|
|
76
76
|
"types": "dist/vector/index.d.ts",
|
|
@@ -80,37 +80,37 @@
|
|
|
80
80
|
"MongoDBWorkflowDefinitionsStore": {
|
|
81
81
|
"types": "dist/storage/domains/workflow-definitions/index.d.ts",
|
|
82
82
|
"implementation": "dist/index.js",
|
|
83
|
-
"line":
|
|
83
|
+
"line": 15476
|
|
84
84
|
},
|
|
85
85
|
"MongoDBWorkspacesStorage": {
|
|
86
86
|
"types": "dist/storage/domains/workspaces/index.d.ts",
|
|
87
87
|
"implementation": "dist/index.js",
|
|
88
|
-
"line":
|
|
88
|
+
"line": 16184
|
|
89
89
|
},
|
|
90
90
|
"NotificationsMongoDB": {
|
|
91
91
|
"types": "dist/storage/domains/notifications/index.d.ts",
|
|
92
92
|
"implementation": "dist/index.js",
|
|
93
|
-
"line":
|
|
93
|
+
"line": 12463
|
|
94
94
|
},
|
|
95
95
|
"ObservabilityMongoDB": {
|
|
96
96
|
"types": "dist/storage/domains/observability/index.d.ts",
|
|
97
97
|
"implementation": "dist/index.js",
|
|
98
|
-
"line":
|
|
98
|
+
"line": 12753
|
|
99
99
|
},
|
|
100
100
|
"SchedulesMongoDB": {
|
|
101
101
|
"types": "dist/storage/domains/schedules/index.d.ts",
|
|
102
102
|
"implementation": "dist/index.js",
|
|
103
|
-
"line":
|
|
103
|
+
"line": 13942
|
|
104
104
|
},
|
|
105
105
|
"ScoresStorageMongoDB": {
|
|
106
106
|
"types": "dist/storage/domains/scores/index.d.ts",
|
|
107
107
|
"implementation": "dist/index.js",
|
|
108
|
-
"line":
|
|
108
|
+
"line": 14594
|
|
109
109
|
},
|
|
110
110
|
"WorkflowsStorageMongoDB": {
|
|
111
111
|
"types": "dist/storage/domains/workflows/index.d.ts",
|
|
112
112
|
"implementation": "dist/index.js",
|
|
113
|
-
"line":
|
|
113
|
+
"line": 15646
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
"modules": {}
|
package/dist/index.cjs
CHANGED
|
@@ -11,7 +11,7 @@ let _mastra_core_agent = require("@mastra/core/agent");
|
|
|
11
11
|
let _mastra_core_evals = require("@mastra/core/evals");
|
|
12
12
|
let _mastra_core_storage_domains_skills = require("@mastra/core/storage/domains/skills");
|
|
13
13
|
// package.json
|
|
14
|
-
var version = "1.28.0-alpha.
|
|
14
|
+
var version = "1.28.0-alpha.3";
|
|
15
15
|
// src/vector/filter.ts
|
|
16
16
|
/**
|
|
17
17
|
* Translator for MongoDB filter queries.
|
|
@@ -2460,12 +2460,14 @@ var MongoDBVector = class MongoDBVector extends _mastra_core_vector.MastraVector
|
|
|
2460
2460
|
const ours = sameName && previous?.ownsTextIndex || previous?.retiredTextIndexNames?.includes(name);
|
|
2461
2461
|
const listedId = created.outcome === "attached" ? created.row?.id : void 0;
|
|
2462
2462
|
const recordedId = ours ? (await this.readRegistryEntry(indexName))?.indexIds?.find((e) => e.name === name)?.id : void 0;
|
|
2463
|
-
if (created.outcome === "owned") {} else if (listedId && listedId === recordedId)
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2463
|
+
if (created.outcome === "owned") {} else if (listedId && listedId === recordedId) {
|
|
2464
|
+
const row = created.outcome === "attached" ? created.row : void 0;
|
|
2465
|
+
if (!((row?.status === "PENDING" || row?.status === "BUILDING" || row?.status === "READY") && !!row.latestDefinition && searchDefinitionsEquivalent(row.latestDefinition, definition))) await this.runSearchIndexCommand({
|
|
2466
|
+
updateSearchIndex: collection.collectionName,
|
|
2467
|
+
id: listedId,
|
|
2468
|
+
definition
|
|
2469
|
+
});
|
|
2470
|
+
} else {
|
|
2469
2471
|
if (ours) this.logger.warn(`search index "${name}" on "${collectionName}" is ${listedId ? `listed with id ${listedId}` : "not listed"} but recorded with ${recordedId ? `id ${recordedId}` : "no id"}; treated as not created by Mastra and not modified`);
|
|
2470
2472
|
const [existing] = await this.listSearchIndexRows(collection, name, "P1");
|
|
2471
2473
|
if (!searchDefinitionsEquivalent(existing?.latestDefinition, definition)) {
|
|
@@ -10181,6 +10183,35 @@ function isAppendOnlySince(storedObservations, snapshotObservations) {
|
|
|
10181
10183
|
const snapshot = snapshotObservations ?? "";
|
|
10182
10184
|
return stored === snapshot || stored.startsWith(snapshot);
|
|
10183
10185
|
}
|
|
10186
|
+
/**
|
|
10187
|
+
* Whether the stored buffered reflection and reflected line count are still the ones in
|
|
10188
|
+
* `snapshot`, so a buffered-reflection swap activates exactly the buffer the caller read.
|
|
10189
|
+
*
|
|
10190
|
+
* Another writer can extend the buffer (`updateBufferedReflection` appends and moves the line
|
|
10191
|
+
* count) after the caller's read. The activated text alone cannot tell the two apart: an
|
|
10192
|
+
* extension that repeats the unreflected tail and moves the cut past it produces the same text.
|
|
10193
|
+
* A snapshot without a buffered reflection (callers that never read one) is not checked.
|
|
10194
|
+
*/
|
|
10195
|
+
function isBufferedReflectionUnchangedSince(stored, snapshot) {
|
|
10196
|
+
if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return true;
|
|
10197
|
+
if ((stored.bufferedReflection ?? "") !== snapshot.bufferedReflection) return false;
|
|
10198
|
+
if (snapshot.reflectedObservationLineCount === void 0 || snapshot.reflectedObservationLineCount === null) return true;
|
|
10199
|
+
return (stored.reflectedObservationLineCount ?? 0) === snapshot.reflectedObservationLineCount;
|
|
10200
|
+
}
|
|
10201
|
+
/**
|
|
10202
|
+
* The generation a buffered-reflection swap just created, marked with
|
|
10203
|
+
* `bufferedReflectionVerified: true` when the swap checked the caller's buffered reflection with
|
|
10204
|
+
* `isBufferedReflectionUnchangedSince` in the same atomic step. A snapshot without a buffered
|
|
10205
|
+
* reflection was not checked, so its successor is returned unmarked. Always returns a new object,
|
|
10206
|
+
* so a store's own record is never handed out or mutated.
|
|
10207
|
+
*/
|
|
10208
|
+
function withBufferedReflectionVerified(successor, snapshot) {
|
|
10209
|
+
if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return { ...successor };
|
|
10210
|
+
return {
|
|
10211
|
+
...successor,
|
|
10212
|
+
bufferedReflectionVerified: true
|
|
10213
|
+
};
|
|
10214
|
+
}
|
|
10184
10215
|
// src/storage/domains/run-fencing.ts
|
|
10185
10216
|
async function getRunClaims(connector, name) {
|
|
10186
10217
|
return await connector.getCollection(name);
|
|
@@ -12134,7 +12165,9 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends _mastra_core_stora
|
|
|
12134
12165
|
async swapBufferedReflectionToActive(input) {
|
|
12135
12166
|
try {
|
|
12136
12167
|
const { currentRecord } = input;
|
|
12137
|
-
|
|
12168
|
+
const planned = {};
|
|
12169
|
+
const result = await this.#rollOver(currentRecord, "swapBufferedReflectionToActive", (doc) => {
|
|
12170
|
+
planned.id = void 0;
|
|
12138
12171
|
const stored = this.parseOMDocument(doc);
|
|
12139
12172
|
const bufferedReflection = stored.bufferedReflection || "";
|
|
12140
12173
|
if (!bufferedReflection) throw new _mastra_core_error.MastraError({
|
|
@@ -12145,12 +12178,14 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends _mastra_core_stora
|
|
|
12145
12178
|
details: { id: currentRecord.id }
|
|
12146
12179
|
});
|
|
12147
12180
|
if (!isAppendOnlySince(stored.activeObservations, currentRecord.activeObservations)) return null;
|
|
12181
|
+
if (!isBufferedReflectionUnchangedSince(stored, currentRecord)) return null;
|
|
12148
12182
|
const reflectedLineCount = stored.reflectedObservationLineCount ?? 0;
|
|
12149
12183
|
const unreflectedContent = (stored.activeObservations || "").split("\n").slice(reflectedLineCount).join("\n").trim();
|
|
12150
12184
|
const newObservations = unreflectedContent ? `${bufferedReflection}\n\n${unreflectedContent}` : bufferedReflection;
|
|
12151
12185
|
const tokenCount = input.tokenCount + Math.max(0, (stored.observationTokenCount ?? 0) - (currentRecord.observationTokenCount ?? 0));
|
|
12186
|
+
planned.id = input.newRecordId ?? globalThis.crypto.randomUUID();
|
|
12152
12187
|
return {
|
|
12153
|
-
newId:
|
|
12188
|
+
newId: planned.id,
|
|
12154
12189
|
mode: "equal",
|
|
12155
12190
|
reflection: newObservations,
|
|
12156
12191
|
tokenCount,
|
|
@@ -12160,6 +12195,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends _mastra_core_stora
|
|
|
12160
12195
|
createdAt: /* @__PURE__ */ new Date()
|
|
12161
12196
|
};
|
|
12162
12197
|
});
|
|
12198
|
+
return result.id === planned.id ? withBufferedReflectionVerified(result, currentRecord) : result;
|
|
12163
12199
|
} catch (error) {
|
|
12164
12200
|
if (error instanceof _mastra_core_error.MastraError) throw error;
|
|
12165
12201
|
throw new _mastra_core_error.MastraError({
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { MessageList } from "@mastra/core/agent";
|
|
|
10
10
|
import { saveScorePayloadSchema } from "@mastra/core/evals";
|
|
11
11
|
import { skillSnapshotFieldValuesEqual } from "@mastra/core/storage/domains/skills";
|
|
12
12
|
// package.json
|
|
13
|
-
var version = "1.28.0-alpha.
|
|
13
|
+
var version = "1.28.0-alpha.3";
|
|
14
14
|
// src/vector/filter.ts
|
|
15
15
|
/**
|
|
16
16
|
* Translator for MongoDB filter queries.
|
|
@@ -2459,12 +2459,14 @@ var MongoDBVector = class MongoDBVector extends MastraVector {
|
|
|
2459
2459
|
const ours = sameName && previous?.ownsTextIndex || previous?.retiredTextIndexNames?.includes(name);
|
|
2460
2460
|
const listedId = created.outcome === "attached" ? created.row?.id : void 0;
|
|
2461
2461
|
const recordedId = ours ? (await this.readRegistryEntry(indexName))?.indexIds?.find((e) => e.name === name)?.id : void 0;
|
|
2462
|
-
if (created.outcome === "owned") {} else if (listedId && listedId === recordedId)
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2462
|
+
if (created.outcome === "owned") {} else if (listedId && listedId === recordedId) {
|
|
2463
|
+
const row = created.outcome === "attached" ? created.row : void 0;
|
|
2464
|
+
if (!((row?.status === "PENDING" || row?.status === "BUILDING" || row?.status === "READY") && !!row.latestDefinition && searchDefinitionsEquivalent(row.latestDefinition, definition))) await this.runSearchIndexCommand({
|
|
2465
|
+
updateSearchIndex: collection.collectionName,
|
|
2466
|
+
id: listedId,
|
|
2467
|
+
definition
|
|
2468
|
+
});
|
|
2469
|
+
} else {
|
|
2468
2470
|
if (ours) this.logger.warn(`search index "${name}" on "${collectionName}" is ${listedId ? `listed with id ${listedId}` : "not listed"} but recorded with ${recordedId ? `id ${recordedId}` : "no id"}; treated as not created by Mastra and not modified`);
|
|
2469
2471
|
const [existing] = await this.listSearchIndexRows(collection, name, "P1");
|
|
2470
2472
|
if (!searchDefinitionsEquivalent(existing?.latestDefinition, definition)) {
|
|
@@ -10180,6 +10182,35 @@ function isAppendOnlySince(storedObservations, snapshotObservations) {
|
|
|
10180
10182
|
const snapshot = snapshotObservations ?? "";
|
|
10181
10183
|
return stored === snapshot || stored.startsWith(snapshot);
|
|
10182
10184
|
}
|
|
10185
|
+
/**
|
|
10186
|
+
* Whether the stored buffered reflection and reflected line count are still the ones in
|
|
10187
|
+
* `snapshot`, so a buffered-reflection swap activates exactly the buffer the caller read.
|
|
10188
|
+
*
|
|
10189
|
+
* Another writer can extend the buffer (`updateBufferedReflection` appends and moves the line
|
|
10190
|
+
* count) after the caller's read. The activated text alone cannot tell the two apart: an
|
|
10191
|
+
* extension that repeats the unreflected tail and moves the cut past it produces the same text.
|
|
10192
|
+
* A snapshot without a buffered reflection (callers that never read one) is not checked.
|
|
10193
|
+
*/
|
|
10194
|
+
function isBufferedReflectionUnchangedSince(stored, snapshot) {
|
|
10195
|
+
if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return true;
|
|
10196
|
+
if ((stored.bufferedReflection ?? "") !== snapshot.bufferedReflection) return false;
|
|
10197
|
+
if (snapshot.reflectedObservationLineCount === void 0 || snapshot.reflectedObservationLineCount === null) return true;
|
|
10198
|
+
return (stored.reflectedObservationLineCount ?? 0) === snapshot.reflectedObservationLineCount;
|
|
10199
|
+
}
|
|
10200
|
+
/**
|
|
10201
|
+
* The generation a buffered-reflection swap just created, marked with
|
|
10202
|
+
* `bufferedReflectionVerified: true` when the swap checked the caller's buffered reflection with
|
|
10203
|
+
* `isBufferedReflectionUnchangedSince` in the same atomic step. A snapshot without a buffered
|
|
10204
|
+
* reflection was not checked, so its successor is returned unmarked. Always returns a new object,
|
|
10205
|
+
* so a store's own record is never handed out or mutated.
|
|
10206
|
+
*/
|
|
10207
|
+
function withBufferedReflectionVerified(successor, snapshot) {
|
|
10208
|
+
if (snapshot.bufferedReflection === void 0 || snapshot.bufferedReflection === null) return { ...successor };
|
|
10209
|
+
return {
|
|
10210
|
+
...successor,
|
|
10211
|
+
bufferedReflectionVerified: true
|
|
10212
|
+
};
|
|
10213
|
+
}
|
|
10183
10214
|
// src/storage/domains/run-fencing.ts
|
|
10184
10215
|
async function getRunClaims(connector, name) {
|
|
10185
10216
|
return await connector.getCollection(name);
|
|
@@ -12133,7 +12164,9 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends MemoryStorage {
|
|
|
12133
12164
|
async swapBufferedReflectionToActive(input) {
|
|
12134
12165
|
try {
|
|
12135
12166
|
const { currentRecord } = input;
|
|
12136
|
-
|
|
12167
|
+
const planned = {};
|
|
12168
|
+
const result = await this.#rollOver(currentRecord, "swapBufferedReflectionToActive", (doc) => {
|
|
12169
|
+
planned.id = void 0;
|
|
12137
12170
|
const stored = this.parseOMDocument(doc);
|
|
12138
12171
|
const bufferedReflection = stored.bufferedReflection || "";
|
|
12139
12172
|
if (!bufferedReflection) throw new MastraError({
|
|
@@ -12144,12 +12177,14 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends MemoryStorage {
|
|
|
12144
12177
|
details: { id: currentRecord.id }
|
|
12145
12178
|
});
|
|
12146
12179
|
if (!isAppendOnlySince(stored.activeObservations, currentRecord.activeObservations)) return null;
|
|
12180
|
+
if (!isBufferedReflectionUnchangedSince(stored, currentRecord)) return null;
|
|
12147
12181
|
const reflectedLineCount = stored.reflectedObservationLineCount ?? 0;
|
|
12148
12182
|
const unreflectedContent = (stored.activeObservations || "").split("\n").slice(reflectedLineCount).join("\n").trim();
|
|
12149
12183
|
const newObservations = unreflectedContent ? `${bufferedReflection}\n\n${unreflectedContent}` : bufferedReflection;
|
|
12150
12184
|
const tokenCount = input.tokenCount + Math.max(0, (stored.observationTokenCount ?? 0) - (currentRecord.observationTokenCount ?? 0));
|
|
12185
|
+
planned.id = input.newRecordId ?? globalThis.crypto.randomUUID();
|
|
12151
12186
|
return {
|
|
12152
|
-
newId:
|
|
12187
|
+
newId: planned.id,
|
|
12153
12188
|
mode: "equal",
|
|
12154
12189
|
reflection: newObservations,
|
|
12155
12190
|
tokenCount,
|
|
@@ -12159,6 +12194,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends MemoryStorage {
|
|
|
12159
12194
|
createdAt: /* @__PURE__ */ new Date()
|
|
12160
12195
|
};
|
|
12161
12196
|
});
|
|
12197
|
+
return result.id === planned.id ? withBufferedReflectionVerified(result, currentRecord) : result;
|
|
12162
12198
|
} catch (error) {
|
|
12163
12199
|
if (error instanceof MastraError) throw error;
|
|
12164
12200
|
throw new MastraError({
|
|
@@ -8,6 +8,7 @@ export declare class KnowledgeMongoDB extends KnowledgeStorage {
|
|
|
8
8
|
constructor(config: MongoDBDomainConfig);
|
|
9
9
|
getCapabilities(): {
|
|
10
10
|
readonly contractVersion: typeof import("@mastra/core/knowledge").KNOWLEDGE_STORAGE_CONTRACT_VERSION;
|
|
11
|
+
readonly supportsActivityDateRange?: boolean;
|
|
11
12
|
readonly schemaVersion: 4;
|
|
12
13
|
readonly supportsSchemaInspection: true;
|
|
13
14
|
readonly supportsExplicitReset: true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mongodb",
|
|
3
|
-
"version": "1.28.0-alpha.
|
|
3
|
+
"version": "1.28.0-alpha.3",
|
|
4
4
|
"description": "MongoDB provider for Mastra - includes vector store capabilities",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@lukeed/uuid": "^2.0.1",
|
|
24
|
-
"mongodb": "^7.
|
|
24
|
+
"mongodb": "^7.9.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "22.19.15",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@internal/lint": "0.0.151",
|
|
37
37
|
"@internal/storage-test-utils": "0.0.147",
|
|
38
38
|
"@internal/types-builder": "0.0.126",
|
|
39
|
-
"@mastra/core": "1.86.0-alpha.
|
|
40
|
-
"@mastra/memory": "1.41.3-alpha.
|
|
39
|
+
"@mastra/core": "1.86.0-alpha.8",
|
|
40
|
+
"@mastra/memory": "1.41.3-alpha.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@mastra/core": ">=1.76.0-0 <2.0.0-0"
|