@mastra/lance 0.0.0-update-scorers-api-20250801170445 → 0.0.0-vector-query-tool-provider-options-20250828222356
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +157 -3
- package/README.md +3 -3
- package/dist/index.cjs +109 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +109 -20
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +10 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +5 -2
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/traces/index.d.ts +1 -1
- package/dist/storage/domains/workflows/index.d.ts +19 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +32 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts +3 -3
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/storage/domains/memory/index.ts +71 -18
- package/src/storage/domains/scores/index.ts +29 -7
- package/src/storage/domains/workflows/index.ts +39 -1
- package/src/storage/index.ts +55 -3
- package/src/vector/index.ts +2 -2
- package/tsup.config.ts +2 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './storage';
|
|
2
|
-
export * from './vector';
|
|
1
|
+
export * from './storage/index.js';
|
|
2
|
+
export * from './vector/index.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -379,6 +379,20 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
379
379
|
);
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
+
normalizeMessage(message) {
|
|
383
|
+
const { thread_id, ...rest } = message;
|
|
384
|
+
return {
|
|
385
|
+
...rest,
|
|
386
|
+
threadId: thread_id,
|
|
387
|
+
content: typeof message.content === "string" ? (() => {
|
|
388
|
+
try {
|
|
389
|
+
return JSON.parse(message.content);
|
|
390
|
+
} catch {
|
|
391
|
+
return message.content;
|
|
392
|
+
}
|
|
393
|
+
})() : message.content
|
|
394
|
+
};
|
|
395
|
+
}
|
|
382
396
|
async getMessages({
|
|
383
397
|
threadId,
|
|
384
398
|
resourceId,
|
|
@@ -419,21 +433,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
419
433
|
allRecords,
|
|
420
434
|
await getTableSchema({ tableName: TABLE_MESSAGES, client: this.client })
|
|
421
435
|
);
|
|
422
|
-
const
|
|
423
|
-
const { thread_id, ...rest } = msg;
|
|
424
|
-
return {
|
|
425
|
-
...rest,
|
|
426
|
-
threadId: thread_id,
|
|
427
|
-
content: typeof msg.content === "string" ? (() => {
|
|
428
|
-
try {
|
|
429
|
-
return JSON.parse(msg.content);
|
|
430
|
-
} catch {
|
|
431
|
-
return msg.content;
|
|
432
|
-
}
|
|
433
|
-
})() : msg.content
|
|
434
|
-
};
|
|
435
|
-
});
|
|
436
|
-
const list = new MessageList({ threadId, resourceId }).add(normalized, "memory");
|
|
436
|
+
const list = new MessageList({ threadId, resourceId }).add(messages.map(this.normalizeMessage), "memory");
|
|
437
437
|
if (format === "v2") return list.get.all.v2();
|
|
438
438
|
return list.get.all.v1();
|
|
439
439
|
} catch (error) {
|
|
@@ -447,6 +447,36 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
447
447
|
);
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
|
+
async getMessagesById({
|
|
451
|
+
messageIds,
|
|
452
|
+
format
|
|
453
|
+
}) {
|
|
454
|
+
if (messageIds.length === 0) return [];
|
|
455
|
+
try {
|
|
456
|
+
const table = await this.client.openTable(TABLE_MESSAGES);
|
|
457
|
+
const quotedIds = messageIds.map((id) => `'${id}'`).join(", ");
|
|
458
|
+
const allRecords = await table.query().where(`id IN (${quotedIds})`).toArray();
|
|
459
|
+
const messages = processResultWithTypeConversion(
|
|
460
|
+
allRecords,
|
|
461
|
+
await getTableSchema({ tableName: TABLE_MESSAGES, client: this.client })
|
|
462
|
+
);
|
|
463
|
+
const list = new MessageList().add(messages.map(this.normalizeMessage), "memory");
|
|
464
|
+
if (format === `v1`) return list.get.all.v1();
|
|
465
|
+
return list.get.all.v2();
|
|
466
|
+
} catch (error) {
|
|
467
|
+
throw new MastraError(
|
|
468
|
+
{
|
|
469
|
+
id: "LANCE_STORE_GET_MESSAGES_BY_ID_FAILED",
|
|
470
|
+
domain: ErrorDomain.STORAGE,
|
|
471
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
472
|
+
details: {
|
|
473
|
+
messageIds: JSON.stringify(messageIds)
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
error
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
450
480
|
async saveMessages(args) {
|
|
451
481
|
try {
|
|
452
482
|
const { messages, format = "v1" } = args;
|
|
@@ -1359,6 +1389,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1359
1389
|
}
|
|
1360
1390
|
async saveScore(score) {
|
|
1361
1391
|
try {
|
|
1392
|
+
const id = crypto.randomUUID();
|
|
1362
1393
|
const table = await this.client.openTable(TABLE_SCORERS);
|
|
1363
1394
|
const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
|
|
1364
1395
|
const allowedFields = new Set(schema.fields.map((f) => f.name));
|
|
@@ -1373,7 +1404,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1373
1404
|
filteredScore[key] = JSON.stringify(filteredScore[key]);
|
|
1374
1405
|
}
|
|
1375
1406
|
}
|
|
1376
|
-
|
|
1407
|
+
filteredScore.id = id;
|
|
1377
1408
|
await table.add([filteredScore], { mode: "append" });
|
|
1378
1409
|
return { score };
|
|
1379
1410
|
} catch (error) {
|
|
@@ -1412,18 +1443,35 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1412
1443
|
}
|
|
1413
1444
|
async getScoresByScorerId({
|
|
1414
1445
|
scorerId,
|
|
1415
|
-
pagination
|
|
1446
|
+
pagination,
|
|
1447
|
+
entityId,
|
|
1448
|
+
entityType,
|
|
1449
|
+
source
|
|
1416
1450
|
}) {
|
|
1417
1451
|
try {
|
|
1418
1452
|
const table = await this.client.openTable(TABLE_SCORERS);
|
|
1419
1453
|
const { page = 0, perPage = 10 } = pagination || {};
|
|
1420
1454
|
const offset = page * perPage;
|
|
1421
|
-
|
|
1455
|
+
let query = table.query().where(`\`scorerId\` = '${scorerId}'`);
|
|
1456
|
+
if (source) {
|
|
1457
|
+
query = query.where(`\`source\` = '${source}'`);
|
|
1458
|
+
}
|
|
1459
|
+
if (entityId) {
|
|
1460
|
+
query = query.where(`\`entityId\` = '${entityId}'`);
|
|
1461
|
+
}
|
|
1462
|
+
if (entityType) {
|
|
1463
|
+
query = query.where(`\`entityType\` = '${entityType}'`);
|
|
1464
|
+
}
|
|
1465
|
+
query = query.limit(perPage);
|
|
1422
1466
|
if (offset > 0) query.offset(offset);
|
|
1423
1467
|
const records = await query.toArray();
|
|
1424
1468
|
const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
|
|
1425
1469
|
const scores = processResultWithTypeConversion(records, schema);
|
|
1426
|
-
|
|
1470
|
+
let totalQuery = table.query().where(`\`scorerId\` = '${scorerId}'`);
|
|
1471
|
+
if (source) {
|
|
1472
|
+
totalQuery = totalQuery.where(`\`source\` = '${source}'`);
|
|
1473
|
+
}
|
|
1474
|
+
const allRecords = await totalQuery.toArray();
|
|
1427
1475
|
const total = allRecords.length;
|
|
1428
1476
|
return {
|
|
1429
1477
|
pagination: {
|
|
@@ -1739,6 +1787,22 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1739
1787
|
super();
|
|
1740
1788
|
this.client = client;
|
|
1741
1789
|
}
|
|
1790
|
+
updateWorkflowResults({
|
|
1791
|
+
// workflowName,
|
|
1792
|
+
// runId,
|
|
1793
|
+
// stepId,
|
|
1794
|
+
// result,
|
|
1795
|
+
// runtimeContext,
|
|
1796
|
+
}) {
|
|
1797
|
+
throw new Error("Method not implemented.");
|
|
1798
|
+
}
|
|
1799
|
+
updateWorkflowState({
|
|
1800
|
+
// workflowName,
|
|
1801
|
+
// runId,
|
|
1802
|
+
// opts,
|
|
1803
|
+
}) {
|
|
1804
|
+
throw new Error("Method not implemented.");
|
|
1805
|
+
}
|
|
1742
1806
|
async persistWorkflowSnapshot({
|
|
1743
1807
|
workflowName,
|
|
1744
1808
|
runId,
|
|
@@ -2069,6 +2133,12 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
2069
2133
|
}) {
|
|
2070
2134
|
return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format, threadConfig });
|
|
2071
2135
|
}
|
|
2136
|
+
async getMessagesById({
|
|
2137
|
+
messageIds,
|
|
2138
|
+
format
|
|
2139
|
+
}) {
|
|
2140
|
+
return this.stores.memory.getMessagesById({ messageIds, format });
|
|
2141
|
+
}
|
|
2072
2142
|
async saveMessages(args) {
|
|
2073
2143
|
return this.stores.memory.saveMessages(args);
|
|
2074
2144
|
}
|
|
@@ -2102,6 +2172,22 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
2102
2172
|
async getWorkflowRunById(args) {
|
|
2103
2173
|
return this.stores.workflows.getWorkflowRunById(args);
|
|
2104
2174
|
}
|
|
2175
|
+
async updateWorkflowResults({
|
|
2176
|
+
workflowName,
|
|
2177
|
+
runId,
|
|
2178
|
+
stepId,
|
|
2179
|
+
result,
|
|
2180
|
+
runtimeContext
|
|
2181
|
+
}) {
|
|
2182
|
+
return this.stores.workflows.updateWorkflowResults({ workflowName, runId, stepId, result, runtimeContext });
|
|
2183
|
+
}
|
|
2184
|
+
async updateWorkflowState({
|
|
2185
|
+
workflowName,
|
|
2186
|
+
runId,
|
|
2187
|
+
opts
|
|
2188
|
+
}) {
|
|
2189
|
+
return this.stores.workflows.updateWorkflowState({ workflowName, runId, opts });
|
|
2190
|
+
}
|
|
2105
2191
|
async persistWorkflowSnapshot({
|
|
2106
2192
|
workflowName,
|
|
2107
2193
|
runId,
|
|
@@ -2120,9 +2206,12 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
2120
2206
|
}
|
|
2121
2207
|
async getScoresByScorerId({
|
|
2122
2208
|
scorerId,
|
|
2209
|
+
source,
|
|
2210
|
+
entityId,
|
|
2211
|
+
entityType,
|
|
2123
2212
|
pagination
|
|
2124
2213
|
}) {
|
|
2125
|
-
return this.stores.scores.getScoresByScorerId({ scorerId, pagination });
|
|
2214
|
+
return this.stores.scores.getScoresByScorerId({ scorerId, source, pagination, entityId, entityType });
|
|
2126
2215
|
}
|
|
2127
2216
|
async saveScore(_score) {
|
|
2128
2217
|
return this.stores.scores.saveScore(_score);
|