@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.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,37 +1243,47 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1242
1243
|
} catch (error) {
|
|
1243
1244
|
throw new MastraError(
|
|
1244
1245
|
{
|
|
1245
|
-
id: "
|
|
1246
|
+
id: createStorageErrorId("LANCE", "SAVE_SCORE", "VALIDATION_FAILED"),
|
|
1246
1247
|
text: "Failed to save score in LanceStorage",
|
|
1247
1248
|
domain: ErrorDomain.STORAGE,
|
|
1248
|
-
category: ErrorCategory.
|
|
1249
|
+
category: ErrorCategory.USER,
|
|
1250
|
+
details: {
|
|
1251
|
+
scorer: score.scorer?.id ?? "unknown",
|
|
1252
|
+
entityId: score.entityId ?? "unknown",
|
|
1253
|
+
entityType: score.entityType ?? "unknown",
|
|
1254
|
+
traceId: score.traceId ?? "",
|
|
1255
|
+
spanId: score.spanId ?? ""
|
|
1256
|
+
}
|
|
1249
1257
|
},
|
|
1250
1258
|
error
|
|
1251
1259
|
);
|
|
1252
1260
|
}
|
|
1261
|
+
const id = crypto.randomUUID();
|
|
1262
|
+
const now = /* @__PURE__ */ new Date();
|
|
1253
1263
|
try {
|
|
1254
|
-
const id = crypto.randomUUID();
|
|
1255
1264
|
const table = await this.client.openTable(TABLE_SCORERS);
|
|
1256
1265
|
const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
|
|
1257
1266
|
const allowedFields = new Set(schema.fields.map((f) => f.name));
|
|
1258
1267
|
const filteredScore = {};
|
|
1259
|
-
Object.keys(validatedScore)
|
|
1268
|
+
for (const key of Object.keys(validatedScore)) {
|
|
1260
1269
|
if (allowedFields.has(key)) {
|
|
1261
|
-
filteredScore[key] =
|
|
1270
|
+
filteredScore[key] = validatedScore[key];
|
|
1262
1271
|
}
|
|
1263
|
-
}
|
|
1272
|
+
}
|
|
1264
1273
|
for (const key in filteredScore) {
|
|
1265
1274
|
if (filteredScore[key] !== null && typeof filteredScore[key] === "object" && !(filteredScore[key] instanceof Date)) {
|
|
1266
1275
|
filteredScore[key] = JSON.stringify(filteredScore[key]);
|
|
1267
1276
|
}
|
|
1268
1277
|
}
|
|
1269
1278
|
filteredScore.id = id;
|
|
1279
|
+
filteredScore.createdAt = now;
|
|
1280
|
+
filteredScore.updatedAt = now;
|
|
1270
1281
|
await table.add([filteredScore], { mode: "append" });
|
|
1271
|
-
return { score };
|
|
1282
|
+
return { score: { ...validatedScore, id, createdAt: now, updatedAt: now } };
|
|
1272
1283
|
} catch (error) {
|
|
1273
1284
|
throw new MastraError(
|
|
1274
1285
|
{
|
|
1275
|
-
id: "
|
|
1286
|
+
id: createStorageErrorId("LANCE", "SAVE_SCORE", "FAILED"),
|
|
1276
1287
|
text: "Failed to save score in LanceStorage",
|
|
1277
1288
|
domain: ErrorDomain.STORAGE,
|
|
1278
1289
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1288,12 +1299,11 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1288
1299
|
const query = table.query().where(`id = '${id}'`).limit(1);
|
|
1289
1300
|
const records = await query.toArray();
|
|
1290
1301
|
if (records.length === 0) return null;
|
|
1291
|
-
|
|
1292
|
-
return processResultWithTypeConversion(records[0], schema);
|
|
1302
|
+
return await this.transformScoreRow(records[0]);
|
|
1293
1303
|
} catch (error) {
|
|
1294
1304
|
throw new MastraError(
|
|
1295
1305
|
{
|
|
1296
|
-
id: "
|
|
1306
|
+
id: createStorageErrorId("LANCE", "GET_SCORE_BY_ID", "FAILED"),
|
|
1297
1307
|
text: "Failed to get score by id in LanceStorage",
|
|
1298
1308
|
domain: ErrorDomain.STORAGE,
|
|
1299
1309
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1303,6 +1313,22 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1303
1313
|
);
|
|
1304
1314
|
}
|
|
1305
1315
|
}
|
|
1316
|
+
/**
|
|
1317
|
+
* LanceDB-specific score row transformation.
|
|
1318
|
+
*
|
|
1319
|
+
* Note: This implementation does NOT use coreTransformScoreRow because:
|
|
1320
|
+
* 1. LanceDB stores schema information in the table itself (requires async fetch)
|
|
1321
|
+
* 2. Uses processResultWithTypeConversion utility for LanceDB-specific type handling
|
|
1322
|
+
*/
|
|
1323
|
+
async transformScoreRow(row) {
|
|
1324
|
+
const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
|
|
1325
|
+
const transformed = processResultWithTypeConversion(row, schema);
|
|
1326
|
+
return {
|
|
1327
|
+
...transformed,
|
|
1328
|
+
createdAt: row.createdAt,
|
|
1329
|
+
updatedAt: row.updatedAt
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1306
1332
|
async listScoresByScorerId({
|
|
1307
1333
|
scorerId,
|
|
1308
1334
|
pagination,
|
|
@@ -1343,8 +1369,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1343
1369
|
if (start > 0) query = query.offset(start);
|
|
1344
1370
|
}
|
|
1345
1371
|
const records = await query.toArray();
|
|
1346
|
-
const
|
|
1347
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1372
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1348
1373
|
return {
|
|
1349
1374
|
pagination: {
|
|
1350
1375
|
page,
|
|
@@ -1357,7 +1382,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1357
1382
|
} catch (error) {
|
|
1358
1383
|
throw new MastraError(
|
|
1359
1384
|
{
|
|
1360
|
-
id: "
|
|
1385
|
+
id: createStorageErrorId("LANCE", "LIST_SCORES_BY_SCORER_ID", "FAILED"),
|
|
1361
1386
|
text: "Failed to get scores by scorerId in LanceStorage",
|
|
1362
1387
|
domain: ErrorDomain.STORAGE,
|
|
1363
1388
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1385,8 +1410,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1385
1410
|
if (start > 0) query = query.offset(start);
|
|
1386
1411
|
}
|
|
1387
1412
|
const records = await query.toArray();
|
|
1388
|
-
const
|
|
1389
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1413
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1390
1414
|
return {
|
|
1391
1415
|
pagination: {
|
|
1392
1416
|
page,
|
|
@@ -1399,7 +1423,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1399
1423
|
} catch (error) {
|
|
1400
1424
|
throw new MastraError(
|
|
1401
1425
|
{
|
|
1402
|
-
id: "
|
|
1426
|
+
id: createStorageErrorId("LANCE", "LIST_SCORES_BY_RUN_ID", "FAILED"),
|
|
1403
1427
|
text: "Failed to get scores by runId in LanceStorage",
|
|
1404
1428
|
domain: ErrorDomain.STORAGE,
|
|
1405
1429
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1428,8 +1452,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1428
1452
|
if (start > 0) query = query.offset(start);
|
|
1429
1453
|
}
|
|
1430
1454
|
const records = await query.toArray();
|
|
1431
|
-
const
|
|
1432
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1455
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1433
1456
|
return {
|
|
1434
1457
|
pagination: {
|
|
1435
1458
|
page,
|
|
@@ -1442,7 +1465,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1442
1465
|
} catch (error) {
|
|
1443
1466
|
throw new MastraError(
|
|
1444
1467
|
{
|
|
1445
|
-
id: "
|
|
1468
|
+
id: createStorageErrorId("LANCE", "LIST_SCORES_BY_ENTITY_ID", "FAILED"),
|
|
1446
1469
|
text: "Failed to get scores by entityId and entityType in LanceStorage",
|
|
1447
1470
|
domain: ErrorDomain.STORAGE,
|
|
1448
1471
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1471,8 +1494,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1471
1494
|
if (start > 0) query = query.offset(start);
|
|
1472
1495
|
}
|
|
1473
1496
|
const records = await query.toArray();
|
|
1474
|
-
const
|
|
1475
|
-
const scores = processResultWithTypeConversion(records, schema);
|
|
1497
|
+
const scores = await Promise.all(records.map(async (record) => await this.transformScoreRow(record)));
|
|
1476
1498
|
return {
|
|
1477
1499
|
pagination: {
|
|
1478
1500
|
page,
|
|
@@ -1485,7 +1507,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1485
1507
|
} catch (error) {
|
|
1486
1508
|
throw new MastraError(
|
|
1487
1509
|
{
|
|
1488
|
-
id: "
|
|
1510
|
+
id: createStorageErrorId("LANCE", "LIST_SCORES_BY_SPAN", "FAILED"),
|
|
1489
1511
|
text: "Failed to get scores by traceId and spanId in LanceStorage",
|
|
1490
1512
|
domain: ErrorDomain.STORAGE,
|
|
1491
1513
|
category: ErrorCategory.THIRD_PARTY,
|
|
@@ -1567,7 +1589,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1567
1589
|
} catch (error) {
|
|
1568
1590
|
throw new MastraError(
|
|
1569
1591
|
{
|
|
1570
|
-
id: "
|
|
1592
|
+
id: createStorageErrorId("LANCE", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1571
1593
|
domain: ErrorDomain.STORAGE,
|
|
1572
1594
|
category: ErrorCategory.THIRD_PARTY,
|
|
1573
1595
|
details: { workflowName, runId }
|
|
@@ -1588,7 +1610,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1588
1610
|
} catch (error) {
|
|
1589
1611
|
throw new MastraError(
|
|
1590
1612
|
{
|
|
1591
|
-
id: "
|
|
1613
|
+
id: createStorageErrorId("LANCE", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1592
1614
|
domain: ErrorDomain.STORAGE,
|
|
1593
1615
|
category: ErrorCategory.THIRD_PARTY,
|
|
1594
1616
|
details: { workflowName, runId }
|
|
@@ -1612,7 +1634,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1612
1634
|
} catch (error) {
|
|
1613
1635
|
throw new MastraError(
|
|
1614
1636
|
{
|
|
1615
|
-
id: "
|
|
1637
|
+
id: createStorageErrorId("LANCE", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
1616
1638
|
domain: ErrorDomain.STORAGE,
|
|
1617
1639
|
category: ErrorCategory.THIRD_PARTY,
|
|
1618
1640
|
details: { runId: args.runId, workflowName: args.workflowName ?? "" }
|
|
@@ -1654,7 +1676,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1654
1676
|
if (args.page < 0 || !Number.isInteger(args.page)) {
|
|
1655
1677
|
throw new MastraError(
|
|
1656
1678
|
{
|
|
1657
|
-
id: "
|
|
1679
|
+
id: createStorageErrorId("LANCE", "LIST_WORKFLOW_RUNS", "INVALID_PAGINATION"),
|
|
1658
1680
|
domain: ErrorDomain.STORAGE,
|
|
1659
1681
|
category: ErrorCategory.USER,
|
|
1660
1682
|
details: { page: args.page, perPage: args.perPage }
|
|
@@ -1674,7 +1696,7 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1674
1696
|
} catch (error) {
|
|
1675
1697
|
throw new MastraError(
|
|
1676
1698
|
{
|
|
1677
|
-
id: "
|
|
1699
|
+
id: createStorageErrorId("LANCE", "LIST_WORKFLOW_RUNS", "FAILED"),
|
|
1678
1700
|
domain: ErrorDomain.STORAGE,
|
|
1679
1701
|
category: ErrorCategory.THIRD_PARTY,
|
|
1680
1702
|
details: { resourceId: args?.resourceId ?? "", workflowName: args?.workflowName ?? "" }
|
|
@@ -1694,7 +1716,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
1694
1716
|
* @param id The unique identifier for this storage instance
|
|
1695
1717
|
* @param name The name for this storage instance
|
|
1696
1718
|
* @param uri The URI to connect to LanceDB
|
|
1697
|
-
* @param
|
|
1719
|
+
* @param connectionOptions connection options for LanceDB
|
|
1720
|
+
* @param storageOptions storage options including disableInit
|
|
1698
1721
|
*
|
|
1699
1722
|
* Usage:
|
|
1700
1723
|
*
|
|
@@ -1712,11 +1735,16 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
1712
1735
|
* ```ts
|
|
1713
1736
|
* const store = await LanceStorage.create('my-storage-id', 'MyStorage', 's3://bucket/db', { storageOptions: { timeout: '60s' } });
|
|
1714
1737
|
* ```
|
|
1738
|
+
*
|
|
1739
|
+
* Disable auto-init for runtime (after CI/CD has run migrations)
|
|
1740
|
+
* ```ts
|
|
1741
|
+
* const store = await LanceStorage.create('my-storage-id', 'MyStorage', '/path/to/db', undefined, { disableInit: true });
|
|
1742
|
+
* ```
|
|
1715
1743
|
*/
|
|
1716
|
-
static async create(id, name, uri,
|
|
1717
|
-
const instance = new _LanceStorage(id, name);
|
|
1744
|
+
static async create(id, name, uri, connectionOptions, storageOptions) {
|
|
1745
|
+
const instance = new _LanceStorage(id, name, storageOptions?.disableInit);
|
|
1718
1746
|
try {
|
|
1719
|
-
instance.lanceClient = await connect(uri,
|
|
1747
|
+
instance.lanceClient = await connect(uri, connectionOptions);
|
|
1720
1748
|
const operations = new StoreOperationsLance({ client: instance.lanceClient });
|
|
1721
1749
|
instance.stores = {
|
|
1722
1750
|
operations: new StoreOperationsLance({ client: instance.lanceClient }),
|
|
@@ -1728,11 +1756,11 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
1728
1756
|
} catch (e) {
|
|
1729
1757
|
throw new MastraError(
|
|
1730
1758
|
{
|
|
1731
|
-
id: "
|
|
1759
|
+
id: createStorageErrorId("LANCE", "CONNECT", "FAILED"),
|
|
1732
1760
|
domain: ErrorDomain.STORAGE,
|
|
1733
1761
|
category: ErrorCategory.THIRD_PARTY,
|
|
1734
1762
|
text: `Failed to connect to LanceDB: ${e.message || e}`,
|
|
1735
|
-
details: { uri, optionsProvided: !!
|
|
1763
|
+
details: { uri, optionsProvided: !!connectionOptions }
|
|
1736
1764
|
},
|
|
1737
1765
|
e
|
|
1738
1766
|
);
|
|
@@ -1742,8 +1770,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
1742
1770
|
* @internal
|
|
1743
1771
|
* Private constructor to enforce using the create factory method
|
|
1744
1772
|
*/
|
|
1745
|
-
constructor(id, name) {
|
|
1746
|
-
super({ id, name });
|
|
1773
|
+
constructor(id, name, disableInit) {
|
|
1774
|
+
super({ id, name, disableInit });
|
|
1747
1775
|
const operations = new StoreOperationsLance({ client: this.lanceClient });
|
|
1748
1776
|
this.stores = {
|
|
1749
1777
|
operations: new StoreOperationsLance({ client: this.lanceClient }),
|
|
@@ -1929,8 +1957,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
1929
1957
|
}) {
|
|
1930
1958
|
return this.stores.scores.listScoresByScorerId({ scorerId, source, pagination, entityId, entityType });
|
|
1931
1959
|
}
|
|
1932
|
-
async saveScore(
|
|
1933
|
-
return this.stores.scores.saveScore(
|
|
1960
|
+
async saveScore(score) {
|
|
1961
|
+
return this.stores.scores.saveScore(score);
|
|
1934
1962
|
}
|
|
1935
1963
|
async listScoresByRunId({
|
|
1936
1964
|
runId,
|
|
@@ -2306,7 +2334,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2306
2334
|
} catch (e) {
|
|
2307
2335
|
throw new MastraError(
|
|
2308
2336
|
{
|
|
2309
|
-
id: "
|
|
2337
|
+
id: createVectorErrorId("LANCE", "CONNECT", "FAILED"),
|
|
2310
2338
|
domain: ErrorDomain.STORAGE,
|
|
2311
2339
|
category: ErrorCategory.THIRD_PARTY,
|
|
2312
2340
|
details: { uri }
|
|
@@ -2349,7 +2377,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2349
2377
|
} catch (error) {
|
|
2350
2378
|
throw new MastraError(
|
|
2351
2379
|
{
|
|
2352
|
-
id: "
|
|
2380
|
+
id: createVectorErrorId("LANCE", "QUERY", "INVALID_ARGS"),
|
|
2353
2381
|
domain: ErrorDomain.STORAGE,
|
|
2354
2382
|
category: ErrorCategory.USER,
|
|
2355
2383
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2397,7 +2425,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2397
2425
|
} catch (error) {
|
|
2398
2426
|
throw new MastraError(
|
|
2399
2427
|
{
|
|
2400
|
-
id: "
|
|
2428
|
+
id: createVectorErrorId("LANCE", "QUERY", "FAILED"),
|
|
2401
2429
|
domain: ErrorDomain.STORAGE,
|
|
2402
2430
|
category: ErrorCategory.THIRD_PARTY,
|
|
2403
2431
|
details: { tableName, includeVector, columnsCount: columns?.length, includeAllColumns }
|
|
@@ -2449,7 +2477,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2449
2477
|
} catch (error) {
|
|
2450
2478
|
throw new MastraError(
|
|
2451
2479
|
{
|
|
2452
|
-
id: "
|
|
2480
|
+
id: createVectorErrorId("LANCE", "UPSERT", "INVALID_ARGS"),
|
|
2453
2481
|
domain: ErrorDomain.STORAGE,
|
|
2454
2482
|
category: ErrorCategory.USER,
|
|
2455
2483
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2485,7 +2513,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2485
2513
|
} catch (error) {
|
|
2486
2514
|
throw new MastraError(
|
|
2487
2515
|
{
|
|
2488
|
-
id: "
|
|
2516
|
+
id: createVectorErrorId("LANCE", "UPSERT", "FAILED"),
|
|
2489
2517
|
domain: ErrorDomain.STORAGE,
|
|
2490
2518
|
category: ErrorCategory.THIRD_PARTY,
|
|
2491
2519
|
details: { tableName, vectorCount: vectors.length, metadataCount: metadata.length, idsCount: ids.length }
|
|
@@ -2512,7 +2540,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2512
2540
|
async createTable(tableName, data, options) {
|
|
2513
2541
|
if (!this.lanceClient) {
|
|
2514
2542
|
throw new MastraError({
|
|
2515
|
-
id: "
|
|
2543
|
+
id: createVectorErrorId("LANCE", "CREATE_TABLE", "INVALID_ARGS"),
|
|
2516
2544
|
domain: ErrorDomain.STORAGE,
|
|
2517
2545
|
category: ErrorCategory.USER,
|
|
2518
2546
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2527,7 +2555,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2527
2555
|
} catch (error) {
|
|
2528
2556
|
throw new MastraError(
|
|
2529
2557
|
{
|
|
2530
|
-
id: "
|
|
2558
|
+
id: createVectorErrorId("LANCE", "CREATE_TABLE", "FAILED"),
|
|
2531
2559
|
domain: ErrorDomain.STORAGE,
|
|
2532
2560
|
category: ErrorCategory.THIRD_PARTY,
|
|
2533
2561
|
details: { tableName }
|
|
@@ -2539,7 +2567,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2539
2567
|
async listTables() {
|
|
2540
2568
|
if (!this.lanceClient) {
|
|
2541
2569
|
throw new MastraError({
|
|
2542
|
-
id: "
|
|
2570
|
+
id: createVectorErrorId("LANCE", "LIST_TABLES", "INVALID_ARGS"),
|
|
2543
2571
|
domain: ErrorDomain.STORAGE,
|
|
2544
2572
|
category: ErrorCategory.USER,
|
|
2545
2573
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2551,7 +2579,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2551
2579
|
} catch (error) {
|
|
2552
2580
|
throw new MastraError(
|
|
2553
2581
|
{
|
|
2554
|
-
id: "
|
|
2582
|
+
id: createVectorErrorId("LANCE", "LIST_TABLES", "FAILED"),
|
|
2555
2583
|
domain: ErrorDomain.STORAGE,
|
|
2556
2584
|
category: ErrorCategory.THIRD_PARTY
|
|
2557
2585
|
},
|
|
@@ -2562,7 +2590,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2562
2590
|
async getTableSchema(tableName) {
|
|
2563
2591
|
if (!this.lanceClient) {
|
|
2564
2592
|
throw new MastraError({
|
|
2565
|
-
id: "
|
|
2593
|
+
id: createVectorErrorId("LANCE", "GET_TABLE_SCHEMA", "INVALID_ARGS"),
|
|
2566
2594
|
domain: ErrorDomain.STORAGE,
|
|
2567
2595
|
category: ErrorCategory.USER,
|
|
2568
2596
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2575,7 +2603,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2575
2603
|
} catch (error) {
|
|
2576
2604
|
throw new MastraError(
|
|
2577
2605
|
{
|
|
2578
|
-
id: "
|
|
2606
|
+
id: createVectorErrorId("LANCE", "GET_TABLE_SCHEMA", "FAILED"),
|
|
2579
2607
|
domain: ErrorDomain.STORAGE,
|
|
2580
2608
|
category: ErrorCategory.THIRD_PARTY,
|
|
2581
2609
|
details: { tableName }
|
|
@@ -2610,7 +2638,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2610
2638
|
} catch (err) {
|
|
2611
2639
|
throw new MastraError(
|
|
2612
2640
|
{
|
|
2613
|
-
id: "
|
|
2641
|
+
id: createVectorErrorId("LANCE", "CREATE_INDEX", "INVALID_ARGS"),
|
|
2614
2642
|
domain: ErrorDomain.STORAGE,
|
|
2615
2643
|
category: ErrorCategory.USER,
|
|
2616
2644
|
details: { tableName: tableName || "", indexName, dimension, metric }
|
|
@@ -2655,7 +2683,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2655
2683
|
} catch (error) {
|
|
2656
2684
|
throw new MastraError(
|
|
2657
2685
|
{
|
|
2658
|
-
id: "
|
|
2686
|
+
id: createVectorErrorId("LANCE", "CREATE_INDEX", "FAILED"),
|
|
2659
2687
|
domain: ErrorDomain.STORAGE,
|
|
2660
2688
|
category: ErrorCategory.THIRD_PARTY,
|
|
2661
2689
|
details: { tableName: tableName || "", indexName, dimension }
|
|
@@ -2667,7 +2695,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2667
2695
|
async listIndexes() {
|
|
2668
2696
|
if (!this.lanceClient) {
|
|
2669
2697
|
throw new MastraError({
|
|
2670
|
-
id: "
|
|
2698
|
+
id: createVectorErrorId("LANCE", "LIST_INDEXES", "INVALID_ARGS"),
|
|
2671
2699
|
domain: ErrorDomain.STORAGE,
|
|
2672
2700
|
category: ErrorCategory.USER,
|
|
2673
2701
|
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
@@ -2686,7 +2714,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2686
2714
|
} catch (error) {
|
|
2687
2715
|
throw new MastraError(
|
|
2688
2716
|
{
|
|
2689
|
-
id: "
|
|
2717
|
+
id: createVectorErrorId("LANCE", "LIST_INDEXES", "FAILED"),
|
|
2690
2718
|
domain: ErrorDomain.STORAGE,
|
|
2691
2719
|
category: ErrorCategory.THIRD_PARTY
|
|
2692
2720
|
},
|
|
@@ -2705,7 +2733,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2705
2733
|
} catch (err) {
|
|
2706
2734
|
throw new MastraError(
|
|
2707
2735
|
{
|
|
2708
|
-
id: "
|
|
2736
|
+
id: createVectorErrorId("LANCE", "DESCRIBE_INDEX", "INVALID_ARGS"),
|
|
2709
2737
|
domain: ErrorDomain.STORAGE,
|
|
2710
2738
|
category: ErrorCategory.USER,
|
|
2711
2739
|
details: { indexName }
|
|
@@ -2740,7 +2768,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2740
2768
|
} catch (error) {
|
|
2741
2769
|
throw new MastraError(
|
|
2742
2770
|
{
|
|
2743
|
-
id: "
|
|
2771
|
+
id: createVectorErrorId("LANCE", "DESCRIBE_INDEX", "FAILED"),
|
|
2744
2772
|
domain: ErrorDomain.STORAGE,
|
|
2745
2773
|
category: ErrorCategory.THIRD_PARTY,
|
|
2746
2774
|
details: { indexName }
|
|
@@ -2760,7 +2788,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2760
2788
|
} catch (err) {
|
|
2761
2789
|
throw new MastraError(
|
|
2762
2790
|
{
|
|
2763
|
-
id: "
|
|
2791
|
+
id: createVectorErrorId("LANCE", "DELETE_INDEX", "INVALID_ARGS"),
|
|
2764
2792
|
domain: ErrorDomain.STORAGE,
|
|
2765
2793
|
category: ErrorCategory.USER,
|
|
2766
2794
|
details: { indexName }
|
|
@@ -2783,7 +2811,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2783
2811
|
} catch (error) {
|
|
2784
2812
|
throw new MastraError(
|
|
2785
2813
|
{
|
|
2786
|
-
id: "
|
|
2814
|
+
id: createVectorErrorId("LANCE", "DELETE_INDEX", "FAILED"),
|
|
2787
2815
|
domain: ErrorDomain.STORAGE,
|
|
2788
2816
|
category: ErrorCategory.THIRD_PARTY,
|
|
2789
2817
|
details: { indexName }
|
|
@@ -2798,7 +2826,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2798
2826
|
async deleteAllTables() {
|
|
2799
2827
|
if (!this.lanceClient) {
|
|
2800
2828
|
throw new MastraError({
|
|
2801
|
-
id: "
|
|
2829
|
+
id: createVectorErrorId("LANCE", "DELETE_ALL_TABLES", "INVALID_ARGS"),
|
|
2802
2830
|
domain: ErrorDomain.STORAGE,
|
|
2803
2831
|
category: ErrorCategory.USER,
|
|
2804
2832
|
details: { methodName: "deleteAllTables" },
|
|
@@ -2810,7 +2838,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2810
2838
|
} catch (error) {
|
|
2811
2839
|
throw new MastraError(
|
|
2812
2840
|
{
|
|
2813
|
-
id: "
|
|
2841
|
+
id: createVectorErrorId("LANCE", "DELETE_ALL_TABLES", "FAILED"),
|
|
2814
2842
|
domain: ErrorDomain.STORAGE,
|
|
2815
2843
|
category: ErrorCategory.THIRD_PARTY,
|
|
2816
2844
|
details: { methodName: "deleteAllTables" }
|
|
@@ -2822,7 +2850,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2822
2850
|
async deleteTable(tableName) {
|
|
2823
2851
|
if (!this.lanceClient) {
|
|
2824
2852
|
throw new MastraError({
|
|
2825
|
-
id: "
|
|
2853
|
+
id: createVectorErrorId("LANCE", "DELETE_TABLE", "INVALID_ARGS"),
|
|
2826
2854
|
domain: ErrorDomain.STORAGE,
|
|
2827
2855
|
category: ErrorCategory.USER,
|
|
2828
2856
|
details: { tableName },
|
|
@@ -2834,7 +2862,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2834
2862
|
} catch (error) {
|
|
2835
2863
|
throw new MastraError(
|
|
2836
2864
|
{
|
|
2837
|
-
id: "
|
|
2865
|
+
id: createVectorErrorId("LANCE", "DELETE_TABLE", "FAILED"),
|
|
2838
2866
|
domain: ErrorDomain.STORAGE,
|
|
2839
2867
|
category: ErrorCategory.THIRD_PARTY,
|
|
2840
2868
|
details: { tableName }
|
|
@@ -2847,7 +2875,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2847
2875
|
const { indexName, update } = params;
|
|
2848
2876
|
if ("id" in params && "filter" in params && params.id && params.filter) {
|
|
2849
2877
|
throw new MastraError({
|
|
2850
|
-
id: "
|
|
2878
|
+
id: createVectorErrorId("LANCE", "UPDATE_VECTOR", "MUTUALLY_EXCLUSIVE"),
|
|
2851
2879
|
domain: ErrorDomain.STORAGE,
|
|
2852
2880
|
category: ErrorCategory.USER,
|
|
2853
2881
|
text: "id and filter are mutually exclusive",
|
|
@@ -2856,7 +2884,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2856
2884
|
}
|
|
2857
2885
|
if (!("id" in params || "filter" in params) || !params.id && !params.filter) {
|
|
2858
2886
|
throw new MastraError({
|
|
2859
|
-
id: "
|
|
2887
|
+
id: createVectorErrorId("LANCE", "UPDATE_VECTOR", "NO_TARGET"),
|
|
2860
2888
|
domain: ErrorDomain.STORAGE,
|
|
2861
2889
|
category: ErrorCategory.USER,
|
|
2862
2890
|
text: "Either id or filter must be provided",
|
|
@@ -2865,7 +2893,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2865
2893
|
}
|
|
2866
2894
|
if ("filter" in params && params.filter && Object.keys(params.filter).length === 0) {
|
|
2867
2895
|
throw new MastraError({
|
|
2868
|
-
id: "
|
|
2896
|
+
id: createVectorErrorId("LANCE", "UPDATE_VECTOR", "EMPTY_FILTER"),
|
|
2869
2897
|
domain: ErrorDomain.STORAGE,
|
|
2870
2898
|
category: ErrorCategory.USER,
|
|
2871
2899
|
text: "Cannot update with empty filter",
|
|
@@ -2874,7 +2902,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2874
2902
|
}
|
|
2875
2903
|
if (!update.vector && !update.metadata) {
|
|
2876
2904
|
throw new MastraError({
|
|
2877
|
-
id: "
|
|
2905
|
+
id: createVectorErrorId("LANCE", "UPDATE_VECTOR", "NO_PAYLOAD"),
|
|
2878
2906
|
domain: ErrorDomain.STORAGE,
|
|
2879
2907
|
category: ErrorCategory.USER,
|
|
2880
2908
|
text: "No updates provided",
|
|
@@ -2969,7 +2997,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2969
2997
|
if (error instanceof MastraError) throw error;
|
|
2970
2998
|
throw new MastraError(
|
|
2971
2999
|
{
|
|
2972
|
-
id: "
|
|
3000
|
+
id: createVectorErrorId("LANCE", "UPDATE_VECTOR", "FAILED"),
|
|
2973
3001
|
domain: ErrorDomain.STORAGE,
|
|
2974
3002
|
category: ErrorCategory.THIRD_PARTY,
|
|
2975
3003
|
details: {
|
|
@@ -2998,7 +3026,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
2998
3026
|
} catch (err) {
|
|
2999
3027
|
throw new MastraError(
|
|
3000
3028
|
{
|
|
3001
|
-
id: "
|
|
3029
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTOR", "INVALID_ARGS"),
|
|
3002
3030
|
domain: ErrorDomain.STORAGE,
|
|
3003
3031
|
category: ErrorCategory.USER,
|
|
3004
3032
|
details: {
|
|
@@ -3031,7 +3059,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3031
3059
|
} catch (error) {
|
|
3032
3060
|
throw new MastraError(
|
|
3033
3061
|
{
|
|
3034
|
-
id: "
|
|
3062
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTOR", "FAILED"),
|
|
3035
3063
|
domain: ErrorDomain.STORAGE,
|
|
3036
3064
|
category: ErrorCategory.THIRD_PARTY,
|
|
3037
3065
|
details: {
|
|
@@ -3071,7 +3099,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3071
3099
|
async deleteVectors({ indexName, filter, ids }) {
|
|
3072
3100
|
if (ids && filter) {
|
|
3073
3101
|
throw new MastraError({
|
|
3074
|
-
id: "
|
|
3102
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTORS", "MUTUALLY_EXCLUSIVE"),
|
|
3075
3103
|
domain: ErrorDomain.STORAGE,
|
|
3076
3104
|
category: ErrorCategory.USER,
|
|
3077
3105
|
text: "ids and filter are mutually exclusive",
|
|
@@ -3080,7 +3108,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3080
3108
|
}
|
|
3081
3109
|
if (!ids && !filter) {
|
|
3082
3110
|
throw new MastraError({
|
|
3083
|
-
id: "
|
|
3111
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTORS", "NO_TARGET"),
|
|
3084
3112
|
domain: ErrorDomain.STORAGE,
|
|
3085
3113
|
category: ErrorCategory.USER,
|
|
3086
3114
|
text: "Either filter or ids must be provided",
|
|
@@ -3089,7 +3117,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3089
3117
|
}
|
|
3090
3118
|
if (ids && ids.length === 0) {
|
|
3091
3119
|
throw new MastraError({
|
|
3092
|
-
id: "
|
|
3120
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTORS", "EMPTY_IDS"),
|
|
3093
3121
|
domain: ErrorDomain.STORAGE,
|
|
3094
3122
|
category: ErrorCategory.USER,
|
|
3095
3123
|
text: "Cannot delete with empty ids array",
|
|
@@ -3098,7 +3126,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3098
3126
|
}
|
|
3099
3127
|
if (filter && Object.keys(filter).length === 0) {
|
|
3100
3128
|
throw new MastraError({
|
|
3101
|
-
id: "
|
|
3129
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTORS", "EMPTY_FILTER"),
|
|
3102
3130
|
domain: ErrorDomain.STORAGE,
|
|
3103
3131
|
category: ErrorCategory.USER,
|
|
3104
3132
|
text: "Cannot delete with empty filter",
|
|
@@ -3158,7 +3186,7 @@ var LanceVectorStore = class _LanceVectorStore extends MastraVector {
|
|
|
3158
3186
|
if (error instanceof MastraError) throw error;
|
|
3159
3187
|
throw new MastraError(
|
|
3160
3188
|
{
|
|
3161
|
-
id: "
|
|
3189
|
+
id: createVectorErrorId("LANCE", "DELETE_VECTORS", "FAILED"),
|
|
3162
3190
|
domain: ErrorDomain.STORAGE,
|
|
3163
3191
|
category: ErrorCategory.THIRD_PARTY,
|
|
3164
3192
|
details: {
|