@mastra/convex 1.5.2 → 1.5.3-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/CHANGELOG.md +9 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +17 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +8 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/convex
|
|
2
2
|
|
|
3
|
+
## 1.5.3-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed resource-scoped message includes across storage adapters so included context cannot cross resource boundaries. ([#20984](https://github.com/mastra-ai/mastra/pull/20984))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`6445eba`](https://github.com/mastra-ai/mastra/commit/6445eba6020abac681aba1cc9289f446cb400cbe), [`df31eb0`](https://github.com/mastra-ai/mastra/commit/df31eb0c7087d782a0d9346e467f9a4af4b0eef6), [`fcd0667`](https://github.com/mastra-ai/mastra/commit/fcd0667a4e378be35c9a1b1eb19cce78fbfd7282), [`bab06b1`](https://github.com/mastra-ai/mastra/commit/bab06b18923873a584bdfc71a6b4ec7fb4727fb7)]:
|
|
10
|
+
- @mastra/core@1.58.0-alpha.5
|
|
11
|
+
|
|
3
12
|
## 1.5.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1090,7 +1090,7 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
|
|
|
1090
1090
|
hasMore: false
|
|
1091
1091
|
};
|
|
1092
1092
|
if (perPage === 0 && include && include.length > 0) {
|
|
1093
|
-
const messages = await this._getIncludedMessages(include);
|
|
1093
|
+
const messages = await this._getIncludedMessages(include, void 0, resourceId);
|
|
1094
1094
|
const list = new _mastra_core_agent.MessageList().add(messages, "memory");
|
|
1095
1095
|
return {
|
|
1096
1096
|
messages: this._sortMessages(list.get.all.db(), field, direction),
|
|
@@ -1123,7 +1123,7 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
|
|
|
1123
1123
|
if (include && include.length > 0) {
|
|
1124
1124
|
const preloadedThreads = /* @__PURE__ */ new Map();
|
|
1125
1125
|
if (!resourceId && !filter?.dateRange && !metadataFilter) for (const tid of threadIds) preloadedThreads.set(tid, rows.filter((r) => r.thread_id === tid));
|
|
1126
|
-
const includedMessages = await this._getIncludedMessages(include, preloadedThreads);
|
|
1126
|
+
const includedMessages = await this._getIncludedMessages(include, preloadedThreads, resourceId);
|
|
1127
1127
|
for (const msg of includedMessages) if (!messageIds.has(msg.id)) {
|
|
1128
1128
|
messages.push(msg);
|
|
1129
1129
|
messageIds.add(msg.id);
|
|
@@ -1305,8 +1305,20 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
|
|
|
1305
1305
|
return direction === "ASC" ? String(aValue).localeCompare(String(bValue)) : String(bValue).localeCompare(String(aValue));
|
|
1306
1306
|
});
|
|
1307
1307
|
}
|
|
1308
|
-
|
|
1308
|
+
/**
|
|
1309
|
+
* Fetches the messages named by `include` together with their surrounding context.
|
|
1310
|
+
*
|
|
1311
|
+
* @param include - Message ids to pin, each with an optional before/after window.
|
|
1312
|
+
* @param preloadedThreads - Thread snapshots already loaded by the caller, reused instead of re-querying.
|
|
1313
|
+
* @param resourceId - When set, restricts both the pinned messages and their context
|
|
1314
|
+
* to that resource so an id from another resource returns nothing.
|
|
1315
|
+
*/
|
|
1316
|
+
async _getIncludedMessages(include, preloadedThreads, resourceId) {
|
|
1309
1317
|
if (include.length === 0) return [];
|
|
1318
|
+
const resourceFilters = resourceId ? [{
|
|
1319
|
+
field: "resourceId",
|
|
1320
|
+
value: resourceId
|
|
1321
|
+
}] : [];
|
|
1310
1322
|
const messages = [];
|
|
1311
1323
|
const messageIds = /* @__PURE__ */ new Set();
|
|
1312
1324
|
const threadMessagesCache = new Map(preloadedThreads ?? []);
|
|
@@ -1327,7 +1339,7 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
|
|
|
1327
1339
|
const messageRows = await this.#db.queryTable(_mastra_core_storage.TABLE_MESSAGES, [{
|
|
1328
1340
|
field: "id",
|
|
1329
1341
|
value: includeItem.id
|
|
1330
|
-
}]);
|
|
1342
|
+
}, ...resourceFilters]);
|
|
1331
1343
|
if (messageRows.length > 0) {
|
|
1332
1344
|
target = messageRows[0];
|
|
1333
1345
|
targetThreadId = target.thread_id;
|
|
@@ -1335,7 +1347,7 @@ var MemoryConvex = class extends _mastra_core_storage.MemoryStorage {
|
|
|
1335
1347
|
const otherThreadRows = await this.#db.queryTable(_mastra_core_storage.TABLE_MESSAGES, [{
|
|
1336
1348
|
field: "thread_id",
|
|
1337
1349
|
value: targetThreadId
|
|
1338
|
-
}]);
|
|
1350
|
+
}, ...resourceFilters]);
|
|
1339
1351
|
threadMessagesCache.set(targetThreadId, otherThreadRows);
|
|
1340
1352
|
for (const row of otherThreadRows) cachedTargets.set(row.id, {
|
|
1341
1353
|
threadId: targetThreadId,
|