@mastra/mongodb 1.15.1 → 1.16.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/CHANGELOG.md +45 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +18 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.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/memory/index.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @mastra/mongodb
|
|
2
2
|
|
|
3
|
+
## 1.16.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- When MongoDB storage initialization fails because an existing non-unique index conflicts with Mastra's required unique index, the error now includes step-by-step migration commands instead of a generic failure message. ([#20486](https://github.com/mastra-ai/mastra/pull/20486))
|
|
8
|
+
|
|
9
|
+
**Before:** `Failed to create default index on collection "mastra_threads". Set skipDefaultIndexes to manage indexes yourself.`
|
|
10
|
+
|
|
11
|
+
**After:**
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
Index conflict on collection "mastra_threads": an existing non-unique index on { id: 1 }
|
|
15
|
+
conflicts with Mastra's required unique index.
|
|
16
|
+
|
|
17
|
+
To migrate:
|
|
18
|
+
1. Check for duplicates: db.mastra_threads.aggregate([{ $group: { _id: "$id", n: { $sum: 1 } } }, { $match: { n: { $gt: 1 } } }])
|
|
19
|
+
2. Drop the old index: db.mastra_threads.dropIndex("id_1")
|
|
20
|
+
3. Recreate as unique: db.mastra_threads.createIndex({ id: 1 }, { unique: true })
|
|
21
|
+
|
|
22
|
+
Alternatively, set skipDefaultIndexes: true to manage indexes yourself.
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`594f7b2`](https://github.com/mastra-ai/mastra/commit/594f7b28f5263fb9982fd50d95c471fb971ea984), [`311f943`](https://github.com/mastra-ai/mastra/commit/311f943bee60e8fdf5c84499ea50e884276c936c), [`0c89896`](https://github.com/mastra-ai/mastra/commit/0c8989673fb7d106837098398131e570c6023b68), [`23b4238`](https://github.com/mastra-ai/mastra/commit/23b423844ad0bcf2a502a68dd62866d6160f9f6d), [`e320a76`](https://github.com/mastra-ai/mastra/commit/e320a763feaf65c6be3cebecf746defcbde161b3), [`03b4918`](https://github.com/mastra-ai/mastra/commit/03b4918c80d188ce375334c393e131c6e94bd7eb), [`14ef73a`](https://github.com/mastra-ai/mastra/commit/14ef73a4bbd73e7808414816eb0628ce1d80b5d7), [`1d677d5`](https://github.com/mastra-ai/mastra/commit/1d677d5f99d7db403f7828585e8c25f299f72628), [`93e28ec`](https://github.com/mastra-ai/mastra/commit/93e28ecce9031c02397e0ae8406593e5c7a95883), [`729dab4`](https://github.com/mastra-ai/mastra/commit/729dab408faccfaef0cbb048e5a4338f9172847e), [`484003d`](https://github.com/mastra-ai/mastra/commit/484003d33ff59330c86b19863e4a38732d7e4155), [`933d291`](https://github.com/mastra-ai/mastra/commit/933d291146b789c19442ad206f94da3e4be90c64)]:
|
|
26
|
+
- @mastra/core@1.56.0-alpha.3
|
|
27
|
+
|
|
28
|
+
## 1.16.0-alpha.0
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- Added persistence for dataset item undeclared tool policies. ([#19643](https://github.com/mastra-ai/mastra/pull/19643))
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
await dataset.addItem({
|
|
36
|
+
input: 'What is the weather?',
|
|
37
|
+
unmockedToolPolicy: 'deny',
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- Added a comment column to experiment results so review comments persist. The column is added automatically and non-destructively on startup for existing databases (https://github.com/mastra-ai/mastra/issues/19857). ([#19865](https://github.com/mastra-ai/mastra/pull/19865))
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [[`c5e56ff`](https://github.com/mastra-ai/mastra/commit/c5e56ff3bcabdf062708f2d48744fec304df6792), [`4e35a56`](https://github.com/mastra-ai/mastra/commit/4e35a56cdf8d74a5ff6d5eda01f2c1deaf6cc7be)]:
|
|
46
|
+
- @mastra/core@1.56.0-alpha.1
|
|
47
|
+
|
|
3
48
|
## 1.15.1
|
|
4
49
|
|
|
5
50
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -10,7 +10,7 @@ let _mastra_core_agent = require("@mastra/core/agent");
|
|
|
10
10
|
let _mastra_core_evals = require("@mastra/core/evals");
|
|
11
11
|
let _mastra_core_storage_domains_skills = require("@mastra/core/storage/domains/skills");
|
|
12
12
|
//#region package.json
|
|
13
|
-
var version = "1.
|
|
13
|
+
var version = "1.16.0-alpha.1";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/vector/filter.ts
|
|
16
16
|
/**
|
|
@@ -2799,6 +2799,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
2799
2799
|
groundTruth: typeof row.groundTruth === "string" ? (0, _mastra_core_storage.safelyParseJSON)(row.groundTruth) : row.groundTruth,
|
|
2800
2800
|
expectedTrajectory: typeof row.expectedTrajectory === "string" ? (0, _mastra_core_storage.safelyParseJSON)(row.expectedTrajectory) : row.expectedTrajectory,
|
|
2801
2801
|
toolMocks: (typeof row.toolMocks === "string" ? (0, _mastra_core_storage.safelyParseJSON)(row.toolMocks) : row.toolMocks) ?? void 0,
|
|
2802
|
+
unmockedToolPolicy: row.unmockedToolPolicy ?? void 0,
|
|
2802
2803
|
requestContext: typeof row.requestContext === "string" ? (0, _mastra_core_storage.safelyParseJSON)(row.requestContext) : row.requestContext,
|
|
2803
2804
|
metadata: typeof row.metadata === "string" ? (0, _mastra_core_storage.safelyParseJSON)(row.metadata) : row.metadata,
|
|
2804
2805
|
source: typeof row.source === "string" ? (0, _mastra_core_storage.safelyParseJSON)(row.source) : row.source,
|
|
@@ -3041,6 +3042,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3041
3042
|
groundTruth: args.groundTruth ?? null,
|
|
3042
3043
|
expectedTrajectory: args.expectedTrajectory ?? null,
|
|
3043
3044
|
toolMocks: args.toolMocks ?? null,
|
|
3045
|
+
unmockedToolPolicy: args.unmockedToolPolicy ?? null,
|
|
3044
3046
|
requestContext: args.requestContext ?? null,
|
|
3045
3047
|
metadata: args.metadata ?? null,
|
|
3046
3048
|
source: args.source ?? null,
|
|
@@ -3064,6 +3066,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3064
3066
|
groundTruth: args.groundTruth,
|
|
3065
3067
|
expectedTrajectory: args.expectedTrajectory,
|
|
3066
3068
|
toolMocks: args.toolMocks,
|
|
3069
|
+
unmockedToolPolicy: args.unmockedToolPolicy,
|
|
3067
3070
|
requestContext: args.requestContext,
|
|
3068
3071
|
metadata: args.metadata,
|
|
3069
3072
|
source: args.source,
|
|
@@ -3098,13 +3101,14 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3098
3101
|
actualDatasetId: existing.datasetId
|
|
3099
3102
|
}
|
|
3100
3103
|
});
|
|
3101
|
-
if (!(args.input !== void 0 || args.groundTruth !== void 0 || args.expectedTrajectory !== void 0 || args.toolMocks !== void 0 || args.requestContext !== void 0 || args.metadata !== void 0 || args.source !== void 0)) return existing;
|
|
3104
|
+
if (!(args.input !== void 0 || args.groundTruth !== void 0 || args.expectedTrajectory !== void 0 || args.toolMocks !== void 0 || args.unmockedToolPolicy !== void 0 || args.requestContext !== void 0 || args.metadata !== void 0 || args.source !== void 0)) return existing;
|
|
3102
3105
|
const now = /* @__PURE__ */ new Date();
|
|
3103
3106
|
const versionId = (0, crypto$1.randomUUID)();
|
|
3104
3107
|
const mergedInput = args.input !== void 0 ? args.input : existing.input;
|
|
3105
3108
|
const mergedGroundTruth = args.groundTruth !== void 0 ? args.groundTruth : existing.groundTruth;
|
|
3106
3109
|
const mergedExpectedTrajectory = args.expectedTrajectory !== void 0 ? args.expectedTrajectory : existing.expectedTrajectory;
|
|
3107
3110
|
const mergedToolMocks = args.toolMocks !== void 0 ? args.toolMocks : existing.toolMocks;
|
|
3111
|
+
const mergedUnmockedToolPolicy = args.unmockedToolPolicy !== void 0 ? args.unmockedToolPolicy : existing.unmockedToolPolicy;
|
|
3108
3112
|
const mergedRequestContext = args.requestContext !== void 0 ? args.requestContext : existing.requestContext;
|
|
3109
3113
|
const mergedMetadata = args.metadata !== void 0 ? args.metadata : existing.metadata;
|
|
3110
3114
|
const mergedSource = args.source !== void 0 ? args.source : existing.source;
|
|
@@ -3146,6 +3150,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3146
3150
|
groundTruth: mergedGroundTruth,
|
|
3147
3151
|
expectedTrajectory: mergedExpectedTrajectory ?? null,
|
|
3148
3152
|
toolMocks: mergedToolMocks ?? null,
|
|
3153
|
+
unmockedToolPolicy: mergedUnmockedToolPolicy ?? null,
|
|
3149
3154
|
requestContext: mergedRequestContext,
|
|
3150
3155
|
metadata: mergedMetadata,
|
|
3151
3156
|
source: mergedSource,
|
|
@@ -3168,6 +3173,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3168
3173
|
groundTruth: mergedGroundTruth,
|
|
3169
3174
|
expectedTrajectory: mergedExpectedTrajectory,
|
|
3170
3175
|
toolMocks: mergedToolMocks,
|
|
3176
|
+
unmockedToolPolicy: mergedUnmockedToolPolicy,
|
|
3171
3177
|
requestContext: mergedRequestContext,
|
|
3172
3178
|
metadata: mergedMetadata,
|
|
3173
3179
|
source: mergedSource,
|
|
@@ -3233,6 +3239,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3233
3239
|
groundTruth: existing.groundTruth,
|
|
3234
3240
|
expectedTrajectory: existing.expectedTrajectory ?? null,
|
|
3235
3241
|
toolMocks: existing.toolMocks ?? null,
|
|
3242
|
+
unmockedToolPolicy: existing.unmockedToolPolicy ?? null,
|
|
3236
3243
|
requestContext: existing.requestContext,
|
|
3237
3244
|
metadata: existing.metadata,
|
|
3238
3245
|
source: existing.source,
|
|
@@ -3305,6 +3312,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3305
3312
|
groundTruth: insert.item.groundTruth,
|
|
3306
3313
|
expectedTrajectory: insert.item.expectedTrajectory,
|
|
3307
3314
|
toolMocks: insert.item.toolMocks,
|
|
3315
|
+
unmockedToolPolicy: insert.item.unmockedToolPolicy,
|
|
3308
3316
|
requestContext: insert.item.requestContext,
|
|
3309
3317
|
metadata: insert.item.metadata,
|
|
3310
3318
|
source: insert.item.source,
|
|
@@ -3385,6 +3393,7 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3385
3393
|
groundTruth: item.groundTruth,
|
|
3386
3394
|
expectedTrajectory: item.expectedTrajectory ?? null,
|
|
3387
3395
|
toolMocks: item.toolMocks ?? null,
|
|
3396
|
+
unmockedToolPolicy: item.unmockedToolPolicy ?? null,
|
|
3388
3397
|
requestContext: item.requestContext,
|
|
3389
3398
|
metadata: item.metadata,
|
|
3390
3399
|
source: item.source,
|
|
@@ -3685,6 +3694,7 @@ function transformExperimentResultRow(row) {
|
|
|
3685
3694
|
traceId: row.traceId ?? null,
|
|
3686
3695
|
status: row.status ?? null,
|
|
3687
3696
|
tags: Array.isArray(row.tags) ? row.tags : parseJsonField(row.tags) ?? null,
|
|
3697
|
+
comment: row.comment ?? null,
|
|
3688
3698
|
toolMockReport: parseJsonField(row.toolMockReport) ?? null,
|
|
3689
3699
|
createdAt: toDate(row.createdAt)
|
|
3690
3700
|
};
|
|
@@ -4101,6 +4111,7 @@ var MongoDBExperimentsStorage = class MongoDBExperimentsStorage extends _mastra_
|
|
|
4101
4111
|
const updateFields = {};
|
|
4102
4112
|
if (input.status !== void 0) updateFields.status = input.status;
|
|
4103
4113
|
if (input.tags !== void 0) updateFields.tags = input.tags;
|
|
4114
|
+
if (input.comment !== void 0) updateFields.comment = input.comment;
|
|
4104
4115
|
if (Object.keys(updateFields).length === 0) {
|
|
4105
4116
|
const existing = await this.getExperimentResultById({ id: input.id });
|
|
4106
4117
|
if (!existing || input.experimentId && existing.experimentId !== input.experimentId) throw new _mastra_core_error.MastraError({
|
|
@@ -5318,11 +5329,15 @@ var MemoryStorageMongoDB = class MemoryStorageMongoDB extends _mastra_core_stora
|
|
|
5318
5329
|
for (const indexDef of this.getDefaultIndexDefinitions()) try {
|
|
5319
5330
|
await (await this.getCollection(indexDef.collection)).createIndex(indexDef.keys, indexDef.options);
|
|
5320
5331
|
} catch (error) {
|
|
5332
|
+
const isUniqueConflict = error?.code === 85 && indexDef.options?.unique === true;
|
|
5333
|
+
const field = Object.keys(indexDef.keys)[0] ?? "id";
|
|
5334
|
+
const indexName = Object.entries(indexDef.keys).map(([k, v]) => `${k}_${v}`).join("_");
|
|
5335
|
+
const text = isUniqueConflict ? `Index conflict on collection "${indexDef.collection}": an existing non-unique index on { ${field}: 1 } conflicts with Mastra's required unique index.\n\nTo migrate:\n 1. Check for duplicates: db.${indexDef.collection}.aggregate([{ $group: { _id: "$${field}", n: { $sum: 1 } } }, { $match: { n: { $gt: 1 } } }])\n 2. Drop the old index: db.${indexDef.collection}.dropIndex("${indexName}")\n 3. Recreate as unique: db.${indexDef.collection}.createIndex({ ${field}: 1 }, { unique: true })\n\nAlternatively, set skipDefaultIndexes: true to manage indexes yourself.` : `Failed to create default index on collection "${indexDef.collection}". Set skipDefaultIndexes to manage indexes yourself.`;
|
|
5321
5336
|
throw new _mastra_core_error.MastraError({
|
|
5322
5337
|
id: (0, _mastra_core_storage.createStorageErrorId)("MONGODB", "CREATE_DEFAULT_INDEXES", "FAILED"),
|
|
5323
5338
|
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
5324
5339
|
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
5325
|
-
text
|
|
5340
|
+
text,
|
|
5326
5341
|
details: { collection: indexDef.collection }
|
|
5327
5342
|
}, error);
|
|
5328
5343
|
}
|