@mastra/playground-ui 7.0.0-beta.1 → 7.0.0-beta.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
@@ -3163,10 +3163,18 @@ TooltipContent.displayName = TooltipPrimitive__namespace.Content.displayName;
3163
3163
  const TooltipIconButton = React.forwardRef(
3164
3164
  ({ children, tooltip, side = "bottom", className, ...rest }, ref) => {
3165
3165
  return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
3166
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button$2, { variant: "ghost", size: "icon", ...rest, className: cn("size-6 p-1", className), ref, children: [
3167
- children,
3168
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: tooltip })
3169
- ] }) }),
3166
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
3167
+ Button$2,
3168
+ {
3169
+ variant: "ghost",
3170
+ size: "icon",
3171
+ ...rest,
3172
+ className: cn("size-6 p-1", className),
3173
+ ref,
3174
+ "aria-label": tooltip,
3175
+ children
3176
+ }
3177
+ ) }),
3170
3178
  /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side, children: tooltip })
3171
3179
  ] }) });
3172
3180
  }
@@ -4682,6 +4690,8 @@ function convertWorkflowRunStateToStreamResult(runState) {
4682
4690
  status: result.status,
4683
4691
  output: "output" in result ? result.output : void 0,
4684
4692
  payload: "payload" in result ? result.payload : void 0,
4693
+ suspendPayload: "suspendPayload" in result ? result.suspendPayload : void 0,
4694
+ suspendOutput: "suspendOutput" in result ? result.suspendOutput : void 0,
4685
4695
  resumePayload: "resumePayload" in result ? result.resumePayload : void 0,
4686
4696
  error: "error" in result ? result.error : void 0,
4687
4697
  startedAt: "startedAt" in result ? result.startedAt : Date.now(),
@@ -5360,7 +5370,9 @@ const useCurrentRun = () => {
5360
5370
  status: value.status,
5361
5371
  output: "output" in value ? value.output : void 0,
5362
5372
  input: value.payload,
5363
- resumeData: "resumePayload" in value ? value.resumePayload : void 0
5373
+ resumeData: "resumePayload" in value ? value.resumePayload : void 0,
5374
+ suspendOutput: "suspendOutput" in value ? value.suspendOutput : void 0,
5375
+ suspendPayload: "suspendPayload" in value ? value.suspendPayload : void 0
5364
5376
  }
5365
5377
  };
5366
5378
  }, {});
@@ -5426,6 +5438,7 @@ const WorkflowStepActionBar = ({
5426
5438
  input,
5427
5439
  output,
5428
5440
  resumeData,
5441
+ suspendOutput,
5429
5442
  error,
5430
5443
  mapConfig,
5431
5444
  stepName,
@@ -5486,14 +5499,14 @@ const WorkflowStepActionBar = ({
5486
5499
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: resumeData }) })
5487
5500
  ] }) })
5488
5501
  ] }),
5489
- output && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5502
+ (output ?? suspendOutput) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5490
5503
  /* @__PURE__ */ jsxRuntime.jsx(Button$1, { onClick: () => setIsOutputOpen(true), children: "Output" }),
5491
5504
  /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOutputOpen, onOpenChange: setIsOutputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
5492
5505
  /* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
5493
5506
  stepName,
5494
5507
  " output"
5495
5508
  ] }),
5496
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: output }) })
5509
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: output ?? suspendOutput }) })
5497
5510
  ] }) })
5498
5511
  ] }),
5499
5512
  error && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -5673,7 +5686,7 @@ const Clock = ({ startedAt, endedAt }) => {
5673
5686
  };
5674
5687
 
5675
5688
  function WorkflowDefaultNode({ data, parentWorkflowName }) {
5676
- const { steps, runId } = useCurrentRun();
5689
+ const { steps } = useCurrentRun();
5677
5690
  const {
5678
5691
  label,
5679
5692
  stepId,
@@ -5763,6 +5776,7 @@ function WorkflowDefaultNode({ data, parentWorkflowName }) {
5763
5776
  input: step?.input,
5764
5777
  resumeData: step?.resumeData,
5765
5778
  output: step?.output,
5779
+ suspendOutput: step?.suspendOutput,
5766
5780
  error: step?.error,
5767
5781
  mapConfig,
5768
5782
  status: step?.status
@@ -6072,6 +6086,7 @@ function WorkflowNestedNode({ data, parentWorkflowName }) {
6072
6086
  input: step?.input,
6073
6087
  resumeData: step?.resumeData,
6074
6088
  output: step?.output,
6089
+ suspendOutput: step?.suspendOutput,
6075
6090
  error: step?.error,
6076
6091
  mapConfig,
6077
6092
  onShowNestedGraph: () => showNestedGraph({ label, fullStep: fullLabel, stepGraph }),
@@ -7501,10 +7516,10 @@ function WorkflowTrigger({
7501
7516
  setCancelResponse(response);
7502
7517
  };
7503
7518
  const streamResultToUse = result ?? streamResult;
7504
- const suspendedSteps = Object.entries(streamResultToUse?.steps || {}).filter(([_, { status }]) => status === "suspended").map(([stepId, { payload: payload2 }]) => ({
7519
+ const suspendedSteps = Object.entries(streamResultToUse?.steps || {}).filter(([_, { status }]) => status === "suspended").map(([stepId, { suspendPayload }]) => ({
7505
7520
  stepId,
7506
7521
  runId: innerRunId,
7507
- suspendPayload: payload2,
7522
+ suspendPayload,
7508
7523
  isLoading: false
7509
7524
  }));
7510
7525
  React.useEffect(() => {
@@ -7615,11 +7630,23 @@ function WorkflowTrigger({
7615
7630
  /* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "secondary", className: "px-4 text-mastra-el-3", size: "xs", children: "Status" }),
7616
7631
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 flex flex-col gap-4", children: Object.entries(workflowActivePaths).filter(([key, _]) => key !== "input" && !key.endsWith(".input")).map(([stepId, step]) => {
7617
7632
  const { status } = step;
7618
- let output = {};
7633
+ let output = void 0;
7634
+ let suspendOutput = void 0;
7635
+ if (step.status === "suspended") {
7636
+ suspendOutput = step.suspendOutput;
7637
+ }
7619
7638
  if (step.status === "success") {
7620
7639
  output = step.output;
7621
7640
  }
7622
- return /* @__PURE__ */ jsxRuntime.jsx(WorkflowStatus, { stepId, status, result: output }, stepId);
7641
+ return /* @__PURE__ */ jsxRuntime.jsx(
7642
+ WorkflowStatus,
7643
+ {
7644
+ stepId,
7645
+ status,
7646
+ result: output ?? suspendOutput ?? {}
7647
+ },
7648
+ stepId
7649
+ );
7623
7650
  }) })
7624
7651
  ] })
7625
7652
  ] })
@@ -11566,6 +11593,102 @@ const AgentAdvancedSettings = () => {
11566
11593
  ] }) });
11567
11594
  };
11568
11595
 
11596
+ const useAgent = (agentId) => {
11597
+ const client = react$3.useMastraClient();
11598
+ const { requestContext } = usePlaygroundStore();
11599
+ return reactQuery.useQuery({
11600
+ queryKey: ["agent", agentId, JSON.stringify(requestContext)],
11601
+ queryFn: () => agentId ? client.getAgent(agentId).details(requestContext) : null,
11602
+ retry: false,
11603
+ enabled: Boolean(agentId)
11604
+ });
11605
+ };
11606
+
11607
+ const useMemory = (agentId) => {
11608
+ const client = react$3.useMastraClient();
11609
+ const { requestContext } = usePlaygroundStore();
11610
+ return reactQuery.useQuery({
11611
+ queryKey: ["memory", agentId],
11612
+ queryFn: () => agentId ? client.getMemoryStatus(agentId, requestContext) : null,
11613
+ enabled: Boolean(agentId),
11614
+ staleTime: 5 * 60 * 1e3,
11615
+ // 5 minutes
11616
+ gcTime: 10 * 60 * 1e3,
11617
+ // 10 minutes
11618
+ retry: false
11619
+ });
11620
+ };
11621
+ const useMemoryConfig = (agentId) => {
11622
+ const client = react$3.useMastraClient();
11623
+ const { requestContext } = usePlaygroundStore();
11624
+ return reactQuery.useQuery({
11625
+ queryKey: ["memory", "config", agentId],
11626
+ queryFn: () => agentId ? client.getMemoryConfig({ agentId, requestContext }) : null,
11627
+ enabled: Boolean(agentId),
11628
+ staleTime: 5 * 60 * 1e3,
11629
+ // 5 minutes
11630
+ gcTime: 10 * 60 * 1e3,
11631
+ // 10 minutes
11632
+ retry: false,
11633
+ refetchOnWindowFocus: false
11634
+ });
11635
+ };
11636
+ const useThreads = ({
11637
+ resourceId,
11638
+ agentId,
11639
+ isMemoryEnabled
11640
+ }) => {
11641
+ const client = react$3.useMastraClient();
11642
+ const { requestContext } = usePlaygroundStore();
11643
+ return reactQuery.useQuery({
11644
+ queryKey: ["memory", "threads", resourceId, agentId],
11645
+ queryFn: async () => {
11646
+ if (!isMemoryEnabled) return null;
11647
+ const result = await client.listMemoryThreads({ resourceId, agentId, requestContext });
11648
+ return result.threads;
11649
+ },
11650
+ enabled: Boolean(isMemoryEnabled),
11651
+ staleTime: 0,
11652
+ gcTime: 0,
11653
+ retry: false,
11654
+ refetchOnWindowFocus: false
11655
+ });
11656
+ };
11657
+ const useDeleteThread = () => {
11658
+ const client = react$3.useMastraClient();
11659
+ const queryClient = reactQuery.useQueryClient();
11660
+ const { requestContext } = usePlaygroundStore();
11661
+ return reactQuery.useMutation({
11662
+ mutationFn: ({ threadId, agentId }) => {
11663
+ const thread = client.getMemoryThread({ threadId, agentId });
11664
+ return thread.delete({ requestContext });
11665
+ },
11666
+ onSuccess: (_, variables) => {
11667
+ const { agentId } = variables;
11668
+ if (agentId) {
11669
+ queryClient.invalidateQueries({ queryKey: ["memory", "threads", agentId, agentId] });
11670
+ }
11671
+ sonner.toast.success("Chat deleted successfully");
11672
+ },
11673
+ onError: () => {
11674
+ sonner.toast.error("Failed to delete chat");
11675
+ }
11676
+ });
11677
+ };
11678
+ const useMemorySearch = ({
11679
+ agentId,
11680
+ resourceId,
11681
+ threadId
11682
+ }) => {
11683
+ const { requestContext } = usePlaygroundStore();
11684
+ const client = react$3.useMastraClient();
11685
+ return reactQuery.useMutation({
11686
+ mutationFn: async ({ searchQuery, memoryConfig }) => {
11687
+ return client.searchMemory({ agentId, resourceId, threadId, searchQuery, memoryConfig, requestContext });
11688
+ }
11689
+ });
11690
+ };
11691
+
11569
11692
  const NetworkCheckbox = ({ hasMemory, hasSubAgents }) => {
11570
11693
  const isNetworkAvailable = hasMemory && hasSubAgents;
11571
11694
  const radio = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
@@ -11598,8 +11721,19 @@ const NetworkCheckbox = ({ hasMemory, hasSubAgents }) => {
11598
11721
  ] }) })
11599
11722
  ] });
11600
11723
  };
11601
- const AgentSettings = ({ modelVersion, hasMemory = false, hasSubAgents = false }) => {
11724
+ const AgentSettings = ({ agentId }) => {
11725
+ const { data: agent, isLoading } = useAgent(agentId);
11726
+ const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
11602
11727
  const { settings, setSettings, resetAll } = useAgentSettings();
11728
+ if (isLoading || isMemoryLoading) {
11729
+ return /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-full" });
11730
+ }
11731
+ if (!agent) {
11732
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Agent not found" });
11733
+ }
11734
+ const hasMemory = Boolean(memory?.result);
11735
+ const hasSubAgents = Boolean(Object.keys(agent.agents || {}).length > 0);
11736
+ const modelVersion = agent.modelVersion;
11603
11737
  let radioValue;
11604
11738
  if (modelVersion === "v2") {
11605
11739
  if (settings?.modelSettings?.chatWithNetwork) {
@@ -13092,10 +13226,18 @@ function getShortId(id) {
13092
13226
  return id.slice(0, 8);
13093
13227
  }
13094
13228
 
13095
- function Notification({ children, className, isVisible, autoDismiss = true, dismissTime = 5e3 }) {
13229
+ function Notification({
13230
+ children,
13231
+ className,
13232
+ isVisible,
13233
+ autoDismiss = true,
13234
+ dismissTime = 5e3,
13235
+ dismissible = true,
13236
+ type = "info"
13237
+ }) {
13096
13238
  const [localIsVisible, setLocalIsVisible] = React.useState(isVisible);
13097
13239
  React.useEffect(() => {
13098
- if (autoDismiss && isVisible) {
13240
+ if (dismissible && autoDismiss && isVisible) {
13099
13241
  const timer = setTimeout(() => {
13100
13242
  setLocalIsVisible(false);
13101
13243
  }, dismissTime);
@@ -13110,13 +13252,27 @@ function Notification({ children, className, isVisible, autoDismiss = true, dism
13110
13252
  "div",
13111
13253
  {
13112
13254
  className: cn(
13113
- "grid grid-cols-[1fr_auto] gap-[0.5rem] rounded-l bg-white/5 p-[1.5rem] py-[1rem] text-[0.875rem] text-icon3 items-center",
13114
- "[&>svg]:w-[1.1em] [&>svg]:h-[1.1em] [&>svg]:opacity-50",
13255
+ "grid grid-cols-[1fr_auto] gap-[0.5rem] rounded-lg bg-white/5 p-[1.5rem] py-[1rem] text-[0.875rem] text-icon3 items-center",
13256
+ {
13257
+ "bg-red-900/10 border border-red-900": type === "error"
13258
+ },
13115
13259
  className
13116
13260
  ),
13117
13261
  children: [
13118
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-[0.5rem] items-center", children }),
13119
- /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => setLocalIsVisible(false), children: [
13262
+ /* @__PURE__ */ jsxRuntime.jsx(
13263
+ "div",
13264
+ {
13265
+ className: cn(
13266
+ "flex gap-[0.5rem] items-start",
13267
+ "[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-70 [&>svg]:translate-y-[0.2em]",
13268
+ {
13269
+ "[&>svg]:text-red-400": type === "error"
13270
+ }
13271
+ ),
13272
+ children
13273
+ }
13274
+ ),
13275
+ dismissible && /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => setLocalIsVisible(false), children: [
13120
13276
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, {}),
13121
13277
  /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden.VisuallyHidden, { children: "Dismiss" })
13122
13278
  ] })
@@ -14526,6 +14682,67 @@ const PromptEnhancerTextarea = ({ agentId }) => {
14526
14682
  ] });
14527
14683
  };
14528
14684
 
14685
+ const useAgents = () => {
14686
+ const client = react$3.useMastraClient();
14687
+ const { requestContext } = usePlaygroundStore();
14688
+ return reactQuery.useQuery({
14689
+ queryKey: ["agents", JSON.stringify(requestContext)],
14690
+ queryFn: () => client.listAgents(requestContext)
14691
+ });
14692
+ };
14693
+ const useUpdateAgentModel = (agentId) => {
14694
+ const client = react$3.useMastraClient();
14695
+ const queryClient = reactQuery.useQueryClient();
14696
+ return reactQuery.useMutation({
14697
+ mutationFn: async (payload) => client.getAgent(agentId).updateModel(payload),
14698
+ onSuccess: () => {
14699
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14700
+ },
14701
+ onError: (err) => {
14702
+ console.error("Error updating model", err);
14703
+ }
14704
+ });
14705
+ };
14706
+ const useReorderModelList = (agentId) => {
14707
+ const client = react$3.useMastraClient();
14708
+ const queryClient = reactQuery.useQueryClient();
14709
+ return reactQuery.useMutation({
14710
+ mutationFn: async (payload) => client.getAgent(agentId).reorderModelList(payload),
14711
+ onSuccess: () => {
14712
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14713
+ },
14714
+ onError: (err) => {
14715
+ console.error("Error reordering model list", err);
14716
+ }
14717
+ });
14718
+ };
14719
+ const useUpdateModelInModelList = (agentId) => {
14720
+ const client = react$3.useMastraClient();
14721
+ const queryClient = reactQuery.useQueryClient();
14722
+ return reactQuery.useMutation({
14723
+ mutationFn: async (payload) => client.getAgent(agentId).updateModelInModelList(payload),
14724
+ onSuccess: () => {
14725
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14726
+ },
14727
+ onError: (err) => {
14728
+ console.error("Error updating model in model list", err);
14729
+ }
14730
+ });
14731
+ };
14732
+ const useResetAgentModel = (agentId) => {
14733
+ const client = react$3.useMastraClient();
14734
+ const queryClient = reactQuery.useQueryClient();
14735
+ return reactQuery.useMutation({
14736
+ mutationFn: async () => client.getAgent(agentId).resetModel(),
14737
+ onSuccess: () => {
14738
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14739
+ },
14740
+ onError: (err) => {
14741
+ console.error("Error resetting model", err);
14742
+ }
14743
+ });
14744
+ };
14745
+
14529
14746
  const AgentMetadataNetworkList = ({ agents }) => {
14530
14747
  const { Link, paths } = useLinkComponent();
14531
14748
  if (agents.length === 0) {
@@ -14533,16 +14750,20 @@ const AgentMetadataNetworkList = ({ agents }) => {
14533
14750
  }
14534
14751
  return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: agents.map((agent) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: paths.agentLink(agent.id), "data-testid": "agent-badge", children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "success", icon: /* @__PURE__ */ jsxRuntime.jsx(AgentIcon, {}), children: agent.name }) }) }, agent.id)) });
14535
14752
  };
14536
- const AgentMetadata = ({
14537
- agentId,
14538
- agent,
14539
- hasMemoryEnabled,
14540
- updateModel,
14541
- resetModel,
14542
- updateModelInModelList,
14543
- reorderModelList,
14544
- modelVersion
14545
- }) => {
14753
+ const AgentMetadata = ({ agentId }) => {
14754
+ const { data: agent, isLoading } = useAgent(agentId);
14755
+ const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
14756
+ const { mutate: reorderModelList } = useReorderModelList(agentId);
14757
+ const { mutateAsync: resetModel } = useResetAgentModel(agentId);
14758
+ const { mutateAsync: updateModelInModelList } = useUpdateModelInModelList(agentId);
14759
+ const { mutateAsync: updateModel } = useUpdateAgentModel(agentId);
14760
+ const hasMemoryEnabled = Boolean(memory?.result);
14761
+ if (isLoading || isMemoryLoading) {
14762
+ return /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-full" });
14763
+ }
14764
+ if (!agent) {
14765
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Agent not found" });
14766
+ }
14546
14767
  const networkAgentsMap = agent.agents ?? {};
14547
14768
  const networkAgents = Object.keys(networkAgentsMap).map((key) => ({ ...networkAgentsMap[key], id: key }));
14548
14769
  const agentTools = agent.tools ?? {};
@@ -14561,7 +14782,7 @@ const AgentMetadata = ({
14561
14782
  AgentMetadataSection,
14562
14783
  {
14563
14784
  title: "Model",
14564
- hint: modelVersion === "v2" ? void 0 : {
14785
+ hint: agent.modelVersion === "v2" ? void 0 : {
14565
14786
  link: "https://mastra.ai/guides/migrations/vnext-to-standard-apis",
14566
14787
  title: "You are using a legacy v1 model",
14567
14788
  icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangleIcon, { fontSize: 14, className: "mb-0.5" })
@@ -14678,8 +14899,10 @@ const AgentMetadataScorerList = ({ entityId, entityType }) => {
14678
14899
  return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: scorerList.map((scorer) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: paths.scorerLink(scorer.id), "data-testid": "scorer-badge", children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GaugeIcon, { className: "text-icon3" }), children: scorer.scorer.config.name }) }) }, scorer.id)) });
14679
14900
  };
14680
14901
 
14681
- const AgentEntityHeader = ({ agentId, isLoading, agentName }) => {
14902
+ const AgentEntityHeader = ({ agentId }) => {
14903
+ const { data: agent, isLoading } = useAgent(agentId);
14682
14904
  const { handleCopy } = useCopyToClipboard({ text: agentId });
14905
+ const agentName = agent?.name || "";
14683
14906
  return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(EntityHeader, { icon: /* @__PURE__ */ jsxRuntime.jsx(AgentIcon, {}), title: agentName, isLoading, children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
14684
14907
  /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: handleCopy, className: "h-badge-default shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, {}), variant: "default", children: agentId }) }) }),
14685
14908
  /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: "Copy Agent ID for use in code" })
@@ -14883,67 +15106,6 @@ const formatDay = (date) => {
14883
15106
  return new Date(date).toLocaleString("en-us", options).replace(",", " at");
14884
15107
  };
14885
15108
 
14886
- const useAgents = () => {
14887
- const client = react$3.useMastraClient();
14888
- const { requestContext } = usePlaygroundStore();
14889
- return reactQuery.useQuery({
14890
- queryKey: ["agents", JSON.stringify(requestContext)],
14891
- queryFn: () => client.listAgents(requestContext)
14892
- });
14893
- };
14894
- const useUpdateAgentModel = (agentId) => {
14895
- const client = react$3.useMastraClient();
14896
- const queryClient = reactQuery.useQueryClient();
14897
- return reactQuery.useMutation({
14898
- mutationFn: async (payload) => client.getAgent(agentId).updateModel(payload),
14899
- onSuccess: () => {
14900
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14901
- },
14902
- onError: (err) => {
14903
- console.error("Error updating model", err);
14904
- }
14905
- });
14906
- };
14907
- const useReorderModelList = (agentId) => {
14908
- const client = react$3.useMastraClient();
14909
- const queryClient = reactQuery.useQueryClient();
14910
- return reactQuery.useMutation({
14911
- mutationFn: async (payload) => client.getAgent(agentId).reorderModelList(payload),
14912
- onSuccess: () => {
14913
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14914
- },
14915
- onError: (err) => {
14916
- console.error("Error reordering model list", err);
14917
- }
14918
- });
14919
- };
14920
- const useUpdateModelInModelList = (agentId) => {
14921
- const client = react$3.useMastraClient();
14922
- const queryClient = reactQuery.useQueryClient();
14923
- return reactQuery.useMutation({
14924
- mutationFn: async (payload) => client.getAgent(agentId).updateModelInModelList(payload),
14925
- onSuccess: () => {
14926
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14927
- },
14928
- onError: (err) => {
14929
- console.error("Error updating model in model list", err);
14930
- }
14931
- });
14932
- };
14933
- const useResetAgentModel = (agentId) => {
14934
- const client = react$3.useMastraClient();
14935
- const queryClient = reactQuery.useQueryClient();
14936
- return reactQuery.useMutation({
14937
- mutationFn: async () => client.getAgent(agentId).resetModel(),
14938
- onSuccess: () => {
14939
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14940
- },
14941
- onError: (err) => {
14942
- console.error("Error resetting model", err);
14943
- }
14944
- });
14945
- };
14946
-
14947
15109
  function AgentCombobox({
14948
15110
  value,
14949
15111
  onValueChange,
@@ -14991,17 +15153,6 @@ function AgentCombobox({
14991
15153
  );
14992
15154
  }
14993
15155
 
14994
- const useAgent = (agentId) => {
14995
- const client = react$3.useMastraClient();
14996
- const { requestContext } = usePlaygroundStore();
14997
- return reactQuery.useQuery({
14998
- queryKey: ["agent", agentId, JSON.stringify(requestContext)],
14999
- queryFn: () => agentId ? client.getAgent(agentId).details(requestContext) : null,
15000
- retry: false,
15001
- enabled: Boolean(agentId)
15002
- });
15003
- };
15004
-
15005
15156
  const useExecuteAgentTool = () => {
15006
15157
  const client = react$3.useMastraClient();
15007
15158
  return reactQuery.useMutation({
@@ -15109,91 +15260,6 @@ const AgentToolPanel = ({ toolId, agentId }) => {
15109
15260
  );
15110
15261
  };
15111
15262
 
15112
- const useMemory = (agentId) => {
15113
- const client = react$3.useMastraClient();
15114
- const { requestContext } = usePlaygroundStore();
15115
- return reactQuery.useQuery({
15116
- queryKey: ["memory", agentId],
15117
- queryFn: () => agentId ? client.getMemoryStatus(agentId, requestContext) : null,
15118
- enabled: Boolean(agentId),
15119
- staleTime: 5 * 60 * 1e3,
15120
- // 5 minutes
15121
- gcTime: 10 * 60 * 1e3,
15122
- // 10 minutes
15123
- retry: false
15124
- });
15125
- };
15126
- const useMemoryConfig = (agentId) => {
15127
- const client = react$3.useMastraClient();
15128
- const { requestContext } = usePlaygroundStore();
15129
- return reactQuery.useQuery({
15130
- queryKey: ["memory", "config", agentId],
15131
- queryFn: () => agentId ? client.getMemoryConfig({ agentId, requestContext }) : null,
15132
- enabled: Boolean(agentId),
15133
- staleTime: 5 * 60 * 1e3,
15134
- // 5 minutes
15135
- gcTime: 10 * 60 * 1e3,
15136
- // 10 minutes
15137
- retry: false,
15138
- refetchOnWindowFocus: false
15139
- });
15140
- };
15141
- const useThreads = ({
15142
- resourceId,
15143
- agentId,
15144
- isMemoryEnabled
15145
- }) => {
15146
- const client = react$3.useMastraClient();
15147
- const { requestContext } = usePlaygroundStore();
15148
- return reactQuery.useQuery({
15149
- queryKey: ["memory", "threads", resourceId, agentId],
15150
- queryFn: async () => {
15151
- if (!isMemoryEnabled) return null;
15152
- const result = await client.listMemoryThreads({ resourceId, agentId, requestContext });
15153
- return result.threads;
15154
- },
15155
- enabled: Boolean(isMemoryEnabled),
15156
- staleTime: 0,
15157
- gcTime: 0,
15158
- retry: false,
15159
- refetchOnWindowFocus: false
15160
- });
15161
- };
15162
- const useDeleteThread = () => {
15163
- const client = react$3.useMastraClient();
15164
- const queryClient = reactQuery.useQueryClient();
15165
- const { requestContext } = usePlaygroundStore();
15166
- return reactQuery.useMutation({
15167
- mutationFn: ({ threadId, agentId }) => {
15168
- const thread = client.getMemoryThread({ threadId, agentId });
15169
- return thread.delete({ requestContext });
15170
- },
15171
- onSuccess: (_, variables) => {
15172
- const { agentId } = variables;
15173
- if (agentId) {
15174
- queryClient.invalidateQueries({ queryKey: ["memory", "threads", agentId, agentId] });
15175
- }
15176
- sonner.toast.success("Chat deleted successfully");
15177
- },
15178
- onError: () => {
15179
- sonner.toast.error("Failed to delete chat");
15180
- }
15181
- });
15182
- };
15183
- const useMemorySearch = ({
15184
- agentId,
15185
- resourceId,
15186
- threadId
15187
- }) => {
15188
- const { requestContext } = usePlaygroundStore();
15189
- const client = react$3.useMastraClient();
15190
- return reactQuery.useMutation({
15191
- mutationFn: async ({ searchQuery, memoryConfig }) => {
15192
- return client.searchMemory({ agentId, resourceId, threadId, searchQuery, memoryConfig, requestContext });
15193
- }
15194
- });
15195
- };
15196
-
15197
15263
  function MarkdownRenderer({ children }) {
15198
15264
  const processedText = children.replace(/\\n/g, "\n");
15199
15265
  return /* @__PURE__ */ jsxRuntime.jsx(Markdown, { remarkPlugins: [remarkGfm], components: COMPONENTS, className: "space-y-3", children: processedText });
@@ -15975,14 +16041,24 @@ const TabContent$1 = ({ children, value }) => {
15975
16041
  };
15976
16042
 
15977
16043
  function AgentInformation({ agentId, threadId }) {
15978
- const { data: agent, isLoading } = useAgent(agentId);
15979
- const { mutateAsync: updateModel } = useUpdateAgentModel(agentId);
15980
- const { mutateAsync: resetModel } = useResetAgentModel(agentId);
15981
- const { mutate: reorderModelList } = useReorderModelList(agentId);
15982
- const { mutateAsync: updateModelInModelList } = useUpdateModelInModelList(agentId);
15983
- const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
15984
- const { settings, setSettings } = useAgentSettings();
15985
- const STORAGE_KEY = "agent-info-selected-tab";
16044
+ const { data: memory } = useMemory(agentId);
16045
+ const hasMemory = Boolean(memory?.result);
16046
+ return /* @__PURE__ */ jsxRuntime.jsxs(AgentInformationLayout, { agentId, children: [
16047
+ /* @__PURE__ */ jsxRuntime.jsx(AgentEntityHeader, { agentId }),
16048
+ /* @__PURE__ */ jsxRuntime.jsxs(AgentInformationTabLayout, { agentId, children: [
16049
+ /* @__PURE__ */ jsxRuntime.jsxs(TabList$1, { children: [
16050
+ /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "overview", children: "Overview" }),
16051
+ /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "model-settings", children: "Model Settings" }),
16052
+ hasMemory && /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "memory", children: "Memory" })
16053
+ ] }),
16054
+ /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "overview", children: /* @__PURE__ */ jsxRuntime.jsx(AgentMetadata, { agentId }) }),
16055
+ /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "model-settings", children: /* @__PURE__ */ jsxRuntime.jsx(AgentSettings, { agentId }) }),
16056
+ hasMemory && /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "memory", children: /* @__PURE__ */ jsxRuntime.jsx(AgentMemory, { agentId, threadId }) })
16057
+ ] })
16058
+ ] });
16059
+ }
16060
+ const STORAGE_KEY = "agent-info-selected-tab";
16061
+ const useAgentInformationTab = ({ isMemoryLoading, hasMemory }) => {
15986
16062
  const [selectedTab, setSelectedTab] = React.useState(() => {
15987
16063
  return sessionStorage.getItem(STORAGE_KEY) || "overview";
15988
16064
  });
@@ -15991,7 +16067,20 @@ function AgentInformation({ agentId, threadId }) {
15991
16067
  sessionStorage.setItem(STORAGE_KEY, value);
15992
16068
  };
15993
16069
  React.useEffect(() => {
15994
- if (agent?.modelId?.includes("gpt-5")) {
16070
+ if (!isMemoryLoading && !hasMemory && selectedTab === "memory") {
16071
+ setSelectedTab("overview");
16072
+ sessionStorage.setItem(STORAGE_KEY, "overview");
16073
+ }
16074
+ }, [isMemoryLoading, hasMemory, selectedTab]);
16075
+ return {
16076
+ selectedTab,
16077
+ handleTabChange
16078
+ };
16079
+ };
16080
+ const useAgentInformationSettings = ({ modelId }) => {
16081
+ const { settings, setSettings } = useAgentSettings();
16082
+ React.useEffect(() => {
16083
+ if (modelId?.includes("gpt-5")) {
15995
16084
  setSettings({
15996
16085
  ...settings || {},
15997
16086
  modelSettings: {
@@ -16000,51 +16089,26 @@ function AgentInformation({ agentId, threadId }) {
16000
16089
  }
16001
16090
  });
16002
16091
  }
16003
- }, [agent]);
16004
- React.useEffect(() => {
16005
- if (!isMemoryLoading && !memory?.result && selectedTab === "memory") {
16006
- handleTabChange("overview");
16007
- }
16008
- }, [isMemoryLoading, memory?.result, selectedTab]);
16009
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-rows-[auto_1fr] h-full items-start overflow-y-auto border-l-sm border-border1", children: [
16010
- /* @__PURE__ */ jsxRuntime.jsx(AgentEntityHeader, { agentId, isLoading: isMemoryLoading, agentName: agent?.name || "" }),
16011
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden border-t-sm border-border1 flex flex-col", children: /* @__PURE__ */ jsxRuntime.jsxs(PlaygroundTabs, { defaultTab: "overview", value: selectedTab, onValueChange: handleTabChange, children: [
16012
- /* @__PURE__ */ jsxRuntime.jsxs(TabList$1, { children: [
16013
- /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "overview", children: "Overview" }),
16014
- /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "model-settings", children: "Model Settings" }),
16015
- memory?.result && /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "memory", children: "Memory" })
16016
- ] }),
16017
- /* @__PURE__ */ jsxRuntime.jsxs(TabContent$1, { value: "overview", children: [
16018
- isLoading && /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-full" }),
16019
- agent && /* @__PURE__ */ jsxRuntime.jsx(
16020
- AgentMetadata,
16021
- {
16022
- agentId,
16023
- agent,
16024
- updateModel,
16025
- resetModel,
16026
- updateModelInModelList,
16027
- reorderModelList,
16028
- hasMemoryEnabled: Boolean(memory?.result),
16029
- modelVersion: agent.modelVersion
16030
- }
16031
- )
16032
- ] }),
16033
- /* @__PURE__ */ jsxRuntime.jsxs(TabContent$1, { value: "model-settings", children: [
16034
- isLoading && /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-full" }),
16035
- agent && /* @__PURE__ */ jsxRuntime.jsx(
16036
- AgentSettings,
16037
- {
16038
- modelVersion: agent.modelVersion,
16039
- hasMemory: Boolean(memory?.result),
16040
- hasSubAgents: Boolean(Object.keys(agent.agents || {}).length > 0)
16041
- }
16042
- )
16043
- ] }),
16044
- /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "memory", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-full" }) : /* @__PURE__ */ jsxRuntime.jsx(AgentMemory, { agentId, threadId }) })
16045
- ] }) })
16046
- ] });
16047
- }
16092
+ }, [modelId]);
16093
+ return {
16094
+ settings,
16095
+ setSettings
16096
+ };
16097
+ };
16098
+ const AgentInformationLayout = ({ children, agentId }) => {
16099
+ const { data: agent } = useAgent(agentId);
16100
+ useAgentInformationSettings({ modelId: agent?.modelId || "" });
16101
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-rows-[auto_1fr] h-full items-start overflow-y-auto border-l-sm border-border1", children });
16102
+ };
16103
+ const AgentInformationTabLayout = ({ children, agentId }) => {
16104
+ const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
16105
+ const hasMemory = Boolean(memory?.result);
16106
+ const { selectedTab, handleTabChange } = useAgentInformationTab({
16107
+ isMemoryLoading,
16108
+ hasMemory
16109
+ });
16110
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden border-t-sm border-border1 flex flex-col", children: /* @__PURE__ */ jsxRuntime.jsx(PlaygroundTabs, { defaultTab: "overview", value: selectedTab, onValueChange: handleTabChange, children }) });
16111
+ };
16048
16112
 
16049
16113
  const NameCell$1 = ({ row }) => {
16050
16114
  const { Link, paths } = useLinkComponent();
@@ -17718,7 +17782,15 @@ function SpanTabs({
17718
17782
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleGaugeIcon, {}),
17719
17783
  " Scoring"
17720
17784
  ] }) }),
17721
- /* @__PURE__ */ jsxRuntime.jsx(SpanScoring, { traceId: trace?.traceId, spanId: span?.spanId, entityType })
17785
+ /* @__PURE__ */ jsxRuntime.jsx(
17786
+ SpanScoring,
17787
+ {
17788
+ traceId: trace?.traceId,
17789
+ isTopLevelSpan: span?.parentSpanId === null,
17790
+ spanId: span?.spanId,
17791
+ entityType
17792
+ }
17793
+ )
17722
17794
  ] }),
17723
17795
  /* @__PURE__ */ jsxRuntime.jsxs(Section, { children: [
17724
17796
  /* @__PURE__ */ jsxRuntime.jsx(Section.Header, { children: /* @__PURE__ */ jsxRuntime.jsxs(Section.Heading, { children: [
@@ -18315,8 +18387,8 @@ const useTriggerScorer = () => {
18315
18387
  });
18316
18388
  };
18317
18389
 
18318
- const SpanScoring = ({ traceId, spanId, entityType }) => {
18319
- const { data: scorers = {}, isLoading } = useScorers();
18390
+ const SpanScoring = ({ traceId, spanId, entityType, isTopLevelSpan }) => {
18391
+ const { data: scorers = {}, isLoading, error } = useScorers();
18320
18392
  const [selectedScorer, setSelectedScorer] = React.useState(null);
18321
18393
  const { mutate: triggerScorer, isPending, isSuccess } = useTriggerScorer();
18322
18394
  const [notificationIsVisible, setNotificationIsVisible] = React.useState(false);
@@ -18332,7 +18404,7 @@ const SpanScoring = ({ traceId, spanId, entityType }) => {
18332
18404
  isRegistered: scorer.isRegistered,
18333
18405
  type: scorer.scorer.config.type
18334
18406
  })).filter((scorer) => scorer.isRegistered);
18335
- if (entityType !== "Agent" || spanId) {
18407
+ if (entityType !== "Agent" || !isTopLevelSpan) {
18336
18408
  scorerList = scorerList.filter((scorer) => scorer.type !== "agent");
18337
18409
  }
18338
18410
  const isWaiting = isPending || isLoading;
@@ -18351,6 +18423,19 @@ const SpanScoring = ({ traceId, spanId, entityType }) => {
18351
18423
  setNotificationIsVisible(false);
18352
18424
  };
18353
18425
  const selectedScorerDescription = scorerList.find((s) => s.name === selectedScorer)?.description || "";
18426
+ if (error) {
18427
+ return /* @__PURE__ */ jsxRuntime.jsxs(Notification, { isVisible: true, autoDismiss: false, type: "error", children: [
18428
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, {}),
18429
+ " ",
18430
+ error?.message ? error.message : "Failed to load scorers."
18431
+ ] });
18432
+ }
18433
+ if (scorerList.length === 0) {
18434
+ return /* @__PURE__ */ jsxRuntime.jsxs(Notification, { isVisible: true, dismissible: false, children: [
18435
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, {}),
18436
+ " No eligible scorers have been defined to run."
18437
+ ] });
18438
+ }
18354
18439
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
18355
18440
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[3fr_1fr] gap-[1rem] items-start", children: [
18356
18441
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-[0.5rem]", children: [
@@ -18957,6 +19042,9 @@ exports.AgentCombobox = AgentCombobox;
18957
19042
  exports.AgentEntityHeader = AgentEntityHeader;
18958
19043
  exports.AgentIcon = AgentIcon;
18959
19044
  exports.AgentInformation = AgentInformation;
19045
+ exports.AgentInformationLayout = AgentInformationLayout;
19046
+ exports.AgentInformationTabLayout = AgentInformationTabLayout;
19047
+ exports.AgentMemory = AgentMemory;
18960
19048
  exports.AgentMetadata = AgentMetadata;
18961
19049
  exports.AgentMetadataList = AgentMetadataList;
18962
19050
  exports.AgentMetadataListEmpty = AgentMetadataListEmpty;
@@ -19153,6 +19241,8 @@ exports.toast = toast;
19153
19241
  exports.traceScoresListColumns = traceScoresListColumns;
19154
19242
  exports.tracesListColumns = tracesListColumns;
19155
19243
  exports.useAgent = useAgent;
19244
+ exports.useAgentInformationSettings = useAgentInformationSettings;
19245
+ exports.useAgentInformationTab = useAgentInformationTab;
19156
19246
  exports.useAgentPromptExperiment = useAgentPromptExperiment;
19157
19247
  exports.useAgentSettings = useAgentSettings;
19158
19248
  exports.useAgents = useAgents;