@mastra/ai-sdk 1.0.0-beta.7 → 1.0.0-beta.8
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 +26 -0
- package/dist/helpers.d.ts +8 -2
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.cjs +13 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -62,6 +62,12 @@ var isWorkflowExecutionDataChunkType = (chunk) => {
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
// src/helpers.ts
|
|
65
|
+
function toAISDKFinishReason(reason) {
|
|
66
|
+
if (reason === "tripwire" || reason === "retry") {
|
|
67
|
+
return "other";
|
|
68
|
+
}
|
|
69
|
+
return reason;
|
|
70
|
+
}
|
|
65
71
|
function convertMastraChunkToAISDKv5({
|
|
66
72
|
chunk,
|
|
67
73
|
mode = "stream"
|
|
@@ -86,7 +92,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
86
92
|
case "finish": {
|
|
87
93
|
return {
|
|
88
94
|
type: "finish",
|
|
89
|
-
finishReason: chunk.payload.stepResult.reason,
|
|
95
|
+
finishReason: toAISDKFinishReason(chunk.payload.stepResult.reason),
|
|
90
96
|
totalUsage: chunk.payload.output.usage
|
|
91
97
|
};
|
|
92
98
|
}
|
|
@@ -225,7 +231,7 @@ function convertMastraChunkToAISDKv5({
|
|
|
225
231
|
...rest2
|
|
226
232
|
},
|
|
227
233
|
usage: chunk.payload.output.usage,
|
|
228
|
-
finishReason: chunk.payload.stepResult.reason,
|
|
234
|
+
finishReason: toAISDKFinishReason(chunk.payload.stepResult.reason),
|
|
229
235
|
providerMetadata
|
|
230
236
|
};
|
|
231
237
|
}
|
|
@@ -286,7 +292,10 @@ function convertMastraChunkToAISDKv5({
|
|
|
286
292
|
return {
|
|
287
293
|
type: "data-tripwire",
|
|
288
294
|
data: {
|
|
289
|
-
|
|
295
|
+
reason: chunk.payload.reason,
|
|
296
|
+
retry: chunk.payload.retry,
|
|
297
|
+
metadata: chunk.payload.metadata,
|
|
298
|
+
processorId: chunk.payload.processorId
|
|
290
299
|
}
|
|
291
300
|
};
|
|
292
301
|
default:
|
|
@@ -2106,7 +2115,7 @@ function convertMastraChunkToAISDKStreamPart(chunk) {
|
|
|
2106
2115
|
const usage = chunk.payload.output?.usage;
|
|
2107
2116
|
return {
|
|
2108
2117
|
type: "finish",
|
|
2109
|
-
finishReason: chunk.payload.stepResult?.reason || "stop",
|
|
2118
|
+
finishReason: toAISDKFinishReason(chunk.payload.stepResult?.reason || "stop"),
|
|
2110
2119
|
usage: usage ? {
|
|
2111
2120
|
inputTokens: usage.inputTokens || 0,
|
|
2112
2121
|
outputTokens: usage.outputTokens || 0,
|