@mastra/playground-ui 5.1.2-alpha.0 → 5.1.2-alpha.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/dist/index.cjs.js +77 -85
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +78 -86
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/ui/button.d.ts +1 -1
- package/dist/src/components/ui/command.d.ts +2 -2
- package/dist/src/components/ui/resizable.d.ts +1 -1
- package/dist/src/contexts/mastra-client-context.d.ts +9 -0
- package/dist/src/domains/agents/agent/agent-chat.d.ts +1 -1
- package/dist/src/domains/agents/agent/agent-evals.d.ts +1 -2
- package/dist/src/domains/agents/agent/agent-traces.d.ts +1 -2
- package/dist/src/domains/traces/context/trace-context.d.ts +1 -2
- package/dist/src/domains/traces/traces-table.d.ts +1 -2
- package/dist/src/domains/workflows/workflow/legacy-workflow-graph.d.ts +1 -2
- package/dist/src/domains/workflows/workflow/legacy-workflow-trigger.d.ts +1 -2
- package/dist/src/domains/workflows/workflow/workflow-graph.d.ts +1 -2
- package/dist/src/domains/workflows/workflow/workflow-traces.d.ts +1 -2
- package/dist/src/domains/workflows/workflow/workflow-trigger.d.ts +1 -2
- package/dist/src/hooks/use-evals.d.ts +1 -1
- package/dist/src/hooks/use-traces.d.ts +1 -1
- package/dist/src/hooks/use-workflows.d.ts +5 -5
- package/dist/src/index.d.ts +1 -1
- package/dist/src/lib/mastra-client.d.ts +1 -1
- package/dist/src/services/mastra-runtime-provider.d.ts +1 -1
- package/dist/src/services/network-runtime-provider.d.ts +1 -1
- package/dist/src/types.d.ts +0 -1
- package/package.json +4 -4
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default, { createContext, useContext, forwardRef, useState, useEffect, memo, useMemo, useRef, useCallback, Suspense, Fragment as Fragment$1 } from 'react';
|
|
4
|
+
import { MastraClient } from '@mastra/client-js';
|
|
2
5
|
import { useMessage, MessagePrimitive, ActionBarPrimitive, useComposerRuntime, ComposerPrimitive, useAttachment, AttachmentPrimitive, ThreadPrimitive, useExternalStoreRuntime, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, AssistantRuntimeProvider } from '@assistant-ui/react';
|
|
3
6
|
import { CheckIcon as CheckIcon$1, CopyIcon, ChevronUpIcon, X, FileIcon, CircleXIcon, Mic, PlusIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, Check, ChevronUp, ChevronDown, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Network, PauseIcon, Loader2, CircleDashed, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Braces, Brackets, TrashIcon, Plus, Minus, Maximize, CirclePause } from 'lucide-react';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
import React__default, { forwardRef, useState, useEffect, memo, useMemo, useRef, createContext, useContext, useCallback, Suspense, Fragment as Fragment$1 } from 'react';
|
|
6
7
|
import { Slot } from '@radix-ui/react-slot';
|
|
7
8
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
8
9
|
import { TooltipProvider as TooltipProvider$1 } from '@radix-ui/react-tooltip';
|
|
@@ -19,7 +20,6 @@ import CodeMirror from '@uiw/react-codemirror';
|
|
|
19
20
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
20
21
|
import { useShallow } from 'zustand/shallow';
|
|
21
22
|
import { RuntimeContext } from '@mastra/core/di';
|
|
22
|
-
import { MastraClient } from '@mastra/client-js';
|
|
23
23
|
import { create } from 'zustand';
|
|
24
24
|
import { persist } from 'zustand/middleware';
|
|
25
25
|
import { format, formatDistanceToNow, isValid } from 'date-fns';
|
|
@@ -52,7 +52,32 @@ import { CodeBlock as CodeBlock$1 } from 'react-code-block';
|
|
|
52
52
|
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
53
53
|
import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
54
54
|
|
|
55
|
-
import './index.css';
|
|
55
|
+
import './index.css';const createMastraClient = (baseUrl, mastraClientHeaders = {}) => {
|
|
56
|
+
return new MastraClient({
|
|
57
|
+
baseUrl: baseUrl || "",
|
|
58
|
+
// only add the header if the baseUrl is not provided i.e it's a local dev environment
|
|
59
|
+
headers: !baseUrl ? { ...mastraClientHeaders, "x-mastra-dev-playground": "true" } : mastraClientHeaders
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const MastraClientContext = createContext(void 0);
|
|
64
|
+
const MastraClientProvider = ({
|
|
65
|
+
children,
|
|
66
|
+
baseUrl,
|
|
67
|
+
headers
|
|
68
|
+
}) => {
|
|
69
|
+
const client = createMastraClient(baseUrl, headers);
|
|
70
|
+
return /* @__PURE__ */ jsx(MastraClientContext.Provider, { value: { client }, children });
|
|
71
|
+
};
|
|
72
|
+
const useMastraClient = () => {
|
|
73
|
+
const context = useContext(MastraClientContext);
|
|
74
|
+
if (context === void 0) {
|
|
75
|
+
throw new Error("useMastraClient must be used within a MastraClientProvider");
|
|
76
|
+
}
|
|
77
|
+
return context.client;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
56
81
|
|
|
57
82
|
const falsyToString = (value)=>typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
58
83
|
const cx = clsx;
|
|
@@ -4453,14 +4478,6 @@ const CircleStopIcon = () => {
|
|
|
4453
4478
|
return /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", width: "16", height: "16", children: /* @__PURE__ */ jsx("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" }) });
|
|
4454
4479
|
};
|
|
4455
4480
|
|
|
4456
|
-
const createMastraClient = (baseUrl) => {
|
|
4457
|
-
return new MastraClient({
|
|
4458
|
-
baseUrl: baseUrl || "",
|
|
4459
|
-
// only add the header if the baseUrl is not provided i.e it's a local dev environment
|
|
4460
|
-
headers: !baseUrl ? { "x-mastra-dev-playground": "true" } : {}
|
|
4461
|
-
});
|
|
4462
|
-
};
|
|
4463
|
-
|
|
4464
4481
|
const fileToBase64 = async (file) => {
|
|
4465
4482
|
return new Promise((resolve, reject) => {
|
|
4466
4483
|
const reader = new FileReader();
|
|
@@ -4502,7 +4519,6 @@ function MastraRuntimeProvider({
|
|
|
4502
4519
|
agentName,
|
|
4503
4520
|
memory,
|
|
4504
4521
|
threadId,
|
|
4505
|
-
baseUrl,
|
|
4506
4522
|
refreshThreadList,
|
|
4507
4523
|
modelSettings = {},
|
|
4508
4524
|
chatWithGenerate,
|
|
@@ -4543,7 +4559,7 @@ function MastraRuntimeProvider({
|
|
|
4543
4559
|
}
|
|
4544
4560
|
}
|
|
4545
4561
|
}, [initialMessages, threadId, memory]);
|
|
4546
|
-
const mastra =
|
|
4562
|
+
const mastra = useMastraClient();
|
|
4547
4563
|
const agent = mastra.getAgent(agentId);
|
|
4548
4564
|
const onNew = async (message) => {
|
|
4549
4565
|
if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
|
|
@@ -4901,7 +4917,6 @@ const AgentChat = ({
|
|
|
4901
4917
|
threadId,
|
|
4902
4918
|
initialMessages,
|
|
4903
4919
|
memory,
|
|
4904
|
-
baseUrl,
|
|
4905
4920
|
refreshThreadList,
|
|
4906
4921
|
showFileSupport
|
|
4907
4922
|
}) => {
|
|
@@ -4915,7 +4930,6 @@ const AgentChat = ({
|
|
|
4915
4930
|
threadId,
|
|
4916
4931
|
initialMessages,
|
|
4917
4932
|
memory,
|
|
4918
|
-
baseUrl,
|
|
4919
4933
|
refreshThreadList,
|
|
4920
4934
|
modelSettings,
|
|
4921
4935
|
chatWithGenerate,
|
|
@@ -5095,10 +5109,10 @@ const TabsContent = React.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
5095
5109
|
));
|
|
5096
5110
|
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
5097
5111
|
|
|
5098
|
-
const useEvalsByAgentId = (agentId, type
|
|
5112
|
+
const useEvalsByAgentId = (agentId, type) => {
|
|
5099
5113
|
const [evals, setEvals] = useState([]);
|
|
5100
5114
|
const [isLoading, setIsLoading] = useState(true);
|
|
5101
|
-
const client =
|
|
5115
|
+
const client = useMastraClient();
|
|
5102
5116
|
const fetchEvals = async (_agentId) => {
|
|
5103
5117
|
setIsLoading(true);
|
|
5104
5118
|
const activeAgentId = _agentId ?? agentId;
|
|
@@ -5136,18 +5150,14 @@ const tabIndicatorClass = cn(
|
|
|
5136
5150
|
"focus-visible:outline-none"
|
|
5137
5151
|
);
|
|
5138
5152
|
const tabContentClass = cn("data-[state=inactive]:mt-0 min-h-0 h-full grid grid-rows-[1fr]");
|
|
5139
|
-
function AgentEvals({ agentId
|
|
5153
|
+
function AgentEvals({ agentId }) {
|
|
5140
5154
|
const [activeTab, setActiveTab] = useState("live");
|
|
5141
5155
|
const {
|
|
5142
5156
|
evals: liveEvals,
|
|
5143
5157
|
isLoading: isLiveLoading,
|
|
5144
5158
|
refetchEvals: refetchLiveEvals
|
|
5145
|
-
} = useEvalsByAgentId(agentId, "live"
|
|
5146
|
-
const {
|
|
5147
|
-
evals: ciEvals,
|
|
5148
|
-
isLoading: isCiLoading,
|
|
5149
|
-
refetchEvals: refetchCiEvals
|
|
5150
|
-
} = useEvalsByAgentId(agentId, "ci", baseUrl);
|
|
5159
|
+
} = useEvalsByAgentId(agentId, "live");
|
|
5160
|
+
const { evals: ciEvals, isLoading: isCiLoading, refetchEvals: refetchCiEvals } = useEvalsByAgentId(agentId, "ci");
|
|
5151
5161
|
const contextValue = {
|
|
5152
5162
|
handleRefresh,
|
|
5153
5163
|
isLoading: activeTab === "live" ? isLiveLoading : isCiLoading
|
|
@@ -5373,11 +5383,10 @@ function EvalTable({ evals, isCIMode = false }) {
|
|
|
5373
5383
|
const TraceContext = createContext({});
|
|
5374
5384
|
function TraceProvider({
|
|
5375
5385
|
children,
|
|
5376
|
-
initialTraces
|
|
5386
|
+
initialTraces: traces = []
|
|
5377
5387
|
}) {
|
|
5378
5388
|
const [open, setOpen] = useState(false);
|
|
5379
5389
|
const [trace, setTrace] = useState(null);
|
|
5380
|
-
const [traces, setTraces] = useState(initialTraces || []);
|
|
5381
5390
|
const [currentTraceIndex, setCurrentTraceIndex] = useState(0);
|
|
5382
5391
|
const [span, setSpan] = useState(null);
|
|
5383
5392
|
const nextTrace = () => {
|
|
@@ -5414,7 +5423,6 @@ function TraceProvider({
|
|
|
5414
5423
|
trace,
|
|
5415
5424
|
setTrace,
|
|
5416
5425
|
traces,
|
|
5417
|
-
setTraces,
|
|
5418
5426
|
currentTraceIndex,
|
|
5419
5427
|
setCurrentTraceIndex,
|
|
5420
5428
|
nextTrace,
|
|
@@ -5539,9 +5547,6 @@ const toSigFigs = (num, sigFigs) => {
|
|
|
5539
5547
|
return Number(num.toPrecision(sigFigs));
|
|
5540
5548
|
};
|
|
5541
5549
|
|
|
5542
|
-
const TracesTableSkeleton = ({ colsCount }) => {
|
|
5543
|
-
return /* @__PURE__ */ jsx(Tbody, { children: /* @__PURE__ */ jsx(Row, { children: Array.from({ length: colsCount }).map((_, index) => /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "w-1/2" }) }, index)) }) });
|
|
5544
|
-
};
|
|
5545
5550
|
const TracesTableEmpty = ({ colsCount }) => {
|
|
5546
5551
|
return /* @__PURE__ */ jsx(Tbody, { children: /* @__PURE__ */ jsx(Row, { children: /* @__PURE__ */ jsx(Cell, { colSpan: colsCount, className: "text-center py-4", children: /* @__PURE__ */ jsx(Txt, { children: "No traces found" }) }) }) });
|
|
5547
5552
|
};
|
|
@@ -5562,7 +5567,7 @@ const TraceRow = ({ trace, index, isActive }) => {
|
|
|
5562
5567
|
/* @__PURE__ */ jsx(Cell, { children: hasFailure ? /* @__PURE__ */ jsx(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsx(X, {}), children: "Failed" }) : /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(Check, {}), variant: "success", children: "Success" }) })
|
|
5563
5568
|
] });
|
|
5564
5569
|
};
|
|
5565
|
-
const TracesTable = ({ traces,
|
|
5570
|
+
const TracesTable = ({ traces, error }) => {
|
|
5566
5571
|
const hasNoTraces = !traces || traces.length === 0;
|
|
5567
5572
|
const { currentTraceIndex } = useContext(TraceContext);
|
|
5568
5573
|
const colsCount = 4;
|
|
@@ -5574,7 +5579,7 @@ const TracesTable = ({ traces, isLoading, error }) => {
|
|
|
5574
5579
|
/* @__PURE__ */ jsx(Th, { width: 120, children: "Spans" }),
|
|
5575
5580
|
/* @__PURE__ */ jsx(Th, { width: 120, children: "Status" })
|
|
5576
5581
|
] }),
|
|
5577
|
-
|
|
5582
|
+
error ? /* @__PURE__ */ jsx(TracesTableError, { error, colsCount }) : hasNoTraces ? /* @__PURE__ */ jsx(TracesTableEmpty, { colsCount }) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Tbody, { children: traces.map((trace, index) => /* @__PURE__ */ jsx(TraceRow, { trace, index, isActive: index === currentTraceIndex }, trace.traceId)) }) })
|
|
5578
5583
|
] });
|
|
5579
5584
|
};
|
|
5580
5585
|
|
|
@@ -6182,14 +6187,14 @@ const TracesSidebar = ({ onResize }) => {
|
|
|
6182
6187
|
);
|
|
6183
6188
|
};
|
|
6184
6189
|
|
|
6185
|
-
function AgentTraces({ className, traces,
|
|
6186
|
-
return /* @__PURE__ */ jsx(AgentTracesInner, { className, traces,
|
|
6190
|
+
function AgentTraces({ className, traces, error }) {
|
|
6191
|
+
return /* @__PURE__ */ jsx(TraceProvider, { initialTraces: traces || [], children: /* @__PURE__ */ jsx(AgentTracesInner, { className, traces, error }) });
|
|
6187
6192
|
}
|
|
6188
|
-
function AgentTracesInner({ className, traces,
|
|
6193
|
+
function AgentTracesInner({ className, traces, error }) {
|
|
6189
6194
|
const [sidebarWidth, setSidebarWidth] = useState(100);
|
|
6190
6195
|
const { isOpen: open } = useContext(TraceContext);
|
|
6191
6196
|
return /* @__PURE__ */ jsxs("div", { className: clsx("h-full relative overflow-hidden flex", className), children: [
|
|
6192
|
-
/* @__PURE__ */ jsx("div", { className: "h-full overflow-y-scroll w-full", children: /* @__PURE__ */ jsx(TracesTable, { traces,
|
|
6197
|
+
/* @__PURE__ */ jsx("div", { className: "h-full overflow-y-scroll w-full", children: /* @__PURE__ */ jsx(TracesTable, { traces, error }) }),
|
|
6193
6198
|
open && /* @__PURE__ */ jsx(TracesSidebar, { width: sidebarWidth, onResize: setSidebarWidth })
|
|
6194
6199
|
] });
|
|
6195
6200
|
}
|
|
@@ -6203,7 +6208,6 @@ function MastraNetworkRuntimeProvider({
|
|
|
6203
6208
|
initialMessages,
|
|
6204
6209
|
memory,
|
|
6205
6210
|
threadId,
|
|
6206
|
-
baseUrl,
|
|
6207
6211
|
refreshThreadList,
|
|
6208
6212
|
modelSettings = {}
|
|
6209
6213
|
}) {
|
|
@@ -6219,7 +6223,7 @@ function MastraNetworkRuntimeProvider({
|
|
|
6219
6223
|
}
|
|
6220
6224
|
}
|
|
6221
6225
|
}, [initialMessages, threadId, memory, messages]);
|
|
6222
|
-
const mastra =
|
|
6226
|
+
const mastra = useMastraClient();
|
|
6223
6227
|
const network = mastra.getNetwork(agentId);
|
|
6224
6228
|
const onNew = async (message) => {
|
|
6225
6229
|
if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
|
|
@@ -6641,10 +6645,10 @@ const NetworkChat = ({ agentId, memory }) => {
|
|
|
6641
6645
|
return /* @__PURE__ */ jsx(MastraNetworkRuntimeProvider, { agentId, memory, modelSettings, children: /* @__PURE__ */ jsx("div", { className: "h-full pb-4", children: /* @__PURE__ */ jsx(Thread, { ToolFallback }) }) });
|
|
6642
6646
|
};
|
|
6643
6647
|
|
|
6644
|
-
function WorkflowTraces({ traces,
|
|
6645
|
-
return /* @__PURE__ */ jsx(
|
|
6648
|
+
function WorkflowTraces({ traces, error, runId, stepName }) {
|
|
6649
|
+
return /* @__PURE__ */ jsx(TraceProvider, { initialTraces: traces || [], children: /* @__PURE__ */ jsx(WorkflowTracesInner, { traces, error, runId, stepName }) });
|
|
6646
6650
|
}
|
|
6647
|
-
function WorkflowTracesInner({ traces,
|
|
6651
|
+
function WorkflowTracesInner({ traces, error, runId, stepName }) {
|
|
6648
6652
|
const hasRunRef = useRef(false);
|
|
6649
6653
|
const [sidebarWidth, setSidebarWidth] = useState(100);
|
|
6650
6654
|
const { isOpen: open, setTrace, setIsOpen, setSpan } = useContext(TraceContext);
|
|
@@ -6661,7 +6665,7 @@ function WorkflowTracesInner({ traces, isLoading, error, runId, stepName }) {
|
|
|
6661
6665
|
hasRunRef.current = true;
|
|
6662
6666
|
}, [runId, traces, setTrace]);
|
|
6663
6667
|
return /* @__PURE__ */ jsxs("main", { className: "h-full relative overflow-hidden flex", children: [
|
|
6664
|
-
/* @__PURE__ */ jsx("div", { className: "h-full overflow-y-scroll w-full", children: /* @__PURE__ */ jsx(TracesTable, { traces,
|
|
6668
|
+
/* @__PURE__ */ jsx("div", { className: "h-full overflow-y-scroll w-full", children: /* @__PURE__ */ jsx(TracesTable, { traces, error }) }),
|
|
6665
6669
|
open && /* @__PURE__ */ jsx(TracesSidebar, { width: sidebarWidth, onResize: setSidebarWidth })
|
|
6666
6670
|
] });
|
|
6667
6671
|
}
|
|
@@ -6701,10 +6705,10 @@ const sanitizeWorkflowWatchResult = (record) => {
|
|
|
6701
6705
|
};
|
|
6702
6706
|
return sanitizedRecord;
|
|
6703
6707
|
};
|
|
6704
|
-
const useLegacyWorkflow = (workflowId
|
|
6708
|
+
const useLegacyWorkflow = (workflowId) => {
|
|
6705
6709
|
const [legacyWorkflow, setLegacyWorkflow] = useState(null);
|
|
6706
6710
|
const [isLoading, setIsLoading] = useState(true);
|
|
6707
|
-
const client =
|
|
6711
|
+
const client = useMastraClient();
|
|
6708
6712
|
useEffect(() => {
|
|
6709
6713
|
const fetchWorkflow = async () => {
|
|
6710
6714
|
setIsLoading(true);
|
|
@@ -6746,10 +6750,10 @@ const useLegacyWorkflow = (workflowId, baseUrl) => {
|
|
|
6746
6750
|
}, [workflowId]);
|
|
6747
6751
|
return { legacyWorkflow, isLoading };
|
|
6748
6752
|
};
|
|
6749
|
-
const useWorkflow = (workflowId
|
|
6753
|
+
const useWorkflow = (workflowId) => {
|
|
6750
6754
|
const [workflow, setWorkflow] = useState(null);
|
|
6751
6755
|
const [isLoading, setIsLoading] = useState(true);
|
|
6752
|
-
const client =
|
|
6756
|
+
const client = useMastraClient();
|
|
6753
6757
|
useEffect(() => {
|
|
6754
6758
|
const fetchWorkflow = async () => {
|
|
6755
6759
|
setIsLoading(true);
|
|
@@ -6773,8 +6777,8 @@ const useWorkflow = (workflowId, baseUrl) => {
|
|
|
6773
6777
|
}, [workflowId]);
|
|
6774
6778
|
return { workflow, isLoading };
|
|
6775
6779
|
};
|
|
6776
|
-
const useExecuteWorkflow = (
|
|
6777
|
-
const client =
|
|
6780
|
+
const useExecuteWorkflow = () => {
|
|
6781
|
+
const client = useMastraClient();
|
|
6778
6782
|
const createLegacyWorkflowRun = async ({ workflowId, prevRunId }) => {
|
|
6779
6783
|
try {
|
|
6780
6784
|
const workflow = client.getLegacyWorkflow(workflowId);
|
|
@@ -6853,11 +6857,12 @@ const useExecuteWorkflow = (baseUrl) => {
|
|
|
6853
6857
|
startAsyncWorkflowRun
|
|
6854
6858
|
};
|
|
6855
6859
|
};
|
|
6856
|
-
const useWatchWorkflow = (
|
|
6860
|
+
const useWatchWorkflow = () => {
|
|
6857
6861
|
const [isWatchingLegacyWorkflow, setIsWatchingLegacyWorkflow] = useState(false);
|
|
6858
6862
|
const [isWatchingWorkflow, setIsWatchingWorkflow] = useState(false);
|
|
6859
6863
|
const [legacyWatchResult, setLegacyWatchResult] = useState(null);
|
|
6860
6864
|
const [watchResult, setWatchResult] = useState(null);
|
|
6865
|
+
const client = useMastraClient();
|
|
6861
6866
|
const debouncedSetLegacyWorkflowWatchResult = useDebouncedCallback((record) => {
|
|
6862
6867
|
const formattedResults = Object.entries(record.results || {}).reduce(
|
|
6863
6868
|
(acc, [key, value]) => {
|
|
@@ -6886,7 +6891,6 @@ const useWatchWorkflow = (baseUrl) => {
|
|
|
6886
6891
|
const watchLegacyWorkflow = async ({ workflowId, runId }) => {
|
|
6887
6892
|
try {
|
|
6888
6893
|
setIsWatchingLegacyWorkflow(true);
|
|
6889
|
-
const client = createMastraClient(baseUrl);
|
|
6890
6894
|
const workflow = client.getLegacyWorkflow(workflowId);
|
|
6891
6895
|
await workflow.watch({ runId }, (record) => {
|
|
6892
6896
|
try {
|
|
@@ -6912,7 +6916,6 @@ const useWatchWorkflow = (baseUrl) => {
|
|
|
6912
6916
|
const watchWorkflow = async ({ workflowId, runId }) => {
|
|
6913
6917
|
try {
|
|
6914
6918
|
setIsWatchingWorkflow(true);
|
|
6915
|
-
const client = createMastraClient(baseUrl);
|
|
6916
6919
|
const workflow = client.getWorkflow(workflowId);
|
|
6917
6920
|
await workflow.watch({ runId }, (record) => {
|
|
6918
6921
|
try {
|
|
@@ -6940,9 +6943,10 @@ const useWatchWorkflow = (baseUrl) => {
|
|
|
6940
6943
|
watchResult
|
|
6941
6944
|
};
|
|
6942
6945
|
};
|
|
6943
|
-
const useResumeWorkflow = (
|
|
6946
|
+
const useResumeWorkflow = () => {
|
|
6944
6947
|
const [isResumingLegacyWorkflow, setIsResumingLegacyWorkflow] = useState(false);
|
|
6945
6948
|
const [isResumingWorkflow, setIsResumingWorkflow] = useState(false);
|
|
6949
|
+
const client = useMastraClient();
|
|
6946
6950
|
const resumeLegacyWorkflow = async ({
|
|
6947
6951
|
workflowId,
|
|
6948
6952
|
stepId,
|
|
@@ -6951,7 +6955,6 @@ const useResumeWorkflow = (baseUrl) => {
|
|
|
6951
6955
|
}) => {
|
|
6952
6956
|
try {
|
|
6953
6957
|
setIsResumingLegacyWorkflow(true);
|
|
6954
|
-
const client = createMastraClient(baseUrl);
|
|
6955
6958
|
const response = await client.getLegacyWorkflow(workflowId).resume({ stepId, runId, context });
|
|
6956
6959
|
return response;
|
|
6957
6960
|
} catch (error) {
|
|
@@ -6970,7 +6973,6 @@ const useResumeWorkflow = (baseUrl) => {
|
|
|
6970
6973
|
}) => {
|
|
6971
6974
|
try {
|
|
6972
6975
|
setIsResumingWorkflow(true);
|
|
6973
|
-
const client = createMastraClient(baseUrl);
|
|
6974
6976
|
const runtimeContext = new RuntimeContext$1();
|
|
6975
6977
|
Object.entries(playgroundRuntimeContext).forEach(([key, value]) => {
|
|
6976
6978
|
runtimeContext.set(key, value);
|
|
@@ -8253,8 +8255,8 @@ const lodashTitleCase = (str) => {
|
|
|
8253
8255
|
return camelCased.replace(/([A-Z])/g, " $1").replace(/^./, (str2) => str2.toUpperCase()).trim();
|
|
8254
8256
|
};
|
|
8255
8257
|
|
|
8256
|
-
function LegacyWorkflowGraph({ workflowId
|
|
8257
|
-
const { legacyWorkflow, isLoading } = useLegacyWorkflow(workflowId
|
|
8258
|
+
function LegacyWorkflowGraph({ workflowId }) {
|
|
8259
|
+
const { legacyWorkflow, isLoading } = useLegacyWorkflow(workflowId);
|
|
8258
8260
|
if (isLoading) {
|
|
8259
8261
|
return /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[600px]" }) });
|
|
8260
8262
|
}
|
|
@@ -9126,18 +9128,17 @@ const WorkflowResult = ({ jsonResult, sanitizedJsonResult }) => {
|
|
|
9126
9128
|
|
|
9127
9129
|
function LegacyWorkflowTrigger({
|
|
9128
9130
|
workflowId,
|
|
9129
|
-
baseUrl,
|
|
9130
9131
|
setRunId
|
|
9131
9132
|
}) {
|
|
9132
9133
|
const { legacyResult: result, setLegacyResult: setResult, payload, setPayload } = useContext(WorkflowRunContext);
|
|
9133
|
-
const { isLoading, legacyWorkflow: workflow } = useLegacyWorkflow(workflowId
|
|
9134
|
-
const { createLegacyWorkflowRun: createWorkflowRun, startLegacyWorkflowRun: startWorkflowRun } = useExecuteWorkflow(
|
|
9134
|
+
const { isLoading, legacyWorkflow: workflow } = useLegacyWorkflow(workflowId);
|
|
9135
|
+
const { createLegacyWorkflowRun: createWorkflowRun, startLegacyWorkflowRun: startWorkflowRun } = useExecuteWorkflow();
|
|
9135
9136
|
const {
|
|
9136
9137
|
watchLegacyWorkflow: watchWorkflow,
|
|
9137
9138
|
legacyWatchResult: watchResult,
|
|
9138
9139
|
isWatchingLegacyWorkflow: isWatchingWorkflow
|
|
9139
|
-
} = useWatchWorkflow(
|
|
9140
|
-
const { resumeLegacyWorkflow: resumeWorkflow, isResumingLegacyWorkflow: isResumingWorkflow } = useResumeWorkflow(
|
|
9140
|
+
} = useWatchWorkflow();
|
|
9141
|
+
const { resumeLegacyWorkflow: resumeWorkflow, isResumingLegacyWorkflow: isResumingWorkflow } = useResumeWorkflow();
|
|
9141
9142
|
const [suspendedSteps, setSuspendedSteps] = useState([]);
|
|
9142
9143
|
const [isRunning, setIsRunning] = useState(false);
|
|
9143
9144
|
const triggerSchema = workflow?.triggerSchema;
|
|
@@ -9562,8 +9563,8 @@ function WorkflowGraphInner({ workflow, onShowTrace }) {
|
|
|
9562
9563
|
) });
|
|
9563
9564
|
}
|
|
9564
9565
|
|
|
9565
|
-
function WorkflowGraph({ workflowId,
|
|
9566
|
-
const { workflow, isLoading } = useWorkflow(workflowId
|
|
9566
|
+
function WorkflowGraph({ workflowId, onShowTrace }) {
|
|
9567
|
+
const { workflow, isLoading } = useWorkflow(workflowId);
|
|
9567
9568
|
if (isLoading) {
|
|
9568
9569
|
return /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[600px]" }) });
|
|
9569
9570
|
}
|
|
@@ -9597,17 +9598,13 @@ const WorkflowStatus = ({ stepId, status }) => {
|
|
|
9597
9598
|
);
|
|
9598
9599
|
};
|
|
9599
9600
|
|
|
9600
|
-
function WorkflowTrigger({
|
|
9601
|
-
workflowId,
|
|
9602
|
-
baseUrl,
|
|
9603
|
-
setRunId
|
|
9604
|
-
}) {
|
|
9601
|
+
function WorkflowTrigger({ workflowId, setRunId }) {
|
|
9605
9602
|
const { runtimeContext } = usePlaygroundStore();
|
|
9606
9603
|
const { result, setResult, payload, setPayload } = useContext(WorkflowRunContext);
|
|
9607
|
-
const { isLoading, workflow } = useWorkflow(workflowId
|
|
9608
|
-
const { createWorkflowRun, startWorkflowRun } = useExecuteWorkflow(
|
|
9609
|
-
const { watchWorkflow, watchResult, isWatchingWorkflow } = useWatchWorkflow(
|
|
9610
|
-
const { resumeWorkflow, isResumingWorkflow } = useResumeWorkflow(
|
|
9604
|
+
const { isLoading, workflow } = useWorkflow(workflowId);
|
|
9605
|
+
const { createWorkflowRun, startWorkflowRun } = useExecuteWorkflow();
|
|
9606
|
+
const { watchWorkflow, watchResult, isWatchingWorkflow } = useWatchWorkflow();
|
|
9607
|
+
const { resumeWorkflow, isResumingWorkflow } = useResumeWorkflow();
|
|
9611
9608
|
const [suspendedSteps, setSuspendedSteps] = useState([]);
|
|
9612
9609
|
const [isRunning, setIsRunning] = useState(false);
|
|
9613
9610
|
const triggerSchema = workflow?.inputSchema;
|
|
@@ -10097,10 +10094,9 @@ function usePolling({
|
|
|
10097
10094
|
};
|
|
10098
10095
|
}
|
|
10099
10096
|
|
|
10100
|
-
const useTraces = (componentName,
|
|
10097
|
+
const useTraces = (componentName, isWorkflow = false) => {
|
|
10101
10098
|
const [traces, setTraces] = useState([]);
|
|
10102
|
-
const
|
|
10103
|
-
const client = useMemo(() => createMastraClient(baseUrl), [baseUrl]);
|
|
10099
|
+
const client = useMemo(() => useMastraClient(), []);
|
|
10104
10100
|
const fetchFn = useCallback(async () => {
|
|
10105
10101
|
try {
|
|
10106
10102
|
const res = await client.getTelemetry({
|
|
@@ -10117,15 +10113,11 @@ const useTraces = (componentName, baseUrl, isWorkflow = false) => {
|
|
|
10117
10113
|
throw error2;
|
|
10118
10114
|
}
|
|
10119
10115
|
}, [client, componentName, isWorkflow]);
|
|
10120
|
-
const onSuccess = useCallback(
|
|
10121
|
-
(newTraces)
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
}
|
|
10126
|
-
},
|
|
10127
|
-
[setTraceContextTraces]
|
|
10128
|
-
);
|
|
10116
|
+
const onSuccess = useCallback((newTraces) => {
|
|
10117
|
+
if (newTraces.length > 0) {
|
|
10118
|
+
setTraces(() => newTraces);
|
|
10119
|
+
}
|
|
10120
|
+
}, []);
|
|
10129
10121
|
const onError = useCallback((error2) => {
|
|
10130
10122
|
console.log(`error, onError`, error2);
|
|
10131
10123
|
toast.error(error2.message);
|
|
@@ -10144,5 +10136,5 @@ const useTraces = (componentName, baseUrl, isWorkflow = false) => {
|
|
|
10144
10136
|
return { traces, firstCallLoading, error };
|
|
10145
10137
|
};
|
|
10146
10138
|
|
|
10147
|
-
export { AgentChat, AgentCoinIcon, AgentContext, AgentEvals, AgentIcon, AgentNetworkCoinIcon, AgentProvider, AgentTraces, AiIcon, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button, Cell, CheckIcon, ChevronIcon, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DbIcon, DebugIcon, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityIcon, EntityName, EntryCell, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, JudgeIcon, LatencyIcon, LegacyWorkflowGraph, LegacyWorkflowTrigger, LogsIcon, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, NetworkChat, NetworkContext, NetworkProvider, OpenAIIcon, PromptIcon, RepoIcon, Row, ScoreIcon, SettingsIcon, SlashIcon, Table, Tbody, Th, Thead, ThreadDeleteButton, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolsIcon,
|
|
10139
|
+
export { AgentChat, AgentCoinIcon, AgentContext, AgentEvals, AgentIcon, AgentNetworkCoinIcon, AgentProvider, AgentTraces, AiIcon, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button, Cell, CheckIcon, ChevronIcon, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DbIcon, DebugIcon, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityIcon, EntityName, EntryCell, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, JudgeIcon, LatencyIcon, LegacyWorkflowGraph, LegacyWorkflowTrigger, LogsIcon, MastraClientProvider, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, NetworkChat, NetworkContext, NetworkProvider, OpenAIIcon, PromptIcon, RepoIcon, Row, ScoreIcon, SettingsIcon, SlashIcon, Table, Tbody, Th, Thead, ThreadDeleteButton, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolsIcon, TraceIcon, TsIcon, Txt, TxtCell, UnitCell, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunProvider, WorkflowTraces, WorkflowTrigger, refineTraces, useCurrentRun, useMastraClient, usePlaygroundStore, usePolling, useSpeechRecognition, useTraces };
|
|
10148
10140
|
//# sourceMappingURL=index.es.js.map
|