@mastra/dynamodb 0.0.0-rag-chunk-extract-llm-option-20250926183645 → 0.0.0-remove-unused-model-providers-api-20251030210744

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.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DynamoDBClient, DescribeTableCommand } from '@aws-sdk/client-dynamodb';
2
2
  import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
3
3
  import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
4
- import { MastraStorage, StoreOperations, TracesStorage, TABLE_TRACES, WorkflowsStorage, MemoryStorage, resolveMessageLimit, ScoresStorage, LegacyEvalsStorage, TABLE_AI_SPANS, TABLE_RESOURCES, TABLE_SCORERS, TABLE_EVALS, TABLE_WORKFLOW_SNAPSHOT, TABLE_MESSAGES, TABLE_THREADS } from '@mastra/core/storage';
4
+ import { MastraStorage, StoreOperations, WorkflowsStorage, MemoryStorage, resolveMessageLimit, ScoresStorage, TABLE_AI_SPANS, TABLE_RESOURCES, TABLE_TRACES, TABLE_SCORERS, TABLE_WORKFLOW_SNAPSHOT, TABLE_MESSAGES, TABLE_THREADS } from '@mastra/core/storage';
5
5
  import { Entity, Service } from 'electrodb';
6
6
  import { MessageList } from '@mastra/core/agent';
7
7
  import { saveScorePayloadSchema } from '@mastra/core/scores';
@@ -562,7 +562,7 @@ var scoreEntity = new Entity({
562
562
  return value;
563
563
  }
564
564
  },
565
- runtimeContext: {
565
+ requestContext: {
566
566
  type: "string",
567
567
  required: false,
568
568
  set: (value) => {
@@ -933,187 +933,6 @@ function getElectroDbService(client, tableName) {
933
933
  }
934
934
  );
935
935
  }
936
- var LegacyEvalsDynamoDB = class extends LegacyEvalsStorage {
937
- service;
938
- tableName;
939
- constructor({ service, tableName }) {
940
- super();
941
- this.service = service;
942
- this.tableName = tableName;
943
- }
944
- // Eval operations
945
- async getEvalsByAgentName(agentName, type) {
946
- this.logger.debug("Getting evals for agent", { agentName, type });
947
- try {
948
- const query = this.service.entities.eval.query.byAgent({ entity: "eval", agent_name: agentName });
949
- const results = await query.go({ order: "desc", limit: 100 });
950
- if (!results.data.length) {
951
- return [];
952
- }
953
- let filteredData = results.data;
954
- if (type) {
955
- filteredData = filteredData.filter((evalRecord) => {
956
- try {
957
- const testInfo = evalRecord.test_info && typeof evalRecord.test_info === "string" ? JSON.parse(evalRecord.test_info) : void 0;
958
- if (type === "test" && !testInfo) {
959
- return false;
960
- }
961
- if (type === "live" && testInfo) {
962
- return false;
963
- }
964
- } catch (e) {
965
- this.logger.warn("Failed to parse test_info during filtering", { record: evalRecord, error: e });
966
- }
967
- return true;
968
- });
969
- }
970
- return filteredData.map((evalRecord) => {
971
- try {
972
- return {
973
- input: evalRecord.input,
974
- output: evalRecord.output,
975
- // Safely parse result and test_info
976
- result: evalRecord.result && typeof evalRecord.result === "string" ? JSON.parse(evalRecord.result) : void 0,
977
- agentName: evalRecord.agent_name,
978
- createdAt: evalRecord.created_at,
979
- // Keep as string from DDB?
980
- metricName: evalRecord.metric_name,
981
- instructions: evalRecord.instructions,
982
- runId: evalRecord.run_id,
983
- globalRunId: evalRecord.global_run_id,
984
- testInfo: evalRecord.test_info && typeof evalRecord.test_info === "string" ? JSON.parse(evalRecord.test_info) : void 0
985
- };
986
- } catch (parseError) {
987
- this.logger.error("Failed to parse eval record", { record: evalRecord, error: parseError });
988
- return {
989
- agentName: evalRecord.agent_name,
990
- createdAt: evalRecord.created_at,
991
- runId: evalRecord.run_id,
992
- globalRunId: evalRecord.global_run_id
993
- };
994
- }
995
- });
996
- } catch (error) {
997
- throw new MastraError(
998
- {
999
- id: "STORAGE_DYNAMODB_STORE_GET_EVALS_BY_AGENT_NAME_FAILED",
1000
- domain: ErrorDomain.STORAGE,
1001
- category: ErrorCategory.THIRD_PARTY,
1002
- details: { agentName }
1003
- },
1004
- error
1005
- );
1006
- }
1007
- }
1008
- async getEvals(options = {}) {
1009
- const { agentName, type, page = 0, perPage = 100, dateRange } = options;
1010
- this.logger.debug("Getting evals with pagination", { agentName, type, page, perPage, dateRange });
1011
- try {
1012
- let query;
1013
- if (agentName) {
1014
- query = this.service.entities.eval.query.byAgent({ entity: "eval", agent_name: agentName });
1015
- } else {
1016
- query = this.service.entities.eval.query.byEntity({ entity: "eval" });
1017
- }
1018
- const results = await query.go({
1019
- order: "desc",
1020
- pages: "all"
1021
- // Get all pages to apply filtering and pagination
1022
- });
1023
- if (!results.data.length) {
1024
- return {
1025
- evals: [],
1026
- total: 0,
1027
- page,
1028
- perPage,
1029
- hasMore: false
1030
- };
1031
- }
1032
- let filteredData = results.data;
1033
- if (type) {
1034
- filteredData = filteredData.filter((evalRecord) => {
1035
- try {
1036
- const testInfo = evalRecord.test_info && typeof evalRecord.test_info === "string" ? JSON.parse(evalRecord.test_info) : void 0;
1037
- if (type === "test" && !testInfo) {
1038
- return false;
1039
- }
1040
- if (type === "live" && testInfo) {
1041
- return false;
1042
- }
1043
- } catch (e) {
1044
- this.logger.warn("Failed to parse test_info during filtering", { record: evalRecord, error: e });
1045
- }
1046
- return true;
1047
- });
1048
- }
1049
- if (dateRange) {
1050
- const fromDate = dateRange.start;
1051
- const toDate = dateRange.end;
1052
- filteredData = filteredData.filter((evalRecord) => {
1053
- const recordDate = new Date(evalRecord.created_at);
1054
- if (fromDate && recordDate < fromDate) {
1055
- return false;
1056
- }
1057
- if (toDate && recordDate > toDate) {
1058
- return false;
1059
- }
1060
- return true;
1061
- });
1062
- }
1063
- const total = filteredData.length;
1064
- const start = page * perPage;
1065
- const end = start + perPage;
1066
- const paginatedData = filteredData.slice(start, end);
1067
- const evals = paginatedData.map((evalRecord) => {
1068
- try {
1069
- return {
1070
- input: evalRecord.input,
1071
- output: evalRecord.output,
1072
- result: evalRecord.result && typeof evalRecord.result === "string" ? JSON.parse(evalRecord.result) : void 0,
1073
- agentName: evalRecord.agent_name,
1074
- createdAt: evalRecord.created_at,
1075
- metricName: evalRecord.metric_name,
1076
- instructions: evalRecord.instructions,
1077
- runId: evalRecord.run_id,
1078
- globalRunId: evalRecord.global_run_id,
1079
- testInfo: evalRecord.test_info && typeof evalRecord.test_info === "string" ? JSON.parse(evalRecord.test_info) : void 0
1080
- };
1081
- } catch (parseError) {
1082
- this.logger.error("Failed to parse eval record", { record: evalRecord, error: parseError });
1083
- return {
1084
- agentName: evalRecord.agent_name,
1085
- createdAt: evalRecord.created_at,
1086
- runId: evalRecord.run_id,
1087
- globalRunId: evalRecord.global_run_id
1088
- };
1089
- }
1090
- });
1091
- const hasMore = end < total;
1092
- return {
1093
- evals,
1094
- total,
1095
- page,
1096
- perPage,
1097
- hasMore
1098
- };
1099
- } catch (error) {
1100
- throw new MastraError(
1101
- {
1102
- id: "STORAGE_DYNAMODB_STORE_GET_EVALS_FAILED",
1103
- domain: ErrorDomain.STORAGE,
1104
- category: ErrorCategory.THIRD_PARTY,
1105
- details: {
1106
- agentName: agentName || "all",
1107
- type: type || "all",
1108
- page,
1109
- perPage
1110
- }
1111
- },
1112
- error
1113
- );
1114
- }
1115
- }
1116
- };
1117
936
  var MemoryStorageDynamoDB = class extends MemoryStorage {
1118
937
  service;
1119
938
  constructor({ service }) {
@@ -1218,7 +1037,7 @@ var MemoryStorageDynamoDB = class extends MemoryStorage {
1218
1037
  resourceId: thread.resourceId,
1219
1038
  title: threadData.title,
1220
1039
  createdAt: thread.createdAt || now,
1221
- updatedAt: now,
1040
+ updatedAt: thread.updatedAt || now,
1222
1041
  metadata: thread.metadata
1223
1042
  };
1224
1043
  } catch (error) {
@@ -1370,10 +1189,7 @@ var MemoryStorageDynamoDB = class extends MemoryStorage {
1370
1189
  );
1371
1190
  }
1372
1191
  }
1373
- async getMessagesById({
1374
- messageIds,
1375
- format
1376
- }) {
1192
+ async listMessagesById({ messageIds }) {
1377
1193
  this.logger.debug("Getting messages by ID", { messageIds });
1378
1194
  if (messageIds.length === 0) return [];
1379
1195
  try {
@@ -1386,7 +1202,6 @@ var MemoryStorageDynamoDB = class extends MemoryStorage {
1386
1202
  (message, index, self) => index === self.findIndex((m) => m.id === message.id)
1387
1203
  );
1388
1204
  const list = new MessageList().add(uniqueMessages, "memory");
1389
- if (format === `v1`) return list.get.all.v1();
1390
1205
  return list.get.all.v2();
1391
1206
  } catch (error) {
1392
1207
  throw new MastraError(
@@ -1400,6 +1215,150 @@ var MemoryStorageDynamoDB = class extends MemoryStorage {
1400
1215
  );
1401
1216
  }
1402
1217
  }
1218
+ async listMessages(args) {
1219
+ const { threadId, resourceId, include, filter, limit, offset = 0, orderBy } = args;
1220
+ if (!threadId.trim()) {
1221
+ throw new MastraError(
1222
+ {
1223
+ id: "STORAGE_DYNAMODB_LIST_MESSAGES_INVALID_THREAD_ID",
1224
+ domain: ErrorDomain.STORAGE,
1225
+ category: ErrorCategory.THIRD_PARTY,
1226
+ details: { threadId }
1227
+ },
1228
+ new Error("threadId must be a non-empty string")
1229
+ );
1230
+ }
1231
+ try {
1232
+ let perPage = 40;
1233
+ if (limit !== void 0) {
1234
+ if (limit === false) {
1235
+ perPage = Number.MAX_SAFE_INTEGER;
1236
+ } else if (limit === 0) {
1237
+ perPage = 0;
1238
+ } else if (typeof limit === "number" && limit > 0) {
1239
+ perPage = limit;
1240
+ }
1241
+ }
1242
+ const page = perPage === 0 ? 0 : Math.floor(offset / perPage);
1243
+ const sortField = orderBy?.field || "createdAt";
1244
+ const sortDirection = orderBy?.direction || "DESC";
1245
+ this.logger.debug("Getting messages with listMessages", {
1246
+ threadId,
1247
+ resourceId,
1248
+ limit,
1249
+ offset,
1250
+ perPage,
1251
+ page,
1252
+ sortField,
1253
+ sortDirection
1254
+ });
1255
+ const query = this.service.entities.message.query.byThread({ entity: "message", threadId });
1256
+ const results = await query.go();
1257
+ let allThreadMessages = results.data.map((data) => this.parseMessageData(data)).filter((msg) => "content" in msg && typeof msg.content === "object");
1258
+ if (resourceId) {
1259
+ allThreadMessages = allThreadMessages.filter((msg) => msg.resourceId === resourceId);
1260
+ }
1261
+ if (filter?.dateRange) {
1262
+ const dateRange = filter.dateRange;
1263
+ allThreadMessages = allThreadMessages.filter((msg) => {
1264
+ const createdAt = new Date(msg.createdAt).getTime();
1265
+ if (dateRange.start) {
1266
+ const startTime = dateRange.start instanceof Date ? dateRange.start.getTime() : new Date(dateRange.start).getTime();
1267
+ if (createdAt < startTime) return false;
1268
+ }
1269
+ if (dateRange.end) {
1270
+ const endTime = dateRange.end instanceof Date ? dateRange.end.getTime() : new Date(dateRange.end).getTime();
1271
+ if (createdAt > endTime) return false;
1272
+ }
1273
+ return true;
1274
+ });
1275
+ }
1276
+ allThreadMessages.sort((a, b) => {
1277
+ const aValue = sortField === "createdAt" ? new Date(a.createdAt).getTime() : a[sortField];
1278
+ const bValue = sortField === "createdAt" ? new Date(b.createdAt).getTime() : b[sortField];
1279
+ if (aValue === bValue) {
1280
+ return a.id.localeCompare(b.id);
1281
+ }
1282
+ return sortDirection === "ASC" ? aValue - bValue : bValue - aValue;
1283
+ });
1284
+ const total = allThreadMessages.length;
1285
+ const paginatedMessages = allThreadMessages.slice(offset, offset + perPage);
1286
+ const paginatedCount = paginatedMessages.length;
1287
+ if (total === 0 && paginatedCount === 0) {
1288
+ return {
1289
+ messages: [],
1290
+ total: 0,
1291
+ page,
1292
+ perPage,
1293
+ hasMore: false
1294
+ };
1295
+ }
1296
+ const messageIds = new Set(paginatedMessages.map((m) => m.id));
1297
+ let includeMessages = [];
1298
+ if (include && include.length > 0) {
1299
+ const selectBy = { include };
1300
+ includeMessages = await this._getIncludedMessages(threadId, selectBy);
1301
+ for (const includeMsg of includeMessages) {
1302
+ if (!messageIds.has(includeMsg.id)) {
1303
+ paginatedMessages.push(includeMsg);
1304
+ messageIds.add(includeMsg.id);
1305
+ }
1306
+ }
1307
+ }
1308
+ const list = new MessageList().add(paginatedMessages, "memory");
1309
+ let finalMessages = list.get.all.v2();
1310
+ finalMessages = finalMessages.sort((a, b) => {
1311
+ const aValue = sortField === "createdAt" ? new Date(a.createdAt).getTime() : a[sortField];
1312
+ const bValue = sortField === "createdAt" ? new Date(b.createdAt).getTime() : b[sortField];
1313
+ if (aValue === bValue) {
1314
+ return a.id.localeCompare(b.id);
1315
+ }
1316
+ return sortDirection === "ASC" ? aValue - bValue : bValue - aValue;
1317
+ });
1318
+ const returnedThreadMessageIds = new Set(finalMessages.filter((m) => m.threadId === threadId).map((m) => m.id));
1319
+ const allThreadMessagesReturned = returnedThreadMessageIds.size >= total;
1320
+ const hasMore = limit === false ? false : allThreadMessagesReturned ? false : offset + paginatedCount < total;
1321
+ return {
1322
+ messages: finalMessages,
1323
+ total,
1324
+ page,
1325
+ perPage,
1326
+ hasMore
1327
+ };
1328
+ } catch (error) {
1329
+ const mastraError = new MastraError(
1330
+ {
1331
+ id: "STORAGE_DYNAMODB_STORE_LIST_MESSAGES_FAILED",
1332
+ domain: ErrorDomain.STORAGE,
1333
+ category: ErrorCategory.THIRD_PARTY,
1334
+ details: {
1335
+ threadId,
1336
+ resourceId: resourceId ?? ""
1337
+ }
1338
+ },
1339
+ error
1340
+ );
1341
+ this.logger?.error?.(mastraError.toString());
1342
+ this.logger?.trackException?.(mastraError);
1343
+ return {
1344
+ messages: [],
1345
+ total: 0,
1346
+ page: Math.floor(offset / (limit === false ? Number.MAX_SAFE_INTEGER : limit || 40)),
1347
+ perPage: limit === false ? Number.MAX_SAFE_INTEGER : limit || 40,
1348
+ hasMore: false
1349
+ };
1350
+ }
1351
+ }
1352
+ /**
1353
+ * @todo When migrating from getThreadsByResourceIdPaginated to this method,
1354
+ * implement orderBy and sortDirection support for full sorting capabilities
1355
+ */
1356
+ async listThreadsByResourceId(args) {
1357
+ const { resourceId, limit, offset } = args;
1358
+ const page = Math.floor(offset / limit);
1359
+ const perPage = limit;
1360
+ return this.getThreadsByResourceIdPaginated({ resourceId, page, perPage });
1361
+ }
1403
1362
  async saveMessages(args) {
1404
1363
  const { messages, format = "v1" } = args;
1405
1364
  this.logger.debug("Saving messages", { count: messages.length });
@@ -1855,7 +1814,6 @@ var StoreOperationsDynamoDB = class extends StoreOperations {
1855
1814
  [TABLE_THREADS]: "thread",
1856
1815
  [TABLE_MESSAGES]: "message",
1857
1816
  [TABLE_WORKFLOW_SNAPSHOT]: "workflow_snapshot",
1858
- [TABLE_EVALS]: "eval",
1859
1817
  [TABLE_SCORERS]: "score",
1860
1818
  [TABLE_TRACES]: "trace",
1861
1819
  [TABLE_RESOURCES]: "resource",
@@ -2044,6 +2002,10 @@ var StoreOperationsDynamoDB = class extends StoreOperations {
2044
2002
  if (!item.id) throw new Error(`Missing required key 'id' for entity 'score'`);
2045
2003
  key.id = item.id;
2046
2004
  break;
2005
+ case "resource":
2006
+ if (!item.id) throw new Error(`Missing required key 'id' for entity 'resource'`);
2007
+ key.id = item.id;
2008
+ break;
2047
2009
  default:
2048
2010
  this.logger.warn(`Unknown entity type encountered during clearTable: ${entityName}`);
2049
2011
  throw new Error(`Cannot construct delete key for unknown entity type: ${entityName}`);
@@ -2220,7 +2182,7 @@ var ScoresStorageDynamoDB = class extends ScoresStorage {
2220
2182
  input: typeof validatedScore.input === "string" ? validatedScore.input : JSON.stringify(validatedScore.input),
2221
2183
  output: typeof validatedScore.output === "string" ? validatedScore.output : JSON.stringify(validatedScore.output),
2222
2184
  additionalContext: typeof validatedScore.additionalContext === "string" ? validatedScore.additionalContext : JSON.stringify(validatedScore.additionalContext),
2223
- runtimeContext: typeof validatedScore.runtimeContext === "string" ? validatedScore.runtimeContext : JSON.stringify(validatedScore.runtimeContext),
2185
+ requestContext: typeof validatedScore.requestContext === "string" ? validatedScore.requestContext : JSON.stringify(validatedScore.requestContext),
2224
2186
  entityType: validatedScore.entityType,
2225
2187
  entityData: typeof validatedScore.entity === "string" ? validatedScore.entity : JSON.stringify(validatedScore.entity),
2226
2188
  entityId: validatedScore.entityId,
@@ -2417,239 +2379,6 @@ var ScoresStorageDynamoDB = class extends ScoresStorage {
2417
2379
  }
2418
2380
  }
2419
2381
  };
2420
- var TracesStorageDynamoDB = class extends TracesStorage {
2421
- service;
2422
- operations;
2423
- constructor({ service, operations }) {
2424
- super();
2425
- this.service = service;
2426
- this.operations = operations;
2427
- }
2428
- // Trace operations
2429
- async getTraces(args) {
2430
- const { name, scope, page, perPage } = args;
2431
- this.logger.debug("Getting traces", { name, scope, page, perPage });
2432
- try {
2433
- let query;
2434
- if (name) {
2435
- query = this.service.entities.trace.query.byName({ entity: "trace", name });
2436
- } else if (scope) {
2437
- query = this.service.entities.trace.query.byScope({ entity: "trace", scope });
2438
- } else {
2439
- this.logger.warn("Performing a scan operation on traces - consider using a more specific query");
2440
- query = this.service.entities.trace.scan;
2441
- }
2442
- let items = [];
2443
- let cursor = null;
2444
- let pagesFetched = 0;
2445
- const startPage = page > 0 ? page : 1;
2446
- do {
2447
- const results = await query.go({ cursor, limit: perPage });
2448
- pagesFetched++;
2449
- if (pagesFetched === startPage) {
2450
- items = results.data;
2451
- break;
2452
- }
2453
- cursor = results.cursor;
2454
- if (!cursor && results.data.length > 0 && pagesFetched < startPage) {
2455
- break;
2456
- }
2457
- } while (cursor && pagesFetched < startPage);
2458
- return items;
2459
- } catch (error) {
2460
- throw new MastraError(
2461
- {
2462
- id: "STORAGE_DYNAMODB_STORE_GET_TRACES_FAILED",
2463
- domain: ErrorDomain.STORAGE,
2464
- category: ErrorCategory.THIRD_PARTY
2465
- },
2466
- error
2467
- );
2468
- }
2469
- }
2470
- async batchTraceInsert({ records }) {
2471
- this.logger.debug("Batch inserting traces", { count: records.length });
2472
- if (!records.length) {
2473
- return;
2474
- }
2475
- try {
2476
- const recordsToSave = records.map((rec) => ({ entity: "trace", ...rec }));
2477
- await this.operations.batchInsert({
2478
- tableName: TABLE_TRACES,
2479
- records: recordsToSave
2480
- // Pass records with 'entity' included
2481
- });
2482
- } catch (error) {
2483
- throw new MastraError(
2484
- {
2485
- id: "STORAGE_DYNAMODB_STORE_BATCH_TRACE_INSERT_FAILED",
2486
- domain: ErrorDomain.STORAGE,
2487
- category: ErrorCategory.THIRD_PARTY,
2488
- details: { count: records.length }
2489
- },
2490
- error
2491
- );
2492
- }
2493
- }
2494
- async getTracesPaginated(args) {
2495
- const { name, scope, page = 0, perPage = 100, attributes, filters, dateRange } = args;
2496
- this.logger.debug("Getting traces with pagination", { name, scope, page, perPage, attributes, filters, dateRange });
2497
- try {
2498
- let query;
2499
- if (name) {
2500
- query = this.service.entities.trace.query.byName({ entity: "trace", name });
2501
- } else if (scope) {
2502
- query = this.service.entities.trace.query.byScope({ entity: "trace", scope });
2503
- } else {
2504
- this.logger.warn("Performing a scan operation on traces - consider using a more specific query");
2505
- query = this.service.entities.trace.scan;
2506
- }
2507
- const results = await query.go({
2508
- order: "desc",
2509
- pages: "all"
2510
- // Get all pages to apply filtering and pagination
2511
- });
2512
- if (!results.data.length) {
2513
- return {
2514
- traces: [],
2515
- total: 0,
2516
- page,
2517
- perPage,
2518
- hasMore: false
2519
- };
2520
- }
2521
- let filteredData = results.data;
2522
- if (attributes) {
2523
- filteredData = filteredData.filter((item) => {
2524
- try {
2525
- let itemAttributes = {};
2526
- if (item.attributes) {
2527
- if (typeof item.attributes === "string") {
2528
- if (item.attributes === "[object Object]") {
2529
- itemAttributes = {};
2530
- } else {
2531
- try {
2532
- itemAttributes = JSON.parse(item.attributes);
2533
- } catch {
2534
- itemAttributes = {};
2535
- }
2536
- }
2537
- } else if (typeof item.attributes === "object") {
2538
- itemAttributes = item.attributes;
2539
- }
2540
- }
2541
- return Object.entries(attributes).every(([key, value]) => itemAttributes[key] === value);
2542
- } catch (e) {
2543
- this.logger.warn("Failed to parse attributes during filtering", { item, error: e });
2544
- return false;
2545
- }
2546
- });
2547
- }
2548
- if (dateRange?.start) {
2549
- filteredData = filteredData.filter((item) => {
2550
- const itemDate = new Date(item.createdAt);
2551
- return itemDate >= dateRange.start;
2552
- });
2553
- }
2554
- if (dateRange?.end) {
2555
- filteredData = filteredData.filter((item) => {
2556
- const itemDate = new Date(item.createdAt);
2557
- return itemDate <= dateRange.end;
2558
- });
2559
- }
2560
- const total = filteredData.length;
2561
- const start = page * perPage;
2562
- const end = start + perPage;
2563
- const paginatedData = filteredData.slice(start, end);
2564
- const traces = paginatedData.map((item) => {
2565
- let attributes2;
2566
- if (item.attributes) {
2567
- if (typeof item.attributes === "string") {
2568
- if (item.attributes === "[object Object]") {
2569
- attributes2 = void 0;
2570
- } else {
2571
- try {
2572
- attributes2 = JSON.parse(item.attributes);
2573
- } catch {
2574
- attributes2 = void 0;
2575
- }
2576
- }
2577
- } else if (typeof item.attributes === "object") {
2578
- attributes2 = item.attributes;
2579
- }
2580
- }
2581
- let status;
2582
- if (item.status) {
2583
- if (typeof item.status === "string") {
2584
- try {
2585
- status = JSON.parse(item.status);
2586
- } catch {
2587
- status = void 0;
2588
- }
2589
- } else if (typeof item.status === "object") {
2590
- status = item.status;
2591
- }
2592
- }
2593
- let events;
2594
- if (item.events) {
2595
- if (typeof item.events === "string") {
2596
- try {
2597
- events = JSON.parse(item.events);
2598
- } catch {
2599
- events = void 0;
2600
- }
2601
- } else if (Array.isArray(item.events)) {
2602
- events = item.events;
2603
- }
2604
- }
2605
- let links;
2606
- if (item.links) {
2607
- if (typeof item.links === "string") {
2608
- try {
2609
- links = JSON.parse(item.links);
2610
- } catch {
2611
- links = void 0;
2612
- }
2613
- } else if (Array.isArray(item.links)) {
2614
- links = item.links;
2615
- }
2616
- }
2617
- return {
2618
- id: item.id,
2619
- parentSpanId: item.parentSpanId,
2620
- name: item.name,
2621
- traceId: item.traceId,
2622
- scope: item.scope,
2623
- kind: item.kind,
2624
- attributes: attributes2,
2625
- status,
2626
- events,
2627
- links,
2628
- other: item.other,
2629
- startTime: item.startTime,
2630
- endTime: item.endTime,
2631
- createdAt: item.createdAt
2632
- };
2633
- });
2634
- return {
2635
- traces,
2636
- total,
2637
- page,
2638
- perPage,
2639
- hasMore: end < total
2640
- };
2641
- } catch (error) {
2642
- throw new MastraError(
2643
- {
2644
- id: "STORAGE_DYNAMODB_STORE_GET_TRACES_PAGINATED_FAILED",
2645
- domain: ErrorDomain.STORAGE,
2646
- category: ErrorCategory.THIRD_PARTY
2647
- },
2648
- error
2649
- );
2650
- }
2651
- }
2652
- };
2653
2382
  function formatWorkflowRun(snapshotData) {
2654
2383
  return {
2655
2384
  workflowName: snapshotData.workflow_name,
@@ -2671,7 +2400,7 @@ var WorkflowStorageDynamoDB = class extends WorkflowsStorage {
2671
2400
  // runId,
2672
2401
  // stepId,
2673
2402
  // result,
2674
- // runtimeContext,
2403
+ // requestContext,
2675
2404
  }) {
2676
2405
  throw new Error("Method not implemented.");
2677
2406
  }
@@ -2744,7 +2473,7 @@ var WorkflowStorageDynamoDB = class extends WorkflowsStorage {
2744
2473
  );
2745
2474
  }
2746
2475
  }
2747
- async getWorkflowRuns(args) {
2476
+ async listWorkflowRuns(args) {
2748
2477
  this.logger.debug("Getting workflow runs", { args });
2749
2478
  try {
2750
2479
  const limit = args?.limit || 10;
@@ -2900,14 +2629,11 @@ var DynamoDBStore = class extends MastraStorage {
2900
2629
  tableName: this.tableName,
2901
2630
  client: this.client
2902
2631
  });
2903
- const traces = new TracesStorageDynamoDB({ service: this.service, operations });
2904
2632
  const workflows = new WorkflowStorageDynamoDB({ service: this.service });
2905
2633
  const memory = new MemoryStorageDynamoDB({ service: this.service });
2906
2634
  const scores = new ScoresStorageDynamoDB({ service: this.service });
2907
2635
  this.stores = {
2908
2636
  operations,
2909
- legacyEvals: new LegacyEvalsDynamoDB({ service: this.service, tableName: this.tableName }),
2910
- traces,
2911
2637
  workflows,
2912
2638
  memory,
2913
2639
  scores
@@ -3049,12 +2775,6 @@ var DynamoDBStore = class extends MastraStorage {
3049
2775
  }) {
3050
2776
  return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format });
3051
2777
  }
3052
- async getMessagesById({
3053
- messageIds,
3054
- format
3055
- }) {
3056
- return this.stores.memory.getMessagesById({ messageIds, format });
3057
- }
3058
2778
  async saveMessages(args) {
3059
2779
  return this.stores.memory.saveMessages(args);
3060
2780
  }
@@ -3067,25 +2787,15 @@ var DynamoDBStore = class extends MastraStorage {
3067
2787
  async updateMessages(_args) {
3068
2788
  return this.stores.memory.updateMessages(_args);
3069
2789
  }
3070
- // Trace operations
3071
- async getTraces(args) {
3072
- return this.stores.traces.getTraces(args);
3073
- }
3074
- async batchTraceInsert({ records }) {
3075
- return this.stores.traces.batchTraceInsert({ records });
3076
- }
3077
- async getTracesPaginated(_args) {
3078
- return this.stores.traces.getTracesPaginated(_args);
3079
- }
3080
2790
  // Workflow operations
3081
2791
  async updateWorkflowResults({
3082
2792
  workflowName,
3083
2793
  runId,
3084
2794
  stepId,
3085
2795
  result,
3086
- runtimeContext
2796
+ requestContext
3087
2797
  }) {
3088
- return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, runtimeContext });
2798
+ return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, requestContext });
3089
2799
  }
3090
2800
  async updateWorkflowState({
3091
2801
  workflowName,
@@ -3108,8 +2818,8 @@ var DynamoDBStore = class extends MastraStorage {
3108
2818
  }) {
3109
2819
  return this.stores.workflows.loadWorkflowSnapshot({ workflowName, runId });
3110
2820
  }
3111
- async getWorkflowRuns(args) {
3112
- return this.stores.workflows.getWorkflowRuns(args);
2821
+ async listWorkflowRuns(args) {
2822
+ return this.stores.workflows.listWorkflowRuns(args);
3113
2823
  }
3114
2824
  async getWorkflowRunById(args) {
3115
2825
  return this.stores.workflows.getWorkflowRunById(args);
@@ -3127,13 +2837,6 @@ var DynamoDBStore = class extends MastraStorage {
3127
2837
  }) {
3128
2838
  return this.stores.memory.updateResource({ resourceId, workingMemory, metadata });
3129
2839
  }
3130
- // Eval operations
3131
- async getEvalsByAgentName(agentName, type) {
3132
- return this.stores.legacyEvals.getEvalsByAgentName(agentName, type);
3133
- }
3134
- async getEvals(options) {
3135
- return this.stores.legacyEvals.getEvals(options);
3136
- }
3137
2840
  /**
3138
2841
  * Closes the DynamoDB client connection and cleans up resources.
3139
2842
  * Should be called when the store is no longer needed, e.g., at the end of tests or application shutdown.