@mastra/clickhouse 1.0.0-beta.8 → 1.0.0
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 +993 -0
- package/README.md +1 -1
- package/dist/docs/README.md +31 -0
- package/dist/docs/SKILL.md +32 -0
- package/dist/docs/SOURCE_MAP.json +6 -0
- package/dist/docs/storage/01-reference.md +182 -0
- package/dist/index.cjs +392 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +393 -37
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts +50 -0
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/db/utils.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +2 -2
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +23 -0
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +42 -9
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @mastra/clickhouse Documentation
|
|
2
|
+
|
|
3
|
+
> Embedded documentation for coding agents
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Read the skill overview
|
|
9
|
+
cat docs/SKILL.md
|
|
10
|
+
|
|
11
|
+
# Get the source map
|
|
12
|
+
cat docs/SOURCE_MAP.json
|
|
13
|
+
|
|
14
|
+
# Read topic documentation
|
|
15
|
+
cat docs/<topic>/01-overview.md
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Structure
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
docs/
|
|
22
|
+
├── SKILL.md # Entry point
|
|
23
|
+
├── README.md # This file
|
|
24
|
+
├── SOURCE_MAP.json # Export index
|
|
25
|
+
├── storage/ (1 files)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Version
|
|
29
|
+
|
|
30
|
+
Package: @mastra/clickhouse
|
|
31
|
+
Version: 1.0.0
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mastra-clickhouse-docs
|
|
3
|
+
description: Documentation for @mastra/clickhouse. Includes links to type definitions and readable implementation code in dist/.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @mastra/clickhouse Documentation
|
|
7
|
+
|
|
8
|
+
> **Version**: 1.0.0
|
|
9
|
+
> **Package**: @mastra/clickhouse
|
|
10
|
+
|
|
11
|
+
## Quick Navigation
|
|
12
|
+
|
|
13
|
+
Use SOURCE_MAP.json to find any export:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cat docs/SOURCE_MAP.json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Each export maps to:
|
|
20
|
+
- **types**: `.d.ts` file with JSDoc and API signatures
|
|
21
|
+
- **implementation**: `.js` chunk file with readable source
|
|
22
|
+
- **docs**: Conceptual documentation in `docs/`
|
|
23
|
+
|
|
24
|
+
## Top Exports
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
See SOURCE_MAP.json for the complete list.
|
|
29
|
+
|
|
30
|
+
## Available Topics
|
|
31
|
+
|
|
32
|
+
- [Storage](storage/) - 1 file(s)
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Storage API Reference
|
|
2
|
+
|
|
3
|
+
> API reference for storage - 1 entries
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Reference: Composite Storage
|
|
9
|
+
|
|
10
|
+
> Documentation for combining multiple storage backends in Mastra.
|
|
11
|
+
|
|
12
|
+
`MastraCompositeStore` can compose storage domains from different providers. Use it when you need different databases for different purposes. For example, use LibSQL for memory and PostgreSQL for workflows.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
`MastraCompositeStore` is included in `@mastra/core`:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @mastra/core@beta
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
You'll also need to install the storage providers you want to compose:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @mastra/pg@beta @mastra/libsql@beta
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Storage domains
|
|
29
|
+
|
|
30
|
+
Mastra organizes storage into five specialized domains, each handling a specific type of data. Each domain can be backed by a different storage adapter, and domain classes are exported from each storage package.
|
|
31
|
+
|
|
32
|
+
| Domain | Description |
|
|
33
|
+
|--------|-------------|
|
|
34
|
+
| `memory` | Conversation persistence for agents. Stores threads (conversation sessions), messages, resources (user identities), and working memory (persistent context across conversations). |
|
|
35
|
+
| `workflows` | Workflow execution state. When workflows suspend for human input, external events, or scheduled resumption, their state is persisted here to enable resumption after server restarts. |
|
|
36
|
+
| `scores` | Evaluation results from Mastra's evals system. Scores and metrics are persisted here for analysis and comparison over time. |
|
|
37
|
+
| `observability` | Telemetry data including traces and spans. Agent interactions, tool calls, and LLM requests generate spans collected into traces for debugging and performance analysis. |
|
|
38
|
+
| `agents` | Agent configurations for stored agents. Enables agents to be defined and updated at runtime without code deployments. |
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
### Basic composition
|
|
43
|
+
|
|
44
|
+
Import domain classes directly from each store package and compose them:
|
|
45
|
+
|
|
46
|
+
```typescript title="src/mastra/index.ts"
|
|
47
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
48
|
+
import { WorkflowsPG, ScoresPG } from "@mastra/pg";
|
|
49
|
+
import { MemoryLibSQL } from "@mastra/libsql";
|
|
50
|
+
import { Mastra } from "@mastra/core";
|
|
51
|
+
|
|
52
|
+
export const mastra = new Mastra({
|
|
53
|
+
storage: new MastraCompositeStore({
|
|
54
|
+
id: "composite",
|
|
55
|
+
domains: {
|
|
56
|
+
memory: new MemoryLibSQL({ url: "file:./local.db" }),
|
|
57
|
+
workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
|
|
58
|
+
scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### With a default storage
|
|
65
|
+
|
|
66
|
+
Use `default` to specify a fallback storage, then override specific domains:
|
|
67
|
+
|
|
68
|
+
```typescript title="src/mastra/index.ts"
|
|
69
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
70
|
+
import { PostgresStore } from "@mastra/pg";
|
|
71
|
+
import { MemoryLibSQL } from "@mastra/libsql";
|
|
72
|
+
import { Mastra } from "@mastra/core";
|
|
73
|
+
|
|
74
|
+
const pgStore = new PostgresStore({
|
|
75
|
+
id: "pg",
|
|
76
|
+
connectionString: process.env.DATABASE_URL,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export const mastra = new Mastra({
|
|
80
|
+
storage: new MastraCompositeStore({
|
|
81
|
+
id: "composite",
|
|
82
|
+
default: pgStore,
|
|
83
|
+
domains: {
|
|
84
|
+
memory: new MemoryLibSQL({ url: "file:./local.db" }),
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Options
|
|
91
|
+
|
|
92
|
+
## Initialization
|
|
93
|
+
|
|
94
|
+
`MastraCompositeStore` initializes each configured domain independently. When passed to the Mastra class, `init()` is called automatically:
|
|
95
|
+
|
|
96
|
+
```typescript title="src/mastra/index.ts"
|
|
97
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
98
|
+
import { MemoryPG, WorkflowsPG, ScoresPG } from "@mastra/pg";
|
|
99
|
+
import { Mastra } from "@mastra/core";
|
|
100
|
+
|
|
101
|
+
const storage = new MastraCompositeStore({
|
|
102
|
+
id: "composite",
|
|
103
|
+
domains: {
|
|
104
|
+
memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
|
|
105
|
+
workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
|
|
106
|
+
scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const mastra = new Mastra({
|
|
111
|
+
storage, // init() called automatically
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
If using storage directly, call `init()` explicitly:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
119
|
+
import { MemoryPG } from "@mastra/pg";
|
|
120
|
+
|
|
121
|
+
const storage = new MastraCompositeStore({
|
|
122
|
+
id: "composite",
|
|
123
|
+
domains: {
|
|
124
|
+
memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
await storage.init();
|
|
129
|
+
|
|
130
|
+
// Access domain-specific stores via getStore()
|
|
131
|
+
const memoryStore = await storage.getStore("memory");
|
|
132
|
+
const thread = await memoryStore?.getThreadById({ threadId: "..." });
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Use cases
|
|
136
|
+
|
|
137
|
+
### Separate databases for different workloads
|
|
138
|
+
|
|
139
|
+
Use a local database for development while keeping production data in a managed service:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
143
|
+
import { MemoryPG, WorkflowsPG, ScoresPG } from "@mastra/pg";
|
|
144
|
+
import { MemoryLibSQL } from "@mastra/libsql";
|
|
145
|
+
|
|
146
|
+
const storage = new MastraCompositeStore({
|
|
147
|
+
id: "composite",
|
|
148
|
+
domains: {
|
|
149
|
+
// Use local SQLite for development, PostgreSQL for production
|
|
150
|
+
memory:
|
|
151
|
+
process.env.NODE_ENV === "development"
|
|
152
|
+
? new MemoryLibSQL({ url: "file:./dev.db" })
|
|
153
|
+
: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
|
|
154
|
+
workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
|
|
155
|
+
scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Specialized storage for observability
|
|
161
|
+
|
|
162
|
+
Use a time-series database for traces while keeping other data in PostgreSQL:
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
166
|
+
import { MemoryPG, WorkflowsPG, ScoresPG } from "@mastra/pg";
|
|
167
|
+
import { ObservabilityStorageClickhouse } from "@mastra/clickhouse";
|
|
168
|
+
|
|
169
|
+
const storage = new MastraCompositeStore({
|
|
170
|
+
id: "composite",
|
|
171
|
+
domains: {
|
|
172
|
+
memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
|
|
173
|
+
workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
|
|
174
|
+
scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
|
|
175
|
+
observability: new ObservabilityStorageClickhouse({
|
|
176
|
+
url: process.env.CLICKHOUSE_URL,
|
|
177
|
+
username: process.env.CLICKHOUSE_USERNAME,
|
|
178
|
+
password: process.env.CLICKHOUSE_PASSWORD,
|
|
179
|
+
}),
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
```
|