@mastra/lance 1.3.0-alpha.0 → 1.3.0-alpha.1
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 +14 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/lance
|
|
2
2
|
|
|
3
|
+
## 1.3.0-alpha.1
|
|
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.3.0-alpha.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -869,7 +869,7 @@ var StoreMemoryLance = class extends _mastra_core_storage.MemoryStorage {
|
|
|
869
869
|
hasMore: false
|
|
870
870
|
};
|
|
871
871
|
if (perPage === 0 && include && include.length > 0) {
|
|
872
|
-
const includedMessages = await this._getIncludedMessages(table, include);
|
|
872
|
+
const includedMessages = await this._getIncludedMessages(table, include, resourceId);
|
|
873
873
|
const list = new _mastra_core_agent.MessageList().add(includedMessages, "memory");
|
|
874
874
|
return {
|
|
875
875
|
messages: this._sortMessages(list.get.all.db(), field, direction),
|
|
@@ -902,7 +902,7 @@ var StoreMemoryLance = class extends _mastra_core_storage.MemoryStorage {
|
|
|
902
902
|
const primaryPageCount = messages.length;
|
|
903
903
|
const messageIds = new Set(messages.map((m) => m.id));
|
|
904
904
|
if (include && include.length > 0) {
|
|
905
|
-
const includedMessages = await this._getIncludedMessages(table, include);
|
|
905
|
+
const includedMessages = await this._getIncludedMessages(table, include, resourceId);
|
|
906
906
|
for (const includeMsg of includedMessages) if (!messageIds.has(includeMsg.id)) {
|
|
907
907
|
messages.push(includeMsg);
|
|
908
908
|
messageIds.add(includeMsg.id);
|
|
@@ -1060,16 +1060,25 @@ var StoreMemoryLance = class extends _mastra_core_storage.MemoryStorage {
|
|
|
1060
1060
|
return direction === "ASC" ? aValue - bValue : bValue - aValue;
|
|
1061
1061
|
});
|
|
1062
1062
|
}
|
|
1063
|
-
|
|
1063
|
+
/**
|
|
1064
|
+
* Fetches the messages named by `include` together with their surrounding context.
|
|
1065
|
+
*
|
|
1066
|
+
* @param table - Open handle to the messages table.
|
|
1067
|
+
* @param include - Message ids to pin, each with an optional before/after window.
|
|
1068
|
+
* @param resourceId - When set, restricts both the pinned messages and their context
|
|
1069
|
+
* to that resource so an id from another resource returns nothing.
|
|
1070
|
+
*/
|
|
1071
|
+
async _getIncludedMessages(table, include, resourceId) {
|
|
1064
1072
|
if (include.length === 0) return [];
|
|
1073
|
+
const resourceCondition = resourceId ? ` AND resourceId = '${this.escapeSql(resourceId)}'` : "";
|
|
1065
1074
|
const targetIds = include.map((item) => item.id);
|
|
1066
1075
|
const idCondition = targetIds.length === 1 ? `id = '${this.escapeSql(targetIds[0])}'` : `id IN (${targetIds.map((id) => `'${this.escapeSql(id)}'`).join(", ")})`;
|
|
1067
|
-
const targetRecords = await table.query().where(idCondition).toArray();
|
|
1076
|
+
const targetRecords = await table.query().where(`${idCondition}${resourceCondition}`).toArray();
|
|
1068
1077
|
if (!include.some((item) => item.withPreviousMessages || item.withNextMessages)) return targetRecords.map((row) => this.normalizeMessage(row));
|
|
1069
1078
|
const threadIdsToFetch = [...new Set(targetRecords.map((r) => r.thread_id))];
|
|
1070
1079
|
const threadCache = /* @__PURE__ */ new Map();
|
|
1071
1080
|
for (const tid of threadIdsToFetch) {
|
|
1072
|
-
const threadRecords = await table.query().where(`thread_id = '${this.escapeSql(tid)}'`).toArray();
|
|
1081
|
+
const threadRecords = await table.query().where(`thread_id = '${this.escapeSql(tid)}'${resourceCondition}`).toArray();
|
|
1073
1082
|
threadRecords.sort((a, b) => a.createdAt - b.createdAt);
|
|
1074
1083
|
threadCache.set(tid, threadRecords);
|
|
1075
1084
|
}
|