@mastra/convex 1.1.0-alpha.0 → 1.2.0-alpha.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/README.md +31 -13
  3. package/dist/{chunk-FZDLZ4S3.js → chunk-AJFME2ZF.js} +323 -16
  4. package/dist/chunk-AJFME2ZF.js.map +1 -0
  5. package/dist/{chunk-JPWDG4L3.js → chunk-MC75WADX.js} +79 -4
  6. package/dist/chunk-MC75WADX.js.map +1 -0
  7. package/dist/{chunk-EEELVBWO.cjs → chunk-ORSDZTO4.cjs} +322 -15
  8. package/dist/chunk-ORSDZTO4.cjs.map +1 -0
  9. package/dist/{chunk-CV23JOCS.cjs → chunk-SFRHJGSM.cjs} +102 -2
  10. package/dist/chunk-SFRHJGSM.cjs.map +1 -0
  11. package/dist/docs/SKILL.md +1 -1
  12. package/dist/docs/assets/SOURCE_MAP.json +63 -23
  13. package/dist/index.cjs +634 -69
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.js +574 -49
  16. package/dist/index.js.map +1 -1
  17. package/dist/schema.cjs +60 -20
  18. package/dist/schema.d.ts +192 -2
  19. package/dist/schema.d.ts.map +1 -1
  20. package/dist/schema.js +1 -1
  21. package/dist/server/index-map.d.ts.map +1 -1
  22. package/dist/server/index.cjs +63 -23
  23. package/dist/server/index.d.ts +1 -1
  24. package/dist/server/index.d.ts.map +1 -1
  25. package/dist/server/index.js +2 -2
  26. package/dist/server/storage.d.ts.map +1 -1
  27. package/dist/storage/db/index.d.ts +28 -1
  28. package/dist/storage/db/index.d.ts.map +1 -1
  29. package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
  30. package/dist/storage/domains/channels/index.d.ts +19 -0
  31. package/dist/storage/domains/channels/index.d.ts.map +1 -0
  32. package/dist/storage/domains/schedules/index.d.ts +19 -0
  33. package/dist/storage/domains/schedules/index.d.ts.map +1 -0
  34. package/dist/storage/index.d.ts +3 -1
  35. package/dist/storage/index.d.ts.map +1 -1
  36. package/dist/storage/types.d.ts +42 -0
  37. package/dist/storage/types.d.ts.map +1 -1
  38. package/package.json +5 -5
  39. package/dist/chunk-CV23JOCS.cjs.map +0 -1
  40. package/dist/chunk-EEELVBWO.cjs.map +0 -1
  41. package/dist/chunk-FZDLZ4S3.js.map +0 -1
  42. package/dist/chunk-JPWDG4L3.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,134 @@
1
1
  # @mastra/convex
2
2
 
3
+ ## 1.2.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Convex can now persist channel installations and provider configuration. ([#16718](https://github.com/mastra-ai/mastra/pull/16718))
8
+
9
+ ```ts
10
+ import { ConvexStore } from '@mastra/convex';
11
+
12
+ const storage = new ConvexStore({
13
+ id: 'app-storage',
14
+ deploymentUrl: process.env.CONVEX_URL!,
15
+ adminAuthToken: process.env.CONVEX_ADMIN_KEY!,
16
+ });
17
+
18
+ const channels = await storage.getStore('channels');
19
+
20
+ await channels?.saveInstallation({
21
+ id: 'slack-agent-1',
22
+ platform: 'slack',
23
+ agentId: 'agent-1',
24
+ status: 'active',
25
+ webhookId: 'webhook-1',
26
+ data: { teamId: 'T123', botUserId: 'U123' },
27
+ createdAt: new Date(),
28
+ updatedAt: new Date(),
29
+ });
30
+ ```
31
+
32
+ - Workflow schedules can now be stored in Convex. ([#16710](https://github.com/mastra-ai/mastra/pull/16710))
33
+
34
+ ```ts
35
+ import { ConvexStore } from '@mastra/convex';
36
+
37
+ const storage = new ConvexStore({
38
+ id: 'app-storage',
39
+ deploymentUrl: process.env.CONVEX_URL!,
40
+ adminAuthToken: process.env.CONVEX_ADMIN_KEY!,
41
+ });
42
+
43
+ const schedules = await storage.getStore('schedules');
44
+
45
+ await schedules?.createSchedule({
46
+ id: 'daily-summary',
47
+ target: { type: 'workflow', workflowId: 'summary-workflow' },
48
+ cron: '0 9 * * *',
49
+ status: 'active',
50
+ nextFireAt: Date.now(),
51
+ createdAt: Date.now(),
52
+ updatedAt: Date.now(),
53
+ });
54
+ ```
55
+
56
+ ### Patch Changes
57
+
58
+ - Improved Convex background task reliability with safer lifecycle updates, faster filtering, and smoother upgrades from older storage rows. ([#16724](https://github.com/mastra-ai/mastra/pull/16724))
59
+
60
+ - Updated dependencies [[`0cbece9`](https://github.com/mastra-ai/mastra/commit/0cbece9d832cb134a74cdbf3682d390a058215a4), [`7dfe1bc`](https://github.com/mastra-ai/mastra/commit/7dfe1bcfe71d261a6fd6bbf29b1dec49d78fb98f), [`70cb714`](https://github.com/mastra-ai/mastra/commit/70cb7149c8f16f478e15b58498254a53181750a4), [`7f9da22`](https://github.com/mastra-ai/mastra/commit/7f9da22efd5aa595e138a31de55a5f0f2f28b33d)]:
61
+ - @mastra/core@1.37.0-alpha.6
62
+
63
+ ## 1.1.0
64
+
65
+ ### Minor Changes
66
+
67
+ - Added native Convex vector search support for production workloads. The new `ConvexNativeVector` adapter uses ([#16729](https://github.com/mastra-ai/mastra/pull/16729))
68
+ Convex schema-defined vector indexes and `ctx.vectorSearch` instead of loading vectors through `ConvexVector` and
69
+ scoring them in JavaScript.
70
+
71
+ Define a native vector table in `convex/schema.ts`:
72
+
73
+ ```ts
74
+ import { defineSchema } from 'convex/server';
75
+ import { defineMastraNativeVectorTable } from '@mastra/convex/schema';
76
+
77
+ export default defineSchema({
78
+ docs_vectors: defineMastraNativeVectorTable({
79
+ dimensions: 1536,
80
+ }),
81
+ });
82
+ ```
83
+
84
+ Export the native vector handlers:
85
+
86
+ ```ts
87
+ import { mastraNativeVectorAction, mastraNativeVectorMutation, mastraNativeVectorQuery } from '@mastra/convex/server';
88
+
89
+ export const query = mastraNativeVectorAction;
90
+ export const read = mastraNativeVectorQuery;
91
+ export const write = mastraNativeVectorMutation;
92
+ ```
93
+
94
+ Then configure `ConvexNativeVector` in your Mastra app:
95
+
96
+ ```ts
97
+ import { ConvexNativeVector } from '@mastra/convex';
98
+
99
+ const vectorStore = new ConvexNativeVector({
100
+ id: 'convex-native-vectors',
101
+ deploymentUrl: process.env.CONVEX_URL!,
102
+ adminAuthToken: process.env.CONVEX_ADMIN_KEY!,
103
+ indexes: {
104
+ docs: {
105
+ tableName: 'docs_vectors',
106
+ vectorIndexName: 'by_embedding',
107
+ dimension: 1536,
108
+ },
109
+ },
110
+ });
111
+ ```
112
+
113
+ - Added `ConvexServerCache` so Convex-backed Mastra apps can keep durable stream replay and response cache state in Convex. ([#16736](https://github.com/mastra-ai/mastra/pull/16736))
114
+
115
+ ```ts
116
+ import { ConvexServerCache } from '@mastra/convex';
117
+
118
+ const cache = new ConvexServerCache({
119
+ deploymentUrl: process.env.CONVEX_URL!,
120
+ adminAuthToken: process.env.CONVEX_ADMIN_KEY!,
121
+ });
122
+ ```
123
+
124
+ The package also exports the Convex cache schema tables and server mutation for mounting the cache handler in a Convex app.
125
+ Existing Convex users who adopt the cache must add `mastra_cache` and `mastra_cache_list_items` to their Convex schema, mount the `mastraCache` handler, and deploy the schema update.
126
+
127
+ ### Patch Changes
128
+
129
+ - Updated dependencies [[`452036a`](https://github.com/mastra-ai/mastra/commit/452036a0d965b4f4c1efd93606e4f03b50b807a5), [`c272d50`](https://github.com/mastra-ai/mastra/commit/c272d50610a54496b6b6d92ccd4d37b333a2613a), [`27fd1b7`](https://github.com/mastra-ai/mastra/commit/27fd1b79ac62eb7694f92587eb7d1be05b59be01), [`5ba7253`](https://github.com/mastra-ai/mastra/commit/5ba7253745c85e8df8012a76d954c640ffa336f7), [`5556cc1`](https://github.com/mastra-ai/mastra/commit/5556cc1befec71518d84f826b3bfe3a079a9daf7), [`f73980d`](https://github.com/mastra-ai/mastra/commit/f73980d651eb5f7f1ab20582de4615a1b6f10fce), [`5499303`](https://github.com/mastra-ai/mastra/commit/54993032c1ebc09642625b78d2014e0cf84a3cae), [`a702009`](https://github.com/mastra-ai/mastra/commit/a702009d3cfaa745120f501e21c783ed4d6a3072), [`9aee493`](https://github.com/mastra-ai/mastra/commit/9aee493ed6089b5133472623dcce49934bf2d509), [`d8692af`](https://github.com/mastra-ai/mastra/commit/d8692afa253028e39cdce2aafa0ac414071a762e), [`1a9cc60`](https://github.com/mastra-ai/mastra/commit/1a9cc6069f9910fc3d59e4953ac8cd95d89ad6f5), [`8cdb86c`](https://github.com/mastra-ai/mastra/commit/8cdb86ceed1137bc2768e147dce85a0692b9fb26), [`8534d79`](https://github.com/mastra-ai/mastra/commit/8534d791fa1cb70fe1c19e2604c4b63cc10dd051), [`eda90c5`](https://github.com/mastra-ai/mastra/commit/eda90c5bfd7de11805ecc9f4552716c895fbaf78), [`a935b0a`](https://github.com/mastra-ai/mastra/commit/a935b0a0977ae3f196b33ec7621f528069c82db0), [`9c88701`](https://github.com/mastra-ai/mastra/commit/9c8870195b41a38dc40b6ba2aa55eda04df8fa69), [`c78f8cd`](https://github.com/mastra-ai/mastra/commit/c78f8cd6222a86e6c60ae5210b6929ad5221b6fb), [`e146aad`](https://github.com/mastra-ai/mastra/commit/e146aadbba66c410ba0e74bac4c50135495cb8dd), [`ac79462`](https://github.com/mastra-ai/mastra/commit/ac79462b98f1062394c45093aa515b0766f27ee2), [`1a0ec78`](https://github.com/mastra-ai/mastra/commit/1a0ec789a26cae443744e9abbd62ed6ee676af39), [`e47bca7`](https://github.com/mastra-ai/mastra/commit/e47bca7b72866d3abd173b9f530ac4318113a8ff), [`afc004f`](https://github.com/mastra-ai/mastra/commit/afc004f5cc7e30697809e7021820b9f5881e6719), [`0031d0f`](https://github.com/mastra-ai/mastra/commit/0031d0f13831d7843ac5d498734a7d92862e2ce3), [`841a222`](https://github.com/mastra-ai/mastra/commit/841a222560d8c19238f8213713f30535cdd82284), [`64c1e0b`](https://github.com/mastra-ai/mastra/commit/64c1e0b35165c96b659818bd0177aa18794ef11f), [`40d83a9`](https://github.com/mastra-ai/mastra/commit/40d83a90d9be31a1b83e04649edb703eb7753e33), [`4e88dc6`](https://github.com/mastra-ai/mastra/commit/4e88dc6b89f154c0eae37221c8126be0c23c569f), [`19018f0`](https://github.com/mastra-ai/mastra/commit/19018f05722af74a5978781a7731a654b26f7f2a), [`19281c7`](https://github.com/mastra-ai/mastra/commit/19281c70424f757219782de16c2699743c5e04d0), [`3498b49`](https://github.com/mastra-ai/mastra/commit/3498b4946be94f4313cd817733589680dcda5278), [`d52b6fe`](https://github.com/mastra-ai/mastra/commit/d52b6fe1c56853eb38864baae0bbfa75cc739ccb), [`408be73`](https://github.com/mastra-ai/mastra/commit/408be73449dfab92b51eab8c6623b6c443debc25), [`359439b`](https://github.com/mastra-ai/mastra/commit/359439bb8c635e048176306828195f8297f50021), [`71a820b`](https://github.com/mastra-ai/mastra/commit/71a820b2353fa1406772c50760a3732058a8b337), [`1698f5e`](https://github.com/mastra-ai/mastra/commit/1698f5ec141d34f22a873efdb145ce3cdf848a5e)]:
130
+ - @mastra/core@1.36.0
131
+
3
132
  ## 1.1.0-alpha.0
4
133
 
5
134
  ### Minor Changes
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Convex adapters for Mastra:
4
4
 
5
- - `ConvexStore` implements the Mastra storage contract (threads, messages, workflows, scores, resources).
5
+ - `ConvexStore` implements the Mastra storage contract (threads, messages, workflows, scores, resources, schedules, channels, background tasks).
6
6
  - `ConvexVector` stores embeddings inside Convex and performs development-scale cosine similarity search.
7
7
  - `ConvexNativeVector` uses Convex native vector search for production workloads.
8
8
  - `ConvexServerCache` stores Mastra server cache entries in Convex for durable stream replay and response caching.
@@ -28,6 +28,11 @@ import {
28
28
  mastraResourcesTable,
29
29
  mastraWorkflowSnapshotsTable,
30
30
  mastraScoresTable,
31
+ mastraSchedulesTable,
32
+ mastraScheduleTriggersTable,
33
+ mastraChannelInstallationsTable,
34
+ mastraChannelConfigTable,
35
+ mastraBackgroundTasksTable,
31
36
  mastraVectorIndexesTable,
32
37
  mastraVectorsTable,
33
38
  mastraCacheTable,
@@ -41,6 +46,11 @@ export default defineSchema({
41
46
  mastra_resources: mastraResourcesTable,
42
47
  mastra_workflow_snapshots: mastraWorkflowSnapshotsTable,
43
48
  mastra_scorers: mastraScoresTable,
49
+ mastra_schedules: mastraSchedulesTable,
50
+ mastra_schedule_triggers: mastraScheduleTriggersTable,
51
+ mastra_channel_installations: mastraChannelInstallationsTable,
52
+ mastra_channel_config: mastraChannelConfigTable,
53
+ mastra_background_tasks: mastraBackgroundTasksTable,
44
54
  mastra_vector_indexes: mastraVectorIndexesTable,
45
55
  mastra_vectors: mastraVectorsTable,
46
56
  mastra_cache: mastraCacheTable,
@@ -160,24 +170,32 @@ Native vector search uses Convex's schema-defined vector indexes and action-only
160
170
 
161
171
  This adapter uses **typed Convex tables** for each Mastra domain:
162
172
 
163
- | Domain | Convex Table | Purpose |
164
- | -------------- | --------------------------- | -------------------- |
165
- | Threads | `mastra_threads` | Conversation threads |
166
- | Messages | `mastra_messages` | Chat messages |
167
- | Resources | `mastra_resources` | User working memory |
168
- | Workflows | `mastra_workflow_snapshots` | Workflow state |
169
- | Scorers | `mastra_scorers` | Evaluation data |
170
- | Vector Indexes | `mastra_vector_indexes` | Index metadata |
171
- | Vectors | `mastra_vectors` | Embeddings |
172
- | Cache | `mastra_cache` | Cache metadata |
173
- | Cache Items | `mastra_cache_list_items` | Cache list entries |
174
- | Fallback | `mastra_documents` | Unknown tables |
173
+ | Domain | Convex Table | Purpose |
174
+ | ---------------- | ------------------------------------------------------- | -------------------------------- |
175
+ | Threads | `mastra_threads` | Conversation threads |
176
+ | Messages | `mastra_messages` | Chat messages |
177
+ | Resources | `mastra_resources` | User working memory |
178
+ | Workflows | `mastra_workflow_snapshots` | Workflow state |
179
+ | Scorers | `mastra_scorers` | Evaluation data |
180
+ | Schedules | `mastra_schedules` | Workflow schedules |
181
+ | Triggers | `mastra_schedule_triggers` | Schedule history |
182
+ | Channels | `mastra_channel_installations`, `mastra_channel_config` | Channel installations and config |
183
+ | Background Tasks | `mastra_background_tasks` | Background task state |
184
+ | Vector Indexes | `mastra_vector_indexes` | Index metadata |
185
+ | Vectors | `mastra_vectors` | Embeddings |
186
+ | Cache | `mastra_cache` | Cache metadata |
187
+ | Cache Items | `mastra_cache_list_items` | Cache list entries |
188
+ | Fallback | `mastra_documents` | Unknown tables |
175
189
 
176
190
  All typed tables include:
177
191
 
178
192
  - An `id` field for Mastra's record ID (distinct from Convex's auto-generated `_id`)
179
193
  - A `by_record_id` index for efficient lookups by Mastra ID
180
194
 
195
+ Schedule due reads and trigger-history reads use bounded Convex queries to avoid deployment read limits. When no explicit trigger-history limit is provided, the adapter returns the newest 100 rows. Schedule listing is capped at 8,000 rows per call. Schedule rows also store a normalized `workflow_id` alongside the serialized target so workflow filters can run inside Convex before the listing cap is applied.
196
+
197
+ Background task reads and updates also tolerate older rows that were written to the fallback `mastra_documents` table.
198
+
181
199
  ## Testing
182
200
 
183
201
  Set the following environment variables before running tests: