@mastra/playground-ui 7.0.0-beta.2 → 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.es.js CHANGED
@@ -3129,10 +3129,18 @@ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
3129
3129
  const TooltipIconButton = forwardRef(
3130
3130
  ({ children, tooltip, side = "bottom", className, ...rest }, ref) => {
3131
3131
  return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
3132
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button$2, { variant: "ghost", size: "icon", ...rest, className: cn("size-6 p-1", className), ref, children: [
3133
- children,
3134
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: tooltip })
3135
- ] }) }),
3132
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
3133
+ Button$2,
3134
+ {
3135
+ variant: "ghost",
3136
+ size: "icon",
3137
+ ...rest,
3138
+ className: cn("size-6 p-1", className),
3139
+ ref,
3140
+ "aria-label": tooltip,
3141
+ children
3142
+ }
3143
+ ) }),
3136
3144
  /* @__PURE__ */ jsx(TooltipContent, { side, children: tooltip })
3137
3145
  ] }) });
3138
3146
  }
@@ -11551,6 +11559,102 @@ const AgentAdvancedSettings = () => {
11551
11559
  ] }) });
11552
11560
  };
11553
11561
 
11562
+ const useAgent = (agentId) => {
11563
+ const client = useMastraClient();
11564
+ const { requestContext } = usePlaygroundStore();
11565
+ return useQuery({
11566
+ queryKey: ["agent", agentId, JSON.stringify(requestContext)],
11567
+ queryFn: () => agentId ? client.getAgent(agentId).details(requestContext) : null,
11568
+ retry: false,
11569
+ enabled: Boolean(agentId)
11570
+ });
11571
+ };
11572
+
11573
+ const useMemory = (agentId) => {
11574
+ const client = useMastraClient();
11575
+ const { requestContext } = usePlaygroundStore();
11576
+ return useQuery({
11577
+ queryKey: ["memory", agentId],
11578
+ queryFn: () => agentId ? client.getMemoryStatus(agentId, requestContext) : null,
11579
+ enabled: Boolean(agentId),
11580
+ staleTime: 5 * 60 * 1e3,
11581
+ // 5 minutes
11582
+ gcTime: 10 * 60 * 1e3,
11583
+ // 10 minutes
11584
+ retry: false
11585
+ });
11586
+ };
11587
+ const useMemoryConfig = (agentId) => {
11588
+ const client = useMastraClient();
11589
+ const { requestContext } = usePlaygroundStore();
11590
+ return useQuery({
11591
+ queryKey: ["memory", "config", agentId],
11592
+ queryFn: () => agentId ? client.getMemoryConfig({ agentId, requestContext }) : null,
11593
+ enabled: Boolean(agentId),
11594
+ staleTime: 5 * 60 * 1e3,
11595
+ // 5 minutes
11596
+ gcTime: 10 * 60 * 1e3,
11597
+ // 10 minutes
11598
+ retry: false,
11599
+ refetchOnWindowFocus: false
11600
+ });
11601
+ };
11602
+ const useThreads = ({
11603
+ resourceId,
11604
+ agentId,
11605
+ isMemoryEnabled
11606
+ }) => {
11607
+ const client = useMastraClient();
11608
+ const { requestContext } = usePlaygroundStore();
11609
+ return useQuery({
11610
+ queryKey: ["memory", "threads", resourceId, agentId],
11611
+ queryFn: async () => {
11612
+ if (!isMemoryEnabled) return null;
11613
+ const result = await client.listMemoryThreads({ resourceId, agentId, requestContext });
11614
+ return result.threads;
11615
+ },
11616
+ enabled: Boolean(isMemoryEnabled),
11617
+ staleTime: 0,
11618
+ gcTime: 0,
11619
+ retry: false,
11620
+ refetchOnWindowFocus: false
11621
+ });
11622
+ };
11623
+ const useDeleteThread = () => {
11624
+ const client = useMastraClient();
11625
+ const queryClient = useQueryClient();
11626
+ const { requestContext } = usePlaygroundStore();
11627
+ return useMutation({
11628
+ mutationFn: ({ threadId, agentId }) => {
11629
+ const thread = client.getMemoryThread({ threadId, agentId });
11630
+ return thread.delete({ requestContext });
11631
+ },
11632
+ onSuccess: (_, variables) => {
11633
+ const { agentId } = variables;
11634
+ if (agentId) {
11635
+ queryClient.invalidateQueries({ queryKey: ["memory", "threads", agentId, agentId] });
11636
+ }
11637
+ toast$1.success("Chat deleted successfully");
11638
+ },
11639
+ onError: () => {
11640
+ toast$1.error("Failed to delete chat");
11641
+ }
11642
+ });
11643
+ };
11644
+ const useMemorySearch = ({
11645
+ agentId,
11646
+ resourceId,
11647
+ threadId
11648
+ }) => {
11649
+ const { requestContext } = usePlaygroundStore();
11650
+ const client = useMastraClient();
11651
+ return useMutation({
11652
+ mutationFn: async ({ searchQuery, memoryConfig }) => {
11653
+ return client.searchMemory({ agentId, resourceId, threadId, searchQuery, memoryConfig, requestContext });
11654
+ }
11655
+ });
11656
+ };
11657
+
11554
11658
  const NetworkCheckbox = ({ hasMemory, hasSubAgents }) => {
11555
11659
  const isNetworkAvailable = hasMemory && hasSubAgents;
11556
11660
  const radio = /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
@@ -11583,8 +11687,19 @@ const NetworkCheckbox = ({ hasMemory, hasSubAgents }) => {
11583
11687
  ] }) })
11584
11688
  ] });
11585
11689
  };
11586
- const AgentSettings = ({ modelVersion, hasMemory = false, hasSubAgents = false }) => {
11690
+ const AgentSettings = ({ agentId }) => {
11691
+ const { data: agent, isLoading } = useAgent(agentId);
11692
+ const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
11587
11693
  const { settings, setSettings, resetAll } = useAgentSettings();
11694
+ if (isLoading || isMemoryLoading) {
11695
+ return /* @__PURE__ */ jsx(Skeleton, { className: "h-full" });
11696
+ }
11697
+ if (!agent) {
11698
+ return /* @__PURE__ */ jsx("div", { children: "Agent not found" });
11699
+ }
11700
+ const hasMemory = Boolean(memory?.result);
11701
+ const hasSubAgents = Boolean(Object.keys(agent.agents || {}).length > 0);
11702
+ const modelVersion = agent.modelVersion;
11588
11703
  let radioValue;
11589
11704
  if (modelVersion === "v2") {
11590
11705
  if (settings?.modelSettings?.chatWithNetwork) {
@@ -13077,10 +13192,18 @@ function getShortId(id) {
13077
13192
  return id.slice(0, 8);
13078
13193
  }
13079
13194
 
13080
- function Notification({ children, className, isVisible, autoDismiss = true, dismissTime = 5e3 }) {
13195
+ function Notification({
13196
+ children,
13197
+ className,
13198
+ isVisible,
13199
+ autoDismiss = true,
13200
+ dismissTime = 5e3,
13201
+ dismissible = true,
13202
+ type = "info"
13203
+ }) {
13081
13204
  const [localIsVisible, setLocalIsVisible] = useState(isVisible);
13082
13205
  useEffect(() => {
13083
- if (autoDismiss && isVisible) {
13206
+ if (dismissible && autoDismiss && isVisible) {
13084
13207
  const timer = setTimeout(() => {
13085
13208
  setLocalIsVisible(false);
13086
13209
  }, dismissTime);
@@ -13095,13 +13218,27 @@ function Notification({ children, className, isVisible, autoDismiss = true, dism
13095
13218
  "div",
13096
13219
  {
13097
13220
  className: cn(
13098
- "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",
13099
- "[&>svg]:w-[1.1em] [&>svg]:h-[1.1em] [&>svg]:opacity-50",
13221
+ "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",
13222
+ {
13223
+ "bg-red-900/10 border border-red-900": type === "error"
13224
+ },
13100
13225
  className
13101
13226
  ),
13102
13227
  children: [
13103
- /* @__PURE__ */ jsx("div", { className: "flex gap-[0.5rem] items-center", children }),
13104
- /* @__PURE__ */ jsxs(Button, { variant: "ghost", onClick: () => setLocalIsVisible(false), children: [
13228
+ /* @__PURE__ */ jsx(
13229
+ "div",
13230
+ {
13231
+ className: cn(
13232
+ "flex gap-[0.5rem] items-start",
13233
+ "[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-70 [&>svg]:translate-y-[0.2em]",
13234
+ {
13235
+ "[&>svg]:text-red-400": type === "error"
13236
+ }
13237
+ ),
13238
+ children
13239
+ }
13240
+ ),
13241
+ dismissible && /* @__PURE__ */ jsxs(Button, { variant: "ghost", onClick: () => setLocalIsVisible(false), children: [
13105
13242
  /* @__PURE__ */ jsx(XIcon, {}),
13106
13243
  /* @__PURE__ */ jsx(VisuallyHidden$1, { children: "Dismiss" })
13107
13244
  ] })
@@ -14511,6 +14648,67 @@ const PromptEnhancerTextarea = ({ agentId }) => {
14511
14648
  ] });
14512
14649
  };
14513
14650
 
14651
+ const useAgents = () => {
14652
+ const client = useMastraClient();
14653
+ const { requestContext } = usePlaygroundStore();
14654
+ return useQuery({
14655
+ queryKey: ["agents", JSON.stringify(requestContext)],
14656
+ queryFn: () => client.listAgents(requestContext)
14657
+ });
14658
+ };
14659
+ const useUpdateAgentModel = (agentId) => {
14660
+ const client = useMastraClient();
14661
+ const queryClient = useQueryClient();
14662
+ return useMutation({
14663
+ mutationFn: async (payload) => client.getAgent(agentId).updateModel(payload),
14664
+ onSuccess: () => {
14665
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14666
+ },
14667
+ onError: (err) => {
14668
+ console.error("Error updating model", err);
14669
+ }
14670
+ });
14671
+ };
14672
+ const useReorderModelList = (agentId) => {
14673
+ const client = useMastraClient();
14674
+ const queryClient = useQueryClient();
14675
+ return useMutation({
14676
+ mutationFn: async (payload) => client.getAgent(agentId).reorderModelList(payload),
14677
+ onSuccess: () => {
14678
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14679
+ },
14680
+ onError: (err) => {
14681
+ console.error("Error reordering model list", err);
14682
+ }
14683
+ });
14684
+ };
14685
+ const useUpdateModelInModelList = (agentId) => {
14686
+ const client = useMastraClient();
14687
+ const queryClient = useQueryClient();
14688
+ return useMutation({
14689
+ mutationFn: async (payload) => client.getAgent(agentId).updateModelInModelList(payload),
14690
+ onSuccess: () => {
14691
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14692
+ },
14693
+ onError: (err) => {
14694
+ console.error("Error updating model in model list", err);
14695
+ }
14696
+ });
14697
+ };
14698
+ const useResetAgentModel = (agentId) => {
14699
+ const client = useMastraClient();
14700
+ const queryClient = useQueryClient();
14701
+ return useMutation({
14702
+ mutationFn: async () => client.getAgent(agentId).resetModel(),
14703
+ onSuccess: () => {
14704
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14705
+ },
14706
+ onError: (err) => {
14707
+ console.error("Error resetting model", err);
14708
+ }
14709
+ });
14710
+ };
14711
+
14514
14712
  const AgentMetadataNetworkList = ({ agents }) => {
14515
14713
  const { Link, paths } = useLinkComponent();
14516
14714
  if (agents.length === 0) {
@@ -14518,16 +14716,20 @@ const AgentMetadataNetworkList = ({ agents }) => {
14518
14716
  }
14519
14717
  return /* @__PURE__ */ jsx(AgentMetadataList, { children: agents.map((agent) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: paths.agentLink(agent.id), "data-testid": "agent-badge", children: /* @__PURE__ */ jsx(Badge, { variant: "success", icon: /* @__PURE__ */ jsx(AgentIcon, {}), children: agent.name }) }) }, agent.id)) });
14520
14718
  };
14521
- const AgentMetadata = ({
14522
- agentId,
14523
- agent,
14524
- hasMemoryEnabled,
14525
- updateModel,
14526
- resetModel,
14527
- updateModelInModelList,
14528
- reorderModelList,
14529
- modelVersion
14530
- }) => {
14719
+ const AgentMetadata = ({ agentId }) => {
14720
+ const { data: agent, isLoading } = useAgent(agentId);
14721
+ const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
14722
+ const { mutate: reorderModelList } = useReorderModelList(agentId);
14723
+ const { mutateAsync: resetModel } = useResetAgentModel(agentId);
14724
+ const { mutateAsync: updateModelInModelList } = useUpdateModelInModelList(agentId);
14725
+ const { mutateAsync: updateModel } = useUpdateAgentModel(agentId);
14726
+ const hasMemoryEnabled = Boolean(memory?.result);
14727
+ if (isLoading || isMemoryLoading) {
14728
+ return /* @__PURE__ */ jsx(Skeleton, { className: "h-full" });
14729
+ }
14730
+ if (!agent) {
14731
+ return /* @__PURE__ */ jsx("div", { children: "Agent not found" });
14732
+ }
14531
14733
  const networkAgentsMap = agent.agents ?? {};
14532
14734
  const networkAgents = Object.keys(networkAgentsMap).map((key) => ({ ...networkAgentsMap[key], id: key }));
14533
14735
  const agentTools = agent.tools ?? {};
@@ -14546,7 +14748,7 @@ const AgentMetadata = ({
14546
14748
  AgentMetadataSection,
14547
14749
  {
14548
14750
  title: "Model",
14549
- hint: modelVersion === "v2" ? void 0 : {
14751
+ hint: agent.modelVersion === "v2" ? void 0 : {
14550
14752
  link: "https://mastra.ai/guides/migrations/vnext-to-standard-apis",
14551
14753
  title: "You are using a legacy v1 model",
14552
14754
  icon: /* @__PURE__ */ jsx(AlertTriangleIcon, { fontSize: 14, className: "mb-0.5" })
@@ -14663,8 +14865,10 @@ const AgentMetadataScorerList = ({ entityId, entityType }) => {
14663
14865
  return /* @__PURE__ */ jsx(AgentMetadataList, { children: scorerList.map((scorer) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: paths.scorerLink(scorer.id), "data-testid": "scorer-badge", children: /* @__PURE__ */ jsx(Badge, { icon: /* @__PURE__ */ jsx(GaugeIcon, { className: "text-icon3" }), children: scorer.scorer.config.name }) }) }, scorer.id)) });
14664
14866
  };
14665
14867
 
14666
- const AgentEntityHeader = ({ agentId, isLoading, agentName }) => {
14868
+ const AgentEntityHeader = ({ agentId }) => {
14869
+ const { data: agent, isLoading } = useAgent(agentId);
14667
14870
  const { handleCopy } = useCopyToClipboard({ text: agentId });
14871
+ const agentName = agent?.name || "";
14668
14872
  return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(EntityHeader, { icon: /* @__PURE__ */ jsx(AgentIcon, {}), title: agentName, isLoading, children: /* @__PURE__ */ jsxs(Tooltip, { children: [
14669
14873
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { onClick: handleCopy, className: "h-badge-default shrink-0", children: /* @__PURE__ */ jsx(Badge, { icon: /* @__PURE__ */ jsx(CopyIcon, {}), variant: "default", children: agentId }) }) }),
14670
14874
  /* @__PURE__ */ jsx(TooltipContent, { children: "Copy Agent ID for use in code" })
@@ -14868,67 +15072,6 @@ const formatDay = (date) => {
14868
15072
  return new Date(date).toLocaleString("en-us", options).replace(",", " at");
14869
15073
  };
14870
15074
 
14871
- const useAgents = () => {
14872
- const client = useMastraClient();
14873
- const { requestContext } = usePlaygroundStore();
14874
- return useQuery({
14875
- queryKey: ["agents", JSON.stringify(requestContext)],
14876
- queryFn: () => client.listAgents(requestContext)
14877
- });
14878
- };
14879
- const useUpdateAgentModel = (agentId) => {
14880
- const client = useMastraClient();
14881
- const queryClient = useQueryClient();
14882
- return useMutation({
14883
- mutationFn: async (payload) => client.getAgent(agentId).updateModel(payload),
14884
- onSuccess: () => {
14885
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14886
- },
14887
- onError: (err) => {
14888
- console.error("Error updating model", err);
14889
- }
14890
- });
14891
- };
14892
- const useReorderModelList = (agentId) => {
14893
- const client = useMastraClient();
14894
- const queryClient = useQueryClient();
14895
- return useMutation({
14896
- mutationFn: async (payload) => client.getAgent(agentId).reorderModelList(payload),
14897
- onSuccess: () => {
14898
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14899
- },
14900
- onError: (err) => {
14901
- console.error("Error reordering model list", err);
14902
- }
14903
- });
14904
- };
14905
- const useUpdateModelInModelList = (agentId) => {
14906
- const client = useMastraClient();
14907
- const queryClient = useQueryClient();
14908
- return useMutation({
14909
- mutationFn: async (payload) => client.getAgent(agentId).updateModelInModelList(payload),
14910
- onSuccess: () => {
14911
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14912
- },
14913
- onError: (err) => {
14914
- console.error("Error updating model in model list", err);
14915
- }
14916
- });
14917
- };
14918
- const useResetAgentModel = (agentId) => {
14919
- const client = useMastraClient();
14920
- const queryClient = useQueryClient();
14921
- return useMutation({
14922
- mutationFn: async () => client.getAgent(agentId).resetModel(),
14923
- onSuccess: () => {
14924
- queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14925
- },
14926
- onError: (err) => {
14927
- console.error("Error resetting model", err);
14928
- }
14929
- });
14930
- };
14931
-
14932
15075
  function AgentCombobox({
14933
15076
  value,
14934
15077
  onValueChange,
@@ -14976,17 +15119,6 @@ function AgentCombobox({
14976
15119
  );
14977
15120
  }
14978
15121
 
14979
- const useAgent = (agentId) => {
14980
- const client = useMastraClient();
14981
- const { requestContext } = usePlaygroundStore();
14982
- return useQuery({
14983
- queryKey: ["agent", agentId, JSON.stringify(requestContext)],
14984
- queryFn: () => agentId ? client.getAgent(agentId).details(requestContext) : null,
14985
- retry: false,
14986
- enabled: Boolean(agentId)
14987
- });
14988
- };
14989
-
14990
15122
  const useExecuteAgentTool = () => {
14991
15123
  const client = useMastraClient();
14992
15124
  return useMutation({
@@ -15094,91 +15226,6 @@ const AgentToolPanel = ({ toolId, agentId }) => {
15094
15226
  );
15095
15227
  };
15096
15228
 
15097
- const useMemory = (agentId) => {
15098
- const client = useMastraClient();
15099
- const { requestContext } = usePlaygroundStore();
15100
- return useQuery({
15101
- queryKey: ["memory", agentId],
15102
- queryFn: () => agentId ? client.getMemoryStatus(agentId, requestContext) : null,
15103
- enabled: Boolean(agentId),
15104
- staleTime: 5 * 60 * 1e3,
15105
- // 5 minutes
15106
- gcTime: 10 * 60 * 1e3,
15107
- // 10 minutes
15108
- retry: false
15109
- });
15110
- };
15111
- const useMemoryConfig = (agentId) => {
15112
- const client = useMastraClient();
15113
- const { requestContext } = usePlaygroundStore();
15114
- return useQuery({
15115
- queryKey: ["memory", "config", agentId],
15116
- queryFn: () => agentId ? client.getMemoryConfig({ agentId, requestContext }) : null,
15117
- enabled: Boolean(agentId),
15118
- staleTime: 5 * 60 * 1e3,
15119
- // 5 minutes
15120
- gcTime: 10 * 60 * 1e3,
15121
- // 10 minutes
15122
- retry: false,
15123
- refetchOnWindowFocus: false
15124
- });
15125
- };
15126
- const useThreads = ({
15127
- resourceId,
15128
- agentId,
15129
- isMemoryEnabled
15130
- }) => {
15131
- const client = useMastraClient();
15132
- const { requestContext } = usePlaygroundStore();
15133
- return useQuery({
15134
- queryKey: ["memory", "threads", resourceId, agentId],
15135
- queryFn: async () => {
15136
- if (!isMemoryEnabled) return null;
15137
- const result = await client.listMemoryThreads({ resourceId, agentId, requestContext });
15138
- return result.threads;
15139
- },
15140
- enabled: Boolean(isMemoryEnabled),
15141
- staleTime: 0,
15142
- gcTime: 0,
15143
- retry: false,
15144
- refetchOnWindowFocus: false
15145
- });
15146
- };
15147
- const useDeleteThread = () => {
15148
- const client = useMastraClient();
15149
- const queryClient = useQueryClient();
15150
- const { requestContext } = usePlaygroundStore();
15151
- return useMutation({
15152
- mutationFn: ({ threadId, agentId }) => {
15153
- const thread = client.getMemoryThread({ threadId, agentId });
15154
- return thread.delete({ requestContext });
15155
- },
15156
- onSuccess: (_, variables) => {
15157
- const { agentId } = variables;
15158
- if (agentId) {
15159
- queryClient.invalidateQueries({ queryKey: ["memory", "threads", agentId, agentId] });
15160
- }
15161
- toast$1.success("Chat deleted successfully");
15162
- },
15163
- onError: () => {
15164
- toast$1.error("Failed to delete chat");
15165
- }
15166
- });
15167
- };
15168
- const useMemorySearch = ({
15169
- agentId,
15170
- resourceId,
15171
- threadId
15172
- }) => {
15173
- const { requestContext } = usePlaygroundStore();
15174
- const client = useMastraClient();
15175
- return useMutation({
15176
- mutationFn: async ({ searchQuery, memoryConfig }) => {
15177
- return client.searchMemory({ agentId, resourceId, threadId, searchQuery, memoryConfig, requestContext });
15178
- }
15179
- });
15180
- };
15181
-
15182
15229
  function MarkdownRenderer({ children }) {
15183
15230
  const processedText = children.replace(/\\n/g, "\n");
15184
15231
  return /* @__PURE__ */ jsx(Markdown, { remarkPlugins: [remarkGfm], components: COMPONENTS, className: "space-y-3", children: processedText });
@@ -15960,14 +16007,24 @@ const TabContent$1 = ({ children, value }) => {
15960
16007
  };
15961
16008
 
15962
16009
  function AgentInformation({ agentId, threadId }) {
15963
- const { data: agent, isLoading } = useAgent(agentId);
15964
- const { mutateAsync: updateModel } = useUpdateAgentModel(agentId);
15965
- const { mutateAsync: resetModel } = useResetAgentModel(agentId);
15966
- const { mutate: reorderModelList } = useReorderModelList(agentId);
15967
- const { mutateAsync: updateModelInModelList } = useUpdateModelInModelList(agentId);
15968
- const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
15969
- const { settings, setSettings } = useAgentSettings();
15970
- const STORAGE_KEY = "agent-info-selected-tab";
16010
+ const { data: memory } = useMemory(agentId);
16011
+ const hasMemory = Boolean(memory?.result);
16012
+ return /* @__PURE__ */ jsxs(AgentInformationLayout, { agentId, children: [
16013
+ /* @__PURE__ */ jsx(AgentEntityHeader, { agentId }),
16014
+ /* @__PURE__ */ jsxs(AgentInformationTabLayout, { agentId, children: [
16015
+ /* @__PURE__ */ jsxs(TabList$1, { children: [
16016
+ /* @__PURE__ */ jsx(Tab$1, { value: "overview", children: "Overview" }),
16017
+ /* @__PURE__ */ jsx(Tab$1, { value: "model-settings", children: "Model Settings" }),
16018
+ hasMemory && /* @__PURE__ */ jsx(Tab$1, { value: "memory", children: "Memory" })
16019
+ ] }),
16020
+ /* @__PURE__ */ jsx(TabContent$1, { value: "overview", children: /* @__PURE__ */ jsx(AgentMetadata, { agentId }) }),
16021
+ /* @__PURE__ */ jsx(TabContent$1, { value: "model-settings", children: /* @__PURE__ */ jsx(AgentSettings, { agentId }) }),
16022
+ hasMemory && /* @__PURE__ */ jsx(TabContent$1, { value: "memory", children: /* @__PURE__ */ jsx(AgentMemory, { agentId, threadId }) })
16023
+ ] })
16024
+ ] });
16025
+ }
16026
+ const STORAGE_KEY = "agent-info-selected-tab";
16027
+ const useAgentInformationTab = ({ isMemoryLoading, hasMemory }) => {
15971
16028
  const [selectedTab, setSelectedTab] = useState(() => {
15972
16029
  return sessionStorage.getItem(STORAGE_KEY) || "overview";
15973
16030
  });
@@ -15976,7 +16033,20 @@ function AgentInformation({ agentId, threadId }) {
15976
16033
  sessionStorage.setItem(STORAGE_KEY, value);
15977
16034
  };
15978
16035
  useEffect(() => {
15979
- if (agent?.modelId?.includes("gpt-5")) {
16036
+ if (!isMemoryLoading && !hasMemory && selectedTab === "memory") {
16037
+ setSelectedTab("overview");
16038
+ sessionStorage.setItem(STORAGE_KEY, "overview");
16039
+ }
16040
+ }, [isMemoryLoading, hasMemory, selectedTab]);
16041
+ return {
16042
+ selectedTab,
16043
+ handleTabChange
16044
+ };
16045
+ };
16046
+ const useAgentInformationSettings = ({ modelId }) => {
16047
+ const { settings, setSettings } = useAgentSettings();
16048
+ useEffect(() => {
16049
+ if (modelId?.includes("gpt-5")) {
15980
16050
  setSettings({
15981
16051
  ...settings || {},
15982
16052
  modelSettings: {
@@ -15985,51 +16055,26 @@ function AgentInformation({ agentId, threadId }) {
15985
16055
  }
15986
16056
  });
15987
16057
  }
15988
- }, [agent]);
15989
- useEffect(() => {
15990
- if (!isMemoryLoading && !memory?.result && selectedTab === "memory") {
15991
- handleTabChange("overview");
15992
- }
15993
- }, [isMemoryLoading, memory?.result, selectedTab]);
15994
- return /* @__PURE__ */ jsxs("div", { className: "grid grid-rows-[auto_1fr] h-full items-start overflow-y-auto border-l-sm border-border1", children: [
15995
- /* @__PURE__ */ jsx(AgentEntityHeader, { agentId, isLoading: isMemoryLoading, agentName: agent?.name || "" }),
15996
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden border-t-sm border-border1 flex flex-col", children: /* @__PURE__ */ jsxs(PlaygroundTabs, { defaultTab: "overview", value: selectedTab, onValueChange: handleTabChange, children: [
15997
- /* @__PURE__ */ jsxs(TabList$1, { children: [
15998
- /* @__PURE__ */ jsx(Tab$1, { value: "overview", children: "Overview" }),
15999
- /* @__PURE__ */ jsx(Tab$1, { value: "model-settings", children: "Model Settings" }),
16000
- memory?.result && /* @__PURE__ */ jsx(Tab$1, { value: "memory", children: "Memory" })
16001
- ] }),
16002
- /* @__PURE__ */ jsxs(TabContent$1, { value: "overview", children: [
16003
- isLoading && /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }),
16004
- agent && /* @__PURE__ */ jsx(
16005
- AgentMetadata,
16006
- {
16007
- agentId,
16008
- agent,
16009
- updateModel,
16010
- resetModel,
16011
- updateModelInModelList,
16012
- reorderModelList,
16013
- hasMemoryEnabled: Boolean(memory?.result),
16014
- modelVersion: agent.modelVersion
16015
- }
16016
- )
16017
- ] }),
16018
- /* @__PURE__ */ jsxs(TabContent$1, { value: "model-settings", children: [
16019
- isLoading && /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }),
16020
- agent && /* @__PURE__ */ jsx(
16021
- AgentSettings,
16022
- {
16023
- modelVersion: agent.modelVersion,
16024
- hasMemory: Boolean(memory?.result),
16025
- hasSubAgents: Boolean(Object.keys(agent.agents || {}).length > 0)
16026
- }
16027
- )
16028
- ] }),
16029
- /* @__PURE__ */ jsx(TabContent$1, { value: "memory", children: isLoading ? /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) : /* @__PURE__ */ jsx(AgentMemory, { agentId, threadId }) })
16030
- ] }) })
16031
- ] });
16032
- }
16058
+ }, [modelId]);
16059
+ return {
16060
+ settings,
16061
+ setSettings
16062
+ };
16063
+ };
16064
+ const AgentInformationLayout = ({ children, agentId }) => {
16065
+ const { data: agent } = useAgent(agentId);
16066
+ useAgentInformationSettings({ modelId: agent?.modelId || "" });
16067
+ return /* @__PURE__ */ jsx("div", { className: "grid grid-rows-[auto_1fr] h-full items-start overflow-y-auto border-l-sm border-border1", children });
16068
+ };
16069
+ const AgentInformationTabLayout = ({ children, agentId }) => {
16070
+ const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
16071
+ const hasMemory = Boolean(memory?.result);
16072
+ const { selectedTab, handleTabChange } = useAgentInformationTab({
16073
+ isMemoryLoading,
16074
+ hasMemory
16075
+ });
16076
+ return /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden border-t-sm border-border1 flex flex-col", children: /* @__PURE__ */ jsx(PlaygroundTabs, { defaultTab: "overview", value: selectedTab, onValueChange: handleTabChange, children }) });
16077
+ };
16033
16078
 
16034
16079
  const NameCell$1 = ({ row }) => {
16035
16080
  const { Link, paths } = useLinkComponent();
@@ -17703,7 +17748,15 @@ function SpanTabs({
17703
17748
  /* @__PURE__ */ jsx(CircleGaugeIcon, {}),
17704
17749
  " Scoring"
17705
17750
  ] }) }),
17706
- /* @__PURE__ */ jsx(SpanScoring, { traceId: trace?.traceId, spanId: span?.spanId, entityType })
17751
+ /* @__PURE__ */ jsx(
17752
+ SpanScoring,
17753
+ {
17754
+ traceId: trace?.traceId,
17755
+ isTopLevelSpan: span?.parentSpanId === null,
17756
+ spanId: span?.spanId,
17757
+ entityType
17758
+ }
17759
+ )
17707
17760
  ] }),
17708
17761
  /* @__PURE__ */ jsxs(Section, { children: [
17709
17762
  /* @__PURE__ */ jsx(Section.Header, { children: /* @__PURE__ */ jsxs(Section.Heading, { children: [
@@ -18300,8 +18353,8 @@ const useTriggerScorer = () => {
18300
18353
  });
18301
18354
  };
18302
18355
 
18303
- const SpanScoring = ({ traceId, spanId, entityType }) => {
18304
- const { data: scorers = {}, isLoading } = useScorers();
18356
+ const SpanScoring = ({ traceId, spanId, entityType, isTopLevelSpan }) => {
18357
+ const { data: scorers = {}, isLoading, error } = useScorers();
18305
18358
  const [selectedScorer, setSelectedScorer] = useState(null);
18306
18359
  const { mutate: triggerScorer, isPending, isSuccess } = useTriggerScorer();
18307
18360
  const [notificationIsVisible, setNotificationIsVisible] = useState(false);
@@ -18317,7 +18370,7 @@ const SpanScoring = ({ traceId, spanId, entityType }) => {
18317
18370
  isRegistered: scorer.isRegistered,
18318
18371
  type: scorer.scorer.config.type
18319
18372
  })).filter((scorer) => scorer.isRegistered);
18320
- if (entityType !== "Agent" || spanId) {
18373
+ if (entityType !== "Agent" || !isTopLevelSpan) {
18321
18374
  scorerList = scorerList.filter((scorer) => scorer.type !== "agent");
18322
18375
  }
18323
18376
  const isWaiting = isPending || isLoading;
@@ -18336,6 +18389,19 @@ const SpanScoring = ({ traceId, spanId, entityType }) => {
18336
18389
  setNotificationIsVisible(false);
18337
18390
  };
18338
18391
  const selectedScorerDescription = scorerList.find((s) => s.name === selectedScorer)?.description || "";
18392
+ if (error) {
18393
+ return /* @__PURE__ */ jsxs(Notification, { isVisible: true, autoDismiss: false, type: "error", children: [
18394
+ /* @__PURE__ */ jsx(InfoIcon$1, {}),
18395
+ " ",
18396
+ error?.message ? error.message : "Failed to load scorers."
18397
+ ] });
18398
+ }
18399
+ if (scorerList.length === 0) {
18400
+ return /* @__PURE__ */ jsxs(Notification, { isVisible: true, dismissible: false, children: [
18401
+ /* @__PURE__ */ jsx(InfoIcon$1, {}),
18402
+ " No eligible scorers have been defined to run."
18403
+ ] });
18404
+ }
18339
18405
  return /* @__PURE__ */ jsxs("div", { children: [
18340
18406
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[3fr_1fr] gap-[1rem] items-start", children: [
18341
18407
  /* @__PURE__ */ jsxs("div", { className: "grid gap-[0.5rem]", children: [
@@ -18932,5 +18998,5 @@ function MCPServerCombobox({
18932
18998
  );
18933
18999
  }
18934
19000
 
18935
- export { AgentChat, AgentCoinIcon, AgentCombobox, AgentEntityHeader, AgentIcon, AgentInformation, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataNetworkList, AgentMetadataScorerList, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentPromptExperimentProvider, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentToolPanel, AgentsTable, AiIcon, Alert$1 as Alert, AlertDescription$1 as AlertDescription, AlertDialog, AlertTitle$1 as AlertTitle, ApiIcon, Badge, BranchIcon, Breadcrumb, Button$1 as Button, ButtonsGroup, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, CommitIcon, CrossIcon, Crumb, DateTimeCell, DateTimePicker, DateTimePickerContent, DbIcon, DebugIcon, DefaultTrigger, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityHeader, EntityIcon, EntityName, Entry, EntryCell, EntryList, EntryListSkeleton, EnvIcon, FiltersIcon, FolderIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, InputField, JudgeIcon, Kbd, KeyValueList, LatencyIcon, LinkComponentProvider, LogoWithoutText, LogsIcon, MCPDetail, MCPServerCombobox, MCPTable, MCPToolPanel, MainContentContent, MainContentLayout, MainSidebar, MainSidebarProvider, McpCoinIcon, McpServerIcon, MemoryIcon, MemorySearch, Notification, OpenAIIcon, PageHeader, PlaygroundQueryClient, PlaygroundTabs, PromptIcon, RadioGroup, RadioGroupItem, RepoIcon, RequestContext, RequestContextWrapper, Row, ScoreDialog, ScorerCombobox, ScorersTable, ScoresList, ScoresTools, SearchField, Searchbar, SearchbarWrapper, Section, Sections, SelectField, SettingsIcon, SideDialog, Skeleton, SlashIcon, SpanScoreList, SpanScoring, SpanTabs, Tab$1 as Tab, TabContent$1 as TabContent, TabList$1 as TabList, Table, Tbody, TemplateFailure, TemplateForm, TemplateInfo, TemplateInstallation, TemplateSuccess, TemplatesList, TemplatesTools, TextAndIcon, Th, Thead, ThreadDeleteButton, ThreadInputProvider, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolCombobox, ToolFallback, ToolIconMap, ToolInformation, ToolPanel, ToolTable, ToolsIcon, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TraceDialog, TraceIcon, TraceTimeline, TraceTimelineLegend, TraceTimelineSpan, TracesList, TracesTools, TsIcon, Txt, TxtCell, VariablesIcon, WorkflowCoinIcon, WorkflowCombobox, WorkflowGraph, WorkflowIcon, WorkflowInformation, WorkflowRunContext, WorkflowRunDetail, WorkflowRunList, WorkflowRunProvider, WorkflowTable, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, convertWorkflowRunStateToStreamResult, extractPrompt, formatHierarchicalSpans, getColumnTemplate, getShortId, getSpanTypeUi, getToNextEntryFn, getToPreviousEntryFn, parseError, providerMapToIcon, scoresListColumns, spanTypePrefixes, toast, traceScoresListColumns, tracesListColumns, useAgent, useAgentPromptExperiment, useAgentSettings, useAgents, useCancelWorkflowRun, useCurrentRun, useDeleteThread, useExecuteAgentTool, useExecuteMCPTool, useExecuteTool, useExecuteWorkflow, useInView, useLinkComponent, useMCPServerTool, useMCPServerTools, useMCPServers, useMainSidebar, useMemory, useMemoryConfig, useMemorySearch, usePlaygroundStore, useReorderModelList, useResetAgentModel, useScorer, useScorers, useScoresByScorerId, useSpeechRecognition, useStreamWorkflow, useThreadInput, useThreads, useTool, useTools, useTraceSpanScores, useUpdateAgentModel, useUpdateModelInModelList, useWorkflow, useWorkflowRunExecutionResult, useWorkflowRuns, useWorkflows, useWorkingMemory };
19001
+ export { AgentChat, AgentCoinIcon, AgentCombobox, AgentEntityHeader, AgentIcon, AgentInformation, AgentInformationLayout, AgentInformationTabLayout, AgentMemory, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataNetworkList, AgentMetadataScorerList, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentPromptExperimentProvider, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentToolPanel, AgentsTable, AiIcon, Alert$1 as Alert, AlertDescription$1 as AlertDescription, AlertDialog, AlertTitle$1 as AlertTitle, ApiIcon, Badge, BranchIcon, Breadcrumb, Button$1 as Button, ButtonsGroup, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, CommitIcon, CrossIcon, Crumb, DateTimeCell, DateTimePicker, DateTimePickerContent, DbIcon, DebugIcon, DefaultTrigger, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityHeader, EntityIcon, EntityName, Entry, EntryCell, EntryList, EntryListSkeleton, EnvIcon, FiltersIcon, FolderIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, InputField, JudgeIcon, Kbd, KeyValueList, LatencyIcon, LinkComponentProvider, LogoWithoutText, LogsIcon, MCPDetail, MCPServerCombobox, MCPTable, MCPToolPanel, MainContentContent, MainContentLayout, MainSidebar, MainSidebarProvider, McpCoinIcon, McpServerIcon, MemoryIcon, MemorySearch, Notification, OpenAIIcon, PageHeader, PlaygroundQueryClient, PlaygroundTabs, PromptIcon, RadioGroup, RadioGroupItem, RepoIcon, RequestContext, RequestContextWrapper, Row, ScoreDialog, ScorerCombobox, ScorersTable, ScoresList, ScoresTools, SearchField, Searchbar, SearchbarWrapper, Section, Sections, SelectField, SettingsIcon, SideDialog, Skeleton, SlashIcon, SpanScoreList, SpanScoring, SpanTabs, Tab$1 as Tab, TabContent$1 as TabContent, TabList$1 as TabList, Table, Tbody, TemplateFailure, TemplateForm, TemplateInfo, TemplateInstallation, TemplateSuccess, TemplatesList, TemplatesTools, TextAndIcon, Th, Thead, ThreadDeleteButton, ThreadInputProvider, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolCombobox, ToolFallback, ToolIconMap, ToolInformation, ToolPanel, ToolTable, ToolsIcon, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TraceDialog, TraceIcon, TraceTimeline, TraceTimelineLegend, TraceTimelineSpan, TracesList, TracesTools, TsIcon, Txt, TxtCell, VariablesIcon, WorkflowCoinIcon, WorkflowCombobox, WorkflowGraph, WorkflowIcon, WorkflowInformation, WorkflowRunContext, WorkflowRunDetail, WorkflowRunList, WorkflowRunProvider, WorkflowTable, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, convertWorkflowRunStateToStreamResult, extractPrompt, formatHierarchicalSpans, getColumnTemplate, getShortId, getSpanTypeUi, getToNextEntryFn, getToPreviousEntryFn, parseError, providerMapToIcon, scoresListColumns, spanTypePrefixes, toast, traceScoresListColumns, tracesListColumns, useAgent, useAgentInformationSettings, useAgentInformationTab, useAgentPromptExperiment, useAgentSettings, useAgents, useCancelWorkflowRun, useCurrentRun, useDeleteThread, useExecuteAgentTool, useExecuteMCPTool, useExecuteTool, useExecuteWorkflow, useInView, useLinkComponent, useMCPServerTool, useMCPServerTools, useMCPServers, useMainSidebar, useMemory, useMemoryConfig, useMemorySearch, usePlaygroundStore, useReorderModelList, useResetAgentModel, useScorer, useScorers, useScoresByScorerId, useSpeechRecognition, useStreamWorkflow, useThreadInput, useThreads, useTool, useTools, useTraceSpanScores, useUpdateAgentModel, useUpdateModelInModelList, useWorkflow, useWorkflowRunExecutionResult, useWorkflowRuns, useWorkflows, useWorkingMemory };
18936
19002
  //# sourceMappingURL=index.es.js.map