@mastra/redis 0.0.0-a2a-vnext-20260424123427

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 ADDED
@@ -0,0 +1,34 @@
1
+ # @mastra/redis
2
+
3
+ ## 0.0.0-a2a-vnext-20260424123427
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`092271d`](https://github.com/mastra-ai/mastra/commit/092271d86af4cbe0d70cbf32709dd99b58acd3dd)]:
8
+ - @mastra/core@0.0.0-a2a-vnext-20260424123427
9
+
10
+ ## 1.0.1
11
+
12
+ ### Patch Changes
13
+
14
+ - Add Redis storage provider ([#11795](https://github.com/mastra-ai/mastra/pull/11795))
15
+
16
+ Introduces `@mastra/redis`, a Redis-backed storage implementation for Mastra built on the official `redis` (node-redis) client.
17
+
18
+ Includes support for the core storage domains (memory, workflows, scores) and multiple connection options: `connectionString`, `host`/`port`/`db`/`password`, or injecting a pre-configured client for advanced setups (e.g. custom socket/retry settings, Sentinel/Cluster via custom client).
19
+
20
+ - Updated dependencies [[`20f59b8`](https://github.com/mastra-ai/mastra/commit/20f59b876cf91199efbc49a0e36b391240708f08), [`aba393e`](https://github.com/mastra-ai/mastra/commit/aba393e2da7390c69b80e516a4f153cda6f09376), [`3d83d06`](https://github.com/mastra-ai/mastra/commit/3d83d06f776f00fb5f4163dddd32a030c5c20844), [`e2687a7`](https://github.com/mastra-ai/mastra/commit/e2687a7408790c384563816a9a28ed06735684c9), [`fdd54cf`](https://github.com/mastra-ai/mastra/commit/fdd54cf612a9af876e9fdd85e534454f6e7dd518), [`6315317`](https://github.com/mastra-ai/mastra/commit/63153175fe9a7b224e5be7c209bbebc01dd9b0d5), [`a371ac5`](https://github.com/mastra-ai/mastra/commit/a371ac534aa1bb368a1acf9d8b313378dfdc787e), [`0474c2b`](https://github.com/mastra-ai/mastra/commit/0474c2b2e7c7e1ad8691dca031284841391ff1ef), [`0a5fa1d`](https://github.com/mastra-ai/mastra/commit/0a5fa1d3cb0583889d06687155f26fd7d2edc76c), [`7e0e63e`](https://github.com/mastra-ai/mastra/commit/7e0e63e2e485e84442351f4c7a79a424c83539dc), [`ea43e64`](https://github.com/mastra-ai/mastra/commit/ea43e646dd95d507694b6112b0bf1df22ad552b2), [`f607106`](https://github.com/mastra-ai/mastra/commit/f607106854c6416c4a07d4082604b9f66d047221), [`30456b6`](https://github.com/mastra-ai/mastra/commit/30456b6b08c8fd17e109dd093b73d93b65e83bc5), [`9d11a8c`](https://github.com/mastra-ai/mastra/commit/9d11a8c1c8924eb975a245a5884d40ca1b7e0491), [`9d3b24b`](https://github.com/mastra-ai/mastra/commit/9d3b24b19407ae9c09586cf7766d38dc4dff4a69), [`00d1b16`](https://github.com/mastra-ai/mastra/commit/00d1b16b401199cb294fa23f43336547db4dca9b), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`62919a6`](https://github.com/mastra-ai/mastra/commit/62919a6ee0fbf3779ad21a97b1ec6696515d5104), [`d246696`](https://github.com/mastra-ai/mastra/commit/d246696139a3144a5b21b042d41c532688e957e1), [`354f9ce`](https://github.com/mastra-ai/mastra/commit/354f9ce1ca6af2074b6a196a23f8ec30012dccca), [`16e34ca`](https://github.com/mastra-ai/mastra/commit/16e34caa98b9a114b17a6125e4e3fd87f169d0d0), [`7020c06`](https://github.com/mastra-ai/mastra/commit/7020c0690b199d9da337f0e805f16948e557922e), [`8786a61`](https://github.com/mastra-ai/mastra/commit/8786a61fa54ba265f85eeff9985ca39863d18bb6), [`9467ea8`](https://github.com/mastra-ai/mastra/commit/9467ea87695749a53dfc041576410ebf9ee7bb67), [`7338d94`](https://github.com/mastra-ai/mastra/commit/7338d949380cf68b095342e8e42610dc51d557c1), [`c80dc16`](https://github.com/mastra-ai/mastra/commit/c80dc16e113e6cc159f510ffde501ad4711b2189), [`af8a57e`](https://github.com/mastra-ai/mastra/commit/af8a57ed9ba9685ad8601d5b71ae3706da6222f9), [`d63ffdb`](https://github.com/mastra-ai/mastra/commit/d63ffdbb2c11e76fe5ea45faab44bc15460f010c), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`1bd5104`](https://github.com/mastra-ai/mastra/commit/1bd51048b6da93507276d6623e3fd96a9e1a8944), [`e9837b5`](https://github.com/mastra-ai/mastra/commit/e9837b53699e18711b09e0ca010a4106376f2653), [`8f1b280`](https://github.com/mastra-ai/mastra/commit/8f1b280b7fe6999ec654f160cb69c1a8719e7a57), [`92dcf02`](https://github.com/mastra-ai/mastra/commit/92dcf029294210ac91b090900c1a0555a425c57a), [`0fd90a2`](https://github.com/mastra-ai/mastra/commit/0fd90a215caf5fca8099c15a67ca03e4427747a3), [`8fb2405`](https://github.com/mastra-ai/mastra/commit/8fb2405138f2d208b7962ad03f121ca25bcc28c5), [`12df98c`](https://github.com/mastra-ai/mastra/commit/12df98c4904643d9481f5c78f3bed443725b4c96)]:
21
+ - @mastra/core@1.26.0
22
+
23
+ ## 1.0.1-alpha.0
24
+
25
+ ### Patch Changes
26
+
27
+ - Add Redis storage provider ([#11795](https://github.com/mastra-ai/mastra/pull/11795))
28
+
29
+ Introduces `@mastra/redis`, a Redis-backed storage implementation for Mastra built on the official `redis` (node-redis) client.
30
+
31
+ Includes support for the core storage domains (memory, workflows, scores) and multiple connection options: `connectionString`, `host`/`port`/`db`/`password`, or injecting a pre-configured client for advanced setups (e.g. custom socket/retry settings, Sentinel/Cluster via custom client).
32
+
33
+ - Updated dependencies [[`a371ac5`](https://github.com/mastra-ai/mastra/commit/a371ac534aa1bb368a1acf9d8b313378dfdc787e), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`c80dc16`](https://github.com/mastra-ai/mastra/commit/c80dc16e113e6cc159f510ffde501ad4711b2189), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e)]:
34
+ - @mastra/core@1.26.0-alpha.12
package/LICENSE.md ADDED
@@ -0,0 +1,30 @@
1
+ Portions of this software are licensed as follows:
2
+
3
+ - All content that resides under any directory named "ee/" within this
4
+ repository, including but not limited to:
5
+ - `packages/core/src/auth/ee/`
6
+ - `packages/server/src/server/auth/ee/`
7
+ is licensed under the license defined in `ee/LICENSE`.
8
+
9
+ - All third-party components incorporated into the Mastra Software are
10
+ licensed under the original license provided by the owner of the
11
+ applicable component.
12
+
13
+ - Content outside of the above-mentioned directories or restrictions is
14
+ available under the "Apache License 2.0" as defined below.
15
+
16
+ # Apache License 2.0
17
+
18
+ Copyright (c) 2025 Kepler Software, Inc.
19
+
20
+ Licensed under the Apache License, Version 2.0 (the "License");
21
+ you may not use this file except in compliance with the License.
22
+ You may obtain a copy of the License at
23
+
24
+ http://www.apache.org/licenses/LICENSE-2.0
25
+
26
+ Unless required by applicable law or agreed to in writing, software
27
+ distributed under the License is distributed on an "AS IS" BASIS,
28
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ See the License for the specific language governing permissions and
30
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,223 @@
1
+ # @mastra/redis
2
+
3
+ Redis storage provider for Mastra that provides storage capabilities for direct Redis connections.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/redis
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Basic Usage
14
+
15
+ ```typescript
16
+ import { RedisStore } from '@mastra/redis';
17
+
18
+ // Using connection string
19
+ const storage = new RedisStore({
20
+ id: 'my-storage',
21
+ connectionString: 'redis://localhost:6379',
22
+ });
23
+
24
+ // Using host/port config
25
+ const storage = new RedisStore({
26
+ id: 'my-storage',
27
+ host: 'localhost',
28
+ port: 6379,
29
+ password: 'your-password',
30
+ db: 0,
31
+ });
32
+
33
+ // Initialize (connects to Redis)
34
+ await storage.init();
35
+ ```
36
+
37
+ ### With Pre-configured Client
38
+
39
+ ```typescript
40
+ import { RedisStore } from '@mastra/redis';
41
+ import { createClient } from 'redis';
42
+
43
+ // Create a custom redis client with specific settings
44
+ const client = createClient({
45
+ url: 'redis://localhost:6379',
46
+ socket: {
47
+ reconnectStrategy: retries => Math.min(retries * 50, 2000),
48
+ },
49
+ });
50
+
51
+ // Connect the client before passing to RedisStore
52
+ await client.connect();
53
+
54
+ const storage = new RedisStore({
55
+ id: 'my-storage',
56
+ client,
57
+ });
58
+ ```
59
+
60
+ ## Parameters
61
+
62
+ | Parameter | Type | Description |
63
+ | ------------------ | ------------- | ------------------------------------------------------ |
64
+ | `id` | `string` | Unique identifier for the storage instance |
65
+ | `connectionString` | `string` | Redis connection URL (e.g., `redis://localhost:6379`) |
66
+ | `host` | `string` | Redis host address |
67
+ | `port` | `number` | Redis port (default: 6379) |
68
+ | `password` | `string` | Redis password for authentication |
69
+ | `db` | `number` | Redis database number (default: 0) |
70
+ | `client` | `RedisClient` | Pre-configured redis client (from the `redis` package) |
71
+ | `disableInit` | `boolean` | Disable automatic initialization |
72
+
73
+ ## Accessing Storage Domains
74
+
75
+ ```typescript
76
+ // Access memory domain (threads, messages, resources)
77
+ const memory = await storage.getStore('memory');
78
+ await memory?.saveThread({ thread });
79
+ await memory?.saveMessages({ messages });
80
+
81
+ // Access workflows domain
82
+ const workflows = await storage.getStore('workflows');
83
+ await workflows?.persistWorkflowSnapshot({ workflowName, runId, snapshot });
84
+
85
+ // Access scores domain
86
+ const scores = await storage.getStore('scores');
87
+ await scores?.saveScore(score);
88
+ ```
89
+
90
+ ## Usage with Mastra Agent
91
+
92
+ ```typescript
93
+ import { Memory } from '@mastra/memory';
94
+ import { Agent } from '@mastra/core/agent';
95
+ import { RedisStore } from '@mastra/redis';
96
+
97
+ export const redisAgent = new Agent({
98
+ id: 'redis-agent',
99
+ name: 'Redis Agent',
100
+ instructions: 'You are an AI agent with memory backed by Redis.',
101
+ model: 'openai/gpt-4',
102
+ memory: new Memory({
103
+ storage: new RedisStore({
104
+ id: 'redis-agent-storage',
105
+ connectionString: process.env.REDIS_URL!,
106
+ }),
107
+ options: {
108
+ generateTitle: true,
109
+ },
110
+ }),
111
+ });
112
+ ```
113
+
114
+ ## Accessing the Underlying Client
115
+
116
+ You can access the underlying redis client for advanced operations:
117
+
118
+ ```typescript
119
+ const storage = new RedisStore({
120
+ id: 'my-storage',
121
+ connectionString: 'redis://localhost:6379',
122
+ });
123
+
124
+ await storage.init();
125
+
126
+ // Get the redis client
127
+ const client = storage.getClient();
128
+
129
+ // Use for custom operations
130
+ await client.set('custom-key', 'value');
131
+ const value = await client.get('custom-key');
132
+ ```
133
+
134
+ ## Key Structure
135
+
136
+ The Redis storage uses the following key patterns:
137
+
138
+ - Threads: `mastra_threads:id:{threadId}`
139
+ - Messages: `mastra_messages:threadId:{threadId}:id:{messageId}`
140
+ - Message index: `msg-idx:{messageId}` (for fast lookups)
141
+ - Thread messages sorted set: `thread:{threadId}:messages`
142
+ - Workflow snapshots: `mastra_workflow_snapshot:namespace:{ns}:workflow_name:{name}:run_id:{id}`
143
+ - Scores: `mastra_scorers:id:{scoreId}`
144
+ - Resources: `mastra_resources:{resourceId}`
145
+
146
+ ## Features
147
+
148
+ - Direct Redis connections via the official `redis` package (node-redis)
149
+ - Support for Redis Sentinel and Cluster (via custom client)
150
+ - Persistent storage for threads, messages, and resources
151
+ - Workflow state persistence with snapshot support
152
+ - Evaluation scores storage
153
+ - Sorted sets for message ordering
154
+ - Efficient batch operations with multi/exec
155
+
156
+ ## Connection Options
157
+
158
+ ### Standalone Redis
159
+
160
+ ```typescript
161
+ const storage = new RedisStore({
162
+ id: 'standalone',
163
+ host: 'localhost',
164
+ port: 6379,
165
+ });
166
+ ```
167
+
168
+ ### Redis with Password
169
+
170
+ ```typescript
171
+ const storage = new RedisStore({
172
+ id: 'auth',
173
+ connectionString: 'redis://:password@localhost:6379',
174
+ });
175
+ ```
176
+
177
+ ### Redis Sentinel (via custom client)
178
+
179
+ ```typescript
180
+ import { createClient } from 'redis';
181
+
182
+ const client = createClient({
183
+ url: 'redis://localhost:26379',
184
+ // Configure sentinel options as needed
185
+ });
186
+ await client.connect();
187
+
188
+ const storage = new RedisStore({
189
+ id: 'sentinel',
190
+ client,
191
+ });
192
+ ```
193
+
194
+ ### Redis Cluster (via custom client)
195
+
196
+ ```typescript
197
+ import { RedisStore } from '@mastra/redis';
198
+ import { createCluster } from 'redis';
199
+
200
+ const cluster = createCluster({
201
+ rootNodes: [{ url: 'redis://node-1:6379' }, { url: 'redis://node-2:6379' }],
202
+ });
203
+ await cluster.connect();
204
+
205
+ const storage = new RedisStore({
206
+ id: 'cluster',
207
+ client: cluster,
208
+ });
209
+ ```
210
+
211
+ ## Closing Connections
212
+
213
+ Always close connections when done:
214
+
215
+ ```typescript
216
+ await storage.close();
217
+ ```
218
+
219
+ ## Related Links
220
+
221
+ - [Redis Documentation](https://redis.io/documentation)
222
+ - [node-redis Documentation](https://github.com/redis/node-redis)
223
+ - [Mastra Documentation](https://mastra.ai/docs)
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@mastra/redis",
3
+ "version": "0.0.0-a2a-vnext-20260424123427",
4
+ "description": "Redis storage provider for Mastra - provides storage capabilities for direct Redis connections",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "author": "Mauro Erta <mauro@vlkstudio.com>",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "license": "Apache-2.0",
23
+ "dependencies": {
24
+ "redis": "5.10.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "22.13.17",
28
+ "@vitest/coverage-v8": "4.1.5",
29
+ "@vitest/ui": "4.1.5",
30
+ "dotenv": "^17.0.0",
31
+ "eslint": "^9.37.0",
32
+ "tsup": "^8.5.0",
33
+ "typescript": "^5.9.3",
34
+ "vitest": "4.1.5",
35
+ "@internal/lint": "0.0.0-a2a-vnext-20260424123427",
36
+ "@mastra/core": "0.0.0-a2a-vnext-20260424123427",
37
+ "@internal/storage-test-utils": "0.0.82",
38
+ "@internal/types-builder": "0.0.0-a2a-vnext-20260424123427"
39
+ },
40
+ "peerDependencies": {
41
+ "@mastra/core": "0.0.0-a2a-vnext-20260424123427"
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "CHANGELOG.md"
46
+ ],
47
+ "homepage": "https://mastra.ai",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/mastra-ai/mastra.git",
51
+ "directory": "stores/redis"
52
+ },
53
+ "bugs": {
54
+ "url": "https://github.com/mastra-ai/mastra/issues"
55
+ },
56
+ "engines": {
57
+ "node": ">=22.13.0"
58
+ },
59
+ "scripts": {
60
+ "pretest": "docker compose up -d",
61
+ "test": "vitest run",
62
+ "posttest": "docker compose down",
63
+ "lint": "eslint .",
64
+ "build:lib": "tsup --silent --config tsup.config.ts",
65
+ "build:docs": "pnpx tsx ../../scripts/generate-package-docs.ts stores/redis",
66
+ "build:watch": "tsup --watch --silent --config tsup.config.ts"
67
+ }
68
+ }