@mastra/lance 0.0.0-fix-issue-10434-concurrent-write-corruption-20251124213939 → 0.0.0-fix-request-context-as-query-key-20251209093005
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 +133 -3
- package/dist/index.cjs +141 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +142 -114
- 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 +10 -2
- 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 +32 -4
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -91,7 +91,7 @@ async function getTableSchema({
|
|
|
91
91
|
} catch (validationError) {
|
|
92
92
|
throw new error.MastraError(
|
|
93
93
|
{
|
|
94
|
-
id: "
|
|
94
|
+
id: storage.createStorageErrorId("LANCE", "GET_TABLE_SCHEMA", "INVALID_ARGS"),
|
|
95
95
|
domain: error.ErrorDomain.STORAGE,
|
|
96
96
|
category: error.ErrorCategory.USER,
|
|
97
97
|
text: validationError.message,
|
|
@@ -114,7 +114,7 @@ async function getTableSchema({
|
|
|
114
114
|
} catch (error$1) {
|
|
115
115
|
throw new error.MastraError(
|
|
116
116
|
{
|
|
117
|
-
id: "
|
|
117
|
+
id: storage.createStorageErrorId("LANCE", "GET_TABLE_SCHEMA", "FAILED"),
|
|
118
118
|
domain: error.ErrorDomain.STORAGE,
|
|
119
119
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
120
120
|
details: { tableName }
|
|
@@ -151,7 +151,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
151
151
|
} catch (error$1) {
|
|
152
152
|
throw new error.MastraError(
|
|
153
153
|
{
|
|
154
|
-
id: "
|
|
154
|
+
id: storage.createStorageErrorId("LANCE", "GET_THREAD_BY_ID", "FAILED"),
|
|
155
155
|
domain: error.ErrorDomain.STORAGE,
|
|
156
156
|
category: error.ErrorCategory.THIRD_PARTY
|
|
157
157
|
},
|
|
@@ -173,7 +173,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
173
173
|
} catch (error$1) {
|
|
174
174
|
throw new error.MastraError(
|
|
175
175
|
{
|
|
176
|
-
id: "
|
|
176
|
+
id: storage.createStorageErrorId("LANCE", "SAVE_THREAD", "FAILED"),
|
|
177
177
|
domain: error.ErrorDomain.STORAGE,
|
|
178
178
|
category: error.ErrorCategory.THIRD_PARTY
|
|
179
179
|
},
|
|
@@ -215,7 +215,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
215
215
|
}
|
|
216
216
|
throw new error.MastraError(
|
|
217
217
|
{
|
|
218
|
-
id: "
|
|
218
|
+
id: storage.createStorageErrorId("LANCE", "UPDATE_THREAD", "FAILED"),
|
|
219
219
|
domain: error.ErrorDomain.STORAGE,
|
|
220
220
|
category: error.ErrorCategory.THIRD_PARTY
|
|
221
221
|
},
|
|
@@ -225,7 +225,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
225
225
|
}
|
|
226
226
|
throw new error.MastraError(
|
|
227
227
|
{
|
|
228
|
-
id: "
|
|
228
|
+
id: storage.createStorageErrorId("LANCE", "UPDATE_THREAD", "FAILED"),
|
|
229
229
|
domain: error.ErrorDomain.STORAGE,
|
|
230
230
|
category: error.ErrorCategory.THIRD_PARTY
|
|
231
231
|
},
|
|
@@ -241,7 +241,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
241
241
|
} catch (error$1) {
|
|
242
242
|
throw new error.MastraError(
|
|
243
243
|
{
|
|
244
|
-
id: "
|
|
244
|
+
id: storage.createStorageErrorId("LANCE", "DELETE_THREAD", "FAILED"),
|
|
245
245
|
domain: error.ErrorDomain.STORAGE,
|
|
246
246
|
category: error.ErrorCategory.THIRD_PARTY
|
|
247
247
|
},
|
|
@@ -281,7 +281,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
281
281
|
} catch (error$1) {
|
|
282
282
|
throw new error.MastraError(
|
|
283
283
|
{
|
|
284
|
-
id: "
|
|
284
|
+
id: storage.createStorageErrorId("LANCE", "LIST_MESSAGES_BY_ID", "FAILED"),
|
|
285
285
|
domain: error.ErrorDomain.STORAGE,
|
|
286
286
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
287
287
|
details: {
|
|
@@ -294,15 +294,16 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
294
294
|
}
|
|
295
295
|
async listMessages(args) {
|
|
296
296
|
const { threadId, resourceId, include, filter, perPage: perPageInput, page = 0, orderBy } = args;
|
|
297
|
-
|
|
297
|
+
const threadIds = Array.isArray(threadId) ? threadId : [threadId];
|
|
298
|
+
if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
|
|
298
299
|
throw new error.MastraError(
|
|
299
300
|
{
|
|
300
|
-
id: "
|
|
301
|
+
id: storage.createStorageErrorId("LANCE", "LIST_MESSAGES", "INVALID_THREAD_ID"),
|
|
301
302
|
domain: error.ErrorDomain.STORAGE,
|
|
302
303
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
303
|
-
details: { threadId }
|
|
304
|
+
details: { threadId: Array.isArray(threadId) ? threadId.join(",") : threadId }
|
|
304
305
|
},
|
|
305
|
-
new Error("threadId must be a non-empty string")
|
|
306
|
+
new Error("threadId must be a non-empty string or array of non-empty strings")
|
|
306
307
|
);
|
|
307
308
|
}
|
|
308
309
|
const perPage = storage.normalizePerPage(perPageInput, 40);
|
|
@@ -311,7 +312,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
311
312
|
if (page < 0) {
|
|
312
313
|
throw new error.MastraError(
|
|
313
314
|
{
|
|
314
|
-
id: "
|
|
315
|
+
id: storage.createStorageErrorId("LANCE", "LIST_MESSAGES", "INVALID_PAGE"),
|
|
315
316
|
domain: error.ErrorDomain.STORAGE,
|
|
316
317
|
category: error.ErrorCategory.USER,
|
|
317
318
|
details: { page }
|
|
@@ -321,7 +322,8 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
321
322
|
}
|
|
322
323
|
const { field, direction } = this.parseOrderBy(orderBy, "ASC");
|
|
323
324
|
const table = await this.client.openTable(storage.TABLE_MESSAGES);
|
|
324
|
-
const
|
|
325
|
+
const threadCondition = threadIds.length === 1 ? `thread_id = '${this.escapeSql(threadIds[0])}'` : `thread_id IN (${threadIds.map((t) => `'${this.escapeSql(t)}'`).join(", ")})`;
|
|
326
|
+
const conditions = [threadCondition];
|
|
325
327
|
if (resourceId) {
|
|
326
328
|
conditions.push(`\`resourceId\` = '${this.escapeSql(resourceId)}'`);
|
|
327
329
|
}
|
|
@@ -361,9 +363,9 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
361
363
|
}
|
|
362
364
|
const messageIds = new Set(messages.map((m) => m.id));
|
|
363
365
|
if (include && include.length > 0) {
|
|
364
|
-
const
|
|
366
|
+
const threadIds2 = [...new Set(include.map((item) => item.threadId || threadId))];
|
|
365
367
|
const allThreadMessages = [];
|
|
366
|
-
for (const tid of
|
|
368
|
+
for (const tid of threadIds2) {
|
|
367
369
|
const threadQuery = table.query().where(`thread_id = '${tid}'`);
|
|
368
370
|
let threadRecords = await threadQuery.toArray();
|
|
369
371
|
allThreadMessages.push(...threadRecords);
|
|
@@ -405,11 +407,11 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
405
407
|
} catch (error$1) {
|
|
406
408
|
const mastraError = new error.MastraError(
|
|
407
409
|
{
|
|
408
|
-
id: "
|
|
410
|
+
id: storage.createStorageErrorId("LANCE", "LIST_MESSAGES", "FAILED"),
|
|
409
411
|
domain: error.ErrorDomain.STORAGE,
|
|
410
412
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
411
413
|
details: {
|
|
412
|
-
threadId,
|
|
414
|
+
threadId: Array.isArray(threadId) ? threadId.join(",") : threadId,
|
|
413
415
|
resourceId: resourceId ?? ""
|
|
414
416
|
}
|
|
415
417
|
},
|
|
@@ -470,7 +472,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
470
472
|
} catch (error$1) {
|
|
471
473
|
throw new error.MastraError(
|
|
472
474
|
{
|
|
473
|
-
id: "
|
|
475
|
+
id: storage.createStorageErrorId("LANCE", "SAVE_MESSAGES", "FAILED"),
|
|
474
476
|
domain: error.ErrorDomain.STORAGE,
|
|
475
477
|
category: error.ErrorCategory.THIRD_PARTY
|
|
476
478
|
},
|
|
@@ -485,7 +487,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
485
487
|
if (page < 0) {
|
|
486
488
|
throw new error.MastraError(
|
|
487
489
|
{
|
|
488
|
-
id: "
|
|
490
|
+
id: storage.createStorageErrorId("LANCE", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
|
|
489
491
|
domain: error.ErrorDomain.STORAGE,
|
|
490
492
|
category: error.ErrorCategory.USER,
|
|
491
493
|
details: { page }
|
|
@@ -525,7 +527,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
525
527
|
} catch (error$1) {
|
|
526
528
|
throw new error.MastraError(
|
|
527
529
|
{
|
|
528
|
-
id: "
|
|
530
|
+
id: storage.createStorageErrorId("LANCE", "LIST_THREADS_BY_RESOURCE_ID", "FAILED"),
|
|
529
531
|
domain: error.ErrorDomain.STORAGE,
|
|
530
532
|
category: error.ErrorCategory.THIRD_PARTY
|
|
531
533
|
},
|
|
@@ -660,7 +662,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
660
662
|
} catch (error$1) {
|
|
661
663
|
throw new error.MastraError(
|
|
662
664
|
{
|
|
663
|
-
id: "
|
|
665
|
+
id: storage.createStorageErrorId("LANCE", "UPDATE_MESSAGES", "FAILED"),
|
|
664
666
|
domain: error.ErrorDomain.STORAGE,
|
|
665
667
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
666
668
|
details: { count: messages.length }
|
|
@@ -737,7 +739,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
737
739
|
} catch (error$1) {
|
|
738
740
|
throw new error.MastraError(
|
|
739
741
|
{
|
|
740
|
-
id: "
|
|
742
|
+
id: storage.createStorageErrorId("LANCE", "GET_RESOURCE_BY_ID", "FAILED"),
|
|
741
743
|
domain: error.ErrorDomain.STORAGE,
|
|
742
744
|
category: error.ErrorCategory.THIRD_PARTY
|
|
743
745
|
},
|
|
@@ -761,7 +763,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
761
763
|
} catch (error$1) {
|
|
762
764
|
throw new error.MastraError(
|
|
763
765
|
{
|
|
764
|
-
id: "
|
|
766
|
+
id: storage.createStorageErrorId("LANCE", "SAVE_RESOURCE", "FAILED"),
|
|
765
767
|
domain: error.ErrorDomain.STORAGE,
|
|
766
768
|
category: error.ErrorCategory.THIRD_PARTY
|
|
767
769
|
},
|
|
@@ -815,7 +817,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
|
|
|
815
817
|
}
|
|
816
818
|
throw new error.MastraError(
|
|
817
819
|
{
|
|
818
|
-
id: "
|
|
820
|
+
id: storage.createStorageErrorId("LANCE", "UPDATE_RESOURCE", "FAILED"),
|
|
819
821
|
domain: error.ErrorDomain.STORAGE,
|
|
820
822
|
category: error.ErrorCategory.THIRD_PARTY
|
|
821
823
|
},
|
|
@@ -906,7 +908,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
906
908
|
} catch (error$1) {
|
|
907
909
|
throw new error.MastraError(
|
|
908
910
|
{
|
|
909
|
-
id: "
|
|
911
|
+
id: storage.createStorageErrorId("LANCE", "CREATE_TABLE", "INVALID_ARGS"),
|
|
910
912
|
domain: error.ErrorDomain.STORAGE,
|
|
911
913
|
category: error.ErrorCategory.USER,
|
|
912
914
|
details: { tableName }
|
|
@@ -924,7 +926,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
924
926
|
}
|
|
925
927
|
throw new error.MastraError(
|
|
926
928
|
{
|
|
927
|
-
id: "
|
|
929
|
+
id: storage.createStorageErrorId("LANCE", "CREATE_TABLE", "FAILED"),
|
|
928
930
|
domain: error.ErrorDomain.STORAGE,
|
|
929
931
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
930
932
|
details: { tableName }
|
|
@@ -944,7 +946,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
944
946
|
} catch (validationError) {
|
|
945
947
|
throw new error.MastraError(
|
|
946
948
|
{
|
|
947
|
-
id: "
|
|
949
|
+
id: storage.createStorageErrorId("LANCE", "DROP_TABLE", "INVALID_ARGS"),
|
|
948
950
|
domain: error.ErrorDomain.STORAGE,
|
|
949
951
|
category: error.ErrorCategory.USER,
|
|
950
952
|
text: validationError.message,
|
|
@@ -962,7 +964,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
962
964
|
}
|
|
963
965
|
throw new error.MastraError(
|
|
964
966
|
{
|
|
965
|
-
id: "
|
|
967
|
+
id: storage.createStorageErrorId("LANCE", "DROP_TABLE", "FAILED"),
|
|
966
968
|
domain: error.ErrorDomain.STORAGE,
|
|
967
969
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
968
970
|
details: { tableName }
|
|
@@ -993,7 +995,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
993
995
|
} catch (validationError) {
|
|
994
996
|
throw new error.MastraError(
|
|
995
997
|
{
|
|
996
|
-
id: "
|
|
998
|
+
id: storage.createStorageErrorId("LANCE", "ALTER_TABLE", "INVALID_ARGS"),
|
|
997
999
|
domain: error.ErrorDomain.STORAGE,
|
|
998
1000
|
category: error.ErrorCategory.USER,
|
|
999
1001
|
text: validationError.message,
|
|
@@ -1028,7 +1030,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
1028
1030
|
} catch (error$1) {
|
|
1029
1031
|
throw new error.MastraError(
|
|
1030
1032
|
{
|
|
1031
|
-
id: "
|
|
1033
|
+
id: storage.createStorageErrorId("LANCE", "ALTER_TABLE", "FAILED"),
|
|
1032
1034
|
domain: error.ErrorDomain.STORAGE,
|
|
1033
1035
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1034
1036
|
details: { tableName }
|
|
@@ -1048,7 +1050,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
1048
1050
|
} catch (validationError) {
|
|
1049
1051
|
throw new error.MastraError(
|
|
1050
1052
|
{
|
|
1051
|
-
id: "
|
|
1053
|
+
id: storage.createStorageErrorId("LANCE", "CLEAR_TABLE", "INVALID_ARGS"),
|
|
1052
1054
|
domain: error.ErrorDomain.STORAGE,
|
|
1053
1055
|
category: error.ErrorCategory.USER,
|
|
1054
1056
|
text: validationError.message,
|
|
@@ -1063,7 +1065,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
1063
1065
|
} catch (error$1) {
|
|
1064
1066
|
throw new error.MastraError(
|
|
1065
1067
|
{
|
|
1066
|
-
id: "
|
|
1068
|
+
id: storage.createStorageErrorId("LANCE", "CLEAR_TABLE", "FAILED"),
|
|
1067
1069
|
domain: error.ErrorDomain.STORAGE,
|
|
1068
1070
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1069
1071
|
details: { tableName }
|
|
@@ -1086,7 +1088,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
1086
1088
|
} catch (validationError) {
|
|
1087
1089
|
throw new error.MastraError(
|
|
1088
1090
|
{
|
|
1089
|
-
id: "
|
|
1091
|
+
id: storage.createStorageErrorId("LANCE", "INSERT", "INVALID_ARGS"),
|
|
1090
1092
|
domain: error.ErrorDomain.STORAGE,
|
|
1091
1093
|
category: error.ErrorCategory.USER,
|
|
1092
1094
|
text: validationError.message,
|
|
@@ -1105,12 +1107,11 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
1105
1107
|
processedRecord[key] = JSON.stringify(processedRecord[key]);
|
|
1106
1108
|
}
|
|
1107
1109
|
}
|
|
1108
|
-
console.info(await table.schema());
|
|
1109
1110
|
await table.mergeInsert(primaryId).whenMatchedUpdateAll().whenNotMatchedInsertAll().execute([processedRecord]);
|
|
1110
1111
|
} catch (error$1) {
|
|
1111
1112
|
throw new error.MastraError(
|
|
1112
1113
|
{
|
|
1113
|
-
id: "
|
|
1114
|
+
id: storage.createStorageErrorId("LANCE", "INSERT", "FAILED"),
|
|
1114
1115
|
domain: error.ErrorDomain.STORAGE,
|
|
1115
1116
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1116
1117
|
details: { tableName }
|
|
@@ -1133,7 +1134,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
1133
1134
|
} catch (validationError) {
|
|
1134
1135
|
throw new error.MastraError(
|
|
1135
1136
|
{
|
|
1136
|
-
id: "
|
|
1137
|
+
id: storage.createStorageErrorId("LANCE", "BATCH_INSERT", "INVALID_ARGS"),
|
|
1137
1138
|
domain: error.ErrorDomain.STORAGE,
|
|
1138
1139
|
category: error.ErrorCategory.USER,
|
|
1139
1140
|
text: validationError.message,
|
|
@@ -1159,7 +1160,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
1159
1160
|
} catch (error$1) {
|
|
1160
1161
|
throw new error.MastraError(
|
|
1161
1162
|
{
|
|
1162
|
-
id: "
|
|
1163
|
+
id: storage.createStorageErrorId("LANCE", "BATCH_INSERT", "FAILED"),
|
|
1163
1164
|
domain: error.ErrorDomain.STORAGE,
|
|
1164
1165
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1165
1166
|
details: { tableName }
|
|
@@ -1182,7 +1183,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
1182
1183
|
} catch (validationError) {
|
|
1183
1184
|
throw new error.MastraError(
|
|
1184
1185
|
{
|
|
1185
|
-
id: "
|
|
1186
|
+
id: storage.createStorageErrorId("LANCE", "LOAD", "INVALID_ARGS"),
|
|
1186
1187
|
domain: error.ErrorDomain.STORAGE,
|
|
1187
1188
|
category: error.ErrorCategory.USER,
|
|
1188
1189
|
text: validationError.message,
|
|
@@ -1221,7 +1222,7 @@ var StoreOperationsLance = class extends storage.StoreOperations {
|
|
|
1221
1222
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
1222
1223
|
throw new error.MastraError(
|
|
1223
1224
|
{
|
|
1224
|
-
id: "
|
|
1225
|
+
id: storage.createStorageErrorId("LANCE", "LOAD", "FAILED"),
|
|
1225
1226
|
domain: error.ErrorDomain.STORAGE,
|
|
1226
1227
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1227
1228
|
details: { tableName, keyCount: Object.keys(keys).length, firstKey: Object.keys(keys)[0] ?? "" }
|
|
@@ -1244,37 +1245,47 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1244
1245
|
} catch (error$1) {
|
|
1245
1246
|
throw new error.MastraError(
|
|
1246
1247
|
{
|
|
1247
|
-
id: "
|
|
1248
|
+
id: storage.createStorageErrorId("LANCE", "SAVE_SCORE", "VALIDATION_FAILED"),
|
|
1248
1249
|
text: "Failed to save score in LanceStorage",
|
|
1249
1250
|
domain: error.ErrorDomain.STORAGE,
|
|
1250
|
-
category: error.ErrorCategory.
|
|
1251
|
+
category: error.ErrorCategory.USER,
|
|
1252
|
+
details: {
|
|
1253
|
+
scorer: score.scorer?.id ?? "unknown",
|
|
1254
|
+
entityId: score.entityId ?? "unknown",
|
|
1255
|
+
entityType: score.entityType ?? "unknown",
|
|
1256
|
+
traceId: score.traceId ?? "",
|
|
1257
|
+
spanId: score.spanId ?? ""
|
|
1258
|
+
}
|
|
1251
1259
|
},
|
|
1252
1260
|
error$1
|
|
1253
1261
|
);
|
|
1254
1262
|
}
|
|
1263
|
+
const id = crypto.randomUUID();
|
|
1264
|
+
const now = /* @__PURE__ */ new Date();
|
|
1255
1265
|
try {
|
|
1256
|
-
const id = crypto.randomUUID();
|
|
1257
1266
|
const table = await this.client.openTable(storage.TABLE_SCORERS);
|
|
1258
1267
|
const schema = await getTableSchema({ tableName: storage.TABLE_SCORERS, client: this.client });
|
|
1259
1268
|
const allowedFields = new Set(schema.fields.map((f) => f.name));
|
|
1260
1269
|
const filteredScore = {};
|
|
1261
|
-
Object.keys(validatedScore)
|
|
1270
|
+
for (const key of Object.keys(validatedScore)) {
|
|
1262
1271
|
if (allowedFields.has(key)) {
|
|
1263
|
-
filteredScore[key] =
|
|
1272
|
+
filteredScore[key] = validatedScore[key];
|
|
1264
1273
|
}
|
|
1265
|
-
}
|
|
1274
|
+
}
|
|
1266
1275
|
for (const key in filteredScore) {
|
|
1267
1276
|
if (filteredScore[key] !== null && typeof filteredScore[key] === "object" && !(filteredScore[key] instanceof Date)) {
|
|
1268
1277
|
filteredScore[key] = JSON.stringify(filteredScore[key]);
|
|
1269
1278
|
}
|
|
1270
1279
|
}
|
|
1271
1280
|
filteredScore.id = id;
|
|
1281
|
+
filteredScore.createdAt = now;
|
|
1282
|
+
filteredScore.updatedAt = now;
|
|
1272
1283
|
await table.add([filteredScore], { mode: "append" });
|
|
1273
|
-
return { score };
|
|
1284
|
+
return { score: { ...validatedScore, id, createdAt: now, updatedAt: now } };
|
|
1274
1285
|
} catch (error$1) {
|
|
1275
1286
|
throw new error.MastraError(
|
|
1276
1287
|
{
|
|
1277
|
-
id: "
|
|
1288
|
+
id: storage.createStorageErrorId("LANCE", "SAVE_SCORE", "FAILED"),
|
|
1278
1289
|
text: "Failed to save score in LanceStorage",
|
|
1279
1290
|
domain: error.ErrorDomain.STORAGE,
|
|
1280
1291
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
@@ -1290,12 +1301,11 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1290
1301
|
const query = table.query().where(`id = '${id}'`).limit(1);
|
|
1291
1302
|
const records = await query.toArray();
|
|
1292
1303
|
if (records.length === 0) return null;
|
|
1293
|
-
|
|
1294
|
-
return processResultWithTypeConversion(records[0], schema);
|
|
1304
|
+
return await this.transformScoreRow(records[0]);
|
|
1295
1305
|
} catch (error$1) {
|
|
1296
1306
|
throw new error.MastraError(
|
|
1297
1307
|
{
|
|
1298
|
-
id: "
|
|
1308
|
+
id: storage.createStorageErrorId("LANCE", "GET_SCORE_BY_ID", "FAILED"),
|
|
1299
1309
|
text: "Failed to get score by id in LanceStorage",
|
|
1300
1310
|
domain: error.ErrorDomain.STORAGE,
|
|
1301
1311
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
@@ -1305,6 +1315,22 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1305
1315
|
);
|
|
1306
1316
|
}
|
|
1307
1317
|
}
|
|
1318
|
+
/**
|
|
1319
|
+
* LanceDB-specific score row transformation.
|
|
1320
|
+
*
|
|
1321
|
+
* Note: This implementation does NOT use coreTransformScoreRow because:
|
|
1322
|
+
* 1. LanceDB stores schema information in the table itself (requires async fetch)
|
|
1323
|
+
* 2. Uses processResultWithTypeConversion utility for LanceDB-specific type handling
|
|
1324
|
+
*/
|
|
1325
|
+
async transformScoreRow(row) {
|
|
1326
|
+
const schema = await getTableSchema({ tableName: storage.TABLE_SCORERS, client: this.client });
|
|
1327
|
+
const transformed = processResultWithTypeConversion(row, schema);
|
|
1328
|
+
return {
|
|
1329
|
+
...transformed,
|
|
1330
|
+
createdAt: row.createdAt,
|
|
1331
|
+
updatedAt: row.updatedAt
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1308
1334
|
async listScoresByScorerId({
|
|
1309
1335
|
scorerId,
|
|
1310
1336
|
pagination,
|
|
@@ -1345,8 +1371,7 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1345
1371
|
if (start > 0) query = query.offset(start);
|
|
1346
1372
|
}
|
|
1347
1373
|
const records = await query.toArray();
|
|
1348
|
-
const
|
|
1349
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1374
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1350
1375
|
return {
|
|
1351
1376
|
pagination: {
|
|
1352
1377
|
page,
|
|
@@ -1359,7 +1384,7 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1359
1384
|
} catch (error$1) {
|
|
1360
1385
|
throw new error.MastraError(
|
|
1361
1386
|
{
|
|
1362
|
-
id: "
|
|
1387
|
+
id: storage.createStorageErrorId("LANCE", "LIST_SCORES_BY_SCORER_ID", "FAILED"),
|
|
1363
1388
|
text: "Failed to get scores by scorerId in LanceStorage",
|
|
1364
1389
|
domain: error.ErrorDomain.STORAGE,
|
|
1365
1390
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
@@ -1387,8 +1412,7 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1387
1412
|
if (start > 0) query = query.offset(start);
|
|
1388
1413
|
}
|
|
1389
1414
|
const records = await query.toArray();
|
|
1390
|
-
const
|
|
1391
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1415
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1392
1416
|
return {
|
|
1393
1417
|
pagination: {
|
|
1394
1418
|
page,
|
|
@@ -1401,7 +1425,7 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1401
1425
|
} catch (error$1) {
|
|
1402
1426
|
throw new error.MastraError(
|
|
1403
1427
|
{
|
|
1404
|
-
id: "
|
|
1428
|
+
id: storage.createStorageErrorId("LANCE", "LIST_SCORES_BY_RUN_ID", "FAILED"),
|
|
1405
1429
|
text: "Failed to get scores by runId in LanceStorage",
|
|
1406
1430
|
domain: error.ErrorDomain.STORAGE,
|
|
1407
1431
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
@@ -1430,8 +1454,7 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1430
1454
|
if (start > 0) query = query.offset(start);
|
|
1431
1455
|
}
|
|
1432
1456
|
const records = await query.toArray();
|
|
1433
|
-
const
|
|
1434
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1457
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1435
1458
|
return {
|
|
1436
1459
|
pagination: {
|
|
1437
1460
|
page,
|
|
@@ -1444,7 +1467,7 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1444
1467
|
} catch (error$1) {
|
|
1445
1468
|
throw new error.MastraError(
|
|
1446
1469
|
{
|
|
1447
|
-
id: "
|
|
1470
|
+
id: storage.createStorageErrorId("LANCE", "LIST_SCORES_BY_ENTITY_ID", "FAILED"),
|
|
1448
1471
|
text: "Failed to get scores by entityId and entityType in LanceStorage",
|
|
1449
1472
|
domain: error.ErrorDomain.STORAGE,
|
|
1450
1473
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
@@ -1473,8 +1496,7 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1473
1496
|
if (start > 0) query = query.offset(start);
|
|
1474
1497
|
}
|
|
1475
1498
|
const records = await query.toArray();
|
|
1476
|
-
const
|
|
1477
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1499
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1478
1500
|
return {
|
|
1479
1501
|
pagination: {
|
|
1480
1502
|
page,
|
|
@@ -1487,7 +1509,7 @@ var StoreScoresLance = class extends storage.ScoresStorage {
|
|
|
1487
1509
|
} catch (error$1) {
|
|
1488
1510
|
throw new error.MastraError(
|
|
1489
1511
|
{
|
|
1490
|
-
id: "
|
|
1512
|
+
id: storage.createStorageErrorId("LANCE", "LIST_SCORES_BY_SPAN", "FAILED"),
|
|
1491
1513
|
text: "Failed to get scores by traceId and spanId in LanceStorage",
|
|
1492
1514
|
domain: error.ErrorDomain.STORAGE,
|
|
1493
1515
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
@@ -1569,7 +1591,7 @@ var StoreWorkflowsLance = class extends storage.WorkflowsStorage {
|
|
|
1569
1591
|
} catch (error$1) {
|
|
1570
1592
|
throw new error.MastraError(
|
|
1571
1593
|
{
|
|
1572
|
-
id: "
|
|
1594
|
+
id: storage.createStorageErrorId("LANCE", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1573
1595
|
domain: error.ErrorDomain.STORAGE,
|
|
1574
1596
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1575
1597
|
details: { workflowName, runId }
|
|
@@ -1590,7 +1612,7 @@ var StoreWorkflowsLance = class extends storage.WorkflowsStorage {
|
|
|
1590
1612
|
} catch (error$1) {
|
|
1591
1613
|
throw new error.MastraError(
|
|
1592
1614
|
{
|
|
1593
|
-
id: "
|
|
1615
|
+
id: storage.createStorageErrorId("LANCE", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1594
1616
|
domain: error.ErrorDomain.STORAGE,
|
|
1595
1617
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1596
1618
|
details: { workflowName, runId }
|
|
@@ -1614,7 +1636,7 @@ var StoreWorkflowsLance = class extends storage.WorkflowsStorage {
|
|
|
1614
1636
|
} catch (error$1) {
|
|
1615
1637
|
throw new error.MastraError(
|
|
1616
1638
|
{
|
|
1617
|
-
id: "
|
|
1639
|
+
id: storage.createStorageErrorId("LANCE", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
1618
1640
|
domain: error.ErrorDomain.STORAGE,
|
|
1619
1641
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1620
1642
|
details: { runId: args.runId, workflowName: args.workflowName ?? "" }
|
|
@@ -1656,7 +1678,7 @@ var StoreWorkflowsLance = class extends storage.WorkflowsStorage {
|
|
|
1656
1678
|
if (args.page < 0 || !Number.isInteger(args.page)) {
|
|
1657
1679
|
throw new error.MastraError(
|
|
1658
1680
|
{
|
|
1659
|
-
id: "
|
|
1681
|
+
id: storage.createStorageErrorId("LANCE", "LIST_WORKFLOW_RUNS", "INVALID_PAGINATION"),
|
|
1660
1682
|
domain: error.ErrorDomain.STORAGE,
|
|
1661
1683
|
category: error.ErrorCategory.USER,
|
|
1662
1684
|
details: { page: args.page, perPage: args.perPage }
|
|
@@ -1676,7 +1698,7 @@ var StoreWorkflowsLance = class extends storage.WorkflowsStorage {
|
|
|
1676
1698
|
} catch (error$1) {
|
|
1677
1699
|
throw new error.MastraError(
|
|
1678
1700
|
{
|
|
1679
|
-
id: "
|
|
1701
|
+
id: storage.createStorageErrorId("LANCE", "LIST_WORKFLOW_RUNS", "FAILED"),
|
|
1680
1702
|
domain: error.ErrorDomain.STORAGE,
|
|
1681
1703
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1682
1704
|
details: { resourceId: args?.resourceId ?? "", workflowName: args?.workflowName ?? "" }
|
|
@@ -1696,7 +1718,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1696
1718
|
* @param id The unique identifier for this storage instance
|
|
1697
1719
|
* @param name The name for this storage instance
|
|
1698
1720
|
* @param uri The URI to connect to LanceDB
|
|
1699
|
-
* @param
|
|
1721
|
+
* @param connectionOptions connection options for LanceDB
|
|
1722
|
+
* @param storageOptions storage options including disableInit
|
|
1700
1723
|
*
|
|
1701
1724
|
* Usage:
|
|
1702
1725
|
*
|
|
@@ -1714,11 +1737,16 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1714
1737
|
* ```ts
|
|
1715
1738
|
* const store = await LanceStorage.create('my-storage-id', 'MyStorage', 's3://bucket/db', { storageOptions: { timeout: '60s' } });
|
|
1716
1739
|
* ```
|
|
1740
|
+
*
|
|
1741
|
+
* Disable auto-init for runtime (after CI/CD has run migrations)
|
|
1742
|
+
* ```ts
|
|
1743
|
+
* const store = await LanceStorage.create('my-storage-id', 'MyStorage', '/path/to/db', undefined, { disableInit: true });
|
|
1744
|
+
* ```
|
|
1717
1745
|
*/
|
|
1718
|
-
static async create(id, name, uri,
|
|
1719
|
-
const instance = new _LanceStorage(id, name);
|
|
1746
|
+
static async create(id, name, uri, connectionOptions, storageOptions) {
|
|
1747
|
+
const instance = new _LanceStorage(id, name, storageOptions?.disableInit);
|
|
1720
1748
|
try {
|
|
1721
|
-
instance.lanceClient = await lancedb.connect(uri,
|
|
1749
|
+
instance.lanceClient = await lancedb.connect(uri, connectionOptions);
|
|
1722
1750
|
const operations = new StoreOperationsLance({ client: instance.lanceClient });
|
|
1723
1751
|
instance.stores = {
|
|
1724
1752
|
operations: new StoreOperationsLance({ client: instance.lanceClient }),
|
|
@@ -1730,11 +1758,11 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1730
1758
|
} catch (e) {
|
|
1731
1759
|
throw new error.MastraError(
|
|
1732
1760
|
{
|
|
1733
|
-
id: "
|
|
1761
|
+
id: storage.createStorageErrorId("LANCE", "CONNECT", "FAILED"),
|
|
1734
1762
|
domain: error.ErrorDomain.STORAGE,
|
|
1735
1763
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1736
1764
|
text: `Failed to connect to LanceDB: ${e.message || e}`,
|
|
1737
|
-
details: { uri, optionsProvided: !!
|
|
1765
|
+
details: { uri, optionsProvided: !!connectionOptions }
|
|
1738
1766
|
},
|
|
1739
1767
|
e
|
|
1740
1768
|
);
|
|
@@ -1744,8 +1772,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1744
1772
|
* @internal
|
|
1745
1773
|
* Private constructor to enforce using the create factory method
|
|
1746
1774
|
*/
|
|
1747
|
-
constructor(id, name) {
|
|
1748
|
-
super({ id, name });
|
|
1775
|
+
constructor(id, name, disableInit) {
|
|
1776
|
+
super({ id, name, disableInit });
|
|
1749
1777
|
const operations = new StoreOperationsLance({ client: this.lanceClient });
|
|
1750
1778
|
this.stores = {
|
|
1751
1779
|
operations: new StoreOperationsLance({ client: this.lanceClient }),
|
|
@@ -1931,8 +1959,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1931
1959
|
}) {
|
|
1932
1960
|
return this.stores.scores.listScoresByScorerId({ scorerId, source, pagination, entityId, entityType });
|
|
1933
1961
|
}
|
|
1934
|
-
async saveScore(
|
|
1935
|
-
return this.stores.scores.saveScore(
|
|
1962
|
+
async saveScore(score) {
|
|
1963
|
+
return this.stores.scores.saveScore(score);
|
|
1936
1964
|
}
|
|
1937
1965
|
async listScoresByRunId({
|
|
1938
1966
|
runId,
|
|
@@ -2308,7 +2336,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2308
2336
|
} catch (e) {
|
|
2309
2337
|
throw new error.MastraError(
|
|
2310
2338
|
{
|
|
2311
|
-
id: "
|
|
2339
|
+
id: storage.createVectorErrorId("LANCE", "CONNECT", "FAILED"),
|
|
2312
2340
|
domain: error.ErrorDomain.STORAGE,
|
|
2313
2341
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2314
2342
|
details: { uri }
|
|
@@ -2351,7 +2379,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2351
2379
|
} catch (error$1) {
|
|
2352
2380
|
throw new error.MastraError(
|
|
2353
2381
|
{
|
|
2354
|
-
id: "
|
|
2382
|
+
id: storage.createVectorErrorId("LANCE", "QUERY", "INVALID_ARGS"),
|
|
2355
2383
|
domain: error.ErrorDomain.STORAGE,
|
|
2356
2384
|
category: error.ErrorCategory.USER,
|
|
2357
2385
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2399,7 +2427,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2399
2427
|
} catch (error$1) {
|
|
2400
2428
|
throw new error.MastraError(
|
|
2401
2429
|
{
|
|
2402
|
-
id: "
|
|
2430
|
+
id: storage.createVectorErrorId("LANCE", "QUERY", "FAILED"),
|
|
2403
2431
|
domain: error.ErrorDomain.STORAGE,
|
|
2404
2432
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2405
2433
|
details: { tableName, includeVector, columnsCount: columns?.length, includeAllColumns }
|
|
@@ -2451,7 +2479,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2451
2479
|
} catch (error$1) {
|
|
2452
2480
|
throw new error.MastraError(
|
|
2453
2481
|
{
|
|
2454
|
-
id: "
|
|
2482
|
+
id: storage.createVectorErrorId("LANCE", "UPSERT", "INVALID_ARGS"),
|
|
2455
2483
|
domain: error.ErrorDomain.STORAGE,
|
|
2456
2484
|
category: error.ErrorCategory.USER,
|
|
2457
2485
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2487,7 +2515,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2487
2515
|
} catch (error$1) {
|
|
2488
2516
|
throw new error.MastraError(
|
|
2489
2517
|
{
|
|
2490
|
-
id: "
|
|
2518
|
+
id: storage.createVectorErrorId("LANCE", "UPSERT", "FAILED"),
|
|
2491
2519
|
domain: error.ErrorDomain.STORAGE,
|
|
2492
2520
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2493
2521
|
details: { tableName, vectorCount: vectors.length, metadataCount: metadata.length, idsCount: ids.length }
|
|
@@ -2514,7 +2542,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2514
2542
|
async createTable(tableName, data, options) {
|
|
2515
2543
|
if (!this.lanceClient) {
|
|
2516
2544
|
throw new error.MastraError({
|
|
2517
|
-
id: "
|
|
2545
|
+
id: storage.createVectorErrorId("LANCE", "CREATE_TABLE", "INVALID_ARGS"),
|
|
2518
2546
|
domain: error.ErrorDomain.STORAGE,
|
|
2519
2547
|
category: error.ErrorCategory.USER,
|
|
2520
2548
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2529,7 +2557,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2529
2557
|
} catch (error$1) {
|
|
2530
2558
|
throw new error.MastraError(
|
|
2531
2559
|
{
|
|
2532
|
-
id: "
|
|
2560
|
+
id: storage.createVectorErrorId("LANCE", "CREATE_TABLE", "FAILED"),
|
|
2533
2561
|
domain: error.ErrorDomain.STORAGE,
|
|
2534
2562
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2535
2563
|
details: { tableName }
|
|
@@ -2541,7 +2569,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2541
2569
|
async listTables() {
|
|
2542
2570
|
if (!this.lanceClient) {
|
|
2543
2571
|
throw new error.MastraError({
|
|
2544
|
-
id: "
|
|
2572
|
+
id: storage.createVectorErrorId("LANCE", "LIST_TABLES", "INVALID_ARGS"),
|
|
2545
2573
|
domain: error.ErrorDomain.STORAGE,
|
|
2546
2574
|
category: error.ErrorCategory.USER,
|
|
2547
2575
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2553,7 +2581,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2553
2581
|
} catch (error$1) {
|
|
2554
2582
|
throw new error.MastraError(
|
|
2555
2583
|
{
|
|
2556
|
-
id: "
|
|
2584
|
+
id: storage.createVectorErrorId("LANCE", "LIST_TABLES", "FAILED"),
|
|
2557
2585
|
domain: error.ErrorDomain.STORAGE,
|
|
2558
2586
|
category: error.ErrorCategory.THIRD_PARTY
|
|
2559
2587
|
},
|
|
@@ -2564,7 +2592,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2564
2592
|
async getTableSchema(tableName) {
|
|
2565
2593
|
if (!this.lanceClient) {
|
|
2566
2594
|
throw new error.MastraError({
|
|
2567
|
-
id: "
|
|
2595
|
+
id: storage.createVectorErrorId("LANCE", "GET_TABLE_SCHEMA", "INVALID_ARGS"),
|
|
2568
2596
|
domain: error.ErrorDomain.STORAGE,
|
|
2569
2597
|
category: error.ErrorCategory.USER,
|
|
2570
2598
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2577,7 +2605,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2577
2605
|
} catch (error$1) {
|
|
2578
2606
|
throw new error.MastraError(
|
|
2579
2607
|
{
|
|
2580
|
-
id: "
|
|
2608
|
+
id: storage.createVectorErrorId("LANCE", "GET_TABLE_SCHEMA", "FAILED"),
|
|
2581
2609
|
domain: error.ErrorDomain.STORAGE,
|
|
2582
2610
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2583
2611
|
details: { tableName }
|
|
@@ -2612,7 +2640,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2612
2640
|
} catch (err) {
|
|
2613
2641
|
throw new error.MastraError(
|
|
2614
2642
|
{
|
|
2615
|
-
id: "
|
|
2643
|
+
id: storage.createVectorErrorId("LANCE", "CREATE_INDEX", "INVALID_ARGS"),
|
|
2616
2644
|
domain: error.ErrorDomain.STORAGE,
|
|
2617
2645
|
category: error.ErrorCategory.USER,
|
|
2618
2646
|
details: { tableName: tableName || "", indexName, dimension, metric }
|
|
@@ -2657,7 +2685,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2657
2685
|
} catch (error$1) {
|
|
2658
2686
|
throw new error.MastraError(
|
|
2659
2687
|
{
|
|
2660
|
-
id: "
|
|
2688
|
+
id: storage.createVectorErrorId("LANCE", "CREATE_INDEX", "FAILED"),
|
|
2661
2689
|
domain: error.ErrorDomain.STORAGE,
|
|
2662
2690
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2663
2691
|
details: { tableName: tableName || "", indexName, dimension }
|
|
@@ -2669,7 +2697,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2669
2697
|
async listIndexes() {
|
|
2670
2698
|
if (!this.lanceClient) {
|
|
2671
2699
|
throw new error.MastraError({
|
|
2672
|
-
id: "
|
|
2700
|
+
id: storage.createVectorErrorId("LANCE", "LIST_INDEXES", "INVALID_ARGS"),
|
|
2673
2701
|
domain: error.ErrorDomain.STORAGE,
|
|
2674
2702
|
category: error.ErrorCategory.USER,
|
|
2675
2703
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2688,7 +2716,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2688
2716
|
} catch (error$1) {
|
|
2689
2717
|
throw new error.MastraError(
|
|
2690
2718
|
{
|
|
2691
|
-
id: "
|
|
2719
|
+
id: storage.createVectorErrorId("LANCE", "LIST_INDEXES", "FAILED"),
|
|
2692
2720
|
domain: error.ErrorDomain.STORAGE,
|
|
2693
2721
|
category: error.ErrorCategory.THIRD_PARTY
|
|
2694
2722
|
},
|
|
@@ -2707,7 +2735,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2707
2735
|
} catch (err) {
|
|
2708
2736
|
throw new error.MastraError(
|
|
2709
2737
|
{
|
|
2710
|
-
id: "
|
|
2738
|
+
id: storage.createVectorErrorId("LANCE", "DESCRIBE_INDEX", "INVALID_ARGS"),
|
|
2711
2739
|
domain: error.ErrorDomain.STORAGE,
|
|
2712
2740
|
category: error.ErrorCategory.USER,
|
|
2713
2741
|
details: { indexName }
|
|
@@ -2742,7 +2770,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2742
2770
|
} catch (error$1) {
|
|
2743
2771
|
throw new error.MastraError(
|
|
2744
2772
|
{
|
|
2745
|
-
id: "
|
|
2773
|
+
id: storage.createVectorErrorId("LANCE", "DESCRIBE_INDEX", "FAILED"),
|
|
2746
2774
|
domain: error.ErrorDomain.STORAGE,
|
|
2747
2775
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2748
2776
|
details: { indexName }
|
|
@@ -2762,7 +2790,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2762
2790
|
} catch (err) {
|
|
2763
2791
|
throw new error.MastraError(
|
|
2764
2792
|
{
|
|
2765
|
-
id: "
|
|
2793
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_INDEX", "INVALID_ARGS"),
|
|
2766
2794
|
domain: error.ErrorDomain.STORAGE,
|
|
2767
2795
|
category: error.ErrorCategory.USER,
|
|
2768
2796
|
details: { indexName }
|
|
@@ -2785,7 +2813,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2785
2813
|
} catch (error$1) {
|
|
2786
2814
|
throw new error.MastraError(
|
|
2787
2815
|
{
|
|
2788
|
-
id: "
|
|
2816
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_INDEX", "FAILED"),
|
|
2789
2817
|
domain: error.ErrorDomain.STORAGE,
|
|
2790
2818
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2791
2819
|
details: { indexName }
|
|
@@ -2800,7 +2828,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2800
2828
|
async deleteAllTables() {
|
|
2801
2829
|
if (!this.lanceClient) {
|
|
2802
2830
|
throw new error.MastraError({
|
|
2803
|
-
id: "
|
|
2831
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_ALL_TABLES", "INVALID_ARGS"),
|
|
2804
2832
|
domain: error.ErrorDomain.STORAGE,
|
|
2805
2833
|
category: error.ErrorCategory.USER,
|
|
2806
2834
|
details: { methodName: "deleteAllTables" },
|
|
@@ -2812,7 +2840,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2812
2840
|
} catch (error$1) {
|
|
2813
2841
|
throw new error.MastraError(
|
|
2814
2842
|
{
|
|
2815
|
-
id: "
|
|
2843
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_ALL_TABLES", "FAILED"),
|
|
2816
2844
|
domain: error.ErrorDomain.STORAGE,
|
|
2817
2845
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2818
2846
|
details: { methodName: "deleteAllTables" }
|
|
@@ -2824,7 +2852,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2824
2852
|
async deleteTable(tableName) {
|
|
2825
2853
|
if (!this.lanceClient) {
|
|
2826
2854
|
throw new error.MastraError({
|
|
2827
|
-
id: "
|
|
2855
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_TABLE", "INVALID_ARGS"),
|
|
2828
2856
|
domain: error.ErrorDomain.STORAGE,
|
|
2829
2857
|
category: error.ErrorCategory.USER,
|
|
2830
2858
|
details: { tableName },
|
|
@@ -2836,7 +2864,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2836
2864
|
} catch (error$1) {
|
|
2837
2865
|
throw new error.MastraError(
|
|
2838
2866
|
{
|
|
2839
|
-
id: "
|
|
2867
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_TABLE", "FAILED"),
|
|
2840
2868
|
domain: error.ErrorDomain.STORAGE,
|
|
2841
2869
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2842
2870
|
details: { tableName }
|
|
@@ -2849,7 +2877,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2849
2877
|
const { indexName, update } = params;
|
|
2850
2878
|
if ("id" in params && "filter" in params && params.id && params.filter) {
|
|
2851
2879
|
throw new error.MastraError({
|
|
2852
|
-
id: "
|
|
2880
|
+
id: storage.createVectorErrorId("LANCE", "UPDATE_VECTOR", "MUTUALLY_EXCLUSIVE"),
|
|
2853
2881
|
domain: error.ErrorDomain.STORAGE,
|
|
2854
2882
|
category: error.ErrorCategory.USER,
|
|
2855
2883
|
text: "id and filter are mutually exclusive",
|
|
@@ -2858,7 +2886,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2858
2886
|
}
|
|
2859
2887
|
if (!("id" in params || "filter" in params) || !params.id && !params.filter) {
|
|
2860
2888
|
throw new error.MastraError({
|
|
2861
|
-
id: "
|
|
2889
|
+
id: storage.createVectorErrorId("LANCE", "UPDATE_VECTOR", "NO_TARGET"),
|
|
2862
2890
|
domain: error.ErrorDomain.STORAGE,
|
|
2863
2891
|
category: error.ErrorCategory.USER,
|
|
2864
2892
|
text: "Either id or filter must be provided",
|
|
@@ -2867,7 +2895,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2867
2895
|
}
|
|
2868
2896
|
if ("filter" in params && params.filter && Object.keys(params.filter).length === 0) {
|
|
2869
2897
|
throw new error.MastraError({
|
|
2870
|
-
id: "
|
|
2898
|
+
id: storage.createVectorErrorId("LANCE", "UPDATE_VECTOR", "EMPTY_FILTER"),
|
|
2871
2899
|
domain: error.ErrorDomain.STORAGE,
|
|
2872
2900
|
category: error.ErrorCategory.USER,
|
|
2873
2901
|
text: "Cannot update with empty filter",
|
|
@@ -2876,7 +2904,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2876
2904
|
}
|
|
2877
2905
|
if (!update.vector && !update.metadata) {
|
|
2878
2906
|
throw new error.MastraError({
|
|
2879
|
-
id: "
|
|
2907
|
+
id: storage.createVectorErrorId("LANCE", "UPDATE_VECTOR", "NO_PAYLOAD"),
|
|
2880
2908
|
domain: error.ErrorDomain.STORAGE,
|
|
2881
2909
|
category: error.ErrorCategory.USER,
|
|
2882
2910
|
text: "No updates provided",
|
|
@@ -2971,7 +2999,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2971
2999
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
2972
3000
|
throw new error.MastraError(
|
|
2973
3001
|
{
|
|
2974
|
-
id: "
|
|
3002
|
+
id: storage.createVectorErrorId("LANCE", "UPDATE_VECTOR", "FAILED"),
|
|
2975
3003
|
domain: error.ErrorDomain.STORAGE,
|
|
2976
3004
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
2977
3005
|
details: {
|
|
@@ -3000,7 +3028,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
3000
3028
|
} catch (err) {
|
|
3001
3029
|
throw new error.MastraError(
|
|
3002
3030
|
{
|
|
3003
|
-
id: "
|
|
3031
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_VECTOR", "INVALID_ARGS"),
|
|
3004
3032
|
domain: error.ErrorDomain.STORAGE,
|
|
3005
3033
|
category: error.ErrorCategory.USER,
|
|
3006
3034
|
details: {
|
|
@@ -3033,7 +3061,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
3033
3061
|
} catch (error$1) {
|
|
3034
3062
|
throw new error.MastraError(
|
|
3035
3063
|
{
|
|
3036
|
-
id: "
|
|
3064
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_VECTOR", "FAILED"),
|
|
3037
3065
|
domain: error.ErrorDomain.STORAGE,
|
|
3038
3066
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3039
3067
|
details: {
|
|
@@ -3073,7 +3101,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
3073
3101
|
async deleteVectors({ indexName, filter, ids }) {
|
|
3074
3102
|
if (ids && filter) {
|
|
3075
3103
|
throw new error.MastraError({
|
|
3076
|
-
id: "
|
|
3104
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_VECTORS", "MUTUALLY_EXCLUSIVE"),
|
|
3077
3105
|
domain: error.ErrorDomain.STORAGE,
|
|
3078
3106
|
category: error.ErrorCategory.USER,
|
|
3079
3107
|
text: "ids and filter are mutually exclusive",
|
|
@@ -3082,7 +3110,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
3082
3110
|
}
|
|
3083
3111
|
if (!ids && !filter) {
|
|
3084
3112
|
throw new error.MastraError({
|
|
3085
|
-
id: "
|
|
3113
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_VECTORS", "NO_TARGET"),
|
|
3086
3114
|
domain: error.ErrorDomain.STORAGE,
|
|
3087
3115
|
category: error.ErrorCategory.USER,
|
|
3088
3116
|
text: "Either filter or ids must be provided",
|
|
@@ -3091,7 +3119,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
3091
3119
|
}
|
|
3092
3120
|
if (ids && ids.length === 0) {
|
|
3093
3121
|
throw new error.MastraError({
|
|
3094
|
-
id: "
|
|
3122
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_VECTORS", "EMPTY_IDS"),
|
|
3095
3123
|
domain: error.ErrorDomain.STORAGE,
|
|
3096
3124
|
category: error.ErrorCategory.USER,
|
|
3097
3125
|
text: "Cannot delete with empty ids array",
|
|
@@ -3100,7 +3128,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
3100
3128
|
}
|
|
3101
3129
|
if (filter && Object.keys(filter).length === 0) {
|
|
3102
3130
|
throw new error.MastraError({
|
|
3103
|
-
id: "
|
|
3131
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_VECTORS", "EMPTY_FILTER"),
|
|
3104
3132
|
domain: error.ErrorDomain.STORAGE,
|
|
3105
3133
|
category: error.ErrorCategory.USER,
|
|
3106
3134
|
text: "Cannot delete with empty filter",
|
|
@@ -3160,7 +3188,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
3160
3188
|
if (error$1 instanceof error.MastraError) throw error$1;
|
|
3161
3189
|
throw new error.MastraError(
|
|
3162
3190
|
{
|
|
3163
|
-
id: "
|
|
3191
|
+
id: storage.createVectorErrorId("LANCE", "DELETE_VECTORS", "FAILED"),
|
|
3164
3192
|
domain: error.ErrorDomain.STORAGE,
|
|
3165
3193
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
3166
3194
|
details: {
|