@mastra/playground-ui 6.6.2-alpha.0 → 6.7.0-alpha.0

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/index.cjs.js +800 -70
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.es.js +786 -75
  5. package/dist/index.es.js.map +1 -1
  6. package/dist/src/components/assistant-ui/tools/badges/agent-badge-wrapper.d.ts +3 -2
  7. package/dist/src/components/assistant-ui/tools/badges/agent-badge.d.ts +3 -2
  8. package/dist/src/components/assistant-ui/tools/badges/tool-approval-buttons.d.ts +10 -0
  9. package/dist/src/components/assistant-ui/tools/badges/tool-badge.d.ts +3 -2
  10. package/dist/src/components/assistant-ui/tools/badges/workflow-badge.d.ts +4 -3
  11. package/dist/src/components/assistant-ui/tools/tool-approval.d.ts +8 -0
  12. package/dist/src/domains/agents/hooks/use-agents.d.ts +12 -0
  13. package/dist/src/domains/agents/hooks/use-execute-agent-tool.d.ts +7 -0
  14. package/dist/src/domains/agents/index.d.ts +3 -0
  15. package/dist/src/domains/evals/hooks/index.d.ts +1 -0
  16. package/dist/src/domains/evals/hooks/use-evals-by-agent-id.d.ts +14 -0
  17. package/dist/src/domains/evals/index.d.ts +1 -0
  18. package/dist/src/domains/memory/hooks/index.d.ts +1 -0
  19. package/dist/src/domains/memory/hooks/use-memory.d.ts +25 -0
  20. package/dist/src/domains/tools/hooks/index.d.ts +1 -0
  21. package/dist/src/domains/tools/hooks/use-execute-tool.d.ts +5 -0
  22. package/dist/src/domains/tools/index.d.ts +1 -0
  23. package/dist/src/domains/workflows/hooks/index.d.ts +2 -0
  24. package/dist/src/domains/workflows/hooks/use-workflows-actions.d.ts +67 -0
  25. package/dist/src/domains/workflows/hooks/use-workflows.d.ts +1 -0
  26. package/dist/src/domains/workflows/index.d.ts +1 -0
  27. package/dist/src/hooks/use-workflows.d.ts +0 -8
  28. package/dist/src/index.d.ts +2 -0
  29. package/dist/src/services/tool-call-provider.d.ts +25 -0
  30. package/dist/src/types/memory.d.ts +3 -0
  31. package/dist/src/types.d.ts +1 -0
  32. package/package.json +16 -8
package/dist/index.es.js CHANGED
@@ -47,13 +47,14 @@ import * as LabelPrimitive from '@radix-ui/react-label';
47
47
  import { ZodProvider, getFieldConfigInZodStack, getDefaultValueInZodStack } from '@autoform/zod/v4';
48
48
  import { z as z$1 } from 'zod/v3';
49
49
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
50
- import { useMastraClient, resolveToChildMessages, useChat, toAssistantUIMessage } from '@mastra/react';
51
- import { useQuery, useMutation, QueryClient, QueryClientProvider } from '@tanstack/react-query';
50
+ import { useMastraClient, mapWorkflowStreamChunkToWatchResult, resolveToChildMessages, useChat, toAssistantUIMessage } from '@mastra/react';
51
+ import { useQuery, useMutation, useQueryClient, QueryClient, QueryClientProvider } from '@tanstack/react-query';
52
52
  import './index.css';export * from '@tanstack/react-query';
53
53
  import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-table';
54
+ import { RuntimeContext as RuntimeContext$1 } from '@mastra/core/runtime-context';
54
55
  import Markdown from 'react-markdown';
55
56
  import { useShallow } from 'zustand/shallow';
56
- import { RuntimeContext as RuntimeContext$1 } from '@mastra/core/di';
57
+ import { RuntimeContext as RuntimeContext$2 } from '@mastra/core/di';
57
58
  import { MastraClient } from '@mastra/client-js';
58
59
  import { AnimatePresence } from 'motion/react';
59
60
  import * as TabsPrimitive from '@radix-ui/react-tabs';
@@ -4396,6 +4397,9 @@ const BadgeWrapper = ({
4396
4397
  "data-testid": dataTestId
4397
4398
  }) => {
4398
4399
  const [isCollapsed, setIsCollapsed] = useState(initialCollapsed);
4400
+ useEffect(() => {
4401
+ setIsCollapsed(initialCollapsed);
4402
+ }, [initialCollapsed]);
4399
4403
  return /* @__PURE__ */ jsxs("div", { className: "mb-4", "data-testid": dataTestId, children: [
4400
4404
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row gap-2 items-center justify-between", children: [
4401
4405
  /* @__PURE__ */ jsxs(
@@ -4512,17 +4516,114 @@ const NetworkChoiceMetadataDialogTrigger = ({
4512
4516
  ] });
4513
4517
  };
4514
4518
 
4515
- const ToolBadge = ({ toolName, args, result, metadata, toolOutput }) => {
4519
+ const sizeClasses = {
4520
+ md: "h-button-md gap-md",
4521
+ lg: "h-button-lg gap-lg"
4522
+ };
4523
+ const variantClasses$1 = {
4524
+ default: "bg-surface2 hover:bg-surface4 text-icon3 hover:text-icon6 disabled:opacity-50",
4525
+ light: "bg-surface3 hover:bg-surface5 text-icon6 disabled:opacity-50"
4526
+ };
4527
+ const Button$1 = ({ className, as, size = "md", variant = "default", ...props }) => {
4528
+ const Component = as || "button";
4529
+ return /* @__PURE__ */ jsx(
4530
+ Component,
4531
+ {
4532
+ className: clsx(
4533
+ "bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
4534
+ variantClasses$1[variant],
4535
+ sizeClasses[size],
4536
+ className,
4537
+ {
4538
+ "cursor-not-allowed": props.disabled
4539
+ }
4540
+ ),
4541
+ ...props
4542
+ }
4543
+ );
4544
+ };
4545
+
4546
+ const ToolCallContext = createContext(void 0);
4547
+ function ToolCallProvider({
4548
+ children,
4549
+ approveToolcall,
4550
+ declineToolcall,
4551
+ isRunning,
4552
+ toolCallApprovals
4553
+ }) {
4554
+ return /* @__PURE__ */ jsx(ToolCallContext.Provider, { value: { approveToolcall, declineToolcall, isRunning, toolCallApprovals }, children });
4555
+ }
4556
+ function useToolCall() {
4557
+ const context = useContext(ToolCallContext);
4558
+ if (!context) {
4559
+ throw new Error("useToolCall must be used within a ToolCallProvider");
4560
+ }
4561
+ return context;
4562
+ }
4563
+
4564
+ const ToolApprovalButtons = ({ toolCalled, toolCallId, toolApprovalMetadata }) => {
4565
+ const { approveToolcall, declineToolcall, isRunning, toolCallApprovals } = useToolCall();
4566
+ const handleApprove = () => {
4567
+ approveToolcall(toolCallId);
4568
+ };
4569
+ const handleDecline = () => {
4570
+ declineToolcall(toolCallId);
4571
+ };
4572
+ const toolCallApprovalStatus = toolCallApprovals?.[toolCallId]?.status;
4573
+ if (toolApprovalMetadata && !toolCalled) {
4574
+ return /* @__PURE__ */ jsxs("div", { children: [
4575
+ /* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Approval required" }),
4576
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-center", children: [
4577
+ /* @__PURE__ */ jsxs(
4578
+ Button$1,
4579
+ {
4580
+ onClick: handleApprove,
4581
+ disabled: isRunning || !!toolCallApprovalStatus,
4582
+ className: toolCallApprovalStatus === "approved" ? "!text-accent1" : "",
4583
+ children: [
4584
+ /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Check, {}) }),
4585
+ "Approve"
4586
+ ]
4587
+ }
4588
+ ),
4589
+ /* @__PURE__ */ jsxs(
4590
+ Button$1,
4591
+ {
4592
+ onClick: handleDecline,
4593
+ disabled: isRunning || !!toolCallApprovalStatus,
4594
+ className: toolCallApprovalStatus === "declined" ? "!text-accent2" : "",
4595
+ children: [
4596
+ /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(X, {}) }),
4597
+ "Decline"
4598
+ ]
4599
+ }
4600
+ )
4601
+ ] })
4602
+ ] });
4603
+ }
4604
+ return null;
4605
+ };
4606
+
4607
+ const ToolBadge = ({
4608
+ toolName,
4609
+ args,
4610
+ result,
4611
+ metadata,
4612
+ toolOutput,
4613
+ toolCallId,
4614
+ toolApprovalMetadata
4615
+ }) => {
4516
4616
  let argSlot = null;
4517
4617
  try {
4518
4618
  const { __mastraMetadata: _, ...formattedArgs } = typeof args === "object" ? args : JSON.parse(args);
4519
4619
  argSlot = /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: formattedArgs, "data-testid": "tool-args" });
4520
4620
  } catch {
4521
- argSlot = /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: args });
4621
+ argSlot = /* @__PURE__ */ jsx("pre", { className: "whitespace-pre bg-surface4 p-4 rounded-md overflow-x-auto", children: args });
4522
4622
  }
4523
- let resultSlot = typeof result === "string" ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap bg-surface4 p-4 rounded-md", children: result }) : /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: result, "data-testid": "tool-result" });
4623
+ let resultSlot = typeof result === "string" ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre bg-surface4 p-4 rounded-md overflow-x-auto", children: result }) : /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: result, "data-testid": "tool-result" });
4524
4624
  const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
4525
4625
  const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
4626
+ const toolCalled = result || toolOutput.length > 0;
4526
4627
  return /* @__PURE__ */ jsx(
4527
4628
  BadgeWrapper,
4528
4629
  {
@@ -4536,19 +4637,28 @@ const ToolBadge = ({ toolName, args, result, metadata, toolOutput }) => {
4536
4637
  input: agentNetworkInput
4537
4638
  }
4538
4639
  ),
4640
+ initialCollapsed: !!!toolApprovalMetadata,
4539
4641
  children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
4540
4642
  /* @__PURE__ */ jsxs("div", { children: [
4541
4643
  /* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool arguments" }),
4542
4644
  argSlot
4543
4645
  ] }),
4544
- resultSlot !== void 0 && /* @__PURE__ */ jsxs("div", { children: [
4646
+ resultSlot !== void 0 && result && /* @__PURE__ */ jsxs("div", { children: [
4545
4647
  /* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool result" }),
4546
4648
  resultSlot
4547
4649
  ] }),
4548
4650
  toolOutput.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
4549
4651
  /* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool output" }),
4550
4652
  /* @__PURE__ */ jsx("div", { className: "h-40 overflow-y-auto", children: /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: toolOutput, "data-testid": "tool-output" }) })
4551
- ] })
4653
+ ] }),
4654
+ /* @__PURE__ */ jsx(
4655
+ ToolApprovalButtons,
4656
+ {
4657
+ toolCalled,
4658
+ toolCallId,
4659
+ toolApprovalMetadata
4660
+ }
4661
+ )
4552
4662
  ] })
4553
4663
  }
4554
4664
  );
@@ -5135,33 +5245,6 @@ const useCurrentRun = () => {
5135
5245
  return { steps, runId: context.runId };
5136
5246
  };
5137
5247
 
5138
- const sizeClasses = {
5139
- md: "h-button-md gap-md",
5140
- lg: "h-button-lg gap-lg"
5141
- };
5142
- const variantClasses$1 = {
5143
- default: "bg-surface2 hover:bg-surface4 text-icon3 hover:text-icon6",
5144
- light: "bg-surface3 hover:bg-surface5 text-icon6"
5145
- };
5146
- const Button$1 = ({ className, as, size = "md", variant = "default", ...props }) => {
5147
- const Component = as || "button";
5148
- return /* @__PURE__ */ jsx(
5149
- Component,
5150
- {
5151
- className: clsx(
5152
- "bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
5153
- variantClasses$1[variant],
5154
- sizeClasses[size],
5155
- className,
5156
- {
5157
- "cursor-not-allowed": props.disabled
5158
- }
5159
- ),
5160
- ...props
5161
- }
5162
- );
5163
- };
5164
-
5165
5248
  const useCodemirrorTheme$1 = () => {
5166
5249
  return useMemo(
5167
5250
  () => draculaInit({
@@ -7762,6 +7845,334 @@ const EmptyWorkflowsTable = () => /* @__PURE__ */ jsx("div", { className: "flex
7762
7845
  }
7763
7846
  ) });
7764
7847
 
7848
+ const useWorkflows = () => {
7849
+ const client = useMastraClient();
7850
+ const { runtimeContext } = usePlaygroundStore();
7851
+ return useQuery({
7852
+ queryKey: ["workflows", JSON.stringify(runtimeContext)],
7853
+ queryFn: () => client.getWorkflows(runtimeContext)
7854
+ });
7855
+ };
7856
+
7857
+ const useExecuteWorkflow = () => {
7858
+ const client = useMastraClient();
7859
+ const createWorkflowRun = useMutation({
7860
+ mutationFn: async ({ workflowId, prevRunId }) => {
7861
+ try {
7862
+ const workflow = client.getWorkflow(workflowId);
7863
+ const { runId: newRunId } = await workflow.createRunAsync({ runId: prevRunId });
7864
+ return { runId: newRunId };
7865
+ } catch (error) {
7866
+ console.error("Error creating workflow run:", error);
7867
+ throw error;
7868
+ }
7869
+ }
7870
+ });
7871
+ const startWorkflowRun = useMutation({
7872
+ mutationFn: async ({
7873
+ workflowId,
7874
+ runId,
7875
+ input,
7876
+ runtimeContext: playgroundRuntimeContext
7877
+ }) => {
7878
+ try {
7879
+ const runtimeContext = new RuntimeContext$1();
7880
+ Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
7881
+ runtimeContext.set(key, value);
7882
+ });
7883
+ const workflow = client.getWorkflow(workflowId);
7884
+ await workflow.start({ runId, inputData: input || {}, runtimeContext });
7885
+ } catch (error) {
7886
+ console.error("Error starting workflow run:", error);
7887
+ throw error;
7888
+ }
7889
+ }
7890
+ });
7891
+ const startAsyncWorkflowRun = useMutation({
7892
+ mutationFn: async ({
7893
+ workflowId,
7894
+ runId,
7895
+ input,
7896
+ runtimeContext: playgroundRuntimeContext
7897
+ }) => {
7898
+ try {
7899
+ const runtimeContext = new RuntimeContext$1();
7900
+ Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
7901
+ runtimeContext.set(key, value);
7902
+ });
7903
+ const workflow = client.getWorkflow(workflowId);
7904
+ const result = await workflow.startAsync({ runId, inputData: input || {}, runtimeContext });
7905
+ return result;
7906
+ } catch (error) {
7907
+ console.error("Error starting workflow run:", error);
7908
+ throw error;
7909
+ }
7910
+ }
7911
+ });
7912
+ return {
7913
+ startWorkflowRun,
7914
+ createWorkflowRun,
7915
+ startAsyncWorkflowRun
7916
+ };
7917
+ };
7918
+ const useStreamWorkflow = () => {
7919
+ const client = useMastraClient();
7920
+ const [streamResult, setStreamResult] = useState({});
7921
+ const [isStreaming, setIsStreaming] = useState(false);
7922
+ const readerRef = useRef(null);
7923
+ const observerRef = useRef(null);
7924
+ const resumeStreamRef = useRef(null);
7925
+ const isMountedRef = useRef(true);
7926
+ useEffect(() => {
7927
+ isMountedRef.current = true;
7928
+ return () => {
7929
+ isMountedRef.current = false;
7930
+ if (readerRef.current) {
7931
+ try {
7932
+ readerRef.current.releaseLock();
7933
+ } catch (error) {
7934
+ }
7935
+ readerRef.current = null;
7936
+ }
7937
+ if (observerRef.current) {
7938
+ try {
7939
+ observerRef.current.releaseLock();
7940
+ } catch (error) {
7941
+ }
7942
+ observerRef.current = null;
7943
+ }
7944
+ if (resumeStreamRef.current) {
7945
+ try {
7946
+ resumeStreamRef.current.releaseLock();
7947
+ } catch (error) {
7948
+ }
7949
+ resumeStreamRef.current = null;
7950
+ }
7951
+ };
7952
+ }, []);
7953
+ const streamWorkflow = useMutation({
7954
+ mutationFn: async ({
7955
+ workflowId,
7956
+ runId,
7957
+ inputData,
7958
+ runtimeContext: playgroundRuntimeContext
7959
+ }) => {
7960
+ if (readerRef.current) {
7961
+ readerRef.current.releaseLock();
7962
+ }
7963
+ if (!isMountedRef.current) return;
7964
+ setIsStreaming(true);
7965
+ setStreamResult({ input: inputData });
7966
+ const runtimeContext = new RuntimeContext$1();
7967
+ Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
7968
+ runtimeContext.set(key, value);
7969
+ });
7970
+ const workflow = client.getWorkflow(workflowId);
7971
+ const stream = await workflow.streamVNext({ runId, inputData, runtimeContext, closeOnSuspend: true });
7972
+ if (!stream) throw new Error("No stream returned");
7973
+ const reader = stream.getReader();
7974
+ readerRef.current = reader;
7975
+ try {
7976
+ while (true) {
7977
+ if (!isMountedRef.current) break;
7978
+ const { done, value } = await reader.read();
7979
+ if (done) break;
7980
+ if (isMountedRef.current) {
7981
+ setStreamResult((prev) => {
7982
+ const newResult = mapWorkflowStreamChunkToWatchResult(prev, value);
7983
+ return newResult;
7984
+ });
7985
+ if (value.type === "workflow-step-start") {
7986
+ setIsStreaming(true);
7987
+ }
7988
+ if (value.type === "workflow-step-suspended") {
7989
+ setIsStreaming(false);
7990
+ }
7991
+ }
7992
+ }
7993
+ } catch (error) {
7994
+ console.error("Error streaming workflow:", error);
7995
+ } finally {
7996
+ if (isMountedRef.current) {
7997
+ setIsStreaming(false);
7998
+ }
7999
+ if (readerRef.current) {
8000
+ readerRef.current.releaseLock();
8001
+ readerRef.current = null;
8002
+ }
8003
+ }
8004
+ }
8005
+ });
8006
+ const observeWorkflowStream = useMutation({
8007
+ mutationFn: async ({
8008
+ workflowId,
8009
+ runId,
8010
+ storeRunResult
8011
+ }) => {
8012
+ if (observerRef.current) {
8013
+ observerRef.current.releaseLock();
8014
+ }
8015
+ if (!isMountedRef.current) return;
8016
+ setIsStreaming(true);
8017
+ setStreamResult(storeRunResult || {});
8018
+ if (storeRunResult?.status === "suspended") {
8019
+ setIsStreaming(false);
8020
+ return;
8021
+ }
8022
+ const workflow = client.getWorkflow(workflowId);
8023
+ const stream = await workflow.observeStreamVNext({ runId });
8024
+ if (!stream) throw new Error("No stream returned");
8025
+ const reader = stream.getReader();
8026
+ observerRef.current = reader;
8027
+ try {
8028
+ while (true) {
8029
+ if (!isMountedRef.current) break;
8030
+ const { done, value } = await reader.read();
8031
+ if (done) break;
8032
+ if (isMountedRef.current) {
8033
+ setStreamResult((prev) => {
8034
+ const newResult = mapWorkflowStreamChunkToWatchResult(prev, value);
8035
+ return newResult;
8036
+ });
8037
+ if (value.type === "workflow-step-start") {
8038
+ setIsStreaming(true);
8039
+ }
8040
+ if (value.type === "workflow-step-suspended") {
8041
+ setIsStreaming(false);
8042
+ }
8043
+ }
8044
+ }
8045
+ } catch (error) {
8046
+ console.error("Error streaming workflow:", error);
8047
+ } finally {
8048
+ if (isMountedRef.current) {
8049
+ setIsStreaming(false);
8050
+ }
8051
+ if (observerRef.current) {
8052
+ observerRef.current.releaseLock();
8053
+ observerRef.current = null;
8054
+ }
8055
+ }
8056
+ }
8057
+ });
8058
+ const resumeWorkflowStream = useMutation({
8059
+ mutationFn: async ({
8060
+ workflowId,
8061
+ runId,
8062
+ step,
8063
+ resumeData,
8064
+ runtimeContext: playgroundRuntimeContext
8065
+ }) => {
8066
+ if (resumeStreamRef.current) {
8067
+ resumeStreamRef.current.releaseLock();
8068
+ }
8069
+ if (!isMountedRef.current) return;
8070
+ setIsStreaming(true);
8071
+ const workflow = client.getWorkflow(workflowId);
8072
+ const runtimeContext = new RuntimeContext$1();
8073
+ Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
8074
+ runtimeContext.set(key, value);
8075
+ });
8076
+ const stream = await workflow.resumeStreamVNext({ runId, step, resumeData, runtimeContext });
8077
+ if (!stream) throw new Error("No stream returned");
8078
+ const reader = stream.getReader();
8079
+ resumeStreamRef.current = reader;
8080
+ try {
8081
+ while (true) {
8082
+ if (!isMountedRef.current) break;
8083
+ const { done, value } = await reader.read();
8084
+ if (done) break;
8085
+ if (isMountedRef.current) {
8086
+ setStreamResult((prev) => {
8087
+ const newResult = mapWorkflowStreamChunkToWatchResult(prev, value);
8088
+ return newResult;
8089
+ });
8090
+ if (value.type === "workflow-step-start") {
8091
+ setIsStreaming(true);
8092
+ }
8093
+ if (value.type === "workflow-step-suspended") {
8094
+ setIsStreaming(false);
8095
+ }
8096
+ }
8097
+ }
8098
+ } catch (error) {
8099
+ console.error("Error resuming workflow stream:", error);
8100
+ } finally {
8101
+ if (isMountedRef.current) {
8102
+ setIsStreaming(false);
8103
+ }
8104
+ if (resumeStreamRef.current) {
8105
+ resumeStreamRef.current.releaseLock();
8106
+ resumeStreamRef.current = null;
8107
+ }
8108
+ }
8109
+ }
8110
+ });
8111
+ const closeStreamsAndReset = () => {
8112
+ setIsStreaming(false);
8113
+ setStreamResult({});
8114
+ if (readerRef.current) {
8115
+ try {
8116
+ readerRef.current.releaseLock();
8117
+ } catch (error) {
8118
+ }
8119
+ readerRef.current = null;
8120
+ }
8121
+ if (observerRef.current) {
8122
+ try {
8123
+ observerRef.current.releaseLock();
8124
+ } catch (error) {
8125
+ }
8126
+ observerRef.current = null;
8127
+ }
8128
+ if (resumeStreamRef.current) {
8129
+ try {
8130
+ resumeStreamRef.current.releaseLock();
8131
+ } catch (error) {
8132
+ }
8133
+ resumeStreamRef.current = null;
8134
+ }
8135
+ };
8136
+ return {
8137
+ streamWorkflow,
8138
+ streamResult,
8139
+ isStreaming,
8140
+ observeWorkflowStream,
8141
+ closeStreamsAndReset,
8142
+ resumeWorkflowStream
8143
+ };
8144
+ };
8145
+ const useCancelWorkflowRun = () => {
8146
+ const client = useMastraClient();
8147
+ const cancelWorkflowRun = useMutation({
8148
+ mutationFn: async ({ workflowId, runId }) => {
8149
+ try {
8150
+ const response = await client.getWorkflow(workflowId).cancelRun(runId);
8151
+ return response;
8152
+ } catch (error) {
8153
+ console.error("Error canceling workflow run:", error);
8154
+ throw error;
8155
+ }
8156
+ }
8157
+ });
8158
+ return cancelWorkflowRun;
8159
+ };
8160
+ const useSendWorkflowRunEvent = (workflowId) => {
8161
+ const client = useMastraClient();
8162
+ const sendWorkflowRunEvent = useMutation({
8163
+ mutationFn: async ({ runId, event, data }) => {
8164
+ try {
8165
+ const response = await client.getWorkflow(workflowId).sendRunEvent({ runId, event, data });
8166
+ return response;
8167
+ } catch (error) {
8168
+ console.error("Error sending workflow run event:", error);
8169
+ throw error;
8170
+ }
8171
+ }
8172
+ });
8173
+ return sendWorkflowRunEvent;
8174
+ };
8175
+
7765
8176
  const LoadingBadge = () => {
7766
8177
  return /* @__PURE__ */ jsx(
7767
8178
  BadgeWrapper,
@@ -7800,7 +8211,15 @@ const useWorkflow = (workflowId) => {
7800
8211
  });
7801
8212
  };
7802
8213
 
7803
- const WorkflowBadge = ({ runId, workflowId, isStreaming, metadata }) => {
8214
+ const WorkflowBadge = ({
8215
+ result,
8216
+ workflowId,
8217
+ isStreaming,
8218
+ metadata,
8219
+ toolCallId,
8220
+ toolApprovalMetadata
8221
+ }) => {
8222
+ const { runId, status } = result || {};
7804
8223
  const { data: workflow, isLoading: isWorkflowLoading } = useWorkflow(workflowId);
7805
8224
  const { data: runs, isLoading: isRunsLoading } = useWorkflowRuns(workflowId, {
7806
8225
  enabled: Boolean(runId) && !isStreaming
@@ -7827,7 +8246,8 @@ const WorkflowBadge = ({ runId, workflowId, isStreaming, metadata }) => {
7827
8246
  ),
7828
8247
  children: [
7829
8248
  !isStreaming && !isLoading && /* @__PURE__ */ jsx(WorkflowRunProvider, { snapshot, children: /* @__PURE__ */ jsx(WorkflowBadgeExtended, { workflowId, workflow, runId }) }),
7830
- isStreaming && /* @__PURE__ */ jsx(WorkflowBadgeExtended, { workflowId, workflow, runId })
8249
+ isStreaming && /* @__PURE__ */ jsx(WorkflowBadgeExtended, { workflowId, workflow, runId }),
8250
+ /* @__PURE__ */ jsx(ToolApprovalButtons, { toolCalled: !!status, toolCallId, toolApprovalMetadata })
7831
8251
  ]
7832
8252
  }
7833
8253
  );
@@ -7850,10 +8270,10 @@ const useWorkflowStream = (workflowFullState) => {
7850
8270
  }, [workflowFullState]);
7851
8271
  };
7852
8272
 
7853
- const AgentBadge = ({ agentId, messages = [], metadata }) => {
8273
+ const AgentBadge = ({ agentId, messages = [], metadata, toolCallId, toolApprovalMetadata }) => {
7854
8274
  const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
7855
8275
  const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
7856
- return /* @__PURE__ */ jsx(
8276
+ return /* @__PURE__ */ jsxs(
7857
8277
  BadgeWrapper,
7858
8278
  {
7859
8279
  "data-testid": "agent-badge",
@@ -7867,29 +8287,39 @@ const AgentBadge = ({ agentId, messages = [], metadata }) => {
7867
8287
  input: agentNetworkInput
7868
8288
  }
7869
8289
  ),
7870
- children: messages.map((message, index) => {
7871
- if (message.type === "text") {
7872
- return /* @__PURE__ */ jsx(Markdown, { children: message.content }, index);
7873
- }
7874
- const result = typeof message.toolOutput === "string" ? JSON.parse(message.toolOutput) : message.toolOutput;
7875
- return /* @__PURE__ */ jsx(React__default.Fragment, { children: /* @__PURE__ */ jsx(
7876
- ToolFallback,
7877
- {
7878
- toolName: message.toolName,
7879
- argsText: typeof message.args === "string" ? message.args : JSON.stringify(message.args),
7880
- result,
7881
- args: message.args,
7882
- status: { type: "complete" },
7883
- type: "tool-call",
7884
- toolCallId: message.toolCallId,
7885
- addResult: () => {
7886
- },
7887
- metadata: {
7888
- mode: "stream"
8290
+ children: [
8291
+ messages.map((message, index) => {
8292
+ if (message.type === "text") {
8293
+ return /* @__PURE__ */ jsx(Markdown, { children: message.content }, index);
8294
+ }
8295
+ const result = typeof message.toolOutput === "string" ? JSON.parse(message.toolOutput) : message.toolOutput;
8296
+ return /* @__PURE__ */ jsx(React__default.Fragment, { children: /* @__PURE__ */ jsx(
8297
+ ToolFallback,
8298
+ {
8299
+ toolName: message.toolName,
8300
+ argsText: typeof message.args === "string" ? message.args : JSON.stringify(message.args),
8301
+ result,
8302
+ args: message.args,
8303
+ status: { type: "complete" },
8304
+ type: "tool-call",
8305
+ toolCallId: message.toolCallId,
8306
+ addResult: () => {
8307
+ },
8308
+ metadata: {
8309
+ mode: "stream"
8310
+ }
7889
8311
  }
8312
+ ) }, index);
8313
+ }),
8314
+ /* @__PURE__ */ jsx(
8315
+ ToolApprovalButtons,
8316
+ {
8317
+ toolCalled: messages?.length > 0,
8318
+ toolCallId,
8319
+ toolApprovalMetadata
7890
8320
  }
7891
- ) }, index);
7892
- })
8321
+ )
8322
+ ]
7893
8323
  }
7894
8324
  );
7895
8325
  };
@@ -7911,27 +8341,53 @@ const useAgentMessages = ({
7911
8341
  });
7912
8342
  };
7913
8343
 
7914
- const AgentBadgeWrapper = ({ agentId, result, metadata }) => {
8344
+ const AgentBadgeWrapper = ({
8345
+ agentId,
8346
+ result,
8347
+ metadata,
8348
+ toolCallId,
8349
+ toolApprovalMetadata
8350
+ }) => {
7915
8351
  const { data: memoryMessages } = useAgentMessages({
7916
8352
  threadId: result?.subAgentThreadId ?? "",
7917
8353
  agentId,
7918
8354
  memory: true
7919
8355
  });
7920
8356
  const childMessages = result?.childMessages ?? resolveToChildMessages(memoryMessages?.uiMessages ?? []);
7921
- return /* @__PURE__ */ jsx(AgentBadge, { agentId, messages: childMessages, metadata });
8357
+ return /* @__PURE__ */ jsx(
8358
+ AgentBadge,
8359
+ {
8360
+ agentId,
8361
+ messages: childMessages,
8362
+ metadata,
8363
+ toolCallId,
8364
+ toolApprovalMetadata
8365
+ }
8366
+ );
7922
8367
  };
7923
8368
 
7924
8369
  const ToolFallback = ({ toolName, result, args, ...props }) => {
7925
8370
  return /* @__PURE__ */ jsx(WorkflowRunProvider, { children: /* @__PURE__ */ jsx(ToolFallbackInner, { toolName, result, args, ...props }) });
7926
8371
  };
7927
- const ToolFallbackInner = ({ toolName, result, args, metadata, ...props }) => {
8372
+ const ToolFallbackInner = ({ toolName, result, args, metadata, toolCallId, ...props }) => {
7928
8373
  const isAgent = metadata?.mode === "network" && metadata.from === "AGENT" || toolName.startsWith("agent-");
7929
8374
  const isWorkflow = metadata?.mode === "network" && metadata.from === "WORKFLOW" || toolName.startsWith("workflow-");
7930
8375
  const agentToolName = toolName.startsWith("agent-") ? toolName.substring("agent-".length) : toolName;
7931
8376
  const workflowToolName = toolName.startsWith("workflow-") ? toolName.substring("workflow-".length) : toolName;
8377
+ const requireApprovalMetadata = metadata?.mode === "stream" && metadata?.requireApprovalMetadata;
8378
+ const toolApprovalMetadata = requireApprovalMetadata ? requireApprovalMetadata?.[toolCallId] : void 0;
7932
8379
  useWorkflowStream(result);
7933
8380
  if (isAgent) {
7934
- return /* @__PURE__ */ jsx(AgentBadgeWrapper, { agentId: agentToolName, result, metadata });
8381
+ return /* @__PURE__ */ jsx(
8382
+ AgentBadgeWrapper,
8383
+ {
8384
+ agentId: agentToolName,
8385
+ result,
8386
+ metadata,
8387
+ toolCallId,
8388
+ toolApprovalMetadata
8389
+ }
8390
+ );
7935
8391
  }
7936
8392
  if (isWorkflow) {
7937
8393
  const isStreaming = metadata?.mode === "stream" || metadata?.mode === "network";
@@ -7940,8 +8396,10 @@ const ToolFallbackInner = ({ toolName, result, args, metadata, ...props }) => {
7940
8396
  {
7941
8397
  workflowId: workflowToolName,
7942
8398
  isStreaming,
7943
- runId: result?.runId,
7944
- metadata
8399
+ result,
8400
+ metadata,
8401
+ toolCallId,
8402
+ toolApprovalMetadata
7945
8403
  }
7946
8404
  );
7947
8405
  }
@@ -7952,7 +8410,9 @@ const ToolFallbackInner = ({ toolName, result, args, metadata, ...props }) => {
7952
8410
  args,
7953
8411
  result,
7954
8412
  toolOutput: result?.toolOutput || [],
7955
- metadata
8413
+ metadata,
8414
+ toolCallId,
8415
+ toolApprovalMetadata
7956
8416
  }
7957
8417
  );
7958
8418
  };
@@ -9620,7 +10080,10 @@ function MastraRuntimeProvider({
9620
10080
  sendMessage,
9621
10081
  cancelRun,
9622
10082
  isRunning: isRunningStream,
9623
- setMessages
10083
+ setMessages,
10084
+ approveToolCall,
10085
+ declineToolCall,
10086
+ toolCallApprovals
9624
10087
  } = useChat({
9625
10088
  agentId,
9626
10089
  initializeMessages: () => initialMessages || []
@@ -9640,10 +10103,11 @@ function MastraRuntimeProvider({
9640
10103
  chatWithGenerateLegacy,
9641
10104
  chatWithGenerate,
9642
10105
  chatWithNetwork,
9643
- providerOptions
10106
+ providerOptions,
10107
+ requireToolApproval
9644
10108
  } = settings?.modelSettings ?? {};
9645
10109
  const toolCallIdToName = useRef({});
9646
- const runtimeContextInstance = new RuntimeContext$1();
10110
+ const runtimeContextInstance = new RuntimeContext$2();
9647
10111
  Object.entries(runtimeContext ?? {}).forEach(([key, value]) => {
9648
10112
  runtimeContextInstance.set(key, value);
9649
10113
  });
@@ -9657,7 +10121,8 @@ function MastraRuntimeProvider({
9657
10121
  maxTokens,
9658
10122
  instructions,
9659
10123
  providerOptions,
9660
- maxSteps
10124
+ maxSteps,
10125
+ requireToolApproval
9661
10126
  };
9662
10127
  const baseClient = useMastraClient();
9663
10128
  const isVNext = modelVersion === "v2";
@@ -10045,10 +10510,23 @@ function MastraRuntimeProvider({
10045
10510
  convertMessage: (x) => x,
10046
10511
  onNew,
10047
10512
  onCancel,
10048
- adapters: isReady ? adapters : void 0
10513
+ adapters: isReady ? adapters : void 0,
10514
+ extras: {
10515
+ approveToolCall,
10516
+ declineToolCall
10517
+ }
10049
10518
  });
10050
10519
  if (!isReady) return null;
10051
- return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { runtime, children });
10520
+ return /* @__PURE__ */ jsx(AssistantRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx(
10521
+ ToolCallProvider,
10522
+ {
10523
+ approveToolcall: approveToolCall,
10524
+ declineToolcall: declineToolCall,
10525
+ isRunning: isRunningStream,
10526
+ toolCallApprovals,
10527
+ children
10528
+ }
10529
+ ) });
10052
10530
  }
10053
10531
 
10054
10532
  const defaultSettings = {
@@ -10869,6 +11347,16 @@ const AgentSettings = ({ modelVersion, hasMemory = false, hasSubAgents = false }
10869
11347
  ]
10870
11348
  }
10871
11349
  ) }),
11350
+ /* @__PURE__ */ jsx(Entry, { label: "Require Tool Approval", children: /* @__PURE__ */ jsx(
11351
+ Checkbox,
11352
+ {
11353
+ checked: settings?.modelSettings?.requireToolApproval,
11354
+ onCheckedChange: (value) => setSettings({
11355
+ ...settings,
11356
+ modelSettings: { ...settings?.modelSettings, requireToolApproval: value }
11357
+ })
11358
+ }
11359
+ ) }),
10872
11360
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-8", children: [
10873
11361
  /* @__PURE__ */ jsx(Entry, { label: "Temperature", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-row justify-between items-center gap-2", children: [
10874
11362
  /* @__PURE__ */ jsx(
@@ -14269,6 +14757,93 @@ const formatDay = (date) => {
14269
14757
  return new Date(date).toLocaleString("en-us", options).replace(",", " at");
14270
14758
  };
14271
14759
 
14760
+ const useAgents = () => {
14761
+ const client = useMastraClient();
14762
+ const { runtimeContext } = usePlaygroundStore();
14763
+ return useQuery({
14764
+ queryKey: ["agents", JSON.stringify(runtimeContext)],
14765
+ queryFn: () => client.getAgents(runtimeContext)
14766
+ });
14767
+ };
14768
+ const useModelProviders = () => {
14769
+ const client = useMastraClient();
14770
+ return useQuery({
14771
+ queryKey: ["model-providers"],
14772
+ queryFn: () => client.getModelProviders()
14773
+ });
14774
+ };
14775
+ const useUpdateAgentModel = (agentId) => {
14776
+ const client = useMastraClient();
14777
+ const queryClient = useQueryClient();
14778
+ return useMutation({
14779
+ mutationFn: async (payload) => client.getAgent(agentId).updateModel(payload),
14780
+ onSuccess: () => {
14781
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14782
+ },
14783
+ onError: (err) => {
14784
+ console.error("Error updating model", err);
14785
+ }
14786
+ });
14787
+ };
14788
+ const useReorderModelList = (agentId) => {
14789
+ const client = useMastraClient();
14790
+ const queryClient = useQueryClient();
14791
+ return useMutation({
14792
+ mutationFn: async (payload) => client.getAgent(agentId).reorderModelList(payload),
14793
+ onSuccess: () => {
14794
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14795
+ },
14796
+ onError: (err) => {
14797
+ console.error("Error reordering model list", err);
14798
+ }
14799
+ });
14800
+ };
14801
+ const useUpdateModelInModelList = (agentId) => {
14802
+ const client = useMastraClient();
14803
+ const queryClient = useQueryClient();
14804
+ return useMutation({
14805
+ mutationFn: async (payload) => client.getAgent(agentId).updateModelInModelList(payload),
14806
+ onSuccess: () => {
14807
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14808
+ },
14809
+ onError: (err) => {
14810
+ console.error("Error updating model in model list", err);
14811
+ }
14812
+ });
14813
+ };
14814
+
14815
+ const useAgent = (agentId) => {
14816
+ const client = useMastraClient();
14817
+ const { runtimeContext } = usePlaygroundStore();
14818
+ return useQuery({
14819
+ queryKey: ["agent", agentId, JSON.stringify(runtimeContext)],
14820
+ queryFn: () => agentId ? client.getAgent(agentId).details(runtimeContext) : null,
14821
+ retry: false,
14822
+ enabled: Boolean(agentId)
14823
+ });
14824
+ };
14825
+
14826
+ const useExecuteAgentTool = () => {
14827
+ const client = useMastraClient();
14828
+ return useMutation({
14829
+ mutationFn: async ({ agentId, toolId, input, playgroundRuntimeContext }) => {
14830
+ const runtimeContext = new RuntimeContext$2();
14831
+ Object.entries(playgroundRuntimeContext ?? {}).forEach(([key, value]) => {
14832
+ runtimeContext.set(key, value);
14833
+ });
14834
+ try {
14835
+ const agent = client.getAgent(agentId);
14836
+ const response = await agent.executeTool(toolId, { data: input, runtimeContext });
14837
+ return response;
14838
+ } catch (error) {
14839
+ toast.error("Error executing agent tool");
14840
+ console.error("Error executing tool:", error);
14841
+ throw error;
14842
+ }
14843
+ }
14844
+ });
14845
+ };
14846
+
14272
14847
  const NameCell$1 = ({ row }) => {
14273
14848
  const { Link, paths } = useLinkComponent();
14274
14849
  const tool = row.original;
@@ -14391,6 +14966,31 @@ const EmptyToolsTable = () => /* @__PURE__ */ jsx("div", { className: "flex h-fu
14391
14966
  }
14392
14967
  ) });
14393
14968
 
14969
+ const useExecuteTool = () => {
14970
+ const client = useMastraClient();
14971
+ return useMutation({
14972
+ mutationFn: async ({
14973
+ toolId,
14974
+ input,
14975
+ runtimeContext: playgroundRuntimeContext
14976
+ }) => {
14977
+ const runtimeContext = new RuntimeContext$2();
14978
+ Object.entries(playgroundRuntimeContext ?? {}).forEach(([key, value]) => {
14979
+ runtimeContext.set(key, value);
14980
+ });
14981
+ try {
14982
+ const tool = client.getTool(toolId);
14983
+ const response = await tool.execute({ data: input, runtimeContext });
14984
+ return response;
14985
+ } catch (error) {
14986
+ toast.error("Error executing dev tool");
14987
+ console.error("Error executing dev tool:", error);
14988
+ throw error;
14989
+ }
14990
+ }
14991
+ });
14992
+ };
14993
+
14394
14994
  function TemplatesTools({
14395
14995
  tagOptions,
14396
14996
  selectedTag,
@@ -16117,7 +16717,7 @@ function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
16117
16717
  console.warn("Only one of traceUsage or spanUsage should be provided");
16118
16718
  return null;
16119
16719
  }
16120
- const generationSpans = traceSpans.filter((span) => span.spanType === "llm_generation");
16720
+ const generationSpans = traceSpans.filter((span) => span.spanType === "model_generation");
16121
16721
  const hasV5Format = generationSpans.some(
16122
16722
  (span) => span.attributes?.usage?.inputTokens !== void 0 || span.attributes?.usage?.outputTokens !== void 0
16123
16723
  );
@@ -17392,6 +17992,106 @@ const PlaygroundQueryClient = ({ children }) => {
17392
17992
  return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children });
17393
17993
  };
17394
17994
 
17995
+ const useMemory = (agentId) => {
17996
+ const client = useMastraClient();
17997
+ return useQuery({
17998
+ queryKey: ["memory", agentId],
17999
+ queryFn: () => agentId ? client.getMemoryStatus(agentId) : null,
18000
+ enabled: Boolean(agentId),
18001
+ staleTime: 5 * 60 * 1e3,
18002
+ // 5 minutes
18003
+ gcTime: 10 * 60 * 1e3,
18004
+ // 10 minutes
18005
+ retry: false
18006
+ });
18007
+ };
18008
+ const useMemoryConfig = (agentId) => {
18009
+ const client = useMastraClient();
18010
+ return useQuery({
18011
+ queryKey: ["memory", "config", agentId],
18012
+ queryFn: () => agentId ? client.getMemoryConfig({ agentId }) : null,
18013
+ enabled: Boolean(agentId),
18014
+ staleTime: 5 * 60 * 1e3,
18015
+ // 5 minutes
18016
+ gcTime: 10 * 60 * 1e3,
18017
+ // 10 minutes
18018
+ retry: false,
18019
+ refetchOnWindowFocus: false
18020
+ });
18021
+ };
18022
+ const useThreads = ({
18023
+ resourceId,
18024
+ agentId,
18025
+ isMemoryEnabled
18026
+ }) => {
18027
+ const client = useMastraClient();
18028
+ return useQuery({
18029
+ queryKey: ["memory", "threads", resourceId, agentId],
18030
+ queryFn: () => isMemoryEnabled ? client.getMemoryThreads({ resourceId, agentId }) : null,
18031
+ enabled: Boolean(isMemoryEnabled),
18032
+ staleTime: 0,
18033
+ gcTime: 0,
18034
+ retry: false,
18035
+ refetchOnWindowFocus: false
18036
+ });
18037
+ };
18038
+ const useDeleteThread = () => {
18039
+ const client = useMastraClient();
18040
+ const queryClient = useQueryClient();
18041
+ return useMutation({
18042
+ mutationFn: ({ threadId, agentId, networkId }) => client.deleteThread(threadId, { agentId, networkId }),
18043
+ onSuccess: (_, variables) => {
18044
+ const { agentId, networkId } = variables;
18045
+ if (agentId) {
18046
+ queryClient.invalidateQueries({ queryKey: ["memory", "threads", agentId, agentId] });
18047
+ }
18048
+ if (networkId) {
18049
+ queryClient.invalidateQueries({ queryKey: ["network", "threads", networkId, networkId] });
18050
+ }
18051
+ toast.success("Chat deleted successfully");
18052
+ },
18053
+ onError: () => {
18054
+ toast.error("Failed to delete chat");
18055
+ }
18056
+ });
18057
+ };
18058
+ const useMemorySearch = ({
18059
+ agentId,
18060
+ resourceId,
18061
+ threadId
18062
+ }) => {
18063
+ const searchMemory = async (searchQuery, memoryConfig) => {
18064
+ if (!searchQuery.trim()) {
18065
+ return { results: [], count: 0, query: searchQuery };
18066
+ }
18067
+ const params = new URLSearchParams({
18068
+ searchQuery,
18069
+ resourceId,
18070
+ agentId
18071
+ });
18072
+ if (threadId) {
18073
+ params.append("threadId", threadId);
18074
+ }
18075
+ if (memoryConfig) {
18076
+ params.append("memoryConfig", JSON.stringify(memoryConfig));
18077
+ }
18078
+ const response = await fetch(`/api/memory/search?${params}`, {
18079
+ method: "GET",
18080
+ headers: {
18081
+ "Content-Type": "application/json",
18082
+ "x-mastra-dev-playground": "true"
18083
+ }
18084
+ });
18085
+ if (!response.ok) {
18086
+ const errorData = await response.json().catch(() => ({ message: "Unknown error" }));
18087
+ console.error("Search memory error:", errorData);
18088
+ throw new Error(errorData.message || errorData.error || "Failed to search memory");
18089
+ }
18090
+ return response.json();
18091
+ };
18092
+ return { searchMemory };
18093
+ };
18094
+
17395
18095
  const formatRelativeTime = (date) => {
17396
18096
  const now = /* @__PURE__ */ new Date();
17397
18097
  const seconds = Math.floor((now.getTime() - date.getTime()) / 1e3);
@@ -17843,5 +18543,16 @@ const EmptyMCPTable = () => /* @__PURE__ */ jsx("div", { className: "flex h-full
17843
18543
  }
17844
18544
  ) });
17845
18545
 
17846
- export { AgentChat, AgentCoinIcon, AgentEntityHeader, AgentEvals, AgentIcon, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataNetworkList, AgentMetadataPrompt, AgentMetadataScorerList, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentsTable, AiIcon, Alert$1 as Alert, AlertDescription$1 as AlertDescription, AlertDialog, AlertTitle$1 as AlertTitle, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button$1 as Button, ButtonsGroup, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, CommitIcon, CrossIcon, Crumb, DarkLogo, DateTimeCell, DateTimePicker, DateTimePickerContent, DbIcon, DebugIcon, DefaultTrigger, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityHeader, EntityIcon, EntityMainHeader, EntityName, Entry, EntryCell, EntryList, EntryListSkeleton, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, FormActions, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, InputField, JudgeIcon, Kbd, KeyValueList, LatencyIcon, LinkComponentProvider, LogsIcon, MCPTable, MainContentContent, MainContentLayout, MainSidebar, MainSidebarProvider, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, MemorySearch, ModelResetProvider, Notification, OpenAIIcon, PageHeader, PlaygroundQueryClient, PlaygroundTabs, PromptIcon, RadioGroup, RadioGroupField, RadioGroupItem, RepoIcon, Row, RuntimeContext, RuntimeContextWrapper, ScoreDialog, ScoreIcon, ScorersTable, ScoresList, ScoresTools, SearchField, Searchbar, SearchbarWrapper, Section, Sections, SelectField, SettingsIcon, SideDialog, SlashIcon, SliderField, SpanScoreList, SpanScoring, SpanTabs, Tab$1 as Tab, TabContent$1 as TabContent, TabList$1 as TabList, Table$1 as Table, Tbody, TemplateFailure, TemplateForm, TemplateInfo, TemplateInstallation, TemplateSuccess, TemplatesList, TemplatesTools, TextAndIcon, TextareaField, Th, Thead, ThreadDeleteButton, ThreadInputProvider, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolFallback, ToolTable, ToolsIcon, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TraceDialog, TraceIcon, TraceTimeline, TraceTimelineLegend, TraceTimelineSpan, TracesList, TracesTools, TracesView, TracesViewSkeleton, TsIcon, Txt, TxtCell, UnitCell, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunDetail, WorkflowRunList, WorkflowRunProvider, WorkflowTable, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, allowedAiSpanAttributes, cleanString, convertWorkflowRunStateToStreamResult, extractPrompt, formatDuration, formatHierarchicalSpans, formatOtelTimestamp, formatOtelTimestamp2, getColumnTemplate, getShortId, getSpanTypeUi, getToNextEntryFn, getToPreviousEntryFn, parseError, providerMapToIcon, scoresListColumns, spanTypePrefixes, traceScoresListColumns, tracesListColumns, transformKey, useAgentSettings, useCurrentRun, useInView, useLinkComponent, useMCPServerTools, useMainSidebar, useModelReset, usePlaygroundStore, usePolling, useScorer, useScorers, useScoresByEntityId, useScoresByScorerId, useSpeechRecognition, useThreadInput, useTraceSpanScores, useWorkflow, useWorkflowRuns, useWorkingMemory };
18546
+ const useEvalsByAgentId = (agentId, type) => {
18547
+ const { runtimeContext } = usePlaygroundStore();
18548
+ const client = useMastraClient();
18549
+ return useQuery({
18550
+ staleTime: 0,
18551
+ gcTime: 0,
18552
+ queryKey: ["evals", agentId, type, JSON.stringify(runtimeContext)],
18553
+ queryFn: () => type === "live" ? client.getAgent(agentId).liveEvals(runtimeContext) : client.getAgent(agentId).evals(runtimeContext)
18554
+ });
18555
+ };
18556
+
18557
+ export { AgentChat, AgentCoinIcon, AgentEntityHeader, AgentEvals, AgentIcon, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataNetworkList, AgentMetadataPrompt, AgentMetadataScorerList, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentsTable, AiIcon, Alert$1 as Alert, AlertDescription$1 as AlertDescription, AlertDialog, AlertTitle$1 as AlertTitle, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button$1 as Button, ButtonsGroup, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, CommitIcon, CrossIcon, Crumb, DarkLogo, DateTimeCell, DateTimePicker, DateTimePickerContent, DbIcon, DebugIcon, DefaultTrigger, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityHeader, EntityIcon, EntityMainHeader, EntityName, Entry, EntryCell, EntryList, EntryListSkeleton, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, FormActions, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, InputField, JudgeIcon, Kbd, KeyValueList, LatencyIcon, LinkComponentProvider, LogsIcon, MCPTable, MainContentContent, MainContentLayout, MainSidebar, MainSidebarProvider, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, MemorySearch, ModelResetProvider, Notification, OpenAIIcon, PageHeader, PlaygroundQueryClient, PlaygroundTabs, PromptIcon, RadioGroup, RadioGroupField, RadioGroupItem, RepoIcon, Row, RuntimeContext, RuntimeContextWrapper, ScoreDialog, ScoreIcon, ScorersTable, ScoresList, ScoresTools, SearchField, Searchbar, SearchbarWrapper, Section, Sections, SelectField, SettingsIcon, SideDialog, SlashIcon, SliderField, SpanScoreList, SpanScoring, SpanTabs, Tab$1 as Tab, TabContent$1 as TabContent, TabList$1 as TabList, Table$1 as Table, Tbody, TemplateFailure, TemplateForm, TemplateInfo, TemplateInstallation, TemplateSuccess, TemplatesList, TemplatesTools, TextAndIcon, TextareaField, Th, Thead, ThreadDeleteButton, ThreadInputProvider, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolFallback, ToolTable, ToolsIcon, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TraceDialog, TraceIcon, TraceTimeline, TraceTimelineLegend, TraceTimelineSpan, TracesList, TracesTools, TracesView, TracesViewSkeleton, TsIcon, Txt, TxtCell, UnitCell, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunDetail, WorkflowRunList, WorkflowRunProvider, WorkflowTable, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, allowedAiSpanAttributes, cleanString, convertWorkflowRunStateToStreamResult, extractPrompt, formatDuration, formatHierarchicalSpans, formatOtelTimestamp, formatOtelTimestamp2, getColumnTemplate, getShortId, getSpanTypeUi, getToNextEntryFn, getToPreviousEntryFn, parseError, providerMapToIcon, scoresListColumns, spanTypePrefixes, traceScoresListColumns, tracesListColumns, transformKey, useAgent, useAgentSettings, useAgents, useCancelWorkflowRun, useCurrentRun, useDeleteThread, useEvalsByAgentId, useExecuteAgentTool, useExecuteTool, useExecuteWorkflow, useInView, useLinkComponent, useMCPServerTools, useMainSidebar, useMemory, useMemoryConfig, useMemorySearch, useModelProviders, useModelReset, usePlaygroundStore, usePolling, useReorderModelList, useScorer, useScorers, useScoresByEntityId, useScoresByScorerId, useSendWorkflowRunEvent, useSpeechRecognition, useStreamWorkflow, useThreadInput, useThreads, useTraceSpanScores, useUpdateAgentModel, useUpdateModelInModelList, useWorkflow, useWorkflowRuns, useWorkflows, useWorkingMemory };
17847
18558
  //# sourceMappingURL=index.es.js.map