@mastra/lance 1.0.0-beta.2 → 1.0.0-beta.4
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 +56 -0
- package/dist/index.cjs +125 -105
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +126 -106
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/operations/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/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +30 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { connect, Index } from '@lancedb/lancedb';
|
|
2
2
|
import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
|
|
3
|
-
import { MastraStorage, StoreOperations, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, normalizePerPage, calculatePagination, TABLE_RESOURCES, ScoresStorage, TABLE_SCORERS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ensureDate } from '@mastra/core/storage';
|
|
3
|
+
import { MastraStorage, createStorageErrorId, createVectorErrorId, StoreOperations, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, normalizePerPage, calculatePagination, TABLE_RESOURCES, ScoresStorage, TABLE_SCORERS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ensureDate } from '@mastra/core/storage';
|
|
4
4
|
import { MessageList } from '@mastra/core/agent';
|
|
5
5
|
import { Utf8, Float64, Binary, Float32, Int32, Field, Schema } from 'apache-arrow';
|
|
6
6
|
import { saveScorePayloadSchema } from '@mastra/core/evals';
|
|
@@ -89,7 +89,7 @@ async function getTableSchema({
|
|
|
89
89
|
} catch (validationError) {
|
|
90
90
|
throw new MastraError(
|
|
91
91
|
{
|
|
92
|
-
id: "
|
|
92
|
+
id: createStorageErrorId("LANCE", "GET_TABLE_SCHEMA", "INVALID_ARGS"),
|
|
93
93
|
domain: ErrorDomain.STORAGE,
|
|
94
94
|
category: ErrorCategory.USER,
|
|
95
95
|
text: validationError.message,
|
|
@@ -112,7 +112,7 @@ async function getTableSchema({
|
|
|
112
112
|
} catch (error) {
|
|
113
113
|
throw new MastraError(
|
|
114
114
|
{
|
|
115
|
-
id: "
|
|
115
|
+
id: createStorageErrorId("LANCE", "GET_TABLE_SCHEMA", "FAILED"),
|
|
116
116
|
domain: ErrorDomain.STORAGE,
|
|
117
117
|
category: ErrorCategory.THIRD_PARTY,
|
|
118
118
|
details: { tableName }
|
|
@@ -149,7 +149,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
149
149
|
} catch (error) {
|
|
150
150
|
throw new MastraError(
|
|
151
151
|
{
|
|
152
|
-
id: "
|
|
152
|
+
id: createStorageErrorId("LANCE", "GET_THREAD_BY_ID", "FAILED"),
|
|
153
153
|
domain: ErrorDomain.STORAGE,
|
|
154
154
|
category: ErrorCategory.THIRD_PARTY
|
|
155
155
|
},
|
|
@@ -171,7 +171,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
171
171
|
} catch (error) {
|
|
172
172
|
throw new MastraError(
|
|
173
173
|
{
|
|
174
|
-
id: "
|
|
174
|
+
id: createStorageErrorId("LANCE", "SAVE_THREAD", "FAILED"),
|
|
175
175
|
domain: ErrorDomain.STORAGE,
|
|
176
176
|
category: ErrorCategory.THIRD_PARTY
|
|
177
177
|
},
|
|
@@ -213,7 +213,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
213
213
|
}
|
|
214
214
|
throw new MastraError(
|
|
215
215
|
{
|
|
216
|
-
id: "
|
|
216
|
+
id: createStorageErrorId("LANCE", "UPDATE_THREAD", "FAILED"),
|
|
217
217
|
domain: ErrorDomain.STORAGE,
|
|
218
218
|
category: ErrorCategory.THIRD_PARTY
|
|
219
219
|
},
|
|
@@ -223,7 +223,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
223
223
|
}
|
|
224
224
|
throw new MastraError(
|
|
225
225
|
{
|
|
226
|
-
id: "
|
|
226
|
+
id: createStorageErrorId("LANCE", "UPDATE_THREAD", "FAILED"),
|
|
227
227
|
domain: ErrorDomain.STORAGE,
|
|
228
228
|
category: ErrorCategory.THIRD_PARTY
|
|
229
229
|
},
|
|
@@ -239,7 +239,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
239
239
|
} catch (error) {
|
|
240
240
|
throw new MastraError(
|
|
241
241
|
{
|
|
242
|
-
id: "
|
|
242
|
+
id: createStorageErrorId("LANCE", "DELETE_THREAD", "FAILED"),
|
|
243
243
|
domain: ErrorDomain.STORAGE,
|
|
244
244
|
category: ErrorCategory.THIRD_PARTY
|
|
245
245
|
},
|
|
@@ -279,7 +279,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
279
279
|
} catch (error) {
|
|
280
280
|
throw new MastraError(
|
|
281
281
|
{
|
|
282
|
-
id: "
|
|
282
|
+
id: createStorageErrorId("LANCE", "LIST_MESSAGES_BY_ID", "FAILED"),
|
|
283
283
|
domain: ErrorDomain.STORAGE,
|
|
284
284
|
category: ErrorCategory.THIRD_PARTY,
|
|
285
285
|
details: {
|
|
@@ -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
|
-
id: "
|
|
299
|
+
id: createStorageErrorId("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);
|
|
@@ -309,7 +310,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
309
310
|
if (page < 0) {
|
|
310
311
|
throw new MastraError(
|
|
311
312
|
{
|
|
312
|
-
id: "
|
|
313
|
+
id: createStorageErrorId("LANCE", "LIST_MESSAGES", "INVALID_PAGE"),
|
|
313
314
|
domain: ErrorDomain.STORAGE,
|
|
314
315
|
category: ErrorCategory.USER,
|
|
315
316
|
details: { page }
|
|
@@ -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);
|
|
@@ -403,11 +405,11 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
403
405
|
} catch (error) {
|
|
404
406
|
const mastraError = new MastraError(
|
|
405
407
|
{
|
|
406
|
-
id: "
|
|
408
|
+
id: createStorageErrorId("LANCE", "LIST_MESSAGES", "FAILED"),
|
|
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
|
},
|
|
@@ -468,7 +470,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
468
470
|
} catch (error) {
|
|
469
471
|
throw new MastraError(
|
|
470
472
|
{
|
|
471
|
-
id: "
|
|
473
|
+
id: createStorageErrorId("LANCE", "SAVE_MESSAGES", "FAILED"),
|
|
472
474
|
domain: ErrorDomain.STORAGE,
|
|
473
475
|
category: ErrorCategory.THIRD_PARTY
|
|
474
476
|
},
|
|
@@ -483,7 +485,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
483
485
|
if (page < 0) {
|
|
484
486
|
throw new MastraError(
|
|
485
487
|
{
|
|
486
|
-
id: "
|
|
488
|
+
id: createStorageErrorId("LANCE", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
|
|
487
489
|
domain: ErrorDomain.STORAGE,
|
|
488
490
|
category: ErrorCategory.USER,
|
|
489
491
|
details: { page }
|
|
@@ -523,7 +525,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
523
525
|
} catch (error) {
|
|
524
526
|
throw new MastraError(
|
|
525
527
|
{
|
|
526
|
-
id: "
|
|
528
|
+
id: createStorageErrorId("LANCE", "LIST_THREADS_BY_RESOURCE_ID", "FAILED"),
|
|
527
529
|
domain: ErrorDomain.STORAGE,
|
|
528
530
|
category: ErrorCategory.THIRD_PARTY
|
|
529
531
|
},
|
|
@@ -658,7 +660,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
658
660
|
} catch (error) {
|
|
659
661
|
throw new MastraError(
|
|
660
662
|
{
|
|
661
|
-
id: "
|
|
663
|
+
id: createStorageErrorId("LANCE", "UPDATE_MESSAGES", "FAILED"),
|
|
662
664
|
domain: ErrorDomain.STORAGE,
|
|
663
665
|
category: ErrorCategory.THIRD_PARTY,
|
|
664
666
|
details: { count: messages.length }
|
|
@@ -735,7 +737,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
735
737
|
} catch (error) {
|
|
736
738
|
throw new MastraError(
|
|
737
739
|
{
|
|
738
|
-
id: "
|
|
740
|
+
id: createStorageErrorId("LANCE", "GET_RESOURCE_BY_ID", "FAILED"),
|
|
739
741
|
domain: ErrorDomain.STORAGE,
|
|
740
742
|
category: ErrorCategory.THIRD_PARTY
|
|
741
743
|
},
|
|
@@ -759,7 +761,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
759
761
|
} catch (error) {
|
|
760
762
|
throw new MastraError(
|
|
761
763
|
{
|
|
762
|
-
id: "
|
|
764
|
+
id: createStorageErrorId("LANCE", "SAVE_RESOURCE", "FAILED"),
|
|
763
765
|
domain: ErrorDomain.STORAGE,
|
|
764
766
|
category: ErrorCategory.THIRD_PARTY
|
|
765
767
|
},
|
|
@@ -813,7 +815,7 @@ var StoreMemoryLance = class extends MemoryStorage {
|
|
|
813
815
|
}
|
|
814
816
|
throw new MastraError(
|
|
815
817
|
{
|
|
816
|
-
id: "
|
|
818
|
+
id: createStorageErrorId("LANCE", "UPDATE_RESOURCE", "FAILED"),
|
|
817
819
|
domain: ErrorDomain.STORAGE,
|
|
818
820
|
category: ErrorCategory.THIRD_PARTY
|
|
819
821
|
},
|
|
@@ -904,7 +906,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
904
906
|
} catch (error) {
|
|
905
907
|
throw new MastraError(
|
|
906
908
|
{
|
|
907
|
-
id: "
|
|
909
|
+
id: createStorageErrorId("LANCE", "CREATE_TABLE", "INVALID_ARGS"),
|
|
908
910
|
domain: ErrorDomain.STORAGE,
|
|
909
911
|
category: ErrorCategory.USER,
|
|
910
912
|
details: { tableName }
|
|
@@ -922,7 +924,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
922
924
|
}
|
|
923
925
|
throw new MastraError(
|
|
924
926
|
{
|
|
925
|
-
id: "
|
|
927
|
+
id: createStorageErrorId("LANCE", "CREATE_TABLE", "FAILED"),
|
|
926
928
|
domain: ErrorDomain.STORAGE,
|
|
927
929
|
category: ErrorCategory.THIRD_PARTY,
|
|
928
930
|
details: { tableName }
|
|
@@ -942,7 +944,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
942
944
|
} catch (validationError) {
|
|
943
945
|
throw new MastraError(
|
|
944
946
|
{
|
|
945
|
-
id: "
|
|
947
|
+
id: createStorageErrorId("LANCE", "DROP_TABLE", "INVALID_ARGS"),
|
|
946
948
|
domain: ErrorDomain.STORAGE,
|
|
947
949
|
category: ErrorCategory.USER,
|
|
948
950
|
text: validationError.message,
|
|
@@ -960,7 +962,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
960
962
|
}
|
|
961
963
|
throw new MastraError(
|
|
962
964
|
{
|
|
963
|
-
id: "
|
|
965
|
+
id: createStorageErrorId("LANCE", "DROP_TABLE", "FAILED"),
|
|
964
966
|
domain: ErrorDomain.STORAGE,
|
|
965
967
|
category: ErrorCategory.THIRD_PARTY,
|
|
966
968
|
details: { tableName }
|
|
@@ -991,7 +993,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
991
993
|
} catch (validationError) {
|
|
992
994
|
throw new MastraError(
|
|
993
995
|
{
|
|
994
|
-
id: "
|
|
996
|
+
id: createStorageErrorId("LANCE", "ALTER_TABLE", "INVALID_ARGS"),
|
|
995
997
|
domain: ErrorDomain.STORAGE,
|
|
996
998
|
category: ErrorCategory.USER,
|
|
997
999
|
text: validationError.message,
|
|
@@ -1026,7 +1028,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
1026
1028
|
} catch (error) {
|
|
1027
1029
|
throw new MastraError(
|
|
1028
1030
|
{
|
|
1029
|
-
id: "
|
|
1031
|
+
id: createStorageErrorId("LANCE", "ALTER_TABLE", "FAILED"),
|
|
1030
1032
|
domain: ErrorDomain.STORAGE,
|
|
1031
1033
|
category: ErrorCategory.THIRD_PARTY,
|
|
1032
1034
|
details: { tableName }
|
|
@@ -1046,7 +1048,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
1046
1048
|
} catch (validationError) {
|
|
1047
1049
|
throw new MastraError(
|
|
1048
1050
|
{
|
|
1049
|
-
id: "
|
|
1051
|
+
id: createStorageErrorId("LANCE", "CLEAR_TABLE", "INVALID_ARGS"),
|
|
1050
1052
|
domain: ErrorDomain.STORAGE,
|
|
1051
1053
|
category: ErrorCategory.USER,
|
|
1052
1054
|
text: validationError.message,
|
|
@@ -1061,7 +1063,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
1061
1063
|
} catch (error) {
|
|
1062
1064
|
throw new MastraError(
|
|
1063
1065
|
{
|
|
1064
|
-
id: "
|
|
1066
|
+
id: createStorageErrorId("LANCE", "CLEAR_TABLE", "FAILED"),
|
|
1065
1067
|
domain: ErrorDomain.STORAGE,
|
|
1066
1068
|
category: ErrorCategory.THIRD_PARTY,
|
|
1067
1069
|
details: { tableName }
|
|
@@ -1084,7 +1086,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
1084
1086
|
} catch (validationError) {
|
|
1085
1087
|
throw new MastraError(
|
|
1086
1088
|
{
|
|
1087
|
-
id: "
|
|
1089
|
+
id: createStorageErrorId("LANCE", "INSERT", "INVALID_ARGS"),
|
|
1088
1090
|
domain: ErrorDomain.STORAGE,
|
|
1089
1091
|
category: ErrorCategory.USER,
|
|
1090
1092
|
text: validationError.message,
|
|
@@ -1103,12 +1105,11 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
1103
1105
|
processedRecord[key] = JSON.stringify(processedRecord[key]);
|
|
1104
1106
|
}
|
|
1105
1107
|
}
|
|
1106
|
-
console.info(await table.schema());
|
|
1107
1108
|
await table.mergeInsert(primaryId).whenMatchedUpdateAll().whenNotMatchedInsertAll().execute([processedRecord]);
|
|
1108
1109
|
} catch (error) {
|
|
1109
1110
|
throw new MastraError(
|
|
1110
1111
|
{
|
|
1111
|
-
id: "
|
|
1112
|
+
id: createStorageErrorId("LANCE", "INSERT", "FAILED"),
|
|
1112
1113
|
domain: ErrorDomain.STORAGE,
|
|
1113
1114
|
category: ErrorCategory.THIRD_PARTY,
|
|
1114
1115
|
details: { tableName }
|
|
@@ -1131,7 +1132,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
1131
1132
|
} catch (validationError) {
|
|
1132
1133
|
throw new MastraError(
|
|
1133
1134
|
{
|
|
1134
|
-
id: "
|
|
1135
|
+
id: createStorageErrorId("LANCE", "BATCH_INSERT", "INVALID_ARGS"),
|
|
1135
1136
|
domain: ErrorDomain.STORAGE,
|
|
1136
1137
|
category: ErrorCategory.USER,
|
|
1137
1138
|
text: validationError.message,
|
|
@@ -1157,7 +1158,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
1157
1158
|
} catch (error) {
|
|
1158
1159
|
throw new MastraError(
|
|
1159
1160
|
{
|
|
1160
|
-
id: "
|
|
1161
|
+
id: createStorageErrorId("LANCE", "BATCH_INSERT", "FAILED"),
|
|
1161
1162
|
domain: ErrorDomain.STORAGE,
|
|
1162
1163
|
category: ErrorCategory.THIRD_PARTY,
|
|
1163
1164
|
details: { tableName }
|
|
@@ -1180,7 +1181,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
1180
1181
|
} catch (validationError) {
|
|
1181
1182
|
throw new MastraError(
|
|
1182
1183
|
{
|
|
1183
|
-
id: "
|
|
1184
|
+
id: createStorageErrorId("LANCE", "LOAD", "INVALID_ARGS"),
|
|
1184
1185
|
domain: ErrorDomain.STORAGE,
|
|
1185
1186
|
category: ErrorCategory.USER,
|
|
1186
1187
|
text: validationError.message,
|
|
@@ -1219,7 +1220,7 @@ var StoreOperationsLance = class extends StoreOperations {
|
|
|
1219
1220
|
if (error instanceof MastraError) throw error;
|
|
1220
1221
|
throw new MastraError(
|
|
1221
1222
|
{
|
|
1222
|
-
id: "
|
|
1223
|
+
id: createStorageErrorId("LANCE", "LOAD", "FAILED"),
|
|
1223
1224
|
domain: ErrorDomain.STORAGE,
|
|
1224
1225
|
category: ErrorCategory.THIRD_PARTY,
|
|
1225
1226
|
details: { tableName, keyCount: Object.keys(keys).length, firstKey: Object.keys(keys)[0] ?? "" }
|
|
@@ -1242,7 +1243,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1242
1243
|
} catch (error) {
|
|
1243
1244
|
throw new MastraError(
|
|
1244
1245
|
{
|
|
1245
|
-
id: "
|
|
1246
|
+
id: createStorageErrorId("LANCE", "SAVE_SCORE", "INVALID_PAYLOAD"),
|
|
1246
1247
|
text: "Failed to save score in LanceStorage",
|
|
1247
1248
|
domain: ErrorDomain.STORAGE,
|
|
1248
1249
|
category: ErrorCategory.THIRD_PARTY
|
|
@@ -1266,13 +1267,15 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1266
1267
|
filteredScore[key] = JSON.stringify(filteredScore[key]);
|
|
1267
1268
|
}
|
|
1268
1269
|
}
|
|
1270
|
+
filteredScore.createdAt = /* @__PURE__ */ new Date();
|
|
1271
|
+
filteredScore.updatedAt = /* @__PURE__ */ new Date();
|
|
1269
1272
|
filteredScore.id = id;
|
|
1270
1273
|
await table.add([filteredScore], { mode: "append" });
|
|
1271
1274
|
return { score };
|
|
1272
1275
|
} catch (error) {
|
|
1273
1276
|
throw new MastraError(
|
|
1274
1277
|
{
|
|
1275
|
-
id: "
|
|
1278
|
+
id: createStorageErrorId("LANCE", "SAVE_SCORE", "FAILED"),
|
|
1276
1279
|
text: "Failed to save score in LanceStorage",
|
|
1277
1280
|
domain: ErrorDomain.STORAGE,
|
|
1278
1281
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1288,12 +1291,11 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1288
1291
|
const query = table.query().where(`id = '${id}'`).limit(1);
|
|
1289
1292
|
const records = await query.toArray();
|
|
1290
1293
|
if (records.length === 0) return null;
|
|
1291
|
-
|
|
1292
|
-
return processResultWithTypeConversion(records[0], schema);
|
|
1294
|
+
return await this.transformScoreRow(records[0]);
|
|
1293
1295
|
} catch (error) {
|
|
1294
1296
|
throw new MastraError(
|
|
1295
1297
|
{
|
|
1296
|
-
id: "
|
|
1298
|
+
id: createStorageErrorId("LANCE", "GET_SCORE_BY_ID", "FAILED"),
|
|
1297
1299
|
text: "Failed to get score by id in LanceStorage",
|
|
1298
1300
|
domain: ErrorDomain.STORAGE,
|
|
1299
1301
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1303,6 +1305,22 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1303
1305
|
);
|
|
1304
1306
|
}
|
|
1305
1307
|
}
|
|
1308
|
+
/**
|
|
1309
|
+
* LanceDB-specific score row transformation.
|
|
1310
|
+
*
|
|
1311
|
+
* Note: This implementation does NOT use coreTransformScoreRow because:
|
|
1312
|
+
* 1. LanceDB stores schema information in the table itself (requires async fetch)
|
|
1313
|
+
* 2. Uses processResultWithTypeConversion utility for LanceDB-specific type handling
|
|
1314
|
+
*/
|
|
1315
|
+
async transformScoreRow(row) {
|
|
1316
|
+
const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
|
|
1317
|
+
const transformed = processResultWithTypeConversion(row, schema);
|
|
1318
|
+
return {
|
|
1319
|
+
...transformed,
|
|
1320
|
+
createdAt: row.createdAt,
|
|
1321
|
+
updatedAt: row.updatedAt
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1306
1324
|
async listScoresByScorerId({
|
|
1307
1325
|
scorerId,
|
|
1308
1326
|
pagination,
|
|
@@ -1343,8 +1361,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1343
1361
|
if (start > 0) query = query.offset(start);
|
|
1344
1362
|
}
|
|
1345
1363
|
const records = await query.toArray();
|
|
1346
|
-
const
|
|
1347
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1364
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1348
1365
|
return {
|
|
1349
1366
|
pagination: {
|
|
1350
1367
|
page,
|
|
@@ -1357,7 +1374,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1357
1374
|
} catch (error) {
|
|
1358
1375
|
throw new MastraError(
|
|
1359
1376
|
{
|
|
1360
|
-
id: "
|
|
1377
|
+
id: createStorageErrorId("LANCE", "LIST_SCORES_BY_SCORER_ID", "FAILED"),
|
|
1361
1378
|
text: "Failed to get scores by scorerId in LanceStorage",
|
|
1362
1379
|
domain: ErrorDomain.STORAGE,
|
|
1363
1380
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1385,8 +1402,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1385
1402
|
if (start > 0) query = query.offset(start);
|
|
1386
1403
|
}
|
|
1387
1404
|
const records = await query.toArray();
|
|
1388
|
-
const
|
|
1389
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1405
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1390
1406
|
return {
|
|
1391
1407
|
pagination: {
|
|
1392
1408
|
page,
|
|
@@ -1399,7 +1415,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1399
1415
|
} catch (error) {
|
|
1400
1416
|
throw new MastraError(
|
|
1401
1417
|
{
|
|
1402
|
-
id: "
|
|
1418
|
+
id: createStorageErrorId("LANCE", "LIST_SCORES_BY_RUN_ID", "FAILED"),
|
|
1403
1419
|
text: "Failed to get scores by runId in LanceStorage",
|
|
1404
1420
|
domain: ErrorDomain.STORAGE,
|
|
1405
1421
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1428,8 +1444,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1428
1444
|
if (start > 0) query = query.offset(start);
|
|
1429
1445
|
}
|
|
1430
1446
|
const records = await query.toArray();
|
|
1431
|
-
const
|
|
1432
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1447
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1433
1448
|
return {
|
|
1434
1449
|
pagination: {
|
|
1435
1450
|
page,
|
|
@@ -1442,7 +1457,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1442
1457
|
} catch (error) {
|
|
1443
1458
|
throw new MastraError(
|
|
1444
1459
|
{
|
|
1445
|
-
id: "
|
|
1460
|
+
id: createStorageErrorId("LANCE", "LIST_SCORES_BY_ENTITY_ID", "FAILED"),
|
|
1446
1461
|
text: "Failed to get scores by entityId and entityType in LanceStorage",
|
|
1447
1462
|
domain: ErrorDomain.STORAGE,
|
|
1448
1463
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1471,8 +1486,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1471
1486
|
if (start > 0) query = query.offset(start);
|
|
1472
1487
|
}
|
|
1473
1488
|
const records = await query.toArray();
|
|
1474
|
-
const
|
|
1475
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1489
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1476
1490
|
return {
|
|
1477
1491
|
pagination: {
|
|
1478
1492
|
page,
|
|
@@ -1485,7 +1499,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1485
1499
|
} catch (error) {
|
|
1486
1500
|
throw new MastraError(
|
|
1487
1501
|
{
|
|
1488
|
-
id: "
|
|
1502
|
+
id: createStorageErrorId("LANCE", "LIST_SCORES_BY_SPAN", "FAILED"),
|
|
1489
1503
|
text: "Failed to get scores by traceId and spanId in LanceStorage",
|
|
1490
1504
|
domain: ErrorDomain.STORAGE,
|
|
1491
1505
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1567,7 +1581,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1567
1581
|
} catch (error) {
|
|
1568
1582
|
throw new MastraError(
|
|
1569
1583
|
{
|
|
1570
|
-
id: "
|
|
1584
|
+
id: createStorageErrorId("LANCE", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1571
1585
|
domain: ErrorDomain.STORAGE,
|
|
1572
1586
|
category: ErrorCategory.THIRD_PARTY,
|
|
1573
1587
|
details: { workflowName, runId }
|
|
@@ -1588,7 +1602,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1588
1602
|
} catch (error) {
|
|
1589
1603
|
throw new MastraError(
|
|
1590
1604
|
{
|
|
1591
|
-
id: "
|
|
1605
|
+
id: createStorageErrorId("LANCE", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1592
1606
|
domain: ErrorDomain.STORAGE,
|
|
1593
1607
|
category: ErrorCategory.THIRD_PARTY,
|
|
1594
1608
|
details: { workflowName, runId }
|
|
@@ -1612,7 +1626,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1612
1626
|
} catch (error) {
|
|
1613
1627
|
throw new MastraError(
|
|
1614
1628
|
{
|
|
1615
|
-
id: "
|
|
1629
|
+
id: createStorageErrorId("LANCE", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
1616
1630
|
domain: ErrorDomain.STORAGE,
|
|
1617
1631
|
category: ErrorCategory.THIRD_PARTY,
|
|
1618
1632
|
details: { runId: args.runId, workflowName: args.workflowName ?? "" }
|
|
@@ -1654,7 +1668,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1654
1668
|
if (args.page < 0 || !Number.isInteger(args.page)) {
|
|
1655
1669
|
throw new MastraError(
|
|
1656
1670
|
{
|
|
1657
|
-
id: "
|
|
1671
|
+
id: createStorageErrorId("LANCE", "LIST_WORKFLOW_RUNS", "INVALID_PAGINATION"),
|
|
1658
1672
|
domain: ErrorDomain.STORAGE,
|
|
1659
1673
|
category: ErrorCategory.USER,
|
|
1660
1674
|
details: { page: args.page, perPage: args.perPage }
|
|
@@ -1674,7 +1688,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1674
1688
|
} catch (error) {
|
|
1675
1689
|
throw new MastraError(
|
|
1676
1690
|
{
|
|
1677
|
-
id: "
|
|
1691
|
+
id: createStorageErrorId("LANCE", "LIST_WORKFLOW_RUNS", "FAILED"),
|
|
1678
1692
|
domain: ErrorDomain.STORAGE,
|
|
1679
1693
|
category: ErrorCategory.THIRD_PARTY,
|
|
1680
1694
|
details: { resourceId: args?.resourceId ?? "", workflowName: args?.workflowName ?? "" }
|
|
@@ -1694,7 +1708,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
1694
1708
|
* @param id The unique identifier for this storage instance
|
|
1695
1709
|
* @param name The name for this storage instance
|
|
1696
1710
|
* @param uri The URI to connect to LanceDB
|
|
1697
|
-
* @param
|
|
1711
|
+
* @param connectionOptions connection options for LanceDB
|
|
1712
|
+
* @param storageOptions storage options including disableInit
|
|
1698
1713
|
*
|
|
1699
1714
|
* Usage:
|
|
1700
1715
|
*
|
|
@@ -1712,11 +1727,16 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
1712
1727
|
* ```ts
|
|
1713
1728
|
* const store = await LanceStorage.create('my-storage-id', 'MyStorage', 's3://bucket/db', { storageOptions: { timeout: '60s' } });
|
|
1714
1729
|
* ```
|
|
1730
|
+
*
|
|
1731
|
+
* Disable auto-init for runtime (after CI/CD has run migrations)
|
|
1732
|
+
* ```ts
|
|
1733
|
+
* const store = await LanceStorage.create('my-storage-id', 'MyStorage', '/path/to/db', undefined, { disableInit: true });
|
|
1734
|
+
* ```
|
|
1715
1735
|
*/
|
|
1716
|
-
static async create(id, name, uri,
|
|
1717
|
-
const instance = new _LanceStorage(id, name);
|
|
1736
|
+
static async create(id, name, uri, connectionOptions, storageOptions) {
|
|
1737
|
+
const instance = new _LanceStorage(id, name, storageOptions?.disableInit);
|
|
1718
1738
|
try {
|
|
1719
|
-
instance.lanceClient = await connect(uri,
|
|
1739
|
+
instance.lanceClient = await connect(uri, connectionOptions);
|
|
1720
1740
|
const operations = new StoreOperationsLance({ client: instance.lanceClient });
|
|
1721
1741
|
instance.stores = {
|
|
1722
1742
|
operations: new StoreOperationsLance({ client: instance.lanceClient }),
|
|
@@ -1728,11 +1748,11 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
1728
1748
|
} catch (e) {
|
|
1729
1749
|
throw new MastraError(
|
|
1730
1750
|
{
|
|
1731
|
-
id: "
|
|
1751
|
+
id: createStorageErrorId("LANCE", "CONNECT", "FAILED"),
|
|
1732
1752
|
domain: ErrorDomain.STORAGE,
|
|
1733
1753
|
category: ErrorCategory.THIRD_PARTY,
|
|
1734
1754
|
text: `Failed to connect to LanceDB: ${e.message || e}`,
|
|
1735
|
-
details: { uri, optionsProvided: !!
|
|
1755
|
+
details: { uri, optionsProvided: !!connectionOptions }
|
|
1736
1756
|
},
|
|
1737
1757
|
e
|
|
1738
1758
|
);
|
|
@@ -1742,8 +1762,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
1742
1762
|
* @internal
|
|
1743
1763
|
* Private constructor to enforce using the create factory method
|
|
1744
1764
|
*/
|
|
1745
|
-
constructor(id, name) {
|
|
1746
|
-
super({ id, name });
|
|
1765
|
+
constructor(id, name, disableInit) {
|
|
1766
|
+
super({ id, name, disableInit });
|
|
1747
1767
|
const operations = new StoreOperationsLance({ client: this.lanceClient });
|
|
1748
1768
|
this.stores = {
|
|
1749
1769
|
operations: new StoreOperationsLance({ client: this.lanceClient }),
|
|
@@ -2306,7 +2326,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2306
2326
|
} catch (e) {
|
|
2307
2327
|
throw new MastraError(
|
|
2308
2328
|
{
|
|
2309
|
-
id: "
|
|
2329
|
+
id: createVectorErrorId("LANCE", "CONNECT", "FAILED"),
|
|
2310
2330
|
domain: ErrorDomain.STORAGE,
|
|
2311
2331
|
category: ErrorCategory.THIRD_PARTY,
|
|
2312
2332
|
details: { uri }
|
|
@@ -2349,7 +2369,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2349
2369
|
} catch (error) {
|
|
2350
2370
|
throw new MastraError(
|
|
2351
2371
|
{
|
|
2352
|
-
id: "
|
|
2372
|
+
id: createVectorErrorId("LANCE", "QUERY", "INVALID_ARGS"),
|
|
2353
2373
|
domain: ErrorDomain.STORAGE,
|
|
2354
2374
|
category: ErrorCategory.USER,
|
|
2355
2375
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2397,7 +2417,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2397
2417
|
} catch (error) {
|
|
2398
2418
|
throw new MastraError(
|
|
2399
2419
|
{
|
|
2400
|
-
id: "
|
|
2420
|
+
id: createVectorErrorId("LANCE", "QUERY", "FAILED"),
|
|
2401
2421
|
domain: ErrorDomain.STORAGE,
|
|
2402
2422
|
category: ErrorCategory.THIRD_PARTY,
|
|
2403
2423
|
details: { tableName, includeVector, columnsCount: columns?.length, includeAllColumns }
|
|
@@ -2449,7 +2469,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2449
2469
|
} catch (error) {
|
|
2450
2470
|
throw new MastraError(
|
|
2451
2471
|
{
|
|
2452
|
-
id: "
|
|
2472
|
+
id: createVectorErrorId("LANCE", "UPSERT", "INVALID_ARGS"),
|
|
2453
2473
|
domain: ErrorDomain.STORAGE,
|
|
2454
2474
|
category: ErrorCategory.USER,
|
|
2455
2475
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2485,7 +2505,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2485
2505
|
} catch (error) {
|
|
2486
2506
|
throw new MastraError(
|
|
2487
2507
|
{
|
|
2488
|
-
id: "
|
|
2508
|
+
id: createVectorErrorId("LANCE", "UPSERT", "FAILED"),
|
|
2489
2509
|
domain: ErrorDomain.STORAGE,
|
|
2490
2510
|
category: ErrorCategory.THIRD_PARTY,
|
|
2491
2511
|
details: { tableName, vectorCount: vectors.length, metadataCount: metadata.length, idsCount: ids.length }
|
|
@@ -2512,7 +2532,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2512
2532
|
async createTable(tableName, data, options) {
|
|
2513
2533
|
if (!this.lanceClient) {
|
|
2514
2534
|
throw new MastraError({
|
|
2515
|
-
id: "
|
|
2535
|
+
id: createVectorErrorId("LANCE", "CREATE_TABLE", "INVALID_ARGS"),
|
|
2516
2536
|
domain: ErrorDomain.STORAGE,
|
|
2517
2537
|
category: ErrorCategory.USER,
|
|
2518
2538
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2527,7 +2547,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2527
2547
|
} catch (error) {
|
|
2528
2548
|
throw new MastraError(
|
|
2529
2549
|
{
|
|
2530
|
-
id: "
|
|
2550
|
+
id: createVectorErrorId("LANCE", "CREATE_TABLE", "FAILED"),
|
|
2531
2551
|
domain: ErrorDomain.STORAGE,
|
|
2532
2552
|
category: ErrorCategory.THIRD_PARTY,
|
|
2533
2553
|
details: { tableName }
|
|
@@ -2539,7 +2559,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2539
2559
|
async listTables() {
|
|
2540
2560
|
if (!this.lanceClient) {
|
|
2541
2561
|
throw new MastraError({
|
|
2542
|
-
id: "
|
|
2562
|
+
id: createVectorErrorId("LANCE", "LIST_TABLES", "INVALID_ARGS"),
|
|
2543
2563
|
domain: ErrorDomain.STORAGE,
|
|
2544
2564
|
category: ErrorCategory.USER,
|
|
2545
2565
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2551,7 +2571,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2551
2571
|
} catch (error) {
|
|
2552
2572
|
throw new MastraError(
|
|
2553
2573
|
{
|
|
2554
|
-
id: "
|
|
2574
|
+
id: createVectorErrorId("LANCE", "LIST_TABLES", "FAILED"),
|
|
2555
2575
|
domain: ErrorDomain.STORAGE,
|
|
2556
2576
|
category: ErrorCategory.THIRD_PARTY
|
|
2557
2577
|
},
|
|
@@ -2562,7 +2582,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2562
2582
|
async getTableSchema(tableName) {
|
|
2563
2583
|
if (!this.lanceClient) {
|
|
2564
2584
|
throw new MastraError({
|
|
2565
|
-
id: "
|
|
2585
|
+
id: createVectorErrorId("LANCE", "GET_TABLE_SCHEMA", "INVALID_ARGS"),
|
|
2566
2586
|
domain: ErrorDomain.STORAGE,
|
|
2567
2587
|
category: ErrorCategory.USER,
|
|
2568
2588
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2575,7 +2595,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2575
2595
|
} catch (error) {
|
|
2576
2596
|
throw new MastraError(
|
|
2577
2597
|
{
|
|
2578
|
-
id: "
|
|
2598
|
+
id: createVectorErrorId("LANCE", "GET_TABLE_SCHEMA", "FAILED"),
|
|
2579
2599
|
domain: ErrorDomain.STORAGE,
|
|
2580
2600
|
category: ErrorCategory.THIRD_PARTY,
|
|
2581
2601
|
details: { tableName }
|
|
@@ -2610,7 +2630,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2610
2630
|
} catch (err) {
|
|
2611
2631
|
throw new MastraError(
|
|
2612
2632
|
{
|
|
2613
|
-
id: "
|
|
2633
|
+
id: createVectorErrorId("LANCE", "CREATE_INDEX", "INVALID_ARGS"),
|
|
2614
2634
|
domain: ErrorDomain.STORAGE,
|
|
2615
2635
|
category: ErrorCategory.USER,
|
|
2616
2636
|
details: { tableName: tableName || "", indexName, dimension, metric }
|
|
@@ -2655,7 +2675,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2655
2675
|
} catch (error) {
|
|
2656
2676
|
throw new MastraError(
|
|
2657
2677
|
{
|
|
2658
|
-
id: "
|
|
2678
|
+
id: createVectorErrorId("LANCE", "CREATE_INDEX", "FAILED"),
|
|
2659
2679
|
domain: ErrorDomain.STORAGE,
|
|
2660
2680
|
category: ErrorCategory.THIRD_PARTY,
|
|
2661
2681
|
details: { tableName: tableName || "", indexName, dimension }
|
|
@@ -2667,7 +2687,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2667
2687
|
async listIndexes() {
|
|
2668
2688
|
if (!this.lanceClient) {
|
|
2669
2689
|
throw new MastraError({
|
|
2670
|
-
id: "
|
|
2690
|
+
id: createVectorErrorId("LANCE", "LIST_INDEXES", "INVALID_ARGS"),
|
|
2671
2691
|
domain: ErrorDomain.STORAGE,
|
|
2672
2692
|
category: ErrorCategory.USER,
|
|
2673
2693
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2686,7 +2706,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2686
2706
|
} catch (error) {
|
|
2687
2707
|
throw new MastraError(
|
|
2688
2708
|
{
|
|
2689
|
-
id: "
|
|
2709
|
+
id: createVectorErrorId("LANCE", "LIST_INDEXES", "FAILED"),
|
|
2690
2710
|
domain: ErrorDomain.STORAGE,
|
|
2691
2711
|
category: ErrorCategory.THIRD_PARTY
|
|
2692
2712
|
},
|
|
@@ -2705,7 +2725,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2705
2725
|
} catch (err) {
|
|
2706
2726
|
throw new MastraError(
|
|
2707
2727
|
{
|
|
2708
|
-
id: "
|
|
2728
|
+
id: createVectorErrorId("LANCE", "DESCRIBE_INDEX", "INVALID_ARGS"),
|
|
2709
2729
|
domain: ErrorDomain.STORAGE,
|
|
2710
2730
|
category: ErrorCategory.USER,
|
|
2711
2731
|
details: { indexName }
|
|
@@ -2740,7 +2760,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2740
2760
|
} catch (error) {
|
|
2741
2761
|
throw new MastraError(
|
|
2742
2762
|
{
|
|
2743
|
-
id: "
|
|
2763
|
+
id: createVectorErrorId("LANCE", "DESCRIBE_INDEX", "FAILED"),
|
|
2744
2764
|
domain: ErrorDomain.STORAGE,
|
|
2745
2765
|
category: ErrorCategory.THIRD_PARTY,
|
|
2746
2766
|
details: { indexName }
|
|
@@ -2760,7 +2780,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2760
2780
|
} catch (err) {
|
|
2761
2781
|
throw new MastraError(
|
|
2762
2782
|
{
|
|
2763
|
-
id: "
|
|
2783
|
+
id: createVectorErrorId("LANCE", "DELETE_INDEX", "INVALID_ARGS"),
|
|
2764
2784
|
domain: ErrorDomain.STORAGE,
|
|
2765
2785
|
category: ErrorCategory.USER,
|
|
2766
2786
|
details: { indexName }
|
|
@@ -2783,7 +2803,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2783
2803
|
} catch (error) {
|
|
2784
2804
|
throw new MastraError(
|
|
2785
2805
|
{
|
|
2786
|
-
id: "
|
|
2806
|
+
id: createVectorErrorId("LANCE", "DELETE_INDEX", "FAILED"),
|
|
2787
2807
|
domain: ErrorDomain.STORAGE,
|
|
2788
2808
|
category: ErrorCategory.THIRD_PARTY,
|
|
2789
2809
|
details: { indexName }
|
|
@@ -2798,7 +2818,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2798
2818
|
async deleteAllTables() {
|
|
2799
2819
|
if (!this.lanceClient) {
|
|
2800
2820
|
throw new MastraError({
|
|
2801
|
-
id: "
|
|
2821
|
+
id: createVectorErrorId("LANCE", "DELETE_ALL_TABLES", "INVALID_ARGS"),
|
|
2802
2822
|
domain: ErrorDomain.STORAGE,
|
|
2803
2823
|
category: ErrorCategory.USER,
|
|
2804
2824
|
details: { methodName: "deleteAllTables" },
|
|
@@ -2810,7 +2830,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2810
2830
|
} catch (error) {
|
|
2811
2831
|
throw new MastraError(
|
|
2812
2832
|
{
|
|
2813
|
-
id: "
|
|
2833
|
+
id: createVectorErrorId("LANCE", "DELETE_ALL_TABLES", "FAILED"),
|
|
2814
2834
|
domain: ErrorDomain.STORAGE,
|
|
2815
2835
|
category: ErrorCategory.THIRD_PARTY,
|
|
2816
2836
|
details: { methodName: "deleteAllTables" }
|
|
@@ -2822,7 +2842,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2822
2842
|
async deleteTable(tableName) {
|
|
2823
2843
|
if (!this.lanceClient) {
|
|
2824
2844
|
throw new MastraError({
|
|
2825
|
-
id: "
|
|
2845
|
+
id: createVectorErrorId("LANCE", "DELETE_TABLE", "INVALID_ARGS"),
|
|
2826
2846
|
domain: ErrorDomain.STORAGE,
|
|
2827
2847
|
category: ErrorCategory.USER,
|
|
2828
2848
|
details: { tableName },
|
|
@@ -2834,7 +2854,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2834
2854
|
} catch (error) {
|
|
2835
2855
|
throw new MastraError(
|
|
2836
2856
|
{
|
|
2837
|
-
id: "
|
|
2857
|
+
id: createVectorErrorId("LANCE", "DELETE_TABLE", "FAILED"),
|
|
2838
2858
|
domain: ErrorDomain.STORAGE,
|
|
2839
2859
|
category: ErrorCategory.THIRD_PARTY,
|
|
2840
2860
|
details: { tableName }
|
|
@@ -2847,7 +2867,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2847
2867
|
const { indexName, update } = params;
|
|
2848
2868
|
if ("id" in params && "filter" in params && params.id && params.filter) {
|
|
2849
2869
|
throw new MastraError({
|
|
2850
|
-
id: "
|
|
2870
|
+
id: createVectorErrorId("LANCE", "UPDATE_VECTOR", "MUTUALLY_EXCLUSIVE"),
|
|
2851
2871
|
domain: ErrorDomain.STORAGE,
|
|
2852
2872
|
category: ErrorCategory.USER,
|
|
2853
2873
|
text: "id and filter are mutually exclusive",
|
|
@@ -2856,7 +2876,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2856
2876
|
}
|
|
2857
2877
|
if (!("id" in params || "filter" in params) || !params.id && !params.filter) {
|
|
2858
2878
|
throw new MastraError({
|
|
2859
|
-
id: "
|
|
2879
|
+
id: createVectorErrorId("LANCE", "UPDATE_VECTOR", "NO_TARGET"),
|
|
2860
2880
|
domain: ErrorDomain.STORAGE,
|
|
2861
2881
|
category: ErrorCategory.USER,
|
|
2862
2882
|
text: "Either id or filter must be provided",
|
|
@@ -2865,7 +2885,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2865
2885
|
}
|
|
2866
2886
|
if ("filter" in params && params.filter && Object.keys(params.filter).length === 0) {
|
|
2867
2887
|
throw new MastraError({
|
|
2868
|
-
id: "
|
|
2888
|
+
id: createVectorErrorId("LANCE", "UPDATE_VECTOR", "EMPTY_FILTER"),
|
|
2869
2889
|
domain: ErrorDomain.STORAGE,
|
|
2870
2890
|
category: ErrorCategory.USER,
|
|
2871
2891
|
text: "Cannot update with empty filter",
|
|
@@ -2874,7 +2894,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2874
2894
|
}
|
|
2875
2895
|
if (!update.vector && !update.metadata) {
|
|
2876
2896
|
throw new MastraError({
|
|
2877
|
-
id: "
|
|
2897
|
+
id: createVectorErrorId("LANCE", "UPDATE_VECTOR", "NO_PAYLOAD"),
|
|
2878
2898
|
domain: ErrorDomain.STORAGE,
|
|
2879
2899
|
category: ErrorCategory.USER,
|
|
2880
2900
|
text: "No updates provided",
|
|
@@ -2969,7 +2989,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2969
2989
|
if (error instanceof MastraError) throw error;
|
|
2970
2990
|
throw new MastraError(
|
|
2971
2991
|
{
|
|
2972
|
-
id: "
|
|
2992
|
+
id: createVectorErrorId("LANCE", "UPDATE_VECTOR", "FAILED"),
|
|
2973
2993
|
domain: ErrorDomain.STORAGE,
|
|
2974
2994
|
category: ErrorCategory.THIRD_PARTY,
|
|
2975
2995
|
details: {
|
|
@@ -2998,7 +3018,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2998
3018
|
} catch (err) {
|
|
2999
3019
|
throw new MastraError(
|
|
3000
3020
|
{
|
|
3001
|
-
id: "
|
|
3021
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTOR", "INVALID_ARGS"),
|
|
3002
3022
|
domain: ErrorDomain.STORAGE,
|
|
3003
3023
|
category: ErrorCategory.USER,
|
|
3004
3024
|
details: {
|
|
@@ -3031,7 +3051,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3031
3051
|
} catch (error) {
|
|
3032
3052
|
throw new MastraError(
|
|
3033
3053
|
{
|
|
3034
|
-
id: "
|
|
3054
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTOR", "FAILED"),
|
|
3035
3055
|
domain: ErrorDomain.STORAGE,
|
|
3036
3056
|
category: ErrorCategory.THIRD_PARTY,
|
|
3037
3057
|
details: {
|
|
@@ -3071,7 +3091,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3071
3091
|
async deleteVectors({ indexName, filter, ids }) {
|
|
3072
3092
|
if (ids && filter) {
|
|
3073
3093
|
throw new MastraError({
|
|
3074
|
-
id: "
|
|
3094
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTORS", "MUTUALLY_EXCLUSIVE"),
|
|
3075
3095
|
domain: ErrorDomain.STORAGE,
|
|
3076
3096
|
category: ErrorCategory.USER,
|
|
3077
3097
|
text: "ids and filter are mutually exclusive",
|
|
@@ -3080,7 +3100,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3080
3100
|
}
|
|
3081
3101
|
if (!ids && !filter) {
|
|
3082
3102
|
throw new MastraError({
|
|
3083
|
-
id: "
|
|
3103
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTORS", "NO_TARGET"),
|
|
3084
3104
|
domain: ErrorDomain.STORAGE,
|
|
3085
3105
|
category: ErrorCategory.USER,
|
|
3086
3106
|
text: "Either filter or ids must be provided",
|
|
@@ -3089,7 +3109,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3089
3109
|
}
|
|
3090
3110
|
if (ids && ids.length === 0) {
|
|
3091
3111
|
throw new MastraError({
|
|
3092
|
-
id: "
|
|
3112
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTORS", "EMPTY_IDS"),
|
|
3093
3113
|
domain: ErrorDomain.STORAGE,
|
|
3094
3114
|
category: ErrorCategory.USER,
|
|
3095
3115
|
text: "Cannot delete with empty ids array",
|
|
@@ -3098,7 +3118,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3098
3118
|
}
|
|
3099
3119
|
if (filter && Object.keys(filter).length === 0) {
|
|
3100
3120
|
throw new MastraError({
|
|
3101
|
-
id: "
|
|
3121
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTORS", "EMPTY_FILTER"),
|
|
3102
3122
|
domain: ErrorDomain.STORAGE,
|
|
3103
3123
|
category: ErrorCategory.USER,
|
|
3104
3124
|
text: "Cannot delete with empty filter",
|
|
@@ -3158,7 +3178,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3158
3178
|
if (error instanceof MastraError) throw error;
|
|
3159
3179
|
throw new MastraError(
|
|
3160
3180
|
{
|
|
3161
|
-
id: "
|
|
3181
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTORS", "FAILED"),
|
|
3162
3182
|
domain: ErrorDomain.STORAGE,
|
|
3163
3183
|
category: ErrorCategory.THIRD_PARTY,
|
|
3164
3184
|
details: {
|