@mastra/lance 0.2.4 → 0.2.5
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +35 -0
- package/dist/index.cjs +26 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -5
- package/dist/index.js.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/index.d.ts +5 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/storage/domains/scores/index.ts +29 -7
- package/src/storage/index.ts +8 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Connection } from '@lancedb/lancedb';
|
|
2
|
-
import type { ScoreRowData } from '@mastra/core/scores';
|
|
2
|
+
import type { ScoreRowData, ScoringSource } from '@mastra/core/scores';
|
|
3
3
|
import { ScoresStorage } from '@mastra/core/storage';
|
|
4
4
|
import type { PaginationInfo, StoragePagination } from '@mastra/core/storage';
|
|
5
5
|
export declare class StoreScoresLance extends ScoresStorage {
|
|
@@ -13,9 +13,12 @@ export declare class StoreScoresLance extends ScoresStorage {
|
|
|
13
13
|
getScoreById({ id }: {
|
|
14
14
|
id: string;
|
|
15
15
|
}): Promise<ScoreRowData | null>;
|
|
16
|
-
getScoresByScorerId({ scorerId, pagination, }: {
|
|
16
|
+
getScoresByScorerId({ scorerId, pagination, entityId, entityType, source, }: {
|
|
17
17
|
scorerId: string;
|
|
18
18
|
pagination: StoragePagination;
|
|
19
|
+
entityId?: string;
|
|
20
|
+
entityType?: string;
|
|
21
|
+
source?: ScoringSource;
|
|
19
22
|
}): Promise<{
|
|
20
23
|
pagination: PaginationInfo;
|
|
21
24
|
scores: ScoreRowData[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"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KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAqC7D,mBAAmB,CAAC,EACxB,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;CA0CpE"}
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConnectionOptions } from '@lancedb/lancedb';
|
|
2
2
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
3
3
|
import type { MastraMessageV1, MastraMessageV2, StorageThreadType, TraceType } from '@mastra/core/memory';
|
|
4
|
-
import type { ScoreRowData } from '@mastra/core/scores';
|
|
4
|
+
import type { ScoreRowData, ScoringSource } from '@mastra/core/scores';
|
|
5
5
|
import { MastraStorage } from '@mastra/core/storage';
|
|
6
6
|
import type { TABLE_NAMES, PaginationInfo, StorageGetMessagesArg, StorageColumn, EvalRow, WorkflowRuns, StoragePagination, StorageDomains, StorageGetTracesPaginatedArg, StorageResourceType } from '@mastra/core/storage';
|
|
7
7
|
import type { Trace } from '@mastra/core/telemetry';
|
|
@@ -204,9 +204,12 @@ export declare class LanceStorage extends MastraStorage {
|
|
|
204
204
|
getScoreById({ id: _id }: {
|
|
205
205
|
id: string;
|
|
206
206
|
}): Promise<ScoreRowData | null>;
|
|
207
|
-
getScoresByScorerId({ scorerId, pagination, }: {
|
|
207
|
+
getScoresByScorerId({ scorerId, source, entityId, entityType, pagination, }: {
|
|
208
208
|
scorerId: string;
|
|
209
209
|
pagination: StoragePagination;
|
|
210
|
+
source?: ScoringSource;
|
|
211
|
+
entityId?: string;
|
|
212
|
+
entityType?: string;
|
|
210
213
|
}): Promise<{
|
|
211
214
|
pagination: PaginationInfo;
|
|
212
215
|
scores: ScoreRowData[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1G,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,4BAA4B,EAC5B,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAQ/D,qBAAa,YAAa,SAAQ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ACR,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,iBAAiB,CAAC;QAC9B,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAI7D,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IAIjE,gBAAgB,CAAC,EACrB,KAAK,EACL,UAAU,GACX,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAI7D,mBAAmB,CAAC,EACxB,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;CAGpE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/lance",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Lance provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"./package.json": "./package.json"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@lancedb/lancedb": "^0.
|
|
22
|
+
"@lancedb/lancedb": "^0.21.2",
|
|
23
23
|
"apache-arrow": "^18.1.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"tsup": "^8.5.0",
|
|
30
30
|
"typescript": "^5.8.3",
|
|
31
31
|
"vitest": "^3.2.4",
|
|
32
|
-
"@internal/lint": "0.0.
|
|
33
|
-
"@internal/types-builder": "0.0.
|
|
34
|
-
"@mastra/core": "^0.13.
|
|
35
|
-
"@internal/storage-test-utils": "0.0.
|
|
32
|
+
"@internal/lint": "0.0.29",
|
|
33
|
+
"@internal/types-builder": "0.0.4",
|
|
34
|
+
"@mastra/core": "^0.13.2",
|
|
35
|
+
"@internal/storage-test-utils": "0.0.25"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@mastra/core": ">=0.13.0-0 <0.14.0-0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Connection } from '@lancedb/lancedb';
|
|
2
2
|
import { ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';
|
|
3
|
-
import type { ScoreRowData } from '@mastra/core/scores';
|
|
3
|
+
import type { ScoreRowData, ScoringSource } from '@mastra/core/scores';
|
|
4
4
|
import { ScoresStorage, TABLE_SCORERS } from '@mastra/core/storage';
|
|
5
5
|
import type { PaginationInfo, StoragePagination } from '@mastra/core/storage';
|
|
6
6
|
import { getTableSchema, processResultWithTypeConversion } from '../utils';
|
|
@@ -14,6 +14,7 @@ export class StoreScoresLance extends ScoresStorage {
|
|
|
14
14
|
|
|
15
15
|
async saveScore(score: ScoreRowData): Promise<{ score: ScoreRowData }> {
|
|
16
16
|
try {
|
|
17
|
+
const id = crypto.randomUUID();
|
|
17
18
|
const table = await this.client.openTable(TABLE_SCORERS);
|
|
18
19
|
// Fetch schema fields for mastra_scorers
|
|
19
20
|
const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
|
|
@@ -36,8 +37,7 @@ export class StoreScoresLance extends ScoresStorage {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
filteredScore.id = id;
|
|
41
41
|
await table.add([filteredScore], { mode: 'append' });
|
|
42
42
|
return { score };
|
|
43
43
|
} catch (error: any) {
|
|
@@ -82,24 +82,46 @@ export class StoreScoresLance extends ScoresStorage {
|
|
|
82
82
|
async getScoresByScorerId({
|
|
83
83
|
scorerId,
|
|
84
84
|
pagination,
|
|
85
|
+
entityId,
|
|
86
|
+
entityType,
|
|
87
|
+
source,
|
|
85
88
|
}: {
|
|
86
89
|
scorerId: string;
|
|
87
90
|
pagination: StoragePagination;
|
|
91
|
+
entityId?: string;
|
|
92
|
+
entityType?: string;
|
|
93
|
+
source?: ScoringSource;
|
|
88
94
|
}): Promise<{ pagination: PaginationInfo; scores: ScoreRowData[] }> {
|
|
89
95
|
try {
|
|
90
96
|
const table = await this.client.openTable(TABLE_SCORERS);
|
|
91
97
|
// Use zero-based pagination (default page = 0)
|
|
92
98
|
const { page = 0, perPage = 10 } = pagination || {};
|
|
93
99
|
const offset = page * perPage;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
100
|
+
|
|
101
|
+
let query = table.query().where(`\`scorerId\` = '${scorerId}'`);
|
|
102
|
+
|
|
103
|
+
if (source) {
|
|
104
|
+
query = query.where(`\`source\` = '${source}'`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (entityId) {
|
|
108
|
+
query = query.where(`\`entityId\` = '${entityId}'`);
|
|
109
|
+
}
|
|
110
|
+
if (entityType) {
|
|
111
|
+
query = query.where(`\`entityType\` = '${entityType}'`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
query = query.limit(perPage);
|
|
97
115
|
if (offset > 0) query.offset(offset);
|
|
98
116
|
const records = await query.toArray();
|
|
99
117
|
const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
|
|
100
118
|
const scores = processResultWithTypeConversion(records, schema) as ScoreRowData[];
|
|
101
119
|
|
|
102
|
-
|
|
120
|
+
let totalQuery = table.query().where(`\`scorerId\` = '${scorerId}'`);
|
|
121
|
+
if (source) {
|
|
122
|
+
totalQuery = totalQuery.where(`\`source\` = '${source}'`);
|
|
123
|
+
}
|
|
124
|
+
const allRecords = await totalQuery.toArray();
|
|
103
125
|
const total = allRecords.length;
|
|
104
126
|
|
|
105
127
|
return {
|
package/src/storage/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Connection, ConnectionOptions } from '@lancedb/lancedb';
|
|
|
3
3
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
4
4
|
import { ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';
|
|
5
5
|
import type { MastraMessageV1, MastraMessageV2, StorageThreadType, TraceType } from '@mastra/core/memory';
|
|
6
|
-
import type { ScoreRowData } from '@mastra/core/scores';
|
|
6
|
+
import type { ScoreRowData, ScoringSource } from '@mastra/core/scores';
|
|
7
7
|
import { MastraStorage } from '@mastra/core/storage';
|
|
8
8
|
import type {
|
|
9
9
|
TABLE_NAMES,
|
|
@@ -406,12 +406,18 @@ export class LanceStorage extends MastraStorage {
|
|
|
406
406
|
|
|
407
407
|
async getScoresByScorerId({
|
|
408
408
|
scorerId,
|
|
409
|
+
source,
|
|
410
|
+
entityId,
|
|
411
|
+
entityType,
|
|
409
412
|
pagination,
|
|
410
413
|
}: {
|
|
411
414
|
scorerId: string;
|
|
412
415
|
pagination: StoragePagination;
|
|
416
|
+
source?: ScoringSource;
|
|
417
|
+
entityId?: string;
|
|
418
|
+
entityType?: string;
|
|
413
419
|
}): Promise<{ pagination: PaginationInfo; scores: ScoreRowData[] }> {
|
|
414
|
-
return this.stores.scores.getScoresByScorerId({ scorerId, pagination });
|
|
420
|
+
return this.stores.scores.getScoresByScorerId({ scorerId, source, pagination, entityId, entityType });
|
|
415
421
|
}
|
|
416
422
|
|
|
417
423
|
async saveScore(_score: ScoreRowData): Promise<{ score: ScoreRowData }> {
|