@mastra/playground-ui 6.6.2-alpha.0 → 6.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/index.cjs.js +571 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +557 -5
- package/dist/index.es.js.map +1 -1
- package/dist/src/domains/agents/hooks/use-agents.d.ts +12 -0
- package/dist/src/domains/agents/hooks/use-execute-agent-tool.d.ts +7 -0
- package/dist/src/domains/agents/index.d.ts +3 -0
- package/dist/src/domains/evals/hooks/index.d.ts +1 -0
- package/dist/src/domains/evals/hooks/use-evals-by-agent-id.d.ts +14 -0
- package/dist/src/domains/evals/index.d.ts +1 -0
- package/dist/src/domains/memory/hooks/index.d.ts +1 -0
- package/dist/src/domains/memory/hooks/use-memory.d.ts +25 -0
- package/dist/src/domains/tools/hooks/index.d.ts +1 -0
- package/dist/src/domains/tools/hooks/use-execute-tool.d.ts +5 -0
- package/dist/src/domains/tools/index.d.ts +1 -0
- package/dist/src/domains/workflows/hooks/index.d.ts +2 -0
- package/dist/src/domains/workflows/hooks/use-workflows-actions.d.ts +67 -0
- package/dist/src/domains/workflows/hooks/use-workflows.d.ts +1 -0
- package/dist/src/domains/workflows/index.d.ts +1 -0
- package/dist/src/hooks/use-workflows.d.ts +0 -8
- package/dist/src/index.d.ts +2 -0
- package/dist/src/types/memory.d.ts +3 -0
- package/package.json +8 -7
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$
|
|
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';
|
|
@@ -7762,6 +7763,334 @@ const EmptyWorkflowsTable = () => /* @__PURE__ */ jsx("div", { className: "flex
|
|
|
7762
7763
|
}
|
|
7763
7764
|
) });
|
|
7764
7765
|
|
|
7766
|
+
const useWorkflows = () => {
|
|
7767
|
+
const client = useMastraClient();
|
|
7768
|
+
const { runtimeContext } = usePlaygroundStore();
|
|
7769
|
+
return useQuery({
|
|
7770
|
+
queryKey: ["workflows", JSON.stringify(runtimeContext)],
|
|
7771
|
+
queryFn: () => client.getWorkflows(runtimeContext)
|
|
7772
|
+
});
|
|
7773
|
+
};
|
|
7774
|
+
|
|
7775
|
+
const useExecuteWorkflow = () => {
|
|
7776
|
+
const client = useMastraClient();
|
|
7777
|
+
const createWorkflowRun = useMutation({
|
|
7778
|
+
mutationFn: async ({ workflowId, prevRunId }) => {
|
|
7779
|
+
try {
|
|
7780
|
+
const workflow = client.getWorkflow(workflowId);
|
|
7781
|
+
const { runId: newRunId } = await workflow.createRunAsync({ runId: prevRunId });
|
|
7782
|
+
return { runId: newRunId };
|
|
7783
|
+
} catch (error) {
|
|
7784
|
+
console.error("Error creating workflow run:", error);
|
|
7785
|
+
throw error;
|
|
7786
|
+
}
|
|
7787
|
+
}
|
|
7788
|
+
});
|
|
7789
|
+
const startWorkflowRun = useMutation({
|
|
7790
|
+
mutationFn: async ({
|
|
7791
|
+
workflowId,
|
|
7792
|
+
runId,
|
|
7793
|
+
input,
|
|
7794
|
+
runtimeContext: playgroundRuntimeContext
|
|
7795
|
+
}) => {
|
|
7796
|
+
try {
|
|
7797
|
+
const runtimeContext = new RuntimeContext$1();
|
|
7798
|
+
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
7799
|
+
runtimeContext.set(key, value);
|
|
7800
|
+
});
|
|
7801
|
+
const workflow = client.getWorkflow(workflowId);
|
|
7802
|
+
await workflow.start({ runId, inputData: input || {}, runtimeContext });
|
|
7803
|
+
} catch (error) {
|
|
7804
|
+
console.error("Error starting workflow run:", error);
|
|
7805
|
+
throw error;
|
|
7806
|
+
}
|
|
7807
|
+
}
|
|
7808
|
+
});
|
|
7809
|
+
const startAsyncWorkflowRun = useMutation({
|
|
7810
|
+
mutationFn: async ({
|
|
7811
|
+
workflowId,
|
|
7812
|
+
runId,
|
|
7813
|
+
input,
|
|
7814
|
+
runtimeContext: playgroundRuntimeContext
|
|
7815
|
+
}) => {
|
|
7816
|
+
try {
|
|
7817
|
+
const runtimeContext = new RuntimeContext$1();
|
|
7818
|
+
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
7819
|
+
runtimeContext.set(key, value);
|
|
7820
|
+
});
|
|
7821
|
+
const workflow = client.getWorkflow(workflowId);
|
|
7822
|
+
const result = await workflow.startAsync({ runId, inputData: input || {}, runtimeContext });
|
|
7823
|
+
return result;
|
|
7824
|
+
} catch (error) {
|
|
7825
|
+
console.error("Error starting workflow run:", error);
|
|
7826
|
+
throw error;
|
|
7827
|
+
}
|
|
7828
|
+
}
|
|
7829
|
+
});
|
|
7830
|
+
return {
|
|
7831
|
+
startWorkflowRun,
|
|
7832
|
+
createWorkflowRun,
|
|
7833
|
+
startAsyncWorkflowRun
|
|
7834
|
+
};
|
|
7835
|
+
};
|
|
7836
|
+
const useStreamWorkflow = () => {
|
|
7837
|
+
const client = useMastraClient();
|
|
7838
|
+
const [streamResult, setStreamResult] = useState({});
|
|
7839
|
+
const [isStreaming, setIsStreaming] = useState(false);
|
|
7840
|
+
const readerRef = useRef(null);
|
|
7841
|
+
const observerRef = useRef(null);
|
|
7842
|
+
const resumeStreamRef = useRef(null);
|
|
7843
|
+
const isMountedRef = useRef(true);
|
|
7844
|
+
useEffect(() => {
|
|
7845
|
+
isMountedRef.current = true;
|
|
7846
|
+
return () => {
|
|
7847
|
+
isMountedRef.current = false;
|
|
7848
|
+
if (readerRef.current) {
|
|
7849
|
+
try {
|
|
7850
|
+
readerRef.current.releaseLock();
|
|
7851
|
+
} catch (error) {
|
|
7852
|
+
}
|
|
7853
|
+
readerRef.current = null;
|
|
7854
|
+
}
|
|
7855
|
+
if (observerRef.current) {
|
|
7856
|
+
try {
|
|
7857
|
+
observerRef.current.releaseLock();
|
|
7858
|
+
} catch (error) {
|
|
7859
|
+
}
|
|
7860
|
+
observerRef.current = null;
|
|
7861
|
+
}
|
|
7862
|
+
if (resumeStreamRef.current) {
|
|
7863
|
+
try {
|
|
7864
|
+
resumeStreamRef.current.releaseLock();
|
|
7865
|
+
} catch (error) {
|
|
7866
|
+
}
|
|
7867
|
+
resumeStreamRef.current = null;
|
|
7868
|
+
}
|
|
7869
|
+
};
|
|
7870
|
+
}, []);
|
|
7871
|
+
const streamWorkflow = useMutation({
|
|
7872
|
+
mutationFn: async ({
|
|
7873
|
+
workflowId,
|
|
7874
|
+
runId,
|
|
7875
|
+
inputData,
|
|
7876
|
+
runtimeContext: playgroundRuntimeContext
|
|
7877
|
+
}) => {
|
|
7878
|
+
if (readerRef.current) {
|
|
7879
|
+
readerRef.current.releaseLock();
|
|
7880
|
+
}
|
|
7881
|
+
if (!isMountedRef.current) return;
|
|
7882
|
+
setIsStreaming(true);
|
|
7883
|
+
setStreamResult({ input: inputData });
|
|
7884
|
+
const runtimeContext = new RuntimeContext$1();
|
|
7885
|
+
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
7886
|
+
runtimeContext.set(key, value);
|
|
7887
|
+
});
|
|
7888
|
+
const workflow = client.getWorkflow(workflowId);
|
|
7889
|
+
const stream = await workflow.streamVNext({ runId, inputData, runtimeContext, closeOnSuspend: true });
|
|
7890
|
+
if (!stream) throw new Error("No stream returned");
|
|
7891
|
+
const reader = stream.getReader();
|
|
7892
|
+
readerRef.current = reader;
|
|
7893
|
+
try {
|
|
7894
|
+
while (true) {
|
|
7895
|
+
if (!isMountedRef.current) break;
|
|
7896
|
+
const { done, value } = await reader.read();
|
|
7897
|
+
if (done) break;
|
|
7898
|
+
if (isMountedRef.current) {
|
|
7899
|
+
setStreamResult((prev) => {
|
|
7900
|
+
const newResult = mapWorkflowStreamChunkToWatchResult(prev, value);
|
|
7901
|
+
return newResult;
|
|
7902
|
+
});
|
|
7903
|
+
if (value.type === "workflow-step-start") {
|
|
7904
|
+
setIsStreaming(true);
|
|
7905
|
+
}
|
|
7906
|
+
if (value.type === "workflow-step-suspended") {
|
|
7907
|
+
setIsStreaming(false);
|
|
7908
|
+
}
|
|
7909
|
+
}
|
|
7910
|
+
}
|
|
7911
|
+
} catch (error) {
|
|
7912
|
+
console.error("Error streaming workflow:", error);
|
|
7913
|
+
} finally {
|
|
7914
|
+
if (isMountedRef.current) {
|
|
7915
|
+
setIsStreaming(false);
|
|
7916
|
+
}
|
|
7917
|
+
if (readerRef.current) {
|
|
7918
|
+
readerRef.current.releaseLock();
|
|
7919
|
+
readerRef.current = null;
|
|
7920
|
+
}
|
|
7921
|
+
}
|
|
7922
|
+
}
|
|
7923
|
+
});
|
|
7924
|
+
const observeWorkflowStream = useMutation({
|
|
7925
|
+
mutationFn: async ({
|
|
7926
|
+
workflowId,
|
|
7927
|
+
runId,
|
|
7928
|
+
storeRunResult
|
|
7929
|
+
}) => {
|
|
7930
|
+
if (observerRef.current) {
|
|
7931
|
+
observerRef.current.releaseLock();
|
|
7932
|
+
}
|
|
7933
|
+
if (!isMountedRef.current) return;
|
|
7934
|
+
setIsStreaming(true);
|
|
7935
|
+
setStreamResult(storeRunResult || {});
|
|
7936
|
+
if (storeRunResult?.status === "suspended") {
|
|
7937
|
+
setIsStreaming(false);
|
|
7938
|
+
return;
|
|
7939
|
+
}
|
|
7940
|
+
const workflow = client.getWorkflow(workflowId);
|
|
7941
|
+
const stream = await workflow.observeStreamVNext({ runId });
|
|
7942
|
+
if (!stream) throw new Error("No stream returned");
|
|
7943
|
+
const reader = stream.getReader();
|
|
7944
|
+
observerRef.current = reader;
|
|
7945
|
+
try {
|
|
7946
|
+
while (true) {
|
|
7947
|
+
if (!isMountedRef.current) break;
|
|
7948
|
+
const { done, value } = await reader.read();
|
|
7949
|
+
if (done) break;
|
|
7950
|
+
if (isMountedRef.current) {
|
|
7951
|
+
setStreamResult((prev) => {
|
|
7952
|
+
const newResult = mapWorkflowStreamChunkToWatchResult(prev, value);
|
|
7953
|
+
return newResult;
|
|
7954
|
+
});
|
|
7955
|
+
if (value.type === "workflow-step-start") {
|
|
7956
|
+
setIsStreaming(true);
|
|
7957
|
+
}
|
|
7958
|
+
if (value.type === "workflow-step-suspended") {
|
|
7959
|
+
setIsStreaming(false);
|
|
7960
|
+
}
|
|
7961
|
+
}
|
|
7962
|
+
}
|
|
7963
|
+
} catch (error) {
|
|
7964
|
+
console.error("Error streaming workflow:", error);
|
|
7965
|
+
} finally {
|
|
7966
|
+
if (isMountedRef.current) {
|
|
7967
|
+
setIsStreaming(false);
|
|
7968
|
+
}
|
|
7969
|
+
if (observerRef.current) {
|
|
7970
|
+
observerRef.current.releaseLock();
|
|
7971
|
+
observerRef.current = null;
|
|
7972
|
+
}
|
|
7973
|
+
}
|
|
7974
|
+
}
|
|
7975
|
+
});
|
|
7976
|
+
const resumeWorkflowStream = useMutation({
|
|
7977
|
+
mutationFn: async ({
|
|
7978
|
+
workflowId,
|
|
7979
|
+
runId,
|
|
7980
|
+
step,
|
|
7981
|
+
resumeData,
|
|
7982
|
+
runtimeContext: playgroundRuntimeContext
|
|
7983
|
+
}) => {
|
|
7984
|
+
if (resumeStreamRef.current) {
|
|
7985
|
+
resumeStreamRef.current.releaseLock();
|
|
7986
|
+
}
|
|
7987
|
+
if (!isMountedRef.current) return;
|
|
7988
|
+
setIsStreaming(true);
|
|
7989
|
+
const workflow = client.getWorkflow(workflowId);
|
|
7990
|
+
const runtimeContext = new RuntimeContext$1();
|
|
7991
|
+
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
7992
|
+
runtimeContext.set(key, value);
|
|
7993
|
+
});
|
|
7994
|
+
const stream = await workflow.resumeStreamVNext({ runId, step, resumeData, runtimeContext });
|
|
7995
|
+
if (!stream) throw new Error("No stream returned");
|
|
7996
|
+
const reader = stream.getReader();
|
|
7997
|
+
resumeStreamRef.current = reader;
|
|
7998
|
+
try {
|
|
7999
|
+
while (true) {
|
|
8000
|
+
if (!isMountedRef.current) break;
|
|
8001
|
+
const { done, value } = await reader.read();
|
|
8002
|
+
if (done) break;
|
|
8003
|
+
if (isMountedRef.current) {
|
|
8004
|
+
setStreamResult((prev) => {
|
|
8005
|
+
const newResult = mapWorkflowStreamChunkToWatchResult(prev, value);
|
|
8006
|
+
return newResult;
|
|
8007
|
+
});
|
|
8008
|
+
if (value.type === "workflow-step-start") {
|
|
8009
|
+
setIsStreaming(true);
|
|
8010
|
+
}
|
|
8011
|
+
if (value.type === "workflow-step-suspended") {
|
|
8012
|
+
setIsStreaming(false);
|
|
8013
|
+
}
|
|
8014
|
+
}
|
|
8015
|
+
}
|
|
8016
|
+
} catch (error) {
|
|
8017
|
+
console.error("Error resuming workflow stream:", error);
|
|
8018
|
+
} finally {
|
|
8019
|
+
if (isMountedRef.current) {
|
|
8020
|
+
setIsStreaming(false);
|
|
8021
|
+
}
|
|
8022
|
+
if (resumeStreamRef.current) {
|
|
8023
|
+
resumeStreamRef.current.releaseLock();
|
|
8024
|
+
resumeStreamRef.current = null;
|
|
8025
|
+
}
|
|
8026
|
+
}
|
|
8027
|
+
}
|
|
8028
|
+
});
|
|
8029
|
+
const closeStreamsAndReset = () => {
|
|
8030
|
+
setIsStreaming(false);
|
|
8031
|
+
setStreamResult({});
|
|
8032
|
+
if (readerRef.current) {
|
|
8033
|
+
try {
|
|
8034
|
+
readerRef.current.releaseLock();
|
|
8035
|
+
} catch (error) {
|
|
8036
|
+
}
|
|
8037
|
+
readerRef.current = null;
|
|
8038
|
+
}
|
|
8039
|
+
if (observerRef.current) {
|
|
8040
|
+
try {
|
|
8041
|
+
observerRef.current.releaseLock();
|
|
8042
|
+
} catch (error) {
|
|
8043
|
+
}
|
|
8044
|
+
observerRef.current = null;
|
|
8045
|
+
}
|
|
8046
|
+
if (resumeStreamRef.current) {
|
|
8047
|
+
try {
|
|
8048
|
+
resumeStreamRef.current.releaseLock();
|
|
8049
|
+
} catch (error) {
|
|
8050
|
+
}
|
|
8051
|
+
resumeStreamRef.current = null;
|
|
8052
|
+
}
|
|
8053
|
+
};
|
|
8054
|
+
return {
|
|
8055
|
+
streamWorkflow,
|
|
8056
|
+
streamResult,
|
|
8057
|
+
isStreaming,
|
|
8058
|
+
observeWorkflowStream,
|
|
8059
|
+
closeStreamsAndReset,
|
|
8060
|
+
resumeWorkflowStream
|
|
8061
|
+
};
|
|
8062
|
+
};
|
|
8063
|
+
const useCancelWorkflowRun = () => {
|
|
8064
|
+
const client = useMastraClient();
|
|
8065
|
+
const cancelWorkflowRun = useMutation({
|
|
8066
|
+
mutationFn: async ({ workflowId, runId }) => {
|
|
8067
|
+
try {
|
|
8068
|
+
const response = await client.getWorkflow(workflowId).cancelRun(runId);
|
|
8069
|
+
return response;
|
|
8070
|
+
} catch (error) {
|
|
8071
|
+
console.error("Error canceling workflow run:", error);
|
|
8072
|
+
throw error;
|
|
8073
|
+
}
|
|
8074
|
+
}
|
|
8075
|
+
});
|
|
8076
|
+
return cancelWorkflowRun;
|
|
8077
|
+
};
|
|
8078
|
+
const useSendWorkflowRunEvent = (workflowId) => {
|
|
8079
|
+
const client = useMastraClient();
|
|
8080
|
+
const sendWorkflowRunEvent = useMutation({
|
|
8081
|
+
mutationFn: async ({ runId, event, data }) => {
|
|
8082
|
+
try {
|
|
8083
|
+
const response = await client.getWorkflow(workflowId).sendRunEvent({ runId, event, data });
|
|
8084
|
+
return response;
|
|
8085
|
+
} catch (error) {
|
|
8086
|
+
console.error("Error sending workflow run event:", error);
|
|
8087
|
+
throw error;
|
|
8088
|
+
}
|
|
8089
|
+
}
|
|
8090
|
+
});
|
|
8091
|
+
return sendWorkflowRunEvent;
|
|
8092
|
+
};
|
|
8093
|
+
|
|
7765
8094
|
const LoadingBadge = () => {
|
|
7766
8095
|
return /* @__PURE__ */ jsx(
|
|
7767
8096
|
BadgeWrapper,
|
|
@@ -9643,7 +9972,7 @@ function MastraRuntimeProvider({
|
|
|
9643
9972
|
providerOptions
|
|
9644
9973
|
} = settings?.modelSettings ?? {};
|
|
9645
9974
|
const toolCallIdToName = useRef({});
|
|
9646
|
-
const runtimeContextInstance = new RuntimeContext$
|
|
9975
|
+
const runtimeContextInstance = new RuntimeContext$2();
|
|
9647
9976
|
Object.entries(runtimeContext ?? {}).forEach(([key, value]) => {
|
|
9648
9977
|
runtimeContextInstance.set(key, value);
|
|
9649
9978
|
});
|
|
@@ -14269,6 +14598,93 @@ const formatDay = (date) => {
|
|
|
14269
14598
|
return new Date(date).toLocaleString("en-us", options).replace(",", " at");
|
|
14270
14599
|
};
|
|
14271
14600
|
|
|
14601
|
+
const useAgents = () => {
|
|
14602
|
+
const client = useMastraClient();
|
|
14603
|
+
const { runtimeContext } = usePlaygroundStore();
|
|
14604
|
+
return useQuery({
|
|
14605
|
+
queryKey: ["agents", JSON.stringify(runtimeContext)],
|
|
14606
|
+
queryFn: () => client.getAgents(runtimeContext)
|
|
14607
|
+
});
|
|
14608
|
+
};
|
|
14609
|
+
const useModelProviders = () => {
|
|
14610
|
+
const client = useMastraClient();
|
|
14611
|
+
return useQuery({
|
|
14612
|
+
queryKey: ["model-providers"],
|
|
14613
|
+
queryFn: () => client.getModelProviders()
|
|
14614
|
+
});
|
|
14615
|
+
};
|
|
14616
|
+
const useUpdateAgentModel = (agentId) => {
|
|
14617
|
+
const client = useMastraClient();
|
|
14618
|
+
const queryClient = useQueryClient();
|
|
14619
|
+
return useMutation({
|
|
14620
|
+
mutationFn: async (payload) => client.getAgent(agentId).updateModel(payload),
|
|
14621
|
+
onSuccess: () => {
|
|
14622
|
+
queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
|
|
14623
|
+
},
|
|
14624
|
+
onError: (err) => {
|
|
14625
|
+
console.error("Error updating model", err);
|
|
14626
|
+
}
|
|
14627
|
+
});
|
|
14628
|
+
};
|
|
14629
|
+
const useReorderModelList = (agentId) => {
|
|
14630
|
+
const client = useMastraClient();
|
|
14631
|
+
const queryClient = useQueryClient();
|
|
14632
|
+
return useMutation({
|
|
14633
|
+
mutationFn: async (payload) => client.getAgent(agentId).reorderModelList(payload),
|
|
14634
|
+
onSuccess: () => {
|
|
14635
|
+
queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
|
|
14636
|
+
},
|
|
14637
|
+
onError: (err) => {
|
|
14638
|
+
console.error("Error reordering model list", err);
|
|
14639
|
+
}
|
|
14640
|
+
});
|
|
14641
|
+
};
|
|
14642
|
+
const useUpdateModelInModelList = (agentId) => {
|
|
14643
|
+
const client = useMastraClient();
|
|
14644
|
+
const queryClient = useQueryClient();
|
|
14645
|
+
return useMutation({
|
|
14646
|
+
mutationFn: async (payload) => client.getAgent(agentId).updateModelInModelList(payload),
|
|
14647
|
+
onSuccess: () => {
|
|
14648
|
+
queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
|
|
14649
|
+
},
|
|
14650
|
+
onError: (err) => {
|
|
14651
|
+
console.error("Error updating model in model list", err);
|
|
14652
|
+
}
|
|
14653
|
+
});
|
|
14654
|
+
};
|
|
14655
|
+
|
|
14656
|
+
const useAgent = (agentId) => {
|
|
14657
|
+
const client = useMastraClient();
|
|
14658
|
+
const { runtimeContext } = usePlaygroundStore();
|
|
14659
|
+
return useQuery({
|
|
14660
|
+
queryKey: ["agent", agentId, JSON.stringify(runtimeContext)],
|
|
14661
|
+
queryFn: () => agentId ? client.getAgent(agentId).details(runtimeContext) : null,
|
|
14662
|
+
retry: false,
|
|
14663
|
+
enabled: Boolean(agentId)
|
|
14664
|
+
});
|
|
14665
|
+
};
|
|
14666
|
+
|
|
14667
|
+
const useExecuteAgentTool = () => {
|
|
14668
|
+
const client = useMastraClient();
|
|
14669
|
+
return useMutation({
|
|
14670
|
+
mutationFn: async ({ agentId, toolId, input, playgroundRuntimeContext }) => {
|
|
14671
|
+
const runtimeContext = new RuntimeContext$2();
|
|
14672
|
+
Object.entries(playgroundRuntimeContext ?? {}).forEach(([key, value]) => {
|
|
14673
|
+
runtimeContext.set(key, value);
|
|
14674
|
+
});
|
|
14675
|
+
try {
|
|
14676
|
+
const agent = client.getAgent(agentId);
|
|
14677
|
+
const response = await agent.executeTool(toolId, { data: input, runtimeContext });
|
|
14678
|
+
return response;
|
|
14679
|
+
} catch (error) {
|
|
14680
|
+
toast.error("Error executing agent tool");
|
|
14681
|
+
console.error("Error executing tool:", error);
|
|
14682
|
+
throw error;
|
|
14683
|
+
}
|
|
14684
|
+
}
|
|
14685
|
+
});
|
|
14686
|
+
};
|
|
14687
|
+
|
|
14272
14688
|
const NameCell$1 = ({ row }) => {
|
|
14273
14689
|
const { Link, paths } = useLinkComponent();
|
|
14274
14690
|
const tool = row.original;
|
|
@@ -14391,6 +14807,31 @@ const EmptyToolsTable = () => /* @__PURE__ */ jsx("div", { className: "flex h-fu
|
|
|
14391
14807
|
}
|
|
14392
14808
|
) });
|
|
14393
14809
|
|
|
14810
|
+
const useExecuteTool = () => {
|
|
14811
|
+
const client = useMastraClient();
|
|
14812
|
+
return useMutation({
|
|
14813
|
+
mutationFn: async ({
|
|
14814
|
+
toolId,
|
|
14815
|
+
input,
|
|
14816
|
+
runtimeContext: playgroundRuntimeContext
|
|
14817
|
+
}) => {
|
|
14818
|
+
const runtimeContext = new RuntimeContext$2();
|
|
14819
|
+
Object.entries(playgroundRuntimeContext ?? {}).forEach(([key, value]) => {
|
|
14820
|
+
runtimeContext.set(key, value);
|
|
14821
|
+
});
|
|
14822
|
+
try {
|
|
14823
|
+
const tool = client.getTool(toolId);
|
|
14824
|
+
const response = await tool.execute({ data: input, runtimeContext });
|
|
14825
|
+
return response;
|
|
14826
|
+
} catch (error) {
|
|
14827
|
+
toast.error("Error executing dev tool");
|
|
14828
|
+
console.error("Error executing dev tool:", error);
|
|
14829
|
+
throw error;
|
|
14830
|
+
}
|
|
14831
|
+
}
|
|
14832
|
+
});
|
|
14833
|
+
};
|
|
14834
|
+
|
|
14394
14835
|
function TemplatesTools({
|
|
14395
14836
|
tagOptions,
|
|
14396
14837
|
selectedTag,
|
|
@@ -17392,6 +17833,106 @@ const PlaygroundQueryClient = ({ children }) => {
|
|
|
17392
17833
|
return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children });
|
|
17393
17834
|
};
|
|
17394
17835
|
|
|
17836
|
+
const useMemory = (agentId) => {
|
|
17837
|
+
const client = useMastraClient();
|
|
17838
|
+
return useQuery({
|
|
17839
|
+
queryKey: ["memory", agentId],
|
|
17840
|
+
queryFn: () => agentId ? client.getMemoryStatus(agentId) : null,
|
|
17841
|
+
enabled: Boolean(agentId),
|
|
17842
|
+
staleTime: 5 * 60 * 1e3,
|
|
17843
|
+
// 5 minutes
|
|
17844
|
+
gcTime: 10 * 60 * 1e3,
|
|
17845
|
+
// 10 minutes
|
|
17846
|
+
retry: false
|
|
17847
|
+
});
|
|
17848
|
+
};
|
|
17849
|
+
const useMemoryConfig = (agentId) => {
|
|
17850
|
+
const client = useMastraClient();
|
|
17851
|
+
return useQuery({
|
|
17852
|
+
queryKey: ["memory", "config", agentId],
|
|
17853
|
+
queryFn: () => agentId ? client.getMemoryConfig({ agentId }) : null,
|
|
17854
|
+
enabled: Boolean(agentId),
|
|
17855
|
+
staleTime: 5 * 60 * 1e3,
|
|
17856
|
+
// 5 minutes
|
|
17857
|
+
gcTime: 10 * 60 * 1e3,
|
|
17858
|
+
// 10 minutes
|
|
17859
|
+
retry: false,
|
|
17860
|
+
refetchOnWindowFocus: false
|
|
17861
|
+
});
|
|
17862
|
+
};
|
|
17863
|
+
const useThreads = ({
|
|
17864
|
+
resourceId,
|
|
17865
|
+
agentId,
|
|
17866
|
+
isMemoryEnabled
|
|
17867
|
+
}) => {
|
|
17868
|
+
const client = useMastraClient();
|
|
17869
|
+
return useQuery({
|
|
17870
|
+
queryKey: ["memory", "threads", resourceId, agentId],
|
|
17871
|
+
queryFn: () => isMemoryEnabled ? client.getMemoryThreads({ resourceId, agentId }) : null,
|
|
17872
|
+
enabled: Boolean(isMemoryEnabled),
|
|
17873
|
+
staleTime: 0,
|
|
17874
|
+
gcTime: 0,
|
|
17875
|
+
retry: false,
|
|
17876
|
+
refetchOnWindowFocus: false
|
|
17877
|
+
});
|
|
17878
|
+
};
|
|
17879
|
+
const useDeleteThread = () => {
|
|
17880
|
+
const client = useMastraClient();
|
|
17881
|
+
const queryClient = useQueryClient();
|
|
17882
|
+
return useMutation({
|
|
17883
|
+
mutationFn: ({ threadId, agentId, networkId }) => client.deleteThread(threadId, { agentId, networkId }),
|
|
17884
|
+
onSuccess: (_, variables) => {
|
|
17885
|
+
const { agentId, networkId } = variables;
|
|
17886
|
+
if (agentId) {
|
|
17887
|
+
queryClient.invalidateQueries({ queryKey: ["memory", "threads", agentId, agentId] });
|
|
17888
|
+
}
|
|
17889
|
+
if (networkId) {
|
|
17890
|
+
queryClient.invalidateQueries({ queryKey: ["network", "threads", networkId, networkId] });
|
|
17891
|
+
}
|
|
17892
|
+
toast.success("Chat deleted successfully");
|
|
17893
|
+
},
|
|
17894
|
+
onError: () => {
|
|
17895
|
+
toast.error("Failed to delete chat");
|
|
17896
|
+
}
|
|
17897
|
+
});
|
|
17898
|
+
};
|
|
17899
|
+
const useMemorySearch = ({
|
|
17900
|
+
agentId,
|
|
17901
|
+
resourceId,
|
|
17902
|
+
threadId
|
|
17903
|
+
}) => {
|
|
17904
|
+
const searchMemory = async (searchQuery, memoryConfig) => {
|
|
17905
|
+
if (!searchQuery.trim()) {
|
|
17906
|
+
return { results: [], count: 0, query: searchQuery };
|
|
17907
|
+
}
|
|
17908
|
+
const params = new URLSearchParams({
|
|
17909
|
+
searchQuery,
|
|
17910
|
+
resourceId,
|
|
17911
|
+
agentId
|
|
17912
|
+
});
|
|
17913
|
+
if (threadId) {
|
|
17914
|
+
params.append("threadId", threadId);
|
|
17915
|
+
}
|
|
17916
|
+
if (memoryConfig) {
|
|
17917
|
+
params.append("memoryConfig", JSON.stringify(memoryConfig));
|
|
17918
|
+
}
|
|
17919
|
+
const response = await fetch(`/api/memory/search?${params}`, {
|
|
17920
|
+
method: "GET",
|
|
17921
|
+
headers: {
|
|
17922
|
+
"Content-Type": "application/json",
|
|
17923
|
+
"x-mastra-dev-playground": "true"
|
|
17924
|
+
}
|
|
17925
|
+
});
|
|
17926
|
+
if (!response.ok) {
|
|
17927
|
+
const errorData = await response.json().catch(() => ({ message: "Unknown error" }));
|
|
17928
|
+
console.error("Search memory error:", errorData);
|
|
17929
|
+
throw new Error(errorData.message || errorData.error || "Failed to search memory");
|
|
17930
|
+
}
|
|
17931
|
+
return response.json();
|
|
17932
|
+
};
|
|
17933
|
+
return { searchMemory };
|
|
17934
|
+
};
|
|
17935
|
+
|
|
17395
17936
|
const formatRelativeTime = (date) => {
|
|
17396
17937
|
const now = /* @__PURE__ */ new Date();
|
|
17397
17938
|
const seconds = Math.floor((now.getTime() - date.getTime()) / 1e3);
|
|
@@ -17843,5 +18384,16 @@ const EmptyMCPTable = () => /* @__PURE__ */ jsx("div", { className: "flex h-full
|
|
|
17843
18384
|
}
|
|
17844
18385
|
) });
|
|
17845
18386
|
|
|
17846
|
-
|
|
18387
|
+
const useEvalsByAgentId = (agentId, type) => {
|
|
18388
|
+
const { runtimeContext } = usePlaygroundStore();
|
|
18389
|
+
const client = useMastraClient();
|
|
18390
|
+
return useQuery({
|
|
18391
|
+
staleTime: 0,
|
|
18392
|
+
gcTime: 0,
|
|
18393
|
+
queryKey: ["evals", agentId, type, JSON.stringify(runtimeContext)],
|
|
18394
|
+
queryFn: () => type === "live" ? client.getAgent(agentId).liveEvals(runtimeContext) : client.getAgent(agentId).evals(runtimeContext)
|
|
18395
|
+
});
|
|
18396
|
+
};
|
|
18397
|
+
|
|
18398
|
+
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
18399
|
//# sourceMappingURL=index.es.js.map
|