@mastra/convex 0.0.0-feat-add-query-option-to-playground-20251209160219 → 0.0.0-feat-8782-cf-bindings-20260102164434

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +679 -5
  2. package/README.md +1 -1
  3. package/dist/{chunk-QKN2PWR2.cjs → chunk-BKVR7SL7.cjs} +2 -89
  4. package/dist/chunk-BKVR7SL7.cjs.map +1 -0
  5. package/dist/chunk-H5QJE733.cjs +104 -0
  6. package/dist/chunk-H5QJE733.cjs.map +1 -0
  7. package/dist/chunk-HXB4DWFE.js +73 -0
  8. package/dist/chunk-HXB4DWFE.js.map +1 -0
  9. package/dist/{chunk-NZCHEPNU.js → chunk-KSAPIIEJ.js} +5 -65
  10. package/dist/chunk-KSAPIIEJ.js.map +1 -0
  11. package/dist/docs/README.md +32 -0
  12. package/dist/docs/SKILL.md +46 -0
  13. package/dist/docs/SOURCE_MAP.json +63 -0
  14. package/dist/docs/storage/01-reference.md +140 -0
  15. package/dist/docs/vectors/01-reference.md +240 -0
  16. package/dist/index.cjs +182 -303
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.js +166 -287
  19. package/dist/index.js.map +1 -1
  20. package/dist/schema.cjs +72 -0
  21. package/dist/schema.cjs.map +1 -0
  22. package/dist/{server/schema.d.ts → schema.d.ts} +14 -1
  23. package/dist/schema.d.ts.map +1 -0
  24. package/dist/schema.js +3 -0
  25. package/dist/schema.js.map +1 -0
  26. package/dist/server/index.cjs +19 -18
  27. package/dist/server/index.d.ts +1 -1
  28. package/dist/server/index.d.ts.map +1 -1
  29. package/dist/server/index.js +2 -1
  30. package/dist/storage/db/index.d.ts +57 -0
  31. package/dist/storage/db/index.d.ts.map +1 -0
  32. package/dist/storage/domains/{memory.d.ts → memory/index.d.ts} +6 -4
  33. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  34. package/dist/storage/domains/{scores.d.ts → scores/index.d.ts} +11 -18
  35. package/dist/storage/domains/scores/index.d.ts.map +1 -0
  36. package/dist/storage/domains/{workflows.d.ts → workflows/index.d.ts} +9 -13
  37. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  38. package/dist/storage/index.d.ts +54 -157
  39. package/dist/storage/index.d.ts.map +1 -1
  40. package/package.json +16 -6
  41. package/dist/chunk-NZCHEPNU.js.map +0 -1
  42. package/dist/chunk-QKN2PWR2.cjs.map +0 -1
  43. package/dist/server/schema.d.ts.map +0 -1
  44. package/dist/storage/domains/memory.d.ts.map +0 -1
  45. package/dist/storage/domains/scores.d.ts.map +0 -1
  46. package/dist/storage/domains/workflows.d.ts.map +0 -1
  47. package/dist/storage/operations.d.ts +0 -40
  48. package/dist/storage/operations.d.ts.map +0 -1
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: mastra-convex-docs
3
+ description: Documentation for @mastra/convex. Includes links to type definitions and readable implementation code in dist/.
4
+ ---
5
+
6
+ # @mastra/convex Documentation
7
+
8
+ > **Version**: 0.1.0-beta.7
9
+ > **Package**: @mastra/convex
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
+ - mastraStorage: dist/index.d.ts
27
+ - TABLE_MESSAGES: dist/index.d.ts
28
+ - TABLE_RESOURCES: dist/index.d.ts
29
+ - TABLE_SCORERS: dist/index.d.ts
30
+ - TABLE_THREADS: dist/index.d.ts
31
+ - TABLE_WORKFLOW_SNAPSHOT: dist/index.d.ts
32
+ - mastraDocumentsTable: dist/index.d.ts
33
+ - mastraMessagesTable: dist/index.d.ts
34
+ - mastraResourcesTable: dist/index.d.ts
35
+ - mastraScoresTable: dist/index.d.ts
36
+ - mastraThreadsTable: dist/index.d.ts
37
+ - mastraVectorIndexesTable: dist/index.d.ts
38
+ - mastraVectorsTable: dist/index.d.ts
39
+ - mastraWorkflowSnapshotsTable: dist/index.d.ts
40
+
41
+ See SOURCE_MAP.json for the complete list.
42
+
43
+ ## Available Topics
44
+
45
+ - [Storage](storage/) - 1 file(s)
46
+ - [Vectors](vectors/) - 1 file(s)
@@ -0,0 +1,63 @@
1
+ {
2
+ "version": "0.1.0-beta.7",
3
+ "package": "@mastra/convex",
4
+ "exports": {
5
+ "mastraStorage": {
6
+ "types": "dist/index.d.ts",
7
+ "implementation": "dist/chunk-KSAPIIEJ.js"
8
+ },
9
+ "TABLE_MESSAGES": {
10
+ "types": "dist/index.d.ts",
11
+ "implementation": "dist/chunk-HXB4DWFE.js"
12
+ },
13
+ "TABLE_RESOURCES": {
14
+ "types": "dist/index.d.ts",
15
+ "implementation": "dist/chunk-HXB4DWFE.js"
16
+ },
17
+ "TABLE_SCORERS": {
18
+ "types": "dist/index.d.ts",
19
+ "implementation": "dist/chunk-HXB4DWFE.js"
20
+ },
21
+ "TABLE_THREADS": {
22
+ "types": "dist/index.d.ts",
23
+ "implementation": "dist/chunk-HXB4DWFE.js"
24
+ },
25
+ "TABLE_WORKFLOW_SNAPSHOT": {
26
+ "types": "dist/index.d.ts",
27
+ "implementation": "dist/chunk-HXB4DWFE.js"
28
+ },
29
+ "mastraDocumentsTable": {
30
+ "types": "dist/index.d.ts",
31
+ "implementation": "dist/chunk-HXB4DWFE.js"
32
+ },
33
+ "mastraMessagesTable": {
34
+ "types": "dist/index.d.ts",
35
+ "implementation": "dist/chunk-HXB4DWFE.js"
36
+ },
37
+ "mastraResourcesTable": {
38
+ "types": "dist/index.d.ts",
39
+ "implementation": "dist/chunk-HXB4DWFE.js"
40
+ },
41
+ "mastraScoresTable": {
42
+ "types": "dist/index.d.ts",
43
+ "implementation": "dist/chunk-HXB4DWFE.js"
44
+ },
45
+ "mastraThreadsTable": {
46
+ "types": "dist/index.d.ts",
47
+ "implementation": "dist/chunk-HXB4DWFE.js"
48
+ },
49
+ "mastraVectorIndexesTable": {
50
+ "types": "dist/index.d.ts",
51
+ "implementation": "dist/chunk-HXB4DWFE.js"
52
+ },
53
+ "mastraVectorsTable": {
54
+ "types": "dist/index.d.ts",
55
+ "implementation": "dist/chunk-HXB4DWFE.js"
56
+ },
57
+ "mastraWorkflowSnapshotsTable": {
58
+ "types": "dist/index.d.ts",
59
+ "implementation": "dist/chunk-HXB4DWFE.js"
60
+ }
61
+ },
62
+ "modules": {}
63
+ }
@@ -0,0 +1,140 @@
1
+ # Storage API Reference
2
+
3
+ > API reference for storage - 1 entries
4
+
5
+
6
+ ---
7
+
8
+ ## Reference: Convex Storage
9
+
10
+ > Documentation for the Convex storage implementation in Mastra.
11
+
12
+ The Convex storage implementation provides a serverless storage solution using [Convex](https://convex.dev), a full-stack TypeScript development platform with real-time sync and automatic caching.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @mastra/convex@beta
18
+ ```
19
+
20
+ ## Convex Setup
21
+
22
+ Before using `ConvexStore`, you need to set up the Convex schema and storage handler in your Convex project.
23
+
24
+ ### 1. Set up Convex Schema
25
+
26
+ In `convex/schema.ts`:
27
+
28
+ ```typescript
29
+ import { defineSchema } from 'convex/server';
30
+ import {
31
+ mastraThreadsTable,
32
+ mastraMessagesTable,
33
+ mastraResourcesTable,
34
+ mastraWorkflowSnapshotsTable,
35
+ mastraScoresTable,
36
+ mastraVectorIndexesTable,
37
+ mastraVectorsTable,
38
+ mastraDocumentsTable,
39
+ } from '@mastra/convex/schema';
40
+
41
+ export default defineSchema({
42
+ mastra_threads: mastraThreadsTable,
43
+ mastra_messages: mastraMessagesTable,
44
+ mastra_resources: mastraResourcesTable,
45
+ mastra_workflow_snapshots: mastraWorkflowSnapshotsTable,
46
+ mastra_scorers: mastraScoresTable,
47
+ mastra_vector_indexes: mastraVectorIndexesTable,
48
+ mastra_vectors: mastraVectorsTable,
49
+ mastra_documents: mastraDocumentsTable,
50
+ });
51
+ ```
52
+
53
+ ### 2. Create the Storage Handler
54
+
55
+ In `convex/mastra/storage.ts`:
56
+
57
+ ```typescript
58
+ import { mastraStorage } from '@mastra/convex/server';
59
+
60
+ export const handle = mastraStorage;
61
+ ```
62
+
63
+ ### 3. Deploy to Convex
64
+
65
+ ```bash
66
+ npx convex dev
67
+ # or for production
68
+ npx convex deploy
69
+ ```
70
+
71
+ ## Usage
72
+
73
+ ```typescript
74
+ import { ConvexStore } from "@mastra/convex";
75
+
76
+ const storage = new ConvexStore({
77
+ id: 'convex-storage',
78
+ deploymentUrl: process.env.CONVEX_URL!,
79
+ adminAuthToken: process.env.CONVEX_ADMIN_KEY!,
80
+ });
81
+ ```
82
+
83
+ ## Parameters
84
+
85
+ ## Constructor Examples
86
+
87
+ ```ts
88
+ import { ConvexStore } from "@mastra/convex";
89
+
90
+ // Basic configuration
91
+ const store = new ConvexStore({
92
+ id: 'convex-storage',
93
+ deploymentUrl: "https://your-project.convex.cloud",
94
+ adminAuthToken: "your-admin-token",
95
+ });
96
+
97
+ // With custom storage function path
98
+ const storeCustom = new ConvexStore({
99
+ id: 'convex-storage',
100
+ deploymentUrl: "https://your-project.convex.cloud",
101
+ adminAuthToken: "your-admin-token",
102
+ storageFunction: "custom/path:handler",
103
+ });
104
+ ```
105
+
106
+ ## Additional Notes
107
+
108
+ ### Schema Management
109
+
110
+ The storage implementation uses typed Convex tables for each Mastra domain:
111
+
112
+ | Domain | Convex Table | Purpose |
113
+ | -------------- | --------------------------- | -------------------- |
114
+ | Threads | `mastra_threads` | Conversation threads |
115
+ | Messages | `mastra_messages` | Chat messages |
116
+ | Resources | `mastra_resources` | User working memory |
117
+ | Workflows | `mastra_workflow_snapshots` | Workflow state |
118
+ | Scorers | `mastra_scorers` | Evaluation data |
119
+ | Fallback | `mastra_documents` | Unknown tables |
120
+
121
+ ### Architecture
122
+
123
+ All typed tables include:
124
+
125
+ - An `id` field for Mastra's record ID (distinct from Convex's auto-generated `_id`)
126
+ - A `by_record_id` index for efficient lookups by Mastra ID
127
+
128
+ This design ensures compatibility with Mastra's storage contract while leveraging Convex's automatic indexing and real-time capabilities.
129
+
130
+ ### Environment Variables
131
+
132
+ Set these environment variables for your deployment:
133
+
134
+ - `CONVEX_URL` – Your Convex deployment URL
135
+ - `CONVEX_ADMIN_KEY` – Admin authentication token (get from Convex dashboard)
136
+
137
+ ## Related
138
+
139
+ - [Convex Vector Store](../vectors/convex)
140
+ - [Convex Documentation](https://docs.convex.dev/)
@@ -0,0 +1,240 @@
1
+ # Vectors API Reference
2
+
3
+ > API reference for vectors - 1 entries
4
+
5
+
6
+ ---
7
+
8
+ ## Reference: Convex Vector Store
9
+
10
+ > Documentation for the ConvexVector class in Mastra, which provides vector search using Convex.
11
+
12
+ The ConvexVector class provides vector storage and similarity search using [Convex](https://convex.dev). It stores embeddings inside Convex and performs cosine similarity search.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @mastra/convex@beta
18
+ ```
19
+
20
+ ## Convex Setup
21
+
22
+ Before using `ConvexVector`, you need to set up the Convex schema and storage handler. See [Convex Storage Setup](../storage/convex#convex-setup) for setup instructions.
23
+
24
+ ## Constructor Options
25
+
26
+ ## Constructor Examples
27
+
28
+ ### Basic Configuration
29
+
30
+ ```ts
31
+ import { ConvexVector } from "@mastra/convex";
32
+
33
+ const vectorStore = new ConvexVector({
34
+ id: 'convex-vectors',
35
+ deploymentUrl: "https://your-project.convex.cloud",
36
+ adminAuthToken: "your-admin-token",
37
+ });
38
+ ```
39
+
40
+ ### Custom Storage Function
41
+
42
+ ```ts
43
+ const vectorStore = new ConvexVector({
44
+ id: 'convex-vectors',
45
+ deploymentUrl: "https://your-project.convex.cloud",
46
+ adminAuthToken: "your-admin-token",
47
+ storageFunction: "custom/path:handler",
48
+ });
49
+ ```
50
+
51
+ ## Methods
52
+
53
+ ### createIndex()
54
+
55
+ ```typescript
56
+ await vectorStore.createIndex({
57
+ indexName: "my_vectors",
58
+ dimension: 1536,
59
+ });
60
+ ```
61
+
62
+ ### upsert()
63
+
64
+ ```typescript
65
+ await vectorStore.upsert({
66
+ indexName: "my_vectors",
67
+ vectors: [[0.1, 0.2, 0.3, ...]],
68
+ metadata: [{ label: "example" }],
69
+ ids: ["vec-1"],
70
+ });
71
+ ```
72
+
73
+ ### query()
74
+
75
+ ```typescript
76
+ const results = await vectorStore.query({
77
+ indexName: "my_vectors",
78
+ queryVector: [0.1, 0.2, 0.3, ...],
79
+ topK: 5,
80
+ filter: { category: "documents" },
81
+ });
82
+ ```
83
+
84
+ ### listIndexes()
85
+
86
+ Returns an array of index names as strings.
87
+
88
+ ```typescript
89
+ const indexes = await vectorStore.listIndexes();
90
+ // ["my_vectors", "embeddings", ...]
91
+ ```
92
+
93
+ ### describeIndex()
94
+
95
+ Returns:
96
+
97
+ ```typescript
98
+ interface IndexStats {
99
+ dimension: number;
100
+ count: number;
101
+ metric: "cosine" | "euclidean" | "dotproduct";
102
+ }
103
+ ```
104
+
105
+ ### deleteIndex()
106
+
107
+ Deletes the index and all its vectors.
108
+
109
+ ```typescript
110
+ await vectorStore.deleteIndex({ indexName: "my_vectors" });
111
+ ```
112
+
113
+ ### updateVector()
114
+
115
+ Update a single vector by ID or by metadata filter. Either `id` or `filter` must be provided, but not both.
116
+
117
+ ```typescript
118
+ // Update by ID
119
+ await vectorStore.updateVector({
120
+ indexName: "my_vectors",
121
+ id: "vector123",
122
+ update: {
123
+ vector: [0.1, 0.2, 0.3],
124
+ metadata: { label: "updated" },
125
+ },
126
+ });
127
+
128
+ // Update by filter
129
+ await vectorStore.updateVector({
130
+ indexName: "my_vectors",
131
+ filter: { category: "product" },
132
+ update: {
133
+ metadata: { status: "reviewed" },
134
+ },
135
+ });
136
+ ```
137
+
138
+ ### deleteVector()
139
+
140
+ ```typescript
141
+ await vectorStore.deleteVector({ indexName: "my_vectors", id: "vector123" });
142
+ ```
143
+
144
+ ### deleteVectors()
145
+
146
+ Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both.
147
+
148
+ ```typescript
149
+ // Delete by IDs
150
+ await vectorStore.deleteVectors({
151
+ indexName: "my_vectors",
152
+ ids: ["vec1", "vec2", "vec3"],
153
+ });
154
+
155
+ // Delete by filter
156
+ await vectorStore.deleteVectors({
157
+ indexName: "my_vectors",
158
+ filter: { status: "archived" },
159
+ });
160
+ ```
161
+
162
+ ## Response Types
163
+
164
+ Query results are returned in this format:
165
+
166
+ ```typescript
167
+ interface QueryResult {
168
+ id: string;
169
+ score: number;
170
+ metadata: Record<string, any>;
171
+ vector?: number[]; // Only included if includeVector is true
172
+ }
173
+ ```
174
+
175
+ ## Metadata Filtering
176
+
177
+ ConvexVector supports metadata filtering with various operators:
178
+
179
+ ```typescript
180
+ // Simple equality
181
+ const results = await vectorStore.query({
182
+ indexName: "my_vectors",
183
+ queryVector: embedding,
184
+ filter: { category: "documents" },
185
+ });
186
+
187
+ // Comparison operators
188
+ const results = await vectorStore.query({
189
+ indexName: "my_vectors",
190
+ queryVector: embedding,
191
+ filter: {
192
+ price: { $gt: 100 },
193
+ status: { $in: ["active", "pending"] },
194
+ },
195
+ });
196
+
197
+ // Logical operators
198
+ const results = await vectorStore.query({
199
+ indexName: "my_vectors",
200
+ queryVector: embedding,
201
+ filter: {
202
+ $and: [
203
+ { category: "electronics" },
204
+ { price: { $lte: 500 } },
205
+ ],
206
+ },
207
+ });
208
+ ```
209
+
210
+ ### Supported Filter Operators
211
+
212
+ | Operator | Description |
213
+ | -------- | ----------- |
214
+ | `$eq` | Equal to |
215
+ | `$ne` | Not equal to |
216
+ | `$gt` | Greater than |
217
+ | `$gte` | Greater than or equal |
218
+ | `$lt` | Less than |
219
+ | `$lte` | Less than or equal |
220
+ | `$in` | In array |
221
+ | `$nin` | Not in array |
222
+ | `$and` | Logical AND |
223
+ | `$or` | Logical OR |
224
+
225
+ ## Architecture
226
+
227
+ ConvexVector stores vectors in the `mastra_vectors` table with the following structure:
228
+
229
+ - `id`: Unique vector identifier
230
+ - `indexName`: Name of the index
231
+ - `embedding`: The vector data (array of floats)
232
+ - `metadata`: Optional JSON metadata
233
+
234
+ Vector similarity search is performed using cosine similarity, computed in the Convex function.
235
+
236
+ ## Related
237
+
238
+ - [Convex Storage](../storage/convex)
239
+ - [Metadata Filters](../rag/metadata-filters)
240
+ - [Convex Documentation](https://docs.convex.dev/)