@mastra/mongodb 1.0.0-beta.2 → 1.0.0-beta.4

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/index.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var error = require('@mastra/core/error');
4
+ var storage = require('@mastra/core/storage');
4
5
  var vector = require('@mastra/core/vector');
5
6
  var mongodb = require('mongodb');
6
7
  var uuid = require('uuid');
7
8
  var filter = require('@mastra/core/vector/filter');
8
- var storage = require('@mastra/core/storage');
9
9
  var agent = require('@mastra/core/agent');
10
10
  var evals = require('@mastra/core/evals');
11
11
 
@@ -13,7 +13,7 @@ var evals = require('@mastra/core/evals');
13
13
 
14
14
  // package.json
15
15
  var package_default = {
16
- version: "1.0.0-beta.2"};
16
+ version: "1.0.0-beta.4"};
17
17
  var MongoDBFilterTranslator = class extends filter.BaseFilterTranslator {
18
18
  getSupportedOperators() {
19
19
  return {
@@ -136,7 +136,7 @@ var MongoDBVector = class extends vector.MastraVector {
136
136
  } catch (error$1) {
137
137
  throw new error.MastraError(
138
138
  {
139
- id: "STORAGE_MONGODB_VECTOR_CONNECT_FAILED",
139
+ id: storage.createVectorErrorId("MONGODB", "CONNECT", "FAILED"),
140
140
  domain: error.ErrorDomain.STORAGE,
141
141
  category: error.ErrorCategory.THIRD_PARTY
142
142
  },
@@ -150,7 +150,7 @@ var MongoDBVector = class extends vector.MastraVector {
150
150
  } catch (error$1) {
151
151
  throw new error.MastraError(
152
152
  {
153
- id: "STORAGE_MONGODB_VECTOR_DISCONNECT_FAILED",
153
+ id: storage.createVectorErrorId("MONGODB", "DISCONNECT", "FAILED"),
154
154
  domain: error.ErrorDomain.STORAGE,
155
155
  category: error.ErrorCategory.THIRD_PARTY
156
156
  },
@@ -171,7 +171,7 @@ var MongoDBVector = class extends vector.MastraVector {
171
171
  } catch (error$1) {
172
172
  throw new error.MastraError(
173
173
  {
174
- id: "STORAGE_MONGODB_VECTOR_CREATE_INDEX_INVALID_ARGS",
174
+ id: storage.createVectorErrorId("MONGODB", "CREATE_INDEX", "INVALID_ARGS"),
175
175
  domain: error.ErrorDomain.STORAGE,
176
176
  category: error.ErrorCategory.USER,
177
177
  details: {
@@ -224,7 +224,7 @@ var MongoDBVector = class extends vector.MastraVector {
224
224
  if (error$1.codeName !== "IndexAlreadyExists") {
225
225
  throw new error.MastraError(
226
226
  {
227
- id: "STORAGE_MONGODB_VECTOR_CREATE_INDEX_FAILED",
227
+ id: storage.createVectorErrorId("MONGODB", "CREATE_INDEX", "FAILED"),
228
228
  domain: error.ErrorDomain.STORAGE,
229
229
  category: error.ErrorCategory.THIRD_PARTY
230
230
  },
@@ -237,7 +237,7 @@ var MongoDBVector = class extends vector.MastraVector {
237
237
  } catch (error$1) {
238
238
  throw new error.MastraError(
239
239
  {
240
- id: "STORAGE_MONGODB_VECTOR_CREATE_INDEX_FAILED_STORE_METADATA",
240
+ id: storage.createVectorErrorId("MONGODB", "CREATE_INDEX", "STORE_METADATA_FAILED"),
241
241
  domain: error.ErrorDomain.STORAGE,
242
242
  category: error.ErrorCategory.THIRD_PARTY,
243
243
  details: {
@@ -314,7 +314,7 @@ var MongoDBVector = class extends vector.MastraVector {
314
314
  } catch (error$1) {
315
315
  throw new error.MastraError(
316
316
  {
317
- id: "STORAGE_MONGODB_VECTOR_UPSERT_FAILED",
317
+ id: storage.createVectorErrorId("MONGODB", "UPSERT", "FAILED"),
318
318
  domain: error.ErrorDomain.STORAGE,
319
319
  category: error.ErrorCategory.THIRD_PARTY,
320
320
  details: {
@@ -395,7 +395,7 @@ var MongoDBVector = class extends vector.MastraVector {
395
395
  } catch (error$1) {
396
396
  throw new error.MastraError(
397
397
  {
398
- id: "STORAGE_MONGODB_VECTOR_QUERY_FAILED",
398
+ id: storage.createVectorErrorId("MONGODB", "QUERY", "FAILED"),
399
399
  domain: error.ErrorDomain.STORAGE,
400
400
  category: error.ErrorCategory.THIRD_PARTY,
401
401
  details: {
@@ -413,7 +413,7 @@ var MongoDBVector = class extends vector.MastraVector {
413
413
  } catch (error$1) {
414
414
  throw new error.MastraError(
415
415
  {
416
- id: "STORAGE_MONGODB_VECTOR_LIST_INDEXES_FAILED",
416
+ id: storage.createVectorErrorId("MONGODB", "LIST_INDEXES", "FAILED"),
417
417
  domain: error.ErrorDomain.STORAGE,
418
418
  category: error.ErrorCategory.THIRD_PARTY
419
419
  },
@@ -442,7 +442,7 @@ var MongoDBVector = class extends vector.MastraVector {
442
442
  } catch (error$1) {
443
443
  throw new error.MastraError(
444
444
  {
445
- id: "STORAGE_MONGODB_VECTOR_DESCRIBE_INDEX_FAILED",
445
+ id: storage.createVectorErrorId("MONGODB", "DESCRIBE_INDEX", "FAILED"),
446
446
  domain: error.ErrorDomain.STORAGE,
447
447
  category: error.ErrorCategory.THIRD_PARTY,
448
448
  details: {
@@ -465,7 +465,7 @@ var MongoDBVector = class extends vector.MastraVector {
465
465
  } catch (error$1) {
466
466
  throw new error.MastraError(
467
467
  {
468
- id: "STORAGE_MONGODB_VECTOR_DELETE_INDEX_FAILED",
468
+ id: storage.createVectorErrorId("MONGODB", "DELETE_INDEX", "FAILED"),
469
469
  domain: error.ErrorDomain.STORAGE,
470
470
  category: error.ErrorCategory.THIRD_PARTY,
471
471
  details: {
@@ -490,7 +490,7 @@ var MongoDBVector = class extends vector.MastraVector {
490
490
  const { indexName, update } = params;
491
491
  if ("id" in params && params.id && "filter" in params && params.filter) {
492
492
  throw new error.MastraError({
493
- id: "STORAGE_MONGODB_VECTOR_UPDATE_MUTUALLY_EXCLUSIVE_PARAMS",
493
+ id: storage.createVectorErrorId("MONGODB", "UPDATE_VECTOR", "MUTUALLY_EXCLUSIVE"),
494
494
  domain: error.ErrorDomain.STORAGE,
495
495
  category: error.ErrorCategory.USER,
496
496
  details: { indexName },
@@ -499,7 +499,7 @@ var MongoDBVector = class extends vector.MastraVector {
499
499
  }
500
500
  if (!("id" in params || "filter" in params) || !params.id && !params.filter) {
501
501
  throw new error.MastraError({
502
- id: "STORAGE_MONGODB_VECTOR_UPDATE_MISSING_PARAMS",
502
+ id: storage.createVectorErrorId("MONGODB", "UPDATE_VECTOR", "NO_TARGET"),
503
503
  domain: error.ErrorDomain.STORAGE,
504
504
  category: error.ErrorCategory.USER,
505
505
  text: "Either id or filter must be provided",
@@ -533,7 +533,7 @@ var MongoDBVector = class extends vector.MastraVector {
533
533
  const filter = params.filter;
534
534
  if (!filter || Object.keys(filter).length === 0) {
535
535
  throw new error.MastraError({
536
- id: "STORAGE_MONGODB_VECTOR_UPDATE_EMPTY_FILTER",
536
+ id: storage.createVectorErrorId("MONGODB", "UPDATE_VECTOR", "EMPTY_FILTER"),
537
537
  domain: error.ErrorDomain.STORAGE,
538
538
  category: error.ErrorCategory.USER,
539
539
  details: { indexName },
@@ -544,7 +544,7 @@ var MongoDBVector = class extends vector.MastraVector {
544
544
  const transformedFilter = this.transformMetadataFilter(mongoFilter);
545
545
  if (!transformedFilter || Object.keys(transformedFilter).length === 0) {
546
546
  throw new error.MastraError({
547
- id: "STORAGE_MONGODB_VECTOR_UPDATE_INVALID_FILTER",
547
+ id: storage.createVectorErrorId("MONGODB", "UPDATE_VECTOR", "INVALID_FILTER"),
548
548
  domain: error.ErrorDomain.STORAGE,
549
549
  category: error.ErrorCategory.USER,
550
550
  details: { indexName },
@@ -566,7 +566,7 @@ var MongoDBVector = class extends vector.MastraVector {
566
566
  }
567
567
  throw new error.MastraError(
568
568
  {
569
- id: "STORAGE_MONGODB_VECTOR_UPDATE_VECTOR_FAILED",
569
+ id: storage.createVectorErrorId("MONGODB", "UPDATE_VECTOR", "FAILED"),
570
570
  domain: error.ErrorDomain.STORAGE,
571
571
  category: error.ErrorCategory.THIRD_PARTY,
572
572
  details: errorDetails
@@ -589,7 +589,7 @@ var MongoDBVector = class extends vector.MastraVector {
589
589
  } catch (error$1) {
590
590
  throw new error.MastraError(
591
591
  {
592
- id: "STORAGE_MONGODB_VECTOR_DELETE_VECTOR_FAILED",
592
+ id: storage.createVectorErrorId("MONGODB", "DELETE_VECTOR", "FAILED"),
593
593
  domain: error.ErrorDomain.STORAGE,
594
594
  category: error.ErrorCategory.THIRD_PARTY,
595
595
  details: {
@@ -604,7 +604,7 @@ var MongoDBVector = class extends vector.MastraVector {
604
604
  async deleteVectors({ indexName, filter, ids }) {
605
605
  if (!filter && !ids) {
606
606
  throw new error.MastraError({
607
- id: "STORAGE_MONGODB_VECTOR_DELETE_MISSING_PARAMS",
607
+ id: storage.createVectorErrorId("MONGODB", "DELETE_VECTORS", "NO_TARGET"),
608
608
  domain: error.ErrorDomain.STORAGE,
609
609
  category: error.ErrorCategory.USER,
610
610
  details: { indexName },
@@ -613,7 +613,7 @@ var MongoDBVector = class extends vector.MastraVector {
613
613
  }
614
614
  if (filter && ids) {
615
615
  throw new error.MastraError({
616
- id: "STORAGE_MONGODB_VECTOR_DELETE_CONFLICTING_PARAMS",
616
+ id: storage.createVectorErrorId("MONGODB", "DELETE_VECTORS", "MUTUALLY_EXCLUSIVE"),
617
617
  domain: error.ErrorDomain.STORAGE,
618
618
  category: error.ErrorCategory.USER,
619
619
  details: { indexName },
@@ -625,7 +625,7 @@ var MongoDBVector = class extends vector.MastraVector {
625
625
  if (ids) {
626
626
  if (ids.length === 0) {
627
627
  throw new error.MastraError({
628
- id: "STORAGE_MONGODB_VECTOR_DELETE_EMPTY_IDS",
628
+ id: storage.createVectorErrorId("MONGODB", "DELETE_VECTORS", "EMPTY_IDS"),
629
629
  domain: error.ErrorDomain.STORAGE,
630
630
  category: error.ErrorCategory.USER,
631
631
  details: { indexName },
@@ -636,7 +636,7 @@ var MongoDBVector = class extends vector.MastraVector {
636
636
  } else {
637
637
  if (!filter || Object.keys(filter).length === 0) {
638
638
  throw new error.MastraError({
639
- id: "STORAGE_MONGODB_VECTOR_DELETE_EMPTY_FILTER",
639
+ id: storage.createVectorErrorId("MONGODB", "DELETE_VECTORS", "EMPTY_FILTER"),
640
640
  domain: error.ErrorDomain.STORAGE,
641
641
  category: error.ErrorCategory.USER,
642
642
  details: { indexName },
@@ -647,7 +647,7 @@ var MongoDBVector = class extends vector.MastraVector {
647
647
  const transformedFilter = this.transformMetadataFilter(mongoFilter);
648
648
  if (!transformedFilter || Object.keys(transformedFilter).length === 0) {
649
649
  throw new error.MastraError({
650
- id: "STORAGE_MONGODB_VECTOR_DELETE_INVALID_FILTER",
650
+ id: storage.createVectorErrorId("MONGODB", "DELETE_VECTORS", "INVALID_FILTER"),
651
651
  domain: error.ErrorDomain.STORAGE,
652
652
  category: error.ErrorCategory.USER,
653
653
  details: { indexName },
@@ -665,7 +665,7 @@ var MongoDBVector = class extends vector.MastraVector {
665
665
  }
666
666
  throw new error.MastraError(
667
667
  {
668
- id: "STORAGE_MONGODB_VECTOR_DELETE_VECTORS_FAILED",
668
+ id: storage.createVectorErrorId("MONGODB", "DELETE_VECTORS", "FAILED"),
669
669
  domain: error.ErrorDomain.STORAGE,
670
670
  category: error.ErrorCategory.THIRD_PARTY,
671
671
  details: {
@@ -838,8 +838,6 @@ var MongoDBConnector = class _MongoDBConnector {
838
838
  }
839
839
  }
840
840
  };
841
-
842
- // src/storage/domains/utils.ts
843
841
  function formatDateForMongoDB(date) {
844
842
  return typeof date === "string" ? new Date(date) : date;
845
843
  }
@@ -870,18 +868,16 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
870
868
  if (row.type && row.type !== "v2") result.type = row.type;
871
869
  return result;
872
870
  }
873
- async _getIncludedMessages({
874
- threadId,
875
- include
876
- }) {
877
- if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
878
- if (!include) return null;
871
+ async _getIncludedMessages({ include }) {
872
+ if (!include || include.length === 0) return null;
879
873
  const collection = await this.operations.getCollection(storage.TABLE_MESSAGES);
880
874
  const includedMessages = [];
881
875
  for (const inc of include) {
882
876
  const { id, withPreviousMessages = 0, withNextMessages = 0 } = inc;
883
- const searchThreadId = inc.threadId || threadId;
884
- const allMessages = await collection.find({ thread_id: searchThreadId }).sort({ createdAt: 1 }).toArray();
877
+ const targetMessage = await collection.findOne({ id });
878
+ if (!targetMessage) continue;
879
+ const messageThreadId = targetMessage.thread_id;
880
+ const allMessages = await collection.find({ thread_id: messageThreadId }).sort({ createdAt: 1 }).toArray();
885
881
  const targetIndex = allMessages.findIndex((msg) => msg.id === id);
886
882
  if (targetIndex === -1) continue;
887
883
  const startIndex = Math.max(0, targetIndex - withPreviousMessages);
@@ -911,7 +907,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
911
907
  } catch (error$1) {
912
908
  throw new error.MastraError(
913
909
  {
914
- id: "MONGODB_STORE_LIST_MESSAGES_BY_ID_FAILED",
910
+ id: storage.createStorageErrorId("MONGODB", "LIST_MESSAGES_BY_ID", "FAILED"),
915
911
  domain: error.ErrorDomain.STORAGE,
916
912
  category: error.ErrorCategory.THIRD_PARTY,
917
913
  details: { messageIds: JSON.stringify(messageIds) }
@@ -922,21 +918,22 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
922
918
  }
923
919
  async listMessages(args) {
924
920
  const { threadId, resourceId, include, filter, perPage: perPageInput, page = 0, orderBy } = args;
925
- if (!threadId.trim()) {
921
+ const threadIds = Array.isArray(threadId) ? threadId : [threadId];
922
+ if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
926
923
  throw new error.MastraError(
927
924
  {
928
- id: "STORAGE_MONGODB_LIST_MESSAGES_INVALID_THREAD_ID",
925
+ id: storage.createStorageErrorId("MONGODB", "LIST_MESSAGES", "INVALID_THREAD_ID"),
929
926
  domain: error.ErrorDomain.STORAGE,
930
927
  category: error.ErrorCategory.THIRD_PARTY,
931
- details: { threadId }
928
+ details: { threadId: Array.isArray(threadId) ? threadId.join(",") : threadId }
932
929
  },
933
- new Error("threadId must be a non-empty string")
930
+ new Error("threadId must be a non-empty string or array of non-empty strings")
934
931
  );
935
932
  }
936
933
  if (page < 0) {
937
934
  throw new error.MastraError(
938
935
  {
939
- id: "STORAGE_MONGODB_LIST_MESSAGES_INVALID_PAGE",
936
+ id: storage.createStorageErrorId("MONGODB", "LIST_MESSAGES", "INVALID_PAGE"),
940
937
  domain: error.ErrorDomain.STORAGE,
941
938
  category: error.ErrorCategory.USER,
942
939
  details: { page }
@@ -950,7 +947,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
950
947
  const { field, direction } = this.parseOrderBy(orderBy, "ASC");
951
948
  const sortOrder = direction === "ASC" ? 1 : -1;
952
949
  const collection = await this.operations.getCollection(storage.TABLE_MESSAGES);
953
- const query = { thread_id: threadId };
950
+ const query = { thread_id: threadIds.length === 1 ? threadIds[0] : { $in: threadIds } };
954
951
  if (resourceId) {
955
952
  query.resourceId = resourceId;
956
953
  }
@@ -982,7 +979,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
982
979
  }
983
980
  const messageIds = new Set(messages.map((m) => m.id));
984
981
  if (include && include.length > 0) {
985
- const includeMessages = await this._getIncludedMessages({ threadId, include });
982
+ const includeMessages = await this._getIncludedMessages({ include });
986
983
  if (includeMessages) {
987
984
  for (const includeMsg of includeMessages) {
988
985
  if (!messageIds.has(includeMsg.id)) {
@@ -1003,7 +1000,10 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1003
1000
  }
1004
1001
  return direction === "ASC" ? String(aValue).localeCompare(String(bValue)) : String(bValue).localeCompare(String(aValue));
1005
1002
  });
1006
- const returnedThreadMessageIds = new Set(finalMessages.filter((m) => m.threadId === threadId).map((m) => m.id));
1003
+ const threadIdSet = new Set(threadIds);
1004
+ const returnedThreadMessageIds = new Set(
1005
+ finalMessages.filter((m) => m.threadId && threadIdSet.has(m.threadId)).map((m) => m.id)
1006
+ );
1007
1007
  const allThreadMessagesReturned = returnedThreadMessageIds.size >= total;
1008
1008
  const hasMore = perPageInput !== false && !allThreadMessagesReturned && offset + perPage < total;
1009
1009
  return {
@@ -1016,11 +1016,11 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1016
1016
  } catch (error$1) {
1017
1017
  const mastraError = new error.MastraError(
1018
1018
  {
1019
- id: "MONGODB_STORE_LIST_MESSAGES_FAILED",
1019
+ id: storage.createStorageErrorId("MONGODB", "LIST_MESSAGES", "FAILED"),
1020
1020
  domain: error.ErrorDomain.STORAGE,
1021
1021
  category: error.ErrorCategory.THIRD_PARTY,
1022
1022
  details: {
1023
- threadId,
1023
+ threadId: Array.isArray(threadId) ? threadId.join(",") : threadId,
1024
1024
  resourceId: resourceId ?? ""
1025
1025
  }
1026
1026
  },
@@ -1085,7 +1085,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1085
1085
  } catch (error$1) {
1086
1086
  throw new error.MastraError(
1087
1087
  {
1088
- id: "MONGODB_STORE_SAVE_MESSAGES_FAILED",
1088
+ id: storage.createStorageErrorId("MONGODB", "SAVE_MESSAGES", "FAILED"),
1089
1089
  domain: error.ErrorDomain.STORAGE,
1090
1090
  category: error.ErrorCategory.THIRD_PARTY
1091
1091
  },
@@ -1183,7 +1183,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1183
1183
  } catch (error$1) {
1184
1184
  throw new error.MastraError(
1185
1185
  {
1186
- id: "STORAGE_MONGODB_STORE_GET_RESOURCE_BY_ID_FAILED",
1186
+ id: storage.createStorageErrorId("MONGODB", "GET_RESOURCE_BY_ID", "FAILED"),
1187
1187
  domain: error.ErrorDomain.STORAGE,
1188
1188
  category: error.ErrorCategory.THIRD_PARTY,
1189
1189
  details: { resourceId }
@@ -1209,7 +1209,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1209
1209
  } catch (error$1) {
1210
1210
  throw new error.MastraError(
1211
1211
  {
1212
- id: "STORAGE_MONGODB_STORE_SAVE_RESOURCE_FAILED",
1212
+ id: storage.createStorageErrorId("MONGODB", "SAVE_RESOURCE", "FAILED"),
1213
1213
  domain: error.ErrorDomain.STORAGE,
1214
1214
  category: error.ErrorCategory.THIRD_PARTY,
1215
1215
  details: { resourceId: resource.id }
@@ -1254,7 +1254,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1254
1254
  } catch (error$1) {
1255
1255
  throw new error.MastraError(
1256
1256
  {
1257
- id: "STORAGE_MONGODB_STORE_UPDATE_RESOURCE_FAILED",
1257
+ id: storage.createStorageErrorId("MONGODB", "UPDATE_RESOURCE", "FAILED"),
1258
1258
  domain: error.ErrorDomain.STORAGE,
1259
1259
  category: error.ErrorCategory.THIRD_PARTY,
1260
1260
  details: { resourceId }
@@ -1277,7 +1277,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1277
1277
  } catch (error$1) {
1278
1278
  throw new error.MastraError(
1279
1279
  {
1280
- id: "STORAGE_MONGODB_STORE_GET_THREAD_BY_ID_FAILED",
1280
+ id: storage.createStorageErrorId("MONGODB", "GET_THREAD_BY_ID", "FAILED"),
1281
1281
  domain: error.ErrorDomain.STORAGE,
1282
1282
  category: error.ErrorCategory.THIRD_PARTY,
1283
1283
  details: { threadId }
@@ -1292,7 +1292,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1292
1292
  if (page < 0) {
1293
1293
  throw new error.MastraError(
1294
1294
  {
1295
- id: "STORAGE_MONGODB_LIST_THREADS_BY_RESOURCE_ID_INVALID_PAGE",
1295
+ id: storage.createStorageErrorId("MONGODB", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
1296
1296
  domain: error.ErrorDomain.STORAGE,
1297
1297
  category: error.ErrorCategory.USER,
1298
1298
  details: { page }
@@ -1338,7 +1338,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1338
1338
  } catch (error$1) {
1339
1339
  throw new error.MastraError(
1340
1340
  {
1341
- id: "MONGODB_STORE_LIST_THREADS_BY_RESOURCE_ID_FAILED",
1341
+ id: storage.createStorageErrorId("MONGODB", "LIST_THREADS_BY_RESOURCE_ID", "FAILED"),
1342
1342
  domain: error.ErrorDomain.STORAGE,
1343
1343
  category: error.ErrorCategory.THIRD_PARTY,
1344
1344
  details: { resourceId: args.resourceId }
@@ -1364,7 +1364,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1364
1364
  } catch (error$1) {
1365
1365
  throw new error.MastraError(
1366
1366
  {
1367
- id: "STORAGE_MONGODB_STORE_SAVE_THREAD_FAILED",
1367
+ id: storage.createStorageErrorId("MONGODB", "SAVE_THREAD", "FAILED"),
1368
1368
  domain: error.ErrorDomain.STORAGE,
1369
1369
  category: error.ErrorCategory.THIRD_PARTY,
1370
1370
  details: { threadId: thread.id }
@@ -1381,7 +1381,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1381
1381
  const thread = await this.getThreadById({ threadId: id });
1382
1382
  if (!thread) {
1383
1383
  throw new error.MastraError({
1384
- id: "STORAGE_MONGODB_STORE_UPDATE_THREAD_NOT_FOUND",
1384
+ id: storage.createStorageErrorId("MONGODB", "UPDATE_THREAD", "NOT_FOUND"),
1385
1385
  domain: error.ErrorDomain.STORAGE,
1386
1386
  category: error.ErrorCategory.THIRD_PARTY,
1387
1387
  details: { threadId: id, status: 404 },
@@ -1410,7 +1410,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1410
1410
  } catch (error$1) {
1411
1411
  throw new error.MastraError(
1412
1412
  {
1413
- id: "STORAGE_MONGODB_STORE_UPDATE_THREAD_FAILED",
1413
+ id: storage.createStorageErrorId("MONGODB", "UPDATE_THREAD", "FAILED"),
1414
1414
  domain: error.ErrorDomain.STORAGE,
1415
1415
  category: error.ErrorCategory.THIRD_PARTY,
1416
1416
  details: { threadId: id }
@@ -1429,7 +1429,7 @@ var MemoryStorageMongoDB = class extends storage.MemoryStorage {
1429
1429
  } catch (error$1) {
1430
1430
  throw new error.MastraError(
1431
1431
  {
1432
- id: "STORAGE_MONGODB_STORE_DELETE_THREAD_FAILED",
1432
+ id: storage.createStorageErrorId("MONGODB", "DELETE_THREAD", "FAILED"),
1433
1433
  domain: error.ErrorDomain.STORAGE,
1434
1434
  category: error.ErrorCategory.THIRD_PARTY,
1435
1435
  details: { threadId }
@@ -1466,7 +1466,7 @@ var ObservabilityMongoDB = class extends storage.ObservabilityStorage {
1466
1466
  } catch (error$1) {
1467
1467
  throw new error.MastraError(
1468
1468
  {
1469
- id: "MONGODB_STORE_CREATE_SPAN_FAILED",
1469
+ id: storage.createStorageErrorId("MONGODB", "CREATE_SPAN", "FAILED"),
1470
1470
  domain: error.ErrorDomain.STORAGE,
1471
1471
  category: error.ErrorCategory.USER,
1472
1472
  details: {
@@ -1494,7 +1494,7 @@ var ObservabilityMongoDB = class extends storage.ObservabilityStorage {
1494
1494
  } catch (error$1) {
1495
1495
  throw new error.MastraError(
1496
1496
  {
1497
- id: "MONGODB_STORE_GET_TRACE_FAILED",
1497
+ id: storage.createStorageErrorId("MONGODB", "GET_TRACE", "FAILED"),
1498
1498
  domain: error.ErrorDomain.STORAGE,
1499
1499
  category: error.ErrorCategory.USER,
1500
1500
  details: {
@@ -1530,7 +1530,7 @@ var ObservabilityMongoDB = class extends storage.ObservabilityStorage {
1530
1530
  } catch (error$1) {
1531
1531
  throw new error.MastraError(
1532
1532
  {
1533
- id: "MONGODB_STORE_UPDATE_SPAN_FAILED",
1533
+ id: storage.createStorageErrorId("MONGODB", "UPDATE_SPAN", "FAILED"),
1534
1534
  domain: error.ErrorDomain.STORAGE,
1535
1535
  category: error.ErrorCategory.USER,
1536
1536
  details: {
@@ -1576,7 +1576,7 @@ var ObservabilityMongoDB = class extends storage.ObservabilityStorage {
1576
1576
  name = `agent run: '${entityId}'`;
1577
1577
  } else {
1578
1578
  const error$1 = new error.MastraError({
1579
- id: "MONGODB_STORE_GET_TRACES_PAGINATED_FAILED",
1579
+ id: storage.createStorageErrorId("MONGODB", "GET_TRACES_PAGINATED", "INVALID_ENTITY_TYPE"),
1580
1580
  domain: error.ErrorDomain.STORAGE,
1581
1581
  category: error.ErrorCategory.USER,
1582
1582
  details: {
@@ -1613,7 +1613,7 @@ var ObservabilityMongoDB = class extends storage.ObservabilityStorage {
1613
1613
  } catch (error$1) {
1614
1614
  throw new error.MastraError(
1615
1615
  {
1616
- id: "MONGODB_STORE_GET_TRACES_PAGINATED_FAILED",
1616
+ id: storage.createStorageErrorId("MONGODB", "GET_TRACES_PAGINATED", "FAILED"),
1617
1617
  domain: error.ErrorDomain.STORAGE,
1618
1618
  category: error.ErrorCategory.USER
1619
1619
  },
@@ -1641,7 +1641,7 @@ var ObservabilityMongoDB = class extends storage.ObservabilityStorage {
1641
1641
  } catch (error$1) {
1642
1642
  throw new error.MastraError(
1643
1643
  {
1644
- id: "MONGODB_STORE_BATCH_CREATE_SPANS_FAILED",
1644
+ id: storage.createStorageErrorId("MONGODB", "BATCH_CREATE_SPANS", "FAILED"),
1645
1645
  domain: error.ErrorDomain.STORAGE,
1646
1646
  category: error.ErrorCategory.USER
1647
1647
  },
@@ -1674,7 +1674,7 @@ var ObservabilityMongoDB = class extends storage.ObservabilityStorage {
1674
1674
  } catch (error$1) {
1675
1675
  throw new error.MastraError(
1676
1676
  {
1677
- id: "MONGODB_STORE_BATCH_UPDATE_SPANS_FAILED",
1677
+ id: storage.createStorageErrorId("MONGODB", "BATCH_UPDATE_SPANS", "FAILED"),
1678
1678
  domain: error.ErrorDomain.STORAGE,
1679
1679
  category: error.ErrorCategory.USER
1680
1680
  },
@@ -1691,7 +1691,7 @@ var ObservabilityMongoDB = class extends storage.ObservabilityStorage {
1691
1691
  } catch (error$1) {
1692
1692
  throw new error.MastraError(
1693
1693
  {
1694
- id: "MONGODB_STORE_BATCH_DELETE_TRACES_FAILED",
1694
+ id: storage.createStorageErrorId("MONGODB", "BATCH_DELETE_TRACES", "FAILED"),
1695
1695
  domain: error.ErrorDomain.STORAGE,
1696
1696
  category: error.ErrorCategory.USER
1697
1697
  },
@@ -1742,7 +1742,7 @@ var StoreOperationsMongoDB = class extends storage.StoreOperations {
1742
1742
  } catch (error$1) {
1743
1743
  const mastraError = new error.MastraError(
1744
1744
  {
1745
- id: "STORAGE_MONGODB_STORE_CLEAR_TABLE_FAILED",
1745
+ id: storage.createStorageErrorId("MONGODB", "CLEAR_TABLE", "FAILED"),
1746
1746
  domain: error.ErrorDomain.STORAGE,
1747
1747
  category: error.ErrorCategory.THIRD_PARTY,
1748
1748
  details: { tableName }
@@ -1764,7 +1764,7 @@ var StoreOperationsMongoDB = class extends storage.StoreOperations {
1764
1764
  }
1765
1765
  throw new error.MastraError(
1766
1766
  {
1767
- id: "MONGODB_STORE_DROP_TABLE_FAILED",
1767
+ id: storage.createStorageErrorId("MONGODB", "DROP_TABLE", "FAILED"),
1768
1768
  domain: error.ErrorDomain.STORAGE,
1769
1769
  category: error.ErrorCategory.THIRD_PARTY,
1770
1770
  details: { tableName }
@@ -1795,7 +1795,7 @@ var StoreOperationsMongoDB = class extends storage.StoreOperations {
1795
1795
  } catch (error$1) {
1796
1796
  const mastraError = new error.MastraError(
1797
1797
  {
1798
- id: "STORAGE_MONGODB_STORE_INSERT_FAILED",
1798
+ id: storage.createStorageErrorId("MONGODB", "INSERT", "FAILED"),
1799
1799
  domain: error.ErrorDomain.STORAGE,
1800
1800
  category: error.ErrorCategory.THIRD_PARTY,
1801
1801
  details: { tableName }
@@ -1818,7 +1818,7 @@ var StoreOperationsMongoDB = class extends storage.StoreOperations {
1818
1818
  } catch (error$1) {
1819
1819
  throw new error.MastraError(
1820
1820
  {
1821
- id: "STORAGE_MONGODB_STORE_BATCH_INSERT_FAILED",
1821
+ id: storage.createStorageErrorId("MONGODB", "BATCH_INSERT", "FAILED"),
1822
1822
  domain: error.ErrorDomain.STORAGE,
1823
1823
  category: error.ErrorCategory.THIRD_PARTY,
1824
1824
  details: { tableName }
@@ -1835,7 +1835,7 @@ var StoreOperationsMongoDB = class extends storage.StoreOperations {
1835
1835
  } catch (error$1) {
1836
1836
  throw new error.MastraError(
1837
1837
  {
1838
- id: "STORAGE_MONGODB_STORE_LOAD_FAILED",
1838
+ id: storage.createStorageErrorId("MONGODB", "LOAD", "FAILED"),
1839
1839
  domain: error.ErrorDomain.STORAGE,
1840
1840
  category: error.ErrorCategory.THIRD_PARTY,
1841
1841
  details: { tableName }
@@ -1857,7 +1857,7 @@ var StoreOperationsMongoDB = class extends storage.StoreOperations {
1857
1857
  } catch (error$1) {
1858
1858
  throw new error.MastraError(
1859
1859
  {
1860
- id: "STORAGE_MONGODB_STORE_UPDATE_FAILED",
1860
+ id: storage.createStorageErrorId("MONGODB", "UPDATE", "FAILED"),
1861
1861
  domain: error.ErrorDomain.STORAGE,
1862
1862
  category: error.ErrorCategory.THIRD_PARTY,
1863
1863
  details: { tableName }
@@ -1889,7 +1889,7 @@ var StoreOperationsMongoDB = class extends storage.StoreOperations {
1889
1889
  } catch (error$1) {
1890
1890
  throw new error.MastraError(
1891
1891
  {
1892
- id: "STORAGE_MONGODB_STORE_BATCH_UPDATE_FAILED",
1892
+ id: storage.createStorageErrorId("MONGODB", "BATCH_UPDATE", "FAILED"),
1893
1893
  domain: error.ErrorDomain.STORAGE,
1894
1894
  category: error.ErrorCategory.THIRD_PARTY,
1895
1895
  details: { tableName }
@@ -1900,98 +1900,9 @@ var StoreOperationsMongoDB = class extends storage.StoreOperations {
1900
1900
  }
1901
1901
  };
1902
1902
  function transformScoreRow(row) {
1903
- let scorerValue = null;
1904
- if (row.scorer) {
1905
- try {
1906
- scorerValue = typeof row.scorer === "string" ? storage.safelyParseJSON(row.scorer) : row.scorer;
1907
- } catch (e) {
1908
- console.warn("Failed to parse scorer:", e);
1909
- }
1910
- }
1911
- let preprocessStepResultValue = null;
1912
- if (row.preprocessStepResult) {
1913
- try {
1914
- preprocessStepResultValue = typeof row.preprocessStepResult === "string" ? storage.safelyParseJSON(row.preprocessStepResult) : row.preprocessStepResult;
1915
- } catch (e) {
1916
- console.warn("Failed to parse preprocessStepResult:", e);
1917
- }
1918
- }
1919
- let analyzeStepResultValue = null;
1920
- if (row.analyzeStepResult) {
1921
- try {
1922
- analyzeStepResultValue = typeof row.analyzeStepResult === "string" ? storage.safelyParseJSON(row.analyzeStepResult) : row.analyzeStepResult;
1923
- } catch (e) {
1924
- console.warn("Failed to parse analyzeStepResult:", e);
1925
- }
1926
- }
1927
- let inputValue = null;
1928
- if (row.input) {
1929
- try {
1930
- inputValue = typeof row.input === "string" ? storage.safelyParseJSON(row.input) : row.input;
1931
- } catch (e) {
1932
- console.warn("Failed to parse input:", e);
1933
- }
1934
- }
1935
- let outputValue = null;
1936
- if (row.output) {
1937
- try {
1938
- outputValue = typeof row.output === "string" ? storage.safelyParseJSON(row.output) : row.output;
1939
- } catch (e) {
1940
- console.warn("Failed to parse output:", e);
1941
- }
1942
- }
1943
- let entityValue = null;
1944
- if (row.entity) {
1945
- try {
1946
- entityValue = typeof row.entity === "string" ? storage.safelyParseJSON(row.entity) : row.entity;
1947
- } catch (e) {
1948
- console.warn("Failed to parse entity:", e);
1949
- }
1950
- }
1951
- let requestContextValue = null;
1952
- if (row.requestContext) {
1953
- try {
1954
- requestContextValue = typeof row.requestContext === "string" ? storage.safelyParseJSON(row.requestContext) : row.requestContext;
1955
- } catch (e) {
1956
- console.warn("Failed to parse requestContext:", e);
1957
- }
1958
- }
1959
- let metadataValue = null;
1960
- if (row.metadata) {
1961
- try {
1962
- metadataValue = typeof row.metadata === "string" ? storage.safelyParseJSON(row.metadata) : row.metadata;
1963
- } catch (e) {
1964
- console.warn("Failed to parse metadata:", e);
1965
- }
1966
- }
1967
- return {
1968
- id: row.id,
1969
- entityId: row.entityId,
1970
- entityType: row.entityType,
1971
- scorerId: row.scorerId,
1972
- traceId: row.traceId,
1973
- spanId: row.spanId,
1974
- runId: row.runId,
1975
- scorer: scorerValue,
1976
- preprocessStepResult: preprocessStepResultValue,
1977
- preprocessPrompt: row.preprocessPrompt,
1978
- analyzeStepResult: analyzeStepResultValue,
1979
- generateScorePrompt: row.generateScorePrompt,
1980
- score: row.score,
1981
- analyzePrompt: row.analyzePrompt,
1982
- reasonPrompt: row.reasonPrompt,
1983
- metadata: metadataValue,
1984
- input: inputValue,
1985
- output: outputValue,
1986
- additionalContext: row.additionalContext,
1987
- requestContext: requestContextValue,
1988
- entity: entityValue,
1989
- source: row.source,
1990
- resourceId: row.resourceId,
1991
- threadId: row.threadId,
1992
- createdAt: new Date(row.createdAt),
1993
- updatedAt: new Date(row.updatedAt)
1994
- };
1903
+ return storage.transformScoreRow(row, {
1904
+ convertTimestamps: true
1905
+ });
1995
1906
  }
1996
1907
  var ScoresStorageMongoDB = class extends storage.ScoresStorage {
1997
1908
  operations;
@@ -2010,7 +1921,7 @@ var ScoresStorageMongoDB = class extends storage.ScoresStorage {
2010
1921
  } catch (error$1) {
2011
1922
  throw new error.MastraError(
2012
1923
  {
2013
- id: "STORAGE_MONGODB_STORE_GET_SCORE_BY_ID_FAILED",
1924
+ id: storage.createStorageErrorId("MONGODB", "GET_SCORE_BY_ID", "FAILED"),
2014
1925
  domain: error.ErrorDomain.STORAGE,
2015
1926
  category: error.ErrorCategory.THIRD_PARTY,
2016
1927
  details: { id }
@@ -2026,7 +1937,7 @@ var ScoresStorageMongoDB = class extends storage.ScoresStorage {
2026
1937
  } catch (error$1) {
2027
1938
  throw new error.MastraError(
2028
1939
  {
2029
- id: "STORAGE_MONGODB_STORE_SAVE_SCORE_VALIDATION_FAILED",
1940
+ id: storage.createStorageErrorId("MONGODB", "SAVE_SCORE", "VALIDATION_FAILED"),
2030
1941
  domain: error.ErrorDomain.STORAGE,
2031
1942
  category: error.ErrorCategory.THIRD_PARTY
2032
1943
  },
@@ -2036,36 +1947,29 @@ var ScoresStorageMongoDB = class extends storage.ScoresStorage {
2036
1947
  try {
2037
1948
  const now = /* @__PURE__ */ new Date();
2038
1949
  const scoreId = `score-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
2039
- const scoreData = {
2040
- id: scoreId,
2041
- entityId: validatedScore.entityId,
2042
- entityType: validatedScore.entityType,
2043
- scorerId: validatedScore.scorerId,
2044
- traceId: validatedScore.traceId || "",
2045
- spanId: validatedScore.spanId || "",
2046
- runId: validatedScore.runId,
2047
- scorer: typeof validatedScore.scorer === "string" ? storage.safelyParseJSON(validatedScore.scorer) : validatedScore.scorer,
2048
- preprocessStepResult: typeof validatedScore.preprocessStepResult === "string" ? storage.safelyParseJSON(validatedScore.preprocessStepResult) : validatedScore.preprocessStepResult,
2049
- analyzeStepResult: typeof validatedScore.analyzeStepResult === "string" ? storage.safelyParseJSON(validatedScore.analyzeStepResult) : validatedScore.analyzeStepResult,
2050
- score: validatedScore.score,
2051
- reason: validatedScore.reason,
2052
- preprocessPrompt: validatedScore.preprocessPrompt,
2053
- generateScorePrompt: validatedScore.generateScorePrompt,
2054
- generateReasonPrompt: validatedScore.generateReasonPrompt,
2055
- analyzePrompt: validatedScore.analyzePrompt,
2056
- input: typeof validatedScore.input === "string" ? storage.safelyParseJSON(validatedScore.input) : validatedScore.input,
2057
- output: typeof validatedScore.output === "string" ? storage.safelyParseJSON(validatedScore.output) : validatedScore.output,
2058
- additionalContext: validatedScore.additionalContext,
2059
- requestContext: typeof validatedScore.requestContext === "string" ? storage.safelyParseJSON(validatedScore.requestContext) : validatedScore.requestContext,
2060
- entity: typeof validatedScore.entity === "string" ? storage.safelyParseJSON(validatedScore.entity) : validatedScore.entity,
2061
- source: validatedScore.source,
2062
- resourceId: validatedScore.resourceId || "",
2063
- threadId: validatedScore.threadId || "",
2064
- createdAt: now,
2065
- updatedAt: now
1950
+ const scorer = typeof validatedScore.scorer === "string" ? storage.safelyParseJSON(validatedScore.scorer) : validatedScore.scorer;
1951
+ const preprocessStepResult = typeof validatedScore.preprocessStepResult === "string" ? storage.safelyParseJSON(validatedScore.preprocessStepResult) : validatedScore.preprocessStepResult;
1952
+ const analyzeStepResult = typeof validatedScore.analyzeStepResult === "string" ? storage.safelyParseJSON(validatedScore.analyzeStepResult) : validatedScore.analyzeStepResult;
1953
+ const input = typeof validatedScore.input === "string" ? storage.safelyParseJSON(validatedScore.input) : validatedScore.input;
1954
+ const output = typeof validatedScore.output === "string" ? storage.safelyParseJSON(validatedScore.output) : validatedScore.output;
1955
+ const requestContext = typeof validatedScore.requestContext === "string" ? storage.safelyParseJSON(validatedScore.requestContext) : validatedScore.requestContext;
1956
+ const entity = typeof validatedScore.entity === "string" ? storage.safelyParseJSON(validatedScore.entity) : validatedScore.entity;
1957
+ const createdAt = now;
1958
+ const updatedAt = now;
1959
+ const dataToSave = {
1960
+ ...validatedScore,
1961
+ scorer,
1962
+ preprocessStepResult,
1963
+ analyzeStepResult,
1964
+ input,
1965
+ output,
1966
+ requestContext,
1967
+ entity,
1968
+ createdAt,
1969
+ updatedAt
2066
1970
  };
2067
1971
  const collection = await this.operations.getCollection(storage.TABLE_SCORERS);
2068
- await collection.insertOne(scoreData);
1972
+ await collection.insertOne(dataToSave);
2069
1973
  const savedScore = {
2070
1974
  ...score,
2071
1975
  id: scoreId,
@@ -2076,7 +1980,7 @@ var ScoresStorageMongoDB = class extends storage.ScoresStorage {
2076
1980
  } catch (error$1) {
2077
1981
  throw new error.MastraError(
2078
1982
  {
2079
- id: "STORAGE_MONGODB_STORE_SAVE_SCORE_FAILED",
1983
+ id: storage.createStorageErrorId("MONGODB", "SAVE_SCORE", "FAILED"),
2080
1984
  domain: error.ErrorDomain.STORAGE,
2081
1985
  category: error.ErrorCategory.THIRD_PARTY,
2082
1986
  details: { scorerId: score.scorerId, runId: score.runId }
@@ -2138,7 +2042,7 @@ var ScoresStorageMongoDB = class extends storage.ScoresStorage {
2138
2042
  } catch (error$1) {
2139
2043
  throw new error.MastraError(
2140
2044
  {
2141
- id: "STORAGE_MONGODB_STORE_GET_SCORES_BY_SCORER_ID_FAILED",
2045
+ id: storage.createStorageErrorId("MONGODB", "LIST_SCORES_BY_SCORER_ID", "FAILED"),
2142
2046
  domain: error.ErrorDomain.STORAGE,
2143
2047
  category: error.ErrorCategory.THIRD_PARTY,
2144
2048
  details: { scorerId, page: pagination.page, perPage: pagination.perPage }
@@ -2187,7 +2091,7 @@ var ScoresStorageMongoDB = class extends storage.ScoresStorage {
2187
2091
  } catch (error$1) {
2188
2092
  throw new error.MastraError(
2189
2093
  {
2190
- id: "STORAGE_MONGODB_STORE_GET_SCORES_BY_RUN_ID_FAILED",
2094
+ id: storage.createStorageErrorId("MONGODB", "LIST_SCORES_BY_RUN_ID", "FAILED"),
2191
2095
  domain: error.ErrorDomain.STORAGE,
2192
2096
  category: error.ErrorCategory.THIRD_PARTY,
2193
2097
  details: { runId, page: pagination.page, perPage: pagination.perPage }
@@ -2237,7 +2141,7 @@ var ScoresStorageMongoDB = class extends storage.ScoresStorage {
2237
2141
  } catch (error$1) {
2238
2142
  throw new error.MastraError(
2239
2143
  {
2240
- id: "STORAGE_MONGODB_STORE_GET_SCORES_BY_ENTITY_ID_FAILED",
2144
+ id: storage.createStorageErrorId("MONGODB", "LIST_SCORES_BY_ENTITY_ID", "FAILED"),
2241
2145
  domain: error.ErrorDomain.STORAGE,
2242
2146
  category: error.ErrorCategory.THIRD_PARTY,
2243
2147
  details: { entityId, entityType, page: pagination.page, perPage: pagination.perPage }
@@ -2288,7 +2192,7 @@ var ScoresStorageMongoDB = class extends storage.ScoresStorage {
2288
2192
  } catch (error$1) {
2289
2193
  throw new error.MastraError(
2290
2194
  {
2291
- id: "STORAGE_MONGODB_STORE_GET_SCORES_BY_SPAN_FAILED",
2195
+ id: storage.createStorageErrorId("MONGODB", "LIST_SCORES_BY_SPAN", "FAILED"),
2292
2196
  domain: error.ErrorDomain.STORAGE,
2293
2197
  category: error.ErrorCategory.THIRD_PARTY,
2294
2198
  details: { traceId, spanId, page: pagination.page, perPage: pagination.perPage }
@@ -2345,7 +2249,7 @@ var WorkflowsStorageMongoDB = class extends storage.WorkflowsStorage {
2345
2249
  } catch (error$1) {
2346
2250
  throw new error.MastraError(
2347
2251
  {
2348
- id: "STORAGE_MONGODB_STORE_PERSIST_WORKFLOW_SNAPSHOT_FAILED",
2252
+ id: storage.createStorageErrorId("MONGODB", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
2349
2253
  domain: error.ErrorDomain.STORAGE,
2350
2254
  category: error.ErrorCategory.THIRD_PARTY,
2351
2255
  details: { workflowName, runId }
@@ -2373,7 +2277,7 @@ var WorkflowsStorageMongoDB = class extends storage.WorkflowsStorage {
2373
2277
  } catch (error$1) {
2374
2278
  throw new error.MastraError(
2375
2279
  {
2376
- id: "STORAGE_MONGODB_STORE_LOAD_WORKFLOW_SNAPSHOT_FAILED",
2280
+ id: storage.createStorageErrorId("MONGODB", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
2377
2281
  domain: error.ErrorDomain.STORAGE,
2378
2282
  category: error.ErrorCategory.THIRD_PARTY,
2379
2283
  details: { workflowName, runId }
@@ -2412,7 +2316,7 @@ var WorkflowsStorageMongoDB = class extends storage.WorkflowsStorage {
2412
2316
  if (options.page < 0) {
2413
2317
  throw new error.MastraError(
2414
2318
  {
2415
- id: "STORAGE_MONGODB_INVALID_PAGE",
2319
+ id: storage.createStorageErrorId("MONGODB", "LIST_WORKFLOW_RUNS", "INVALID_PAGE"),
2416
2320
  domain: error.ErrorDomain.STORAGE,
2417
2321
  category: error.ErrorCategory.USER,
2418
2322
  details: { page: options.page }
@@ -2438,7 +2342,7 @@ var WorkflowsStorageMongoDB = class extends storage.WorkflowsStorage {
2438
2342
  } catch (error$1) {
2439
2343
  throw new error.MastraError(
2440
2344
  {
2441
- id: "STORAGE_MONGODB_STORE_LIST_WORKFLOW_RUNS_FAILED",
2345
+ id: storage.createStorageErrorId("MONGODB", "LIST_WORKFLOW_RUNS", "FAILED"),
2442
2346
  domain: error.ErrorDomain.STORAGE,
2443
2347
  category: error.ErrorCategory.THIRD_PARTY,
2444
2348
  details: { workflowName: options.workflowName || "unknown" }
@@ -2465,7 +2369,7 @@ var WorkflowsStorageMongoDB = class extends storage.WorkflowsStorage {
2465
2369
  } catch (error$1) {
2466
2370
  throw new error.MastraError(
2467
2371
  {
2468
- id: "STORAGE_MONGODB_STORE_GET_WORKFLOW_RUN_BY_ID_FAILED",
2372
+ id: storage.createStorageErrorId("MONGODB", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
2469
2373
  domain: error.ErrorDomain.STORAGE,
2470
2374
  category: error.ErrorCategory.THIRD_PARTY,
2471
2375
  details: { runId: args.runId }
@@ -2503,7 +2407,7 @@ var loadConnector = (config) => {
2503
2407
  } catch (error$1) {
2504
2408
  throw new error.MastraError(
2505
2409
  {
2506
- id: "STORAGE_MONGODB_STORE_CONSTRUCTOR_FAILED",
2410
+ id: storage.createStorageErrorId("MONGODB", "CONSTRUCTOR", "FAILED"),
2507
2411
  domain: error.ErrorDomain.STORAGE,
2508
2412
  category: error.ErrorCategory.USER,
2509
2413
  details: { connectionHandler: true }
@@ -2521,7 +2425,7 @@ var loadConnector = (config) => {
2521
2425
  } catch (error$1) {
2522
2426
  throw new error.MastraError(
2523
2427
  {
2524
- id: "STORAGE_MONGODB_STORE_CONSTRUCTOR_FAILED",
2428
+ id: storage.createStorageErrorId("MONGODB", "CONSTRUCTOR", "FAILED"),
2525
2429
  domain: error.ErrorDomain.STORAGE,
2526
2430
  category: error.ErrorCategory.USER,
2527
2431
  details: { url: config?.url, dbName: config?.dbName }
@@ -2544,7 +2448,7 @@ var MongoDBStore = class extends storage.MastraStorage {
2544
2448
  };
2545
2449
  }
2546
2450
  constructor(config) {
2547
- super({ id: config.id, name: "MongoDBStore" });
2451
+ super({ id: config.id, name: "MongoDBStore", disableInit: config.disableInit });
2548
2452
  this.stores = {};
2549
2453
  this.#connector = loadConnector(config);
2550
2454
  const operations = new StoreOperationsMongoDB({
@@ -2664,7 +2568,7 @@ var MongoDBStore = class extends storage.MastraStorage {
2664
2568
  } catch (error$1) {
2665
2569
  throw new error.MastraError(
2666
2570
  {
2667
- id: "STORAGE_MONGODB_STORE_CLOSE_FAILED",
2571
+ id: storage.createStorageErrorId("MONGODB", "CLOSE", "FAILED"),
2668
2572
  domain: error.ErrorDomain.STORAGE,
2669
2573
  category: error.ErrorCategory.USER
2670
2574
  },
@@ -2736,7 +2640,7 @@ var MongoDBStore = class extends storage.MastraStorage {
2736
2640
  async createSpan(span) {
2737
2641
  if (!this.stores.observability) {
2738
2642
  throw new error.MastraError({
2739
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2643
+ id: storage.createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2740
2644
  domain: error.ErrorDomain.STORAGE,
2741
2645
  category: error.ErrorCategory.SYSTEM,
2742
2646
  text: "Observability storage is not initialized"
@@ -2751,7 +2655,7 @@ var MongoDBStore = class extends storage.MastraStorage {
2751
2655
  }) {
2752
2656
  if (!this.stores.observability) {
2753
2657
  throw new error.MastraError({
2754
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2658
+ id: storage.createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2755
2659
  domain: error.ErrorDomain.STORAGE,
2756
2660
  category: error.ErrorCategory.SYSTEM,
2757
2661
  text: "Observability storage is not initialized"
@@ -2762,7 +2666,7 @@ var MongoDBStore = class extends storage.MastraStorage {
2762
2666
  async getTrace(traceId) {
2763
2667
  if (!this.stores.observability) {
2764
2668
  throw new error.MastraError({
2765
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2669
+ id: storage.createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2766
2670
  domain: error.ErrorDomain.STORAGE,
2767
2671
  category: error.ErrorCategory.SYSTEM,
2768
2672
  text: "Observability storage is not initialized"
@@ -2773,7 +2677,7 @@ var MongoDBStore = class extends storage.MastraStorage {
2773
2677
  async getTracesPaginated(args) {
2774
2678
  if (!this.stores.observability) {
2775
2679
  throw new error.MastraError({
2776
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2680
+ id: storage.createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2777
2681
  domain: error.ErrorDomain.STORAGE,
2778
2682
  category: error.ErrorCategory.SYSTEM,
2779
2683
  text: "Observability storage is not initialized"
@@ -2784,7 +2688,7 @@ var MongoDBStore = class extends storage.MastraStorage {
2784
2688
  async batchCreateSpans(args) {
2785
2689
  if (!this.stores.observability) {
2786
2690
  throw new error.MastraError({
2787
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2691
+ id: storage.createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2788
2692
  domain: error.ErrorDomain.STORAGE,
2789
2693
  category: error.ErrorCategory.SYSTEM,
2790
2694
  text: "Observability storage is not initialized"
@@ -2795,7 +2699,7 @@ var MongoDBStore = class extends storage.MastraStorage {
2795
2699
  async batchUpdateSpans(args) {
2796
2700
  if (!this.stores.observability) {
2797
2701
  throw new error.MastraError({
2798
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2702
+ id: storage.createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2799
2703
  domain: error.ErrorDomain.STORAGE,
2800
2704
  category: error.ErrorCategory.SYSTEM,
2801
2705
  text: "Observability storage is not initialized"
@@ -2806,7 +2710,7 @@ var MongoDBStore = class extends storage.MastraStorage {
2806
2710
  async batchDeleteTraces(args) {
2807
2711
  if (!this.stores.observability) {
2808
2712
  throw new error.MastraError({
2809
- id: "MONGODB_STORE_OBSERVABILITY_NOT_INITIALIZED",
2713
+ id: storage.createStorageErrorId("MONGODB", "OBSERVABILITY", "NOT_INITIALIZED"),
2810
2714
  domain: error.ErrorDomain.STORAGE,
2811
2715
  category: error.ErrorCategory.SYSTEM,
2812
2716
  text: "Observability storage is not initialized"