@mastra/lance 1.0.0-beta.2 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/index.cjs +32 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -17
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +8 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -292,15 +292,16 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
292
292
|
}
|
|
293
293
|
async listMessages(args) {
|
|
294
294
|
const { threadId, resourceId, include, filter, perPage: perPageInput, page = 0, orderBy } = args;
|
|
295
|
-
|
|
295
|
+
const threadIds = Array.isArray(threadId) ? threadId : [threadId];
|
|
296
|
+
if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
|
|
296
297
|
throw new MastraError(
|
|
297
298
|
{
|
|
298
299
|
id: "STORAGE_LANCE_LIST_MESSAGES_INVALID_THREAD_ID",
|
|
299
300
|
domain: ErrorDomain.STORAGE,
|
|
300
301
|
category: ErrorCategory.THIRD_PARTY,
|
|
301
|
-
details: { threadId }
|
|
302
|
+
details: { threadId: Array.isArray(threadId) ? threadId.join(",") : threadId }
|
|
302
303
|
},
|
|
303
|
-
new Error("threadId must be a non-empty string")
|
|
304
|
+
new Error("threadId must be a non-empty string or array of non-empty strings")
|
|
304
305
|
);
|
|
305
306
|
}
|
|
306
307
|
const perPage = normalizePerPage(perPageInput, 40);
|
|
@@ -319,7 +320,8 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
319
320
|
}
|
|
320
321
|
const { field, direction } = this.parseOrderBy(orderBy, "ASC");
|
|
321
322
|
const table = await this.client.openTable(TABLE_MESSAGES);
|
|
322
|
-
const
|
|
323
|
+
const threadCondition = threadIds.length === 1 ? `thread_id = '${this.escapeSql(threadIds[0])}'` : `thread_id IN (${threadIds.map((t) => `'${this.escapeSql(t)}'`).join(", ")})`;
|
|
324
|
+
const conditions = [threadCondition];
|
|
323
325
|
if (resourceId) {
|
|
324
326
|
conditions.push(`\`resourceId\` = '${this.escapeSql(resourceId)}'`);
|
|
325
327
|
}
|
|
@@ -359,9 +361,9 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
359
361
|
}
|
|
360
362
|
const messageIds = new Set(messages.map((m) => m.id));
|
|
361
363
|
if (include && include.length > 0) {
|
|
362
|
-
const
|
|
364
|
+
const threadIds2 = [...new Set(include.map((item) => item.threadId || threadId))];
|
|
363
365
|
const allThreadMessages = [];
|
|
364
|
-
for (const tid of
|
|
366
|
+
for (const tid of threadIds2) {
|
|
365
367
|
const threadQuery = table.query().where(`thread_id = '${tid}'`);
|
|
366
368
|
let threadRecords = await threadQuery.toArray();
|
|
367
369
|
allThreadMessages.push(...threadRecords);
|
|
@@ -407,7 +409,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
407
409
|
domain: ErrorDomain.STORAGE,
|
|
408
410
|
category: ErrorCategory.THIRD_PARTY,
|
|
409
411
|
details: {
|
|
410
|
-
threadId,
|
|
412
|
+
threadId: Array.isArray(threadId) ? threadId.join(",") : threadId,
|
|
411
413
|
resourceId: resourceId ?? ""
|
|
412
414
|
}
|
|
413
415
|
},
|
|
@@ -1266,6 +1268,8 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1266
1268
|
filteredScore[key] = JSON.stringify(filteredScore[key]);
|
|
1267
1269
|
}
|
|
1268
1270
|
}
|
|
1271
|
+
filteredScore.createdAt = /* @__PURE__ */ new Date();
|
|
1272
|
+
filteredScore.updatedAt = /* @__PURE__ */ new Date();
|
|
1269
1273
|
filteredScore.id = id;
|
|
1270
1274
|
await table.add([filteredScore], { mode: "append" });
|
|
1271
1275
|
return { score };
|
|
@@ -1288,8 +1292,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1288
1292
|
const query = table.query().where(`id = '${id}'`).limit(1);
|
|
1289
1293
|
const records = await query.toArray();
|
|
1290
1294
|
if (records.length === 0) return null;
|
|
1291
|
-
|
|
1292
|
-
return processResultWithTypeConversion(records[0], schema);
|
|
1295
|
+
return await this.transformScoreRow(records[0]);
|
|
1293
1296
|
} catch (error) {
|
|
1294
1297
|
throw new MastraError(
|
|
1295
1298
|
{
|
|
@@ -1303,6 +1306,22 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1303
1306
|
);
|
|
1304
1307
|
}
|
|
1305
1308
|
}
|
|
1309
|
+
/**
|
|
1310
|
+
* LanceDB-specific score row transformation.
|
|
1311
|
+
*
|
|
1312
|
+
* Note: This implementation does NOT use coreTransformScoreRow because:
|
|
1313
|
+
* 1. LanceDB stores schema information in the table itself (requires async fetch)
|
|
1314
|
+
* 2. Uses processResultWithTypeConversion utility for LanceDB-specific type handling
|
|
1315
|
+
*/
|
|
1316
|
+
async transformScoreRow(row) {
|
|
1317
|
+
const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
|
|
1318
|
+
const transformed = processResultWithTypeConversion(row, schema);
|
|
1319
|
+
return {
|
|
1320
|
+
...transformed,
|
|
1321
|
+
createdAt: row.createdAt,
|
|
1322
|
+
updatedAt: row.updatedAt
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1306
1325
|
async listScoresByScorerId({
|
|
1307
1326
|
scorerId,
|
|
1308
1327
|
pagination,
|
|
@@ -1343,8 +1362,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1343
1362
|
if (start > 0) query = query.offset(start);
|
|
1344
1363
|
}
|
|
1345
1364
|
const records = await query.toArray();
|
|
1346
|
-
const
|
|
1347
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1365
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1348
1366
|
return {
|
|
1349
1367
|
pagination: {
|
|
1350
1368
|
page,
|
|
@@ -1385,8 +1403,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1385
1403
|
if (start > 0) query = query.offset(start);
|
|
1386
1404
|
}
|
|
1387
1405
|
const records = await query.toArray();
|
|
1388
|
-
const
|
|
1389
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1406
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1390
1407
|
return {
|
|
1391
1408
|
pagination: {
|
|
1392
1409
|
page,
|
|
@@ -1428,8 +1445,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1428
1445
|
if (start > 0) query = query.offset(start);
|
|
1429
1446
|
}
|
|
1430
1447
|
const records = await query.toArray();
|
|
1431
|
-
const
|
|
1432
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1448
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1433
1449
|
return {
|
|
1434
1450
|
pagination: {
|
|
1435
1451
|
page,
|
|
@@ -1471,8 +1487,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1471
1487
|
if (start > 0) query = query.offset(start);
|
|
1472
1488
|
}
|
|
1473
1489
|
const records = await query.toArray();
|
|
1474
|
-
const
|
|
1475
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1490
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1476
1491
|
return {
|
|
1477
1492
|
pagination: {
|
|
1478
1493
|
page,
|