@mastra/ai-sdk 1.10.3-alpha.1 → 1.10.4-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/_types/@ai-sdk_provider/package.json +1 -0
- package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +1 -1
- package/dist/_types/@internal_ai-sdk-v5/package.json +1 -0
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +1 -1
- package/dist/_types/@internal_ai-v6/package.json +1 -0
- package/dist/_types/@internal_ai-v7/dist/index.d.ts +1 -1
- package/dist/_types/@internal_ai-v7/package.json +1 -0
- package/dist/_types/@types_json-schema/package.json +1 -0
- package/dist/chat-route.d.ts +3 -3
- package/dist/convert-streams.d.ts +5 -3
- package/dist/convert-streams.d.ts.map +1 -1
- package/dist/helpers.d.ts +15 -7
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.cjs +85 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +85 -29
- package/dist/index.js.map +1 -1
- package/dist/middleware.d.ts +2 -2
- package/dist/public-types.d.ts +3 -3
- package/dist/transformers.d.ts +43 -28
- package/dist/transformers.d.ts.map +1 -1
- package/package.json +16 -16
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSONSchema7 } from '../../@types_json-schema/index.
|
|
1
|
+
import { JSONSchema7 } from '../../@types_json-schema/index.js';
|
|
2
2
|
import { ServerResponse } from 'node:http';
|
|
3
3
|
import { ServerResponse as ServerResponse_2 } from 'http';
|
|
4
4
|
import { WORKFLOW_DESERIALIZE } from '@workflow/serde';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/dist/chat-route.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { UIMessageStreamOptions as UIMessageStreamOptionsV5 } from './_types/@internal_ai-sdk-v5/dist/index.
|
|
2
|
-
import type { UIMessageStreamOptions as UIMessageStreamOptionsV6 } from './_types/@internal_ai-v6/dist/index.
|
|
3
|
-
import type { UIMessageStreamOptions as UIMessageStreamOptionsV7 } from './_types/@internal_ai-v7/dist/index.
|
|
1
|
+
import type { UIMessageStreamOptions as UIMessageStreamOptionsV5 } from './_types/@internal_ai-sdk-v5/dist/index.js';
|
|
2
|
+
import type { UIMessageStreamOptions as UIMessageStreamOptionsV6 } from './_types/@internal_ai-v6/dist/index.js';
|
|
3
|
+
import type { UIMessageStreamOptions as UIMessageStreamOptionsV7 } from './_types/@internal_ai-v7/dist/index.js';
|
|
4
4
|
import type { AgentExecutionOptions } from '@mastra/core/agent';
|
|
5
5
|
import type { Mastra } from '@mastra/core/mastra';
|
|
6
6
|
import { registerApiRoute } from '@mastra/core/server';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { InferUIMessageChunk as InferUIMessageChunkV5, UIMessage as UIMessageV5, UIMessageStreamOptions as UIMessageStreamOptionsV5 } from './_types/@internal_ai-sdk-v5/dist/index.
|
|
2
|
-
import type { UIMessage as UIMessageV6, UIMessageStreamOptions as UIMessageStreamOptionsV6 } from './_types/@internal_ai-v6/dist/index.
|
|
3
|
-
import type { UIMessage as UIMessageV7, UIMessageStreamOptions as UIMessageStreamOptionsV7 } from './_types/@internal_ai-v7/dist/index.
|
|
1
|
+
import type { InferUIMessageChunk as InferUIMessageChunkV5, UIMessage as UIMessageV5, UIMessageStreamOptions as UIMessageStreamOptionsV5 } from './_types/@internal_ai-sdk-v5/dist/index.js';
|
|
2
|
+
import type { UIMessage as UIMessageV6, UIMessageStreamOptions as UIMessageStreamOptionsV6 } from './_types/@internal_ai-v6/dist/index.js';
|
|
3
|
+
import type { UIMessage as UIMessageV7, UIMessageStreamOptions as UIMessageStreamOptionsV7 } from './_types/@internal_ai-v7/dist/index.js';
|
|
4
4
|
import type { MastraModelOutput, MastraAgentNetworkStream, WorkflowRunOutput } from '@mastra/core/stream';
|
|
5
5
|
import type { MastraWorkflowStream, Step, WorkflowResult } from '@mastra/core/workflows';
|
|
6
6
|
import type { ZodObject, ZodType } from 'zod/v4';
|
|
@@ -40,6 +40,8 @@ type AgentStreamOptionsBase = {
|
|
|
40
40
|
sendFinish?: boolean;
|
|
41
41
|
sendReasoning?: boolean;
|
|
42
42
|
sendSources?: boolean;
|
|
43
|
+
/** When true, sub-agent runs are emitted as data-tool-agent parts with ancestry metadata. */
|
|
44
|
+
includeSubAgentMetadata?: boolean;
|
|
43
45
|
/** Experimental transforms applied to Mastra chunks before AI SDK UI conversion. */
|
|
44
46
|
experimentalTransform?: MastraStreamTransformOptions<any>;
|
|
45
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-streams.d.ts","sourceRoot":"","sources":["../src/convert-streams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,IAAI,qBAAqB,EAC5C,SAAS,IAAI,WAAW,EACxB,sBAAsB,IAAI,wBAAwB,EACnD,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAEV,SAAS,IAAI,WAAW,EACxB,sBAAsB,IAAI,wBAAwB,EACnD,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,IAAI,WAAW,EAAE,sBAAsB,IAAI,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACpH,OAAO,KAAK,EAAE,iBAAiB,EAAa,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrH,OAAO,KAAK,EAAE,oBAAoB,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,OA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AAE,EACtD,MAAM,SAAS,SAAS,CAAC,GAAG,CAAC,EAE7B,MAAM,EAAE,iBAAiB,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,EAC1E,OAAO,EAAE,uBAAuB,GAC/B,iBAAiB,CAAC;AACrB,wBAAgB,aAAa,CAAC,MAAM,GAAG,SAAS,EAC9C,MAAM,EAAE,wBAAwB,CAAC,MAAM,CAAC,EACxC,OAAO,EAAE,sBAAsB,GAC9B,iBAAiB,CAAC;AACrB,wBAAgB,aAAa,CAAC,OAAO,EACnC,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAClC,OAAO,EAAE,oBAAoB,GAC5B,iBAAiB,CAAC"}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { InferUIMessageChunk, ObjectStreamPart, TextStreamPart, ToolSet, UIMessage, FinishReason } from './_types/@internal_ai-sdk-v5/dist/index.
|
|
2
|
-
import type { FinishReason as FinishReasonV6, InferUIMessageChunk as InferUIMessageChunkV6, ToolApprovalRequest, UIMessage as UIMessageV6 } from './_types/@internal_ai-v6/dist/index.
|
|
1
|
+
import type { InferUIMessageChunk, ObjectStreamPart, TextStreamPart, ToolSet, UIMessage, FinishReason } from './_types/@internal_ai-sdk-v5/dist/index.js';
|
|
2
|
+
import type { FinishReason as FinishReasonV6, InferUIMessageChunk as InferUIMessageChunkV6, ToolApprovalRequest, UIMessage as UIMessageV6 } from './_types/@internal_ai-v6/dist/index.js';
|
|
3
3
|
import type { DataChunkType, ChunkType, MastraFinishReason } from '@mastra/core/stream';
|
|
4
4
|
/**
|
|
5
5
|
* Separator used to encode both runId and toolCallId into a single approvalId string.
|
|
@@ -22,10 +22,16 @@ type AISDKToolOutputDenied = {
|
|
|
22
22
|
providerExecuted?: boolean;
|
|
23
23
|
dynamic?: boolean;
|
|
24
24
|
};
|
|
25
|
+
export type ToolOutputAncestryEntry = {
|
|
26
|
+
toolCallId: string;
|
|
27
|
+
toolName?: string;
|
|
28
|
+
agentId?: string;
|
|
29
|
+
};
|
|
25
30
|
export type ToolAgentChunkType = {
|
|
26
31
|
type: 'tool-agent';
|
|
27
32
|
toolCallId: string;
|
|
28
33
|
payload: any;
|
|
34
|
+
ancestry: ToolOutputAncestryEntry[];
|
|
29
35
|
};
|
|
30
36
|
export type ToolWorkflowChunkType = {
|
|
31
37
|
type: 'tool-workflow';
|
|
@@ -55,12 +61,14 @@ export declare function convertMastraChunkToAISDKv6<OUTPUT = undefined>({ chunk,
|
|
|
55
61
|
chunk: ChunkType<OUTPUT>;
|
|
56
62
|
mode?: 'generate' | 'stream';
|
|
57
63
|
}): OutputChunkType<OUTPUT> | AISDKToolOutputDenied | OutputChunkType<OUTPUT>[];
|
|
64
|
+
type ConvertedToolOutput = {
|
|
65
|
+
type: 'tool-output';
|
|
66
|
+
toolCallId: string;
|
|
67
|
+
toolName?: string;
|
|
68
|
+
output: any;
|
|
69
|
+
};
|
|
58
70
|
export declare function convertFullStreamChunkToUIMessageStream<UI_MESSAGE extends UIMessage>({ part, messageMetadataValue, sendReasoning, sendSources, onError, sendStart, sendFinish, responseMessageId, }: {
|
|
59
|
-
part: TextStreamPart<ToolSet> | AISDKToolOutputDenied | DataChunkType | ToolApprovalRequest |
|
|
60
|
-
type: 'tool-output';
|
|
61
|
-
toolCallId: string;
|
|
62
|
-
output: any;
|
|
63
|
-
};
|
|
71
|
+
part: TextStreamPart<ToolSet> | AISDKToolOutputDenied | DataChunkType | ToolApprovalRequest | ConvertedToolOutput;
|
|
64
72
|
messageMetadataValue?: unknown;
|
|
65
73
|
sendReasoning?: boolean;
|
|
66
74
|
sendSources?: boolean;
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAEnB,gBAAgB,E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AClB,MAAM,EAAE,GAAG,CAAC;CACb,CAAC;AAuDF,wBAAgB,uCAAuC,CAAC,UAAU,SAAS,SAAS,EAAE,EACpF,IAAI,EACJ,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,OAAO,EACP,SAAS,EACT,UAAU,EACV,iBAAiB,GAClB,EAAE;IAED,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,qBAAqB,GAAG,aAAa,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;IAClH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;IACpC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GACG,mBAAmB,CAAC,UAAU,CAAC,GAC/B,qBAAqB,CAAC,WAAW,CAAC,GAClC,kBAAkB,GAClB,qBAAqB,GACrB,oBAAoB,GACpB,SAAS,CA0SZ"}
|
package/dist/index.cjs
CHANGED
|
@@ -32,7 +32,7 @@ let _mastra_core_request_context = require("@mastra/core/request-context");
|
|
|
32
32
|
let _mastra_core_agent = require("@mastra/core/agent");
|
|
33
33
|
let _mastra_core_di = require("@mastra/core/di");
|
|
34
34
|
let _mastra_core_processors = require("@mastra/core/processors");
|
|
35
|
-
//#region ../../packages/_vendored/ai_v5/dist/dist-
|
|
35
|
+
//#region ../../packages/_vendored/ai_v5/dist/dist-CQthBS6n.js
|
|
36
36
|
var marker$1$6 = "vercel.ai.error";
|
|
37
37
|
var symbol$1$7 = Symbol.for(marker$1$6);
|
|
38
38
|
var _a$1$7;
|
|
@@ -5050,7 +5050,7 @@ function createUIMessageStream$2({ execute, onError = () => "An error occurred."
|
|
|
5050
5050
|
});
|
|
5051
5051
|
}
|
|
5052
5052
|
//#endregion
|
|
5053
|
-
//#region ../../packages/_vendored/ai_v6/dist/dist-
|
|
5053
|
+
//#region ../../packages/_vendored/ai_v6/dist/dist-BJ8L5vTo.js
|
|
5054
5054
|
var marker$1$4 = "vercel.ai.error";
|
|
5055
5055
|
var symbol$1$4 = Symbol.for(marker$1$4);
|
|
5056
5056
|
var _a$1$4;
|
|
@@ -8829,7 +8829,7 @@ var doWrap = ({ model, middleware: { transformParams, wrapGenerate, wrapStream,
|
|
|
8829
8829
|
};
|
|
8830
8830
|
};
|
|
8831
8831
|
//#endregion
|
|
8832
|
-
//#region ../../packages/_vendored/ai_v7/dist/dist-
|
|
8832
|
+
//#region ../../packages/_vendored/ai_v7/dist/dist-BWqbqY3Z.js
|
|
8833
8833
|
var marker$1 = "vercel.ai.error";
|
|
8834
8834
|
var symbol$1 = Symbol.for(marker$1);
|
|
8835
8835
|
var _a$1;
|
|
@@ -12365,6 +12365,39 @@ function convertMastraChunkToAISDKv6({ chunk, mode = "stream" }) {
|
|
|
12365
12365
|
includeRawFinishReason: true
|
|
12366
12366
|
});
|
|
12367
12367
|
}
|
|
12368
|
+
function createToolOutputAncestryEntry(toolCallId, toolName) {
|
|
12369
|
+
const agentId = toolName?.startsWith("agent-") ? toolName.slice(6) : void 0;
|
|
12370
|
+
return {
|
|
12371
|
+
toolCallId,
|
|
12372
|
+
...toolName ? { toolName } : {},
|
|
12373
|
+
...agentId ? { agentId } : {}
|
|
12374
|
+
};
|
|
12375
|
+
}
|
|
12376
|
+
/**
|
|
12377
|
+
* Each agent-as-tool delegation wraps progressive chunks in another `tool-output`
|
|
12378
|
+
* envelope. Preserve every boundary for routing while returning only the originating
|
|
12379
|
+
* leaf chunk to downstream transformers.
|
|
12380
|
+
*/
|
|
12381
|
+
function normalizeNestedToolOutput(part) {
|
|
12382
|
+
const ancestry = [createToolOutputAncestryEntry(part.toolCallId, part.toolName)];
|
|
12383
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12384
|
+
let current = part.output;
|
|
12385
|
+
while (current !== null && typeof current === "object") {
|
|
12386
|
+
if (seen.has(current)) return;
|
|
12387
|
+
seen.add(current);
|
|
12388
|
+
if (current.type !== "tool-output") return {
|
|
12389
|
+
output: current,
|
|
12390
|
+
ancestry
|
|
12391
|
+
};
|
|
12392
|
+
const toolCallId = current.payload?.toolCallId ?? current.toolCallId;
|
|
12393
|
+
if (typeof toolCallId !== "string") return;
|
|
12394
|
+
const toolName = current.payload?.toolName ?? current.toolName;
|
|
12395
|
+
ancestry.push(createToolOutputAncestryEntry(toolCallId, typeof toolName === "string" ? toolName : void 0));
|
|
12396
|
+
const nested = current.payload?.output ?? current.output;
|
|
12397
|
+
if (nested === void 0) return;
|
|
12398
|
+
current = nested;
|
|
12399
|
+
}
|
|
12400
|
+
}
|
|
12368
12401
|
function convertFullStreamChunkToUIMessageStream({ part, messageMetadataValue, sendReasoning, sendSources, onError, sendStart, sendFinish, responseMessageId }) {
|
|
12369
12402
|
const partType = part?.type;
|
|
12370
12403
|
if (!sendReasoning && (partType === "text-start" || partType === "text-delta" || partType === "text-end") && part.providerMetadata?.openai?.itemId != null) {
|
|
@@ -12480,25 +12513,29 @@ function convertFullStreamChunkToUIMessageStream({ part, messageMetadataValue, s
|
|
|
12480
12513
|
type: "tool-output-denied",
|
|
12481
12514
|
toolCallId: part.toolCallId
|
|
12482
12515
|
};
|
|
12483
|
-
case "tool-output":
|
|
12484
|
-
|
|
12516
|
+
case "tool-output": {
|
|
12517
|
+
const normalized = normalizeNestedToolOutput(part);
|
|
12518
|
+
if (!normalized) return;
|
|
12519
|
+
const { output, ancestry } = normalized;
|
|
12520
|
+
if (output.from === "AGENT") return {
|
|
12485
12521
|
type: "tool-agent",
|
|
12486
12522
|
toolCallId: part.toolCallId,
|
|
12487
|
-
payload:
|
|
12523
|
+
payload: output,
|
|
12524
|
+
ancestry
|
|
12488
12525
|
};
|
|
12489
|
-
else if (
|
|
12526
|
+
else if (output.from === "WORKFLOW") return {
|
|
12490
12527
|
type: "tool-workflow",
|
|
12491
12528
|
toolCallId: part.toolCallId,
|
|
12492
|
-
payload:
|
|
12529
|
+
payload: output
|
|
12493
12530
|
};
|
|
12494
|
-
else if (
|
|
12531
|
+
else if (output.from === "NETWORK") return {
|
|
12495
12532
|
type: "tool-network",
|
|
12496
12533
|
toolCallId: part.toolCallId,
|
|
12497
|
-
payload:
|
|
12534
|
+
payload: output
|
|
12498
12535
|
};
|
|
12499
|
-
else if (isDataChunkType(
|
|
12500
|
-
if (!("data" in
|
|
12501
|
-
const { type, data, id } =
|
|
12536
|
+
else if (isDataChunkType(output)) {
|
|
12537
|
+
if (!("data" in output)) throw new Error(`UI Messages require a data property when using data- prefixed chunks \n ${JSON.stringify(part)}`);
|
|
12538
|
+
const { type, data, id } = output;
|
|
12502
12539
|
return {
|
|
12503
12540
|
type,
|
|
12504
12541
|
data,
|
|
@@ -12506,6 +12543,7 @@ function convertFullStreamChunkToUIMessageStream({ part, messageMetadataValue, s
|
|
|
12506
12543
|
};
|
|
12507
12544
|
}
|
|
12508
12545
|
return;
|
|
12546
|
+
}
|
|
12509
12547
|
case "tool-error": return {
|
|
12510
12548
|
type: "tool-output-error",
|
|
12511
12549
|
toolCallId: part.toolCallId,
|
|
@@ -12660,7 +12698,7 @@ function AgentNetworkToAISDKTransformer() {
|
|
|
12660
12698
|
function AgentNetworkToAISDKV6Transformer() {
|
|
12661
12699
|
return createAgentNetworkToAISDKTransformer();
|
|
12662
12700
|
}
|
|
12663
|
-
function createAgentStreamToAISDKTransformer(convertMastraChunkToAISDK, { lastMessageId, sendStart = true, sendFinish = true, sendReasoning, sendSources, messageMetadata, onError }) {
|
|
12701
|
+
function createAgentStreamToAISDKTransformer(convertMastraChunkToAISDK, { lastMessageId, sendStart = true, sendFinish = true, sendReasoning, sendSources, messageMetadata, onError, includeSubAgentMetadata = false }) {
|
|
12664
12702
|
let bufferedSteps = /* @__PURE__ */ new Map();
|
|
12665
12703
|
let tripwireOccurred = false;
|
|
12666
12704
|
let finishEventSent = false;
|
|
@@ -12691,8 +12729,9 @@ function createAgentStreamToAISDKTransformer(convertMastraChunkToAISDK, { lastMe
|
|
|
12691
12729
|
}
|
|
12692
12730
|
});
|
|
12693
12731
|
if (transformedChunk) if (transformedChunk.type === "tool-agent") {
|
|
12694
|
-
|
|
12695
|
-
const
|
|
12732
|
+
if (!includeSubAgentMetadata) return;
|
|
12733
|
+
const { payload, ancestry } = transformedChunk;
|
|
12734
|
+
const agentTransformed = transformAgent(payload, bufferedSteps, ancestry);
|
|
12696
12735
|
if (agentTransformed) if (Array.isArray(agentTransformed)) for (const part of agentTransformed) controller.enqueue(part);
|
|
12697
12736
|
else controller.enqueue(agentTransformed);
|
|
12698
12737
|
} else if (transformedChunk.type === "tool-workflow") {
|
|
@@ -12754,7 +12793,7 @@ function createAgentStreamToAISDKTransformer(convertMastraChunkToAISDK, { lastMe
|
|
|
12754
12793
|
}
|
|
12755
12794
|
});
|
|
12756
12795
|
}
|
|
12757
|
-
function AgentStreamToAISDKTransformer({ lastMessageId, sendStart = true, sendFinish = true, sendReasoning, sendSources, messageMetadata, onError }) {
|
|
12796
|
+
function AgentStreamToAISDKTransformer({ lastMessageId, sendStart = true, sendFinish = true, sendReasoning, sendSources, messageMetadata, onError, includeSubAgentMetadata = false }) {
|
|
12758
12797
|
return createAgentStreamToAISDKTransformer(convertMastraChunkToAISDKv5, {
|
|
12759
12798
|
lastMessageId,
|
|
12760
12799
|
sendStart,
|
|
@@ -12762,10 +12801,11 @@ function AgentStreamToAISDKTransformer({ lastMessageId, sendStart = true, sendFi
|
|
|
12762
12801
|
sendReasoning,
|
|
12763
12802
|
sendSources,
|
|
12764
12803
|
messageMetadata,
|
|
12765
|
-
onError
|
|
12804
|
+
onError,
|
|
12805
|
+
includeSubAgentMetadata
|
|
12766
12806
|
});
|
|
12767
12807
|
}
|
|
12768
|
-
function AgentStreamToAISDKV6Transformer({ lastMessageId, sendStart = true, sendFinish = true, sendReasoning, sendSources, messageMetadata, onError }) {
|
|
12808
|
+
function AgentStreamToAISDKV6Transformer({ lastMessageId, sendStart = true, sendFinish = true, sendReasoning, sendSources, messageMetadata, onError, includeSubAgentMetadata = false }) {
|
|
12769
12809
|
return createAgentStreamToAISDKTransformer(convertMastraChunkToAISDKv6, {
|
|
12770
12810
|
lastMessageId,
|
|
12771
12811
|
sendStart,
|
|
@@ -12773,7 +12813,8 @@ function AgentStreamToAISDKV6Transformer({ lastMessageId, sendStart = true, send
|
|
|
12773
12813
|
sendReasoning,
|
|
12774
12814
|
sendSources,
|
|
12775
12815
|
messageMetadata,
|
|
12776
|
-
onError
|
|
12816
|
+
onError,
|
|
12817
|
+
includeSubAgentMetadata
|
|
12777
12818
|
});
|
|
12778
12819
|
}
|
|
12779
12820
|
function ensureAgentRunState(bufferedSteps, runId) {
|
|
@@ -12885,19 +12926,28 @@ function serializeAgentRun(current, { includeCompletedStepDetails, includeRespon
|
|
|
12885
12926
|
steps: data.steps.map((step) => cloneAgentStep(step, { includeDetails: includeCompletedStepDetails }))
|
|
12886
12927
|
};
|
|
12887
12928
|
}
|
|
12929
|
+
function createAgentStreamAncestryMetadata(ancestry) {
|
|
12930
|
+
const parentAgentId = ancestry.at(-2)?.agentId;
|
|
12931
|
+
return {
|
|
12932
|
+
ancestry,
|
|
12933
|
+
depth: ancestry.length,
|
|
12934
|
+
...parentAgentId ? { parentAgentId } : {}
|
|
12935
|
+
};
|
|
12936
|
+
}
|
|
12888
12937
|
function createAgentDataPart(args) {
|
|
12889
|
-
const { current, runId, includeCompletedStepDetails, includeResponseMessages } = args;
|
|
12938
|
+
const { current, runId, ancestry, includeCompletedStepDetails, includeResponseMessages } = args;
|
|
12890
12939
|
return {
|
|
12891
12940
|
type: "data-tool-agent",
|
|
12892
12941
|
id: runId,
|
|
12893
12942
|
data: serializeAgentRun(current, {
|
|
12894
12943
|
includeCompletedStepDetails,
|
|
12895
12944
|
includeResponseMessages
|
|
12896
|
-
})
|
|
12945
|
+
}),
|
|
12946
|
+
...createAgentStreamAncestryMetadata(ancestry)
|
|
12897
12947
|
};
|
|
12898
12948
|
}
|
|
12899
12949
|
function createAgentStepDataPart(args) {
|
|
12900
|
-
const { runId, stepIndex, step } = args;
|
|
12950
|
+
const { runId, stepIndex, step, ancestry } = args;
|
|
12901
12951
|
return {
|
|
12902
12952
|
type: "data-tool-agent-step",
|
|
12903
12953
|
id: `${runId}:${stepIndex}`,
|
|
@@ -12905,10 +12955,11 @@ function createAgentStepDataPart(args) {
|
|
|
12905
12955
|
runId,
|
|
12906
12956
|
stepIndex,
|
|
12907
12957
|
step: cloneAgentStep(step, { includeDetails: true })
|
|
12908
|
-
}
|
|
12958
|
+
},
|
|
12959
|
+
...createAgentStreamAncestryMetadata(ancestry)
|
|
12909
12960
|
};
|
|
12910
12961
|
}
|
|
12911
|
-
function transformAgent(payload, bufferedSteps) {
|
|
12962
|
+
function transformAgent(payload, bufferedSteps, ancestry = []) {
|
|
12912
12963
|
let hasChanged = false;
|
|
12913
12964
|
let completedStep = null;
|
|
12914
12965
|
switch (payload.type) {
|
|
@@ -13121,13 +13172,15 @@ function transformAgent(payload, bufferedSteps) {
|
|
|
13121
13172
|
const snapshot = createAgentDataPart({
|
|
13122
13173
|
current: bufferedSteps.get(payload.runId),
|
|
13123
13174
|
runId: payload.runId,
|
|
13175
|
+
ancestry,
|
|
13124
13176
|
includeCompletedStepDetails: payload.type === "finish",
|
|
13125
13177
|
includeResponseMessages: payload.type === "finish"
|
|
13126
13178
|
});
|
|
13127
13179
|
if (completedStep) return [snapshot, createAgentStepDataPart({
|
|
13128
13180
|
runId: payload.runId,
|
|
13129
13181
|
stepIndex: completedStep.stepIndex,
|
|
13130
|
-
step: completedStep.step
|
|
13182
|
+
step: completedStep.step,
|
|
13183
|
+
ancestry
|
|
13131
13184
|
})];
|
|
13132
13185
|
return snapshot;
|
|
13133
13186
|
}
|
|
@@ -13646,7 +13699,8 @@ function toAISdkV5Stream(stream, options = {
|
|
|
13646
13699
|
sendReasoning: options.sendReasoning,
|
|
13647
13700
|
sendSources: options.sendSources,
|
|
13648
13701
|
messageMetadata: options.messageMetadata,
|
|
13649
|
-
onError: options.onError
|
|
13702
|
+
onError: options.onError,
|
|
13703
|
+
includeSubAgentMetadata: options.includeSubAgentMetadata
|
|
13650
13704
|
}));
|
|
13651
13705
|
}
|
|
13652
13706
|
function toAISdkStream(stream, options = {
|
|
@@ -13672,7 +13726,8 @@ function toAISdkStream(stream, options = {
|
|
|
13672
13726
|
sendReasoning: options.sendReasoning,
|
|
13673
13727
|
sendSources: options.sendSources,
|
|
13674
13728
|
messageMetadata: options.messageMetadata,
|
|
13675
|
-
onError: options.onError
|
|
13729
|
+
onError: options.onError,
|
|
13730
|
+
includeSubAgentMetadata: options.includeSubAgentMetadata
|
|
13676
13731
|
}));
|
|
13677
13732
|
}
|
|
13678
13733
|
const from = options.from;
|
|
@@ -13692,7 +13747,8 @@ function toAISdkStream(stream, options = {
|
|
|
13692
13747
|
sendReasoning: options.sendReasoning,
|
|
13693
13748
|
sendSources: options.sendSources,
|
|
13694
13749
|
messageMetadata: options.messageMetadata,
|
|
13695
|
-
onError: options.onError
|
|
13750
|
+
onError: options.onError,
|
|
13751
|
+
includeSubAgentMetadata: options.includeSubAgentMetadata
|
|
13696
13752
|
}));
|
|
13697
13753
|
}
|
|
13698
13754
|
//#endregion
|