@mastra/mssql 1.7.0-alpha.0 → 1.7.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 +24 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -9
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +9 -2
- 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/mssql
|
|
2
2
|
|
|
3
|
+
## 1.7.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.7.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.7.0-alpha.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2416,7 +2416,7 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2416
2416
|
text: `Thread ${id} not found`,
|
|
2417
2417
|
details: {
|
|
2418
2418
|
threadId: id,
|
|
2419
|
-
title
|
|
2419
|
+
title: title ?? null
|
|
2420
2420
|
}
|
|
2421
2421
|
});
|
|
2422
2422
|
const mergedMetadata = {
|
|
@@ -2435,7 +2435,7 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2435
2435
|
WHERE id = @id`;
|
|
2436
2436
|
const req = this.pool.request();
|
|
2437
2437
|
req.input("id", id);
|
|
2438
|
-
req.input("title", title);
|
|
2438
|
+
req.input("title", title ?? existingThread.title);
|
|
2439
2439
|
req.input("metadata", JSON.stringify(mergedMetadata));
|
|
2440
2440
|
req.input("updatedAt", /* @__PURE__ */ new Date());
|
|
2441
2441
|
const result = await req.query(sql);
|
|
@@ -2451,7 +2451,7 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2451
2451
|
text: `Thread ${id} not found after update`,
|
|
2452
2452
|
details: {
|
|
2453
2453
|
threadId: id,
|
|
2454
|
-
title
|
|
2454
|
+
title: title ?? null
|
|
2455
2455
|
}
|
|
2456
2456
|
});
|
|
2457
2457
|
return {
|
|
@@ -2467,7 +2467,7 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2467
2467
|
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
2468
2468
|
details: {
|
|
2469
2469
|
threadId: id,
|
|
2470
|
-
title
|
|
2470
|
+
title: title ?? null
|
|
2471
2471
|
}
|
|
2472
2472
|
}, error);
|
|
2473
2473
|
}
|
|
@@ -2511,7 +2511,14 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2511
2511
|
return diff !== 0 ? diff : a.id.localeCompare(b.id);
|
|
2512
2512
|
});
|
|
2513
2513
|
}
|
|
2514
|
-
|
|
2514
|
+
/**
|
|
2515
|
+
* Fetches the messages named by `include` together with their surrounding context.
|
|
2516
|
+
*
|
|
2517
|
+
* @param include - Message ids to pin, each with an optional before/after window.
|
|
2518
|
+
* @param resourceId - When set, restricts both the pinned messages and their context
|
|
2519
|
+
* to that resource so an id from another resource returns nothing.
|
|
2520
|
+
*/
|
|
2521
|
+
async _getIncludedMessages({ include, resourceId }) {
|
|
2515
2522
|
if (!include || include.length === 0) return null;
|
|
2516
2523
|
const unionQueries = [];
|
|
2517
2524
|
const paramValues = [];
|
|
@@ -2521,6 +2528,7 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2521
2528
|
indexName: _mastra_core_storage.TABLE_MESSAGES,
|
|
2522
2529
|
schemaName: getSchemaName(this.schema)
|
|
2523
2530
|
});
|
|
2531
|
+
const resourceCondition = resourceId ? ` AND [resourceId] = @presource` : "";
|
|
2524
2532
|
for (const inc of include) {
|
|
2525
2533
|
const { id, withPreviousMessages = 0, withNextMessages = 0 } = inc;
|
|
2526
2534
|
const pId = `@p${paramIdx}`;
|
|
@@ -2539,7 +2547,7 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2539
2547
|
FROM (
|
|
2540
2548
|
SELECT *, ROW_NUMBER() OVER (ORDER BY [createdAt] ASC) as row_num
|
|
2541
2549
|
FROM ${tableName}
|
|
2542
|
-
WHERE [thread_id] = (SELECT thread_id FROM ${tableName} WHERE id = ${pId})
|
|
2550
|
+
WHERE [thread_id] = (SELECT thread_id FROM ${tableName} WHERE id = ${pId}${resourceCondition})${resourceCondition}
|
|
2543
2551
|
) AS m
|
|
2544
2552
|
WHERE m.id = ${pId}
|
|
2545
2553
|
OR EXISTS (
|
|
@@ -2547,7 +2555,7 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2547
2555
|
FROM (
|
|
2548
2556
|
SELECT *, ROW_NUMBER() OVER (ORDER BY [createdAt] ASC) as row_num
|
|
2549
2557
|
FROM ${tableName}
|
|
2550
|
-
WHERE [thread_id] = (SELECT thread_id FROM ${tableName} WHERE id = ${pId})
|
|
2558
|
+
WHERE [thread_id] = (SELECT thread_id FROM ${tableName} WHERE id = ${pId}${resourceCondition})${resourceCondition}
|
|
2551
2559
|
) AS target
|
|
2552
2560
|
WHERE target.id = ${pId}
|
|
2553
2561
|
AND (
|
|
@@ -2571,6 +2579,7 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2571
2579
|
`;
|
|
2572
2580
|
const req = this.pool.request();
|
|
2573
2581
|
for (let i = 0; i < paramValues.length; ++i) req.input(paramNames[i], paramValues[i]);
|
|
2582
|
+
if (resourceId) req.input("presource", resourceId);
|
|
2574
2583
|
const includedRows = (await req.query(finalQuery)).recordset || [];
|
|
2575
2584
|
const seen = /* @__PURE__ */ new Set();
|
|
2576
2585
|
return includedRows.filter((row) => {
|
|
@@ -2670,7 +2679,10 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2670
2679
|
hasMore: false
|
|
2671
2680
|
};
|
|
2672
2681
|
if (perPage === 0 && include && include.length > 0) {
|
|
2673
|
-
const includeMessages = await this._getIncludedMessages({
|
|
2682
|
+
const includeMessages = await this._getIncludedMessages({
|
|
2683
|
+
include,
|
|
2684
|
+
resourceId
|
|
2685
|
+
});
|
|
2674
2686
|
const messages = this._parseAndFormatMessages(includeMessages ?? [], "v2");
|
|
2675
2687
|
return {
|
|
2676
2688
|
messages: this._sortMessages(messages, field, direction),
|
|
@@ -2707,7 +2719,10 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2707
2719
|
};
|
|
2708
2720
|
if (include?.length) {
|
|
2709
2721
|
const messageIds = new Set(messages.map((m) => m.id));
|
|
2710
|
-
(await this._getIncludedMessages({
|
|
2722
|
+
(await this._getIncludedMessages({
|
|
2723
|
+
include,
|
|
2724
|
+
resourceId
|
|
2725
|
+
}))?.forEach((msg) => {
|
|
2711
2726
|
if (!messageIds.has(msg.id)) {
|
|
2712
2727
|
messages.push(msg);
|
|
2713
2728
|
messageIds.add(msg.id);
|