@mastra/lance 0.0.0-vector-query-tool-provider-options-20250828222356 → 0.0.0-vnext-20251104230439
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 +392 -3
- package/dist/index.cjs +336 -553
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +337 -554
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +18 -39
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/operations/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +12 -4
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/utils.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +6 -12
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +33 -83
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +21 -8
- package/dist/storage/domains/legacy-evals/index.d.ts +0 -25
- package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
- package/dist/storage/domains/traces/index.d.ts +0 -34
- package/dist/storage/domains/traces/index.d.ts.map +0 -1
- package/eslint.config.js +0 -6
- package/src/index.ts +0 -2
- package/src/storage/domains/legacy-evals/index.ts +0 -156
- package/src/storage/domains/memory/index.ts +0 -1000
- package/src/storage/domains/operations/index.ts +0 -489
- package/src/storage/domains/scores/index.ts +0 -243
- package/src/storage/domains/traces/index.ts +0 -212
- package/src/storage/domains/utils.ts +0 -158
- package/src/storage/domains/workflows/index.ts +0 -245
- package/src/storage/index.test.ts +0 -10
- package/src/storage/index.ts +0 -494
- package/src/vector/filter.test.ts +0 -295
- package/src/vector/filter.ts +0 -443
- package/src/vector/index.test.ts +0 -1493
- package/src/vector/index.ts +0 -941
- package/src/vector/types.ts +0 -16
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -17
- package/vitest.config.ts +0 -11
package/dist/index.cjs
CHANGED
|
@@ -5,130 +5,15 @@ 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 evals = require('@mastra/core/evals');
|
|
8
9
|
var vector = require('@mastra/core/vector');
|
|
9
10
|
var filter = require('@mastra/core/vector/filter');
|
|
10
11
|
|
|
11
12
|
// src/storage/index.ts
|
|
12
|
-
var StoreLegacyEvalsLance = class extends storage.LegacyEvalsStorage {
|
|
13
|
-
client;
|
|
14
|
-
constructor({ client }) {
|
|
15
|
-
super();
|
|
16
|
-
this.client = client;
|
|
17
|
-
}
|
|
18
|
-
async getEvalsByAgentName(agentName, type) {
|
|
19
|
-
try {
|
|
20
|
-
const table = await this.client.openTable(storage.TABLE_EVALS);
|
|
21
|
-
const query = table.query().where(`agent_name = '${agentName}'`);
|
|
22
|
-
const records = await query.toArray();
|
|
23
|
-
let filteredRecords = records;
|
|
24
|
-
if (type === "live") {
|
|
25
|
-
filteredRecords = records.filter((record) => record.test_info === null);
|
|
26
|
-
} else if (type === "test") {
|
|
27
|
-
filteredRecords = records.filter((record) => record.test_info !== null);
|
|
28
|
-
}
|
|
29
|
-
return filteredRecords.map((record) => {
|
|
30
|
-
return {
|
|
31
|
-
id: record.id,
|
|
32
|
-
input: record.input,
|
|
33
|
-
output: record.output,
|
|
34
|
-
agentName: record.agent_name,
|
|
35
|
-
metricName: record.metric_name,
|
|
36
|
-
result: JSON.parse(record.result),
|
|
37
|
-
instructions: record.instructions,
|
|
38
|
-
testInfo: record.test_info ? JSON.parse(record.test_info) : null,
|
|
39
|
-
globalRunId: record.global_run_id,
|
|
40
|
-
runId: record.run_id,
|
|
41
|
-
createdAt: new Date(record.created_at).toString()
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
} catch (error$1) {
|
|
45
|
-
throw new error.MastraError(
|
|
46
|
-
{
|
|
47
|
-
id: "LANCE_STORE_GET_EVALS_BY_AGENT_NAME_FAILED",
|
|
48
|
-
domain: error.ErrorDomain.STORAGE,
|
|
49
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
50
|
-
details: { agentName }
|
|
51
|
-
},
|
|
52
|
-
error$1
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async getEvals(options) {
|
|
57
|
-
try {
|
|
58
|
-
const table = await this.client.openTable(storage.TABLE_EVALS);
|
|
59
|
-
const conditions = [];
|
|
60
|
-
if (options.agentName) {
|
|
61
|
-
conditions.push(`agent_name = '${options.agentName}'`);
|
|
62
|
-
}
|
|
63
|
-
if (options.type === "live") {
|
|
64
|
-
conditions.push("length(test_info) = 0");
|
|
65
|
-
} else if (options.type === "test") {
|
|
66
|
-
conditions.push("length(test_info) > 0");
|
|
67
|
-
}
|
|
68
|
-
const startDate = options.dateRange?.start || options.fromDate;
|
|
69
|
-
const endDate = options.dateRange?.end || options.toDate;
|
|
70
|
-
if (startDate) {
|
|
71
|
-
conditions.push(`\`created_at\` >= ${startDate.getTime()}`);
|
|
72
|
-
}
|
|
73
|
-
if (endDate) {
|
|
74
|
-
conditions.push(`\`created_at\` <= ${endDate.getTime()}`);
|
|
75
|
-
}
|
|
76
|
-
let total = 0;
|
|
77
|
-
if (conditions.length > 0) {
|
|
78
|
-
total = await table.countRows(conditions.join(" AND "));
|
|
79
|
-
} else {
|
|
80
|
-
total = await table.countRows();
|
|
81
|
-
}
|
|
82
|
-
const query = table.query();
|
|
83
|
-
if (conditions.length > 0) {
|
|
84
|
-
const whereClause = conditions.join(" AND ");
|
|
85
|
-
query.where(whereClause);
|
|
86
|
-
}
|
|
87
|
-
const records = await query.toArray();
|
|
88
|
-
const evals = records.sort((a, b) => b.created_at - a.created_at).map((record) => {
|
|
89
|
-
return {
|
|
90
|
-
id: record.id,
|
|
91
|
-
input: record.input,
|
|
92
|
-
output: record.output,
|
|
93
|
-
agentName: record.agent_name,
|
|
94
|
-
metricName: record.metric_name,
|
|
95
|
-
result: JSON.parse(record.result),
|
|
96
|
-
instructions: record.instructions,
|
|
97
|
-
testInfo: record.test_info ? JSON.parse(record.test_info) : null,
|
|
98
|
-
globalRunId: record.global_run_id,
|
|
99
|
-
runId: record.run_id,
|
|
100
|
-
createdAt: new Date(record.created_at).toISOString()
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
const page = options.page || 0;
|
|
104
|
-
const perPage = options.perPage || 10;
|
|
105
|
-
const pagedEvals = evals.slice(page * perPage, (page + 1) * perPage);
|
|
106
|
-
return {
|
|
107
|
-
evals: pagedEvals,
|
|
108
|
-
total,
|
|
109
|
-
page,
|
|
110
|
-
perPage,
|
|
111
|
-
hasMore: total > (page + 1) * perPage
|
|
112
|
-
};
|
|
113
|
-
} catch (error$1) {
|
|
114
|
-
throw new error.MastraError(
|
|
115
|
-
{
|
|
116
|
-
id: "LANCE_STORE_GET_EVALS_FAILED",
|
|
117
|
-
domain: error.ErrorDomain.STORAGE,
|
|
118
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
119
|
-
details: { agentName: options.agentName ?? "" }
|
|
120
|
-
},
|
|
121
|
-
error$1
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
13
|
function getPrimaryKeys(tableName) {
|
|
127
14
|
let primaryId = ["id"];
|
|
128
15
|
if (tableName === storage.TABLE_WORKFLOW_SNAPSHOT) {
|
|
129
16
|
primaryId = ["workflow_name", "run_id"];
|
|
130
|
-
} else if (tableName === storage.TABLE_EVALS) {
|
|
131
|
-
primaryId = ["agent_name", "metric_name", "run_id"];
|
|
132
17
|
}
|
|
133
18
|
return primaryId;
|
|
134
19
|
}
|
|
@@ -189,7 +74,6 @@ function processResultWithTypeConversion(rawResult, tableSchema) {
|
|
|
189
74
|
} else if (fieldTypeStr.includes("float64") && ["createdAt", "updatedAt"].includes(key)) {
|
|
190
75
|
processedResult[key] = new Date(processedResult[key]);
|
|
191
76
|
}
|
|
192
|
-
console.log(key, "processedResult", processedResult);
|
|
193
77
|
}
|
|
194
78
|
return processedResult;
|
|
195
79
|
}
|
|
@@ -249,6 +133,10 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
249
133
|
this.client = client;
|
|
250
134
|
this.operations = operations;
|
|
251
135
|
}
|
|
136
|
+
// Utility to escape single quotes in SQL strings
|
|
137
|
+
escapeSql(str) {
|
|
138
|
+
return str.replace(/'/g, "''");
|
|
139
|
+
}
|
|
252
140
|
async getThreadById({ threadId }) {
|
|
253
141
|
try {
|
|
254
142
|
const thread = await this.operations.load({ tableName: storage.TABLE_THREADS, keys: { id: threadId } });
|
|
@@ -271,26 +159,6 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
271
159
|
);
|
|
272
160
|
}
|
|
273
161
|
}
|
|
274
|
-
async getThreadsByResourceId({ resourceId }) {
|
|
275
|
-
try {
|
|
276
|
-
const table = await this.client.openTable(storage.TABLE_THREADS);
|
|
277
|
-
const query = table.query().where(`\`resourceId\` = '${resourceId}'`);
|
|
278
|
-
const records = await query.toArray();
|
|
279
|
-
return processResultWithTypeConversion(
|
|
280
|
-
records,
|
|
281
|
-
await getTableSchema({ tableName: storage.TABLE_THREADS, client: this.client })
|
|
282
|
-
);
|
|
283
|
-
} catch (error$1) {
|
|
284
|
-
throw new error.MastraError(
|
|
285
|
-
{
|
|
286
|
-
id: "LANCE_STORE_GET_THREADS_BY_RESOURCE_ID_FAILED",
|
|
287
|
-
domain: error.ErrorDomain.STORAGE,
|
|
288
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
289
|
-
},
|
|
290
|
-
error$1
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
162
|
/**
|
|
295
163
|
* Saves a thread to the database. This function doesn't overwrite existing threads.
|
|
296
164
|
* @param thread - The thread to save
|
|
@@ -399,10 +267,10 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
399
267
|
threadId,
|
|
400
268
|
resourceId,
|
|
401
269
|
selectBy,
|
|
402
|
-
format,
|
|
403
270
|
threadConfig
|
|
404
271
|
}) {
|
|
405
272
|
try {
|
|
273
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
406
274
|
if (threadConfig) {
|
|
407
275
|
throw new Error("ThreadConfig is not supported by LanceDB storage");
|
|
408
276
|
}
|
|
@@ -435,25 +303,28 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
435
303
|
allRecords,
|
|
436
304
|
await getTableSchema({ tableName: storage.TABLE_MESSAGES, client: this.client })
|
|
437
305
|
);
|
|
438
|
-
const list = new agent.MessageList({ threadId, resourceId }).add(
|
|
439
|
-
|
|
440
|
-
|
|
306
|
+
const list = new agent.MessageList({ threadId, resourceId }).add(
|
|
307
|
+
messages.map(this.normalizeMessage),
|
|
308
|
+
"memory"
|
|
309
|
+
);
|
|
310
|
+
return { messages: list.get.all.db() };
|
|
441
311
|
} catch (error$1) {
|
|
442
312
|
throw new error.MastraError(
|
|
443
313
|
{
|
|
444
314
|
id: "LANCE_STORE_GET_MESSAGES_FAILED",
|
|
445
315
|
domain: error.ErrorDomain.STORAGE,
|
|
446
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
316
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
317
|
+
details: {
|
|
318
|
+
threadId,
|
|
319
|
+
resourceId: resourceId ?? ""
|
|
320
|
+
}
|
|
447
321
|
},
|
|
448
322
|
error$1
|
|
449
323
|
);
|
|
450
324
|
}
|
|
451
325
|
}
|
|
452
|
-
async
|
|
453
|
-
messageIds
|
|
454
|
-
format
|
|
455
|
-
}) {
|
|
456
|
-
if (messageIds.length === 0) return [];
|
|
326
|
+
async listMessagesById({ messageIds }) {
|
|
327
|
+
if (messageIds.length === 0) return { messages: [] };
|
|
457
328
|
try {
|
|
458
329
|
const table = await this.client.openTable(storage.TABLE_MESSAGES);
|
|
459
330
|
const quotedIds = messageIds.map((id) => `'${id}'`).join(", ");
|
|
@@ -462,13 +333,15 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
462
333
|
allRecords,
|
|
463
334
|
await getTableSchema({ tableName: storage.TABLE_MESSAGES, client: this.client })
|
|
464
335
|
);
|
|
465
|
-
const list = new agent.MessageList().add(
|
|
466
|
-
|
|
467
|
-
|
|
336
|
+
const list = new agent.MessageList().add(
|
|
337
|
+
messages.map(this.normalizeMessage),
|
|
338
|
+
"memory"
|
|
339
|
+
);
|
|
340
|
+
return { messages: list.get.all.db() };
|
|
468
341
|
} catch (error$1) {
|
|
469
342
|
throw new error.MastraError(
|
|
470
343
|
{
|
|
471
|
-
id: "
|
|
344
|
+
id: "LANCE_STORE_LIST_MESSAGES_BY_ID_FAILED",
|
|
472
345
|
domain: error.ErrorDomain.STORAGE,
|
|
473
346
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
474
347
|
details: {
|
|
@@ -479,11 +352,145 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
479
352
|
);
|
|
480
353
|
}
|
|
481
354
|
}
|
|
355
|
+
async listMessages(args) {
|
|
356
|
+
const { threadId, resourceId, include, filter, perPage: perPageInput, page = 0, orderBy } = args;
|
|
357
|
+
if (!threadId.trim()) {
|
|
358
|
+
throw new error.MastraError(
|
|
359
|
+
{
|
|
360
|
+
id: "STORAGE_LANCE_LIST_MESSAGES_INVALID_THREAD_ID",
|
|
361
|
+
domain: error.ErrorDomain.STORAGE,
|
|
362
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
363
|
+
details: { threadId }
|
|
364
|
+
},
|
|
365
|
+
new Error("threadId must be a non-empty string")
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
const perPage = storage.normalizePerPage(perPageInput, 40);
|
|
369
|
+
const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
370
|
+
try {
|
|
371
|
+
if (page < 0) {
|
|
372
|
+
throw new error.MastraError(
|
|
373
|
+
{
|
|
374
|
+
id: "STORAGE_LANCE_LIST_MESSAGES_INVALID_PAGE",
|
|
375
|
+
domain: error.ErrorDomain.STORAGE,
|
|
376
|
+
category: error.ErrorCategory.USER,
|
|
377
|
+
details: { page }
|
|
378
|
+
},
|
|
379
|
+
new Error("page must be >= 0")
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
const { field, direction } = this.parseOrderBy(orderBy);
|
|
383
|
+
const table = await this.client.openTable(storage.TABLE_MESSAGES);
|
|
384
|
+
const conditions = [`thread_id = '${this.escapeSql(threadId)}'`];
|
|
385
|
+
if (resourceId) {
|
|
386
|
+
conditions.push(`\`resourceId\` = '${this.escapeSql(resourceId)}'`);
|
|
387
|
+
}
|
|
388
|
+
if (filter?.dateRange?.start) {
|
|
389
|
+
const startTime = filter.dateRange.start instanceof Date ? filter.dateRange.start.getTime() : new Date(filter.dateRange.start).getTime();
|
|
390
|
+
conditions.push(`\`createdAt\` >= ${startTime}`);
|
|
391
|
+
}
|
|
392
|
+
if (filter?.dateRange?.end) {
|
|
393
|
+
const endTime = filter.dateRange.end instanceof Date ? filter.dateRange.end.getTime() : new Date(filter.dateRange.end).getTime();
|
|
394
|
+
conditions.push(`\`createdAt\` <= ${endTime}`);
|
|
395
|
+
}
|
|
396
|
+
const whereClause = conditions.join(" AND ");
|
|
397
|
+
const total = await table.countRows(whereClause);
|
|
398
|
+
const query = table.query().where(whereClause);
|
|
399
|
+
let allRecords = await query.toArray();
|
|
400
|
+
allRecords.sort((a, b) => {
|
|
401
|
+
const aValue = field === "createdAt" ? a.createdAt : a[field];
|
|
402
|
+
const bValue = field === "createdAt" ? b.createdAt : b[field];
|
|
403
|
+
if (aValue == null && bValue == null) return 0;
|
|
404
|
+
if (aValue == null) return direction === "ASC" ? -1 : 1;
|
|
405
|
+
if (bValue == null) return direction === "ASC" ? 1 : -1;
|
|
406
|
+
if (typeof aValue === "string" && typeof bValue === "string") {
|
|
407
|
+
return direction === "ASC" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
|
|
408
|
+
}
|
|
409
|
+
return direction === "ASC" ? aValue - bValue : bValue - aValue;
|
|
410
|
+
});
|
|
411
|
+
const paginatedRecords = allRecords.slice(offset, offset + perPage);
|
|
412
|
+
const messages = paginatedRecords.map((row) => this.normalizeMessage(row));
|
|
413
|
+
if (total === 0 && messages.length === 0 && (!include || include.length === 0)) {
|
|
414
|
+
return {
|
|
415
|
+
messages: [],
|
|
416
|
+
total: 0,
|
|
417
|
+
page,
|
|
418
|
+
perPage: perPageForResponse,
|
|
419
|
+
hasMore: false
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
const messageIds = new Set(messages.map((m) => m.id));
|
|
423
|
+
if (include && include.length > 0) {
|
|
424
|
+
const threadIds = [...new Set(include.map((item) => item.threadId || threadId))];
|
|
425
|
+
const allThreadMessages = [];
|
|
426
|
+
for (const tid of threadIds) {
|
|
427
|
+
const threadQuery = table.query().where(`thread_id = '${tid}'`);
|
|
428
|
+
let threadRecords = await threadQuery.toArray();
|
|
429
|
+
allThreadMessages.push(...threadRecords);
|
|
430
|
+
}
|
|
431
|
+
allThreadMessages.sort((a, b) => a.createdAt - b.createdAt);
|
|
432
|
+
const contextMessages = this.processMessagesWithContext(allThreadMessages, include);
|
|
433
|
+
const includedMessages = contextMessages.map((row) => this.normalizeMessage(row));
|
|
434
|
+
for (const includeMsg of includedMessages) {
|
|
435
|
+
if (!messageIds.has(includeMsg.id)) {
|
|
436
|
+
messages.push(includeMsg);
|
|
437
|
+
messageIds.add(includeMsg.id);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
const list = new agent.MessageList().add(messages, "memory");
|
|
442
|
+
let finalMessages = list.get.all.db();
|
|
443
|
+
finalMessages = finalMessages.sort((a, b) => {
|
|
444
|
+
const aValue = field === "createdAt" ? new Date(a.createdAt).getTime() : a[field];
|
|
445
|
+
const bValue = field === "createdAt" ? new Date(b.createdAt).getTime() : b[field];
|
|
446
|
+
if (aValue == null && bValue == null) return 0;
|
|
447
|
+
if (aValue == null) return direction === "ASC" ? -1 : 1;
|
|
448
|
+
if (bValue == null) return direction === "ASC" ? 1 : -1;
|
|
449
|
+
if (typeof aValue === "string" && typeof bValue === "string") {
|
|
450
|
+
return direction === "ASC" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
|
|
451
|
+
}
|
|
452
|
+
return direction === "ASC" ? aValue - bValue : bValue - aValue;
|
|
453
|
+
});
|
|
454
|
+
const returnedThreadMessageIds = new Set(finalMessages.filter((m) => m.threadId === threadId).map((m) => m.id));
|
|
455
|
+
const allThreadMessagesReturned = returnedThreadMessageIds.size >= total;
|
|
456
|
+
const fetchedAll = perPageInput === false || allThreadMessagesReturned;
|
|
457
|
+
const hasMore = !fetchedAll && offset + perPage < total;
|
|
458
|
+
return {
|
|
459
|
+
messages: finalMessages,
|
|
460
|
+
total,
|
|
461
|
+
page,
|
|
462
|
+
perPage: perPageForResponse,
|
|
463
|
+
hasMore
|
|
464
|
+
};
|
|
465
|
+
} catch (error$1) {
|
|
466
|
+
const mastraError = new error.MastraError(
|
|
467
|
+
{
|
|
468
|
+
id: "LANCE_STORE_LIST_MESSAGES_FAILED",
|
|
469
|
+
domain: error.ErrorDomain.STORAGE,
|
|
470
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
471
|
+
details: {
|
|
472
|
+
threadId,
|
|
473
|
+
resourceId: resourceId ?? ""
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
error$1
|
|
477
|
+
);
|
|
478
|
+
this.logger?.error?.(mastraError.toString());
|
|
479
|
+
this.logger?.trackException?.(mastraError);
|
|
480
|
+
return {
|
|
481
|
+
messages: [],
|
|
482
|
+
total: 0,
|
|
483
|
+
page,
|
|
484
|
+
perPage: perPageForResponse,
|
|
485
|
+
hasMore: false
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
}
|
|
482
489
|
async saveMessages(args) {
|
|
483
490
|
try {
|
|
484
|
-
const { messages
|
|
491
|
+
const { messages } = args;
|
|
485
492
|
if (messages.length === 0) {
|
|
486
|
-
return [];
|
|
493
|
+
return { messages: [] };
|
|
487
494
|
}
|
|
488
495
|
const threadId = messages[0]?.threadId;
|
|
489
496
|
if (!threadId) {
|
|
@@ -519,8 +526,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
519
526
|
const updateRecord = { id: threadId, updatedAt: currentTime };
|
|
520
527
|
await threadsTable.mergeInsert("id").whenMatchedUpdateAll().whenNotMatchedInsertAll().execute([updateRecord]);
|
|
521
528
|
const list = new agent.MessageList().add(messages, "memory");
|
|
522
|
-
|
|
523
|
-
return list.get.all.v1();
|
|
529
|
+
return { messages: list.get.all.db() };
|
|
524
530
|
} catch (error$1) {
|
|
525
531
|
throw new error.MastraError(
|
|
526
532
|
{
|
|
@@ -532,32 +538,54 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
532
538
|
);
|
|
533
539
|
}
|
|
534
540
|
}
|
|
535
|
-
async
|
|
541
|
+
async listThreadsByResourceId(args) {
|
|
536
542
|
try {
|
|
537
|
-
const { resourceId, page = 0, perPage
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
543
|
+
const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
|
|
544
|
+
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
545
|
+
if (page < 0) {
|
|
546
|
+
throw new error.MastraError(
|
|
547
|
+
{
|
|
548
|
+
id: "STORAGE_LANCE_LIST_THREADS_BY_RESOURCE_ID_INVALID_PAGE",
|
|
549
|
+
domain: error.ErrorDomain.STORAGE,
|
|
550
|
+
category: error.ErrorCategory.USER,
|
|
551
|
+
details: { page }
|
|
552
|
+
},
|
|
553
|
+
new Error("page must be >= 0")
|
|
554
|
+
);
|
|
545
555
|
}
|
|
556
|
+
const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
557
|
+
const { field, direction } = this.parseOrderBy(orderBy);
|
|
558
|
+
const table = await this.client.openTable(storage.TABLE_THREADS);
|
|
559
|
+
const total = await table.countRows(`\`resourceId\` = '${this.escapeSql(resourceId)}'`);
|
|
560
|
+
const query = table.query().where(`\`resourceId\` = '${this.escapeSql(resourceId)}'`);
|
|
546
561
|
const records = await query.toArray();
|
|
547
|
-
records.sort((a, b) =>
|
|
562
|
+
records.sort((a, b) => {
|
|
563
|
+
const aValue = ["createdAt", "updatedAt"].includes(field) ? new Date(a[field]).getTime() : a[field];
|
|
564
|
+
const bValue = ["createdAt", "updatedAt"].includes(field) ? new Date(b[field]).getTime() : b[field];
|
|
565
|
+
if (aValue == null && bValue == null) return 0;
|
|
566
|
+
if (aValue == null) return direction === "ASC" ? -1 : 1;
|
|
567
|
+
if (bValue == null) return direction === "ASC" ? 1 : -1;
|
|
568
|
+
if (typeof aValue === "string" && typeof bValue === "string") {
|
|
569
|
+
return direction === "ASC" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
|
|
570
|
+
}
|
|
571
|
+
return direction === "ASC" ? aValue - bValue : bValue - aValue;
|
|
572
|
+
});
|
|
573
|
+
const paginatedRecords = records.slice(offset, offset + perPage);
|
|
548
574
|
const schema = await getTableSchema({ tableName: storage.TABLE_THREADS, client: this.client });
|
|
549
|
-
const threads =
|
|
575
|
+
const threads = paginatedRecords.map(
|
|
576
|
+
(record) => processResultWithTypeConversion(record, schema)
|
|
577
|
+
);
|
|
550
578
|
return {
|
|
551
579
|
threads,
|
|
552
580
|
total,
|
|
553
581
|
page,
|
|
554
|
-
perPage,
|
|
555
|
-
hasMore:
|
|
582
|
+
perPage: perPageForResponse,
|
|
583
|
+
hasMore: offset + perPage < total
|
|
556
584
|
};
|
|
557
585
|
} catch (error$1) {
|
|
558
586
|
throw new error.MastraError(
|
|
559
587
|
{
|
|
560
|
-
id: "
|
|
588
|
+
id: "LANCE_STORE_LIST_THREADS_BY_RESOURCE_ID_FAILED",
|
|
561
589
|
domain: error.ErrorDomain.STORAGE,
|
|
562
590
|
category: error.ErrorCategory.THIRD_PARTY
|
|
563
591
|
},
|
|
@@ -613,127 +641,8 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
613
641
|
});
|
|
614
642
|
return Array.from(allIndices).sort((a, b) => a - b).map((index) => records[index]);
|
|
615
643
|
}
|
|
616
|
-
async getMessagesPaginated(args) {
|
|
617
|
-
try {
|
|
618
|
-
const { threadId, resourceId, selectBy, format = "v1" } = args;
|
|
619
|
-
if (!threadId) {
|
|
620
|
-
throw new Error("Thread ID is required for getMessagesPaginated");
|
|
621
|
-
}
|
|
622
|
-
const page = selectBy?.pagination?.page ?? 0;
|
|
623
|
-
const perPage = selectBy?.pagination?.perPage ?? 10;
|
|
624
|
-
const dateRange = selectBy?.pagination?.dateRange;
|
|
625
|
-
const fromDate = dateRange?.start;
|
|
626
|
-
const toDate = dateRange?.end;
|
|
627
|
-
const table = await this.client.openTable(storage.TABLE_MESSAGES);
|
|
628
|
-
const messages = [];
|
|
629
|
-
if (selectBy?.include && Array.isArray(selectBy.include)) {
|
|
630
|
-
const threadIds = [...new Set(selectBy.include.map((item) => item.threadId))];
|
|
631
|
-
const allThreadMessages = [];
|
|
632
|
-
for (const threadId2 of threadIds) {
|
|
633
|
-
const threadQuery = table.query().where(`thread_id = '${threadId2}'`);
|
|
634
|
-
let threadRecords = await threadQuery.toArray();
|
|
635
|
-
if (fromDate) threadRecords = threadRecords.filter((m) => m.createdAt >= fromDate.getTime());
|
|
636
|
-
if (toDate) threadRecords = threadRecords.filter((m) => m.createdAt <= toDate.getTime());
|
|
637
|
-
allThreadMessages.push(...threadRecords);
|
|
638
|
-
}
|
|
639
|
-
allThreadMessages.sort((a, b) => a.createdAt - b.createdAt);
|
|
640
|
-
const contextMessages = this.processMessagesWithContext(allThreadMessages, selectBy.include);
|
|
641
|
-
messages.push(...contextMessages);
|
|
642
|
-
}
|
|
643
|
-
const conditions = [`thread_id = '${threadId}'`];
|
|
644
|
-
if (resourceId) {
|
|
645
|
-
conditions.push(`\`resourceId\` = '${resourceId}'`);
|
|
646
|
-
}
|
|
647
|
-
if (fromDate) {
|
|
648
|
-
conditions.push(`\`createdAt\` >= ${fromDate.getTime()}`);
|
|
649
|
-
}
|
|
650
|
-
if (toDate) {
|
|
651
|
-
conditions.push(`\`createdAt\` <= ${toDate.getTime()}`);
|
|
652
|
-
}
|
|
653
|
-
let total = 0;
|
|
654
|
-
if (conditions.length > 0) {
|
|
655
|
-
total = await table.countRows(conditions.join(" AND "));
|
|
656
|
-
} else {
|
|
657
|
-
total = await table.countRows();
|
|
658
|
-
}
|
|
659
|
-
if (total === 0 && messages.length === 0) {
|
|
660
|
-
return {
|
|
661
|
-
messages: [],
|
|
662
|
-
total: 0,
|
|
663
|
-
page,
|
|
664
|
-
perPage,
|
|
665
|
-
hasMore: false
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
const excludeIds = messages.map((m) => m.id);
|
|
669
|
-
let selectedMessages = [];
|
|
670
|
-
if (selectBy?.last && selectBy.last > 0) {
|
|
671
|
-
const query = table.query();
|
|
672
|
-
if (conditions.length > 0) {
|
|
673
|
-
query.where(conditions.join(" AND "));
|
|
674
|
-
}
|
|
675
|
-
let records = await query.toArray();
|
|
676
|
-
records = records.sort((a, b) => a.createdAt - b.createdAt);
|
|
677
|
-
if (excludeIds.length > 0) {
|
|
678
|
-
records = records.filter((m) => !excludeIds.includes(m.id));
|
|
679
|
-
}
|
|
680
|
-
selectedMessages = records.slice(-selectBy.last);
|
|
681
|
-
} else {
|
|
682
|
-
const query = table.query();
|
|
683
|
-
if (conditions.length > 0) {
|
|
684
|
-
query.where(conditions.join(" AND "));
|
|
685
|
-
}
|
|
686
|
-
let records = await query.toArray();
|
|
687
|
-
records = records.sort((a, b) => a.createdAt - b.createdAt);
|
|
688
|
-
if (excludeIds.length > 0) {
|
|
689
|
-
records = records.filter((m) => !excludeIds.includes(m.id));
|
|
690
|
-
}
|
|
691
|
-
selectedMessages = records.slice(page * perPage, (page + 1) * perPage);
|
|
692
|
-
}
|
|
693
|
-
const allMessages = [...messages, ...selectedMessages];
|
|
694
|
-
const seen = /* @__PURE__ */ new Set();
|
|
695
|
-
const dedupedMessages = allMessages.filter((m) => {
|
|
696
|
-
const key = `${m.id}:${m.thread_id}`;
|
|
697
|
-
if (seen.has(key)) return false;
|
|
698
|
-
seen.add(key);
|
|
699
|
-
return true;
|
|
700
|
-
});
|
|
701
|
-
const formattedMessages = dedupedMessages.map((msg) => {
|
|
702
|
-
const { thread_id, ...rest } = msg;
|
|
703
|
-
return {
|
|
704
|
-
...rest,
|
|
705
|
-
threadId: thread_id,
|
|
706
|
-
content: typeof msg.content === "string" ? (() => {
|
|
707
|
-
try {
|
|
708
|
-
return JSON.parse(msg.content);
|
|
709
|
-
} catch {
|
|
710
|
-
return msg.content;
|
|
711
|
-
}
|
|
712
|
-
})() : msg.content
|
|
713
|
-
};
|
|
714
|
-
});
|
|
715
|
-
const list = new agent.MessageList().add(formattedMessages, "memory");
|
|
716
|
-
return {
|
|
717
|
-
messages: format === "v2" ? list.get.all.v2() : list.get.all.v1(),
|
|
718
|
-
total,
|
|
719
|
-
// Total should be the count of messages matching the filters
|
|
720
|
-
page,
|
|
721
|
-
perPage,
|
|
722
|
-
hasMore: total > (page + 1) * perPage
|
|
723
|
-
};
|
|
724
|
-
} catch (error$1) {
|
|
725
|
-
throw new error.MastraError(
|
|
726
|
-
{
|
|
727
|
-
id: "LANCE_STORE_GET_MESSAGES_PAGINATED_FAILED",
|
|
728
|
-
domain: error.ErrorDomain.STORAGE,
|
|
729
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
730
|
-
},
|
|
731
|
-
error$1
|
|
732
|
-
);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
644
|
/**
|
|
736
|
-
* Parse message data from LanceDB record format to
|
|
645
|
+
* Parse message data from LanceDB record format to MastraDBMessage format
|
|
737
646
|
*/
|
|
738
647
|
parseMessageData(data) {
|
|
739
648
|
const { thread_id, ...rest } = data;
|
|
@@ -1256,7 +1165,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
1256
1165
|
processedRecord[key] = JSON.stringify(processedRecord[key]);
|
|
1257
1166
|
}
|
|
1258
1167
|
}
|
|
1259
|
-
console.
|
|
1168
|
+
console.info(await table.schema());
|
|
1260
1169
|
await table.mergeInsert(primaryId).whenMatchedUpdateAll().whenNotMatchedInsertAll().execute([processedRecord]);
|
|
1261
1170
|
} catch (error$1) {
|
|
1262
1171
|
throw new error.MastraError(
|
|
@@ -1306,7 +1215,6 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
1306
1215
|
}
|
|
1307
1216
|
return processedRecord;
|
|
1308
1217
|
});
|
|
1309
|
-
console.log(processedRecords);
|
|
1310
1218
|
await table.mergeInsert(primaryId).whenMatchedUpdateAll().whenNotMatchedInsertAll().execute(processedRecords);
|
|
1311
1219
|
} catch (error$1) {
|
|
1312
1220
|
throw new error.MastraError(
|
|
@@ -1390,13 +1298,27 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1390
1298
|
this.client = client;
|
|
1391
1299
|
}
|
|
1392
1300
|
async saveScore(score) {
|
|
1301
|
+
let validatedScore;
|
|
1302
|
+
try {
|
|
1303
|
+
validatedScore = evals.saveScorePayloadSchema.parse(score);
|
|
1304
|
+
} catch (error$1) {
|
|
1305
|
+
throw new error.MastraError(
|
|
1306
|
+
{
|
|
1307
|
+
id: "LANCE_STORAGE_SAVE_SCORE_FAILED",
|
|
1308
|
+
text: "Failed to save score in LanceStorage",
|
|
1309
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1310
|
+
category: error.ErrorCategory.THIRD_PARTY
|
|
1311
|
+
},
|
|
1312
|
+
error$1
|
|
1313
|
+
);
|
|
1314
|
+
}
|
|
1393
1315
|
try {
|
|
1394
1316
|
const id = crypto.randomUUID();
|
|
1395
1317
|
const table = await this.client.openTable(storage.TABLE_SCORERS);
|
|
1396
1318
|
const schema = await getTableSchema({ tableName: storage.TABLE_SCORERS, client: this.client });
|
|
1397
1319
|
const allowedFields = new Set(schema.fields.map((f) => f.name));
|
|
1398
1320
|
const filteredScore = {};
|
|
1399
|
-
Object.keys(
|
|
1321
|
+
Object.keys(validatedScore).forEach((key) => {
|
|
1400
1322
|
if (allowedFields.has(key)) {
|
|
1401
1323
|
filteredScore[key] = score[key];
|
|
1402
1324
|
}
|
|
@@ -1443,7 +1365,7 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1443
1365
|
);
|
|
1444
1366
|
}
|
|
1445
1367
|
}
|
|
1446
|
-
async
|
|
1368
|
+
async listScoresByScorerId({
|
|
1447
1369
|
scorerId,
|
|
1448
1370
|
pagination,
|
|
1449
1371
|
entityId,
|
|
@@ -1451,9 +1373,10 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1451
1373
|
source
|
|
1452
1374
|
}) {
|
|
1453
1375
|
try {
|
|
1376
|
+
const { page, perPage: perPageInput } = pagination;
|
|
1377
|
+
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
1378
|
+
const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
1454
1379
|
const table = await this.client.openTable(storage.TABLE_SCORERS);
|
|
1455
|
-
const { page = 0, perPage = 10 } = pagination || {};
|
|
1456
|
-
const offset = page * perPage;
|
|
1457
1380
|
let query = table.query().where(`\`scorerId\` = '${scorerId}'`);
|
|
1458
1381
|
if (source) {
|
|
1459
1382
|
query = query.where(`\`source\` = '${source}'`);
|
|
@@ -1464,23 +1387,32 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1464
1387
|
if (entityType) {
|
|
1465
1388
|
query = query.where(`\`entityType\` = '${entityType}'`);
|
|
1466
1389
|
}
|
|
1467
|
-
query = query.limit(perPage);
|
|
1468
|
-
if (offset > 0) query.offset(offset);
|
|
1469
|
-
const records = await query.toArray();
|
|
1470
|
-
const schema = await getTableSchema({ tableName: storage.TABLE_SCORERS, client: this.client });
|
|
1471
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1472
1390
|
let totalQuery = table.query().where(`\`scorerId\` = '${scorerId}'`);
|
|
1473
1391
|
if (source) {
|
|
1474
1392
|
totalQuery = totalQuery.where(`\`source\` = '${source}'`);
|
|
1475
1393
|
}
|
|
1394
|
+
if (entityId) {
|
|
1395
|
+
totalQuery = totalQuery.where(`\`entityId\` = '${entityId}'`);
|
|
1396
|
+
}
|
|
1397
|
+
if (entityType) {
|
|
1398
|
+
totalQuery = totalQuery.where(`\`entityType\` = '${entityType}'`);
|
|
1399
|
+
}
|
|
1476
1400
|
const allRecords = await totalQuery.toArray();
|
|
1477
1401
|
const total = allRecords.length;
|
|
1402
|
+
const end = perPageInput === false ? total : start + perPage;
|
|
1403
|
+
if (perPageInput !== false) {
|
|
1404
|
+
query = query.limit(perPage);
|
|
1405
|
+
if (start > 0) query = query.offset(start);
|
|
1406
|
+
}
|
|
1407
|
+
const records = await query.toArray();
|
|
1408
|
+
const schema = await getTableSchema({ tableName: storage.TABLE_SCORERS, client: this.client });
|
|
1409
|
+
const scores = processResultWithTypeConversion(records, schema);
|
|
1478
1410
|
return {
|
|
1479
1411
|
pagination: {
|
|
1480
1412
|
page,
|
|
1481
|
-
perPage,
|
|
1413
|
+
perPage: perPageForResponse,
|
|
1482
1414
|
total,
|
|
1483
|
-
hasMore:
|
|
1415
|
+
hasMore: end < total
|
|
1484
1416
|
},
|
|
1485
1417
|
scores
|
|
1486
1418
|
};
|
|
@@ -1497,27 +1429,32 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1497
1429
|
);
|
|
1498
1430
|
}
|
|
1499
1431
|
}
|
|
1500
|
-
async
|
|
1432
|
+
async listScoresByRunId({
|
|
1501
1433
|
runId,
|
|
1502
1434
|
pagination
|
|
1503
1435
|
}) {
|
|
1504
1436
|
try {
|
|
1437
|
+
const { page, perPage: perPageInput } = pagination;
|
|
1438
|
+
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
1439
|
+
const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
1505
1440
|
const table = await this.client.openTable(storage.TABLE_SCORERS);
|
|
1506
|
-
const
|
|
1507
|
-
const
|
|
1508
|
-
const
|
|
1509
|
-
|
|
1441
|
+
const allRecords = await table.query().where(`\`runId\` = '${runId}'`).toArray();
|
|
1442
|
+
const total = allRecords.length;
|
|
1443
|
+
const end = perPageInput === false ? total : start + perPage;
|
|
1444
|
+
let query = table.query().where(`\`runId\` = '${runId}'`);
|
|
1445
|
+
if (perPageInput !== false) {
|
|
1446
|
+
query = query.limit(perPage);
|
|
1447
|
+
if (start > 0) query = query.offset(start);
|
|
1448
|
+
}
|
|
1510
1449
|
const records = await query.toArray();
|
|
1511
1450
|
const schema = await getTableSchema({ tableName: storage.TABLE_SCORERS, client: this.client });
|
|
1512
1451
|
const scores = processResultWithTypeConversion(records, schema);
|
|
1513
|
-
const allRecords = await table.query().where(`\`runId\` = '${runId}'`).toArray();
|
|
1514
|
-
const total = allRecords.length;
|
|
1515
1452
|
return {
|
|
1516
1453
|
pagination: {
|
|
1517
1454
|
page,
|
|
1518
|
-
perPage,
|
|
1455
|
+
perPage: perPageForResponse,
|
|
1519
1456
|
total,
|
|
1520
|
-
hasMore:
|
|
1457
|
+
hasMore: end < total
|
|
1521
1458
|
},
|
|
1522
1459
|
scores
|
|
1523
1460
|
};
|
|
@@ -1534,28 +1471,33 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1534
1471
|
);
|
|
1535
1472
|
}
|
|
1536
1473
|
}
|
|
1537
|
-
async
|
|
1474
|
+
async listScoresByEntityId({
|
|
1538
1475
|
entityId,
|
|
1539
1476
|
entityType,
|
|
1540
1477
|
pagination
|
|
1541
1478
|
}) {
|
|
1542
1479
|
try {
|
|
1480
|
+
const { page, perPage: perPageInput } = pagination;
|
|
1481
|
+
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
1482
|
+
const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
1543
1483
|
const table = await this.client.openTable(storage.TABLE_SCORERS);
|
|
1544
|
-
const
|
|
1545
|
-
const
|
|
1546
|
-
const
|
|
1547
|
-
|
|
1484
|
+
const allRecords = await table.query().where(`\`entityId\` = '${entityId}' AND \`entityType\` = '${entityType}'`).toArray();
|
|
1485
|
+
const total = allRecords.length;
|
|
1486
|
+
const end = perPageInput === false ? total : start + perPage;
|
|
1487
|
+
let query = table.query().where(`\`entityId\` = '${entityId}' AND \`entityType\` = '${entityType}'`);
|
|
1488
|
+
if (perPageInput !== false) {
|
|
1489
|
+
query = query.limit(perPage);
|
|
1490
|
+
if (start > 0) query = query.offset(start);
|
|
1491
|
+
}
|
|
1548
1492
|
const records = await query.toArray();
|
|
1549
1493
|
const schema = await getTableSchema({ tableName: storage.TABLE_SCORERS, client: this.client });
|
|
1550
1494
|
const scores = processResultWithTypeConversion(records, schema);
|
|
1551
|
-
const allRecords = await table.query().where(`\`entityId\` = '${entityId}' AND \`entityType\` = '${entityType}'`).toArray();
|
|
1552
|
-
const total = allRecords.length;
|
|
1553
1495
|
return {
|
|
1554
1496
|
pagination: {
|
|
1555
1497
|
page,
|
|
1556
|
-
perPage,
|
|
1498
|
+
perPage: perPageForResponse,
|
|
1557
1499
|
total,
|
|
1558
|
-
hasMore:
|
|
1500
|
+
hasMore: end < total
|
|
1559
1501
|
},
|
|
1560
1502
|
scores
|
|
1561
1503
|
};
|
|
@@ -1572,198 +1514,49 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1572
1514
|
);
|
|
1573
1515
|
}
|
|
1574
1516
|
}
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
constructor({ client, operations }) {
|
|
1580
|
-
super();
|
|
1581
|
-
this.client = client;
|
|
1582
|
-
this.operations = operations;
|
|
1583
|
-
}
|
|
1584
|
-
async saveTrace({ trace }) {
|
|
1585
|
-
try {
|
|
1586
|
-
const table = await this.client.openTable(storage.TABLE_TRACES);
|
|
1587
|
-
const record = {
|
|
1588
|
-
...trace,
|
|
1589
|
-
attributes: JSON.stringify(trace.attributes),
|
|
1590
|
-
status: JSON.stringify(trace.status),
|
|
1591
|
-
events: JSON.stringify(trace.events),
|
|
1592
|
-
links: JSON.stringify(trace.links),
|
|
1593
|
-
other: JSON.stringify(trace.other)
|
|
1594
|
-
};
|
|
1595
|
-
await table.add([record], { mode: "append" });
|
|
1596
|
-
return trace;
|
|
1597
|
-
} catch (error$1) {
|
|
1598
|
-
throw new error.MastraError(
|
|
1599
|
-
{
|
|
1600
|
-
id: "LANCE_STORE_SAVE_TRACE_FAILED",
|
|
1601
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1602
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1603
|
-
},
|
|
1604
|
-
error$1
|
|
1605
|
-
);
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
async getTraceById({ traceId }) {
|
|
1609
|
-
try {
|
|
1610
|
-
const table = await this.client.openTable(storage.TABLE_TRACES);
|
|
1611
|
-
const query = table.query().where(`id = '${traceId}'`);
|
|
1612
|
-
const records = await query.toArray();
|
|
1613
|
-
return records[0];
|
|
1614
|
-
} catch (error$1) {
|
|
1615
|
-
throw new error.MastraError(
|
|
1616
|
-
{
|
|
1617
|
-
id: "LANCE_STORE_GET_TRACE_BY_ID_FAILED",
|
|
1618
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1619
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1620
|
-
},
|
|
1621
|
-
error$1
|
|
1622
|
-
);
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
async getTraces({
|
|
1626
|
-
name,
|
|
1627
|
-
scope,
|
|
1628
|
-
page = 1,
|
|
1629
|
-
perPage = 10,
|
|
1630
|
-
attributes
|
|
1517
|
+
async listScoresBySpan({
|
|
1518
|
+
traceId,
|
|
1519
|
+
spanId,
|
|
1520
|
+
pagination
|
|
1631
1521
|
}) {
|
|
1632
1522
|
try {
|
|
1633
|
-
const
|
|
1634
|
-
const
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
}
|
|
1641
|
-
if (
|
|
1642
|
-
query
|
|
1643
|
-
|
|
1644
|
-
const offset = (page - 1) * perPage;
|
|
1645
|
-
query.limit(perPage);
|
|
1646
|
-
if (offset > 0) {
|
|
1647
|
-
query.offset(offset);
|
|
1648
|
-
}
|
|
1649
|
-
const records = await query.toArray();
|
|
1650
|
-
return records.map((record) => {
|
|
1651
|
-
const processed = {
|
|
1652
|
-
...record,
|
|
1653
|
-
attributes: record.attributes ? JSON.parse(record.attributes) : {},
|
|
1654
|
-
status: record.status ? JSON.parse(record.status) : {},
|
|
1655
|
-
events: record.events ? JSON.parse(record.events) : [],
|
|
1656
|
-
links: record.links ? JSON.parse(record.links) : [],
|
|
1657
|
-
other: record.other ? JSON.parse(record.other) : {},
|
|
1658
|
-
startTime: new Date(record.startTime),
|
|
1659
|
-
endTime: new Date(record.endTime),
|
|
1660
|
-
createdAt: new Date(record.createdAt)
|
|
1661
|
-
};
|
|
1662
|
-
if (processed.parentSpanId === null || processed.parentSpanId === void 0) {
|
|
1663
|
-
processed.parentSpanId = "";
|
|
1664
|
-
} else {
|
|
1665
|
-
processed.parentSpanId = String(processed.parentSpanId);
|
|
1666
|
-
}
|
|
1667
|
-
return processed;
|
|
1668
|
-
});
|
|
1669
|
-
} catch (error$1) {
|
|
1670
|
-
throw new error.MastraError(
|
|
1671
|
-
{
|
|
1672
|
-
id: "LANCE_STORE_GET_TRACES_FAILED",
|
|
1673
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1674
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1675
|
-
details: { name: name ?? "", scope: scope ?? "" }
|
|
1676
|
-
},
|
|
1677
|
-
error$1
|
|
1678
|
-
);
|
|
1679
|
-
}
|
|
1680
|
-
}
|
|
1681
|
-
async getTracesPaginated(args) {
|
|
1682
|
-
try {
|
|
1683
|
-
const table = await this.client.openTable(storage.TABLE_TRACES);
|
|
1684
|
-
const query = table.query();
|
|
1685
|
-
const conditions = [];
|
|
1686
|
-
if (args.name) {
|
|
1687
|
-
conditions.push(`name = '${args.name}'`);
|
|
1688
|
-
}
|
|
1689
|
-
if (args.scope) {
|
|
1690
|
-
conditions.push(`scope = '${args.scope}'`);
|
|
1691
|
-
}
|
|
1692
|
-
if (args.attributes) {
|
|
1693
|
-
const attributesStr = JSON.stringify(args.attributes);
|
|
1694
|
-
conditions.push(`attributes LIKE '%${attributesStr.replace(/"/g, '\\"')}%'`);
|
|
1695
|
-
}
|
|
1696
|
-
if (args.dateRange?.start) {
|
|
1697
|
-
conditions.push(`\`createdAt\` >= ${args.dateRange.start.getTime()}`);
|
|
1698
|
-
}
|
|
1699
|
-
if (args.dateRange?.end) {
|
|
1700
|
-
conditions.push(`\`createdAt\` <= ${args.dateRange.end.getTime()}`);
|
|
1701
|
-
}
|
|
1702
|
-
if (conditions.length > 0) {
|
|
1703
|
-
const whereClause = conditions.join(" AND ");
|
|
1704
|
-
query.where(whereClause);
|
|
1705
|
-
}
|
|
1706
|
-
let total = 0;
|
|
1707
|
-
if (conditions.length > 0) {
|
|
1708
|
-
const countQuery = table.query().where(conditions.join(" AND "));
|
|
1709
|
-
const allRecords = await countQuery.toArray();
|
|
1710
|
-
total = allRecords.length;
|
|
1711
|
-
} else {
|
|
1712
|
-
total = await table.countRows();
|
|
1713
|
-
}
|
|
1714
|
-
const page = args.page || 0;
|
|
1715
|
-
const perPage = args.perPage || 10;
|
|
1716
|
-
const offset = page * perPage;
|
|
1717
|
-
query.limit(perPage);
|
|
1718
|
-
if (offset > 0) {
|
|
1719
|
-
query.offset(offset);
|
|
1523
|
+
const { page, perPage: perPageInput } = pagination;
|
|
1524
|
+
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
1525
|
+
const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
1526
|
+
const table = await this.client.openTable(storage.TABLE_SCORERS);
|
|
1527
|
+
const allRecords = await table.query().where(`\`traceId\` = '${traceId}' AND \`spanId\` = '${spanId}'`).toArray();
|
|
1528
|
+
const total = allRecords.length;
|
|
1529
|
+
const end = perPageInput === false ? total : start + perPage;
|
|
1530
|
+
let query = table.query().where(`\`traceId\` = '${traceId}' AND \`spanId\` = '${spanId}'`);
|
|
1531
|
+
if (perPageInput !== false) {
|
|
1532
|
+
query = query.limit(perPage);
|
|
1533
|
+
if (start > 0) query = query.offset(start);
|
|
1720
1534
|
}
|
|
1721
1535
|
const records = await query.toArray();
|
|
1722
|
-
const
|
|
1723
|
-
|
|
1724
|
-
...record,
|
|
1725
|
-
attributes: record.attributes ? JSON.parse(record.attributes) : {},
|
|
1726
|
-
status: record.status ? JSON.parse(record.status) : {},
|
|
1727
|
-
events: record.events ? JSON.parse(record.events) : [],
|
|
1728
|
-
links: record.links ? JSON.parse(record.links) : [],
|
|
1729
|
-
other: record.other ? JSON.parse(record.other) : {},
|
|
1730
|
-
startTime: new Date(record.startTime),
|
|
1731
|
-
endTime: new Date(record.endTime),
|
|
1732
|
-
createdAt: new Date(record.createdAt)
|
|
1733
|
-
};
|
|
1734
|
-
if (processed.parentSpanId === null || processed.parentSpanId === void 0) {
|
|
1735
|
-
processed.parentSpanId = "";
|
|
1736
|
-
} else {
|
|
1737
|
-
processed.parentSpanId = String(processed.parentSpanId);
|
|
1738
|
-
}
|
|
1739
|
-
return processed;
|
|
1740
|
-
});
|
|
1536
|
+
const schema = await getTableSchema({ tableName: storage.TABLE_SCORERS, client: this.client });
|
|
1537
|
+
const scores = processResultWithTypeConversion(records, schema);
|
|
1741
1538
|
return {
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1539
|
+
pagination: {
|
|
1540
|
+
page,
|
|
1541
|
+
perPage: perPageForResponse,
|
|
1542
|
+
total,
|
|
1543
|
+
hasMore: end < total
|
|
1544
|
+
},
|
|
1545
|
+
scores
|
|
1747
1546
|
};
|
|
1748
1547
|
} catch (error$1) {
|
|
1749
1548
|
throw new error.MastraError(
|
|
1750
1549
|
{
|
|
1751
|
-
id: "
|
|
1550
|
+
id: "LANCE_STORAGE_GET_SCORES_BY_SPAN_FAILED",
|
|
1551
|
+
text: "Failed to get scores by traceId and spanId in LanceStorage",
|
|
1752
1552
|
domain: error.ErrorDomain.STORAGE,
|
|
1753
1553
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1754
|
-
details: {
|
|
1554
|
+
details: { error: error$1?.message }
|
|
1755
1555
|
},
|
|
1756
1556
|
error$1
|
|
1757
1557
|
);
|
|
1758
1558
|
}
|
|
1759
1559
|
}
|
|
1760
|
-
async batchTraceInsert({ records }) {
|
|
1761
|
-
this.logger.debug("Batch inserting traces", { count: records.length });
|
|
1762
|
-
await this.operations.batchInsert({
|
|
1763
|
-
tableName: storage.TABLE_TRACES,
|
|
1764
|
-
records
|
|
1765
|
-
});
|
|
1766
|
-
}
|
|
1767
1560
|
};
|
|
1768
1561
|
function parseWorkflowRun(row) {
|
|
1769
1562
|
let parsedSnapshot = row.snapshot;
|
|
@@ -1794,7 +1587,7 @@ var StoreWorkflowsLance = class extends storage.WorkflowsStorage {
|
|
|
1794
1587
|
// runId,
|
|
1795
1588
|
// stepId,
|
|
1796
1589
|
// result,
|
|
1797
|
-
//
|
|
1590
|
+
// requestContext,
|
|
1798
1591
|
}) {
|
|
1799
1592
|
throw new Error("Method not implemented.");
|
|
1800
1593
|
}
|
|
@@ -1808,6 +1601,7 @@ var StoreWorkflowsLance = class extends storage.WorkflowsStorage {
|
|
|
1808
1601
|
async persistWorkflowSnapshot({
|
|
1809
1602
|
workflowName,
|
|
1810
1603
|
runId,
|
|
1604
|
+
resourceId,
|
|
1811
1605
|
snapshot
|
|
1812
1606
|
}) {
|
|
1813
1607
|
try {
|
|
@@ -1824,6 +1618,7 @@ var StoreWorkflowsLance = class extends storage.WorkflowsStorage {
|
|
|
1824
1618
|
const record = {
|
|
1825
1619
|
workflow_name: workflowName,
|
|
1826
1620
|
run_id: runId,
|
|
1621
|
+
resourceId,
|
|
1827
1622
|
snapshot: JSON.stringify(snapshot),
|
|
1828
1623
|
createdAt,
|
|
1829
1624
|
updatedAt: now
|
|
@@ -1886,7 +1681,7 @@ var StoreWorkflowsLance = class extends storage.WorkflowsStorage {
|
|
|
1886
1681
|
);
|
|
1887
1682
|
}
|
|
1888
1683
|
}
|
|
1889
|
-
async
|
|
1684
|
+
async listWorkflowRuns(args) {
|
|
1890
1685
|
try {
|
|
1891
1686
|
const table = await this.client.openTable(storage.TABLE_WORKFLOW_SNAPSHOT);
|
|
1892
1687
|
let query = table.query();
|
|
@@ -1910,11 +1705,22 @@ var StoreWorkflowsLance = class extends storage.WorkflowsStorage {
|
|
|
1910
1705
|
} else {
|
|
1911
1706
|
total = await table.countRows();
|
|
1912
1707
|
}
|
|
1913
|
-
if (args?.
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1708
|
+
if (args?.perPage !== void 0 && args?.page !== void 0) {
|
|
1709
|
+
const normalizedPerPage = storage.normalizePerPage(args.perPage, Number.MAX_SAFE_INTEGER);
|
|
1710
|
+
if (args.page < 0 || !Number.isInteger(args.page)) {
|
|
1711
|
+
throw new error.MastraError(
|
|
1712
|
+
{
|
|
1713
|
+
id: "LANCE_STORE_INVALID_PAGINATION_PARAMS",
|
|
1714
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1715
|
+
category: error.ErrorCategory.USER,
|
|
1716
|
+
details: { page: args.page, perPage: args.perPage }
|
|
1717
|
+
},
|
|
1718
|
+
new Error(`Invalid pagination parameters: page=${args.page}, perPage=${args.perPage}`)
|
|
1719
|
+
);
|
|
1720
|
+
}
|
|
1721
|
+
const offset = args.page * normalizedPerPage;
|
|
1722
|
+
query.limit(normalizedPerPage);
|
|
1723
|
+
query.offset(offset);
|
|
1918
1724
|
}
|
|
1919
1725
|
const records = await query.toArray();
|
|
1920
1726
|
return {
|
|
@@ -1924,10 +1730,10 @@ var StoreWorkflowsLance = class extends storage.WorkflowsStorage {
|
|
|
1924
1730
|
} catch (error$1) {
|
|
1925
1731
|
throw new error.MastraError(
|
|
1926
1732
|
{
|
|
1927
|
-
id: "
|
|
1733
|
+
id: "LANCE_STORE_LIST_WORKFLOW_RUNS_FAILED",
|
|
1928
1734
|
domain: error.ErrorDomain.STORAGE,
|
|
1929
1735
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1930
|
-
details: {
|
|
1736
|
+
details: { resourceId: args?.resourceId ?? "", workflowName: args?.workflowName ?? "" }
|
|
1931
1737
|
},
|
|
1932
1738
|
error$1
|
|
1933
1739
|
);
|
|
@@ -1969,10 +1775,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1969
1775
|
instance.stores = {
|
|
1970
1776
|
operations: new StoreOperationsLance({ client: instance.lanceClient }),
|
|
1971
1777
|
workflows: new StoreWorkflowsLance({ client: instance.lanceClient }),
|
|
1972
|
-
traces: new StoreTracesLance({ client: instance.lanceClient, operations }),
|
|
1973
1778
|
scores: new StoreScoresLance({ client: instance.lanceClient }),
|
|
1974
|
-
memory: new StoreMemoryLance({ client: instance.lanceClient, operations })
|
|
1975
|
-
legacyEvals: new StoreLegacyEvalsLance({ client: instance.lanceClient })
|
|
1779
|
+
memory: new StoreMemoryLance({ client: instance.lanceClient, operations })
|
|
1976
1780
|
};
|
|
1977
1781
|
return instance;
|
|
1978
1782
|
} catch (e) {
|
|
@@ -1998,9 +1802,7 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1998
1802
|
this.stores = {
|
|
1999
1803
|
operations: new StoreOperationsLance({ client: this.lanceClient }),
|
|
2000
1804
|
workflows: new StoreWorkflowsLance({ client: this.lanceClient }),
|
|
2001
|
-
traces: new StoreTracesLance({ client: this.lanceClient, operations }),
|
|
2002
1805
|
scores: new StoreScoresLance({ client: this.lanceClient }),
|
|
2003
|
-
legacyEvals: new StoreLegacyEvalsLance({ client: this.lanceClient }),
|
|
2004
1806
|
memory: new StoreMemoryLance({ client: this.lanceClient, operations })
|
|
2005
1807
|
};
|
|
2006
1808
|
}
|
|
@@ -2035,9 +1837,6 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
2035
1837
|
async getThreadById({ threadId }) {
|
|
2036
1838
|
return this.stores.memory.getThreadById({ threadId });
|
|
2037
1839
|
}
|
|
2038
|
-
async getThreadsByResourceId({ resourceId }) {
|
|
2039
|
-
return this.stores.memory.getThreadsByResourceId({ resourceId });
|
|
2040
|
-
}
|
|
2041
1840
|
/**
|
|
2042
1841
|
* Saves a thread to the database. This function doesn't overwrite existing threads.
|
|
2043
1842
|
* @param thread - The thread to save
|
|
@@ -2062,7 +1861,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
2062
1861
|
resourceWorkingMemory: true,
|
|
2063
1862
|
hasColumn: true,
|
|
2064
1863
|
createTable: true,
|
|
2065
|
-
deleteMessages: false
|
|
1864
|
+
deleteMessages: false,
|
|
1865
|
+
listScoresBySpan: true
|
|
2066
1866
|
};
|
|
2067
1867
|
}
|
|
2068
1868
|
async getResourceById({ resourceId }) {
|
|
@@ -2130,46 +1930,21 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
2130
1930
|
threadId,
|
|
2131
1931
|
resourceId,
|
|
2132
1932
|
selectBy,
|
|
2133
|
-
format,
|
|
2134
1933
|
threadConfig
|
|
2135
1934
|
}) {
|
|
2136
|
-
return this.stores.memory.getMessages({ threadId, resourceId, selectBy,
|
|
1935
|
+
return this.stores.memory.getMessages({ threadId, resourceId, selectBy, threadConfig });
|
|
2137
1936
|
}
|
|
2138
|
-
async
|
|
2139
|
-
messageIds
|
|
2140
|
-
format
|
|
2141
|
-
}) {
|
|
2142
|
-
return this.stores.memory.getMessagesById({ messageIds, format });
|
|
1937
|
+
async listMessagesById({ messageIds }) {
|
|
1938
|
+
return this.stores.memory.listMessagesById({ messageIds });
|
|
2143
1939
|
}
|
|
2144
1940
|
async saveMessages(args) {
|
|
2145
1941
|
return this.stores.memory.saveMessages(args);
|
|
2146
1942
|
}
|
|
2147
|
-
async getThreadsByResourceIdPaginated(args) {
|
|
2148
|
-
return this.stores.memory.getThreadsByResourceIdPaginated(args);
|
|
2149
|
-
}
|
|
2150
|
-
async getMessagesPaginated(args) {
|
|
2151
|
-
return this.stores.memory.getMessagesPaginated(args);
|
|
2152
|
-
}
|
|
2153
1943
|
async updateMessages(_args) {
|
|
2154
1944
|
return this.stores.memory.updateMessages(_args);
|
|
2155
1945
|
}
|
|
2156
|
-
async
|
|
2157
|
-
return this.stores.
|
|
2158
|
-
}
|
|
2159
|
-
async getTraces(args) {
|
|
2160
|
-
return this.stores.traces.getTraces(args);
|
|
2161
|
-
}
|
|
2162
|
-
async getTracesPaginated(args) {
|
|
2163
|
-
return this.stores.traces.getTracesPaginated(args);
|
|
2164
|
-
}
|
|
2165
|
-
async getEvalsByAgentName(agentName, type) {
|
|
2166
|
-
return this.stores.legacyEvals.getEvalsByAgentName(agentName, type);
|
|
2167
|
-
}
|
|
2168
|
-
async getEvals(options) {
|
|
2169
|
-
return this.stores.legacyEvals.getEvals(options);
|
|
2170
|
-
}
|
|
2171
|
-
async getWorkflowRuns(args) {
|
|
2172
|
-
return this.stores.workflows.getWorkflowRuns(args);
|
|
1946
|
+
async listWorkflowRuns(args) {
|
|
1947
|
+
return this.stores.workflows.listWorkflowRuns(args);
|
|
2173
1948
|
}
|
|
2174
1949
|
async getWorkflowRunById(args) {
|
|
2175
1950
|
return this.stores.workflows.getWorkflowRunById(args);
|
|
@@ -2179,9 +1954,9 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
2179
1954
|
runId,
|
|
2180
1955
|
stepId,
|
|
2181
1956
|
result,
|
|
2182
|
-
|
|
1957
|
+
requestContext
|
|
2183
1958
|
}) {
|
|
2184
|
-
return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result,
|
|
1959
|
+
return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, requestContext });
|
|
2185
1960
|
}
|
|
2186
1961
|
async updateWorkflowState({
|
|
2187
1962
|
workflowName,
|
|
@@ -2193,9 +1968,10 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
2193
1968
|
async persistWorkflowSnapshot({
|
|
2194
1969
|
workflowName,
|
|
2195
1970
|
runId,
|
|
1971
|
+
resourceId,
|
|
2196
1972
|
snapshot
|
|
2197
1973
|
}) {
|
|
2198
|
-
return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
1974
|
+
return this.stores.workflows.persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot });
|
|
2199
1975
|
}
|
|
2200
1976
|
async loadWorkflowSnapshot({
|
|
2201
1977
|
workflowName,
|
|
@@ -2206,30 +1982,37 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
2206
1982
|
async getScoreById({ id: _id }) {
|
|
2207
1983
|
return this.stores.scores.getScoreById({ id: _id });
|
|
2208
1984
|
}
|
|
2209
|
-
async
|
|
1985
|
+
async listScoresByScorerId({
|
|
2210
1986
|
scorerId,
|
|
2211
1987
|
source,
|
|
2212
1988
|
entityId,
|
|
2213
1989
|
entityType,
|
|
2214
1990
|
pagination
|
|
2215
1991
|
}) {
|
|
2216
|
-
return this.stores.scores.
|
|
1992
|
+
return this.stores.scores.listScoresByScorerId({ scorerId, source, pagination, entityId, entityType });
|
|
2217
1993
|
}
|
|
2218
1994
|
async saveScore(_score) {
|
|
2219
1995
|
return this.stores.scores.saveScore(_score);
|
|
2220
1996
|
}
|
|
2221
|
-
async
|
|
1997
|
+
async listScoresByRunId({
|
|
2222
1998
|
runId,
|
|
2223
1999
|
pagination
|
|
2224
2000
|
}) {
|
|
2225
|
-
return this.stores.scores.
|
|
2001
|
+
return this.stores.scores.listScoresByRunId({ runId, pagination });
|
|
2226
2002
|
}
|
|
2227
|
-
async
|
|
2003
|
+
async listScoresByEntityId({
|
|
2228
2004
|
entityId,
|
|
2229
2005
|
entityType,
|
|
2230
2006
|
pagination
|
|
2231
2007
|
}) {
|
|
2232
|
-
return this.stores.scores.
|
|
2008
|
+
return this.stores.scores.listScoresByEntityId({ entityId, entityType, pagination });
|
|
2009
|
+
}
|
|
2010
|
+
async listScoresBySpan({
|
|
2011
|
+
traceId,
|
|
2012
|
+
spanId,
|
|
2013
|
+
pagination
|
|
2014
|
+
}) {
|
|
2015
|
+
return this.stores.scores.listScoresBySpan({ traceId, spanId, pagination });
|
|
2233
2016
|
}
|
|
2234
2017
|
};
|
|
2235
2018
|
var LanceFilterTranslator = class extends filter.BaseFilterTranslator {
|