@mastra/lance 0.1.2 → 0.1.3-alpha.1

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/dist/index.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  var lancedb = require('@lancedb/lancedb');
4
4
  var agent = require('@mastra/core/agent');
5
+ var error = require('@mastra/core/error');
5
6
  var storage = require('@mastra/core/storage');
6
7
  var apacheArrow = require('apache-arrow');
7
8
  var vector = require('@mastra/core/vector');
@@ -38,7 +39,16 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
38
39
  instance.lanceClient = await lancedb.connect(uri, options);
39
40
  return instance;
40
41
  } catch (e) {
41
- throw new Error(`Failed to connect to LanceDB: ${e}`);
42
+ throw new error.MastraError(
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
+ );
42
52
  }
43
53
  }
44
54
  /**
@@ -52,11 +62,40 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
52
62
  tableName,
53
63
  schema
54
64
  }) {
65
+ try {
66
+ if (!this.lanceClient) {
67
+ throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
68
+ }
69
+ if (!tableName) {
70
+ throw new Error("tableName is required for createTable.");
71
+ }
72
+ if (!schema) {
73
+ throw new Error("schema is required for createTable.");
74
+ }
75
+ } catch (error$1) {
76
+ throw new error.MastraError(
77
+ {
78
+ id: "STORAGE_LANCE_STORAGE_CREATE_TABLE_INVALID_ARGS",
79
+ domain: error.ErrorDomain.STORAGE,
80
+ category: error.ErrorCategory.USER,
81
+ details: { tableName }
82
+ },
83
+ error$1
84
+ );
85
+ }
55
86
  try {
56
87
  const arrowSchema = this.translateSchema(schema);
57
88
  await this.lanceClient.createEmptyTable(tableName, arrowSchema);
58
- } catch (error) {
59
- throw new Error(`Failed to create table: ${error}`);
89
+ } catch (error$1) {
90
+ throw new error.MastraError(
91
+ {
92
+ id: "STORAGE_LANCE_STORAGE_CREATE_TABLE_FAILED",
93
+ domain: error.ErrorDomain.STORAGE,
94
+ category: error.ErrorCategory.THIRD_PARTY,
95
+ details: { tableName }
96
+ },
97
+ error$1
98
+ );
60
99
  }
61
100
  }
62
101
  translateSchema(schema) {
@@ -99,14 +138,41 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
99
138
  * @param tableName Name of the table to drop
100
139
  */
101
140
  async dropTable(tableName) {
141
+ try {
142
+ if (!this.lanceClient) {
143
+ throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
144
+ }
145
+ if (!tableName) {
146
+ throw new Error("tableName is required for dropTable.");
147
+ }
148
+ } catch (validationError) {
149
+ throw new error.MastraError(
150
+ {
151
+ id: "STORAGE_LANCE_STORAGE_DROP_TABLE_INVALID_ARGS",
152
+ domain: error.ErrorDomain.STORAGE,
153
+ category: error.ErrorCategory.USER,
154
+ text: validationError.message,
155
+ details: { tableName }
156
+ },
157
+ validationError
158
+ );
159
+ }
102
160
  try {
103
161
  await this.lanceClient.dropTable(tableName);
104
- } catch (error) {
105
- if (error.toString().includes("was not found")) {
162
+ } catch (error$1) {
163
+ if (error$1.toString().includes("was not found") || error$1.message?.includes("Table not found")) {
106
164
  this.logger.debug(`Table '${tableName}' does not exist, skipping drop`);
107
165
  return;
108
166
  }
109
- throw new Error(`Failed to drop table: ${error}`);
167
+ throw new error.MastraError(
168
+ {
169
+ id: "STORAGE_LANCE_STORAGE_DROP_TABLE_FAILED",
170
+ domain: error.ErrorDomain.STORAGE,
171
+ category: error.ErrorCategory.THIRD_PARTY,
172
+ details: { tableName }
173
+ },
174
+ error$1
175
+ );
110
176
  }
111
177
  }
112
178
  /**
@@ -115,6 +181,25 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
115
181
  * @returns Table schema
116
182
  */
117
183
  async getTableSchema(tableName) {
184
+ try {
185
+ if (!this.lanceClient) {
186
+ throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
187
+ }
188
+ if (!tableName) {
189
+ throw new Error("tableName is required for getTableSchema.");
190
+ }
191
+ } catch (validationError) {
192
+ throw new error.MastraError(
193
+ {
194
+ id: "STORAGE_LANCE_STORAGE_GET_TABLE_SCHEMA_INVALID_ARGS",
195
+ domain: error.ErrorDomain.STORAGE,
196
+ category: error.ErrorCategory.USER,
197
+ text: validationError.message,
198
+ details: { tableName }
199
+ },
200
+ validationError
201
+ );
202
+ }
118
203
  try {
119
204
  const table = await this.lanceClient.openTable(tableName);
120
205
  const rawSchema = await table.schema();
@@ -126,8 +211,16 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
126
211
  return fields.map((field) => field.name);
127
212
  }
128
213
  };
129
- } catch (error) {
130
- throw new Error(`Failed to get table schema: ${error}`);
214
+ } catch (error$1) {
215
+ throw new error.MastraError(
216
+ {
217
+ id: "STORAGE_LANCE_STORAGE_GET_TABLE_SCHEMA_FAILED",
218
+ domain: error.ErrorDomain.STORAGE,
219
+ category: error.ErrorCategory.THIRD_PARTY,
220
+ details: { tableName }
221
+ },
222
+ error$1
223
+ );
131
224
  }
132
225
  }
133
226
  getDefaultValue(type) {
@@ -158,32 +251,101 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
158
251
  schema,
159
252
  ifNotExists
160
253
  }) {
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"]})`
254
+ try {
255
+ if (!this.lanceClient) {
256
+ throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
257
+ }
258
+ if (!tableName) {
259
+ throw new Error("tableName is required for alterTable.");
260
+ }
261
+ if (!schema) {
262
+ throw new Error("schema is required for alterTable.");
263
+ }
264
+ if (!ifNotExists || ifNotExists.length === 0) {
265
+ this.logger.debug("No columns specified to add in alterTable, skipping.");
266
+ return;
267
+ }
268
+ } catch (validationError) {
269
+ throw new error.MastraError(
270
+ {
271
+ id: "STORAGE_LANCE_STORAGE_ALTER_TABLE_INVALID_ARGS",
272
+ domain: error.ErrorDomain.STORAGE,
273
+ category: error.ErrorCategory.USER,
274
+ text: validationError.message,
275
+ details: { tableName }
276
+ },
277
+ validationError
278
+ );
279
+ }
280
+ try {
281
+ const table = await this.lanceClient.openTable(tableName);
282
+ const currentSchema = await table.schema();
283
+ const existingFields = new Set(currentSchema.fields.map((f) => f.name));
284
+ const typeMap = {
285
+ text: "string",
286
+ integer: "int",
287
+ bigint: "bigint",
288
+ timestamp: "timestamp",
289
+ jsonb: "string",
290
+ uuid: "string"
177
291
  };
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}`);
292
+ const columnsToAdd = ifNotExists.filter((col) => schema[col] && !existingFields.has(col)).map((col) => {
293
+ const colDef = schema[col];
294
+ return {
295
+ name: col,
296
+ valueSql: colDef?.nullable ? `cast(NULL as ${typeMap[colDef.type ?? "text"]})` : `cast(${this.getDefaultValue(colDef?.type ?? "text")} as ${typeMap[colDef?.type ?? "text"]})`
297
+ };
298
+ });
299
+ if (columnsToAdd.length > 0) {
300
+ await table.addColumns(columnsToAdd);
301
+ this.logger?.info?.(`Added columns [${columnsToAdd.map((c) => c.name).join(", ")}] to table ${tableName}`);
302
+ }
303
+ } catch (error$1) {
304
+ throw new error.MastraError(
305
+ {
306
+ id: "STORAGE_LANCE_STORAGE_ALTER_TABLE_FAILED",
307
+ domain: error.ErrorDomain.STORAGE,
308
+ category: error.ErrorCategory.THIRD_PARTY,
309
+ details: { tableName }
310
+ },
311
+ error$1
312
+ );
182
313
  }
183
314
  }
184
315
  async clearTable({ tableName }) {
185
- const table = await this.lanceClient.openTable(tableName);
186
- await table.delete("1=1");
316
+ try {
317
+ if (!this.lanceClient) {
318
+ throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
319
+ }
320
+ if (!tableName) {
321
+ throw new Error("tableName is required for clearTable.");
322
+ }
323
+ } catch (validationError) {
324
+ throw new error.MastraError(
325
+ {
326
+ id: "STORAGE_LANCE_STORAGE_CLEAR_TABLE_INVALID_ARGS",
327
+ domain: error.ErrorDomain.STORAGE,
328
+ category: error.ErrorCategory.USER,
329
+ text: validationError.message,
330
+ details: { tableName }
331
+ },
332
+ validationError
333
+ );
334
+ }
335
+ try {
336
+ const table = await this.lanceClient.openTable(tableName);
337
+ await table.delete("1=1");
338
+ } catch (error$1) {
339
+ throw new error.MastraError(
340
+ {
341
+ id: "STORAGE_LANCE_STORAGE_CLEAR_TABLE_FAILED",
342
+ domain: error.ErrorDomain.STORAGE,
343
+ category: error.ErrorCategory.THIRD_PARTY,
344
+ details: { tableName }
345
+ },
346
+ error$1
347
+ );
348
+ }
187
349
  }
188
350
  /**
189
351
  * 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.
@@ -191,6 +353,28 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
191
353
  * @param record The record to insert.
192
354
  */
193
355
  async insert({ tableName, record }) {
356
+ try {
357
+ if (!this.lanceClient) {
358
+ throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
359
+ }
360
+ if (!tableName) {
361
+ throw new Error("tableName is required for insert.");
362
+ }
363
+ if (!record || Object.keys(record).length === 0) {
364
+ throw new Error("record is required and cannot be empty for insert.");
365
+ }
366
+ } catch (validationError) {
367
+ throw new error.MastraError(
368
+ {
369
+ id: "STORAGE_LANCE_STORAGE_INSERT_INVALID_ARGS",
370
+ domain: error.ErrorDomain.STORAGE,
371
+ category: error.ErrorCategory.USER,
372
+ text: validationError.message,
373
+ details: { tableName }
374
+ },
375
+ validationError
376
+ );
377
+ }
194
378
  try {
195
379
  const table = await this.lanceClient.openTable(tableName);
196
380
  const processedRecord = { ...record };
@@ -201,8 +385,16 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
201
385
  }
202
386
  }
203
387
  await table.add([processedRecord], { mode: "overwrite" });
204
- } catch (error) {
205
- throw new Error(`Failed to insert record: ${error}`);
388
+ } catch (error$1) {
389
+ throw new error.MastraError(
390
+ {
391
+ id: "STORAGE_LANCE_STORAGE_INSERT_FAILED",
392
+ domain: error.ErrorDomain.STORAGE,
393
+ category: error.ErrorCategory.THIRD_PARTY,
394
+ details: { tableName }
395
+ },
396
+ error$1
397
+ );
206
398
  }
207
399
  }
208
400
  /**
@@ -211,6 +403,28 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
211
403
  * @param records The records to insert.
212
404
  */
213
405
  async batchInsert({ tableName, records }) {
406
+ try {
407
+ if (!this.lanceClient) {
408
+ throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
409
+ }
410
+ if (!tableName) {
411
+ throw new Error("tableName is required for batchInsert.");
412
+ }
413
+ if (!records || records.length === 0) {
414
+ throw new Error("records array is required and cannot be empty for batchInsert.");
415
+ }
416
+ } catch (validationError) {
417
+ throw new error.MastraError(
418
+ {
419
+ id: "STORAGE_LANCE_STORAGE_BATCH_INSERT_INVALID_ARGS",
420
+ domain: error.ErrorDomain.STORAGE,
421
+ category: error.ErrorCategory.USER,
422
+ text: validationError.message,
423
+ details: { tableName }
424
+ },
425
+ validationError
426
+ );
427
+ }
214
428
  try {
215
429
  const table = await this.lanceClient.openTable(tableName);
216
430
  const processedRecords = records.map((record) => {
@@ -224,8 +438,16 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
224
438
  return processedRecord;
225
439
  });
226
440
  await table.add(processedRecords, { mode: "overwrite" });
227
- } catch (error) {
228
- throw new Error(`Failed to batch insert records: ${error}`);
441
+ } catch (error$1) {
442
+ throw new error.MastraError(
443
+ {
444
+ id: "STORAGE_LANCE_STORAGE_BATCH_INSERT_FAILED",
445
+ domain: error.ErrorDomain.STORAGE,
446
+ category: error.ErrorCategory.THIRD_PARTY,
447
+ details: { tableName }
448
+ },
449
+ error$1
450
+ );
229
451
  }
230
452
  }
231
453
  /**
@@ -236,6 +458,28 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
236
458
  * @returns The loaded record with proper type conversions, or null if not found
237
459
  */
238
460
  async load({ tableName, keys }) {
461
+ try {
462
+ if (!this.lanceClient) {
463
+ throw new Error("LanceDB client not initialized. Call LanceStorage.create() first.");
464
+ }
465
+ if (!tableName) {
466
+ throw new Error("tableName is required for load.");
467
+ }
468
+ if (!keys || Object.keys(keys).length === 0) {
469
+ throw new Error("keys are required and cannot be empty for load.");
470
+ }
471
+ } catch (validationError) {
472
+ throw new error.MastraError(
473
+ {
474
+ id: "STORAGE_LANCE_STORAGE_LOAD_INVALID_ARGS",
475
+ domain: error.ErrorDomain.STORAGE,
476
+ category: error.ErrorCategory.USER,
477
+ text: validationError.message,
478
+ details: { tableName }
479
+ },
480
+ validationError
481
+ );
482
+ }
239
483
  try {
240
484
  const table = await this.lanceClient.openTable(tableName);
241
485
  const tableSchema = await this.getTableSchema(tableName);
@@ -262,8 +506,17 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
262
506
  return null;
263
507
  }
264
508
  return this.processResultWithTypeConversion(result[0], tableSchema);
265
- } catch (error) {
266
- throw new Error(`Failed to load record: ${error}`);
509
+ } catch (error$1) {
510
+ if (error$1 instanceof error.MastraError) throw error$1;
511
+ throw new error.MastraError(
512
+ {
513
+ id: "STORAGE_LANCE_STORAGE_LOAD_FAILED",
514
+ domain: error.ErrorDomain.STORAGE,
515
+ category: error.ErrorCategory.THIRD_PARTY,
516
+ details: { tableName, keyCount: Object.keys(keys).length, firstKey: Object.keys(keys)[0] ?? "" }
517
+ },
518
+ error$1
519
+ );
267
520
  }
268
521
  }
269
522
  /**
@@ -337,8 +590,15 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
337
590
  getThreadById({ threadId }) {
338
591
  try {
339
592
  return this.load({ tableName: storage.TABLE_THREADS, keys: { id: threadId } });
340
- } catch (error) {
341
- throw new Error(`Failed to get thread by ID: ${error}`);
593
+ } catch (error$1) {
594
+ throw new error.MastraError(
595
+ {
596
+ id: "LANCE_STORE_GET_THREAD_BY_ID_FAILED",
597
+ domain: error.ErrorDomain.STORAGE,
598
+ category: error.ErrorCategory.THIRD_PARTY
599
+ },
600
+ error$1
601
+ );
342
602
  }
343
603
  }
344
604
  async getThreadsByResourceId({ resourceId }) {
@@ -350,8 +610,15 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
350
610
  records,
351
611
  await this.getTableSchema(storage.TABLE_THREADS)
352
612
  );
353
- } catch (error) {
354
- throw new Error(`Failed to get threads by resource ID: ${error}`);
613
+ } catch (error$1) {
614
+ throw new error.MastraError(
615
+ {
616
+ id: "LANCE_STORE_GET_THREADS_BY_RESOURCE_ID_FAILED",
617
+ domain: error.ErrorDomain.STORAGE,
618
+ category: error.ErrorCategory.THIRD_PARTY
619
+ },
620
+ error$1
621
+ );
355
622
  }
356
623
  }
357
624
  /**
@@ -365,8 +632,15 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
365
632
  const table = await this.lanceClient.openTable(storage.TABLE_THREADS);
366
633
  await table.add([record], { mode: "append" });
367
634
  return thread;
368
- } catch (error) {
369
- throw new Error(`Failed to save thread: ${error}`);
635
+ } catch (error$1) {
636
+ throw new error.MastraError(
637
+ {
638
+ id: "LANCE_STORE_SAVE_THREAD_FAILED",
639
+ domain: error.ErrorDomain.STORAGE,
640
+ category: error.ErrorCategory.THIRD_PARTY
641
+ },
642
+ error$1
643
+ );
370
644
  }
371
645
  }
372
646
  async updateThread({
@@ -384,16 +658,30 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
384
658
  records[0],
385
659
  await this.getTableSchema(storage.TABLE_THREADS)
386
660
  );
387
- } catch (error) {
388
- throw new Error(`Failed to update thread: ${error}`);
661
+ } catch (error$1) {
662
+ throw new error.MastraError(
663
+ {
664
+ id: "LANCE_STORE_UPDATE_THREAD_FAILED",
665
+ domain: error.ErrorDomain.STORAGE,
666
+ category: error.ErrorCategory.THIRD_PARTY
667
+ },
668
+ error$1
669
+ );
389
670
  }
390
671
  }
391
672
  async deleteThread({ threadId }) {
392
673
  try {
393
674
  const table = await this.lanceClient.openTable(storage.TABLE_THREADS);
394
675
  await table.delete(`id = '${threadId}'`);
395
- } catch (error) {
396
- throw new Error(`Failed to delete thread: ${error}`);
676
+ } catch (error$1) {
677
+ throw new error.MastraError(
678
+ {
679
+ id: "LANCE_STORE_DELETE_THREAD_FAILED",
680
+ domain: error.ErrorDomain.STORAGE,
681
+ category: error.ErrorCategory.THIRD_PARTY
682
+ },
683
+ error$1
684
+ );
397
685
  }
398
686
  }
399
687
  /**
@@ -455,6 +743,7 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
455
743
  if (threadConfig) {
456
744
  throw new Error("ThreadConfig is not supported by LanceDB storage");
457
745
  }
746
+ const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: Number.MAX_SAFE_INTEGER });
458
747
  const table = await this.lanceClient.openTable(storage.TABLE_MESSAGES);
459
748
  let query = table.query().where(`\`threadId\` = '${threadId}'`);
460
749
  if (selectBy) {
@@ -473,8 +762,8 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
473
762
  if (selectBy?.include && selectBy.include.length > 0) {
474
763
  records = this.processMessagesWithContext(records, selectBy.include);
475
764
  }
476
- if (selectBy?.last !== void 0 && selectBy.last !== false) {
477
- records = records.slice(-selectBy.last);
765
+ if (limit !== Number.MAX_SAFE_INTEGER) {
766
+ records = records.slice(-limit);
478
767
  }
479
768
  const messages = this.processResultWithTypeConversion(records, await this.getTableSchema(storage.TABLE_MESSAGES));
480
769
  const normalized = messages.map((msg) => ({
@@ -490,8 +779,15 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
490
779
  const list = new agent.MessageList({ threadId, resourceId }).add(normalized, "memory");
491
780
  if (format === "v2") return list.get.all.v2();
492
781
  return list.get.all.v1();
493
- } catch (error) {
494
- throw new Error(`Failed to get messages: ${error}`);
782
+ } catch (error$1) {
783
+ throw new error.MastraError(
784
+ {
785
+ id: "LANCE_STORE_GET_MESSAGES_FAILED",
786
+ domain: error.ErrorDomain.STORAGE,
787
+ category: error.ErrorCategory.THIRD_PARTY
788
+ },
789
+ error$1
790
+ );
495
791
  }
496
792
  }
497
793
  async saveMessages(args) {
@@ -513,8 +809,15 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
513
809
  const list = new agent.MessageList().add(messages, "memory");
514
810
  if (format === `v2`) return list.get.all.v2();
515
811
  return list.get.all.v1();
516
- } catch (error) {
517
- throw new Error(`Failed to save messages: ${error}`);
812
+ } catch (error$1) {
813
+ throw new error.MastraError(
814
+ {
815
+ id: "LANCE_STORE_SAVE_MESSAGES_FAILED",
816
+ domain: error.ErrorDomain.STORAGE,
817
+ category: error.ErrorCategory.THIRD_PARTY
818
+ },
819
+ error$1
820
+ );
518
821
  }
519
822
  }
520
823
  async saveTrace({ trace }) {
@@ -530,8 +833,15 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
530
833
  };
531
834
  await table.add([record], { mode: "append" });
532
835
  return trace;
533
- } catch (error) {
534
- throw new Error(`Failed to save trace: ${error}`);
836
+ } catch (error$1) {
837
+ throw new error.MastraError(
838
+ {
839
+ id: "LANCE_STORE_SAVE_TRACE_FAILED",
840
+ domain: error.ErrorDomain.STORAGE,
841
+ category: error.ErrorCategory.THIRD_PARTY
842
+ },
843
+ error$1
844
+ );
535
845
  }
536
846
  }
537
847
  async getTraceById({ traceId }) {
@@ -540,8 +850,15 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
540
850
  const query = table.query().where(`id = '${traceId}'`);
541
851
  const records = await query.toArray();
542
852
  return this.processResultWithTypeConversion(records[0], await this.getTableSchema(storage.TABLE_TRACES));
543
- } catch (error) {
544
- throw new Error(`Failed to get trace by ID: ${error}`);
853
+ } catch (error$1) {
854
+ throw new error.MastraError(
855
+ {
856
+ id: "LANCE_STORE_GET_TRACE_BY_ID_FAILED",
857
+ domain: error.ErrorDomain.STORAGE,
858
+ category: error.ErrorCategory.THIRD_PARTY
859
+ },
860
+ error$1
861
+ );
545
862
  }
546
863
  }
547
864
  async getTraces({
@@ -582,8 +899,16 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
582
899
  createdAt: new Date(record.createdAt)
583
900
  };
584
901
  });
585
- } catch (error) {
586
- throw new Error(`Failed to get traces: ${error}`);
902
+ } catch (error$1) {
903
+ throw new error.MastraError(
904
+ {
905
+ id: "LANCE_STORE_GET_TRACES_FAILED",
906
+ domain: error.ErrorDomain.STORAGE,
907
+ category: error.ErrorCategory.THIRD_PARTY,
908
+ details: { name: name ?? "", scope: scope ?? "" }
909
+ },
910
+ error$1
911
+ );
587
912
  }
588
913
  }
589
914
  async saveEvals({ evals }) {
@@ -603,8 +928,15 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
603
928
  }));
604
929
  await table.add(transformedEvals, { mode: "append" });
605
930
  return evals;
606
- } catch (error) {
607
- throw new Error(`Failed to save evals: ${error}`);
931
+ } catch (error$1) {
932
+ throw new error.MastraError(
933
+ {
934
+ id: "LANCE_STORE_SAVE_EVALS_FAILED",
935
+ domain: error.ErrorDomain.STORAGE,
936
+ category: error.ErrorCategory.THIRD_PARTY
937
+ },
938
+ error$1
939
+ );
608
940
  }
609
941
  }
610
942
  async getEvalsByAgentName(agentName, type) {
@@ -630,8 +962,16 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
630
962
  createdAt: new Date(record.created_at).toString()
631
963
  };
632
964
  });
633
- } catch (error) {
634
- throw new Error(`Failed to get evals by agent name: ${error}`);
965
+ } catch (error$1) {
966
+ throw new error.MastraError(
967
+ {
968
+ id: "LANCE_STORE_GET_EVALS_BY_AGENT_NAME_FAILED",
969
+ domain: error.ErrorDomain.STORAGE,
970
+ category: error.ErrorCategory.THIRD_PARTY,
971
+ details: { agentName }
972
+ },
973
+ error$1
974
+ );
635
975
  }
636
976
  }
637
977
  parseWorkflowRun(row) {
@@ -676,8 +1016,16 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
676
1016
  runs: records.map((record) => this.parseWorkflowRun(record)),
677
1017
  total: records.length
678
1018
  };
679
- } catch (error) {
680
- throw new Error(`Failed to get workflow runs: ${error}`);
1019
+ } catch (error$1) {
1020
+ throw new error.MastraError(
1021
+ {
1022
+ id: "LANCE_STORE_GET_WORKFLOW_RUNS_FAILED",
1023
+ domain: error.ErrorDomain.STORAGE,
1024
+ category: error.ErrorCategory.THIRD_PARTY,
1025
+ details: { namespace: args?.namespace ?? "", workflowName: args?.workflowName ?? "" }
1026
+ },
1027
+ error$1
1028
+ );
681
1029
  }
682
1030
  }
683
1031
  /**
@@ -697,8 +1045,16 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
697
1045
  if (records.length === 0) return null;
698
1046
  const record = records[0];
699
1047
  return this.parseWorkflowRun(record);
700
- } catch (error) {
701
- throw new Error(`Failed to get workflow run by id: ${error}`);
1048
+ } catch (error$1) {
1049
+ throw new error.MastraError(
1050
+ {
1051
+ id: "LANCE_STORE_GET_WORKFLOW_RUN_BY_ID_FAILED",
1052
+ domain: error.ErrorDomain.STORAGE,
1053
+ category: error.ErrorCategory.THIRD_PARTY,
1054
+ details: { runId: args.runId, workflowName: args.workflowName ?? "" }
1055
+ },
1056
+ error$1
1057
+ );
702
1058
  }
703
1059
  }
704
1060
  async persistWorkflowSnapshot({
@@ -727,8 +1083,16 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
727
1083
  updatedAt: now
728
1084
  };
729
1085
  await table.add([record], { mode });
730
- } catch (error) {
731
- throw new Error(`Failed to persist workflow snapshot: ${error}`);
1086
+ } catch (error$1) {
1087
+ throw new error.MastraError(
1088
+ {
1089
+ id: "LANCE_STORE_PERSIST_WORKFLOW_SNAPSHOT_FAILED",
1090
+ domain: error.ErrorDomain.STORAGE,
1091
+ category: error.ErrorCategory.THIRD_PARTY,
1092
+ details: { workflowName, runId }
1093
+ },
1094
+ error$1
1095
+ );
732
1096
  }
733
1097
  }
734
1098
  async loadWorkflowSnapshot({
@@ -740,18 +1104,51 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
740
1104
  const query = table.query().where(`workflow_name = '${workflowName}' AND run_id = '${runId}'`);
741
1105
  const records = await query.toArray();
742
1106
  return records.length > 0 ? JSON.parse(records[0].snapshot) : null;
743
- } catch (error) {
744
- throw new Error(`Failed to load workflow snapshot: ${error}`);
1107
+ } catch (error$1) {
1108
+ throw new error.MastraError(
1109
+ {
1110
+ id: "LANCE_STORE_LOAD_WORKFLOW_SNAPSHOT_FAILED",
1111
+ domain: error.ErrorDomain.STORAGE,
1112
+ category: error.ErrorCategory.THIRD_PARTY,
1113
+ details: { workflowName, runId }
1114
+ },
1115
+ error$1
1116
+ );
745
1117
  }
746
1118
  }
747
1119
  async getTracesPaginated(_args) {
748
- throw new Error("Method not implemented.");
1120
+ throw new error.MastraError(
1121
+ {
1122
+ id: "LANCE_STORE_GET_TRACES_PAGINATED_FAILED",
1123
+ domain: error.ErrorDomain.STORAGE,
1124
+ category: error.ErrorCategory.THIRD_PARTY
1125
+ },
1126
+ "Method not implemented."
1127
+ );
749
1128
  }
750
1129
  async getThreadsByResourceIdPaginated(_args) {
751
- throw new Error("Method not implemented.");
1130
+ throw new error.MastraError(
1131
+ {
1132
+ id: "LANCE_STORE_GET_THREADS_BY_RESOURCE_ID_PAGINATED_FAILED",
1133
+ domain: error.ErrorDomain.STORAGE,
1134
+ category: error.ErrorCategory.THIRD_PARTY
1135
+ },
1136
+ "Method not implemented."
1137
+ );
752
1138
  }
753
1139
  async getMessagesPaginated(_args) {
754
- throw new Error("Method not implemented.");
1140
+ throw new error.MastraError(
1141
+ {
1142
+ id: "LANCE_STORE_GET_MESSAGES_PAGINATED_FAILED",
1143
+ domain: error.ErrorDomain.STORAGE,
1144
+ category: error.ErrorCategory.THIRD_PARTY
1145
+ },
1146
+ "Method not implemented."
1147
+ );
1148
+ }
1149
+ async updateMessages(_args) {
1150
+ this.logger.error("updateMessages is not yet implemented in LanceStore");
1151
+ throw new Error("Method not implemented");
755
1152
  }
756
1153
  };
757
1154
  var LanceFilterTranslator = class extends filter.BaseFilterTranslator {
@@ -1105,7 +1502,15 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1105
1502
  instance.lanceClient = await lancedb.connect(uri, options);
1106
1503
  return instance;
1107
1504
  } catch (e) {
1108
- throw new Error(`Failed to connect to LanceDB: ${e}`);
1505
+ throw new error.MastraError(
1506
+ {
1507
+ id: "STORAGE_LANCE_VECTOR_CONNECT_FAILED",
1508
+ domain: error.ErrorDomain.STORAGE,
1509
+ category: error.ErrorCategory.THIRD_PARTY,
1510
+ details: { uri }
1511
+ },
1512
+ e
1513
+ );
1109
1514
  }
1110
1515
  }
1111
1516
  /**
@@ -1129,14 +1534,27 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1129
1534
  columns = [],
1130
1535
  includeAllColumns = false
1131
1536
  }) {
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");
1537
+ try {
1538
+ if (!this.lanceClient) {
1539
+ throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
1540
+ }
1541
+ if (!tableName) {
1542
+ throw new Error("tableName is required");
1543
+ }
1544
+ if (!queryVector) {
1545
+ throw new Error("queryVector is required");
1546
+ }
1547
+ } catch (error$1) {
1548
+ throw new error.MastraError(
1549
+ {
1550
+ id: "STORAGE_LANCE_VECTOR_QUERY_FAILED_INVALID_ARGS",
1551
+ domain: error.ErrorDomain.STORAGE,
1552
+ category: error.ErrorCategory.USER,
1553
+ text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
1554
+ details: { tableName }
1555
+ },
1556
+ error$1
1557
+ );
1140
1558
  }
1141
1559
  try {
1142
1560
  const table = await this.lanceClient.openTable(tableName);
@@ -1174,8 +1592,16 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1174
1592
  score: result._distance
1175
1593
  };
1176
1594
  });
1177
- } catch (error) {
1178
- throw new Error(`Failed to query vectors: ${error.message}`);
1595
+ } catch (error$1) {
1596
+ throw new error.MastraError(
1597
+ {
1598
+ id: "STORAGE_LANCE_VECTOR_QUERY_FAILED",
1599
+ domain: error.ErrorDomain.STORAGE,
1600
+ category: error.ErrorCategory.THIRD_PARTY,
1601
+ details: { tableName, includeVector, columnsCount: columns?.length, includeAllColumns }
1602
+ },
1603
+ error$1
1604
+ );
1179
1605
  }
1180
1606
  }
1181
1607
  filterTranslator(filter) {
@@ -1208,14 +1634,27 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1208
1634
  return translator.translate(prefixedFilter);
1209
1635
  }
1210
1636
  async upsert({ tableName, vectors, metadata = [], ids = [] }) {
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");
1637
+ try {
1638
+ if (!this.lanceClient) {
1639
+ throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
1640
+ }
1641
+ if (!tableName) {
1642
+ throw new Error("tableName is required");
1643
+ }
1644
+ if (!vectors || !Array.isArray(vectors) || vectors.length === 0) {
1645
+ throw new Error("vectors array is required and must not be empty");
1646
+ }
1647
+ } catch (error$1) {
1648
+ throw new error.MastraError(
1649
+ {
1650
+ id: "STORAGE_LANCE_VECTOR_UPSERT_FAILED_INVALID_ARGS",
1651
+ domain: error.ErrorDomain.STORAGE,
1652
+ category: error.ErrorCategory.USER,
1653
+ text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
1654
+ details: { tableName }
1655
+ },
1656
+ error$1
1657
+ );
1219
1658
  }
1220
1659
  try {
1221
1660
  const tables = await this.lanceClient.tableNames();
@@ -1241,8 +1680,16 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1241
1680
  });
1242
1681
  await table.add(data, { mode: "overwrite" });
1243
1682
  return vectorIds;
1244
- } catch (error) {
1245
- throw new Error(`Failed to upsert vectors: ${error.message}`);
1683
+ } catch (error$1) {
1684
+ throw new error.MastraError(
1685
+ {
1686
+ id: "STORAGE_LANCE_VECTOR_UPSERT_FAILED",
1687
+ domain: error.ErrorDomain.STORAGE,
1688
+ category: error.ErrorCategory.THIRD_PARTY,
1689
+ details: { tableName, vectorCount: vectors.length, metadataCount: metadata.length, idsCount: ids.length }
1690
+ },
1691
+ error$1
1692
+ );
1246
1693
  }
1247
1694
  }
1248
1695
  /**
@@ -1262,29 +1709,78 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1262
1709
  }
1263
1710
  async createTable(tableName, data, options) {
1264
1711
  if (!this.lanceClient) {
1265
- throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
1712
+ throw new error.MastraError({
1713
+ id: "STORAGE_LANCE_VECTOR_CREATE_TABLE_FAILED_INVALID_ARGS",
1714
+ domain: error.ErrorDomain.STORAGE,
1715
+ category: error.ErrorCategory.USER,
1716
+ text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
1717
+ details: { tableName }
1718
+ });
1719
+ }
1720
+ if (Array.isArray(data)) {
1721
+ data = data.map((record) => this.flattenObject(record));
1266
1722
  }
1267
1723
  try {
1268
- if (Array.isArray(data)) {
1269
- data = data.map((record) => this.flattenObject(record));
1270
- }
1271
1724
  return await this.lanceClient.createTable(tableName, data, options);
1272
- } catch (error) {
1273
- throw new Error(`Failed to create table: ${error.message}`);
1725
+ } catch (error$1) {
1726
+ throw new error.MastraError(
1727
+ {
1728
+ id: "STORAGE_LANCE_VECTOR_CREATE_TABLE_FAILED",
1729
+ domain: error.ErrorDomain.STORAGE,
1730
+ category: error.ErrorCategory.THIRD_PARTY,
1731
+ details: { tableName }
1732
+ },
1733
+ error$1
1734
+ );
1274
1735
  }
1275
1736
  }
1276
1737
  async listTables() {
1277
1738
  if (!this.lanceClient) {
1278
- throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
1739
+ throw new error.MastraError({
1740
+ id: "STORAGE_LANCE_VECTOR_LIST_TABLES_FAILED_INVALID_ARGS",
1741
+ domain: error.ErrorDomain.STORAGE,
1742
+ category: error.ErrorCategory.USER,
1743
+ text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
1744
+ details: { methodName: "listTables" }
1745
+ });
1746
+ }
1747
+ try {
1748
+ return await this.lanceClient.tableNames();
1749
+ } catch (error$1) {
1750
+ throw new error.MastraError(
1751
+ {
1752
+ id: "STORAGE_LANCE_VECTOR_LIST_TABLES_FAILED",
1753
+ domain: error.ErrorDomain.STORAGE,
1754
+ category: error.ErrorCategory.THIRD_PARTY
1755
+ },
1756
+ error$1
1757
+ );
1279
1758
  }
1280
- return await this.lanceClient.tableNames();
1281
1759
  }
1282
1760
  async getTableSchema(tableName) {
1283
1761
  if (!this.lanceClient) {
1284
- throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
1762
+ throw new error.MastraError({
1763
+ id: "STORAGE_LANCE_VECTOR_GET_TABLE_SCHEMA_FAILED_INVALID_ARGS",
1764
+ domain: error.ErrorDomain.STORAGE,
1765
+ category: error.ErrorCategory.USER,
1766
+ text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
1767
+ details: { tableName }
1768
+ });
1769
+ }
1770
+ try {
1771
+ const table = await this.lanceClient.openTable(tableName);
1772
+ return await table.schema();
1773
+ } catch (error$1) {
1774
+ throw new error.MastraError(
1775
+ {
1776
+ id: "STORAGE_LANCE_VECTOR_GET_TABLE_SCHEMA_FAILED",
1777
+ domain: error.ErrorDomain.STORAGE,
1778
+ category: error.ErrorCategory.THIRD_PARTY,
1779
+ details: { tableName }
1780
+ },
1781
+ error$1
1782
+ );
1285
1783
  }
1286
- const table = await this.lanceClient.openTable(tableName);
1287
- return await table.schema();
1288
1784
  }
1289
1785
  /**
1290
1786
  * indexName is actually a column name in a table in lanceDB
@@ -1296,10 +1792,10 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1296
1792
  metric = "cosine",
1297
1793
  indexConfig = {}
1298
1794
  }) {
1299
- if (!this.lanceClient) {
1300
- throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
1301
- }
1302
1795
  try {
1796
+ if (!this.lanceClient) {
1797
+ throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
1798
+ }
1303
1799
  if (!tableName) {
1304
1800
  throw new Error("tableName is required");
1305
1801
  }
@@ -1309,6 +1805,18 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1309
1805
  if (typeof dimension !== "number" || dimension <= 0) {
1310
1806
  throw new Error("dimension must be a positive number");
1311
1807
  }
1808
+ } catch (err) {
1809
+ throw new error.MastraError(
1810
+ {
1811
+ id: "STORAGE_LANCE_VECTOR_CREATE_INDEX_FAILED_INVALID_ARGS",
1812
+ domain: error.ErrorDomain.STORAGE,
1813
+ category: error.ErrorCategory.USER,
1814
+ details: { tableName: tableName || "", indexName, dimension, metric }
1815
+ },
1816
+ err
1817
+ );
1818
+ }
1819
+ try {
1312
1820
  const tables = await this.lanceClient.tableNames();
1313
1821
  if (!tables.includes(tableName)) {
1314
1822
  throw new Error(
@@ -1342,13 +1850,27 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1342
1850
  })
1343
1851
  });
1344
1852
  }
1345
- } catch (error) {
1346
- throw new Error(`Failed to create index: ${error.message}`);
1853
+ } catch (error$1) {
1854
+ throw new error.MastraError(
1855
+ {
1856
+ id: "STORAGE_LANCE_VECTOR_CREATE_INDEX_FAILED",
1857
+ domain: error.ErrorDomain.STORAGE,
1858
+ category: error.ErrorCategory.THIRD_PARTY,
1859
+ details: { tableName: tableName || "", indexName, dimension }
1860
+ },
1861
+ error$1
1862
+ );
1347
1863
  }
1348
1864
  }
1349
1865
  async listIndexes() {
1350
1866
  if (!this.lanceClient) {
1351
- throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
1867
+ throw new error.MastraError({
1868
+ id: "STORAGE_LANCE_VECTOR_LIST_INDEXES_FAILED_INVALID_ARGS",
1869
+ domain: error.ErrorDomain.STORAGE,
1870
+ category: error.ErrorCategory.USER,
1871
+ text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance",
1872
+ details: { methodName: "listIndexes" }
1873
+ });
1352
1874
  }
1353
1875
  try {
1354
1876
  const tables = await this.lanceClient.tableNames();
@@ -1359,16 +1881,35 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1359
1881
  allIndices.push(...tableIndices.map((index) => index.name));
1360
1882
  }
1361
1883
  return allIndices;
1362
- } catch (error) {
1363
- throw new Error(`Failed to list indexes: ${error.message}`);
1884
+ } catch (error$1) {
1885
+ throw new error.MastraError(
1886
+ {
1887
+ id: "STORAGE_LANCE_VECTOR_LIST_INDEXES_FAILED",
1888
+ domain: error.ErrorDomain.STORAGE,
1889
+ category: error.ErrorCategory.THIRD_PARTY
1890
+ },
1891
+ error$1
1892
+ );
1364
1893
  }
1365
1894
  }
1366
1895
  async describeIndex({ indexName }) {
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");
1896
+ try {
1897
+ if (!this.lanceClient) {
1898
+ throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
1899
+ }
1900
+ if (!indexName) {
1901
+ throw new Error("indexName is required");
1902
+ }
1903
+ } catch (err) {
1904
+ throw new error.MastraError(
1905
+ {
1906
+ id: "STORAGE_LANCE_VECTOR_DESCRIBE_INDEX_FAILED_INVALID_ARGS",
1907
+ domain: error.ErrorDomain.STORAGE,
1908
+ category: error.ErrorCategory.USER,
1909
+ details: { indexName }
1910
+ },
1911
+ err
1912
+ );
1372
1913
  }
1373
1914
  try {
1374
1915
  const tables = await this.lanceClient.tableNames();
@@ -1394,16 +1935,36 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1394
1935
  }
1395
1936
  }
1396
1937
  throw new Error(`IndexName: ${indexName} not found`);
1397
- } catch (error) {
1398
- throw new Error(`Failed to describe index: ${error.message}`);
1938
+ } catch (error$1) {
1939
+ throw new error.MastraError(
1940
+ {
1941
+ id: "STORAGE_LANCE_VECTOR_DESCRIBE_INDEX_FAILED",
1942
+ domain: error.ErrorDomain.STORAGE,
1943
+ category: error.ErrorCategory.THIRD_PARTY,
1944
+ details: { indexName }
1945
+ },
1946
+ error$1
1947
+ );
1399
1948
  }
1400
1949
  }
1401
1950
  async deleteIndex({ indexName }) {
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");
1951
+ try {
1952
+ if (!this.lanceClient) {
1953
+ throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
1954
+ }
1955
+ if (!indexName) {
1956
+ throw new Error("indexName is required");
1957
+ }
1958
+ } catch (err) {
1959
+ throw new error.MastraError(
1960
+ {
1961
+ id: "STORAGE_LANCE_VECTOR_DELETE_INDEX_FAILED_INVALID_ARGS",
1962
+ domain: error.ErrorDomain.STORAGE,
1963
+ category: error.ErrorCategory.USER,
1964
+ details: { indexName }
1965
+ },
1966
+ err
1967
+ );
1407
1968
  }
1408
1969
  try {
1409
1970
  const tables = await this.lanceClient.tableNames();
@@ -1417,8 +1978,16 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1417
1978
  }
1418
1979
  }
1419
1980
  throw new Error(`Index ${indexName} not found`);
1420
- } catch (error) {
1421
- throw new Error(`Failed to delete index: ${error.message}`);
1981
+ } catch (error$1) {
1982
+ throw new error.MastraError(
1983
+ {
1984
+ id: "STORAGE_LANCE_VECTOR_DELETE_INDEX_FAILED",
1985
+ domain: error.ErrorDomain.STORAGE,
1986
+ category: error.ErrorCategory.THIRD_PARTY,
1987
+ details: { indexName }
1988
+ },
1989
+ error$1
1990
+ );
1422
1991
  }
1423
1992
  }
1424
1993
  /**
@@ -1426,33 +1995,73 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1426
1995
  */
1427
1996
  async deleteAllTables() {
1428
1997
  if (!this.lanceClient) {
1429
- throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
1998
+ throw new error.MastraError({
1999
+ id: "STORAGE_LANCE_VECTOR_DELETE_ALL_TABLES_FAILED_INVALID_ARGS",
2000
+ domain: error.ErrorDomain.STORAGE,
2001
+ category: error.ErrorCategory.USER,
2002
+ details: { methodName: "deleteAllTables" },
2003
+ text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance"
2004
+ });
1430
2005
  }
1431
2006
  try {
1432
2007
  await this.lanceClient.dropAllTables();
1433
- } catch (error) {
1434
- throw new Error(`Failed to delete tables: ${error.message}`);
2008
+ } catch (error$1) {
2009
+ throw new error.MastraError(
2010
+ {
2011
+ id: "STORAGE_LANCE_VECTOR_DELETE_ALL_TABLES_FAILED",
2012
+ domain: error.ErrorDomain.STORAGE,
2013
+ category: error.ErrorCategory.THIRD_PARTY,
2014
+ details: { methodName: "deleteAllTables" }
2015
+ },
2016
+ error$1
2017
+ );
1435
2018
  }
1436
2019
  }
1437
2020
  async deleteTable(tableName) {
1438
2021
  if (!this.lanceClient) {
1439
- throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
2022
+ throw new error.MastraError({
2023
+ id: "STORAGE_LANCE_VECTOR_DELETE_TABLE_FAILED_INVALID_ARGS",
2024
+ domain: error.ErrorDomain.STORAGE,
2025
+ category: error.ErrorCategory.USER,
2026
+ details: { tableName },
2027
+ text: "LanceDB client not initialized. Use LanceVectorStore.create() to create an instance"
2028
+ });
1440
2029
  }
1441
2030
  try {
1442
2031
  await this.lanceClient.dropTable(tableName);
1443
- } catch (error) {
1444
- throw new Error(`Failed to delete tables: ${error.message}`);
2032
+ } catch (error$1) {
2033
+ throw new error.MastraError(
2034
+ {
2035
+ id: "STORAGE_LANCE_VECTOR_DELETE_TABLE_FAILED",
2036
+ domain: error.ErrorDomain.STORAGE,
2037
+ category: error.ErrorCategory.THIRD_PARTY,
2038
+ details: { tableName }
2039
+ },
2040
+ error$1
2041
+ );
1445
2042
  }
1446
2043
  }
1447
2044
  async updateVector({ indexName, id, update }) {
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");
2045
+ try {
2046
+ if (!this.lanceClient) {
2047
+ throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
2048
+ }
2049
+ if (!indexName) {
2050
+ throw new Error("indexName is required");
2051
+ }
2052
+ if (!id) {
2053
+ throw new Error("id is required");
2054
+ }
2055
+ } catch (err) {
2056
+ throw new error.MastraError(
2057
+ {
2058
+ id: "STORAGE_LANCE_VECTOR_UPDATE_VECTOR_FAILED_INVALID_ARGS",
2059
+ domain: error.ErrorDomain.STORAGE,
2060
+ category: error.ErrorCategory.USER,
2061
+ details: { indexName, id }
2062
+ },
2063
+ err
2064
+ );
1456
2065
  }
1457
2066
  try {
1458
2067
  const tables = await this.lanceClient.tableNames();
@@ -1505,19 +2114,39 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1505
2114
  }
1506
2115
  }
1507
2116
  throw new Error(`No table found with column/index '${indexName}'`);
1508
- } catch (error) {
1509
- throw new Error(`Failed to update index: ${error.message}`);
2117
+ } catch (error$1) {
2118
+ throw new error.MastraError(
2119
+ {
2120
+ id: "STORAGE_LANCE_VECTOR_UPDATE_VECTOR_FAILED",
2121
+ domain: error.ErrorDomain.STORAGE,
2122
+ category: error.ErrorCategory.THIRD_PARTY,
2123
+ details: { indexName, id, hasVector: !!update.vector, hasMetadata: !!update.metadata }
2124
+ },
2125
+ error$1
2126
+ );
1510
2127
  }
1511
2128
  }
1512
2129
  async deleteVector({ indexName, id }) {
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");
2130
+ try {
2131
+ if (!this.lanceClient) {
2132
+ throw new Error("LanceDB client not initialized. Use LanceVectorStore.create() to create an instance");
2133
+ }
2134
+ if (!indexName) {
2135
+ throw new Error("indexName is required");
2136
+ }
2137
+ if (!id) {
2138
+ throw new Error("id is required");
2139
+ }
2140
+ } catch (err) {
2141
+ throw new error.MastraError(
2142
+ {
2143
+ id: "STORAGE_LANCE_VECTOR_DELETE_VECTOR_FAILED_INVALID_ARGS",
2144
+ domain: error.ErrorDomain.STORAGE,
2145
+ category: error.ErrorCategory.USER,
2146
+ details: { indexName, id }
2147
+ },
2148
+ err
2149
+ );
1521
2150
  }
1522
2151
  try {
1523
2152
  const tables = await this.lanceClient.tableNames();
@@ -1538,8 +2167,16 @@ var LanceVectorStore = class _LanceVectorStore extends vector.MastraVector {
1538
2167
  }
1539
2168
  }
1540
2169
  throw new Error(`No table found with column/index '${indexName}'`);
1541
- } catch (error) {
1542
- throw new Error(`Failed to delete index: ${error.message}`);
2170
+ } catch (error$1) {
2171
+ throw new error.MastraError(
2172
+ {
2173
+ id: "STORAGE_LANCE_VECTOR_DELETE_VECTOR_FAILED",
2174
+ domain: error.ErrorDomain.STORAGE,
2175
+ category: error.ErrorCategory.THIRD_PARTY,
2176
+ details: { indexName, id }
2177
+ },
2178
+ error$1
2179
+ );
1543
2180
  }
1544
2181
  }
1545
2182
  /**