@mastra/convex 0.0.0-new-button-export-20251219130424 → 0.0.0-remove-ai-peer-dep-from-evals-20260105220639

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.
@@ -0,0 +1,104 @@
1
+ 'use strict';
2
+
3
+ var constants = require('@mastra/core/storage/constants');
4
+ var server = require('convex/server');
5
+ var values = require('convex/values');
6
+
7
+ // src/schema.ts
8
+ function columnToValidator(column) {
9
+ let validator;
10
+ switch (column.type) {
11
+ case "text":
12
+ validator = values.v.string();
13
+ break;
14
+ case "integer":
15
+ case "float":
16
+ validator = values.v.number();
17
+ break;
18
+ case "bigint":
19
+ validator = values.v.int64();
20
+ break;
21
+ case "boolean":
22
+ validator = values.v.boolean();
23
+ break;
24
+ case "timestamp":
25
+ validator = values.v.string();
26
+ break;
27
+ case "jsonb":
28
+ case "json":
29
+ validator = values.v.any();
30
+ break;
31
+ default:
32
+ validator = values.v.any();
33
+ }
34
+ return column.nullable ? values.v.optional(validator) : validator;
35
+ }
36
+ function buildTableFromSchema(schema) {
37
+ const fields = {};
38
+ for (const [key, column] of Object.entries(schema)) {
39
+ fields[key] = columnToValidator(column);
40
+ }
41
+ return fields;
42
+ }
43
+ var mastraThreadsTable = server.defineTable(buildTableFromSchema(constants.TABLE_SCHEMAS[constants.TABLE_THREADS])).index("by_record_id", ["id"]).index("by_resource", ["resourceId"]).index("by_created", ["createdAt"]).index("by_updated", ["updatedAt"]);
44
+ var mastraMessagesTable = server.defineTable(buildTableFromSchema(constants.TABLE_SCHEMAS[constants.TABLE_MESSAGES])).index("by_record_id", ["id"]).index("by_thread", ["thread_id"]).index("by_thread_created", ["thread_id", "createdAt"]).index("by_resource", ["resourceId"]);
45
+ var mastraResourcesTable = server.defineTable(buildTableFromSchema(constants.TABLE_SCHEMAS[constants.TABLE_RESOURCES])).index("by_record_id", ["id"]).index("by_updated", ["updatedAt"]);
46
+ var mastraWorkflowSnapshotsTable = server.defineTable(buildTableFromSchema(constants.TABLE_SCHEMAS[constants.TABLE_WORKFLOW_SNAPSHOT])).index("by_record_id", ["id"]).index("by_workflow_run", ["workflow_name", "run_id"]).index("by_workflow", ["workflow_name"]).index("by_resource", ["resourceId"]).index("by_created", ["createdAt"]);
47
+ var mastraScoresTable = server.defineTable(buildTableFromSchema(constants.TABLE_SCHEMAS[constants.TABLE_SCORERS])).index("by_record_id", ["id"]).index("by_scorer", ["scorerId"]).index("by_entity", ["entityId", "entityType"]).index("by_run", ["runId"]).index("by_created", ["createdAt"]);
48
+ var mastraVectorIndexesTable = server.defineTable({
49
+ id: values.v.string(),
50
+ // Mastra record ID (same as indexName)
51
+ indexName: values.v.string(),
52
+ dimension: values.v.number(),
53
+ metric: values.v.string(),
54
+ createdAt: values.v.string()
55
+ }).index("by_record_id", ["id"]).index("by_name", ["indexName"]);
56
+ var mastraVectorsTable = server.defineTable({
57
+ id: values.v.string(),
58
+ // Mastra record ID
59
+ indexName: values.v.string(),
60
+ embedding: values.v.array(values.v.float64()),
61
+ metadata: values.v.optional(values.v.any())
62
+ }).index("by_index_id", ["indexName", "id"]).index("by_index", ["indexName"]);
63
+ var mastraDocumentsTable = server.defineTable({
64
+ table: values.v.string(),
65
+ primaryKey: values.v.string(),
66
+ record: values.v.any()
67
+ }).index("by_table", ["table"]).index("by_table_primary", ["table", "primaryKey"]);
68
+ var TABLE_VECTOR_INDEXES = "mastra_vector_indexes";
69
+ var TABLE_VECTORS = "mastra_vectors";
70
+ var TABLE_DOCUMENTS = "mastra_documents";
71
+
72
+ Object.defineProperty(exports, "TABLE_MESSAGES", {
73
+ enumerable: true,
74
+ get: function () { return constants.TABLE_MESSAGES; }
75
+ });
76
+ Object.defineProperty(exports, "TABLE_RESOURCES", {
77
+ enumerable: true,
78
+ get: function () { return constants.TABLE_RESOURCES; }
79
+ });
80
+ Object.defineProperty(exports, "TABLE_SCORERS", {
81
+ enumerable: true,
82
+ get: function () { return constants.TABLE_SCORERS; }
83
+ });
84
+ Object.defineProperty(exports, "TABLE_THREADS", {
85
+ enumerable: true,
86
+ get: function () { return constants.TABLE_THREADS; }
87
+ });
88
+ Object.defineProperty(exports, "TABLE_WORKFLOW_SNAPSHOT", {
89
+ enumerable: true,
90
+ get: function () { return constants.TABLE_WORKFLOW_SNAPSHOT; }
91
+ });
92
+ exports.TABLE_DOCUMENTS = TABLE_DOCUMENTS;
93
+ exports.TABLE_VECTORS = TABLE_VECTORS;
94
+ exports.TABLE_VECTOR_INDEXES = TABLE_VECTOR_INDEXES;
95
+ exports.mastraDocumentsTable = mastraDocumentsTable;
96
+ exports.mastraMessagesTable = mastraMessagesTable;
97
+ exports.mastraResourcesTable = mastraResourcesTable;
98
+ exports.mastraScoresTable = mastraScoresTable;
99
+ exports.mastraThreadsTable = mastraThreadsTable;
100
+ exports.mastraVectorIndexesTable = mastraVectorIndexesTable;
101
+ exports.mastraVectorsTable = mastraVectorsTable;
102
+ exports.mastraWorkflowSnapshotsTable = mastraWorkflowSnapshotsTable;
103
+ //# sourceMappingURL=chunk-H5QJE733.cjs.map
104
+ //# sourceMappingURL=chunk-H5QJE733.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts"],"names":["v","defineTable","TABLE_SCHEMAS","TABLE_THREADS","TABLE_MESSAGES","TABLE_RESOURCES","TABLE_WORKFLOW_SNAPSHOT","TABLE_SCORERS"],"mappings":";;;;;;;AAwBA,SAAS,kBAAkB,MAAA,EAA8C;AACvE,EAAA,IAAI,SAAA;AACJ,EAAA,QAAQ,OAAO,IAAA;AAAM,IACnB,KAAK,MAAA;AACH,MAAA,SAAA,GAAYA,SAAE,MAAA,EAAO;AACrB,MAAA;AAAA,IACF,KAAK,SAAA;AAAA,IACL,KAAK,OAAA;AACH,MAAA,SAAA,GAAYA,SAAE,MAAA,EAAO;AACrB,MAAA;AAAA,IACF,KAAK,QAAA;AACH,MAAA,SAAA,GAAYA,SAAE,KAAA,EAAM;AACpB,MAAA;AAAA,IACF,KAAK,SAA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,KAAA,CAAM,cAAA,EAAgB,CAAC,IAAI,CAAC,CAAA,CAC5B,KAAA,CAAM,SAAA,EAAW,CAAC,WAAW,CAAC;AAM1B,IAAM,qBAAqBC,kBAAA,CAAY;AAAA,EAC5C,EAAA,EAAID,SAAE,MAAA,EAAO;AAAA;AAAA,EACb,SAAA,EAAWA,SAAE,MAAA,EAAO;AAAA,EACpB,SAAA,EAAWA,QAAA,CAAE,KAAA,CAAMA,QAAA,CAAE,SAAS,CAAA;AAAA,EAC9B,QAAA,EAAUA,QAAA,CAAE,QAAA,CAASA,QAAA,CAAE,KAAK;AAC9B,CAAC,CAAA,CACE,KAAA,CAAM,aAAA,EAAe,CAAC,WAAA,EAAa,IAAI,CAAC,CAAA,CACxC,KAAA,CAAM,UAAA,EAAY,CAAC,WAAW,CAAC;AAS3B,IAAM,uBAAuBC,kBAAA,CAAY;AAAA,EAC9C,KAAA,EAAOD,SAAE,MAAA,EAAO;AAAA,EAChB,UAAA,EAAYA,SAAE,MAAA,EAAO;AAAA,EACrB,MAAA,EAAQA,SAAE,GAAA;AACZ,CAAC,CAAA,CACE,KAAA,CAAM,UAAA,EAAY,CAAC,OAAO,CAAC,CAAA,CAC3B,KAAA,CAAM,kBAAA,EAAoB,CAAC,OAAA,EAAS,YAAY,CAAC;AAS7C,IAAM,oBAAA,GAAuB;AAC7B,IAAM,aAAA,GAAgB;AACtB,IAAM,eAAA,GAAkB","file":"chunk-H5QJE733.cjs","sourcesContent":["/**\n * Convex schema definitions for Mastra tables.\n *\n * This file dynamically builds Convex table definitions from the canonical\n * TABLE_SCHEMAS in @mastra/core/storage/constants to ensure they stay in sync.\n *\n * The import path @mastra/core/storage/constants is specifically designed to\n * avoid pulling in Node.js dependencies, making it safe to use in Convex's\n * sandboxed schema evaluation environment.\n */\nimport {\n TABLE_SCHEMAS,\n TABLE_WORKFLOW_SNAPSHOT,\n TABLE_MESSAGES,\n TABLE_THREADS,\n TABLE_RESOURCES,\n TABLE_SCORERS,\n} from '@mastra/core/storage/constants';\nimport { defineTable } from 'convex/server';\nimport { v } from 'convex/values';\n\n/**\n * Helper to convert Mastra StorageColumn type to Convex validator\n */\nfunction columnToValidator(column: { type: string; nullable?: boolean }) {\n let validator;\n switch (column.type) {\n case 'text':\n validator = v.string();\n break;\n case 'integer':\n case 'float':\n validator = v.number();\n break;\n case 'bigint':\n validator = v.int64();\n break;\n case 'boolean':\n validator = v.boolean();\n break;\n case 'timestamp':\n validator = v.string(); // Store as ISO string\n break;\n case 'jsonb':\n case 'json':\n validator = v.any();\n break;\n default:\n validator = v.any();\n }\n return column.nullable ? v.optional(validator) : validator;\n}\n\n/**\n * Build Convex table definition from Mastra schema.\n * Includes the `id` field as a regular field (Convex auto-generates _id).\n */\nfunction buildTableFromSchema(schema: Record<string, { type: string; nullable?: boolean; primaryKey?: boolean }>) {\n const fields: Record<string, any> = {};\n for (const [key, column] of Object.entries(schema)) {\n fields[key] = columnToValidator(column);\n }\n return fields;\n}\n\n// ============================================================================\n// Table Definitions - Built from @mastra/core TABLE_SCHEMAS\n// ============================================================================\n\n/**\n * Threads table - stores conversation threads\n * Schema: TABLE_SCHEMAS[TABLE_THREADS]\n */\nexport const mastraThreadsTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_THREADS]))\n .index('by_record_id', ['id'])\n .index('by_resource', ['resourceId'])\n .index('by_created', ['createdAt'])\n .index('by_updated', ['updatedAt']);\n\n/**\n * Messages table - stores conversation messages\n * Schema: TABLE_SCHEMAS[TABLE_MESSAGES]\n */\nexport const mastraMessagesTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_MESSAGES]))\n .index('by_record_id', ['id'])\n .index('by_thread', ['thread_id'])\n .index('by_thread_created', ['thread_id', 'createdAt'])\n .index('by_resource', ['resourceId']);\n\n/**\n * Resources table - stores resource/user working memory\n * Schema: TABLE_SCHEMAS[TABLE_RESOURCES]\n */\nexport const mastraResourcesTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_RESOURCES]))\n .index('by_record_id', ['id'])\n .index('by_updated', ['updatedAt']);\n\n/**\n * Workflow snapshots table - stores workflow execution state\n * Schema: TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT]\n */\nexport const mastraWorkflowSnapshotsTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT]))\n .index('by_record_id', ['id'])\n .index('by_workflow_run', ['workflow_name', 'run_id'])\n .index('by_workflow', ['workflow_name'])\n .index('by_resource', ['resourceId'])\n .index('by_created', ['createdAt']);\n\n/**\n * Scores table - stores evaluation scores\n * Schema: TABLE_SCHEMAS[TABLE_SCORERS]\n */\nexport const mastraScoresTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_SCORERS]))\n .index('by_record_id', ['id'])\n .index('by_scorer', ['scorerId'])\n .index('by_entity', ['entityId', 'entityType'])\n .index('by_run', ['runId'])\n .index('by_created', ['createdAt']);\n\n// ============================================================================\n// Vector Tables - Not in core schemas (vector-specific)\n// ============================================================================\n\n/**\n * Vector indexes table - stores metadata about vector indexes\n */\nexport const mastraVectorIndexesTable = defineTable({\n id: v.string(), // Mastra record ID (same as indexName)\n indexName: v.string(),\n dimension: v.number(),\n metric: v.string(),\n createdAt: v.string(),\n})\n .index('by_record_id', ['id'])\n .index('by_name', ['indexName']);\n\n/**\n * Vectors table - stores vector embeddings\n * Uses indexName field to support multiple indexes with different dimensions\n */\nexport const mastraVectorsTable = defineTable({\n id: v.string(), // Mastra record ID\n indexName: v.string(),\n embedding: v.array(v.float64()),\n metadata: v.optional(v.any()),\n})\n .index('by_index_id', ['indexName', 'id']) // Composite for scoped lookups per index\n .index('by_index', ['indexName']);\n\n// ============================================================================\n// Fallback Table - For unknown/custom tables\n// ============================================================================\n\n/**\n * Generic documents table - fallback for unknown table types\n */\nexport const mastraDocumentsTable = defineTable({\n table: v.string(),\n primaryKey: v.string(),\n record: v.any(),\n})\n .index('by_table', ['table'])\n .index('by_table_primary', ['table', 'primaryKey']);\n\n// ============================================================================\n// Re-export table name constants for convenience\n// ============================================================================\n\nexport { TABLE_WORKFLOW_SNAPSHOT, TABLE_MESSAGES, TABLE_THREADS, TABLE_RESOURCES, TABLE_SCORERS };\n\n// Additional table name constants for vector tables (not in core)\nexport const TABLE_VECTOR_INDEXES = 'mastra_vector_indexes';\nexport const TABLE_VECTORS = 'mastra_vectors';\nexport const TABLE_DOCUMENTS = 'mastra_documents';\n"]}
@@ -0,0 +1,73 @@
1
+ import { TABLE_SCHEMAS, TABLE_THREADS, TABLE_MESSAGES, TABLE_RESOURCES, TABLE_WORKFLOW_SNAPSHOT, TABLE_SCORERS } from '@mastra/core/storage/constants';
2
+ export { TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCORERS, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT } from '@mastra/core/storage/constants';
3
+ import { defineTable } from 'convex/server';
4
+ import { v } from 'convex/values';
5
+
6
+ // src/schema.ts
7
+ function columnToValidator(column) {
8
+ let validator;
9
+ switch (column.type) {
10
+ case "text":
11
+ validator = v.string();
12
+ break;
13
+ case "integer":
14
+ case "float":
15
+ validator = v.number();
16
+ break;
17
+ case "bigint":
18
+ validator = v.int64();
19
+ break;
20
+ case "boolean":
21
+ validator = v.boolean();
22
+ break;
23
+ case "timestamp":
24
+ validator = v.string();
25
+ break;
26
+ case "jsonb":
27
+ case "json":
28
+ validator = v.any();
29
+ break;
30
+ default:
31
+ validator = v.any();
32
+ }
33
+ return column.nullable ? v.optional(validator) : validator;
34
+ }
35
+ function buildTableFromSchema(schema) {
36
+ const fields = {};
37
+ for (const [key, column] of Object.entries(schema)) {
38
+ fields[key] = columnToValidator(column);
39
+ }
40
+ return fields;
41
+ }
42
+ var mastraThreadsTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_THREADS])).index("by_record_id", ["id"]).index("by_resource", ["resourceId"]).index("by_created", ["createdAt"]).index("by_updated", ["updatedAt"]);
43
+ var mastraMessagesTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_MESSAGES])).index("by_record_id", ["id"]).index("by_thread", ["thread_id"]).index("by_thread_created", ["thread_id", "createdAt"]).index("by_resource", ["resourceId"]);
44
+ var mastraResourcesTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_RESOURCES])).index("by_record_id", ["id"]).index("by_updated", ["updatedAt"]);
45
+ var mastraWorkflowSnapshotsTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT])).index("by_record_id", ["id"]).index("by_workflow_run", ["workflow_name", "run_id"]).index("by_workflow", ["workflow_name"]).index("by_resource", ["resourceId"]).index("by_created", ["createdAt"]);
46
+ var mastraScoresTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_SCORERS])).index("by_record_id", ["id"]).index("by_scorer", ["scorerId"]).index("by_entity", ["entityId", "entityType"]).index("by_run", ["runId"]).index("by_created", ["createdAt"]);
47
+ var mastraVectorIndexesTable = defineTable({
48
+ id: v.string(),
49
+ // Mastra record ID (same as indexName)
50
+ indexName: v.string(),
51
+ dimension: v.number(),
52
+ metric: v.string(),
53
+ createdAt: v.string()
54
+ }).index("by_record_id", ["id"]).index("by_name", ["indexName"]);
55
+ var mastraVectorsTable = defineTable({
56
+ id: v.string(),
57
+ // Mastra record ID
58
+ indexName: v.string(),
59
+ embedding: v.array(v.float64()),
60
+ metadata: v.optional(v.any())
61
+ }).index("by_index_id", ["indexName", "id"]).index("by_index", ["indexName"]);
62
+ var mastraDocumentsTable = defineTable({
63
+ table: v.string(),
64
+ primaryKey: v.string(),
65
+ record: v.any()
66
+ }).index("by_table", ["table"]).index("by_table_primary", ["table", "primaryKey"]);
67
+ var TABLE_VECTOR_INDEXES = "mastra_vector_indexes";
68
+ var TABLE_VECTORS = "mastra_vectors";
69
+ var TABLE_DOCUMENTS = "mastra_documents";
70
+
71
+ export { TABLE_DOCUMENTS, TABLE_VECTORS, TABLE_VECTOR_INDEXES, mastraDocumentsTable, mastraMessagesTable, mastraResourcesTable, mastraScoresTable, mastraThreadsTable, mastraVectorIndexesTable, mastraVectorsTable, mastraWorkflowSnapshotsTable };
72
+ //# sourceMappingURL=chunk-HXB4DWFE.js.map
73
+ //# sourceMappingURL=chunk-HXB4DWFE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema.ts"],"names":[],"mappings":";;;;;;AAwBA,SAAS,kBAAkB,MAAA,EAA8C;AACvE,EAAA,IAAI,SAAA;AACJ,EAAA,QAAQ,OAAO,IAAA;AAAM,IACnB,KAAK,MAAA;AACH,MAAA,SAAA,GAAY,EAAE,MAAA,EAAO;AACrB,MAAA;AAAA,IACF,KAAK,SAAA;AAAA,IACL,KAAK,OAAA;AACH,MAAA,SAAA,GAAY,EAAE,MAAA,EAAO;AACrB,MAAA;AAAA,IACF,KAAK,QAAA;AACH,MAAA,SAAA,GAAY,EAAE,KAAA,EAAM;AACpB,MAAA;AAAA,IACF,KAAK,SAAA;AACH,MAAA,SAAA,GAAY,EAAE,OAAA,EAAQ;AACtB,MAAA;AAAA,IACF,KAAK,WAAA;AACH,MAAA,SAAA,GAAY,EAAE,MAAA,EAAO;AACrB,MAAA;AAAA,IACF,KAAK,OAAA;AAAA,IACL,KAAK,MAAA;AACH,MAAA,SAAA,GAAY,EAAE,GAAA,EAAI;AAClB,MAAA;AAAA,IACF;AACE,MAAA,SAAA,GAAY,EAAE,GAAA,EAAI;AAAA;AAEtB,EAAA,OAAO,MAAA,CAAO,QAAA,GAAW,CAAA,CAAE,QAAA,CAAS,SAAS,CAAA,GAAI,SAAA;AACnD;AAMA,SAAS,qBAAqB,MAAA,EAAoF;AAChH,EAAA,MAAM,SAA8B,EAAC;AACrC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,MAAM,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AAClD,IAAA,MAAA,CAAO,GAAG,CAAA,GAAI,iBAAA,CAAkB,MAAM,CAAA;AAAA,EACx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KAAA,CAAM,UAAA,EAAY,CAAC,OAAO,CAAC,CAAA,CAC3B,KAAA,CAAM,kBAAA,EAAoB,CAAC,OAAA,EAAS,YAAY,CAAC;AAS7C,IAAM,oBAAA,GAAuB;AAC7B,IAAM,aAAA,GAAgB;AACtB,IAAM,eAAA,GAAkB","file":"chunk-HXB4DWFE.js","sourcesContent":["/**\n * Convex schema definitions for Mastra tables.\n *\n * This file dynamically builds Convex table definitions from the canonical\n * TABLE_SCHEMAS in @mastra/core/storage/constants to ensure they stay in sync.\n *\n * The import path @mastra/core/storage/constants is specifically designed to\n * avoid pulling in Node.js dependencies, making it safe to use in Convex's\n * sandboxed schema evaluation environment.\n */\nimport {\n TABLE_SCHEMAS,\n TABLE_WORKFLOW_SNAPSHOT,\n TABLE_MESSAGES,\n TABLE_THREADS,\n TABLE_RESOURCES,\n TABLE_SCORERS,\n} from '@mastra/core/storage/constants';\nimport { defineTable } from 'convex/server';\nimport { v } from 'convex/values';\n\n/**\n * Helper to convert Mastra StorageColumn type to Convex validator\n */\nfunction columnToValidator(column: { type: string; nullable?: boolean }) {\n let validator;\n switch (column.type) {\n case 'text':\n validator = v.string();\n break;\n case 'integer':\n case 'float':\n validator = v.number();\n break;\n case 'bigint':\n validator = v.int64();\n break;\n case 'boolean':\n validator = v.boolean();\n break;\n case 'timestamp':\n validator = v.string(); // Store as ISO string\n break;\n case 'jsonb':\n case 'json':\n validator = v.any();\n break;\n default:\n validator = v.any();\n }\n return column.nullable ? v.optional(validator) : validator;\n}\n\n/**\n * Build Convex table definition from Mastra schema.\n * Includes the `id` field as a regular field (Convex auto-generates _id).\n */\nfunction buildTableFromSchema(schema: Record<string, { type: string; nullable?: boolean; primaryKey?: boolean }>) {\n const fields: Record<string, any> = {};\n for (const [key, column] of Object.entries(schema)) {\n fields[key] = columnToValidator(column);\n }\n return fields;\n}\n\n// ============================================================================\n// Table Definitions - Built from @mastra/core TABLE_SCHEMAS\n// ============================================================================\n\n/**\n * Threads table - stores conversation threads\n * Schema: TABLE_SCHEMAS[TABLE_THREADS]\n */\nexport const mastraThreadsTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_THREADS]))\n .index('by_record_id', ['id'])\n .index('by_resource', ['resourceId'])\n .index('by_created', ['createdAt'])\n .index('by_updated', ['updatedAt']);\n\n/**\n * Messages table - stores conversation messages\n * Schema: TABLE_SCHEMAS[TABLE_MESSAGES]\n */\nexport const mastraMessagesTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_MESSAGES]))\n .index('by_record_id', ['id'])\n .index('by_thread', ['thread_id'])\n .index('by_thread_created', ['thread_id', 'createdAt'])\n .index('by_resource', ['resourceId']);\n\n/**\n * Resources table - stores resource/user working memory\n * Schema: TABLE_SCHEMAS[TABLE_RESOURCES]\n */\nexport const mastraResourcesTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_RESOURCES]))\n .index('by_record_id', ['id'])\n .index('by_updated', ['updatedAt']);\n\n/**\n * Workflow snapshots table - stores workflow execution state\n * Schema: TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT]\n */\nexport const mastraWorkflowSnapshotsTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT]))\n .index('by_record_id', ['id'])\n .index('by_workflow_run', ['workflow_name', 'run_id'])\n .index('by_workflow', ['workflow_name'])\n .index('by_resource', ['resourceId'])\n .index('by_created', ['createdAt']);\n\n/**\n * Scores table - stores evaluation scores\n * Schema: TABLE_SCHEMAS[TABLE_SCORERS]\n */\nexport const mastraScoresTable = defineTable(buildTableFromSchema(TABLE_SCHEMAS[TABLE_SCORERS]))\n .index('by_record_id', ['id'])\n .index('by_scorer', ['scorerId'])\n .index('by_entity', ['entityId', 'entityType'])\n .index('by_run', ['runId'])\n .index('by_created', ['createdAt']);\n\n// ============================================================================\n// Vector Tables - Not in core schemas (vector-specific)\n// ============================================================================\n\n/**\n * Vector indexes table - stores metadata about vector indexes\n */\nexport const mastraVectorIndexesTable = defineTable({\n id: v.string(), // Mastra record ID (same as indexName)\n indexName: v.string(),\n dimension: v.number(),\n metric: v.string(),\n createdAt: v.string(),\n})\n .index('by_record_id', ['id'])\n .index('by_name', ['indexName']);\n\n/**\n * Vectors table - stores vector embeddings\n * Uses indexName field to support multiple indexes with different dimensions\n */\nexport const mastraVectorsTable = defineTable({\n id: v.string(), // Mastra record ID\n indexName: v.string(),\n embedding: v.array(v.float64()),\n metadata: v.optional(v.any()),\n})\n .index('by_index_id', ['indexName', 'id']) // Composite for scoped lookups per index\n .index('by_index', ['indexName']);\n\n// ============================================================================\n// Fallback Table - For unknown/custom tables\n// ============================================================================\n\n/**\n * Generic documents table - fallback for unknown table types\n */\nexport const mastraDocumentsTable = defineTable({\n table: v.string(),\n primaryKey: v.string(),\n record: v.any(),\n})\n .index('by_table', ['table'])\n .index('by_table_primary', ['table', 'primaryKey']);\n\n// ============================================================================\n// Re-export table name constants for convenience\n// ============================================================================\n\nexport { TABLE_WORKFLOW_SNAPSHOT, TABLE_MESSAGES, TABLE_THREADS, TABLE_RESOURCES, TABLE_SCORERS };\n\n// Additional table name constants for vector tables (not in core)\nexport const TABLE_VECTOR_INDEXES = 'mastra_vector_indexes';\nexport const TABLE_VECTORS = 'mastra_vectors';\nexport const TABLE_DOCUMENTS = 'mastra_documents';\n"]}
@@ -0,0 +1,32 @@
1
+ # @mastra/convex Documentation
2
+
3
+ > Embedded documentation for coding agents
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Read the skill overview
9
+ cat docs/SKILL.md
10
+
11
+ # Get the source map
12
+ cat docs/SOURCE_MAP.json
13
+
14
+ # Read topic documentation
15
+ cat docs/<topic>/01-overview.md
16
+ ```
17
+
18
+ ## Structure
19
+
20
+ ```
21
+ docs/
22
+ ├── SKILL.md # Entry point
23
+ ├── README.md # This file
24
+ ├── SOURCE_MAP.json # Export index
25
+ ├── storage/ (1 files)
26
+ ├── vectors/ (1 files)
27
+ ```
28
+
29
+ ## Version
30
+
31
+ Package: @mastra/convex
32
+ Version: 0.1.0-beta.7
@@ -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/)