@mastra/lance 0.3.2 → 0.3.3

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @mastra/lance
2
2
 
3
+ ## 0.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Update peer deps ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
8
+
9
+ - Lance db support to fetch scores by trace and span id ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
10
+
11
+ - Updated dependencies [[`dc099b4`](https://github.com/mastra-ai/mastra/commit/dc099b40fb31147ba3f362f98d991892033c4c67), [`504438b`](https://github.com/mastra-ai/mastra/commit/504438b961bde211071186bba63a842c4e3db879), [`b342a68`](https://github.com/mastra-ai/mastra/commit/b342a68e1399cf1ece9ba11bda112db89d21118c), [`a7243e2`](https://github.com/mastra-ai/mastra/commit/a7243e2e58762667a6e3921e755e89d6bb0a3282), [`7fceb0a`](https://github.com/mastra-ai/mastra/commit/7fceb0a327d678e812f90f5387c5bc4f38bd039e), [`303a9c0`](https://github.com/mastra-ai/mastra/commit/303a9c0d7dd58795915979f06a0512359e4532fb), [`df64f9e`](https://github.com/mastra-ai/mastra/commit/df64f9ef814916fff9baedd861c988084e7c41de), [`370f8a6`](https://github.com/mastra-ai/mastra/commit/370f8a6480faec70fef18d72e5f7538f27004301), [`809eea0`](https://github.com/mastra-ai/mastra/commit/809eea092fa80c3f69b9eaf078d843b57fd2a88e), [`683e5a1`](https://github.com/mastra-ai/mastra/commit/683e5a1466e48b686825b2c11f84680f296138e4), [`3679378`](https://github.com/mastra-ai/mastra/commit/3679378673350aa314741dc826f837b1984149bc), [`7775bc2`](https://github.com/mastra-ai/mastra/commit/7775bc20bb1ad1ab24797fb420e4f96c65b0d8ec), [`623ffaf`](https://github.com/mastra-ai/mastra/commit/623ffaf2d969e11e99a0224633cf7b5a0815c857), [`9fc1613`](https://github.com/mastra-ai/mastra/commit/9fc16136400186648880fd990119ac15f7c02ee4), [`61f62aa`](https://github.com/mastra-ai/mastra/commit/61f62aa31bc88fe4ddf8da6240dbcfbeb07358bd), [`db1891a`](https://github.com/mastra-ai/mastra/commit/db1891a4707443720b7cd8a260dc7e1d49b3609c), [`e8f379d`](https://github.com/mastra-ai/mastra/commit/e8f379d390efa264c4e0874f9ac0cf8839b07777), [`652066b`](https://github.com/mastra-ai/mastra/commit/652066bd1efc6bb6813ba950ed1d7573e8b7d9d4), [`3e292ba`](https://github.com/mastra-ai/mastra/commit/3e292ba00837886d5d68a34cbc0d9b703c991883), [`418c136`](https://github.com/mastra-ai/mastra/commit/418c1366843d88e491bca3f87763899ce855ca29), [`ea8d386`](https://github.com/mastra-ai/mastra/commit/ea8d386cd8c5593664515fd5770c06bf2aa980ef), [`67b0f00`](https://github.com/mastra-ai/mastra/commit/67b0f005b520335c71fb85cbaa25df4ce8484a81), [`c2a4919`](https://github.com/mastra-ai/mastra/commit/c2a4919ba6797d8bdb1509e02287496eef69303e), [`c84b7d0`](https://github.com/mastra-ai/mastra/commit/c84b7d093c4657772140cbfd2b15ef72f3315ed5), [`0130986`](https://github.com/mastra-ai/mastra/commit/0130986fc62d0edcc626dd593282661dbb9af141)]:
12
+ - @mastra/core@0.19.0
13
+
14
+ ## 0.3.3-alpha.0
15
+
16
+ ### Patch Changes
17
+
18
+ - Update peer deps ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
19
+
20
+ - Lance db support to fetch scores by trace and span id ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
21
+
22
+ - Updated dependencies [[`504438b`](https://github.com/mastra-ai/mastra/commit/504438b961bde211071186bba63a842c4e3db879), [`a7243e2`](https://github.com/mastra-ai/mastra/commit/a7243e2e58762667a6e3921e755e89d6bb0a3282), [`7fceb0a`](https://github.com/mastra-ai/mastra/commit/7fceb0a327d678e812f90f5387c5bc4f38bd039e), [`df64f9e`](https://github.com/mastra-ai/mastra/commit/df64f9ef814916fff9baedd861c988084e7c41de), [`809eea0`](https://github.com/mastra-ai/mastra/commit/809eea092fa80c3f69b9eaf078d843b57fd2a88e), [`683e5a1`](https://github.com/mastra-ai/mastra/commit/683e5a1466e48b686825b2c11f84680f296138e4), [`3679378`](https://github.com/mastra-ai/mastra/commit/3679378673350aa314741dc826f837b1984149bc), [`7775bc2`](https://github.com/mastra-ai/mastra/commit/7775bc20bb1ad1ab24797fb420e4f96c65b0d8ec), [`db1891a`](https://github.com/mastra-ai/mastra/commit/db1891a4707443720b7cd8a260dc7e1d49b3609c), [`e8f379d`](https://github.com/mastra-ai/mastra/commit/e8f379d390efa264c4e0874f9ac0cf8839b07777), [`652066b`](https://github.com/mastra-ai/mastra/commit/652066bd1efc6bb6813ba950ed1d7573e8b7d9d4), [`ea8d386`](https://github.com/mastra-ai/mastra/commit/ea8d386cd8c5593664515fd5770c06bf2aa980ef), [`c2a4919`](https://github.com/mastra-ai/mastra/commit/c2a4919ba6797d8bdb1509e02287496eef69303e), [`0130986`](https://github.com/mastra-ai/mastra/commit/0130986fc62d0edcc626dd593282661dbb9af141)]:
23
+ - @mastra/core@0.19.0-alpha.1
24
+
3
25
  ## 0.3.2
4
26
 
5
27
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -5,6 +5,7 @@ var error = require('@mastra/core/error');
5
5
  var storage = require('@mastra/core/storage');
6
6
  var agent = require('@mastra/core/agent');
7
7
  var apacheArrow = require('apache-arrow');
8
+ var scores = require('@mastra/core/scores');
8
9
  var vector = require('@mastra/core/vector');
9
10
  var filter = require('@mastra/core/vector/filter');
10
11
 
@@ -1398,13 +1399,27 @@ var StoreScoresLance = class extends storage.ScoresStorage {
1398
1399
  this.client = client;
1399
1400
  }
1400
1401
  async saveScore(score) {
1402
+ let validatedScore;
1403
+ try {
1404
+ validatedScore = scores.saveScorePayloadSchema.parse(score);
1405
+ } catch (error$1) {
1406
+ throw new error.MastraError(
1407
+ {
1408
+ id: "LANCE_STORAGE_SAVE_SCORE_FAILED",
1409
+ text: "Failed to save score in LanceStorage",
1410
+ domain: error.ErrorDomain.STORAGE,
1411
+ category: error.ErrorCategory.THIRD_PARTY
1412
+ },
1413
+ error$1
1414
+ );
1415
+ }
1401
1416
  try {
1402
1417
  const id = crypto.randomUUID();
1403
1418
  const table = await this.client.openTable(storage.TABLE_SCORERS);
1404
1419
  const schema = await getTableSchema({ tableName: storage.TABLE_SCORERS, client: this.client });
1405
1420
  const allowedFields = new Set(schema.fields.map((f) => f.name));
1406
1421
  const filteredScore = {};
1407
- Object.keys(score).forEach((key) => {
1422
+ Object.keys(validatedScore).forEach((key) => {
1408
1423
  if (allowedFields.has(key)) {
1409
1424
  filteredScore[key] = score[key];
1410
1425
  }
@@ -1580,6 +1595,44 @@ var StoreScoresLance = class extends storage.ScoresStorage {
1580
1595
  );
1581
1596
  }
1582
1597
  }
1598
+ async getScoresBySpan({
1599
+ traceId,
1600
+ spanId,
1601
+ pagination
1602
+ }) {
1603
+ try {
1604
+ const table = await this.client.openTable(storage.TABLE_SCORERS);
1605
+ const { page = 0, perPage = 10 } = pagination || {};
1606
+ const offset = page * perPage;
1607
+ const query = table.query().where(`\`traceId\` = '${traceId}' AND \`spanId\` = '${spanId}'`).limit(perPage);
1608
+ if (offset > 0) query.offset(offset);
1609
+ const records = await query.toArray();
1610
+ const schema = await getTableSchema({ tableName: storage.TABLE_SCORERS, client: this.client });
1611
+ const scores = processResultWithTypeConversion(records, schema);
1612
+ const allRecords = await table.query().where(`\`traceId\` = '${traceId}' AND \`spanId\` = '${spanId}'`).toArray();
1613
+ const total = allRecords.length;
1614
+ return {
1615
+ pagination: {
1616
+ page,
1617
+ perPage,
1618
+ total,
1619
+ hasMore: offset + scores.length < total
1620
+ },
1621
+ scores
1622
+ };
1623
+ } catch (error$1) {
1624
+ throw new error.MastraError(
1625
+ {
1626
+ id: "LANCE_STORAGE_GET_SCORES_BY_SPAN_FAILED",
1627
+ text: "Failed to get scores by traceId and spanId in LanceStorage",
1628
+ domain: error.ErrorDomain.STORAGE,
1629
+ category: error.ErrorCategory.THIRD_PARTY,
1630
+ details: { error: error$1?.message }
1631
+ },
1632
+ error$1
1633
+ );
1634
+ }
1635
+ }
1583
1636
  };
1584
1637
  var StoreTracesLance = class extends storage.TracesStorage {
1585
1638
  client;
@@ -2072,7 +2125,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
2072
2125
  resourceWorkingMemory: true,
2073
2126
  hasColumn: true,
2074
2127
  createTable: true,
2075
- deleteMessages: false
2128
+ deleteMessages: false,
2129
+ getScoresBySpan: true
2076
2130
  };
2077
2131
  }
2078
2132
  async getResourceById({ resourceId }) {
@@ -2242,6 +2296,13 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
2242
2296
  }) {
2243
2297
  return this.stores.scores.getScoresByEntityId({ entityId, entityType, pagination });
2244
2298
  }
2299
+ async getScoresBySpan({
2300
+ traceId,
2301
+ spanId,
2302
+ pagination
2303
+ }) {
2304
+ return this.stores.scores.getScoresBySpan({ traceId, spanId, pagination });
2305
+ }
2245
2306
  };
2246
2307
  var LanceFilterTranslator = class extends filter.BaseFilterTranslator {
2247
2308
  translate(filter) {