@mastra/ai-sdk 1.10.5 → 1.10.6
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/helpers.d.ts.map +1 -1
- package/dist/index.cjs +45 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -51
- package/dist/index.js.map +1 -1
- package/dist/transformers.d.ts +1 -10
- package/dist/transformers.d.ts.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { MASTRA_RESOURCE_ID_KEY } from "@mastra/core/request-context";
|
|
|
10
10
|
import { MessageList, TripWire, aiV5ModelMessageToV2PromptMessage } from "@mastra/core/agent";
|
|
11
11
|
import { RequestContext } from "@mastra/core/di";
|
|
12
12
|
import { MessageHistory, SemanticRecall, WorkingMemory } from "@mastra/core/processors";
|
|
13
|
-
//#region ../../packages/_vendored/ai_v5/dist/dist-
|
|
13
|
+
//#region ../../packages/_vendored/ai_v5/dist/dist-KmM6rhg_.js
|
|
14
14
|
var marker$2$4 = "vercel.ai.error";
|
|
15
15
|
var symbol$2$3 = Symbol.for(marker$2$4);
|
|
16
16
|
var _a$2$3;
|
|
@@ -5426,7 +5426,7 @@ function createUIMessageStream$2({ execute, onError = () => "An error occurred."
|
|
|
5426
5426
|
});
|
|
5427
5427
|
}
|
|
5428
5428
|
//#endregion
|
|
5429
|
-
//#region ../../packages/_vendored/ai_v6/dist/dist
|
|
5429
|
+
//#region ../../packages/_vendored/ai_v6/dist/dist-BBy3PDi4.js
|
|
5430
5430
|
var marker$2$1 = "vercel.ai.error";
|
|
5431
5431
|
var symbol$2$2 = Symbol.for(marker$2$1);
|
|
5432
5432
|
var _a$2$2;
|
|
@@ -9522,7 +9522,7 @@ var doWrap = ({ model, middleware: { transformParams, wrapGenerate, wrapStream,
|
|
|
9522
9522
|
};
|
|
9523
9523
|
};
|
|
9524
9524
|
//#endregion
|
|
9525
|
-
//#region ../../packages/_vendored/ai_v7/dist/dist-
|
|
9525
|
+
//#region ../../packages/_vendored/ai_v7/dist/dist-I7kChHSf.js
|
|
9526
9526
|
var marker$1 = "vercel.ai.error";
|
|
9527
9527
|
var symbol$1 = Symbol.for(marker$1);
|
|
9528
9528
|
var _a$1;
|
|
@@ -13352,6 +13352,7 @@ const isMastraTextStreamChunk = (chunk) => {
|
|
|
13352
13352
|
"tool-input-delta",
|
|
13353
13353
|
"tool-call-approval",
|
|
13354
13354
|
"tool-call-suspended",
|
|
13355
|
+
"tool-call-resumed",
|
|
13355
13356
|
"tool-call",
|
|
13356
13357
|
"tool-result",
|
|
13357
13358
|
"tool-error",
|
|
@@ -13391,6 +13392,12 @@ const isAgentExecutionDataChunkType = (chunk) => {
|
|
|
13391
13392
|
const isWorkflowExecutionDataChunkType = (chunk) => {
|
|
13392
13393
|
return chunk && typeof chunk === "object" && "type" in chunk && chunk.type?.startsWith("workflow-execution-event-") && "payload" in chunk && typeof chunk.payload === "object" && "type" in chunk.payload && chunk.payload.type?.startsWith("data-");
|
|
13393
13394
|
};
|
|
13395
|
+
const toUIDataChunk = ({ type, data, id, transient }) => ({
|
|
13396
|
+
type,
|
|
13397
|
+
data,
|
|
13398
|
+
...id !== void 0 && { id },
|
|
13399
|
+
...transient !== void 0 && { transient }
|
|
13400
|
+
});
|
|
13394
13401
|
/**
|
|
13395
13402
|
* Maps Mastra's extended finish reasons to AI SDK-compatible values.
|
|
13396
13403
|
* 'tripwire' and 'retry' are Mastra-specific reasons for processor scenarios,
|
|
@@ -13547,6 +13554,33 @@ function convertMastraChunkToAISDKBase({ chunk, mode = "stream", normalizeWarnin
|
|
|
13547
13554
|
resumeSchema: chunk.payload.resumeSchema
|
|
13548
13555
|
}
|
|
13549
13556
|
};
|
|
13557
|
+
case "tool-call-resumed":
|
|
13558
|
+
if (chunk.payload.kind === "approval") return {
|
|
13559
|
+
type: "data-tool-call-approval",
|
|
13560
|
+
id: chunk.payload.toolCallId,
|
|
13561
|
+
data: {
|
|
13562
|
+
state: "data-tool-call-approval",
|
|
13563
|
+
runId: chunk.runId,
|
|
13564
|
+
toolCallId: chunk.payload.toolCallId,
|
|
13565
|
+
toolName: chunk.payload.toolName,
|
|
13566
|
+
args: hasTransformedToolPayload(displayApprovalTransform) ? displayApprovalTransform.transformed : chunk.payload.args,
|
|
13567
|
+
resumeSchema: chunk.payload.resumeSchema,
|
|
13568
|
+
resumed: true
|
|
13569
|
+
}
|
|
13570
|
+
};
|
|
13571
|
+
return {
|
|
13572
|
+
type: "data-tool-call-suspended",
|
|
13573
|
+
id: chunk.payload.toolCallId,
|
|
13574
|
+
data: {
|
|
13575
|
+
state: "data-tool-call-suspended",
|
|
13576
|
+
runId: chunk.runId,
|
|
13577
|
+
toolCallId: chunk.payload.toolCallId,
|
|
13578
|
+
toolName: chunk.payload.toolName,
|
|
13579
|
+
suspendPayload: hasTransformedToolPayload(displaySuspendTransform) ? displaySuspendTransform.transformed : chunk.payload.suspendPayload,
|
|
13580
|
+
resumeSchema: chunk.payload.resumeSchema,
|
|
13581
|
+
resumed: true
|
|
13582
|
+
}
|
|
13583
|
+
};
|
|
13550
13584
|
case "tool-call-input-streaming-start": return {
|
|
13551
13585
|
type: "tool-input-start",
|
|
13552
13586
|
id: chunk.payload.toolCallId,
|
|
@@ -13912,12 +13946,7 @@ function convertFullStreamChunkToUIMessageStream({ part, messageMetadataValue, s
|
|
|
13912
13946
|
};
|
|
13913
13947
|
else if (isDataChunkType(output)) {
|
|
13914
13948
|
if (!("data" in output)) throw new Error(`UI Messages require a data property when using data- prefixed chunks \n ${JSON.stringify(part)}`);
|
|
13915
|
-
|
|
13916
|
-
return {
|
|
13917
|
-
type,
|
|
13918
|
-
data,
|
|
13919
|
-
...id !== void 0 && { id }
|
|
13920
|
-
};
|
|
13949
|
+
return toUIDataChunk(output);
|
|
13921
13950
|
}
|
|
13922
13951
|
return;
|
|
13923
13952
|
}
|
|
@@ -13958,21 +13987,11 @@ function convertFullStreamChunkToUIMessageStream({ part, messageMetadataValue, s
|
|
|
13958
13987
|
if (typeof partType === "string" && partType.startsWith("background-task-")) {
|
|
13959
13988
|
const backgroundTaskChunk = convertBackgroundTaskChunkToDataChunk(part);
|
|
13960
13989
|
if (!backgroundTaskChunk) return;
|
|
13961
|
-
|
|
13962
|
-
return {
|
|
13963
|
-
type,
|
|
13964
|
-
data,
|
|
13965
|
-
...id !== void 0 && { id }
|
|
13966
|
-
};
|
|
13990
|
+
return toUIDataChunk(backgroundTaskChunk);
|
|
13967
13991
|
}
|
|
13968
13992
|
if (isDataChunkType(part)) {
|
|
13969
13993
|
if (!("data" in part)) throw new Error(`UI Messages require a data property when using data- prefixed chunks \n ${JSON.stringify(part)}`);
|
|
13970
|
-
|
|
13971
|
-
return {
|
|
13972
|
-
type,
|
|
13973
|
-
data,
|
|
13974
|
-
...id !== void 0 && { id }
|
|
13975
|
-
};
|
|
13994
|
+
return toUIDataChunk(part);
|
|
13976
13995
|
}
|
|
13977
13996
|
return;
|
|
13978
13997
|
}
|
|
@@ -14679,24 +14698,14 @@ function transformWorkflow(payload, bufferedWorkflows, isNested, includeTextStre
|
|
|
14679
14698
|
}
|
|
14680
14699
|
if (output && isDataChunkType(output)) {
|
|
14681
14700
|
if (!("data" in output)) throw new Error(`UI Messages require a data property when using data- prefixed chunks \n ${JSON.stringify(output)}`);
|
|
14682
|
-
|
|
14683
|
-
return {
|
|
14684
|
-
type,
|
|
14685
|
-
data,
|
|
14686
|
-
...id !== void 0 && { id }
|
|
14687
|
-
};
|
|
14701
|
+
return toUIDataChunk(output);
|
|
14688
14702
|
}
|
|
14689
14703
|
return null;
|
|
14690
14704
|
}
|
|
14691
14705
|
default:
|
|
14692
14706
|
if (isDataChunkType(payload)) {
|
|
14693
14707
|
if (!("data" in payload)) throw new Error(`UI Messages require a data property when using data- prefixed chunks \n ${JSON.stringify(payload)}`);
|
|
14694
|
-
|
|
14695
|
-
return {
|
|
14696
|
-
type,
|
|
14697
|
-
data,
|
|
14698
|
-
...id !== void 0 && { id }
|
|
14699
|
-
};
|
|
14708
|
+
return toUIDataChunk(payload);
|
|
14700
14709
|
}
|
|
14701
14710
|
return null;
|
|
14702
14711
|
}
|
|
@@ -14962,21 +14971,11 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
14962
14971
|
default:
|
|
14963
14972
|
if (isAgentExecutionDataChunkType(payload)) {
|
|
14964
14973
|
if (!("data" in payload.payload)) throw new Error(`UI Messages require a data property when using data- prefixed chunks \n ${JSON.stringify(payload)}`);
|
|
14965
|
-
|
|
14966
|
-
return {
|
|
14967
|
-
type,
|
|
14968
|
-
data,
|
|
14969
|
-
...id !== void 0 && { id }
|
|
14970
|
-
};
|
|
14974
|
+
return toUIDataChunk(payload.payload);
|
|
14971
14975
|
}
|
|
14972
14976
|
if (isWorkflowExecutionDataChunkType(payload)) {
|
|
14973
14977
|
if (!("data" in payload.payload)) throw new Error(`UI Messages require a data property when using data- prefixed chunks \n ${JSON.stringify(payload)}`);
|
|
14974
|
-
|
|
14975
|
-
return {
|
|
14976
|
-
type,
|
|
14977
|
-
data,
|
|
14978
|
-
...id !== void 0 && { id }
|
|
14979
|
-
};
|
|
14978
|
+
return toUIDataChunk(payload.payload);
|
|
14980
14979
|
}
|
|
14981
14980
|
if (payload.type.startsWith("agent-execution-event-")) {
|
|
14982
14981
|
const stepId = payload.payload.runId;
|
|
@@ -15042,12 +15041,7 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
15042
15041
|
}
|
|
15043
15042
|
if (isDataChunkType(payload)) {
|
|
15044
15043
|
if (!("data" in payload)) throw new Error(`UI Messages require a data property when using data- prefixed chunks \n ${JSON.stringify(payload)}`);
|
|
15045
|
-
|
|
15046
|
-
return {
|
|
15047
|
-
type,
|
|
15048
|
-
data,
|
|
15049
|
-
...id !== void 0 && { id }
|
|
15050
|
-
};
|
|
15044
|
+
return toUIDataChunk(payload);
|
|
15051
15045
|
}
|
|
15052
15046
|
return null;
|
|
15053
15047
|
}
|