@mastra/playground-ui 5.0.1-alpha.2 → 5.0.1-alpha.4

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.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useMessage, MessagePrimitive, ActionBarPrimitive, ThreadPrimitive, ComposerPrimitive, useExternalStoreRuntime, AssistantRuntimeProvider } from '@assistant-ui/react';
3
- import { CheckIcon as CheckIcon$1, CopyIcon, ChevronUpIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, ChevronUp, ChevronDown, Check, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, X, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, PlusIcon, TrashIcon, Plus, Loader2 } from 'lucide-react';
3
+ import { CheckIcon as CheckIcon$1, CopyIcon, ChevronUpIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, X, Check, ChevronUp, ChevronDown, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, PlusIcon, TrashIcon, Plus, Loader2 } from 'lucide-react';
4
4
  import * as React from 'react';
5
5
  import React__default, { forwardRef, memo, useState, useMemo, useRef, useEffect, createContext, useContext, useCallback, Suspense, Fragment as Fragment$1 } from 'react';
6
6
  import { Slot } from '@radix-ui/react-slot';
@@ -4285,7 +4285,7 @@ function MastraRuntimeProvider({
4285
4285
  ] });
4286
4286
  }
4287
4287
 
4288
- const defaultModelSettings = {
4288
+ const defaultModelSettings$1 = {
4289
4289
  maxRetries: 2,
4290
4290
  maxSteps: 5,
4291
4291
  temperature: 0.5,
@@ -4293,10 +4293,10 @@ const defaultModelSettings = {
4293
4293
  };
4294
4294
  const AgentContext = createContext({});
4295
4295
  function AgentProvider({ children }) {
4296
- const [modelSettings, setModelSettings] = useState(defaultModelSettings);
4296
+ const [modelSettings, setModelSettings] = useState(defaultModelSettings$1);
4297
4297
  const [chatWithGenerate, setChatWithGenerate] = useState(false);
4298
4298
  const resetModelSettings = () => {
4299
- setModelSettings(defaultModelSettings);
4299
+ setModelSettings(defaultModelSettings$1);
4300
4300
  };
4301
4301
  return /* @__PURE__ */ jsx(
4302
4302
  AgentContext.Provider,
@@ -5093,8 +5093,20 @@ const Th = ({ className, children, ...props }) => {
5093
5093
  const Tbody = ({ className, children }) => {
5094
5094
  return /* @__PURE__ */ jsx("tbody", { className: clsx("", className), children });
5095
5095
  };
5096
- const Row = ({ className, children, selected = false }) => {
5097
- return /* @__PURE__ */ jsx("tr", { className: clsx("border-b-sm border-border1 hover:bg-surface3", selected && "bg-surface4", className), children });
5096
+ const Row = ({ className, children, selected = false, onClick }) => {
5097
+ return /* @__PURE__ */ jsx(
5098
+ "tr",
5099
+ {
5100
+ className: clsx(
5101
+ "border-b-sm border-border1 hover:bg-surface3",
5102
+ selected && "bg-surface4",
5103
+ onClick && "cursor-pointer",
5104
+ className
5105
+ ),
5106
+ onClick,
5107
+ children
5108
+ }
5109
+ );
5098
5110
  };
5099
5111
 
5100
5112
  const variants = {
@@ -5187,7 +5199,8 @@ const TracesTableError = ({ error, colsCount }) => {
5187
5199
  };
5188
5200
  const TraceRow = ({ trace, index, isActive }) => {
5189
5201
  const { openTrace } = useOpenTrace();
5190
- return /* @__PURE__ */ jsxs(Row, { className: isActive ? "bg-surface4" : "", children: [
5202
+ const hasFailure = trace.trace.some((span) => span.status.code !== 0);
5203
+ return /* @__PURE__ */ jsxs(Row, { className: isActive ? "bg-surface4" : "", onClick: () => openTrace(trace.trace, index), children: [
5191
5204
  /* @__PURE__ */ jsx(DateTimeCell, { dateTime: new Date(trace.started / 1e3) }),
5192
5205
  /* @__PURE__ */ jsx(TxtCell, { children: trace.traceId }),
5193
5206
  /* @__PURE__ */ jsx(UnitCell, { unit: "ms", children: trace.duration / 1e3 }),
@@ -5195,7 +5208,8 @@ const TraceRow = ({ trace, index, isActive }) => {
5195
5208
  trace.trace.length,
5196
5209
  " span",
5197
5210
  trace.trace.length > 1 ? "s" : ""
5198
- ] }) }) })
5211
+ ] }) }) }),
5212
+ /* @__PURE__ */ jsx(Cell, { children: hasFailure ? /* @__PURE__ */ jsx(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsx(X, {}), children: "Failed" }) : /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(Check, {}), variant: "success", children: "Success" }) })
5199
5213
  ] });
5200
5214
  };
5201
5215
  const TracesTable = ({ traces, isLoading, error }) => {
@@ -5207,7 +5221,8 @@ const TracesTable = ({ traces, isLoading, error }) => {
5207
5221
  /* @__PURE__ */ jsx(Th, { width: 160, children: "Time" }),
5208
5222
  /* @__PURE__ */ jsx(Th, { width: "auto", children: "Trace Id" }),
5209
5223
  /* @__PURE__ */ jsx(Th, { width: 160, children: "Duration" }),
5210
- /* @__PURE__ */ jsx(Th, { width: 160, children: "Spans" })
5224
+ /* @__PURE__ */ jsx(Th, { width: 160, children: "Spans" }),
5225
+ /* @__PURE__ */ jsx(Th, { width: 160, children: "Status" })
5211
5226
  ] }),
5212
5227
  isLoading ? /* @__PURE__ */ jsx(TracesTableSkeleton, { colsCount }) : error ? /* @__PURE__ */ jsx(TracesTableError, { error, colsCount }) : hasNoTraces ? /* @__PURE__ */ jsx(TracesTableEmpty, { colsCount }) : /* @__PURE__ */ jsx(Tbody, { children: traces.map((trace, index) => /* @__PURE__ */ jsx(TraceRow, { trace, index, isActive: index === currentTraceIndex }, trace.traceId)) })
5213
5228
  ] });
@@ -5329,7 +5344,7 @@ const variantClasses = {
5329
5344
  };
5330
5345
  const Time = ({ durationMs, tokenCount, variant, progressPercent }) => {
5331
5346
  const variantClass = variant ? variantClasses[variant] : "bg-accent3";
5332
- return /* @__PURE__ */ jsxs("div", { children: [
5347
+ return /* @__PURE__ */ jsxs("div", { className: "w-[166px] shrink-0", children: [
5333
5348
  /* @__PURE__ */ jsx("div", { className: "bg-surface4 relative h-[6px] w-full rounded-full p-px overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: clsx("absolute h-1 rounded-full", variantClass), style: { width: `${progressPercent}%` } }) }),
5334
5349
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 pt-0.5", children: [
5335
5350
  /* @__PURE__ */ jsxs(Txt, { variant: "ui-sm", className: "text-icon2 font-medium", children: [
@@ -5380,8 +5395,8 @@ const Span = ({ children, durationMs, variant, tokenCount, spans, isRoot, onClic
5380
5395
  const progressPercent = durationMs / traceDuration * 100;
5381
5396
  const TextEl = onClick ? "button" : "div";
5382
5397
  return /* @__PURE__ */ jsx(TraceDurationProvider, { durationMs, children: /* @__PURE__ */ jsxs("li", { children: [
5383
- /* @__PURE__ */ jsxs("div", { className: clsx("grid grid-cols-2 items-center gap-2 rounded-md pl-2", isActive && "bg-surface4"), children: [
5384
- /* @__PURE__ */ jsxs("div", { className: "flex h-8 items-center gap-1", children: [
5398
+ /* @__PURE__ */ jsxs("div", { className: clsx("flex justify-between items-center gap-2 rounded-md pl-2", isActive && "bg-surface4"), children: [
5399
+ /* @__PURE__ */ jsxs("div", { className: "flex h-8 items-center gap-1 min-w-0", children: [
5385
5400
  spans ? /* @__PURE__ */ jsx(
5386
5401
  "button",
5387
5402
  {
@@ -5519,6 +5534,7 @@ function TraceDetails() {
5519
5534
  const { trace, currentTraceIndex, prevTrace, nextTrace, traces, clearData } = useContext(TraceContext);
5520
5535
  const actualTrace = traces[currentTraceIndex];
5521
5536
  if (!actualTrace || !trace) return null;
5537
+ const hasFailure = trace.some((span) => span.status.code !== 0);
5522
5538
  return /* @__PURE__ */ jsxs("aside", { children: [
5523
5539
  /* @__PURE__ */ jsxs(Header, { children: [
5524
5540
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
@@ -5533,10 +5549,13 @@ function TraceDetails() {
5533
5549
  }
5534
5550
  )
5535
5551
  ] }),
5536
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Txt, { variant: "ui-lg", className: "font-medium text-icon5", children: [
5537
- "Trace ",
5538
- /* @__PURE__ */ jsx("span", { className: "ml-2 text-icon3", children: actualTrace.traceId.substring(0, 5) })
5539
- ] }) })
5552
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 justify-between w-full", children: [
5553
+ /* @__PURE__ */ jsxs(Txt, { variant: "ui-lg", className: "font-medium text-icon5 shrink-0", children: [
5554
+ "Trace ",
5555
+ /* @__PURE__ */ jsx("span", { className: "ml-2 text-icon3", children: actualTrace.traceId.substring(0, 5) })
5556
+ ] }),
5557
+ hasFailure && /* @__PURE__ */ jsx(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsx(X, {}), children: "Failed" })
5558
+ ] })
5540
5559
  ] }),
5541
5560
  /* @__PURE__ */ jsx("div", { className: "p-5", children: /* @__PURE__ */ jsx(SpanView, { trace }) })
5542
5561
  ] });
@@ -5597,7 +5616,11 @@ function SpanDetail() {
5597
5616
  /* @__PURE__ */ jsx(Icon, { size: "lg", className: "bg-surface4 p-1 rounded-md", children: /* @__PURE__ */ jsx(SpanIcon, { className: variantClass }) }),
5598
5617
  span.name
5599
5618
  ] }),
5600
- /* @__PURE__ */ jsx("div", { className: "flex flex-row gap-2 items-center", children: /* @__PURE__ */ jsxs(Badge$1, { icon: /* @__PURE__ */ jsx(LatencyIcon, {}), children: [
5619
+ /* @__PURE__ */ jsx("div", { className: "flex flex-row gap-2 items-center", children: span.status.code === 0 ? /* @__PURE__ */ jsxs(Badge$1, { icon: /* @__PURE__ */ jsx(LatencyIcon, {}), variant: "success", children: [
5620
+ formatDuration(span.duration),
5621
+ "ms"
5622
+ ] }) : /* @__PURE__ */ jsxs(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsx(X, {}), children: [
5623
+ "Failed in ",
5601
5624
  formatDuration(span.duration),
5602
5625
  "ms"
5603
5626
  ] }) }),
@@ -5684,15 +5707,15 @@ const TracesSidebar = ({ onResize }) => {
5684
5707
  );
5685
5708
  };
5686
5709
 
5687
- function AgentTraces({ agentName, baseUrl }) {
5688
- return /* @__PURE__ */ jsx(TraceProvider, { children: /* @__PURE__ */ jsx(AgentTracesInner, { agentName, baseUrl }) });
5710
+ function AgentTraces({ agentName, baseUrl, className }) {
5711
+ return /* @__PURE__ */ jsx(TraceProvider, { children: /* @__PURE__ */ jsx(AgentTracesInner, { agentName, baseUrl, className }) });
5689
5712
  }
5690
- function AgentTracesInner({ agentName, baseUrl }) {
5713
+ function AgentTracesInner({ agentName, baseUrl, className }) {
5691
5714
  const [sidebarWidth, setSidebarWidth] = useState(100);
5692
5715
  const { traces, firstCallLoading, error } = useTraces(agentName, baseUrl);
5693
5716
  const { isOpen: open } = useContext(TraceContext);
5694
- return /* @__PURE__ */ jsxs("main", { className: "h-full relative overflow-hidden flex", children: [
5695
- /* @__PURE__ */ jsx("div", { className: clsx("h-full", open ? "w-auto" : "w-full"), children: /* @__PURE__ */ jsx(TracesTable, { traces, isLoading: firstCallLoading, error }) }),
5717
+ return /* @__PURE__ */ jsxs("div", { className: clsx("h-full relative overflow-hidden flex", className), children: [
5718
+ /* @__PURE__ */ jsx("div", { className: clsx("h-full overflow-y-scroll", open ? "w-auto" : "w-full"), children: /* @__PURE__ */ jsx(TracesTable, { traces, isLoading: firstCallLoading, error }) }),
5696
5719
  open && /* @__PURE__ */ jsx(TracesSidebar, { width: sidebarWidth, onResize: setSidebarWidth })
5697
5720
  ] });
5698
5721
  }
@@ -5707,11 +5730,13 @@ function MastraNetworkRuntimeProvider({
5707
5730
  memory,
5708
5731
  threadId,
5709
5732
  baseUrl,
5710
- refreshThreadList
5733
+ refreshThreadList,
5734
+ modelSettings = {}
5711
5735
  }) {
5712
5736
  const [isRunning, setIsRunning] = useState(false);
5713
5737
  const [messages, setMessages] = useState(initialMessages || []);
5714
5738
  const [currentThreadId, setCurrentThreadId] = useState(threadId);
5739
+ const { frequencyPenalty, presencePenalty, maxRetries, maxSteps, maxTokens, temperature, topK, topP, instructions } = modelSettings;
5715
5740
  useEffect(() => {
5716
5741
  if (messages.length === 0 || currentThreadId !== threadId) {
5717
5742
  if (initialMessages && threadId && memory) {
@@ -5721,8 +5746,6 @@ function MastraNetworkRuntimeProvider({
5721
5746
  }
5722
5747
  }, [initialMessages, threadId, memory, messages]);
5723
5748
  const mastra = createMastraClient(baseUrl);
5724
- console.log("MastraClient initialized");
5725
- console.log(messages, "###");
5726
5749
  const network = mastra.getNetwork(agentId);
5727
5750
  const onNew = async (message) => {
5728
5751
  if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
@@ -5751,6 +5774,15 @@ function MastraNetworkRuntimeProvider({
5751
5774
  }
5752
5775
  ],
5753
5776
  runId: agentId,
5777
+ frequencyPenalty,
5778
+ presencePenalty,
5779
+ maxRetries,
5780
+ maxSteps,
5781
+ maxTokens,
5782
+ temperature,
5783
+ topK,
5784
+ topP,
5785
+ instructions,
5754
5786
  ...memory ? { threadId, resourceId: agentId } : {}
5755
5787
  });
5756
5788
  if (!response.body) {
@@ -6105,8 +6137,34 @@ const ToolFallback = (props) => {
6105
6137
  }) });
6106
6138
  };
6107
6139
 
6140
+ const defaultModelSettings = {
6141
+ maxRetries: 2,
6142
+ maxSteps: 5,
6143
+ temperature: 0.5,
6144
+ topP: 1
6145
+ };
6146
+ const NetworkContext = createContext({});
6147
+ function NetworkProvider({ children }) {
6148
+ const [modelSettings, setModelSettings] = useState(defaultModelSettings);
6149
+ const resetModelSettings = () => {
6150
+ setModelSettings(defaultModelSettings);
6151
+ };
6152
+ return /* @__PURE__ */ jsx(
6153
+ NetworkContext.Provider,
6154
+ {
6155
+ value: {
6156
+ modelSettings,
6157
+ setModelSettings,
6158
+ resetModelSettings
6159
+ },
6160
+ children
6161
+ }
6162
+ );
6163
+ }
6164
+
6108
6165
  const NetworkChat = ({ agentId, memory }) => {
6109
- return /* @__PURE__ */ jsx(MastraNetworkRuntimeProvider, { agentId, memory, children: /* @__PURE__ */ jsx("div", { className: "h-full pb-4", children: /* @__PURE__ */ jsx(Thread, { ToolFallback }) }) });
6166
+ const { modelSettings } = useContext(NetworkContext);
6167
+ return /* @__PURE__ */ jsx(MastraNetworkRuntimeProvider, { agentId, memory, modelSettings, children: /* @__PURE__ */ jsx("div", { className: "h-full pb-4", children: /* @__PURE__ */ jsx(Thread, { ToolFallback }) }) });
6110
6168
  };
6111
6169
 
6112
6170
  function WorkflowTraces({ workflowName, baseUrl }) {
@@ -8647,7 +8705,7 @@ function VNextWorkflowTrigger({
8647
8705
  ] }) }, stepId) });
8648
8706
  }) })
8649
8707
  ] }),
8650
- isSuspendedSteps && suspendedSteps?.map((step) => {
8708
+ !isWatchingVNextWorkflow && isSuspendedSteps && suspendedSteps?.map((step) => {
8651
8709
  const stepDefinition = vNextWorkflow.steps[step.stepId];
8652
8710
  const stepSchema = stepDefinition?.resumeSchema ? resolveSerializedZodOutput(jsonSchemaToZod(parse(stepDefinition.resumeSchema))) : z.record(z.string(), z.any());
8653
8711
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col px-4", children: [
@@ -8846,5 +8904,5 @@ const DarkLogo = (props) => /* @__PURE__ */ jsxs("svg", { width: "100", height:
8846
8904
  )
8847
8905
  ] });
8848
8906
 
8849
- export { AgentChat, AgentCoinIcon, AgentContext, AgentEvals, AgentIcon, AgentProvider, AgentTraces, AiIcon, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button, Cell, CheckIcon, ChevronIcon, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DbIcon, DebugIcon, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EntryCell, EnvIcon, EvaluatorCoinIcon, FiltersIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, JudgeIcon, LatencyIcon, LogsIcon, MastraResizablePanel, MemoryIcon, NetworkChat, OpenAIIcon, PromptIcon, RepoIcon, Row, ScoreIcon, SettingsIcon, SlashIcon, Table, Tbody, Th, Thead, ToolsIcon, TraceIcon, TsIcon, Txt, TxtCell, UnitCell, VNextWorkflowGraph, VNextWorkflowTrigger, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunProvider, WorkflowTraces, WorkflowTrigger };
8907
+ export { AgentChat, AgentCoinIcon, AgentContext, AgentEvals, AgentIcon, AgentProvider, AgentTraces, AiIcon, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button, Cell, CheckIcon, ChevronIcon, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DbIcon, DebugIcon, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EntryCell, EnvIcon, EvaluatorCoinIcon, FiltersIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, JudgeIcon, LatencyIcon, LogsIcon, MastraResizablePanel, MemoryIcon, NetworkChat, NetworkContext, NetworkProvider, OpenAIIcon, PromptIcon, RepoIcon, Row, ScoreIcon, SettingsIcon, SlashIcon, Table, Tbody, Th, Thead, ToolsIcon, TraceIcon, TsIcon, Txt, TxtCell, UnitCell, VNextWorkflowGraph, VNextWorkflowTrigger, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunProvider, WorkflowTraces, WorkflowTrigger };
8850
8908
  //# sourceMappingURL=index.es.js.map