@mastra/clickhouse 0.11.0 → 0.11.1-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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +24 -0
- package/dist/_tsup-dts-rollup.d.cts +10 -0
- package/dist/_tsup-dts-rollup.d.ts +10 -0
- package/dist/index.cjs +293 -97
- package/dist/index.js +275 -79
- package/package.json +2 -2
- package/src/storage/index.ts +297 -94
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/clickhouse@0.11.
|
|
2
|
+
> @mastra/clickhouse@0.11.1-alpha.1 build /home/runner/work/mastra/mastra/stores/clickhouse
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 8767ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/clickhouse/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/clickhouse/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 11882ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m36.43 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 1044ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m37.19 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 1046ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @mastra/clickhouse
|
|
2
2
|
|
|
3
|
+
## 0.11.1-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2097952: [MASTRA-4021] Fix PG getMessages and update messageLimit for all storage adapters
|
|
8
|
+
- 0e17048: Throw mastra errors in storage packages
|
|
9
|
+
- Updated dependencies [d1baedb]
|
|
10
|
+
- Updated dependencies [4d21bf2]
|
|
11
|
+
- Updated dependencies [2097952]
|
|
12
|
+
- Updated dependencies [4fb0cc2]
|
|
13
|
+
- Updated dependencies [d2a7a31]
|
|
14
|
+
- Updated dependencies [0e17048]
|
|
15
|
+
- @mastra/core@0.10.7-alpha.1
|
|
16
|
+
|
|
17
|
+
## 0.11.1-alpha.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- d8f2d19: Add updateMessages API to storage classes (only support for PG and LibSQL for now) and to memory class. Additionally allow for metadata to be saved in the content field of a message.
|
|
22
|
+
- Updated dependencies [d8f2d19]
|
|
23
|
+
- Updated dependencies [9d52b17]
|
|
24
|
+
- Updated dependencies [8ba1b51]
|
|
25
|
+
- @mastra/core@0.10.7-alpha.0
|
|
26
|
+
|
|
3
27
|
## 0.11.0
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ClickHouseClient } from '@clickhouse/client';
|
|
2
2
|
import type { EvalRow } from '@mastra/core/storage';
|
|
3
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
3
4
|
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
4
5
|
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
5
6
|
import { MastraStorage } from '@mastra/core/storage';
|
|
@@ -160,6 +161,15 @@ declare class ClickhouseStore extends MastraStorage {
|
|
|
160
161
|
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
161
162
|
}>;
|
|
162
163
|
close(): Promise<void>;
|
|
164
|
+
updateMessages(_args: {
|
|
165
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
166
|
+
id: string;
|
|
167
|
+
content?: {
|
|
168
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
169
|
+
content?: MastraMessageContentV2['content'];
|
|
170
|
+
};
|
|
171
|
+
}[];
|
|
172
|
+
}): Promise<MastraMessageV2[]>;
|
|
163
173
|
}
|
|
164
174
|
export { ClickhouseStore }
|
|
165
175
|
export { ClickhouseStore as ClickhouseStore_alias_1 }
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ClickHouseClient } from '@clickhouse/client';
|
|
2
2
|
import type { EvalRow } from '@mastra/core/storage';
|
|
3
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
3
4
|
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
4
5
|
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
5
6
|
import { MastraStorage } from '@mastra/core/storage';
|
|
@@ -160,6 +161,15 @@ declare class ClickhouseStore extends MastraStorage {
|
|
|
160
161
|
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
161
162
|
}>;
|
|
162
163
|
close(): Promise<void>;
|
|
164
|
+
updateMessages(_args: {
|
|
165
|
+
messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
166
|
+
id: string;
|
|
167
|
+
content?: {
|
|
168
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
169
|
+
content?: MastraMessageContentV2['content'];
|
|
170
|
+
};
|
|
171
|
+
}[];
|
|
172
|
+
}): Promise<MastraMessageV2[]>;
|
|
163
173
|
}
|
|
164
174
|
export { ClickhouseStore }
|
|
165
175
|
export { ClickhouseStore as ClickhouseStore_alias_1 }
|
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
|
|
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,
|
|
@@ -100,12 +106,19 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
100
106
|
}
|
|
101
107
|
const rows = await result.json();
|
|
102
108
|
return rows.data.map((row) => this.transformEvalRow(row));
|
|
103
|
-
} catch (error) {
|
|
104
|
-
if (error
|
|
109
|
+
} catch (error$1) {
|
|
110
|
+
if (error$1?.message?.includes("no such table") || error$1?.message?.includes("does not exist")) {
|
|
105
111
|
return [];
|
|
106
112
|
}
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
throw new error.MastraError(
|
|
114
|
+
{
|
|
115
|
+
id: "CLICKHOUSE_STORAGE_GET_EVALS_BY_AGENT_FAILED",
|
|
116
|
+
domain: error.ErrorDomain.STORAGE,
|
|
117
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
118
|
+
details: { agentName, type: type ?? null }
|
|
119
|
+
},
|
|
120
|
+
error$1
|
|
121
|
+
);
|
|
109
122
|
}
|
|
110
123
|
}
|
|
111
124
|
async batchInsert({ tableName, records }) {
|
|
@@ -128,9 +141,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
128
141
|
output_format_json_quote_64bit_integers: 0
|
|
129
142
|
}
|
|
130
143
|
});
|
|
131
|
-
} catch (error) {
|
|
132
|
-
|
|
133
|
-
|
|
144
|
+
} catch (error$1) {
|
|
145
|
+
throw new error.MastraError(
|
|
146
|
+
{
|
|
147
|
+
id: "CLICKHOUSE_STORAGE_BATCH_INSERT_FAILED",
|
|
148
|
+
domain: error.ErrorDomain.STORAGE,
|
|
149
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
150
|
+
details: { tableName }
|
|
151
|
+
},
|
|
152
|
+
error$1
|
|
153
|
+
);
|
|
134
154
|
}
|
|
135
155
|
}
|
|
136
156
|
async getTraces({
|
|
@@ -178,48 +198,96 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
178
198
|
args.var_to_date = toDate.getTime() / 1e3;
|
|
179
199
|
}
|
|
180
200
|
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
201
|
+
try {
|
|
202
|
+
const result = await this.db.query({
|
|
203
|
+
query: `SELECT *, toDateTime64(createdAt, 3) as createdAt FROM ${storage.TABLE_TRACES} ${whereClause} ORDER BY "createdAt" DESC LIMIT ${limit} OFFSET ${offset}`,
|
|
204
|
+
query_params: args,
|
|
205
|
+
clickhouse_settings: {
|
|
206
|
+
// Allows to insert serialized JS Dates (such as '2023-12-06T10:54:48.000Z')
|
|
207
|
+
date_time_input_format: "best_effort",
|
|
208
|
+
date_time_output_format: "iso",
|
|
209
|
+
use_client_time_zone: 1,
|
|
210
|
+
output_format_json_quote_64bit_integers: 0
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
if (!result) {
|
|
214
|
+
return [];
|
|
190
215
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return
|
|
216
|
+
const resp = await result.json();
|
|
217
|
+
const rows = resp.data;
|
|
218
|
+
return rows.map((row) => ({
|
|
219
|
+
id: row.id,
|
|
220
|
+
parentSpanId: row.parentSpanId,
|
|
221
|
+
traceId: row.traceId,
|
|
222
|
+
name: row.name,
|
|
223
|
+
scope: row.scope,
|
|
224
|
+
kind: row.kind,
|
|
225
|
+
status: safelyParseJSON(row.status),
|
|
226
|
+
events: safelyParseJSON(row.events),
|
|
227
|
+
links: safelyParseJSON(row.links),
|
|
228
|
+
attributes: safelyParseJSON(row.attributes),
|
|
229
|
+
startTime: row.startTime,
|
|
230
|
+
endTime: row.endTime,
|
|
231
|
+
other: safelyParseJSON(row.other),
|
|
232
|
+
createdAt: row.createdAt
|
|
233
|
+
}));
|
|
234
|
+
} catch (error$1) {
|
|
235
|
+
if (error$1?.message?.includes("no such table") || error$1?.message?.includes("does not exist")) {
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
throw new error.MastraError(
|
|
239
|
+
{
|
|
240
|
+
id: "CLICKHOUSE_STORAGE_GET_TRACES_FAILED",
|
|
241
|
+
domain: error.ErrorDomain.STORAGE,
|
|
242
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
243
|
+
details: {
|
|
244
|
+
name: name ?? null,
|
|
245
|
+
scope: scope ?? null,
|
|
246
|
+
page,
|
|
247
|
+
perPage,
|
|
248
|
+
attributes: attributes ? JSON.stringify(attributes) : null,
|
|
249
|
+
filters: filters ? JSON.stringify(filters) : null,
|
|
250
|
+
fromDate: fromDate?.toISOString() ?? null,
|
|
251
|
+
toDate: toDate?.toISOString() ?? null
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
error$1
|
|
255
|
+
);
|
|
194
256
|
}
|
|
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
|
-
}));
|
|
213
257
|
}
|
|
214
258
|
async optimizeTable({ tableName }) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
259
|
+
try {
|
|
260
|
+
await this.db.command({
|
|
261
|
+
query: `OPTIMIZE TABLE ${tableName} FINAL`
|
|
262
|
+
});
|
|
263
|
+
} catch (error$1) {
|
|
264
|
+
throw new error.MastraError(
|
|
265
|
+
{
|
|
266
|
+
id: "CLICKHOUSE_STORAGE_OPTIMIZE_TABLE_FAILED",
|
|
267
|
+
domain: error.ErrorDomain.STORAGE,
|
|
268
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
269
|
+
details: { tableName }
|
|
270
|
+
},
|
|
271
|
+
error$1
|
|
272
|
+
);
|
|
273
|
+
}
|
|
218
274
|
}
|
|
219
275
|
async materializeTtl({ tableName }) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
276
|
+
try {
|
|
277
|
+
await this.db.command({
|
|
278
|
+
query: `ALTER TABLE ${tableName} MATERIALIZE TTL;`
|
|
279
|
+
});
|
|
280
|
+
} catch (error$1) {
|
|
281
|
+
throw new error.MastraError(
|
|
282
|
+
{
|
|
283
|
+
id: "CLICKHOUSE_STORAGE_MATERIALIZE_TTL_FAILED",
|
|
284
|
+
domain: error.ErrorDomain.STORAGE,
|
|
285
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
286
|
+
details: { tableName }
|
|
287
|
+
},
|
|
288
|
+
error$1
|
|
289
|
+
);
|
|
290
|
+
}
|
|
223
291
|
}
|
|
224
292
|
async createTable({
|
|
225
293
|
tableName,
|
|
@@ -262,9 +330,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
262
330
|
output_format_json_quote_64bit_integers: 0
|
|
263
331
|
}
|
|
264
332
|
});
|
|
265
|
-
} catch (error) {
|
|
266
|
-
|
|
267
|
-
|
|
333
|
+
} catch (error$1) {
|
|
334
|
+
throw new error.MastraError(
|
|
335
|
+
{
|
|
336
|
+
id: "CLICKHOUSE_STORAGE_CREATE_TABLE_FAILED",
|
|
337
|
+
domain: error.ErrorDomain.STORAGE,
|
|
338
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
339
|
+
details: { tableName }
|
|
340
|
+
},
|
|
341
|
+
error$1
|
|
342
|
+
);
|
|
268
343
|
}
|
|
269
344
|
}
|
|
270
345
|
getSqlType(type) {
|
|
@@ -315,11 +390,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
315
390
|
this.logger?.debug?.(`Added column ${columnName} to table ${tableName}`);
|
|
316
391
|
}
|
|
317
392
|
}
|
|
318
|
-
} catch (error) {
|
|
319
|
-
|
|
320
|
-
|
|
393
|
+
} catch (error$1) {
|
|
394
|
+
throw new error.MastraError(
|
|
395
|
+
{
|
|
396
|
+
id: "CLICKHOUSE_STORAGE_ALTER_TABLE_FAILED",
|
|
397
|
+
domain: error.ErrorDomain.STORAGE,
|
|
398
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
399
|
+
details: { tableName }
|
|
400
|
+
},
|
|
401
|
+
error$1
|
|
321
402
|
);
|
|
322
|
-
throw new Error(`Failed to alter table ${tableName}: ${error}`);
|
|
323
403
|
}
|
|
324
404
|
}
|
|
325
405
|
async clearTable({ tableName }) {
|
|
@@ -334,9 +414,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
334
414
|
output_format_json_quote_64bit_integers: 0
|
|
335
415
|
}
|
|
336
416
|
});
|
|
337
|
-
} catch (error) {
|
|
338
|
-
|
|
339
|
-
|
|
417
|
+
} catch (error$1) {
|
|
418
|
+
throw new error.MastraError(
|
|
419
|
+
{
|
|
420
|
+
id: "CLICKHOUSE_STORAGE_CLEAR_TABLE_FAILED",
|
|
421
|
+
domain: error.ErrorDomain.STORAGE,
|
|
422
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
423
|
+
details: { tableName }
|
|
424
|
+
},
|
|
425
|
+
error$1
|
|
426
|
+
);
|
|
340
427
|
}
|
|
341
428
|
}
|
|
342
429
|
async insert({ tableName, record }) {
|
|
@@ -358,9 +445,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
358
445
|
use_client_time_zone: 1
|
|
359
446
|
}
|
|
360
447
|
});
|
|
361
|
-
} catch (error) {
|
|
362
|
-
|
|
363
|
-
|
|
448
|
+
} catch (error$1) {
|
|
449
|
+
throw new error.MastraError(
|
|
450
|
+
{
|
|
451
|
+
id: "CLICKHOUSE_STORAGE_INSERT_FAILED",
|
|
452
|
+
domain: error.ErrorDomain.STORAGE,
|
|
453
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
454
|
+
details: { tableName }
|
|
455
|
+
},
|
|
456
|
+
error$1
|
|
457
|
+
);
|
|
364
458
|
}
|
|
365
459
|
}
|
|
366
460
|
async load({ tableName, keys }) {
|
|
@@ -399,9 +493,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
399
493
|
}
|
|
400
494
|
const data = transformRow(rows.data[0]);
|
|
401
495
|
return data;
|
|
402
|
-
} catch (error) {
|
|
403
|
-
|
|
404
|
-
|
|
496
|
+
} catch (error$1) {
|
|
497
|
+
throw new error.MastraError(
|
|
498
|
+
{
|
|
499
|
+
id: "CLICKHOUSE_STORAGE_LOAD_FAILED",
|
|
500
|
+
domain: error.ErrorDomain.STORAGE,
|
|
501
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
502
|
+
details: { tableName }
|
|
503
|
+
},
|
|
504
|
+
error$1
|
|
505
|
+
);
|
|
405
506
|
}
|
|
406
507
|
}
|
|
407
508
|
async getThreadById({ threadId }) {
|
|
@@ -437,9 +538,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
437
538
|
createdAt: thread.createdAt,
|
|
438
539
|
updatedAt: thread.updatedAt
|
|
439
540
|
};
|
|
440
|
-
} catch (error) {
|
|
441
|
-
|
|
442
|
-
|
|
541
|
+
} catch (error$1) {
|
|
542
|
+
throw new error.MastraError(
|
|
543
|
+
{
|
|
544
|
+
id: "CLICKHOUSE_STORAGE_GET_THREAD_BY_ID_FAILED",
|
|
545
|
+
domain: error.ErrorDomain.STORAGE,
|
|
546
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
547
|
+
details: { threadId }
|
|
548
|
+
},
|
|
549
|
+
error$1
|
|
550
|
+
);
|
|
443
551
|
}
|
|
444
552
|
}
|
|
445
553
|
async getThreadsByResourceId({ resourceId }) {
|
|
@@ -471,9 +579,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
471
579
|
createdAt: thread.createdAt,
|
|
472
580
|
updatedAt: thread.updatedAt
|
|
473
581
|
}));
|
|
474
|
-
} catch (error) {
|
|
475
|
-
|
|
476
|
-
|
|
582
|
+
} catch (error$1) {
|
|
583
|
+
throw new error.MastraError(
|
|
584
|
+
{
|
|
585
|
+
id: "CLICKHOUSE_STORAGE_GET_THREADS_BY_RESOURCE_ID_FAILED",
|
|
586
|
+
domain: error.ErrorDomain.STORAGE,
|
|
587
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
588
|
+
details: { resourceId }
|
|
589
|
+
},
|
|
590
|
+
error$1
|
|
591
|
+
);
|
|
477
592
|
}
|
|
478
593
|
}
|
|
479
594
|
async saveThread({ thread }) {
|
|
@@ -496,9 +611,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
496
611
|
}
|
|
497
612
|
});
|
|
498
613
|
return thread;
|
|
499
|
-
} catch (error) {
|
|
500
|
-
|
|
501
|
-
|
|
614
|
+
} catch (error$1) {
|
|
615
|
+
throw new error.MastraError(
|
|
616
|
+
{
|
|
617
|
+
id: "CLICKHOUSE_STORAGE_SAVE_THREAD_FAILED",
|
|
618
|
+
domain: error.ErrorDomain.STORAGE,
|
|
619
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
620
|
+
details: { threadId: thread.id }
|
|
621
|
+
},
|
|
622
|
+
error$1
|
|
623
|
+
);
|
|
502
624
|
}
|
|
503
625
|
}
|
|
504
626
|
async updateThread({
|
|
@@ -541,9 +663,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
541
663
|
}
|
|
542
664
|
});
|
|
543
665
|
return updatedThread;
|
|
544
|
-
} catch (error) {
|
|
545
|
-
|
|
546
|
-
|
|
666
|
+
} catch (error$1) {
|
|
667
|
+
throw new error.MastraError(
|
|
668
|
+
{
|
|
669
|
+
id: "CLICKHOUSE_STORAGE_UPDATE_THREAD_FAILED",
|
|
670
|
+
domain: error.ErrorDomain.STORAGE,
|
|
671
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
672
|
+
details: { threadId: id, title }
|
|
673
|
+
},
|
|
674
|
+
error$1
|
|
675
|
+
);
|
|
547
676
|
}
|
|
548
677
|
}
|
|
549
678
|
async deleteThread({ threadId }) {
|
|
@@ -562,9 +691,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
562
691
|
output_format_json_quote_64bit_integers: 0
|
|
563
692
|
}
|
|
564
693
|
});
|
|
565
|
-
} catch (error) {
|
|
566
|
-
|
|
567
|
-
|
|
694
|
+
} catch (error$1) {
|
|
695
|
+
throw new error.MastraError(
|
|
696
|
+
{
|
|
697
|
+
id: "CLICKHOUSE_STORAGE_DELETE_THREAD_FAILED",
|
|
698
|
+
domain: error.ErrorDomain.STORAGE,
|
|
699
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
700
|
+
details: { threadId }
|
|
701
|
+
},
|
|
702
|
+
error$1
|
|
703
|
+
);
|
|
568
704
|
}
|
|
569
705
|
}
|
|
570
706
|
async getMessages({
|
|
@@ -575,7 +711,7 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
575
711
|
}) {
|
|
576
712
|
try {
|
|
577
713
|
const messages = [];
|
|
578
|
-
const limit =
|
|
714
|
+
const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
579
715
|
const include = selectBy?.include || [];
|
|
580
716
|
if (include.length) {
|
|
581
717
|
const includeResult = await this.db.query({
|
|
@@ -671,9 +807,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
671
807
|
const list = new agent.MessageList({ threadId, resourceId }).add(messages, "memory");
|
|
672
808
|
if (format === `v2`) return list.get.all.v2();
|
|
673
809
|
return list.get.all.v1();
|
|
674
|
-
} catch (error) {
|
|
675
|
-
|
|
676
|
-
|
|
810
|
+
} catch (error$1) {
|
|
811
|
+
throw new error.MastraError(
|
|
812
|
+
{
|
|
813
|
+
id: "CLICKHOUSE_STORAGE_GET_MESSAGES_FAILED",
|
|
814
|
+
domain: error.ErrorDomain.STORAGE,
|
|
815
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
816
|
+
details: { threadId, resourceId: resourceId ?? "" }
|
|
817
|
+
},
|
|
818
|
+
error$1
|
|
819
|
+
);
|
|
677
820
|
}
|
|
678
821
|
}
|
|
679
822
|
async saveMessages(args) {
|
|
@@ -733,9 +876,15 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
733
876
|
const list = new agent.MessageList({ threadId, resourceId }).add(messages, "memory");
|
|
734
877
|
if (format === `v2`) return list.get.all.v2();
|
|
735
878
|
return list.get.all.v1();
|
|
736
|
-
} catch (error) {
|
|
737
|
-
|
|
738
|
-
|
|
879
|
+
} catch (error$1) {
|
|
880
|
+
throw new error.MastraError(
|
|
881
|
+
{
|
|
882
|
+
id: "CLICKHOUSE_STORAGE_SAVE_MESSAGES_FAILED",
|
|
883
|
+
domain: error.ErrorDomain.STORAGE,
|
|
884
|
+
category: error.ErrorCategory.THIRD_PARTY
|
|
885
|
+
},
|
|
886
|
+
error$1
|
|
887
|
+
);
|
|
739
888
|
}
|
|
740
889
|
}
|
|
741
890
|
async persistWorkflowSnapshot({
|
|
@@ -771,9 +920,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
771
920
|
output_format_json_quote_64bit_integers: 0
|
|
772
921
|
}
|
|
773
922
|
});
|
|
774
|
-
} catch (error) {
|
|
775
|
-
|
|
776
|
-
|
|
923
|
+
} catch (error$1) {
|
|
924
|
+
throw new error.MastraError(
|
|
925
|
+
{
|
|
926
|
+
id: "CLICKHOUSE_STORAGE_PERSIST_WORKFLOW_SNAPSHOT_FAILED",
|
|
927
|
+
domain: error.ErrorDomain.STORAGE,
|
|
928
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
929
|
+
details: { workflowName, runId }
|
|
930
|
+
},
|
|
931
|
+
error$1
|
|
932
|
+
);
|
|
777
933
|
}
|
|
778
934
|
}
|
|
779
935
|
async loadWorkflowSnapshot({
|
|
@@ -792,9 +948,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
792
948
|
return null;
|
|
793
949
|
}
|
|
794
950
|
return result.snapshot;
|
|
795
|
-
} catch (error) {
|
|
796
|
-
|
|
797
|
-
|
|
951
|
+
} catch (error$1) {
|
|
952
|
+
throw new error.MastraError(
|
|
953
|
+
{
|
|
954
|
+
id: "CLICKHOUSE_STORAGE_LOAD_WORKFLOW_SNAPSHOT_FAILED",
|
|
955
|
+
domain: error.ErrorDomain.STORAGE,
|
|
956
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
957
|
+
details: { workflowName, runId }
|
|
958
|
+
},
|
|
959
|
+
error$1
|
|
960
|
+
);
|
|
798
961
|
}
|
|
799
962
|
}
|
|
800
963
|
parseWorkflowRun(row) {
|
|
@@ -884,9 +1047,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
884
1047
|
return this.parseWorkflowRun(row);
|
|
885
1048
|
});
|
|
886
1049
|
return { runs, total: total || runs.length };
|
|
887
|
-
} catch (error) {
|
|
888
|
-
|
|
889
|
-
|
|
1050
|
+
} catch (error$1) {
|
|
1051
|
+
throw new error.MastraError(
|
|
1052
|
+
{
|
|
1053
|
+
id: "CLICKHOUSE_STORAGE_GET_WORKFLOW_RUNS_FAILED",
|
|
1054
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1055
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
1056
|
+
details: { workflowName: workflowName ?? "", resourceId: resourceId ?? "" }
|
|
1057
|
+
},
|
|
1058
|
+
error$1
|
|
1059
|
+
);
|
|
890
1060
|
}
|
|
891
1061
|
}
|
|
892
1062
|
async getWorkflowRunById({
|
|
@@ -925,9 +1095,16 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
925
1095
|
return null;
|
|
926
1096
|
}
|
|
927
1097
|
return this.parseWorkflowRun(resultJson[0]);
|
|
928
|
-
} catch (error) {
|
|
929
|
-
|
|
930
|
-
|
|
1098
|
+
} catch (error$1) {
|
|
1099
|
+
throw new error.MastraError(
|
|
1100
|
+
{
|
|
1101
|
+
id: "CLICKHOUSE_STORAGE_GET_WORKFLOW_RUN_BY_ID_FAILED",
|
|
1102
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1103
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
1104
|
+
details: { runId: runId ?? "", workflowName: workflowName ?? "" }
|
|
1105
|
+
},
|
|
1106
|
+
error$1
|
|
1107
|
+
);
|
|
931
1108
|
}
|
|
932
1109
|
}
|
|
933
1110
|
async hasColumn(table, column) {
|
|
@@ -939,17 +1116,36 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
939
1116
|
return columns.some((c) => c.name === column);
|
|
940
1117
|
}
|
|
941
1118
|
async getTracesPaginated(_args) {
|
|
942
|
-
throw new
|
|
1119
|
+
throw new error.MastraError({
|
|
1120
|
+
id: "CLICKHOUSE_STORAGE_GET_TRACES_PAGINATED_FAILED",
|
|
1121
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1122
|
+
category: error.ErrorCategory.USER,
|
|
1123
|
+
text: "Method not implemented."
|
|
1124
|
+
});
|
|
943
1125
|
}
|
|
944
1126
|
async getThreadsByResourceIdPaginated(_args) {
|
|
945
|
-
throw new
|
|
1127
|
+
throw new error.MastraError({
|
|
1128
|
+
id: "CLICKHOUSE_STORAGE_GET_THREADS_BY_RESOURCE_ID_PAGINATED_FAILED",
|
|
1129
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1130
|
+
category: error.ErrorCategory.USER,
|
|
1131
|
+
text: "Method not implemented."
|
|
1132
|
+
});
|
|
946
1133
|
}
|
|
947
1134
|
async getMessagesPaginated(_args) {
|
|
948
|
-
throw new
|
|
1135
|
+
throw new error.MastraError({
|
|
1136
|
+
id: "CLICKHOUSE_STORAGE_GET_MESSAGES_PAGINATED_FAILED",
|
|
1137
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1138
|
+
category: error.ErrorCategory.USER,
|
|
1139
|
+
text: "Method not implemented."
|
|
1140
|
+
});
|
|
949
1141
|
}
|
|
950
1142
|
async close() {
|
|
951
1143
|
await this.db.close();
|
|
952
1144
|
}
|
|
1145
|
+
async updateMessages(_args) {
|
|
1146
|
+
this.logger.error("updateMessages is not yet implemented in ClickhouseStore");
|
|
1147
|
+
throw new Error("Method not implemented");
|
|
1148
|
+
}
|
|
953
1149
|
};
|
|
954
1150
|
|
|
955
1151
|
exports.COLUMN_TYPES = COLUMN_TYPES;
|