@mastra/lance 0.0.0-message-file-url-handling-fix-20250904234524 → 0.0.0-model-router-unknown-provider-20251017212006

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
@@ -3,6 +3,7 @@ import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
3
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';
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
 
@@ -187,7 +188,6 @@ function processResultWithTypeConversion(rawResult, tableSchema) {
187
188
  } else if (fieldTypeStr.includes("float64") && ["createdAt", "updatedAt"].includes(key)) {
188
189
  processedResult[key] = new Date(processedResult[key]);
189
190
  }
190
- console.log(key, "processedResult", processedResult);
191
191
  }
192
192
  return processedResult;
193
193
  }
@@ -1264,7 +1264,7 @@ var StoreOperationsLance = class extends StoreOperations {
1264
1264
  processedRecord[key] = JSON.stringify(processedRecord[key]);
1265
1265
  }
1266
1266
  }
1267
- console.log(await table.schema());
1267
+ console.info(await table.schema());
1268
1268
  await table.mergeInsert(primaryId).whenMatchedUpdateAll().whenNotMatchedInsertAll().execute([processedRecord]);
1269
1269
  } catch (error) {
1270
1270
  throw new MastraError(
@@ -1314,7 +1314,6 @@ var StoreOperationsLance = class extends StoreOperations {
1314
1314
  }
1315
1315
  return processedRecord;
1316
1316
  });
1317
- console.log(processedRecords);
1318
1317
  await table.mergeInsert(primaryId).whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(processedRecords);
1319
1318
  } catch (error) {
1320
1319
  throw new MastraError(
@@ -1398,13 +1397,27 @@ var StoreScoresLance = class extends ScoresStorage {
1398
1397
  this.client = client;
1399
1398
  }
1400
1399
  async saveScore(score) {
1400
+ let validatedScore;
1401
+ try {
1402
+ validatedScore = saveScorePayloadSchema.parse(score);
1403
+ } catch (error) {
1404
+ throw new MastraError(
1405
+ {
1406
+ id: "LANCE_STORAGE_SAVE_SCORE_FAILED",
1407
+ text: "Failed to save score in LanceStorage",
1408
+ domain: ErrorDomain.STORAGE,
1409
+ category: ErrorCategory.THIRD_PARTY
1410
+ },
1411
+ error
1412
+ );
1413
+ }
1401
1414
  try {
1402
1415
  const id = crypto.randomUUID();
1403
1416
  const table = await this.client.openTable(TABLE_SCORERS);
1404
1417
  const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
1405
1418
  const allowedFields = new Set(schema.fields.map((f) => f.name));
1406
1419
  const filteredScore = {};
1407
- Object.keys(score).forEach((key) => {
1420
+ Object.keys(validatedScore).forEach((key) => {
1408
1421
  if (allowedFields.has(key)) {
1409
1422
  filteredScore[key] = score[key];
1410
1423
  }
@@ -1580,6 +1593,44 @@ var StoreScoresLance = class extends ScoresStorage {
1580
1593
  );
1581
1594
  }
1582
1595
  }
1596
+ async getScoresBySpan({
1597
+ traceId,
1598
+ spanId,
1599
+ pagination
1600
+ }) {
1601
+ try {
1602
+ const table = await this.client.openTable(TABLE_SCORERS);
1603
+ const { page = 0, perPage = 10 } = pagination || {};
1604
+ const offset = page * perPage;
1605
+ const query = table.query().where(`\`traceId\` = '${traceId}' AND \`spanId\` = '${spanId}'`).limit(perPage);
1606
+ if (offset > 0) query.offset(offset);
1607
+ const records = await query.toArray();
1608
+ const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
1609
+ const scores = processResultWithTypeConversion(records, schema);
1610
+ const allRecords = await table.query().where(`\`traceId\` = '${traceId}' AND \`spanId\` = '${spanId}'`).toArray();
1611
+ const total = allRecords.length;
1612
+ return {
1613
+ pagination: {
1614
+ page,
1615
+ perPage,
1616
+ total,
1617
+ hasMore: offset + scores.length < total
1618
+ },
1619
+ scores
1620
+ };
1621
+ } catch (error) {
1622
+ throw new MastraError(
1623
+ {
1624
+ id: "LANCE_STORAGE_GET_SCORES_BY_SPAN_FAILED",
1625
+ text: "Failed to get scores by traceId and spanId in LanceStorage",
1626
+ domain: ErrorDomain.STORAGE,
1627
+ category: ErrorCategory.THIRD_PARTY,
1628
+ details: { error: error?.message }
1629
+ },
1630
+ error
1631
+ );
1632
+ }
1633
+ }
1583
1634
  };
1584
1635
  var StoreTracesLance = class extends TracesStorage {
1585
1636
  client;
@@ -1816,6 +1867,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1816
1867
  async persistWorkflowSnapshot({
1817
1868
  workflowName,
1818
1869
  runId,
1870
+ resourceId,
1819
1871
  snapshot
1820
1872
  }) {
1821
1873
  try {
@@ -1832,6 +1884,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1832
1884
  const record = {
1833
1885
  workflow_name: workflowName,
1834
1886
  run_id: runId,
1887
+ resourceId,
1835
1888
  snapshot: JSON.stringify(snapshot),
1836
1889
  createdAt,
1837
1890
  updatedAt: now
@@ -2070,7 +2123,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2070
2123
  resourceWorkingMemory: true,
2071
2124
  hasColumn: true,
2072
2125
  createTable: true,
2073
- deleteMessages: false
2126
+ deleteMessages: false,
2127
+ getScoresBySpan: true
2074
2128
  };
2075
2129
  }
2076
2130
  async getResourceById({ resourceId }) {
@@ -2201,9 +2255,10 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2201
2255
  async persistWorkflowSnapshot({
2202
2256
  workflowName,
2203
2257
  runId,
2258
+ resourceId,
2204
2259
  snapshot
2205
2260
  }) {
2206
- return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, snapshot });
2261
+ return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot });
2207
2262
  }
2208
2263
  async loadWorkflowSnapshot({
2209
2264
  workflowName,
@@ -2239,6 +2294,13 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2239
2294
  }) {
2240
2295
  return this.stores.scores.getScoresByEntityId({ entityId, entityType, pagination });
2241
2296
  }
2297
+ async getScoresBySpan({
2298
+ traceId,
2299
+ spanId,
2300
+ pagination
2301
+ }) {
2302
+ return this.stores.scores.getScoresBySpan({ traceId, spanId, pagination });
2303
+ }
2242
2304
  };
2243
2305
  var LanceFilterTranslator = class extends BaseFilterTranslator {
2244
2306
  translate(filter) {