@mastra/convex 1.7.5-alpha.1 → 1.7.6-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.
- package/dist/_types/@internal_core/dist/memory/index.d.ts +12 -15
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +89 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -43
- package/dist/index.js.map +1 -1
- package/dist/schema.cjs +61 -12
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.js +1 -2
- package/dist/server/index.cjs +61 -11
- package/dist/server/index.js +1 -1
- package/dist/server/observational-memory.d.ts.map +1 -1
- package/dist/{server-CedrKoHl.js → server-BRy-fyDz.js} +8 -15
- package/dist/server-BRy-fyDz.js.map +1 -0
- package/dist/{server-BxQKtmhb.cjs → server-BwpzJLxa.cjs} +8 -15
- package/dist/server-BwpzJLxa.cjs.map +1 -0
- package/package.json +13 -13
- package/dist/server-BxQKtmhb.cjs.map +0 -1
- package/dist/server-CedrKoHl.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as mastraCache, i as mastraStorage, n as mastraNativeVectorMutation, r as mastraNativeVectorQuery, t as mastraNativeVectorAction } from "./server-
|
|
1
|
+
import { a as mastraCache, i as mastraStorage, n as mastraNativeVectorMutation, r as mastraNativeVectorQuery, t as mastraNativeVectorAction } from "./server-BRy-fyDz.js";
|
|
2
2
|
import { TABLE_BACKGROUND_TASKS, TABLE_CHANNEL_CONFIG, TABLE_CHANNEL_INSTALLATIONS, TABLE_MESSAGES, TABLE_OBSERVATIONAL_MEMORY, TABLE_RESOURCES, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, TABLE_SCORERS, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, defineMastraNativeVectorTable, mastraBackgroundTasksTable, mastraCacheListItemsTable, mastraCacheTable, mastraChannelConfigTable, mastraChannelInstallationsTable, mastraDocumentsTable, mastraMessagesTable, mastraObservationalMemoryTable, mastraResourcesTable, mastraScheduleTriggersTable, mastraSchedulesTable, mastraScoresTable, mastraThreadsTable, mastraVectorIndexesTable, mastraVectorsTable, mastraWorkflowSnapshotsTable } from "./schema.js";
|
|
3
3
|
import { MastraServerCache } from "@mastra/core/cache";
|
|
4
4
|
import { BackgroundTasksStorage, ChannelsStorage, MastraCompositeStore, MemoryStorage, RUN_FENCE_CONFLICT_ERROR_ID, RunFenceConflictError, SchedulesStorage, ScoresStorage, TABLE_BACKGROUND_TASKS as TABLE_BACKGROUND_TASKS$1, TABLE_CHANNEL_CONFIG as TABLE_CHANNEL_CONFIG$1, TABLE_CHANNEL_INSTALLATIONS as TABLE_CHANNEL_INSTALLATIONS$1, TABLE_MEMORY_RUN_FENCES, TABLE_MESSAGES as TABLE_MESSAGES$1, TABLE_RESOURCES as TABLE_RESOURCES$1, TABLE_SCHEDULES as TABLE_SCHEDULES$1, TABLE_SCHEDULE_TRIGGERS as TABLE_SCHEDULE_TRIGGERS$1, TABLE_SCORERS as TABLE_SCORERS$1, TABLE_THREADS as TABLE_THREADS$1, TABLE_WORKFLOW_RUN_OWNERS, TABLE_WORKFLOW_SNAPSHOT as TABLE_WORKFLOW_SNAPSHOT$1, WorkflowsStorage, calculatePagination, createStorageErrorId, createVectorErrorId, executeRetentionPrune, filterByDateRange, normalizePerPage, normalizeScheduleTarget, resolveRetentionTargets, resolveRunFence, retentionCutoffMs, safelyParseJSON, storageMessageMatchesMetadataFilter, validateStorageMetadataFilter } from "@mastra/core/storage";
|
|
@@ -6,7 +6,7 @@ import { MastraBase } from "@mastra/core/base";
|
|
|
6
6
|
import { MessageList } from "@mastra/core/agent";
|
|
7
7
|
import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
|
|
8
8
|
import { MastraVector } from "@mastra/core/vector";
|
|
9
|
-
|
|
9
|
+
// src/cache/client.ts
|
|
10
10
|
const DEFAULT_CACHE_FUNCTION = "mastra/cache:handle";
|
|
11
11
|
const DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
12
12
|
const trimTrailingSlashes = (value) => {
|
|
@@ -84,8 +84,7 @@ var ConvexCacheClient = class {
|
|
|
84
84
|
return result;
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
|
|
88
|
-
//#region src/cache/index.ts
|
|
87
|
+
// src/cache/index.ts
|
|
89
88
|
const DEFAULT_KEY_PREFIX = "mastra:cache:";
|
|
90
89
|
const DEFAULT_TTL_MS = 3e5;
|
|
91
90
|
const MAX_CACHE_OPERATION_BATCHES = 1e3;
|
|
@@ -173,8 +172,7 @@ var ConvexServerCache = class extends MastraServerCache {
|
|
|
173
172
|
}));
|
|
174
173
|
}
|
|
175
174
|
};
|
|
176
|
-
|
|
177
|
-
//#region src/storage/client.ts
|
|
175
|
+
// src/storage/client.ts
|
|
178
176
|
const DEFAULT_STORAGE_FUNCTION = "mastra/storage:handle";
|
|
179
177
|
var ConvexAdminClient = class {
|
|
180
178
|
deploymentUrl;
|
|
@@ -251,8 +249,7 @@ var ConvexAdminClient = class {
|
|
|
251
249
|
return result;
|
|
252
250
|
}
|
|
253
251
|
};
|
|
254
|
-
|
|
255
|
-
//#region src/storage/run-fencing.ts
|
|
252
|
+
// src/storage/run-fencing.ts
|
|
256
253
|
const READ_OPS = /* @__PURE__ */ new Set([
|
|
257
254
|
"load",
|
|
258
255
|
"loadMany",
|
|
@@ -410,16 +407,14 @@ async function pruneRunClaims(client, tableName, column, cutoff, limit) {
|
|
|
410
407
|
}, "prune");
|
|
411
408
|
return result;
|
|
412
409
|
}
|
|
413
|
-
|
|
414
|
-
//#region src/storage/types.ts
|
|
410
|
+
// src/storage/types.ts
|
|
415
411
|
/**
|
|
416
412
|
* Observational memory table name. Defined locally (not value-imported from
|
|
417
413
|
* core) following the mongodb/pg convention: core exports the constant, but
|
|
418
414
|
* OM is optional and the constant is absent from older cores in the peer range.
|
|
419
415
|
*/
|
|
420
416
|
const TABLE_OBSERVATIONAL_MEMORY$1 = "mastra_observational_memory";
|
|
421
|
-
|
|
422
|
-
//#region src/storage/db/index.ts
|
|
417
|
+
// src/storage/db/index.ts
|
|
423
418
|
const LOAD_MANY_REQUEST_BATCH_SIZE = 10;
|
|
424
419
|
/**
|
|
425
420
|
* Resolves ConvexDomainConfig to a ConvexAdminClient.
|
|
@@ -739,8 +734,7 @@ var ConvexDB = class ConvexDB extends MastraBase {
|
|
|
739
734
|
return normalized;
|
|
740
735
|
}
|
|
741
736
|
};
|
|
742
|
-
|
|
743
|
-
//#region src/storage/domains/background-tasks/index.ts
|
|
737
|
+
// src/storage/domains/background-tasks/index.ts
|
|
744
738
|
function serializeJson$1(v) {
|
|
745
739
|
if (v === void 0 || v === null) return null;
|
|
746
740
|
return JSON.stringify(v);
|
|
@@ -954,8 +948,7 @@ var BackgroundTasksConvex = class extends BackgroundTasksStorage {
|
|
|
954
948
|
return total;
|
|
955
949
|
}
|
|
956
950
|
};
|
|
957
|
-
|
|
958
|
-
//#region src/storage/domains/channels/index.ts
|
|
951
|
+
// src/storage/domains/channels/index.ts
|
|
959
952
|
const statusPriority = {
|
|
960
953
|
active: 0,
|
|
961
954
|
pending: 1,
|
|
@@ -1092,8 +1085,7 @@ var ChannelsConvex = class extends ChannelsStorage {
|
|
|
1092
1085
|
await this.#db.deleteMany(TABLE_CHANNEL_CONFIG$1, [platform]);
|
|
1093
1086
|
}
|
|
1094
1087
|
};
|
|
1095
|
-
|
|
1096
|
-
//#region ../../packages/_internal-core/dist/memory/index.js
|
|
1088
|
+
// ../../packages/_internal-core/dist/memory/index.js
|
|
1097
1089
|
/**
|
|
1098
1090
|
* Backs `updateActiveObservations` in adapters that implement `commitActiveObservations`.
|
|
1099
1091
|
* Callers of `updateActiveObservations` (which resolves `void`) can't see a commit result, so a
|
|
@@ -1103,8 +1095,7 @@ function assertActiveObservationsApplied(result, id) {
|
|
|
1103
1095
|
if (result.applied) return;
|
|
1104
1096
|
throw new Error(result.reason === "retired" ? `Observational memory record ${id} was superseded by a newer generation; observations were not written` : `Observational memory record ${id} changed since the observations were composed; observations were not written`);
|
|
1105
1097
|
}
|
|
1106
|
-
|
|
1107
|
-
//#region src/storage/domains/memory/index.ts
|
|
1098
|
+
// src/storage/domains/memory/index.ts
|
|
1108
1099
|
function parseStoredThread(row) {
|
|
1109
1100
|
return {
|
|
1110
1101
|
...row,
|
|
@@ -1228,13 +1219,14 @@ var MemoryConvex = class MemoryConvex extends MemoryStorage {
|
|
|
1228
1219
|
}
|
|
1229
1220
|
async init() {}
|
|
1230
1221
|
async prune(policies, options) {
|
|
1222
|
+
const targets = resolveRetentionTargets({
|
|
1223
|
+
policies,
|
|
1224
|
+
descriptor: MemoryConvex.retentionTables,
|
|
1225
|
+
order: ["runFences"]
|
|
1226
|
+
});
|
|
1231
1227
|
return executeRetentionPrune({
|
|
1232
1228
|
domain: "memory",
|
|
1233
|
-
targets
|
|
1234
|
-
policies,
|
|
1235
|
-
descriptor: MemoryConvex.retentionTables,
|
|
1236
|
-
order: ["runFences"]
|
|
1237
|
-
}),
|
|
1229
|
+
targets,
|
|
1238
1230
|
options,
|
|
1239
1231
|
cutoffFor: (target, now) => retentionCutoffMs(target.policy, now),
|
|
1240
1232
|
deleteBatch: (_target, cutoff, limit) => pruneRunClaims(this.#client, TABLE_MEMORY_RUN_FENCES, "retiredAt", Number(cutoff), limit)
|
|
@@ -1990,8 +1982,7 @@ var MemoryConvex = class MemoryConvex extends MemoryStorage {
|
|
|
1990
1982
|
});
|
|
1991
1983
|
}
|
|
1992
1984
|
};
|
|
1993
|
-
|
|
1994
|
-
//#region src/storage/domains/schedules/index.ts
|
|
1985
|
+
// src/storage/domains/schedules/index.ts
|
|
1995
1986
|
const SCHEDULE_LIST_LIMIT = 8e3;
|
|
1996
1987
|
function serializeJson(value) {
|
|
1997
1988
|
return JSON.stringify(value);
|
|
@@ -2208,8 +2199,7 @@ var SchedulesConvex = class extends SchedulesStorage {
|
|
|
2208
2199
|
})).map(recordToTrigger);
|
|
2209
2200
|
}
|
|
2210
2201
|
};
|
|
2211
|
-
|
|
2212
|
-
//#region src/storage/domains/scores/index.ts
|
|
2202
|
+
// src/storage/domains/scores/index.ts
|
|
2213
2203
|
var ScoresConvex = class extends ScoresStorage {
|
|
2214
2204
|
#db;
|
|
2215
2205
|
constructor(config) {
|
|
@@ -2303,8 +2293,7 @@ var ScoresConvex = class extends ScoresStorage {
|
|
|
2303
2293
|
};
|
|
2304
2294
|
}
|
|
2305
2295
|
};
|
|
2306
|
-
|
|
2307
|
-
//#region src/storage/domains/workflows/index.ts
|
|
2296
|
+
// src/storage/domains/workflows/index.ts
|
|
2308
2297
|
var WorkflowsConvex = class WorkflowsConvex extends WorkflowsStorage {
|
|
2309
2298
|
/**
|
|
2310
2299
|
* Tables `prune()` can clean up. Run ownership records anchor on `updatedAt` (epoch ms), which every
|
|
@@ -2332,13 +2321,14 @@ var WorkflowsConvex = class WorkflowsConvex extends WorkflowsStorage {
|
|
|
2332
2321
|
}
|
|
2333
2322
|
async init() {}
|
|
2334
2323
|
async prune(policies, options) {
|
|
2324
|
+
const targets = resolveRetentionTargets({
|
|
2325
|
+
policies,
|
|
2326
|
+
descriptor: WorkflowsConvex.retentionTables,
|
|
2327
|
+
order: ["runOwnership"]
|
|
2328
|
+
});
|
|
2335
2329
|
return executeRetentionPrune({
|
|
2336
2330
|
domain: "workflows",
|
|
2337
|
-
targets
|
|
2338
|
-
policies,
|
|
2339
|
-
descriptor: WorkflowsConvex.retentionTables,
|
|
2340
|
-
order: ["runOwnership"]
|
|
2341
|
-
}),
|
|
2331
|
+
targets,
|
|
2342
2332
|
options,
|
|
2343
2333
|
cutoffFor: (target, now) => retentionCutoffMs(target.policy, now),
|
|
2344
2334
|
deleteBatch: (_target, cutoff, limit) => pruneRunClaims(this.#client, TABLE_WORKFLOW_RUN_OWNERS, "updatedAt", Number(cutoff), limit)
|
|
@@ -2497,8 +2487,7 @@ var WorkflowsConvex = class WorkflowsConvex extends WorkflowsStorage {
|
|
|
2497
2487
|
return JSON.parse(JSON.stringify(run.snapshot));
|
|
2498
2488
|
}
|
|
2499
2489
|
};
|
|
2500
|
-
|
|
2501
|
-
//#region src/storage/index.ts
|
|
2490
|
+
// src/storage/index.ts
|
|
2502
2491
|
/**
|
|
2503
2492
|
* Type guard for pre-configured client config
|
|
2504
2493
|
*/
|
|
@@ -2544,8 +2533,7 @@ var ConvexStore = class extends MastraCompositeStore {
|
|
|
2544
2533
|
};
|
|
2545
2534
|
}
|
|
2546
2535
|
};
|
|
2547
|
-
|
|
2548
|
-
//#region src/vector/index.ts
|
|
2536
|
+
// src/vector/index.ts
|
|
2549
2537
|
const INDEX_METADATA_TABLE = "mastra_vector_indexes";
|
|
2550
2538
|
const VECTOR_QUERY_PAGE_SIZE = 256;
|
|
2551
2539
|
var ConvexVector = class extends MastraVector {
|
|
@@ -2813,8 +2801,7 @@ function cosineSimilarity(a, b) {
|
|
|
2813
2801
|
if (magA === 0 || magB === 0) return -1;
|
|
2814
2802
|
return dot / (Math.sqrt(magA) * Math.sqrt(magB));
|
|
2815
2803
|
}
|
|
2816
|
-
|
|
2817
|
-
//#region src/vector/native.ts
|
|
2804
|
+
// src/vector/native.ts
|
|
2818
2805
|
const DEFAULT_VECTOR_INDEX = "by_embedding";
|
|
2819
2806
|
const DEFAULT_ID_FIELD = "id";
|
|
2820
2807
|
const DEFAULT_ID_INDEX = "by_record_id";
|
|
@@ -2999,7 +2986,6 @@ var ConvexNativeVector = class extends MastraVector {
|
|
|
2999
2986
|
return typeof metadata === "object" && metadata !== null && !Array.isArray(metadata);
|
|
3000
2987
|
}
|
|
3001
2988
|
};
|
|
3002
|
-
//#endregion
|
|
3003
2989
|
export { ConvexCacheClient, ConvexNativeVector, ConvexServerCache, ConvexStore, ConvexVector, TABLE_BACKGROUND_TASKS, TABLE_CHANNEL_CONFIG, TABLE_CHANNEL_INSTALLATIONS, TABLE_MESSAGES, TABLE_OBSERVATIONAL_MEMORY, TABLE_RESOURCES, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, TABLE_SCORERS, TABLE_THREADS, TABLE_WORKFLOW_SNAPSHOT, defineMastraNativeVectorTable, mastraBackgroundTasksTable, mastraCache, mastraCacheListItemsTable, mastraCacheTable, mastraChannelConfigTable, mastraChannelInstallationsTable, mastraDocumentsTable, mastraMessagesTable, mastraNativeVectorAction, mastraNativeVectorMutation, mastraNativeVectorQuery, mastraObservationalMemoryTable, mastraResourcesTable, mastraScheduleTriggersTable, mastraSchedulesTable, mastraScoresTable, mastraStorage, mastraThreadsTable, mastraVectorIndexesTable, mastraVectorsTable, mastraWorkflowSnapshotsTable };
|
|
3004
2990
|
|
|
3005
2991
|
//# sourceMappingURL=index.js.map
|