@mastra/mssql 0.0.0-feat-improve-processors-20251205191721 → 0.0.0-feat-add-query-option-to-playground-20251209160219

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  var error = require('@mastra/core/error');
4
4
  var storage = require('@mastra/core/storage');
5
- var sql2 = require('mssql');
5
+ var sql3 = require('mssql');
6
6
  var agent = require('@mastra/core/agent');
7
7
  var utils = require('@mastra/core/utils');
8
8
  var crypto = require('crypto');
@@ -10,7 +10,7 @@ var evals = require('@mastra/core/evals');
10
10
 
11
11
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
12
 
13
- var sql2__default = /*#__PURE__*/_interopDefault(sql2);
13
+ var sql3__default = /*#__PURE__*/_interopDefault(sql3);
14
14
 
15
15
  // src/storage/index.ts
16
16
  function getSchemaName(schema) {
@@ -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",
@@ -233,7 +233,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
233
233
  dataRequest.input("resourceId", resourceId);
234
234
  dataRequest.input("offset", offset);
235
235
  if (limitValue > 2147483647) {
236
- dataRequest.input("perPage", sql2__default.default.BigInt, limitValue);
236
+ dataRequest.input("perPage", sql3__default.default.BigInt, limitValue);
237
237
  } else {
238
238
  dataRequest.input("perPage", limitValue);
239
239
  }
@@ -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: {
@@ -297,18 +297,18 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
297
297
  req.input("title", thread.title);
298
298
  const metadata = thread.metadata ? JSON.stringify(thread.metadata) : null;
299
299
  if (metadata === null) {
300
- req.input("metadata", sql2__default.default.NVarChar, null);
300
+ req.input("metadata", sql3__default.default.NVarChar, null);
301
301
  } else {
302
302
  req.input("metadata", metadata);
303
303
  }
304
- req.input("createdAt", sql2__default.default.DateTime2, thread.createdAt);
305
- req.input("updatedAt", sql2__default.default.DateTime2, thread.updatedAt);
304
+ req.input("createdAt", sql3__default.default.DateTime2, thread.createdAt);
305
+ req.input("updatedAt", sql3__default.default.DateTime2, thread.updatedAt);
306
306
  await req.query(mergeSql);
307
307
  return thread;
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",
@@ -598,7 +598,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
598
598
  return result2.recordset || [];
599
599
  }
600
600
  request.input("offset", offset);
601
- request.input("limit", perPage > 2147483647 ? sql2__default.default.BigInt : sql2__default.default.Int, perPage);
601
+ request.input("limit", perPage > 2147483647 ? sql3__default.default.BigInt : sql3__default.default.Int, perPage);
602
602
  const result = await request.query(
603
603
  `${baseQuery}${actualWhereClause} ${orderByStatement} OFFSET @offset ROWS FETCH NEXT @limit ROWS ONLY`
604
604
  );
@@ -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`,
@@ -723,7 +723,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
723
723
  "content",
724
724
  typeof message.content === "string" ? message.content : JSON.stringify(message.content)
725
725
  );
726
- request.input("createdAt", sql2__default.default.DateTime2, message.createdAt);
726
+ request.input("createdAt", sql3__default.default.DateTime2, message.createdAt);
727
727
  request.input("role", message.role);
728
728
  request.input("type", message.type || "v2");
729
729
  request.input("resourceId", message.resourceId);
@@ -742,7 +742,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
742
742
  await request.query(mergeSql);
743
743
  }
744
744
  const threadReq = transaction.request();
745
- threadReq.input("updatedAt", sql2__default.default.DateTime2, /* @__PURE__ */ new Date());
745
+ threadReq.input("updatedAt", sql3__default.default.DateTime2, /* @__PURE__ */ new Date());
746
746
  threadReq.input("id", threadId);
747
747
  await threadReq.query(`UPDATE ${tableThreads} SET [updatedAt] = @updatedAt WHERE id = @id`);
748
748
  await transaction.commit();
@@ -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
  });
@@ -1443,7 +1443,7 @@ var StoreOperationsMSSQL = class extends storage.StoreOperations {
1443
1443
  const value = record[col];
1444
1444
  const preparedValue = this.prepareValue(value, col, tableName);
1445
1445
  if (preparedValue instanceof Date) {
1446
- request.input(`param${i}`, sql2__default.default.DateTime2, preparedValue);
1446
+ request.input(`param${i}`, sql3__default.default.DateTime2, preparedValue);
1447
1447
  } else if (preparedValue === null || preparedValue === void 0) {
1448
1448
  request.input(`param${i}`, this.getMssqlType(tableName, col), null);
1449
1449
  } else {
@@ -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: {
@@ -1781,23 +1781,23 @@ ${columns}
1781
1781
  const col = storage.TABLE_SCHEMAS[tableName]?.[columnName];
1782
1782
  switch (col?.type) {
1783
1783
  case "text":
1784
- return sql2__default.default.NVarChar;
1784
+ return sql3__default.default.NVarChar;
1785
1785
  case "timestamp":
1786
- return sql2__default.default.DateTime2;
1786
+ return sql3__default.default.DateTime2;
1787
1787
  case "uuid":
1788
- return sql2__default.default.UniqueIdentifier;
1788
+ return sql3__default.default.UniqueIdentifier;
1789
1789
  case "jsonb":
1790
- return sql2__default.default.NVarChar;
1790
+ return sql3__default.default.NVarChar;
1791
1791
  case "integer":
1792
- return sql2__default.default.Int;
1792
+ return sql3__default.default.Int;
1793
1793
  case "bigint":
1794
- return sql2__default.default.BigInt;
1794
+ return sql3__default.default.BigInt;
1795
1795
  case "float":
1796
- return sql2__default.default.Float;
1796
+ return sql3__default.default.Float;
1797
1797
  case "boolean":
1798
- return sql2__default.default.Bit;
1798
+ return sql3__default.default.Bit;
1799
1799
  default:
1800
- return sql2__default.default.NVarChar;
1800
+ return sql3__default.default.NVarChar;
1801
1801
  }
1802
1802
  }
1803
1803
  /**
@@ -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 }
@@ -2690,7 +2697,7 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2690
2697
  const transaction = this.pool.transaction();
2691
2698
  try {
2692
2699
  await transaction.begin();
2693
- const selectRequest = new sql2__default.default.Request(transaction);
2700
+ const selectRequest = new sql3__default.default.Request(transaction);
2694
2701
  selectRequest.input("workflow_name", workflowName);
2695
2702
  selectRequest.input("run_id", runId);
2696
2703
  const existingSnapshotResult = await selectRequest.query(
@@ -2718,12 +2725,12 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2718
2725
  }
2719
2726
  snapshot.context[stepId] = result;
2720
2727
  snapshot.requestContext = { ...snapshot.requestContext, ...requestContext };
2721
- const upsertReq = new sql2__default.default.Request(transaction);
2728
+ const upsertReq = new sql3__default.default.Request(transaction);
2722
2729
  upsertReq.input("workflow_name", workflowName);
2723
2730
  upsertReq.input("run_id", runId);
2724
2731
  upsertReq.input("snapshot", JSON.stringify(snapshot));
2725
- upsertReq.input("createdAt", sql2__default.default.DateTime2, /* @__PURE__ */ new Date());
2726
- upsertReq.input("updatedAt", sql2__default.default.DateTime2, /* @__PURE__ */ new Date());
2732
+ upsertReq.input("createdAt", sql3__default.default.DateTime2, /* @__PURE__ */ new Date());
2733
+ upsertReq.input("updatedAt", sql3__default.default.DateTime2, /* @__PURE__ */ new Date());
2727
2734
  await upsertReq.query(
2728
2735
  `MERGE ${table} AS target
2729
2736
  USING (SELECT @workflow_name AS workflow_name, @run_id AS run_id) AS src
@@ -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: {
@@ -2763,7 +2770,7 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2763
2770
  const transaction = this.pool.transaction();
2764
2771
  try {
2765
2772
  await transaction.begin();
2766
- const selectRequest = new sql2__default.default.Request(transaction);
2773
+ const selectRequest = new sql3__default.default.Request(transaction);
2767
2774
  selectRequest.input("workflow_name", workflowName);
2768
2775
  selectRequest.input("run_id", runId);
2769
2776
  const existingSnapshotResult = await selectRequest.query(
@@ -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: {
@@ -2791,11 +2798,11 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2791
2798
  );
2792
2799
  }
2793
2800
  const updatedSnapshot = { ...snapshot, ...opts };
2794
- const updateRequest = new sql2__default.default.Request(transaction);
2801
+ const updateRequest = new sql3__default.default.Request(transaction);
2795
2802
  updateRequest.input("snapshot", JSON.stringify(updatedSnapshot));
2796
2803
  updateRequest.input("workflow_name", workflowName);
2797
2804
  updateRequest.input("run_id", runId);
2798
- updateRequest.input("updatedAt", sql2__default.default.DateTime2, /* @__PURE__ */ new Date());
2805
+ updateRequest.input("updatedAt", sql3__default.default.DateTime2, /* @__PURE__ */ new Date());
2799
2806
  await updateRequest.query(
2800
2807
  `UPDATE ${table} SET snapshot = @snapshot, [updatedAt] = @updatedAt WHERE workflow_name = @workflow_name AND run_id = @run_id`
2801
2808
  );
@@ -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: {
@@ -2834,8 +2842,8 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2834
2842
  request.input("run_id", runId);
2835
2843
  request.input("resourceId", resourceId);
2836
2844
  request.input("snapshot", JSON.stringify(snapshot));
2837
- request.input("createdAt", sql2__default.default.DateTime2, new Date(now));
2838
- request.input("updatedAt", sql2__default.default.DateTime2, new Date(now));
2845
+ request.input("createdAt", sql3__default.default.DateTime2, new Date(now));
2846
+ request.input("updatedAt", sql3__default.default.DateTime2, new Date(now));
2839
2847
  const mergeSql = `MERGE INTO ${table} AS target
2840
2848
  USING (SELECT @workflow_name AS workflow_name, @run_id AS run_id) AS src
2841
2849
  ON target.workflow_name = src.workflow_name AND target.run_id = src.run_id
@@ -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: {
@@ -2932,6 +2940,35 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2932
2940
  );
2933
2941
  }
2934
2942
  }
2943
+ async deleteWorkflowRunById({ runId, workflowName }) {
2944
+ const table = getTableName({ indexName: storage.TABLE_WORKFLOW_SNAPSHOT, schemaName: getSchemaName(this.schema) });
2945
+ const transaction = this.pool.transaction();
2946
+ try {
2947
+ await transaction.begin();
2948
+ const deleteRequest = new sql3__default.default.Request(transaction);
2949
+ deleteRequest.input("workflow_name", workflowName);
2950
+ deleteRequest.input("run_id", runId);
2951
+ await deleteRequest.query(`DELETE FROM ${table} WHERE workflow_name = @workflow_name AND run_id = @run_id`);
2952
+ await transaction.commit();
2953
+ } catch (error$1) {
2954
+ try {
2955
+ await transaction.rollback();
2956
+ } catch {
2957
+ }
2958
+ throw new error.MastraError(
2959
+ {
2960
+ id: storage.createStorageErrorId("MSSQL", "DELETE_WORKFLOW_RUN_BY_ID", "FAILED"),
2961
+ domain: error.ErrorDomain.STORAGE,
2962
+ category: error.ErrorCategory.THIRD_PARTY,
2963
+ details: {
2964
+ runId,
2965
+ workflowName
2966
+ }
2967
+ },
2968
+ error$1
2969
+ );
2970
+ }
2971
+ }
2935
2972
  async listWorkflowRuns({
2936
2973
  workflowName,
2937
2974
  fromDate,
@@ -2975,7 +3012,7 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
2975
3012
  const request = this.pool.request();
2976
3013
  Object.entries(paramMap).forEach(([key, value]) => {
2977
3014
  if (value instanceof Date) {
2978
- request.input(key, sql2__default.default.DateTime, value);
3015
+ request.input(key, sql3__default.default.DateTime, value);
2979
3016
  } else {
2980
3017
  request.input(key, value);
2981
3018
  }
@@ -3000,7 +3037,7 @@ var WorkflowsMSSQL = class extends storage.WorkflowsStorage {
3000
3037
  } catch (error$1) {
3001
3038
  throw new error.MastraError(
3002
3039
  {
3003
- id: "MASTRA_STORAGE_MSSQL_STORE_LIST_WORKFLOW_RUNS_FAILED",
3040
+ id: storage.createStorageErrorId("MSSQL", "LIST_WORKFLOW_RUNS", "FAILED"),
3004
3041
  domain: error.ErrorDomain.STORAGE,
3005
3042
  category: error.ErrorCategory.THIRD_PARTY,
3006
3043
  details: {
@@ -3023,7 +3060,7 @@ var MSSQLStore = class extends storage.MastraStorage {
3023
3060
  if (!config.id || typeof config.id !== "string" || config.id.trim() === "") {
3024
3061
  throw new Error("MSSQLStore: id must be provided and cannot be empty.");
3025
3062
  }
3026
- super({ id: config.id, name: "MSSQLStore" });
3063
+ super({ id: config.id, name: "MSSQLStore", disableInit: config.disableInit });
3027
3064
  try {
3028
3065
  if ("connectionString" in config) {
3029
3066
  if (!config.connectionString || typeof config.connectionString !== "string" || config.connectionString.trim() === "") {
@@ -3038,7 +3075,7 @@ var MSSQLStore = class extends storage.MastraStorage {
3038
3075
  }
3039
3076
  }
3040
3077
  this.schema = config.schemaName || "dbo";
3041
- this.pool = "connectionString" in config ? new sql2__default.default.ConnectionPool(config.connectionString) : new sql2__default.default.ConnectionPool({
3078
+ this.pool = "connectionString" in config ? new sql3__default.default.ConnectionPool(config.connectionString) : new sql3__default.default.ConnectionPool({
3042
3079
  server: config.server,
3043
3080
  database: config.database,
3044
3081
  user: config.user,
@@ -3061,7 +3098,7 @@ var MSSQLStore = class extends storage.MastraStorage {
3061
3098
  } catch (e) {
3062
3099
  throw new error.MastraError(
3063
3100
  {
3064
- id: "MASTRA_STORAGE_MSSQL_STORE_INITIALIZATION_FAILED",
3101
+ id: storage.createStorageErrorId("MSSQL", "INITIALIZATION", "FAILED"),
3065
3102
  domain: error.ErrorDomain.STORAGE,
3066
3103
  category: error.ErrorCategory.USER
3067
3104
  },
@@ -3085,7 +3122,7 @@ var MSSQLStore = class extends storage.MastraStorage {
3085
3122
  this.isConnected = null;
3086
3123
  throw new error.MastraError(
3087
3124
  {
3088
- id: "MASTRA_STORAGE_MSSQL_STORE_INIT_FAILED",
3125
+ id: storage.createStorageErrorId("MSSQL", "INIT", "FAILED"),
3089
3126
  domain: error.ErrorDomain.STORAGE,
3090
3127
  category: error.ErrorCategory.THIRD_PARTY
3091
3128
  },
@@ -3229,6 +3266,9 @@ var MSSQLStore = class extends storage.MastraStorage {
3229
3266
  }) {
3230
3267
  return this.stores.workflows.getWorkflowRunById({ runId, workflowName });
3231
3268
  }
3269
+ async deleteWorkflowRunById({ runId, workflowName }) {
3270
+ return this.stores.workflows.deleteWorkflowRunById({ runId, workflowName });
3271
+ }
3232
3272
  async close() {
3233
3273
  await this.pool.close();
3234
3274
  }
@@ -3253,7 +3293,7 @@ var MSSQLStore = class extends storage.MastraStorage {
3253
3293
  getObservabilityStore() {
3254
3294
  if (!this.stores.observability) {
3255
3295
  throw new error.MastraError({
3256
- id: "MSSQL_STORE_OBSERVABILITY_NOT_INITIALIZED",
3296
+ id: storage.createStorageErrorId("MSSQL", "OBSERVABILITY", "NOT_INITIALIZED"),
3257
3297
  domain: error.ErrorDomain.STORAGE,
3258
3298
  category: error.ErrorCategory.SYSTEM,
3259
3299
  text: "Observability storage is not initialized"
@@ -3307,8 +3347,8 @@ var MSSQLStore = class extends storage.MastraStorage {
3307
3347
  source: _source
3308
3348
  });
3309
3349
  }
3310
- async saveScore(_score) {
3311
- return this.stores.scores.saveScore(_score);
3350
+ async saveScore(score) {
3351
+ return this.stores.scores.saveScore(score);
3312
3352
  }
3313
3353
  async listScoresByRunId({
3314
3354
  runId: _runId,