@mastra/ai-sdk 1.9.0 → 1.9.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 +18 -0
- package/dist/chat-route.d.ts +5 -2
- package/dist/chat-route.d.ts.map +1 -1
- package/dist/index.cjs +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
+
## 1.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Forward `messageMetadata` from `chatRoute` to the underlying AI SDK stream handler. ([#21919](https://github.com/mastra-ai/mastra/pull/21919))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`88d14ca`](https://github.com/mastra-ai/mastra/commit/88d14cac008582a618fecc3d5c7fd3bdf4f6ddc3), [`480e491`](https://github.com/mastra-ai/mastra/commit/480e491588bd6a7a1c9ee4407590ad625dd33952), [`9267e9b`](https://github.com/mastra-ai/mastra/commit/9267e9b3d9c2fcf16936050495a787054c2431ab), [`acc3471`](https://github.com/mastra-ai/mastra/commit/acc3471de5f3fde8027ee4e355af292b2bc1bc30), [`b6a771e`](https://github.com/mastra-ai/mastra/commit/b6a771ef23d203ddb348efca8065eff65def8191), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`9267e9b`](https://github.com/mastra-ai/mastra/commit/9267e9b3d9c2fcf16936050495a787054c2431ab), [`3bb88dd`](https://github.com/mastra-ai/mastra/commit/3bb88ddf07fb98f3cd16d3bff94e51cd3b45d011), [`d23e75d`](https://github.com/mastra-ai/mastra/commit/d23e75d57cc7cf5b9bfdbee896bf5a6a2484fed7), [`c8faa4e`](https://github.com/mastra-ai/mastra/commit/c8faa4e1cfebaec56b65e754e90b9fe46d153359), [`d378d75`](https://github.com/mastra-ai/mastra/commit/d378d7511f71309ed61a8f6b93cd0361dc6cb70f), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`26d4016`](https://github.com/mastra-ai/mastra/commit/26d40160ff7f7d8bf95fee2039a52cbc83863533), [`7c60df5`](https://github.com/mastra-ai/mastra/commit/7c60df5c7872343fbac5c3e5b1175c8076a5abfd), [`9267e9b`](https://github.com/mastra-ai/mastra/commit/9267e9b3d9c2fcf16936050495a787054c2431ab), [`84a5b69`](https://github.com/mastra-ai/mastra/commit/84a5b699f84d6bae0a34efe5a970d891090b9f41), [`f2031a4`](https://github.com/mastra-ai/mastra/commit/f2031a47445e8f67a89ba1309036816f97ab7a65), [`9267e9b`](https://github.com/mastra-ai/mastra/commit/9267e9b3d9c2fcf16936050495a787054c2431ab), [`cad4208`](https://github.com/mastra-ai/mastra/commit/cad42082e6aa1776168a94914f523334be45d929), [`8e529d4`](https://github.com/mastra-ai/mastra/commit/8e529d4ac754efef04b225841349e0da9edf89a6), [`57c5103`](https://github.com/mastra-ai/mastra/commit/57c51035a2a36e3df3c4f32f46bb789a66ed5946), [`038b7b4`](https://github.com/mastra-ai/mastra/commit/038b7b405cb4ac25ab3f3031334111b1f87ac112), [`4132d61`](https://github.com/mastra-ai/mastra/commit/4132d61f8367077120ee9e6420d3224dffd93c93), [`d378d75`](https://github.com/mastra-ai/mastra/commit/d378d7511f71309ed61a8f6b93cd0361dc6cb70f)]:
|
|
10
|
+
- @mastra/core@1.61.0
|
|
11
|
+
|
|
12
|
+
## 1.9.1-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Forward `messageMetadata` from `chatRoute` to the underlying AI SDK stream handler. ([#21919](https://github.com/mastra-ai/mastra/pull/21919))
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`480e491`](https://github.com/mastra-ai/mastra/commit/480e491588bd6a7a1c9ee4407590ad625dd33952), [`3bb88dd`](https://github.com/mastra-ai/mastra/commit/3bb88ddf07fb98f3cd16d3bff94e51cd3b45d011), [`d378d75`](https://github.com/mastra-ai/mastra/commit/d378d7511f71309ed61a8f6b93cd0361dc6cb70f), [`cad4208`](https://github.com/mastra-ai/mastra/commit/cad42082e6aa1776168a94914f523334be45d929), [`d378d75`](https://github.com/mastra-ai/mastra/commit/d378d7511f71309ed61a8f6b93cd0361dc6cb70f)]:
|
|
19
|
+
- @mastra/core@1.61.0-alpha.2
|
|
20
|
+
|
|
3
21
|
## 1.9.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/chat-route.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ type ChatStreamHandlerOptionsV7<UI_MESSAGE extends V7UIMessage = V7UIMessage, OU
|
|
|
85
85
|
export declare function handleChatStream<UI_MESSAGE extends V5UIMessage = V5UIMessage, OUTPUT = undefined>(options: ChatStreamHandlerOptionsV5<UI_MESSAGE, OUTPUT>): Promise<V5UIMessageStream<UI_MESSAGE>>;
|
|
86
86
|
export declare function handleChatStream<UI_MESSAGE extends V6UIMessage = V6UIMessage, OUTPUT = undefined>(options: ChatStreamHandlerOptionsV6<UI_MESSAGE, OUTPUT>): Promise<V6UIMessageStream<UI_MESSAGE>>;
|
|
87
87
|
export declare function handleChatStream<UI_MESSAGE extends V7UIMessage = V7UIMessage, OUTPUT = undefined>(options: ChatStreamHandlerOptionsV7<UI_MESSAGE, OUTPUT>): Promise<V7UIMessageStream<UI_MESSAGE>>;
|
|
88
|
-
export type chatRouteOptions<OUTPUT = undefined> = {
|
|
88
|
+
export type chatRouteOptions<OUTPUT = undefined, UI_MESSAGE extends SupportedUIMessage = SupportedUIMessage> = {
|
|
89
89
|
defaultOptions?: ChatStreamDefaultOptions<OUTPUT>;
|
|
90
90
|
/** Experimental transforms applied before converting Mastra chunks to AI SDK UI chunks. */
|
|
91
91
|
experimentalTransform?: MastraStreamTransformOptions<OUTPUT>;
|
|
@@ -105,6 +105,8 @@ export type chatRouteOptions<OUTPUT = undefined> = {
|
|
|
105
105
|
/** Target interval for periodic SSE comment heartbeats. Values up to 0 disable heartbeats. `NaN`, positive infinity, and values above 2,147,483,647 throw a `RangeError`. */
|
|
106
106
|
heartbeatMs?: number;
|
|
107
107
|
onError?: (error: unknown) => string;
|
|
108
|
+
/** Metadata attached to start and finish message parts in the AI SDK stream. */
|
|
109
|
+
messageMetadata?: ChatStreamHandlerOptions<UI_MESSAGE, OUTPUT>['messageMetadata'];
|
|
108
110
|
};
|
|
109
111
|
/**
|
|
110
112
|
* Creates a chat route handler for streaming agent conversations using the AI SDK format.
|
|
@@ -121,6 +123,7 @@ export type chatRouteOptions<OUTPUT = undefined> = {
|
|
|
121
123
|
* @param {boolean} [options.sendSources=false] - Whether to include source citations in the stream
|
|
122
124
|
* @param {number} [options.heartbeatMs] - Target interval for periodic SSE comment heartbeats. Already-buffered source events and stream lifecycle signals take priority. Values up to 0 disable heartbeats. `NaN`, positive infinity, and values above 2,147,483,647 throw a `RangeError`.
|
|
123
125
|
* @param {(error: unknown) => string} [options.onError] - Custom error serializer streamed to the client. When omitted, errors are passed through a default serializer that strips sensitive fields (e.g. `APICallError.requestBodyValues`, which holds the system prompt) before they reach the client.
|
|
126
|
+
* @param {Function} [options.messageMetadata] - Maps stream parts to metadata attached to AI SDK start and finish message parts.
|
|
124
127
|
*
|
|
125
128
|
* @returns {ReturnType<typeof registerApiRoute>} A registered API route handler
|
|
126
129
|
*
|
|
@@ -152,6 +155,6 @@ export type chatRouteOptions<OUTPUT = undefined> = {
|
|
|
152
155
|
* - If both `agent` and `:agentId` are present, a warning is logged and the fixed `agent` takes precedence
|
|
153
156
|
* - Request context from the incoming request overrides `defaultOptions.requestContext` if both are present
|
|
154
157
|
*/
|
|
155
|
-
export declare function chatRoute<OUTPUT = undefined>({ path, agent, defaultOptions, experimentalTransform, version, agentVersion, sendStart, sendFinish, sendReasoning, sendSources, heartbeatMs, onError, }: chatRouteOptions<OUTPUT>): ReturnType<typeof registerApiRoute>;
|
|
158
|
+
export declare function chatRoute<OUTPUT = undefined, UI_MESSAGE extends SupportedUIMessage = SupportedUIMessage>({ path, agent, defaultOptions, experimentalTransform, version, agentVersion, sendStart, sendFinish, sendReasoning, sendSources, heartbeatMs, onError, messageMetadata, }: chatRouteOptions<OUTPUT, UI_MESSAGE>): ReturnType<typeof registerApiRoute>;
|
|
156
159
|
export {};
|
|
157
160
|
//# sourceMappingURL=chat-route.d.ts.map
|
package/dist/chat-route.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-route.d.ts","sourceRoot":"","sources":["../src/chat-route.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,IAAI,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAM9F,OAAO,KAAK,EAAE,sBAAsB,IAAI,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAK1F,OAAO,KAAK,EAAE,sBAAsB,IAAI,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,KAAK,EAAE,qBAAqB,EAA6B,MAAM,oBAAoB,CAAC;AAC3F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,KAAK,EACV,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAGpE,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,E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ACA;IACE,IAAI,EAAE,GAAG,MAAM,WAAW,MAAM,EAAE,CAAC;IACnC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CACJ,GAAG;IACA,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,6KAA6K;IAC7K,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;IACrC,gFAAgF;IAChF,eAAe,CAAC,EAAE,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;CACnF,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,SAAS,CAAC,MAAM,GAAG,SAAS,EAAE,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,EAAE,EACxG,IAAuB,EACvB,KAAK,EACL,cAAc,EACd,qBAAqB,EACrB,OAAc,EACd,YAAY,EACZ,SAAgB,EAChB,UAAiB,EACjB,aAAqB,EACrB,WAAmB,EACnB,WAAW,EACX,OAAO,EACP,eAAe,GAChB,EAAE,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAkO5E"}
|
package/dist/index.cjs
CHANGED
|
@@ -13985,6 +13985,7 @@ async function handleChatStream({ mastra, agentId, agentVersion, params, default
|
|
|
13985
13985
|
* @param {boolean} [options.sendSources=false] - Whether to include source citations in the stream
|
|
13986
13986
|
* @param {number} [options.heartbeatMs] - Target interval for periodic SSE comment heartbeats. Already-buffered source events and stream lifecycle signals take priority. Values up to 0 disable heartbeats. `NaN`, positive infinity, and values above 2,147,483,647 throw a `RangeError`.
|
|
13987
13987
|
* @param {(error: unknown) => string} [options.onError] - Custom error serializer streamed to the client. When omitted, errors are passed through a default serializer that strips sensitive fields (e.g. `APICallError.requestBodyValues`, which holds the system prompt) before they reach the client.
|
|
13988
|
+
* @param {Function} [options.messageMetadata] - Maps stream parts to metadata attached to AI SDK start and finish message parts.
|
|
13988
13989
|
*
|
|
13989
13990
|
* @returns {ReturnType<typeof registerApiRoute>} A registered API route handler
|
|
13990
13991
|
*
|
|
@@ -14016,7 +14017,7 @@ async function handleChatStream({ mastra, agentId, agentVersion, params, default
|
|
|
14016
14017
|
* - If both `agent` and `:agentId` are present, a warning is logged and the fixed `agent` takes precedence
|
|
14017
14018
|
* - Request context from the incoming request overrides `defaultOptions.requestContext` if both are present
|
|
14018
14019
|
*/
|
|
14019
|
-
function chatRoute({ path = "/chat/:agentId", agent, defaultOptions, experimentalTransform, version = "v5", agentVersion, sendStart = true, sendFinish = true, sendReasoning = false, sendSources = false, heartbeatMs, onError }) {
|
|
14020
|
+
function chatRoute({ path = "/chat/:agentId", agent, defaultOptions, experimentalTransform, version = "v5", agentVersion, sendStart = true, sendFinish = true, sendReasoning = false, sendSources = false, heartbeatMs, onError, messageMetadata }) {
|
|
14020
14021
|
if (!agent && !path.includes("/:agentId")) throw new Error("Path must include :agentId to route to the correct agent or pass the agent explicitly");
|
|
14021
14022
|
assertValidHeartbeatMs(heartbeatMs);
|
|
14022
14023
|
return (0, _mastra_core_server.registerApiRoute)(path, {
|
|
@@ -14150,13 +14151,18 @@ function chatRoute({ path = "/chat/:agentId", agent, defaultOptions, experimenta
|
|
|
14150
14151
|
let response;
|
|
14151
14152
|
if (version === "v7") response = createUIMessageStreamResponse({ stream: await handleChatStream({
|
|
14152
14153
|
...handlerOptions,
|
|
14153
|
-
version: "v7"
|
|
14154
|
+
version: "v7",
|
|
14155
|
+
messageMetadata
|
|
14154
14156
|
}) });
|
|
14155
14157
|
else if (version === "v6") response = createUIMessageStreamResponse$1({ stream: await handleChatStream({
|
|
14156
14158
|
...handlerOptions,
|
|
14157
|
-
version: "v6"
|
|
14159
|
+
version: "v6",
|
|
14160
|
+
messageMetadata
|
|
14161
|
+
}) });
|
|
14162
|
+
else response = createUIMessageStreamResponse$2({ stream: await handleChatStream({
|
|
14163
|
+
...handlerOptions,
|
|
14164
|
+
messageMetadata
|
|
14158
14165
|
}) });
|
|
14159
|
-
else response = createUIMessageStreamResponse$2({ stream: await handleChatStream(handlerOptions) });
|
|
14160
14166
|
return withSseHeartbeat(response, heartbeatMs);
|
|
14161
14167
|
}
|
|
14162
14168
|
});
|