@mastra/playground-ui 6.2.0-alpha.3 → 6.2.0-alpha.5
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 +22 -0
- package/dist/index.cjs.js +116 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +116 -20
- package/dist/index.es.js.map +1 -1
- package/dist/src/domains/observability/components/trace-span-usage.d.ts +17 -7
- package/dist/src/hooks/use-workflows.d.ts +2 -2
- package/dist/src/index.d.ts +1 -0
- package/dist/src/lib/errors.d.ts +4 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @mastra/playground-ui
|
|
2
2
|
|
|
3
|
+
## 6.2.0-alpha.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix VNext generate/stream usage tokens. They used to be undefined, now we are receiving the proper values. ([#7901](https://github.com/mastra-ai/mastra/pull/7901))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`05c7abf`](https://github.com/mastra-ai/mastra/commit/05c7abfe105a015b7760c9bf33ff4419727502a0), [`aee4f00`](https://github.com/mastra-ai/mastra/commit/aee4f00e61e1a42e81a6d74ff149dbe69e32695a)]:
|
|
10
|
+
- @mastra/core@0.17.0-alpha.8
|
|
11
|
+
- @mastra/client-js@0.13.0-alpha.8
|
|
12
|
+
|
|
13
|
+
## 6.2.0-alpha.4
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Fixed createRun change in agent builder that was missed ([#7966](https://github.com/mastra-ai/mastra/pull/7966))
|
|
18
|
+
|
|
19
|
+
- fix error message when fetching observability things ([#7956](https://github.com/mastra-ai/mastra/pull/7956))
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`4f9ea8c`](https://github.com/mastra-ai/mastra/commit/4f9ea8c95ea74ba9abbf3b2ab6106c7d7bc45689)]:
|
|
22
|
+
- @mastra/core@0.17.0-alpha.7
|
|
23
|
+
- @mastra/client-js@0.13.0-alpha.7
|
|
24
|
+
|
|
3
25
|
## 6.2.0-alpha.3
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -17148,8 +17148,16 @@ const allowedAiSpanAttributes = [
|
|
|
17148
17148
|
"ai.response.text",
|
|
17149
17149
|
"ai.response.timestamp",
|
|
17150
17150
|
"componentName",
|
|
17151
|
+
// new format
|
|
17152
|
+
"ai.usage.inputTokens",
|
|
17153
|
+
"ai.usage.outputTokens",
|
|
17154
|
+
// Legacy format
|
|
17151
17155
|
"ai.usage.promptTokens",
|
|
17152
|
-
"ai.usage.completionTokens"
|
|
17156
|
+
"ai.usage.completionTokens",
|
|
17157
|
+
// Common fields
|
|
17158
|
+
"ai.usage.totalTokens",
|
|
17159
|
+
"ai.usage.reasoningTokens",
|
|
17160
|
+
"ai.usage.cachedInputTokens"
|
|
17153
17161
|
];
|
|
17154
17162
|
|
|
17155
17163
|
function SpanDetail() {
|
|
@@ -17695,6 +17703,9 @@ function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
|
|
|
17695
17703
|
return null;
|
|
17696
17704
|
}
|
|
17697
17705
|
const generationSpans = traceSpans.filter((span) => span.spanType === "llm_generation");
|
|
17706
|
+
const hasV5Format = generationSpans.some(
|
|
17707
|
+
(span) => span.attributes?.usage?.inputTokens !== void 0 || span.attributes?.usage?.outputTokens !== void 0
|
|
17708
|
+
);
|
|
17698
17709
|
const tokensByProvider = generationSpans.reduce(
|
|
17699
17710
|
(acc, span) => {
|
|
17700
17711
|
const spanUsage2 = span.attributes?.usage || {};
|
|
@@ -17702,33 +17713,65 @@ function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
|
|
|
17702
17713
|
const provider = span?.attributes?.provider || "";
|
|
17703
17714
|
const spanModelProvider = `${provider}${provider && model ? " / " : ""}${model}`;
|
|
17704
17715
|
if (!acc?.[spanModelProvider]) {
|
|
17705
|
-
|
|
17716
|
+
if (hasV5Format) {
|
|
17717
|
+
acc[spanModelProvider] = {
|
|
17718
|
+
inputTokens: 0,
|
|
17719
|
+
outputTokens: 0,
|
|
17720
|
+
totalTokens: 0,
|
|
17721
|
+
reasoningTokens: 0,
|
|
17722
|
+
cachedInputTokens: 0
|
|
17723
|
+
};
|
|
17724
|
+
} else {
|
|
17725
|
+
acc[spanModelProvider] = { promptTokens: 0, completionTokens: 0, totalTokens: 0 };
|
|
17726
|
+
}
|
|
17727
|
+
}
|
|
17728
|
+
if ("inputTokens" in acc[spanModelProvider] && hasV5Format) {
|
|
17729
|
+
const inputTokens = spanUsage2.inputTokens ?? 0;
|
|
17730
|
+
const outputTokens = spanUsage2.outputTokens ?? 0;
|
|
17731
|
+
const reasoningTokens = spanUsage2.reasoningTokens ?? 0;
|
|
17732
|
+
const cachedInputTokens = spanUsage2.cachedInputTokens ?? 0;
|
|
17733
|
+
const v5Acc = acc[spanModelProvider];
|
|
17734
|
+
v5Acc.inputTokens += inputTokens;
|
|
17735
|
+
v5Acc.outputTokens += outputTokens;
|
|
17736
|
+
v5Acc.reasoningTokens += reasoningTokens;
|
|
17737
|
+
v5Acc.cachedInputTokens += cachedInputTokens;
|
|
17738
|
+
v5Acc.totalTokens += spanUsage2.totalTokens || inputTokens + outputTokens;
|
|
17739
|
+
} else if ("promptTokens" in acc[spanModelProvider] && !hasV5Format) {
|
|
17740
|
+
const promptTokens = spanUsage2.promptTokens ?? 0;
|
|
17741
|
+
const completionTokens = spanUsage2.completionTokens ?? 0;
|
|
17742
|
+
const legacyAcc = acc[spanModelProvider];
|
|
17743
|
+
legacyAcc.promptTokens += promptTokens;
|
|
17744
|
+
legacyAcc.completionTokens += completionTokens;
|
|
17745
|
+
legacyAcc.totalTokens += spanUsage2.totalTokens || promptTokens + completionTokens;
|
|
17706
17746
|
}
|
|
17707
|
-
acc[spanModelProvider].promptTokens += spanUsage2.promptTokens || 0;
|
|
17708
|
-
acc[spanModelProvider].completionTokens += spanUsage2.completionTokens || 0;
|
|
17709
|
-
acc[spanModelProvider].totalTokens += (spanUsage2.promptTokens || 0) + (spanUsage2.completionTokens || 0);
|
|
17710
17747
|
return acc;
|
|
17711
17748
|
},
|
|
17712
17749
|
{}
|
|
17713
17750
|
);
|
|
17714
|
-
const traceTokensBasedOnSpans = Object.keys(
|
|
17715
|
-
tokensByProvider
|
|
17716
|
-
).reduce(
|
|
17751
|
+
const traceTokensBasedOnSpans = Object.keys(tokensByProvider).reduce(
|
|
17717
17752
|
(acc, provider) => {
|
|
17718
|
-
const
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17753
|
+
const providerUsage = tokensByProvider[provider];
|
|
17754
|
+
if (hasV5Format) {
|
|
17755
|
+
const v5Usage = providerUsage;
|
|
17756
|
+
const v5Acc = acc;
|
|
17757
|
+
v5Acc.inputTokens = (v5Acc.inputTokens || 0) + v5Usage.inputTokens;
|
|
17758
|
+
v5Acc.outputTokens = (v5Acc.outputTokens || 0) + v5Usage.outputTokens;
|
|
17759
|
+
v5Acc.reasoningTokens = (v5Acc.reasoningTokens || 0) + (v5Usage?.reasoningTokens ?? 0);
|
|
17760
|
+
v5Acc.cachedInputTokens = (v5Acc.cachedInputTokens || 0) + (v5Usage?.cachedInputTokens ?? 0);
|
|
17761
|
+
v5Acc.totalTokens = (v5Acc.totalTokens || 0) + v5Usage.totalTokens;
|
|
17762
|
+
} else {
|
|
17763
|
+
const legacyUsage = providerUsage;
|
|
17764
|
+
const legacyAcc = acc;
|
|
17765
|
+
legacyAcc.promptTokens = (legacyAcc.promptTokens || 0) + legacyUsage.promptTokens;
|
|
17766
|
+
legacyAcc.completionTokens = (legacyAcc.completionTokens || 0) + legacyUsage.completionTokens;
|
|
17767
|
+
legacyAcc.totalTokens = (legacyAcc.totalTokens || 0) + legacyUsage.totalTokens;
|
|
17768
|
+
}
|
|
17722
17769
|
return acc;
|
|
17723
17770
|
},
|
|
17724
|
-
{ promptTokens: 0, completionTokens: 0, totalTokens: 0 }
|
|
17771
|
+
hasV5Format ? { inputTokens: 0, outputTokens: 0, totalTokens: 0, reasoningTokens: 0, cachedInputTokens: 0 } : { promptTokens: 0, completionTokens: 0, totalTokens: 0 }
|
|
17725
17772
|
);
|
|
17726
17773
|
const tokensByProviderValid = JSON.stringify(traceUsage) === JSON.stringify(traceTokensBasedOnSpans);
|
|
17727
|
-
const
|
|
17728
|
-
totalTokens: {
|
|
17729
|
-
label: "Total LLM Tokens",
|
|
17730
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CoinsIcon, {})
|
|
17731
|
-
},
|
|
17774
|
+
const legacyTokenPresentations = {
|
|
17732
17775
|
promptTokens: {
|
|
17733
17776
|
label: "Prompt Tokens",
|
|
17734
17777
|
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRightIcon, {})
|
|
@@ -17738,7 +17781,42 @@ function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
|
|
|
17738
17781
|
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRightToLineIcon, {})
|
|
17739
17782
|
}
|
|
17740
17783
|
};
|
|
17741
|
-
const
|
|
17784
|
+
const v5TokenPresentations = {
|
|
17785
|
+
inputTokens: {
|
|
17786
|
+
label: "Input Tokens",
|
|
17787
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRightIcon, {})
|
|
17788
|
+
},
|
|
17789
|
+
outputTokens: {
|
|
17790
|
+
label: "Output Tokens",
|
|
17791
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRightToLineIcon, {})
|
|
17792
|
+
},
|
|
17793
|
+
reasoningTokens: {
|
|
17794
|
+
label: "Reasoning Tokens",
|
|
17795
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRightToLineIcon, {})
|
|
17796
|
+
},
|
|
17797
|
+
cachedInputTokens: {
|
|
17798
|
+
label: "Cached Input Tokens",
|
|
17799
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRightToLineIcon, {})
|
|
17800
|
+
}
|
|
17801
|
+
};
|
|
17802
|
+
const commonTokenPresentations = {
|
|
17803
|
+
totalTokens: {
|
|
17804
|
+
label: "Total LLM Tokens",
|
|
17805
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CoinsIcon, {})
|
|
17806
|
+
}
|
|
17807
|
+
};
|
|
17808
|
+
let tokenPresentations = {};
|
|
17809
|
+
if (hasV5Format) {
|
|
17810
|
+
tokenPresentations = { ...commonTokenPresentations, ...v5TokenPresentations };
|
|
17811
|
+
} else {
|
|
17812
|
+
tokenPresentations = { ...commonTokenPresentations, ...legacyTokenPresentations };
|
|
17813
|
+
}
|
|
17814
|
+
let usageKeyOrder = [];
|
|
17815
|
+
if (hasV5Format) {
|
|
17816
|
+
usageKeyOrder = ["totalTokens", "inputTokens", "outputTokens", "reasoningTokens", "cachedInputTokens"];
|
|
17817
|
+
} else {
|
|
17818
|
+
usageKeyOrder = ["totalTokens", "promptTokens", "completionTokens"];
|
|
17819
|
+
}
|
|
17742
17820
|
const usageAsArray = Object.entries(traceUsage || spanUsage || {}).map(([key, value]) => ({ key, value })).sort((a, b) => usageKeyOrder.indexOf(a.key) - usageKeyOrder.indexOf(b.key));
|
|
17743
17821
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
17744
17822
|
"div",
|
|
@@ -18708,6 +18786,24 @@ const MemorySearch = ({
|
|
|
18708
18786
|
] });
|
|
18709
18787
|
};
|
|
18710
18788
|
|
|
18789
|
+
const errorFallback = "Something went wrong while fetching the data.";
|
|
18790
|
+
const parseError = (error) => {
|
|
18791
|
+
try {
|
|
18792
|
+
const httpErrorPattern = /^HTTP error! status:\s*\d+\s*- \s*/;
|
|
18793
|
+
const errorMessage = error?.message.replace(httpErrorPattern, "");
|
|
18794
|
+
const jsonError = JSON.parse(errorMessage || "{}");
|
|
18795
|
+
return {
|
|
18796
|
+
error: jsonError?.error || errorFallback,
|
|
18797
|
+
stack: jsonError?.stack || error?.stack
|
|
18798
|
+
};
|
|
18799
|
+
} catch {
|
|
18800
|
+
return {
|
|
18801
|
+
error: error?.message || errorFallback,
|
|
18802
|
+
stack: void 0
|
|
18803
|
+
};
|
|
18804
|
+
}
|
|
18805
|
+
};
|
|
18806
|
+
|
|
18711
18807
|
exports.AgentChat = AgentChat;
|
|
18712
18808
|
exports.AgentCoinIcon = AgentCoinIcon;
|
|
18713
18809
|
exports.AgentEntityHeader = AgentEntityHeader;
|
|
@@ -18910,6 +19006,7 @@ exports.getColumnTemplate = getColumnTemplate;
|
|
|
18910
19006
|
exports.getShortId = getShortId;
|
|
18911
19007
|
exports.getSpanTypeUi = getSpanTypeUi;
|
|
18912
19008
|
exports.mapWorkflowStreamChunkToWatchResult = mapWorkflowStreamChunkToWatchResult;
|
|
19009
|
+
exports.parseError = parseError;
|
|
18913
19010
|
exports.providerMapToIcon = providerMapToIcon;
|
|
18914
19011
|
exports.spanTypePrefixes = spanTypePrefixes;
|
|
18915
19012
|
exports.transformKey = transformKey;
|