@mastra/dynamodb 0.0.0-remove-unused-import-20250909212718 → 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/CHANGELOG.md +221 -3
- package/README.md +0 -4
- package/dist/entities/index.d.ts +16 -1
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/score.d.ts +16 -1
- package/dist/entities/score.d.ts.map +1 -1
- package/dist/index.cjs +240 -471
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +241 -472
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +8 -7
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/operations/index.d.ts.map +1 -1
- package/dist/storage/domains/score/index.d.ts +8 -0
- package/dist/storage/domains/score/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +5 -11
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +15 -42
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/storage/domains/legacy-evals/index.d.ts +0 -19
- package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
- package/dist/storage/domains/traces/index.d.ts +0 -28
- package/dist/storage/domains/traces/index.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var error = require('@mastra/core/error');
|
|
|
6
6
|
var storage = require('@mastra/core/storage');
|
|
7
7
|
var electrodb = require('electrodb');
|
|
8
8
|
var agent = require('@mastra/core/agent');
|
|
9
|
+
var scores = require('@mastra/core/scores');
|
|
9
10
|
|
|
10
11
|
// src/storage/index.ts
|
|
11
12
|
|
|
@@ -372,6 +373,10 @@ var scoreEntity = new electrodb.Entity({
|
|
|
372
373
|
type: "string",
|
|
373
374
|
required: false
|
|
374
375
|
},
|
|
376
|
+
spanId: {
|
|
377
|
+
type: "string",
|
|
378
|
+
required: false
|
|
379
|
+
},
|
|
375
380
|
runId: {
|
|
376
381
|
type: "string",
|
|
377
382
|
required: true
|
|
@@ -559,7 +564,7 @@ var scoreEntity = new electrodb.Entity({
|
|
|
559
564
|
return value;
|
|
560
565
|
}
|
|
561
566
|
},
|
|
562
|
-
|
|
567
|
+
requestContext: {
|
|
563
568
|
type: "string",
|
|
564
569
|
required: false,
|
|
565
570
|
set: (value) => {
|
|
@@ -658,6 +663,11 @@ var scoreEntity = new electrodb.Entity({
|
|
|
658
663
|
index: "gsi6",
|
|
659
664
|
pk: { field: "gsi6pk", composite: ["entity", "threadId"] },
|
|
660
665
|
sk: { field: "gsi6sk", composite: ["createdAt"] }
|
|
666
|
+
},
|
|
667
|
+
bySpan: {
|
|
668
|
+
index: "gsi7",
|
|
669
|
+
pk: { field: "gsi7pk", composite: ["entity", "traceId", "spanId"] },
|
|
670
|
+
sk: { field: "gsi7sk", composite: ["createdAt"] }
|
|
661
671
|
}
|
|
662
672
|
}
|
|
663
673
|
});
|
|
@@ -925,187 +935,6 @@ function getElectroDbService(client, tableName) {
|
|
|
925
935
|
}
|
|
926
936
|
);
|
|
927
937
|
}
|
|
928
|
-
var LegacyEvalsDynamoDB = class extends storage.LegacyEvalsStorage {
|
|
929
|
-
service;
|
|
930
|
-
tableName;
|
|
931
|
-
constructor({ service, tableName }) {
|
|
932
|
-
super();
|
|
933
|
-
this.service = service;
|
|
934
|
-
this.tableName = tableName;
|
|
935
|
-
}
|
|
936
|
-
// Eval operations
|
|
937
|
-
async getEvalsByAgentName(agentName, type) {
|
|
938
|
-
this.logger.debug("Getting evals for agent", { agentName, type });
|
|
939
|
-
try {
|
|
940
|
-
const query = this.service.entities.eval.query.byAgent({ entity: "eval", agent_name: agentName });
|
|
941
|
-
const results = await query.go({ order: "desc", limit: 100 });
|
|
942
|
-
if (!results.data.length) {
|
|
943
|
-
return [];
|
|
944
|
-
}
|
|
945
|
-
let filteredData = results.data;
|
|
946
|
-
if (type) {
|
|
947
|
-
filteredData = filteredData.filter((evalRecord) => {
|
|
948
|
-
try {
|
|
949
|
-
const testInfo = evalRecord.test_info && typeof evalRecord.test_info === "string" ? JSON.parse(evalRecord.test_info) : void 0;
|
|
950
|
-
if (type === "test" && !testInfo) {
|
|
951
|
-
return false;
|
|
952
|
-
}
|
|
953
|
-
if (type === "live" && testInfo) {
|
|
954
|
-
return false;
|
|
955
|
-
}
|
|
956
|
-
} catch (e) {
|
|
957
|
-
this.logger.warn("Failed to parse test_info during filtering", { record: evalRecord, error: e });
|
|
958
|
-
}
|
|
959
|
-
return true;
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
return filteredData.map((evalRecord) => {
|
|
963
|
-
try {
|
|
964
|
-
return {
|
|
965
|
-
input: evalRecord.input,
|
|
966
|
-
output: evalRecord.output,
|
|
967
|
-
// Safely parse result and test_info
|
|
968
|
-
result: evalRecord.result && typeof evalRecord.result === "string" ? JSON.parse(evalRecord.result) : void 0,
|
|
969
|
-
agentName: evalRecord.agent_name,
|
|
970
|
-
createdAt: evalRecord.created_at,
|
|
971
|
-
// Keep as string from DDB?
|
|
972
|
-
metricName: evalRecord.metric_name,
|
|
973
|
-
instructions: evalRecord.instructions,
|
|
974
|
-
runId: evalRecord.run_id,
|
|
975
|
-
globalRunId: evalRecord.global_run_id,
|
|
976
|
-
testInfo: evalRecord.test_info && typeof evalRecord.test_info === "string" ? JSON.parse(evalRecord.test_info) : void 0
|
|
977
|
-
};
|
|
978
|
-
} catch (parseError) {
|
|
979
|
-
this.logger.error("Failed to parse eval record", { record: evalRecord, error: parseError });
|
|
980
|
-
return {
|
|
981
|
-
agentName: evalRecord.agent_name,
|
|
982
|
-
createdAt: evalRecord.created_at,
|
|
983
|
-
runId: evalRecord.run_id,
|
|
984
|
-
globalRunId: evalRecord.global_run_id
|
|
985
|
-
};
|
|
986
|
-
}
|
|
987
|
-
});
|
|
988
|
-
} catch (error$1) {
|
|
989
|
-
throw new error.MastraError(
|
|
990
|
-
{
|
|
991
|
-
id: "STORAGE_DYNAMODB_STORE_GET_EVALS_BY_AGENT_NAME_FAILED",
|
|
992
|
-
domain: error.ErrorDomain.STORAGE,
|
|
993
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
994
|
-
details: { agentName }
|
|
995
|
-
},
|
|
996
|
-
error$1
|
|
997
|
-
);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
async getEvals(options = {}) {
|
|
1001
|
-
const { agentName, type, page = 0, perPage = 100, dateRange } = options;
|
|
1002
|
-
this.logger.debug("Getting evals with pagination", { agentName, type, page, perPage, dateRange });
|
|
1003
|
-
try {
|
|
1004
|
-
let query;
|
|
1005
|
-
if (agentName) {
|
|
1006
|
-
query = this.service.entities.eval.query.byAgent({ entity: "eval", agent_name: agentName });
|
|
1007
|
-
} else {
|
|
1008
|
-
query = this.service.entities.eval.query.byEntity({ entity: "eval" });
|
|
1009
|
-
}
|
|
1010
|
-
const results = await query.go({
|
|
1011
|
-
order: "desc",
|
|
1012
|
-
pages: "all"
|
|
1013
|
-
// Get all pages to apply filtering and pagination
|
|
1014
|
-
});
|
|
1015
|
-
if (!results.data.length) {
|
|
1016
|
-
return {
|
|
1017
|
-
evals: [],
|
|
1018
|
-
total: 0,
|
|
1019
|
-
page,
|
|
1020
|
-
perPage,
|
|
1021
|
-
hasMore: false
|
|
1022
|
-
};
|
|
1023
|
-
}
|
|
1024
|
-
let filteredData = results.data;
|
|
1025
|
-
if (type) {
|
|
1026
|
-
filteredData = filteredData.filter((evalRecord) => {
|
|
1027
|
-
try {
|
|
1028
|
-
const testInfo = evalRecord.test_info && typeof evalRecord.test_info === "string" ? JSON.parse(evalRecord.test_info) : void 0;
|
|
1029
|
-
if (type === "test" && !testInfo) {
|
|
1030
|
-
return false;
|
|
1031
|
-
}
|
|
1032
|
-
if (type === "live" && testInfo) {
|
|
1033
|
-
return false;
|
|
1034
|
-
}
|
|
1035
|
-
} catch (e) {
|
|
1036
|
-
this.logger.warn("Failed to parse test_info during filtering", { record: evalRecord, error: e });
|
|
1037
|
-
}
|
|
1038
|
-
return true;
|
|
1039
|
-
});
|
|
1040
|
-
}
|
|
1041
|
-
if (dateRange) {
|
|
1042
|
-
const fromDate = dateRange.start;
|
|
1043
|
-
const toDate = dateRange.end;
|
|
1044
|
-
filteredData = filteredData.filter((evalRecord) => {
|
|
1045
|
-
const recordDate = new Date(evalRecord.created_at);
|
|
1046
|
-
if (fromDate && recordDate < fromDate) {
|
|
1047
|
-
return false;
|
|
1048
|
-
}
|
|
1049
|
-
if (toDate && recordDate > toDate) {
|
|
1050
|
-
return false;
|
|
1051
|
-
}
|
|
1052
|
-
return true;
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
const total = filteredData.length;
|
|
1056
|
-
const start = page * perPage;
|
|
1057
|
-
const end = start + perPage;
|
|
1058
|
-
const paginatedData = filteredData.slice(start, end);
|
|
1059
|
-
const evals = paginatedData.map((evalRecord) => {
|
|
1060
|
-
try {
|
|
1061
|
-
return {
|
|
1062
|
-
input: evalRecord.input,
|
|
1063
|
-
output: evalRecord.output,
|
|
1064
|
-
result: evalRecord.result && typeof evalRecord.result === "string" ? JSON.parse(evalRecord.result) : void 0,
|
|
1065
|
-
agentName: evalRecord.agent_name,
|
|
1066
|
-
createdAt: evalRecord.created_at,
|
|
1067
|
-
metricName: evalRecord.metric_name,
|
|
1068
|
-
instructions: evalRecord.instructions,
|
|
1069
|
-
runId: evalRecord.run_id,
|
|
1070
|
-
globalRunId: evalRecord.global_run_id,
|
|
1071
|
-
testInfo: evalRecord.test_info && typeof evalRecord.test_info === "string" ? JSON.parse(evalRecord.test_info) : void 0
|
|
1072
|
-
};
|
|
1073
|
-
} catch (parseError) {
|
|
1074
|
-
this.logger.error("Failed to parse eval record", { record: evalRecord, error: parseError });
|
|
1075
|
-
return {
|
|
1076
|
-
agentName: evalRecord.agent_name,
|
|
1077
|
-
createdAt: evalRecord.created_at,
|
|
1078
|
-
runId: evalRecord.run_id,
|
|
1079
|
-
globalRunId: evalRecord.global_run_id
|
|
1080
|
-
};
|
|
1081
|
-
}
|
|
1082
|
-
});
|
|
1083
|
-
const hasMore = end < total;
|
|
1084
|
-
return {
|
|
1085
|
-
evals,
|
|
1086
|
-
total,
|
|
1087
|
-
page,
|
|
1088
|
-
perPage,
|
|
1089
|
-
hasMore
|
|
1090
|
-
};
|
|
1091
|
-
} catch (error$1) {
|
|
1092
|
-
throw new error.MastraError(
|
|
1093
|
-
{
|
|
1094
|
-
id: "STORAGE_DYNAMODB_STORE_GET_EVALS_FAILED",
|
|
1095
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1096
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1097
|
-
details: {
|
|
1098
|
-
agentName: agentName || "all",
|
|
1099
|
-
type: type || "all",
|
|
1100
|
-
page,
|
|
1101
|
-
perPage
|
|
1102
|
-
}
|
|
1103
|
-
},
|
|
1104
|
-
error$1
|
|
1105
|
-
);
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
};
|
|
1109
938
|
var MemoryStorageDynamoDB = class extends storage.MemoryStorage {
|
|
1110
939
|
service;
|
|
1111
940
|
constructor({ service }) {
|
|
@@ -1210,7 +1039,7 @@ var MemoryStorageDynamoDB = class extends storage.MemoryStorage {
|
|
|
1210
1039
|
resourceId: thread.resourceId,
|
|
1211
1040
|
title: threadData.title,
|
|
1212
1041
|
createdAt: thread.createdAt || now,
|
|
1213
|
-
updatedAt: now,
|
|
1042
|
+
updatedAt: thread.updatedAt || now,
|
|
1214
1043
|
metadata: thread.metadata
|
|
1215
1044
|
};
|
|
1216
1045
|
} catch (error$1) {
|
|
@@ -1362,10 +1191,7 @@ var MemoryStorageDynamoDB = class extends storage.MemoryStorage {
|
|
|
1362
1191
|
);
|
|
1363
1192
|
}
|
|
1364
1193
|
}
|
|
1365
|
-
async
|
|
1366
|
-
messageIds,
|
|
1367
|
-
format
|
|
1368
|
-
}) {
|
|
1194
|
+
async listMessagesById({ messageIds }) {
|
|
1369
1195
|
this.logger.debug("Getting messages by ID", { messageIds });
|
|
1370
1196
|
if (messageIds.length === 0) return [];
|
|
1371
1197
|
try {
|
|
@@ -1378,7 +1204,6 @@ var MemoryStorageDynamoDB = class extends storage.MemoryStorage {
|
|
|
1378
1204
|
(message, index, self) => index === self.findIndex((m) => m.id === message.id)
|
|
1379
1205
|
);
|
|
1380
1206
|
const list = new agent.MessageList().add(uniqueMessages, "memory");
|
|
1381
|
-
if (format === `v1`) return list.get.all.v1();
|
|
1382
1207
|
return list.get.all.v2();
|
|
1383
1208
|
} catch (error$1) {
|
|
1384
1209
|
throw new error.MastraError(
|
|
@@ -1392,6 +1217,150 @@ var MemoryStorageDynamoDB = class extends storage.MemoryStorage {
|
|
|
1392
1217
|
);
|
|
1393
1218
|
}
|
|
1394
1219
|
}
|
|
1220
|
+
async listMessages(args) {
|
|
1221
|
+
const { threadId, resourceId, include, filter, limit, offset = 0, orderBy } = args;
|
|
1222
|
+
if (!threadId.trim()) {
|
|
1223
|
+
throw new error.MastraError(
|
|
1224
|
+
{
|
|
1225
|
+
id: "STORAGE_DYNAMODB_LIST_MESSAGES_INVALID_THREAD_ID",
|
|
1226
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1227
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
1228
|
+
details: { threadId }
|
|
1229
|
+
},
|
|
1230
|
+
new Error("threadId must be a non-empty string")
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
try {
|
|
1234
|
+
let perPage = 40;
|
|
1235
|
+
if (limit !== void 0) {
|
|
1236
|
+
if (limit === false) {
|
|
1237
|
+
perPage = Number.MAX_SAFE_INTEGER;
|
|
1238
|
+
} else if (limit === 0) {
|
|
1239
|
+
perPage = 0;
|
|
1240
|
+
} else if (typeof limit === "number" && limit > 0) {
|
|
1241
|
+
perPage = limit;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
const page = perPage === 0 ? 0 : Math.floor(offset / perPage);
|
|
1245
|
+
const sortField = orderBy?.field || "createdAt";
|
|
1246
|
+
const sortDirection = orderBy?.direction || "DESC";
|
|
1247
|
+
this.logger.debug("Getting messages with listMessages", {
|
|
1248
|
+
threadId,
|
|
1249
|
+
resourceId,
|
|
1250
|
+
limit,
|
|
1251
|
+
offset,
|
|
1252
|
+
perPage,
|
|
1253
|
+
page,
|
|
1254
|
+
sortField,
|
|
1255
|
+
sortDirection
|
|
1256
|
+
});
|
|
1257
|
+
const query = this.service.entities.message.query.byThread({ entity: "message", threadId });
|
|
1258
|
+
const results = await query.go();
|
|
1259
|
+
let allThreadMessages = results.data.map((data) => this.parseMessageData(data)).filter((msg) => "content" in msg && typeof msg.content === "object");
|
|
1260
|
+
if (resourceId) {
|
|
1261
|
+
allThreadMessages = allThreadMessages.filter((msg) => msg.resourceId === resourceId);
|
|
1262
|
+
}
|
|
1263
|
+
if (filter?.dateRange) {
|
|
1264
|
+
const dateRange = filter.dateRange;
|
|
1265
|
+
allThreadMessages = allThreadMessages.filter((msg) => {
|
|
1266
|
+
const createdAt = new Date(msg.createdAt).getTime();
|
|
1267
|
+
if (dateRange.start) {
|
|
1268
|
+
const startTime = dateRange.start instanceof Date ? dateRange.start.getTime() : new Date(dateRange.start).getTime();
|
|
1269
|
+
if (createdAt < startTime) return false;
|
|
1270
|
+
}
|
|
1271
|
+
if (dateRange.end) {
|
|
1272
|
+
const endTime = dateRange.end instanceof Date ? dateRange.end.getTime() : new Date(dateRange.end).getTime();
|
|
1273
|
+
if (createdAt > endTime) return false;
|
|
1274
|
+
}
|
|
1275
|
+
return true;
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
allThreadMessages.sort((a, b) => {
|
|
1279
|
+
const aValue = sortField === "createdAt" ? new Date(a.createdAt).getTime() : a[sortField];
|
|
1280
|
+
const bValue = sortField === "createdAt" ? new Date(b.createdAt).getTime() : b[sortField];
|
|
1281
|
+
if (aValue === bValue) {
|
|
1282
|
+
return a.id.localeCompare(b.id);
|
|
1283
|
+
}
|
|
1284
|
+
return sortDirection === "ASC" ? aValue - bValue : bValue - aValue;
|
|
1285
|
+
});
|
|
1286
|
+
const total = allThreadMessages.length;
|
|
1287
|
+
const paginatedMessages = allThreadMessages.slice(offset, offset + perPage);
|
|
1288
|
+
const paginatedCount = paginatedMessages.length;
|
|
1289
|
+
if (total === 0 && paginatedCount === 0) {
|
|
1290
|
+
return {
|
|
1291
|
+
messages: [],
|
|
1292
|
+
total: 0,
|
|
1293
|
+
page,
|
|
1294
|
+
perPage,
|
|
1295
|
+
hasMore: false
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1298
|
+
const messageIds = new Set(paginatedMessages.map((m) => m.id));
|
|
1299
|
+
let includeMessages = [];
|
|
1300
|
+
if (include && include.length > 0) {
|
|
1301
|
+
const selectBy = { include };
|
|
1302
|
+
includeMessages = await this._getIncludedMessages(threadId, selectBy);
|
|
1303
|
+
for (const includeMsg of includeMessages) {
|
|
1304
|
+
if (!messageIds.has(includeMsg.id)) {
|
|
1305
|
+
paginatedMessages.push(includeMsg);
|
|
1306
|
+
messageIds.add(includeMsg.id);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
const list = new agent.MessageList().add(paginatedMessages, "memory");
|
|
1311
|
+
let finalMessages = list.get.all.v2();
|
|
1312
|
+
finalMessages = finalMessages.sort((a, b) => {
|
|
1313
|
+
const aValue = sortField === "createdAt" ? new Date(a.createdAt).getTime() : a[sortField];
|
|
1314
|
+
const bValue = sortField === "createdAt" ? new Date(b.createdAt).getTime() : b[sortField];
|
|
1315
|
+
if (aValue === bValue) {
|
|
1316
|
+
return a.id.localeCompare(b.id);
|
|
1317
|
+
}
|
|
1318
|
+
return sortDirection === "ASC" ? aValue - bValue : bValue - aValue;
|
|
1319
|
+
});
|
|
1320
|
+
const returnedThreadMessageIds = new Set(finalMessages.filter((m) => m.threadId === threadId).map((m) => m.id));
|
|
1321
|
+
const allThreadMessagesReturned = returnedThreadMessageIds.size >= total;
|
|
1322
|
+
const hasMore = limit === false ? false : allThreadMessagesReturned ? false : offset + paginatedCount < total;
|
|
1323
|
+
return {
|
|
1324
|
+
messages: finalMessages,
|
|
1325
|
+
total,
|
|
1326
|
+
page,
|
|
1327
|
+
perPage,
|
|
1328
|
+
hasMore
|
|
1329
|
+
};
|
|
1330
|
+
} catch (error$1) {
|
|
1331
|
+
const mastraError = new error.MastraError(
|
|
1332
|
+
{
|
|
1333
|
+
id: "STORAGE_DYNAMODB_STORE_LIST_MESSAGES_FAILED",
|
|
1334
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1335
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
1336
|
+
details: {
|
|
1337
|
+
threadId,
|
|
1338
|
+
resourceId: resourceId ?? ""
|
|
1339
|
+
}
|
|
1340
|
+
},
|
|
1341
|
+
error$1
|
|
1342
|
+
);
|
|
1343
|
+
this.logger?.error?.(mastraError.toString());
|
|
1344
|
+
this.logger?.trackException?.(mastraError);
|
|
1345
|
+
return {
|
|
1346
|
+
messages: [],
|
|
1347
|
+
total: 0,
|
|
1348
|
+
page: Math.floor(offset / (limit === false ? Number.MAX_SAFE_INTEGER : limit || 40)),
|
|
1349
|
+
perPage: limit === false ? Number.MAX_SAFE_INTEGER : limit || 40,
|
|
1350
|
+
hasMore: false
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* @todo When migrating from getThreadsByResourceIdPaginated to this method,
|
|
1356
|
+
* implement orderBy and sortDirection support for full sorting capabilities
|
|
1357
|
+
*/
|
|
1358
|
+
async listThreadsByResourceId(args) {
|
|
1359
|
+
const { resourceId, limit, offset } = args;
|
|
1360
|
+
const page = Math.floor(offset / limit);
|
|
1361
|
+
const perPage = limit;
|
|
1362
|
+
return this.getThreadsByResourceIdPaginated({ resourceId, page, perPage });
|
|
1363
|
+
}
|
|
1395
1364
|
async saveMessages(args) {
|
|
1396
1365
|
const { messages, format = "v1" } = args;
|
|
1397
1366
|
this.logger.debug("Saving messages", { count: messages.length });
|
|
@@ -1847,7 +1816,6 @@ var StoreOperationsDynamoDB = class extends storage.StoreOperations {
|
|
|
1847
1816
|
[storage.TABLE_THREADS]: "thread",
|
|
1848
1817
|
[storage.TABLE_MESSAGES]: "message",
|
|
1849
1818
|
[storage.TABLE_WORKFLOW_SNAPSHOT]: "workflow_snapshot",
|
|
1850
|
-
[storage.TABLE_EVALS]: "eval",
|
|
1851
1819
|
[storage.TABLE_SCORERS]: "score",
|
|
1852
1820
|
[storage.TABLE_TRACES]: "trace",
|
|
1853
1821
|
[storage.TABLE_RESOURCES]: "resource",
|
|
@@ -2036,6 +2004,10 @@ var StoreOperationsDynamoDB = class extends storage.StoreOperations {
|
|
|
2036
2004
|
if (!item.id) throw new Error(`Missing required key 'id' for entity 'score'`);
|
|
2037
2005
|
key.id = item.id;
|
|
2038
2006
|
break;
|
|
2007
|
+
case "resource":
|
|
2008
|
+
if (!item.id) throw new Error(`Missing required key 'id' for entity 'resource'`);
|
|
2009
|
+
key.id = item.id;
|
|
2010
|
+
break;
|
|
2039
2011
|
default:
|
|
2040
2012
|
this.logger.warn(`Unknown entity type encountered during clearTable: ${entityName}`);
|
|
2041
2013
|
throw new Error(`Cannot construct delete key for unknown entity type: ${entityName}`);
|
|
@@ -2178,34 +2150,47 @@ var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
|
|
|
2178
2150
|
}
|
|
2179
2151
|
}
|
|
2180
2152
|
async saveScore(score) {
|
|
2181
|
-
|
|
2153
|
+
let validatedScore;
|
|
2154
|
+
try {
|
|
2155
|
+
validatedScore = scores.saveScorePayloadSchema.parse(score);
|
|
2156
|
+
} catch (error$1) {
|
|
2157
|
+
throw new error.MastraError(
|
|
2158
|
+
{
|
|
2159
|
+
id: "STORAGE_DYNAMODB_STORE_SAVE_SCORE_FAILED",
|
|
2160
|
+
domain: error.ErrorDomain.STORAGE,
|
|
2161
|
+
category: error.ErrorCategory.THIRD_PARTY
|
|
2162
|
+
},
|
|
2163
|
+
error$1
|
|
2164
|
+
);
|
|
2165
|
+
}
|
|
2182
2166
|
const now = /* @__PURE__ */ new Date();
|
|
2183
2167
|
const scoreId = `score-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
2184
2168
|
const scoreData = {
|
|
2185
2169
|
entity: "score",
|
|
2186
2170
|
id: scoreId,
|
|
2187
|
-
scorerId:
|
|
2188
|
-
traceId:
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2171
|
+
scorerId: validatedScore.scorerId,
|
|
2172
|
+
traceId: validatedScore.traceId || "",
|
|
2173
|
+
spanId: validatedScore.spanId || "",
|
|
2174
|
+
runId: validatedScore.runId,
|
|
2175
|
+
scorer: typeof validatedScore.scorer === "string" ? validatedScore.scorer : JSON.stringify(validatedScore.scorer),
|
|
2176
|
+
preprocessStepResult: typeof validatedScore.preprocessStepResult === "string" ? validatedScore.preprocessStepResult : JSON.stringify(validatedScore.preprocessStepResult),
|
|
2177
|
+
analyzeStepResult: typeof validatedScore.analyzeStepResult === "string" ? validatedScore.analyzeStepResult : JSON.stringify(validatedScore.analyzeStepResult),
|
|
2178
|
+
score: validatedScore.score,
|
|
2179
|
+
reason: validatedScore.reason,
|
|
2180
|
+
preprocessPrompt: validatedScore.preprocessPrompt,
|
|
2181
|
+
generateScorePrompt: validatedScore.generateScorePrompt,
|
|
2182
|
+
generateReasonPrompt: validatedScore.generateReasonPrompt,
|
|
2183
|
+
analyzePrompt: validatedScore.analyzePrompt,
|
|
2184
|
+
input: typeof validatedScore.input === "string" ? validatedScore.input : JSON.stringify(validatedScore.input),
|
|
2185
|
+
output: typeof validatedScore.output === "string" ? validatedScore.output : JSON.stringify(validatedScore.output),
|
|
2186
|
+
additionalContext: typeof validatedScore.additionalContext === "string" ? validatedScore.additionalContext : JSON.stringify(validatedScore.additionalContext),
|
|
2187
|
+
requestContext: typeof validatedScore.requestContext === "string" ? validatedScore.requestContext : JSON.stringify(validatedScore.requestContext),
|
|
2188
|
+
entityType: validatedScore.entityType,
|
|
2189
|
+
entityData: typeof validatedScore.entity === "string" ? validatedScore.entity : JSON.stringify(validatedScore.entity),
|
|
2190
|
+
entityId: validatedScore.entityId,
|
|
2191
|
+
source: validatedScore.source,
|
|
2192
|
+
resourceId: validatedScore.resourceId || "",
|
|
2193
|
+
threadId: validatedScore.threadId || "",
|
|
2209
2194
|
createdAt: now.toISOString(),
|
|
2210
2195
|
updatedAt: now.toISOString()
|
|
2211
2196
|
};
|
|
@@ -2358,234 +2343,38 @@ var ScoresStorageDynamoDB = class extends storage.ScoresStorage {
|
|
|
2358
2343
|
);
|
|
2359
2344
|
}
|
|
2360
2345
|
}
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
this.service = service;
|
|
2368
|
-
this.operations = operations;
|
|
2369
|
-
}
|
|
2370
|
-
// Trace operations
|
|
2371
|
-
async getTraces(args) {
|
|
2372
|
-
const { name, scope, page, perPage } = args;
|
|
2373
|
-
this.logger.debug("Getting traces", { name, scope, page, perPage });
|
|
2374
|
-
try {
|
|
2375
|
-
let query;
|
|
2376
|
-
if (name) {
|
|
2377
|
-
query = this.service.entities.trace.query.byName({ entity: "trace", name });
|
|
2378
|
-
} else if (scope) {
|
|
2379
|
-
query = this.service.entities.trace.query.byScope({ entity: "trace", scope });
|
|
2380
|
-
} else {
|
|
2381
|
-
this.logger.warn("Performing a scan operation on traces - consider using a more specific query");
|
|
2382
|
-
query = this.service.entities.trace.scan;
|
|
2383
|
-
}
|
|
2384
|
-
let items = [];
|
|
2385
|
-
let cursor = null;
|
|
2386
|
-
let pagesFetched = 0;
|
|
2387
|
-
const startPage = page > 0 ? page : 1;
|
|
2388
|
-
do {
|
|
2389
|
-
const results = await query.go({ cursor, limit: perPage });
|
|
2390
|
-
pagesFetched++;
|
|
2391
|
-
if (pagesFetched === startPage) {
|
|
2392
|
-
items = results.data;
|
|
2393
|
-
break;
|
|
2394
|
-
}
|
|
2395
|
-
cursor = results.cursor;
|
|
2396
|
-
if (!cursor && results.data.length > 0 && pagesFetched < startPage) {
|
|
2397
|
-
break;
|
|
2398
|
-
}
|
|
2399
|
-
} while (cursor && pagesFetched < startPage);
|
|
2400
|
-
return items;
|
|
2401
|
-
} catch (error$1) {
|
|
2402
|
-
throw new error.MastraError(
|
|
2403
|
-
{
|
|
2404
|
-
id: "STORAGE_DYNAMODB_STORE_GET_TRACES_FAILED",
|
|
2405
|
-
domain: error.ErrorDomain.STORAGE,
|
|
2406
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
2407
|
-
},
|
|
2408
|
-
error$1
|
|
2409
|
-
);
|
|
2410
|
-
}
|
|
2411
|
-
}
|
|
2412
|
-
async batchTraceInsert({ records }) {
|
|
2413
|
-
this.logger.debug("Batch inserting traces", { count: records.length });
|
|
2414
|
-
if (!records.length) {
|
|
2415
|
-
return;
|
|
2416
|
-
}
|
|
2417
|
-
try {
|
|
2418
|
-
const recordsToSave = records.map((rec) => ({ entity: "trace", ...rec }));
|
|
2419
|
-
await this.operations.batchInsert({
|
|
2420
|
-
tableName: storage.TABLE_TRACES,
|
|
2421
|
-
records: recordsToSave
|
|
2422
|
-
// Pass records with 'entity' included
|
|
2423
|
-
});
|
|
2424
|
-
} catch (error$1) {
|
|
2425
|
-
throw new error.MastraError(
|
|
2426
|
-
{
|
|
2427
|
-
id: "STORAGE_DYNAMODB_STORE_BATCH_TRACE_INSERT_FAILED",
|
|
2428
|
-
domain: error.ErrorDomain.STORAGE,
|
|
2429
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
2430
|
-
details: { count: records.length }
|
|
2431
|
-
},
|
|
2432
|
-
error$1
|
|
2433
|
-
);
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
async getTracesPaginated(args) {
|
|
2437
|
-
const { name, scope, page = 0, perPage = 100, attributes, filters, dateRange } = args;
|
|
2438
|
-
this.logger.debug("Getting traces with pagination", { name, scope, page, perPage, attributes, filters, dateRange });
|
|
2346
|
+
async getScoresBySpan({
|
|
2347
|
+
traceId,
|
|
2348
|
+
spanId,
|
|
2349
|
+
pagination
|
|
2350
|
+
}) {
|
|
2351
|
+
this.logger.debug("Getting scores by span", { traceId, spanId, pagination });
|
|
2439
2352
|
try {
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
const results = await query.go({
|
|
2450
|
-
order: "desc",
|
|
2451
|
-
pages: "all"
|
|
2452
|
-
// Get all pages to apply filtering and pagination
|
|
2453
|
-
});
|
|
2454
|
-
if (!results.data.length) {
|
|
2455
|
-
return {
|
|
2456
|
-
traces: [],
|
|
2457
|
-
total: 0,
|
|
2458
|
-
page,
|
|
2459
|
-
perPage,
|
|
2460
|
-
hasMore: false
|
|
2461
|
-
};
|
|
2462
|
-
}
|
|
2463
|
-
let filteredData = results.data;
|
|
2464
|
-
if (attributes) {
|
|
2465
|
-
filteredData = filteredData.filter((item) => {
|
|
2466
|
-
try {
|
|
2467
|
-
let itemAttributes = {};
|
|
2468
|
-
if (item.attributes) {
|
|
2469
|
-
if (typeof item.attributes === "string") {
|
|
2470
|
-
if (item.attributes === "[object Object]") {
|
|
2471
|
-
itemAttributes = {};
|
|
2472
|
-
} else {
|
|
2473
|
-
try {
|
|
2474
|
-
itemAttributes = JSON.parse(item.attributes);
|
|
2475
|
-
} catch {
|
|
2476
|
-
itemAttributes = {};
|
|
2477
|
-
}
|
|
2478
|
-
}
|
|
2479
|
-
} else if (typeof item.attributes === "object") {
|
|
2480
|
-
itemAttributes = item.attributes;
|
|
2481
|
-
}
|
|
2482
|
-
}
|
|
2483
|
-
return Object.entries(attributes).every(([key, value]) => itemAttributes[key] === value);
|
|
2484
|
-
} catch (e) {
|
|
2485
|
-
this.logger.warn("Failed to parse attributes during filtering", { item, error: e });
|
|
2486
|
-
return false;
|
|
2487
|
-
}
|
|
2488
|
-
});
|
|
2489
|
-
}
|
|
2490
|
-
if (dateRange?.start) {
|
|
2491
|
-
filteredData = filteredData.filter((item) => {
|
|
2492
|
-
const itemDate = new Date(item.createdAt);
|
|
2493
|
-
return itemDate >= dateRange.start;
|
|
2494
|
-
});
|
|
2495
|
-
}
|
|
2496
|
-
if (dateRange?.end) {
|
|
2497
|
-
filteredData = filteredData.filter((item) => {
|
|
2498
|
-
const itemDate = new Date(item.createdAt);
|
|
2499
|
-
return itemDate <= dateRange.end;
|
|
2500
|
-
});
|
|
2501
|
-
}
|
|
2502
|
-
const total = filteredData.length;
|
|
2503
|
-
const start = page * perPage;
|
|
2504
|
-
const end = start + perPage;
|
|
2505
|
-
const paginatedData = filteredData.slice(start, end);
|
|
2506
|
-
const traces = paginatedData.map((item) => {
|
|
2507
|
-
let attributes2;
|
|
2508
|
-
if (item.attributes) {
|
|
2509
|
-
if (typeof item.attributes === "string") {
|
|
2510
|
-
if (item.attributes === "[object Object]") {
|
|
2511
|
-
attributes2 = void 0;
|
|
2512
|
-
} else {
|
|
2513
|
-
try {
|
|
2514
|
-
attributes2 = JSON.parse(item.attributes);
|
|
2515
|
-
} catch {
|
|
2516
|
-
attributes2 = void 0;
|
|
2517
|
-
}
|
|
2518
|
-
}
|
|
2519
|
-
} else if (typeof item.attributes === "object") {
|
|
2520
|
-
attributes2 = item.attributes;
|
|
2521
|
-
}
|
|
2522
|
-
}
|
|
2523
|
-
let status;
|
|
2524
|
-
if (item.status) {
|
|
2525
|
-
if (typeof item.status === "string") {
|
|
2526
|
-
try {
|
|
2527
|
-
status = JSON.parse(item.status);
|
|
2528
|
-
} catch {
|
|
2529
|
-
status = void 0;
|
|
2530
|
-
}
|
|
2531
|
-
} else if (typeof item.status === "object") {
|
|
2532
|
-
status = item.status;
|
|
2533
|
-
}
|
|
2534
|
-
}
|
|
2535
|
-
let events;
|
|
2536
|
-
if (item.events) {
|
|
2537
|
-
if (typeof item.events === "string") {
|
|
2538
|
-
try {
|
|
2539
|
-
events = JSON.parse(item.events);
|
|
2540
|
-
} catch {
|
|
2541
|
-
events = void 0;
|
|
2542
|
-
}
|
|
2543
|
-
} else if (Array.isArray(item.events)) {
|
|
2544
|
-
events = item.events;
|
|
2545
|
-
}
|
|
2546
|
-
}
|
|
2547
|
-
let links;
|
|
2548
|
-
if (item.links) {
|
|
2549
|
-
if (typeof item.links === "string") {
|
|
2550
|
-
try {
|
|
2551
|
-
links = JSON.parse(item.links);
|
|
2552
|
-
} catch {
|
|
2553
|
-
links = void 0;
|
|
2554
|
-
}
|
|
2555
|
-
} else if (Array.isArray(item.links)) {
|
|
2556
|
-
links = item.links;
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
2559
|
-
return {
|
|
2560
|
-
id: item.id,
|
|
2561
|
-
parentSpanId: item.parentSpanId,
|
|
2562
|
-
name: item.name,
|
|
2563
|
-
traceId: item.traceId,
|
|
2564
|
-
scope: item.scope,
|
|
2565
|
-
kind: item.kind,
|
|
2566
|
-
attributes: attributes2,
|
|
2567
|
-
status,
|
|
2568
|
-
events,
|
|
2569
|
-
links,
|
|
2570
|
-
other: item.other,
|
|
2571
|
-
startTime: item.startTime,
|
|
2572
|
-
endTime: item.endTime,
|
|
2573
|
-
createdAt: item.createdAt
|
|
2574
|
-
};
|
|
2575
|
-
});
|
|
2353
|
+
const query = this.service.entities.score.query.bySpan({ entity: "score", traceId, spanId });
|
|
2354
|
+
const results = await query.go();
|
|
2355
|
+
const allScores = results.data.map((data) => this.parseScoreData(data));
|
|
2356
|
+
allScores.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
2357
|
+
const startIndex = pagination.page * pagination.perPage;
|
|
2358
|
+
const endIndex = startIndex + pagination.perPage;
|
|
2359
|
+
const paginatedScores = allScores.slice(startIndex, endIndex);
|
|
2360
|
+
const total = allScores.length;
|
|
2361
|
+
const hasMore = endIndex < total;
|
|
2576
2362
|
return {
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2363
|
+
scores: paginatedScores,
|
|
2364
|
+
pagination: {
|
|
2365
|
+
total,
|
|
2366
|
+
page: pagination.page,
|
|
2367
|
+
perPage: pagination.perPage,
|
|
2368
|
+
hasMore
|
|
2369
|
+
}
|
|
2582
2370
|
};
|
|
2583
2371
|
} catch (error$1) {
|
|
2584
2372
|
throw new error.MastraError(
|
|
2585
2373
|
{
|
|
2586
|
-
id: "
|
|
2374
|
+
id: "STORAGE_DYNAMODB_STORE_GET_SCORES_BY_SPAN_FAILED",
|
|
2587
2375
|
domain: error.ErrorDomain.STORAGE,
|
|
2588
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
2376
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
2377
|
+
details: { traceId, spanId, page: pagination.page, perPage: pagination.perPage }
|
|
2589
2378
|
},
|
|
2590
2379
|
error$1
|
|
2591
2380
|
);
|
|
@@ -2613,7 +2402,7 @@ var WorkflowStorageDynamoDB = class extends storage.WorkflowsStorage {
|
|
|
2613
2402
|
// runId,
|
|
2614
2403
|
// stepId,
|
|
2615
2404
|
// result,
|
|
2616
|
-
//
|
|
2405
|
+
// requestContext,
|
|
2617
2406
|
}) {
|
|
2618
2407
|
throw new Error("Method not implemented.");
|
|
2619
2408
|
}
|
|
@@ -2628,11 +2417,11 @@ var WorkflowStorageDynamoDB = class extends storage.WorkflowsStorage {
|
|
|
2628
2417
|
async persistWorkflowSnapshot({
|
|
2629
2418
|
workflowName,
|
|
2630
2419
|
runId,
|
|
2420
|
+
resourceId,
|
|
2631
2421
|
snapshot
|
|
2632
2422
|
}) {
|
|
2633
2423
|
this.logger.debug("Persisting workflow snapshot", { workflowName, runId });
|
|
2634
2424
|
try {
|
|
2635
|
-
const resourceId = "resourceId" in snapshot ? snapshot.resourceId : void 0;
|
|
2636
2425
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2637
2426
|
const data = {
|
|
2638
2427
|
entity: "workflow_snapshot",
|
|
@@ -2686,7 +2475,7 @@ var WorkflowStorageDynamoDB = class extends storage.WorkflowsStorage {
|
|
|
2686
2475
|
);
|
|
2687
2476
|
}
|
|
2688
2477
|
}
|
|
2689
|
-
async
|
|
2478
|
+
async listWorkflowRuns(args) {
|
|
2690
2479
|
this.logger.debug("Getting workflow runs", { args });
|
|
2691
2480
|
try {
|
|
2692
2481
|
const limit = args?.limit || 10;
|
|
@@ -2758,8 +2547,6 @@ var WorkflowStorageDynamoDB = class extends storage.WorkflowsStorage {
|
|
|
2758
2547
|
async getWorkflowRunById(args) {
|
|
2759
2548
|
const { runId, workflowName } = args;
|
|
2760
2549
|
this.logger.debug("Getting workflow run by ID", { runId, workflowName });
|
|
2761
|
-
console.log("workflowName", workflowName);
|
|
2762
|
-
console.log("runId", runId);
|
|
2763
2550
|
try {
|
|
2764
2551
|
if (workflowName) {
|
|
2765
2552
|
this.logger.debug("WorkflowName provided, using direct GET operation.");
|
|
@@ -2769,7 +2556,6 @@ var WorkflowStorageDynamoDB = class extends storage.WorkflowsStorage {
|
|
|
2769
2556
|
workflow_name: workflowName,
|
|
2770
2557
|
run_id: runId
|
|
2771
2558
|
}).go();
|
|
2772
|
-
console.log("result", result2);
|
|
2773
2559
|
if (!result2.data) {
|
|
2774
2560
|
return null;
|
|
2775
2561
|
}
|
|
@@ -2845,14 +2631,11 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
2845
2631
|
tableName: this.tableName,
|
|
2846
2632
|
client: this.client
|
|
2847
2633
|
});
|
|
2848
|
-
const traces = new TracesStorageDynamoDB({ service: this.service, operations });
|
|
2849
2634
|
const workflows = new WorkflowStorageDynamoDB({ service: this.service });
|
|
2850
2635
|
const memory = new MemoryStorageDynamoDB({ service: this.service });
|
|
2851
2636
|
const scores = new ScoresStorageDynamoDB({ service: this.service });
|
|
2852
2637
|
this.stores = {
|
|
2853
2638
|
operations,
|
|
2854
|
-
legacyEvals: new LegacyEvalsDynamoDB({ service: this.service, tableName: this.tableName }),
|
|
2855
|
-
traces,
|
|
2856
2639
|
workflows,
|
|
2857
2640
|
memory,
|
|
2858
2641
|
scores
|
|
@@ -2874,7 +2657,8 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
2874
2657
|
resourceWorkingMemory: true,
|
|
2875
2658
|
hasColumn: false,
|
|
2876
2659
|
createTable: false,
|
|
2877
|
-
deleteMessages: false
|
|
2660
|
+
deleteMessages: false,
|
|
2661
|
+
getScoresBySpan: true
|
|
2878
2662
|
};
|
|
2879
2663
|
}
|
|
2880
2664
|
/**
|
|
@@ -2993,12 +2777,6 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
2993
2777
|
}) {
|
|
2994
2778
|
return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format });
|
|
2995
2779
|
}
|
|
2996
|
-
async getMessagesById({
|
|
2997
|
-
messageIds,
|
|
2998
|
-
format
|
|
2999
|
-
}) {
|
|
3000
|
-
return this.stores.memory.getMessagesById({ messageIds, format });
|
|
3001
|
-
}
|
|
3002
2780
|
async saveMessages(args) {
|
|
3003
2781
|
return this.stores.memory.saveMessages(args);
|
|
3004
2782
|
}
|
|
@@ -3011,25 +2789,15 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
3011
2789
|
async updateMessages(_args) {
|
|
3012
2790
|
return this.stores.memory.updateMessages(_args);
|
|
3013
2791
|
}
|
|
3014
|
-
// Trace operations
|
|
3015
|
-
async getTraces(args) {
|
|
3016
|
-
return this.stores.traces.getTraces(args);
|
|
3017
|
-
}
|
|
3018
|
-
async batchTraceInsert({ records }) {
|
|
3019
|
-
return this.stores.traces.batchTraceInsert({ records });
|
|
3020
|
-
}
|
|
3021
|
-
async getTracesPaginated(_args) {
|
|
3022
|
-
return this.stores.traces.getTracesPaginated(_args);
|
|
3023
|
-
}
|
|
3024
2792
|
// Workflow operations
|
|
3025
2793
|
async updateWorkflowResults({
|
|
3026
2794
|
workflowName,
|
|
3027
2795
|
runId,
|
|
3028
2796
|
stepId,
|
|
3029
2797
|
result,
|
|
3030
|
-
|
|
2798
|
+
requestContext
|
|
3031
2799
|
}) {
|
|
3032
|
-
return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result,
|
|
2800
|
+
return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, requestContext });
|
|
3033
2801
|
}
|
|
3034
2802
|
async updateWorkflowState({
|
|
3035
2803
|
workflowName,
|
|
@@ -3041,9 +2809,10 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
3041
2809
|
async persistWorkflowSnapshot({
|
|
3042
2810
|
workflowName,
|
|
3043
2811
|
runId,
|
|
2812
|
+
resourceId,
|
|
3044
2813
|
snapshot
|
|
3045
2814
|
}) {
|
|
3046
|
-
return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
2815
|
+
return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot });
|
|
3047
2816
|
}
|
|
3048
2817
|
async loadWorkflowSnapshot({
|
|
3049
2818
|
workflowName,
|
|
@@ -3051,8 +2820,8 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
3051
2820
|
}) {
|
|
3052
2821
|
return this.stores.workflows.loadWorkflowSnapshot({ workflowName, runId });
|
|
3053
2822
|
}
|
|
3054
|
-
async
|
|
3055
|
-
return this.stores.workflows.
|
|
2823
|
+
async listWorkflowRuns(args) {
|
|
2824
|
+
return this.stores.workflows.listWorkflowRuns(args);
|
|
3056
2825
|
}
|
|
3057
2826
|
async getWorkflowRunById(args) {
|
|
3058
2827
|
return this.stores.workflows.getWorkflowRunById(args);
|
|
@@ -3070,13 +2839,6 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
3070
2839
|
}) {
|
|
3071
2840
|
return this.stores.memory.updateResource({ resourceId, workingMemory, metadata });
|
|
3072
2841
|
}
|
|
3073
|
-
// Eval operations
|
|
3074
|
-
async getEvalsByAgentName(agentName, type) {
|
|
3075
|
-
return this.stores.legacyEvals.getEvalsByAgentName(agentName, type);
|
|
3076
|
-
}
|
|
3077
|
-
async getEvals(options) {
|
|
3078
|
-
return this.stores.legacyEvals.getEvals(options);
|
|
3079
|
-
}
|
|
3080
2842
|
/**
|
|
3081
2843
|
* Closes the DynamoDB client connection and cleans up resources.
|
|
3082
2844
|
* Should be called when the store is no longer needed, e.g., at the end of tests or application shutdown.
|
|
@@ -3132,6 +2894,13 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
3132
2894
|
}) {
|
|
3133
2895
|
return this.stores.scores.getScoresByScorerId({ scorerId, source, entityId, entityType, pagination });
|
|
3134
2896
|
}
|
|
2897
|
+
async getScoresBySpan({
|
|
2898
|
+
traceId,
|
|
2899
|
+
spanId,
|
|
2900
|
+
pagination
|
|
2901
|
+
}) {
|
|
2902
|
+
return this.stores.scores.getScoresBySpan({ traceId, spanId, pagination });
|
|
2903
|
+
}
|
|
3135
2904
|
};
|
|
3136
2905
|
|
|
3137
2906
|
exports.DynamoDBStore = DynamoDBStore;
|