@mastra/ai-sdk 1.9.1 → 1.10.0-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 +31 -0
- package/dist/index.cjs +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/sse-heartbeat.d.ts +8 -2
- package/dist/sse-heartbeat.d.ts.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
+
## 1.10.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added `withSseHeartbeat()` to the public API so you can keep server-sent event streams alive outside of `chatRoute()`. ([#22116](https://github.com/mastra-ai/mastra/pull/22116))
|
|
8
|
+
|
|
9
|
+
If you build the response yourself in a Next.js, Astro, Nuxt, or SvelteKit route handler, proxies can drop the connection when the stream sends no bytes during a long reasoning burst or slow tool call. `chatRoute()` already avoided this with its `heartbeatMs` option, but the underlying helper was not exported.
|
|
10
|
+
|
|
11
|
+
**Before**
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
return createUIMessageStreamResponse({ stream });
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**After**
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { withSseHeartbeat } from '@mastra/ai-sdk';
|
|
21
|
+
|
|
22
|
+
return withSseHeartbeat(createUIMessageStreamResponse({ stream }), 15000);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`assertValidHeartbeatMs()` is exported alongside it so you can validate a user-supplied interval before streaming. Closes #21954.
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Fixed suspended agent runs resuming on a newer published version. When an agent is resolved from a status selector (for example `{ status: 'published' }`), the version the run started on is now recorded when the run suspends and reused when it resumes, so approval and human-in-the-loop flows finish on the same version they started on. New runs still pick up the latest published version. Fixes #21846 ([#22128](https://github.com/mastra-ai/mastra/pull/22128))
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [[`2c85f42`](https://github.com/mastra-ai/mastra/commit/2c85f428e04ccd63ea31a7ec80b5b327afdad555), [`11bbeb9`](https://github.com/mastra-ai/mastra/commit/11bbeb9b108ef2264e05acefc6dafb9cbb342921), [`1a485f3`](https://github.com/mastra-ai/mastra/commit/1a485f3538f5ec64d58bd8b5e1e99de0c695c87b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`8661d7d`](https://github.com/mastra-ai/mastra/commit/8661d7d7179f0a024456aabdd8679bcecd09ac28), [`575e343`](https://github.com/mastra-ai/mastra/commit/575e343900451021d96110916497d334af7bc252), [`cacb839`](https://github.com/mastra-ai/mastra/commit/cacb8392d9e74189b56d857290b0615f98a2683d), [`b47b26e`](https://github.com/mastra-ai/mastra/commit/b47b26e6fe95cb8a3482be2c5e52de157fe59d0b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`c46eb09`](https://github.com/mastra-ai/mastra/commit/c46eb09ce4987509af57a0ac582c61241a6dd2f1), [`30ed33e`](https://github.com/mastra-ai/mastra/commit/30ed33ee14084a26019aba15fceadda6d6ddefaf), [`91ad69d`](https://github.com/mastra-ai/mastra/commit/91ad69d64994c89199b0c55399e64ed91c61df2f), [`8dc408d`](https://github.com/mastra-ai/mastra/commit/8dc408d34438f9e13297f792c11a5cfd6cf952e1), [`c92def1`](https://github.com/mastra-ai/mastra/commit/c92def10a13c822972c96f0a4ca6ffc1f4258aed), [`c5eaec5`](https://github.com/mastra-ai/mastra/commit/c5eaec5a860d80d0e3805e67db0414b87ac8cbed), [`e66b2ba`](https://github.com/mastra-ai/mastra/commit/e66b2ba100db63eaeab6e21e1ea34b113f2ec781)]:
|
|
32
|
+
- @mastra/core@1.62.0-alpha.3
|
|
33
|
+
|
|
3
34
|
## 1.9.1
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -13671,8 +13671,14 @@ function assertValidHeartbeatMs(heartbeatMs) {
|
|
|
13671
13671
|
if (heartbeatMs !== void 0 && !(heartbeatMs <= 0) && (!Number.isFinite(heartbeatMs) || heartbeatMs > MAX_TIMEOUT_MS)) throw new RangeError(`heartbeatMs must be a finite number no greater than ${MAX_TIMEOUT_MS}`);
|
|
13672
13672
|
}
|
|
13673
13673
|
/**
|
|
13674
|
-
*
|
|
13675
|
-
*
|
|
13674
|
+
* Wraps an SSE `Response` so it emits periodic `: heartbeat` comments while the source is idle,
|
|
13675
|
+
* keeping connections alive through proxies that close idle streams.
|
|
13676
|
+
*
|
|
13677
|
+
* Heartbeats are only inserted between complete SSE frames. AI SDK serialization uses LF-delimited
|
|
13678
|
+
* frames, which this wrapper preserves and relies on.
|
|
13679
|
+
*
|
|
13680
|
+
* Returns the input response unchanged when `heartbeatMs` is omitted, is `<= 0`, or the response has
|
|
13681
|
+
* no body. Throws a `RangeError` when `heartbeatMs` is enabled but cannot be scheduled with a timer.
|
|
13676
13682
|
*/
|
|
13677
13683
|
function withSseHeartbeat(response, heartbeatMs) {
|
|
13678
13684
|
assertValidHeartbeatMs(heartbeatMs);
|
|
@@ -15264,6 +15270,7 @@ function toAISdkFormat() {
|
|
|
15264
15270
|
throw new Error("toAISdkFormat() has been deprecated. Please use toAISdkStream() instead.\n\nMigration:\n import { toAISdkFormat } from \"@mastra/ai-sdk\";\n // Change to:\n import { toAISdkStream } from \"@mastra/ai-sdk\";\n\nThe function signature remains the same.");
|
|
15265
15271
|
}
|
|
15266
15272
|
//#endregion
|
|
15273
|
+
exports.assertValidHeartbeatMs = assertValidHeartbeatMs;
|
|
15267
15274
|
exports.chatRoute = chatRoute;
|
|
15268
15275
|
exports.handleChatStream = handleChatStream;
|
|
15269
15276
|
exports.handleNetworkStream = handleNetworkStream;
|
|
@@ -15274,6 +15281,7 @@ exports.toAISdkFormat = toAISdkFormat;
|
|
|
15274
15281
|
exports.toAISdkStream = toAISdkStream;
|
|
15275
15282
|
exports.toAISdkV5Stream = toAISdkV5Stream;
|
|
15276
15283
|
exports.withMastra = withMastra;
|
|
15284
|
+
exports.withSseHeartbeat = withSseHeartbeat;
|
|
15277
15285
|
exports.workflowRoute = workflowRoute;
|
|
15278
15286
|
exports.workflowSnapshotToStream = workflowSnapshotToStream;
|
|
15279
15287
|
|