@mastra/playground-ui 5.1.2-alpha.4 → 5.1.2-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/dist/index.cjs.js CHANGED
@@ -6057,42 +6057,6 @@ function transformKey(key) {
6057
6057
  const newKey = key.split(".").join(" ").split("_").join(" ").replaceAll("ai", "AI");
6058
6058
  return newKey.substring(0, 1).toUpperCase() + newKey.substring(1);
6059
6059
  }
6060
- const refineTraces = (traces, isWorkflow = false) => {
6061
- const listOfSpanIds = /* @__PURE__ */ new Set();
6062
- const newName = (name) => {
6063
- if (name?.startsWith("workflow.") && isWorkflow) {
6064
- return name?.split(".")?.slice(2)?.join(".");
6065
- }
6066
- if (name?.startsWith("agent.") && !isWorkflow) {
6067
- return name?.split(".")?.slice(1)?.join(".");
6068
- }
6069
- return name;
6070
- };
6071
- const groupedTraces = traces?.reduce((acc, curr) => {
6072
- const newCurr = { ...curr, name: newName(curr.name), duration: curr.endTime - curr.startTime };
6073
- listOfSpanIds.add(curr.id);
6074
- return { ...acc, [curr.traceId]: [...acc[curr.traceId] || [], newCurr] };
6075
- }, {});
6076
- const tracesData = Object.entries(groupedTraces).map(([key, value]) => {
6077
- const parentSpan = value.find((span) => !span.parentSpanId || !listOfSpanIds.has(span.parentSpanId));
6078
- const enrichedSpans = value.map((span) => ({
6079
- ...span,
6080
- parentSpanId: parentSpan?.id === span.id ? null : span?.parentSpanId
6081
- }));
6082
- const failedStatus = value.find((span) => span.status.code !== 0)?.status;
6083
- const runId = value?.[0]?.attributes?.runId;
6084
- return {
6085
- traceId: key,
6086
- serviceName: parentSpan?.name || key,
6087
- duration: parentSpan?.duration || value.reduce((acc, curr) => acc + curr.duration, 0),
6088
- status: failedStatus || parentSpan?.status || value[0].status,
6089
- started: value[0].startTime,
6090
- trace: enrichedSpans,
6091
- runId: runId ? String(runId) : void 0
6092
- };
6093
- });
6094
- return tracesData;
6095
- };
6096
6060
 
6097
6061
  function SpanDetail() {
6098
6062
  const { span, setSpan, trace, setIsOpen } = React.useContext(TraceContext);
@@ -9826,7 +9790,7 @@ const DataTable = ({
9826
9790
  const rows = table.getRowModel().rows;
9827
9791
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
9828
9792
  /* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
9829
- /* @__PURE__ */ jsxRuntime.jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => {
9793
+ /* @__PURE__ */ jsxRuntime.jsx(Thead, { className: "sticky top-0 bg-surface2", children: ths.headers.map((header) => {
9830
9794
  const size = header.column.getSize();
9831
9795
  const meta = header.column.columnDef.meta;
9832
9796
  return /* @__PURE__ */ jsxRuntime.jsx(Th, { style: { width: meta?.width || size || "auto" }, children: header.isPlaceholder ? null : reactTable.flexRender(header.column.columnDef.header, header.getContext()) }, header.id);
@@ -10134,48 +10098,6 @@ function usePolling({
10134
10098
  };
10135
10099
  }
10136
10100
 
10137
- const useTraces = (componentName, isWorkflow = false) => {
10138
- const [traces, setTraces] = React.useState([]);
10139
- const client = React.useMemo(() => useMastraClient(), []);
10140
- const fetchFn = React.useCallback(async () => {
10141
- try {
10142
- const res = await client.getTelemetry({
10143
- attribute: {
10144
- componentName
10145
- }
10146
- });
10147
- if (!res.traces) {
10148
- throw new Error("Error fetching traces");
10149
- }
10150
- const refinedTraces = refineTraces(res?.traces || [], isWorkflow);
10151
- return refinedTraces;
10152
- } catch (error2) {
10153
- throw error2;
10154
- }
10155
- }, [client, componentName, isWorkflow]);
10156
- const onSuccess = React.useCallback((newTraces) => {
10157
- if (newTraces.length > 0) {
10158
- setTraces(() => newTraces);
10159
- }
10160
- }, []);
10161
- const onError = React.useCallback((error2) => {
10162
- console.log(`error, onError`, error2);
10163
- sonner.toast.error(error2.message);
10164
- }, []);
10165
- const shouldContinue = React.useCallback(() => {
10166
- return true;
10167
- }, []);
10168
- const { firstCallLoading, error } = usePolling({
10169
- fetchFn,
10170
- interval: 3e3,
10171
- onSuccess,
10172
- onError,
10173
- shouldContinue,
10174
- enabled: true
10175
- });
10176
- return { traces, firstCallLoading, error };
10177
- };
10178
-
10179
10101
  exports.AgentChat = AgentChat;
10180
10102
  exports.AgentCoinIcon = AgentCoinIcon;
10181
10103
  exports.AgentContext = AgentContext;
@@ -10270,11 +10192,9 @@ exports.WorkflowRunContext = WorkflowRunContext;
10270
10192
  exports.WorkflowRunProvider = WorkflowRunProvider;
10271
10193
  exports.WorkflowTraces = WorkflowTraces;
10272
10194
  exports.WorkflowTrigger = WorkflowTrigger;
10273
- exports.refineTraces = refineTraces;
10274
10195
  exports.useCurrentRun = useCurrentRun;
10275
10196
  exports.useMastraClient = useMastraClient;
10276
10197
  exports.usePlaygroundStore = usePlaygroundStore;
10277
10198
  exports.usePolling = usePolling;
10278
10199
  exports.useSpeechRecognition = useSpeechRecognition;
10279
- exports.useTraces = useTraces;
10280
10200
  //# sourceMappingURL=index.cjs.js.map