@mastra/convex 0.0.0-top-level-fix-20251211111608 → 0.0.0-unified-workspace-snapshot-20260128233410

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 +884 -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-FTVDAP6U.cjs +113 -0
  6. package/dist/chunk-FTVDAP6U.cjs.map +1 -0
  7. package/dist/chunk-G5FLGAPE.js +82 -0
  8. package/dist/chunk-G5FLGAPE.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 +146 -0
  15. package/dist/docs/vectors/01-reference.md +240 -0
  16. package/dist/index.cjs +221 -307
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.js +205 -291
  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} +38 -3
  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 +66 -0
  31. package/dist/storage/db/index.d.ts.map +1 -0
  32. package/dist/storage/domains/{memory.d.ts → memory/index.d.ts} +8 -6
  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 +56 -159
  39. package/dist/storage/index.d.ts.map +1 -1
  40. package/package.json +23 -13
  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**: 1.0.0
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": "1.0.0",
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-G5FLGAPE.js"
12
+ },
13
+ "TABLE_RESOURCES": {
14
+ "types": "dist/index.d.ts",
15
+ "implementation": "dist/chunk-G5FLGAPE.js"
16
+ },
17
+ "TABLE_SCORERS": {
18
+ "types": "dist/index.d.ts",
19
+ "implementation": "dist/chunk-G5FLGAPE.js"
20
+ },
21
+ "TABLE_THREADS": {
22
+ "types": "dist/index.d.ts",
23
+ "implementation": "dist/chunk-G5FLGAPE.js"
24
+ },
25
+ "TABLE_WORKFLOW_SNAPSHOT": {
26
+ "types": "dist/index.d.ts",
27
+ "implementation": "dist/chunk-G5FLGAPE.js"
28
+ },
29
+ "mastraDocumentsTable": {
30
+ "types": "dist/index.d.ts",
31
+ "implementation": "dist/chunk-G5FLGAPE.js"
32
+ },
33
+ "mastraMessagesTable": {
34
+ "types": "dist/index.d.ts",
35
+ "implementation": "dist/chunk-G5FLGAPE.js"
36
+ },
37
+ "mastraResourcesTable": {
38
+ "types": "dist/index.d.ts",
39
+ "implementation": "dist/chunk-G5FLGAPE.js"
40
+ },
41
+ "mastraScoresTable": {
42
+ "types": "dist/index.d.ts",
43
+ "implementation": "dist/chunk-G5FLGAPE.js"
44
+ },
45
+ "mastraThreadsTable": {
46
+ "types": "dist/index.d.ts",
47
+ "implementation": "dist/chunk-G5FLGAPE.js"
48
+ },
49
+ "mastraVectorIndexesTable": {
50
+ "types": "dist/index.d.ts",
51
+ "implementation": "dist/chunk-G5FLGAPE.js"
52
+ },
53
+ "mastraVectorsTable": {
54
+ "types": "dist/index.d.ts",
55
+ "implementation": "dist/chunk-G5FLGAPE.js"
56
+ },
57
+ "mastraWorkflowSnapshotsTable": {
58
+ "types": "dist/index.d.ts",
59
+ "implementation": "dist/chunk-G5FLGAPE.js"
60
+ }
61
+ },
62
+ "modules": {}
63
+ }
@@ -0,0 +1,146 @@
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
+ > **Observability Not Supported**
15
+ Convex storage **does not support the observability domain**. Traces from the `DefaultExporter` cannot be persisted to Convex, and Mastra Studio's observability features won't work with Convex as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite#specialized-storage-for-observability-recommended-for-production) to route observability data to a supported provider like ClickHouse or PostgreSQL.
16
+
17
+ > **Record Size Limit**
18
+ Convex enforces a **1 MiB maximum record size**. This limit can be exceeded when storing messages with base64-encoded attachments such as images. See [Handling large attachments](https://mastra.ai/docs/memory/storage#handling-large-attachments) for workarounds including uploading attachments to external storage like S3, Cloudflare R2, or [Convex file storage](https://docs.convex.dev/file-storage).
19
+
20
+ ## Installation
21
+
22
+ ```bash npm2yarn
23
+ npm install @mastra/convex@latest
24
+ ```
25
+
26
+ ## Convex Setup
27
+
28
+ Before using `ConvexStore`, you need to set up the Convex schema and storage handler in your Convex project.
29
+
30
+ ### 1. Set up Convex Schema
31
+
32
+ In `convex/schema.ts`:
33
+
34
+ ```typescript
35
+ import { defineSchema } from 'convex/server';
36
+ import {
37
+ mastraThreadsTable,
38
+ mastraMessagesTable,
39
+ mastraResourcesTable,
40
+ mastraWorkflowSnapshotsTable,
41
+ mastraScoresTable,
42
+ mastraVectorIndexesTable,
43
+ mastraVectorsTable,
44
+ mastraDocumentsTable,
45
+ } from '@mastra/convex/schema';
46
+
47
+ export default defineSchema({
48
+ mastra_threads: mastraThreadsTable,
49
+ mastra_messages: mastraMessagesTable,
50
+ mastra_resources: mastraResourcesTable,
51
+ mastra_workflow_snapshots: mastraWorkflowSnapshotsTable,
52
+ mastra_scorers: mastraScoresTable,
53
+ mastra_vector_indexes: mastraVectorIndexesTable,
54
+ mastra_vectors: mastraVectorsTable,
55
+ mastra_documents: mastraDocumentsTable,
56
+ });
57
+ ```
58
+
59
+ ### 2. Create the Storage Handler
60
+
61
+ In `convex/mastra/storage.ts`:
62
+
63
+ ```typescript
64
+ import { mastraStorage } from '@mastra/convex/server';
65
+
66
+ export const handle = mastraStorage;
67
+ ```
68
+
69
+ ### 3. Deploy to Convex
70
+
71
+ ```bash
72
+ npx convex dev
73
+ # or for production
74
+ npx convex deploy
75
+ ```
76
+
77
+ ## Usage
78
+
79
+ ```typescript
80
+ import { ConvexStore } from "@mastra/convex";
81
+
82
+ const storage = new ConvexStore({
83
+ id: 'convex-storage',
84
+ deploymentUrl: process.env.CONVEX_URL!,
85
+ adminAuthToken: process.env.CONVEX_ADMIN_KEY!,
86
+ });
87
+ ```
88
+
89
+ ## Parameters
90
+
91
+ ## Constructor Examples
92
+
93
+ ```ts
94
+ import { ConvexStore } from "@mastra/convex";
95
+
96
+ // Basic configuration
97
+ const store = new ConvexStore({
98
+ id: 'convex-storage',
99
+ deploymentUrl: "https://your-project.convex.cloud",
100
+ adminAuthToken: "your-admin-token",
101
+ });
102
+
103
+ // With custom storage function path
104
+ const storeCustom = new ConvexStore({
105
+ id: 'convex-storage',
106
+ deploymentUrl: "https://your-project.convex.cloud",
107
+ adminAuthToken: "your-admin-token",
108
+ storageFunction: "custom/path:handler",
109
+ });
110
+ ```
111
+
112
+ ## Additional Notes
113
+
114
+ ### Schema Management
115
+
116
+ The storage implementation uses typed Convex tables for each Mastra domain:
117
+
118
+ | Domain | Convex Table | Purpose |
119
+ | -------------- | --------------------------- | -------------------- |
120
+ | Threads | `mastra_threads` | Conversation threads |
121
+ | Messages | `mastra_messages` | Chat messages |
122
+ | Resources | `mastra_resources` | User working memory |
123
+ | Workflows | `mastra_workflow_snapshots` | Workflow state |
124
+ | Scorers | `mastra_scorers` | Evaluation data |
125
+ | Fallback | `mastra_documents` | Unknown tables |
126
+
127
+ ### Architecture
128
+
129
+ All typed tables include:
130
+
131
+ - An `id` field for Mastra's record ID (distinct from Convex's auto-generated `_id`)
132
+ - A `by_record_id` index for efficient lookups by Mastra ID
133
+
134
+ This design ensures compatibility with Mastra's storage contract while leveraging Convex's automatic indexing and real-time capabilities.
135
+
136
+ ### Environment Variables
137
+
138
+ Set these environment variables for your deployment:
139
+
140
+ - `CONVEX_URL` – Your Convex deployment URL
141
+ - `CONVEX_ADMIN_KEY` – Admin authentication token (get from Convex dashboard)
142
+
143
+ ## Related
144
+
145
+ - [Convex Vector Store](../vectors/convex)
146
+ - [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 npm2yarn
17
+ npm install @mastra/convex@latest
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/)