@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.cjs.js CHANGED
@@ -52,6 +52,7 @@ const RadioGroupPrimitive = require('@radix-ui/react-radio-group');
52
52
  const react$3 = require('@mastra/react');
53
53
  const reactQuery = require('@tanstack/react-query');
54
54
  const reactTable = require('@tanstack/react-table');
55
+ const runtimeContext = require('@mastra/core/runtime-context');
55
56
  const Markdown = require('react-markdown');
56
57
  const shallow = require('zustand/shallow');
57
58
  const di = require('@mastra/core/di');
@@ -4431,6 +4432,9 @@ const BadgeWrapper = ({
4431
4432
  "data-testid": dataTestId
4432
4433
  }) => {
4433
4434
  const [isCollapsed, setIsCollapsed] = React.useState(initialCollapsed);
4435
+ React.useEffect(() => {
4436
+ setIsCollapsed(initialCollapsed);
4437
+ }, [initialCollapsed]);
4434
4438
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", "data-testid": dataTestId, children: [
4435
4439
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row gap-2 items-center justify-between", children: [
4436
4440
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -4547,17 +4551,114 @@ const NetworkChoiceMetadataDialogTrigger = ({
4547
4551
  ] });
4548
4552
  };
4549
4553
 
4550
- const ToolBadge = ({ toolName, args, result, metadata, toolOutput }) => {
4554
+ const sizeClasses = {
4555
+ md: "h-button-md gap-md",
4556
+ lg: "h-button-lg gap-lg"
4557
+ };
4558
+ const variantClasses$1 = {
4559
+ default: "bg-surface2 hover:bg-surface4 text-icon3 hover:text-icon6 disabled:opacity-50",
4560
+ light: "bg-surface3 hover:bg-surface5 text-icon6 disabled:opacity-50"
4561
+ };
4562
+ const Button$1 = ({ className, as, size = "md", variant = "default", ...props }) => {
4563
+ const Component = as || "button";
4564
+ return /* @__PURE__ */ jsxRuntime.jsx(
4565
+ Component,
4566
+ {
4567
+ className: clsx(
4568
+ "bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
4569
+ variantClasses$1[variant],
4570
+ sizeClasses[size],
4571
+ className,
4572
+ {
4573
+ "cursor-not-allowed": props.disabled
4574
+ }
4575
+ ),
4576
+ ...props
4577
+ }
4578
+ );
4579
+ };
4580
+
4581
+ const ToolCallContext = React.createContext(void 0);
4582
+ function ToolCallProvider({
4583
+ children,
4584
+ approveToolcall,
4585
+ declineToolcall,
4586
+ isRunning,
4587
+ toolCallApprovals
4588
+ }) {
4589
+ return /* @__PURE__ */ jsxRuntime.jsx(ToolCallContext.Provider, { value: { approveToolcall, declineToolcall, isRunning, toolCallApprovals }, children });
4590
+ }
4591
+ function useToolCall() {
4592
+ const context = React.useContext(ToolCallContext);
4593
+ if (!context) {
4594
+ throw new Error("useToolCall must be used within a ToolCallProvider");
4595
+ }
4596
+ return context;
4597
+ }
4598
+
4599
+ const ToolApprovalButtons = ({ toolCalled, toolCallId, toolApprovalMetadata }) => {
4600
+ const { approveToolcall, declineToolcall, isRunning, toolCallApprovals } = useToolCall();
4601
+ const handleApprove = () => {
4602
+ approveToolcall(toolCallId);
4603
+ };
4604
+ const handleDecline = () => {
4605
+ declineToolcall(toolCallId);
4606
+ };
4607
+ const toolCallApprovalStatus = toolCallApprovals?.[toolCallId]?.status;
4608
+ if (toolApprovalMetadata && !toolCalled) {
4609
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4610
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium pb-2", children: "Approval required" }),
4611
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 items-center", children: [
4612
+ /* @__PURE__ */ jsxRuntime.jsxs(
4613
+ Button$1,
4614
+ {
4615
+ onClick: handleApprove,
4616
+ disabled: isRunning || !!toolCallApprovalStatus,
4617
+ className: toolCallApprovalStatus === "approved" ? "!text-accent1" : "",
4618
+ children: [
4619
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, {}) }),
4620
+ "Approve"
4621
+ ]
4622
+ }
4623
+ ),
4624
+ /* @__PURE__ */ jsxRuntime.jsxs(
4625
+ Button$1,
4626
+ {
4627
+ onClick: handleDecline,
4628
+ disabled: isRunning || !!toolCallApprovalStatus,
4629
+ className: toolCallApprovalStatus === "declined" ? "!text-accent2" : "",
4630
+ children: [
4631
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}) }),
4632
+ "Decline"
4633
+ ]
4634
+ }
4635
+ )
4636
+ ] })
4637
+ ] });
4638
+ }
4639
+ return null;
4640
+ };
4641
+
4642
+ const ToolBadge = ({
4643
+ toolName,
4644
+ args,
4645
+ result,
4646
+ metadata,
4647
+ toolOutput,
4648
+ toolCallId,
4649
+ toolApprovalMetadata
4650
+ }) => {
4551
4651
  let argSlot = null;
4552
4652
  try {
4553
4653
  const { __mastraMetadata: _, ...formattedArgs } = typeof args === "object" ? args : JSON.parse(args);
4554
4654
  argSlot = /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$2, { data: formattedArgs, "data-testid": "tool-args" });
4555
4655
  } catch {
4556
- argSlot = /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap", children: args });
4656
+ argSlot = /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre bg-surface4 p-4 rounded-md overflow-x-auto", children: args });
4557
4657
  }
4558
- let resultSlot = typeof result === "string" ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap bg-surface4 p-4 rounded-md", children: result }) : /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$2, { data: result, "data-testid": "tool-result" });
4658
+ let resultSlot = typeof result === "string" ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre bg-surface4 p-4 rounded-md overflow-x-auto", children: result }) : /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$2, { data: result, "data-testid": "tool-result" });
4559
4659
  const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
4560
4660
  const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
4661
+ const toolCalled = result || toolOutput.length > 0;
4561
4662
  return /* @__PURE__ */ jsxRuntime.jsx(
4562
4663
  BadgeWrapper,
4563
4664
  {
@@ -4571,19 +4672,28 @@ const ToolBadge = ({ toolName, args, result, metadata, toolOutput }) => {
4571
4672
  input: agentNetworkInput
4572
4673
  }
4573
4674
  ),
4675
+ initialCollapsed: !!!toolApprovalMetadata,
4574
4676
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
4575
4677
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4576
4678
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium pb-2", children: "Tool arguments" }),
4577
4679
  argSlot
4578
4680
  ] }),
4579
- resultSlot !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4681
+ resultSlot !== void 0 && result && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4580
4682
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium pb-2", children: "Tool result" }),
4581
4683
  resultSlot
4582
4684
  ] }),
4583
4685
  toolOutput.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4584
4686
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium pb-2", children: "Tool output" }),
4585
4687
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-40 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$2, { data: toolOutput, "data-testid": "tool-output" }) })
4586
- ] })
4688
+ ] }),
4689
+ /* @__PURE__ */ jsxRuntime.jsx(
4690
+ ToolApprovalButtons,
4691
+ {
4692
+ toolCalled,
4693
+ toolCallId,
4694
+ toolApprovalMetadata
4695
+ }
4696
+ )
4587
4697
  ] })
4588
4698
  }
4589
4699
  );
@@ -5170,33 +5280,6 @@ const useCurrentRun = () => {
5170
5280
  return { steps, runId: context.runId };
5171
5281
  };
5172
5282
 
5173
- const sizeClasses = {
5174
- md: "h-button-md gap-md",
5175
- lg: "h-button-lg gap-lg"
5176
- };
5177
- const variantClasses$1 = {
5178
- default: "bg-surface2 hover:bg-surface4 text-icon3 hover:text-icon6",
5179
- light: "bg-surface3 hover:bg-surface5 text-icon6"
5180
- };
5181
- const Button$1 = ({ className, as, size = "md", variant = "default", ...props }) => {
5182
- const Component = as || "button";
5183
- return /* @__PURE__ */ jsxRuntime.jsx(
5184
- Component,
5185
- {
5186
- className: clsx(
5187
- "bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
5188
- variantClasses$1[variant],
5189
- sizeClasses[size],
5190
- className,
5191
- {
5192
- "cursor-not-allowed": props.disabled
5193
- }
5194
- ),
5195
- ...props
5196
- }
5197
- );
5198
- };
5199
-
5200
5283
  const useCodemirrorTheme$1 = () => {
5201
5284
  return React.useMemo(
5202
5285
  () => codemirrorThemeDracula.draculaInit({
@@ -7797,6 +7880,334 @@ const EmptyWorkflowsTable = () => /* @__PURE__ */ jsxRuntime.jsx("div", { classN
7797
7880
  }
7798
7881
  ) });
7799
7882
 
7883
+ const useWorkflows = () => {
7884
+ const client = react$3.useMastraClient();
7885
+ const { runtimeContext } = usePlaygroundStore();
7886
+ return reactQuery.useQuery({
7887
+ queryKey: ["workflows", JSON.stringify(runtimeContext)],
7888
+ queryFn: () => client.getWorkflows(runtimeContext)
7889
+ });
7890
+ };
7891
+
7892
+ const useExecuteWorkflow = () => {
7893
+ const client = react$3.useMastraClient();
7894
+ const createWorkflowRun = reactQuery.useMutation({
7895
+ mutationFn: async ({ workflowId, prevRunId }) => {
7896
+ try {
7897
+ const workflow = client.getWorkflow(workflowId);
7898
+ const { runId: newRunId } = await workflow.createRunAsync({ runId: prevRunId });
7899
+ return { runId: newRunId };
7900
+ } catch (error) {
7901
+ console.error("Error creating workflow run:", error);
7902
+ throw error;
7903
+ }
7904
+ }
7905
+ });
7906
+ const startWorkflowRun = reactQuery.useMutation({
7907
+ mutationFn: async ({
7908
+ workflowId,
7909
+ runId,
7910
+ input,
7911
+ runtimeContext: playgroundRuntimeContext
7912
+ }) => {
7913
+ try {
7914
+ const runtimeContext$1 = new runtimeContext.RuntimeContext();
7915
+ Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
7916
+ runtimeContext$1.set(key, value);
7917
+ });
7918
+ const workflow = client.getWorkflow(workflowId);
7919
+ await workflow.start({ runId, inputData: input || {}, runtimeContext: runtimeContext$1 });
7920
+ } catch (error) {
7921
+ console.error("Error starting workflow run:", error);
7922
+ throw error;
7923
+ }
7924
+ }
7925
+ });
7926
+ const startAsyncWorkflowRun = reactQuery.useMutation({
7927
+ mutationFn: async ({
7928
+ workflowId,
7929
+ runId,
7930
+ input,
7931
+ runtimeContext: playgroundRuntimeContext
7932
+ }) => {
7933
+ try {
7934
+ const runtimeContext$1 = new runtimeContext.RuntimeContext();
7935
+ Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
7936
+ runtimeContext$1.set(key, value);
7937
+ });
7938
+ const workflow = client.getWorkflow(workflowId);
7939
+ const result = await workflow.startAsync({ runId, inputData: input || {}, runtimeContext: runtimeContext$1 });
7940
+ return result;
7941
+ } catch (error) {
7942
+ console.error("Error starting workflow run:", error);
7943
+ throw error;
7944
+ }
7945
+ }
7946
+ });
7947
+ return {
7948
+ startWorkflowRun,
7949
+ createWorkflowRun,
7950
+ startAsyncWorkflowRun
7951
+ };
7952
+ };
7953
+ const useStreamWorkflow = () => {
7954
+ const client = react$3.useMastraClient();
7955
+ const [streamResult, setStreamResult] = React.useState({});
7956
+ const [isStreaming, setIsStreaming] = React.useState(false);
7957
+ const readerRef = React.useRef(null);
7958
+ const observerRef = React.useRef(null);
7959
+ const resumeStreamRef = React.useRef(null);
7960
+ const isMountedRef = React.useRef(true);
7961
+ React.useEffect(() => {
7962
+ isMountedRef.current = true;
7963
+ return () => {
7964
+ isMountedRef.current = false;
7965
+ if (readerRef.current) {
7966
+ try {
7967
+ readerRef.current.releaseLock();
7968
+ } catch (error) {
7969
+ }
7970
+ readerRef.current = null;
7971
+ }
7972
+ if (observerRef.current) {
7973
+ try {
7974
+ observerRef.current.releaseLock();
7975
+ } catch (error) {
7976
+ }
7977
+ observerRef.current = null;
7978
+ }
7979
+ if (resumeStreamRef.current) {
7980
+ try {
7981
+ resumeStreamRef.current.releaseLock();
7982
+ } catch (error) {
7983
+ }
7984
+ resumeStreamRef.current = null;
7985
+ }
7986
+ };
7987
+ }, []);
7988
+ const streamWorkflow = reactQuery.useMutation({
7989
+ mutationFn: async ({
7990
+ workflowId,
7991
+ runId,
7992
+ inputData,
7993
+ runtimeContext: playgroundRuntimeContext
7994
+ }) => {
7995
+ if (readerRef.current) {
7996
+ readerRef.current.releaseLock();
7997
+ }
7998
+ if (!isMountedRef.current) return;
7999
+ setIsStreaming(true);
8000
+ setStreamResult({ input: inputData });
8001
+ const runtimeContext$1 = new runtimeContext.RuntimeContext();
8002
+ Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
8003
+ runtimeContext$1.set(key, value);
8004
+ });
8005
+ const workflow = client.getWorkflow(workflowId);
8006
+ const stream = await workflow.streamVNext({ runId, inputData, runtimeContext: runtimeContext$1, closeOnSuspend: true });
8007
+ if (!stream) throw new Error("No stream returned");
8008
+ const reader = stream.getReader();
8009
+ readerRef.current = reader;
8010
+ try {
8011
+ while (true) {
8012
+ if (!isMountedRef.current) break;
8013
+ const { done, value } = await reader.read();
8014
+ if (done) break;
8015
+ if (isMountedRef.current) {
8016
+ setStreamResult((prev) => {
8017
+ const newResult = react$3.mapWorkflowStreamChunkToWatchResult(prev, value);
8018
+ return newResult;
8019
+ });
8020
+ if (value.type === "workflow-step-start") {
8021
+ setIsStreaming(true);
8022
+ }
8023
+ if (value.type === "workflow-step-suspended") {
8024
+ setIsStreaming(false);
8025
+ }
8026
+ }
8027
+ }
8028
+ } catch (error) {
8029
+ console.error("Error streaming workflow:", error);
8030
+ } finally {
8031
+ if (isMountedRef.current) {
8032
+ setIsStreaming(false);
8033
+ }
8034
+ if (readerRef.current) {
8035
+ readerRef.current.releaseLock();
8036
+ readerRef.current = null;
8037
+ }
8038
+ }
8039
+ }
8040
+ });
8041
+ const observeWorkflowStream = reactQuery.useMutation({
8042
+ mutationFn: async ({
8043
+ workflowId,
8044
+ runId,
8045
+ storeRunResult
8046
+ }) => {
8047
+ if (observerRef.current) {
8048
+ observerRef.current.releaseLock();
8049
+ }
8050
+ if (!isMountedRef.current) return;
8051
+ setIsStreaming(true);
8052
+ setStreamResult(storeRunResult || {});
8053
+ if (storeRunResult?.status === "suspended") {
8054
+ setIsStreaming(false);
8055
+ return;
8056
+ }
8057
+ const workflow = client.getWorkflow(workflowId);
8058
+ const stream = await workflow.observeStreamVNext({ runId });
8059
+ if (!stream) throw new Error("No stream returned");
8060
+ const reader = stream.getReader();
8061
+ observerRef.current = reader;
8062
+ try {
8063
+ while (true) {
8064
+ if (!isMountedRef.current) break;
8065
+ const { done, value } = await reader.read();
8066
+ if (done) break;
8067
+ if (isMountedRef.current) {
8068
+ setStreamResult((prev) => {
8069
+ const newResult = react$3.mapWorkflowStreamChunkToWatchResult(prev, value);
8070
+ return newResult;
8071
+ });
8072
+ if (value.type === "workflow-step-start") {
8073
+ setIsStreaming(true);
8074
+ }
8075
+ if (value.type === "workflow-step-suspended") {
8076
+ setIsStreaming(false);
8077
+ }
8078
+ }
8079
+ }
8080
+ } catch (error) {
8081
+ console.error("Error streaming workflow:", error);
8082
+ } finally {
8083
+ if (isMountedRef.current) {
8084
+ setIsStreaming(false);
8085
+ }
8086
+ if (observerRef.current) {
8087
+ observerRef.current.releaseLock();
8088
+ observerRef.current = null;
8089
+ }
8090
+ }
8091
+ }
8092
+ });
8093
+ const resumeWorkflowStream = reactQuery.useMutation({
8094
+ mutationFn: async ({
8095
+ workflowId,
8096
+ runId,
8097
+ step,
8098
+ resumeData,
8099
+ runtimeContext: playgroundRuntimeContext
8100
+ }) => {
8101
+ if (resumeStreamRef.current) {
8102
+ resumeStreamRef.current.releaseLock();
8103
+ }
8104
+ if (!isMountedRef.current) return;
8105
+ setIsStreaming(true);
8106
+ const workflow = client.getWorkflow(workflowId);
8107
+ const runtimeContext$1 = new runtimeContext.RuntimeContext();
8108
+ Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
8109
+ runtimeContext$1.set(key, value);
8110
+ });
8111
+ const stream = await workflow.resumeStreamVNext({ runId, step, resumeData, runtimeContext: runtimeContext$1 });
8112
+ if (!stream) throw new Error("No stream returned");
8113
+ const reader = stream.getReader();
8114
+ resumeStreamRef.current = reader;
8115
+ try {
8116
+ while (true) {
8117
+ if (!isMountedRef.current) break;
8118
+ const { done, value } = await reader.read();
8119
+ if (done) break;
8120
+ if (isMountedRef.current) {
8121
+ setStreamResult((prev) => {
8122
+ const newResult = react$3.mapWorkflowStreamChunkToWatchResult(prev, value);
8123
+ return newResult;
8124
+ });
8125
+ if (value.type === "workflow-step-start") {
8126
+ setIsStreaming(true);
8127
+ }
8128
+ if (value.type === "workflow-step-suspended") {
8129
+ setIsStreaming(false);
8130
+ }
8131
+ }
8132
+ }
8133
+ } catch (error) {
8134
+ console.error("Error resuming workflow stream:", error);
8135
+ } finally {
8136
+ if (isMountedRef.current) {
8137
+ setIsStreaming(false);
8138
+ }
8139
+ if (resumeStreamRef.current) {
8140
+ resumeStreamRef.current.releaseLock();
8141
+ resumeStreamRef.current = null;
8142
+ }
8143
+ }
8144
+ }
8145
+ });
8146
+ const closeStreamsAndReset = () => {
8147
+ setIsStreaming(false);
8148
+ setStreamResult({});
8149
+ if (readerRef.current) {
8150
+ try {
8151
+ readerRef.current.releaseLock();
8152
+ } catch (error) {
8153
+ }
8154
+ readerRef.current = null;
8155
+ }
8156
+ if (observerRef.current) {
8157
+ try {
8158
+ observerRef.current.releaseLock();
8159
+ } catch (error) {
8160
+ }
8161
+ observerRef.current = null;
8162
+ }
8163
+ if (resumeStreamRef.current) {
8164
+ try {
8165
+ resumeStreamRef.current.releaseLock();
8166
+ } catch (error) {
8167
+ }
8168
+ resumeStreamRef.current = null;
8169
+ }
8170
+ };
8171
+ return {
8172
+ streamWorkflow,
8173
+ streamResult,
8174
+ isStreaming,
8175
+ observeWorkflowStream,
8176
+ closeStreamsAndReset,
8177
+ resumeWorkflowStream
8178
+ };
8179
+ };
8180
+ const useCancelWorkflowRun = () => {
8181
+ const client = react$3.useMastraClient();
8182
+ const cancelWorkflowRun = reactQuery.useMutation({
8183
+ mutationFn: async ({ workflowId, runId }) => {
8184
+ try {
8185
+ const response = await client.getWorkflow(workflowId).cancelRun(runId);
8186
+ return response;
8187
+ } catch (error) {
8188
+ console.error("Error canceling workflow run:", error);
8189
+ throw error;
8190
+ }
8191
+ }
8192
+ });
8193
+ return cancelWorkflowRun;
8194
+ };
8195
+ const useSendWorkflowRunEvent = (workflowId) => {
8196
+ const client = react$3.useMastraClient();
8197
+ const sendWorkflowRunEvent = reactQuery.useMutation({
8198
+ mutationFn: async ({ runId, event, data }) => {
8199
+ try {
8200
+ const response = await client.getWorkflow(workflowId).sendRunEvent({ runId, event, data });
8201
+ return response;
8202
+ } catch (error) {
8203
+ console.error("Error sending workflow run event:", error);
8204
+ throw error;
8205
+ }
8206
+ }
8207
+ });
8208
+ return sendWorkflowRunEvent;
8209
+ };
8210
+
7800
8211
  const LoadingBadge = () => {
7801
8212
  return /* @__PURE__ */ jsxRuntime.jsx(
7802
8213
  BadgeWrapper,
@@ -7835,7 +8246,15 @@ const useWorkflow = (workflowId) => {
7835
8246
  });
7836
8247
  };
7837
8248
 
7838
- const WorkflowBadge = ({ runId, workflowId, isStreaming, metadata }) => {
8249
+ const WorkflowBadge = ({
8250
+ result,
8251
+ workflowId,
8252
+ isStreaming,
8253
+ metadata,
8254
+ toolCallId,
8255
+ toolApprovalMetadata
8256
+ }) => {
8257
+ const { runId, status } = result || {};
7839
8258
  const { data: workflow, isLoading: isWorkflowLoading } = useWorkflow(workflowId);
7840
8259
  const { data: runs, isLoading: isRunsLoading } = useWorkflowRuns(workflowId, {
7841
8260
  enabled: Boolean(runId) && !isStreaming
@@ -7862,7 +8281,8 @@ const WorkflowBadge = ({ runId, workflowId, isStreaming, metadata }) => {
7862
8281
  ),
7863
8282
  children: [
7864
8283
  !isStreaming && !isLoading && /* @__PURE__ */ jsxRuntime.jsx(WorkflowRunProvider, { snapshot, children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowBadgeExtended, { workflowId, workflow, runId }) }),
7865
- isStreaming && /* @__PURE__ */ jsxRuntime.jsx(WorkflowBadgeExtended, { workflowId, workflow, runId })
8284
+ isStreaming && /* @__PURE__ */ jsxRuntime.jsx(WorkflowBadgeExtended, { workflowId, workflow, runId }),
8285
+ /* @__PURE__ */ jsxRuntime.jsx(ToolApprovalButtons, { toolCalled: !!status, toolCallId, toolApprovalMetadata })
7866
8286
  ]
7867
8287
  }
7868
8288
  );
@@ -7885,10 +8305,10 @@ const useWorkflowStream = (workflowFullState) => {
7885
8305
  }, [workflowFullState]);
7886
8306
  };
7887
8307
 
7888
- const AgentBadge = ({ agentId, messages = [], metadata }) => {
8308
+ const AgentBadge = ({ agentId, messages = [], metadata, toolCallId, toolApprovalMetadata }) => {
7889
8309
  const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
7890
8310
  const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
7891
- return /* @__PURE__ */ jsxRuntime.jsx(
8311
+ return /* @__PURE__ */ jsxRuntime.jsxs(
7892
8312
  BadgeWrapper,
7893
8313
  {
7894
8314
  "data-testid": "agent-badge",
@@ -7902,29 +8322,39 @@ const AgentBadge = ({ agentId, messages = [], metadata }) => {
7902
8322
  input: agentNetworkInput
7903
8323
  }
7904
8324
  ),
7905
- children: messages.map((message, index) => {
7906
- if (message.type === "text") {
7907
- return /* @__PURE__ */ jsxRuntime.jsx(Markdown, { children: message.content }, index);
7908
- }
7909
- const result = typeof message.toolOutput === "string" ? JSON.parse(message.toolOutput) : message.toolOutput;
7910
- return /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
7911
- ToolFallback,
7912
- {
7913
- toolName: message.toolName,
7914
- argsText: typeof message.args === "string" ? message.args : JSON.stringify(message.args),
7915
- result,
7916
- args: message.args,
7917
- status: { type: "complete" },
7918
- type: "tool-call",
7919
- toolCallId: message.toolCallId,
7920
- addResult: () => {
7921
- },
7922
- metadata: {
7923
- mode: "stream"
8325
+ children: [
8326
+ messages.map((message, index) => {
8327
+ if (message.type === "text") {
8328
+ return /* @__PURE__ */ jsxRuntime.jsx(Markdown, { children: message.content }, index);
8329
+ }
8330
+ const result = typeof message.toolOutput === "string" ? JSON.parse(message.toolOutput) : message.toolOutput;
8331
+ return /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
8332
+ ToolFallback,
8333
+ {
8334
+ toolName: message.toolName,
8335
+ argsText: typeof message.args === "string" ? message.args : JSON.stringify(message.args),
8336
+ result,
8337
+ args: message.args,
8338
+ status: { type: "complete" },
8339
+ type: "tool-call",
8340
+ toolCallId: message.toolCallId,
8341
+ addResult: () => {
8342
+ },
8343
+ metadata: {
8344
+ mode: "stream"
8345
+ }
7924
8346
  }
8347
+ ) }, index);
8348
+ }),
8349
+ /* @__PURE__ */ jsxRuntime.jsx(
8350
+ ToolApprovalButtons,
8351
+ {
8352
+ toolCalled: messages?.length > 0,
8353
+ toolCallId,
8354
+ toolApprovalMetadata
7925
8355
  }
7926
- ) }, index);
7927
- })
8356
+ )
8357
+ ]
7928
8358
  }
7929
8359
  );
7930
8360
  };
@@ -7946,27 +8376,53 @@ const useAgentMessages = ({
7946
8376
  });
7947
8377
  };
7948
8378
 
7949
- const AgentBadgeWrapper = ({ agentId, result, metadata }) => {
8379
+ const AgentBadgeWrapper = ({
8380
+ agentId,
8381
+ result,
8382
+ metadata,
8383
+ toolCallId,
8384
+ toolApprovalMetadata
8385
+ }) => {
7950
8386
  const { data: memoryMessages } = useAgentMessages({
7951
8387
  threadId: result?.subAgentThreadId ?? "",
7952
8388
  agentId,
7953
8389
  memory: true
7954
8390
  });
7955
8391
  const childMessages = result?.childMessages ?? react$3.resolveToChildMessages(memoryMessages?.uiMessages ?? []);
7956
- return /* @__PURE__ */ jsxRuntime.jsx(AgentBadge, { agentId, messages: childMessages, metadata });
8392
+ return /* @__PURE__ */ jsxRuntime.jsx(
8393
+ AgentBadge,
8394
+ {
8395
+ agentId,
8396
+ messages: childMessages,
8397
+ metadata,
8398
+ toolCallId,
8399
+ toolApprovalMetadata
8400
+ }
8401
+ );
7957
8402
  };
7958
8403
 
7959
8404
  const ToolFallback = ({ toolName, result, args, ...props }) => {
7960
8405
  return /* @__PURE__ */ jsxRuntime.jsx(WorkflowRunProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackInner, { toolName, result, args, ...props }) });
7961
8406
  };
7962
- const ToolFallbackInner = ({ toolName, result, args, metadata, ...props }) => {
8407
+ const ToolFallbackInner = ({ toolName, result, args, metadata, toolCallId, ...props }) => {
7963
8408
  const isAgent = metadata?.mode === "network" && metadata.from === "AGENT" || toolName.startsWith("agent-");
7964
8409
  const isWorkflow = metadata?.mode === "network" && metadata.from === "WORKFLOW" || toolName.startsWith("workflow-");
7965
8410
  const agentToolName = toolName.startsWith("agent-") ? toolName.substring("agent-".length) : toolName;
7966
8411
  const workflowToolName = toolName.startsWith("workflow-") ? toolName.substring("workflow-".length) : toolName;
8412
+ const requireApprovalMetadata = metadata?.mode === "stream" && metadata?.requireApprovalMetadata;
8413
+ const toolApprovalMetadata = requireApprovalMetadata ? requireApprovalMetadata?.[toolCallId] : void 0;
7967
8414
  useWorkflowStream(result);
7968
8415
  if (isAgent) {
7969
- return /* @__PURE__ */ jsxRuntime.jsx(AgentBadgeWrapper, { agentId: agentToolName, result, metadata });
8416
+ return /* @__PURE__ */ jsxRuntime.jsx(
8417
+ AgentBadgeWrapper,
8418
+ {
8419
+ agentId: agentToolName,
8420
+ result,
8421
+ metadata,
8422
+ toolCallId,
8423
+ toolApprovalMetadata
8424
+ }
8425
+ );
7970
8426
  }
7971
8427
  if (isWorkflow) {
7972
8428
  const isStreaming = metadata?.mode === "stream" || metadata?.mode === "network";
@@ -7975,8 +8431,10 @@ const ToolFallbackInner = ({ toolName, result, args, metadata, ...props }) => {
7975
8431
  {
7976
8432
  workflowId: workflowToolName,
7977
8433
  isStreaming,
7978
- runId: result?.runId,
7979
- metadata
8434
+ result,
8435
+ metadata,
8436
+ toolCallId,
8437
+ toolApprovalMetadata
7980
8438
  }
7981
8439
  );
7982
8440
  }
@@ -7987,7 +8445,9 @@ const ToolFallbackInner = ({ toolName, result, args, metadata, ...props }) => {
7987
8445
  args,
7988
8446
  result,
7989
8447
  toolOutput: result?.toolOutput || [],
7990
- metadata
8448
+ metadata,
8449
+ toolCallId,
8450
+ toolApprovalMetadata
7991
8451
  }
7992
8452
  );
7993
8453
  };
@@ -9655,7 +10115,10 @@ function MastraRuntimeProvider({
9655
10115
  sendMessage,
9656
10116
  cancelRun,
9657
10117
  isRunning: isRunningStream,
9658
- setMessages
10118
+ setMessages,
10119
+ approveToolCall,
10120
+ declineToolCall,
10121
+ toolCallApprovals
9659
10122
  } = react$3.useChat({
9660
10123
  agentId,
9661
10124
  initializeMessages: () => initialMessages || []
@@ -9675,7 +10138,8 @@ function MastraRuntimeProvider({
9675
10138
  chatWithGenerateLegacy,
9676
10139
  chatWithGenerate,
9677
10140
  chatWithNetwork,
9678
- providerOptions
10141
+ providerOptions,
10142
+ requireToolApproval
9679
10143
  } = settings?.modelSettings ?? {};
9680
10144
  const toolCallIdToName = React.useRef({});
9681
10145
  const runtimeContextInstance = new di.RuntimeContext();
@@ -9692,7 +10156,8 @@ function MastraRuntimeProvider({
9692
10156
  maxTokens,
9693
10157
  instructions,
9694
10158
  providerOptions,
9695
- maxSteps
10159
+ maxSteps,
10160
+ requireToolApproval
9696
10161
  };
9697
10162
  const baseClient = react$3.useMastraClient();
9698
10163
  const isVNext = modelVersion === "v2";
@@ -10080,10 +10545,23 @@ function MastraRuntimeProvider({
10080
10545
  convertMessage: (x) => x,
10081
10546
  onNew,
10082
10547
  onCancel,
10083
- adapters: isReady ? adapters : void 0
10548
+ adapters: isReady ? adapters : void 0,
10549
+ extras: {
10550
+ approveToolCall,
10551
+ declineToolCall
10552
+ }
10084
10553
  });
10085
10554
  if (!isReady) return null;
10086
- return /* @__PURE__ */ jsxRuntime.jsx(react.AssistantRuntimeProvider, { runtime, children });
10555
+ return /* @__PURE__ */ jsxRuntime.jsx(react.AssistantRuntimeProvider, { runtime, children: /* @__PURE__ */ jsxRuntime.jsx(
10556
+ ToolCallProvider,
10557
+ {
10558
+ approveToolcall: approveToolCall,
10559
+ declineToolcall: declineToolCall,
10560
+ isRunning: isRunningStream,
10561
+ toolCallApprovals,
10562
+ children
10563
+ }
10564
+ ) });
10087
10565
  }
10088
10566
 
10089
10567
  const defaultSettings = {
@@ -10904,6 +11382,16 @@ const AgentSettings = ({ modelVersion, hasMemory = false, hasSubAgents = false }
10904
11382
  ]
10905
11383
  }
10906
11384
  ) }),
11385
+ /* @__PURE__ */ jsxRuntime.jsx(Entry, { label: "Require Tool Approval", children: /* @__PURE__ */ jsxRuntime.jsx(
11386
+ Checkbox,
11387
+ {
11388
+ checked: settings?.modelSettings?.requireToolApproval,
11389
+ onCheckedChange: (value) => setSettings({
11390
+ ...settings,
11391
+ modelSettings: { ...settings?.modelSettings, requireToolApproval: value }
11392
+ })
11393
+ }
11394
+ ) }),
10907
11395
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-8", children: [
10908
11396
  /* @__PURE__ */ jsxRuntime.jsx(Entry, { label: "Temperature", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row justify-between items-center gap-2", children: [
10909
11397
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -14304,6 +14792,93 @@ const formatDay = (date) => {
14304
14792
  return new Date(date).toLocaleString("en-us", options).replace(",", " at");
14305
14793
  };
14306
14794
 
14795
+ const useAgents = () => {
14796
+ const client = react$3.useMastraClient();
14797
+ const { runtimeContext } = usePlaygroundStore();
14798
+ return reactQuery.useQuery({
14799
+ queryKey: ["agents", JSON.stringify(runtimeContext)],
14800
+ queryFn: () => client.getAgents(runtimeContext)
14801
+ });
14802
+ };
14803
+ const useModelProviders = () => {
14804
+ const client = react$3.useMastraClient();
14805
+ return reactQuery.useQuery({
14806
+ queryKey: ["model-providers"],
14807
+ queryFn: () => client.getModelProviders()
14808
+ });
14809
+ };
14810
+ const useUpdateAgentModel = (agentId) => {
14811
+ const client = react$3.useMastraClient();
14812
+ const queryClient = reactQuery.useQueryClient();
14813
+ return reactQuery.useMutation({
14814
+ mutationFn: async (payload) => client.getAgent(agentId).updateModel(payload),
14815
+ onSuccess: () => {
14816
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14817
+ },
14818
+ onError: (err) => {
14819
+ console.error("Error updating model", err);
14820
+ }
14821
+ });
14822
+ };
14823
+ const useReorderModelList = (agentId) => {
14824
+ const client = react$3.useMastraClient();
14825
+ const queryClient = reactQuery.useQueryClient();
14826
+ return reactQuery.useMutation({
14827
+ mutationFn: async (payload) => client.getAgent(agentId).reorderModelList(payload),
14828
+ onSuccess: () => {
14829
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14830
+ },
14831
+ onError: (err) => {
14832
+ console.error("Error reordering model list", err);
14833
+ }
14834
+ });
14835
+ };
14836
+ const useUpdateModelInModelList = (agentId) => {
14837
+ const client = react$3.useMastraClient();
14838
+ const queryClient = reactQuery.useQueryClient();
14839
+ return reactQuery.useMutation({
14840
+ mutationFn: async (payload) => client.getAgent(agentId).updateModelInModelList(payload),
14841
+ onSuccess: () => {
14842
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
14843
+ },
14844
+ onError: (err) => {
14845
+ console.error("Error updating model in model list", err);
14846
+ }
14847
+ });
14848
+ };
14849
+
14850
+ const useAgent = (agentId) => {
14851
+ const client = react$3.useMastraClient();
14852
+ const { runtimeContext } = usePlaygroundStore();
14853
+ return reactQuery.useQuery({
14854
+ queryKey: ["agent", agentId, JSON.stringify(runtimeContext)],
14855
+ queryFn: () => agentId ? client.getAgent(agentId).details(runtimeContext) : null,
14856
+ retry: false,
14857
+ enabled: Boolean(agentId)
14858
+ });
14859
+ };
14860
+
14861
+ const useExecuteAgentTool = () => {
14862
+ const client = react$3.useMastraClient();
14863
+ return reactQuery.useMutation({
14864
+ mutationFn: async ({ agentId, toolId, input, playgroundRuntimeContext }) => {
14865
+ const runtimeContext = new di.RuntimeContext();
14866
+ Object.entries(playgroundRuntimeContext ?? {}).forEach(([key, value]) => {
14867
+ runtimeContext.set(key, value);
14868
+ });
14869
+ try {
14870
+ const agent = client.getAgent(agentId);
14871
+ const response = await agent.executeTool(toolId, { data: input, runtimeContext });
14872
+ return response;
14873
+ } catch (error) {
14874
+ sonner.toast.error("Error executing agent tool");
14875
+ console.error("Error executing tool:", error);
14876
+ throw error;
14877
+ }
14878
+ }
14879
+ });
14880
+ };
14881
+
14307
14882
  const NameCell$1 = ({ row }) => {
14308
14883
  const { Link, paths } = useLinkComponent();
14309
14884
  const tool = row.original;
@@ -14426,6 +15001,31 @@ const EmptyToolsTable = () => /* @__PURE__ */ jsxRuntime.jsx("div", { className:
14426
15001
  }
14427
15002
  ) });
14428
15003
 
15004
+ const useExecuteTool = () => {
15005
+ const client = react$3.useMastraClient();
15006
+ return reactQuery.useMutation({
15007
+ mutationFn: async ({
15008
+ toolId,
15009
+ input,
15010
+ runtimeContext: playgroundRuntimeContext
15011
+ }) => {
15012
+ const runtimeContext = new di.RuntimeContext();
15013
+ Object.entries(playgroundRuntimeContext ?? {}).forEach(([key, value]) => {
15014
+ runtimeContext.set(key, value);
15015
+ });
15016
+ try {
15017
+ const tool = client.getTool(toolId);
15018
+ const response = await tool.execute({ data: input, runtimeContext });
15019
+ return response;
15020
+ } catch (error) {
15021
+ sonner.toast.error("Error executing dev tool");
15022
+ console.error("Error executing dev tool:", error);
15023
+ throw error;
15024
+ }
15025
+ }
15026
+ });
15027
+ };
15028
+
14429
15029
  function TemplatesTools({
14430
15030
  tagOptions,
14431
15031
  selectedTag,
@@ -16152,7 +16752,7 @@ function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
16152
16752
  console.warn("Only one of traceUsage or spanUsage should be provided");
16153
16753
  return null;
16154
16754
  }
16155
- const generationSpans = traceSpans.filter((span) => span.spanType === "llm_generation");
16755
+ const generationSpans = traceSpans.filter((span) => span.spanType === "model_generation");
16156
16756
  const hasV5Format = generationSpans.some(
16157
16757
  (span) => span.attributes?.usage?.inputTokens !== void 0 || span.attributes?.usage?.outputTokens !== void 0
16158
16758
  );
@@ -17427,6 +18027,106 @@ const PlaygroundQueryClient = ({ children }) => {
17427
18027
  return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClient, children });
17428
18028
  };
17429
18029
 
18030
+ const useMemory = (agentId) => {
18031
+ const client = react$3.useMastraClient();
18032
+ return reactQuery.useQuery({
18033
+ queryKey: ["memory", agentId],
18034
+ queryFn: () => agentId ? client.getMemoryStatus(agentId) : null,
18035
+ enabled: Boolean(agentId),
18036
+ staleTime: 5 * 60 * 1e3,
18037
+ // 5 minutes
18038
+ gcTime: 10 * 60 * 1e3,
18039
+ // 10 minutes
18040
+ retry: false
18041
+ });
18042
+ };
18043
+ const useMemoryConfig = (agentId) => {
18044
+ const client = react$3.useMastraClient();
18045
+ return reactQuery.useQuery({
18046
+ queryKey: ["memory", "config", agentId],
18047
+ queryFn: () => agentId ? client.getMemoryConfig({ agentId }) : null,
18048
+ enabled: Boolean(agentId),
18049
+ staleTime: 5 * 60 * 1e3,
18050
+ // 5 minutes
18051
+ gcTime: 10 * 60 * 1e3,
18052
+ // 10 minutes
18053
+ retry: false,
18054
+ refetchOnWindowFocus: false
18055
+ });
18056
+ };
18057
+ const useThreads = ({
18058
+ resourceId,
18059
+ agentId,
18060
+ isMemoryEnabled
18061
+ }) => {
18062
+ const client = react$3.useMastraClient();
18063
+ return reactQuery.useQuery({
18064
+ queryKey: ["memory", "threads", resourceId, agentId],
18065
+ queryFn: () => isMemoryEnabled ? client.getMemoryThreads({ resourceId, agentId }) : null,
18066
+ enabled: Boolean(isMemoryEnabled),
18067
+ staleTime: 0,
18068
+ gcTime: 0,
18069
+ retry: false,
18070
+ refetchOnWindowFocus: false
18071
+ });
18072
+ };
18073
+ const useDeleteThread = () => {
18074
+ const client = react$3.useMastraClient();
18075
+ const queryClient = reactQuery.useQueryClient();
18076
+ return reactQuery.useMutation({
18077
+ mutationFn: ({ threadId, agentId, networkId }) => client.deleteThread(threadId, { agentId, networkId }),
18078
+ onSuccess: (_, variables) => {
18079
+ const { agentId, networkId } = variables;
18080
+ if (agentId) {
18081
+ queryClient.invalidateQueries({ queryKey: ["memory", "threads", agentId, agentId] });
18082
+ }
18083
+ if (networkId) {
18084
+ queryClient.invalidateQueries({ queryKey: ["network", "threads", networkId, networkId] });
18085
+ }
18086
+ sonner.toast.success("Chat deleted successfully");
18087
+ },
18088
+ onError: () => {
18089
+ sonner.toast.error("Failed to delete chat");
18090
+ }
18091
+ });
18092
+ };
18093
+ const useMemorySearch = ({
18094
+ agentId,
18095
+ resourceId,
18096
+ threadId
18097
+ }) => {
18098
+ const searchMemory = async (searchQuery, memoryConfig) => {
18099
+ if (!searchQuery.trim()) {
18100
+ return { results: [], count: 0, query: searchQuery };
18101
+ }
18102
+ const params = new URLSearchParams({
18103
+ searchQuery,
18104
+ resourceId,
18105
+ agentId
18106
+ });
18107
+ if (threadId) {
18108
+ params.append("threadId", threadId);
18109
+ }
18110
+ if (memoryConfig) {
18111
+ params.append("memoryConfig", JSON.stringify(memoryConfig));
18112
+ }
18113
+ const response = await fetch(`/api/memory/search?${params}`, {
18114
+ method: "GET",
18115
+ headers: {
18116
+ "Content-Type": "application/json",
18117
+ "x-mastra-dev-playground": "true"
18118
+ }
18119
+ });
18120
+ if (!response.ok) {
18121
+ const errorData = await response.json().catch(() => ({ message: "Unknown error" }));
18122
+ console.error("Search memory error:", errorData);
18123
+ throw new Error(errorData.message || errorData.error || "Failed to search memory");
18124
+ }
18125
+ return response.json();
18126
+ };
18127
+ return { searchMemory };
18128
+ };
18129
+
17430
18130
  const formatRelativeTime = (date) => {
17431
18131
  const now = /* @__PURE__ */ new Date();
17432
18132
  const seconds = Math.floor((now.getTime() - date.getTime()) / 1e3);
@@ -17878,6 +18578,17 @@ const EmptyMCPTable = () => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
17878
18578
  }
17879
18579
  ) });
17880
18580
 
18581
+ const useEvalsByAgentId = (agentId, type) => {
18582
+ const { runtimeContext } = usePlaygroundStore();
18583
+ const client = react$3.useMastraClient();
18584
+ return reactQuery.useQuery({
18585
+ staleTime: 0,
18586
+ gcTime: 0,
18587
+ queryKey: ["evals", agentId, type, JSON.stringify(runtimeContext)],
18588
+ queryFn: () => type === "live" ? client.getAgent(agentId).liveEvals(runtimeContext) : client.getAgent(agentId).evals(runtimeContext)
18589
+ });
18590
+ };
18591
+
17881
18592
  exports.AgentChat = AgentChat;
17882
18593
  exports.AgentCoinIcon = AgentCoinIcon;
17883
18594
  exports.AgentEntityHeader = AgentEntityHeader;
@@ -18082,24 +18793,43 @@ exports.spanTypePrefixes = spanTypePrefixes;
18082
18793
  exports.traceScoresListColumns = traceScoresListColumns;
18083
18794
  exports.tracesListColumns = tracesListColumns;
18084
18795
  exports.transformKey = transformKey;
18796
+ exports.useAgent = useAgent;
18085
18797
  exports.useAgentSettings = useAgentSettings;
18798
+ exports.useAgents = useAgents;
18799
+ exports.useCancelWorkflowRun = useCancelWorkflowRun;
18086
18800
  exports.useCurrentRun = useCurrentRun;
18801
+ exports.useDeleteThread = useDeleteThread;
18802
+ exports.useEvalsByAgentId = useEvalsByAgentId;
18803
+ exports.useExecuteAgentTool = useExecuteAgentTool;
18804
+ exports.useExecuteTool = useExecuteTool;
18805
+ exports.useExecuteWorkflow = useExecuteWorkflow;
18087
18806
  exports.useInView = useInView;
18088
18807
  exports.useLinkComponent = useLinkComponent;
18089
18808
  exports.useMCPServerTools = useMCPServerTools;
18090
18809
  exports.useMainSidebar = useMainSidebar;
18810
+ exports.useMemory = useMemory;
18811
+ exports.useMemoryConfig = useMemoryConfig;
18812
+ exports.useMemorySearch = useMemorySearch;
18813
+ exports.useModelProviders = useModelProviders;
18091
18814
  exports.useModelReset = useModelReset;
18092
18815
  exports.usePlaygroundStore = usePlaygroundStore;
18093
18816
  exports.usePolling = usePolling;
18817
+ exports.useReorderModelList = useReorderModelList;
18094
18818
  exports.useScorer = useScorer;
18095
18819
  exports.useScorers = useScorers;
18096
18820
  exports.useScoresByEntityId = useScoresByEntityId;
18097
18821
  exports.useScoresByScorerId = useScoresByScorerId;
18822
+ exports.useSendWorkflowRunEvent = useSendWorkflowRunEvent;
18098
18823
  exports.useSpeechRecognition = useSpeechRecognition;
18824
+ exports.useStreamWorkflow = useStreamWorkflow;
18099
18825
  exports.useThreadInput = useThreadInput;
18826
+ exports.useThreads = useThreads;
18100
18827
  exports.useTraceSpanScores = useTraceSpanScores;
18828
+ exports.useUpdateAgentModel = useUpdateAgentModel;
18829
+ exports.useUpdateModelInModelList = useUpdateModelInModelList;
18101
18830
  exports.useWorkflow = useWorkflow;
18102
18831
  exports.useWorkflowRuns = useWorkflowRuns;
18832
+ exports.useWorkflows = useWorkflows;
18103
18833
  exports.useWorkingMemory = useWorkingMemory;
18104
18834
  Object.keys(reactQuery).forEach(k => {
18105
18835
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {