@mastra/mongodb 1.22.0 → 1.23.0-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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-semantic-recall.md +2 -2
- package/dist/docs/references/docs-memory-working-memory.md +16 -0
- package/dist/docs/references/reference-rag-retrieval.md +7 -5
- package/dist/docs/references/reference-rag-vector-databases.md +1 -1
- package/dist/index.cjs +60 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +61 -67
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/knowledge/index.d.ts +12 -8
- package/dist/storage/domains/knowledge/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +2 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/docs/SKILL.md
CHANGED
|
@@ -411,11 +411,11 @@ PostgreSQL supports both IVFFlat and HNSW indexes. By default, Mastra creates an
|
|
|
411
411
|
|
|
412
412
|
```typescript
|
|
413
413
|
import { Memory } from '@mastra/memory'
|
|
414
|
-
import {
|
|
414
|
+
import { PostgresStore, PgVector } from '@mastra/pg'
|
|
415
415
|
|
|
416
416
|
const agent = new Agent({
|
|
417
417
|
memory: new Memory({
|
|
418
|
-
storage: new
|
|
418
|
+
storage: new PostgresStore({
|
|
419
419
|
id: 'agent-storage',
|
|
420
420
|
connectionString: process.env.DATABASE_URL,
|
|
421
421
|
}),
|
|
@@ -272,6 +272,22 @@ Schema-based working memory uses **merge semantics**, meaning the agent only nee
|
|
|
272
272
|
- **Set a field to `null` to delete it:** This explicitly removes the field from memory
|
|
273
273
|
- **Arrays are replaced entirely:** When an array field is provided, it replaces the existing array (arrays aren't merged element-by-element)
|
|
274
274
|
|
|
275
|
+
### Concurrent updates
|
|
276
|
+
|
|
277
|
+
With `scope: 'resource'` and a storage adapter that supports atomic merges (currently `@mastra/pg`), each merge runs inside a row-locked database transaction. Concurrent updates to different fields from separate processes are all kept. Other adapters merge in the application, which only serializes writers inside a single process.
|
|
278
|
+
|
|
279
|
+
To merge a partial update from your own code, call `memory.mergeWorkingMemory()`:
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
await memory.mergeWorkingMemory({
|
|
283
|
+
threadId: 'thread-1',
|
|
284
|
+
resourceId: 'user-123',
|
|
285
|
+
workingMemory: { preferences: { tone: 'formal' } },
|
|
286
|
+
})
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
It throws if working memory isn't schema-based and resource-scoped, or if the storage adapter doesn't support atomic merges. Check `await memory.supportsAtomicWorkingMemoryMerge()` first if you need to fall back.
|
|
290
|
+
|
|
275
291
|
## Choosing between template and schema
|
|
276
292
|
|
|
277
293
|
- Use a **template** (Markdown) if you want the agent to maintain memory as a free-form text block, such as a user profile or scratchpad. Templates use **replace semantics**: the agent must provide the complete memory content on each update.
|
|
@@ -50,23 +50,25 @@ console.log(results)
|
|
|
50
50
|
|
|
51
51
|
The `topK` parameter specifies the maximum number of most similar results to return from the vector search.
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
Each result includes an `id`, a similarity `score`, and the stored `metadata`. When you store chunk text in metadata, it's available as `metadata.text`:
|
|
54
54
|
|
|
55
55
|
```ts
|
|
56
56
|
[
|
|
57
57
|
{
|
|
58
|
-
|
|
58
|
+
id: 'chunk-1',
|
|
59
59
|
score: 0.89,
|
|
60
|
-
metadata: { source: 'article1.txt' },
|
|
60
|
+
metadata: { text: 'Climate change poses significant challenges...', source: 'article1.txt' },
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
|
-
|
|
63
|
+
id: 'chunk-2',
|
|
64
64
|
score: 0.82,
|
|
65
|
-
metadata: { source: 'article1.txt' },
|
|
65
|
+
metadata: { text: 'Rising temperatures affect crop yields...', source: 'article1.txt' },
|
|
66
66
|
},
|
|
67
67
|
]
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
Results can also include `vector` when you set `includeVector: true`, and `document` when the store returns the original document (Chroma only).
|
|
71
|
+
|
|
70
72
|
## Advanced retrieval options
|
|
71
73
|
|
|
72
74
|
### Metadata Filtering
|
package/dist/index.cjs
CHANGED
|
@@ -9,7 +9,7 @@ let _mastra_core_agent = require("@mastra/core/agent");
|
|
|
9
9
|
let _mastra_core_evals = require("@mastra/core/evals");
|
|
10
10
|
let _mastra_core_storage_domains_skills = require("@mastra/core/storage/domains/skills");
|
|
11
11
|
//#region package.json
|
|
12
|
-
var version = "1.
|
|
12
|
+
var version = "1.23.0-alpha.1";
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/vector/filter.ts
|
|
15
15
|
/**
|
|
@@ -4764,13 +4764,26 @@ async function assertKnowledgeDescriptionWithinBoundCompat(description) {
|
|
|
4764
4764
|
}
|
|
4765
4765
|
assertWithinBound(description);
|
|
4766
4766
|
}
|
|
4767
|
+
let assertRecordTextWithinBound;
|
|
4768
|
+
async function assertKnowledgeRecordTextWithinBoundCompat(text) {
|
|
4769
|
+
if (!assertRecordTextWithinBound) assertRecordTextWithinBound = (await import("@mastra/core/storage")).assertKnowledgeRecordTextWithinBound ?? ((value) => {
|
|
4770
|
+
if (value.length > 1e3) throw new Error("Knowledge record text exceeds the 1000 UTF-16 code unit limit; split it into separate facts or summarize it");
|
|
4771
|
+
});
|
|
4772
|
+
assertRecordTextWithinBound(text);
|
|
4773
|
+
}
|
|
4767
4774
|
const cloneScope = (scope) => [...scope];
|
|
4768
4775
|
const canonicalName = (name) => name.trim().toLocaleLowerCase();
|
|
4769
4776
|
const nodeReferenceId = (node) => typeof node === "string" ? node : node.id;
|
|
4770
4777
|
const sessionOptions = (session) => session ? { session } : {};
|
|
4771
4778
|
function visibleScopeKeys(scope) {
|
|
4772
4779
|
const canonical = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(scope);
|
|
4773
|
-
|
|
4780
|
+
const subsets = [[]];
|
|
4781
|
+
for (const entry of canonical) subsets.push(...subsets.map((subset) => [...subset, entry]));
|
|
4782
|
+
const keys = /* @__PURE__ */ new Set();
|
|
4783
|
+
for (const subset of subsets.slice(1)) try {
|
|
4784
|
+
keys.add((0, _mastra_core_storage.knowledgeScopeKey)(subset));
|
|
4785
|
+
} catch {}
|
|
4786
|
+
return [...keys];
|
|
4774
4787
|
}
|
|
4775
4788
|
function recordCursorFilter(cursor, expected) {
|
|
4776
4789
|
const parsed = (0, _mastra_core_storage.parseKnowledgeNodeCursor)(cursor, expected);
|
|
@@ -4806,7 +4819,6 @@ function recordFromDocument(row) {
|
|
|
4806
4819
|
sourceThreadId: String(row.sourceThreadId),
|
|
4807
4820
|
capturedAt: new Date(row.capturedAt),
|
|
4808
4821
|
when: row.when ? new Date(row.when) : void 0,
|
|
4809
|
-
maxScope: row.maxScope ?? void 0,
|
|
4810
4822
|
metadata: row.metadata ?? void 0,
|
|
4811
4823
|
deletedAt: row.deletedAt ? new Date(row.deletedAt) : void 0,
|
|
4812
4824
|
deletedBy: row.deletedBy ?? void 0
|
|
@@ -4829,12 +4841,12 @@ function outboxFromDocument(row) {
|
|
|
4829
4841
|
completedAt: row.completedAt ? new Date(row.completedAt) : void 0
|
|
4830
4842
|
};
|
|
4831
4843
|
}
|
|
4844
|
+
const KNOWLEDGE_CURATION_CURSOR_REMOVED_MESSAGE = "Knowledge curation cursors were removed: observation-time curate is the only Knowledge writer and needs no cursor.";
|
|
4832
4845
|
var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.KnowledgeStorage {
|
|
4833
4846
|
static MANAGED_COLLECTIONS = [
|
|
4834
4847
|
_mastra_core_storage.TABLE_KNOWLEDGE_NODES,
|
|
4835
4848
|
_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS,
|
|
4836
4849
|
_mastra_core_storage.TABLE_KNOWLEDGE_MENTIONS,
|
|
4837
|
-
_mastra_core_storage.TABLE_KNOWLEDGE_CURSORS,
|
|
4838
4850
|
_mastra_core_storage.TABLE_KNOWLEDGE_ACTIVITY,
|
|
4839
4851
|
_mastra_core_storage.TABLE_KNOWLEDGE_SEMANTIC_OUTBOX
|
|
4840
4852
|
];
|
|
@@ -4847,7 +4859,6 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
4847
4859
|
const nodes = await this.#collection(_mastra_core_storage.TABLE_KNOWLEDGE_NODES);
|
|
4848
4860
|
const knowledge = await this.#collection(_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS);
|
|
4849
4861
|
const mentions = await this.#collection(_mastra_core_storage.TABLE_KNOWLEDGE_MENTIONS);
|
|
4850
|
-
const cursors = await this.#collection(_mastra_core_storage.TABLE_KNOWLEDGE_CURSORS);
|
|
4851
4862
|
const activity = await this.#collection(_mastra_core_storage.TABLE_KNOWLEDGE_ACTIVITY);
|
|
4852
4863
|
const outbox = await this.#collection(_mastra_core_storage.TABLE_KNOWLEDGE_SEMANTIC_OUTBOX);
|
|
4853
4864
|
await Promise.all([
|
|
@@ -4860,6 +4871,10 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
4860
4871
|
scopeKey: 1,
|
|
4861
4872
|
type: 1
|
|
4862
4873
|
}),
|
|
4874
|
+
nodes.createIndex({
|
|
4875
|
+
type: 1,
|
|
4876
|
+
canonicalName: 1
|
|
4877
|
+
}),
|
|
4863
4878
|
knowledge.createIndex({
|
|
4864
4879
|
node: 1,
|
|
4865
4880
|
id: -1
|
|
@@ -4868,6 +4883,10 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
4868
4883
|
sourceThreadId: 1,
|
|
4869
4884
|
id: -1
|
|
4870
4885
|
}),
|
|
4886
|
+
knowledge.createIndex({
|
|
4887
|
+
scopeKey: 1,
|
|
4888
|
+
id: -1
|
|
4889
|
+
}),
|
|
4871
4890
|
mentions.createIndex({
|
|
4872
4891
|
sourceType: 1,
|
|
4873
4892
|
sourceId: 1,
|
|
@@ -4878,11 +4897,11 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
4878
4897
|
sourceType: 1,
|
|
4879
4898
|
sourceId: 1
|
|
4880
4899
|
}),
|
|
4881
|
-
cursors.createIndex({
|
|
4882
|
-
sourceThreadId: 1,
|
|
4883
|
-
agent: 1
|
|
4884
|
-
}, { unique: true }),
|
|
4885
4900
|
activity.createIndex({ id: -1 }),
|
|
4901
|
+
activity.createIndex({
|
|
4902
|
+
scopeKey: 1,
|
|
4903
|
+
id: -1
|
|
4904
|
+
}),
|
|
4886
4905
|
outbox.createIndex({ idempotencyKey: 1 }, { unique: true }),
|
|
4887
4906
|
outbox.createIndex({
|
|
4888
4907
|
status: 1,
|
|
@@ -4898,6 +4917,11 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
4898
4917
|
}
|
|
4899
4918
|
async createNode(input) {
|
|
4900
4919
|
await assertKnowledgeDescriptionWithinBoundCompat(input.description);
|
|
4920
|
+
if (input.scopeAddresses?.length) {
|
|
4921
|
+
const error = /* @__PURE__ */ new Error("This Knowledge storage adapter does not expose structural scope placement.");
|
|
4922
|
+
error.name = "KnowledgeUnsupportedCapabilityError";
|
|
4923
|
+
throw error;
|
|
4924
|
+
}
|
|
4901
4925
|
const scope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope);
|
|
4902
4926
|
return this.#connector.withTransaction(async (session) => {
|
|
4903
4927
|
const existing = await this.#getNodeByName(input.name, scope, session);
|
|
@@ -5090,9 +5114,9 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
5090
5114
|
});
|
|
5091
5115
|
}
|
|
5092
5116
|
async appendKnowledge(input) {
|
|
5117
|
+
await assertKnowledgeRecordTextWithinBoundCompat(input.text);
|
|
5093
5118
|
const scope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope);
|
|
5094
5119
|
const defaultScope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.defaultScope);
|
|
5095
|
-
(0, _mastra_core_storage.assertKnowledgeScopeWithinCeiling)(scope, input.maxScope);
|
|
5096
5120
|
return this.#connector.withTransaction(async (session) => {
|
|
5097
5121
|
const parent = await this.#resolveTerminalNode(nodeReferenceId(input.node), session);
|
|
5098
5122
|
if (!parent) throw new _mastra_core_storage.KnowledgeNotFoundError("node", nodeReferenceId(input.node));
|
|
@@ -5107,14 +5131,12 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
5107
5131
|
sourceThreadId: input.sourceThreadId,
|
|
5108
5132
|
capturedAt: /* @__PURE__ */ new Date(),
|
|
5109
5133
|
when: input.when,
|
|
5110
|
-
maxScope: input.maxScope,
|
|
5111
5134
|
metadata: input.metadata
|
|
5112
5135
|
};
|
|
5113
5136
|
await (await this.#knowledge()).insertOne({
|
|
5114
5137
|
...record,
|
|
5115
5138
|
scopeKey: (0, _mastra_core_storage.knowledgeScopeKey)(scope),
|
|
5116
5139
|
when: record.when ?? null,
|
|
5117
|
-
maxScope: record.maxScope ?? null,
|
|
5118
5140
|
deletedAt: null,
|
|
5119
5141
|
deletedBy: null
|
|
5120
5142
|
}, sessionOptions(session));
|
|
@@ -5199,7 +5221,6 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
5199
5221
|
return this.#connector.withTransaction(async (session) => {
|
|
5200
5222
|
const record = await this.#getKnowledge(input.id, true, session);
|
|
5201
5223
|
if (!record) throw new _mastra_core_storage.KnowledgeNotFoundError("record", input.id);
|
|
5202
|
-
(0, _mastra_core_storage.assertKnowledgeScopeWithinCeiling)(scope, record.maxScope);
|
|
5203
5224
|
await (await this.#knowledge()).updateOne({ id: input.id }, { $set: {
|
|
5204
5225
|
scope,
|
|
5205
5226
|
scopeKey: (0, _mastra_core_storage.knowledgeScopeKey)(scope)
|
|
@@ -5213,17 +5234,6 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
5213
5234
|
};
|
|
5214
5235
|
});
|
|
5215
5236
|
}
|
|
5216
|
-
async raiseKnowledgeCeiling(input) {
|
|
5217
|
-
const record = await this.#getKnowledge(input.id, true);
|
|
5218
|
-
if (!record) throw new _mastra_core_storage.KnowledgeNotFoundError("record", input.id);
|
|
5219
|
-
(0, _mastra_core_storage.assertKnowledgeScopeWithinCeiling)(record.scope, input.maxScope);
|
|
5220
|
-
(0, _mastra_core_storage.assertKnowledgeCeilingRaised)(record.maxScope, input.maxScope);
|
|
5221
|
-
await (await this.#knowledge()).updateOne({ id: input.id }, { $set: { maxScope: input.maxScope ?? null } });
|
|
5222
|
-
return {
|
|
5223
|
-
...record,
|
|
5224
|
-
maxScope: input.maxScope
|
|
5225
|
-
};
|
|
5226
|
-
}
|
|
5227
5237
|
async search(input) {
|
|
5228
5238
|
const scope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope);
|
|
5229
5239
|
const query = input.query.trim();
|
|
@@ -5263,7 +5273,7 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
5263
5273
|
results.push({
|
|
5264
5274
|
type: "record",
|
|
5265
5275
|
id: record.id,
|
|
5266
|
-
recordId: record.node,
|
|
5276
|
+
recordId: parentVisible ? record.node : record.id,
|
|
5267
5277
|
name: parentVisible ? parent.name : "(private node)",
|
|
5268
5278
|
text: record.text,
|
|
5269
5279
|
scope: cloneScope(record.scope)
|
|
@@ -5272,36 +5282,19 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
5272
5282
|
}
|
|
5273
5283
|
return results.slice(0, limit);
|
|
5274
5284
|
}
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
}, {
|
|
5289
|
-
$max: { lastKnowledgeId: input.lastKnowledgeId },
|
|
5290
|
-
$set: { updatedAt: /* @__PURE__ */ new Date() },
|
|
5291
|
-
$setOnInsert: {
|
|
5292
|
-
sourceThreadId: input.sourceThreadId,
|
|
5293
|
-
agent: input.agent
|
|
5294
|
-
}
|
|
5295
|
-
}, {
|
|
5296
|
-
upsert: true,
|
|
5297
|
-
returnDocument: "after"
|
|
5298
|
-
});
|
|
5299
|
-
return {
|
|
5300
|
-
sourceThreadId: row.sourceThreadId,
|
|
5301
|
-
agent: row.agent,
|
|
5302
|
-
lastKnowledgeId: row.lastKnowledgeId,
|
|
5303
|
-
updatedAt: new Date(row.updatedAt)
|
|
5304
|
-
};
|
|
5285
|
+
/**
|
|
5286
|
+
* @deprecated Curation cursors were removed. Observation-time curate is the only Knowledge writer and needs no
|
|
5287
|
+
* cursor. Always throws.
|
|
5288
|
+
*/
|
|
5289
|
+
async getCurationCursor(_input) {
|
|
5290
|
+
throw new Error(KNOWLEDGE_CURATION_CURSOR_REMOVED_MESSAGE);
|
|
5291
|
+
}
|
|
5292
|
+
/**
|
|
5293
|
+
* @deprecated Curation cursors were removed. Observation-time curate is the only Knowledge writer and needs no
|
|
5294
|
+
* cursor. Always throws.
|
|
5295
|
+
*/
|
|
5296
|
+
async advanceCurationCursor(_input) {
|
|
5297
|
+
throw new Error(KNOWLEDGE_CURATION_CURSOR_REMOVED_MESSAGE);
|
|
5305
5298
|
}
|
|
5306
5299
|
async listActivity(input) {
|
|
5307
5300
|
const scope = (0, _mastra_core_storage.canonicalizeKnowledgeScope)(input.scope);
|
|
@@ -5422,9 +5415,6 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
5422
5415
|
#mentions() {
|
|
5423
5416
|
return this.#collection(_mastra_core_storage.TABLE_KNOWLEDGE_MENTIONS);
|
|
5424
5417
|
}
|
|
5425
|
-
#cursors() {
|
|
5426
|
-
return this.#collection(_mastra_core_storage.TABLE_KNOWLEDGE_CURSORS);
|
|
5427
|
-
}
|
|
5428
5418
|
#activityCollection() {
|
|
5429
5419
|
return this.#collection(_mastra_core_storage.TABLE_KNOWLEDGE_ACTIVITY);
|
|
5430
5420
|
}
|
|
@@ -5447,12 +5437,14 @@ var KnowledgeMongoDB = class KnowledgeMongoDB extends _mastra_core_storage.Knowl
|
|
|
5447
5437
|
return row ? nodeFromDocument(row) : null;
|
|
5448
5438
|
}
|
|
5449
5439
|
async #resolveNode(name, scope, session) {
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5440
|
+
const candidates = (await (await this.#nodes()).find({
|
|
5441
|
+
type: "node",
|
|
5442
|
+
canonicalName: canonicalName(name),
|
|
5443
|
+
$or: [{ scopeKey: { $in: visibleScopeKeys(scope) } }, { mergedInto: { $ne: null } }]
|
|
5444
|
+
}, sessionOptions(session)).toArray()).map(nodeFromDocument).sort((left, right) => right.scope.length - left.scope.length);
|
|
5445
|
+
for (const candidate of candidates) {
|
|
5446
|
+
const terminal = await this.#resolveTerminalNode(candidate.id, session);
|
|
5447
|
+
if (terminal && (0, _mastra_core_storage.isKnowledgeScopeVisible)(terminal.scope, scope)) return terminal;
|
|
5456
5448
|
}
|
|
5457
5449
|
return null;
|
|
5458
5450
|
}
|
|
@@ -11592,10 +11584,12 @@ var WorkflowsStorageMongoDB = class WorkflowsStorageMongoDB extends _mastra_core
|
|
|
11592
11584
|
async dangerouslyClearAll() {
|
|
11593
11585
|
await (await this.getCollection(_mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT)).deleteMany({});
|
|
11594
11586
|
}
|
|
11595
|
-
async updateWorkflowResults({ workflowName, runId, stepId, result, requestContext }) {
|
|
11587
|
+
async updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state }) {
|
|
11596
11588
|
try {
|
|
11597
11589
|
const collection = await this.getCollection(_mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT);
|
|
11598
11590
|
const now = /* @__PURE__ */ new Date();
|
|
11591
|
+
const contextUpdate = { [stepId]: result };
|
|
11592
|
+
if (state !== void 0) contextUpdate.__state = state;
|
|
11599
11593
|
const defaultSnapshot = {
|
|
11600
11594
|
context: {},
|
|
11601
11595
|
activePaths: [],
|
|
@@ -11618,7 +11612,7 @@ var WorkflowsStorageMongoDB = class WorkflowsStorageMongoDB extends _mastra_core
|
|
|
11618
11612
|
run_id: runId,
|
|
11619
11613
|
snapshot: { $mergeObjects: [
|
|
11620
11614
|
{ $ifNull: ["$snapshot", defaultSnapshot] },
|
|
11621
|
-
{ context: { $mergeObjects: [{ $ifNull: [{ $ifNull: ["$snapshot.context", {}] }, {}] },
|
|
11615
|
+
{ context: { $mergeObjects: [{ $ifNull: [{ $ifNull: ["$snapshot.context", {}] }, {}] }, contextUpdate] } },
|
|
11622
11616
|
{ requestContext: { $mergeObjects: [{ $ifNull: [{ $ifNull: ["$snapshot.requestContext", {}] }, {}] }, requestContext] } }
|
|
11623
11617
|
] },
|
|
11624
11618
|
updatedAt: now,
|