@mastra/mssql 1.0.0-beta.3 → 1.0.0-beta.5

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 CHANGED
@@ -1,5 +1,52 @@
1
1
  # @mastra/mssql
2
2
 
3
+ ## 1.0.0-beta.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix saveScore not persisting ID correctly, breaking getScoreById retrieval ([#10915](https://github.com/mastra-ai/mastra/pull/10915))
8
+
9
+ **What Changed**
10
+ - saveScore now correctly returns scores that can be retrieved with getScoreById
11
+ - Validation errors now include contextual information (scorer, entity, trace details) for easier debugging
12
+
13
+ **Impact**
14
+ Previously, calling getScoreById after saveScore would return null because the generated ID wasn't persisted to the database. This is now fixed across all store implementations, ensuring consistent behavior and data integrity.
15
+
16
+ - Updated dependencies [[`0d41fe2`](https://github.com/mastra-ai/mastra/commit/0d41fe245355dfc66d61a0d9c85d9400aac351ff), [`6b3ba91`](https://github.com/mastra-ai/mastra/commit/6b3ba91494cc10394df96782f349a4f7b1e152cc), [`7907fd1`](https://github.com/mastra-ai/mastra/commit/7907fd1c5059813b7b870b81ca71041dc807331b)]:
17
+ - @mastra/core@1.0.0-beta.8
18
+
19
+ ## 1.0.0-beta.4
20
+
21
+ ### Minor Changes
22
+
23
+ - Add `disableInit` option to all storage adapters ([#10851](https://github.com/mastra-ai/mastra/pull/10851))
24
+
25
+ Adds a new `disableInit` config option to all storage providers that allows users to disable automatic table creation/migrations at runtime. This is useful for CI/CD pipelines where you want to run migrations during deployment with elevated credentials, then run the application with `disableInit: true` so it doesn't attempt schema changes at runtime.
26
+
27
+ ```typescript
28
+ // CI/CD script - run migrations
29
+ const storage = new PostgresStore({
30
+ connectionString: DATABASE_URL,
31
+ id: 'pg-storage',
32
+ });
33
+ await storage.init();
34
+
35
+ // Runtime - skip auto-init
36
+ const storage = new PostgresStore({
37
+ connectionString: DATABASE_URL,
38
+ id: 'pg-storage',
39
+ disableInit: true,
40
+ });
41
+ ```
42
+
43
+ ### Patch Changes
44
+
45
+ - Standardize error IDs across all storage and vector stores using centralized helper functions (`createStorageErrorId` and `createVectorErrorId`). This ensures consistent error ID patterns (`MASTRA_STORAGE_{STORE}_{OPERATION}_{STATUS}` and `MASTRA_VECTOR_{STORE}_{OPERATION}_{STATUS}`) across the codebase for better error tracking and debugging. ([#10913](https://github.com/mastra-ai/mastra/pull/10913))
46
+
47
+ - Updated dependencies [[`3076c67`](https://github.com/mastra-ai/mastra/commit/3076c6778b18988ae7d5c4c5c466366974b2d63f), [`85d7ee1`](https://github.com/mastra-ai/mastra/commit/85d7ee18ff4e14d625a8a30ec6656bb49804989b), [`c6c1092`](https://github.com/mastra-ai/mastra/commit/c6c1092f8fbf76109303f69e000e96fd1960c4ce), [`81dc110`](https://github.com/mastra-ai/mastra/commit/81dc11008d147cf5bdc8996ead1aa61dbdebb6fc), [`7aedb74`](https://github.com/mastra-ai/mastra/commit/7aedb74883adf66af38e270e4068fd42e7a37036), [`8f02d80`](https://github.com/mastra-ai/mastra/commit/8f02d800777397e4b45d7f1ad041988a8b0c6630), [`d7aad50`](https://github.com/mastra-ai/mastra/commit/d7aad501ce61646b76b4b511e558ac4eea9884d0), [`ce0a73a`](https://github.com/mastra-ai/mastra/commit/ce0a73abeaa75b10ca38f9e40a255a645d50ebfb), [`a02e542`](https://github.com/mastra-ai/mastra/commit/a02e542d23179bad250b044b17ff023caa61739f), [`a372c64`](https://github.com/mastra-ai/mastra/commit/a372c640ad1fd12e8f0613cebdc682fc156b4d95), [`8846867`](https://github.com/mastra-ai/mastra/commit/8846867ffa9a3746767618e314bebac08eb77d87), [`42a42cf`](https://github.com/mastra-ai/mastra/commit/42a42cf3132b9786feecbb8c13c583dce5b0e198), [`ae08bf0`](https://github.com/mastra-ai/mastra/commit/ae08bf0ebc6a4e4da992b711c4a389c32ba84cf4), [`21735a7`](https://github.com/mastra-ai/mastra/commit/21735a7ef306963554a69a89b44f06c3bcd85141), [`1d877b8`](https://github.com/mastra-ai/mastra/commit/1d877b8d7b536a251c1a7a18db7ddcf4f68d6f8b)]:
48
+ - @mastra/core@1.0.0-beta.7
49
+
3
50
  ## 1.0.0-beta.3
4
51
 
5
52
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -181,7 +181,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
181
181
  } catch (error$1) {
182
182
  throw new error.MastraError(
183
183
  {
184
- id: "MASTRA_STORAGE_MSSQL_STORE_GET_THREAD_BY_ID_FAILED",
184
+ id: storage.createStorageErrorId("MSSQL", "GET_THREAD_BY_ID", "FAILED"),
185
185
  domain: error.ErrorDomain.STORAGE,
186
186
  category: error.ErrorCategory.THIRD_PARTY,
187
187
  details: {
@@ -196,7 +196,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
196
196
  const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
197
197
  if (page < 0) {
198
198
  throw new error.MastraError({
199
- id: "MASTRA_STORAGE_MSSQL_STORE_INVALID_PAGE",
199
+ id: storage.createStorageErrorId("MSSQL", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
200
200
  domain: error.ErrorDomain.STORAGE,
201
201
  category: error.ErrorCategory.USER,
202
202
  text: "Page number must be non-negative",
@@ -255,7 +255,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
255
255
  } catch (error$1) {
256
256
  const mastraError = new error.MastraError(
257
257
  {
258
- id: "MASTRA_STORAGE_MSSQL_STORE_LIST_THREADS_BY_RESOURCE_ID_FAILED",
258
+ id: storage.createStorageErrorId("MSSQL", "LIST_THREADS_BY_RESOURCE_ID", "FAILED"),
259
259
  domain: error.ErrorDomain.STORAGE,
260
260
  category: error.ErrorCategory.THIRD_PARTY,
261
261
  details: {
@@ -308,7 +308,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
308
308
  } catch (error$1) {
309
309
  throw new error.MastraError(
310
310
  {
311
- id: "MASTRA_STORAGE_MSSQL_STORE_SAVE_THREAD_FAILED",
311
+ id: storage.createStorageErrorId("MSSQL", "SAVE_THREAD", "FAILED"),
312
312
  domain: error.ErrorDomain.STORAGE,
313
313
  category: error.ErrorCategory.THIRD_PARTY,
314
314
  details: {
@@ -330,7 +330,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
330
330
  const existingThread = await this.getThreadById({ threadId: id });
331
331
  if (!existingThread) {
332
332
  throw new error.MastraError({
333
- id: "MASTRA_STORAGE_MSSQL_STORE_UPDATE_THREAD_FAILED",
333
+ id: storage.createStorageErrorId("MSSQL", "UPDATE_THREAD", "NOT_FOUND"),
334
334
  domain: error.ErrorDomain.STORAGE,
335
335
  category: error.ErrorCategory.USER,
336
336
  text: `Thread ${id} not found`,
@@ -365,7 +365,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
365
365
  }
366
366
  if (!thread) {
367
367
  throw new error.MastraError({
368
- id: "MASTRA_STORAGE_MSSQL_STORE_UPDATE_THREAD_FAILED",
368
+ id: storage.createStorageErrorId("MSSQL", "UPDATE_THREAD", "NOT_FOUND"),
369
369
  domain: error.ErrorDomain.STORAGE,
370
370
  category: error.ErrorCategory.USER,
371
371
  text: `Thread ${id} not found after update`,
@@ -384,7 +384,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
384
384
  } catch (error$1) {
385
385
  throw new error.MastraError(
386
386
  {
387
- id: "MASTRA_STORAGE_MSSQL_STORE_UPDATE_THREAD_FAILED",
387
+ id: storage.createStorageErrorId("MSSQL", "UPDATE_THREAD", "FAILED"),
388
388
  domain: error.ErrorDomain.STORAGE,
389
389
  category: error.ErrorCategory.THIRD_PARTY,
390
390
  details: {
@@ -414,7 +414,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
414
414
  });
415
415
  throw new error.MastraError(
416
416
  {
417
- id: "MASTRA_STORAGE_MSSQL_STORE_DELETE_THREAD_FAILED",
417
+ id: storage.createStorageErrorId("MSSQL", "DELETE_THREAD", "FAILED"),
418
418
  domain: error.ErrorDomain.STORAGE,
419
419
  category: error.ErrorCategory.THIRD_PARTY,
420
420
  details: {
@@ -529,7 +529,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
529
529
  } catch (error$1) {
530
530
  const mastraError = new error.MastraError(
531
531
  {
532
- id: "MASTRA_STORAGE_MSSQL_STORE_LIST_MESSAGES_BY_ID_FAILED",
532
+ id: storage.createStorageErrorId("MSSQL", "LIST_MESSAGES_BY_ID", "FAILED"),
533
533
  domain: error.ErrorDomain.STORAGE,
534
534
  category: error.ErrorCategory.THIRD_PARTY,
535
535
  details: {
@@ -549,7 +549,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
549
549
  if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
550
550
  throw new error.MastraError(
551
551
  {
552
- id: "STORAGE_MSSQL_LIST_MESSAGES_INVALID_THREAD_ID",
552
+ id: storage.createStorageErrorId("MSSQL", "LIST_MESSAGES", "INVALID_THREAD_ID"),
553
553
  domain: error.ErrorDomain.STORAGE,
554
554
  category: error.ErrorCategory.THIRD_PARTY,
555
555
  details: { threadId: Array.isArray(threadId) ? threadId.join(",") : threadId }
@@ -559,7 +559,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
559
559
  }
560
560
  if (page < 0) {
561
561
  throw new error.MastraError({
562
- id: "MASTRA_STORAGE_MSSQL_STORE_INVALID_PAGE",
562
+ id: storage.createStorageErrorId("MSSQL", "LIST_MESSAGES", "INVALID_PAGE"),
563
563
  domain: error.ErrorDomain.STORAGE,
564
564
  category: error.ErrorCategory.USER,
565
565
  text: "Page number must be non-negative",
@@ -657,7 +657,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
657
657
  } catch (error$1) {
658
658
  const mastraError = new error.MastraError(
659
659
  {
660
- id: "MASTRA_STORAGE_MSSQL_STORE_LIST_MESSAGES_FAILED",
660
+ id: storage.createStorageErrorId("MSSQL", "LIST_MESSAGES", "FAILED"),
661
661
  domain: error.ErrorDomain.STORAGE,
662
662
  category: error.ErrorCategory.THIRD_PARTY,
663
663
  details: {
@@ -683,7 +683,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
683
683
  const threadId = messages[0]?.threadId;
684
684
  if (!threadId) {
685
685
  throw new error.MastraError({
686
- id: "MASTRA_STORAGE_MSSQL_STORE_SAVE_MESSAGES_FAILED",
686
+ id: storage.createStorageErrorId("MSSQL", "SAVE_MESSAGES", "INVALID_THREAD_ID"),
687
687
  domain: error.ErrorDomain.STORAGE,
688
688
  category: error.ErrorCategory.THIRD_PARTY,
689
689
  text: `Thread ID is required`
@@ -692,7 +692,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
692
692
  const thread = await this.getThreadById({ threadId });
693
693
  if (!thread) {
694
694
  throw new error.MastraError({
695
- id: "MASTRA_STORAGE_MSSQL_STORE_SAVE_MESSAGES_FAILED",
695
+ id: storage.createStorageErrorId("MSSQL", "SAVE_MESSAGES", "THREAD_NOT_FOUND"),
696
696
  domain: error.ErrorDomain.STORAGE,
697
697
  category: error.ErrorCategory.THIRD_PARTY,
698
698
  text: `Thread ${threadId} not found`,
@@ -765,7 +765,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
765
765
  } catch (error$1) {
766
766
  throw new error.MastraError(
767
767
  {
768
- id: "MASTRA_STORAGE_MSSQL_STORE_SAVE_MESSAGES_FAILED",
768
+ id: storage.createStorageErrorId("MSSQL", "SAVE_MESSAGES", "FAILED"),
769
769
  domain: error.ErrorDomain.STORAGE,
770
770
  category: error.ErrorCategory.THIRD_PARTY,
771
771
  details: { threadId }
@@ -856,7 +856,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
856
856
  await transaction.rollback();
857
857
  throw new error.MastraError(
858
858
  {
859
- id: "MASTRA_STORAGE_MSSQL_UPDATE_MESSAGES_FAILED",
859
+ id: storage.createStorageErrorId("MSSQL", "UPDATE_MESSAGES", "FAILED"),
860
860
  domain: error.ErrorDomain.STORAGE,
861
861
  category: error.ErrorCategory.THIRD_PARTY
862
862
  },
@@ -918,7 +918,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
918
918
  } catch (error$1) {
919
919
  throw new error.MastraError(
920
920
  {
921
- id: "MASTRA_STORAGE_MSSQL_STORE_DELETE_MESSAGES_FAILED",
921
+ id: storage.createStorageErrorId("MSSQL", "DELETE_MESSAGES", "FAILED"),
922
922
  domain: error.ErrorDomain.STORAGE,
923
923
  category: error.ErrorCategory.THIRD_PARTY,
924
924
  details: { messageIds: messageIds.join(", ") }
@@ -946,7 +946,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
946
946
  } catch (error$1) {
947
947
  const mastraError = new error.MastraError(
948
948
  {
949
- id: "MASTRA_STORAGE_MSSQL_GET_RESOURCE_BY_ID_FAILED",
949
+ id: storage.createStorageErrorId("MSSQL", "GET_RESOURCE_BY_ID", "FAILED"),
950
950
  domain: error.ErrorDomain.STORAGE,
951
951
  category: error.ErrorCategory.THIRD_PARTY,
952
952
  details: { resourceId }
@@ -1013,7 +1013,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
1013
1013
  } catch (error$1) {
1014
1014
  const mastraError = new error.MastraError(
1015
1015
  {
1016
- id: "MASTRA_STORAGE_MSSQL_UPDATE_RESOURCE_FAILED",
1016
+ id: storage.createStorageErrorId("MSSQL", "UPDATE_RESOURCE", "FAILED"),
1017
1017
  domain: error.ErrorDomain.STORAGE,
1018
1018
  category: error.ErrorCategory.THIRD_PARTY,
1019
1019
  details: { resourceId }
@@ -1060,7 +1060,7 @@ var ObservabilityMSSQL = class extends storage.ObservabilityStorage {
1060
1060
  } catch (error$1) {
1061
1061
  throw new error.MastraError(
1062
1062
  {
1063
- id: "MSSQL_STORE_CREATE_SPAN_FAILED",
1063
+ id: storage.createStorageErrorId("MSSQL", "CREATE_SPAN", "FAILED"),
1064
1064
  domain: error.ErrorDomain.STORAGE,
1065
1065
  category: error.ErrorCategory.USER,
1066
1066
  details: {
@@ -1106,7 +1106,7 @@ var ObservabilityMSSQL = class extends storage.ObservabilityStorage {
1106
1106
  } catch (error$1) {
1107
1107
  throw new error.MastraError(
1108
1108
  {
1109
- id: "MSSQL_STORE_GET_TRACE_FAILED",
1109
+ id: storage.createStorageErrorId("MSSQL", "GET_TRACE", "FAILED"),
1110
1110
  domain: error.ErrorDomain.STORAGE,
1111
1111
  category: error.ErrorCategory.USER,
1112
1112
  details: {
@@ -1138,7 +1138,7 @@ var ObservabilityMSSQL = class extends storage.ObservabilityStorage {
1138
1138
  } catch (error$1) {
1139
1139
  throw new error.MastraError(
1140
1140
  {
1141
- id: "MSSQL_STORE_UPDATE_SPAN_FAILED",
1141
+ id: storage.createStorageErrorId("MSSQL", "UPDATE_SPAN", "FAILED"),
1142
1142
  domain: error.ErrorDomain.STORAGE,
1143
1143
  category: error.ErrorCategory.USER,
1144
1144
  details: {
@@ -1175,7 +1175,7 @@ var ObservabilityMSSQL = class extends storage.ObservabilityStorage {
1175
1175
  name = `agent run: '${entityId}'`;
1176
1176
  } else {
1177
1177
  const error$1 = new error.MastraError({
1178
- id: "MSSQL_STORE_GET_TRACES_PAGINATED_FAILED",
1178
+ id: storage.createStorageErrorId("MSSQL", "GET_TRACES_PAGINATED", "INVALID_ENTITY_TYPE"),
1179
1179
  domain: error.ErrorDomain.STORAGE,
1180
1180
  category: error.ErrorCategory.USER,
1181
1181
  details: {
@@ -1244,7 +1244,7 @@ var ObservabilityMSSQL = class extends storage.ObservabilityStorage {
1244
1244
  } catch (error$1) {
1245
1245
  throw new error.MastraError(
1246
1246
  {
1247
- id: "MSSQL_STORE_GET_TRACES_PAGINATED_FAILED",
1247
+ id: storage.createStorageErrorId("MSSQL", "GET_TRACES_PAGINATED", "FAILED"),
1248
1248
  domain: error.ErrorDomain.STORAGE,
1249
1249
  category: error.ErrorCategory.USER
1250
1250
  },
@@ -1268,7 +1268,7 @@ var ObservabilityMSSQL = class extends storage.ObservabilityStorage {
1268
1268
  } catch (error$1) {
1269
1269
  throw new error.MastraError(
1270
1270
  {
1271
- id: "MSSQL_STORE_BATCH_CREATE_SPANS_FAILED",
1271
+ id: storage.createStorageErrorId("MSSQL", "BATCH_CREATE_SPANS", "FAILED"),
1272
1272
  domain: error.ErrorDomain.STORAGE,
1273
1273
  category: error.ErrorCategory.USER,
1274
1274
  details: {
@@ -1304,7 +1304,7 @@ var ObservabilityMSSQL = class extends storage.ObservabilityStorage {
1304
1304
  } catch (error$1) {
1305
1305
  throw new error.MastraError(
1306
1306
  {
1307
- id: "MSSQL_STORE_BATCH_UPDATE_SPANS_FAILED",
1307
+ id: storage.createStorageErrorId("MSSQL", "BATCH_UPDATE_SPANS", "FAILED"),
1308
1308
  domain: error.ErrorDomain.STORAGE,
1309
1309
  category: error.ErrorCategory.USER,
1310
1310
  details: {
@@ -1328,7 +1328,7 @@ var ObservabilityMSSQL = class extends storage.ObservabilityStorage {
1328
1328
  } catch (error$1) {
1329
1329
  throw new error.MastraError(
1330
1330
  {
1331
- id: "MSSQL_STORE_BATCH_DELETE_TRACES_FAILED",
1331
+ id: storage.createStorageErrorId("MSSQL", "BATCH_DELETE_TRACES", "FAILED"),
1332
1332
  domain: error.ErrorDomain.STORAGE,
1333
1333
  category: error.ErrorCategory.USER,
1334
1334
  details: {
@@ -1368,7 +1368,7 @@ var StoreOperationsMSSQL = class extends storage.StoreOperations {
1368
1368
  return "BIT";
1369
1369
  default:
1370
1370
  throw new error.MastraError({
1371
- id: "MASTRA_STORAGE_MSSQL_STORE_TYPE_NOT_SUPPORTED",
1371
+ id: storage.createStorageErrorId("MSSQL", "TYPE", "NOT_SUPPORTED"),
1372
1372
  domain: error.ErrorDomain.STORAGE,
1373
1373
  category: error.ErrorCategory.THIRD_PARTY
1374
1374
  });
@@ -1454,7 +1454,7 @@ var StoreOperationsMSSQL = class extends storage.StoreOperations {
1454
1454
  } catch (error$1) {
1455
1455
  throw new error.MastraError(
1456
1456
  {
1457
- id: "MASTRA_STORAGE_MSSQL_STORE_INSERT_FAILED",
1457
+ id: storage.createStorageErrorId("MSSQL", "INSERT", "FAILED"),
1458
1458
  domain: error.ErrorDomain.STORAGE,
1459
1459
  category: error.ErrorCategory.THIRD_PARTY,
1460
1460
  details: {
@@ -1480,7 +1480,7 @@ var StoreOperationsMSSQL = class extends storage.StoreOperations {
1480
1480
  } catch (error$1) {
1481
1481
  throw new error.MastraError(
1482
1482
  {
1483
- id: "MASTRA_STORAGE_MSSQL_STORE_CLEAR_TABLE_FAILED",
1483
+ id: storage.createStorageErrorId("MSSQL", "CLEAR_TABLE", "FAILED"),
1484
1484
  domain: error.ErrorDomain.STORAGE,
1485
1485
  category: error.ErrorCategory.THIRD_PARTY,
1486
1486
  details: {
@@ -1583,7 +1583,7 @@ ${columns}
1583
1583
  } catch (error$1) {
1584
1584
  throw new error.MastraError(
1585
1585
  {
1586
- id: "MASTRA_STORAGE_MSSQL_STORE_CREATE_TABLE_FAILED",
1586
+ id: storage.createStorageErrorId("MSSQL", "CREATE_TABLE", "FAILED"),
1587
1587
  domain: error.ErrorDomain.STORAGE,
1588
1588
  category: error.ErrorCategory.THIRD_PARTY,
1589
1589
  details: {
@@ -1643,7 +1643,7 @@ ${columns}
1643
1643
  } catch (error$1) {
1644
1644
  throw new error.MastraError(
1645
1645
  {
1646
- id: "MASTRA_STORAGE_MSSQL_STORE_ALTER_TABLE_FAILED",
1646
+ id: storage.createStorageErrorId("MSSQL", "ALTER_TABLE", "FAILED"),
1647
1647
  domain: error.ErrorDomain.STORAGE,
1648
1648
  category: error.ErrorCategory.THIRD_PARTY,
1649
1649
  details: {
@@ -1684,7 +1684,7 @@ ${columns}
1684
1684
  } catch (error$1) {
1685
1685
  throw new error.MastraError(
1686
1686
  {
1687
- id: "MASTRA_STORAGE_MSSQL_STORE_LOAD_FAILED",
1687
+ id: storage.createStorageErrorId("MSSQL", "LOAD", "FAILED"),
1688
1688
  domain: error.ErrorDomain.STORAGE,
1689
1689
  category: error.ErrorCategory.THIRD_PARTY,
1690
1690
  details: {
@@ -1707,7 +1707,7 @@ ${columns}
1707
1707
  await transaction.rollback();
1708
1708
  throw new error.MastraError(
1709
1709
  {
1710
- id: "MASTRA_STORAGE_MSSQL_STORE_BATCH_INSERT_FAILED",
1710
+ id: storage.createStorageErrorId("MSSQL", "BATCH_INSERT", "FAILED"),
1711
1711
  domain: error.ErrorDomain.STORAGE,
1712
1712
  category: error.ErrorCategory.THIRD_PARTY,
1713
1713
  details: {
@@ -1726,7 +1726,7 @@ ${columns}
1726
1726
  } catch (error$1) {
1727
1727
  throw new error.MastraError(
1728
1728
  {
1729
- id: "MASTRA_STORAGE_MSSQL_STORE_DROP_TABLE_FAILED",
1729
+ id: storage.createStorageErrorId("MSSQL", "DROP_TABLE", "FAILED"),
1730
1730
  domain: error.ErrorDomain.STORAGE,
1731
1731
  category: error.ErrorCategory.THIRD_PARTY,
1732
1732
  details: {
@@ -1812,7 +1812,7 @@ ${columns}
1812
1812
  try {
1813
1813
  if (!data || Object.keys(data).length === 0) {
1814
1814
  throw new error.MastraError({
1815
- id: "MASTRA_STORAGE_MSSQL_UPDATE_EMPTY_DATA",
1815
+ id: storage.createStorageErrorId("MSSQL", "UPDATE", "EMPTY_DATA"),
1816
1816
  domain: error.ErrorDomain.STORAGE,
1817
1817
  category: error.ErrorCategory.USER,
1818
1818
  text: "Cannot update with empty data payload"
@@ -1820,7 +1820,7 @@ ${columns}
1820
1820
  }
1821
1821
  if (!keys || Object.keys(keys).length === 0) {
1822
1822
  throw new error.MastraError({
1823
- id: "MASTRA_STORAGE_MSSQL_UPDATE_EMPTY_KEYS",
1823
+ id: storage.createStorageErrorId("MSSQL", "UPDATE", "EMPTY_KEYS"),
1824
1824
  domain: error.ErrorDomain.STORAGE,
1825
1825
  category: error.ErrorCategory.USER,
1826
1826
  text: "Cannot update without keys to identify records"
@@ -1861,7 +1861,7 @@ ${columns}
1861
1861
  } catch (error$1) {
1862
1862
  throw new error.MastraError(
1863
1863
  {
1864
- id: "MASTRA_STORAGE_MSSQL_STORE_UPDATE_FAILED",
1864
+ id: storage.createStorageErrorId("MSSQL", "UPDATE", "FAILED"),
1865
1865
  domain: error.ErrorDomain.STORAGE,
1866
1866
  category: error.ErrorCategory.THIRD_PARTY,
1867
1867
  details: {
@@ -1890,7 +1890,7 @@ ${columns}
1890
1890
  await transaction.rollback();
1891
1891
  throw new error.MastraError(
1892
1892
  {
1893
- id: "MASTRA_STORAGE_MSSQL_STORE_BATCH_UPDATE_FAILED",
1893
+ id: storage.createStorageErrorId("MSSQL", "BATCH_UPDATE", "FAILED"),
1894
1894
  domain: error.ErrorDomain.STORAGE,
1895
1895
  category: error.ErrorCategory.THIRD_PARTY,
1896
1896
  details: {
@@ -1939,7 +1939,7 @@ ${columns}
1939
1939
  await transaction.rollback();
1940
1940
  throw new error.MastraError(
1941
1941
  {
1942
- id: "MASTRA_STORAGE_MSSQL_STORE_BATCH_DELETE_FAILED",
1942
+ id: storage.createStorageErrorId("MSSQL", "BATCH_DELETE", "FAILED"),
1943
1943
  domain: error.ErrorDomain.STORAGE,
1944
1944
  category: error.ErrorCategory.THIRD_PARTY,
1945
1945
  details: {
@@ -1996,7 +1996,7 @@ ${columns}
1996
1996
  } catch (error$1) {
1997
1997
  throw new error.MastraError(
1998
1998
  {
1999
- id: "MASTRA_STORAGE_MSSQL_INDEX_CREATE_FAILED",
1999
+ id: storage.createStorageErrorId("MSSQL", "INDEX_CREATE", "FAILED"),
2000
2000
  domain: error.ErrorDomain.STORAGE,
2001
2001
  category: error.ErrorCategory.THIRD_PARTY,
2002
2002
  details: {
@@ -2032,7 +2032,7 @@ ${columns}
2032
2032
  if (result.recordset.length > 1) {
2033
2033
  const tables = result.recordset.map((r) => r.table_name).join(", ");
2034
2034
  throw new error.MastraError({
2035
- id: "MASTRA_STORAGE_MSSQL_INDEX_AMBIGUOUS",
2035
+ id: storage.createStorageErrorId("MSSQL", "INDEX", "AMBIGUOUS"),
2036
2036
  domain: error.ErrorDomain.STORAGE,
2037
2037
  category: error.ErrorCategory.USER,
2038
2038
  text: `Index "${indexNameSafe}" exists on multiple tables (${tables}) in schema "${schemaName}". Please drop indexes manually or ensure unique index names.`
@@ -2048,7 +2048,7 @@ ${columns}
2048
2048
  } catch (error$1) {
2049
2049
  throw new error.MastraError(
2050
2050
  {
2051
- id: "MASTRA_STORAGE_MSSQL_INDEX_DROP_FAILED",
2051
+ id: storage.createStorageErrorId("MSSQL", "INDEX_DROP", "FAILED"),
2052
2052
  domain: error.ErrorDomain.STORAGE,
2053
2053
  category: error.ErrorCategory.THIRD_PARTY,
2054
2054
  details: {
@@ -2132,7 +2132,7 @@ ${columns}
2132
2132
  } catch (error$1) {
2133
2133
  throw new error.MastraError(
2134
2134
  {
2135
- id: "MASTRA_STORAGE_MSSQL_INDEX_LIST_FAILED",
2135
+ id: storage.createStorageErrorId("MSSQL", "INDEX_LIST", "FAILED"),
2136
2136
  domain: error.ErrorDomain.STORAGE,
2137
2137
  category: error.ErrorCategory.THIRD_PARTY,
2138
2138
  details: tableName ? {
@@ -2205,7 +2205,7 @@ ${columns}
2205
2205
  } catch (error$1) {
2206
2206
  throw new error.MastraError(
2207
2207
  {
2208
- id: "MASTRA_STORAGE_MSSQL_INDEX_DESCRIBE_FAILED",
2208
+ id: storage.createStorageErrorId("MSSQL", "INDEX_DESCRIBE", "FAILED"),
2209
2209
  domain: error.ErrorDomain.STORAGE,
2210
2210
  category: error.ErrorCategory.THIRD_PARTY,
2211
2211
  details: {
@@ -2286,7 +2286,7 @@ ${columns}
2286
2286
  } catch (error$1) {
2287
2287
  throw new error.MastraError(
2288
2288
  {
2289
- id: "MASTRA_STORAGE_MSSQL_STORE_CREATE_PERFORMANCE_INDEXES_FAILED",
2289
+ id: storage.createStorageErrorId("MSSQL", "CREATE_PERFORMANCE_INDEXES", "FAILED"),
2290
2290
  domain: error.ErrorDomain.STORAGE,
2291
2291
  category: error.ErrorCategory.THIRD_PARTY
2292
2292
  },
@@ -2328,7 +2328,7 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
2328
2328
  } catch (error$1) {
2329
2329
  throw new error.MastraError(
2330
2330
  {
2331
- id: "MASTRA_STORAGE_MSSQL_STORE_GET_SCORE_BY_ID_FAILED",
2331
+ id: storage.createStorageErrorId("MSSQL", "GET_SCORE_BY_ID", "FAILED"),
2332
2332
  domain: error.ErrorDomain.STORAGE,
2333
2333
  category: error.ErrorCategory.THIRD_PARTY,
2334
2334
  details: { id }
@@ -2344,15 +2344,23 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
2344
2344
  } catch (error$1) {
2345
2345
  throw new error.MastraError(
2346
2346
  {
2347
- id: "MASTRA_STORAGE_MSSQL_STORE_SAVE_SCORE_VALIDATION_FAILED",
2347
+ id: storage.createStorageErrorId("MSSQL", "SAVE_SCORE", "VALIDATION_FAILED"),
2348
2348
  domain: error.ErrorDomain.STORAGE,
2349
- category: error.ErrorCategory.THIRD_PARTY
2349
+ category: error.ErrorCategory.USER,
2350
+ details: {
2351
+ scorer: score.scorer?.id ?? "unknown",
2352
+ entityId: score.entityId ?? "unknown",
2353
+ entityType: score.entityType ?? "unknown",
2354
+ traceId: score.traceId ?? "",
2355
+ spanId: score.spanId ?? ""
2356
+ }
2350
2357
  },
2351
2358
  error$1
2352
2359
  );
2353
2360
  }
2354
2361
  try {
2355
2362
  const scoreId = crypto.randomUUID();
2363
+ const now = /* @__PURE__ */ new Date();
2356
2364
  const {
2357
2365
  scorer,
2358
2366
  preprocessStepResult,
@@ -2379,16 +2387,15 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
2379
2387
  requestContext: requestContext || null,
2380
2388
  entity: entity || null,
2381
2389
  scorer: scorer || null,
2382
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2383
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2390
+ createdAt: now.toISOString(),
2391
+ updatedAt: now.toISOString()
2384
2392
  }
2385
2393
  });
2386
- const scoreFromDb = await this.getScoreById({ id: scoreId });
2387
- return { score: scoreFromDb };
2394
+ return { score: { ...validatedScore, id: scoreId, createdAt: now, updatedAt: now } };
2388
2395
  } catch (error$1) {
2389
2396
  throw new error.MastraError(
2390
2397
  {
2391
- id: "MASTRA_STORAGE_MSSQL_STORE_SAVE_SCORE_FAILED",
2398
+ id: storage.createStorageErrorId("MSSQL", "SAVE_SCORE", "FAILED"),
2392
2399
  domain: error.ErrorDomain.STORAGE,
2393
2400
  category: error.ErrorCategory.THIRD_PARTY
2394
2401
  },
@@ -2466,7 +2473,7 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
2466
2473
  } catch (error$1) {
2467
2474
  throw new error.MastraError(
2468
2475
  {
2469
- id: "MASTRA_STORAGE_MSSQL_STORE_GET_SCORES_BY_SCORER_ID_FAILED",
2476
+ id: storage.createStorageErrorId("MSSQL", "LIST_SCORES_BY_SCORER_ID", "FAILED"),
2470
2477
  domain: error.ErrorDomain.STORAGE,
2471
2478
  category: error.ErrorCategory.THIRD_PARTY,
2472
2479
  details: { scorerId }
@@ -2521,7 +2528,7 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
2521
2528
  } catch (error$1) {
2522
2529
  throw new error.MastraError(
2523
2530
  {
2524
- id: "MASTRA_STORAGE_MSSQL_STORE_GET_SCORES_BY_RUN_ID_FAILED",
2531
+ id: storage.createStorageErrorId("MSSQL", "LIST_SCORES_BY_RUN_ID", "FAILED"),
2525
2532
  domain: error.ErrorDomain.STORAGE,
2526
2533
  category: error.ErrorCategory.THIRD_PARTY,
2527
2534
  details: { runId }
@@ -2579,7 +2586,7 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
2579
2586
  } catch (error$1) {
2580
2587
  throw new error.MastraError(
2581
2588
  {
2582
- id: "MASTRA_STORAGE_MSSQL_STORE_GET_SCORES_BY_ENTITY_ID_FAILED",
2589
+ id: storage.createStorageErrorId("MSSQL", "LIST_SCORES_BY_ENTITY_ID", "FAILED"),
2583
2590
  domain: error.ErrorDomain.STORAGE,
2584
2591
  category: error.ErrorCategory.THIRD_PARTY,
2585
2592
  details: { entityId, entityType }
@@ -2637,7 +2644,7 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
2637
2644
  } catch (error$1) {
2638
2645
  throw new error.MastraError(
2639
2646
  {
2640
- id: "MASTRA_STORAGE_MSSQL_STORE_GET_SCORES_BY_SPAN_FAILED",
2647
+ id: storage.createStorageErrorId("MSSQL", "LIST_SCORES_BY_SPAN", "FAILED"),
2641
2648
  domain: error.ErrorDomain.STORAGE,
2642
2649
  category: error.ErrorCategory.THIRD_PARTY,
2643
2650
  details: { traceId, spanId }
@@ -2741,7 +2748,7 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2741
2748
  }
2742
2749
  throw new error.MastraError(
2743
2750
  {
2744
- id: "MASTRA_STORAGE_MSSQL_STORE_UPDATE_WORKFLOW_RESULTS_FAILED",
2751
+ id: storage.createStorageErrorId("MSSQL", "UPDATE_WORKFLOW_RESULTS", "FAILED"),
2745
2752
  domain: error.ErrorDomain.STORAGE,
2746
2753
  category: error.ErrorCategory.THIRD_PARTY,
2747
2754
  details: {
@@ -2779,7 +2786,7 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2779
2786
  await transaction.rollback();
2780
2787
  throw new error.MastraError(
2781
2788
  {
2782
- id: "MASTRA_STORAGE_MSSQL_STORE_UPDATE_WORKFLOW_STATE_SNAPSHOT_NOT_FOUND",
2789
+ id: storage.createStorageErrorId("MSSQL", "UPDATE_WORKFLOW_STATE", "SNAPSHOT_NOT_FOUND"),
2783
2790
  domain: error.ErrorDomain.STORAGE,
2784
2791
  category: error.ErrorCategory.SYSTEM,
2785
2792
  details: {
@@ -2806,9 +2813,10 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2806
2813
  await transaction.rollback();
2807
2814
  } catch {
2808
2815
  }
2816
+ if (error$1 instanceof error.MastraError) throw error$1;
2809
2817
  throw new error.MastraError(
2810
2818
  {
2811
- id: "MASTRA_STORAGE_MSSQL_STORE_UPDATE_WORKFLOW_STATE_FAILED",
2819
+ id: storage.createStorageErrorId("MSSQL", "UPDATE_WORKFLOW_STATE", "FAILED"),
2812
2820
  domain: error.ErrorDomain.STORAGE,
2813
2821
  category: error.ErrorCategory.THIRD_PARTY,
2814
2822
  details: {
@@ -2849,7 +2857,7 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2849
2857
  } catch (error$1) {
2850
2858
  throw new error.MastraError(
2851
2859
  {
2852
- id: "MASTRA_STORAGE_MSSQL_STORE_PERSIST_WORKFLOW_SNAPSHOT_FAILED",
2860
+ id: storage.createStorageErrorId("MSSQL", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
2853
2861
  domain: error.ErrorDomain.STORAGE,
2854
2862
  category: error.ErrorCategory.THIRD_PARTY,
2855
2863
  details: {
@@ -2880,7 +2888,7 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2880
2888
  } catch (error$1) {
2881
2889
  throw new error.MastraError(
2882
2890
  {
2883
- id: "MASTRA_STORAGE_MSSQL_STORE_LOAD_WORKFLOW_SNAPSHOT_FAILED",
2891
+ id: storage.createStorageErrorId("MSSQL", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
2884
2892
  domain: error.ErrorDomain.STORAGE,
2885
2893
  category: error.ErrorCategory.THIRD_PARTY,
2886
2894
  details: {
@@ -2920,7 +2928,7 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2920
2928
  } catch (error$1) {
2921
2929
  throw new error.MastraError(
2922
2930
  {
2923
- id: "MASTRA_STORAGE_MSSQL_STORE_GET_WORKFLOW_RUN_BY_ID_FAILED",
2931
+ id: storage.createStorageErrorId("MSSQL", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
2924
2932
  domain: error.ErrorDomain.STORAGE,
2925
2933
  category: error.ErrorCategory.THIRD_PARTY,
2926
2934
  details: {
@@ -3000,7 +3008,7 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
3000
3008
  } catch (error$1) {
3001
3009
  throw new error.MastraError(
3002
3010
  {
3003
- id: "MASTRA_STORAGE_MSSQL_STORE_LIST_WORKFLOW_RUNS_FAILED",
3011
+ id: storage.createStorageErrorId("MSSQL", "LIST_WORKFLOW_RUNS", "FAILED"),
3004
3012
  domain: error.ErrorDomain.STORAGE,
3005
3013
  category: error.ErrorCategory.THIRD_PARTY,
3006
3014
  details: {
@@ -3023,7 +3031,7 @@ var MSSQLStore = class extends storage.MastraStorage {
3023
3031
  if (!config.id || typeof config.id !== "string" || config.id.trim() === "") {
3024
3032
  throw new Error("MSSQLStore: id must be provided and cannot be empty.");
3025
3033
  }
3026
- super({ id: config.id, name: "MSSQLStore" });
3034
+ super({ id: config.id, name: "MSSQLStore", disableInit: config.disableInit });
3027
3035
  try {
3028
3036
  if ("connectionString" in config) {
3029
3037
  if (!config.connectionString || typeof config.connectionString !== "string" || config.connectionString.trim() === "") {
@@ -3061,7 +3069,7 @@ var MSSQLStore = class extends storage.MastraStorage {
3061
3069
  } catch (e) {
3062
3070
  throw new error.MastraError(
3063
3071
  {
3064
- id: "MASTRA_STORAGE_MSSQL_STORE_INITIALIZATION_FAILED",
3072
+ id: storage.createStorageErrorId("MSSQL", "INITIALIZATION", "FAILED"),
3065
3073
  domain: error.ErrorDomain.STORAGE,
3066
3074
  category: error.ErrorCategory.USER
3067
3075
  },
@@ -3085,7 +3093,7 @@ var MSSQLStore = class extends storage.MastraStorage {
3085
3093
  this.isConnected = null;
3086
3094
  throw new error.MastraError(
3087
3095
  {
3088
- id: "MASTRA_STORAGE_MSSQL_STORE_INIT_FAILED",
3096
+ id: storage.createStorageErrorId("MSSQL", "INIT", "FAILED"),
3089
3097
  domain: error.ErrorDomain.STORAGE,
3090
3098
  category: error.ErrorCategory.THIRD_PARTY
3091
3099
  },
@@ -3253,7 +3261,7 @@ var MSSQLStore = class extends storage.MastraStorage {
3253
3261
  getObservabilityStore() {
3254
3262
  if (!this.stores.observability) {
3255
3263
  throw new error.MastraError({
3256
- id: "MSSQL_STORE_OBSERVABILITY_NOT_INITIALIZED",
3264
+ id: storage.createStorageErrorId("MSSQL", "OBSERVABILITY", "NOT_INITIALIZED"),
3257
3265
  domain: error.ErrorDomain.STORAGE,
3258
3266
  category: error.ErrorCategory.SYSTEM,
3259
3267
  text: "Observability storage is not initialized"
@@ -3307,8 +3315,8 @@ var MSSQLStore = class extends storage.MastraStorage {
3307
3315
  source: _source
3308
3316
  });
3309
3317
  }
3310
- async saveScore(_score) {
3311
- return this.stores.scores.saveScore(_score);
3318
+ async saveScore(score) {
3319
+ return this.stores.scores.saveScore(score);
3312
3320
  }
3313
3321
  async listScoresByRunId({
3314
3322
  runId: _runId,