@mastra/ai-sdk 1.4.2 → 1.4.3
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/index.cjs +91 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -1
- package/dist/transformers.d.ts.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
+
## 1.4.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed sub-agent streams so nested tool input progress is emitted while tool arguments are still being generated. This lets UIs show delegated agents preparing tool calls before the final tool input is available. Fixes #16422. ([#16553](https://github.com/mastra-ai/mastra/pull/16553))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`452036a`](https://github.com/mastra-ai/mastra/commit/452036a0d965b4f4c1efd93606e4f03b50b807a5), [`c272d50`](https://github.com/mastra-ai/mastra/commit/c272d50610a54496b6b6d92ccd4d37b333a2613a), [`27fd1b7`](https://github.com/mastra-ai/mastra/commit/27fd1b79ac62eb7694f92587eb7d1be05b59be01), [`5ba7253`](https://github.com/mastra-ai/mastra/commit/5ba7253745c85e8df8012a76d954c640ffa336f7), [`5556cc1`](https://github.com/mastra-ai/mastra/commit/5556cc1befec71518d84f826b3bfe3a079a9daf7), [`f73980d`](https://github.com/mastra-ai/mastra/commit/f73980d651eb5f7f1ab20582de4615a1b6f10fce), [`5499303`](https://github.com/mastra-ai/mastra/commit/54993032c1ebc09642625b78d2014e0cf84a3cae), [`a702009`](https://github.com/mastra-ai/mastra/commit/a702009d3cfaa745120f501e21c783ed4d6a3072), [`9aee493`](https://github.com/mastra-ai/mastra/commit/9aee493ed6089b5133472623dcce49934bf2d509), [`d8692af`](https://github.com/mastra-ai/mastra/commit/d8692afa253028e39cdce2aafa0ac414071a762e), [`1a9cc60`](https://github.com/mastra-ai/mastra/commit/1a9cc6069f9910fc3d59e4953ac8cd95d89ad6f5), [`8cdb86c`](https://github.com/mastra-ai/mastra/commit/8cdb86ceed1137bc2768e147dce85a0692b9fb26), [`8534d79`](https://github.com/mastra-ai/mastra/commit/8534d791fa1cb70fe1c19e2604c4b63cc10dd051), [`eda90c5`](https://github.com/mastra-ai/mastra/commit/eda90c5bfd7de11805ecc9f4552716c895fbaf78), [`a935b0a`](https://github.com/mastra-ai/mastra/commit/a935b0a0977ae3f196b33ec7621f528069c82db0), [`9c88701`](https://github.com/mastra-ai/mastra/commit/9c8870195b41a38dc40b6ba2aa55eda04df8fa69), [`c78f8cd`](https://github.com/mastra-ai/mastra/commit/c78f8cd6222a86e6c60ae5210b6929ad5221b6fb), [`e146aad`](https://github.com/mastra-ai/mastra/commit/e146aadbba66c410ba0e74bac4c50135495cb8dd), [`ac79462`](https://github.com/mastra-ai/mastra/commit/ac79462b98f1062394c45093aa515b0766f27ee2), [`1a0ec78`](https://github.com/mastra-ai/mastra/commit/1a0ec789a26cae443744e9abbd62ed6ee676af39), [`e47bca7`](https://github.com/mastra-ai/mastra/commit/e47bca7b72866d3abd173b9f530ac4318113a8ff), [`afc004f`](https://github.com/mastra-ai/mastra/commit/afc004f5cc7e30697809e7021820b9f5881e6719), [`0031d0f`](https://github.com/mastra-ai/mastra/commit/0031d0f13831d7843ac5d498734a7d92862e2ce3), [`841a222`](https://github.com/mastra-ai/mastra/commit/841a222560d8c19238f8213713f30535cdd82284), [`64c1e0b`](https://github.com/mastra-ai/mastra/commit/64c1e0b35165c96b659818bd0177aa18794ef11f), [`40d83a9`](https://github.com/mastra-ai/mastra/commit/40d83a90d9be31a1b83e04649edb703eb7753e33), [`4e88dc6`](https://github.com/mastra-ai/mastra/commit/4e88dc6b89f154c0eae37221c8126be0c23c569f), [`19018f0`](https://github.com/mastra-ai/mastra/commit/19018f05722af74a5978781a7731a654b26f7f2a), [`19281c7`](https://github.com/mastra-ai/mastra/commit/19281c70424f757219782de16c2699743c5e04d0), [`3498b49`](https://github.com/mastra-ai/mastra/commit/3498b4946be94f4313cd817733589680dcda5278), [`d52b6fe`](https://github.com/mastra-ai/mastra/commit/d52b6fe1c56853eb38864baae0bbfa75cc739ccb), [`408be73`](https://github.com/mastra-ai/mastra/commit/408be73449dfab92b51eab8c6623b6c443debc25), [`359439b`](https://github.com/mastra-ai/mastra/commit/359439bb8c635e048176306828195f8297f50021), [`71a820b`](https://github.com/mastra-ai/mastra/commit/71a820b2353fa1406772c50760a3732058a8b337), [`1698f5e`](https://github.com/mastra-ai/mastra/commit/1698f5ec141d34f22a873efdb145ce3cdf848a5e)]:
|
|
10
|
+
- @mastra/core@1.36.0
|
|
11
|
+
|
|
12
|
+
## 1.4.3-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fixed sub-agent streams so nested tool input progress is emitted while tool arguments are still being generated. This lets UIs show delegated agents preparing tool calls before the final tool input is available. Fixes #16422. ([#16553](https://github.com/mastra-ai/mastra/pull/16553))
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`5ba7253`](https://github.com/mastra-ai/mastra/commit/5ba7253745c85e8df8012a76d954c640ffa336f7), [`f73980d`](https://github.com/mastra-ai/mastra/commit/f73980d651eb5f7f1ab20582de4615a1b6f10fce), [`9c88701`](https://github.com/mastra-ai/mastra/commit/9c8870195b41a38dc40b6ba2aa55eda04df8fa69), [`4e88dc6`](https://github.com/mastra-ai/mastra/commit/4e88dc6b89f154c0eae37221c8126be0c23c569f), [`19018f0`](https://github.com/mastra-ai/mastra/commit/19018f05722af74a5978781a7731a654b26f7f2a)]:
|
|
19
|
+
- @mastra/core@1.36.0-alpha.2
|
|
20
|
+
|
|
3
21
|
## 1.4.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -12926,6 +12926,7 @@ function ensureAgentRunState(bufferedSteps, runId) {
|
|
|
12926
12926
|
sources: [],
|
|
12927
12927
|
files: [],
|
|
12928
12928
|
toolCalls: [],
|
|
12929
|
+
pendingToolCalls: [],
|
|
12929
12930
|
toolResults: [],
|
|
12930
12931
|
request: {},
|
|
12931
12932
|
response: {
|
|
@@ -12941,6 +12942,44 @@ function ensureAgentRunState(bufferedSteps, runId) {
|
|
|
12941
12942
|
}
|
|
12942
12943
|
return bufferedSteps.get(runId);
|
|
12943
12944
|
}
|
|
12945
|
+
function upsertPendingToolCall(pendingToolCalls = [], toolCallId, updates) {
|
|
12946
|
+
const existingIndex = pendingToolCalls.findIndex((call) => call.toolCallId === toolCallId);
|
|
12947
|
+
if (existingIndex === -1) {
|
|
12948
|
+
return [
|
|
12949
|
+
...pendingToolCalls,
|
|
12950
|
+
{
|
|
12951
|
+
toolCallId,
|
|
12952
|
+
toolName: updates.toolName || "",
|
|
12953
|
+
argsText: updates.argsText || "",
|
|
12954
|
+
state: updates.state || "input-streaming",
|
|
12955
|
+
...updates.providerExecuted != null ? { providerExecuted: updates.providerExecuted } : {},
|
|
12956
|
+
...updates.providerMetadata != null ? { providerMetadata: updates.providerMetadata } : {},
|
|
12957
|
+
...updates.dynamic != null ? { dynamic: updates.dynamic } : {}
|
|
12958
|
+
}
|
|
12959
|
+
];
|
|
12960
|
+
}
|
|
12961
|
+
return pendingToolCalls.map((call, index) => {
|
|
12962
|
+
if (index !== existingIndex) return call;
|
|
12963
|
+
return {
|
|
12964
|
+
...call,
|
|
12965
|
+
...updates,
|
|
12966
|
+
toolName: updates.toolName || call.toolName,
|
|
12967
|
+
argsText: updates.argsText ?? call.argsText
|
|
12968
|
+
};
|
|
12969
|
+
});
|
|
12970
|
+
}
|
|
12971
|
+
function appendPendingToolCallArgs(pendingToolCalls = [], payload) {
|
|
12972
|
+
const existing = pendingToolCalls.find((call) => call.toolCallId === payload.toolCallId);
|
|
12973
|
+
return upsertPendingToolCall(pendingToolCalls, payload.toolCallId, {
|
|
12974
|
+
toolName: payload.toolName || existing?.toolName || "",
|
|
12975
|
+
argsText: `${existing?.argsText || ""}${payload.argsTextDelta || ""}`,
|
|
12976
|
+
state: "input-streaming",
|
|
12977
|
+
providerMetadata: payload.providerMetadata ?? existing?.providerMetadata
|
|
12978
|
+
});
|
|
12979
|
+
}
|
|
12980
|
+
function removePendingToolCall(pendingToolCalls = [], toolCallId) {
|
|
12981
|
+
return pendingToolCalls.filter((call) => call.toolCallId !== toolCallId);
|
|
12982
|
+
}
|
|
12944
12983
|
function transformAgent(payload, bufferedSteps) {
|
|
12945
12984
|
let hasChanged = false;
|
|
12946
12985
|
switch (payload.type) {
|
|
@@ -12956,6 +12995,7 @@ function transformAgent(payload, bufferedSteps) {
|
|
|
12956
12995
|
sources: [],
|
|
12957
12996
|
files: [],
|
|
12958
12997
|
toolCalls: [],
|
|
12998
|
+
pendingToolCalls: [],
|
|
12959
12999
|
toolResults: [],
|
|
12960
13000
|
request: {},
|
|
12961
13001
|
response: {
|
|
@@ -12970,6 +13010,50 @@ function transformAgent(payload, bufferedSteps) {
|
|
|
12970
13010
|
});
|
|
12971
13011
|
hasChanged = true;
|
|
12972
13012
|
break;
|
|
13013
|
+
case "tool-call-input-streaming-start": {
|
|
13014
|
+
const toolInputStartRun = ensureAgentRunState(bufferedSteps, payload.runId);
|
|
13015
|
+
const existing = toolInputStartRun.pendingToolCalls?.find(
|
|
13016
|
+
(call) => call.toolCallId === payload.payload.toolCallId
|
|
13017
|
+
);
|
|
13018
|
+
bufferedSteps.set(payload.runId, {
|
|
13019
|
+
...toolInputStartRun,
|
|
13020
|
+
pendingToolCalls: upsertPendingToolCall(toolInputStartRun.pendingToolCalls, payload.payload.toolCallId, {
|
|
13021
|
+
toolName: payload.payload.toolName,
|
|
13022
|
+
argsText: existing?.argsText ?? "",
|
|
13023
|
+
state: "input-streaming",
|
|
13024
|
+
providerExecuted: payload.payload.providerExecuted,
|
|
13025
|
+
providerMetadata: payload.payload.providerMetadata,
|
|
13026
|
+
dynamic: payload.payload.dynamic
|
|
13027
|
+
})
|
|
13028
|
+
});
|
|
13029
|
+
hasChanged = true;
|
|
13030
|
+
break;
|
|
13031
|
+
}
|
|
13032
|
+
case "tool-call-delta": {
|
|
13033
|
+
const toolCallDeltaRun = ensureAgentRunState(bufferedSteps, payload.runId);
|
|
13034
|
+
bufferedSteps.set(payload.runId, {
|
|
13035
|
+
...toolCallDeltaRun,
|
|
13036
|
+
pendingToolCalls: appendPendingToolCallArgs(toolCallDeltaRun.pendingToolCalls, payload.payload)
|
|
13037
|
+
});
|
|
13038
|
+
hasChanged = true;
|
|
13039
|
+
break;
|
|
13040
|
+
}
|
|
13041
|
+
case "tool-call-input-streaming-end": {
|
|
13042
|
+
const toolInputEndRun = ensureAgentRunState(bufferedSteps, payload.runId);
|
|
13043
|
+
const existing = toolInputEndRun.pendingToolCalls?.find(
|
|
13044
|
+
(call) => call.toolCallId === payload.payload.toolCallId
|
|
13045
|
+
);
|
|
13046
|
+
bufferedSteps.set(payload.runId, {
|
|
13047
|
+
...toolInputEndRun,
|
|
13048
|
+
pendingToolCalls: upsertPendingToolCall(toolInputEndRun.pendingToolCalls, payload.payload.toolCallId, {
|
|
13049
|
+
toolName: existing?.toolName || "",
|
|
13050
|
+
state: "input-available",
|
|
13051
|
+
providerMetadata: payload.payload.providerMetadata ?? existing?.providerMetadata
|
|
13052
|
+
})
|
|
13053
|
+
});
|
|
13054
|
+
hasChanged = true;
|
|
13055
|
+
break;
|
|
13056
|
+
}
|
|
12973
13057
|
case "finish":
|
|
12974
13058
|
bufferedSteps.set(payload.runId, {
|
|
12975
13059
|
...bufferedSteps.get(payload.runId),
|
|
@@ -13018,6 +13102,10 @@ function transformAgent(payload, bufferedSteps) {
|
|
|
13018
13102
|
case "tool-call":
|
|
13019
13103
|
bufferedSteps.set(payload.runId, {
|
|
13020
13104
|
...bufferedSteps.get(payload.runId),
|
|
13105
|
+
pendingToolCalls: removePendingToolCall(
|
|
13106
|
+
bufferedSteps.get(payload.runId).pendingToolCalls,
|
|
13107
|
+
payload.payload.toolCallId
|
|
13108
|
+
),
|
|
13021
13109
|
toolCalls: [...bufferedSteps.get(payload.runId).toolCalls, payload.payload]
|
|
13022
13110
|
});
|
|
13023
13111
|
hasChanged = true;
|
|
@@ -13026,6 +13114,7 @@ function transformAgent(payload, bufferedSteps) {
|
|
|
13026
13114
|
const toolResultRun = ensureAgentRunState(bufferedSteps, payload.runId);
|
|
13027
13115
|
bufferedSteps.set(payload.runId, {
|
|
13028
13116
|
...toolResultRun,
|
|
13117
|
+
pendingToolCalls: removePendingToolCall(toolResultRun.pendingToolCalls, payload.payload.toolCallId),
|
|
13029
13118
|
toolResults: [...toolResultRun.toolResults, payload.payload]
|
|
13030
13119
|
});
|
|
13031
13120
|
hasChanged = true;
|
|
@@ -13056,6 +13145,7 @@ function transformAgent(payload, bufferedSteps) {
|
|
|
13056
13145
|
...stepRunWithoutSteps,
|
|
13057
13146
|
text: stepText,
|
|
13058
13147
|
reasoning: stepReasoning,
|
|
13148
|
+
pendingToolCalls: [],
|
|
13059
13149
|
stepType: stepRun.steps.length === 0 ? "initial" : "tool-result",
|
|
13060
13150
|
reasoningText: stepReasoning.join(""),
|
|
13061
13151
|
staticToolCalls: stepRun.toolCalls.filter(
|
|
@@ -13087,6 +13177,7 @@ function transformAgent(payload, bufferedSteps) {
|
|
|
13087
13177
|
sources: [],
|
|
13088
13178
|
files: [],
|
|
13089
13179
|
toolCalls: [],
|
|
13180
|
+
pendingToolCalls: [],
|
|
13090
13181
|
toolResults: [],
|
|
13091
13182
|
usage: payload.payload.output.usage,
|
|
13092
13183
|
warnings: payload.payload.stepResult.warnings || [],
|