@mastra/ai-sdk 1.10.7 → 1.11.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/dist/chat-route.d.ts +16 -7
- package/dist/chat-route.d.ts.map +1 -1
- package/dist/convert-streams.d.ts +4 -4
- package/dist/convert-streams.d.ts.map +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/public-types.d.ts +8 -0
- package/dist/public-types.d.ts.map +1 -1
- package/dist/transformers.d.ts +4 -2
- package/dist/transformers.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -14258,7 +14258,10 @@ function createAgentStreamToAISDKTransformer(convertMastraChunkToAISDK, { lastMe
|
|
|
14258
14258
|
part: p,
|
|
14259
14259
|
sendReasoning,
|
|
14260
14260
|
sendSources,
|
|
14261
|
-
messageMetadataValue: p ? messageMetadata?.({
|
|
14261
|
+
messageMetadataValue: p ? messageMetadata?.({
|
|
14262
|
+
part: p,
|
|
14263
|
+
traceId: chunk.traceId
|
|
14264
|
+
}) : void 0,
|
|
14262
14265
|
sendStart,
|
|
14263
14266
|
sendFinish,
|
|
14264
14267
|
responseMessageId: lastMessageId,
|
|
@@ -15423,7 +15426,7 @@ function extractV6NativeApprovals(messages) {
|
|
|
15423
15426
|
/** Streams exact approval targets sequentially as one v6/v7 UI-message response. */
|
|
15424
15427
|
function streamV6ApprovalResumes(args) {
|
|
15425
15428
|
const { agent, approvals, baseOptions, structuredOutput, messages, lastMessageId } = args;
|
|
15426
|
-
const { sendStart, sendFinish, sendReasoning, sendSources, onError, messageMetadata, experimentalTransform } = args;
|
|
15429
|
+
const { sendStart, sendFinish, sendReasoning, sendSources, includeSubAgentMetadata, onError, messageMetadata, experimentalTransform } = args;
|
|
15427
15430
|
return (args.version === "v7" ? createUIMessageStream : createUIMessageStream$1)({
|
|
15428
15431
|
originalMessages: messages,
|
|
15429
15432
|
onError,
|
|
@@ -15447,6 +15450,7 @@ function streamV6ApprovalResumes(args) {
|
|
|
15447
15450
|
sendFinish,
|
|
15448
15451
|
sendReasoning,
|
|
15449
15452
|
sendSources,
|
|
15453
|
+
includeSubAgentMetadata,
|
|
15450
15454
|
experimentalTransform,
|
|
15451
15455
|
onError,
|
|
15452
15456
|
messageMetadata
|
|
@@ -15493,7 +15497,7 @@ const CREDENTIAL_HEADER_NAMES = /* @__PURE__ */ new Set([
|
|
|
15493
15497
|
"x-goog-api-key",
|
|
15494
15498
|
"cookie"
|
|
15495
15499
|
]);
|
|
15496
|
-
async function handleChatStream({ mastra, agentId, agentVersion, params, defaultOptions, experimentalTransform, version = "v5", sendStart = true, sendFinish = true, sendReasoning = false, sendSources = false, onError, messageMetadata }) {
|
|
15500
|
+
async function handleChatStream({ mastra, agentId, agentVersion, params, defaultOptions, experimentalTransform, version = "v5", sendStart = true, sendFinish = true, sendReasoning = false, sendSources = false, includeSubAgentMetadata = true, onError, messageMetadata }) {
|
|
15497
15501
|
const { messages, resumeData, runId, requestContext, trigger, ...rest } = params;
|
|
15498
15502
|
if (resumeData && !runId) throw new Error("runId is required when resumeData is provided");
|
|
15499
15503
|
const baseAgent = mastra.getAgentById(agentId);
|
|
@@ -15545,6 +15549,7 @@ async function handleChatStream({ mastra, agentId, agentVersion, params, default
|
|
|
15545
15549
|
sendFinish,
|
|
15546
15550
|
sendReasoning,
|
|
15547
15551
|
sendSources,
|
|
15552
|
+
includeSubAgentMetadata,
|
|
15548
15553
|
onError,
|
|
15549
15554
|
experimentalTransform: effectiveExperimentalTransform,
|
|
15550
15555
|
messageMetadata
|
|
@@ -15568,6 +15573,7 @@ async function handleChatStream({ mastra, agentId, agentVersion, params, default
|
|
|
15568
15573
|
sendFinish,
|
|
15569
15574
|
sendReasoning,
|
|
15570
15575
|
sendSources,
|
|
15576
|
+
includeSubAgentMetadata,
|
|
15571
15577
|
experimentalTransform: effectiveExperimentalTransform,
|
|
15572
15578
|
onError,
|
|
15573
15579
|
messageMetadata
|
|
@@ -15584,6 +15590,7 @@ async function handleChatStream({ mastra, agentId, agentVersion, params, default
|
|
|
15584
15590
|
sendFinish,
|
|
15585
15591
|
sendReasoning,
|
|
15586
15592
|
sendSources,
|
|
15593
|
+
includeSubAgentMetadata,
|
|
15587
15594
|
experimentalTransform: effectiveExperimentalTransform,
|
|
15588
15595
|
onError,
|
|
15589
15596
|
messageMetadata
|
|
@@ -15604,9 +15611,10 @@ async function handleChatStream({ mastra, agentId, agentVersion, params, default
|
|
|
15604
15611
|
* @param {boolean} [options.sendFinish=true] - Whether to send finish events in the stream
|
|
15605
15612
|
* @param {boolean} [options.sendReasoning=false] - Whether to include reasoning steps in the stream
|
|
15606
15613
|
* @param {boolean} [options.sendSources=false] - Whether to include source citations in the stream
|
|
15614
|
+
* @param {boolean} [options.includeSubAgentMetadata=true] - Whether to emit `data-tool-agent` / `data-tool-agent-step` parts with sub-agent progress
|
|
15607
15615
|
* @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`.
|
|
15608
15616
|
* @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.
|
|
15609
|
-
* @param {Function} [options.messageMetadata] - Maps stream parts to metadata attached to AI SDK start and finish message parts.
|
|
15617
|
+
* @param {Function} [options.messageMetadata] - Maps stream parts to metadata attached to AI SDK start and finish message parts. Receives `{ part, traceId }`.
|
|
15610
15618
|
*
|
|
15611
15619
|
* @returns {ReturnType<typeof registerApiRoute>} A registered API route handler
|
|
15612
15620
|
*
|
|
@@ -15638,7 +15646,7 @@ async function handleChatStream({ mastra, agentId, agentVersion, params, default
|
|
|
15638
15646
|
* - If both `agent` and `:agentId` are present, a warning is logged and the fixed `agent` takes precedence
|
|
15639
15647
|
* - Request context from the incoming request overrides `defaultOptions.requestContext` if both are present
|
|
15640
15648
|
*/
|
|
15641
|
-
function chatRoute({ path = "/chat/:agentId", agent, defaultOptions, experimentalTransform, version = "v5", agentVersion, sendStart = true, sendFinish = true, sendReasoning = false, sendSources = false, heartbeatMs, onError, messageMetadata }) {
|
|
15649
|
+
function chatRoute({ path = "/chat/:agentId", agent, defaultOptions, experimentalTransform, version = "v5", agentVersion, sendStart = true, sendFinish = true, sendReasoning = false, sendSources = false, includeSubAgentMetadata = true, heartbeatMs, onError, messageMetadata }) {
|
|
15642
15650
|
if (!agent && !path.includes("/:agentId")) throw new Error("Path must include :agentId to route to the correct agent or pass the agent explicitly");
|
|
15643
15651
|
assertValidHeartbeatMs(heartbeatMs);
|
|
15644
15652
|
return registerApiRoute(path, {
|
|
@@ -15767,6 +15775,7 @@ function chatRoute({ path = "/chat/:agentId", agent, defaultOptions, experimenta
|
|
|
15767
15775
|
sendFinish,
|
|
15768
15776
|
sendReasoning,
|
|
15769
15777
|
sendSources,
|
|
15778
|
+
includeSubAgentMetadata,
|
|
15770
15779
|
onError
|
|
15771
15780
|
};
|
|
15772
15781
|
let response;
|