@mastra/lance 0.0.0-playground-studio-cloud-20251031080052 → 0.0.0-refactor-agent-information-for-recomposable-ui-20251112151814

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,133 +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, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ensureDate } from '@mastra/core/storage';
3
+ import { MastraStorage, StoreOperations, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, normalizePerPage, calculatePagination, 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
+ import { saveScorePayloadSchema } from '@mastra/core/evals';
7
7
  import { MastraVector } from '@mastra/core/vector';
8
8
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
9
9
 
10
10
  // src/storage/index.ts
11
- var StoreLegacyEvalsLance = class extends LegacyEvalsStorage {
12
- client;
13
- constructor({ client }) {
14
- super();
15
- this.client = client;
16
- }
17
- async getEvalsByAgentName(agentName, type) {
18
- try {
19
- const table = await this.client.openTable(TABLE_EVALS);
20
- const query = table.query().where(`agent_name = '${agentName}'`);
21
- const records = await query.toArray();
22
- let filteredRecords = records;
23
- if (type === "live") {
24
- filteredRecords = records.filter((record) => record.test_info === null);
25
- } else if (type === "test") {
26
- filteredRecords = records.filter((record) => record.test_info !== null);
27
- }
28
- return filteredRecords.map((record) => {
29
- return {
30
- id: record.id,
31
- input: record.input,
32
- output: record.output,
33
- agentName: record.agent_name,
34
- metricName: record.metric_name,
35
- result: JSON.parse(record.result),
36
- instructions: record.instructions,
37
- testInfo: record.test_info ? JSON.parse(record.test_info) : null,
38
- globalRunId: record.global_run_id,
39
- runId: record.run_id,
40
- createdAt: new Date(record.created_at).toString()
41
- };
42
- });
43
- } catch (error) {
44
- throw new MastraError(
45
- {
46
- id: "LANCE_STORE_GET_EVALS_BY_AGENT_NAME_FAILED",
47
- domain: ErrorDomain.STORAGE,
48
- category: ErrorCategory.THIRD_PARTY,
49
- details: { agentName }
50
- },
51
- error
52
- );
53
- }
54
- }
55
- async getEvals(options) {
56
- try {
57
- const table = await this.client.openTable(TABLE_EVALS);
58
- const conditions = [];
59
- if (options.agentName) {
60
- conditions.push(`agent_name = '${options.agentName}'`);
61
- }
62
- if (options.type === "live") {
63
- conditions.push("test_info IS NULL");
64
- } else if (options.type === "test") {
65
- conditions.push("test_info IS NOT NULL");
66
- }
67
- const startDate = options.dateRange?.start || options.fromDate;
68
- const endDate = options.dateRange?.end || options.toDate;
69
- if (startDate) {
70
- conditions.push(`\`created_at\` >= ${startDate.getTime()}`);
71
- }
72
- if (endDate) {
73
- conditions.push(`\`created_at\` <= ${endDate.getTime()}`);
74
- }
75
- let total = 0;
76
- if (conditions.length > 0) {
77
- total = await table.countRows(conditions.join(" AND "));
78
- } else {
79
- total = await table.countRows();
80
- }
81
- const query = table.query();
82
- if (conditions.length > 0) {
83
- const whereClause = conditions.join(" AND ");
84
- query.where(whereClause);
85
- }
86
- const records = await query.toArray();
87
- const evals = records.sort((a, b) => b.created_at - a.created_at).map((record) => {
88
- return {
89
- id: record.id,
90
- input: record.input,
91
- output: record.output,
92
- agentName: record.agent_name,
93
- metricName: record.metric_name,
94
- result: JSON.parse(record.result),
95
- instructions: record.instructions,
96
- testInfo: record.test_info ? JSON.parse(record.test_info) : null,
97
- globalRunId: record.global_run_id,
98
- runId: record.run_id,
99
- createdAt: new Date(record.created_at).toISOString()
100
- };
101
- });
102
- const page = options.page || 0;
103
- const perPage = options.perPage || 10;
104
- const pagedEvals = evals.slice(page * perPage, (page + 1) * perPage);
105
- return {
106
- evals: pagedEvals,
107
- total,
108
- page,
109
- perPage,
110
- hasMore: total > (page + 1) * perPage
111
- };
112
- } catch (error) {
113
- throw new MastraError(
114
- {
115
- id: "LANCE_STORE_GET_EVALS_FAILED",
116
- domain: ErrorDomain.STORAGE,
117
- category: ErrorCategory.THIRD_PARTY,
118
- details: { agentName: options.agentName ?? "" }
119
- },
120
- error
121
- );
122
- }
123
- }
124
- };
125
11
  function getPrimaryKeys(tableName) {
126
12
  let primaryId = ["id"];
127
13
  if (tableName === TABLE_WORKFLOW_SNAPSHOT) {
128
14
  primaryId = ["workflow_name", "run_id"];
129
- } else if (tableName === TABLE_EVALS) {
130
- primaryId = ["agent_name", "metric_name", "run_id"];
131
15
  }
132
16
  return primaryId;
133
17
  }
@@ -247,6 +131,10 @@ var StoreMemoryLance = class extends MemoryStorage {
247
131
  this.client = client;
248
132
  this.operations = operations;
249
133
  }
134
+ // Utility to escape single quotes in SQL strings
135
+ escapeSql(str) {
136
+ return str.replace(/'/g, "''");
137
+ }
250
138
  async getThreadById({ threadId }) {
251
139
  try {
252
140
  const thread = await this.operations.load({ tableName: TABLE_THREADS, keys: { id: threadId } });
@@ -269,26 +157,6 @@ var StoreMemoryLance = class extends MemoryStorage {
269
157
  );
270
158
  }
271
159
  }
272
- async getThreadsByResourceId({ resourceId }) {
273
- try {
274
- const table = await this.client.openTable(TABLE_THREADS);
275
- const query = table.query().where(`\`resourceId\` = '${resourceId}'`);
276
- const records = await query.toArray();
277
- return processResultWithTypeConversion(
278
- records,
279
- await getTableSchema({ tableName: TABLE_THREADS, client: this.client })
280
- );
281
- } catch (error) {
282
- throw new MastraError(
283
- {
284
- id: "LANCE_STORE_GET_THREADS_BY_RESOURCE_ID_FAILED",
285
- domain: ErrorDomain.STORAGE,
286
- category: ErrorCategory.THIRD_PARTY
287
- },
288
- error
289
- );
290
- }
291
- }
292
160
  /**
293
161
  * Saves a thread to the database. This function doesn't overwrite existing threads.
294
162
  * @param thread - The thread to save
@@ -393,100 +261,174 @@ var StoreMemoryLance = class extends MemoryStorage {
393
261
  })() : message.content
394
262
  };
395
263
  }
396
- async getMessages({
397
- threadId,
398
- resourceId,
399
- selectBy,
400
- format,
401
- threadConfig
402
- }) {
264
+ async listMessagesById({ messageIds }) {
265
+ if (messageIds.length === 0) return { messages: [] };
403
266
  try {
404
- if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
405
- if (threadConfig) {
406
- throw new Error("ThreadConfig is not supported by LanceDB storage");
407
- }
408
- const limit = resolveMessageLimit({ last: selectBy?.last, defaultLimit: Number.MAX_SAFE_INTEGER });
409
267
  const table = await this.client.openTable(TABLE_MESSAGES);
410
- let allRecords = [];
411
- if (selectBy?.include && selectBy.include.length > 0) {
412
- const threadIds = [...new Set(selectBy.include.map((item) => item.threadId))];
413
- for (const threadId2 of threadIds) {
414
- const threadQuery = table.query().where(`thread_id = '${threadId2}'`);
415
- let threadRecords = await threadQuery.toArray();
416
- allRecords.push(...threadRecords);
417
- }
418
- } else {
419
- let query = table.query().where(`\`thread_id\` = '${threadId}'`);
420
- allRecords = await query.toArray();
421
- }
422
- allRecords.sort((a, b) => {
423
- const dateA = new Date(a.createdAt).getTime();
424
- const dateB = new Date(b.createdAt).getTime();
425
- return dateA - dateB;
426
- });
427
- if (selectBy?.include && selectBy.include.length > 0) {
428
- allRecords = this.processMessagesWithContext(allRecords, selectBy.include);
429
- }
430
- if (limit !== Number.MAX_SAFE_INTEGER) {
431
- allRecords = allRecords.slice(-limit);
432
- }
268
+ const quotedIds = messageIds.map((id) => `'${id}'`).join(", ");
269
+ const allRecords = await table.query().where(`id IN (${quotedIds})`).toArray();
433
270
  const messages = processResultWithTypeConversion(
434
271
  allRecords,
435
272
  await getTableSchema({ tableName: TABLE_MESSAGES, client: this.client })
436
273
  );
437
- const list = new MessageList({ threadId, resourceId }).add(messages.map(this.normalizeMessage), "memory");
438
- if (format === "v2") return list.get.all.v2();
439
- return list.get.all.v1();
274
+ const list = new MessageList().add(
275
+ messages.map(this.normalizeMessage),
276
+ "memory"
277
+ );
278
+ return { messages: list.get.all.db() };
440
279
  } catch (error) {
441
280
  throw new MastraError(
442
281
  {
443
- id: "LANCE_STORE_GET_MESSAGES_FAILED",
282
+ id: "LANCE_STORE_LIST_MESSAGES_BY_ID_FAILED",
444
283
  domain: ErrorDomain.STORAGE,
445
284
  category: ErrorCategory.THIRD_PARTY,
446
285
  details: {
447
- threadId,
448
- resourceId: resourceId ?? ""
286
+ messageIds: JSON.stringify(messageIds)
449
287
  }
450
288
  },
451
289
  error
452
290
  );
453
291
  }
454
292
  }
455
- async getMessagesById({
456
- messageIds,
457
- format
458
- }) {
459
- if (messageIds.length === 0) return [];
293
+ async listMessages(args) {
294
+ const { threadId, resourceId, include, filter, perPage: perPageInput, page = 0, orderBy } = args;
295
+ if (!threadId.trim()) {
296
+ throw new MastraError(
297
+ {
298
+ id: "STORAGE_LANCE_LIST_MESSAGES_INVALID_THREAD_ID",
299
+ domain: ErrorDomain.STORAGE,
300
+ category: ErrorCategory.THIRD_PARTY,
301
+ details: { threadId }
302
+ },
303
+ new Error("threadId must be a non-empty string")
304
+ );
305
+ }
306
+ const perPage = normalizePerPage(perPageInput, 40);
307
+ const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
460
308
  try {
309
+ if (page < 0) {
310
+ throw new MastraError(
311
+ {
312
+ id: "STORAGE_LANCE_LIST_MESSAGES_INVALID_PAGE",
313
+ domain: ErrorDomain.STORAGE,
314
+ category: ErrorCategory.USER,
315
+ details: { page }
316
+ },
317
+ new Error("page must be >= 0")
318
+ );
319
+ }
320
+ const { field, direction } = this.parseOrderBy(orderBy, "ASC");
461
321
  const table = await this.client.openTable(TABLE_MESSAGES);
462
- const quotedIds = messageIds.map((id) => `'${id}'`).join(", ");
463
- const allRecords = await table.query().where(`id IN (${quotedIds})`).toArray();
464
- const messages = processResultWithTypeConversion(
465
- allRecords,
466
- await getTableSchema({ tableName: TABLE_MESSAGES, client: this.client })
467
- );
468
- const list = new MessageList().add(messages.map(this.normalizeMessage), "memory");
469
- if (format === `v1`) return list.get.all.v1();
470
- return list.get.all.v2();
322
+ const conditions = [`thread_id = '${this.escapeSql(threadId)}'`];
323
+ if (resourceId) {
324
+ conditions.push(`\`resourceId\` = '${this.escapeSql(resourceId)}'`);
325
+ }
326
+ if (filter?.dateRange?.start) {
327
+ const startTime = filter.dateRange.start instanceof Date ? filter.dateRange.start.getTime() : new Date(filter.dateRange.start).getTime();
328
+ conditions.push(`\`createdAt\` >= ${startTime}`);
329
+ }
330
+ if (filter?.dateRange?.end) {
331
+ const endTime = filter.dateRange.end instanceof Date ? filter.dateRange.end.getTime() : new Date(filter.dateRange.end).getTime();
332
+ conditions.push(`\`createdAt\` <= ${endTime}`);
333
+ }
334
+ const whereClause = conditions.join(" AND ");
335
+ const total = await table.countRows(whereClause);
336
+ const query = table.query().where(whereClause);
337
+ let allRecords = await query.toArray();
338
+ allRecords.sort((a, b) => {
339
+ const aValue = field === "createdAt" ? a.createdAt : a[field];
340
+ const bValue = field === "createdAt" ? b.createdAt : b[field];
341
+ if (aValue == null && bValue == null) return 0;
342
+ if (aValue == null) return direction === "ASC" ? -1 : 1;
343
+ if (bValue == null) return direction === "ASC" ? 1 : -1;
344
+ if (typeof aValue === "string" && typeof bValue === "string") {
345
+ return direction === "ASC" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
346
+ }
347
+ return direction === "ASC" ? aValue - bValue : bValue - aValue;
348
+ });
349
+ const paginatedRecords = allRecords.slice(offset, offset + perPage);
350
+ const messages = paginatedRecords.map((row) => this.normalizeMessage(row));
351
+ if (total === 0 && messages.length === 0 && (!include || include.length === 0)) {
352
+ return {
353
+ messages: [],
354
+ total: 0,
355
+ page,
356
+ perPage: perPageForResponse,
357
+ hasMore: false
358
+ };
359
+ }
360
+ const messageIds = new Set(messages.map((m) => m.id));
361
+ if (include && include.length > 0) {
362
+ const threadIds = [...new Set(include.map((item) => item.threadId || threadId))];
363
+ const allThreadMessages = [];
364
+ for (const tid of threadIds) {
365
+ const threadQuery = table.query().where(`thread_id = '${tid}'`);
366
+ let threadRecords = await threadQuery.toArray();
367
+ allThreadMessages.push(...threadRecords);
368
+ }
369
+ allThreadMessages.sort((a, b) => a.createdAt - b.createdAt);
370
+ const contextMessages = this.processMessagesWithContext(allThreadMessages, include);
371
+ const includedMessages = contextMessages.map((row) => this.normalizeMessage(row));
372
+ for (const includeMsg of includedMessages) {
373
+ if (!messageIds.has(includeMsg.id)) {
374
+ messages.push(includeMsg);
375
+ messageIds.add(includeMsg.id);
376
+ }
377
+ }
378
+ }
379
+ const list = new MessageList().add(messages, "memory");
380
+ let finalMessages = list.get.all.db();
381
+ finalMessages = finalMessages.sort((a, b) => {
382
+ const aValue = field === "createdAt" ? new Date(a.createdAt).getTime() : a[field];
383
+ const bValue = field === "createdAt" ? new Date(b.createdAt).getTime() : b[field];
384
+ if (aValue == null && bValue == null) return 0;
385
+ if (aValue == null) return direction === "ASC" ? -1 : 1;
386
+ if (bValue == null) return direction === "ASC" ? 1 : -1;
387
+ if (typeof aValue === "string" && typeof bValue === "string") {
388
+ return direction === "ASC" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
389
+ }
390
+ return direction === "ASC" ? aValue - bValue : bValue - aValue;
391
+ });
392
+ const returnedThreadMessageIds = new Set(finalMessages.filter((m) => m.threadId === threadId).map((m) => m.id));
393
+ const allThreadMessagesReturned = returnedThreadMessageIds.size >= total;
394
+ const fetchedAll = perPageInput === false || allThreadMessagesReturned;
395
+ const hasMore = !fetchedAll && offset + perPage < total;
396
+ return {
397
+ messages: finalMessages,
398
+ total,
399
+ page,
400
+ perPage: perPageForResponse,
401
+ hasMore
402
+ };
471
403
  } catch (error) {
472
- throw new MastraError(
404
+ const mastraError = new MastraError(
473
405
  {
474
- id: "LANCE_STORE_GET_MESSAGES_BY_ID_FAILED",
406
+ id: "LANCE_STORE_LIST_MESSAGES_FAILED",
475
407
  domain: ErrorDomain.STORAGE,
476
408
  category: ErrorCategory.THIRD_PARTY,
477
409
  details: {
478
- messageIds: JSON.stringify(messageIds)
410
+ threadId,
411
+ resourceId: resourceId ?? ""
479
412
  }
480
413
  },
481
414
  error
482
415
  );
416
+ this.logger?.error?.(mastraError.toString());
417
+ this.logger?.trackException?.(mastraError);
418
+ return {
419
+ messages: [],
420
+ total: 0,
421
+ page,
422
+ perPage: perPageForResponse,
423
+ hasMore: false
424
+ };
483
425
  }
484
426
  }
485
427
  async saveMessages(args) {
486
428
  try {
487
- const { messages, format = "v1" } = args;
429
+ const { messages } = args;
488
430
  if (messages.length === 0) {
489
- return [];
431
+ return { messages: [] };
490
432
  }
491
433
  const threadId = messages[0]?.threadId;
492
434
  if (!threadId) {
@@ -522,8 +464,7 @@ var StoreMemoryLance = class extends MemoryStorage {
522
464
  const updateRecord = { id: threadId, updatedAt: currentTime };
523
465
  await threadsTable.mergeInsert("id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute([updateRecord]);
524
466
  const list = new MessageList().add(messages, "memory");
525
- if (format === `v2`) return list.get.all.v2();
526
- return list.get.all.v1();
467
+ return { messages: list.get.all.db() };
527
468
  } catch (error) {
528
469
  throw new MastraError(
529
470
  {
@@ -535,32 +476,54 @@ var StoreMemoryLance = class extends MemoryStorage {
535
476
  );
536
477
  }
537
478
  }
538
- async getThreadsByResourceIdPaginated(args) {
479
+ async listThreadsByResourceId(args) {
539
480
  try {
540
- const { resourceId, page = 0, perPage = 10 } = args;
541
- const table = await this.client.openTable(TABLE_THREADS);
542
- const total = await table.countRows(`\`resourceId\` = '${resourceId}'`);
543
- const query = table.query().where(`\`resourceId\` = '${resourceId}'`);
544
- const offset = page * perPage;
545
- query.limit(perPage);
546
- if (offset > 0) {
547
- query.offset(offset);
481
+ const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
482
+ const perPage = normalizePerPage(perPageInput, 100);
483
+ if (page < 0) {
484
+ throw new MastraError(
485
+ {
486
+ id: "STORAGE_LANCE_LIST_THREADS_BY_RESOURCE_ID_INVALID_PAGE",
487
+ domain: ErrorDomain.STORAGE,
488
+ category: ErrorCategory.USER,
489
+ details: { page }
490
+ },
491
+ new Error("page must be >= 0")
492
+ );
548
493
  }
494
+ const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
495
+ const { field, direction } = this.parseOrderBy(orderBy);
496
+ const table = await this.client.openTable(TABLE_THREADS);
497
+ const total = await table.countRows(`\`resourceId\` = '${this.escapeSql(resourceId)}'`);
498
+ const query = table.query().where(`\`resourceId\` = '${this.escapeSql(resourceId)}'`);
549
499
  const records = await query.toArray();
550
- records.sort((a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime());
500
+ records.sort((a, b) => {
501
+ const aValue = ["createdAt", "updatedAt"].includes(field) ? new Date(a[field]).getTime() : a[field];
502
+ const bValue = ["createdAt", "updatedAt"].includes(field) ? new Date(b[field]).getTime() : b[field];
503
+ if (aValue == null && bValue == null) return 0;
504
+ if (aValue == null) return direction === "ASC" ? -1 : 1;
505
+ if (bValue == null) return direction === "ASC" ? 1 : -1;
506
+ if (typeof aValue === "string" && typeof bValue === "string") {
507
+ return direction === "ASC" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
508
+ }
509
+ return direction === "ASC" ? aValue - bValue : bValue - aValue;
510
+ });
511
+ const paginatedRecords = records.slice(offset, offset + perPage);
551
512
  const schema = await getTableSchema({ tableName: TABLE_THREADS, client: this.client });
552
- const threads = records.map((record) => processResultWithTypeConversion(record, schema));
513
+ const threads = paginatedRecords.map(
514
+ (record) => processResultWithTypeConversion(record, schema)
515
+ );
553
516
  return {
554
517
  threads,
555
518
  total,
556
519
  page,
557
- perPage,
558
- hasMore: total > (page + 1) * perPage
520
+ perPage: perPageForResponse,
521
+ hasMore: offset + perPage < total
559
522
  };
560
523
  } catch (error) {
561
524
  throw new MastraError(
562
525
  {
563
- id: "LANCE_STORE_GET_THREADS_BY_RESOURCE_ID_PAGINATED_FAILED",
526
+ id: "LANCE_STORE_LIST_THREADS_BY_RESOURCE_ID_FAILED",
564
527
  domain: ErrorDomain.STORAGE,
565
528
  category: ErrorCategory.THIRD_PARTY
566
529
  },
@@ -616,132 +579,8 @@ var StoreMemoryLance = class extends MemoryStorage {
616
579
  });
617
580
  return Array.from(allIndices).sort((a, b) => a - b).map((index) => records[index]);
618
581
  }
619
- async getMessagesPaginated(args) {
620
- const { threadId, resourceId, selectBy, format = "v1" } = args;
621
- const page = selectBy?.pagination?.page ?? 0;
622
- const perPage = selectBy?.pagination?.perPage ?? 10;
623
- try {
624
- if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
625
- const dateRange = selectBy?.pagination?.dateRange;
626
- const fromDate = dateRange?.start;
627
- const toDate = dateRange?.end;
628
- const table = await this.client.openTable(TABLE_MESSAGES);
629
- const messages = [];
630
- if (selectBy?.include && Array.isArray(selectBy.include)) {
631
- const threadIds = [...new Set(selectBy.include.map((item) => item.threadId))];
632
- const allThreadMessages = [];
633
- for (const threadId2 of threadIds) {
634
- const threadQuery = table.query().where(`thread_id = '${threadId2}'`);
635
- let threadRecords = await threadQuery.toArray();
636
- if (fromDate) threadRecords = threadRecords.filter((m) => m.createdAt >= fromDate.getTime());
637
- if (toDate) threadRecords = threadRecords.filter((m) => m.createdAt <= toDate.getTime());
638
- allThreadMessages.push(...threadRecords);
639
- }
640
- allThreadMessages.sort((a, b) => a.createdAt - b.createdAt);
641
- const contextMessages = this.processMessagesWithContext(allThreadMessages, selectBy.include);
642
- messages.push(...contextMessages);
643
- }
644
- const conditions = [`thread_id = '${threadId}'`];
645
- if (resourceId) {
646
- conditions.push(`\`resourceId\` = '${resourceId}'`);
647
- }
648
- if (fromDate) {
649
- conditions.push(`\`createdAt\` >= ${fromDate.getTime()}`);
650
- }
651
- if (toDate) {
652
- conditions.push(`\`createdAt\` <= ${toDate.getTime()}`);
653
- }
654
- let total = 0;
655
- if (conditions.length > 0) {
656
- total = await table.countRows(conditions.join(" AND "));
657
- } else {
658
- total = await table.countRows();
659
- }
660
- if (total === 0 && messages.length === 0) {
661
- return {
662
- messages: [],
663
- total: 0,
664
- page,
665
- perPage,
666
- hasMore: false
667
- };
668
- }
669
- const excludeIds = messages.map((m) => m.id);
670
- let selectedMessages = [];
671
- if (selectBy?.last && selectBy.last > 0) {
672
- const query = table.query();
673
- if (conditions.length > 0) {
674
- query.where(conditions.join(" AND "));
675
- }
676
- let records = await query.toArray();
677
- records = records.sort((a, b) => a.createdAt - b.createdAt);
678
- if (excludeIds.length > 0) {
679
- records = records.filter((m) => !excludeIds.includes(m.id));
680
- }
681
- selectedMessages = records.slice(-selectBy.last);
682
- } else {
683
- const query = table.query();
684
- if (conditions.length > 0) {
685
- query.where(conditions.join(" AND "));
686
- }
687
- let records = await query.toArray();
688
- records = records.sort((a, b) => a.createdAt - b.createdAt);
689
- if (excludeIds.length > 0) {
690
- records = records.filter((m) => !excludeIds.includes(m.id));
691
- }
692
- selectedMessages = records.slice(page * perPage, (page + 1) * perPage);
693
- }
694
- const allMessages = [...messages, ...selectedMessages];
695
- const seen = /* @__PURE__ */ new Set();
696
- const dedupedMessages = allMessages.filter((m) => {
697
- const key = `${m.id}:${m.thread_id}`;
698
- if (seen.has(key)) return false;
699
- seen.add(key);
700
- return true;
701
- });
702
- const formattedMessages = dedupedMessages.map((msg) => {
703
- const { thread_id, ...rest } = msg;
704
- return {
705
- ...rest,
706
- threadId: thread_id,
707
- content: typeof msg.content === "string" ? (() => {
708
- try {
709
- return JSON.parse(msg.content);
710
- } catch {
711
- return msg.content;
712
- }
713
- })() : msg.content
714
- };
715
- });
716
- const list = new MessageList().add(formattedMessages, "memory");
717
- return {
718
- messages: format === "v2" ? list.get.all.v2() : list.get.all.v1(),
719
- total,
720
- // Total should be the count of messages matching the filters
721
- page,
722
- perPage,
723
- hasMore: total > (page + 1) * perPage
724
- };
725
- } catch (error) {
726
- const mastraError = new MastraError(
727
- {
728
- id: "LANCE_STORE_GET_MESSAGES_PAGINATED_FAILED",
729
- domain: ErrorDomain.STORAGE,
730
- category: ErrorCategory.THIRD_PARTY,
731
- details: {
732
- threadId,
733
- resourceId: resourceId ?? ""
734
- }
735
- },
736
- error
737
- );
738
- this.logger?.trackException?.(mastraError);
739
- this.logger?.error?.(mastraError.toString());
740
- return { messages: [], total: 0, page, perPage, hasMore: false };
741
- }
742
- }
743
582
  /**
744
- * Parse message data from LanceDB record format to MastraMessageV2 format
583
+ * Parse message data from LanceDB record format to MastraDBMessage format
745
584
  */
746
585
  parseMessageData(data) {
747
586
  const { thread_id, ...rest } = data;
@@ -1464,7 +1303,7 @@ var StoreScoresLance = class extends ScoresStorage {
1464
1303
  );
1465
1304
  }
1466
1305
  }
1467
- async getScoresByScorerId({
1306
+ async listScoresByScorerId({
1468
1307
  scorerId,
1469
1308
  pagination,
1470
1309
  entityId,
@@ -1472,9 +1311,10 @@ var StoreScoresLance = class extends ScoresStorage {
1472
1311
  source
1473
1312
  }) {
1474
1313
  try {
1314
+ const { page, perPage: perPageInput } = pagination;
1315
+ const perPage = normalizePerPage(perPageInput, 100);
1316
+ const { offset: start, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
1475
1317
  const table = await this.client.openTable(TABLE_SCORERS);
1476
- const { page = 0, perPage = 10 } = pagination || {};
1477
- const offset = page * perPage;
1478
1318
  let query = table.query().where(`\`scorerId\` = '${scorerId}'`);
1479
1319
  if (source) {
1480
1320
  query = query.where(`\`source\` = '${source}'`);
@@ -1485,23 +1325,32 @@ var StoreScoresLance = class extends ScoresStorage {
1485
1325
  if (entityType) {
1486
1326
  query = query.where(`\`entityType\` = '${entityType}'`);
1487
1327
  }
1488
- query = query.limit(perPage);
1489
- if (offset > 0) query.offset(offset);
1490
- const records = await query.toArray();
1491
- const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
1492
- const scores = processResultWithTypeConversion(records, schema);
1493
1328
  let totalQuery = table.query().where(`\`scorerId\` = '${scorerId}'`);
1494
1329
  if (source) {
1495
1330
  totalQuery = totalQuery.where(`\`source\` = '${source}'`);
1496
1331
  }
1332
+ if (entityId) {
1333
+ totalQuery = totalQuery.where(`\`entityId\` = '${entityId}'`);
1334
+ }
1335
+ if (entityType) {
1336
+ totalQuery = totalQuery.where(`\`entityType\` = '${entityType}'`);
1337
+ }
1497
1338
  const allRecords = await totalQuery.toArray();
1498
1339
  const total = allRecords.length;
1340
+ const end = perPageInput === false ? total : start + perPage;
1341
+ if (perPageInput !== false) {
1342
+ query = query.limit(perPage);
1343
+ if (start > 0) query = query.offset(start);
1344
+ }
1345
+ const records = await query.toArray();
1346
+ const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
1347
+ const scores = processResultWithTypeConversion(records, schema);
1499
1348
  return {
1500
1349
  pagination: {
1501
1350
  page,
1502
- perPage,
1351
+ perPage: perPageForResponse,
1503
1352
  total,
1504
- hasMore: offset + scores.length < total
1353
+ hasMore: end < total
1505
1354
  },
1506
1355
  scores
1507
1356
  };
@@ -1518,27 +1367,32 @@ var StoreScoresLance = class extends ScoresStorage {
1518
1367
  );
1519
1368
  }
1520
1369
  }
1521
- async getScoresByRunId({
1370
+ async listScoresByRunId({
1522
1371
  runId,
1523
1372
  pagination
1524
1373
  }) {
1525
1374
  try {
1375
+ const { page, perPage: perPageInput } = pagination;
1376
+ const perPage = normalizePerPage(perPageInput, 100);
1377
+ const { offset: start, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
1526
1378
  const table = await this.client.openTable(TABLE_SCORERS);
1527
- const { page = 0, perPage = 10 } = pagination || {};
1528
- const offset = page * perPage;
1529
- const query = table.query().where(`\`runId\` = '${runId}'`).limit(perPage);
1530
- if (offset > 0) query.offset(offset);
1379
+ const allRecords = await table.query().where(`\`runId\` = '${runId}'`).toArray();
1380
+ const total = allRecords.length;
1381
+ const end = perPageInput === false ? total : start + perPage;
1382
+ let query = table.query().where(`\`runId\` = '${runId}'`);
1383
+ if (perPageInput !== false) {
1384
+ query = query.limit(perPage);
1385
+ if (start > 0) query = query.offset(start);
1386
+ }
1531
1387
  const records = await query.toArray();
1532
1388
  const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
1533
1389
  const scores = processResultWithTypeConversion(records, schema);
1534
- const allRecords = await table.query().where(`\`runId\` = '${runId}'`).toArray();
1535
- const total = allRecords.length;
1536
1390
  return {
1537
1391
  pagination: {
1538
1392
  page,
1539
- perPage,
1393
+ perPage: perPageForResponse,
1540
1394
  total,
1541
- hasMore: offset + scores.length < total
1395
+ hasMore: end < total
1542
1396
  },
1543
1397
  scores
1544
1398
  };
@@ -1555,28 +1409,33 @@ var StoreScoresLance = class extends ScoresStorage {
1555
1409
  );
1556
1410
  }
1557
1411
  }
1558
- async getScoresByEntityId({
1412
+ async listScoresByEntityId({
1559
1413
  entityId,
1560
1414
  entityType,
1561
1415
  pagination
1562
1416
  }) {
1563
1417
  try {
1418
+ const { page, perPage: perPageInput } = pagination;
1419
+ const perPage = normalizePerPage(perPageInput, 100);
1420
+ const { offset: start, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
1564
1421
  const table = await this.client.openTable(TABLE_SCORERS);
1565
- const { page = 0, perPage = 10 } = pagination || {};
1566
- const offset = page * perPage;
1567
- const query = table.query().where(`\`entityId\` = '${entityId}' AND \`entityType\` = '${entityType}'`).limit(perPage);
1568
- if (offset > 0) query.offset(offset);
1422
+ const allRecords = await table.query().where(`\`entityId\` = '${entityId}' AND \`entityType\` = '${entityType}'`).toArray();
1423
+ const total = allRecords.length;
1424
+ const end = perPageInput === false ? total : start + perPage;
1425
+ let query = table.query().where(`\`entityId\` = '${entityId}' AND \`entityType\` = '${entityType}'`);
1426
+ if (perPageInput !== false) {
1427
+ query = query.limit(perPage);
1428
+ if (start > 0) query = query.offset(start);
1429
+ }
1569
1430
  const records = await query.toArray();
1570
1431
  const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
1571
1432
  const scores = processResultWithTypeConversion(records, schema);
1572
- const allRecords = await table.query().where(`\`entityId\` = '${entityId}' AND \`entityType\` = '${entityType}'`).toArray();
1573
- const total = allRecords.length;
1574
1433
  return {
1575
1434
  pagination: {
1576
1435
  page,
1577
- perPage,
1436
+ perPage: perPageForResponse,
1578
1437
  total,
1579
- hasMore: offset + scores.length < total
1438
+ hasMore: end < total
1580
1439
  },
1581
1440
  scores
1582
1441
  };
@@ -1593,28 +1452,33 @@ var StoreScoresLance = class extends ScoresStorage {
1593
1452
  );
1594
1453
  }
1595
1454
  }
1596
- async getScoresBySpan({
1455
+ async listScoresBySpan({
1597
1456
  traceId,
1598
1457
  spanId,
1599
1458
  pagination
1600
1459
  }) {
1601
1460
  try {
1461
+ const { page, perPage: perPageInput } = pagination;
1462
+ const perPage = normalizePerPage(perPageInput, 100);
1463
+ const { offset: start, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
1602
1464
  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);
1465
+ const allRecords = await table.query().where(`\`traceId\` = '${traceId}' AND \`spanId\` = '${spanId}'`).toArray();
1466
+ const total = allRecords.length;
1467
+ const end = perPageInput === false ? total : start + perPage;
1468
+ let query = table.query().where(`\`traceId\` = '${traceId}' AND \`spanId\` = '${spanId}'`);
1469
+ if (perPageInput !== false) {
1470
+ query = query.limit(perPage);
1471
+ if (start > 0) query = query.offset(start);
1472
+ }
1607
1473
  const records = await query.toArray();
1608
1474
  const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
1609
1475
  const scores = processResultWithTypeConversion(records, schema);
1610
- const allRecords = await table.query().where(`\`traceId\` = '${traceId}' AND \`spanId\` = '${spanId}'`).toArray();
1611
- const total = allRecords.length;
1612
1476
  return {
1613
1477
  pagination: {
1614
1478
  page,
1615
- perPage,
1479
+ perPage: perPageForResponse,
1616
1480
  total,
1617
- hasMore: offset + scores.length < total
1481
+ hasMore: end < total
1618
1482
  },
1619
1483
  scores
1620
1484
  };
@@ -1661,7 +1525,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1661
1525
  // runId,
1662
1526
  // stepId,
1663
1527
  // result,
1664
- // runtimeContext,
1528
+ // requestContext,
1665
1529
  }) {
1666
1530
  throw new Error("Method not implemented.");
1667
1531
  }
@@ -1689,11 +1553,13 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1689
1553
  } else {
1690
1554
  createdAt = now;
1691
1555
  }
1556
+ const { status, value, ...rest } = snapshot;
1692
1557
  const record = {
1693
1558
  workflow_name: workflowName,
1694
1559
  run_id: runId,
1695
1560
  resourceId,
1696
- snapshot: JSON.stringify(snapshot),
1561
+ snapshot: JSON.stringify({ status, value, ...rest }),
1562
+ // this is to ensure status is always just before value, for when querying the db by status
1697
1563
  createdAt,
1698
1564
  updatedAt: now
1699
1565
  };
@@ -1755,7 +1621,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1755
1621
  );
1756
1622
  }
1757
1623
  }
1758
- async getWorkflowRuns(args) {
1624
+ async listWorkflowRuns(args) {
1759
1625
  try {
1760
1626
  const table = await this.client.openTable(TABLE_WORKFLOW_SNAPSHOT);
1761
1627
  let query = table.query();
@@ -1763,6 +1629,10 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1763
1629
  if (args?.workflowName) {
1764
1630
  conditions.push(`workflow_name = '${args.workflowName.replace(/'/g, "''")}'`);
1765
1631
  }
1632
+ if (args?.status) {
1633
+ const escapedStatus = args.status.replace(/\\/g, "\\\\").replace(/'/g, "''").replace(/%/g, "\\%").replace(/_/g, "\\_");
1634
+ conditions.push(`\`snapshot\` LIKE '%"status":"${escapedStatus}","value"%'`);
1635
+ }
1766
1636
  if (args?.resourceId) {
1767
1637
  conditions.push(`\`resourceId\` = '${args.resourceId}'`);
1768
1638
  }
@@ -1779,11 +1649,22 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1779
1649
  } else {
1780
1650
  total = await table.countRows();
1781
1651
  }
1782
- if (args?.limit) {
1783
- query.limit(args.limit);
1784
- }
1785
- if (args?.offset) {
1786
- query.offset(args.offset);
1652
+ if (args?.perPage !== void 0 && args?.page !== void 0) {
1653
+ const normalizedPerPage = normalizePerPage(args.perPage, Number.MAX_SAFE_INTEGER);
1654
+ if (args.page < 0 || !Number.isInteger(args.page)) {
1655
+ throw new MastraError(
1656
+ {
1657
+ id: "LANCE_STORE_INVALID_PAGINATION_PARAMS",
1658
+ domain: ErrorDomain.STORAGE,
1659
+ category: ErrorCategory.USER,
1660
+ details: { page: args.page, perPage: args.perPage }
1661
+ },
1662
+ new Error(`Invalid pagination parameters: page=${args.page}, perPage=${args.perPage}`)
1663
+ );
1664
+ }
1665
+ const offset = args.page * normalizedPerPage;
1666
+ query.limit(normalizedPerPage);
1667
+ query.offset(offset);
1787
1668
  }
1788
1669
  const records = await query.toArray();
1789
1670
  return {
@@ -1793,10 +1674,10 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
1793
1674
  } catch (error) {
1794
1675
  throw new MastraError(
1795
1676
  {
1796
- id: "LANCE_STORE_GET_WORKFLOW_RUNS_FAILED",
1677
+ id: "LANCE_STORE_LIST_WORKFLOW_RUNS_FAILED",
1797
1678
  domain: ErrorDomain.STORAGE,
1798
1679
  category: ErrorCategory.THIRD_PARTY,
1799
- details: { namespace: args?.namespace ?? "", workflowName: args?.workflowName ?? "" }
1680
+ details: { resourceId: args?.resourceId ?? "", workflowName: args?.workflowName ?? "" }
1800
1681
  },
1801
1682
  error
1802
1683
  );
@@ -1810,6 +1691,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
1810
1691
  lanceClient;
1811
1692
  /**
1812
1693
  * Creates a new instance of LanceStorage
1694
+ * @param id The unique identifier for this storage instance
1695
+ * @param name The name for this storage instance
1813
1696
  * @param uri The URI to connect to LanceDB
1814
1697
  * @param options connection options
1815
1698
  *
@@ -1817,21 +1700,21 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
1817
1700
  *
1818
1701
  * Connect to a local database
1819
1702
  * ```ts
1820
- * const store = await LanceStorage.create('/path/to/db');
1703
+ * const store = await LanceStorage.create('my-storage-id', 'MyStorage', '/path/to/db');
1821
1704
  * ```
1822
1705
  *
1823
1706
  * Connect to a LanceDB cloud database
1824
1707
  * ```ts
1825
- * const store = await LanceStorage.create('db://host:port');
1708
+ * const store = await LanceStorage.create('my-storage-id', 'MyStorage', 'db://host:port');
1826
1709
  * ```
1827
1710
  *
1828
1711
  * Connect to a cloud database
1829
1712
  * ```ts
1830
- * const store = await LanceStorage.create('s3://bucket/db', { storageOptions: { timeout: '60s' } });
1713
+ * const store = await LanceStorage.create('my-storage-id', 'MyStorage', 's3://bucket/db', { storageOptions: { timeout: '60s' } });
1831
1714
  * ```
1832
1715
  */
1833
- static async create(name, uri, options) {
1834
- const instance = new _LanceStorage(name);
1716
+ static async create(id, name, uri, options) {
1717
+ const instance = new _LanceStorage(id, name);
1835
1718
  try {
1836
1719
  instance.lanceClient = await connect(uri, options);
1837
1720
  const operations = new StoreOperationsLance({ client: instance.lanceClient });
@@ -1839,8 +1722,7 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
1839
1722
  operations: new StoreOperationsLance({ client: instance.lanceClient }),
1840
1723
  workflows: new StoreWorkflowsLance({ client: instance.lanceClient }),
1841
1724
  scores: new StoreScoresLance({ client: instance.lanceClient }),
1842
- memory: new StoreMemoryLance({ client: instance.lanceClient, operations }),
1843
- legacyEvals: new StoreLegacyEvalsLance({ client: instance.lanceClient })
1725
+ memory: new StoreMemoryLance({ client: instance.lanceClient, operations })
1844
1726
  };
1845
1727
  return instance;
1846
1728
  } catch (e) {
@@ -1860,14 +1742,13 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
1860
1742
  * @internal
1861
1743
  * Private constructor to enforce using the create factory method
1862
1744
  */
1863
- constructor(name) {
1864
- super({ name });
1745
+ constructor(id, name) {
1746
+ super({ id, name });
1865
1747
  const operations = new StoreOperationsLance({ client: this.lanceClient });
1866
1748
  this.stores = {
1867
1749
  operations: new StoreOperationsLance({ client: this.lanceClient }),
1868
1750
  workflows: new StoreWorkflowsLance({ client: this.lanceClient }),
1869
1751
  scores: new StoreScoresLance({ client: this.lanceClient }),
1870
- legacyEvals: new StoreLegacyEvalsLance({ client: this.lanceClient }),
1871
1752
  memory: new StoreMemoryLance({ client: this.lanceClient, operations })
1872
1753
  };
1873
1754
  }
@@ -1902,9 +1783,6 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
1902
1783
  async getThreadById({ threadId }) {
1903
1784
  return this.stores.memory.getThreadById({ threadId });
1904
1785
  }
1905
- async getThreadsByResourceId({ resourceId }) {
1906
- return this.stores.memory.getThreadsByResourceId({ resourceId });
1907
- }
1908
1786
  /**
1909
1787
  * Saves a thread to the database. This function doesn't overwrite existing threads.
1910
1788
  * @param thread - The thread to save
@@ -1930,7 +1808,7 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
1930
1808
  hasColumn: true,
1931
1809
  createTable: true,
1932
1810
  deleteMessages: false,
1933
- getScoresBySpan: true
1811
+ listScoresBySpan: true
1934
1812
  };
1935
1813
  }
1936
1814
  async getResourceById({ resourceId }) {
@@ -1994,41 +1872,17 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
1994
1872
  });
1995
1873
  return Array.from(allIndices).sort((a, b) => a - b).map((index) => records[index]);
1996
1874
  }
1997
- async getMessages({
1998
- threadId,
1999
- resourceId,
2000
- selectBy,
2001
- format,
2002
- threadConfig
2003
- }) {
2004
- return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format, threadConfig });
2005
- }
2006
- async getMessagesById({
2007
- messageIds,
2008
- format
2009
- }) {
2010
- return this.stores.memory.getMessagesById({ messageIds, format });
1875
+ async listMessagesById({ messageIds }) {
1876
+ return this.stores.memory.listMessagesById({ messageIds });
2011
1877
  }
2012
1878
  async saveMessages(args) {
2013
1879
  return this.stores.memory.saveMessages(args);
2014
1880
  }
2015
- async getThreadsByResourceIdPaginated(args) {
2016
- return this.stores.memory.getThreadsByResourceIdPaginated(args);
2017
- }
2018
- async getMessagesPaginated(args) {
2019
- return this.stores.memory.getMessagesPaginated(args);
2020
- }
2021
1881
  async updateMessages(_args) {
2022
1882
  return this.stores.memory.updateMessages(_args);
2023
1883
  }
2024
- async getEvalsByAgentName(agentName, type) {
2025
- return this.stores.legacyEvals.getEvalsByAgentName(agentName, type);
2026
- }
2027
- async getEvals(options) {
2028
- return this.stores.legacyEvals.getEvals(options);
2029
- }
2030
- async getWorkflowRuns(args) {
2031
- return this.stores.workflows.getWorkflowRuns(args);
1884
+ async listWorkflowRuns(args) {
1885
+ return this.stores.workflows.listWorkflowRuns(args);
2032
1886
  }
2033
1887
  async getWorkflowRunById(args) {
2034
1888
  return this.stores.workflows.getWorkflowRunById(args);
@@ -2038,9 +1892,9 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2038
1892
  runId,
2039
1893
  stepId,
2040
1894
  result,
2041
- runtimeContext
1895
+ requestContext
2042
1896
  }) {
2043
- return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, runtimeContext });
1897
+ return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, requestContext });
2044
1898
  }
2045
1899
  async updateWorkflowState({
2046
1900
  workflowName,
@@ -2066,37 +1920,37 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
2066
1920
  async getScoreById({ id: _id }) {
2067
1921
  return this.stores.scores.getScoreById({ id: _id });
2068
1922
  }
2069
- async getScoresByScorerId({
1923
+ async listScoresByScorerId({
2070
1924
  scorerId,
2071
1925
  source,
2072
1926
  entityId,
2073
1927
  entityType,
2074
1928
  pagination
2075
1929
  }) {
2076
- return this.stores.scores.getScoresByScorerId({ scorerId, source, pagination, entityId, entityType });
1930
+ return this.stores.scores.listScoresByScorerId({ scorerId, source, pagination, entityId, entityType });
2077
1931
  }
2078
1932
  async saveScore(_score) {
2079
1933
  return this.stores.scores.saveScore(_score);
2080
1934
  }
2081
- async getScoresByRunId({
1935
+ async listScoresByRunId({
2082
1936
  runId,
2083
1937
  pagination
2084
1938
  }) {
2085
- return this.stores.scores.getScoresByRunId({ runId, pagination });
1939
+ return this.stores.scores.listScoresByRunId({ runId, pagination });
2086
1940
  }
2087
- async getScoresByEntityId({
1941
+ async listScoresByEntityId({
2088
1942
  entityId,
2089
1943
  entityType,
2090
1944
  pagination
2091
1945
  }) {
2092
- return this.stores.scores.getScoresByEntityId({ entityId, entityType, pagination });
1946
+ return this.stores.scores.listScoresByEntityId({ entityId, entityType, pagination });
2093
1947
  }
2094
- async getScoresBySpan({
1948
+ async listScoresBySpan({
2095
1949
  traceId,
2096
1950
  spanId,
2097
1951
  pagination
2098
1952
  }) {
2099
- return this.stores.scores.getScoresBySpan({ traceId, spanId, pagination });
1953
+ return this.stores.scores.listScoresBySpan({ traceId, spanId, pagination });
2100
1954
  }
2101
1955
  };
2102
1956
  var LanceFilterTranslator = class extends BaseFilterTranslator {
@@ -2445,7 +2299,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
2445
2299
  * ```
2446
2300
  */
2447
2301
  static async create(uri, options) {
2448
- const instance = new _LanceVectorStore();
2302
+ const instance = new _LanceVectorStore(options?.id || crypto.randomUUID());
2449
2303
  try {
2450
2304
  instance.lanceClient = await connect(uri, options);
2451
2305
  return instance;
@@ -2465,8 +2319,8 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
2465
2319
  * @internal
2466
2320
  * Private constructor to enforce using the create factory method
2467
2321
  */
2468
- constructor() {
2469
- super();
2322
+ constructor(id) {
2323
+ super({ id });
2470
2324
  }
2471
2325
  close() {
2472
2326
  if (this.lanceClient) {