@mastra/mongodb 1.20.0 → 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/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 +3 -3
package/dist/index.js
CHANGED
|
@@ -4,12 +4,11 @@ import { AgentsStorage, BackgroundTasksStorage, BlobStore, DatasetsStorage, Expe
|
|
|
4
4
|
import { MastraVector, validateUpsertInput, validateVectorValues } from "@mastra/core/vector";
|
|
5
5
|
import { MongoBulkWriteError, MongoClient, ObjectId } from "mongodb";
|
|
6
6
|
import { BaseFilterTranslator } from "@mastra/core/vector/filter";
|
|
7
|
-
import { randomUUID } from "crypto";
|
|
8
7
|
import { MessageList } from "@mastra/core/agent";
|
|
9
8
|
import { saveScorePayloadSchema } from "@mastra/core/evals";
|
|
10
9
|
import { skillSnapshotFieldValuesEqual } from "@mastra/core/storage/domains/skills";
|
|
11
10
|
//#region package.json
|
|
12
|
-
var version = "1.20.0";
|
|
11
|
+
var version = "1.20.1-alpha.0";
|
|
13
12
|
//#endregion
|
|
14
13
|
//#region src/vector/filter.ts
|
|
15
14
|
/**
|
|
@@ -1843,7 +1842,7 @@ var MongoDBAgentsStorage = class MongoDBAgentsStorage extends AgentsStorage {
|
|
|
1843
1842
|
};
|
|
1844
1843
|
const { id: _id, authorId: _authorId, visibility: _visibility, metadata: _metadata, ...snapshotConfig } = agent;
|
|
1845
1844
|
const versionDoc = {
|
|
1846
|
-
id: randomUUID(),
|
|
1845
|
+
id: globalThis.crypto.randomUUID(),
|
|
1847
1846
|
agentId: agent.id,
|
|
1848
1847
|
versionNumber: 1,
|
|
1849
1848
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -3010,7 +3009,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
3010
3009
|
}
|
|
3011
3010
|
async createDataset(input) {
|
|
3012
3011
|
try {
|
|
3013
|
-
const id = input.id ?? randomUUID();
|
|
3012
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
3014
3013
|
if (input.id !== void 0) this.validateCallerDefinedDatasetId(input.id);
|
|
3015
3014
|
const now = /* @__PURE__ */ new Date();
|
|
3016
3015
|
const collection = await this.getCollection(TABLE_DATASETS);
|
|
@@ -3201,8 +3200,8 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
3201
3200
|
}
|
|
3202
3201
|
async _doAddItem(args) {
|
|
3203
3202
|
try {
|
|
3204
|
-
const id = randomUUID();
|
|
3205
|
-
const versionId = randomUUID();
|
|
3203
|
+
const id = globalThis.crypto.randomUUID();
|
|
3204
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
3206
3205
|
const now = /* @__PURE__ */ new Date();
|
|
3207
3206
|
const datasetsCollection = await this.getCollection(TABLE_DATASETS);
|
|
3208
3207
|
const itemsCollection = await this.getCollection(TABLE_DATASET_ITEMS);
|
|
@@ -3304,7 +3303,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
3304
3303
|
return existing;
|
|
3305
3304
|
}
|
|
3306
3305
|
const now = /* @__PURE__ */ new Date();
|
|
3307
|
-
const versionId = randomUUID();
|
|
3306
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
3308
3307
|
const datasetsCollection = await this.getCollection(TABLE_DATASETS);
|
|
3309
3308
|
const itemsCollection = await this.getCollection(TABLE_DATASET_ITEMS);
|
|
3310
3309
|
const versionsCollection = await this.getCollection(TABLE_DATASET_VERSIONS);
|
|
@@ -3429,7 +3428,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
3429
3428
|
async _doDeleteItem({ id, datasetId }) {
|
|
3430
3429
|
try {
|
|
3431
3430
|
const now = /* @__PURE__ */ new Date();
|
|
3432
|
-
const versionId = randomUUID();
|
|
3431
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
3433
3432
|
const datasetsCollection = await this.getCollection(TABLE_DATASETS);
|
|
3434
3433
|
const itemsCollection = await this.getCollection(TABLE_DATASET_ITEMS);
|
|
3435
3434
|
const versionsCollection = await this.getCollection(TABLE_DATASET_VERSIONS);
|
|
@@ -3611,7 +3610,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
3611
3610
|
datasetId: input.datasetId,
|
|
3612
3611
|
externalId: { $in: externalIds }
|
|
3613
3612
|
}, { session }).sort({ datasetVersion: 1 }).toArray();
|
|
3614
|
-
const plan = this.planDatasetItemBatch(input.items, historyRows.map((row) => this.transformItemRowFull(row)), randomUUID);
|
|
3613
|
+
const plan = this.planDatasetItemBatch(input.items, historyRows.map((row) => this.transformItemRowFull(row)), () => globalThis.crypto.randomUUID());
|
|
3615
3614
|
const resolved = new Map([...plan.existingCurrentItems].map(([id, row]) => [id, this.datasetItemFromRow(row)]));
|
|
3616
3615
|
if (plan.inserts.length > 0) {
|
|
3617
3616
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -3651,7 +3650,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
3651
3650
|
resolved.set(item.id, item);
|
|
3652
3651
|
}
|
|
3653
3652
|
await versionsCollection.insertOne({
|
|
3654
|
-
id: randomUUID(),
|
|
3653
|
+
id: globalThis.crypto.randomUUID(),
|
|
3655
3654
|
datasetId: input.datasetId,
|
|
3656
3655
|
version: newVersion,
|
|
3657
3656
|
createdAt: now
|
|
@@ -3679,7 +3678,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
3679
3678
|
});
|
|
3680
3679
|
const itemsCollection = await this.getCollection(TABLE_DATASET_ITEMS);
|
|
3681
3680
|
const now = /* @__PURE__ */ new Date();
|
|
3682
|
-
const versionId = randomUUID();
|
|
3681
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
3683
3682
|
const datasetsCollection = await this.getCollection(TABLE_DATASETS);
|
|
3684
3683
|
const versionsCollection = await this.getCollection(TABLE_DATASET_VERSIONS);
|
|
3685
3684
|
await this.#connector.withTransaction(async (session) => {
|
|
@@ -3885,7 +3884,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
3885
3884
|
}
|
|
3886
3885
|
async createDatasetVersion(datasetId, version) {
|
|
3887
3886
|
try {
|
|
3888
|
-
const id = randomUUID();
|
|
3887
|
+
const id = globalThis.crypto.randomUUID();
|
|
3889
3888
|
const now = /* @__PURE__ */ new Date();
|
|
3890
3889
|
await (await this.getCollection(TABLE_DATASET_VERSIONS)).insertOne({
|
|
3891
3890
|
id,
|
|
@@ -4245,7 +4244,7 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends Experime
|
|
|
4245
4244
|
await this.createCustomIndexes();
|
|
4246
4245
|
}
|
|
4247
4246
|
async createExperiment(input) {
|
|
4248
|
-
const id = input.id ?? randomUUID();
|
|
4247
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
4249
4248
|
const now = /* @__PURE__ */ new Date();
|
|
4250
4249
|
const doc = {
|
|
4251
4250
|
id,
|
|
@@ -4423,7 +4422,7 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends Experime
|
|
|
4423
4422
|
}
|
|
4424
4423
|
}
|
|
4425
4424
|
async addExperimentResult(input) {
|
|
4426
|
-
const id = input.id ?? randomUUID();
|
|
4425
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
4427
4426
|
const now = /* @__PURE__ */ new Date();
|
|
4428
4427
|
try {
|
|
4429
4428
|
return await this.#withPurgeBarrier(input.experimentId, input.itemId, async (session, marker) => {
|
|
@@ -4491,7 +4490,7 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends Experime
|
|
|
4491
4490
|
...marker ? { comment: null } : {}
|
|
4492
4491
|
},
|
|
4493
4492
|
$setOnInsert: {
|
|
4494
|
-
id: randomUUID(),
|
|
4493
|
+
id: globalThis.crypto.randomUUID(),
|
|
4495
4494
|
createdAt: /* @__PURE__ */ new Date()
|
|
4496
4495
|
}
|
|
4497
4496
|
}, {
|
|
@@ -5678,7 +5677,7 @@ var MongoDBMCPClientsStorage = class MongoDBMCPClientsStorage extends MCPClients
|
|
|
5678
5677
|
const snapshotConfig = {};
|
|
5679
5678
|
for (const field of SNAPSHOT_FIELDS$5) if (mcpClient[field] !== void 0) snapshotConfig[field] = mcpClient[field];
|
|
5680
5679
|
const versionDoc = {
|
|
5681
|
-
id: randomUUID(),
|
|
5680
|
+
id: globalThis.crypto.randomUUID(),
|
|
5682
5681
|
mcpClientId: mcpClient.id,
|
|
5683
5682
|
versionNumber: 1,
|
|
5684
5683
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -6133,7 +6132,7 @@ var MongoDBMCPServersStorage = class MongoDBMCPServersStorage extends MCPServers
|
|
|
6133
6132
|
const snapshotConfig = {};
|
|
6134
6133
|
for (const field of SNAPSHOT_FIELDS$4) if (mcpServer[field] !== void 0) snapshotConfig[field] = mcpServer[field];
|
|
6135
6134
|
const versionDoc = {
|
|
6136
|
-
id: randomUUID(),
|
|
6135
|
+
id: globalThis.crypto.randomUUID(),
|
|
6137
6136
|
mcpServerId: mcpServer.id,
|
|
6138
6137
|
versionNumber: 1,
|
|
6139
6138
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -7329,7 +7328,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends MemoryStorage {
|
|
|
7329
7328
|
text: `Source thread with id ${sourceThreadId} not found`,
|
|
7330
7329
|
details: { sourceThreadId }
|
|
7331
7330
|
});
|
|
7332
|
-
const newThreadId = providedThreadId || randomUUID();
|
|
7331
|
+
const newThreadId = providedThreadId || globalThis.crypto.randomUUID();
|
|
7333
7332
|
if (await this.getThreadById({ threadId: newThreadId })) throw new MastraError({
|
|
7334
7333
|
id: createStorageErrorId("MONGODB", "CLONE_THREAD", "THREAD_EXISTS"),
|
|
7335
7334
|
domain: ErrorDomain.STORAGE,
|
|
@@ -7379,7 +7378,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends MemoryStorage {
|
|
|
7379
7378
|
if (sourceMessages.length > 0) {
|
|
7380
7379
|
const messageDocs = [];
|
|
7381
7380
|
for (const sourceMsg of sourceMessages) {
|
|
7382
|
-
const newMessageId = randomUUID();
|
|
7381
|
+
const newMessageId = globalThis.crypto.randomUUID();
|
|
7383
7382
|
messageIdMap[sourceMsg.id] = newMessageId;
|
|
7384
7383
|
let parsedContent = sourceMsg.content;
|
|
7385
7384
|
if (typeof parsedContent === "string") try {
|
|
@@ -7528,7 +7527,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends MemoryStorage {
|
|
|
7528
7527
|
}
|
|
7529
7528
|
async initializeObservationalMemory(input) {
|
|
7530
7529
|
try {
|
|
7531
|
-
const id = randomUUID();
|
|
7530
|
+
const id = globalThis.crypto.randomUUID();
|
|
7532
7531
|
const now = /* @__PURE__ */ new Date();
|
|
7533
7532
|
const lookupKey = this.getOMKey(input.threadId, input.resourceId);
|
|
7534
7533
|
const record = {
|
|
@@ -7677,7 +7676,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends MemoryStorage {
|
|
|
7677
7676
|
}
|
|
7678
7677
|
async createReflectionGeneration(input) {
|
|
7679
7678
|
try {
|
|
7680
|
-
const id = randomUUID();
|
|
7679
|
+
const id = globalThis.crypto.randomUUID();
|
|
7681
7680
|
const now = /* @__PURE__ */ new Date();
|
|
7682
7681
|
const lookupKey = this.getOMKey(input.currentRecord.threadId, input.currentRecord.resourceId);
|
|
7683
7682
|
const record = {
|
|
@@ -7943,7 +7942,7 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends MemoryStorage {
|
|
|
7943
7942
|
try {
|
|
7944
7943
|
const collection = await this.getCollection(OM_TABLE);
|
|
7945
7944
|
const newChunk = {
|
|
7946
|
-
id: `ombuf-${randomUUID()}`,
|
|
7945
|
+
id: `ombuf-${globalThis.crypto.randomUUID()}`,
|
|
7947
7946
|
cycleId: input.chunk.cycleId,
|
|
7948
7947
|
observations: input.chunk.observations,
|
|
7949
7948
|
tokenCount: input.chunk.tokenCount,
|
|
@@ -8412,7 +8411,7 @@ var NotificationsMongoDB = class NotificationsMongoDB extends NotificationsStora
|
|
|
8412
8411
|
}
|
|
8413
8412
|
const now = input.createdAt ?? /* @__PURE__ */ new Date();
|
|
8414
8413
|
const record = {
|
|
8415
|
-
id: input.id ?? randomUUID(),
|
|
8414
|
+
id: input.id ?? globalThis.crypto.randomUUID(),
|
|
8416
8415
|
threadId: input.threadId,
|
|
8417
8416
|
source: input.source,
|
|
8418
8417
|
kind: input.kind,
|
|
@@ -9367,7 +9366,7 @@ var MongoDBPromptBlocksStorage = class MongoDBPromptBlocksStorage extends Prompt
|
|
|
9367
9366
|
const snapshotConfig = {};
|
|
9368
9367
|
for (const field of SNAPSHOT_FIELDS$3) if (promptBlock[field] !== void 0) snapshotConfig[field] = promptBlock[field];
|
|
9369
9368
|
const versionDoc = {
|
|
9370
|
-
id: randomUUID(),
|
|
9369
|
+
id: globalThis.crypto.randomUUID(),
|
|
9371
9370
|
blockId: promptBlock.id,
|
|
9372
9371
|
versionNumber: 1,
|
|
9373
9372
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -10072,7 +10071,7 @@ var MongoDBScorerDefinitionsStorage = class MongoDBScorerDefinitionsStorage exte
|
|
|
10072
10071
|
const snapshotConfig = {};
|
|
10073
10072
|
for (const field of SNAPSHOT_FIELDS$2) if (scorerDefinition[field] !== void 0) snapshotConfig[field] = scorerDefinition[field];
|
|
10074
10073
|
const versionDoc = {
|
|
10075
|
-
id: randomUUID(),
|
|
10074
|
+
id: globalThis.crypto.randomUUID(),
|
|
10076
10075
|
scorerDefinitionId: scorerDefinition.id,
|
|
10077
10076
|
versionNumber: 1,
|
|
10078
10077
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -10545,7 +10544,7 @@ var ScoresStorageMongoDB = class ScoresStorageMongoDB extends ScoresStorage {
|
|
|
10545
10544
|
try {
|
|
10546
10545
|
const now = /* @__PURE__ */ new Date();
|
|
10547
10546
|
const suppliedId = validatedScore.id;
|
|
10548
|
-
const scoreId = suppliedId ?? randomUUID();
|
|
10547
|
+
const scoreId = suppliedId ?? globalThis.crypto.randomUUID();
|
|
10549
10548
|
const scorer = typeof validatedScore.scorer === "string" ? safelyParseJSON(validatedScore.scorer) : validatedScore.scorer;
|
|
10550
10549
|
const preprocessStepResult = typeof validatedScore.preprocessStepResult === "string" ? safelyParseJSON(validatedScore.preprocessStepResult) : validatedScore.preprocessStepResult;
|
|
10551
10550
|
const analyzeStepResult = typeof validatedScore.analyzeStepResult === "string" ? safelyParseJSON(validatedScore.analyzeStepResult) : validatedScore.analyzeStepResult;
|
|
@@ -10903,7 +10902,7 @@ var MongoDBSkillsStorage = class MongoDBSkillsStorage extends SkillsStorage {
|
|
|
10903
10902
|
const snapshotConfig = {};
|
|
10904
10903
|
for (const field of SNAPSHOT_FIELDS$1) if (skill[field] !== void 0) snapshotConfig[field] = skill[field];
|
|
10905
10904
|
const versionDoc = {
|
|
10906
|
-
id: randomUUID(),
|
|
10905
|
+
id: globalThis.crypto.randomUUID(),
|
|
10907
10906
|
skillId: id,
|
|
10908
10907
|
versionNumber: 1,
|
|
10909
10908
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -10971,7 +10970,7 @@ var MongoDBSkillsStorage = class MongoDBSkillsStorage extends SkillsStorage {
|
|
|
10971
10970
|
...configFields
|
|
10972
10971
|
};
|
|
10973
10972
|
newVersionDoc = {
|
|
10974
|
-
id: randomUUID(),
|
|
10973
|
+
id: globalThis.crypto.randomUUID(),
|
|
10975
10974
|
skillId: id,
|
|
10976
10975
|
versionNumber: latestVersion.versionNumber + 1,
|
|
10977
10976
|
changedFields,
|
|
@@ -11885,7 +11884,7 @@ var MongoDBWorkspacesStorage = class MongoDBWorkspacesStorage extends Workspaces
|
|
|
11885
11884
|
const snapshotConfig = {};
|
|
11886
11885
|
for (const field of SNAPSHOT_FIELDS) if (workspace[field] !== void 0) snapshotConfig[field] = workspace[field];
|
|
11887
11886
|
const versionDoc = {
|
|
11888
|
-
id: randomUUID(),
|
|
11887
|
+
id: globalThis.crypto.randomUUID(),
|
|
11889
11888
|
workspaceId: id,
|
|
11890
11889
|
versionNumber: 1,
|
|
11891
11890
|
changedFields: Object.keys(snapshotConfig),
|
|
@@ -11944,7 +11943,7 @@ var MongoDBWorkspacesStorage = class MongoDBWorkspacesStorage extends Workspaces
|
|
|
11944
11943
|
...configFields
|
|
11945
11944
|
};
|
|
11946
11945
|
newVersionDoc = {
|
|
11947
|
-
id: randomUUID(),
|
|
11946
|
+
id: globalThis.crypto.randomUUID(),
|
|
11948
11947
|
workspaceId: id,
|
|
11949
11948
|
versionNumber: latestVersion.versionNumber + 1,
|
|
11950
11949
|
changedFields: Object.keys(configFields),
|