@mastra/cloudflare-d1 0.0.0-playground-studio-cloud-20251031080052 → 0.0.0-playground-studio-again-20251114102707

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
@@ -3,9 +3,9 @@
3
3
  var error = require('@mastra/core/error');
4
4
  var storage = require('@mastra/core/storage');
5
5
  var Cloudflare = require('cloudflare');
6
- var utils = require('@mastra/core/utils');
7
6
  var agent = require('@mastra/core/agent');
8
- var scores = require('@mastra/core/scores');
7
+ var utils = require('@mastra/core/utils');
8
+ var evals = require('@mastra/core/evals');
9
9
 
10
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
 
@@ -258,155 +258,7 @@ function deserializeValue(value, type) {
258
258
  return value;
259
259
  }
260
260
 
261
- // src/storage/domains/legacy-evals/index.ts
262
- var LegacyEvalsStorageD1 = class extends storage.LegacyEvalsStorage {
263
- operations;
264
- constructor({ operations }) {
265
- super();
266
- this.operations = operations;
267
- }
268
- async getEvals(options) {
269
- const { agentName, type, page = 0, perPage = 40, dateRange } = options || {};
270
- const fullTableName = this.operations.getTableName(storage.TABLE_EVALS);
271
- const conditions = [];
272
- const queryParams = [];
273
- if (agentName) {
274
- conditions.push(`agent_name = ?`);
275
- queryParams.push(agentName);
276
- }
277
- if (type === "test") {
278
- conditions.push(`(test_info IS NOT NULL AND json_extract(test_info, '$.testPath') IS NOT NULL)`);
279
- } else if (type === "live") {
280
- conditions.push(`(test_info IS NULL OR json_extract(test_info, '$.testPath') IS NULL)`);
281
- }
282
- if (dateRange?.start) {
283
- conditions.push(`created_at >= ?`);
284
- queryParams.push(storage.serializeDate(dateRange.start));
285
- }
286
- if (dateRange?.end) {
287
- conditions.push(`created_at <= ?`);
288
- queryParams.push(storage.serializeDate(dateRange.end));
289
- }
290
- const countQueryBuilder = createSqlBuilder().count().from(fullTableName);
291
- if (conditions.length > 0) {
292
- countQueryBuilder.where(conditions.join(" AND "), ...queryParams);
293
- }
294
- const { sql: countSql, params: countParams } = countQueryBuilder.build();
295
- try {
296
- const countResult = await this.operations.executeQuery({
297
- sql: countSql,
298
- params: countParams,
299
- first: true
300
- });
301
- const total = Number(countResult?.count || 0);
302
- const currentOffset = page * perPage;
303
- if (total === 0) {
304
- return {
305
- evals: [],
306
- total: 0,
307
- page,
308
- perPage,
309
- hasMore: false
310
- };
311
- }
312
- const dataQueryBuilder = createSqlBuilder().select("*").from(fullTableName);
313
- if (conditions.length > 0) {
314
- dataQueryBuilder.where(conditions.join(" AND "), ...queryParams);
315
- }
316
- dataQueryBuilder.orderBy("created_at", "DESC").limit(perPage).offset(currentOffset);
317
- const { sql: dataSql, params: dataParams } = dataQueryBuilder.build();
318
- const rows = await this.operations.executeQuery({
319
- sql: dataSql,
320
- params: dataParams
321
- });
322
- const evals = (isArrayOfRecords(rows) ? rows : []).map((row) => {
323
- const result = deserializeValue(row.result);
324
- const testInfo = row.test_info ? deserializeValue(row.test_info) : void 0;
325
- if (!result || typeof result !== "object" || !("score" in result)) {
326
- throw new Error(`Invalid MetricResult format: ${JSON.stringify(result)}`);
327
- }
328
- return {
329
- input: row.input,
330
- output: row.output,
331
- result,
332
- agentName: row.agent_name,
333
- metricName: row.metric_name,
334
- instructions: row.instructions,
335
- testInfo,
336
- globalRunId: row.global_run_id,
337
- runId: row.run_id,
338
- createdAt: row.created_at
339
- };
340
- });
341
- const hasMore = currentOffset + evals.length < total;
342
- return {
343
- evals,
344
- total,
345
- page,
346
- perPage,
347
- hasMore
348
- };
349
- } catch (error$1) {
350
- throw new error.MastraError(
351
- {
352
- id: "CLOUDFLARE_D1_STORAGE_GET_EVALS_ERROR",
353
- domain: error.ErrorDomain.STORAGE,
354
- category: error.ErrorCategory.THIRD_PARTY,
355
- text: `Failed to retrieve evals for agent ${agentName}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
356
- details: { agentName: agentName ?? "", type: type ?? "" }
357
- },
358
- error$1
359
- );
360
- }
361
- }
362
- /**
363
- * @deprecated use getEvals instead
364
- */
365
- async getEvalsByAgentName(agentName, type) {
366
- const fullTableName = this.operations.getTableName(storage.TABLE_EVALS);
367
- try {
368
- let query = createSqlBuilder().select("*").from(fullTableName).where("agent_name = ?", agentName);
369
- if (type === "test") {
370
- query = query.andWhere("test_info IS NOT NULL AND json_extract(test_info, '$.testPath') IS NOT NULL");
371
- } else if (type === "live") {
372
- query = query.andWhere("(test_info IS NULL OR json_extract(test_info, '$.testPath') IS NULL)");
373
- }
374
- query.orderBy("created_at", "DESC");
375
- const { sql, params } = query.build();
376
- const results = await this.operations.executeQuery({ sql, params });
377
- return isArrayOfRecords(results) ? results.map((row) => {
378
- const result = deserializeValue(row.result);
379
- const testInfo = row.test_info ? deserializeValue(row.test_info) : void 0;
380
- return {
381
- input: row.input || "",
382
- output: row.output || "",
383
- result,
384
- agentName: row.agent_name || "",
385
- metricName: row.metric_name || "",
386
- instructions: row.instructions || "",
387
- runId: row.run_id || "",
388
- globalRunId: row.global_run_id || "",
389
- createdAt: row.created_at || "",
390
- testInfo
391
- };
392
- }) : [];
393
- } catch (error$1) {
394
- const mastraError = new error.MastraError(
395
- {
396
- id: "CLOUDFLARE_D1_STORAGE_GET_EVALS_ERROR",
397
- domain: error.ErrorDomain.STORAGE,
398
- category: error.ErrorCategory.THIRD_PARTY,
399
- text: `Failed to retrieve evals for agent ${agentName}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
400
- details: { agentName }
401
- },
402
- error$1
403
- );
404
- this.logger?.error(mastraError.toString());
405
- this.logger?.trackException(mastraError);
406
- return [];
407
- }
408
- }
409
- };
261
+ // src/storage/domains/memory/index.ts
410
262
  var MemoryStorageD1 = class extends storage.MemoryStorage {
411
263
  operations;
412
264
  constructor({ operations }) {
@@ -554,39 +406,22 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
554
406
  return null;
555
407
  }
556
408
  }
557
- /**
558
- * @deprecated use getThreadsByResourceIdPaginated instead
559
- */
560
- async getThreadsByResourceId({ resourceId }) {
561
- const fullTableName = this.operations.getTableName(storage.TABLE_THREADS);
562
- try {
563
- const query = createSqlBuilder().select("*").from(fullTableName).where("resourceId = ?", resourceId);
564
- const { sql, params } = query.build();
565
- const results = await this.operations.executeQuery({ sql, params });
566
- return (isArrayOfRecords(results) ? results : []).map((thread) => ({
567
- ...thread,
568
- createdAt: storage.ensureDate(thread.createdAt),
569
- updatedAt: storage.ensureDate(thread.updatedAt),
570
- metadata: typeof thread.metadata === "string" ? JSON.parse(thread.metadata || "{}") : thread.metadata || {}
571
- }));
572
- } catch (error$1) {
573
- const mastraError = new error.MastraError(
409
+ async listThreadsByResourceId(args) {
410
+ const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
411
+ const perPage = storage.normalizePerPage(perPageInput, 100);
412
+ if (page < 0) {
413
+ throw new error.MastraError(
574
414
  {
575
- id: "CLOUDFLARE_D1_STORAGE_GET_THREADS_BY_RESOURCE_ID_ERROR",
415
+ id: "STORAGE_CLOUDFLARE_D1_LIST_THREADS_BY_RESOURCE_ID_INVALID_PAGE",
576
416
  domain: error.ErrorDomain.STORAGE,
577
- category: error.ErrorCategory.THIRD_PARTY,
578
- text: `Error getting threads by resourceId ${resourceId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
579
- details: { resourceId }
417
+ category: error.ErrorCategory.USER,
418
+ details: { page }
580
419
  },
581
- error$1
420
+ new Error("page must be >= 0")
582
421
  );
583
- this.logger?.error(mastraError.toString());
584
- this.logger?.trackException(mastraError);
585
- return [];
586
422
  }
587
- }
588
- async getThreadsByResourceIdPaginated(args) {
589
- const { resourceId, page, perPage } = args;
423
+ const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
424
+ const { field, direction } = this.parseOrderBy(orderBy);
590
425
  const fullTableName = this.operations.getTableName(storage.TABLE_THREADS);
591
426
  const mapRowToStorageThreadType = (row) => ({
592
427
  ...row,
@@ -598,20 +433,21 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
598
433
  const countQuery = createSqlBuilder().count().from(fullTableName).where("resourceId = ?", resourceId);
599
434
  const countResult = await this.operations.executeQuery(countQuery.build());
600
435
  const total = Number(countResult?.[0]?.count ?? 0);
601
- const selectQuery = createSqlBuilder().select("*").from(fullTableName).where("resourceId = ?", resourceId).orderBy("createdAt", "DESC").limit(perPage).offset(page * perPage);
436
+ const limitValue = perPageInput === false ? total : perPage;
437
+ const selectQuery = createSqlBuilder().select("*").from(fullTableName).where("resourceId = ?", resourceId).orderBy(field, direction).limit(limitValue).offset(offset);
602
438
  const results = await this.operations.executeQuery(selectQuery.build());
603
439
  const threads = results.map(mapRowToStorageThreadType);
604
440
  return {
605
441
  threads,
606
442
  total,
607
443
  page,
608
- perPage,
609
- hasMore: page * perPage + threads.length < total
444
+ perPage: perPageForResponse,
445
+ hasMore: perPageInput === false ? false : offset + perPage < total
610
446
  };
611
447
  } catch (error$1) {
612
448
  const mastraError = new error.MastraError(
613
449
  {
614
- id: "CLOUDFLARE_D1_STORAGE_GET_THREADS_BY_RESOURCE_ID_PAGINATED_ERROR",
450
+ id: "CLOUDFLARE_D1_STORAGE_LIST_THREADS_BY_RESOURCE_ID_ERROR",
615
451
  domain: error.ErrorDomain.STORAGE,
616
452
  category: error.ErrorCategory.THIRD_PARTY,
617
453
  text: `Error getting threads by resourceId ${resourceId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
@@ -625,7 +461,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
625
461
  threads: [],
626
462
  total: 0,
627
463
  page,
628
- perPage,
464
+ perPage: perPageForResponse,
629
465
  hasMore: false
630
466
  };
631
467
  }
@@ -735,8 +571,8 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
735
571
  }
736
572
  }
737
573
  async saveMessages(args) {
738
- const { messages, format = "v1" } = args;
739
- if (messages.length === 0) return [];
574
+ const { messages } = args;
575
+ if (messages.length === 0) return { messages: [] };
740
576
  try {
741
577
  const now = /* @__PURE__ */ new Date();
742
578
  const threadId = messages[0]?.threadId;
@@ -784,8 +620,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
784
620
  ]);
785
621
  this.logger.debug(`Saved ${messages.length} messages`);
786
622
  const list = new agent.MessageList().add(messages, "memory");
787
- if (format === `v2`) return list.get.all.v2();
788
- return list.get.all.v1();
623
+ return { messages: list.get.all.db() };
789
624
  } catch (error$1) {
790
625
  throw new error.MastraError(
791
626
  {
@@ -798,9 +633,8 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
798
633
  );
799
634
  }
800
635
  }
801
- async _getIncludedMessages(threadId, selectBy) {
636
+ async _getIncludedMessages(threadId, include) {
802
637
  if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
803
- const include = selectBy?.include;
804
638
  if (!include) return null;
805
639
  const unionQueries = [];
806
640
  const params = [];
@@ -856,74 +690,8 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
856
690
  });
857
691
  return processedMessages;
858
692
  }
859
- async getMessages({
860
- threadId,
861
- resourceId,
862
- selectBy,
863
- format
864
- }) {
865
- try {
866
- if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
867
- const fullTableName = this.operations.getTableName(storage.TABLE_MESSAGES);
868
- const limit = storage.resolveMessageLimit({
869
- last: selectBy?.last,
870
- defaultLimit: 40
871
- });
872
- const include = selectBy?.include || [];
873
- const messages = [];
874
- if (include.length) {
875
- const includeResult = await this._getIncludedMessages(threadId, selectBy);
876
- if (Array.isArray(includeResult)) messages.push(...includeResult);
877
- }
878
- const excludeIds = messages.map((m) => m.id);
879
- const query = createSqlBuilder().select(["id", "content", "role", "type", "createdAt", "thread_id AS threadId"]).from(fullTableName).where("thread_id = ?", threadId);
880
- if (excludeIds.length > 0) {
881
- query.andWhere(`id NOT IN (${excludeIds.map(() => "?").join(",")})`, ...excludeIds);
882
- }
883
- query.orderBy("createdAt", "DESC").limit(limit);
884
- const { sql, params } = query.build();
885
- const result = await this.operations.executeQuery({ sql, params });
886
- if (Array.isArray(result)) messages.push(...result);
887
- messages.sort((a, b) => {
888
- const aRecord = a;
889
- const bRecord = b;
890
- const timeA = new Date(aRecord.createdAt).getTime();
891
- const timeB = new Date(bRecord.createdAt).getTime();
892
- return timeA - timeB;
893
- });
894
- const processedMessages = messages.map((message) => {
895
- const processedMsg = {};
896
- for (const [key, value] of Object.entries(message)) {
897
- if (key === `type` && value === `v2`) continue;
898
- processedMsg[key] = deserializeValue(value);
899
- }
900
- return processedMsg;
901
- });
902
- this.logger.debug(`Retrieved ${messages.length} messages for thread ${threadId}`);
903
- const list = new agent.MessageList().add(processedMessages, "memory");
904
- if (format === `v2`) return list.get.all.v2();
905
- return list.get.all.v1();
906
- } catch (error$1) {
907
- const mastraError = new error.MastraError(
908
- {
909
- id: "CLOUDFLARE_D1_STORAGE_GET_MESSAGES_ERROR",
910
- domain: error.ErrorDomain.STORAGE,
911
- category: error.ErrorCategory.THIRD_PARTY,
912
- text: `Failed to retrieve messages for thread ${threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
913
- details: { threadId, resourceId: resourceId ?? "" }
914
- },
915
- error$1
916
- );
917
- this.logger?.error(mastraError.toString());
918
- this.logger?.trackException(mastraError);
919
- throw mastraError;
920
- }
921
- }
922
- async getMessagesById({
923
- messageIds,
924
- format
925
- }) {
926
- if (messageIds.length === 0) return [];
693
+ async listMessagesById({ messageIds }) {
694
+ if (messageIds.length === 0) return { messages: [] };
927
695
  const fullTableName = this.operations.getTableName(storage.TABLE_MESSAGES);
928
696
  const messages = [];
929
697
  try {
@@ -942,12 +710,11 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
942
710
  });
943
711
  this.logger.debug(`Retrieved ${messages.length} messages`);
944
712
  const list = new agent.MessageList().add(processedMessages, "memory");
945
- if (format === `v1`) return list.get.all.v1();
946
- return list.get.all.v2();
713
+ return { messages: list.get.all.db() };
947
714
  } catch (error$1) {
948
715
  const mastraError = new error.MastraError(
949
716
  {
950
- id: "CLOUDFLARE_D1_STORAGE_GET_MESSAGES_BY_ID_ERROR",
717
+ id: "CLOUDFLARE_D1_STORAGE_LIST_MESSAGES_BY_ID_ERROR",
951
718
  domain: error.ErrorDomain.STORAGE,
952
719
  category: error.ErrorCategory.THIRD_PARTY,
953
720
  text: `Failed to retrieve messages by ID: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
@@ -960,118 +727,157 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
960
727
  throw mastraError;
961
728
  }
962
729
  }
963
- async getMessagesPaginated({
964
- threadId,
965
- resourceId,
966
- selectBy,
967
- format
968
- }) {
969
- const { dateRange, page = 0, perPage: perPageInput } = selectBy?.pagination || {};
970
- const { start: fromDate, end: toDate } = dateRange || {};
971
- const perPage = perPageInput !== void 0 ? perPageInput : storage.resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
972
- const fullTableName = this.operations.getTableName(storage.TABLE_MESSAGES);
973
- const messages = [];
730
+ async listMessages(args) {
731
+ const { threadId, resourceId, include, filter, perPage: perPageInput, page = 0, orderBy } = args;
732
+ if (!threadId.trim()) {
733
+ throw new error.MastraError(
734
+ {
735
+ id: "STORAGE_CLOUDFLARE_D1_LIST_MESSAGES_INVALID_THREAD_ID",
736
+ domain: error.ErrorDomain.STORAGE,
737
+ category: error.ErrorCategory.THIRD_PARTY,
738
+ details: { threadId }
739
+ },
740
+ new Error("threadId must be a non-empty string")
741
+ );
742
+ }
743
+ if (page < 0) {
744
+ throw new error.MastraError(
745
+ {
746
+ id: "STORAGE_CLOUDFLARE_D1_LIST_MESSAGES_INVALID_PAGE",
747
+ domain: error.ErrorDomain.STORAGE,
748
+ category: error.ErrorCategory.USER,
749
+ details: { page }
750
+ },
751
+ new Error("page must be >= 0")
752
+ );
753
+ }
754
+ const perPage = storage.normalizePerPage(perPageInput, 40);
755
+ const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
974
756
  try {
975
- if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
976
- if (selectBy?.include?.length) {
977
- const includeResult = await this._getIncludedMessages(threadId, selectBy);
978
- if (Array.isArray(includeResult)) messages.push(...includeResult);
757
+ const fullTableName = this.operations.getTableName(storage.TABLE_MESSAGES);
758
+ let query = `
759
+ SELECT id, content, role, type, createdAt, thread_id AS threadId, resourceId
760
+ FROM ${fullTableName}
761
+ WHERE thread_id = ?
762
+ `;
763
+ const queryParams = [threadId];
764
+ if (resourceId) {
765
+ query += ` AND resourceId = ?`;
766
+ queryParams.push(resourceId);
979
767
  }
980
- const countQuery = createSqlBuilder().count().from(fullTableName).where("thread_id = ?", threadId);
981
- if (fromDate) {
982
- countQuery.andWhere("createdAt >= ?", storage.serializeDate(fromDate));
768
+ const dateRange = filter?.dateRange;
769
+ if (dateRange?.start) {
770
+ const startDate = dateRange.start instanceof Date ? storage.serializeDate(dateRange.start) : storage.serializeDate(new Date(dateRange.start));
771
+ query += ` AND createdAt >= ?`;
772
+ queryParams.push(startDate);
983
773
  }
984
- if (toDate) {
985
- countQuery.andWhere("createdAt <= ?", storage.serializeDate(toDate));
774
+ if (dateRange?.end) {
775
+ const endDate = dateRange.end instanceof Date ? storage.serializeDate(dateRange.end) : storage.serializeDate(new Date(dateRange.end));
776
+ query += ` AND createdAt <= ?`;
777
+ queryParams.push(endDate);
986
778
  }
987
- const countResult = await this.operations.executeQuery(countQuery.build());
779
+ const { field, direction } = this.parseOrderBy(orderBy, "ASC");
780
+ query += ` ORDER BY "${field}" ${direction}`;
781
+ if (perPage !== Number.MAX_SAFE_INTEGER) {
782
+ query += ` LIMIT ? OFFSET ?`;
783
+ queryParams.push(perPage, offset);
784
+ }
785
+ const results = await this.operations.executeQuery({ sql: query, params: queryParams });
786
+ const paginatedMessages = (isArrayOfRecords(results) ? results : []).map((message) => {
787
+ const processedMsg = {};
788
+ for (const [key, value] of Object.entries(message)) {
789
+ if (key === `type` && value === `v2`) continue;
790
+ processedMsg[key] = deserializeValue(value);
791
+ }
792
+ return processedMsg;
793
+ });
794
+ const paginatedCount = paginatedMessages.length;
795
+ let countQuery = `SELECT count() as count FROM ${fullTableName} WHERE thread_id = ?`;
796
+ const countParams = [threadId];
797
+ if (resourceId) {
798
+ countQuery += ` AND resourceId = ?`;
799
+ countParams.push(resourceId);
800
+ }
801
+ if (dateRange?.start) {
802
+ const startDate = dateRange.start instanceof Date ? storage.serializeDate(dateRange.start) : storage.serializeDate(new Date(dateRange.start));
803
+ countQuery += ` AND createdAt >= ?`;
804
+ countParams.push(startDate);
805
+ }
806
+ if (dateRange?.end) {
807
+ const endDate = dateRange.end instanceof Date ? storage.serializeDate(dateRange.end) : storage.serializeDate(new Date(dateRange.end));
808
+ countQuery += ` AND createdAt <= ?`;
809
+ countParams.push(endDate);
810
+ }
811
+ const countResult = await this.operations.executeQuery({ sql: countQuery, params: countParams });
988
812
  const total = Number(countResult[0]?.count ?? 0);
989
- if (total === 0 && messages.length === 0) {
813
+ if (total === 0 && paginatedCount === 0 && (!include || include.length === 0)) {
990
814
  return {
991
815
  messages: [],
992
816
  total: 0,
993
817
  page,
994
- perPage,
818
+ perPage: perPageForResponse,
995
819
  hasMore: false
996
820
  };
997
821
  }
998
- const excludeIds = messages.map((m) => m.id);
999
- const excludeCondition = excludeIds.length > 0 ? `AND id NOT IN (${excludeIds.map(() => "?").join(",")})` : "";
1000
- let query;
1001
- let queryParams = [threadId];
1002
- if (fromDate) {
1003
- queryParams.push(storage.serializeDate(fromDate));
1004
- }
1005
- if (toDate) {
1006
- queryParams.push(storage.serializeDate(toDate));
1007
- }
1008
- if (excludeIds.length > 0) {
1009
- queryParams.push(...excludeIds);
1010
- }
1011
- if (selectBy?.last && selectBy.last > 0) {
1012
- query = `
1013
- SELECT id, content, role, type, createdAt, thread_id AS threadId, resourceId
1014
- FROM ${fullTableName}
1015
- WHERE thread_id = ?
1016
- ${fromDate ? "AND createdAt >= ?" : ""}
1017
- ${toDate ? "AND createdAt <= ?" : ""}
1018
- ${excludeCondition}
1019
- ORDER BY createdAt DESC
1020
- LIMIT ?
1021
- `;
1022
- queryParams.push(selectBy.last);
1023
- } else {
1024
- query = `
1025
- SELECT id, content, role, type, createdAt, thread_id AS threadId, resourceId
1026
- FROM ${fullTableName}
1027
- WHERE thread_id = ?
1028
- ${fromDate ? "AND createdAt >= ?" : ""}
1029
- ${toDate ? "AND createdAt <= ?" : ""}
1030
- ${excludeCondition}
1031
- ORDER BY createdAt DESC
1032
- LIMIT ? OFFSET ?
1033
- `;
1034
- queryParams.push(perPage, page * perPage);
822
+ const messageIds = new Set(paginatedMessages.map((m) => m.id));
823
+ let includeMessages = [];
824
+ if (include && include.length > 0) {
825
+ const includeResult = await this._getIncludedMessages(threadId, include);
826
+ if (Array.isArray(includeResult)) {
827
+ includeMessages = includeResult;
828
+ for (const includeMsg of includeMessages) {
829
+ if (!messageIds.has(includeMsg.id)) {
830
+ paginatedMessages.push(includeMsg);
831
+ messageIds.add(includeMsg.id);
832
+ }
833
+ }
834
+ }
1035
835
  }
1036
- const results = await this.operations.executeQuery({ sql: query, params: queryParams });
1037
- const processedMessages = results.map((message) => {
1038
- const processedMsg = {};
1039
- for (const [key, value] of Object.entries(message)) {
1040
- if (key === `type` && value === `v2`) continue;
1041
- processedMsg[key] = deserializeValue(value);
836
+ const list = new agent.MessageList().add(paginatedMessages, "memory");
837
+ let finalMessages = list.get.all.db();
838
+ finalMessages = finalMessages.sort((a, b) => {
839
+ const isDateField = field === "createdAt" || field === "updatedAt";
840
+ const aValue = isDateField ? new Date(a[field]).getTime() : a[field];
841
+ const bValue = isDateField ? new Date(b[field]).getTime() : b[field];
842
+ if (aValue === bValue) {
843
+ return a.id.localeCompare(b.id);
1042
844
  }
1043
- return processedMsg;
845
+ if (typeof aValue === "number" && typeof bValue === "number") {
846
+ return direction === "ASC" ? aValue - bValue : bValue - aValue;
847
+ }
848
+ return direction === "ASC" ? String(aValue).localeCompare(String(bValue)) : String(bValue).localeCompare(String(aValue));
1044
849
  });
1045
- if (selectBy?.last) {
1046
- processedMessages.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
1047
- }
1048
- const list = new agent.MessageList().add(processedMessages, "memory");
1049
- messages.push(...format === `v2` ? list.get.all.v2() : list.get.all.v1());
850
+ const returnedThreadMessageIds = new Set(finalMessages.filter((m) => m.threadId === threadId).map((m) => m.id));
851
+ const allThreadMessagesReturned = returnedThreadMessageIds.size >= total;
852
+ const hasMore = perPageInput === false ? false : allThreadMessagesReturned ? false : offset + paginatedCount < total;
1050
853
  return {
1051
- messages,
854
+ messages: finalMessages,
1052
855
  total,
1053
856
  page,
1054
- perPage,
1055
- hasMore: selectBy?.last ? false : page * perPage + messages.length < total
857
+ perPage: perPageForResponse,
858
+ hasMore
1056
859
  };
1057
860
  } catch (error$1) {
1058
861
  const mastraError = new error.MastraError(
1059
862
  {
1060
- id: "CLOUDFLARE_D1_STORAGE_GET_MESSAGES_PAGINATED_ERROR",
863
+ id: "CLOUDFLARE_D1_STORAGE_LIST_MESSAGES_ERROR",
1061
864
  domain: error.ErrorDomain.STORAGE,
1062
865
  category: error.ErrorCategory.THIRD_PARTY,
1063
- text: `Failed to retrieve messages for thread ${threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
1064
- details: { threadId, resourceId: resourceId ?? "" }
866
+ text: `Failed to list messages for thread ${threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
867
+ details: {
868
+ threadId,
869
+ resourceId: resourceId ?? ""
870
+ }
1065
871
  },
1066
872
  error$1
1067
873
  );
1068
- this.logger?.error(mastraError.toString());
1069
- this.logger?.trackException(mastraError);
874
+ this.logger?.error?.(mastraError.toString());
875
+ this.logger?.trackException?.(mastraError);
1070
876
  return {
1071
877
  messages: [],
1072
878
  total: 0,
1073
879
  page,
1074
- perPage,
880
+ perPage: perPageForResponse,
1075
881
  hasMore: false
1076
882
  };
1077
883
  }
@@ -1572,7 +1378,7 @@ function transformScoreRow(row) {
1572
1378
  deserialized.analyzeStepResult = storage.safelyParseJSON(row.analyzeStepResult);
1573
1379
  deserialized.metadata = storage.safelyParseJSON(row.metadata);
1574
1380
  deserialized.additionalContext = storage.safelyParseJSON(row.additionalContext);
1575
- deserialized.runtimeContext = storage.safelyParseJSON(row.runtimeContext);
1381
+ deserialized.requestContext = storage.safelyParseJSON(row.requestContext);
1576
1382
  deserialized.entity = storage.safelyParseJSON(row.entity);
1577
1383
  deserialized.createdAt = row.createdAtZ || row.createdAt;
1578
1384
  deserialized.updatedAt = row.updatedAtZ || row.updatedAt;
@@ -1608,7 +1414,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
1608
1414
  async saveScore(score) {
1609
1415
  let parsedScore;
1610
1416
  try {
1611
- parsedScore = scores.saveScorePayloadSchema.parse(score);
1417
+ parsedScore = evals.saveScorePayloadSchema.parse(score);
1612
1418
  } catch (error$1) {
1613
1419
  throw new error.MastraError(
1614
1420
  {
@@ -1656,7 +1462,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
1656
1462
  );
1657
1463
  }
1658
1464
  }
1659
- async getScoresByScorerId({
1465
+ async listScoresByScorerId({
1660
1466
  scorerId,
1661
1467
  entityId,
1662
1468
  entityType,
@@ -1664,6 +1470,9 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
1664
1470
  pagination
1665
1471
  }) {
1666
1472
  try {
1473
+ const { page, perPage: perPageInput } = pagination;
1474
+ const perPage = storage.normalizePerPage(perPageInput, 100);
1475
+ const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
1667
1476
  const fullTableName = this.operations.getTableName(storage.TABLE_SCORERS);
1668
1477
  const countQuery = createSqlBuilder().count().from(fullTableName).where("scorerId = ?", scorerId);
1669
1478
  if (entityId) {
@@ -1681,13 +1490,15 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
1681
1490
  return {
1682
1491
  pagination: {
1683
1492
  total: 0,
1684
- page: pagination.page,
1685
- perPage: pagination.perPage,
1493
+ page,
1494
+ perPage: perPageForResponse,
1686
1495
  hasMore: false
1687
1496
  },
1688
1497
  scores: []
1689
1498
  };
1690
1499
  }
1500
+ const end = perPageInput === false ? total : start + perPage;
1501
+ const limitValue = perPageInput === false ? total : perPage;
1691
1502
  const selectQuery = createSqlBuilder().select("*").from(fullTableName).where("scorerId = ?", scorerId);
1692
1503
  if (entityId) {
1693
1504
  selectQuery.andWhere("entityId = ?", entityId);
@@ -1698,16 +1509,16 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
1698
1509
  if (source) {
1699
1510
  selectQuery.andWhere("source = ?", source);
1700
1511
  }
1701
- selectQuery.limit(pagination.perPage).offset(pagination.page * pagination.perPage);
1512
+ selectQuery.limit(limitValue).offset(start);
1702
1513
  const { sql, params } = selectQuery.build();
1703
1514
  const results = await this.operations.executeQuery({ sql, params });
1704
1515
  const scores = Array.isArray(results) ? results.map(transformScoreRow) : [];
1705
1516
  return {
1706
1517
  pagination: {
1707
1518
  total,
1708
- page: pagination.page,
1709
- perPage: pagination.perPage,
1710
- hasMore: total > (pagination.page + 1) * pagination.perPage
1519
+ page,
1520
+ perPage: perPageForResponse,
1521
+ hasMore: end < total
1711
1522
  },
1712
1523
  scores
1713
1524
  };
@@ -1722,11 +1533,14 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
1722
1533
  );
1723
1534
  }
1724
1535
  }
1725
- async getScoresByRunId({
1536
+ async listScoresByRunId({
1726
1537
  runId,
1727
1538
  pagination
1728
1539
  }) {
1729
1540
  try {
1541
+ const { page, perPage: perPageInput } = pagination;
1542
+ const perPage = storage.normalizePerPage(perPageInput, 100);
1543
+ const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
1730
1544
  const fullTableName = this.operations.getTableName(storage.TABLE_SCORERS);
1731
1545
  const countQuery = createSqlBuilder().count().from(fullTableName).where("runId = ?", runId);
1732
1546
  const countResult = await this.operations.executeQuery(countQuery.build());
@@ -1735,23 +1549,25 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
1735
1549
  return {
1736
1550
  pagination: {
1737
1551
  total: 0,
1738
- page: pagination.page,
1739
- perPage: pagination.perPage,
1552
+ page,
1553
+ perPage: perPageForResponse,
1740
1554
  hasMore: false
1741
1555
  },
1742
1556
  scores: []
1743
1557
  };
1744
1558
  }
1745
- const selectQuery = createSqlBuilder().select("*").from(fullTableName).where("runId = ?", runId).limit(pagination.perPage).offset(pagination.page * pagination.perPage);
1559
+ const end = perPageInput === false ? total : start + perPage;
1560
+ const limitValue = perPageInput === false ? total : perPage;
1561
+ const selectQuery = createSqlBuilder().select("*").from(fullTableName).where("runId = ?", runId).limit(limitValue).offset(start);
1746
1562
  const { sql, params } = selectQuery.build();
1747
1563
  const results = await this.operations.executeQuery({ sql, params });
1748
1564
  const scores = Array.isArray(results) ? results.map(transformScoreRow) : [];
1749
1565
  return {
1750
1566
  pagination: {
1751
1567
  total,
1752
- page: pagination.page,
1753
- perPage: pagination.perPage,
1754
- hasMore: total > (pagination.page + 1) * pagination.perPage
1568
+ page,
1569
+ perPage: perPageForResponse,
1570
+ hasMore: end < total
1755
1571
  },
1756
1572
  scores
1757
1573
  };
@@ -1766,12 +1582,15 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
1766
1582
  );
1767
1583
  }
1768
1584
  }
1769
- async getScoresByEntityId({
1585
+ async listScoresByEntityId({
1770
1586
  entityId,
1771
1587
  entityType,
1772
1588
  pagination
1773
1589
  }) {
1774
1590
  try {
1591
+ const { page, perPage: perPageInput } = pagination;
1592
+ const perPage = storage.normalizePerPage(perPageInput, 100);
1593
+ const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
1775
1594
  const fullTableName = this.operations.getTableName(storage.TABLE_SCORERS);
1776
1595
  const countQuery = createSqlBuilder().count().from(fullTableName).where("entityId = ?", entityId).andWhere("entityType = ?", entityType);
1777
1596
  const countResult = await this.operations.executeQuery(countQuery.build());
@@ -1780,23 +1599,25 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
1780
1599
  return {
1781
1600
  pagination: {
1782
1601
  total: 0,
1783
- page: pagination.page,
1784
- perPage: pagination.perPage,
1602
+ page,
1603
+ perPage: perPageForResponse,
1785
1604
  hasMore: false
1786
1605
  },
1787
1606
  scores: []
1788
1607
  };
1789
1608
  }
1790
- const selectQuery = createSqlBuilder().select("*").from(fullTableName).where("entityId = ?", entityId).andWhere("entityType = ?", entityType).limit(pagination.perPage).offset(pagination.page * pagination.perPage);
1609
+ const end = perPageInput === false ? total : start + perPage;
1610
+ const limitValue = perPageInput === false ? total : perPage;
1611
+ const selectQuery = createSqlBuilder().select("*").from(fullTableName).where("entityId = ?", entityId).andWhere("entityType = ?", entityType).limit(limitValue).offset(start);
1791
1612
  const { sql, params } = selectQuery.build();
1792
1613
  const results = await this.operations.executeQuery({ sql, params });
1793
1614
  const scores = Array.isArray(results) ? results.map(transformScoreRow) : [];
1794
1615
  return {
1795
1616
  pagination: {
1796
1617
  total,
1797
- page: pagination.page,
1798
- perPage: pagination.perPage,
1799
- hasMore: total > (pagination.page + 1) * pagination.perPage
1618
+ page,
1619
+ perPage: perPageForResponse,
1620
+ hasMore: end < total
1800
1621
  },
1801
1622
  scores
1802
1623
  };
@@ -1811,12 +1632,15 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
1811
1632
  );
1812
1633
  }
1813
1634
  }
1814
- async getScoresBySpan({
1635
+ async listScoresBySpan({
1815
1636
  traceId,
1816
1637
  spanId,
1817
1638
  pagination
1818
1639
  }) {
1819
1640
  try {
1641
+ const { page, perPage: perPageInput } = pagination;
1642
+ const perPage = storage.normalizePerPage(perPageInput, 100);
1643
+ const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
1820
1644
  const fullTableName = this.operations.getTableName(storage.TABLE_SCORERS);
1821
1645
  const countQuery = createSqlBuilder().count().from(fullTableName).where("traceId = ?", traceId).andWhere("spanId = ?", spanId);
1822
1646
  const countResult = await this.operations.executeQuery(countQuery.build());
@@ -1825,25 +1649,25 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
1825
1649
  return {
1826
1650
  pagination: {
1827
1651
  total: 0,
1828
- page: pagination.page,
1829
- perPage: pagination.perPage,
1652
+ page,
1653
+ perPage: perPageForResponse,
1830
1654
  hasMore: false
1831
1655
  },
1832
1656
  scores: []
1833
1657
  };
1834
1658
  }
1835
- const limit = pagination.perPage + 1;
1836
- const selectQuery = createSqlBuilder().select("*").from(fullTableName).where("traceId = ?", traceId).andWhere("spanId = ?", spanId).orderBy("createdAt", "DESC").limit(limit).offset(pagination.page * pagination.perPage);
1659
+ const end = perPageInput === false ? total : start + perPage;
1660
+ const limitValue = perPageInput === false ? total : perPage;
1661
+ const selectQuery = createSqlBuilder().select("*").from(fullTableName).where("traceId = ?", traceId).andWhere("spanId = ?", spanId).orderBy("createdAt", "DESC").limit(limitValue).offset(start);
1837
1662
  const { sql, params } = selectQuery.build();
1838
1663
  const results = await this.operations.executeQuery({ sql, params });
1839
- const rows = Array.isArray(results) ? results : [];
1840
- const scores = rows.slice(0, pagination.perPage).map(transformScoreRow);
1664
+ const scores = Array.isArray(results) ? results.map(transformScoreRow) : [];
1841
1665
  return {
1842
1666
  pagination: {
1843
1667
  total,
1844
- page: pagination.page,
1845
- perPage: pagination.perPage,
1846
- hasMore: rows.length > pagination.perPage
1668
+ page,
1669
+ perPage: perPageForResponse,
1670
+ hasMore: end < total
1847
1671
  },
1848
1672
  scores
1849
1673
  };
@@ -1870,7 +1694,7 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
1870
1694
  // runId,
1871
1695
  // stepId,
1872
1696
  // result,
1873
- // runtimeContext,
1697
+ // requestContext,
1874
1698
  }) {
1875
1699
  throw new Error("Method not implemented.");
1876
1700
  }
@@ -1974,19 +1798,24 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
1974
1798
  resourceId: row.resourceId
1975
1799
  };
1976
1800
  }
1977
- async getWorkflowRuns({
1801
+ async listWorkflowRuns({
1978
1802
  workflowName,
1979
1803
  fromDate,
1980
1804
  toDate,
1981
- limit,
1982
- offset,
1983
- resourceId
1805
+ page,
1806
+ perPage,
1807
+ resourceId,
1808
+ status
1984
1809
  } = {}) {
1985
1810
  const fullTableName = this.operations.getTableName(storage.TABLE_WORKFLOW_SNAPSHOT);
1986
1811
  try {
1987
1812
  const builder = createSqlBuilder().select().from(fullTableName);
1988
1813
  const countBuilder = createSqlBuilder().count().from(fullTableName);
1989
1814
  if (workflowName) builder.whereAnd("workflow_name = ?", workflowName);
1815
+ if (status) {
1816
+ builder.whereAnd("json_extract(snapshot, '$.status') = ?", status);
1817
+ countBuilder.whereAnd("json_extract(snapshot, '$.status') = ?", status);
1818
+ }
1990
1819
  if (resourceId) {
1991
1820
  const hasResourceId = await this.operations.hasColumn(fullTableName, "resourceId");
1992
1821
  if (hasResourceId) {
@@ -2005,11 +1834,14 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
2005
1834
  countBuilder.whereAnd("createdAt <= ?", toDate instanceof Date ? toDate.toISOString() : toDate);
2006
1835
  }
2007
1836
  builder.orderBy("createdAt", "DESC");
2008
- if (typeof limit === "number") builder.limit(limit);
2009
- if (typeof offset === "number") builder.offset(offset);
1837
+ if (typeof perPage === "number" && typeof page === "number") {
1838
+ const offset = page * perPage;
1839
+ builder.limit(perPage);
1840
+ builder.offset(offset);
1841
+ }
2010
1842
  const { sql, params } = builder.build();
2011
1843
  let total = 0;
2012
- if (limit !== void 0 && offset !== void 0) {
1844
+ if (perPage !== void 0 && page !== void 0) {
2013
1845
  const { sql: countSql, params: countParams } = countBuilder.build();
2014
1846
  const countResult = await this.operations.executeQuery({
2015
1847
  sql: countSql,
@@ -2024,7 +1856,7 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
2024
1856
  } catch (error$1) {
2025
1857
  throw new error.MastraError(
2026
1858
  {
2027
- id: "CLOUDFLARE_D1_STORAGE_GET_WORKFLOW_RUNS_ERROR",
1859
+ id: "CLOUDFLARE_D1_STORAGE_LIST_WORKFLOW_RUNS_ERROR",
2028
1860
  domain: error.ErrorDomain.STORAGE,
2029
1861
  category: error.ErrorCategory.THIRD_PARTY,
2030
1862
  text: `Failed to retrieve workflow runs: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
@@ -2086,7 +1918,7 @@ var D1Store = class extends storage.MastraStorage {
2086
1918
  */
2087
1919
  constructor(config) {
2088
1920
  try {
2089
- super({ name: "D1" });
1921
+ super({ id: config.id, name: "D1" });
2090
1922
  if (config.tablePrefix && !/^[a-zA-Z0-9_]*$/.test(config.tablePrefix)) {
2091
1923
  throw new Error("Invalid tablePrefix: only letters, numbers, and underscores are allowed.");
2092
1924
  }
@@ -2140,9 +1972,6 @@ var D1Store = class extends storage.MastraStorage {
2140
1972
  const scores = new ScoresStorageD1({
2141
1973
  operations
2142
1974
  });
2143
- const legacyEvals = new LegacyEvalsStorageD1({
2144
- operations
2145
- });
2146
1975
  const workflows = new WorkflowsStorageD1({
2147
1976
  operations
2148
1977
  });
@@ -2152,7 +1981,6 @@ var D1Store = class extends storage.MastraStorage {
2152
1981
  this.stores = {
2153
1982
  operations,
2154
1983
  scores,
2155
- legacyEvals,
2156
1984
  workflows,
2157
1985
  memory
2158
1986
  };
@@ -2164,7 +1992,7 @@ var D1Store = class extends storage.MastraStorage {
2164
1992
  hasColumn: true,
2165
1993
  createTable: true,
2166
1994
  deleteMessages: false,
2167
- getScoresBySpan: true
1995
+ listScoresBySpan: true
2168
1996
  };
2169
1997
  }
2170
1998
  async createTable({
@@ -2204,15 +2032,6 @@ var D1Store = class extends storage.MastraStorage {
2204
2032
  async getThreadById({ threadId }) {
2205
2033
  return this.stores.memory.getThreadById({ threadId });
2206
2034
  }
2207
- /**
2208
- * @deprecated use getThreadsByResourceIdPaginated instead
2209
- */
2210
- async getThreadsByResourceId({ resourceId }) {
2211
- return this.stores.memory.getThreadsByResourceId({ resourceId });
2212
- }
2213
- async getThreadsByResourceIdPaginated(args) {
2214
- return this.stores.memory.getThreadsByResourceIdPaginated(args);
2215
- }
2216
2035
  async saveThread({ thread }) {
2217
2036
  return this.stores.memory.saveThread({ thread });
2218
2037
  }
@@ -2229,34 +2048,14 @@ var D1Store = class extends storage.MastraStorage {
2229
2048
  async saveMessages(args) {
2230
2049
  return this.stores.memory.saveMessages(args);
2231
2050
  }
2232
- async getMessages({
2233
- threadId,
2234
- selectBy,
2235
- format
2236
- }) {
2237
- return this.stores.memory.getMessages({ threadId, selectBy, format });
2238
- }
2239
- async getMessagesById({
2240
- messageIds,
2241
- format
2242
- }) {
2243
- return this.stores.memory.getMessagesById({ messageIds, format });
2244
- }
2245
- async getMessagesPaginated({
2246
- threadId,
2247
- selectBy,
2248
- format
2249
- }) {
2250
- return this.stores.memory.getMessagesPaginated({ threadId, selectBy, format });
2251
- }
2252
2051
  async updateWorkflowResults({
2253
2052
  workflowName,
2254
2053
  runId,
2255
2054
  stepId,
2256
2055
  result,
2257
- runtimeContext
2056
+ requestContext
2258
2057
  }) {
2259
- return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, runtimeContext });
2058
+ return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, requestContext });
2260
2059
  }
2261
2060
  async updateWorkflowState({
2262
2061
  workflowName,
@@ -2276,15 +2075,8 @@ var D1Store = class extends storage.MastraStorage {
2276
2075
  async loadWorkflowSnapshot(params) {
2277
2076
  return this.stores.workflows.loadWorkflowSnapshot(params);
2278
2077
  }
2279
- async getWorkflowRuns({
2280
- workflowName,
2281
- fromDate,
2282
- toDate,
2283
- limit,
2284
- offset,
2285
- resourceId
2286
- } = {}) {
2287
- return this.stores.workflows.getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId });
2078
+ async listWorkflowRuns(args = {}) {
2079
+ return this.stores.workflows.listWorkflowRuns(args);
2288
2080
  }
2289
2081
  async getWorkflowRunById({
2290
2082
  runId,
@@ -2300,15 +2092,6 @@ var D1Store = class extends storage.MastraStorage {
2300
2092
  async batchInsert({ tableName, records }) {
2301
2093
  return this.stores.operations.batchInsert({ tableName, records });
2302
2094
  }
2303
- /**
2304
- * @deprecated use getEvals instead
2305
- */
2306
- async getEvalsByAgentName(agentName, type) {
2307
- return this.stores.legacyEvals.getEvalsByAgentName(agentName, type);
2308
- }
2309
- async getEvals(options) {
2310
- return this.stores.legacyEvals.getEvals(options);
2311
- }
2312
2095
  async updateMessages(_args) {
2313
2096
  return this.stores.memory.updateMessages(_args);
2314
2097
  }
@@ -2331,38 +2114,38 @@ var D1Store = class extends storage.MastraStorage {
2331
2114
  async saveScore(_score) {
2332
2115
  return this.stores.scores.saveScore(_score);
2333
2116
  }
2334
- async getScoresByRunId({
2117
+ async listScoresByRunId({
2335
2118
  runId: _runId,
2336
2119
  pagination: _pagination
2337
2120
  }) {
2338
- return this.stores.scores.getScoresByRunId({ runId: _runId, pagination: _pagination });
2121
+ return this.stores.scores.listScoresByRunId({ runId: _runId, pagination: _pagination });
2339
2122
  }
2340
- async getScoresByEntityId({
2123
+ async listScoresByEntityId({
2341
2124
  entityId: _entityId,
2342
2125
  entityType: _entityType,
2343
2126
  pagination: _pagination
2344
2127
  }) {
2345
- return this.stores.scores.getScoresByEntityId({
2128
+ return this.stores.scores.listScoresByEntityId({
2346
2129
  entityId: _entityId,
2347
2130
  entityType: _entityType,
2348
2131
  pagination: _pagination
2349
2132
  });
2350
2133
  }
2351
- async getScoresByScorerId({
2134
+ async listScoresByScorerId({
2352
2135
  scorerId,
2353
2136
  pagination,
2354
2137
  entityId,
2355
2138
  entityType,
2356
2139
  source
2357
2140
  }) {
2358
- return this.stores.scores.getScoresByScorerId({ scorerId, pagination, entityId, entityType, source });
2141
+ return this.stores.scores.listScoresByScorerId({ scorerId, pagination, entityId, entityType, source });
2359
2142
  }
2360
- async getScoresBySpan({
2143
+ async listScoresBySpan({
2361
2144
  traceId,
2362
2145
  spanId,
2363
2146
  pagination
2364
2147
  }) {
2365
- return this.stores.scores.getScoresBySpan({ traceId, spanId, pagination });
2148
+ return this.stores.scores.listScoresBySpan({ traceId, spanId, pagination });
2366
2149
  }
2367
2150
  /**
2368
2151
  * Close the database connection