@mastra/lance 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/dist/index.js CHANGED
@@ -1,132 +1,17 @@
1
1
  import { connect, Index } from '@lancedb/lancedb';
2
2
  import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
3
- import { MastraStorage, StoreOperations, LegacyEvalsStorage, TABLE_EVALS, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, resolveMessageLimit, TABLE_RESOURCES, ScoresStorage, TABLE_SCORERS, TracesStorage, TABLE_TRACES, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ensureDate } from '@mastra/core/storage';
3
+ import { MastraStorage, StoreOperations, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, resolveMessageLimit, TABLE_RESOURCES, ScoresStorage, TABLE_SCORERS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ensureDate } from '@mastra/core/storage';
4
4
  import { MessageList } from '@mastra/core/agent';
5
5
  import { Utf8, Float64, Binary, Float32, Int32, Field, Schema } from 'apache-arrow';
6
+ import { saveScorePayloadSchema } from '@mastra/core/scores';
6
7
  import { MastraVector } from '@mastra/core/vector';
7
8
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
8
9
 
9
10
  // src/storage/index.ts
10
- var StoreLegacyEvalsLance = class extends LegacyEvalsStorage {
11
- client;
12
- constructor({ client }) {
13
- super();
14
- this.client = client;
15
- }
16
- async getEvalsByAgentName(agentName, type) {
17
- try {
18
- const table = await this.client.openTable(TABLE_EVALS);
19
- const query = table.query().where(`agent_name = '${agentName}'`);
20
- const records = await query.toArray();
21
- let filteredRecords = records;
22
- if (type === "live") {
23
- filteredRecords = records.filter((record) => record.test_info === null);
24
- } else if (type === "test") {
25
- filteredRecords = records.filter((record) => record.test_info !== null);
26
- }
27
- return filteredRecords.map((record) => {
28
- return {
29
- id: record.id,
30
- input: record.input,
31
- output: record.output,
32
- agentName: record.agent_name,
33
- metricName: record.metric_name,
34
- result: JSON.parse(record.result),
35
- instructions: record.instructions,
36
- testInfo: record.test_info ? JSON.parse(record.test_info) : null,
37
- globalRunId: record.global_run_id,
38
- runId: record.run_id,
39
- createdAt: new Date(record.created_at).toString()
40
- };
41
- });
42
- } catch (error) {
43
- throw new MastraError(
44
- {
45
- id: "LANCE_STORE_GET_EVALS_BY_AGENT_NAME_FAILED",
46
- domain: ErrorDomain.STORAGE,
47
- category: ErrorCategory.THIRD_PARTY,
48
- details: { agentName }
49
- },
50
- error
51
- );
52
- }
53
- }
54
- async getEvals(options) {
55
- try {
56
- const table = await this.client.openTable(TABLE_EVALS);
57
- const conditions = [];
58
- if (options.agentName) {
59
- conditions.push(`agent_name = '${options.agentName}'`);
60
- }
61
- if (options.type === "live") {
62
- conditions.push("length(test_info) = 0");
63
- } else if (options.type === "test") {
64
- conditions.push("length(test_info) > 0");
65
- }
66
- const startDate = options.dateRange?.start || options.fromDate;
67
- const endDate = options.dateRange?.end || options.toDate;
68
- if (startDate) {
69
- conditions.push(`\`created_at\` >= ${startDate.getTime()}`);
70
- }
71
- if (endDate) {
72
- conditions.push(`\`created_at\` <= ${endDate.getTime()}`);
73
- }
74
- let total = 0;
75
- if (conditions.length > 0) {
76
- total = await table.countRows(conditions.join(" AND "));
77
- } else {
78
- total = await table.countRows();
79
- }
80
- const query = table.query();
81
- if (conditions.length > 0) {
82
- const whereClause = conditions.join(" AND ");
83
- query.where(whereClause);
84
- }
85
- const records = await query.toArray();
86
- const evals = records.sort((a, b) => b.created_at - a.created_at).map((record) => {
87
- return {
88
- id: record.id,
89
- input: record.input,
90
- output: record.output,
91
- agentName: record.agent_name,
92
- metricName: record.metric_name,
93
- result: JSON.parse(record.result),
94
- instructions: record.instructions,
95
- testInfo: record.test_info ? JSON.parse(record.test_info) : null,
96
- globalRunId: record.global_run_id,
97
- runId: record.run_id,
98
- createdAt: new Date(record.created_at).toISOString()
99
- };
100
- });
101
- const page = options.page || 0;
102
- const perPage = options.perPage || 10;
103
- const pagedEvals = evals.slice(page * perPage, (page + 1) * perPage);
104
- return {
105
- evals: pagedEvals,
106
- total,
107
- page,
108
- perPage,
109
- hasMore: total > (page + 1) * perPage
110
- };
111
- } catch (error) {
112
- throw new MastraError(
113
- {
114
- id: "LANCE_STORE_GET_EVALS_FAILED",
115
- domain: ErrorDomain.STORAGE,
116
- category: ErrorCategory.THIRD_PARTY,
117
- details: { agentName: options.agentName ?? "" }
118
- },
119
- error
120
- );
121
- }
122
- }
123
- };
124
11
  function getPrimaryKeys(tableName) {
125
12
  let primaryId = ["id"];
126
13
  if (tableName === TABLE_WORKFLOW_SNAPSHOT) {
127
14
  primaryId = ["workflow_name", "run_id"];
128
- } else if (tableName === TABLE_EVALS) {
129
- primaryId = ["agent_name", "metric_name", "run_id"];
130
15
  }
131
16
  return primaryId;
132
17
  }
@@ -187,7 +72,6 @@ function processResultWithTypeConversion(rawResult, tableSchema) {
187
72
  } else if (fieldTypeStr.includes("float64") && ["createdAt", "updatedAt"].includes(key)) {
188
73
  processedResult[key] = new Date(processedResult[key]);
189
74
  }
190
- console.log(key, "processedResult", processedResult);
191
75
  }
192
76
  return processedResult;
193
77
  }
@@ -452,10 +336,7 @@ var StoreMemoryLance = class extends MemoryStorage {
452
336
  );
453
337
  }
454
338
  }
455
- async getMessagesById({
456
- messageIds,
457
- format
458
- }) {
339
+ async listMessagesById({ messageIds }) {
459
340
  if (messageIds.length === 0) return [];
460
341
  try {
461
342
  const table = await this.client.openTable(TABLE_MESSAGES);
@@ -466,7 +347,6 @@ var StoreMemoryLance = class extends MemoryStorage {
466
347
  await getTableSchema({ tableName: TABLE_MESSAGES, client: this.client })
467
348
  );
468
349
  const list = new MessageList().add(messages.map(this.normalizeMessage), "memory");
469
- if (format === `v1`) return list.get.all.v1();
470
350
  return list.get.all.v2();
471
351
  } catch (error) {
472
352
  throw new MastraError(
@@ -482,6 +362,138 @@ var StoreMemoryLance = class extends MemoryStorage {
482
362
  );
483
363
  }
484
364
  }
365
+ async listMessages(args) {
366
+ const { threadId, resourceId, include, filter, limit, offset = 0, orderBy } = args;
367
+ if (!threadId.trim()) {
368
+ throw new MastraError(
369
+ {
370
+ id: "STORAGE_LANCE_LIST_MESSAGES_INVALID_THREAD_ID",
371
+ domain: ErrorDomain.STORAGE,
372
+ category: ErrorCategory.THIRD_PARTY,
373
+ details: { threadId }
374
+ },
375
+ new Error("threadId must be a non-empty string")
376
+ );
377
+ }
378
+ try {
379
+ let perPage = 40;
380
+ if (limit !== void 0) {
381
+ if (limit === false) {
382
+ perPage = Number.MAX_SAFE_INTEGER;
383
+ } else if (limit === 0) {
384
+ perPage = 0;
385
+ } else if (typeof limit === "number" && limit > 0) {
386
+ perPage = limit;
387
+ }
388
+ }
389
+ const page = perPage === 0 ? 0 : Math.floor(offset / perPage);
390
+ const sortField = orderBy?.field || "createdAt";
391
+ const sortDirection = orderBy?.direction || "DESC";
392
+ const table = await this.client.openTable(TABLE_MESSAGES);
393
+ const escapeSql = (str) => str.replace(/'/g, "''");
394
+ const conditions = [`thread_id = '${escapeSql(threadId)}'`];
395
+ if (resourceId) {
396
+ conditions.push(`\`resourceId\` = '${escapeSql(resourceId)}'`);
397
+ }
398
+ if (filter?.dateRange?.start) {
399
+ const startTime = filter.dateRange.start instanceof Date ? filter.dateRange.start.getTime() : new Date(filter.dateRange.start).getTime();
400
+ conditions.push(`\`createdAt\` >= ${startTime}`);
401
+ }
402
+ if (filter?.dateRange?.end) {
403
+ const endTime = filter.dateRange.end instanceof Date ? filter.dateRange.end.getTime() : new Date(filter.dateRange.end).getTime();
404
+ conditions.push(`\`createdAt\` <= ${endTime}`);
405
+ }
406
+ const whereClause = conditions.join(" AND ");
407
+ const total = await table.countRows(whereClause);
408
+ const query = table.query().where(whereClause);
409
+ let allRecords = await query.toArray();
410
+ allRecords.sort((a, b) => {
411
+ const aValue = sortField === "createdAt" ? a.createdAt : a[sortField];
412
+ const bValue = sortField === "createdAt" ? b.createdAt : b[sortField];
413
+ return sortDirection === "ASC" ? aValue - bValue : bValue - aValue;
414
+ });
415
+ const paginatedRecords = allRecords.slice(offset, offset + perPage);
416
+ const messages = paginatedRecords.map((row) => this.normalizeMessage(row));
417
+ if (total === 0 && messages.length === 0) {
418
+ return {
419
+ messages: [],
420
+ total: 0,
421
+ page,
422
+ perPage,
423
+ hasMore: false
424
+ };
425
+ }
426
+ const messageIds = new Set(messages.map((m) => m.id));
427
+ if (include && include.length > 0) {
428
+ const threadIds = [...new Set(include.map((item) => item.threadId || threadId))];
429
+ const allThreadMessages = [];
430
+ for (const tid of threadIds) {
431
+ const threadQuery = table.query().where(`thread_id = '${tid}'`);
432
+ let threadRecords = await threadQuery.toArray();
433
+ allThreadMessages.push(...threadRecords);
434
+ }
435
+ allThreadMessages.sort((a, b) => a.createdAt - b.createdAt);
436
+ const contextMessages = this.processMessagesWithContext(allThreadMessages, include);
437
+ const includedMessages = contextMessages.map((row) => this.normalizeMessage(row));
438
+ for (const includeMsg of includedMessages) {
439
+ if (!messageIds.has(includeMsg.id)) {
440
+ messages.push(includeMsg);
441
+ messageIds.add(includeMsg.id);
442
+ }
443
+ }
444
+ }
445
+ const list = new MessageList().add(messages, "memory");
446
+ let finalMessages = list.get.all.v2();
447
+ finalMessages = finalMessages.sort((a, b) => {
448
+ const aValue = sortField === "createdAt" ? new Date(a.createdAt).getTime() : a[sortField];
449
+ const bValue = sortField === "createdAt" ? new Date(b.createdAt).getTime() : b[sortField];
450
+ return sortDirection === "ASC" ? aValue - bValue : bValue - aValue;
451
+ });
452
+ const returnedThreadMessageIds = new Set(finalMessages.filter((m) => m.threadId === threadId).map((m) => m.id));
453
+ const allThreadMessagesReturned = returnedThreadMessageIds.size >= total;
454
+ const hasMore = limit === false ? false : allThreadMessagesReturned ? false : offset + paginatedRecords.length < total;
455
+ return {
456
+ messages: finalMessages,
457
+ total,
458
+ page,
459
+ perPage,
460
+ hasMore
461
+ };
462
+ } catch (error) {
463
+ const errorPerPage = limit === false ? Number.MAX_SAFE_INTEGER : limit === 0 ? 0 : limit || 40;
464
+ const mastraError = new MastraError(
465
+ {
466
+ id: "LANCE_STORE_LIST_MESSAGES_FAILED",
467
+ domain: ErrorDomain.STORAGE,
468
+ category: ErrorCategory.THIRD_PARTY,
469
+ details: {
470
+ threadId,
471
+ resourceId: resourceId ?? ""
472
+ }
473
+ },
474
+ error
475
+ );
476
+ this.logger?.error?.(mastraError.toString());
477
+ this.logger?.trackException?.(mastraError);
478
+ return {
479
+ messages: [],
480
+ total: 0,
481
+ page: errorPerPage === 0 ? 0 : Math.floor(offset / errorPerPage),
482
+ perPage: errorPerPage,
483
+ hasMore: false
484
+ };
485
+ }
486
+ }
487
+ /**
488
+ * @todo When migrating from getThreadsByResourceIdPaginated to this method,
489
+ * implement orderBy and sortDirection support for full sorting capabilities
490
+ */
491
+ async listThreadsByResourceId(args) {
492
+ const { resourceId, limit, offset } = args;
493
+ const page = Math.floor(offset / limit);
494
+ const perPage = limit;
495
+ return this.getThreadsByResourceIdPaginated({ resourceId, page, perPage });
496
+ }
485
497
  async saveMessages(args) {
486
498
  try {
487
499
  const { messages, format = "v1" } = args;
@@ -1264,7 +1276,7 @@ var StoreOperationsLance = class extends StoreOperations {
1264
1276
  processedRecord[key] = JSON.stringify(processedRecord[key]);
1265
1277
  }
1266
1278
  }
1267
- console.log(await table.schema());
1279
+ console.info(await table.schema());
1268
1280
  await table.mergeInsert(primaryId).whenMatchedUpdateAll().whenNotMatchedInsertAll().execute([processedRecord]);
1269
1281
  } catch (error) {
1270
1282
  throw new MastraError(
@@ -1314,7 +1326,6 @@ var StoreOperationsLance = class extends StoreOperations {
1314
1326
  }
1315
1327
  return processedRecord;
1316
1328
  });
1317
- console.log(processedRecords);
1318
1329
  await table.mergeInsert(primaryId).whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(processedRecords);
1319
1330
  } catch (error) {
1320
1331
  throw new MastraError(
@@ -1398,13 +1409,27 @@ var StoreScoresLance = class extends ScoresStorage {
1398
1409
  this.client = client;
1399
1410
  }
1400
1411
  async saveScore(score) {
1412
+ let validatedScore;
1413
+ try {
1414
+ validatedScore = saveScorePayloadSchema.parse(score);
1415
+ } catch (error) {
1416
+ throw new MastraError(
1417
+ {
1418
+ id: "LANCE_STORAGE_SAVE_SCORE_FAILED",
1419
+ text: "Failed to save score in LanceStorage",
1420
+ domain: ErrorDomain.STORAGE,
1421
+ category: ErrorCategory.THIRD_PARTY
1422
+ },
1423
+ error
1424
+ );
1425
+ }
1401
1426
  try {
1402
1427
  const id = crypto.randomUUID();
1403
1428
  const table = await this.client.openTable(TABLE_SCORERS);
1404
1429
  const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
1405
1430
  const allowedFields = new Set(schema.fields.map((f) => f.name));
1406
1431
  const filteredScore = {};
1407
- Object.keys(score).forEach((key) => {
1432
+ Object.keys(validatedScore).forEach((key) => {
1408
1433
  if (allowedFields.has(key)) {
1409
1434
  filteredScore[key] = score[key];
1410
1435
  }
@@ -1580,198 +1605,44 @@ var StoreScoresLance = class extends ScoresStorage {
1580
1605
  );
1581
1606
  }
1582
1607
  }
1583
- };
1584
- var StoreTracesLance = class extends TracesStorage {
1585
- client;
1586
- operations;
1587
- constructor({ client, operations }) {
1588
- super();
1589
- this.client = client;
1590
- this.operations = operations;
1591
- }
1592
- async saveTrace({ trace }) {
1593
- try {
1594
- const table = await this.client.openTable(TABLE_TRACES);
1595
- const record = {
1596
- ...trace,
1597
- attributes: JSON.stringify(trace.attributes),
1598
- status: JSON.stringify(trace.status),
1599
- events: JSON.stringify(trace.events),
1600
- links: JSON.stringify(trace.links),
1601
- other: JSON.stringify(trace.other)
1602
- };
1603
- await table.add([record], { mode: "append" });
1604
- return trace;
1605
- } catch (error) {
1606
- throw new MastraError(
1607
- {
1608
- id: "LANCE_STORE_SAVE_TRACE_FAILED",
1609
- domain: ErrorDomain.STORAGE,
1610
- category: ErrorCategory.THIRD_PARTY
1611
- },
1612
- error
1613
- );
1614
- }
1615
- }
1616
- async getTraceById({ traceId }) {
1617
- try {
1618
- const table = await this.client.openTable(TABLE_TRACES);
1619
- const query = table.query().where(`id = '${traceId}'`);
1620
- const records = await query.toArray();
1621
- return records[0];
1622
- } catch (error) {
1623
- throw new MastraError(
1624
- {
1625
- id: "LANCE_STORE_GET_TRACE_BY_ID_FAILED",
1626
- domain: ErrorDomain.STORAGE,
1627
- category: ErrorCategory.THIRD_PARTY
1628
- },
1629
- error
1630
- );
1631
- }
1632
- }
1633
- async getTraces({
1634
- name,
1635
- scope,
1636
- page = 1,
1637
- perPage = 10,
1638
- attributes
1608
+ async getScoresBySpan({
1609
+ traceId,
1610
+ spanId,
1611
+ pagination
1639
1612
  }) {
1640
1613
  try {
1641
- const table = await this.client.openTable(TABLE_TRACES);
1642
- const query = table.query();
1643
- if (name) {
1644
- query.where(`name = '${name}'`);
1645
- }
1646
- if (scope) {
1647
- query.where(`scope = '${scope}'`);
1648
- }
1649
- if (attributes) {
1650
- query.where(`attributes = '${JSON.stringify(attributes)}'`);
1651
- }
1652
- const offset = (page - 1) * perPage;
1653
- query.limit(perPage);
1654
- if (offset > 0) {
1655
- query.offset(offset);
1656
- }
1657
- const records = await query.toArray();
1658
- return records.map((record) => {
1659
- const processed = {
1660
- ...record,
1661
- attributes: record.attributes ? JSON.parse(record.attributes) : {},
1662
- status: record.status ? JSON.parse(record.status) : {},
1663
- events: record.events ? JSON.parse(record.events) : [],
1664
- links: record.links ? JSON.parse(record.links) : [],
1665
- other: record.other ? JSON.parse(record.other) : {},
1666
- startTime: new Date(record.startTime),
1667
- endTime: new Date(record.endTime),
1668
- createdAt: new Date(record.createdAt)
1669
- };
1670
- if (processed.parentSpanId === null || processed.parentSpanId === void 0) {
1671
- processed.parentSpanId = "";
1672
- } else {
1673
- processed.parentSpanId = String(processed.parentSpanId);
1674
- }
1675
- return processed;
1676
- });
1677
- } catch (error) {
1678
- throw new MastraError(
1679
- {
1680
- id: "LANCE_STORE_GET_TRACES_FAILED",
1681
- domain: ErrorDomain.STORAGE,
1682
- category: ErrorCategory.THIRD_PARTY,
1683
- details: { name: name ?? "", scope: scope ?? "" }
1684
- },
1685
- error
1686
- );
1687
- }
1688
- }
1689
- async getTracesPaginated(args) {
1690
- try {
1691
- const table = await this.client.openTable(TABLE_TRACES);
1692
- const query = table.query();
1693
- const conditions = [];
1694
- if (args.name) {
1695
- conditions.push(`name = '${args.name}'`);
1696
- }
1697
- if (args.scope) {
1698
- conditions.push(`scope = '${args.scope}'`);
1699
- }
1700
- if (args.attributes) {
1701
- const attributesStr = JSON.stringify(args.attributes);
1702
- conditions.push(`attributes LIKE '%${attributesStr.replace(/"/g, '\\"')}%'`);
1703
- }
1704
- if (args.dateRange?.start) {
1705
- conditions.push(`\`createdAt\` >= ${args.dateRange.start.getTime()}`);
1706
- }
1707
- if (args.dateRange?.end) {
1708
- conditions.push(`\`createdAt\` <= ${args.dateRange.end.getTime()}`);
1709
- }
1710
- if (conditions.length > 0) {
1711
- const whereClause = conditions.join(" AND ");
1712
- query.where(whereClause);
1713
- }
1714
- let total = 0;
1715
- if (conditions.length > 0) {
1716
- const countQuery = table.query().where(conditions.join(" AND "));
1717
- const allRecords = await countQuery.toArray();
1718
- total = allRecords.length;
1719
- } else {
1720
- total = await table.countRows();
1721
- }
1722
- const page = args.page || 0;
1723
- const perPage = args.perPage || 10;
1614
+ const table = await this.client.openTable(TABLE_SCORERS);
1615
+ const { page = 0, perPage = 10 } = pagination || {};
1724
1616
  const offset = page * perPage;
1725
- query.limit(perPage);
1726
- if (offset > 0) {
1727
- query.offset(offset);
1728
- }
1617
+ const query = table.query().where(`\`traceId\` = '${traceId}' AND \`spanId\` = '${spanId}'`).limit(perPage);
1618
+ if (offset > 0) query.offset(offset);
1729
1619
  const records = await query.toArray();
1730
- const traces = records.map((record) => {
1731
- const processed = {
1732
- ...record,
1733
- attributes: record.attributes ? JSON.parse(record.attributes) : {},
1734
- status: record.status ? JSON.parse(record.status) : {},
1735
- events: record.events ? JSON.parse(record.events) : [],
1736
- links: record.links ? JSON.parse(record.links) : [],
1737
- other: record.other ? JSON.parse(record.other) : {},
1738
- startTime: new Date(record.startTime),
1739
- endTime: new Date(record.endTime),
1740
- createdAt: new Date(record.createdAt)
1741
- };
1742
- if (processed.parentSpanId === null || processed.parentSpanId === void 0) {
1743
- processed.parentSpanId = "";
1744
- } else {
1745
- processed.parentSpanId = String(processed.parentSpanId);
1746
- }
1747
- return processed;
1748
- });
1620
+ const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
1621
+ const scores = processResultWithTypeConversion(records, schema);
1622
+ const allRecords = await table.query().where(`\`traceId\` = '${traceId}' AND \`spanId\` = '${spanId}'`).toArray();
1623
+ const total = allRecords.length;
1749
1624
  return {
1750
- traces,
1751
- total,
1752
- page,
1753
- perPage,
1754
- hasMore: total > (page + 1) * perPage
1625
+ pagination: {
1626
+ page,
1627
+ perPage,
1628
+ total,
1629
+ hasMore: offset + scores.length < total
1630
+ },
1631
+ scores
1755
1632
  };
1756
1633
  } catch (error) {
1757
1634
  throw new MastraError(
1758
1635
  {
1759
- id: "LANCE_STORE_GET_TRACES_PAGINATED_FAILED",
1636
+ id: "LANCE_STORAGE_GET_SCORES_BY_SPAN_FAILED",
1637
+ text: "Failed to get scores by traceId and spanId in LanceStorage",
1760
1638
  domain: ErrorDomain.STORAGE,
1761
1639
  category: ErrorCategory.THIRD_PARTY,
1762
- details: { name: args.name ?? "", scope: args.scope ?? "" }
1640
+ details: { error: error?.message }
1763
1641
  },
1764
1642
  error
1765
1643
  );
1766
1644
  }
1767
1645
  }
1768
- async batchTraceInsert({ records }) {
1769
- this.logger.debug("Batch inserting traces", { count: records.length });
1770
- await this.operations.batchInsert({
1771
- tableName: TABLE_TRACES,
1772
- records
1773
- });
1774
- }
1775
1646
  };
1776
1647
  function parseWorkflowRun(row) {
1777
1648
  let parsedSnapshot = row.snapshot;
@@ -1802,7 +1673,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1802
1673
  // runId,
1803
1674
  // stepId,
1804
1675
  // result,
1805
- // runtimeContext,
1676
+ // requestContext,
1806
1677
  }) {
1807
1678
  throw new Error("Method not implemented.");
1808
1679
  }
@@ -1816,6 +1687,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1816
1687
  async persistWorkflowSnapshot({
1817
1688
  workflowName,
1818
1689
  runId,
1690
+ resourceId,
1819
1691
  snapshot
1820
1692
  }) {
1821
1693
  try {
@@ -1832,6 +1704,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1832
1704
  const record = {
1833
1705
  workflow_name: workflowName,
1834
1706
  run_id: runId,
1707
+ resourceId,
1835
1708
  snapshot: JSON.stringify(snapshot),
1836
1709
  createdAt,
1837
1710
  updatedAt: now
@@ -1894,7 +1767,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1894
1767
  );
1895
1768
  }
1896
1769
  }
1897
- async getWorkflowRuns(args) {
1770
+ async listWorkflowRuns(args) {
1898
1771
  try {
1899
1772
  const table = await this.client.openTable(TABLE_WORKFLOW_SNAPSHOT);
1900
1773
  let query = table.query();
@@ -1935,7 +1808,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1935
1808
  id: "LANCE_STORE_GET_WORKFLOW_RUNS_FAILED",
1936
1809
  domain: ErrorDomain.STORAGE,
1937
1810
  category: ErrorCategory.THIRD_PARTY,
1938
- details: { namespace: args?.namespace ?? "", workflowName: args?.workflowName ?? "" }
1811
+ details: { resourceId: args?.resourceId ?? "", workflowName: args?.workflowName ?? "" }
1939
1812
  },
1940
1813
  error
1941
1814
  );
@@ -1977,10 +1850,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
1977
1850
  instance.stores = {
1978
1851
  operations: new StoreOperationsLance({ client: instance.lanceClient }),
1979
1852
  workflows: new StoreWorkflowsLance({ client: instance.lanceClient }),
1980
- traces: new StoreTracesLance({ client: instance.lanceClient, operations }),
1981
1853
  scores: new StoreScoresLance({ client: instance.lanceClient }),
1982
- memory: new StoreMemoryLance({ client: instance.lanceClient, operations }),
1983
- legacyEvals: new StoreLegacyEvalsLance({ client: instance.lanceClient })
1854
+ memory: new StoreMemoryLance({ client: instance.lanceClient, operations })
1984
1855
  };
1985
1856
  return instance;
1986
1857
  } catch (e) {
@@ -2006,9 +1877,7 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2006
1877
  this.stores = {
2007
1878
  operations: new StoreOperationsLance({ client: this.lanceClient }),
2008
1879
  workflows: new StoreWorkflowsLance({ client: this.lanceClient }),
2009
- traces: new StoreTracesLance({ client: this.lanceClient, operations }),
2010
1880
  scores: new StoreScoresLance({ client: this.lanceClient }),
2011
- legacyEvals: new StoreLegacyEvalsLance({ client: this.lanceClient }),
2012
1881
  memory: new StoreMemoryLance({ client: this.lanceClient, operations })
2013
1882
  };
2014
1883
  }
@@ -2070,7 +1939,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2070
1939
  resourceWorkingMemory: true,
2071
1940
  hasColumn: true,
2072
1941
  createTable: true,
2073
- deleteMessages: false
1942
+ deleteMessages: false,
1943
+ getScoresBySpan: true
2074
1944
  };
2075
1945
  }
2076
1946
  async getResourceById({ resourceId }) {
@@ -2143,12 +2013,6 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2143
2013
  }) {
2144
2014
  return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format, threadConfig });
2145
2015
  }
2146
- async getMessagesById({
2147
- messageIds,
2148
- format
2149
- }) {
2150
- return this.stores.memory.getMessagesById({ messageIds, format });
2151
- }
2152
2016
  async saveMessages(args) {
2153
2017
  return this.stores.memory.saveMessages(args);
2154
2018
  }
@@ -2161,23 +2025,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2161
2025
  async updateMessages(_args) {
2162
2026
  return this.stores.memory.updateMessages(_args);
2163
2027
  }
2164
- async getTraceById(args) {
2165
- return this.stores.traces.getTraceById(args);
2166
- }
2167
- async getTraces(args) {
2168
- return this.stores.traces.getTraces(args);
2169
- }
2170
- async getTracesPaginated(args) {
2171
- return this.stores.traces.getTracesPaginated(args);
2172
- }
2173
- async getEvalsByAgentName(agentName, type) {
2174
- return this.stores.legacyEvals.getEvalsByAgentName(agentName, type);
2175
- }
2176
- async getEvals(options) {
2177
- return this.stores.legacyEvals.getEvals(options);
2178
- }
2179
- async getWorkflowRuns(args) {
2180
- return this.stores.workflows.getWorkflowRuns(args);
2028
+ async listWorkflowRuns(args) {
2029
+ return this.stores.workflows.listWorkflowRuns(args);
2181
2030
  }
2182
2031
  async getWorkflowRunById(args) {
2183
2032
  return this.stores.workflows.getWorkflowRunById(args);
@@ -2187,9 +2036,9 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2187
2036
  runId,
2188
2037
  stepId,
2189
2038
  result,
2190
- runtimeContext
2039
+ requestContext
2191
2040
  }) {
2192
- return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, runtimeContext });
2041
+ return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, requestContext });
2193
2042
  }
2194
2043
  async updateWorkflowState({
2195
2044
  workflowName,
@@ -2201,9 +2050,10 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2201
2050
  async persistWorkflowSnapshot({
2202
2051
  workflowName,
2203
2052
  runId,
2053
+ resourceId,
2204
2054
  snapshot
2205
2055
  }) {
2206
- return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, snapshot });
2056
+ return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot });
2207
2057
  }
2208
2058
  async loadWorkflowSnapshot({
2209
2059
  workflowName,
@@ -2239,6 +2089,13 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2239
2089
  }) {
2240
2090
  return this.stores.scores.getScoresByEntityId({ entityId, entityType, pagination });
2241
2091
  }
2092
+ async getScoresBySpan({
2093
+ traceId,
2094
+ spanId,
2095
+ pagination
2096
+ }) {
2097
+ return this.stores.scores.getScoresBySpan({ traceId, spanId, pagination });
2098
+ }
2242
2099
  };
2243
2100
  var LanceFilterTranslator = class extends BaseFilterTranslator {
2244
2101
  translate(filter) {