@mastra/clickhouse 0.11.1-alpha.0 → 0.11.1-alpha.2

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 client = require('@clickhouse/client');
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
 
7
8
  // src/storage/index.ts
@@ -66,7 +67,12 @@ var ClickhouseStore = class extends storage.MastraStorage {
66
67
  const resultValue = JSON.parse(row.result);
67
68
  const testInfoValue = row.test_info ? JSON.parse(row.test_info) : void 0;
68
69
  if (!resultValue || typeof resultValue !== "object" || !("score" in resultValue)) {
69
- throw new Error(`Invalid MetricResult format: ${JSON.stringify(resultValue)}`);
70
+ throw new error.MastraError({
71
+ id: "CLICKHOUSE_STORAGE_INVALID_METRIC_FORMAT",
72
+ text: `Invalid MetricResult format: ${JSON.stringify(resultValue)}`,
73
+ domain: error.ErrorDomain.STORAGE,
74
+ category: error.ErrorCategory.USER
75
+ });
70
76
  }
71
77
  return {
72
78
  input: row.input,
@@ -81,6 +87,18 @@ var ClickhouseStore = class extends storage.MastraStorage {
81
87
  createdAt: row.created_at
82
88
  };
83
89
  }
90
+ escape(value) {
91
+ if (typeof value === "string") {
92
+ return `'${value.replace(/'/g, "''")}'`;
93
+ }
94
+ if (value instanceof Date) {
95
+ return `'${value.toISOString()}'`;
96
+ }
97
+ if (value === null || value === void 0) {
98
+ return "NULL";
99
+ }
100
+ return value.toString();
101
+ }
84
102
  async getEvalsByAgentName(agentName, type) {
85
103
  try {
86
104
  const baseQuery = `SELECT *, toDateTime64(createdAt, 3) as createdAt FROM ${storage.TABLE_EVALS} WHERE agent_name = {var_agent_name:String}`;
@@ -100,12 +118,19 @@ var ClickhouseStore = class extends storage.MastraStorage {
100
118
  }
101
119
  const rows = await result.json();
102
120
  return rows.data.map((row) => this.transformEvalRow(row));
103
- } catch (error) {
104
- if (error instanceof Error && error.message.includes("no such table")) {
121
+ } catch (error$1) {
122
+ if (error$1?.message?.includes("no such table") || error$1?.message?.includes("does not exist")) {
105
123
  return [];
106
124
  }
107
- this.logger.error("Failed to get evals for the specified agent: " + error?.message);
108
- throw error;
125
+ throw new error.MastraError(
126
+ {
127
+ id: "CLICKHOUSE_STORAGE_GET_EVALS_BY_AGENT_FAILED",
128
+ domain: error.ErrorDomain.STORAGE,
129
+ category: error.ErrorCategory.THIRD_PARTY,
130
+ details: { agentName, type: type ?? null }
131
+ },
132
+ error$1
133
+ );
109
134
  }
110
135
  }
111
136
  async batchInsert({ tableName, records }) {
@@ -128,9 +153,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
128
153
  output_format_json_quote_64bit_integers: 0
129
154
  }
130
155
  });
131
- } catch (error) {
132
- console.error(`Error inserting into ${tableName}:`, error);
133
- throw error;
156
+ } catch (error$1) {
157
+ throw new error.MastraError(
158
+ {
159
+ id: "CLICKHOUSE_STORAGE_BATCH_INSERT_FAILED",
160
+ domain: error.ErrorDomain.STORAGE,
161
+ category: error.ErrorCategory.THIRD_PARTY,
162
+ details: { tableName }
163
+ },
164
+ error$1
165
+ );
134
166
  }
135
167
  }
136
168
  async getTraces({
@@ -178,48 +210,96 @@ var ClickhouseStore = class extends storage.MastraStorage {
178
210
  args.var_to_date = toDate.getTime() / 1e3;
179
211
  }
180
212
  const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
181
- const result = await this.db.query({
182
- query: `SELECT *, toDateTime64(createdAt, 3) as createdAt FROM ${storage.TABLE_TRACES} ${whereClause} ORDER BY "createdAt" DESC LIMIT ${limit} OFFSET ${offset}`,
183
- query_params: args,
184
- clickhouse_settings: {
185
- // Allows to insert serialized JS Dates (such as '2023-12-06T10:54:48.000Z')
186
- date_time_input_format: "best_effort",
187
- date_time_output_format: "iso",
188
- use_client_time_zone: 1,
189
- output_format_json_quote_64bit_integers: 0
213
+ try {
214
+ const result = await this.db.query({
215
+ query: `SELECT *, toDateTime64(createdAt, 3) as createdAt FROM ${storage.TABLE_TRACES} ${whereClause} ORDER BY "createdAt" DESC LIMIT ${limit} OFFSET ${offset}`,
216
+ query_params: args,
217
+ clickhouse_settings: {
218
+ // Allows to insert serialized JS Dates (such as '2023-12-06T10:54:48.000Z')
219
+ date_time_input_format: "best_effort",
220
+ date_time_output_format: "iso",
221
+ use_client_time_zone: 1,
222
+ output_format_json_quote_64bit_integers: 0
223
+ }
224
+ });
225
+ if (!result) {
226
+ return [];
190
227
  }
191
- });
192
- if (!result) {
193
- return [];
194
- }
195
- const resp = await result.json();
196
- const rows = resp.data;
197
- return rows.map((row) => ({
198
- id: row.id,
199
- parentSpanId: row.parentSpanId,
200
- traceId: row.traceId,
201
- name: row.name,
202
- scope: row.scope,
203
- kind: row.kind,
204
- status: safelyParseJSON(row.status),
205
- events: safelyParseJSON(row.events),
206
- links: safelyParseJSON(row.links),
207
- attributes: safelyParseJSON(row.attributes),
208
- startTime: row.startTime,
209
- endTime: row.endTime,
210
- other: safelyParseJSON(row.other),
211
- createdAt: row.createdAt
212
- }));
228
+ const resp = await result.json();
229
+ const rows = resp.data;
230
+ return rows.map((row) => ({
231
+ id: row.id,
232
+ parentSpanId: row.parentSpanId,
233
+ traceId: row.traceId,
234
+ name: row.name,
235
+ scope: row.scope,
236
+ kind: row.kind,
237
+ status: safelyParseJSON(row.status),
238
+ events: safelyParseJSON(row.events),
239
+ links: safelyParseJSON(row.links),
240
+ attributes: safelyParseJSON(row.attributes),
241
+ startTime: row.startTime,
242
+ endTime: row.endTime,
243
+ other: safelyParseJSON(row.other),
244
+ createdAt: row.createdAt
245
+ }));
246
+ } catch (error$1) {
247
+ if (error$1?.message?.includes("no such table") || error$1?.message?.includes("does not exist")) {
248
+ return [];
249
+ }
250
+ throw new error.MastraError(
251
+ {
252
+ id: "CLICKHOUSE_STORAGE_GET_TRACES_FAILED",
253
+ domain: error.ErrorDomain.STORAGE,
254
+ category: error.ErrorCategory.THIRD_PARTY,
255
+ details: {
256
+ name: name ?? null,
257
+ scope: scope ?? null,
258
+ page,
259
+ perPage,
260
+ attributes: attributes ? JSON.stringify(attributes) : null,
261
+ filters: filters ? JSON.stringify(filters) : null,
262
+ fromDate: fromDate?.toISOString() ?? null,
263
+ toDate: toDate?.toISOString() ?? null
264
+ }
265
+ },
266
+ error$1
267
+ );
268
+ }
213
269
  }
214
270
  async optimizeTable({ tableName }) {
215
- await this.db.command({
216
- query: `OPTIMIZE TABLE ${tableName} FINAL`
217
- });
271
+ try {
272
+ await this.db.command({
273
+ query: `OPTIMIZE TABLE ${tableName} FINAL`
274
+ });
275
+ } catch (error$1) {
276
+ throw new error.MastraError(
277
+ {
278
+ id: "CLICKHOUSE_STORAGE_OPTIMIZE_TABLE_FAILED",
279
+ domain: error.ErrorDomain.STORAGE,
280
+ category: error.ErrorCategory.THIRD_PARTY,
281
+ details: { tableName }
282
+ },
283
+ error$1
284
+ );
285
+ }
218
286
  }
219
287
  async materializeTtl({ tableName }) {
220
- await this.db.command({
221
- query: `ALTER TABLE ${tableName} MATERIALIZE TTL;`
222
- });
288
+ try {
289
+ await this.db.command({
290
+ query: `ALTER TABLE ${tableName} MATERIALIZE TTL;`
291
+ });
292
+ } catch (error$1) {
293
+ throw new error.MastraError(
294
+ {
295
+ id: "CLICKHOUSE_STORAGE_MATERIALIZE_TTL_FAILED",
296
+ domain: error.ErrorDomain.STORAGE,
297
+ category: error.ErrorCategory.THIRD_PARTY,
298
+ details: { tableName }
299
+ },
300
+ error$1
301
+ );
302
+ }
223
303
  }
224
304
  async createTable({
225
305
  tableName,
@@ -262,9 +342,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
262
342
  output_format_json_quote_64bit_integers: 0
263
343
  }
264
344
  });
265
- } catch (error) {
266
- console.error(`Error creating table ${tableName}:`, error);
267
- throw error;
345
+ } catch (error$1) {
346
+ throw new error.MastraError(
347
+ {
348
+ id: "CLICKHOUSE_STORAGE_CREATE_TABLE_FAILED",
349
+ domain: error.ErrorDomain.STORAGE,
350
+ category: error.ErrorCategory.THIRD_PARTY,
351
+ details: { tableName }
352
+ },
353
+ error$1
354
+ );
268
355
  }
269
356
  }
270
357
  getSqlType(type) {
@@ -315,11 +402,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
315
402
  this.logger?.debug?.(`Added column ${columnName} to table ${tableName}`);
316
403
  }
317
404
  }
318
- } catch (error) {
319
- this.logger?.error?.(
320
- `Error altering table ${tableName}: ${error instanceof Error ? error.message : String(error)}`
405
+ } catch (error$1) {
406
+ throw new error.MastraError(
407
+ {
408
+ id: "CLICKHOUSE_STORAGE_ALTER_TABLE_FAILED",
409
+ domain: error.ErrorDomain.STORAGE,
410
+ category: error.ErrorCategory.THIRD_PARTY,
411
+ details: { tableName }
412
+ },
413
+ error$1
321
414
  );
322
- throw new Error(`Failed to alter table ${tableName}: ${error}`);
323
415
  }
324
416
  }
325
417
  async clearTable({ tableName }) {
@@ -334,9 +426,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
334
426
  output_format_json_quote_64bit_integers: 0
335
427
  }
336
428
  });
337
- } catch (error) {
338
- console.error(`Error clearing table ${tableName}:`, error);
339
- throw error;
429
+ } catch (error$1) {
430
+ throw new error.MastraError(
431
+ {
432
+ id: "CLICKHOUSE_STORAGE_CLEAR_TABLE_FAILED",
433
+ domain: error.ErrorDomain.STORAGE,
434
+ category: error.ErrorCategory.THIRD_PARTY,
435
+ details: { tableName }
436
+ },
437
+ error$1
438
+ );
340
439
  }
341
440
  }
342
441
  async insert({ tableName, record }) {
@@ -358,12 +457,22 @@ var ClickhouseStore = class extends storage.MastraStorage {
358
457
  use_client_time_zone: 1
359
458
  }
360
459
  });
361
- } catch (error) {
362
- console.error(`Error inserting into ${tableName}:`, error);
363
- throw error;
460
+ } catch (error$1) {
461
+ throw new error.MastraError(
462
+ {
463
+ id: "CLICKHOUSE_STORAGE_INSERT_FAILED",
464
+ domain: error.ErrorDomain.STORAGE,
465
+ category: error.ErrorCategory.THIRD_PARTY,
466
+ details: { tableName }
467
+ },
468
+ error$1
469
+ );
364
470
  }
365
471
  }
366
- async load({ tableName, keys }) {
472
+ async load({
473
+ tableName,
474
+ keys
475
+ }) {
367
476
  try {
368
477
  const keyEntries = Object.entries(keys);
369
478
  const conditions = keyEntries.map(
@@ -399,9 +508,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
399
508
  }
400
509
  const data = transformRow(rows.data[0]);
401
510
  return data;
402
- } catch (error) {
403
- console.error(`Error loading from ${tableName}:`, error);
404
- throw error;
511
+ } catch (error$1) {
512
+ throw new error.MastraError(
513
+ {
514
+ id: "CLICKHOUSE_STORAGE_LOAD_FAILED",
515
+ domain: error.ErrorDomain.STORAGE,
516
+ category: error.ErrorCategory.THIRD_PARTY,
517
+ details: { tableName }
518
+ },
519
+ error$1
520
+ );
405
521
  }
406
522
  }
407
523
  async getThreadById({ threadId }) {
@@ -437,9 +553,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
437
553
  createdAt: thread.createdAt,
438
554
  updatedAt: thread.updatedAt
439
555
  };
440
- } catch (error) {
441
- console.error(`Error getting thread ${threadId}:`, error);
442
- throw error;
556
+ } catch (error$1) {
557
+ throw new error.MastraError(
558
+ {
559
+ id: "CLICKHOUSE_STORAGE_GET_THREAD_BY_ID_FAILED",
560
+ domain: error.ErrorDomain.STORAGE,
561
+ category: error.ErrorCategory.THIRD_PARTY,
562
+ details: { threadId }
563
+ },
564
+ error$1
565
+ );
443
566
  }
444
567
  }
445
568
  async getThreadsByResourceId({ resourceId }) {
@@ -471,9 +594,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
471
594
  createdAt: thread.createdAt,
472
595
  updatedAt: thread.updatedAt
473
596
  }));
474
- } catch (error) {
475
- console.error(`Error getting threads for resource ${resourceId}:`, error);
476
- throw error;
597
+ } catch (error$1) {
598
+ throw new error.MastraError(
599
+ {
600
+ id: "CLICKHOUSE_STORAGE_GET_THREADS_BY_RESOURCE_ID_FAILED",
601
+ domain: error.ErrorDomain.STORAGE,
602
+ category: error.ErrorCategory.THIRD_PARTY,
603
+ details: { resourceId }
604
+ },
605
+ error$1
606
+ );
477
607
  }
478
608
  }
479
609
  async saveThread({ thread }) {
@@ -496,9 +626,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
496
626
  }
497
627
  });
498
628
  return thread;
499
- } catch (error) {
500
- console.error("Error saving thread:", error);
501
- throw error;
629
+ } catch (error$1) {
630
+ throw new error.MastraError(
631
+ {
632
+ id: "CLICKHOUSE_STORAGE_SAVE_THREAD_FAILED",
633
+ domain: error.ErrorDomain.STORAGE,
634
+ category: error.ErrorCategory.THIRD_PARTY,
635
+ details: { threadId: thread.id }
636
+ },
637
+ error$1
638
+ );
502
639
  }
503
640
  }
504
641
  async updateThread({
@@ -541,9 +678,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
541
678
  }
542
679
  });
543
680
  return updatedThread;
544
- } catch (error) {
545
- console.error("Error updating thread:", error);
546
- throw error;
681
+ } catch (error$1) {
682
+ throw new error.MastraError(
683
+ {
684
+ id: "CLICKHOUSE_STORAGE_UPDATE_THREAD_FAILED",
685
+ domain: error.ErrorDomain.STORAGE,
686
+ category: error.ErrorCategory.THIRD_PARTY,
687
+ details: { threadId: id, title }
688
+ },
689
+ error$1
690
+ );
547
691
  }
548
692
  }
549
693
  async deleteThread({ threadId }) {
@@ -562,9 +706,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
562
706
  output_format_json_quote_64bit_integers: 0
563
707
  }
564
708
  });
565
- } catch (error) {
566
- console.error("Error deleting thread:", error);
567
- throw error;
709
+ } catch (error$1) {
710
+ throw new error.MastraError(
711
+ {
712
+ id: "CLICKHOUSE_STORAGE_DELETE_THREAD_FAILED",
713
+ domain: error.ErrorDomain.STORAGE,
714
+ category: error.ErrorCategory.THIRD_PARTY,
715
+ details: { threadId }
716
+ },
717
+ error$1
718
+ );
568
719
  }
569
720
  }
570
721
  async getMessages({
@@ -575,7 +726,7 @@ var ClickhouseStore = class extends storage.MastraStorage {
575
726
  }) {
576
727
  try {
577
728
  const messages = [];
578
- const limit = typeof selectBy?.last === `number` ? selectBy.last : 40;
729
+ const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
579
730
  const include = selectBy?.include || [];
580
731
  if (include.length) {
581
732
  const includeResult = await this.db.query({
@@ -671,9 +822,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
671
822
  const list = new agent.MessageList({ threadId, resourceId }).add(messages, "memory");
672
823
  if (format === `v2`) return list.get.all.v2();
673
824
  return list.get.all.v1();
674
- } catch (error) {
675
- console.error("Error getting messages:", error);
676
- throw error;
825
+ } catch (error$1) {
826
+ throw new error.MastraError(
827
+ {
828
+ id: "CLICKHOUSE_STORAGE_GET_MESSAGES_FAILED",
829
+ domain: error.ErrorDomain.STORAGE,
830
+ category: error.ErrorCategory.THIRD_PARTY,
831
+ details: { threadId, resourceId: resourceId ?? "" }
832
+ },
833
+ error$1
834
+ );
677
835
  }
678
836
  }
679
837
  async saveMessages(args) {
@@ -689,12 +847,52 @@ var ClickhouseStore = class extends storage.MastraStorage {
689
847
  if (!thread) {
690
848
  throw new Error(`Thread ${threadId} not found`);
691
849
  }
850
+ const existingResult = await this.db.query({
851
+ query: `SELECT id, thread_id FROM ${storage.TABLE_MESSAGES} WHERE id IN ({ids:Array(String)})`,
852
+ query_params: {
853
+ ids: messages.map((m) => m.id)
854
+ },
855
+ clickhouse_settings: {
856
+ // Allows to insert serialized JS Dates (such as '2023-12-06T10:54:48.000Z')
857
+ date_time_input_format: "best_effort",
858
+ date_time_output_format: "iso",
859
+ use_client_time_zone: 1,
860
+ output_format_json_quote_64bit_integers: 0
861
+ },
862
+ format: "JSONEachRow"
863
+ });
864
+ const existingRows = await existingResult.json();
865
+ const existingSet = new Set(existingRows.map((row) => `${row.id}::${row.thread_id}`));
866
+ const toInsert = messages.filter((m) => !existingSet.has(`${m.id}::${threadId}`));
867
+ const toUpdate = messages.filter((m) => existingSet.has(`${m.id}::${threadId}`));
868
+ const updatePromises = toUpdate.map(
869
+ (message) => this.db.command({
870
+ query: `
871
+ ALTER TABLE ${storage.TABLE_MESSAGES}
872
+ UPDATE content = {var_content:String}, role = {var_role:String}, type = {var_type:String}
873
+ WHERE id = {var_id:String} AND thread_id = {var_thread_id:String}
874
+ `,
875
+ query_params: {
876
+ var_content: typeof message.content === "string" ? message.content : JSON.stringify(message.content),
877
+ var_role: message.role,
878
+ var_type: message.type || "v2",
879
+ var_id: message.id,
880
+ var_thread_id: threadId
881
+ },
882
+ clickhouse_settings: {
883
+ // Allows to insert serialized JS Dates (such as '2023-12-06T10:54:48.000Z')
884
+ date_time_input_format: "best_effort",
885
+ use_client_time_zone: 1,
886
+ output_format_json_quote_64bit_integers: 0
887
+ }
888
+ })
889
+ );
692
890
  await Promise.all([
693
891
  // Insert messages
694
892
  this.db.insert({
695
893
  table: storage.TABLE_MESSAGES,
696
894
  format: "JSONEachRow",
697
- values: messages.map((message) => ({
895
+ values: toInsert.map((message) => ({
698
896
  id: message.id,
699
897
  thread_id: threadId,
700
898
  content: typeof message.content === "string" ? message.content : JSON.stringify(message.content),
@@ -709,6 +907,7 @@ var ClickhouseStore = class extends storage.MastraStorage {
709
907
  output_format_json_quote_64bit_integers: 0
710
908
  }
711
909
  }),
910
+ ...updatePromises,
712
911
  // Update thread's updatedAt timestamp
713
912
  this.db.insert({
714
913
  table: storage.TABLE_THREADS,
@@ -733,9 +932,15 @@ var ClickhouseStore = class extends storage.MastraStorage {
733
932
  const list = new agent.MessageList({ threadId, resourceId }).add(messages, "memory");
734
933
  if (format === `v2`) return list.get.all.v2();
735
934
  return list.get.all.v1();
736
- } catch (error) {
737
- console.error("Error saving messages:", error);
738
- throw error;
935
+ } catch (error$1) {
936
+ throw new error.MastraError(
937
+ {
938
+ id: "CLICKHOUSE_STORAGE_SAVE_MESSAGES_FAILED",
939
+ domain: error.ErrorDomain.STORAGE,
940
+ category: error.ErrorCategory.THIRD_PARTY
941
+ },
942
+ error$1
943
+ );
739
944
  }
740
945
  }
741
946
  async persistWorkflowSnapshot({
@@ -771,9 +976,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
771
976
  output_format_json_quote_64bit_integers: 0
772
977
  }
773
978
  });
774
- } catch (error) {
775
- console.error("Error persisting workflow snapshot:", error);
776
- throw error;
979
+ } catch (error$1) {
980
+ throw new error.MastraError(
981
+ {
982
+ id: "CLICKHOUSE_STORAGE_PERSIST_WORKFLOW_SNAPSHOT_FAILED",
983
+ domain: error.ErrorDomain.STORAGE,
984
+ category: error.ErrorCategory.THIRD_PARTY,
985
+ details: { workflowName, runId }
986
+ },
987
+ error$1
988
+ );
777
989
  }
778
990
  }
779
991
  async loadWorkflowSnapshot({
@@ -792,9 +1004,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
792
1004
  return null;
793
1005
  }
794
1006
  return result.snapshot;
795
- } catch (error) {
796
- console.error("Error loading workflow snapshot:", error);
797
- throw error;
1007
+ } catch (error$1) {
1008
+ throw new error.MastraError(
1009
+ {
1010
+ id: "CLICKHOUSE_STORAGE_LOAD_WORKFLOW_SNAPSHOT_FAILED",
1011
+ domain: error.ErrorDomain.STORAGE,
1012
+ category: error.ErrorCategory.THIRD_PARTY,
1013
+ details: { workflowName, runId }
1014
+ },
1015
+ error$1
1016
+ );
798
1017
  }
799
1018
  }
800
1019
  parseWorkflowRun(row) {
@@ -884,9 +1103,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
884
1103
  return this.parseWorkflowRun(row);
885
1104
  });
886
1105
  return { runs, total: total || runs.length };
887
- } catch (error) {
888
- console.error("Error getting workflow runs:", error);
889
- throw error;
1106
+ } catch (error$1) {
1107
+ throw new error.MastraError(
1108
+ {
1109
+ id: "CLICKHOUSE_STORAGE_GET_WORKFLOW_RUNS_FAILED",
1110
+ domain: error.ErrorDomain.STORAGE,
1111
+ category: error.ErrorCategory.THIRD_PARTY,
1112
+ details: { workflowName: workflowName ?? "", resourceId: resourceId ?? "" }
1113
+ },
1114
+ error$1
1115
+ );
890
1116
  }
891
1117
  }
892
1118
  async getWorkflowRunById({
@@ -925,9 +1151,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
925
1151
  return null;
926
1152
  }
927
1153
  return this.parseWorkflowRun(resultJson[0]);
928
- } catch (error) {
929
- console.error("Error getting workflow run by ID:", error);
930
- throw error;
1154
+ } catch (error$1) {
1155
+ throw new error.MastraError(
1156
+ {
1157
+ id: "CLICKHOUSE_STORAGE_GET_WORKFLOW_RUN_BY_ID_FAILED",
1158
+ domain: error.ErrorDomain.STORAGE,
1159
+ category: error.ErrorCategory.THIRD_PARTY,
1160
+ details: { runId: runId ?? "", workflowName: workflowName ?? "" }
1161
+ },
1162
+ error$1
1163
+ );
931
1164
  }
932
1165
  }
933
1166
  async hasColumn(table, column) {
@@ -939,13 +1172,28 @@ var ClickhouseStore = class extends storage.MastraStorage {
939
1172
  return columns.some((c) => c.name === column);
940
1173
  }
941
1174
  async getTracesPaginated(_args) {
942
- throw new Error("Method not implemented.");
1175
+ throw new error.MastraError({
1176
+ id: "CLICKHOUSE_STORAGE_GET_TRACES_PAGINATED_FAILED",
1177
+ domain: error.ErrorDomain.STORAGE,
1178
+ category: error.ErrorCategory.USER,
1179
+ text: "Method not implemented."
1180
+ });
943
1181
  }
944
1182
  async getThreadsByResourceIdPaginated(_args) {
945
- throw new Error("Method not implemented.");
1183
+ throw new error.MastraError({
1184
+ id: "CLICKHOUSE_STORAGE_GET_THREADS_BY_RESOURCE_ID_PAGINATED_FAILED",
1185
+ domain: error.ErrorDomain.STORAGE,
1186
+ category: error.ErrorCategory.USER,
1187
+ text: "Method not implemented."
1188
+ });
946
1189
  }
947
1190
  async getMessagesPaginated(_args) {
948
- throw new Error("Method not implemented.");
1191
+ throw new error.MastraError({
1192
+ id: "CLICKHOUSE_STORAGE_GET_MESSAGES_PAGINATED_FAILED",
1193
+ domain: error.ErrorDomain.STORAGE,
1194
+ category: error.ErrorCategory.USER,
1195
+ text: "Method not implemented."
1196
+ });
949
1197
  }
950
1198
  async close() {
951
1199
  await this.db.close();