@mastra/playground-ui 7.0.0-beta.2 → 7.0.0-beta.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.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
  }
@@ -11585,6 +11593,102 @@ const AgentAdvancedSettings = () => {
11585
11593
  ] }) });
11586
11594
  };
11587
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
+
11588
11692
  const NetworkCheckbox = ({ hasMemory, hasSubAgents }) => {
11589
11693
  const isNetworkAvailable = hasMemory && hasSubAgents;
11590
11694
  const radio = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
@@ -11617,8 +11721,19 @@ const NetworkCheckbox = ({ hasMemory, hasSubAgents }) => {
11617
11721
  ] }) })
11618
11722
  ] });
11619
11723
  };
11620
- 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);
11621
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;
11622
11737
  let radioValue;
11623
11738
  if (modelVersion === "v2") {
11624
11739
  if (settings?.modelSettings?.chatWithNetwork) {
@@ -13111,10 +13226,18 @@ function getShortId(id) {
13111
13226
  return id.slice(0, 8);
13112
13227
  }
13113
13228
 
13114
- 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
+ }) {
13115
13238
  const [localIsVisible, setLocalIsVisible] = React.useState(isVisible);
13116
13239
  React.useEffect(() => {
13117
- if (autoDismiss && isVisible) {
13240
+ if (dismissible && autoDismiss && isVisible) {
13118
13241
  const timer = setTimeout(() => {
13119
13242
  setLocalIsVisible(false);
13120
13243
  }, dismissTime);
@@ -13129,13 +13252,27 @@ function Notification({ children, className, isVisible, autoDismiss = true, dism
13129
13252
  "div",
13130
13253
  {
13131
13254
  className: cn(
13132
- "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",
13133
- "[&>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
+ },
13134
13259
  className
13135
13260
  ),
13136
13261
  children: [
13137
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-[0.5rem] items-center", children }),
13138
- /* @__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: [
13139
13276
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, {}),
13140
13277
  /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden.VisuallyHidden, { children: "Dismiss" })
13141
13278
  ] })
@@ -14545,6 +14682,67 @@ const PromptEnhancerTextarea = ({ agentId }) => {
14545
14682
  ] });
14546
14683
  };
14547
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
+
14548
14746
  const AgentMetadataNetworkList = ({ agents }) => {
14549
14747
  const { Link, paths } = useLinkComponent();
14550
14748
  if (agents.length === 0) {
@@ -14552,16 +14750,20 @@ const AgentMetadataNetworkList = ({ agents }) => {
14552
14750
  }
14553
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)) });
14554
14752
  };
14555
- const AgentMetadata = ({
14556
- agentId,
14557
- agent,
14558
- hasMemoryEnabled,
14559
- updateModel,
14560
- resetModel,
14561
- updateModelInModelList,
14562
- reorderModelList,
14563
- modelVersion
14564
- }) => {
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
+ }
14565
14767
  const networkAgentsMap = agent.agents ?? {};
14566
14768
  const networkAgents = Object.keys(networkAgentsMap).map((key) => ({ ...networkAgentsMap[key], id: key }));
14567
14769
  const agentTools = agent.tools ?? {};
@@ -14569,6 +14771,7 @@ const AgentMetadata = ({
14569
14771
  const agentWorkflows = agent.workflows ?? {};
14570
14772
  const workflows = Object.keys(agentWorkflows).map((key) => ({ id: key, ...agentWorkflows[key] }));
14571
14773
  return /* @__PURE__ */ jsxRuntime.jsxs(AgentMetadataWrapper, { children: [
14774
+ agent?.description && /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataSection, { title: "Description", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: agent.description }) }),
14572
14775
  agent.modelList ? /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataSection, { title: "Models", children: /* @__PURE__ */ jsxRuntime.jsx(
14573
14776
  AgentMetadataModelList,
14574
14777
  {
@@ -14580,7 +14783,7 @@ const AgentMetadata = ({
14580
14783
  AgentMetadataSection,
14581
14784
  {
14582
14785
  title: "Model",
14583
- hint: modelVersion === "v2" ? void 0 : {
14786
+ hint: agent.modelVersion === "v2" ? void 0 : {
14584
14787
  link: "https://mastra.ai/guides/migrations/vnext-to-standard-apis",
14585
14788
  title: "You are using a legacy v1 model",
14586
14789
  icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangleIcon, { fontSize: 14, className: "mb-0.5" })
@@ -14697,8 +14900,10 @@ const AgentMetadataScorerList = ({ entityId, entityType }) => {
14697
14900
  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)) });
14698
14901
  };
14699
14902
 
14700
- const AgentEntityHeader = ({ agentId, isLoading, agentName }) => {
14903
+ const AgentEntityHeader = ({ agentId }) => {
14904
+ const { data: agent, isLoading } = useAgent(agentId);
14701
14905
  const { handleCopy } = useCopyToClipboard({ text: agentId });
14906
+ const agentName = agent?.name || "";
14702
14907
  return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(EntityHeader, { icon: /* @__PURE__ */ jsxRuntime.jsx(AgentIcon, {}), title: agentName, isLoading, children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
14703
14908
  /* @__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 }) }) }),
14704
14909
  /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: "Copy Agent ID for use in code" })
@@ -14902,67 +15107,6 @@ const formatDay = (date) => {
14902
15107
  return new Date(date).toLocaleString("en-us", options).replace(",", " at");
14903
15108
  };
14904
15109
 
14905
- const useAgents = () => {
14906
- const client = react$3.useMastraClient();
14907
- const { requestContext } = usePlaygroundStore();
14908
- return reactQuery.useQuery({
14909
- queryKey: ["agents", JSON.stringify(requestContext)],
14910
- queryFn: () => client.listAgents(requestContext)
14911
- });
14912
- };
14913
- const useUpdateAgentModel = (agentId) => {
14914
- const client = react$3.useMastraClient();
14915
- const queryClient = reactQuery.useQueryClient();
14916
- return reactQuery.useMutation({
14917
- mutationFn: async (payload) => client.getAgent(agentId).updateModel(payload),
14918
- onSuccess: () => {
14919
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14920
- },
14921
- onError: (err) => {
14922
- console.error("Error updating model", err);
14923
- }
14924
- });
14925
- };
14926
- const useReorderModelList = (agentId) => {
14927
- const client = react$3.useMastraClient();
14928
- const queryClient = reactQuery.useQueryClient();
14929
- return reactQuery.useMutation({
14930
- mutationFn: async (payload) => client.getAgent(agentId).reorderModelList(payload),
14931
- onSuccess: () => {
14932
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14933
- },
14934
- onError: (err) => {
14935
- console.error("Error reordering model list", err);
14936
- }
14937
- });
14938
- };
14939
- const useUpdateModelInModelList = (agentId) => {
14940
- const client = react$3.useMastraClient();
14941
- const queryClient = reactQuery.useQueryClient();
14942
- return reactQuery.useMutation({
14943
- mutationFn: async (payload) => client.getAgent(agentId).updateModelInModelList(payload),
14944
- onSuccess: () => {
14945
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14946
- },
14947
- onError: (err) => {
14948
- console.error("Error updating model in model list", err);
14949
- }
14950
- });
14951
- };
14952
- const useResetAgentModel = (agentId) => {
14953
- const client = react$3.useMastraClient();
14954
- const queryClient = reactQuery.useQueryClient();
14955
- return reactQuery.useMutation({
14956
- mutationFn: async () => client.getAgent(agentId).resetModel(),
14957
- onSuccess: () => {
14958
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14959
- },
14960
- onError: (err) => {
14961
- console.error("Error resetting model", err);
14962
- }
14963
- });
14964
- };
14965
-
14966
15110
  function AgentCombobox({
14967
15111
  value,
14968
15112
  onValueChange,
@@ -15010,17 +15154,6 @@ function AgentCombobox({
15010
15154
  );
15011
15155
  }
15012
15156
 
15013
- const useAgent = (agentId) => {
15014
- const client = react$3.useMastraClient();
15015
- const { requestContext } = usePlaygroundStore();
15016
- return reactQuery.useQuery({
15017
- queryKey: ["agent", agentId, JSON.stringify(requestContext)],
15018
- queryFn: () => agentId ? client.getAgent(agentId).details(requestContext) : null,
15019
- retry: false,
15020
- enabled: Boolean(agentId)
15021
- });
15022
- };
15023
-
15024
15157
  const useExecuteAgentTool = () => {
15025
15158
  const client = react$3.useMastraClient();
15026
15159
  return reactQuery.useMutation({
@@ -15128,91 +15261,6 @@ const AgentToolPanel = ({ toolId, agentId }) => {
15128
15261
  );
15129
15262
  };
15130
15263
 
15131
- const useMemory = (agentId) => {
15132
- const client = react$3.useMastraClient();
15133
- const { requestContext } = usePlaygroundStore();
15134
- return reactQuery.useQuery({
15135
- queryKey: ["memory", agentId],
15136
- queryFn: () => agentId ? client.getMemoryStatus(agentId, requestContext) : null,
15137
- enabled: Boolean(agentId),
15138
- staleTime: 5 * 60 * 1e3,
15139
- // 5 minutes
15140
- gcTime: 10 * 60 * 1e3,
15141
- // 10 minutes
15142
- retry: false
15143
- });
15144
- };
15145
- const useMemoryConfig = (agentId) => {
15146
- const client = react$3.useMastraClient();
15147
- const { requestContext } = usePlaygroundStore();
15148
- return reactQuery.useQuery({
15149
- queryKey: ["memory", "config", agentId],
15150
- queryFn: () => agentId ? client.getMemoryConfig({ agentId, requestContext }) : null,
15151
- enabled: Boolean(agentId),
15152
- staleTime: 5 * 60 * 1e3,
15153
- // 5 minutes
15154
- gcTime: 10 * 60 * 1e3,
15155
- // 10 minutes
15156
- retry: false,
15157
- refetchOnWindowFocus: false
15158
- });
15159
- };
15160
- const useThreads = ({
15161
- resourceId,
15162
- agentId,
15163
- isMemoryEnabled
15164
- }) => {
15165
- const client = react$3.useMastraClient();
15166
- const { requestContext } = usePlaygroundStore();
15167
- return reactQuery.useQuery({
15168
- queryKey: ["memory", "threads", resourceId, agentId],
15169
- queryFn: async () => {
15170
- if (!isMemoryEnabled) return null;
15171
- const result = await client.listMemoryThreads({ resourceId, agentId, requestContext });
15172
- return result.threads;
15173
- },
15174
- enabled: Boolean(isMemoryEnabled),
15175
- staleTime: 0,
15176
- gcTime: 0,
15177
- retry: false,
15178
- refetchOnWindowFocus: false
15179
- });
15180
- };
15181
- const useDeleteThread = () => {
15182
- const client = react$3.useMastraClient();
15183
- const queryClient = reactQuery.useQueryClient();
15184
- const { requestContext } = usePlaygroundStore();
15185
- return reactQuery.useMutation({
15186
- mutationFn: ({ threadId, agentId }) => {
15187
- const thread = client.getMemoryThread({ threadId, agentId });
15188
- return thread.delete({ requestContext });
15189
- },
15190
- onSuccess: (_, variables) => {
15191
- const { agentId } = variables;
15192
- if (agentId) {
15193
- queryClient.invalidateQueries({ queryKey: ["memory", "threads", agentId, agentId] });
15194
- }
15195
- sonner.toast.success("Chat deleted successfully");
15196
- },
15197
- onError: () => {
15198
- sonner.toast.error("Failed to delete chat");
15199
- }
15200
- });
15201
- };
15202
- const useMemorySearch = ({
15203
- agentId,
15204
- resourceId,
15205
- threadId
15206
- }) => {
15207
- const { requestContext } = usePlaygroundStore();
15208
- const client = react$3.useMastraClient();
15209
- return reactQuery.useMutation({
15210
- mutationFn: async ({ searchQuery, memoryConfig }) => {
15211
- return client.searchMemory({ agentId, resourceId, threadId, searchQuery, memoryConfig, requestContext });
15212
- }
15213
- });
15214
- };
15215
-
15216
15264
  function MarkdownRenderer({ children }) {
15217
15265
  const processedText = children.replace(/\\n/g, "\n");
15218
15266
  return /* @__PURE__ */ jsxRuntime.jsx(Markdown, { remarkPlugins: [remarkGfm], components: COMPONENTS, className: "space-y-3", children: processedText });
@@ -15994,14 +16042,24 @@ const TabContent$1 = ({ children, value }) => {
15994
16042
  };
15995
16043
 
15996
16044
  function AgentInformation({ agentId, threadId }) {
15997
- const { data: agent, isLoading } = useAgent(agentId);
15998
- const { mutateAsync: updateModel } = useUpdateAgentModel(agentId);
15999
- const { mutateAsync: resetModel } = useResetAgentModel(agentId);
16000
- const { mutate: reorderModelList } = useReorderModelList(agentId);
16001
- const { mutateAsync: updateModelInModelList } = useUpdateModelInModelList(agentId);
16002
- const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
16003
- const { settings, setSettings } = useAgentSettings();
16004
- const STORAGE_KEY = "agent-info-selected-tab";
16045
+ const { data: memory } = useMemory(agentId);
16046
+ const hasMemory = Boolean(memory?.result);
16047
+ return /* @__PURE__ */ jsxRuntime.jsxs(AgentInformationLayout, { agentId, children: [
16048
+ /* @__PURE__ */ jsxRuntime.jsx(AgentEntityHeader, { agentId }),
16049
+ /* @__PURE__ */ jsxRuntime.jsxs(AgentInformationTabLayout, { agentId, children: [
16050
+ /* @__PURE__ */ jsxRuntime.jsxs(TabList$1, { children: [
16051
+ /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "overview", children: "Overview" }),
16052
+ /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "model-settings", children: "Model Settings" }),
16053
+ hasMemory && /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "memory", children: "Memory" })
16054
+ ] }),
16055
+ /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "overview", children: /* @__PURE__ */ jsxRuntime.jsx(AgentMetadata, { agentId }) }),
16056
+ /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "model-settings", children: /* @__PURE__ */ jsxRuntime.jsx(AgentSettings, { agentId }) }),
16057
+ hasMemory && /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "memory", children: /* @__PURE__ */ jsxRuntime.jsx(AgentMemory, { agentId, threadId }) })
16058
+ ] })
16059
+ ] });
16060
+ }
16061
+ const STORAGE_KEY = "agent-info-selected-tab";
16062
+ const useAgentInformationTab = ({ isMemoryLoading, hasMemory }) => {
16005
16063
  const [selectedTab, setSelectedTab] = React.useState(() => {
16006
16064
  return sessionStorage.getItem(STORAGE_KEY) || "overview";
16007
16065
  });
@@ -16010,7 +16068,20 @@ function AgentInformation({ agentId, threadId }) {
16010
16068
  sessionStorage.setItem(STORAGE_KEY, value);
16011
16069
  };
16012
16070
  React.useEffect(() => {
16013
- if (agent?.modelId?.includes("gpt-5")) {
16071
+ if (!isMemoryLoading && !hasMemory && selectedTab === "memory") {
16072
+ setSelectedTab("overview");
16073
+ sessionStorage.setItem(STORAGE_KEY, "overview");
16074
+ }
16075
+ }, [isMemoryLoading, hasMemory, selectedTab]);
16076
+ return {
16077
+ selectedTab,
16078
+ handleTabChange
16079
+ };
16080
+ };
16081
+ const useAgentInformationSettings = ({ modelId }) => {
16082
+ const { settings, setSettings } = useAgentSettings();
16083
+ React.useEffect(() => {
16084
+ if (modelId?.includes("gpt-5")) {
16014
16085
  setSettings({
16015
16086
  ...settings || {},
16016
16087
  modelSettings: {
@@ -16019,51 +16090,26 @@ function AgentInformation({ agentId, threadId }) {
16019
16090
  }
16020
16091
  });
16021
16092
  }
16022
- }, [agent]);
16023
- React.useEffect(() => {
16024
- if (!isMemoryLoading && !memory?.result && selectedTab === "memory") {
16025
- handleTabChange("overview");
16026
- }
16027
- }, [isMemoryLoading, memory?.result, selectedTab]);
16028
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-rows-[auto_1fr] h-full items-start overflow-y-auto border-l-sm border-border1", children: [
16029
- /* @__PURE__ */ jsxRuntime.jsx(AgentEntityHeader, { agentId, isLoading: isMemoryLoading, agentName: agent?.name || "" }),
16030
- /* @__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: [
16031
- /* @__PURE__ */ jsxRuntime.jsxs(TabList$1, { children: [
16032
- /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "overview", children: "Overview" }),
16033
- /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "model-settings", children: "Model Settings" }),
16034
- memory?.result && /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "memory", children: "Memory" })
16035
- ] }),
16036
- /* @__PURE__ */ jsxRuntime.jsxs(TabContent$1, { value: "overview", children: [
16037
- isLoading && /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-full" }),
16038
- agent && /* @__PURE__ */ jsxRuntime.jsx(
16039
- AgentMetadata,
16040
- {
16041
- agentId,
16042
- agent,
16043
- updateModel,
16044
- resetModel,
16045
- updateModelInModelList,
16046
- reorderModelList,
16047
- hasMemoryEnabled: Boolean(memory?.result),
16048
- modelVersion: agent.modelVersion
16049
- }
16050
- )
16051
- ] }),
16052
- /* @__PURE__ */ jsxRuntime.jsxs(TabContent$1, { value: "model-settings", children: [
16053
- isLoading && /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-full" }),
16054
- agent && /* @__PURE__ */ jsxRuntime.jsx(
16055
- AgentSettings,
16056
- {
16057
- modelVersion: agent.modelVersion,
16058
- hasMemory: Boolean(memory?.result),
16059
- hasSubAgents: Boolean(Object.keys(agent.agents || {}).length > 0)
16060
- }
16061
- )
16062
- ] }),
16063
- /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "memory", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-full" }) : /* @__PURE__ */ jsxRuntime.jsx(AgentMemory, { agentId, threadId }) })
16064
- ] }) })
16065
- ] });
16066
- }
16093
+ }, [modelId]);
16094
+ return {
16095
+ settings,
16096
+ setSettings
16097
+ };
16098
+ };
16099
+ const AgentInformationLayout = ({ children, agentId }) => {
16100
+ const { data: agent } = useAgent(agentId);
16101
+ useAgentInformationSettings({ modelId: agent?.modelId || "" });
16102
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-rows-[auto_1fr] h-full items-start overflow-y-auto border-l-sm border-border1", children });
16103
+ };
16104
+ const AgentInformationTabLayout = ({ children, agentId }) => {
16105
+ const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
16106
+ const hasMemory = Boolean(memory?.result);
16107
+ const { selectedTab, handleTabChange } = useAgentInformationTab({
16108
+ isMemoryLoading,
16109
+ hasMemory
16110
+ });
16111
+ 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 }) });
16112
+ };
16067
16113
 
16068
16114
  const NameCell$1 = ({ row }) => {
16069
16115
  const { Link, paths } = useLinkComponent();
@@ -17737,7 +17783,15 @@ function SpanTabs({
17737
17783
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleGaugeIcon, {}),
17738
17784
  " Scoring"
17739
17785
  ] }) }),
17740
- /* @__PURE__ */ jsxRuntime.jsx(SpanScoring, { traceId: trace?.traceId, spanId: span?.spanId, entityType })
17786
+ /* @__PURE__ */ jsxRuntime.jsx(
17787
+ SpanScoring,
17788
+ {
17789
+ traceId: trace?.traceId,
17790
+ isTopLevelSpan: span?.parentSpanId === null,
17791
+ spanId: span?.spanId,
17792
+ entityType
17793
+ }
17794
+ )
17741
17795
  ] }),
17742
17796
  /* @__PURE__ */ jsxRuntime.jsxs(Section, { children: [
17743
17797
  /* @__PURE__ */ jsxRuntime.jsx(Section.Header, { children: /* @__PURE__ */ jsxRuntime.jsxs(Section.Heading, { children: [
@@ -18334,8 +18388,8 @@ const useTriggerScorer = () => {
18334
18388
  });
18335
18389
  };
18336
18390
 
18337
- const SpanScoring = ({ traceId, spanId, entityType }) => {
18338
- const { data: scorers = {}, isLoading } = useScorers();
18391
+ const SpanScoring = ({ traceId, spanId, entityType, isTopLevelSpan }) => {
18392
+ const { data: scorers = {}, isLoading, error } = useScorers();
18339
18393
  const [selectedScorer, setSelectedScorer] = React.useState(null);
18340
18394
  const { mutate: triggerScorer, isPending, isSuccess } = useTriggerScorer();
18341
18395
  const [notificationIsVisible, setNotificationIsVisible] = React.useState(false);
@@ -18351,7 +18405,7 @@ const SpanScoring = ({ traceId, spanId, entityType }) => {
18351
18405
  isRegistered: scorer.isRegistered,
18352
18406
  type: scorer.scorer.config.type
18353
18407
  })).filter((scorer) => scorer.isRegistered);
18354
- if (entityType !== "Agent" || spanId) {
18408
+ if (entityType !== "Agent" || !isTopLevelSpan) {
18355
18409
  scorerList = scorerList.filter((scorer) => scorer.type !== "agent");
18356
18410
  }
18357
18411
  const isWaiting = isPending || isLoading;
@@ -18370,6 +18424,19 @@ const SpanScoring = ({ traceId, spanId, entityType }) => {
18370
18424
  setNotificationIsVisible(false);
18371
18425
  };
18372
18426
  const selectedScorerDescription = scorerList.find((s) => s.name === selectedScorer)?.description || "";
18427
+ if (error) {
18428
+ return /* @__PURE__ */ jsxRuntime.jsxs(Notification, { isVisible: true, autoDismiss: false, type: "error", children: [
18429
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, {}),
18430
+ " ",
18431
+ error?.message ? error.message : "Failed to load scorers."
18432
+ ] });
18433
+ }
18434
+ if (scorerList.length === 0) {
18435
+ return /* @__PURE__ */ jsxRuntime.jsxs(Notification, { isVisible: true, dismissible: false, children: [
18436
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, {}),
18437
+ " No eligible scorers have been defined to run."
18438
+ ] });
18439
+ }
18373
18440
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
18374
18441
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[3fr_1fr] gap-[1rem] items-start", children: [
18375
18442
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-[0.5rem]", children: [
@@ -18976,6 +19043,9 @@ exports.AgentCombobox = AgentCombobox;
18976
19043
  exports.AgentEntityHeader = AgentEntityHeader;
18977
19044
  exports.AgentIcon = AgentIcon;
18978
19045
  exports.AgentInformation = AgentInformation;
19046
+ exports.AgentInformationLayout = AgentInformationLayout;
19047
+ exports.AgentInformationTabLayout = AgentInformationTabLayout;
19048
+ exports.AgentMemory = AgentMemory;
18979
19049
  exports.AgentMetadata = AgentMetadata;
18980
19050
  exports.AgentMetadataList = AgentMetadataList;
18981
19051
  exports.AgentMetadataListEmpty = AgentMetadataListEmpty;
@@ -19172,6 +19242,8 @@ exports.toast = toast;
19172
19242
  exports.traceScoresListColumns = traceScoresListColumns;
19173
19243
  exports.tracesListColumns = tracesListColumns;
19174
19244
  exports.useAgent = useAgent;
19245
+ exports.useAgentInformationSettings = useAgentInformationSettings;
19246
+ exports.useAgentInformationTab = useAgentInformationTab;
19175
19247
  exports.useAgentPromptExperiment = useAgentPromptExperiment;
19176
19248
  exports.useAgentSettings = useAgentSettings;
19177
19249
  exports.useAgents = useAgents;