@mastra/clickhouse 0.0.0-working-memory-per-user-20250620163010 → 0.0.0-zod-v4-compat-part-2-20250822105954
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +168 -4
- package/LICENSE.md +12 -4
- package/dist/index.cjs +2259 -566
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2245 -550
- package/dist/index.js.map +1 -0
- package/dist/storage/domains/legacy-evals/index.d.ts +21 -0
- package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +79 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/operations/index.d.ts +42 -0
- package/dist/storage/domains/operations/index.d.ts.map +1 -0
- package/dist/storage/domains/scores/index.d.ts +43 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/traces/index.d.ts +21 -0
- package/dist/storage/domains/traces/index.d.ts.map +1 -0
- package/dist/storage/domains/utils.d.ts +28 -0
- package/dist/storage/domains/utils.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +36 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/{_tsup-dts-rollup.d.cts → storage/index.d.ts} +106 -87
- package/dist/storage/index.d.ts.map +1 -0
- package/package.json +9 -9
- package/src/storage/domains/legacy-evals/index.ts +246 -0
- package/src/storage/domains/memory/index.ts +1393 -0
- package/src/storage/domains/operations/index.ts +319 -0
- package/src/storage/domains/scores/index.ts +326 -0
- package/src/storage/domains/traces/index.ts +275 -0
- package/src/storage/domains/utils.ts +86 -0
- package/src/storage/domains/workflows/index.ts +285 -0
- package/src/storage/index.test.ts +15 -1013
- package/src/storage/index.ts +214 -1013
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +22 -0
- package/dist/_tsup-dts-rollup.d.ts +0 -187
- package/dist/index.d.cts +0 -4
package/tsconfig.json
CHANGED
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
import { defineConfig } from 'tsup';
|
|
4
|
+
|
|
5
|
+
const exec = promisify(spawn);
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
entry: ['src/index.ts'],
|
|
9
|
+
format: ['esm', 'cjs'],
|
|
10
|
+
clean: true,
|
|
11
|
+
dts: false,
|
|
12
|
+
splitting: true,
|
|
13
|
+
treeshake: {
|
|
14
|
+
preset: 'smallest',
|
|
15
|
+
},
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
onSuccess: async () => {
|
|
18
|
+
await exec('pnpm', ['tsc', '-p', 'tsconfig.build.json'], {
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import type { ClickHouseClient } from '@clickhouse/client';
|
|
2
|
-
import type { EvalRow } from '@mastra/core/storage';
|
|
3
|
-
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
4
|
-
import type { MastraMessageV1 } from '@mastra/core/memory';
|
|
5
|
-
import type { MastraMessageV2 } from '@mastra/core/memory';
|
|
6
|
-
import { MastraStorage } from '@mastra/core/storage';
|
|
7
|
-
import type { PaginationInfo } from '@mastra/core/storage';
|
|
8
|
-
import type { StorageColumn } from '@mastra/core/storage';
|
|
9
|
-
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
10
|
-
import type { StorageGetTracesArg } from '@mastra/core/storage';
|
|
11
|
-
import type { StorageThreadType } from '@mastra/core/memory';
|
|
12
|
-
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
13
|
-
import { TABLE_SCHEMAS } from '@mastra/core/storage';
|
|
14
|
-
import type { Trace } from '@mastra/core/telemetry';
|
|
15
|
-
import type { WorkflowRun } from '@mastra/core/storage';
|
|
16
|
-
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
17
|
-
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
18
|
-
|
|
19
|
-
declare type ClickhouseConfig = {
|
|
20
|
-
url: string;
|
|
21
|
-
username: string;
|
|
22
|
-
password: string;
|
|
23
|
-
ttl?: {
|
|
24
|
-
[TableKey in TABLE_NAMES]?: {
|
|
25
|
-
row?: {
|
|
26
|
-
interval: number;
|
|
27
|
-
unit: IntervalUnit;
|
|
28
|
-
ttlKey?: string;
|
|
29
|
-
};
|
|
30
|
-
columns?: Partial<{
|
|
31
|
-
[ColumnKey in keyof (typeof TABLE_SCHEMAS)[TableKey]]: {
|
|
32
|
-
interval: number;
|
|
33
|
-
unit: IntervalUnit;
|
|
34
|
-
ttlKey?: string;
|
|
35
|
-
};
|
|
36
|
-
}>;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export { ClickhouseConfig }
|
|
41
|
-
export { ClickhouseConfig as ClickhouseConfig_alias_1 }
|
|
42
|
-
|
|
43
|
-
declare class ClickhouseStore extends MastraStorage {
|
|
44
|
-
protected db: ClickHouseClient;
|
|
45
|
-
protected ttl: ClickhouseConfig['ttl'];
|
|
46
|
-
constructor(config: ClickhouseConfig);
|
|
47
|
-
private transformEvalRow;
|
|
48
|
-
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
49
|
-
batchInsert({ tableName, records }: {
|
|
50
|
-
tableName: TABLE_NAMES;
|
|
51
|
-
records: Record<string, any>[];
|
|
52
|
-
}): Promise<void>;
|
|
53
|
-
getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }: {
|
|
54
|
-
name?: string;
|
|
55
|
-
scope?: string;
|
|
56
|
-
page: number;
|
|
57
|
-
perPage: number;
|
|
58
|
-
attributes?: Record<string, string>;
|
|
59
|
-
filters?: Record<string, any>;
|
|
60
|
-
fromDate?: Date;
|
|
61
|
-
toDate?: Date;
|
|
62
|
-
}): Promise<any[]>;
|
|
63
|
-
optimizeTable({ tableName }: {
|
|
64
|
-
tableName: TABLE_NAMES;
|
|
65
|
-
}): Promise<void>;
|
|
66
|
-
materializeTtl({ tableName }: {
|
|
67
|
-
tableName: TABLE_NAMES;
|
|
68
|
-
}): Promise<void>;
|
|
69
|
-
createTable({ tableName, schema, }: {
|
|
70
|
-
tableName: TABLE_NAMES;
|
|
71
|
-
schema: Record<string, StorageColumn>;
|
|
72
|
-
}): Promise<void>;
|
|
73
|
-
protected getSqlType(type: StorageColumn['type']): string;
|
|
74
|
-
/**
|
|
75
|
-
* Alters table schema to add columns if they don't exist
|
|
76
|
-
* @param tableName Name of the table
|
|
77
|
-
* @param schema Schema of the table
|
|
78
|
-
* @param ifNotExists Array of column names to add if they don't exist
|
|
79
|
-
*/
|
|
80
|
-
alterTable({ tableName, schema, ifNotExists, }: {
|
|
81
|
-
tableName: TABLE_NAMES;
|
|
82
|
-
schema: Record<string, StorageColumn>;
|
|
83
|
-
ifNotExists: string[];
|
|
84
|
-
}): Promise<void>;
|
|
85
|
-
clearTable({ tableName }: {
|
|
86
|
-
tableName: TABLE_NAMES;
|
|
87
|
-
}): Promise<void>;
|
|
88
|
-
insert({ tableName, record }: {
|
|
89
|
-
tableName: TABLE_NAMES;
|
|
90
|
-
record: Record<string, any>;
|
|
91
|
-
}): Promise<void>;
|
|
92
|
-
load<R>({ tableName, keys }: {
|
|
93
|
-
tableName: TABLE_NAMES;
|
|
94
|
-
keys: Record<string, string>;
|
|
95
|
-
}): Promise<R | null>;
|
|
96
|
-
getThreadById({ threadId }: {
|
|
97
|
-
threadId: string;
|
|
98
|
-
}): Promise<StorageThreadType | null>;
|
|
99
|
-
getThreadsByResourceId({ resourceId }: {
|
|
100
|
-
resourceId: string;
|
|
101
|
-
}): Promise<StorageThreadType[]>;
|
|
102
|
-
saveThread({ thread }: {
|
|
103
|
-
thread: StorageThreadType;
|
|
104
|
-
}): Promise<StorageThreadType>;
|
|
105
|
-
updateThread({ id, title, metadata, }: {
|
|
106
|
-
id: string;
|
|
107
|
-
title: string;
|
|
108
|
-
metadata: Record<string, unknown>;
|
|
109
|
-
}): Promise<StorageThreadType>;
|
|
110
|
-
deleteThread({ threadId }: {
|
|
111
|
-
threadId: string;
|
|
112
|
-
}): Promise<void>;
|
|
113
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
114
|
-
format?: 'v1';
|
|
115
|
-
}): Promise<MastraMessageV1[]>;
|
|
116
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
117
|
-
format: 'v2';
|
|
118
|
-
}): Promise<MastraMessageV2[]>;
|
|
119
|
-
saveMessages(args: {
|
|
120
|
-
messages: MastraMessageV1[];
|
|
121
|
-
format?: undefined | 'v1';
|
|
122
|
-
}): Promise<MastraMessageV1[]>;
|
|
123
|
-
saveMessages(args: {
|
|
124
|
-
messages: MastraMessageV2[];
|
|
125
|
-
format: 'v2';
|
|
126
|
-
}): Promise<MastraMessageV2[]>;
|
|
127
|
-
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
128
|
-
workflowName: string;
|
|
129
|
-
runId: string;
|
|
130
|
-
snapshot: WorkflowRunState;
|
|
131
|
-
}): Promise<void>;
|
|
132
|
-
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
133
|
-
workflowName: string;
|
|
134
|
-
runId: string;
|
|
135
|
-
}): Promise<WorkflowRunState | null>;
|
|
136
|
-
private parseWorkflowRun;
|
|
137
|
-
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
138
|
-
workflowName?: string;
|
|
139
|
-
fromDate?: Date;
|
|
140
|
-
toDate?: Date;
|
|
141
|
-
limit?: number;
|
|
142
|
-
offset?: number;
|
|
143
|
-
resourceId?: string;
|
|
144
|
-
}): Promise<WorkflowRuns>;
|
|
145
|
-
getWorkflowRunById({ runId, workflowName, }: {
|
|
146
|
-
runId: string;
|
|
147
|
-
workflowName?: string;
|
|
148
|
-
}): Promise<WorkflowRun | null>;
|
|
149
|
-
private hasColumn;
|
|
150
|
-
getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
|
|
151
|
-
traces: Trace[];
|
|
152
|
-
}>;
|
|
153
|
-
getThreadsByResourceIdPaginated(_args: {
|
|
154
|
-
resourceId: string;
|
|
155
|
-
page?: number;
|
|
156
|
-
perPage?: number;
|
|
157
|
-
}): Promise<PaginationInfo & {
|
|
158
|
-
threads: StorageThreadType[];
|
|
159
|
-
}>;
|
|
160
|
-
getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
|
|
161
|
-
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
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[]>;
|
|
173
|
-
}
|
|
174
|
-
export { ClickhouseStore }
|
|
175
|
-
export { ClickhouseStore as ClickhouseStore_alias_1 }
|
|
176
|
-
|
|
177
|
-
declare const COLUMN_TYPES: Record<StorageColumn['type'], string>;
|
|
178
|
-
export { COLUMN_TYPES }
|
|
179
|
-
export { COLUMN_TYPES as COLUMN_TYPES_alias_1 }
|
|
180
|
-
|
|
181
|
-
declare type IntervalUnit = 'NANOSECOND' | 'MICROSECOND' | 'MILLISECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
|
|
182
|
-
|
|
183
|
-
declare const TABLE_ENGINES: Record<TABLE_NAMES, string>;
|
|
184
|
-
export { TABLE_ENGINES }
|
|
185
|
-
export { TABLE_ENGINES as TABLE_ENGINES_alias_1 }
|
|
186
|
-
|
|
187
|
-
export { }
|
package/dist/index.d.cts
DELETED