@mastra/valkey 0.2.1-alpha.0 → 0.2.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/README.md CHANGED
@@ -10,188 +10,7 @@ npm install @mastra/valkey
10
10
 
11
11
  ## Usage
12
12
 
13
- ### Basic Usage
14
-
15
- ```typescript
16
- import { ValkeyStore } from '@mastra/valkey';
17
-
18
- // Using connection string
19
- const storage = new ValkeyStore({
20
- id: 'my-storage',
21
- connectionString: 'valkey://localhost:6379',
22
- });
23
-
24
- // Using host/port config
25
- const storage = new ValkeyStore({
26
- id: 'my-storage',
27
- host: 'localhost',
28
- port: 6379,
29
- password: 'your-password',
30
- db: 0,
31
- });
32
-
33
- // Initialize (connects to Valkey)
34
- await storage.init();
35
- ```
36
-
37
- ### With Pre-configured Client
38
-
39
- ```typescript
40
- import { ValkeyStore } from '@mastra/valkey';
41
- import { createClient } from 'valkey';
42
-
43
- // Create a custom valkey client with specific settings
44
- const client = createClient({
45
- url: 'valkey://localhost:6379',
46
- socket: {
47
- reconnectStrategy: retries => Math.min(retries * 50, 2000),
48
- },
49
- });
50
-
51
- // Connect the client before passing to ValkeyStore
52
- await client.connect();
53
-
54
- const storage = new ValkeyStore({
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` | Valkey connection URL (e.g., `valkey://localhost:6379`) |
66
- | `host` | `string` | Valkey host address |
67
- | `port` | `number` | Valkey port (default: 6379) |
68
- | `password` | `string` | Valkey password for authentication |
69
- | `db` | `number` | Valkey database number (default: 0) |
70
- | `client` | `ValkeyClient` | Pre-configured valkey client (from the `valkey` 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 { ValkeyStore } from '@mastra/valkey';
96
-
97
- export const valkeyAgent = new Agent({
98
- id: 'valkey-agent',
99
- name: 'Valkey Agent',
100
- instructions: 'You are an AI agent with memory backed by Valkey.',
101
- model: 'openai/gpt-4',
102
- memory: new Memory({
103
- storage: new ValkeyStore({
104
- id: 'valkey-agent-storage',
105
- connectionString: process.env.VALKEY_URL!,
106
- }),
107
- options: {
108
- generateTitle: true,
109
- },
110
- }),
111
- });
112
- ```
113
-
114
- ## Accessing the Underlying Client
115
-
116
- You can access the underlying valkey client for advanced operations:
117
-
118
- ```typescript
119
- const storage = new ValkeyStore({
120
- id: 'my-storage',
121
- connectionString: 'valkey://localhost:6379',
122
- });
123
-
124
- await storage.init();
125
-
126
- // Get the valkey 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 Valkey 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 Valkey connections via the official `valkey` package (node-valkey)
149
- - Support for Valkey 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 Valkey
159
-
160
- ```typescript
161
- const storage = new ValkeyStore({
162
- id: 'standalone',
163
- host: 'localhost',
164
- port: 6379,
165
- });
166
- ```
167
-
168
- ### Valkey with Password
169
-
170
- ```typescript
171
- const storage = new ValkeyStore({
172
- id: 'auth',
173
- connectionString: 'valkey://:password@localhost:6379',
174
- });
175
- ```
176
-
177
- ### Valkey Sentinel (via custom client)
178
-
179
- ```typescript
180
- import { createClient } from 'valkey';
181
-
182
- const client = createClient({
183
- url: 'valkey://localhost:26379',
184
- // Configure sentinel options as needed
185
- });
186
- await client.connect();
187
-
188
- const storage = new ValkeyStore({
189
- id: 'sentinel',
190
- client,
191
- });
192
- ```
193
-
194
- ### Valkey Cluster (via custom client)
13
+ Configure the database credentials required by your provider.
195
14
 
196
15
  ```typescript
197
16
  import { ValkeyStore } from '@mastra/valkey';
@@ -208,16 +27,15 @@ const storage = new ValkeyStore({
208
27
  });
209
28
  ```
210
29
 
211
- ## Closing Connections
30
+ ## Documentation
212
31
 
213
- Always close connections when done:
32
+ - [Valkey integration guide](https://mastra.ai/integrations/databases/valkey)
33
+ - [Storage reference](https://mastra.ai/reference/storage/overview)
214
34
 
215
- ```typescript
216
- await storage.close();
217
- ```
35
+ ## Changelog
36
+
37
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/stores/valkey/CHANGELOG.md) for version history and release notes.
218
38
 
219
- ## Related Links
39
+ ## Support
220
40
 
221
- - [Valkey Documentation](https://valkey.io/documentation)
222
- - [node-valkey Documentation](https://github.com/valkey/node-valkey)
223
- - [Mastra Documentation](https://mastra.ai/docs)
41
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
@@ -3,7 +3,7 @@ name: mastra-valkey
3
3
  description: Documentation for @mastra/valkey. Use when working with @mastra/valkey APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/valkey"
6
- version: "0.2.1-alpha.0"
6
+ version: "0.2.1-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.1-alpha.0",
2
+ "version": "0.2.1-alpha.1",
3
3
  "package": "@mastra/valkey",
4
4
  "exports": {},
5
5
  "modules": {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/valkey",
3
- "version": "0.2.1-alpha.0",
3
+ "version": "0.2.1-alpha.1",
4
4
  "description": "Valkey storage and cache provider for Mastra, powered by Valkey GLIDE",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,10 +33,10 @@
33
33
  "tsx": "^4.23.1",
34
34
  "typescript": "^7.0.2",
35
35
  "vitest": "4.1.10",
36
- "@internal/storage-test-utils": "0.0.125",
36
+ "@internal/lint": "0.0.129",
37
37
  "@internal/types-builder": "0.0.104",
38
- "@mastra/core": "1.64.0-alpha.2",
39
- "@internal/lint": "0.0.129"
38
+ "@internal/storage-test-utils": "0.0.125",
39
+ "@mastra/core": "1.64.0-alpha.7"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@mastra/core": ">=1.61.0-0 <2.0.0-0"