@mastra/convex 0.0.0-new-button-export-20251219133013 → 0.0.0-salesman-20260127182805
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/CHANGELOG.md +711 -3
- package/dist/chunk-FTVDAP6U.cjs +113 -0
- package/dist/chunk-FTVDAP6U.cjs.map +1 -0
- package/dist/chunk-G5FLGAPE.js +82 -0
- package/dist/chunk-G5FLGAPE.js.map +1 -0
- package/dist/docs/README.md +32 -0
- package/dist/docs/SKILL.md +46 -0
- package/dist/docs/SOURCE_MAP.json +63 -0
- package/dist/docs/storage/01-reference.md +143 -0
- package/dist/docs/vectors/01-reference.md +240 -0
- package/dist/index.cjs +66 -158
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +54 -146
- package/dist/index.js.map +1 -1
- package/dist/schema.cjs +17 -17
- package/dist/schema.d.ts +66 -67
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +1 -1
- package/dist/server/index.cjs +14 -14
- package/dist/server/index.js +1 -1
- package/dist/storage/db/index.d.ts +10 -1
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +2 -2
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +5 -14
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +56 -125
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +13 -12
- package/dist/chunk-PKUUSREO.js +0 -76
- package/dist/chunk-PKUUSREO.js.map +0 -1
- package/dist/chunk-ZBUP3DS6.cjs +0 -93
- package/dist/chunk-ZBUP3DS6.cjs.map +0 -1
- package/dist/server/schema.d.ts +0 -115
- package/dist/server/schema.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { mastraStorage } from './chunk-KSAPIIEJ.js';
|
|
2
|
-
export { TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCORERS, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, mastraDocumentsTable, mastraMessagesTable, mastraResourcesTable, mastraScoresTable, mastraThreadsTable, mastraVectorIndexesTable, mastraVectorsTable, mastraWorkflowSnapshotsTable } from './chunk-
|
|
3
|
-
import {
|
|
2
|
+
export { TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCORERS, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, mastraDocumentsTable, mastraMessagesTable, mastraResourcesTable, mastraScoresTable, mastraThreadsTable, mastraVectorIndexesTable, mastraVectorsTable, mastraWorkflowSnapshotsTable } from './chunk-G5FLGAPE.js';
|
|
3
|
+
import { MastraCompositeStore, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, TABLE_RESOURCES, createStorageErrorId, normalizePerPage, calculatePagination, filterByDateRange, safelyParseJSON, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ScoresStorage, TABLE_SCORERS } from '@mastra/core/storage';
|
|
4
4
|
import { MessageList } from '@mastra/core/agent';
|
|
5
5
|
import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
|
|
6
6
|
import crypto from 'crypto';
|
|
@@ -84,6 +84,19 @@ var ConvexDB = class extends MastraBase {
|
|
|
84
84
|
async hasColumn(_table, _column) {
|
|
85
85
|
return true;
|
|
86
86
|
}
|
|
87
|
+
async createTable({
|
|
88
|
+
tableName,
|
|
89
|
+
schema: _schema
|
|
90
|
+
}) {
|
|
91
|
+
this.logger.debug(`ConvexDB: createTable called for ${tableName} (schema managed server-side)`);
|
|
92
|
+
}
|
|
93
|
+
async alterTable({
|
|
94
|
+
tableName,
|
|
95
|
+
schema: _schema,
|
|
96
|
+
ifNotExists: _ifNotExists
|
|
97
|
+
}) {
|
|
98
|
+
this.logger.debug(`ConvexDB: alterTable called for ${tableName} (schema managed server-side)`);
|
|
99
|
+
}
|
|
87
100
|
async clearTable({ tableName }) {
|
|
88
101
|
let hasMore = true;
|
|
89
102
|
while (hasMore) {
|
|
@@ -235,18 +248,41 @@ var MemoryConvex = class extends MemoryStorage {
|
|
|
235
248
|
);
|
|
236
249
|
await this.#db.deleteMany(TABLE_THREADS, [threadId]);
|
|
237
250
|
}
|
|
238
|
-
async
|
|
239
|
-
const {
|
|
251
|
+
async listThreads(args) {
|
|
252
|
+
const { page = 0, perPage: perPageInput, orderBy, filter } = args;
|
|
253
|
+
try {
|
|
254
|
+
this.validatePaginationInput(page, perPageInput ?? 100);
|
|
255
|
+
} catch (error) {
|
|
256
|
+
throw new MastraError(
|
|
257
|
+
{
|
|
258
|
+
id: createStorageErrorId("CONVEX", "LIST_THREADS", "INVALID_PAGE"),
|
|
259
|
+
domain: ErrorDomain.STORAGE,
|
|
260
|
+
category: ErrorCategory.USER,
|
|
261
|
+
details: { page, ...perPageInput !== void 0 && { perPage: perPageInput } }
|
|
262
|
+
},
|
|
263
|
+
error instanceof Error ? error : new Error("Invalid pagination parameters")
|
|
264
|
+
);
|
|
265
|
+
}
|
|
240
266
|
const perPage = normalizePerPage(perPageInput, 100);
|
|
241
267
|
const { field, direction } = this.parseOrderBy(orderBy);
|
|
242
268
|
const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
|
|
243
|
-
const
|
|
244
|
-
|
|
269
|
+
const queryFilters = [];
|
|
270
|
+
if (filter?.resourceId) {
|
|
271
|
+
queryFilters.push({ field: "resourceId", value: filter.resourceId });
|
|
272
|
+
}
|
|
273
|
+
const rows = await this.#db.queryTable(TABLE_THREADS, queryFilters);
|
|
274
|
+
let threads = rows.map((row) => ({
|
|
245
275
|
...row,
|
|
246
276
|
metadata: typeof row.metadata === "string" ? JSON.parse(row.metadata) : row.metadata,
|
|
247
277
|
createdAt: new Date(row.createdAt),
|
|
248
278
|
updatedAt: new Date(row.updatedAt)
|
|
249
279
|
}));
|
|
280
|
+
if (filter?.metadata && Object.keys(filter.metadata).length > 0) {
|
|
281
|
+
threads = threads.filter((thread) => {
|
|
282
|
+
if (!thread.metadata) return false;
|
|
283
|
+
return Object.entries(filter.metadata).every(([key, value]) => thread.metadata[key] === value);
|
|
284
|
+
});
|
|
285
|
+
}
|
|
250
286
|
threads.sort((a, b) => {
|
|
251
287
|
const aValue = a[field];
|
|
252
288
|
const bValue = b[field];
|
|
@@ -289,15 +325,7 @@ var MemoryConvex = class extends MemoryStorage {
|
|
|
289
325
|
if (resourceId) {
|
|
290
326
|
rows = rows.filter((row) => row.resourceId === resourceId);
|
|
291
327
|
}
|
|
292
|
-
|
|
293
|
-
const { start, end } = filter.dateRange;
|
|
294
|
-
rows = rows.filter((row) => {
|
|
295
|
-
const created = new Date(row.createdAt).getTime();
|
|
296
|
-
if (start && created < start.getTime()) return false;
|
|
297
|
-
if (end && created > end.getTime()) return false;
|
|
298
|
-
return true;
|
|
299
|
-
});
|
|
300
|
-
}
|
|
328
|
+
rows = filterByDateRange(rows, (row) => new Date(row.createdAt), filter?.dateRange);
|
|
301
329
|
rows.sort((a, b) => {
|
|
302
330
|
const aValue = field === "createdAt" || field === "updatedAt" ? new Date(a[field]).getTime() : a[field];
|
|
303
331
|
const bValue = field === "createdAt" || field === "updatedAt" ? new Date(b[field]).getTime() : b[field];
|
|
@@ -853,143 +881,23 @@ var WorkflowsConvex = class extends WorkflowsStorage {
|
|
|
853
881
|
};
|
|
854
882
|
|
|
855
883
|
// src/storage/index.ts
|
|
856
|
-
var
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
884
|
+
var isClientConfig = (config) => {
|
|
885
|
+
return "client" in config;
|
|
886
|
+
};
|
|
887
|
+
var ConvexStore = class extends MastraCompositeStore {
|
|
860
888
|
constructor(config) {
|
|
861
889
|
super({ id: config.id, name: config.name ?? "ConvexStore", disableInit: config.disableInit });
|
|
862
|
-
const client = new ConvexAdminClient(config);
|
|
890
|
+
const client = isClientConfig(config) ? config.client : new ConvexAdminClient(config);
|
|
863
891
|
const domainConfig = { client };
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
892
|
+
const memory = new MemoryConvex(domainConfig);
|
|
893
|
+
const workflows = new WorkflowsConvex(domainConfig);
|
|
894
|
+
const scores = new ScoresConvex(domainConfig);
|
|
867
895
|
this.stores = {
|
|
868
|
-
memory
|
|
869
|
-
workflows
|
|
870
|
-
scores
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
get supports() {
|
|
874
|
-
return {
|
|
875
|
-
selectByIncludeResourceScope: true,
|
|
876
|
-
resourceWorkingMemory: true,
|
|
877
|
-
hasColumn: false,
|
|
878
|
-
createTable: false,
|
|
879
|
-
deleteMessages: true,
|
|
880
|
-
observabilityInstance: false,
|
|
881
|
-
listScoresBySpan: false
|
|
896
|
+
memory,
|
|
897
|
+
workflows,
|
|
898
|
+
scores
|
|
882
899
|
};
|
|
883
900
|
}
|
|
884
|
-
async getThreadById({ threadId }) {
|
|
885
|
-
return this.memory.getThreadById({ threadId });
|
|
886
|
-
}
|
|
887
|
-
async saveThread({ thread }) {
|
|
888
|
-
return this.memory.saveThread({ thread });
|
|
889
|
-
}
|
|
890
|
-
async updateThread({
|
|
891
|
-
id,
|
|
892
|
-
title,
|
|
893
|
-
metadata
|
|
894
|
-
}) {
|
|
895
|
-
return this.memory.updateThread({ id, title, metadata });
|
|
896
|
-
}
|
|
897
|
-
async deleteThread({ threadId }) {
|
|
898
|
-
await this.memory.deleteThread({ threadId });
|
|
899
|
-
}
|
|
900
|
-
async listMessages(args) {
|
|
901
|
-
return this.memory.listMessages(args);
|
|
902
|
-
}
|
|
903
|
-
async listMessagesById({ messageIds }) {
|
|
904
|
-
return this.memory.listMessagesById({ messageIds });
|
|
905
|
-
}
|
|
906
|
-
async saveMessages(args) {
|
|
907
|
-
return this.memory.saveMessages(args);
|
|
908
|
-
}
|
|
909
|
-
async updateMessages({
|
|
910
|
-
messages
|
|
911
|
-
}) {
|
|
912
|
-
return this.memory.updateMessages({ messages });
|
|
913
|
-
}
|
|
914
|
-
async deleteMessages(messageIds) {
|
|
915
|
-
await this.memory.deleteMessages(messageIds);
|
|
916
|
-
}
|
|
917
|
-
async listThreadsByResourceId(args) {
|
|
918
|
-
return this.memory.listThreadsByResourceId(args);
|
|
919
|
-
}
|
|
920
|
-
async getResourceById({ resourceId }) {
|
|
921
|
-
return this.memory.getResourceById({ resourceId });
|
|
922
|
-
}
|
|
923
|
-
async saveResource({ resource }) {
|
|
924
|
-
return this.memory.saveResource({ resource });
|
|
925
|
-
}
|
|
926
|
-
async updateResource({
|
|
927
|
-
resourceId,
|
|
928
|
-
workingMemory,
|
|
929
|
-
metadata
|
|
930
|
-
}) {
|
|
931
|
-
return this.memory.updateResource({ resourceId, workingMemory, metadata });
|
|
932
|
-
}
|
|
933
|
-
async updateWorkflowResults(params) {
|
|
934
|
-
return this.workflows.updateWorkflowResults(params);
|
|
935
|
-
}
|
|
936
|
-
async updateWorkflowState(params) {
|
|
937
|
-
return this.workflows.updateWorkflowState(params);
|
|
938
|
-
}
|
|
939
|
-
async persistWorkflowSnapshot({
|
|
940
|
-
workflowName,
|
|
941
|
-
runId,
|
|
942
|
-
resourceId,
|
|
943
|
-
snapshot
|
|
944
|
-
}) {
|
|
945
|
-
await this.workflows.persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot });
|
|
946
|
-
}
|
|
947
|
-
async loadWorkflowSnapshot({
|
|
948
|
-
workflowName,
|
|
949
|
-
runId
|
|
950
|
-
}) {
|
|
951
|
-
return this.workflows.loadWorkflowSnapshot({ workflowName, runId });
|
|
952
|
-
}
|
|
953
|
-
async listWorkflowRuns(args) {
|
|
954
|
-
return this.workflows.listWorkflowRuns(args);
|
|
955
|
-
}
|
|
956
|
-
async getWorkflowRunById({
|
|
957
|
-
runId,
|
|
958
|
-
workflowName
|
|
959
|
-
}) {
|
|
960
|
-
return this.workflows.getWorkflowRunById({ runId, workflowName });
|
|
961
|
-
}
|
|
962
|
-
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
963
|
-
return this.workflows.deleteWorkflowRunById({ runId, workflowName });
|
|
964
|
-
}
|
|
965
|
-
async getScoreById({ id }) {
|
|
966
|
-
return this.scores.getScoreById({ id });
|
|
967
|
-
}
|
|
968
|
-
async saveScore(score) {
|
|
969
|
-
return this.scores.saveScore(score);
|
|
970
|
-
}
|
|
971
|
-
async listScoresByScorerId({
|
|
972
|
-
scorerId,
|
|
973
|
-
pagination,
|
|
974
|
-
entityId,
|
|
975
|
-
entityType,
|
|
976
|
-
source
|
|
977
|
-
}) {
|
|
978
|
-
return this.scores.listScoresByScorerId({ scorerId, pagination, entityId, entityType, source });
|
|
979
|
-
}
|
|
980
|
-
async listScoresByRunId({
|
|
981
|
-
runId,
|
|
982
|
-
pagination
|
|
983
|
-
}) {
|
|
984
|
-
return this.scores.listScoresByRunId({ runId, pagination });
|
|
985
|
-
}
|
|
986
|
-
async listScoresByEntityId({
|
|
987
|
-
entityId,
|
|
988
|
-
entityType,
|
|
989
|
-
pagination
|
|
990
|
-
}) {
|
|
991
|
-
return this.scores.listScoresByEntityId({ entityId, entityType, pagination });
|
|
992
|
-
}
|
|
993
901
|
};
|
|
994
902
|
var INDEX_METADATA_TABLE = "mastra_vector_indexes";
|
|
995
903
|
var ConvexVector = class extends MastraVector {
|