@mastra/lance 0.2.10 → 0.2.11-alpha.0
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 +9 -0
- package/package.json +17 -4
- package/.turbo/turbo-build.log +0 -4
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/lance
|
|
2
2
|
|
|
3
|
+
## 0.2.11-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#7343](https://github.com/mastra-ai/mastra/pull/7343) [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e) Thanks [@LekoArts](https://github.com/LekoArts)! - Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`85ef90b`](https://github.com/mastra-ai/mastra/commit/85ef90bb2cd4ae4df855c7ac175f7d392c55c1bf), [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e)]:
|
|
10
|
+
- @mastra/core@0.15.3-alpha.5
|
|
11
|
+
|
|
3
12
|
## 0.2.10
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/lance",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11-alpha.0",
|
|
4
4
|
"description": "Lance provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,13 +30,26 @@
|
|
|
30
30
|
"typescript": "^5.8.3",
|
|
31
31
|
"vitest": "^3.2.4",
|
|
32
32
|
"@internal/lint": "0.0.34",
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@internal/
|
|
33
|
+
"@mastra/core": "^0.15.3-alpha.5",
|
|
34
|
+
"@internal/types-builder": "0.0.9",
|
|
35
|
+
"@internal/storage-test-utils": "0.0.30"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@mastra/core": ">=0.13.0-0 <0.16.0-0"
|
|
39
39
|
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"CHANGELOG.md"
|
|
43
|
+
],
|
|
44
|
+
"homepage": "https://mastra.ai",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/mastra-ai/mastra.git",
|
|
48
|
+
"directory": "stores/lance"
|
|
49
|
+
},
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
52
|
+
},
|
|
40
53
|
"scripts": {
|
|
41
54
|
"build": "tsup --silent --config tsup.config.ts",
|
|
42
55
|
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
package/.turbo/turbo-build.log
DELETED
package/eslint.config.js
DELETED
package/src/index.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import type { Connection } from '@lancedb/lancedb';
|
|
2
|
-
import { ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';
|
|
3
|
-
import { LegacyEvalsStorage, TABLE_EVALS } from '@mastra/core/storage';
|
|
4
|
-
import type { EvalRow, PaginationInfo } from '@mastra/core/storage';
|
|
5
|
-
|
|
6
|
-
export class StoreLegacyEvalsLance extends LegacyEvalsStorage {
|
|
7
|
-
private client: Connection;
|
|
8
|
-
constructor({ client }: { client: Connection }) {
|
|
9
|
-
super();
|
|
10
|
-
this.client = client;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]> {
|
|
14
|
-
try {
|
|
15
|
-
const table = await this.client.openTable(TABLE_EVALS);
|
|
16
|
-
const query = table.query().where(`agent_name = '${agentName}'`);
|
|
17
|
-
const records = await query.toArray();
|
|
18
|
-
|
|
19
|
-
// Filter by type if specified
|
|
20
|
-
let filteredRecords = records;
|
|
21
|
-
if (type === 'live') {
|
|
22
|
-
// Live evals have test_info as null
|
|
23
|
-
filteredRecords = records.filter(record => record.test_info === null);
|
|
24
|
-
} else if (type === 'test') {
|
|
25
|
-
// Test evals have test_info as a JSON string
|
|
26
|
-
filteredRecords = records.filter(record => record.test_info !== null);
|
|
27
|
-
}
|
|
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
|
-
}) as EvalRow[];
|
|
44
|
-
} catch (error: any) {
|
|
45
|
-
throw new MastraError(
|
|
46
|
-
{
|
|
47
|
-
id: 'LANCE_STORE_GET_EVALS_BY_AGENT_NAME_FAILED',
|
|
48
|
-
domain: ErrorDomain.STORAGE,
|
|
49
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
50
|
-
details: { agentName },
|
|
51
|
-
},
|
|
52
|
-
error,
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async getEvals(options: {
|
|
58
|
-
agentName?: string;
|
|
59
|
-
type?: 'test' | 'live';
|
|
60
|
-
page?: number;
|
|
61
|
-
perPage?: number;
|
|
62
|
-
fromDate?: Date;
|
|
63
|
-
toDate?: Date;
|
|
64
|
-
dateRange?: { start?: Date; end?: Date };
|
|
65
|
-
}): Promise<PaginationInfo & { evals: EvalRow[] }> {
|
|
66
|
-
try {
|
|
67
|
-
const table = await this.client.openTable(TABLE_EVALS);
|
|
68
|
-
|
|
69
|
-
// Build combined where clause
|
|
70
|
-
const conditions: string[] = [];
|
|
71
|
-
|
|
72
|
-
if (options.agentName) {
|
|
73
|
-
conditions.push(`agent_name = '${options.agentName}'`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Apply type filtering
|
|
77
|
-
if (options.type === 'live') {
|
|
78
|
-
conditions.push('length(test_info) = 0');
|
|
79
|
-
} else if (options.type === 'test') {
|
|
80
|
-
conditions.push('length(test_info) > 0');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Apply date filtering
|
|
84
|
-
const startDate = options.dateRange?.start || options.fromDate;
|
|
85
|
-
const endDate = options.dateRange?.end || options.toDate;
|
|
86
|
-
|
|
87
|
-
if (startDate) {
|
|
88
|
-
conditions.push(`\`created_at\` >= ${startDate.getTime()}`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (endDate) {
|
|
92
|
-
conditions.push(`\`created_at\` <= ${endDate.getTime()}`);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Get total count with the same conditions
|
|
96
|
-
let total = 0;
|
|
97
|
-
if (conditions.length > 0) {
|
|
98
|
-
total = await table.countRows(conditions.join(' AND '));
|
|
99
|
-
} else {
|
|
100
|
-
total = await table.countRows();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Build query for fetching records
|
|
104
|
-
const query = table.query();
|
|
105
|
-
|
|
106
|
-
// Apply combined where clause if we have conditions
|
|
107
|
-
if (conditions.length > 0) {
|
|
108
|
-
const whereClause = conditions.join(' AND ');
|
|
109
|
-
query.where(whereClause);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const records = await query.toArray();
|
|
113
|
-
|
|
114
|
-
const evals = records
|
|
115
|
-
.sort((a, b) => b.created_at - a.created_at)
|
|
116
|
-
.map(record => {
|
|
117
|
-
return {
|
|
118
|
-
id: record.id,
|
|
119
|
-
input: record.input,
|
|
120
|
-
output: record.output,
|
|
121
|
-
agentName: record.agent_name,
|
|
122
|
-
metricName: record.metric_name,
|
|
123
|
-
result: JSON.parse(record.result),
|
|
124
|
-
instructions: record.instructions,
|
|
125
|
-
testInfo: record.test_info ? JSON.parse(record.test_info) : null,
|
|
126
|
-
globalRunId: record.global_run_id,
|
|
127
|
-
runId: record.run_id,
|
|
128
|
-
createdAt: new Date(record.created_at).toISOString(),
|
|
129
|
-
};
|
|
130
|
-
}) as EvalRow[];
|
|
131
|
-
|
|
132
|
-
// Apply pagination after filtering
|
|
133
|
-
const page = options.page || 0;
|
|
134
|
-
const perPage = options.perPage || 10;
|
|
135
|
-
const pagedEvals = evals.slice(page * perPage, (page + 1) * perPage);
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
evals: pagedEvals,
|
|
139
|
-
total: total,
|
|
140
|
-
page,
|
|
141
|
-
perPage,
|
|
142
|
-
hasMore: total > (page + 1) * perPage,
|
|
143
|
-
};
|
|
144
|
-
} catch (error: any) {
|
|
145
|
-
throw new MastraError(
|
|
146
|
-
{
|
|
147
|
-
id: 'LANCE_STORE_GET_EVALS_FAILED',
|
|
148
|
-
domain: ErrorDomain.STORAGE,
|
|
149
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
150
|
-
details: { agentName: options.agentName ?? '' },
|
|
151
|
-
},
|
|
152
|
-
error,
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|