@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @mastra/playground-ui
|
|
2
2
|
|
|
3
|
+
## 6.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Move all the fetching hooks that should be shared with cloud into playground-ui ([#9133](https://github.com/mastra-ai/mastra/pull/9133))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`2b031e2`](https://github.com/mastra-ai/mastra/commit/2b031e25ca10cd3e4d63e6a27f909cba26d91405)]:
|
|
10
|
+
- @mastra/core@0.22.2
|
|
11
|
+
- @mastra/client-js@0.16.4
|
|
12
|
+
- @mastra/react@0.0.10
|
|
13
|
+
|
|
3
14
|
## 6.6.2-alpha.0
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
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');
|
|
@@ -7797,6 +7798,334 @@ const EmptyWorkflowsTable = () => /* @__PURE__ */ jsxRuntime.jsx("div", { classN
|
|
|
7797
7798
|
}
|
|
7798
7799
|
) });
|
|
7799
7800
|
|
|
7801
|
+
const useWorkflows = () => {
|
|
7802
|
+
const client = react$3.useMastraClient();
|
|
7803
|
+
const { runtimeContext } = usePlaygroundStore();
|
|
7804
|
+
return reactQuery.useQuery({
|
|
7805
|
+
queryKey: ["workflows", JSON.stringify(runtimeContext)],
|
|
7806
|
+
queryFn: () => client.getWorkflows(runtimeContext)
|
|
7807
|
+
});
|
|
7808
|
+
};
|
|
7809
|
+
|
|
7810
|
+
const useExecuteWorkflow = () => {
|
|
7811
|
+
const client = react$3.useMastraClient();
|
|
7812
|
+
const createWorkflowRun = reactQuery.useMutation({
|
|
7813
|
+
mutationFn: async ({ workflowId, prevRunId }) => {
|
|
7814
|
+
try {
|
|
7815
|
+
const workflow = client.getWorkflow(workflowId);
|
|
7816
|
+
const { runId: newRunId } = await workflow.createRunAsync({ runId: prevRunId });
|
|
7817
|
+
return { runId: newRunId };
|
|
7818
|
+
} catch (error) {
|
|
7819
|
+
console.error("Error creating workflow run:", error);
|
|
7820
|
+
throw error;
|
|
7821
|
+
}
|
|
7822
|
+
}
|
|
7823
|
+
});
|
|
7824
|
+
const startWorkflowRun = reactQuery.useMutation({
|
|
7825
|
+
mutationFn: async ({
|
|
7826
|
+
workflowId,
|
|
7827
|
+
runId,
|
|
7828
|
+
input,
|
|
7829
|
+
runtimeContext: playgroundRuntimeContext
|
|
7830
|
+
}) => {
|
|
7831
|
+
try {
|
|
7832
|
+
const runtimeContext$1 = new runtimeContext.RuntimeContext();
|
|
7833
|
+
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
7834
|
+
runtimeContext$1.set(key, value);
|
|
7835
|
+
});
|
|
7836
|
+
const workflow = client.getWorkflow(workflowId);
|
|
7837
|
+
await workflow.start({ runId, inputData: input || {}, runtimeContext: runtimeContext$1 });
|
|
7838
|
+
} catch (error) {
|
|
7839
|
+
console.error("Error starting workflow run:", error);
|
|
7840
|
+
throw error;
|
|
7841
|
+
}
|
|
7842
|
+
}
|
|
7843
|
+
});
|
|
7844
|
+
const startAsyncWorkflowRun = reactQuery.useMutation({
|
|
7845
|
+
mutationFn: async ({
|
|
7846
|
+
workflowId,
|
|
7847
|
+
runId,
|
|
7848
|
+
input,
|
|
7849
|
+
runtimeContext: playgroundRuntimeContext
|
|
7850
|
+
}) => {
|
|
7851
|
+
try {
|
|
7852
|
+
const runtimeContext$1 = new runtimeContext.RuntimeContext();
|
|
7853
|
+
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
7854
|
+
runtimeContext$1.set(key, value);
|
|
7855
|
+
});
|
|
7856
|
+
const workflow = client.getWorkflow(workflowId);
|
|
7857
|
+
const result = await workflow.startAsync({ runId, inputData: input || {}, runtimeContext: runtimeContext$1 });
|
|
7858
|
+
return result;
|
|
7859
|
+
} catch (error) {
|
|
7860
|
+
console.error("Error starting workflow run:", error);
|
|
7861
|
+
throw error;
|
|
7862
|
+
}
|
|
7863
|
+
}
|
|
7864
|
+
});
|
|
7865
|
+
return {
|
|
7866
|
+
startWorkflowRun,
|
|
7867
|
+
createWorkflowRun,
|
|
7868
|
+
startAsyncWorkflowRun
|
|
7869
|
+
};
|
|
7870
|
+
};
|
|
7871
|
+
const useStreamWorkflow = () => {
|
|
7872
|
+
const client = react$3.useMastraClient();
|
|
7873
|
+
const [streamResult, setStreamResult] = React.useState({});
|
|
7874
|
+
const [isStreaming, setIsStreaming] = React.useState(false);
|
|
7875
|
+
const readerRef = React.useRef(null);
|
|
7876
|
+
const observerRef = React.useRef(null);
|
|
7877
|
+
const resumeStreamRef = React.useRef(null);
|
|
7878
|
+
const isMountedRef = React.useRef(true);
|
|
7879
|
+
React.useEffect(() => {
|
|
7880
|
+
isMountedRef.current = true;
|
|
7881
|
+
return () => {
|
|
7882
|
+
isMountedRef.current = false;
|
|
7883
|
+
if (readerRef.current) {
|
|
7884
|
+
try {
|
|
7885
|
+
readerRef.current.releaseLock();
|
|
7886
|
+
} catch (error) {
|
|
7887
|
+
}
|
|
7888
|
+
readerRef.current = null;
|
|
7889
|
+
}
|
|
7890
|
+
if (observerRef.current) {
|
|
7891
|
+
try {
|
|
7892
|
+
observerRef.current.releaseLock();
|
|
7893
|
+
} catch (error) {
|
|
7894
|
+
}
|
|
7895
|
+
observerRef.current = null;
|
|
7896
|
+
}
|
|
7897
|
+
if (resumeStreamRef.current) {
|
|
7898
|
+
try {
|
|
7899
|
+
resumeStreamRef.current.releaseLock();
|
|
7900
|
+
} catch (error) {
|
|
7901
|
+
}
|
|
7902
|
+
resumeStreamRef.current = null;
|
|
7903
|
+
}
|
|
7904
|
+
};
|
|
7905
|
+
}, []);
|
|
7906
|
+
const streamWorkflow = reactQuery.useMutation({
|
|
7907
|
+
mutationFn: async ({
|
|
7908
|
+
workflowId,
|
|
7909
|
+
runId,
|
|
7910
|
+
inputData,
|
|
7911
|
+
runtimeContext: playgroundRuntimeContext
|
|
7912
|
+
}) => {
|
|
7913
|
+
if (readerRef.current) {
|
|
7914
|
+
readerRef.current.releaseLock();
|
|
7915
|
+
}
|
|
7916
|
+
if (!isMountedRef.current) return;
|
|
7917
|
+
setIsStreaming(true);
|
|
7918
|
+
setStreamResult({ input: inputData });
|
|
7919
|
+
const runtimeContext$1 = new runtimeContext.RuntimeContext();
|
|
7920
|
+
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
7921
|
+
runtimeContext$1.set(key, value);
|
|
7922
|
+
});
|
|
7923
|
+
const workflow = client.getWorkflow(workflowId);
|
|
7924
|
+
const stream = await workflow.streamVNext({ runId, inputData, runtimeContext: runtimeContext$1, closeOnSuspend: true });
|
|
7925
|
+
if (!stream) throw new Error("No stream returned");
|
|
7926
|
+
const reader = stream.getReader();
|
|
7927
|
+
readerRef.current = reader;
|
|
7928
|
+
try {
|
|
7929
|
+
while (true) {
|
|
7930
|
+
if (!isMountedRef.current) break;
|
|
7931
|
+
const { done, value } = await reader.read();
|
|
7932
|
+
if (done) break;
|
|
7933
|
+
if (isMountedRef.current) {
|
|
7934
|
+
setStreamResult((prev) => {
|
|
7935
|
+
const newResult = react$3.mapWorkflowStreamChunkToWatchResult(prev, value);
|
|
7936
|
+
return newResult;
|
|
7937
|
+
});
|
|
7938
|
+
if (value.type === "workflow-step-start") {
|
|
7939
|
+
setIsStreaming(true);
|
|
7940
|
+
}
|
|
7941
|
+
if (value.type === "workflow-step-suspended") {
|
|
7942
|
+
setIsStreaming(false);
|
|
7943
|
+
}
|
|
7944
|
+
}
|
|
7945
|
+
}
|
|
7946
|
+
} catch (error) {
|
|
7947
|
+
console.error("Error streaming workflow:", error);
|
|
7948
|
+
} finally {
|
|
7949
|
+
if (isMountedRef.current) {
|
|
7950
|
+
setIsStreaming(false);
|
|
7951
|
+
}
|
|
7952
|
+
if (readerRef.current) {
|
|
7953
|
+
readerRef.current.releaseLock();
|
|
7954
|
+
readerRef.current = null;
|
|
7955
|
+
}
|
|
7956
|
+
}
|
|
7957
|
+
}
|
|
7958
|
+
});
|
|
7959
|
+
const observeWorkflowStream = reactQuery.useMutation({
|
|
7960
|
+
mutationFn: async ({
|
|
7961
|
+
workflowId,
|
|
7962
|
+
runId,
|
|
7963
|
+
storeRunResult
|
|
7964
|
+
}) => {
|
|
7965
|
+
if (observerRef.current) {
|
|
7966
|
+
observerRef.current.releaseLock();
|
|
7967
|
+
}
|
|
7968
|
+
if (!isMountedRef.current) return;
|
|
7969
|
+
setIsStreaming(true);
|
|
7970
|
+
setStreamResult(storeRunResult || {});
|
|
7971
|
+
if (storeRunResult?.status === "suspended") {
|
|
7972
|
+
setIsStreaming(false);
|
|
7973
|
+
return;
|
|
7974
|
+
}
|
|
7975
|
+
const workflow = client.getWorkflow(workflowId);
|
|
7976
|
+
const stream = await workflow.observeStreamVNext({ runId });
|
|
7977
|
+
if (!stream) throw new Error("No stream returned");
|
|
7978
|
+
const reader = stream.getReader();
|
|
7979
|
+
observerRef.current = reader;
|
|
7980
|
+
try {
|
|
7981
|
+
while (true) {
|
|
7982
|
+
if (!isMountedRef.current) break;
|
|
7983
|
+
const { done, value } = await reader.read();
|
|
7984
|
+
if (done) break;
|
|
7985
|
+
if (isMountedRef.current) {
|
|
7986
|
+
setStreamResult((prev) => {
|
|
7987
|
+
const newResult = react$3.mapWorkflowStreamChunkToWatchResult(prev, value);
|
|
7988
|
+
return newResult;
|
|
7989
|
+
});
|
|
7990
|
+
if (value.type === "workflow-step-start") {
|
|
7991
|
+
setIsStreaming(true);
|
|
7992
|
+
}
|
|
7993
|
+
if (value.type === "workflow-step-suspended") {
|
|
7994
|
+
setIsStreaming(false);
|
|
7995
|
+
}
|
|
7996
|
+
}
|
|
7997
|
+
}
|
|
7998
|
+
} catch (error) {
|
|
7999
|
+
console.error("Error streaming workflow:", error);
|
|
8000
|
+
} finally {
|
|
8001
|
+
if (isMountedRef.current) {
|
|
8002
|
+
setIsStreaming(false);
|
|
8003
|
+
}
|
|
8004
|
+
if (observerRef.current) {
|
|
8005
|
+
observerRef.current.releaseLock();
|
|
8006
|
+
observerRef.current = null;
|
|
8007
|
+
}
|
|
8008
|
+
}
|
|
8009
|
+
}
|
|
8010
|
+
});
|
|
8011
|
+
const resumeWorkflowStream = reactQuery.useMutation({
|
|
8012
|
+
mutationFn: async ({
|
|
8013
|
+
workflowId,
|
|
8014
|
+
runId,
|
|
8015
|
+
step,
|
|
8016
|
+
resumeData,
|
|
8017
|
+
runtimeContext: playgroundRuntimeContext
|
|
8018
|
+
}) => {
|
|
8019
|
+
if (resumeStreamRef.current) {
|
|
8020
|
+
resumeStreamRef.current.releaseLock();
|
|
8021
|
+
}
|
|
8022
|
+
if (!isMountedRef.current) return;
|
|
8023
|
+
setIsStreaming(true);
|
|
8024
|
+
const workflow = client.getWorkflow(workflowId);
|
|
8025
|
+
const runtimeContext$1 = new runtimeContext.RuntimeContext();
|
|
8026
|
+
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
8027
|
+
runtimeContext$1.set(key, value);
|
|
8028
|
+
});
|
|
8029
|
+
const stream = await workflow.resumeStreamVNext({ runId, step, resumeData, runtimeContext: runtimeContext$1 });
|
|
8030
|
+
if (!stream) throw new Error("No stream returned");
|
|
8031
|
+
const reader = stream.getReader();
|
|
8032
|
+
resumeStreamRef.current = reader;
|
|
8033
|
+
try {
|
|
8034
|
+
while (true) {
|
|
8035
|
+
if (!isMountedRef.current) break;
|
|
8036
|
+
const { done, value } = await reader.read();
|
|
8037
|
+
if (done) break;
|
|
8038
|
+
if (isMountedRef.current) {
|
|
8039
|
+
setStreamResult((prev) => {
|
|
8040
|
+
const newResult = react$3.mapWorkflowStreamChunkToWatchResult(prev, value);
|
|
8041
|
+
return newResult;
|
|
8042
|
+
});
|
|
8043
|
+
if (value.type === "workflow-step-start") {
|
|
8044
|
+
setIsStreaming(true);
|
|
8045
|
+
}
|
|
8046
|
+
if (value.type === "workflow-step-suspended") {
|
|
8047
|
+
setIsStreaming(false);
|
|
8048
|
+
}
|
|
8049
|
+
}
|
|
8050
|
+
}
|
|
8051
|
+
} catch (error) {
|
|
8052
|
+
console.error("Error resuming workflow stream:", error);
|
|
8053
|
+
} finally {
|
|
8054
|
+
if (isMountedRef.current) {
|
|
8055
|
+
setIsStreaming(false);
|
|
8056
|
+
}
|
|
8057
|
+
if (resumeStreamRef.current) {
|
|
8058
|
+
resumeStreamRef.current.releaseLock();
|
|
8059
|
+
resumeStreamRef.current = null;
|
|
8060
|
+
}
|
|
8061
|
+
}
|
|
8062
|
+
}
|
|
8063
|
+
});
|
|
8064
|
+
const closeStreamsAndReset = () => {
|
|
8065
|
+
setIsStreaming(false);
|
|
8066
|
+
setStreamResult({});
|
|
8067
|
+
if (readerRef.current) {
|
|
8068
|
+
try {
|
|
8069
|
+
readerRef.current.releaseLock();
|
|
8070
|
+
} catch (error) {
|
|
8071
|
+
}
|
|
8072
|
+
readerRef.current = null;
|
|
8073
|
+
}
|
|
8074
|
+
if (observerRef.current) {
|
|
8075
|
+
try {
|
|
8076
|
+
observerRef.current.releaseLock();
|
|
8077
|
+
} catch (error) {
|
|
8078
|
+
}
|
|
8079
|
+
observerRef.current = null;
|
|
8080
|
+
}
|
|
8081
|
+
if (resumeStreamRef.current) {
|
|
8082
|
+
try {
|
|
8083
|
+
resumeStreamRef.current.releaseLock();
|
|
8084
|
+
} catch (error) {
|
|
8085
|
+
}
|
|
8086
|
+
resumeStreamRef.current = null;
|
|
8087
|
+
}
|
|
8088
|
+
};
|
|
8089
|
+
return {
|
|
8090
|
+
streamWorkflow,
|
|
8091
|
+
streamResult,
|
|
8092
|
+
isStreaming,
|
|
8093
|
+
observeWorkflowStream,
|
|
8094
|
+
closeStreamsAndReset,
|
|
8095
|
+
resumeWorkflowStream
|
|
8096
|
+
};
|
|
8097
|
+
};
|
|
8098
|
+
const useCancelWorkflowRun = () => {
|
|
8099
|
+
const client = react$3.useMastraClient();
|
|
8100
|
+
const cancelWorkflowRun = reactQuery.useMutation({
|
|
8101
|
+
mutationFn: async ({ workflowId, runId }) => {
|
|
8102
|
+
try {
|
|
8103
|
+
const response = await client.getWorkflow(workflowId).cancelRun(runId);
|
|
8104
|
+
return response;
|
|
8105
|
+
} catch (error) {
|
|
8106
|
+
console.error("Error canceling workflow run:", error);
|
|
8107
|
+
throw error;
|
|
8108
|
+
}
|
|
8109
|
+
}
|
|
8110
|
+
});
|
|
8111
|
+
return cancelWorkflowRun;
|
|
8112
|
+
};
|
|
8113
|
+
const useSendWorkflowRunEvent = (workflowId) => {
|
|
8114
|
+
const client = react$3.useMastraClient();
|
|
8115
|
+
const sendWorkflowRunEvent = reactQuery.useMutation({
|
|
8116
|
+
mutationFn: async ({ runId, event, data }) => {
|
|
8117
|
+
try {
|
|
8118
|
+
const response = await client.getWorkflow(workflowId).sendRunEvent({ runId, event, data });
|
|
8119
|
+
return response;
|
|
8120
|
+
} catch (error) {
|
|
8121
|
+
console.error("Error sending workflow run event:", error);
|
|
8122
|
+
throw error;
|
|
8123
|
+
}
|
|
8124
|
+
}
|
|
8125
|
+
});
|
|
8126
|
+
return sendWorkflowRunEvent;
|
|
8127
|
+
};
|
|
8128
|
+
|
|
7800
8129
|
const LoadingBadge = () => {
|
|
7801
8130
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7802
8131
|
BadgeWrapper,
|
|
@@ -14304,6 +14633,93 @@ const formatDay = (date) => {
|
|
|
14304
14633
|
return new Date(date).toLocaleString("en-us", options).replace(",", " at");
|
|
14305
14634
|
};
|
|
14306
14635
|
|
|
14636
|
+
const useAgents = () => {
|
|
14637
|
+
const client = react$3.useMastraClient();
|
|
14638
|
+
const { runtimeContext } = usePlaygroundStore();
|
|
14639
|
+
return reactQuery.useQuery({
|
|
14640
|
+
queryKey: ["agents", JSON.stringify(runtimeContext)],
|
|
14641
|
+
queryFn: () => client.getAgents(runtimeContext)
|
|
14642
|
+
});
|
|
14643
|
+
};
|
|
14644
|
+
const useModelProviders = () => {
|
|
14645
|
+
const client = react$3.useMastraClient();
|
|
14646
|
+
return reactQuery.useQuery({
|
|
14647
|
+
queryKey: ["model-providers"],
|
|
14648
|
+
queryFn: () => client.getModelProviders()
|
|
14649
|
+
});
|
|
14650
|
+
};
|
|
14651
|
+
const useUpdateAgentModel = (agentId) => {
|
|
14652
|
+
const client = react$3.useMastraClient();
|
|
14653
|
+
const queryClient = reactQuery.useQueryClient();
|
|
14654
|
+
return reactQuery.useMutation({
|
|
14655
|
+
mutationFn: async (payload) => client.getAgent(agentId).updateModel(payload),
|
|
14656
|
+
onSuccess: () => {
|
|
14657
|
+
queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
|
|
14658
|
+
},
|
|
14659
|
+
onError: (err) => {
|
|
14660
|
+
console.error("Error updating model", err);
|
|
14661
|
+
}
|
|
14662
|
+
});
|
|
14663
|
+
};
|
|
14664
|
+
const useReorderModelList = (agentId) => {
|
|
14665
|
+
const client = react$3.useMastraClient();
|
|
14666
|
+
const queryClient = reactQuery.useQueryClient();
|
|
14667
|
+
return reactQuery.useMutation({
|
|
14668
|
+
mutationFn: async (payload) => client.getAgent(agentId).reorderModelList(payload),
|
|
14669
|
+
onSuccess: () => {
|
|
14670
|
+
queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
|
|
14671
|
+
},
|
|
14672
|
+
onError: (err) => {
|
|
14673
|
+
console.error("Error reordering model list", err);
|
|
14674
|
+
}
|
|
14675
|
+
});
|
|
14676
|
+
};
|
|
14677
|
+
const useUpdateModelInModelList = (agentId) => {
|
|
14678
|
+
const client = react$3.useMastraClient();
|
|
14679
|
+
const queryClient = reactQuery.useQueryClient();
|
|
14680
|
+
return reactQuery.useMutation({
|
|
14681
|
+
mutationFn: async (payload) => client.getAgent(agentId).updateModelInModelList(payload),
|
|
14682
|
+
onSuccess: () => {
|
|
14683
|
+
queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
|
|
14684
|
+
},
|
|
14685
|
+
onError: (err) => {
|
|
14686
|
+
console.error("Error updating model in model list", err);
|
|
14687
|
+
}
|
|
14688
|
+
});
|
|
14689
|
+
};
|
|
14690
|
+
|
|
14691
|
+
const useAgent = (agentId) => {
|
|
14692
|
+
const client = react$3.useMastraClient();
|
|
14693
|
+
const { runtimeContext } = usePlaygroundStore();
|
|
14694
|
+
return reactQuery.useQuery({
|
|
14695
|
+
queryKey: ["agent", agentId, JSON.stringify(runtimeContext)],
|
|
14696
|
+
queryFn: () => agentId ? client.getAgent(agentId).details(runtimeContext) : null,
|
|
14697
|
+
retry: false,
|
|
14698
|
+
enabled: Boolean(agentId)
|
|
14699
|
+
});
|
|
14700
|
+
};
|
|
14701
|
+
|
|
14702
|
+
const useExecuteAgentTool = () => {
|
|
14703
|
+
const client = react$3.useMastraClient();
|
|
14704
|
+
return reactQuery.useMutation({
|
|
14705
|
+
mutationFn: async ({ agentId, toolId, input, playgroundRuntimeContext }) => {
|
|
14706
|
+
const runtimeContext = new di.RuntimeContext();
|
|
14707
|
+
Object.entries(playgroundRuntimeContext ?? {}).forEach(([key, value]) => {
|
|
14708
|
+
runtimeContext.set(key, value);
|
|
14709
|
+
});
|
|
14710
|
+
try {
|
|
14711
|
+
const agent = client.getAgent(agentId);
|
|
14712
|
+
const response = await agent.executeTool(toolId, { data: input, runtimeContext });
|
|
14713
|
+
return response;
|
|
14714
|
+
} catch (error) {
|
|
14715
|
+
sonner.toast.error("Error executing agent tool");
|
|
14716
|
+
console.error("Error executing tool:", error);
|
|
14717
|
+
throw error;
|
|
14718
|
+
}
|
|
14719
|
+
}
|
|
14720
|
+
});
|
|
14721
|
+
};
|
|
14722
|
+
|
|
14307
14723
|
const NameCell$1 = ({ row }) => {
|
|
14308
14724
|
const { Link, paths } = useLinkComponent();
|
|
14309
14725
|
const tool = row.original;
|
|
@@ -14426,6 +14842,31 @@ const EmptyToolsTable = () => /* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
|
14426
14842
|
}
|
|
14427
14843
|
) });
|
|
14428
14844
|
|
|
14845
|
+
const useExecuteTool = () => {
|
|
14846
|
+
const client = react$3.useMastraClient();
|
|
14847
|
+
return reactQuery.useMutation({
|
|
14848
|
+
mutationFn: async ({
|
|
14849
|
+
toolId,
|
|
14850
|
+
input,
|
|
14851
|
+
runtimeContext: playgroundRuntimeContext
|
|
14852
|
+
}) => {
|
|
14853
|
+
const runtimeContext = new di.RuntimeContext();
|
|
14854
|
+
Object.entries(playgroundRuntimeContext ?? {}).forEach(([key, value]) => {
|
|
14855
|
+
runtimeContext.set(key, value);
|
|
14856
|
+
});
|
|
14857
|
+
try {
|
|
14858
|
+
const tool = client.getTool(toolId);
|
|
14859
|
+
const response = await tool.execute({ data: input, runtimeContext });
|
|
14860
|
+
return response;
|
|
14861
|
+
} catch (error) {
|
|
14862
|
+
sonner.toast.error("Error executing dev tool");
|
|
14863
|
+
console.error("Error executing dev tool:", error);
|
|
14864
|
+
throw error;
|
|
14865
|
+
}
|
|
14866
|
+
}
|
|
14867
|
+
});
|
|
14868
|
+
};
|
|
14869
|
+
|
|
14429
14870
|
function TemplatesTools({
|
|
14430
14871
|
tagOptions,
|
|
14431
14872
|
selectedTag,
|
|
@@ -17427,6 +17868,106 @@ const PlaygroundQueryClient = ({ children }) => {
|
|
|
17427
17868
|
return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClient, children });
|
|
17428
17869
|
};
|
|
17429
17870
|
|
|
17871
|
+
const useMemory = (agentId) => {
|
|
17872
|
+
const client = react$3.useMastraClient();
|
|
17873
|
+
return reactQuery.useQuery({
|
|
17874
|
+
queryKey: ["memory", agentId],
|
|
17875
|
+
queryFn: () => agentId ? client.getMemoryStatus(agentId) : null,
|
|
17876
|
+
enabled: Boolean(agentId),
|
|
17877
|
+
staleTime: 5 * 60 * 1e3,
|
|
17878
|
+
// 5 minutes
|
|
17879
|
+
gcTime: 10 * 60 * 1e3,
|
|
17880
|
+
// 10 minutes
|
|
17881
|
+
retry: false
|
|
17882
|
+
});
|
|
17883
|
+
};
|
|
17884
|
+
const useMemoryConfig = (agentId) => {
|
|
17885
|
+
const client = react$3.useMastraClient();
|
|
17886
|
+
return reactQuery.useQuery({
|
|
17887
|
+
queryKey: ["memory", "config", agentId],
|
|
17888
|
+
queryFn: () => agentId ? client.getMemoryConfig({ agentId }) : null,
|
|
17889
|
+
enabled: Boolean(agentId),
|
|
17890
|
+
staleTime: 5 * 60 * 1e3,
|
|
17891
|
+
// 5 minutes
|
|
17892
|
+
gcTime: 10 * 60 * 1e3,
|
|
17893
|
+
// 10 minutes
|
|
17894
|
+
retry: false,
|
|
17895
|
+
refetchOnWindowFocus: false
|
|
17896
|
+
});
|
|
17897
|
+
};
|
|
17898
|
+
const useThreads = ({
|
|
17899
|
+
resourceId,
|
|
17900
|
+
agentId,
|
|
17901
|
+
isMemoryEnabled
|
|
17902
|
+
}) => {
|
|
17903
|
+
const client = react$3.useMastraClient();
|
|
17904
|
+
return reactQuery.useQuery({
|
|
17905
|
+
queryKey: ["memory", "threads", resourceId, agentId],
|
|
17906
|
+
queryFn: () => isMemoryEnabled ? client.getMemoryThreads({ resourceId, agentId }) : null,
|
|
17907
|
+
enabled: Boolean(isMemoryEnabled),
|
|
17908
|
+
staleTime: 0,
|
|
17909
|
+
gcTime: 0,
|
|
17910
|
+
retry: false,
|
|
17911
|
+
refetchOnWindowFocus: false
|
|
17912
|
+
});
|
|
17913
|
+
};
|
|
17914
|
+
const useDeleteThread = () => {
|
|
17915
|
+
const client = react$3.useMastraClient();
|
|
17916
|
+
const queryClient = reactQuery.useQueryClient();
|
|
17917
|
+
return reactQuery.useMutation({
|
|
17918
|
+
mutationFn: ({ threadId, agentId, networkId }) => client.deleteThread(threadId, { agentId, networkId }),
|
|
17919
|
+
onSuccess: (_, variables) => {
|
|
17920
|
+
const { agentId, networkId } = variables;
|
|
17921
|
+
if (agentId) {
|
|
17922
|
+
queryClient.invalidateQueries({ queryKey: ["memory", "threads", agentId, agentId] });
|
|
17923
|
+
}
|
|
17924
|
+
if (networkId) {
|
|
17925
|
+
queryClient.invalidateQueries({ queryKey: ["network", "threads", networkId, networkId] });
|
|
17926
|
+
}
|
|
17927
|
+
sonner.toast.success("Chat deleted successfully");
|
|
17928
|
+
},
|
|
17929
|
+
onError: () => {
|
|
17930
|
+
sonner.toast.error("Failed to delete chat");
|
|
17931
|
+
}
|
|
17932
|
+
});
|
|
17933
|
+
};
|
|
17934
|
+
const useMemorySearch = ({
|
|
17935
|
+
agentId,
|
|
17936
|
+
resourceId,
|
|
17937
|
+
threadId
|
|
17938
|
+
}) => {
|
|
17939
|
+
const searchMemory = async (searchQuery, memoryConfig) => {
|
|
17940
|
+
if (!searchQuery.trim()) {
|
|
17941
|
+
return { results: [], count: 0, query: searchQuery };
|
|
17942
|
+
}
|
|
17943
|
+
const params = new URLSearchParams({
|
|
17944
|
+
searchQuery,
|
|
17945
|
+
resourceId,
|
|
17946
|
+
agentId
|
|
17947
|
+
});
|
|
17948
|
+
if (threadId) {
|
|
17949
|
+
params.append("threadId", threadId);
|
|
17950
|
+
}
|
|
17951
|
+
if (memoryConfig) {
|
|
17952
|
+
params.append("memoryConfig", JSON.stringify(memoryConfig));
|
|
17953
|
+
}
|
|
17954
|
+
const response = await fetch(`/api/memory/search?${params}`, {
|
|
17955
|
+
method: "GET",
|
|
17956
|
+
headers: {
|
|
17957
|
+
"Content-Type": "application/json",
|
|
17958
|
+
"x-mastra-dev-playground": "true"
|
|
17959
|
+
}
|
|
17960
|
+
});
|
|
17961
|
+
if (!response.ok) {
|
|
17962
|
+
const errorData = await response.json().catch(() => ({ message: "Unknown error" }));
|
|
17963
|
+
console.error("Search memory error:", errorData);
|
|
17964
|
+
throw new Error(errorData.message || errorData.error || "Failed to search memory");
|
|
17965
|
+
}
|
|
17966
|
+
return response.json();
|
|
17967
|
+
};
|
|
17968
|
+
return { searchMemory };
|
|
17969
|
+
};
|
|
17970
|
+
|
|
17430
17971
|
const formatRelativeTime = (date) => {
|
|
17431
17972
|
const now = /* @__PURE__ */ new Date();
|
|
17432
17973
|
const seconds = Math.floor((now.getTime() - date.getTime()) / 1e3);
|
|
@@ -17878,6 +18419,17 @@ const EmptyMCPTable = () => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
|
17878
18419
|
}
|
|
17879
18420
|
) });
|
|
17880
18421
|
|
|
18422
|
+
const useEvalsByAgentId = (agentId, type) => {
|
|
18423
|
+
const { runtimeContext } = usePlaygroundStore();
|
|
18424
|
+
const client = react$3.useMastraClient();
|
|
18425
|
+
return reactQuery.useQuery({
|
|
18426
|
+
staleTime: 0,
|
|
18427
|
+
gcTime: 0,
|
|
18428
|
+
queryKey: ["evals", agentId, type, JSON.stringify(runtimeContext)],
|
|
18429
|
+
queryFn: () => type === "live" ? client.getAgent(agentId).liveEvals(runtimeContext) : client.getAgent(agentId).evals(runtimeContext)
|
|
18430
|
+
});
|
|
18431
|
+
};
|
|
18432
|
+
|
|
17881
18433
|
exports.AgentChat = AgentChat;
|
|
17882
18434
|
exports.AgentCoinIcon = AgentCoinIcon;
|
|
17883
18435
|
exports.AgentEntityHeader = AgentEntityHeader;
|
|
@@ -18082,24 +18634,43 @@ exports.spanTypePrefixes = spanTypePrefixes;
|
|
|
18082
18634
|
exports.traceScoresListColumns = traceScoresListColumns;
|
|
18083
18635
|
exports.tracesListColumns = tracesListColumns;
|
|
18084
18636
|
exports.transformKey = transformKey;
|
|
18637
|
+
exports.useAgent = useAgent;
|
|
18085
18638
|
exports.useAgentSettings = useAgentSettings;
|
|
18639
|
+
exports.useAgents = useAgents;
|
|
18640
|
+
exports.useCancelWorkflowRun = useCancelWorkflowRun;
|
|
18086
18641
|
exports.useCurrentRun = useCurrentRun;
|
|
18642
|
+
exports.useDeleteThread = useDeleteThread;
|
|
18643
|
+
exports.useEvalsByAgentId = useEvalsByAgentId;
|
|
18644
|
+
exports.useExecuteAgentTool = useExecuteAgentTool;
|
|
18645
|
+
exports.useExecuteTool = useExecuteTool;
|
|
18646
|
+
exports.useExecuteWorkflow = useExecuteWorkflow;
|
|
18087
18647
|
exports.useInView = useInView;
|
|
18088
18648
|
exports.useLinkComponent = useLinkComponent;
|
|
18089
18649
|
exports.useMCPServerTools = useMCPServerTools;
|
|
18090
18650
|
exports.useMainSidebar = useMainSidebar;
|
|
18651
|
+
exports.useMemory = useMemory;
|
|
18652
|
+
exports.useMemoryConfig = useMemoryConfig;
|
|
18653
|
+
exports.useMemorySearch = useMemorySearch;
|
|
18654
|
+
exports.useModelProviders = useModelProviders;
|
|
18091
18655
|
exports.useModelReset = useModelReset;
|
|
18092
18656
|
exports.usePlaygroundStore = usePlaygroundStore;
|
|
18093
18657
|
exports.usePolling = usePolling;
|
|
18658
|
+
exports.useReorderModelList = useReorderModelList;
|
|
18094
18659
|
exports.useScorer = useScorer;
|
|
18095
18660
|
exports.useScorers = useScorers;
|
|
18096
18661
|
exports.useScoresByEntityId = useScoresByEntityId;
|
|
18097
18662
|
exports.useScoresByScorerId = useScoresByScorerId;
|
|
18663
|
+
exports.useSendWorkflowRunEvent = useSendWorkflowRunEvent;
|
|
18098
18664
|
exports.useSpeechRecognition = useSpeechRecognition;
|
|
18665
|
+
exports.useStreamWorkflow = useStreamWorkflow;
|
|
18099
18666
|
exports.useThreadInput = useThreadInput;
|
|
18667
|
+
exports.useThreads = useThreads;
|
|
18100
18668
|
exports.useTraceSpanScores = useTraceSpanScores;
|
|
18669
|
+
exports.useUpdateAgentModel = useUpdateAgentModel;
|
|
18670
|
+
exports.useUpdateModelInModelList = useUpdateModelInModelList;
|
|
18101
18671
|
exports.useWorkflow = useWorkflow;
|
|
18102
18672
|
exports.useWorkflowRuns = useWorkflowRuns;
|
|
18673
|
+
exports.useWorkflows = useWorkflows;
|
|
18103
18674
|
exports.useWorkingMemory = useWorkingMemory;
|
|
18104
18675
|
Object.keys(reactQuery).forEach(k => {
|
|
18105
18676
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|