@mastra/playground-ui 5.0.1-alpha.1 → 5.0.1-alpha.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/dist/index.cjs.js CHANGED
@@ -3148,7 +3148,7 @@ const Icon = ({ children, className, size = "default", ...props }) => {
3148
3148
  return /* @__PURE__ */ jsxRuntime.jsx("span", { className: clsx("block", sizes[size], className), ...props, children });
3149
3149
  };
3150
3150
 
3151
- const variantClasses$1 = {
3151
+ const variantClasses$2 = {
3152
3152
  default: "text-icon3",
3153
3153
  success: "text-accent1",
3154
3154
  error: "text-accent2",
@@ -3161,12 +3161,12 @@ const Badge$1 = ({ icon, variant = "default", className, children, ...props }) =
3161
3161
  className: clsx(
3162
3162
  "bg-surface4 text-ui-sm gap-md h-badge-default inline-flex items-center rounded-md",
3163
3163
  icon ? "pl-md pr-1.5" : "px-1.5",
3164
- icon || variant === "default" ? "text-icon5" : variantClasses$1[variant],
3164
+ icon || variant === "default" ? "text-icon5" : variantClasses$2[variant],
3165
3165
  className
3166
3166
  ),
3167
3167
  ...props,
3168
3168
  children: [
3169
- icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: variantClasses$1[variant], children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: icon }) }),
3169
+ icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: variantClasses$2[variant], children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: icon }) }),
3170
3170
  children
3171
3171
  ]
3172
3172
  }
@@ -3789,6 +3789,30 @@ const WorkflowCoinIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { wid
3789
3789
  )
3790
3790
  ] });
3791
3791
 
3792
+ const LatencyIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
3793
+ /* @__PURE__ */ jsxRuntime.jsx(
3794
+ "path",
3795
+ {
3796
+ d: "M2.0625 5.99976C2.0625 3.82513 3.82538 2.06226 6 2.06226C6.58712 2.06226 7.14423 2.19076 7.64473 2.42117V1.21042C7.12905 1.03337 6.57575 0.937256 6 0.937256C3.20406 0.937256 0.9375 3.20381 0.9375 5.99976C0.9375 8.7957 3.20406 11.0623 6 11.0623C8.79594 11.0623 11.0625 8.7957 11.0625 5.99976H9.9375C9.9375 8.17438 8.17462 9.93726 6 9.93726C3.82538 9.93726 2.0625 8.17438 2.0625 5.99976Z",
3797
+ fill: "currentColor"
3798
+ }
3799
+ ),
3800
+ /* @__PURE__ */ jsxRuntime.jsx(
3801
+ "path",
3802
+ {
3803
+ d: "M9.28577 4.3986C9.08709 4.3986 8.92603 4.23753 8.92603 4.03885V0.978563C8.92603 0.681899 9.16652 0.441406 9.46318 0.441406C9.75985 0.441406 10.0003 0.6819 10.0003 0.978564V3.25858C10.0003 3.33638 10.0634 3.39944 10.1412 3.39944H11.2091C11.485 3.39944 11.7087 3.62311 11.7087 3.89902C11.7087 4.17493 11.485 4.3986 11.2091 4.3986H9.28577Z",
3804
+ fill: "currentColor"
3805
+ }
3806
+ ),
3807
+ /* @__PURE__ */ jsxRuntime.jsx(
3808
+ "path",
3809
+ {
3810
+ d: "M6.57568 3.69244C6.57568 3.38178 6.32384 3.12994 6.01318 3.12994C5.70252 3.12994 5.45068 3.38178 5.45068 3.69244V6.22272L6.7242 7.88675C6.91301 8.13346 7.26606 8.18039 7.51276 7.99159C7.75946 7.80278 7.8064 7.44973 7.61759 7.20303L6.57568 5.84162V3.69244Z",
3811
+ fill: "currentColor"
3812
+ }
3813
+ )
3814
+ ] });
3815
+
3792
3816
  const useCodemirrorTheme$1 = () => {
3793
3817
  return React.useMemo(
3794
3818
  () => codemirrorThemeDracula.draculaInit({
@@ -3930,31 +3954,23 @@ const Thread = ({ ToolFallback }) => {
3930
3954
  const WrappedAssistantMessage = (props) => {
3931
3955
  return /* @__PURE__ */ jsxRuntime.jsx(AssistantMessage, { ...props, ToolFallback });
3932
3956
  };
3933
- return /* @__PURE__ */ jsxRuntime.jsxs(react.ThreadPrimitive.Root, { className: "max-w-[568px] w-full mx-auto h-[calc(100%-100px)]", children: [
3934
- /* @__PURE__ */ jsxRuntime.jsxs(
3935
- react.ThreadPrimitive.Viewport,
3936
- {
3937
- className: "py-10 overflow-y-auto scroll-smooth h-full px-4",
3938
- ref: areaRef,
3939
- autoScroll: false,
3940
- children: [
3941
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3942
- /* @__PURE__ */ jsxRuntime.jsx(ThreadWelcome, {}),
3943
- /* @__PURE__ */ jsxRuntime.jsx(
3944
- react.ThreadPrimitive.Messages,
3945
- {
3946
- components: {
3947
- UserMessage,
3948
- EditComposer,
3949
- AssistantMessage: WrappedAssistantMessage
3950
- }
3951
- }
3952
- )
3953
- ] }),
3954
- /* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { empty: false, children: /* @__PURE__ */ jsxRuntime.jsx("div", {}) })
3955
- ]
3956
- }
3957
- ),
3957
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.ThreadPrimitive.Root, { className: "max-w-[568px] w-full mx-auto h-[calc(100%-100px)] px-4", children: [
3958
+ /* @__PURE__ */ jsxRuntime.jsxs(react.ThreadPrimitive.Viewport, { className: "py-10 overflow-y-auto scroll-smooth h-full", ref: areaRef, autoScroll: false, children: [
3959
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3960
+ /* @__PURE__ */ jsxRuntime.jsx(ThreadWelcome, {}),
3961
+ /* @__PURE__ */ jsxRuntime.jsx(
3962
+ react.ThreadPrimitive.Messages,
3963
+ {
3964
+ components: {
3965
+ UserMessage,
3966
+ EditComposer,
3967
+ AssistantMessage: WrappedAssistantMessage
3968
+ }
3969
+ }
3970
+ )
3971
+ ] }),
3972
+ /* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { empty: false, children: /* @__PURE__ */ jsxRuntime.jsx("div", {}) })
3973
+ ] }),
3958
3974
  /* @__PURE__ */ jsxRuntime.jsx(Composer, {})
3959
3975
  ] });
3960
3976
  };
@@ -4006,6 +4022,14 @@ const CircleStopIcon = () => {
4006
4022
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
4007
4023
  };
4008
4024
 
4025
+ const createMastraClient = (baseUrl) => {
4026
+ return new clientJs.MastraClient({
4027
+ baseUrl: baseUrl || "",
4028
+ // only add the header if the baseUrl is not provided i.e it's a local dev environment
4029
+ headers: !baseUrl ? { "x-mastra-dev-playground": "true" } : {}
4030
+ });
4031
+ };
4032
+
4009
4033
  const convertMessage$1 = (message) => {
4010
4034
  return message;
4011
4035
  };
@@ -4049,9 +4073,7 @@ function MastraRuntimeProvider({
4049
4073
  }
4050
4074
  }
4051
4075
  }, [initialMessages, threadId, memory]);
4052
- const mastra = new clientJs.MastraClient({
4053
- baseUrl: baseUrl || ""
4054
- });
4076
+ const mastra = createMastraClient(baseUrl);
4055
4077
  const agent = mastra.getAgent(agentId);
4056
4078
  const onNew = async (message) => {
4057
4079
  if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
@@ -4295,7 +4317,7 @@ function MastraRuntimeProvider({
4295
4317
  ] });
4296
4318
  }
4297
4319
 
4298
- const defaultModelSettings = {
4320
+ const defaultModelSettings$1 = {
4299
4321
  maxRetries: 2,
4300
4322
  maxSteps: 5,
4301
4323
  temperature: 0.5,
@@ -4303,10 +4325,10 @@ const defaultModelSettings = {
4303
4325
  };
4304
4326
  const AgentContext = React.createContext({});
4305
4327
  function AgentProvider({ children }) {
4306
- const [modelSettings, setModelSettings] = React.useState(defaultModelSettings);
4328
+ const [modelSettings, setModelSettings] = React.useState(defaultModelSettings$1);
4307
4329
  const [chatWithGenerate, setChatWithGenerate] = React.useState(false);
4308
4330
  const resetModelSettings = () => {
4309
- setModelSettings(defaultModelSettings);
4331
+ setModelSettings(defaultModelSettings$1);
4310
4332
  };
4311
4333
  return /* @__PURE__ */ jsxRuntime.jsx(
4312
4334
  AgentContext.Provider,
@@ -4523,9 +4545,7 @@ TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
4523
4545
  const useEvalsByAgentId = (agentId, type, baseUrl) => {
4524
4546
  const [evals, setEvals] = React.useState([]);
4525
4547
  const [isLoading, setIsLoading] = React.useState(true);
4526
- const client = new clientJs.MastraClient({
4527
- baseUrl: baseUrl || ""
4528
- });
4548
+ const client = createMastraClient(baseUrl);
4529
4549
  const fetchEvals = async (_agentId) => {
4530
4550
  setIsLoading(true);
4531
4551
  const activeAgentId = _agentId ?? agentId;
@@ -4804,7 +4824,6 @@ function TraceProvider({ children }) {
4804
4824
  const [traces, setTraces] = React.useState([]);
4805
4825
  const [currentTraceIndex, setCurrentTraceIndex] = React.useState(0);
4806
4826
  const [span, setSpan] = React.useState(null);
4807
- const [openDetail, setOpenDetail] = React.useState(false);
4808
4827
  const nextTrace = () => {
4809
4828
  if (currentTraceIndex < traces.length - 1) {
4810
4829
  const nextIndex = currentTraceIndex + 1;
@@ -4829,7 +4848,6 @@ function TraceProvider({ children }) {
4829
4848
  setOpen(false);
4830
4849
  setTrace(null);
4831
4850
  setSpan(null);
4832
- setOpenDetail(false);
4833
4851
  };
4834
4852
  return /* @__PURE__ */ jsxRuntime.jsx(
4835
4853
  TraceContext.Provider,
@@ -4847,8 +4865,6 @@ function TraceProvider({ children }) {
4847
4865
  prevTrace,
4848
4866
  span,
4849
4867
  setSpan,
4850
- openDetail,
4851
- setOpenDetail,
4852
4868
  clearData
4853
4869
  },
4854
4870
  children
@@ -4998,10 +5014,8 @@ function transformKey(key) {
4998
5014
  if (key.includes(".result")) {
4999
5015
  return "Output";
5000
5016
  }
5001
- return key.split(".").join(" ").split("_");
5002
- }
5003
- function cleanString(string) {
5004
- return string.replace(/\\n/g, "").replace(/\n/g, "").replace(/\s+/g, " ").trim();
5017
+ const newKey = key.split(".").join(" ").split("_").join(" ").replaceAll("ai", "AI");
5018
+ return newKey.substring(0, 1).toUpperCase() + newKey.substring(1);
5005
5019
  }
5006
5020
  const refineTraces = (traces, isWorkflow = false) => {
5007
5021
  const listOfSpanIds = /* @__PURE__ */ new Set();
@@ -5038,35 +5052,11 @@ const refineTraces = (traces, isWorkflow = false) => {
5038
5052
  });
5039
5053
  return tracesData;
5040
5054
  };
5041
- const allowedAiSpanAttributes = [
5042
- "operation.name",
5043
- "ai.operationId",
5044
- "ai.model.provider",
5045
- "ai.model.id",
5046
- "ai.prompt.format",
5047
- "ai.prompt.messages",
5048
- "ai.prompt.tools",
5049
- "ai.prompt.toolChoice",
5050
- "ai.settings.toolChoice",
5051
- "ai.schema",
5052
- "ai.settings.output",
5053
- "ai.response.object",
5054
- "ai.response.text",
5055
- "ai.response.timestamp",
5056
- "componentName",
5057
- "ai.usage.promptTokens",
5058
- "ai.usage.completionTokens"
5059
- ];
5060
5055
 
5061
5056
  const useTraces = (componentName, baseUrl, isWorkflow = false) => {
5062
5057
  const [traces, setTraces] = React.useState([]);
5063
5058
  const { setTraces: setTraceContextTraces } = React.useContext(TraceContext);
5064
- const client = React.useMemo(
5065
- () => new clientJs.MastraClient({
5066
- baseUrl: baseUrl || ""
5067
- }),
5068
- [baseUrl]
5069
- );
5059
+ const client = React.useMemo(() => createMastraClient(baseUrl), [baseUrl]);
5070
5060
  const fetchFn = React.useCallback(async () => {
5071
5061
  try {
5072
5062
  const res = await client.getTelemetry({
@@ -5123,7 +5113,10 @@ const Th = ({ className, children, ...props }) => {
5123
5113
  return /* @__PURE__ */ jsxRuntime.jsx(
5124
5114
  "th",
5125
5115
  {
5126
- className: clsx("text-icon3 text-ui-sm h-full text-left font-normal uppercase first:pl-5 last:pr-5", className),
5116
+ className: clsx(
5117
+ "text-icon3 text-ui-sm h-full text-left font-normal uppercase first:pl-5 last:pr-5 whitespace-nowrap",
5118
+ className
5119
+ ),
5127
5120
  ...props,
5128
5121
  children
5129
5122
  }
@@ -5202,7 +5195,6 @@ const useOpenTrace = () => {
5202
5195
  setIsOpen: setOpen,
5203
5196
  trace: currentTrace,
5204
5197
  setSpan,
5205
- setOpenDetail,
5206
5198
  setCurrentTraceIndex
5207
5199
  } = React.useContext(TraceContext);
5208
5200
  const openTrace = (trace, traceIndex) => {
@@ -5212,7 +5204,6 @@ const useOpenTrace = () => {
5212
5204
  setCurrentTraceIndex(traceIndex);
5213
5205
  if (open && currentTrace?.[0]?.id !== trace[0].id) return;
5214
5206
  setOpen((prev) => !prev);
5215
- setOpenDetail((prev) => !prev);
5216
5207
  };
5217
5208
  return { openTrace };
5218
5209
  };
@@ -5226,12 +5217,12 @@ const TracesTableEmpty = ({ colsCount }) => {
5226
5217
  const TracesTableError = ({ error, colsCount }) => {
5227
5218
  return /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: /* @__PURE__ */ jsxRuntime.jsx(Row, { children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { colSpan: colsCount, className: "text-center py-4", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { children: error.message }) }) }) });
5228
5219
  };
5229
- const TraceRow = ({ trace, index }) => {
5220
+ const TraceRow = ({ trace, index, isActive }) => {
5230
5221
  const { openTrace } = useOpenTrace();
5231
- return /* @__PURE__ */ jsxRuntime.jsxs(Row, { children: [
5222
+ return /* @__PURE__ */ jsxRuntime.jsxs(Row, { className: isActive ? "bg-surface4" : "", children: [
5232
5223
  /* @__PURE__ */ jsxRuntime.jsx(DateTimeCell, { dateTime: new Date(trace.started / 1e3) }),
5233
5224
  /* @__PURE__ */ jsxRuntime.jsx(TxtCell, { children: trace.traceId }),
5234
- /* @__PURE__ */ jsxRuntime.jsx(UnitCell, { unit: "ms", children: trace.duration }),
5225
+ /* @__PURE__ */ jsxRuntime.jsx(UnitCell, { unit: "ms", children: trace.duration / 1e3 }),
5235
5226
  /* @__PURE__ */ jsxRuntime.jsx(Cell, { children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => openTrace(trace.trace, index), children: /* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(TraceIcon, {}), children: [
5236
5227
  trace.trace.length,
5237
5228
  " span",
@@ -5241,6 +5232,7 @@ const TraceRow = ({ trace, index }) => {
5241
5232
  };
5242
5233
  const TracesTable = ({ traces, isLoading, error }) => {
5243
5234
  const hasNoTraces = !traces || traces.length === 0;
5235
+ const { currentTraceIndex } = React.useContext(TraceContext);
5244
5236
  const colsCount = 4;
5245
5237
  return /* @__PURE__ */ jsxRuntime.jsxs(Table, { size: "small", children: [
5246
5238
  /* @__PURE__ */ jsxRuntime.jsxs(Thead, { children: [
@@ -5249,7 +5241,7 @@ const TracesTable = ({ traces, isLoading, error }) => {
5249
5241
  /* @__PURE__ */ jsxRuntime.jsx(Th, { width: 160, children: "Duration" }),
5250
5242
  /* @__PURE__ */ jsxRuntime.jsx(Th, { width: 160, children: "Spans" })
5251
5243
  ] }),
5252
- isLoading ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableSkeleton, { colsCount }) : error ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableError, { error, colsCount }) : hasNoTraces ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableEmpty, { colsCount }) : /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: traces.map((trace, index) => /* @__PURE__ */ jsxRuntime.jsx(TraceRow, { trace, index }, trace.traceId)) })
5244
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableSkeleton, { colsCount }) : error ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableError, { error, colsCount }) : hasNoTraces ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableEmpty, { colsCount }) : /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: traces.map((trace, index) => /* @__PURE__ */ jsxRuntime.jsx(TraceRow, { trace, index, isActive: index === currentTraceIndex }, trace.traceId)) })
5253
5245
  ] });
5254
5246
  };
5255
5247
 
@@ -5319,8 +5311,8 @@ const MastraResizablePanel = ({
5319
5311
  !disabled && dividerPosition === "left" ? /* @__PURE__ */ jsxRuntime.jsx(
5320
5312
  "div",
5321
5313
  {
5322
- className: `w-1 bg-mastra-bg-1 bg-[#121212] h-full cursor-col-resize hover:w-1.5 hover:bg-mastra-border-2 hover:bg-[#424242] active:bg-mastra-border-3 active:bg-[#3e3e3e] transition-colors absolute inset-y-0 -left-1 -right-1 z-10
5323
- ${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
5314
+ className: `w-px bg-border1 h-full cursor-col-resize hover:w-1.5 hover:bg-mastra-border-2 hover:bg-[#424242] active:bg-mastra-border-3 active:bg-[#3e3e3e] transition-colors absolute inset-y-0 z-10
5315
+ ${isDragging ? "bg-border2 w-1.5 cursor- col-resize" : ""}`,
5324
5316
  onMouseDown: handleMouseDown
5325
5317
  }
5326
5318
  ) : null,
@@ -5328,183 +5320,257 @@ const MastraResizablePanel = ({
5328
5320
  !disabled && dividerPosition === "right" ? /* @__PURE__ */ jsxRuntime.jsx(
5329
5321
  "div",
5330
5322
  {
5331
- className: `w-1 bg-mastra-bg-1 bg-[#121212] h-full cursor-col-resize hover:w-1.5 hover:bg-mastra-border-2 hover:bg-[#424242] active:bg-mastra-border-3 active:bg-[#3e3e3e] transition-colors absolute inset-y-0 -left-1 -right-1 z-10
5332
- ${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
5323
+ className: `w-px bg-border1 h-full cursor-col-resize hover:w-1.5 hover:bg-border2 active:bg-border3 transition-colors absolute inset-y-0 z-10
5324
+ ${isDragging ? "bg-border2 w-1.5 cursor- col-resize" : ""}`,
5333
5325
  onMouseDown: handleMouseDown
5334
5326
  }
5335
5327
  ) : null
5336
5328
  ] });
5337
5329
  };
5338
5330
 
5339
- function TreeNode({ node, depth = 0 }) {
5340
- const [isExpanded, setIsExpanded] = React.useState(true);
5341
- const hasChildren = node.children && node.children.length > 0;
5342
- const { setOpenDetail, setSpan, openDetail, span } = React.useContext(TraceContext);
5343
- const containerRef = React.useRef(null);
5344
- const widthPercentage = Math.min(node.relativePercentage ? node?.relativePercentage * 100 : 0, 100);
5345
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, children: [
5346
- /* @__PURE__ */ jsxRuntime.jsxs(
5347
- Button$1,
5348
- {
5349
- variant: "ghost",
5350
- className: cn("relative flex w-full items-center justify-start gap-2 py-3 pr-1 text-sm", {
5351
- "text-accent-foreground bg-accent": span?.id === node.id
5352
- }),
5353
- onClick: (e) => {
5354
- e.preventDefault();
5355
- e.stopPropagation();
5356
- setSpan(node);
5357
- if (openDetail && node.id !== span?.id) return;
5358
- setOpenDetail(true);
5359
- },
5360
- style: { paddingLeft: `${depth > 0 ? depth * 35 + 28 - depth * 3 : 24}px` },
5361
- children: [
5362
- hasChildren ? /* @__PURE__ */ jsxRuntime.jsx(
5363
- "div",
5364
- {
5365
- onClick: () => setIsExpanded(!isExpanded),
5366
- className: "relative grid h-auto flex-shrink-0 place-items-center rounded-sm bg-mastra-bg-3 p-2",
5367
- children: /* @__PURE__ */ jsxRuntime.jsx(
5368
- "svg",
5369
- {
5370
- className: cn("!h-2 !w-2 transition-transform", isExpanded ? "" : "-rotate-90"),
5371
- xmlns: "http://www.w3.org/2000/svg",
5372
- width: "7",
5373
- height: "6",
5374
- viewBox: "0 0 7 6",
5375
- fill: "none",
5376
- children: /* @__PURE__ */ jsxRuntime.jsx(
5377
- "path",
5378
- {
5379
- d: "M3.9338 5.5C3.74135 5.83333 3.26022 5.83333 3.06777 5.5L0.469694 0.999999C0.277244 0.666666 0.517814 0.25 0.902714 0.25L6.09886 0.25C6.48376 0.25 6.72433 0.666666 6.53188 1L3.9338 5.5Z",
5380
- fill: "#939393"
5381
- }
5382
- )
5383
- }
5384
- )
5385
- }
5386
- ) : null,
5387
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full gap-4 pr-4", children: [
5388
- /* @__PURE__ */ jsxRuntime.jsx(
5389
- "p",
5390
- {
5391
- className: cn("max-w-[250px] text-sm", {
5392
- "text-white": node?.status?.code === 0,
5393
- "text-[#FF4500]": node?.status?.code !== 0,
5394
- "px-1": depth === 0,
5395
- truncate: containerRef.current?.offsetWidth && containerRef.current?.offsetWidth < 450 && depth > 1 && node.name?.length > 16
5396
- }),
5397
- children: node.name
5398
- }
5399
- ),
5400
- node.duration > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full", children: [
5401
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute top-[11px] h-px w-full bg-[hsl(220,14%,19%)]" }),
5402
- /* @__PURE__ */ jsxRuntime.jsx(
5403
- "div",
5404
- {
5405
- style: {
5406
- width: `${widthPercentage}%`,
5407
- left: 0
5408
- },
5409
- className: cn(
5410
- "absolute top-[9px] z-0 h-[5px] rounded-[5px] bg-white transition-all",
5411
- node.name.includes("agent") && "left-1/2 bg-green-500",
5412
- node.name.includes("llm") && "bg-[#5699A8]",
5413
- node.name.includes("ai") && "left-2/4 w-5 bg-[#F09A56]"
5414
- )
5415
- }
5416
- ),
5417
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "absolute left-0 top-3 text-[0.63rem] text-mastra-el-3", children: [
5418
- formatDuration(node.duration),
5419
- "ms"
5420
- ] })
5421
- ] })
5422
- ] })
5423
- ]
5424
- }
5425
- ),
5426
- hasChildren && isExpanded && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: node.children.map((child) => /* @__PURE__ */ jsxRuntime.jsx(TreeNode, { node: child, depth: depth + 1 }, child.id)) })
5331
+ const sizeClasses = {
5332
+ md: "h-button-md gap-md",
5333
+ lg: "h-button-lg gap-lg"
5334
+ };
5335
+ const variantClasses$1 = {
5336
+ default: "bg-surface2 hover:bg-surface4 text-icon3 hover:text-icon6",
5337
+ light: "bg-surface3 hover:bg-surface5 text-icon6"
5338
+ };
5339
+ const Button = ({ className, as, size = "md", variant = "default", ...props }) => {
5340
+ const Component = as || "button";
5341
+ return /* @__PURE__ */ jsxRuntime.jsx(
5342
+ Component,
5343
+ {
5344
+ className: clsx(
5345
+ "bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
5346
+ variantClasses$1[variant],
5347
+ sizeClasses[size],
5348
+ className
5349
+ ),
5350
+ ...props
5351
+ }
5352
+ );
5353
+ };
5354
+
5355
+ const TraceTree = ({ children }) => {
5356
+ return /* @__PURE__ */ jsxRuntime.jsx("ol", { children });
5357
+ };
5358
+
5359
+ const variantClasses = {
5360
+ agent: "bg-accent1"
5361
+ };
5362
+ const Time = ({ durationMs, tokenCount, variant, progressPercent }) => {
5363
+ const variantClass = variant ? variantClasses[variant] : "bg-accent3";
5364
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[166px] shrink-0", children: [
5365
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface4 relative h-[6px] w-full rounded-full p-px overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx("absolute h-1 rounded-full", variantClass), style: { width: `${progressPercent}%` } }) }),
5366
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 pt-0.5", children: [
5367
+ /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon2 font-medium", children: [
5368
+ durationMs,
5369
+ "ms"
5370
+ ] }),
5371
+ tokenCount && /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon2 font-medium", children: [
5372
+ tokenCount,
5373
+ "t"
5374
+ ] })
5375
+ ] })
5427
5376
  ] });
5428
- }
5377
+ };
5378
+
5379
+ const TraceDurationContext = React.createContext(0);
5380
+ const useTraceDuration = () => {
5381
+ return React.useContext(TraceDurationContext);
5382
+ };
5383
+ const TraceDurationProvider = ({ children, durationMs }) => {
5384
+ return /* @__PURE__ */ jsxRuntime.jsx(TraceDurationContext.Provider, { value: durationMs, children });
5385
+ };
5386
+
5387
+ const spanIconMap = {
5388
+ tool: ToolsIcon,
5389
+ agent: AgentIcon,
5390
+ workflow: WorkflowIcon,
5391
+ memory: MemoryIcon,
5392
+ rag: TraceIcon,
5393
+ storage: DbIcon,
5394
+ eval: ScoreIcon,
5395
+ other: TraceIcon
5396
+ };
5397
+ const spanVariantClasses = {
5398
+ tool: "text-[#ECB047]",
5399
+ agent: "text-accent1",
5400
+ workflow: "text-accent3",
5401
+ memory: "text-accent2",
5402
+ rag: "text-accent2",
5403
+ storage: "text-accent2",
5404
+ eval: "text-accent4",
5405
+ other: "text-icon6"
5406
+ };
5407
+ const Span = ({ children, durationMs, variant, tokenCount, spans, isRoot, onClick, isActive }) => {
5408
+ const [isExpanded, setIsExpanded] = React.useState(true);
5409
+ const traceDuration = useTraceDuration();
5410
+ const VariantIcon = spanIconMap[variant];
5411
+ const variantClass = spanVariantClasses[variant];
5412
+ const progressPercent = durationMs / traceDuration * 100;
5413
+ const TextEl = onClick ? "button" : "div";
5414
+ return /* @__PURE__ */ jsxRuntime.jsx(TraceDurationProvider, { durationMs, children: /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
5415
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx("flex justify-between items-center gap-2 rounded-md pl-2", isActive && "bg-surface4"), children: [
5416
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-8 items-center gap-1 min-w-0", children: [
5417
+ spans ? /* @__PURE__ */ jsxRuntime.jsx(
5418
+ "button",
5419
+ {
5420
+ type: "button",
5421
+ "aria-label": isExpanded ? "Collapse span" : "Expand span",
5422
+ "aria-expanded": isExpanded,
5423
+ className: "text-icon3 flex h-4 w-4",
5424
+ onClick: () => setIsExpanded(!isExpanded),
5425
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(ChevronIcon, { className: clsx("transition-transform -rotate-90", { "rotate-0": isExpanded }) }) })
5426
+ }
5427
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": true, className: "h-full w-4", children: !isRoot && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-[7px] h-full w-px rounded-full" }) }),
5428
+ /* @__PURE__ */ jsxRuntime.jsxs(TextEl, { className: "flex items-center gap-2 min-w-0", onClick, children: [
5429
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx("bg-surface4 flex items-center justify-center rounded-md p-[3px]", variantClass), children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(VariantIcon, {}) }) }),
5430
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-md", className: "text-icon6 truncate", children })
5431
+ ] })
5432
+ ] }),
5433
+ /* @__PURE__ */ jsxRuntime.jsx(
5434
+ Time,
5435
+ {
5436
+ durationMs,
5437
+ tokenCount,
5438
+ variant: variant === "agent" ? "agent" : void 0,
5439
+ progressPercent
5440
+ }
5441
+ )
5442
+ ] }),
5443
+ isExpanded && spans && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-4", children: spans })
5444
+ ] }) });
5445
+ };
5446
+
5447
+ const Spans = ({ children }) => {
5448
+ return /* @__PURE__ */ jsxRuntime.jsx("ol", { children });
5449
+ };
5450
+
5451
+ const Trace = ({ name, spans, durationMs, tokenCount, onClick, variant, isActive }) => {
5452
+ return /* @__PURE__ */ jsxRuntime.jsx(TraceDurationProvider, { durationMs, children: /* @__PURE__ */ jsxRuntime.jsx(
5453
+ Span,
5454
+ {
5455
+ isRoot: true,
5456
+ durationMs,
5457
+ variant,
5458
+ spans: /* @__PURE__ */ jsxRuntime.jsx(Spans, { children: spans }),
5459
+ onClick,
5460
+ isActive,
5461
+ children: name
5462
+ }
5463
+ ) });
5464
+ };
5465
+
5466
+ const getSpanVariant = (span) => {
5467
+ const attributes = Object.keys(span.attributes || {}).map((k) => k.toLowerCase());
5468
+ const lowerCaseName = span.name.toLowerCase();
5469
+ const isAiSpan = lowerCaseName.startsWith("ai.");
5470
+ if (isAiSpan) {
5471
+ const isAiAboutTool = lowerCaseName.includes("tool");
5472
+ if (isAiAboutTool) return "tool";
5473
+ return "other";
5474
+ }
5475
+ const hasMemoryRelatedAttributes = attributes.some((key) => key.includes("memory") || key.includes("storage"));
5476
+ if (hasMemoryRelatedAttributes) return "memory";
5477
+ const hasToolRelatedAttributes = attributes.some((key) => key.includes("tool"));
5478
+ if (hasToolRelatedAttributes) return "tool";
5479
+ const hasAgentRelatedAttributes = attributes.some((key) => key.includes("agent."));
5480
+ if (hasAgentRelatedAttributes) return "agent";
5481
+ if (lowerCaseName.includes(".insert")) {
5482
+ const evalRelatedAttribute = attributes.find((key) => String(span.attributes?.[key])?.includes("mastra_evals"));
5483
+ if (evalRelatedAttribute) return "eval";
5484
+ }
5485
+ return "other";
5486
+ };
5429
5487
 
5430
- function TreeView({ tree }) {
5431
- return /* @__PURE__ */ jsxRuntime.jsx("ul", { children: tree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(TreeNode, { node }, node.id)) });
5432
- }
5433
5488
  function buildTree(items, parentSpanId = null) {
5434
5489
  return items.filter((item) => item.parentSpanId === parentSpanId).map((item) => ({
5435
5490
  ...item,
5436
5491
  children: buildTree(items, item.id)
5437
5492
  }));
5438
5493
  }
5494
+ const NestedSpans = ({ spans }) => {
5495
+ const { span: activeSpan, setSpan } = React.useContext(TraceContext);
5496
+ return /* @__PURE__ */ jsxRuntime.jsx(Spans, { children: spans.map((span) => {
5497
+ const isActive = span.id === activeSpan?.id;
5498
+ return /* @__PURE__ */ jsxRuntime.jsx(
5499
+ Span,
5500
+ {
5501
+ spans: span.children.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(NestedSpans, { spans: span.children }),
5502
+ durationMs: span.duration / 1e3,
5503
+ variant: getSpanVariant(span),
5504
+ isActive,
5505
+ onClick: () => setSpan(span),
5506
+ children: span.name
5507
+ },
5508
+ span.id
5509
+ );
5510
+ }) });
5511
+ };
5439
5512
  function SpanView({ trace }) {
5440
- const tree = buildTree(trace.concat([]).reverse());
5441
- return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(TreeView, { tree }) });
5513
+ const shallowCopy = [...trace];
5514
+ const tree = buildTree(shallowCopy.reverse());
5515
+ const { span: activeSpan, setSpan } = React.useContext(TraceContext);
5516
+ return /* @__PURE__ */ jsxRuntime.jsx(TraceTree, { children: tree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
5517
+ Trace,
5518
+ {
5519
+ name: node.name,
5520
+ durationMs: node.duration / 1e3,
5521
+ spans: /* @__PURE__ */ jsxRuntime.jsx(NestedSpans, { spans: node.children }),
5522
+ variant: getSpanVariant(node),
5523
+ isActive: node.id === activeSpan?.id,
5524
+ onClick: () => setSpan(node)
5525
+ }
5526
+ )) });
5442
5527
  }
5443
5528
 
5529
+ const Header = ({ children, border = true }) => {
5530
+ return /* @__PURE__ */ jsxRuntime.jsx(
5531
+ "header",
5532
+ {
5533
+ className: clsx("h-header-default z-50 flex w-full items-center gap-[18px] bg-transparent px-5", {
5534
+ "border-b-sm border-border1": border
5535
+ }),
5536
+ children
5537
+ }
5538
+ );
5539
+ };
5540
+ const HeaderTitle = ({ children }) => {
5541
+ return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "h1", variant: "ui-lg", className: "font-medium text-white", children });
5542
+ };
5543
+ const HeaderAction = ({ children }) => {
5544
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto", children });
5545
+ };
5546
+ const HeaderGroup = ({ children }) => {
5547
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gap-lg flex items-center", children });
5548
+ };
5549
+
5444
5550
  function TraceDetails() {
5445
5551
  const { trace, currentTraceIndex, prevTrace, nextTrace, traces, clearData } = React.useContext(TraceContext);
5446
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5447
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-6 pt-[1.56rem]", children: [
5448
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
5449
- /* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "text-[1.125rem]", children: [
5450
- "Trace Span",
5451
- trace?.length && trace.length > 1 ? "s" : ""
5452
- ] }),
5453
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-mastra-el-3", children: [
5454
- trace?.length ? trace.length : 0,
5455
- " span",
5456
- trace?.length && trace.length > 1 ? "s" : ""
5457
- ] })
5458
- ] }),
5459
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
5460
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
5461
- /* @__PURE__ */ jsxRuntime.jsx(
5462
- Button$1,
5463
- {
5464
- onClick: () => {
5465
- prevTrace();
5466
- },
5467
- disabled: currentTraceIndex === 0,
5468
- variant: "secondary",
5469
- size: "icon",
5470
- className: "!h-3 !w-3 rotate-180 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",
5471
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {})
5472
- }
5473
- ),
5474
- " ",
5475
- /* @__PURE__ */ jsxRuntime.jsx(
5476
- Button$1,
5477
- {
5478
- onClick: () => {
5479
- nextTrace();
5480
- },
5481
- disabled: currentTraceIndex === traces.length - 1,
5482
- variant: "secondary",
5483
- size: "icon",
5484
- className: "!h-3 !w-3 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",
5485
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {})
5486
- }
5487
- )
5488
- ] }),
5489
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-secondary inline-block h-5 w-px" }),
5552
+ const actualTrace = traces[currentTraceIndex];
5553
+ if (!actualTrace || !trace) return null;
5554
+ return /* @__PURE__ */ jsxRuntime.jsxs("aside", { children: [
5555
+ /* @__PURE__ */ jsxRuntime.jsxs(Header, { children: [
5556
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
5557
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { className: "bg-transparent border-none", onClick: prevTrace, disabled: currentTraceIndex === 0, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, {}) }) }),
5490
5558
  /* @__PURE__ */ jsxRuntime.jsx(
5491
- Button$1,
5559
+ Button,
5492
5560
  {
5493
- onClick: () => {
5494
- clearData();
5495
- },
5496
- variant: "secondary",
5497
- size: "icon",
5498
- className: "!h-3 !w-3 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",
5499
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, {})
5561
+ className: "bg-transparent border-none",
5562
+ onClick: nextTrace,
5563
+ disabled: currentTraceIndex === traces.length - 1,
5564
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {}) })
5500
5565
  }
5501
5566
  )
5502
- ] })
5567
+ ] }),
5568
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-lg", className: "font-medium text-icon5", children: [
5569
+ "Trace ",
5570
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-icon3", children: actualTrace.traceId.substring(0, 5) })
5571
+ ] }) })
5503
5572
  ] }),
5504
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-6 px-1", children: [
5505
- " ",
5506
- trace && /* @__PURE__ */ jsxRuntime.jsx(SpanView, { trace })
5507
- ] })
5573
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-5", children: /* @__PURE__ */ jsxRuntime.jsx(SpanView, { trace }) })
5508
5574
  ] });
5509
5575
  }
5510
5576
 
@@ -5531,179 +5597,135 @@ const SyntaxHighlighter = ({ data }) => {
5531
5597
  };
5532
5598
 
5533
5599
  function SpanDetail() {
5534
- const { span } = React.useContext(TraceContext);
5535
- const isAiSpan = span?.name?.startsWith("ai.");
5536
- const aiSpanAttributes = Object.entries(span?.attributes || {}).filter(([key]) => allowedAiSpanAttributes.includes(key)).reduce((acc, [key, value]) => {
5537
- return {
5538
- ...acc,
5539
- [key]: value
5540
- };
5541
- }, {});
5542
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6 pb-20", children: [
5543
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 px-6 pt-[1.56rem]", children: [
5544
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "rounded bg-[#314431] p-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "21", height: "20", viewBox: "0 0 21 20", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
5545
- "path",
5546
- {
5547
- fillRule: "evenodd",
5548
- clipRule: "evenodd",
5549
- d: "M9.3726 2.10787C9.99493 1.48554 11.0066 1.48705 11.6274 2.10787L13.1306 3.61106C13.7529 4.23339 13.7514 5.24504 13.1306 5.86586L11.6274 7.36906C11.0051 7.99138 9.99342 7.98988 9.3726 7.36906L7.86941 5.86586C7.24708 5.24354 7.24858 4.23188 7.86941 3.61106L9.3726 2.10787ZM4.11141 7.36906C4.73374 6.74673 5.74539 6.74824 6.36621 7.36906L7.86941 8.87225C8.49173 9.49458 8.49023 10.5062 7.8694 11.127L6.36621 12.6302C5.74388 13.2526 4.73223 13.2511 4.11141 12.6302L2.60822 11.127C1.98589 10.5047 1.9874 9.49307 2.60822 8.87225L4.11141 7.36906ZM14.6338 7.36906C15.2561 6.74673 16.2678 6.74824 16.8886 7.36906L18.3918 8.87225C19.0141 9.49458 19.0126 10.5062 18.3918 11.127L16.8886 12.6302C16.2663 13.2526 15.2546 13.2511 14.6338 12.6302L13.1306 11.127C12.5083 10.5047 12.5098 9.49307 13.1306 8.87225L14.6338 7.36906ZM9.3726 12.6302C9.99493 12.0079 11.0066 12.0094 11.6274 12.6302L13.1306 14.1334C13.7529 14.7558 13.7514 15.7674 13.1306 16.3882L11.6274 17.8914C11.0051 18.5138 9.99342 18.5123 9.3726 17.8914L7.86941 16.3882C7.24708 15.7659 7.24859 14.7543 7.86941 14.1334L9.3726 12.6302Z",
5550
- fill: "white"
5551
- }
5552
- ) }) }),
5553
- /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-[0.9rem] font-medium", children: span?.name })
5600
+ const { span, setSpan, trace } = React.useContext(TraceContext);
5601
+ if (!span || !trace) return null;
5602
+ const prevSpan = () => {
5603
+ const currentIndex = trace.findIndex((t) => t.id === span.id);
5604
+ if (currentIndex !== -1 && currentIndex < trace.length - 1) {
5605
+ setSpan(trace[currentIndex + 1]);
5606
+ }
5607
+ };
5608
+ const nextSpan = () => {
5609
+ const currentIndex = trace.findIndex((t) => t.id === span.id);
5610
+ if (currentIndex !== -1 && currentIndex > 0) {
5611
+ setSpan(trace[currentIndex - 1]);
5612
+ }
5613
+ };
5614
+ const SpanIcon = spanIconMap[getSpanVariant(span)];
5615
+ const variantClass = spanVariantClasses[getSpanVariant(span)];
5616
+ return /* @__PURE__ */ jsxRuntime.jsxs("aside", { children: [
5617
+ /* @__PURE__ */ jsxRuntime.jsxs(Header, { children: [
5618
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
5619
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { className: "bg-transparent border-none", onClick: prevSpan, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, {}) }) }),
5620
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { className: "bg-transparent border-none", onClick: nextSpan, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {}) }) })
5621
+ ] }),
5622
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-lg", className: "font-medium text-icon5", as: "h2", children: [
5623
+ "Span ",
5624
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-icon3", children: span.id.substring(0, 5) })
5625
+ ] }) })
5554
5626
  ] }),
5555
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-3 gap-1 px-6", children: [
5556
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
5557
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-mastra-el-3", children: "Duration" }),
5558
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-mono text-xs", children: [
5559
- " ",
5560
- span?.duration ? formatDuration(span?.duration) : "",
5561
- "ms"
5562
- ] })
5627
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-5", children: [
5628
+ /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "header-md", as: "h3", className: "text-icon-6 flex items-center gap-4 pb-3", children: [
5629
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "lg", className: "bg-surface4 p-1 rounded-md", children: /* @__PURE__ */ jsxRuntime.jsx(SpanIcon, { className: variantClass }) }),
5630
+ span.name
5563
5631
  ] }),
5564
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
5565
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-mastra-el-3", children: "Time" }),
5566
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-xs", children: span?.startTime ? formatOtelTimestamp(span?.startTime) : "" })
5632
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row gap-2 items-center", children: /* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(LatencyIcon, {}), children: [
5633
+ formatDuration(span.duration),
5634
+ "ms"
5635
+ ] }) }),
5636
+ /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
5637
+ /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "grid grid-cols-2 justify-between gap-2", children: [
5638
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "ID" }),
5639
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: span.id }),
5640
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "Created at" }),
5641
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: span.startTime ? formatOtelTimestamp(span.startTime) : "" })
5567
5642
  ] }),
5568
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
5569
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-mastra-el-3", children: "Status" }),
5570
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("font-mono text-xs", span?.status?.code == 0 ? "text-[#6CD063]" : "text-[#FF4500]"), children: span?.status?.code == 0 ? "OK" : "ERROR" })
5571
- ] })
5572
- ] }),
5573
- span?.status?.code !== 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t-[0.5px] px-6 pt-4", children: span && span?.events?.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Events, { span }) }) : null,
5574
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t-[0.5px] px-6 pt-4", children: span && /* @__PURE__ */ jsxRuntime.jsx(Attributes, { span: { ...span, attributes: isAiSpan ? aiSpanAttributes : span?.attributes } }) }),
5575
- span?.status?.code === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t-[0.5px] px-6 pt-4", children: span && span?.events?.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Events, { span }) }) : null
5643
+ span.attributes && /* @__PURE__ */ jsxRuntime.jsx(Attributes, { attributes: span.attributes }),
5644
+ span.events?.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Events, { span })
5645
+ ] })
5576
5646
  ] });
5577
5647
  }
5648
+ function Attributes({ attributes }) {
5649
+ if (!attributes) return null;
5650
+ const entries = Object.entries(attributes);
5651
+ if (entries.length === 0) return null;
5652
+ const keysToHide = ["http.request_id", "componentName"];
5653
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { children: entries.filter(([key]) => !keysToHide.includes(key)).map(([key, val]) => {
5654
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5655
+ /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
5656
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "h4", variant: "ui-md", className: "text-icon3 pb-2", children: transformKey(key) }),
5657
+ /* @__PURE__ */ jsxRuntime.jsx(AttributeValue, { value: val })
5658
+ ] }, key);
5659
+ }) });
5660
+ }
5661
+ const AttributeValue = ({ value }) => {
5662
+ if (!value)
5663
+ return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: "N/A" });
5664
+ if (typeof value === "number" || typeof value === "boolean") {
5665
+ return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: String(value) });
5666
+ }
5667
+ if (typeof value === "object") {
5668
+ return /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter, { data: value });
5669
+ }
5670
+ try {
5671
+ return /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter, { data: JSON.parse(value) });
5672
+ } catch {
5673
+ return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: String(value) });
5674
+ }
5675
+ };
5578
5676
  function Events({ span }) {
5579
5677
  if (!span.events) return null;
5580
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col px-2", children: [
5581
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg", children: "Events" }),
5678
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5679
+ /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
5680
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6 pb-2", children: "Events" }),
5582
5681
  span.events.map((event) => {
5583
- const eventAttributes = event?.attributes?.map((att) => ({ [att?.key]: att?.value }));
5584
- return /* @__PURE__ */ jsxRuntime.jsxs(
5585
- "div",
5586
- {
5587
- className: cn("flex flex-col gap-2 border-b-[0.5px] last:border-b-0 pt-4 pb-2 first:pb-4"),
5588
- children: [
5589
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-mastra-el-3", children: "Name" }),
5590
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-mono text-xs", children: event.name }),
5591
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-mastra-el-3", children: "Time" }),
5592
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-mono text-xs", children: event.timeUnixNano ? formatOtelTimestamp2(Number(event.timeUnixNano)) : "" }),
5593
- event.attributes?.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(AttributesValues, { attributes: eventAttributes }) : null
5594
- ]
5595
- },
5596
- event.name
5597
- );
5682
+ const isLast = event === span.events[span.events.length - 1];
5683
+ return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
5684
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5685
+ /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "grid grid-cols-2 justify-between gap-2 pb-2", children: [
5686
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "Name" }),
5687
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: event.name }),
5688
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "Time" }),
5689
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: event.timeUnixNano ? formatOtelTimestamp2(Number(event.timeUnixNano)) : "N/A" })
5690
+ ] }),
5691
+ event.attributes?.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2", children: event.attributes.filter((attribute) => attribute !== null).map((attribute) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
5692
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "h4", variant: "ui-md", className: "text-icon3 pb-2", children: transformKey(attribute.key) }),
5693
+ /* @__PURE__ */ jsxRuntime.jsx(AttributeValue, { value: attribute.value })
5694
+ ] }, attribute.key)) }) : null
5695
+ ] }, event.name),
5696
+ !isLast && /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" })
5697
+ ] }, event.name);
5598
5698
  })
5599
5699
  ] });
5600
5700
  }
5601
- function Attributes({ span }) {
5602
- if (!span.attributes) return null;
5603
- return /* @__PURE__ */ jsxRuntime.jsx(AttributesValues, { attributes: span.attributes });
5604
- }
5605
- function AttributesValues({
5606
- attributes,
5607
- depth = 0,
5608
- keyName
5609
- }) {
5610
- if (attributes === null || attributes === void 0 || Array.isArray(attributes) && attributes.length === 0 || typeof attributes === "object" && attributes !== null && Object.keys(attributes).length === 0) {
5611
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm overflow-x-scroll", children: "N/A" });
5612
- }
5613
- if (typeof attributes === "string") {
5614
- try {
5615
- const attr = JSON.parse(attributes);
5616
- if (typeof attr === "object" || Array.isArray(attr)) {
5617
- return /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter, { data: attr });
5618
- }
5619
- } catch {
5620
- const val = attributes ? cleanString(attributes.toString()) : "N/A";
5621
- if (keyName === "Input" && val === "[Not Serializable]") {
5622
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm overflow-x-scroll", children: "No input" });
5623
- }
5624
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm overflow-x-scroll", children: attributes ? cleanString(attributes.toString()) : "N/A" });
5625
- }
5626
- }
5627
- const processedValue = attributes;
5628
- if (Array.isArray(processedValue)) {
5629
- if (processedValue.length === 0) return null;
5630
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 gap-3", children: processedValue.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsxRuntime.jsx(AttributesValues, { attributes: item, depth: depth + 1 }, index) }, index)) }) });
5631
- }
5632
- if (typeof processedValue === "object") {
5633
- const entries = Object.entries(processedValue);
5634
- if (entries.length === 0) return null;
5635
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: entries.map(([key, val]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 p-2 pl-0", children: [
5636
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm capitalize text-mastra-el-3", children: transformKey(key) }),
5637
- /* @__PURE__ */ jsxRuntime.jsx(AttributesValues, { attributes: val, depth: depth + 1, keyName: transformKey(key) })
5638
- ] }, key)) }) });
5639
- }
5640
- if (typeof processedValue === "boolean")
5641
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-sm", children: processedValue.toString() || "N/A" });
5642
- if (typeof processedValue === "number") return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-sm", children: processedValue.toString() });
5643
- if (typeof processedValue === "string")
5644
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-sm", children: processedValue ? cleanString(processedValue.toString()) : "N/A" });
5645
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400", children: String(processedValue) });
5646
- }
5647
5701
 
5648
- const TracesSidebar = ({ className, onResize, width, children }) => {
5649
- const { openDetail, isOpen: open } = React.useContext(TraceContext);
5650
- return /* @__PURE__ */ jsxRuntime.jsxs(
5702
+ const TracesSidebar = ({ onResize }) => {
5703
+ return /* @__PURE__ */ jsxRuntime.jsx(
5651
5704
  MastraResizablePanel,
5652
5705
  {
5653
- className: cn(
5654
- "absolute top-0 bottom-0 right-0 h-full z-20 overflow-x-scroll border-l-[0.5px] bg-mastra-bg-1 bg-[#121212]",
5655
- className
5656
- ),
5657
- defaultWidth: open ? 50 : 30,
5658
- minimumWidth: open ? 50 : 30,
5659
- maximumWidth: open ? 90 : 50,
5706
+ className: "h-full",
5707
+ defaultWidth: 70,
5708
+ minimumWidth: 50,
5709
+ maximumWidth: 70,
5660
5710
  setCurrentWidth: onResize,
5661
- children: [
5662
- open && /* @__PURE__ */ jsxRuntime.jsx(
5663
- "div",
5664
- {
5665
- className: "h-full overflow-x-scroll px-0 absolute left-0 top-0 min-w-[50%] bg-mastra-bg-1 bg-[#121212]",
5666
- style: { width: `${width}%` },
5667
- children: /* @__PURE__ */ jsxRuntime.jsx(TraceDetails, {})
5668
- }
5669
- ),
5670
- /* @__PURE__ */ jsxRuntime.jsx(
5671
- MastraResizablePanel,
5672
- {
5673
- defaultWidth: 50,
5674
- minimumWidth: 30,
5675
- maximumWidth: 80,
5676
- className: cn("h-full overflow-y-hidden border-l-[0.5px] right-0 top-0 z-20 bg-mastra-bg-1 bg-[#121212]", {
5677
- absolute: open,
5678
- "unset-position": !open
5679
- }),
5680
- disabled: !open,
5681
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-y-scroll", children: !openDetail ? children : /* @__PURE__ */ jsxRuntime.jsx(SpanDetail, {}) })
5682
- }
5683
- )
5684
- ]
5711
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full grid grid-cols-2", children: [
5712
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-scroll w-full h-[calc(100%-40px)]", children: /* @__PURE__ */ jsxRuntime.jsx(TraceDetails, {}) }),
5713
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-[calc(100%-40px)] overflow-x-scroll w-full border-l border-border1", children: /* @__PURE__ */ jsxRuntime.jsx(SpanDetail, {}) })
5714
+ ] })
5685
5715
  }
5686
5716
  );
5687
5717
  };
5688
5718
 
5689
- function AgentTraces({ agentName, baseUrl, sidebarChild }) {
5690
- return /* @__PURE__ */ jsxRuntime.jsx(TraceProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(AgentTracesInner, { agentName, baseUrl, sidebarChild }) });
5719
+ function AgentTraces({ agentName, baseUrl, className }) {
5720
+ return /* @__PURE__ */ jsxRuntime.jsx(TraceProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(AgentTracesInner, { agentName, baseUrl, className }) });
5691
5721
  }
5692
- function AgentTracesInner({ agentName, baseUrl, sidebarChild }) {
5693
- const [sidebarWidth, setSidebarWidth] = React.useState(30);
5722
+ function AgentTracesInner({ agentName, baseUrl, className }) {
5723
+ const [sidebarWidth, setSidebarWidth] = React.useState(100);
5694
5724
  const { traces, firstCallLoading, error } = useTraces(agentName, baseUrl);
5695
5725
  const { isOpen: open } = React.useContext(TraceContext);
5696
- return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "h-full relative overflow-hidden flex flex-row", children: [
5697
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 block mr-[30%]", children: /* @__PURE__ */ jsxRuntime.jsx(TracesTable, { traces, isLoading: firstCallLoading, error }) }),
5698
- /* @__PURE__ */ jsxRuntime.jsx(
5699
- TracesSidebar,
5700
- {
5701
- className: cn(open ? "grid grid-cols-2 w-[60%]" : "min-w-[325px]"),
5702
- width: 100 - sidebarWidth,
5703
- onResize: setSidebarWidth,
5704
- children: sidebarChild
5705
- }
5706
- )
5726
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx("h-full relative overflow-hidden flex", className), children: [
5727
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx("h-full overflow-y-scroll", open ? "w-auto" : "w-full"), children: /* @__PURE__ */ jsxRuntime.jsx(TracesTable, { traces, isLoading: firstCallLoading, error }) }),
5728
+ open && /* @__PURE__ */ jsxRuntime.jsx(TracesSidebar, { width: sidebarWidth, onResize: setSidebarWidth })
5707
5729
  ] });
5708
5730
  }
5709
5731
 
@@ -5717,11 +5739,13 @@ function MastraNetworkRuntimeProvider({
5717
5739
  memory,
5718
5740
  threadId,
5719
5741
  baseUrl,
5720
- refreshThreadList
5742
+ refreshThreadList,
5743
+ modelSettings = {}
5721
5744
  }) {
5722
5745
  const [isRunning, setIsRunning] = React.useState(false);
5723
5746
  const [messages, setMessages] = React.useState(initialMessages || []);
5724
5747
  const [currentThreadId, setCurrentThreadId] = React.useState(threadId);
5748
+ const { frequencyPenalty, presencePenalty, maxRetries, maxSteps, maxTokens, temperature, topK, topP, instructions } = modelSettings;
5725
5749
  React.useEffect(() => {
5726
5750
  if (messages.length === 0 || currentThreadId !== threadId) {
5727
5751
  if (initialMessages && threadId && memory) {
@@ -5730,11 +5754,7 @@ function MastraNetworkRuntimeProvider({
5730
5754
  }
5731
5755
  }
5732
5756
  }, [initialMessages, threadId, memory, messages]);
5733
- const mastra = new clientJs.MastraClient({
5734
- baseUrl: baseUrl || ""
5735
- });
5736
- console.log("MastraClient initialized");
5737
- console.log(messages, "###");
5757
+ const mastra = createMastraClient(baseUrl);
5738
5758
  const network = mastra.getNetwork(agentId);
5739
5759
  const onNew = async (message) => {
5740
5760
  if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
@@ -5763,6 +5783,15 @@ function MastraNetworkRuntimeProvider({
5763
5783
  }
5764
5784
  ],
5765
5785
  runId: agentId,
5786
+ frequencyPenalty,
5787
+ presencePenalty,
5788
+ maxRetries,
5789
+ maxSteps,
5790
+ maxTokens,
5791
+ temperature,
5792
+ topK,
5793
+ topP,
5794
+ instructions,
5766
5795
  ...memory ? { threadId, resourceId: agentId } : {}
5767
5796
  });
5768
5797
  if (!response.body) {
@@ -6117,28 +6146,46 @@ const ToolFallback = (props) => {
6117
6146
  }) });
6118
6147
  };
6119
6148
 
6149
+ const defaultModelSettings = {
6150
+ maxRetries: 2,
6151
+ maxSteps: 5,
6152
+ temperature: 0.5,
6153
+ topP: 1
6154
+ };
6155
+ const NetworkContext = React.createContext({});
6156
+ function NetworkProvider({ children }) {
6157
+ const [modelSettings, setModelSettings] = React.useState(defaultModelSettings);
6158
+ const resetModelSettings = () => {
6159
+ setModelSettings(defaultModelSettings);
6160
+ };
6161
+ return /* @__PURE__ */ jsxRuntime.jsx(
6162
+ NetworkContext.Provider,
6163
+ {
6164
+ value: {
6165
+ modelSettings,
6166
+ setModelSettings,
6167
+ resetModelSettings
6168
+ },
6169
+ children
6170
+ }
6171
+ );
6172
+ }
6173
+
6120
6174
  const NetworkChat = ({ agentId, memory }) => {
6121
- return /* @__PURE__ */ jsxRuntime.jsx(MastraNetworkRuntimeProvider, { agentId, memory, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full pb-4", children: /* @__PURE__ */ jsxRuntime.jsx(Thread, { ToolFallback }) }) });
6175
+ const { modelSettings } = React.useContext(NetworkContext);
6176
+ return /* @__PURE__ */ jsxRuntime.jsx(MastraNetworkRuntimeProvider, { agentId, memory, modelSettings, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full pb-4", children: /* @__PURE__ */ jsxRuntime.jsx(Thread, { ToolFallback }) }) });
6122
6177
  };
6123
6178
 
6124
- function WorkflowTraces({ workflowName, baseUrl, sidebarChild }) {
6125
- return /* @__PURE__ */ jsxRuntime.jsx(TraceProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowTracesInner, { workflowName, baseUrl, sidebarChild }) });
6179
+ function WorkflowTraces({ workflowName, baseUrl }) {
6180
+ return /* @__PURE__ */ jsxRuntime.jsx(TraceProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowTracesInner, { workflowName, baseUrl }) });
6126
6181
  }
6127
- function WorkflowTracesInner({ workflowName, baseUrl, sidebarChild }) {
6128
- const [sidebarWidth, setSidebarWidth] = React.useState(30);
6182
+ function WorkflowTracesInner({ workflowName, baseUrl }) {
6183
+ const [sidebarWidth, setSidebarWidth] = React.useState(100);
6129
6184
  const { traces, error, firstCallLoading } = useTraces(workflowName, baseUrl, true);
6130
6185
  const { isOpen: open } = React.useContext(TraceContext);
6131
- return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "h-full relative overflow-hidden flex flex-row", children: [
6132
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 block mr-[30%]", children: /* @__PURE__ */ jsxRuntime.jsx(TracesTable, { traces, isLoading: firstCallLoading, error }) }),
6133
- /* @__PURE__ */ jsxRuntime.jsx(
6134
- TracesSidebar,
6135
- {
6136
- className: cn(open ? "grid grid-cols-2 w-[60%]" : "min-w-[325px]"),
6137
- width: 100 - sidebarWidth,
6138
- onResize: setSidebarWidth,
6139
- children: sidebarChild
6140
- }
6141
- )
6186
+ return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "h-full relative overflow-hidden flex", children: [
6187
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx("h-full", open ? "w-auto" : "w-full"), children: /* @__PURE__ */ jsxRuntime.jsx(TracesTable, { traces, isLoading: firstCallLoading, error }) }),
6188
+ open && /* @__PURE__ */ jsxRuntime.jsx(TracesSidebar, { width: sidebarWidth, onResize: setSidebarWidth })
6142
6189
  ] });
6143
6190
  }
6144
6191
 
@@ -6180,9 +6227,7 @@ const sanitizeVNexWorkflowWatchResult = (record) => {
6180
6227
  const useWorkflow = (workflowId, baseUrl) => {
6181
6228
  const [workflow, setWorkflow] = React.useState(null);
6182
6229
  const [isLoading, setIsLoading] = React.useState(true);
6183
- const client = new clientJs.MastraClient({
6184
- baseUrl: baseUrl || ""
6185
- });
6230
+ const client = createMastraClient(baseUrl);
6186
6231
  React.useEffect(() => {
6187
6232
  const fetchWorkflow = async () => {
6188
6233
  setIsLoading(true);
@@ -6227,9 +6272,7 @@ const useWorkflow = (workflowId, baseUrl) => {
6227
6272
  const useVNextWorkflow = (workflowId, baseUrl) => {
6228
6273
  const [vNextWorkflow, setVNextWorkflow] = React.useState(null);
6229
6274
  const [isLoading, setIsLoading] = React.useState(true);
6230
- const client = new clientJs.MastraClient({
6231
- baseUrl: baseUrl || ""
6232
- });
6275
+ const client = createMastraClient(baseUrl);
6233
6276
  React.useEffect(() => {
6234
6277
  const fetchWorkflow = async () => {
6235
6278
  setIsLoading(true);
@@ -6254,9 +6297,7 @@ const useVNextWorkflow = (workflowId, baseUrl) => {
6254
6297
  return { vNextWorkflow, isLoading };
6255
6298
  };
6256
6299
  const useExecuteWorkflow = (baseUrl) => {
6257
- const client = new clientJs.MastraClient({
6258
- baseUrl: baseUrl || ""
6259
- });
6300
+ const client = createMastraClient(baseUrl);
6260
6301
  const createWorkflowRun = async ({ workflowId, prevRunId }) => {
6261
6302
  try {
6262
6303
  const workflow = client.getWorkflow(workflowId);
@@ -6354,12 +6395,9 @@ const useWatchWorkflow = (baseUrl) => {
6354
6395
  const watchWorkflow = async ({ workflowId, runId }) => {
6355
6396
  try {
6356
6397
  setIsWatchingWorkflow(true);
6357
- const client = new clientJs.MastraClient({
6358
- baseUrl
6359
- });
6398
+ const client = createMastraClient(baseUrl);
6360
6399
  const workflow = client.getWorkflow(workflowId);
6361
6400
  await workflow.watch({ runId }, (record) => {
6362
- console.log("record in use-workflows==", record);
6363
6401
  try {
6364
6402
  debouncedSetWatchResult(record);
6365
6403
  } catch (err) {
@@ -6383,12 +6421,9 @@ const useWatchWorkflow = (baseUrl) => {
6383
6421
  const watchVNextWorkflow = async ({ workflowId, runId }) => {
6384
6422
  try {
6385
6423
  setIsWatchingVNextWorkflow(true);
6386
- const client = new clientJs.MastraClient({
6387
- baseUrl
6388
- });
6424
+ const client = createMastraClient(baseUrl);
6389
6425
  const workflow = client.getVNextWorkflow(workflowId);
6390
6426
  await workflow.watch({ runId }, (record) => {
6391
- console.log("record in use-workflows===", record);
6392
6427
  try {
6393
6428
  debouncedSetVNextWatchResult(record);
6394
6429
  } catch (err) {
@@ -6425,9 +6460,7 @@ const useResumeWorkflow = (baseUrl) => {
6425
6460
  }) => {
6426
6461
  try {
6427
6462
  setIsResumingWorkflow(true);
6428
- const client = new clientJs.MastraClient({
6429
- baseUrl: baseUrl || ""
6430
- });
6463
+ const client = createMastraClient(baseUrl);
6431
6464
  const response = await client.getWorkflow(workflowId).resume({ stepId, runId, context });
6432
6465
  return response;
6433
6466
  } catch (error) {
@@ -6446,9 +6479,7 @@ const useResumeWorkflow = (baseUrl) => {
6446
6479
  }) => {
6447
6480
  try {
6448
6481
  setIsResumingVNextWorkflow(true);
6449
- const client = new clientJs.MastraClient({
6450
- baseUrl: baseUrl || ""
6451
- });
6482
+ const client = createMastraClient(baseUrl);
6452
6483
  const response = await client.getVNextWorkflow(workflowId).resume({ step, runId, resumeData, runtimeContext });
6453
6484
  return response;
6454
6485
  } catch (error) {
@@ -7539,12 +7570,12 @@ const ErrorMessage = ({ error }) => /* @__PURE__ */ jsxRuntime.jsxs(Alert, { var
7539
7570
 
7540
7571
  const SubmitButton = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(Button$1, { type: "submit", children });
7541
7572
 
7542
- const StringField = ({ inputProps, error, id }) => {
7573
+ const StringField = ({ inputProps, error, field, id }) => {
7543
7574
  const { key, ...props } = inputProps;
7544
- return /* @__PURE__ */ jsxRuntime.jsx(Input, { id, className: error ? "border-destructive" : "", ...props });
7575
+ return /* @__PURE__ */ jsxRuntime.jsx(Input, { id, className: error ? "border-destructive" : "", ...props, defaultValue: field.default });
7545
7576
  };
7546
7577
 
7547
- const NumberField = ({ inputProps, error, id }) => {
7578
+ const NumberField = ({ inputProps, error, field, id }) => {
7548
7579
  const { key, ...props } = inputProps;
7549
7580
  return /* @__PURE__ */ jsxRuntime.jsx(
7550
7581
  Input,
@@ -7553,6 +7584,7 @@ const NumberField = ({ inputProps, error, id }) => {
7553
7584
  type: "number",
7554
7585
  className: error ? "border-destructive" : "",
7555
7586
  ...props,
7587
+ defaultValue: field.default,
7556
7588
  onChange: (e) => {
7557
7589
  const value = e.target.value;
7558
7590
  if (value !== "" && !isNaN(Number(value))) {
@@ -7587,7 +7619,7 @@ const Checkbox = React__namespace.forwardRef(({ className, ...props }, ref) => /
7587
7619
  ));
7588
7620
  Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
7589
7621
 
7590
- const BooleanField = ({ field, label, id, inputProps }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2", children: [
7622
+ const BooleanField = ({ field, label, id, inputProps, value }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2", children: [
7591
7623
  /* @__PURE__ */ jsxRuntime.jsx(
7592
7624
  Checkbox,
7593
7625
  {
@@ -7595,13 +7627,13 @@ const BooleanField = ({ field, label, id, inputProps }) => /* @__PURE__ */ jsxRu
7595
7627
  onCheckedChange: (checked) => {
7596
7628
  const event = {
7597
7629
  target: {
7598
- name: field.key,
7630
+ name: inputProps.name,
7599
7631
  value: checked
7600
7632
  }
7601
7633
  };
7602
7634
  inputProps.onChange(event);
7603
7635
  },
7604
- checked: inputProps.value
7636
+ defaultChecked: field.default
7605
7637
  }
7606
7638
  ),
7607
7639
  /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: id, children: [
@@ -7838,9 +7870,17 @@ const DefaultButton = React__namespace.forwardRef(
7838
7870
  );
7839
7871
  DefaultButton.displayName = "DefaultButton";
7840
7872
 
7841
- const DateField = ({ inputProps, error, id }) => {
7873
+ const DateField = ({ inputProps, field, error, id }) => {
7842
7874
  const { key, ...props } = inputProps;
7843
7875
  const [value, setValue] = React.useState(null);
7876
+ React.useEffect(() => {
7877
+ if (field.default) {
7878
+ const date = new Date(field.default);
7879
+ if (dateFns.isValid(date)) {
7880
+ setValue(date);
7881
+ }
7882
+ }
7883
+ }, [field]);
7844
7884
  return /* @__PURE__ */ jsxRuntime.jsx(
7845
7885
  DatePicker,
7846
7886
  {
@@ -7920,16 +7960,16 @@ const SelectItem = React__namespace.forwardRef(({ className, children, ...props
7920
7960
  ));
7921
7961
  SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
7922
7962
 
7923
- const SelectField = ({ field, inputProps, error, id }) => {
7963
+ const SelectField = ({ field, inputProps, error, id, value }) => {
7924
7964
  const { key, ...props } = inputProps;
7925
7965
  return /* @__PURE__ */ jsxRuntime.jsxs(
7926
7966
  Select,
7927
7967
  {
7928
7968
  ...props,
7929
- onValueChange: (value) => {
7969
+ onValueChange: (value2) => {
7930
7970
  const syntheticEvent = {
7931
7971
  target: {
7932
- value,
7972
+ value: value2,
7933
7973
  name: inputProps.name
7934
7974
  }
7935
7975
  };
@@ -7976,10 +8016,10 @@ const ArrayElementWrapper = ({ children, onRemove }) => {
7976
8016
  ] });
7977
8017
  };
7978
8018
 
7979
- const RecordField = ({ inputProps, error, id }) => {
7980
- const { key, value = {}, onChange, ...props } = inputProps;
8019
+ const RecordField = ({ inputProps, field, error, id }) => {
8020
+ const { key, onChange, ...props } = inputProps;
7981
8021
  const [pairs, setPairs] = React__namespace.useState(
7982
- () => Object.entries(value).map(([key2, val]) => ({
8022
+ () => Object.entries(field.default || {}).map(([key2, val]) => ({
7983
8023
  id: key2 || uuid.v4(),
7984
8024
  key: key2,
7985
8025
  value: val
@@ -8007,8 +8047,8 @@ const RecordField = ({ inputProps, error, id }) => {
8007
8047
  },
8008
8048
  [onChange, inputProps.name]
8009
8049
  );
8010
- const handleChange = (id2, field, newValue) => {
8011
- setPairs((prev) => prev.map((pair) => pair.id === id2 ? { ...pair, [field]: newValue } : pair));
8050
+ const handleChange = (id2, field2, newValue) => {
8051
+ setPairs((prev) => prev.map((pair) => pair.id === id2 ? { ...pair, [field2]: newValue } : pair));
8012
8052
  };
8013
8053
  const handleBlur = () => {
8014
8054
  updateForm(pairs);
@@ -8193,7 +8233,7 @@ function DynamicForm({
8193
8233
  onSubmit: async (values) => {
8194
8234
  await onSubmit(values["​"]);
8195
8235
  },
8196
- defaultValues,
8236
+ defaultValues: defaultValues ? { "​": defaultValues } : void 0,
8197
8237
  formProps: {
8198
8238
  className: "space-y-4 p-4"
8199
8239
  },
@@ -8674,9 +8714,9 @@ function VNextWorkflowTrigger({
8674
8714
  ] }) }, stepId) });
8675
8715
  }) })
8676
8716
  ] }),
8677
- isSuspendedSteps && suspendedSteps?.map((step) => {
8717
+ !isWatchingVNextWorkflow && isSuspendedSteps && suspendedSteps?.map((step) => {
8678
8718
  const stepDefinition = vNextWorkflow.steps[step.stepId];
8679
- const stepSchema = stepDefinition?.inputSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(stepDefinition.inputSchema))) : z.z.record(z.z.string(), z.z.any());
8719
+ const stepSchema = stepDefinition?.resumeSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(stepDefinition.resumeSchema))) : z.z.record(z.z.string(), z.z.any());
8680
8720
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col px-4", children: [
8681
8721
  /* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
8682
8722
  step.suspendPayload && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -8798,30 +8838,6 @@ const DataTable = ({
8798
8838
  ] });
8799
8839
  };
8800
8840
 
8801
- const sizeClasses = {
8802
- md: "h-button-md gap-md",
8803
- lg: "h-button-lg gap-lg"
8804
- };
8805
- const variantClasses = {
8806
- default: "bg-surface2 hover:bg-surface4 text-icon3 hover:text-icon6",
8807
- light: "bg-surface3 hover:bg-surface5 text-icon6"
8808
- };
8809
- const Button = ({ className, as, size = "md", variant = "default", ...props }) => {
8810
- const Component = as || "button";
8811
- return /* @__PURE__ */ jsxRuntime.jsx(
8812
- Component,
8813
- {
8814
- className: clsx(
8815
- "bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
8816
- variantClasses[variant],
8817
- sizeClasses[size],
8818
- className
8819
- ),
8820
- ...props
8821
- }
8822
- );
8823
- };
8824
-
8825
8841
  const Breadcrumb = ({ children, label }) => {
8826
8842
  return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": label, children: /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "gap-sm flex items-center", children }) });
8827
8843
  };
@@ -8840,27 +8856,6 @@ const Crumb = ({ className, as, isCurrent, ...props }) => {
8840
8856
  ] });
8841
8857
  };
8842
8858
 
8843
- const Header = ({ children, border = true }) => {
8844
- return /* @__PURE__ */ jsxRuntime.jsx(
8845
- "header",
8846
- {
8847
- className: clsx("h-header-default z-50 flex w-full items-center gap-[18px] bg-transparent px-5", {
8848
- "border-b-sm border-border1": border
8849
- }),
8850
- children
8851
- }
8852
- );
8853
- };
8854
- const HeaderTitle = ({ children }) => {
8855
- return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "h1", variant: "ui-lg", className: "font-medium text-white", children });
8856
- };
8857
- const HeaderAction = ({ children }) => {
8858
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto", children });
8859
- };
8860
- const HeaderGroup = ({ children }) => {
8861
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gap-lg flex items-center", children });
8862
- };
8863
-
8864
8859
  const DarkLogo = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "100", height: "100", viewBox: "0 0 100 100", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
8865
8860
  /* @__PURE__ */ jsxRuntime.jsx(
8866
8861
  "path",
@@ -8961,10 +8956,13 @@ exports.HomeIcon = HomeIcon;
8961
8956
  exports.Icon = Icon;
8962
8957
  exports.InfoIcon = InfoIcon;
8963
8958
  exports.JudgeIcon = JudgeIcon;
8959
+ exports.LatencyIcon = LatencyIcon;
8964
8960
  exports.LogsIcon = LogsIcon;
8965
8961
  exports.MastraResizablePanel = MastraResizablePanel;
8966
8962
  exports.MemoryIcon = MemoryIcon;
8967
8963
  exports.NetworkChat = NetworkChat;
8964
+ exports.NetworkContext = NetworkContext;
8965
+ exports.NetworkProvider = NetworkProvider;
8968
8966
  exports.OpenAIIcon = OpenAIIcon;
8969
8967
  exports.PromptIcon = PromptIcon;
8970
8968
  exports.RepoIcon = RepoIcon;