@mastra/lance 0.0.0-zod-v4-compat-part-2-20250822105954 → 0.0.0-zod-v4-stuff-20250825154219
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 +117 -2
- package/dist/index.cjs +77 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +77 -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/index.d.ts +13 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts +2 -2
- 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/index.ts +20 -2
- package/tsup.config.ts +2 -7
|
@@ -3,7 +3,7 @@ import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
|
3
3
|
import type { MastraMessageV1, MastraMessageV2, StorageThreadType } from '@mastra/core/memory';
|
|
4
4
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
5
5
|
import type { PaginationInfo, StorageGetMessagesArg, StorageResourceType } from '@mastra/core/storage';
|
|
6
|
-
import type { StoreOperationsLance } from '../operations';
|
|
6
|
+
import type { StoreOperationsLance } from '../operations/index.js';
|
|
7
7
|
export declare class StoreMemoryLance extends MemoryStorage {
|
|
8
8
|
private client;
|
|
9
9
|
private operations;
|
|
@@ -33,12 +33,21 @@ export declare class StoreMemoryLance extends MemoryStorage {
|
|
|
33
33
|
deleteThread({ threadId }: {
|
|
34
34
|
threadId: string;
|
|
35
35
|
}): Promise<void>;
|
|
36
|
+
private normalizeMessage;
|
|
36
37
|
getMessages(args: StorageGetMessagesArg & {
|
|
37
38
|
format?: 'v1';
|
|
38
39
|
}): Promise<MastraMessageV1[]>;
|
|
39
40
|
getMessages(args: StorageGetMessagesArg & {
|
|
40
41
|
format: 'v2';
|
|
41
42
|
}): Promise<MastraMessageV2[]>;
|
|
43
|
+
getMessagesById({ messageIds, format, }: {
|
|
44
|
+
messageIds: string[];
|
|
45
|
+
format: 'v1';
|
|
46
|
+
}): Promise<MastraMessageV1[]>;
|
|
47
|
+
getMessagesById({ messageIds, format, }: {
|
|
48
|
+
messageIds: string[];
|
|
49
|
+
format?: 'v2';
|
|
50
|
+
}): Promise<MastraMessageV2[]>;
|
|
42
51
|
saveMessages(args: {
|
|
43
52
|
messages: MastraMessageV1[];
|
|
44
53
|
format?: undefined | 'v1';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EACL,aAAa,EAKd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACvG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAG1D,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,UAAU,CAAuB;gBAC7B,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;QAAE,MAAM,EAAE,UAAU,CAAC;QAAC,UAAU,EAAE,oBAAoB,CAAA;KAAE;IAMtF,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,G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AsB,CAAC,SAAS,CAAC,CAAA;aAAE,CAAC;SAC1G,EAAE,CAAC;KACP,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAgGxB,eAAe,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAiG5F,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAyB3F,cAAc,CAAC,EACnB,UAAU,EACV,aAAa,EACb,QAAQ,GACT,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA+DjC"}
|
|
@@ -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":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAiB,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9E,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,OAAO,CAAC,MAAM,CAAa;gBACf,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,UAAU,CAAA;KAAE;IAKxC,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IA0ChE,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAyBlE,mBAAmB,CAAC,EACxB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM,GACP,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,aAAa,CAAC;KACxB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAwD7D,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;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"}
|
|
@@ -3,7 +3,7 @@ import type { TraceType } from '@mastra/core/memory';
|
|
|
3
3
|
import { TracesStorage } from '@mastra/core/storage';
|
|
4
4
|
import type { PaginationInfo, StorageGetTracesPaginatedArg } from '@mastra/core/storage';
|
|
5
5
|
import type { Trace } from '@mastra/core/telemetry';
|
|
6
|
-
import type { StoreOperationsLance } from '../operations';
|
|
6
|
+
import type { StoreOperationsLance } from '../operations/index.js';
|
|
7
7
|
export declare class StoreTracesLance extends TracesStorage {
|
|
8
8
|
private client;
|
|
9
9
|
private operations;
|
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';
|
|
@@ -117,6 +117,14 @@ export declare class LanceStorage extends MastraStorage {
|
|
|
117
117
|
getMessages(args: StorageGetMessagesArg & {
|
|
118
118
|
format: 'v2';
|
|
119
119
|
}): Promise<MastraMessageV2[]>;
|
|
120
|
+
getMessagesById({ messageIds, format }: {
|
|
121
|
+
messageIds: string[];
|
|
122
|
+
format: 'v1';
|
|
123
|
+
}): Promise<MastraMessageV1[]>;
|
|
124
|
+
getMessagesById({ messageIds, format }: {
|
|
125
|
+
messageIds: string[];
|
|
126
|
+
format?: 'v2';
|
|
127
|
+
}): Promise<MastraMessageV2[]>;
|
|
120
128
|
saveMessages(args: {
|
|
121
129
|
messages: MastraMessageV1[];
|
|
122
130
|
format?: undefined | 'v1';
|
|
@@ -204,9 +212,12 @@ export declare class LanceStorage extends MastraStorage {
|
|
|
204
212
|
getScoreById({ id: _id }: {
|
|
205
213
|
id: string;
|
|
206
214
|
}): Promise<ScoreRowData | null>;
|
|
207
|
-
getScoresByScorerId({ scorerId, pagination, }: {
|
|
215
|
+
getScoresByScorerId({ scorerId, source, entityId, entityType, pagination, }: {
|
|
208
216
|
scorerId: string;
|
|
209
217
|
pagination: StoragePagination;
|
|
218
|
+
source?: ScoringSource;
|
|
219
|
+
entityId?: string;
|
|
220
|
+
entityType?: string;
|
|
210
221
|
}): Promise<{
|
|
211
222
|
pagination: PaginationInfo;
|
|
212
223
|
scores: ScoreRowData[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,iBAAiB,E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AC,YAAY,GAAG,IAAI,CAAC;IAIvE,mBAAmB,CAAC,EACxB,QAAQ,EACR,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/dist/vector/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ConnectionOptions, CreateTableOptions, Table, TableLike } from '@lancedb/lancedb';
|
|
2
2
|
import type { CreateIndexParams, DeleteIndexParams, DeleteVectorParams, DescribeIndexParams, IndexStats, QueryResult, QueryVectorParams, UpdateVectorParams, UpsertVectorParams } from '@mastra/core';
|
|
3
3
|
import { MastraVector } from '@mastra/core/vector';
|
|
4
|
-
import type { LanceVectorFilter } from './filter';
|
|
5
|
-
import type { IndexConfig } from './types';
|
|
4
|
+
import type { LanceVectorFilter } from './filter.js';
|
|
5
|
+
import type { IndexConfig } from './types.js';
|
|
6
6
|
interface LanceCreateIndexParams extends CreateIndexParams {
|
|
7
7
|
indexConfig?: LanceIndexConfig;
|
|
8
8
|
tableName?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/lance",
|
|
3
|
-
"version": "0.0.0-zod-v4-
|
|
3
|
+
"version": "0.0.0-zod-v4-stuff-20250825154219",
|
|
4
4
|
"description": "Lance provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"default": "./dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"require": {
|
|
15
|
-
"types": "./dist/index.d.
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
16
|
"default": "./dist/index.cjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
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,12 +29,13 @@
|
|
|
29
29
|
"tsup": "^8.5.0",
|
|
30
30
|
"typescript": "^5.8.3",
|
|
31
31
|
"vitest": "^3.2.4",
|
|
32
|
-
"@internal/lint": "0.0.0-zod-v4-
|
|
33
|
-
"@internal/storage-test-utils": "0.0.
|
|
34
|
-
"@mastra/core": "0.0.0-zod-v4-
|
|
32
|
+
"@internal/lint": "0.0.0-zod-v4-stuff-20250825154219",
|
|
33
|
+
"@internal/storage-test-utils": "0.0.27",
|
|
34
|
+
"@mastra/core": "0.0.0-zod-v4-stuff-20250825154219",
|
|
35
|
+
"@internal/types-builder": "0.0.0-zod-v4-stuff-20250825154219"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"@mastra/core": "0.0.0-zod-v4-
|
|
38
|
+
"@mastra/core": "0.0.0-zod-v4-stuff-20250825154219"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
41
|
"build": "tsup --silent --config tsup.config.ts",
|
|
@@ -185,6 +185,24 @@ export class StoreMemoryLance extends MemoryStorage {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
private normalizeMessage(message: any): MastraMessageV1 | MastraMessageV2 {
|
|
189
|
+
const { thread_id, ...rest } = message;
|
|
190
|
+
return {
|
|
191
|
+
...rest,
|
|
192
|
+
threadId: thread_id,
|
|
193
|
+
content:
|
|
194
|
+
typeof message.content === 'string'
|
|
195
|
+
? (() => {
|
|
196
|
+
try {
|
|
197
|
+
return JSON.parse(message.content);
|
|
198
|
+
} catch {
|
|
199
|
+
return message.content;
|
|
200
|
+
}
|
|
201
|
+
})()
|
|
202
|
+
: message.content,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
188
206
|
public async getMessages(args: StorageGetMessagesArg & { format?: 'v1' }): Promise<MastraMessageV1[]>;
|
|
189
207
|
public async getMessages(args: StorageGetMessagesArg & { format: 'v2' }): Promise<MastraMessageV2[]>;
|
|
190
208
|
public async getMessages({
|
|
@@ -241,24 +259,8 @@ export class StoreMemoryLance extends MemoryStorage {
|
|
|
241
259
|
allRecords,
|
|
242
260
|
await getTableSchema({ tableName: TABLE_MESSAGES, client: this.client }),
|
|
243
261
|
);
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return {
|
|
247
|
-
...rest,
|
|
248
|
-
threadId: thread_id,
|
|
249
|
-
content:
|
|
250
|
-
typeof msg.content === 'string'
|
|
251
|
-
? (() => {
|
|
252
|
-
try {
|
|
253
|
-
return JSON.parse(msg.content);
|
|
254
|
-
} catch {
|
|
255
|
-
return msg.content;
|
|
256
|
-
}
|
|
257
|
-
})()
|
|
258
|
-
: msg.content,
|
|
259
|
-
};
|
|
260
|
-
});
|
|
261
|
-
const list = new MessageList({ threadId, resourceId }).add(normalized, 'memory');
|
|
262
|
+
|
|
263
|
+
const list = new MessageList({ threadId, resourceId }).add(messages.map(this.normalizeMessage), 'memory');
|
|
262
264
|
if (format === 'v2') return list.get.all.v2();
|
|
263
265
|
return list.get.all.v1();
|
|
264
266
|
} catch (error: any) {
|
|
@@ -273,6 +275,57 @@ export class StoreMemoryLance extends MemoryStorage {
|
|
|
273
275
|
}
|
|
274
276
|
}
|
|
275
277
|
|
|
278
|
+
public async getMessagesById({
|
|
279
|
+
messageIds,
|
|
280
|
+
format,
|
|
281
|
+
}: {
|
|
282
|
+
messageIds: string[];
|
|
283
|
+
format: 'v1';
|
|
284
|
+
}): Promise<MastraMessageV1[]>;
|
|
285
|
+
public async getMessagesById({
|
|
286
|
+
messageIds,
|
|
287
|
+
format,
|
|
288
|
+
}: {
|
|
289
|
+
messageIds: string[];
|
|
290
|
+
format?: 'v2';
|
|
291
|
+
}): Promise<MastraMessageV2[]>;
|
|
292
|
+
public async getMessagesById({
|
|
293
|
+
messageIds,
|
|
294
|
+
format,
|
|
295
|
+
}: {
|
|
296
|
+
messageIds: string[];
|
|
297
|
+
format?: 'v1' | 'v2';
|
|
298
|
+
}): Promise<MastraMessageV1[] | MastraMessageV2[]> {
|
|
299
|
+
if (messageIds.length === 0) return [];
|
|
300
|
+
try {
|
|
301
|
+
const table = await this.client.openTable(TABLE_MESSAGES);
|
|
302
|
+
|
|
303
|
+
const quotedIds = messageIds.map(id => `'${id}'`).join(', ');
|
|
304
|
+
const allRecords = await table.query().where(`id IN (${quotedIds})`).toArray();
|
|
305
|
+
|
|
306
|
+
const messages = processResultWithTypeConversion(
|
|
307
|
+
allRecords,
|
|
308
|
+
await getTableSchema({ tableName: TABLE_MESSAGES, client: this.client }),
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
const list = new MessageList().add(messages.map(this.normalizeMessage), 'memory');
|
|
312
|
+
if (format === `v1`) return list.get.all.v1();
|
|
313
|
+
return list.get.all.v2();
|
|
314
|
+
} catch (error: any) {
|
|
315
|
+
throw new MastraError(
|
|
316
|
+
{
|
|
317
|
+
id: 'LANCE_STORE_GET_MESSAGES_BY_ID_FAILED',
|
|
318
|
+
domain: ErrorDomain.STORAGE,
|
|
319
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
320
|
+
details: {
|
|
321
|
+
messageIds: JSON.stringify(messageIds),
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
error,
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
276
329
|
async saveMessages(args: { messages: MastraMessageV1[]; format?: undefined | 'v1' }): Promise<MastraMessageV1[]>;
|
|
277
330
|
async saveMessages(args: { messages: MastraMessageV2[]; format: 'v2' }): Promise<MastraMessageV2[]>;
|
|
278
331
|
async saveMessages(
|
|
@@ -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,
|
|
@@ -291,6 +291,18 @@ export class LanceStorage extends MastraStorage {
|
|
|
291
291
|
return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format, threadConfig });
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
async getMessagesById({ messageIds, format }: { messageIds: string[]; format: 'v1' }): Promise<MastraMessageV1[]>;
|
|
295
|
+
async getMessagesById({ messageIds, format }: { messageIds: string[]; format?: 'v2' }): Promise<MastraMessageV2[]>;
|
|
296
|
+
async getMessagesById({
|
|
297
|
+
messageIds,
|
|
298
|
+
format,
|
|
299
|
+
}: {
|
|
300
|
+
messageIds: string[];
|
|
301
|
+
format?: 'v1' | 'v2';
|
|
302
|
+
}): Promise<MastraMessageV1[] | MastraMessageV2[]> {
|
|
303
|
+
return this.stores.memory.getMessagesById({ messageIds, format });
|
|
304
|
+
}
|
|
305
|
+
|
|
294
306
|
async saveMessages(args: { messages: MastraMessageV1[]; format?: undefined | 'v1' }): Promise<MastraMessageV1[]>;
|
|
295
307
|
async saveMessages(args: { messages: MastraMessageV2[]; format: 'v2' }): Promise<MastraMessageV2[]>;
|
|
296
308
|
async saveMessages(
|
|
@@ -406,12 +418,18 @@ export class LanceStorage extends MastraStorage {
|
|
|
406
418
|
|
|
407
419
|
async getScoresByScorerId({
|
|
408
420
|
scorerId,
|
|
421
|
+
source,
|
|
422
|
+
entityId,
|
|
423
|
+
entityType,
|
|
409
424
|
pagination,
|
|
410
425
|
}: {
|
|
411
426
|
scorerId: string;
|
|
412
427
|
pagination: StoragePagination;
|
|
428
|
+
source?: ScoringSource;
|
|
429
|
+
entityId?: string;
|
|
430
|
+
entityType?: string;
|
|
413
431
|
}): Promise<{ pagination: PaginationInfo; scores: ScoreRowData[] }> {
|
|
414
|
-
return this.stores.scores.getScoresByScorerId({ scorerId, pagination });
|
|
432
|
+
return this.stores.scores.getScoresByScorerId({ scorerId, source, pagination, entityId, entityType });
|
|
415
433
|
}
|
|
416
434
|
|
|
417
435
|
async saveScore(_score: ScoreRowData): Promise<{ score: ScoreRowData }> {
|
package/tsup.config.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { promisify } from 'util';
|
|
1
|
+
import { generateTypes } from '@internal/types-builder';
|
|
3
2
|
import { defineConfig } from 'tsup';
|
|
4
3
|
|
|
5
|
-
const exec = promisify(spawn);
|
|
6
|
-
|
|
7
4
|
export default defineConfig({
|
|
8
5
|
entry: ['src/index.ts'],
|
|
9
6
|
format: ['esm', 'cjs'],
|
|
@@ -15,8 +12,6 @@ export default defineConfig({
|
|
|
15
12
|
},
|
|
16
13
|
sourcemap: true,
|
|
17
14
|
onSuccess: async () => {
|
|
18
|
-
await
|
|
19
|
-
stdio: 'inherit',
|
|
20
|
-
});
|
|
15
|
+
await generateTypes(process.cwd());
|
|
21
16
|
},
|
|
22
17
|
});
|