@mastra/lance 0.0.0-update-stores-peerDeps-20250723031338 → 0.0.0-vector-query-tool-provider-options-20250828222356

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +201 -2
  2. package/README.md +3 -3
  3. package/dist/index.cjs +113 -21
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.ts +3 -2
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +113 -21
  8. package/dist/index.js.map +1 -0
  9. package/dist/storage/domains/legacy-evals/index.d.ts +25 -0
  10. package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
  11. package/dist/storage/domains/memory/index.d.ts +103 -0
  12. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  13. package/dist/storage/domains/operations/index.d.ts +40 -0
  14. package/dist/storage/domains/operations/index.d.ts.map +1 -0
  15. package/dist/storage/domains/scores/index.d.ts +42 -0
  16. package/dist/storage/domains/scores/index.d.ts.map +1 -0
  17. package/dist/storage/domains/traces/index.d.ts +34 -0
  18. package/dist/storage/domains/traces/index.d.ts.map +1 -0
  19. package/dist/storage/domains/utils.d.ts +10 -0
  20. package/dist/storage/domains/utils.d.ts.map +1 -0
  21. package/dist/storage/domains/workflows/index.d.ts +56 -0
  22. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  23. package/dist/storage/index.d.ts +262 -0
  24. package/dist/storage/index.d.ts.map +1 -0
  25. package/dist/vector/filter.d.ts +41 -0
  26. package/dist/vector/filter.d.ts.map +1 -0
  27. package/dist/vector/index.d.ts +85 -0
  28. package/dist/vector/index.d.ts.map +1 -0
  29. package/dist/vector/types.d.ts +15 -0
  30. package/dist/vector/types.d.ts.map +1 -0
  31. package/package.json +10 -9
  32. package/src/storage/domains/memory/index.ts +71 -18
  33. package/src/storage/domains/scores/index.ts +29 -7
  34. package/src/storage/domains/workflows/index.ts +39 -1
  35. package/src/storage/index.ts +56 -3
  36. package/src/vector/index.ts +2 -2
  37. package/tsconfig.build.json +9 -0
  38. package/tsconfig.json +1 -1
  39. package/tsup.config.ts +17 -0
  40. package/dist/_tsup-dts-rollup.d.cts +0 -680
  41. package/dist/_tsup-dts-rollup.d.ts +0 -680
  42. package/dist/index.d.cts +0 -2
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { LanceStorage } from './_tsup-dts-rollup.js';
2
- export { LanceVectorStore } from './_tsup-dts-rollup.js';
1
+ export * from './storage/index.js';
2
+ export * from './vector/index.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -379,6 +379,20 @@ var StoreMemoryLance = class extends MemoryStorage {
379
379
  );
380
380
  }
381
381
  }
382
+ normalizeMessage(message) {
383
+ const { thread_id, ...rest } = message;
384
+ return {
385
+ ...rest,
386
+ threadId: thread_id,
387
+ content: typeof message.content === "string" ? (() => {
388
+ try {
389
+ return JSON.parse(message.content);
390
+ } catch {
391
+ return message.content;
392
+ }
393
+ })() : message.content
394
+ };
395
+ }
382
396
  async getMessages({
383
397
  threadId,
384
398
  resourceId,
@@ -419,21 +433,7 @@ var StoreMemoryLance = class extends MemoryStorage {
419
433
  allRecords,
420
434
  await getTableSchema({ tableName: TABLE_MESSAGES, client: this.client })
421
435
  );
422
- const normalized = messages.map((msg) => {
423
- const { thread_id, ...rest } = msg;
424
- return {
425
- ...rest,
426
- threadId: thread_id,
427
- content: typeof msg.content === "string" ? (() => {
428
- try {
429
- return JSON.parse(msg.content);
430
- } catch {
431
- return msg.content;
432
- }
433
- })() : msg.content
434
- };
435
- });
436
- const list = new MessageList({ threadId, resourceId }).add(normalized, "memory");
436
+ const list = new MessageList({ threadId, resourceId }).add(messages.map(this.normalizeMessage), "memory");
437
437
  if (format === "v2") return list.get.all.v2();
438
438
  return list.get.all.v1();
439
439
  } catch (error) {
@@ -447,6 +447,36 @@ var StoreMemoryLance = class extends MemoryStorage {
447
447
  );
448
448
  }
449
449
  }
450
+ async getMessagesById({
451
+ messageIds,
452
+ format
453
+ }) {
454
+ if (messageIds.length === 0) return [];
455
+ try {
456
+ const table = await this.client.openTable(TABLE_MESSAGES);
457
+ const quotedIds = messageIds.map((id) => `'${id}'`).join(", ");
458
+ const allRecords = await table.query().where(`id IN (${quotedIds})`).toArray();
459
+ const messages = processResultWithTypeConversion(
460
+ allRecords,
461
+ await getTableSchema({ tableName: TABLE_MESSAGES, client: this.client })
462
+ );
463
+ const list = new MessageList().add(messages.map(this.normalizeMessage), "memory");
464
+ if (format === `v1`) return list.get.all.v1();
465
+ return list.get.all.v2();
466
+ } catch (error) {
467
+ throw new MastraError(
468
+ {
469
+ id: "LANCE_STORE_GET_MESSAGES_BY_ID_FAILED",
470
+ domain: ErrorDomain.STORAGE,
471
+ category: ErrorCategory.THIRD_PARTY,
472
+ details: {
473
+ messageIds: JSON.stringify(messageIds)
474
+ }
475
+ },
476
+ error
477
+ );
478
+ }
479
+ }
450
480
  async saveMessages(args) {
451
481
  try {
452
482
  const { messages, format = "v1" } = args;
@@ -1359,6 +1389,7 @@ var StoreScoresLance = class extends ScoresStorage {
1359
1389
  }
1360
1390
  async saveScore(score) {
1361
1391
  try {
1392
+ const id = crypto.randomUUID();
1362
1393
  const table = await this.client.openTable(TABLE_SCORERS);
1363
1394
  const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
1364
1395
  const allowedFields = new Set(schema.fields.map((f) => f.name));
@@ -1373,7 +1404,7 @@ var StoreScoresLance = class extends ScoresStorage {
1373
1404
  filteredScore[key] = JSON.stringify(filteredScore[key]);
1374
1405
  }
1375
1406
  }
1376
- console.log("Saving score to LanceStorage:", filteredScore);
1407
+ filteredScore.id = id;
1377
1408
  await table.add([filteredScore], { mode: "append" });
1378
1409
  return { score };
1379
1410
  } catch (error) {
@@ -1412,18 +1443,35 @@ var StoreScoresLance = class extends ScoresStorage {
1412
1443
  }
1413
1444
  async getScoresByScorerId({
1414
1445
  scorerId,
1415
- pagination
1446
+ pagination,
1447
+ entityId,
1448
+ entityType,
1449
+ source
1416
1450
  }) {
1417
1451
  try {
1418
1452
  const table = await this.client.openTable(TABLE_SCORERS);
1419
1453
  const { page = 0, perPage = 10 } = pagination || {};
1420
1454
  const offset = page * perPage;
1421
- const query = table.query().where(`\`scorerId\` = '${scorerId}'`).limit(perPage);
1455
+ let query = table.query().where(`\`scorerId\` = '${scorerId}'`);
1456
+ if (source) {
1457
+ query = query.where(`\`source\` = '${source}'`);
1458
+ }
1459
+ if (entityId) {
1460
+ query = query.where(`\`entityId\` = '${entityId}'`);
1461
+ }
1462
+ if (entityType) {
1463
+ query = query.where(`\`entityType\` = '${entityType}'`);
1464
+ }
1465
+ query = query.limit(perPage);
1422
1466
  if (offset > 0) query.offset(offset);
1423
1467
  const records = await query.toArray();
1424
1468
  const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
1425
1469
  const scores = processResultWithTypeConversion(records, schema);
1426
- const allRecords = await table.query().where(`\`scorerId\` = '${scorerId}'`).toArray();
1470
+ let totalQuery = table.query().where(`\`scorerId\` = '${scorerId}'`);
1471
+ if (source) {
1472
+ totalQuery = totalQuery.where(`\`source\` = '${source}'`);
1473
+ }
1474
+ const allRecords = await totalQuery.toArray();
1427
1475
  const total = allRecords.length;
1428
1476
  return {
1429
1477
  pagination: {
@@ -1739,6 +1787,22 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1739
1787
  super();
1740
1788
  this.client = client;
1741
1789
  }
1790
+ updateWorkflowResults({
1791
+ // workflowName,
1792
+ // runId,
1793
+ // stepId,
1794
+ // result,
1795
+ // runtimeContext,
1796
+ }) {
1797
+ throw new Error("Method not implemented.");
1798
+ }
1799
+ updateWorkflowState({
1800
+ // workflowName,
1801
+ // runId,
1802
+ // opts,
1803
+ }) {
1804
+ throw new Error("Method not implemented.");
1805
+ }
1742
1806
  async persistWorkflowSnapshot({
1743
1807
  workflowName,
1744
1808
  runId,
@@ -1995,7 +2059,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
1995
2059
  selectByIncludeResourceScope: true,
1996
2060
  resourceWorkingMemory: true,
1997
2061
  hasColumn: true,
1998
- createTable: true
2062
+ createTable: true,
2063
+ deleteMessages: false
1999
2064
  };
2000
2065
  }
2001
2066
  async getResourceById({ resourceId }) {
@@ -2068,6 +2133,12 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2068
2133
  }) {
2069
2134
  return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format, threadConfig });
2070
2135
  }
2136
+ async getMessagesById({
2137
+ messageIds,
2138
+ format
2139
+ }) {
2140
+ return this.stores.memory.getMessagesById({ messageIds, format });
2141
+ }
2071
2142
  async saveMessages(args) {
2072
2143
  return this.stores.memory.saveMessages(args);
2073
2144
  }
@@ -2101,6 +2172,22 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2101
2172
  async getWorkflowRunById(args) {
2102
2173
  return this.stores.workflows.getWorkflowRunById(args);
2103
2174
  }
2175
+ async updateWorkflowResults({
2176
+ workflowName,
2177
+ runId,
2178
+ stepId,
2179
+ result,
2180
+ runtimeContext
2181
+ }) {
2182
+ return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, runtimeContext });
2183
+ }
2184
+ async updateWorkflowState({
2185
+ workflowName,
2186
+ runId,
2187
+ opts
2188
+ }) {
2189
+ return this.stores.workflows.updateWorkflowState({ workflowName, runId, opts });
2190
+ }
2104
2191
  async persistWorkflowSnapshot({
2105
2192
  workflowName,
2106
2193
  runId,
@@ -2119,9 +2206,12 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2119
2206
  }
2120
2207
  async getScoresByScorerId({
2121
2208
  scorerId,
2209
+ source,
2210
+ entityId,
2211
+ entityType,
2122
2212
  pagination
2123
2213
  }) {
2124
- return this.stores.scores.getScoresByScorerId({ scorerId, pagination });
2214
+ return this.stores.scores.getScoresByScorerId({ scorerId, source, pagination, entityId, entityType });
2125
2215
  }
2126
2216
  async saveScore(_score) {
2127
2217
  return this.stores.scores.saveScore(_score);
@@ -3196,3 +3286,5 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
3196
3286
  };
3197
3287
 
3198
3288
  export { LanceStorage, LanceVectorStore };
3289
+ //# sourceMappingURL=index.js.map
3290
+ //# sourceMappingURL=index.js.map