@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.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 ?? {};
@@ -14535,6 +14737,7 @@ const AgentMetadata = ({
14535
14737
  const agentWorkflows = agent.workflows ?? {};
14536
14738
  const workflows = Object.keys(agentWorkflows).map((key) => ({ id: key, ...agentWorkflows[key] }));
14537
14739
  return /* @__PURE__ */ jsxs(AgentMetadataWrapper, { children: [
14740
+ agent?.description && /* @__PURE__ */ jsx(AgentMetadataSection, { title: "Description", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: agent.description }) }),
14538
14741
  agent.modelList ? /* @__PURE__ */ jsx(AgentMetadataSection, { title: "Models", children: /* @__PURE__ */ jsx(
14539
14742
  AgentMetadataModelList,
14540
14743
  {
@@ -14546,7 +14749,7 @@ const AgentMetadata = ({
14546
14749
  AgentMetadataSection,
14547
14750
  {
14548
14751
  title: "Model",
14549
- hint: modelVersion === "v2" ? void 0 : {
14752
+ hint: agent.modelVersion === "v2" ? void 0 : {
14550
14753
  link: "https://mastra.ai/guides/migrations/vnext-to-standard-apis",
14551
14754
  title: "You are using a legacy v1 model",
14552
14755
  icon: /* @__PURE__ */ jsx(AlertTriangleIcon, { fontSize: 14, className: "mb-0.5" })
@@ -14663,8 +14866,10 @@ const AgentMetadataScorerList = ({ entityId, entityType }) => {
14663
14866
  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
14867
  };
14665
14868
 
14666
- const AgentEntityHeader = ({ agentId, isLoading, agentName }) => {
14869
+ const AgentEntityHeader = ({ agentId }) => {
14870
+ const { data: agent, isLoading } = useAgent(agentId);
14667
14871
  const { handleCopy } = useCopyToClipboard({ text: agentId });
14872
+ const agentName = agent?.name || "";
14668
14873
  return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(EntityHeader, { icon: /* @__PURE__ */ jsx(AgentIcon, {}), title: agentName, isLoading, children: /* @__PURE__ */ jsxs(Tooltip, { children: [
14669
14874
  /* @__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
14875
  /* @__PURE__ */ jsx(TooltipContent, { children: "Copy Agent ID for use in code" })
@@ -14868,67 +15073,6 @@ const formatDay = (date) => {
14868
15073
  return new Date(date).toLocaleString("en-us", options).replace(",", " at");
14869
15074
  };
14870
15075
 
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
15076
  function AgentCombobox({
14933
15077
  value,
14934
15078
  onValueChange,
@@ -14976,17 +15120,6 @@ function AgentCombobox({
14976
15120
  );
14977
15121
  }
14978
15122
 
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
15123
  const useExecuteAgentTool = () => {
14991
15124
  const client = useMastraClient();
14992
15125
  return useMutation({
@@ -15094,91 +15227,6 @@ const AgentToolPanel = ({ toolId, agentId }) => {
15094
15227
  );
15095
15228
  };
15096
15229
 
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
15230
  function MarkdownRenderer({ children }) {
15183
15231
  const processedText = children.replace(/\\n/g, "\n");
15184
15232
  return /* @__PURE__ */ jsx(Markdown, { remarkPlugins: [remarkGfm], components: COMPONENTS, className: "space-y-3", children: processedText });
@@ -15960,14 +16008,24 @@ const TabContent$1 = ({ children, value }) => {
15960
16008
  };
15961
16009
 
15962
16010
  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";
16011
+ const { data: memory } = useMemory(agentId);
16012
+ const hasMemory = Boolean(memory?.result);
16013
+ return /* @__PURE__ */ jsxs(AgentInformationLayout, { agentId, children: [
16014
+ /* @__PURE__ */ jsx(AgentEntityHeader, { agentId }),
16015
+ /* @__PURE__ */ jsxs(AgentInformationTabLayout, { agentId, children: [
16016
+ /* @__PURE__ */ jsxs(TabList$1, { children: [
16017
+ /* @__PURE__ */ jsx(Tab$1, { value: "overview", children: "Overview" }),
16018
+ /* @__PURE__ */ jsx(Tab$1, { value: "model-settings", children: "Model Settings" }),
16019
+ hasMemory && /* @__PURE__ */ jsx(Tab$1, { value: "memory", children: "Memory" })
16020
+ ] }),
16021
+ /* @__PURE__ */ jsx(TabContent$1, { value: "overview", children: /* @__PURE__ */ jsx(AgentMetadata, { agentId }) }),
16022
+ /* @__PURE__ */ jsx(TabContent$1, { value: "model-settings", children: /* @__PURE__ */ jsx(AgentSettings, { agentId }) }),
16023
+ hasMemory && /* @__PURE__ */ jsx(TabContent$1, { value: "memory", children: /* @__PURE__ */ jsx(AgentMemory, { agentId, threadId }) })
16024
+ ] })
16025
+ ] });
16026
+ }
16027
+ const STORAGE_KEY = "agent-info-selected-tab";
16028
+ const useAgentInformationTab = ({ isMemoryLoading, hasMemory }) => {
15971
16029
  const [selectedTab, setSelectedTab] = useState(() => {
15972
16030
  return sessionStorage.getItem(STORAGE_KEY) || "overview";
15973
16031
  });
@@ -15976,7 +16034,20 @@ function AgentInformation({ agentId, threadId }) {
15976
16034
  sessionStorage.setItem(STORAGE_KEY, value);
15977
16035
  };
15978
16036
  useEffect(() => {
15979
- if (agent?.modelId?.includes("gpt-5")) {
16037
+ if (!isMemoryLoading && !hasMemory && selectedTab === "memory") {
16038
+ setSelectedTab("overview");
16039
+ sessionStorage.setItem(STORAGE_KEY, "overview");
16040
+ }
16041
+ }, [isMemoryLoading, hasMemory, selectedTab]);
16042
+ return {
16043
+ selectedTab,
16044
+ handleTabChange
16045
+ };
16046
+ };
16047
+ const useAgentInformationSettings = ({ modelId }) => {
16048
+ const { settings, setSettings } = useAgentSettings();
16049
+ useEffect(() => {
16050
+ if (modelId?.includes("gpt-5")) {
15980
16051
  setSettings({
15981
16052
  ...settings || {},
15982
16053
  modelSettings: {
@@ -15985,51 +16056,26 @@ function AgentInformation({ agentId, threadId }) {
15985
16056
  }
15986
16057
  });
15987
16058
  }
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
- }
16059
+ }, [modelId]);
16060
+ return {
16061
+ settings,
16062
+ setSettings
16063
+ };
16064
+ };
16065
+ const AgentInformationLayout = ({ children, agentId }) => {
16066
+ const { data: agent } = useAgent(agentId);
16067
+ useAgentInformationSettings({ modelId: agent?.modelId || "" });
16068
+ return /* @__PURE__ */ jsx("div", { className: "grid grid-rows-[auto_1fr] h-full items-start overflow-y-auto border-l-sm border-border1", children });
16069
+ };
16070
+ const AgentInformationTabLayout = ({ children, agentId }) => {
16071
+ const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
16072
+ const hasMemory = Boolean(memory?.result);
16073
+ const { selectedTab, handleTabChange } = useAgentInformationTab({
16074
+ isMemoryLoading,
16075
+ hasMemory
16076
+ });
16077
+ 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 }) });
16078
+ };
16033
16079
 
16034
16080
  const NameCell$1 = ({ row }) => {
16035
16081
  const { Link, paths } = useLinkComponent();
@@ -17703,7 +17749,15 @@ function SpanTabs({
17703
17749
  /* @__PURE__ */ jsx(CircleGaugeIcon, {}),
17704
17750
  " Scoring"
17705
17751
  ] }) }),
17706
- /* @__PURE__ */ jsx(SpanScoring, { traceId: trace?.traceId, spanId: span?.spanId, entityType })
17752
+ /* @__PURE__ */ jsx(
17753
+ SpanScoring,
17754
+ {
17755
+ traceId: trace?.traceId,
17756
+ isTopLevelSpan: span?.parentSpanId === null,
17757
+ spanId: span?.spanId,
17758
+ entityType
17759
+ }
17760
+ )
17707
17761
  ] }),
17708
17762
  /* @__PURE__ */ jsxs(Section, { children: [
17709
17763
  /* @__PURE__ */ jsx(Section.Header, { children: /* @__PURE__ */ jsxs(Section.Heading, { children: [
@@ -18300,8 +18354,8 @@ const useTriggerScorer = () => {
18300
18354
  });
18301
18355
  };
18302
18356
 
18303
- const SpanScoring = ({ traceId, spanId, entityType }) => {
18304
- const { data: scorers = {}, isLoading } = useScorers();
18357
+ const SpanScoring = ({ traceId, spanId, entityType, isTopLevelSpan }) => {
18358
+ const { data: scorers = {}, isLoading, error } = useScorers();
18305
18359
  const [selectedScorer, setSelectedScorer] = useState(null);
18306
18360
  const { mutate: triggerScorer, isPending, isSuccess } = useTriggerScorer();
18307
18361
  const [notificationIsVisible, setNotificationIsVisible] = useState(false);
@@ -18317,7 +18371,7 @@ const SpanScoring = ({ traceId, spanId, entityType }) => {
18317
18371
  isRegistered: scorer.isRegistered,
18318
18372
  type: scorer.scorer.config.type
18319
18373
  })).filter((scorer) => scorer.isRegistered);
18320
- if (entityType !== "Agent" || spanId) {
18374
+ if (entityType !== "Agent" || !isTopLevelSpan) {
18321
18375
  scorerList = scorerList.filter((scorer) => scorer.type !== "agent");
18322
18376
  }
18323
18377
  const isWaiting = isPending || isLoading;
@@ -18336,6 +18390,19 @@ const SpanScoring = ({ traceId, spanId, entityType }) => {
18336
18390
  setNotificationIsVisible(false);
18337
18391
  };
18338
18392
  const selectedScorerDescription = scorerList.find((s) => s.name === selectedScorer)?.description || "";
18393
+ if (error) {
18394
+ return /* @__PURE__ */ jsxs(Notification, { isVisible: true, autoDismiss: false, type: "error", children: [
18395
+ /* @__PURE__ */ jsx(InfoIcon$1, {}),
18396
+ " ",
18397
+ error?.message ? error.message : "Failed to load scorers."
18398
+ ] });
18399
+ }
18400
+ if (scorerList.length === 0) {
18401
+ return /* @__PURE__ */ jsxs(Notification, { isVisible: true, dismissible: false, children: [
18402
+ /* @__PURE__ */ jsx(InfoIcon$1, {}),
18403
+ " No eligible scorers have been defined to run."
18404
+ ] });
18405
+ }
18339
18406
  return /* @__PURE__ */ jsxs("div", { children: [
18340
18407
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[3fr_1fr] gap-[1rem] items-start", children: [
18341
18408
  /* @__PURE__ */ jsxs("div", { className: "grid gap-[0.5rem]", children: [
@@ -18932,5 +18999,5 @@ function MCPServerCombobox({
18932
18999
  );
18933
19000
  }
18934
19001
 
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 };
19002
+ 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
19003
  //# sourceMappingURL=index.es.js.map