@mastra/clickhouse 0.12.3 → 0.13.0-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.
@@ -0,0 +1,42 @@
1
+ import type { ClickHouseClient } from '@clickhouse/client';
2
+ import { StoreOperations } from '@mastra/core/storage';
3
+ import type { StorageColumn, TABLE_NAMES } from '@mastra/core/storage';
4
+ import type { ClickhouseConfig } from '../utils.js';
5
+ export declare class StoreOperationsClickhouse extends StoreOperations {
6
+ protected ttl: ClickhouseConfig['ttl'];
7
+ protected client: ClickHouseClient;
8
+ constructor({ client, ttl }: {
9
+ client: ClickHouseClient;
10
+ ttl: ClickhouseConfig['ttl'];
11
+ });
12
+ hasColumn(table: string, column: string): Promise<boolean>;
13
+ protected getSqlType(type: StorageColumn['type']): string;
14
+ createTable({ tableName, schema, }: {
15
+ tableName: TABLE_NAMES;
16
+ schema: Record<string, StorageColumn>;
17
+ }): Promise<void>;
18
+ alterTable({ tableName, schema, ifNotExists, }: {
19
+ tableName: TABLE_NAMES;
20
+ schema: Record<string, StorageColumn>;
21
+ ifNotExists: string[];
22
+ }): Promise<void>;
23
+ clearTable({ tableName }: {
24
+ tableName: TABLE_NAMES;
25
+ }): Promise<void>;
26
+ dropTable({ tableName }: {
27
+ tableName: TABLE_NAMES;
28
+ }): Promise<void>;
29
+ insert({ tableName, record }: {
30
+ tableName: TABLE_NAMES;
31
+ record: Record<string, any>;
32
+ }): Promise<void>;
33
+ batchInsert({ tableName, records }: {
34
+ tableName: TABLE_NAMES;
35
+ records: Record<string, any>[];
36
+ }): Promise<void>;
37
+ load<R>({ tableName, keys }: {
38
+ tableName: TABLE_NAMES;
39
+ keys: Record<string, string>;
40
+ }): Promise<R | null>;
41
+ }
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/operations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KA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E,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMnE,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCrG,WAAW,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmC9G,IAAI,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CA6DhH"}
@@ -0,0 +1,43 @@
1
+ import type { ClickHouseClient } from '@clickhouse/client';
2
+ import type { ScoreRowData } from '@mastra/core/scores';
3
+ import { ScoresStorage } from '@mastra/core/storage';
4
+ import type { PaginationInfo, StoragePagination } from '@mastra/core/storage';
5
+ import type { StoreOperationsClickhouse } from '../operations/index.js';
6
+ export declare class ScoresStorageClickhouse extends ScoresStorage {
7
+ protected client: ClickHouseClient;
8
+ protected operations: StoreOperationsClickhouse;
9
+ constructor({ client, operations }: {
10
+ client: ClickHouseClient;
11
+ operations: StoreOperationsClickhouse;
12
+ });
13
+ private transformScoreRow;
14
+ getScoreById({ id }: {
15
+ id: string;
16
+ }): Promise<ScoreRowData | null>;
17
+ saveScore(score: ScoreRowData): Promise<{
18
+ score: ScoreRowData;
19
+ }>;
20
+ getScoresByRunId({ runId, pagination, }: {
21
+ runId: string;
22
+ pagination: StoragePagination;
23
+ }): Promise<{
24
+ pagination: PaginationInfo;
25
+ scores: ScoreRowData[];
26
+ }>;
27
+ getScoresByScorerId({ scorerId, pagination, }: {
28
+ scorerId: string;
29
+ pagination: StoragePagination;
30
+ }): Promise<{
31
+ pagination: PaginationInfo;
32
+ scores: ScoreRowData[];
33
+ }>;
34
+ getScoresByEntityId({ entityId, entityType, pagination, }: {
35
+ pagination: StoragePagination;
36
+ entityId: string;
37
+ entityType: string;
38
+ }): Promise<{
39
+ pagination: PaginationInfo;
40
+ scores: ScoreRowData[];
41
+ }>;
42
+ }
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAkC,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE/D,qBAAa,uBAAwB,SAAQ,aAAa;IACxD,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC;IACnC,SAAS,CAAC,UAAU,EAAE,yBAAyB,CAAC;gBACpC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;QAAE,MAAM,EAAE,gBAAgB,CAAC;QAAC,UAAU,EAAE,yBAAyB,CAAA;KAAE;IAMvG,OAAO,CAAC,iBAAiB;IA2BnB,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAmClE,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IA6BhE,gBAAgB,CAAC,EACrB,KAAK,EACL,UAAU,GACX,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAkE7D,mBAAmB,CAAC,EACxB,QAAQ,EACR,UAAU,GACX,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAkE7D,mBAAmB,CAAC,EACxB,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;CAkEpE"}
@@ -0,0 +1,21 @@
1
+ import type { ClickHouseClient } from '@clickhouse/client';
2
+ import { TracesStorage } from '@mastra/core/storage';
3
+ import type { PaginationInfo, StorageGetTracesPaginatedArg, StorageGetTracesArg } from '@mastra/core/storage';
4
+ import type { Trace } from '@mastra/core/telemetry';
5
+ import type { StoreOperationsClickhouse } from '../operations/index.js';
6
+ export declare class TracesStorageClickhouse extends TracesStorage {
7
+ protected client: ClickHouseClient;
8
+ protected operations: StoreOperationsClickhouse;
9
+ constructor({ client, operations }: {
10
+ client: ClickHouseClient;
11
+ operations: StoreOperationsClickhouse;
12
+ });
13
+ getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
14
+ traces: Trace[];
15
+ }>;
16
+ getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }: StorageGetTracesArg): Promise<any[]>;
17
+ batchTraceInsert(args: {
18
+ records: Trace[];
19
+ }): Promise<void>;
20
+ }
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/traces/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAgD,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,KAAK,EAAE,cAAc,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE/D,qBAAa,uBAAwB,SAAQ,aAAa;IACxD,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC;IACnC,SAAS,CAAC,UAAU,EAAE,yBAAyB,CAAC;gBAEpC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;QAAE,MAAM,EAAE,gBAAgB,CAAC;QAAC,UAAU,EAAE,yBAAyB,CAAA;KAAE;IAMjG,kBAAkB,CAAC,IAAI,EAAE,4BAA4B,GAAG,OAAO,CAAC,cAAc,GAAG;QAAE,MAAM,EAAE,KAAK,EAAE,CAAA;KAAE,CAAC;IAgJrG,SAAS,CAAC,EACd,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,OAAO,EACP,UAAU,EACV,OAAO,EACP,QAAQ,EACR,MAAM,GACP,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAqGjC,gBAAgB,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,KAAK,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlE"}
@@ -0,0 +1,28 @@
1
+ import type { TABLE_NAMES, TABLE_SCHEMAS, StorageColumn } from '@mastra/core/storage';
2
+ export declare const TABLE_ENGINES: Record<TABLE_NAMES, string>;
3
+ export declare const COLUMN_TYPES: Record<StorageColumn['type'], string>;
4
+ export type IntervalUnit = 'NANOSECOND' | 'MICROSECOND' | 'MILLISECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
5
+ export type ClickhouseConfig = {
6
+ url: string;
7
+ username: string;
8
+ password: string;
9
+ ttl?: {
10
+ [TableKey in TABLE_NAMES]?: {
11
+ row?: {
12
+ interval: number;
13
+ unit: IntervalUnit;
14
+ ttlKey?: string;
15
+ };
16
+ columns?: Partial<{
17
+ [ColumnKey in keyof (typeof TABLE_SCHEMAS)[TableKey]]: {
18
+ interval: number;
19
+ unit: IntervalUnit;
20
+ ttlKey?: string;
21
+ };
22
+ }>;
23
+ };
24
+ };
25
+ };
26
+ export declare function transformRow<R>(row: any): R;
27
+ export declare function transformRows<R>(rows: any[]): R[];
28
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/storage/domains/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAYtF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAQrD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,CAQ9D,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,aAAa,GACb,aAAa,GACb,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,KAAK,GACL,MAAM,GACN,OAAO,GACP,SAAS,GACT,MAAM,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE;SACH,QAAQ,IAAI,WAAW,CAAC,CAAC,EAAE;YAC1B,GAAG,CAAC,EAAE;gBAAE,QAAQ,EAAE,MAAM,CAAC;gBAAC,IAAI,EAAE,YAAY,CAAC;gBAAC,MAAM,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;YAChE,OAAO,CAAC,EAAE,OAAO,CAAC;iBACf,SAAS,IAAI,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC,QAAQ,CAAC,GAAG;oBACrD,QAAQ,EAAE,MAAM,CAAC;oBACjB,IAAI,EAAE,YAAY,CAAC;oBACnB,MAAM,CAAC,EAAE,MAAM,CAAC;iBACjB;aACF,CAAC,CAAC;SACJ;KACF,CAAC;CACH,CAAC;AAEF,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAkB3C;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAEjD"}
@@ -0,0 +1,36 @@
1
+ import type { ClickHouseClient } from '@clickhouse/client';
2
+ import { WorkflowsStorage } from '@mastra/core/storage';
3
+ import type { WorkflowRun, WorkflowRuns } from '@mastra/core/storage';
4
+ import type { WorkflowRunState } from '@mastra/core/workflows';
5
+ import type { StoreOperationsClickhouse } from '../operations/index.js';
6
+ export declare class WorkflowsStorageClickhouse extends WorkflowsStorage {
7
+ protected client: ClickHouseClient;
8
+ protected operations: StoreOperationsClickhouse;
9
+ constructor({ client, operations }: {
10
+ client: ClickHouseClient;
11
+ operations: StoreOperationsClickhouse;
12
+ });
13
+ persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
14
+ workflowName: string;
15
+ runId: string;
16
+ snapshot: WorkflowRunState;
17
+ }): Promise<void>;
18
+ loadWorkflowSnapshot({ workflowName, runId, }: {
19
+ workflowName: string;
20
+ runId: string;
21
+ }): Promise<WorkflowRunState | null>;
22
+ private parseWorkflowRun;
23
+ getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
24
+ workflowName?: string;
25
+ fromDate?: Date;
26
+ toDate?: Date;
27
+ limit?: number;
28
+ offset?: number;
29
+ resourceId?: string;
30
+ }): Promise<WorkflowRuns>;
31
+ getWorkflowRunById({ runId, workflowName, }: {
32
+ runId: string;
33
+ workflowName?: string;
34
+ }): Promise<WorkflowRun | null>;
35
+ }
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAA2B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG/D,qBAAa,0BAA2B,SAAQ,gBAAgB;IAC9D,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAAC;IACnC,SAAS,CAAC,UAAU,EAAE,yBAAyB,CAAC;gBACpC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;QAAE,MAAM,EAAE,gBAAgB,CAAC;QAAC,UAAU,EAAE,yBAAyB,CAAA;KAAE;IAMjG,uBAAuB,CAAC,EAC5B,YAAY,EACZ,KAAK,EACL,QAAQ,GACT,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,IAAI,CAAC;IA8CX,oBAAoB,CAAC,EACzB,YAAY,EACZ,KAAK,GACN,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IA4BpC,OAAO,CAAC,gBAAgB;IAqBlB,eAAe,CAAC,EACpB,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,UAAU,GACX,GAAE;QACD,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,IAAI,CAAC;QAChB,MAAM,CAAC,EAAE,IAAI,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,YAAY,CAAC;IAuFxB,kBAAkB,CAAC,EACvB,KAAK,EACL,YAAY,GACb,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CAmDhC"}
@@ -0,0 +1,206 @@
1
+ import type { ClickHouseClient } from '@clickhouse/client';
2
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
3
+ import type { MastraMessageV1, MastraMessageV2, StorageThreadType } from '@mastra/core/memory';
4
+ import type { ScoreRowData } from '@mastra/core/scores';
5
+ import { MastraStorage } from '@mastra/core/storage';
6
+ import type { TABLE_SCHEMAS, EvalRow, PaginationInfo, StorageColumn, StorageGetMessagesArg, TABLE_NAMES, WorkflowRun, WorkflowRuns, StorageGetTracesArg, StorageGetTracesPaginatedArg, StoragePagination, StorageDomains, PaginationArgs, StorageResourceType } from '@mastra/core/storage';
7
+ import type { Trace } from '@mastra/core/telemetry';
8
+ import type { WorkflowRunState } from '@mastra/core/workflows';
9
+ type IntervalUnit = 'NANOSECOND' | 'MICROSECOND' | 'MILLISECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
10
+ export type ClickhouseConfig = {
11
+ url: string;
12
+ username: string;
13
+ password: string;
14
+ ttl?: {
15
+ [TableKey in TABLE_NAMES]?: {
16
+ row?: {
17
+ interval: number;
18
+ unit: IntervalUnit;
19
+ ttlKey?: string;
20
+ };
21
+ columns?: Partial<{
22
+ [ColumnKey in keyof (typeof TABLE_SCHEMAS)[TableKey]]: {
23
+ interval: number;
24
+ unit: IntervalUnit;
25
+ ttlKey?: string;
26
+ };
27
+ }>;
28
+ };
29
+ };
30
+ };
31
+ export declare class ClickhouseStore extends MastraStorage {
32
+ protected db: ClickHouseClient;
33
+ protected ttl: ClickhouseConfig['ttl'];
34
+ stores: StorageDomains;
35
+ constructor(config: ClickhouseConfig);
36
+ get supports(): {
37
+ selectByIncludeResourceScope: boolean;
38
+ resourceWorkingMemory: boolean;
39
+ hasColumn: boolean;
40
+ createTable: boolean;
41
+ deleteMessages: boolean;
42
+ };
43
+ getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
44
+ getEvals(options: {
45
+ agentName?: string;
46
+ type?: 'test' | 'live';
47
+ } & PaginationArgs): Promise<PaginationInfo & {
48
+ evals: EvalRow[];
49
+ }>;
50
+ batchInsert({ tableName, records }: {
51
+ tableName: TABLE_NAMES;
52
+ records: Record<string, any>[];
53
+ }): Promise<void>;
54
+ optimizeTable({ tableName }: {
55
+ tableName: TABLE_NAMES;
56
+ }): Promise<void>;
57
+ materializeTtl({ tableName }: {
58
+ tableName: TABLE_NAMES;
59
+ }): Promise<void>;
60
+ createTable({ tableName, schema, }: {
61
+ tableName: TABLE_NAMES;
62
+ schema: Record<string, StorageColumn>;
63
+ }): Promise<void>;
64
+ dropTable({ tableName }: {
65
+ tableName: TABLE_NAMES;
66
+ }): Promise<void>;
67
+ alterTable({ tableName, schema, ifNotExists, }: {
68
+ tableName: TABLE_NAMES;
69
+ schema: Record<string, StorageColumn>;
70
+ ifNotExists: string[];
71
+ }): Promise<void>;
72
+ clearTable({ tableName }: {
73
+ tableName: TABLE_NAMES;
74
+ }): Promise<void>;
75
+ insert({ tableName, record }: {
76
+ tableName: TABLE_NAMES;
77
+ record: Record<string, any>;
78
+ }): Promise<void>;
79
+ load<R>({ tableName, keys }: {
80
+ tableName: TABLE_NAMES;
81
+ keys: Record<string, string>;
82
+ }): Promise<R | null>;
83
+ persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
84
+ workflowName: string;
85
+ runId: string;
86
+ snapshot: WorkflowRunState;
87
+ }): Promise<void>;
88
+ loadWorkflowSnapshot({ workflowName, runId, }: {
89
+ workflowName: string;
90
+ runId: string;
91
+ }): Promise<WorkflowRunState | null>;
92
+ getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
93
+ workflowName?: string;
94
+ fromDate?: Date;
95
+ toDate?: Date;
96
+ limit?: number;
97
+ offset?: number;
98
+ resourceId?: string;
99
+ }): Promise<WorkflowRuns>;
100
+ getWorkflowRunById({ runId, workflowName, }: {
101
+ runId: string;
102
+ workflowName?: string;
103
+ }): Promise<WorkflowRun | null>;
104
+ getTraces(args: StorageGetTracesArg): Promise<any[]>;
105
+ getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
106
+ traces: Trace[];
107
+ }>;
108
+ batchTraceInsert(args: {
109
+ records: Trace[];
110
+ }): Promise<void>;
111
+ getThreadById({ threadId }: {
112
+ threadId: string;
113
+ }): Promise<StorageThreadType | null>;
114
+ getThreadsByResourceId({ resourceId }: {
115
+ resourceId: string;
116
+ }): Promise<StorageThreadType[]>;
117
+ saveThread({ thread }: {
118
+ thread: StorageThreadType;
119
+ }): Promise<StorageThreadType>;
120
+ updateThread({ id, title, metadata, }: {
121
+ id: string;
122
+ title: string;
123
+ metadata: Record<string, unknown>;
124
+ }): Promise<StorageThreadType>;
125
+ deleteThread({ threadId }: {
126
+ threadId: string;
127
+ }): Promise<void>;
128
+ getThreadsByResourceIdPaginated(args: {
129
+ resourceId: string;
130
+ page: number;
131
+ perPage: number;
132
+ }): Promise<PaginationInfo & {
133
+ threads: StorageThreadType[];
134
+ }>;
135
+ getMessages(args: StorageGetMessagesArg & {
136
+ format?: 'v1';
137
+ }): Promise<MastraMessageV1[]>;
138
+ getMessages(args: StorageGetMessagesArg & {
139
+ format: 'v2';
140
+ }): Promise<MastraMessageV2[]>;
141
+ saveMessages(args: {
142
+ messages: MastraMessageV1[];
143
+ format?: undefined | 'v1';
144
+ }): Promise<MastraMessageV1[]>;
145
+ saveMessages(args: {
146
+ messages: MastraMessageV2[];
147
+ format: 'v2';
148
+ }): Promise<MastraMessageV2[]>;
149
+ getMessagesPaginated(args: StorageGetMessagesArg & {
150
+ format?: 'v1' | 'v2';
151
+ }): Promise<PaginationInfo & {
152
+ messages: MastraMessageV1[] | MastraMessageV2[];
153
+ }>;
154
+ updateMessages(args: {
155
+ messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
156
+ id: string;
157
+ threadId?: string;
158
+ content?: {
159
+ metadata?: MastraMessageContentV2['metadata'];
160
+ content?: MastraMessageContentV2['content'];
161
+ };
162
+ })[];
163
+ }): Promise<MastraMessageV2[]>;
164
+ getResourceById({ resourceId }: {
165
+ resourceId: string;
166
+ }): Promise<StorageResourceType | null>;
167
+ saveResource({ resource }: {
168
+ resource: StorageResourceType;
169
+ }): Promise<StorageResourceType>;
170
+ updateResource({ resourceId, workingMemory, metadata, }: {
171
+ resourceId: string;
172
+ workingMemory?: string;
173
+ metadata?: Record<string, unknown>;
174
+ }): Promise<StorageResourceType>;
175
+ getScoreById({ id }: {
176
+ id: string;
177
+ }): Promise<ScoreRowData | null>;
178
+ saveScore(_score: ScoreRowData): Promise<{
179
+ score: ScoreRowData;
180
+ }>;
181
+ getScoresByRunId({ runId, pagination, }: {
182
+ runId: string;
183
+ pagination: StoragePagination;
184
+ }): Promise<{
185
+ pagination: PaginationInfo;
186
+ scores: ScoreRowData[];
187
+ }>;
188
+ getScoresByEntityId({ entityId, entityType, pagination, }: {
189
+ pagination: StoragePagination;
190
+ entityId: string;
191
+ entityType: string;
192
+ }): Promise<{
193
+ pagination: PaginationInfo;
194
+ scores: ScoreRowData[];
195
+ }>;
196
+ getScoresByScorerId({ scorerId, pagination, }: {
197
+ scorerId: string;
198
+ pagination: StoragePagination;
199
+ }): Promise<{
200
+ pagination: PaginationInfo;
201
+ scores: ScoreRowData[];
202
+ }>;
203
+ close(): Promise<void>;
204
+ }
205
+ export {};
206
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EACV,aAAa,EACb,OAAO,EACP,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,4BAA4B,EAC5B,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAQ/D,KAAK,YAAY,GACb,YAAY,GACZ,aAAa,GACb,aAAa,GACb,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,KAAK,GACL,MAAM,GACN,OAAO,GACP,SAAS,GACT,MAAM,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,Q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": "@mastra/clickhouse",
3
- "version": "0.12.3",
3
+ "version": "0.13.0-alpha.2",
4
4
  "description": "Clickhouse provider for Mastra - includes db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,7 +12,7 @@
12
12
  "default": "./dist/index.js"
13
13
  },
14
14
  "require": {
15
- "types": "./dist/index.d.cts",
15
+ "types": "./dist/index.d.ts",
16
16
  "default": "./dist/index.cjs"
17
17
  }
18
18
  },
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@clickhouse/client": "^1.11.2"
23
+ "@clickhouse/client": "^1.12.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@microsoft/api-extractor": "^7.52.8",
@@ -29,16 +29,17 @@
29
29
  "tsup": "^8.5.0",
30
30
  "typescript": "^5.8.3",
31
31
  "vitest": "^3.2.4",
32
- "@internal/lint": "0.0.24",
33
- "@internal/storage-test-utils": "0.0.20",
34
- "@mastra/core": "0.12.0"
32
+ "@internal/lint": "0.0.26",
33
+ "@internal/storage-test-utils": "0.0.22",
34
+ "@internal/types-builder": "0.0.1",
35
+ "@mastra/core": "0.13.0-alpha.2"
35
36
  },
36
37
  "peerDependencies": {
37
- "@mastra/core": ">=0.10.7-0 <0.13.0-0"
38
+ "@mastra/core": ">=0.13.0-0 <0.14.0-0"
38
39
  },
39
40
  "scripts": {
40
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
41
- "build:watch": "pnpm build --watch",
41
+ "build": "tsup --silent --config tsup.config.ts",
42
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
42
43
  "pretest": "docker compose up -d && (for i in $(seq 1 30); do docker compose exec -T db clickhouse-client --query 'SELECT 1' && break || (sleep 1; [ $i -eq 30 ] && exit 1); done)",
43
44
  "test": "vitest run",
44
45
  "posttest": "docker compose down -v",
@@ -16,7 +16,7 @@ export class ScoresStorageClickhouse extends ScoresStorage {
16
16
 
17
17
  private transformScoreRow(row: any): ScoreRowData {
18
18
  const scorer = safelyParseJSON(row.scorer);
19
- const extractStepResult = safelyParseJSON(row.extractStepResult);
19
+ const preprocessStepResult = safelyParseJSON(row.preprocessStepResult);
20
20
  const analyzeStepResult = safelyParseJSON(row.analyzeStepResult);
21
21
  const metadata = safelyParseJSON(row.metadata);
22
22
  const input = safelyParseJSON(row.input);
@@ -28,7 +28,7 @@ export class ScoresStorageClickhouse extends ScoresStorage {
28
28
  return {
29
29
  ...row,
30
30
  scorer,
31
- extractStepResult,
31
+ preprocessStepResult,
32
32
  analyzeStepResult,
33
33
  metadata,
34
34
  input,
@@ -112,13 +112,13 @@ export class TracesStorageClickhouse extends TracesStorage {
112
112
  name: row.name,
113
113
  scope: row.scope,
114
114
  kind: row.kind,
115
- status: safelyParseJSON(row.status as string),
116
- events: safelyParseJSON(row.events as string),
117
- links: safelyParseJSON(row.links as string),
118
- attributes: safelyParseJSON(row.attributes as string),
115
+ status: safelyParseJSON(row.status),
116
+ events: safelyParseJSON(row.events),
117
+ links: safelyParseJSON(row.links),
118
+ attributes: safelyParseJSON(row.attributes),
119
119
  startTime: row.startTime,
120
120
  endTime: row.endTime,
121
- other: safelyParseJSON(row.other as string),
121
+ other: safelyParseJSON(row.other),
122
122
  createdAt: row.createdAt,
123
123
  }));
124
124
 
@@ -235,13 +235,13 @@ export class TracesStorageClickhouse extends TracesStorage {
235
235
  name: row.name,
236
236
  scope: row.scope,
237
237
  kind: row.kind,
238
- status: safelyParseJSON(row.status as string),
239
- events: safelyParseJSON(row.events as string),
240
- links: safelyParseJSON(row.links as string),
241
- attributes: safelyParseJSON(row.attributes as string),
238
+ status: safelyParseJSON(row.status),
239
+ events: safelyParseJSON(row.events),
240
+ links: safelyParseJSON(row.links),
241
+ attributes: safelyParseJSON(row.attributes),
242
242
  startTime: row.startTime,
243
243
  endTime: row.endTime,
244
- other: safelyParseJSON(row.other as string),
244
+ other: safelyParseJSON(row.other),
245
245
  createdAt: row.createdAt,
246
246
  }));
247
247
  } catch (error: any) {
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules", "**/*.test.ts", "src/**/*.mock.ts"]
9
+ }
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*"],
3
+ "include": ["src/**/*", "tsup.config.ts"],
4
4
  "exclude": ["node_modules", "**/*.test.ts"]
5
5
  }
package/tsup.config.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { generateTypes } from '@internal/types-builder';
2
+ import { defineConfig } from 'tsup';
3
+
4
+ export default defineConfig({
5
+ entry: ['src/index.ts'],
6
+ format: ['esm', 'cjs'],
7
+ clean: true,
8
+ dts: false,
9
+ splitting: true,
10
+ treeshake: {
11
+ preset: 'smallest',
12
+ },
13
+ sourcemap: true,
14
+ onSuccess: async () => {
15
+ await generateTypes(process.cwd());
16
+ },
17
+ });