@mastra/lance 0.0.0-tool-call-parts-20250630193309 → 0.0.0-workflow-deno-20250616115451
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 +3 -106
- package/dist/_tsup-dts-rollup.d.cts +4 -28
- package/dist/_tsup-dts-rollup.d.ts +4 -28
- package/dist/index.cjs +160 -806
- package/dist/index.js +127 -773
- package/package.json +6 -6
- package/src/storage/index.test.ts +2 -72
- package/src/storage/index.ts +68 -498
- package/src/vector/filter.test.ts +3 -3
- package/src/vector/filter.ts +4 -24
- package/src/vector/index.test.ts +3 -3
- package/src/vector/index.ts +79 -320
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var lancedb = require('@lancedb/lancedb');
|
|
4
4
|
var agent = require('@mastra/core/agent');
|
|
5
|
-
var error = require('@mastra/core/error');
|
|
6
5
|
var storage = require('@mastra/core/storage');
|
|
7
6
|
var apacheArrow = require('apache-arrow');
|
|
8
7
|
var vector = require('@mastra/core/vector');
|
|
@@ -39,26 +38,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
39
38
|
instance.lanceClient = await lancedb.connect(uri, options);
|
|
40
39
|
return instance;
|
|
41
40
|
} catch (e) {
|
|
42
|
-
throw new
|
|
43
|
-
{
|
|
44
|
-
id: "STORAGE_LANCE_STORAGE_CONNECT_FAILED",
|
|
45
|
-
domain: error.ErrorDomain.STORAGE,
|
|
46
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
47
|
-
text: `Failed to connect to LanceDB: ${e.message || e}`,
|
|
48
|
-
details: { uri, optionsProvided: !!options }
|
|
49
|
-
},
|
|
50
|
-
e
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
getPrimaryKeys(tableName) {
|
|
55
|
-
let primaryId = ["id"];
|
|
56
|
-
if (tableName === storage.TABLE_WORKFLOW_SNAPSHOT) {
|
|
57
|
-
primaryId = ["workflow_name", "run_id"];
|
|
58
|
-
} else if (tableName === storage.TABLE_EVALS) {
|
|
59
|
-
primaryId = ["agent_name", "metric_name", "run_id"];
|
|
41
|
+
throw new Error(`Failed to connect to LanceDB: ${e}`);
|
|
60
42
|
}
|
|
61
|
-
return primaryId;
|
|
62
43
|
}
|
|
63
44
|
/**
|
|
64
45
|
* @internal
|
|
@@ -71,40 +52,11 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
71
52
|
tableName,
|
|
72
53
|
schema
|
|
73
54
|
}) {
|
|
74
|
-
try {
|
|
75
|
-
if (!this.lanceClient) {
|
|
76
|
-
throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
|
|
77
|
-
}
|
|
78
|
-
if (!tableName) {
|
|
79
|
-
throw new Error("tableName is required for createTable.");
|
|
80
|
-
}
|
|
81
|
-
if (!schema) {
|
|
82
|
-
throw new Error("schema is required for createTable.");
|
|
83
|
-
}
|
|
84
|
-
} catch (error$1) {
|
|
85
|
-
throw new error.MastraError(
|
|
86
|
-
{
|
|
87
|
-
id: "STORAGE_LANCE_STORAGE_CREATE_TABLE_INVALID_ARGS",
|
|
88
|
-
domain: error.ErrorDomain.STORAGE,
|
|
89
|
-
category: error.ErrorCategory.USER,
|
|
90
|
-
details: { tableName }
|
|
91
|
-
},
|
|
92
|
-
error$1
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
55
|
try {
|
|
96
56
|
const arrowSchema = this.translateSchema(schema);
|
|
97
57
|
await this.lanceClient.createEmptyTable(tableName, arrowSchema);
|
|
98
|
-
} catch (error
|
|
99
|
-
throw new error
|
|
100
|
-
{
|
|
101
|
-
id: "STORAGE_LANCE_STORAGE_CREATE_TABLE_FAILED",
|
|
102
|
-
domain: error.ErrorDomain.STORAGE,
|
|
103
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
104
|
-
details: { tableName }
|
|
105
|
-
},
|
|
106
|
-
error$1
|
|
107
|
-
);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
throw new Error(`Failed to create table: ${error}`);
|
|
108
60
|
}
|
|
109
61
|
}
|
|
110
62
|
translateSchema(schema) {
|
|
@@ -147,41 +99,14 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
147
99
|
* @param tableName Name of the table to drop
|
|
148
100
|
*/
|
|
149
101
|
async dropTable(tableName) {
|
|
150
|
-
try {
|
|
151
|
-
if (!this.lanceClient) {
|
|
152
|
-
throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
|
|
153
|
-
}
|
|
154
|
-
if (!tableName) {
|
|
155
|
-
throw new Error("tableName is required for dropTable.");
|
|
156
|
-
}
|
|
157
|
-
} catch (validationError) {
|
|
158
|
-
throw new error.MastraError(
|
|
159
|
-
{
|
|
160
|
-
id: "STORAGE_LANCE_STORAGE_DROP_TABLE_INVALID_ARGS",
|
|
161
|
-
domain: error.ErrorDomain.STORAGE,
|
|
162
|
-
category: error.ErrorCategory.USER,
|
|
163
|
-
text: validationError.message,
|
|
164
|
-
details: { tableName }
|
|
165
|
-
},
|
|
166
|
-
validationError
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
102
|
try {
|
|
170
103
|
await this.lanceClient.dropTable(tableName);
|
|
171
|
-
} catch (error
|
|
172
|
-
if (error
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (error.toString().includes("was not found")) {
|
|
173
106
|
this.logger.debug(`Table '${tableName}' does not exist, skipping drop`);
|
|
174
107
|
return;
|
|
175
108
|
}
|
|
176
|
-
throw new error
|
|
177
|
-
{
|
|
178
|
-
id: "STORAGE_LANCE_STORAGE_DROP_TABLE_FAILED",
|
|
179
|
-
domain: error.ErrorDomain.STORAGE,
|
|
180
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
181
|
-
details: { tableName }
|
|
182
|
-
},
|
|
183
|
-
error$1
|
|
184
|
-
);
|
|
109
|
+
throw new Error(`Failed to drop table: ${error}`);
|
|
185
110
|
}
|
|
186
111
|
}
|
|
187
112
|
/**
|
|
@@ -190,25 +115,6 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
190
115
|
* @returns Table schema
|
|
191
116
|
*/
|
|
192
117
|
async getTableSchema(tableName) {
|
|
193
|
-
try {
|
|
194
|
-
if (!this.lanceClient) {
|
|
195
|
-
throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
|
|
196
|
-
}
|
|
197
|
-
if (!tableName) {
|
|
198
|
-
throw new Error("tableName is required for getTableSchema.");
|
|
199
|
-
}
|
|
200
|
-
} catch (validationError) {
|
|
201
|
-
throw new error.MastraError(
|
|
202
|
-
{
|
|
203
|
-
id: "STORAGE_LANCE_STORAGE_GET_TABLE_SCHEMA_INVALID_ARGS",
|
|
204
|
-
domain: error.ErrorDomain.STORAGE,
|
|
205
|
-
category: error.ErrorCategory.USER,
|
|
206
|
-
text: validationError.message,
|
|
207
|
-
details: { tableName }
|
|
208
|
-
},
|
|
209
|
-
validationError
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
118
|
try {
|
|
213
119
|
const table = await this.lanceClient.openTable(tableName);
|
|
214
120
|
const rawSchema = await table.schema();
|
|
@@ -220,16 +126,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
220
126
|
return fields.map((field) => field.name);
|
|
221
127
|
}
|
|
222
128
|
};
|
|
223
|
-
} catch (error
|
|
224
|
-
throw new error
|
|
225
|
-
{
|
|
226
|
-
id: "STORAGE_LANCE_STORAGE_GET_TABLE_SCHEMA_FAILED",
|
|
227
|
-
domain: error.ErrorDomain.STORAGE,
|
|
228
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
229
|
-
details: { tableName }
|
|
230
|
-
},
|
|
231
|
-
error$1
|
|
232
|
-
);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
throw new Error(`Failed to get table schema: ${error}`);
|
|
233
131
|
}
|
|
234
132
|
}
|
|
235
133
|
getDefaultValue(type) {
|
|
@@ -260,101 +158,32 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
260
158
|
schema,
|
|
261
159
|
ifNotExists
|
|
262
160
|
}) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
{
|
|
280
|
-
id: "STORAGE_LANCE_STORAGE_ALTER_TABLE_INVALID_ARGS",
|
|
281
|
-
domain: error.ErrorDomain.STORAGE,
|
|
282
|
-
category: error.ErrorCategory.USER,
|
|
283
|
-
text: validationError.message,
|
|
284
|
-
details: { tableName }
|
|
285
|
-
},
|
|
286
|
-
validationError
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
try {
|
|
290
|
-
const table = await this.lanceClient.openTable(tableName);
|
|
291
|
-
const currentSchema = await table.schema();
|
|
292
|
-
const existingFields = new Set(currentSchema.fields.map((f) => f.name));
|
|
293
|
-
const typeMap = {
|
|
294
|
-
text: "string",
|
|
295
|
-
integer: "int",
|
|
296
|
-
bigint: "bigint",
|
|
297
|
-
timestamp: "timestamp",
|
|
298
|
-
jsonb: "string",
|
|
299
|
-
uuid: "string"
|
|
161
|
+
const table = await this.lanceClient.openTable(tableName);
|
|
162
|
+
const currentSchema = await table.schema();
|
|
163
|
+
const existingFields = new Set(currentSchema.fields.map((f) => f.name));
|
|
164
|
+
const typeMap = {
|
|
165
|
+
text: "string",
|
|
166
|
+
integer: "int",
|
|
167
|
+
bigint: "bigint",
|
|
168
|
+
timestamp: "timestamp",
|
|
169
|
+
jsonb: "string",
|
|
170
|
+
uuid: "string"
|
|
171
|
+
};
|
|
172
|
+
const columnsToAdd = ifNotExists.filter((col) => schema[col] && !existingFields.has(col)).map((col) => {
|
|
173
|
+
const colDef = schema[col];
|
|
174
|
+
return {
|
|
175
|
+
name: col,
|
|
176
|
+
valueSql: colDef?.nullable ? `cast(NULL as ${typeMap[colDef.type ?? "text"]})` : `cast(${this.getDefaultValue(colDef?.type ?? "text")} as ${typeMap[colDef?.type ?? "text"]})`
|
|
300
177
|
};
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
valueSql: colDef?.nullable ? `cast(NULL as ${typeMap[colDef.type ?? "text"]})` : `cast(${this.getDefaultValue(colDef?.type ?? "text")} as ${typeMap[colDef?.type ?? "text"]})`
|
|
306
|
-
};
|
|
307
|
-
});
|
|
308
|
-
if (columnsToAdd.length > 0) {
|
|
309
|
-
await table.addColumns(columnsToAdd);
|
|
310
|
-
this.logger?.info?.(`Added columns [${columnsToAdd.map((c) => c.name).join(", ")}] to table ${tableName}`);
|
|
311
|
-
}
|
|
312
|
-
} catch (error$1) {
|
|
313
|
-
throw new error.MastraError(
|
|
314
|
-
{
|
|
315
|
-
id: "STORAGE_LANCE_STORAGE_ALTER_TABLE_FAILED",
|
|
316
|
-
domain: error.ErrorDomain.STORAGE,
|
|
317
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
318
|
-
details: { tableName }
|
|
319
|
-
},
|
|
320
|
-
error$1
|
|
321
|
-
);
|
|
178
|
+
});
|
|
179
|
+
if (columnsToAdd.length > 0) {
|
|
180
|
+
await table.addColumns(columnsToAdd);
|
|
181
|
+
this.logger?.info?.(`Added columns [${columnsToAdd.map((c) => c.name).join(", ")}] to table ${tableName}`);
|
|
322
182
|
}
|
|
323
183
|
}
|
|
324
184
|
async clearTable({ tableName }) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
|
|
328
|
-
}
|
|
329
|
-
if (!tableName) {
|
|
330
|
-
throw new Error("tableName is required for clearTable.");
|
|
331
|
-
}
|
|
332
|
-
} catch (validationError) {
|
|
333
|
-
throw new error.MastraError(
|
|
334
|
-
{
|
|
335
|
-
id: "STORAGE_LANCE_STORAGE_CLEAR_TABLE_INVALID_ARGS",
|
|
336
|
-
domain: error.ErrorDomain.STORAGE,
|
|
337
|
-
category: error.ErrorCategory.USER,
|
|
338
|
-
text: validationError.message,
|
|
339
|
-
details: { tableName }
|
|
340
|
-
},
|
|
341
|
-
validationError
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
try {
|
|
345
|
-
const table = await this.lanceClient.openTable(tableName);
|
|
346
|
-
await table.delete("1=1");
|
|
347
|
-
} catch (error$1) {
|
|
348
|
-
throw new error.MastraError(
|
|
349
|
-
{
|
|
350
|
-
id: "STORAGE_LANCE_STORAGE_CLEAR_TABLE_FAILED",
|
|
351
|
-
domain: error.ErrorDomain.STORAGE,
|
|
352
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
353
|
-
details: { tableName }
|
|
354
|
-
},
|
|
355
|
-
error$1
|
|
356
|
-
);
|
|
357
|
-
}
|
|
185
|
+
const table = await this.lanceClient.openTable(tableName);
|
|
186
|
+
await table.delete("1=1");
|
|
358
187
|
}
|
|
359
188
|
/**
|
|
360
189
|
* Insert a single record into a table. This function overwrites the existing record if it exists. Use this function for inserting records into tables with custom schemas.
|
|
@@ -362,31 +191,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
362
191
|
* @param record The record to insert.
|
|
363
192
|
*/
|
|
364
193
|
async insert({ tableName, record }) {
|
|
365
|
-
try {
|
|
366
|
-
if (!this.lanceClient) {
|
|
367
|
-
throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
|
|
368
|
-
}
|
|
369
|
-
if (!tableName) {
|
|
370
|
-
throw new Error("tableName is required for insert.");
|
|
371
|
-
}
|
|
372
|
-
if (!record || Object.keys(record).length === 0) {
|
|
373
|
-
throw new Error("record is required and cannot be empty for insert.");
|
|
374
|
-
}
|
|
375
|
-
} catch (validationError) {
|
|
376
|
-
throw new error.MastraError(
|
|
377
|
-
{
|
|
378
|
-
id: "STORAGE_LANCE_STORAGE_INSERT_INVALID_ARGS",
|
|
379
|
-
domain: error.ErrorDomain.STORAGE,
|
|
380
|
-
category: error.ErrorCategory.USER,
|
|
381
|
-
text: validationError.message,
|
|
382
|
-
details: { tableName }
|
|
383
|
-
},
|
|
384
|
-
validationError
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
194
|
try {
|
|
388
195
|
const table = await this.lanceClient.openTable(tableName);
|
|
389
|
-
const primaryId = this.getPrimaryKeys(tableName);
|
|
390
196
|
const processedRecord = { ...record };
|
|
391
197
|
for (const key in processedRecord) {
|
|
392
198
|
if (processedRecord[key] !== null && typeof processedRecord[key] === "object" && !(processedRecord[key] instanceof Date)) {
|
|
@@ -394,17 +200,9 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
394
200
|
processedRecord[key] = JSON.stringify(processedRecord[key]);
|
|
395
201
|
}
|
|
396
202
|
}
|
|
397
|
-
await table.
|
|
398
|
-
} catch (error
|
|
399
|
-
throw new error
|
|
400
|
-
{
|
|
401
|
-
id: "STORAGE_LANCE_STORAGE_INSERT_FAILED",
|
|
402
|
-
domain: error.ErrorDomain.STORAGE,
|
|
403
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
404
|
-
details: { tableName }
|
|
405
|
-
},
|
|
406
|
-
error$1
|
|
407
|
-
);
|
|
203
|
+
await table.add([processedRecord], { mode: "overwrite" });
|
|
204
|
+
} catch (error) {
|
|
205
|
+
throw new Error(`Failed to insert record: ${error}`);
|
|
408
206
|
}
|
|
409
207
|
}
|
|
410
208
|
/**
|
|
@@ -413,31 +211,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
413
211
|
* @param records The records to insert.
|
|
414
212
|
*/
|
|
415
213
|
async batchInsert({ tableName, records }) {
|
|
416
|
-
try {
|
|
417
|
-
if (!this.lanceClient) {
|
|
418
|
-
throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
|
|
419
|
-
}
|
|
420
|
-
if (!tableName) {
|
|
421
|
-
throw new Error("tableName is required for batchInsert.");
|
|
422
|
-
}
|
|
423
|
-
if (!records || records.length === 0) {
|
|
424
|
-
throw new Error("records array is required and cannot be empty for batchInsert.");
|
|
425
|
-
}
|
|
426
|
-
} catch (validationError) {
|
|
427
|
-
throw new error.MastraError(
|
|
428
|
-
{
|
|
429
|
-
id: "STORAGE_LANCE_STORAGE_BATCH_INSERT_INVALID_ARGS",
|
|
430
|
-
domain: error.ErrorDomain.STORAGE,
|
|
431
|
-
category: error.ErrorCategory.USER,
|
|
432
|
-
text: validationError.message,
|
|
433
|
-
details: { tableName }
|
|
434
|
-
},
|
|
435
|
-
validationError
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
214
|
try {
|
|
439
215
|
const table = await this.lanceClient.openTable(tableName);
|
|
440
|
-
const primaryId = this.getPrimaryKeys(tableName);
|
|
441
216
|
const processedRecords = records.map((record) => {
|
|
442
217
|
const processedRecord = { ...record };
|
|
443
218
|
for (const key in processedRecord) {
|
|
@@ -448,17 +223,9 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
448
223
|
}
|
|
449
224
|
return processedRecord;
|
|
450
225
|
});
|
|
451
|
-
await table.
|
|
452
|
-
} catch (error
|
|
453
|
-
throw new error
|
|
454
|
-
{
|
|
455
|
-
id: "STORAGE_LANCE_STORAGE_BATCH_INSERT_FAILED",
|
|
456
|
-
domain: error.ErrorDomain.STORAGE,
|
|
457
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
458
|
-
details: { tableName }
|
|
459
|
-
},
|
|
460
|
-
error$1
|
|
461
|
-
);
|
|
226
|
+
await table.add(processedRecords, { mode: "overwrite" });
|
|
227
|
+
} catch (error) {
|
|
228
|
+
throw new Error(`Failed to batch insert records: ${error}`);
|
|
462
229
|
}
|
|
463
230
|
}
|
|
464
231
|
/**
|
|
@@ -469,28 +236,6 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
469
236
|
* @returns The loaded record with proper type conversions, or null if not found
|
|
470
237
|
*/
|
|
471
238
|
async load({ tableName, keys }) {
|
|
472
|
-
try {
|
|
473
|
-
if (!this.lanceClient) {
|
|
474
|
-
throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
|
|
475
|
-
}
|
|
476
|
-
if (!tableName) {
|
|
477
|
-
throw new Error("tableName is required for load.");
|
|
478
|
-
}
|
|
479
|
-
if (!keys || Object.keys(keys).length === 0) {
|
|
480
|
-
throw new Error("keys are required and cannot be empty for load.");
|
|
481
|
-
}
|
|
482
|
-
} catch (validationError) {
|
|
483
|
-
throw new error.MastraError(
|
|
484
|
-
{
|
|
485
|
-
id: "STORAGE_LANCE_STORAGE_LOAD_INVALID_ARGS",
|
|
486
|
-
domain: error.ErrorDomain.STORAGE,
|
|
487
|
-
category: error.ErrorCategory.USER,
|
|
488
|
-
text: validationError.message,
|
|
489
|
-
details: { tableName }
|
|
490
|
-
},
|
|
491
|
-
validationError
|
|
492
|
-
);
|
|
493
|
-
}
|
|
494
239
|
try {
|
|
495
240
|
const table = await this.lanceClient.openTable(tableName);
|
|
496
241
|
const tableSchema = await this.getTableSchema(tableName);
|
|
@@ -517,17 +262,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
517
262
|
return null;
|
|
518
263
|
}
|
|
519
264
|
return this.processResultWithTypeConversion(result[0], tableSchema);
|
|
520
|
-
} catch (error
|
|
521
|
-
|
|
522
|
-
throw new error.MastraError(
|
|
523
|
-
{
|
|
524
|
-
id: "STORAGE_LANCE_STORAGE_LOAD_FAILED",
|
|
525
|
-
domain: error.ErrorDomain.STORAGE,
|
|
526
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
527
|
-
details: { tableName, keyCount: Object.keys(keys).length, firstKey: Object.keys(keys)[0] ?? "" }
|
|
528
|
-
},
|
|
529
|
-
error$1
|
|
530
|
-
);
|
|
265
|
+
} catch (error) {
|
|
266
|
+
throw new Error(`Failed to load record: ${error}`);
|
|
531
267
|
}
|
|
532
268
|
}
|
|
533
269
|
/**
|
|
@@ -601,15 +337,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
601
337
|
getThreadById({ threadId }) {
|
|
602
338
|
try {
|
|
603
339
|
return this.load({ tableName: storage.TABLE_THREADS, keys: { id: threadId } });
|
|
604
|
-
} catch (error
|
|
605
|
-
throw new error
|
|
606
|
-
{
|
|
607
|
-
id: "LANCE_STORE_GET_THREAD_BY_ID_FAILED",
|
|
608
|
-
domain: error.ErrorDomain.STORAGE,
|
|
609
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
610
|
-
},
|
|
611
|
-
error$1
|
|
612
|
-
);
|
|
340
|
+
} catch (error) {
|
|
341
|
+
throw new Error(`Failed to get thread by ID: ${error}`);
|
|
613
342
|
}
|
|
614
343
|
}
|
|
615
344
|
async getThreadsByResourceId({ resourceId }) {
|
|
@@ -621,15 +350,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
621
350
|
records,
|
|
622
351
|
await this.getTableSchema(storage.TABLE_THREADS)
|
|
623
352
|
);
|
|
624
|
-
} catch (error
|
|
625
|
-
throw new error
|
|
626
|
-
{
|
|
627
|
-
id: "LANCE_STORE_GET_THREADS_BY_RESOURCE_ID_FAILED",
|
|
628
|
-
domain: error.ErrorDomain.STORAGE,
|
|
629
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
630
|
-
},
|
|
631
|
-
error$1
|
|
632
|
-
);
|
|
353
|
+
} catch (error) {
|
|
354
|
+
throw new Error(`Failed to get threads by resource ID: ${error}`);
|
|
633
355
|
}
|
|
634
356
|
}
|
|
635
357
|
/**
|
|
@@ -643,15 +365,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
643
365
|
const table = await this.lanceClient.openTable(storage.TABLE_THREADS);
|
|
644
366
|
await table.add([record], { mode: "append" });
|
|
645
367
|
return thread;
|
|
646
|
-
} catch (error
|
|
647
|
-
throw new error
|
|
648
|
-
{
|
|
649
|
-
id: "LANCE_STORE_SAVE_THREAD_FAILED",
|
|
650
|
-
domain: error.ErrorDomain.STORAGE,
|
|
651
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
652
|
-
},
|
|
653
|
-
error$1
|
|
654
|
-
);
|
|
368
|
+
} catch (error) {
|
|
369
|
+
throw new Error(`Failed to save thread: ${error}`);
|
|
655
370
|
}
|
|
656
371
|
}
|
|
657
372
|
async updateThread({
|
|
@@ -662,37 +377,23 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
662
377
|
try {
|
|
663
378
|
const record = { id, title, metadata: JSON.stringify(metadata) };
|
|
664
379
|
const table = await this.lanceClient.openTable(storage.TABLE_THREADS);
|
|
665
|
-
await table.
|
|
380
|
+
await table.add([record], { mode: "overwrite" });
|
|
666
381
|
const query = table.query().where(`id = '${id}'`);
|
|
667
382
|
const records = await query.toArray();
|
|
668
383
|
return this.processResultWithTypeConversion(
|
|
669
384
|
records[0],
|
|
670
385
|
await this.getTableSchema(storage.TABLE_THREADS)
|
|
671
386
|
);
|
|
672
|
-
} catch (error
|
|
673
|
-
throw new error
|
|
674
|
-
{
|
|
675
|
-
id: "LANCE_STORE_UPDATE_THREAD_FAILED",
|
|
676
|
-
domain: error.ErrorDomain.STORAGE,
|
|
677
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
678
|
-
},
|
|
679
|
-
error$1
|
|
680
|
-
);
|
|
387
|
+
} catch (error) {
|
|
388
|
+
throw new Error(`Failed to update thread: ${error}`);
|
|
681
389
|
}
|
|
682
390
|
}
|
|
683
391
|
async deleteThread({ threadId }) {
|
|
684
392
|
try {
|
|
685
393
|
const table = await this.lanceClient.openTable(storage.TABLE_THREADS);
|
|
686
394
|
await table.delete(`id = '${threadId}'`);
|
|
687
|
-
} catch (error
|
|
688
|
-
throw new error
|
|
689
|
-
{
|
|
690
|
-
id: "LANCE_STORE_DELETE_THREAD_FAILED",
|
|
691
|
-
domain: error.ErrorDomain.STORAGE,
|
|
692
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
693
|
-
},
|
|
694
|
-
error$1
|
|
695
|
-
);
|
|
395
|
+
} catch (error) {
|
|
396
|
+
throw new Error(`Failed to delete thread: ${error}`);
|
|
696
397
|
}
|
|
697
398
|
}
|
|
698
399
|
/**
|
|
@@ -754,7 +455,6 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
754
455
|
if (threadConfig) {
|
|
755
456
|
throw new Error("ThreadConfig is not supported by LanceDB storage");
|
|
756
457
|
}
|
|
757
|
-
const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: Number.MAX_SAFE_INTEGER });
|
|
758
458
|
const table = await this.lanceClient.openTable(storage.TABLE_MESSAGES);
|
|
759
459
|
let query = table.query().where(`\`threadId\` = '${threadId}'`);
|
|
760
460
|
if (selectBy) {
|
|
@@ -773,8 +473,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
773
473
|
if (selectBy?.include && selectBy.include.length > 0) {
|
|
774
474
|
records = this.processMessagesWithContext(records, selectBy.include);
|
|
775
475
|
}
|
|
776
|
-
if (
|
|
777
|
-
records = records.slice(-
|
|
476
|
+
if (selectBy?.last !== void 0 && selectBy.last !== false) {
|
|
477
|
+
records = records.slice(-selectBy.last);
|
|
778
478
|
}
|
|
779
479
|
const messages = this.processResultWithTypeConversion(records, await this.getTableSchema(storage.TABLE_MESSAGES));
|
|
780
480
|
const normalized = messages.map((msg) => ({
|
|
@@ -790,15 +490,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
790
490
|
const list = new agent.MessageList({ threadId, resourceId }).add(normalized, "memory");
|
|
791
491
|
if (format === "v2") return list.get.all.v2();
|
|
792
492
|
return list.get.all.v1();
|
|
793
|
-
} catch (error
|
|
794
|
-
throw new error
|
|
795
|
-
{
|
|
796
|
-
id: "LANCE_STORE_GET_MESSAGES_FAILED",
|
|
797
|
-
domain: error.ErrorDomain.STORAGE,
|
|
798
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
799
|
-
},
|
|
800
|
-
error$1
|
|
801
|
-
);
|
|
493
|
+
} catch (error) {
|
|
494
|
+
throw new Error(`Failed to get messages: ${error}`);
|
|
802
495
|
}
|
|
803
496
|
}
|
|
804
497
|
async saveMessages(args) {
|
|
@@ -816,19 +509,12 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
816
509
|
content: JSON.stringify(message.content)
|
|
817
510
|
}));
|
|
818
511
|
const table = await this.lanceClient.openTable(storage.TABLE_MESSAGES);
|
|
819
|
-
await table.
|
|
512
|
+
await table.add(transformedMessages, { mode: "overwrite" });
|
|
820
513
|
const list = new agent.MessageList().add(messages, "memory");
|
|
821
514
|
if (format === `v2`) return list.get.all.v2();
|
|
822
515
|
return list.get.all.v1();
|
|
823
|
-
} catch (error
|
|
824
|
-
throw new error
|
|
825
|
-
{
|
|
826
|
-
id: "LANCE_STORE_SAVE_MESSAGES_FAILED",
|
|
827
|
-
domain: error.ErrorDomain.STORAGE,
|
|
828
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
829
|
-
},
|
|
830
|
-
error$1
|
|
831
|
-
);
|
|
516
|
+
} catch (error) {
|
|
517
|
+
throw new Error(`Failed to save messages: ${error}`);
|
|
832
518
|
}
|
|
833
519
|
}
|
|
834
520
|
async saveTrace({ trace }) {
|
|
@@ -844,15 +530,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
844
530
|
};
|
|
845
531
|
await table.add([record], { mode: "append" });
|
|
846
532
|
return trace;
|
|
847
|
-
} catch (error
|
|
848
|
-
throw new error
|
|
849
|
-
{
|
|
850
|
-
id: "LANCE_STORE_SAVE_TRACE_FAILED",
|
|
851
|
-
domain: error.ErrorDomain.STORAGE,
|
|
852
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
853
|
-
},
|
|
854
|
-
error$1
|
|
855
|
-
);
|
|
533
|
+
} catch (error) {
|
|
534
|
+
throw new Error(`Failed to save trace: ${error}`);
|
|
856
535
|
}
|
|
857
536
|
}
|
|
858
537
|
async getTraceById({ traceId }) {
|
|
@@ -861,15 +540,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
861
540
|
const query = table.query().where(`id = '${traceId}'`);
|
|
862
541
|
const records = await query.toArray();
|
|
863
542
|
return this.processResultWithTypeConversion(records[0], await this.getTableSchema(storage.TABLE_TRACES));
|
|
864
|
-
} catch (error
|
|
865
|
-
throw new error
|
|
866
|
-
{
|
|
867
|
-
id: "LANCE_STORE_GET_TRACE_BY_ID_FAILED",
|
|
868
|
-
domain: error.ErrorDomain.STORAGE,
|
|
869
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
870
|
-
},
|
|
871
|
-
error$1
|
|
872
|
-
);
|
|
543
|
+
} catch (error) {
|
|
544
|
+
throw new Error(`Failed to get trace by ID: ${error}`);
|
|
873
545
|
}
|
|
874
546
|
}
|
|
875
547
|
async getTraces({
|
|
@@ -910,16 +582,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
910
582
|
createdAt: new Date(record.createdAt)
|
|
911
583
|
};
|
|
912
584
|
});
|
|
913
|
-
} catch (error
|
|
914
|
-
throw new error
|
|
915
|
-
{
|
|
916
|
-
id: "LANCE_STORE_GET_TRACES_FAILED",
|
|
917
|
-
domain: error.ErrorDomain.STORAGE,
|
|
918
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
919
|
-
details: { name: name ?? "", scope: scope ?? "" }
|
|
920
|
-
},
|
|
921
|
-
error$1
|
|
922
|
-
);
|
|
585
|
+
} catch (error) {
|
|
586
|
+
throw new Error(`Failed to get traces: ${error}`);
|
|
923
587
|
}
|
|
924
588
|
}
|
|
925
589
|
async saveEvals({ evals }) {
|
|
@@ -939,15 +603,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
939
603
|
}));
|
|
940
604
|
await table.add(transformedEvals, { mode: "append" });
|
|
941
605
|
return evals;
|
|
942
|
-
} catch (error
|
|
943
|
-
throw new error
|
|
944
|
-
{
|
|
945
|
-
id: "LANCE_STORE_SAVE_EVALS_FAILED",
|
|
946
|
-
domain: error.ErrorDomain.STORAGE,
|
|
947
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
948
|
-
},
|
|
949
|
-
error$1
|
|
950
|
-
);
|
|
606
|
+
} catch (error) {
|
|
607
|
+
throw new Error(`Failed to save evals: ${error}`);
|
|
951
608
|
}
|
|
952
609
|
}
|
|
953
610
|
async getEvalsByAgentName(agentName, type) {
|
|
@@ -973,16 +630,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
973
630
|
createdAt: new Date(record.created_at).toString()
|
|
974
631
|
};
|
|
975
632
|
});
|
|
976
|
-
} catch (error
|
|
977
|
-
throw new error
|
|
978
|
-
{
|
|
979
|
-
id: "LANCE_STORE_GET_EVALS_BY_AGENT_NAME_FAILED",
|
|
980
|
-
domain: error.ErrorDomain.STORAGE,
|
|
981
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
982
|
-
details: { agentName }
|
|
983
|
-
},
|
|
984
|
-
error$1
|
|
985
|
-
);
|
|
633
|
+
} catch (error) {
|
|
634
|
+
throw new Error(`Failed to get evals by agent name: ${error}`);
|
|
986
635
|
}
|
|
987
636
|
}
|
|
988
637
|
parseWorkflowRun(row) {
|
|
@@ -1027,16 +676,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1027
676
|
runs: records.map((record) => this.parseWorkflowRun(record)),
|
|
1028
677
|
total: records.length
|
|
1029
678
|
};
|
|
1030
|
-
} catch (error
|
|
1031
|
-
throw new error
|
|
1032
|
-
{
|
|
1033
|
-
id: "LANCE_STORE_GET_WORKFLOW_RUNS_FAILED",
|
|
1034
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1035
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1036
|
-
details: { namespace: args?.namespace ?? "", workflowName: args?.workflowName ?? "" }
|
|
1037
|
-
},
|
|
1038
|
-
error$1
|
|
1039
|
-
);
|
|
679
|
+
} catch (error) {
|
|
680
|
+
throw new Error(`Failed to get workflow runs: ${error}`);
|
|
1040
681
|
}
|
|
1041
682
|
}
|
|
1042
683
|
/**
|
|
@@ -1056,16 +697,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1056
697
|
if (records.length === 0) return null;
|
|
1057
698
|
const record = records[0];
|
|
1058
699
|
return this.parseWorkflowRun(record);
|
|
1059
|
-
} catch (error
|
|
1060
|
-
throw new error
|
|
1061
|
-
{
|
|
1062
|
-
id: "LANCE_STORE_GET_WORKFLOW_RUN_BY_ID_FAILED",
|
|
1063
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1064
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1065
|
-
details: { runId: args.runId, workflowName: args.workflowName ?? "" }
|
|
1066
|
-
},
|
|
1067
|
-
error$1
|
|
1068
|
-
);
|
|
700
|
+
} catch (error) {
|
|
701
|
+
throw new Error(`Failed to get workflow run by id: ${error}`);
|
|
1069
702
|
}
|
|
1070
703
|
}
|
|
1071
704
|
async persistWorkflowSnapshot({
|
|
@@ -1079,8 +712,10 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1079
712
|
const records = await query.toArray();
|
|
1080
713
|
let createdAt;
|
|
1081
714
|
const now = Date.now();
|
|
715
|
+
let mode = "append";
|
|
1082
716
|
if (records.length > 0) {
|
|
1083
717
|
createdAt = records[0].createdAt ?? now;
|
|
718
|
+
mode = "overwrite";
|
|
1084
719
|
} else {
|
|
1085
720
|
createdAt = now;
|
|
1086
721
|
}
|
|
@@ -1091,17 +726,9 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1091
726
|
createdAt,
|
|
1092
727
|
updatedAt: now
|
|
1093
728
|
};
|
|
1094
|
-
await table.
|
|
1095
|
-
} catch (error
|
|
1096
|
-
throw new error
|
|
1097
|
-
{
|
|
1098
|
-
id: "LANCE_STORE_PERSIST_WORKFLOW_SNAPSHOT_FAILED",
|
|
1099
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1100
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1101
|
-
details: { workflowName, runId }
|
|
1102
|
-
},
|
|
1103
|
-
error$1
|
|
1104
|
-
);
|
|
729
|
+
await table.add([record], { mode });
|
|
730
|
+
} catch (error) {
|
|
731
|
+
throw new Error(`Failed to persist workflow snapshot: ${error}`);
|
|
1105
732
|
}
|
|
1106
733
|
}
|
|
1107
734
|
async loadWorkflowSnapshot({
|
|
@@ -1113,51 +740,18 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
|
|
|
1113
740
|
const query = table.query().where(`workflow_name = '${workflowName}' AND run_id = '${runId}'`);
|
|
1114
741
|
const records = await query.toArray();
|
|
1115
742
|
return records.length > 0 ? JSON.parse(records[0].snapshot) : null;
|
|
1116
|
-
} catch (error
|
|
1117
|
-
throw new error
|
|
1118
|
-
{
|
|
1119
|
-
id: "LANCE_STORE_LOAD_WORKFLOW_SNAPSHOT_FAILED",
|
|
1120
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1121
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1122
|
-
details: { workflowName, runId }
|
|
1123
|
-
},
|
|
1124
|
-
error$1
|
|
1125
|
-
);
|
|
743
|
+
} catch (error) {
|
|
744
|
+
throw new Error(`Failed to load workflow snapshot: ${error}`);
|
|
1126
745
|
}
|
|
1127
746
|
}
|
|
1128
747
|
async getTracesPaginated(_args) {
|
|
1129
|
-
throw new
|
|
1130
|
-
{
|
|
1131
|
-
id: "LANCE_STORE_GET_TRACES_PAGINATED_FAILED",
|
|
1132
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1133
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1134
|
-
},
|
|
1135
|
-
"Method not implemented."
|
|
1136
|
-
);
|
|
748
|
+
throw new Error("Method not implemented.");
|
|
1137
749
|
}
|
|
1138
750
|
async getThreadsByResourceIdPaginated(_args) {
|
|
1139
|
-
throw new
|
|
1140
|
-
{
|
|
1141
|
-
id: "LANCE_STORE_GET_THREADS_BY_RESOURCE_ID_PAGINATED_FAILED",
|
|
1142
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1143
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1144
|
-
},
|
|
1145
|
-
"Method not implemented."
|
|
1146
|
-
);
|
|
751
|
+
throw new Error("Method not implemented.");
|
|
1147
752
|
}
|
|
1148
753
|
async getMessagesPaginated(_args) {
|
|
1149
|
-
throw new
|
|
1150
|
-
{
|
|
1151
|
-
id: "LANCE_STORE_GET_MESSAGES_PAGINATED_FAILED",
|
|
1152
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1153
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1154
|
-
},
|
|
1155
|
-
"Method not implemented."
|
|
1156
|
-
);
|
|
1157
|
-
}
|
|
1158
|
-
async updateMessages(_args) {
|
|
1159
|
-
this.logger.error("updateMessages is not yet implemented in LanceStore");
|
|
1160
|
-
throw new Error("Method not implemented");
|
|
754
|
+
throw new Error("Method not implemented.");
|
|
1161
755
|
}
|
|
1162
756
|
};
|
|
1163
757
|
var LanceFilterTranslator = class extends filter.BaseFilterTranslator {
|
|
@@ -1511,15 +1105,7 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1511
1105
|
instance.lanceClient = await lancedb.connect(uri, options);
|
|
1512
1106
|
return instance;
|
|
1513
1107
|
} catch (e) {
|
|
1514
|
-
throw new
|
|
1515
|
-
{
|
|
1516
|
-
id: "STORAGE_LANCE_VECTOR_CONNECT_FAILED",
|
|
1517
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1518
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1519
|
-
details: { uri }
|
|
1520
|
-
},
|
|
1521
|
-
e
|
|
1522
|
-
);
|
|
1108
|
+
throw new Error(`Failed to connect to LanceDB: ${e}`);
|
|
1523
1109
|
}
|
|
1524
1110
|
}
|
|
1525
1111
|
/**
|
|
@@ -1543,27 +1129,14 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1543
1129
|
columns = [],
|
|
1544
1130
|
includeAllColumns = false
|
|
1545
1131
|
}) {
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
throw new Error("queryVector is required");
|
|
1555
|
-
}
|
|
1556
|
-
} catch (error$1) {
|
|
1557
|
-
throw new error.MastraError(
|
|
1558
|
-
{
|
|
1559
|
-
id: "STORAGE_LANCE_VECTOR_QUERY_FAILED_INVALID_ARGS",
|
|
1560
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1561
|
-
category: error.ErrorCategory.USER,
|
|
1562
|
-
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
1563
|
-
details: { tableName }
|
|
1564
|
-
},
|
|
1565
|
-
error$1
|
|
1566
|
-
);
|
|
1132
|
+
if (!this.lanceClient) {
|
|
1133
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1134
|
+
}
|
|
1135
|
+
if (!tableName) {
|
|
1136
|
+
throw new Error("tableName is required");
|
|
1137
|
+
}
|
|
1138
|
+
if (!queryVector) {
|
|
1139
|
+
throw new Error("queryVector is required");
|
|
1567
1140
|
}
|
|
1568
1141
|
try {
|
|
1569
1142
|
const table = await this.lanceClient.openTable(tableName);
|
|
@@ -1601,16 +1174,8 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1601
1174
|
score: result._distance
|
|
1602
1175
|
};
|
|
1603
1176
|
});
|
|
1604
|
-
} catch (error
|
|
1605
|
-
throw new error.
|
|
1606
|
-
{
|
|
1607
|
-
id: "STORAGE_LANCE_VECTOR_QUERY_FAILED",
|
|
1608
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1609
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1610
|
-
details: { tableName, includeVector, columnsCount: columns?.length, includeAllColumns }
|
|
1611
|
-
},
|
|
1612
|
-
error$1
|
|
1613
|
-
);
|
|
1177
|
+
} catch (error) {
|
|
1178
|
+
throw new Error(`Failed to query vectors: ${error.message}`);
|
|
1614
1179
|
}
|
|
1615
1180
|
}
|
|
1616
1181
|
filterTranslator(filter) {
|
|
@@ -1643,27 +1208,14 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1643
1208
|
return translator.translate(prefixedFilter);
|
|
1644
1209
|
}
|
|
1645
1210
|
async upsert({ tableName, vectors, metadata = [], ids = [] }) {
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
throw new Error("vectors array is required and must not be empty");
|
|
1655
|
-
}
|
|
1656
|
-
} catch (error$1) {
|
|
1657
|
-
throw new error.MastraError(
|
|
1658
|
-
{
|
|
1659
|
-
id: "STORAGE_LANCE_VECTOR_UPSERT_FAILED_INVALID_ARGS",
|
|
1660
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1661
|
-
category: error.ErrorCategory.USER,
|
|
1662
|
-
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
1663
|
-
details: { tableName }
|
|
1664
|
-
},
|
|
1665
|
-
error$1
|
|
1666
|
-
);
|
|
1211
|
+
if (!this.lanceClient) {
|
|
1212
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1213
|
+
}
|
|
1214
|
+
if (!tableName) {
|
|
1215
|
+
throw new Error("tableName is required");
|
|
1216
|
+
}
|
|
1217
|
+
if (!vectors || !Array.isArray(vectors) || vectors.length === 0) {
|
|
1218
|
+
throw new Error("vectors array is required and must not be empty");
|
|
1667
1219
|
}
|
|
1668
1220
|
try {
|
|
1669
1221
|
const tables = await this.lanceClient.tableNames();
|
|
@@ -1689,16 +1241,8 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1689
1241
|
});
|
|
1690
1242
|
await table.add(data, { mode: "overwrite" });
|
|
1691
1243
|
return vectorIds;
|
|
1692
|
-
} catch (error
|
|
1693
|
-
throw new error.
|
|
1694
|
-
{
|
|
1695
|
-
id: "STORAGE_LANCE_VECTOR_UPSERT_FAILED",
|
|
1696
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1697
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1698
|
-
details: { tableName, vectorCount: vectors.length, metadataCount: metadata.length, idsCount: ids.length }
|
|
1699
|
-
},
|
|
1700
|
-
error$1
|
|
1701
|
-
);
|
|
1244
|
+
} catch (error) {
|
|
1245
|
+
throw new Error(`Failed to upsert vectors: ${error.message}`);
|
|
1702
1246
|
}
|
|
1703
1247
|
}
|
|
1704
1248
|
/**
|
|
@@ -1718,78 +1262,29 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1718
1262
|
}
|
|
1719
1263
|
async createTable(tableName, data, options) {
|
|
1720
1264
|
if (!this.lanceClient) {
|
|
1721
|
-
throw new
|
|
1722
|
-
id: "STORAGE_LANCE_VECTOR_CREATE_TABLE_FAILED_INVALID_ARGS",
|
|
1723
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1724
|
-
category: error.ErrorCategory.USER,
|
|
1725
|
-
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
1726
|
-
details: { tableName }
|
|
1727
|
-
});
|
|
1728
|
-
}
|
|
1729
|
-
if (Array.isArray(data)) {
|
|
1730
|
-
data = data.map((record) => this.flattenObject(record));
|
|
1265
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1731
1266
|
}
|
|
1732
1267
|
try {
|
|
1268
|
+
if (Array.isArray(data)) {
|
|
1269
|
+
data = data.map((record) => this.flattenObject(record));
|
|
1270
|
+
}
|
|
1733
1271
|
return await this.lanceClient.createTable(tableName, data, options);
|
|
1734
|
-
} catch (error
|
|
1735
|
-
throw new error.
|
|
1736
|
-
{
|
|
1737
|
-
id: "STORAGE_LANCE_VECTOR_CREATE_TABLE_FAILED",
|
|
1738
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1739
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1740
|
-
details: { tableName }
|
|
1741
|
-
},
|
|
1742
|
-
error$1
|
|
1743
|
-
);
|
|
1272
|
+
} catch (error) {
|
|
1273
|
+
throw new Error(`Failed to create table: ${error.message}`);
|
|
1744
1274
|
}
|
|
1745
1275
|
}
|
|
1746
1276
|
async listTables() {
|
|
1747
1277
|
if (!this.lanceClient) {
|
|
1748
|
-
throw new
|
|
1749
|
-
id: "STORAGE_LANCE_VECTOR_LIST_TABLES_FAILED_INVALID_ARGS",
|
|
1750
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1751
|
-
category: error.ErrorCategory.USER,
|
|
1752
|
-
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
1753
|
-
details: { methodName: "listTables" }
|
|
1754
|
-
});
|
|
1755
|
-
}
|
|
1756
|
-
try {
|
|
1757
|
-
return await this.lanceClient.tableNames();
|
|
1758
|
-
} catch (error$1) {
|
|
1759
|
-
throw new error.MastraError(
|
|
1760
|
-
{
|
|
1761
|
-
id: "STORAGE_LANCE_VECTOR_LIST_TABLES_FAILED",
|
|
1762
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1763
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1764
|
-
},
|
|
1765
|
-
error$1
|
|
1766
|
-
);
|
|
1278
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1767
1279
|
}
|
|
1280
|
+
return await this.lanceClient.tableNames();
|
|
1768
1281
|
}
|
|
1769
1282
|
async getTableSchema(tableName) {
|
|
1770
1283
|
if (!this.lanceClient) {
|
|
1771
|
-
throw new
|
|
1772
|
-
id: "STORAGE_LANCE_VECTOR_GET_TABLE_SCHEMA_FAILED_INVALID_ARGS",
|
|
1773
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1774
|
-
category: error.ErrorCategory.USER,
|
|
1775
|
-
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
1776
|
-
details: { tableName }
|
|
1777
|
-
});
|
|
1778
|
-
}
|
|
1779
|
-
try {
|
|
1780
|
-
const table = await this.lanceClient.openTable(tableName);
|
|
1781
|
-
return await table.schema();
|
|
1782
|
-
} catch (error$1) {
|
|
1783
|
-
throw new error.MastraError(
|
|
1784
|
-
{
|
|
1785
|
-
id: "STORAGE_LANCE_VECTOR_GET_TABLE_SCHEMA_FAILED",
|
|
1786
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1787
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1788
|
-
details: { tableName }
|
|
1789
|
-
},
|
|
1790
|
-
error$1
|
|
1791
|
-
);
|
|
1284
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1792
1285
|
}
|
|
1286
|
+
const table = await this.lanceClient.openTable(tableName);
|
|
1287
|
+
return await table.schema();
|
|
1793
1288
|
}
|
|
1794
1289
|
/**
|
|
1795
1290
|
* indexName is actually a column name in a table in lanceDB
|
|
@@ -1801,10 +1296,10 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1801
1296
|
metric = "cosine",
|
|
1802
1297
|
indexConfig = {}
|
|
1803
1298
|
}) {
|
|
1299
|
+
if (!this.lanceClient) {
|
|
1300
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1301
|
+
}
|
|
1804
1302
|
try {
|
|
1805
|
-
if (!this.lanceClient) {
|
|
1806
|
-
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1807
|
-
}
|
|
1808
1303
|
if (!tableName) {
|
|
1809
1304
|
throw new Error("tableName is required");
|
|
1810
1305
|
}
|
|
@@ -1814,18 +1309,6 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1814
1309
|
if (typeof dimension !== "number" || dimension <= 0) {
|
|
1815
1310
|
throw new Error("dimension must be a positive number");
|
|
1816
1311
|
}
|
|
1817
|
-
} catch (err) {
|
|
1818
|
-
throw new error.MastraError(
|
|
1819
|
-
{
|
|
1820
|
-
id: "STORAGE_LANCE_VECTOR_CREATE_INDEX_FAILED_INVALID_ARGS",
|
|
1821
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1822
|
-
category: error.ErrorCategory.USER,
|
|
1823
|
-
details: { tableName: tableName || "", indexName, dimension, metric }
|
|
1824
|
-
},
|
|
1825
|
-
err
|
|
1826
|
-
);
|
|
1827
|
-
}
|
|
1828
|
-
try {
|
|
1829
1312
|
const tables = await this.lanceClient.tableNames();
|
|
1830
1313
|
if (!tables.includes(tableName)) {
|
|
1831
1314
|
throw new Error(
|
|
@@ -1859,27 +1342,13 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1859
1342
|
})
|
|
1860
1343
|
});
|
|
1861
1344
|
}
|
|
1862
|
-
} catch (error
|
|
1863
|
-
throw new error.
|
|
1864
|
-
{
|
|
1865
|
-
id: "STORAGE_LANCE_VECTOR_CREATE_INDEX_FAILED",
|
|
1866
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1867
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1868
|
-
details: { tableName: tableName || "", indexName, dimension }
|
|
1869
|
-
},
|
|
1870
|
-
error$1
|
|
1871
|
-
);
|
|
1345
|
+
} catch (error) {
|
|
1346
|
+
throw new Error(`Failed to create index: ${error.message}`);
|
|
1872
1347
|
}
|
|
1873
1348
|
}
|
|
1874
1349
|
async listIndexes() {
|
|
1875
1350
|
if (!this.lanceClient) {
|
|
1876
|
-
throw new
|
|
1877
|
-
id: "STORAGE_LANCE_VECTOR_LIST_INDEXES_FAILED_INVALID_ARGS",
|
|
1878
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1879
|
-
category: error.ErrorCategory.USER,
|
|
1880
|
-
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
|
|
1881
|
-
details: { methodName: "listIndexes" }
|
|
1882
|
-
});
|
|
1351
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1883
1352
|
}
|
|
1884
1353
|
try {
|
|
1885
1354
|
const tables = await this.lanceClient.tableNames();
|
|
@@ -1890,35 +1359,16 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1890
1359
|
allIndices.push(...tableIndices.map((index) => index.name));
|
|
1891
1360
|
}
|
|
1892
1361
|
return allIndices;
|
|
1893
|
-
} catch (error
|
|
1894
|
-
throw new error.
|
|
1895
|
-
{
|
|
1896
|
-
id: "STORAGE_LANCE_VECTOR_LIST_INDEXES_FAILED",
|
|
1897
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1898
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1899
|
-
},
|
|
1900
|
-
error$1
|
|
1901
|
-
);
|
|
1362
|
+
} catch (error) {
|
|
1363
|
+
throw new Error(`Failed to list indexes: ${error.message}`);
|
|
1902
1364
|
}
|
|
1903
1365
|
}
|
|
1904
1366
|
async describeIndex({ indexName }) {
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
throw new Error("indexName is required");
|
|
1911
|
-
}
|
|
1912
|
-
} catch (err) {
|
|
1913
|
-
throw new error.MastraError(
|
|
1914
|
-
{
|
|
1915
|
-
id: "STORAGE_LANCE_VECTOR_DESCRIBE_INDEX_FAILED_INVALID_ARGS",
|
|
1916
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1917
|
-
category: error.ErrorCategory.USER,
|
|
1918
|
-
details: { indexName }
|
|
1919
|
-
},
|
|
1920
|
-
err
|
|
1921
|
-
);
|
|
1367
|
+
if (!this.lanceClient) {
|
|
1368
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1369
|
+
}
|
|
1370
|
+
if (!indexName) {
|
|
1371
|
+
throw new Error("indexName is required");
|
|
1922
1372
|
}
|
|
1923
1373
|
try {
|
|
1924
1374
|
const tables = await this.lanceClient.tableNames();
|
|
@@ -1944,36 +1394,16 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1944
1394
|
}
|
|
1945
1395
|
}
|
|
1946
1396
|
throw new Error(`IndexName: ${indexName} not found`);
|
|
1947
|
-
} catch (error
|
|
1948
|
-
throw new error.
|
|
1949
|
-
{
|
|
1950
|
-
id: "STORAGE_LANCE_VECTOR_DESCRIBE_INDEX_FAILED",
|
|
1951
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1952
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1953
|
-
details: { indexName }
|
|
1954
|
-
},
|
|
1955
|
-
error$1
|
|
1956
|
-
);
|
|
1397
|
+
} catch (error) {
|
|
1398
|
+
throw new Error(`Failed to describe index: ${error.message}`);
|
|
1957
1399
|
}
|
|
1958
1400
|
}
|
|
1959
1401
|
async deleteIndex({ indexName }) {
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
throw new Error("indexName is required");
|
|
1966
|
-
}
|
|
1967
|
-
} catch (err) {
|
|
1968
|
-
throw new error.MastraError(
|
|
1969
|
-
{
|
|
1970
|
-
id: "STORAGE_LANCE_VECTOR_DELETE_INDEX_FAILED_INVALID_ARGS",
|
|
1971
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1972
|
-
category: error.ErrorCategory.USER,
|
|
1973
|
-
details: { indexName }
|
|
1974
|
-
},
|
|
1975
|
-
err
|
|
1976
|
-
);
|
|
1402
|
+
if (!this.lanceClient) {
|
|
1403
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1404
|
+
}
|
|
1405
|
+
if (!indexName) {
|
|
1406
|
+
throw new Error("indexName is required");
|
|
1977
1407
|
}
|
|
1978
1408
|
try {
|
|
1979
1409
|
const tables = await this.lanceClient.tableNames();
|
|
@@ -1987,16 +1417,8 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
1987
1417
|
}
|
|
1988
1418
|
}
|
|
1989
1419
|
throw new Error(`Index ${indexName} not found`);
|
|
1990
|
-
} catch (error
|
|
1991
|
-
throw new error.
|
|
1992
|
-
{
|
|
1993
|
-
id: "STORAGE_LANCE_VECTOR_DELETE_INDEX_FAILED",
|
|
1994
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1995
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1996
|
-
details: { indexName }
|
|
1997
|
-
},
|
|
1998
|
-
error$1
|
|
1999
|
-
);
|
|
1420
|
+
} catch (error) {
|
|
1421
|
+
throw new Error(`Failed to delete index: ${error.message}`);
|
|
2000
1422
|
}
|
|
2001
1423
|
}
|
|
2002
1424
|
/**
|
|
@@ -2004,73 +1426,33 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2004
1426
|
*/
|
|
2005
1427
|
async deleteAllTables() {
|
|
2006
1428
|
if (!this.lanceClient) {
|
|
2007
|
-
throw new
|
|
2008
|
-
id: "STORAGE_LANCE_VECTOR_DELETE_ALL_TABLES_FAILED_INVALID_ARGS",
|
|
2009
|
-
domain: error.ErrorDomain.STORAGE,
|
|
2010
|
-
category: error.ErrorCategory.USER,
|
|
2011
|
-
details: { methodName: "deleteAllTables" },
|
|
2012
|
-
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance"
|
|
2013
|
-
});
|
|
1429
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
2014
1430
|
}
|
|
2015
1431
|
try {
|
|
2016
1432
|
await this.lanceClient.dropAllTables();
|
|
2017
|
-
} catch (error
|
|
2018
|
-
throw new error.
|
|
2019
|
-
{
|
|
2020
|
-
id: "STORAGE_LANCE_VECTOR_DELETE_ALL_TABLES_FAILED",
|
|
2021
|
-
domain: error.ErrorDomain.STORAGE,
|
|
2022
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
2023
|
-
details: { methodName: "deleteAllTables" }
|
|
2024
|
-
},
|
|
2025
|
-
error$1
|
|
2026
|
-
);
|
|
1433
|
+
} catch (error) {
|
|
1434
|
+
throw new Error(`Failed to delete tables: ${error.message}`);
|
|
2027
1435
|
}
|
|
2028
1436
|
}
|
|
2029
1437
|
async deleteTable(tableName) {
|
|
2030
1438
|
if (!this.lanceClient) {
|
|
2031
|
-
throw new
|
|
2032
|
-
id: "STORAGE_LANCE_VECTOR_DELETE_TABLE_FAILED_INVALID_ARGS",
|
|
2033
|
-
domain: error.ErrorDomain.STORAGE,
|
|
2034
|
-
category: error.ErrorCategory.USER,
|
|
2035
|
-
details: { tableName },
|
|
2036
|
-
text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance"
|
|
2037
|
-
});
|
|
1439
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
2038
1440
|
}
|
|
2039
1441
|
try {
|
|
2040
1442
|
await this.lanceClient.dropTable(tableName);
|
|
2041
|
-
} catch (error
|
|
2042
|
-
throw new error.
|
|
2043
|
-
{
|
|
2044
|
-
id: "STORAGE_LANCE_VECTOR_DELETE_TABLE_FAILED",
|
|
2045
|
-
domain: error.ErrorDomain.STORAGE,
|
|
2046
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
2047
|
-
details: { tableName }
|
|
2048
|
-
},
|
|
2049
|
-
error$1
|
|
2050
|
-
);
|
|
1443
|
+
} catch (error) {
|
|
1444
|
+
throw new Error(`Failed to delete tables: ${error.message}`);
|
|
2051
1445
|
}
|
|
2052
1446
|
}
|
|
2053
1447
|
async updateVector({ indexName, id, update }) {
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
throw new Error("id is required");
|
|
2063
|
-
}
|
|
2064
|
-
} catch (err) {
|
|
2065
|
-
throw new error.MastraError(
|
|
2066
|
-
{
|
|
2067
|
-
id: "STORAGE_LANCE_VECTOR_UPDATE_VECTOR_FAILED_INVALID_ARGS",
|
|
2068
|
-
domain: error.ErrorDomain.STORAGE,
|
|
2069
|
-
category: error.ErrorCategory.USER,
|
|
2070
|
-
details: { indexName, id }
|
|
2071
|
-
},
|
|
2072
|
-
err
|
|
2073
|
-
);
|
|
1448
|
+
if (!this.lanceClient) {
|
|
1449
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1450
|
+
}
|
|
1451
|
+
if (!indexName) {
|
|
1452
|
+
throw new Error("indexName is required");
|
|
1453
|
+
}
|
|
1454
|
+
if (!id) {
|
|
1455
|
+
throw new Error("id is required");
|
|
2074
1456
|
}
|
|
2075
1457
|
try {
|
|
2076
1458
|
const tables = await this.lanceClient.tableNames();
|
|
@@ -2123,39 +1505,19 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2123
1505
|
}
|
|
2124
1506
|
}
|
|
2125
1507
|
throw new Error(`No table found with column/index '${indexName}'`);
|
|
2126
|
-
} catch (error
|
|
2127
|
-
throw new error.
|
|
2128
|
-
{
|
|
2129
|
-
id: "STORAGE_LANCE_VECTOR_UPDATE_VECTOR_FAILED",
|
|
2130
|
-
domain: error.ErrorDomain.STORAGE,
|
|
2131
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
2132
|
-
details: { indexName, id, hasVector: !!update.vector, hasMetadata: !!update.metadata }
|
|
2133
|
-
},
|
|
2134
|
-
error$1
|
|
2135
|
-
);
|
|
1508
|
+
} catch (error) {
|
|
1509
|
+
throw new Error(`Failed to update index: ${error.message}`);
|
|
2136
1510
|
}
|
|
2137
1511
|
}
|
|
2138
1512
|
async deleteVector({ indexName, id }) {
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
throw new Error("id is required");
|
|
2148
|
-
}
|
|
2149
|
-
} catch (err) {
|
|
2150
|
-
throw new error.MastraError(
|
|
2151
|
-
{
|
|
2152
|
-
id: "STORAGE_LANCE_VECTOR_DELETE_VECTOR_FAILED_INVALID_ARGS",
|
|
2153
|
-
domain: error.ErrorDomain.STORAGE,
|
|
2154
|
-
category: error.ErrorCategory.USER,
|
|
2155
|
-
details: { indexName, id }
|
|
2156
|
-
},
|
|
2157
|
-
err
|
|
2158
|
-
);
|
|
1513
|
+
if (!this.lanceClient) {
|
|
1514
|
+
throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
|
|
1515
|
+
}
|
|
1516
|
+
if (!indexName) {
|
|
1517
|
+
throw new Error("indexName is required");
|
|
1518
|
+
}
|
|
1519
|
+
if (!id) {
|
|
1520
|
+
throw new Error("id is required");
|
|
2159
1521
|
}
|
|
2160
1522
|
try {
|
|
2161
1523
|
const tables = await this.lanceClient.tableNames();
|
|
@@ -2176,16 +1538,8 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
|
|
|
2176
1538
|
}
|
|
2177
1539
|
}
|
|
2178
1540
|
throw new Error(`No table found with column/index '${indexName}'`);
|
|
2179
|
-
} catch (error
|
|
2180
|
-
throw new error.
|
|
2181
|
-
{
|
|
2182
|
-
id: "STORAGE_LANCE_VECTOR_DELETE_VECTOR_FAILED",
|
|
2183
|
-
domain: error.ErrorDomain.STORAGE,
|
|
2184
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
2185
|
-
details: { indexName, id }
|
|
2186
|
-
},
|
|
2187
|
-
error$1
|
|
2188
|
-
);
|
|
1541
|
+
} catch (error) {
|
|
1542
|
+
throw new Error(`Failed to delete index: ${error.message}`);
|
|
2189
1543
|
}
|
|
2190
1544
|
}
|
|
2191
1545
|
/**
|