@mastra/mongodb 1.20.0-alpha.1 → 1.20.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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-retention.md +1 -1
- package/dist/index.cjs +29 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -30
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/datasets/index.d.ts.map +1 -1
- package/dist/storage/domains/experiments/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/notifications/index.d.ts.map +1 -1
- package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -1
- package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/skills/index.d.ts.map +1 -1
- package/dist/storage/domains/workspaces/index.d.ts.map +1 -1
- package/package.json +5 -5
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.20.
|
|
6
|
+
version: "1.20.1-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -202,7 +202,7 @@ async function retentionTick() {
|
|
|
202
202
|
}
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
-
You can also cancel a long-running prune with an `AbortSignal`: the loop stops between batches and returns partial results with `done: false
|
|
205
|
+
You can also cancel a long-running prune with an `AbortSignal`: the loop stops between batches and returns partial results with `done: false`. The next run resumes cleanly.
|
|
206
206
|
|
|
207
207
|
## ClickHouse native TTL
|
|
208
208
|
|
package/dist/index.cjs
CHANGED
|
@@ -5,12 +5,11 @@ let _mastra_core_storage = require("@mastra/core/storage");
|
|
|
5
5
|
let _mastra_core_vector = require("@mastra/core/vector");
|
|
6
6
|
let mongodb = require("mongodb");
|
|
7
7
|
let _mastra_core_vector_filter = require("@mastra/core/vector/filter");
|
|
8
|
-
let crypto$1 = require("crypto");
|
|
9
8
|
let _mastra_core_agent = require("@mastra/core/agent");
|
|
10
9
|
let _mastra_core_evals = require("@mastra/core/evals");
|
|
11
10
|
let _mastra_core_storage_domains_skills = require("@mastra/core/storage/domains/skills");
|
|
12
11
|
//#region package.json
|
|
13
|
-
var version = "1.20.
|
|
12
|
+
var version = "1.20.1-alpha.0";
|
|
14
13
|
//#endregion
|
|
15
14
|
//#region src/vector/filter.ts
|
|
16
15
|
/**
|
|
@@ -1844,7 +1843,7 @@ var MongoDBAgentsStorage = class MongoDBAgentsStorage extends _mastra_core_stora
|
|
|
1844
1843
|
};
|
|
1845
1844
|
const { id: _id, authorId: _authorId, visibility: _visibility, metadata: _metadata, ...snapshotConfig } = agent;
|
|
1846
1845
|
const versionDoc = {
|
|
1847
|
-
id:
|
|
1846
|
+
id: globalThis.crypto.randomUUID(),
|
|
1848
1847
|
agentId: agent.id,
|
|
1849
1848
|
versionNumber: 1,
|
|
1850
1849
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -3011,7 +3010,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3011
3010
|
}
|
|
3012
3011
|
async createDataset(input) {
|
|
3013
3012
|
try {
|
|
3014
|
-
const id = input.id ??
|
|
3013
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
3015
3014
|
if (input.id !== void 0) this.validateCallerDefinedDatasetId(input.id);
|
|
3016
3015
|
const now = /* @__PURE__ */ new Date();
|
|
3017
3016
|
const collection = await this.getCollection(_mastra_core_storage.TABLE_DATASETS);
|
|
@@ -3202,8 +3201,8 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3202
3201
|
}
|
|
3203
3202
|
async _doAddItem(args) {
|
|
3204
3203
|
try {
|
|
3205
|
-
const id =
|
|
3206
|
-
const versionId =
|
|
3204
|
+
const id = globalThis.crypto.randomUUID();
|
|
3205
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
3207
3206
|
const now = /* @__PURE__ */ new Date();
|
|
3208
3207
|
const datasetsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASETS);
|
|
3209
3208
|
const itemsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_ITEMS);
|
|
@@ -3305,7 +3304,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3305
3304
|
return existing;
|
|
3306
3305
|
}
|
|
3307
3306
|
const now = /* @__PURE__ */ new Date();
|
|
3308
|
-
const versionId =
|
|
3307
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
3309
3308
|
const datasetsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASETS);
|
|
3310
3309
|
const itemsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_ITEMS);
|
|
3311
3310
|
const versionsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_VERSIONS);
|
|
@@ -3430,7 +3429,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3430
3429
|
async _doDeleteItem({ id, datasetId }) {
|
|
3431
3430
|
try {
|
|
3432
3431
|
const now = /* @__PURE__ */ new Date();
|
|
3433
|
-
const versionId =
|
|
3432
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
3434
3433
|
const datasetsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASETS);
|
|
3435
3434
|
const itemsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_ITEMS);
|
|
3436
3435
|
const versionsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_VERSIONS);
|
|
@@ -3612,7 +3611,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3612
3611
|
datasetId: input.datasetId,
|
|
3613
3612
|
externalId: { $in: externalIds }
|
|
3614
3613
|
}, { session }).sort({ datasetVersion: 1 }).toArray();
|
|
3615
|
-
const plan = this.planDatasetItemBatch(input.items, historyRows.map((row) => this.transformItemRowFull(row)), crypto
|
|
3614
|
+
const plan = this.planDatasetItemBatch(input.items, historyRows.map((row) => this.transformItemRowFull(row)), () => globalThis.crypto.randomUUID());
|
|
3616
3615
|
const resolved = new Map([...plan.existingCurrentItems].map(([id, row]) => [id, this.datasetItemFromRow(row)]));
|
|
3617
3616
|
if (plan.inserts.length > 0) {
|
|
3618
3617
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -3652,7 +3651,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3652
3651
|
resolved.set(item.id, item);
|
|
3653
3652
|
}
|
|
3654
3653
|
await versionsCollection.insertOne({
|
|
3655
|
-
id:
|
|
3654
|
+
id: globalThis.crypto.randomUUID(),
|
|
3656
3655
|
datasetId: input.datasetId,
|
|
3657
3656
|
version: newVersion,
|
|
3658
3657
|
createdAt: now
|
|
@@ -3680,7 +3679,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3680
3679
|
});
|
|
3681
3680
|
const itemsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_ITEMS);
|
|
3682
3681
|
const now = /* @__PURE__ */ new Date();
|
|
3683
|
-
const versionId =
|
|
3682
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
3684
3683
|
const datasetsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASETS);
|
|
3685
3684
|
const versionsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_VERSIONS);
|
|
3686
3685
|
await this.#connector.withTransaction(async (session) => {
|
|
@@ -3886,7 +3885,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3886
3885
|
}
|
|
3887
3886
|
async createDatasetVersion(datasetId, version) {
|
|
3888
3887
|
try {
|
|
3889
|
-
const id =
|
|
3888
|
+
const id = globalThis.crypto.randomUUID();
|
|
3890
3889
|
const now = /* @__PURE__ */ new Date();
|
|
3891
3890
|
await (await this.getCollection(_mastra_core_storage.TABLE_DATASET_VERSIONS)).insertOne({
|
|
3892
3891
|
id,
|
|
@@ -4246,7 +4245,7 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends _mastra_
|
|
|
4246
4245
|
await this.createCustomIndexes();
|
|
4247
4246
|
}
|
|
4248
4247
|
async createExperiment(input) {
|
|
4249
|
-
const id = input.id ??
|
|
4248
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
4250
4249
|
const now = /* @__PURE__ */ new Date();
|
|
4251
4250
|
const doc = {
|
|
4252
4251
|
id,
|
|
@@ -4424,7 +4423,7 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends _mastra_
|
|
|
4424
4423
|
}
|
|
4425
4424
|
}
|
|
4426
4425
|
async addExperimentResult(input) {
|
|
4427
|
-
const id = input.id ??
|
|
4426
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
4428
4427
|
const now = /* @__PURE__ */ new Date();
|
|
4429
4428
|
try {
|
|
4430
4429
|
return await this.#withPurgeBarrier(input.experimentId, input.itemId, async (session, marker) => {
|
|
@@ -4492,7 +4491,7 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends _mastra_
|
|
|
4492
4491
|
...marker ? { comment: null } : {}
|
|
4493
4492
|
},
|
|
4494
4493
|
$setOnInsert: {
|
|
4495
|
-
id:
|
|
4494
|
+
id: globalThis.crypto.randomUUID(),
|
|
4496
4495
|
createdAt: /* @__PURE__ */ new Date()
|
|
4497
4496
|
}
|
|
4498
4497
|
}, {
|
|
@@ -5679,7 +5678,7 @@ var MongoDBMCPClientsStorage = class MongoDBMCPClientsStorage extends _mastra_co
|
|
|
5679
5678
|
const snapshotConfig = {};
|
|
5680
5679
|
for (const field of SNAPSHOT_FIELDS$5) if (mcpClient[field] !== void 0) snapshotConfig[field] = mcpClient[field];
|
|
5681
5680
|
const versionDoc = {
|
|
5682
|
-
id:
|
|
5681
|
+
id: globalThis.crypto.randomUUID(),
|
|
5683
5682
|
mcpClientId: mcpClient.id,
|
|
5684
5683
|
versionNumber: 1,
|
|
5685
5684
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -6134,7 +6133,7 @@ var MongoDBMCPServersStorage = class MongoDBMCPServersStorage extends _mastra_co
|
|
|
6134
6133
|
const snapshotConfig = {};
|
|
6135
6134
|
for (const field of SNAPSHOT_FIELDS$4) if (mcpServer[field] !== void 0) snapshotConfig[field] = mcpServer[field];
|
|
6136
6135
|
const versionDoc = {
|
|
6137
|
-
id:
|
|
6136
|
+
id: globalThis.crypto.randomUUID(),
|
|
6138
6137
|
mcpServerId: mcpServer.id,
|
|
6139
6138
|
versionNumber: 1,
|
|
6140
6139
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -7330,7 +7329,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends _mastra_core_stora
|
|
|
7330
7329
|
text: `Source thread with id ${sourceThreadId} not found`,
|
|
7331
7330
|
details: { sourceThreadId }
|
|
7332
7331
|
});
|
|
7333
|
-
const newThreadId = providedThreadId ||
|
|
7332
|
+
const newThreadId = providedThreadId || globalThis.crypto.randomUUID();
|
|
7334
7333
|
if (await this.getThreadById({ threadId: newThreadId })) throw new _mastra_core_error.MastraError({
|
|
7335
7334
|
id: (0, _mastra_core_storage.createStorageErrorId)("MONGODB", "CLONE_THREAD", "THREAD_EXISTS"),
|
|
7336
7335
|
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
@@ -7380,7 +7379,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends _mastra_core_stora
|
|
|
7380
7379
|
if (sourceMessages.length > 0) {
|
|
7381
7380
|
const messageDocs = [];
|
|
7382
7381
|
for (const sourceMsg of sourceMessages) {
|
|
7383
|
-
const newMessageId =
|
|
7382
|
+
const newMessageId = globalThis.crypto.randomUUID();
|
|
7384
7383
|
messageIdMap[sourceMsg.id] = newMessageId;
|
|
7385
7384
|
let parsedContent = sourceMsg.content;
|
|
7386
7385
|
if (typeof parsedContent === "string") try {
|
|
@@ -7529,7 +7528,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends _mastra_core_stora
|
|
|
7529
7528
|
}
|
|
7530
7529
|
async initializeObservationalMemory(input) {
|
|
7531
7530
|
try {
|
|
7532
|
-
const id =
|
|
7531
|
+
const id = globalThis.crypto.randomUUID();
|
|
7533
7532
|
const now = /* @__PURE__ */ new Date();
|
|
7534
7533
|
const lookupKey = this.getOMKey(input.threadId, input.resourceId);
|
|
7535
7534
|
const record = {
|
|
@@ -7678,7 +7677,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends _mastra_core_stora
|
|
|
7678
7677
|
}
|
|
7679
7678
|
async createReflectionGeneration(input) {
|
|
7680
7679
|
try {
|
|
7681
|
-
const id =
|
|
7680
|
+
const id = globalThis.crypto.randomUUID();
|
|
7682
7681
|
const now = /* @__PURE__ */ new Date();
|
|
7683
7682
|
const lookupKey = this.getOMKey(input.currentRecord.threadId, input.currentRecord.resourceId);
|
|
7684
7683
|
const record = {
|
|
@@ -7944,7 +7943,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends _mastra_core_stora
|
|
|
7944
7943
|
try {
|
|
7945
7944
|
const collection = await this.getCollection(OM_TABLE);
|
|
7946
7945
|
const newChunk = {
|
|
7947
|
-
id: `ombuf-${
|
|
7946
|
+
id: `ombuf-${globalThis.crypto.randomUUID()}`,
|
|
7948
7947
|
cycleId: input.chunk.cycleId,
|
|
7949
7948
|
observations: input.chunk.observations,
|
|
7950
7949
|
tokenCount: input.chunk.tokenCount,
|
|
@@ -8413,7 +8412,7 @@ var NotificationsMongoDB = class NotificationsMongoDB extends _mastra_core_stora
|
|
|
8413
8412
|
}
|
|
8414
8413
|
const now = input.createdAt ?? /* @__PURE__ */ new Date();
|
|
8415
8414
|
const record = {
|
|
8416
|
-
id: input.id ??
|
|
8415
|
+
id: input.id ?? globalThis.crypto.randomUUID(),
|
|
8417
8416
|
threadId: input.threadId,
|
|
8418
8417
|
source: input.source,
|
|
8419
8418
|
kind: input.kind,
|
|
@@ -9368,7 +9367,7 @@ var MongoDBPromptBlocksStorage = class MongoDBPromptBlocksStorage extends _mastr
|
|
|
9368
9367
|
const snapshotConfig = {};
|
|
9369
9368
|
for (const field of SNAPSHOT_FIELDS$3) if (promptBlock[field] !== void 0) snapshotConfig[field] = promptBlock[field];
|
|
9370
9369
|
const versionDoc = {
|
|
9371
|
-
id:
|
|
9370
|
+
id: globalThis.crypto.randomUUID(),
|
|
9372
9371
|
blockId: promptBlock.id,
|
|
9373
9372
|
versionNumber: 1,
|
|
9374
9373
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -10073,7 +10072,7 @@ var MongoDBScorerDefinitionsStorage = class MongoDBScorerDefinitionsStorage exte
|
|
|
10073
10072
|
const snapshotConfig = {};
|
|
10074
10073
|
for (const field of SNAPSHOT_FIELDS$2) if (scorerDefinition[field] !== void 0) snapshotConfig[field] = scorerDefinition[field];
|
|
10075
10074
|
const versionDoc = {
|
|
10076
|
-
id:
|
|
10075
|
+
id: globalThis.crypto.randomUUID(),
|
|
10077
10076
|
scorerDefinitionId: scorerDefinition.id,
|
|
10078
10077
|
versionNumber: 1,
|
|
10079
10078
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -10546,7 +10545,7 @@ var ScoresStorageMongoDB = class ScoresStorageMongoDB extends _mastra_core_stora
|
|
|
10546
10545
|
try {
|
|
10547
10546
|
const now = /* @__PURE__ */ new Date();
|
|
10548
10547
|
const suppliedId = validatedScore.id;
|
|
10549
|
-
const scoreId = suppliedId ??
|
|
10548
|
+
const scoreId = suppliedId ?? globalThis.crypto.randomUUID();
|
|
10550
10549
|
const scorer = typeof validatedScore.scorer === "string" ? (0, _mastra_core_storage.safelyParseJSON)(validatedScore.scorer) : validatedScore.scorer;
|
|
10551
10550
|
const preprocessStepResult = typeof validatedScore.preprocessStepResult === "string" ? (0, _mastra_core_storage.safelyParseJSON)(validatedScore.preprocessStepResult) : validatedScore.preprocessStepResult;
|
|
10552
10551
|
const analyzeStepResult = typeof validatedScore.analyzeStepResult === "string" ? (0, _mastra_core_storage.safelyParseJSON)(validatedScore.analyzeStepResult) : validatedScore.analyzeStepResult;
|
|
@@ -10904,7 +10903,7 @@ var MongoDBSkillsStorage = class MongoDBSkillsStorage extends _mastra_core_stora
|
|
|
10904
10903
|
const snapshotConfig = {};
|
|
10905
10904
|
for (const field of SNAPSHOT_FIELDS$1) if (skill[field] !== void 0) snapshotConfig[field] = skill[field];
|
|
10906
10905
|
const versionDoc = {
|
|
10907
|
-
id:
|
|
10906
|
+
id: globalThis.crypto.randomUUID(),
|
|
10908
10907
|
skillId: id,
|
|
10909
10908
|
versionNumber: 1,
|
|
10910
10909
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -10972,7 +10971,7 @@ var MongoDBSkillsStorage = class MongoDBSkillsStorage extends _mastra_core_stora
|
|
|
10972
10971
|
...configFields
|
|
10973
10972
|
};
|
|
10974
10973
|
newVersionDoc = {
|
|
10975
|
-
id:
|
|
10974
|
+
id: globalThis.crypto.randomUUID(),
|
|
10976
10975
|
skillId: id,
|
|
10977
10976
|
versionNumber: latestVersion.versionNumber + 1,
|
|
10978
10977
|
changedFields,
|
|
@@ -11886,7 +11885,7 @@ var MongoDBWorkspacesStorage = class MongoDBWorkspacesStorage extends _mastra_co
|
|
|
11886
11885
|
const snapshotConfig = {};
|
|
11887
11886
|
for (const field of SNAPSHOT_FIELDS) if (workspace[field] !== void 0) snapshotConfig[field] = workspace[field];
|
|
11888
11887
|
const versionDoc = {
|
|
11889
|
-
id:
|
|
11888
|
+
id: globalThis.crypto.randomUUID(),
|
|
11890
11889
|
workspaceId: id,
|
|
11891
11890
|
versionNumber: 1,
|
|
11892
11891
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -11945,7 +11944,7 @@ var MongoDBWorkspacesStorage = class MongoDBWorkspacesStorage extends _mastra_co
|
|
|
11945
11944
|
...configFields
|
|
11946
11945
|
};
|
|
11947
11946
|
newVersionDoc = {
|
|
11948
|
-
id:
|
|
11947
|
+
id: globalThis.crypto.randomUUID(),
|
|
11949
11948
|
workspaceId: id,
|
|
11950
11949
|
versionNumber: latestVersion.versionNumber + 1,
|
|
11951
11950
|
changedFields: Object.keys(configFields),
|