@mastra/ai-sdk 0.0.0-fix-multi-modal-for-cloud-20251028082043 → 0.0.0-fix-persist-session-cache-option-mcp-server-20251030171242
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 +7 -3
- package/dist/index.cjs +50 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -55
- package/dist/index.js.map +1 -1
- package/dist/transformers.d.ts +27 -0
- package/dist/transformers.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
-
## 0.0.0-fix-
|
|
3
|
+
## 0.0.0-fix-persist-session-cache-option-mcp-server-20251030171242
|
|
4
4
|
|
|
5
5
|
### Major Changes
|
|
6
6
|
|
|
7
|
+
- Rename RuntimeContext to RequestContext ([#9511](https://github.com/mastra-ai/mastra/pull/9511))
|
|
8
|
+
|
|
7
9
|
- Removed old tracing code based on OpenTelemetry ([#9237](https://github.com/mastra-ai/mastra/pull/9237))
|
|
8
10
|
|
|
9
11
|
### Minor Changes
|
|
@@ -12,8 +14,10 @@
|
|
|
12
14
|
|
|
13
15
|
### Patch Changes
|
|
14
16
|
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
+
- Fix usage tracking with agent network ([#9226](https://github.com/mastra-ai/mastra/pull/9226))
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`f743dbb`](https://github.com/mastra-ai/mastra/commit/f743dbb8b40d1627b5c10c0e6fc154f4ebb6e394), [`0e8ed46`](https://github.com/mastra-ai/mastra/commit/0e8ed467c54d6901a6a365f270ec15d6faadb36c), [`6c049d9`](https://github.com/mastra-ai/mastra/commit/6c049d94063fdcbd5b81c4912a2bf82a92c9cc0b), [`3443770`](https://github.com/mastra-ai/mastra/commit/3443770662df8eb24c9df3589b2792d78cfcb811), [`9e1911d`](https://github.com/mastra-ai/mastra/commit/9e1911db2b4db85e0e768c3f15e0d61e319869f6), [`ebac155`](https://github.com/mastra-ai/mastra/commit/ebac15564a590117db7078233f927a7e28a85106), [`5948e6a`](https://github.com/mastra-ai/mastra/commit/5948e6a5146c83666ba3f294b2be576c82a513fb), [`8940859`](https://github.com/mastra-ai/mastra/commit/89408593658199b4ad67f7b65e888f344e64a442), [`e629310`](https://github.com/mastra-ai/mastra/commit/e629310f1a73fa236d49ec7a1d1cceb6229dc7cc), [`4c6b492`](https://github.com/mastra-ai/mastra/commit/4c6b492c4dd591c6a592520c1f6855d6e936d71f), [`9d819d5`](https://github.com/mastra-ai/mastra/commit/9d819d54b61481639f4008e4694791bddf187edd), [`71c8d6c`](https://github.com/mastra-ai/mastra/commit/71c8d6c161253207b2b9588bdadb7eed604f7253), [`6179a9b`](https://github.com/mastra-ai/mastra/commit/6179a9ba36ffac326de3cc3c43cdc8028d37c251), [`7051bf3`](https://github.com/mastra-ai/mastra/commit/7051bf38b3b122a069008f861f7bfc004a6d9f6e), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`c576fc0`](https://github.com/mastra-ai/mastra/commit/c576fc0b100b2085afded91a37c97a0ea0ec09c7), [`9f4a683`](https://github.com/mastra-ai/mastra/commit/9f4a6833e88b52574665c028fd5508ad5c2f6004), [`57d157f`](https://github.com/mastra-ai/mastra/commit/57d157f0b163a95c3e6c9eae31bdb11d1bfc64f9), [`2a90c55`](https://github.com/mastra-ai/mastra/commit/2a90c55a86a9210697d5adaab5ee94584b079adc), [`d78b38d`](https://github.com/mastra-ai/mastra/commit/d78b38d898fce285260d3bbb4befade54331617f), [`c710c16`](https://github.com/mastra-ai/mastra/commit/c710c1652dccfdc4111c8412bca7a6bb1d48b441), [`cfae733`](https://github.com/mastra-ai/mastra/commit/cfae73394f4920635e6c919c8e95ff9a0788e2e5), [`e3dfda7`](https://github.com/mastra-ai/mastra/commit/e3dfda7b11bf3b8c4bb55637028befb5f387fc74), [`844ea5d`](https://github.com/mastra-ai/mastra/commit/844ea5dc0c248961e7bf73629ae7dcff503e853c), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`7b763e5`](https://github.com/mastra-ai/mastra/commit/7b763e52fc3eaf699c2a99f2adf418dd46e4e9a5), [`d36cfbb`](https://github.com/mastra-ai/mastra/commit/d36cfbbb6565ba5f827883cc9bb648eb14befdc1), [`3697853`](https://github.com/mastra-ai/mastra/commit/3697853deeb72017d90e0f38a93c1e29221aeca0), [`a534e95`](https://github.com/mastra-ai/mastra/commit/a534e9591f83b3cc1ebff99c67edf4cda7bf81d3), [`9d0e7fe`](https://github.com/mastra-ai/mastra/commit/9d0e7feca8ed98de959f53476ee1456073673348), [`53d927c`](https://github.com/mastra-ai/mastra/commit/53d927cc6f03bff33655b7e2b788da445a08731d), [`22f64bc`](https://github.com/mastra-ai/mastra/commit/22f64bc1d37149480b58bf2fefe35b79a1e3e7d5), [`bda6370`](https://github.com/mastra-ai/mastra/commit/bda637009360649aaf579919e7873e33553c273e), [`c7f1f7d`](https://github.com/mastra-ai/mastra/commit/c7f1f7d24f61f247f018cc2d1f33bf63212959a7), [`735d8c1`](https://github.com/mastra-ai/mastra/commit/735d8c1c0d19fbc09e6f8b66cf41bc7655993838), [`c218bd3`](https://github.com/mastra-ai/mastra/commit/c218bd3759e32423735b04843a09404572631014), [`2c4438b`](https://github.com/mastra-ai/mastra/commit/2c4438b87817ab7eed818c7990fef010475af1a3), [`2b8893c`](https://github.com/mastra-ai/mastra/commit/2b8893cb108ef9acb72ee7835cd625610d2c1a4a), [`8e5c75b`](https://github.com/mastra-ai/mastra/commit/8e5c75bdb1d08a42d45309a4c72def4b6890230f), [`fa8409b`](https://github.com/mastra-ai/mastra/commit/fa8409bc39cfd8ba6643b9db5269b90b22e2a2f7), [`173c535`](https://github.com/mastra-ai/mastra/commit/173c535c0645b0da404fe09f003778f0b0d4e019)]:
|
|
20
|
+
- @mastra/core@0.0.0-fix-persist-session-cache-option-mcp-server-20251030171242
|
|
17
21
|
|
|
18
22
|
## 0.2.3
|
|
19
23
|
|
package/dist/index.cjs
CHANGED
|
@@ -702,19 +702,22 @@ function transformWorkflow(payload, bufferedWorkflows, isNested) {
|
|
|
702
702
|
function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
703
703
|
switch (payload.type) {
|
|
704
704
|
case "routing-agent-start": {
|
|
705
|
-
if (!bufferedNetworks.has(payload.
|
|
706
|
-
bufferedNetworks.set(payload.
|
|
705
|
+
if (!bufferedNetworks.has(payload.runId)) {
|
|
706
|
+
bufferedNetworks.set(payload.runId, {
|
|
707
707
|
name: payload.payload.agentId,
|
|
708
|
-
steps: []
|
|
708
|
+
steps: [],
|
|
709
|
+
usage: null,
|
|
710
|
+
output: null
|
|
709
711
|
});
|
|
710
712
|
}
|
|
711
713
|
return {
|
|
712
714
|
type: isNested ? "data-tool-network" : "data-network",
|
|
713
|
-
id: payload.
|
|
715
|
+
id: payload.runId,
|
|
714
716
|
data: {
|
|
715
|
-
name: bufferedNetworks.get(payload.
|
|
717
|
+
name: bufferedNetworks.get(payload.runId).name,
|
|
716
718
|
status: "running",
|
|
717
|
-
|
|
719
|
+
usage: null,
|
|
720
|
+
steps: bufferedNetworks.get(payload.runId).steps,
|
|
718
721
|
output: null
|
|
719
722
|
}
|
|
720
723
|
};
|
|
@@ -737,62 +740,56 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
737
740
|
};
|
|
738
741
|
}
|
|
739
742
|
case "agent-execution-start": {
|
|
740
|
-
const current = bufferedNetworks.get(payload.
|
|
743
|
+
const current = bufferedNetworks.get(payload.runId) || { name: "", steps: [], usage: null, output: null };
|
|
741
744
|
current.steps.push({
|
|
742
745
|
name: payload.payload.agentId,
|
|
743
746
|
status: "running",
|
|
744
747
|
input: payload.payload.args || null,
|
|
745
748
|
output: null
|
|
746
749
|
});
|
|
747
|
-
bufferedNetworks.set(payload.
|
|
750
|
+
bufferedNetworks.set(payload.runId, current);
|
|
748
751
|
return {
|
|
749
752
|
type: isNested ? "data-tool-network" : "data-network",
|
|
750
|
-
id: payload.
|
|
753
|
+
id: payload.runId,
|
|
751
754
|
data: {
|
|
752
|
-
|
|
753
|
-
status: "running"
|
|
754
|
-
steps: current.steps,
|
|
755
|
-
output: null
|
|
755
|
+
...current,
|
|
756
|
+
status: "running"
|
|
756
757
|
}
|
|
757
758
|
};
|
|
758
759
|
}
|
|
759
760
|
case "workflow-execution-start": {
|
|
760
|
-
const current = bufferedNetworks.get(payload.
|
|
761
|
+
const current = bufferedNetworks.get(payload.runId) || { name: "", steps: [], usage: null, output: null };
|
|
761
762
|
current.steps.push({
|
|
762
763
|
name: payload.payload.name,
|
|
763
764
|
status: "running",
|
|
764
765
|
input: payload.payload.args || null,
|
|
765
766
|
output: null
|
|
766
767
|
});
|
|
767
|
-
bufferedNetworks.set(payload.
|
|
768
|
+
bufferedNetworks.set(payload.runId, current);
|
|
768
769
|
return {
|
|
769
770
|
type: isNested ? "data-tool-network" : "data-network",
|
|
770
|
-
id: payload.
|
|
771
|
+
id: payload.runId,
|
|
771
772
|
data: {
|
|
772
|
-
|
|
773
|
-
status: "running"
|
|
774
|
-
steps: current.steps,
|
|
775
|
-
output: null
|
|
773
|
+
...current,
|
|
774
|
+
status: "running"
|
|
776
775
|
}
|
|
777
776
|
};
|
|
778
777
|
}
|
|
779
778
|
case "tool-execution-start": {
|
|
780
|
-
const current = bufferedNetworks.get(payload.
|
|
779
|
+
const current = bufferedNetworks.get(payload.runId) || { name: "", steps: [], usage: null, output: null };
|
|
781
780
|
current.steps.push({
|
|
782
781
|
name: payload.payload.args?.toolName,
|
|
783
782
|
status: "running",
|
|
784
783
|
input: payload.payload.args?.args || null,
|
|
785
784
|
output: null
|
|
786
785
|
});
|
|
787
|
-
bufferedNetworks.set(payload.
|
|
786
|
+
bufferedNetworks.set(payload.runId, current);
|
|
788
787
|
return {
|
|
789
788
|
type: isNested ? "data-tool-network" : "data-network",
|
|
790
|
-
id: payload.
|
|
789
|
+
id: payload.runId,
|
|
791
790
|
data: {
|
|
792
|
-
|
|
793
|
-
status: "running"
|
|
794
|
-
steps: current.steps,
|
|
795
|
-
output: null
|
|
791
|
+
...current,
|
|
792
|
+
status: "running"
|
|
796
793
|
}
|
|
797
794
|
};
|
|
798
795
|
}
|
|
@@ -809,10 +806,10 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
809
806
|
type: isNested ? "data-tool-network" : "data-network",
|
|
810
807
|
id: payload.runId,
|
|
811
808
|
data: {
|
|
812
|
-
|
|
809
|
+
...current,
|
|
810
|
+
usage: payload.payload?.usage ?? current.usage,
|
|
813
811
|
status: "running",
|
|
814
|
-
|
|
815
|
-
output: payload.payload.result ?? null
|
|
812
|
+
output: payload.payload.result ?? current.output
|
|
816
813
|
}
|
|
817
814
|
};
|
|
818
815
|
}
|
|
@@ -829,10 +826,9 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
829
826
|
type: isNested ? "data-tool-network" : "data-network",
|
|
830
827
|
id: payload.runId,
|
|
831
828
|
data: {
|
|
832
|
-
|
|
829
|
+
...current,
|
|
833
830
|
status: "running",
|
|
834
|
-
|
|
835
|
-
output: payload.payload.result ?? null
|
|
831
|
+
output: payload.payload.result ?? current.output
|
|
836
832
|
}
|
|
837
833
|
};
|
|
838
834
|
}
|
|
@@ -849,38 +845,37 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
849
845
|
type: isNested ? "data-tool-network" : "data-network",
|
|
850
846
|
id: payload.runId,
|
|
851
847
|
data: {
|
|
852
|
-
|
|
848
|
+
...current,
|
|
849
|
+
usage: payload.payload?.usage ?? current.usage,
|
|
853
850
|
status: "running",
|
|
854
|
-
|
|
855
|
-
output: payload.payload.result ?? null
|
|
851
|
+
output: payload.payload.result ?? current.output
|
|
856
852
|
}
|
|
857
853
|
};
|
|
858
854
|
}
|
|
859
855
|
case "routing-agent-end": {
|
|
860
|
-
const current = bufferedNetworks.get(payload.
|
|
856
|
+
const current = bufferedNetworks.get(payload.runId);
|
|
861
857
|
if (!current) return null;
|
|
862
858
|
return {
|
|
863
859
|
type: isNested ? "data-tool-network" : "data-network",
|
|
864
|
-
id: payload.
|
|
860
|
+
id: payload.runId,
|
|
865
861
|
data: {
|
|
866
|
-
|
|
862
|
+
...current,
|
|
867
863
|
status: "finished",
|
|
868
|
-
|
|
869
|
-
output: payload.payload?.result ??
|
|
864
|
+
usage: payload.payload?.usage ?? current.usage,
|
|
865
|
+
output: payload.payload?.result ?? current.output
|
|
870
866
|
}
|
|
871
867
|
};
|
|
872
868
|
}
|
|
873
869
|
case "network-execution-event-step-finish": {
|
|
874
|
-
const current = bufferedNetworks.get(payload.
|
|
870
|
+
const current = bufferedNetworks.get(payload.runId);
|
|
875
871
|
if (!current) return null;
|
|
876
872
|
return {
|
|
877
873
|
type: isNested ? "data-tool-network" : "data-network",
|
|
878
|
-
id: payload.
|
|
874
|
+
id: payload.runId,
|
|
879
875
|
data: {
|
|
880
|
-
|
|
876
|
+
...current,
|
|
881
877
|
status: "finished",
|
|
882
|
-
|
|
883
|
-
output: payload.payload?.result ?? null
|
|
878
|
+
output: payload.payload?.result ?? current.output
|
|
884
879
|
}
|
|
885
880
|
};
|
|
886
881
|
}
|
|
@@ -891,10 +886,10 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
891
886
|
type: isNested ? "data-tool-network" : "data-network",
|
|
892
887
|
id: payload.runId,
|
|
893
888
|
data: {
|
|
894
|
-
|
|
889
|
+
...current,
|
|
890
|
+
usage: payload.payload?.usage ?? current.usage,
|
|
895
891
|
status: "finished",
|
|
896
|
-
|
|
897
|
-
output: payload.payload?.result ?? null
|
|
892
|
+
output: payload.payload?.result ?? current.output
|
|
898
893
|
}
|
|
899
894
|
};
|
|
900
895
|
}
|
|
@@ -1031,7 +1026,7 @@ function chatRoute({
|
|
|
1031
1026
|
handler: async (c) => {
|
|
1032
1027
|
const { messages, ...rest } = await c.req.json();
|
|
1033
1028
|
const mastra = c.get("mastra");
|
|
1034
|
-
const
|
|
1029
|
+
const requestContext = c.get("requestContext");
|
|
1035
1030
|
let agentToUse = agent;
|
|
1036
1031
|
if (!agent) {
|
|
1037
1032
|
const agentId = c.req.param("agentId");
|
|
@@ -1042,8 +1037,8 @@ function chatRoute({
|
|
|
1042
1037
|
`Fixed agent ID was set together with an agentId path parameter. This can lead to unexpected behavior.`
|
|
1043
1038
|
);
|
|
1044
1039
|
}
|
|
1045
|
-
if (
|
|
1046
|
-
mastra.getLogger()?.warn(`"
|
|
1040
|
+
if (requestContext && defaultOptions?.requestContext) {
|
|
1041
|
+
mastra.getLogger()?.warn(`"requestContext" set in the route options will be overridden by the request's "requestContext".`);
|
|
1047
1042
|
}
|
|
1048
1043
|
if (!agentToUse) {
|
|
1049
1044
|
throw new Error("Agent ID is required");
|
|
@@ -1055,7 +1050,7 @@ function chatRoute({
|
|
|
1055
1050
|
const result = await agentObj.stream(messages, {
|
|
1056
1051
|
...defaultOptions,
|
|
1057
1052
|
...rest,
|
|
1058
|
-
|
|
1053
|
+
requestContext: requestContext || defaultOptions?.requestContext
|
|
1059
1054
|
});
|
|
1060
1055
|
const uiMessageStream = ai.createUIMessageStream({
|
|
1061
1056
|
originalMessages: messages,
|
|
@@ -1101,7 +1096,7 @@ function workflowRoute({
|
|
|
1101
1096
|
type: "object",
|
|
1102
1097
|
properties: {
|
|
1103
1098
|
inputData: { type: "object", additionalProperties: true },
|
|
1104
|
-
|
|
1099
|
+
requestContext: { type: "object", additionalProperties: true },
|
|
1105
1100
|
tracingOptions: { type: "object", additionalProperties: true }
|
|
1106
1101
|
}
|
|
1107
1102
|
}
|
|
@@ -1183,7 +1178,7 @@ function networkRoute({
|
|
|
1183
1178
|
type: "object",
|
|
1184
1179
|
properties: {
|
|
1185
1180
|
messages: { type: "array", items: { type: "object" } },
|
|
1186
|
-
|
|
1181
|
+
requestContext: { type: "object", additionalProperties: true },
|
|
1187
1182
|
runId: { type: "string" },
|
|
1188
1183
|
maxSteps: { type: "number" },
|
|
1189
1184
|
threadId: { type: "string" },
|