@mastra/spanner 1.6.0-alpha.0 → 1.6.0-alpha.2
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 +28 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +29 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -13
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +9 -3
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @mastra/spanner
|
|
2
2
|
|
|
3
|
+
## 1.6.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed generated thread titles being clobbered during a turn ([#21041](https://github.com/mastra-ai/mastra/pull/21041))
|
|
8
|
+
|
|
9
|
+
`updateThread` required both `title` and `metadata`, so callers that only needed to
|
|
10
|
+
change metadata (message persistence, working memory, observational memory, channel
|
|
11
|
+
subscriptions) had to read the thread and pass its title back. When title generation
|
|
12
|
+
finished between that read and the write, the freshly generated title was overwritten
|
|
13
|
+
with the stale one.
|
|
14
|
+
|
|
15
|
+
`title` and `metadata` are now independently optional: omitting one leaves that column
|
|
16
|
+
untouched. Callers that only change metadata no longer send a title, and message
|
|
17
|
+
persistence no longer rewrites a thread row it just read.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`1c75e32`](https://github.com/mastra-ai/mastra/commit/1c75e32f7fc0b9fb6f548b4407feaec8a1440212), [`c47165c`](https://github.com/mastra-ai/mastra/commit/c47165c983c87594c6952f1fd2fa51a90205034c), [`e08e789`](https://github.com/mastra-ai/mastra/commit/e08e789c1bf4cd2fe46363f7a4728536ceccc9bd), [`35cc901`](https://github.com/mastra-ai/mastra/commit/35cc90102cf834a84827acaf9eee0b6d6d1e2a3b), [`a8b4cf0`](https://github.com/mastra-ai/mastra/commit/a8b4cf02823cffebc4751a53337dfacf097c1ae1), [`f33264f`](https://github.com/mastra-ai/mastra/commit/f33264f517ae603279afd5c4251e2b40f6dd3618), [`689f2c4`](https://github.com/mastra-ai/mastra/commit/689f2c4b6c0835fe455702b01d21daa8abcd9331), [`eeae63e`](https://github.com/mastra-ai/mastra/commit/eeae63e7fbe8e1f237adc69bca6e2ac13c5ca907), [`4c186a0`](https://github.com/mastra-ai/mastra/commit/4c186a017275f45e6ed4c09de0f89550e2d09e8c), [`b0fa077`](https://github.com/mastra-ai/mastra/commit/b0fa077bcbc9b08551846fe372a0d3d15b71ed72)]:
|
|
20
|
+
- @mastra/core@1.58.0-alpha.8
|
|
21
|
+
|
|
22
|
+
## 1.6.0-alpha.1
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Fixed resource-scoped message includes across storage adapters so included context cannot cross resource boundaries. ([#20984](https://github.com/mastra-ai/mastra/pull/20984))
|
|
27
|
+
|
|
28
|
+
- 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)]:
|
|
29
|
+
- @mastra/core@1.58.0-alpha.5
|
|
30
|
+
|
|
3
31
|
## 1.6.0-alpha.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-spanner
|
|
|
3
3
|
description: Documentation for @mastra/spanner. Use when working with @mastra/spanner APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/spanner"
|
|
6
|
-
version: "1.6.0-alpha.
|
|
6
|
+
version: "1.6.0-alpha.2"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/dist/index.cjs
CHANGED
|
@@ -6603,7 +6603,7 @@ var MemorySpanner = class MemorySpanner extends _mastra_core_storage.MemoryStora
|
|
|
6603
6603
|
text: `Thread ${id} not found`,
|
|
6604
6604
|
details: {
|
|
6605
6605
|
threadId: id,
|
|
6606
|
-
title
|
|
6606
|
+
title: title ?? null
|
|
6607
6607
|
}
|
|
6608
6608
|
});
|
|
6609
6609
|
existingThread = this.formatThreadRow(row);
|
|
@@ -6615,7 +6615,7 @@ var MemorySpanner = class MemorySpanner extends _mastra_core_storage.MemoryStora
|
|
|
6615
6615
|
tableName: _mastra_core_storage.TABLE_THREADS,
|
|
6616
6616
|
keys: { id },
|
|
6617
6617
|
data: {
|
|
6618
|
-
title,
|
|
6618
|
+
title: title ?? existingThread.title,
|
|
6619
6619
|
metadata: merged,
|
|
6620
6620
|
updatedAt: now
|
|
6621
6621
|
},
|
|
@@ -6643,7 +6643,7 @@ var MemorySpanner = class MemorySpanner extends _mastra_core_storage.MemoryStora
|
|
|
6643
6643
|
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
6644
6644
|
details: {
|
|
6645
6645
|
threadId: id,
|
|
6646
|
-
title
|
|
6646
|
+
title: title ?? null
|
|
6647
6647
|
}
|
|
6648
6648
|
}, error);
|
|
6649
6649
|
}
|
|
@@ -6738,12 +6738,20 @@ var MemorySpanner = class MemorySpanner extends _mastra_core_storage.MemoryStora
|
|
|
6738
6738
|
throw mastraError;
|
|
6739
6739
|
}
|
|
6740
6740
|
}
|
|
6741
|
-
/**
|
|
6742
|
-
|
|
6741
|
+
/**
|
|
6742
|
+
* Resolves the `include` clause: pinned messages plus their before/after windows.
|
|
6743
|
+
*
|
|
6744
|
+
* @param include - Message ids to pin, each with an optional before/after window.
|
|
6745
|
+
* @param resourceId - When set, restricts both the pinned messages and their context
|
|
6746
|
+
* to that resource so an id from another resource returns nothing.
|
|
6747
|
+
*/
|
|
6748
|
+
async getIncludedMessages({ include, resourceId }) {
|
|
6743
6749
|
if (!include || include.length === 0) return null;
|
|
6750
|
+
const resourceCondition = resourceId ? ` AND ${quoteIdent("resourceId", "column name")} = @scopedResourceId` : "";
|
|
6751
|
+
const resourceParams = resourceId ? { scopedResourceId: resourceId } : {};
|
|
6744
6752
|
const ids = include.map((i) => i.id);
|
|
6745
6753
|
const placeholders = [];
|
|
6746
|
-
const idParams = {};
|
|
6754
|
+
const idParams = { ...resourceParams };
|
|
6747
6755
|
ids.forEach((id, i) => {
|
|
6748
6756
|
const name = `tid${i}`;
|
|
6749
6757
|
placeholders.push(`@${name}`);
|
|
@@ -6751,7 +6759,7 @@ var MemorySpanner = class MemorySpanner extends _mastra_core_storage.MemoryStora
|
|
|
6751
6759
|
});
|
|
6752
6760
|
const targetsSql = `SELECT id, content, role, type, ${quoteIdent("createdAt", "column name")}, ${quoteIdent("thread_id", "column name")} AS threadId, ${quoteIdent("resourceId", "column name")}
|
|
6753
6761
|
FROM ${quoteIdent(_mastra_core_storage.TABLE_MESSAGES, "table name")}
|
|
6754
|
-
WHERE id IN (${placeholders.join(", ")})`;
|
|
6762
|
+
WHERE id IN (${placeholders.join(", ")})${resourceCondition}`;
|
|
6755
6763
|
const [targetRows] = await this.database.run({
|
|
6756
6764
|
sql: targetsSql,
|
|
6757
6765
|
params: idParams,
|
|
@@ -6776,14 +6784,15 @@ var MemorySpanner = class MemorySpanner extends _mastra_core_storage.MemoryStora
|
|
|
6776
6784
|
sql: `SELECT id, content, role, type, ${quoteIdent("createdAt", "column name")}, ${quoteIdent("thread_id", "column name")} AS threadId, ${quoteIdent("resourceId", "column name")}
|
|
6777
6785
|
FROM ${quoteIdent(_mastra_core_storage.TABLE_MESSAGES, "table name")}
|
|
6778
6786
|
WHERE ${quoteIdent("thread_id", "column name")} = @threadId
|
|
6779
|
-
AND (${quoteIdent("createdAt", "column name")} < @ts OR (${quoteIdent("createdAt", "column name")} = @ts AND id < @id))
|
|
6787
|
+
AND (${quoteIdent("createdAt", "column name")} < @ts OR (${quoteIdent("createdAt", "column name")} = @ts AND id < @id))${resourceCondition}
|
|
6780
6788
|
ORDER BY ${quoteIdent("createdAt", "column name")} DESC, id DESC
|
|
6781
6789
|
LIMIT @lim`,
|
|
6782
6790
|
params: {
|
|
6783
6791
|
threadId,
|
|
6784
6792
|
ts: targetCreatedAt,
|
|
6785
6793
|
id: target.id,
|
|
6786
|
-
lim: withPreviousMessages
|
|
6794
|
+
lim: withPreviousMessages,
|
|
6795
|
+
...resourceParams
|
|
6787
6796
|
},
|
|
6788
6797
|
json: true
|
|
6789
6798
|
});
|
|
@@ -6797,14 +6806,15 @@ var MemorySpanner = class MemorySpanner extends _mastra_core_storage.MemoryStora
|
|
|
6797
6806
|
sql: `SELECT id, content, role, type, ${quoteIdent("createdAt", "column name")}, ${quoteIdent("thread_id", "column name")} AS threadId, ${quoteIdent("resourceId", "column name")}
|
|
6798
6807
|
FROM ${quoteIdent(_mastra_core_storage.TABLE_MESSAGES, "table name")}
|
|
6799
6808
|
WHERE ${quoteIdent("thread_id", "column name")} = @threadId
|
|
6800
|
-
AND (${quoteIdent("createdAt", "column name")} > @ts OR (${quoteIdent("createdAt", "column name")} = @ts AND id > @id))
|
|
6809
|
+
AND (${quoteIdent("createdAt", "column name")} > @ts OR (${quoteIdent("createdAt", "column name")} = @ts AND id > @id))${resourceCondition}
|
|
6801
6810
|
ORDER BY ${quoteIdent("createdAt", "column name")} ASC, id ASC
|
|
6802
6811
|
LIMIT @lim`,
|
|
6803
6812
|
params: {
|
|
6804
6813
|
threadId,
|
|
6805
6814
|
ts: targetCreatedAt,
|
|
6806
6815
|
id: target.id,
|
|
6807
|
-
lim: withNextMessages
|
|
6816
|
+
lim: withNextMessages,
|
|
6817
|
+
...resourceParams
|
|
6808
6818
|
},
|
|
6809
6819
|
json: true
|
|
6810
6820
|
});
|
|
@@ -6857,7 +6867,10 @@ var MemorySpanner = class MemorySpanner extends _mastra_core_storage.MemoryStora
|
|
|
6857
6867
|
hasMore: false
|
|
6858
6868
|
};
|
|
6859
6869
|
if (perPage === 0 && include && include.length > 0) {
|
|
6860
|
-
const includeMessages = await this.getIncludedMessages({
|
|
6870
|
+
const includeMessages = await this.getIncludedMessages({
|
|
6871
|
+
include,
|
|
6872
|
+
resourceId
|
|
6873
|
+
}) ?? [];
|
|
6861
6874
|
const parsedIncludes = this.parseAndFormatMessages(includeMessages, "v2");
|
|
6862
6875
|
const dirMul = direction === "ASC" ? 1 : -1;
|
|
6863
6876
|
return {
|
|
@@ -6915,7 +6928,10 @@ var MemorySpanner = class MemorySpanner extends _mastra_core_storage.MemoryStora
|
|
|
6915
6928
|
};
|
|
6916
6929
|
if (include?.length) {
|
|
6917
6930
|
const seen = new Set(messages.map((m) => m.id));
|
|
6918
|
-
(await this.getIncludedMessages({
|
|
6931
|
+
(await this.getIncludedMessages({
|
|
6932
|
+
include,
|
|
6933
|
+
resourceId
|
|
6934
|
+
}))?.forEach((msg) => {
|
|
6919
6935
|
if (!seen.has(msg.id)) {
|
|
6920
6936
|
messages.push(msg);
|
|
6921
6937
|
seen.add(msg.id);
|