@mastra/playground-ui 5.1.14-alpha.0 → 5.1.14-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/{colors-CD-k9ILs.cjs → colors-DLwJ7rFA.cjs} +12 -2
- package/dist/colors-DLwJ7rFA.cjs.map +1 -0
- package/dist/{colors-B25-HzLf.js → colors-DrbbnW3f.js} +12 -2
- package/dist/colors-DrbbnW3f.js.map +1 -0
- package/dist/index.cjs.js +2503 -1606
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +2464 -1607
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/assistant-ui/memory-search.d.ts +11 -0
- package/dist/src/components/assistant-ui/thread.d.ts +2 -1
- package/dist/src/components/ui/alert-dialog.d.ts +26 -0
- package/dist/src/components/ui/entity-header.d.ts +7 -0
- package/dist/src/components/ui/playground-tabs.d.ts +22 -0
- package/dist/src/domains/agents/components/agent-chat.d.ts +1 -1
- package/dist/src/domains/agents/components/agent-entity-header.d.ts +6 -0
- package/dist/src/domains/agents/components/agent-metadata/agent-metadata-list.d.ts +12 -0
- package/dist/src/domains/agents/components/agent-metadata/agent-metadata-prompt.d.ts +4 -0
- package/dist/src/domains/agents/components/agent-metadata/agent-metadata-section.d.ts +9 -0
- package/dist/src/domains/agents/components/agent-metadata/agent-metadata-wrapper.d.ts +4 -0
- package/dist/src/domains/agents/components/agent-metadata/agent-metadata.d.ts +24 -0
- package/dist/src/domains/agents/components/agent-metadata/index.d.ts +5 -0
- package/dist/src/domains/agents/components/chat-threads.d.ts +11 -0
- package/dist/src/domains/agents/index.d.ts +3 -1
- package/dist/src/domains/scores/components/scorer-list.d.ts +9 -0
- package/dist/src/domains/scores/hooks/use-scorers.d.ts +25 -0
- package/dist/src/domains/scores/index.d.ts +2 -0
- package/dist/src/domains/traces/{traces-table.d.ts → components/traces-table.d.ts} +1 -1
- package/dist/src/domains/traces/components/traces-view.d.ts +13 -0
- package/dist/src/domains/traces/index.d.ts +2 -0
- package/dist/src/domains/workflows/index.d.ts +0 -1
- package/dist/src/domains/workflows/workflow/workflow-step-action-bar.d.ts +2 -1
- package/dist/src/ds/tokens/colors.d.ts +10 -0
- package/dist/src/hooks/index.d.ts +1 -0
- package/dist/src/hooks/use-in-view.d.ts +9 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/lib/tanstack-query.d.ts +4 -0
- package/dist/src/types/memory.d.ts +29 -0
- package/dist/src/types.d.ts +1 -0
- package/dist/tokens.cjs.js +1 -1
- package/dist/tokens.es.js +1 -1
- package/package.json +5 -5
- package/dist/colors-B25-HzLf.js.map +0 -1
- package/dist/colors-CD-k9ILs.cjs.map +0 -1
- package/dist/src/domains/agents/components/agent-traces.d.ts +0 -10
- package/dist/src/domains/workflows/workflow/workflow-traces.d.ts +0 -11
- package/dist/src/main.d.ts +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -26,9 +26,8 @@ const di = require('@mastra/core/di');
|
|
|
26
26
|
const zustand = require('zustand');
|
|
27
27
|
const middleware = require('zustand/middleware');
|
|
28
28
|
const dateFns = require('date-fns');
|
|
29
|
-
const TabsPrimitive = require('@radix-ui/react-tabs');
|
|
30
29
|
const react$1 = require('motion/react');
|
|
31
|
-
const
|
|
30
|
+
const TabsPrimitive = require('@radix-ui/react-tabs');
|
|
32
31
|
const SliderPrimitive = require('@radix-ui/react-slider');
|
|
33
32
|
const LabelPrimitive = require('@radix-ui/react-label');
|
|
34
33
|
const RadioGroupPrimitive = require('@radix-ui/react-radio-group');
|
|
@@ -36,7 +35,9 @@ const CollapsiblePrimitive = require('@radix-ui/react-collapsible');
|
|
|
36
35
|
const prettier = require('prettier');
|
|
37
36
|
const prettierPluginBabel = require('prettier/plugins/babel');
|
|
38
37
|
const prettierPluginEstree = require('prettier/plugins/estree');
|
|
38
|
+
const colors = require('./colors-DLwJ7rFA.cjs');
|
|
39
39
|
const reactTable = require('@tanstack/react-table');
|
|
40
|
+
const AlertDialogPrimitive = require('@radix-ui/react-alert-dialog');
|
|
40
41
|
const uiUtils = require('@ai-sdk/ui-utils');
|
|
41
42
|
const Markdown = require('react-markdown');
|
|
42
43
|
const react$2 = require('@xyflow/react');
|
|
@@ -57,6 +58,7 @@ const PopoverPrimitive = require('@radix-ui/react-popover');
|
|
|
57
58
|
const SelectPrimitive = require('@radix-ui/react-select');
|
|
58
59
|
const zod = require('@autoform/zod');
|
|
59
60
|
const reactCodeBlock = require('react-code-block');
|
|
61
|
+
const reactQuery = require('@tanstack/react-query');
|
|
60
62
|
|
|
61
63
|
function _interopNamespaceDefault(e) {
|
|
62
64
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
@@ -84,6 +86,7 @@ const SliderPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SliderP
|
|
|
84
86
|
const LabelPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(LabelPrimitive);
|
|
85
87
|
const RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(RadioGroupPrimitive);
|
|
86
88
|
const CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(CollapsiblePrimitive);
|
|
89
|
+
const AlertDialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(AlertDialogPrimitive);
|
|
87
90
|
const ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(ScrollAreaPrimitive);
|
|
88
91
|
const CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(CheckboxPrimitive);
|
|
89
92
|
const PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(PopoverPrimitive);
|
|
@@ -4402,8 +4405,9 @@ const Reasoning = ({ text }) => {
|
|
|
4402
4405
|
|
|
4403
4406
|
const AssistantMessage = ({ ToolFallback: ToolFallbackCustom }) => {
|
|
4404
4407
|
const data = react.useMessage();
|
|
4408
|
+
const messageId = data.id;
|
|
4405
4409
|
const isToolCallAndOrReasoning = data.content.every(({ type }) => type === "tool-call" || type === "reasoning");
|
|
4406
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(react.MessagePrimitive.Root, { className: "max-w-full", children: [
|
|
4410
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.MessagePrimitive.Root, { className: "max-w-full", "data-message-id": messageId, children: [
|
|
4407
4411
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-icon6 text-ui-lg leading-ui-lg", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4408
4412
|
react.MessagePrimitive.Content,
|
|
4409
4413
|
{
|
|
@@ -4603,7 +4607,9 @@ const UserMessageAttachments = () => {
|
|
|
4603
4607
|
return /* @__PURE__ */ jsxRuntime.jsx(react.MessagePrimitive.Attachments, { components: { Attachment: InMessageContextWrapper } });
|
|
4604
4608
|
};
|
|
4605
4609
|
const UserMessage = () => {
|
|
4606
|
-
|
|
4610
|
+
const message = react.useMessage();
|
|
4611
|
+
const messageId = message?.id;
|
|
4612
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.MessagePrimitive.Root, { className: "w-full flex items-end pb-4 flex-col", "data-message-id": messageId, children: [
|
|
4607
4613
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-[366px] px-5 py-3 text-icon6 text-ui-lg leading-ui-lg rounded-lg bg-surface3", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4608
4614
|
react.MessagePrimitive.Content,
|
|
4609
4615
|
{
|
|
@@ -4864,7 +4870,7 @@ const ComposerAttachments = () => {
|
|
|
4864
4870
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full flex-row items-center gap-4 pb-2", children: /* @__PURE__ */ jsxRuntime.jsx(react.ComposerPrimitive.Attachments, { components: { Attachment: AttachmentThumbnail } }) });
|
|
4865
4871
|
};
|
|
4866
4872
|
|
|
4867
|
-
const Thread = ({ ToolFallback, agentName, hasMemory }) => {
|
|
4873
|
+
const Thread = ({ ToolFallback, agentName, hasMemory, onInputChange }) => {
|
|
4868
4874
|
const areaRef = React.useRef(null);
|
|
4869
4875
|
useAutoscroll(areaRef, { enabled: true });
|
|
4870
4876
|
const WrappedAssistantMessage = (props) => {
|
|
@@ -4885,7 +4891,7 @@ const Thread = ({ ToolFallback, agentName, hasMemory }) => {
|
|
|
4885
4891
|
) }),
|
|
4886
4892
|
/* @__PURE__ */ jsxRuntime.jsx(react.ThreadPrimitive.If, { empty: false, children: /* @__PURE__ */ jsxRuntime.jsx("div", {}) })
|
|
4887
4893
|
] }),
|
|
4888
|
-
/* @__PURE__ */ jsxRuntime.jsx(Composer$1, { hasMemory })
|
|
4894
|
+
/* @__PURE__ */ jsxRuntime.jsx(Composer$1, { hasMemory, onInputChange })
|
|
4889
4895
|
] });
|
|
4890
4896
|
};
|
|
4891
4897
|
const ThreadWrapper$1 = ({ children }) => {
|
|
@@ -4907,7 +4913,7 @@ const ThreadWelcome$1 = ({ agentName }) => {
|
|
|
4907
4913
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-4 font-medium", children: "How can I help you today?" })
|
|
4908
4914
|
] }) });
|
|
4909
4915
|
};
|
|
4910
|
-
const Composer$1 = ({ hasMemory }) => {
|
|
4916
|
+
const Composer$1 = ({ hasMemory, onInputChange }) => {
|
|
4911
4917
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-4", children: [
|
|
4912
4918
|
/* @__PURE__ */ jsxRuntime.jsxs(react.ComposerPrimitive.Root, { children: [
|
|
4913
4919
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-[568px] w-full mx-auto pb-2", children: /* @__PURE__ */ jsxRuntime.jsx(ComposerAttachments, {}) }),
|
|
@@ -4919,7 +4925,8 @@ const Composer$1 = ({ hasMemory }) => {
|
|
|
4919
4925
|
autoFocus: true,
|
|
4920
4926
|
placeholder: "Enter your message...",
|
|
4921
4927
|
name: "",
|
|
4922
|
-
id: ""
|
|
4928
|
+
id: "",
|
|
4929
|
+
onChange: (e) => onInputChange?.(e.target.value)
|
|
4923
4930
|
}
|
|
4924
4931
|
) }),
|
|
4925
4932
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
@@ -5195,6 +5202,7 @@ function MastraRuntimeProvider({
|
|
|
5195
5202
|
const [messages, setMessages] = React.useState([]);
|
|
5196
5203
|
const [currentThreadId, setCurrentThreadId] = React.useState(threadId);
|
|
5197
5204
|
const { refetch: refreshWorkingMemory } = useWorkingMemory();
|
|
5205
|
+
const abortControllerRef = React.useRef(null);
|
|
5198
5206
|
const {
|
|
5199
5207
|
frequencyPenalty,
|
|
5200
5208
|
presencePenalty,
|
|
@@ -5246,8 +5254,7 @@ function MastraRuntimeProvider({
|
|
|
5246
5254
|
}
|
|
5247
5255
|
}
|
|
5248
5256
|
}, [initialMessages, threadId, memory]);
|
|
5249
|
-
const
|
|
5250
|
-
const agent = mastra.getAgent(agentId);
|
|
5257
|
+
const baseClient = useMastraClient();
|
|
5251
5258
|
const onNew = async (message) => {
|
|
5252
5259
|
if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
|
|
5253
5260
|
const attachments = await convertToAIAttachments(message.attachments);
|
|
@@ -5257,6 +5264,13 @@ function MastraRuntimeProvider({
|
|
|
5257
5264
|
{ role: "user", content: input, attachments: message.attachments }
|
|
5258
5265
|
]);
|
|
5259
5266
|
setIsRunning(true);
|
|
5267
|
+
const controller = new AbortController();
|
|
5268
|
+
abortControllerRef.current = controller;
|
|
5269
|
+
const clientWithAbort = new clientJs.MastraClient({
|
|
5270
|
+
...baseClient.options,
|
|
5271
|
+
abortSignal: controller.signal
|
|
5272
|
+
});
|
|
5273
|
+
const agent = clientWithAbort.getAgent(agentId);
|
|
5260
5274
|
try {
|
|
5261
5275
|
if (chatWithGenerate) {
|
|
5262
5276
|
const generateResponse = await agent.generate({
|
|
@@ -5281,7 +5295,7 @@ function MastraRuntimeProvider({
|
|
|
5281
5295
|
...memory ? { threadId, resourceId: agentId } : {},
|
|
5282
5296
|
providerOptions
|
|
5283
5297
|
});
|
|
5284
|
-
if (generateResponse.response) {
|
|
5298
|
+
if (generateResponse.response && "messages" in generateResponse.response) {
|
|
5285
5299
|
const latestMessage = generateResponse.response.messages.reduce(
|
|
5286
5300
|
(acc, message2) => {
|
|
5287
5301
|
const _content = Array.isArray(acc.content) ? acc.content : [];
|
|
@@ -5535,10 +5549,22 @@ function MastraRuntimeProvider({
|
|
|
5535
5549
|
} catch (error) {
|
|
5536
5550
|
console.error("Error occurred in MastraRuntimeProvider", error);
|
|
5537
5551
|
setIsRunning(false);
|
|
5552
|
+
if (error.name === "AbortError") {
|
|
5553
|
+
return;
|
|
5554
|
+
}
|
|
5538
5555
|
setMessages((currentConversation) => [
|
|
5539
5556
|
...currentConversation,
|
|
5540
5557
|
{ role: "assistant", content: [{ type: "text", text: `${error}` }] }
|
|
5541
5558
|
]);
|
|
5559
|
+
} finally {
|
|
5560
|
+
abortControllerRef.current = null;
|
|
5561
|
+
}
|
|
5562
|
+
};
|
|
5563
|
+
const onCancel = async () => {
|
|
5564
|
+
if (abortControllerRef.current) {
|
|
5565
|
+
abortControllerRef.current.abort();
|
|
5566
|
+
abortControllerRef.current = null;
|
|
5567
|
+
setIsRunning(false);
|
|
5542
5568
|
}
|
|
5543
5569
|
};
|
|
5544
5570
|
const runtime = react.useExternalStoreRuntime({
|
|
@@ -5546,6 +5572,7 @@ function MastraRuntimeProvider({
|
|
|
5546
5572
|
messages,
|
|
5547
5573
|
convertMessage: convertMessage$2,
|
|
5548
5574
|
onNew,
|
|
5575
|
+
onCancel,
|
|
5549
5576
|
adapters: {
|
|
5550
5577
|
attachments: new react.CompositeAttachmentAdapter([
|
|
5551
5578
|
new react.SimpleImageAttachmentAdapter(),
|
|
@@ -5632,7 +5659,15 @@ const usePlaygroundStore = zustand.create()(
|
|
|
5632
5659
|
)
|
|
5633
5660
|
);
|
|
5634
5661
|
|
|
5635
|
-
const AgentChat = ({
|
|
5662
|
+
const AgentChat = ({
|
|
5663
|
+
agentId,
|
|
5664
|
+
agentName,
|
|
5665
|
+
threadId,
|
|
5666
|
+
initialMessages,
|
|
5667
|
+
memory,
|
|
5668
|
+
refreshThreadList,
|
|
5669
|
+
onInputChange
|
|
5670
|
+
}) => {
|
|
5636
5671
|
const { settings } = useAgentSettings();
|
|
5637
5672
|
const { runtimeContext } = usePlaygroundStore();
|
|
5638
5673
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5646,7 +5681,7 @@ const AgentChat = ({ agentId, agentName, threadId, initialMessages, memory, refr
|
|
|
5646
5681
|
refreshThreadList,
|
|
5647
5682
|
settings,
|
|
5648
5683
|
runtimeContext,
|
|
5649
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Thread, { agentName: agentName ?? "", hasMemory: memory })
|
|
5684
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Thread, { agentName: agentName ?? "", hasMemory: memory, onInputChange })
|
|
5650
5685
|
}
|
|
5651
5686
|
);
|
|
5652
5687
|
};
|
|
@@ -5800,16 +5835,33 @@ const TableCaption = React__namespace.forwardRef(
|
|
|
5800
5835
|
TableCaption.displayName = "TableCaption";
|
|
5801
5836
|
|
|
5802
5837
|
const Tabs = TabsPrimitive__namespace.Root;
|
|
5803
|
-
const TabsList = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5838
|
+
const TabsList = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5839
|
+
TabsPrimitive__namespace.List,
|
|
5840
|
+
{
|
|
5841
|
+
ref,
|
|
5842
|
+
className: clsx("bg-muted text-muted-foreground inline-flex items-center bg-transparent", className),
|
|
5843
|
+
...props
|
|
5844
|
+
}
|
|
5845
|
+
));
|
|
5804
5846
|
TabsList.displayName = TabsPrimitive__namespace.List.displayName;
|
|
5805
|
-
const TabsTrigger = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5847
|
+
const TabsTrigger = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5848
|
+
TabsPrimitive__namespace.Trigger,
|
|
5849
|
+
{
|
|
5850
|
+
ref,
|
|
5851
|
+
className: cn(
|
|
5852
|
+
"ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground whitespace-nowrap focus-visible:outline-none text-ui-lg text-icon3 -mb-[0.5px] inline-flex items-center justify-center border-b-2 border-transparent p-3 font-medium focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-b-2 data-[state=active]:border-white data-[state=active]:shadow",
|
|
5853
|
+
className
|
|
5854
|
+
),
|
|
5855
|
+
...props
|
|
5856
|
+
}
|
|
5857
|
+
));
|
|
5806
5858
|
TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
|
|
5807
5859
|
const TabsContent = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5808
5860
|
TabsPrimitive__namespace.Content,
|
|
5809
5861
|
{
|
|
5810
5862
|
ref,
|
|
5811
5863
|
className: cn(
|
|
5812
|
-
"
|
|
5864
|
+
"ring-offset-background focus-visible:ring-ring mt-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
5813
5865
|
className
|
|
5814
5866
|
),
|
|
5815
5867
|
...props
|
|
@@ -5817,6 +5869,43 @@ const TabsContent = React__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
5817
5869
|
));
|
|
5818
5870
|
TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
|
|
5819
5871
|
|
|
5872
|
+
const PlaygroundTabs = ({
|
|
5873
|
+
children,
|
|
5874
|
+
defaultTab,
|
|
5875
|
+
value,
|
|
5876
|
+
onValueChange
|
|
5877
|
+
}) => {
|
|
5878
|
+
const [internalTab, setInternalTab] = React.useState(defaultTab);
|
|
5879
|
+
const isControlled = value !== void 0 && onValueChange !== void 0;
|
|
5880
|
+
const currentTab = isControlled ? value : internalTab;
|
|
5881
|
+
const handleTabChange = (newValue) => {
|
|
5882
|
+
const typedValue = newValue;
|
|
5883
|
+
if (isControlled) {
|
|
5884
|
+
onValueChange(typedValue);
|
|
5885
|
+
} else {
|
|
5886
|
+
setInternalTab(typedValue);
|
|
5887
|
+
}
|
|
5888
|
+
};
|
|
5889
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tabs, { value: currentTab, onValueChange: handleTabChange, className: "h-full", children });
|
|
5890
|
+
};
|
|
5891
|
+
const TabList = ({ children }) => {
|
|
5892
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsx(TabsList, { className: "border-b-sm border-border1 flex min-w-full shrink-0", children }) });
|
|
5893
|
+
};
|
|
5894
|
+
const Tab = ({ children, value, onClick }) => {
|
|
5895
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5896
|
+
TabsTrigger,
|
|
5897
|
+
{
|
|
5898
|
+
value,
|
|
5899
|
+
className: "text-xs p-3 text-mastra-el-3 data-[state=active]:text-mastra-el-5 data-[state=active]:border-b-2 whitespace-nowrap flex-shrink-0",
|
|
5900
|
+
onClick,
|
|
5901
|
+
children
|
|
5902
|
+
}
|
|
5903
|
+
);
|
|
5904
|
+
};
|
|
5905
|
+
const TabContent = ({ children, value }) => {
|
|
5906
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value, className: "h-full overflow-hidden flex flex-col", children });
|
|
5907
|
+
};
|
|
5908
|
+
|
|
5820
5909
|
const scrollableContentClass = cn(
|
|
5821
5910
|
"relative overflow-y-auto overflow-x-hidden invisible hover:visible focus:visible",
|
|
5822
5911
|
"[&::-webkit-scrollbar]:w-1",
|
|
@@ -5825,35 +5914,27 @@ const scrollableContentClass = cn(
|
|
|
5825
5914
|
"[&::-webkit-scrollbar-thumb]:bg-mastra-border/20",
|
|
5826
5915
|
"[&>*]:visible"
|
|
5827
5916
|
);
|
|
5828
|
-
|
|
5917
|
+
cn(
|
|
5829
5918
|
"px-4 py-2 text-sm transition-all border-b-2 border-transparent",
|
|
5830
5919
|
"data-[state=active]:border-white data-[state=active]:text-white font-medium",
|
|
5831
5920
|
"data-[state=inactive]:text-mastra-el-4 hover:data-[state=inactive]:text-mastra-el-2",
|
|
5832
5921
|
"focus-visible:outline-none"
|
|
5833
5922
|
);
|
|
5834
|
-
|
|
5923
|
+
cn("data-[state=inactive]:mt-0 min-h-0 h-full grid grid-rows-[1fr]");
|
|
5835
5924
|
function AgentEvals({ liveEvals, ciEvals, onRefetchLiveEvals, onRefetchCiEvals }) {
|
|
5836
5925
|
const [activeTab, setActiveTab] = React.useState("live");
|
|
5837
5926
|
function handleRefresh() {
|
|
5838
5927
|
if (activeTab === "live") return onRefetchLiveEvals();
|
|
5839
5928
|
return onRefetchCiEvals();
|
|
5840
5929
|
}
|
|
5841
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
value:
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "live", className: tabIndicatorClass, children: "Live" }),
|
|
5850
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "ci", className: tabIndicatorClass, children: "CI" })
|
|
5851
|
-
] }) }),
|
|
5852
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "live", className: tabContentClass, children: /* @__PURE__ */ jsxRuntime.jsx(EvalTable, { evals: liveEvals, isCIMode: false, onRefresh: handleRefresh }) }),
|
|
5853
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "ci", className: tabContentClass, children: /* @__PURE__ */ jsxRuntime.jsx(EvalTable, { evals: ciEvals, isCIMode: true, onRefresh: handleRefresh }) })
|
|
5854
|
-
]
|
|
5855
|
-
}
|
|
5856
|
-
);
|
|
5930
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(PlaygroundTabs, { defaultTab: "live", children: [
|
|
5931
|
+
/* @__PURE__ */ jsxRuntime.jsxs(TabList, { children: [
|
|
5932
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tab, { value: "live", children: "Live" }),
|
|
5933
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tab, { value: "ci", children: "CI" })
|
|
5934
|
+
] }),
|
|
5935
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabContent, { value: "live", children: /* @__PURE__ */ jsxRuntime.jsx(EvalTable, { evals: liveEvals, isCIMode: false, onRefresh: handleRefresh }) }),
|
|
5936
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabContent, { value: "ci", children: /* @__PURE__ */ jsxRuntime.jsx(EvalTable, { evals: ciEvals, isCIMode: true, onRefresh: handleRefresh }) })
|
|
5937
|
+
] });
|
|
5857
5938
|
}
|
|
5858
5939
|
function EvalTable({ evals, isCIMode = false, onRefresh }) {
|
|
5859
5940
|
const [expandedMetrics, setExpandedMetrics] = React.useState(/* @__PURE__ */ new Set());
|
|
@@ -6042,907 +6123,170 @@ function EvalTable({ evals, isCIMode = false, onRefresh }) {
|
|
|
6042
6123
|
}
|
|
6043
6124
|
}
|
|
6044
6125
|
|
|
6045
|
-
const
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
const nextTrace2 = traces[nextIndex].trace;
|
|
6059
|
-
setTrace(nextTrace2);
|
|
6060
|
-
const parentSpan = nextTrace2.find((span2) => span2.parentSpanId === null) || nextTrace2[0];
|
|
6061
|
-
setSpan(parentSpan);
|
|
6062
|
-
}
|
|
6063
|
-
};
|
|
6064
|
-
const prevTrace = () => {
|
|
6065
|
-
if (currentTraceIndex > 0) {
|
|
6066
|
-
const prevIndex = currentTraceIndex - 1;
|
|
6067
|
-
setCurrentTraceIndex(prevIndex);
|
|
6068
|
-
const prevTrace2 = traces[prevIndex].trace;
|
|
6069
|
-
setTrace(prevTrace2);
|
|
6070
|
-
const parentSpan = prevTrace2.find((span2) => span2.parentSpanId === null) || prevTrace2[0];
|
|
6071
|
-
setSpan(parentSpan);
|
|
6072
|
-
}
|
|
6073
|
-
};
|
|
6074
|
-
const clearData = () => {
|
|
6075
|
-
setOpen(false);
|
|
6076
|
-
setTrace(null);
|
|
6077
|
-
setSpan(null);
|
|
6078
|
-
};
|
|
6079
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6080
|
-
TraceContext.Provider,
|
|
6081
|
-
{
|
|
6082
|
-
value: {
|
|
6083
|
-
isOpen: open,
|
|
6084
|
-
setIsOpen: setOpen,
|
|
6085
|
-
trace,
|
|
6086
|
-
setTrace,
|
|
6087
|
-
traces,
|
|
6088
|
-
currentTraceIndex,
|
|
6089
|
-
setCurrentTraceIndex,
|
|
6090
|
-
nextTrace,
|
|
6091
|
-
prevTrace,
|
|
6092
|
-
span,
|
|
6093
|
-
setSpan,
|
|
6094
|
-
clearData
|
|
6095
|
-
},
|
|
6096
|
-
children
|
|
6097
|
-
}
|
|
6098
|
-
);
|
|
6099
|
-
}
|
|
6126
|
+
const Slider = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6127
|
+
SliderPrimitive__namespace.Root,
|
|
6128
|
+
{
|
|
6129
|
+
ref,
|
|
6130
|
+
className: cn("relative flex w-full touch-none select-none items-center", className),
|
|
6131
|
+
...props,
|
|
6132
|
+
children: [
|
|
6133
|
+
/* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Track, { className: "relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20", children: /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Range, { className: "absolute h-full bg-primary/50" }) }),
|
|
6134
|
+
/* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Thumb, { className: "block h-4 w-4 rounded-full border border-primary/50 bg-white shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" })
|
|
6135
|
+
]
|
|
6136
|
+
}
|
|
6137
|
+
));
|
|
6138
|
+
Slider.displayName = SliderPrimitive__namespace.Root.displayName;
|
|
6100
6139
|
|
|
6101
|
-
const
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
const
|
|
6106
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6107
|
-
};
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
};
|
|
6111
|
-
const Th = ({ className, children, ...props }) => {
|
|
6140
|
+
const labelVariants = cva("text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
6141
|
+
const Label = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive__namespace.Root, { ref, className: cn(labelVariants(), className), ...props }));
|
|
6142
|
+
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
6143
|
+
|
|
6144
|
+
const RadioGroup = React__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
6145
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Root, { className: cn("grid gap-2", className), ...props, ref });
|
|
6146
|
+
});
|
|
6147
|
+
RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
|
|
6148
|
+
const RadioGroupItem = React__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
6112
6149
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6113
|
-
|
|
6150
|
+
RadioGroupPrimitive__namespace.Item,
|
|
6114
6151
|
{
|
|
6115
|
-
|
|
6116
|
-
|
|
6152
|
+
ref,
|
|
6153
|
+
className: cn(
|
|
6154
|
+
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
6117
6155
|
className
|
|
6118
6156
|
),
|
|
6119
6157
|
...props,
|
|
6120
|
-
children
|
|
6158
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Indicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { className: "h-2.5 w-2.5 fill-current text-current" }) })
|
|
6121
6159
|
}
|
|
6122
6160
|
);
|
|
6161
|
+
});
|
|
6162
|
+
RadioGroupItem.displayName = RadioGroupPrimitive__namespace.Item.displayName;
|
|
6163
|
+
|
|
6164
|
+
const Entry = ({ label, children }) => {
|
|
6165
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
6166
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon3", children: label }),
|
|
6167
|
+
children
|
|
6168
|
+
] });
|
|
6123
6169
|
};
|
|
6124
|
-
|
|
6125
|
-
|
|
6170
|
+
|
|
6171
|
+
const sizeClasses = {
|
|
6172
|
+
md: "h-button-md gap-md",
|
|
6173
|
+
lg: "h-button-lg gap-lg"
|
|
6126
6174
|
};
|
|
6127
|
-
const
|
|
6175
|
+
const variantClasses$1 = {
|
|
6176
|
+
default: "bg-surface2 hover:bg-surface4 text-icon3 hover:text-icon6",
|
|
6177
|
+
light: "bg-surface3 hover:bg-surface5 text-icon6"
|
|
6178
|
+
};
|
|
6179
|
+
const Button = ({ className, as, size = "md", variant = "default", ...props }) => {
|
|
6180
|
+
const Component = as || "button";
|
|
6128
6181
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6129
|
-
|
|
6182
|
+
Component,
|
|
6130
6183
|
{
|
|
6131
6184
|
className: clsx(
|
|
6132
|
-
"border-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
className
|
|
6185
|
+
"bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
|
|
6186
|
+
variantClasses$1[variant],
|
|
6187
|
+
sizeClasses[size],
|
|
6188
|
+
className,
|
|
6189
|
+
{
|
|
6190
|
+
"cursor-not-allowed": props.disabled
|
|
6191
|
+
}
|
|
6136
6192
|
),
|
|
6137
|
-
|
|
6138
|
-
children
|
|
6193
|
+
...props
|
|
6139
6194
|
}
|
|
6140
6195
|
);
|
|
6141
6196
|
};
|
|
6142
6197
|
|
|
6143
|
-
const
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
const formattedDay = `${month} ${day}`;
|
|
6147
|
-
const time = new Intl.DateTimeFormat("en-US", {
|
|
6148
|
-
hour: "2-digit",
|
|
6149
|
-
minute: "2-digit",
|
|
6150
|
-
second: "2-digit",
|
|
6151
|
-
hour12: false
|
|
6152
|
-
// Use 24-hour format
|
|
6153
|
-
}).format(date);
|
|
6154
|
-
return { day: formattedDay, time };
|
|
6155
|
-
};
|
|
6198
|
+
const Collapsible = CollapsiblePrimitive__namespace.Root;
|
|
6199
|
+
const CollapsibleTrigger = CollapsiblePrimitive__namespace.CollapsibleTrigger;
|
|
6200
|
+
const CollapsibleContent = CollapsiblePrimitive__namespace.CollapsibleContent;
|
|
6156
6201
|
|
|
6157
|
-
const
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3 w-full truncate", children: unit })
|
|
6167
|
-
] }) });
|
|
6168
|
-
};
|
|
6169
|
-
const DateTimeCell = ({ dateTime, ...props }) => {
|
|
6170
|
-
const { day, time } = formatDateCell(dateTime);
|
|
6171
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Cell, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0", children: [
|
|
6172
|
-
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3", children: day }),
|
|
6173
|
-
" ",
|
|
6174
|
-
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", children: time })
|
|
6175
|
-
] }) });
|
|
6202
|
+
const formatJSON = async (code) => {
|
|
6203
|
+
const formatted = await prettier.format(code, {
|
|
6204
|
+
semi: false,
|
|
6205
|
+
parser: "json",
|
|
6206
|
+
printWidth: 80,
|
|
6207
|
+
tabWidth: 2,
|
|
6208
|
+
plugins: [prettierPluginBabel, prettierPluginEstree]
|
|
6209
|
+
});
|
|
6210
|
+
return formatted;
|
|
6176
6211
|
};
|
|
6177
|
-
const
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
meta
|
|
6185
|
-
] }) });
|
|
6212
|
+
const isValidJson = (str) => {
|
|
6213
|
+
try {
|
|
6214
|
+
const obj = JSON.parse(str);
|
|
6215
|
+
return !!obj && typeof obj === "object";
|
|
6216
|
+
} catch (e) {
|
|
6217
|
+
return false;
|
|
6218
|
+
}
|
|
6186
6219
|
};
|
|
6187
6220
|
|
|
6188
|
-
const
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
setOpen((prev) => !prev);
|
|
6204
|
-
};
|
|
6205
|
-
return { openTrace };
|
|
6206
|
-
};
|
|
6207
|
-
|
|
6208
|
-
const toSigFigs = (num, sigFigs) => {
|
|
6209
|
-
return Number(num.toPrecision(sigFigs));
|
|
6210
|
-
};
|
|
6211
|
-
|
|
6212
|
-
const TracesTableEmpty = ({ colsCount }) => {
|
|
6213
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: /* @__PURE__ */ jsxRuntime.jsx(Row, { children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { colSpan: colsCount, className: "text-center py-4", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { children: "No traces found" }) }) }) });
|
|
6214
|
-
};
|
|
6215
|
-
const TracesTableError = ({ error, colsCount }) => {
|
|
6216
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: /* @__PURE__ */ jsxRuntime.jsx(Row, { children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { colSpan: colsCount, className: "text-center py-4", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { children: error.message }) }) }) });
|
|
6217
|
-
};
|
|
6218
|
-
const TraceRow = ({ trace, index, isActive }) => {
|
|
6219
|
-
const { openTrace } = useOpenTrace();
|
|
6220
|
-
const hasFailure = trace.trace.some((span) => span.status.code !== 0);
|
|
6221
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Row, { className: isActive ? "bg-surface4" : "", onClick: () => openTrace(trace.trace, index), children: [
|
|
6222
|
-
/* @__PURE__ */ jsxRuntime.jsx(DateTimeCell, { dateTime: new Date(trace.started / 1e3) }),
|
|
6223
|
-
/* @__PURE__ */ jsxRuntime.jsxs(TxtCell, { title: trace.traceId, children: [
|
|
6224
|
-
trace.traceId.substring(0, 7),
|
|
6225
|
-
"..."
|
|
6226
|
-
] }),
|
|
6227
|
-
/* @__PURE__ */ jsxRuntime.jsx(UnitCell, { unit: "ms", children: toSigFigs(trace.duration / 1e3, 3) }),
|
|
6228
|
-
/* @__PURE__ */ jsxRuntime.jsx(Cell, { children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => openTrace(trace.trace, index), children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(TraceIcon, {}), children: trace.trace.length }) }) }),
|
|
6229
|
-
/* @__PURE__ */ jsxRuntime.jsx(Cell, { children: hasFailure ? /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}), children: "Failed" }) : /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, {}), variant: "success", children: "Success" }) })
|
|
6230
|
-
] });
|
|
6221
|
+
const useCodemirrorTheme = () => {
|
|
6222
|
+
return React.useMemo(
|
|
6223
|
+
() => codemirrorThemeDracula.draculaInit({
|
|
6224
|
+
settings: {
|
|
6225
|
+
fontFamily: "var(--geist-mono)",
|
|
6226
|
+
fontSize: "0.8rem",
|
|
6227
|
+
lineHighlight: "transparent",
|
|
6228
|
+
gutterBackground: "transparent",
|
|
6229
|
+
gutterForeground: colors.Colors.surface3,
|
|
6230
|
+
background: "transparent"
|
|
6231
|
+
},
|
|
6232
|
+
styles: [{ tag: [highlight$1.tags.className, highlight$1.tags.propertyName] }]
|
|
6233
|
+
}),
|
|
6234
|
+
[]
|
|
6235
|
+
);
|
|
6231
6236
|
};
|
|
6232
|
-
const
|
|
6233
|
-
const
|
|
6234
|
-
const
|
|
6235
|
-
|
|
6236
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Table, { size: "small", children: [
|
|
6237
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Thead, { children: [
|
|
6238
|
-
/* @__PURE__ */ jsxRuntime.jsx(Th, { width: 120, children: "Time" }),
|
|
6239
|
-
/* @__PURE__ */ jsxRuntime.jsx(Th, { width: "auto", children: "Trace Id" }),
|
|
6240
|
-
/* @__PURE__ */ jsxRuntime.jsx(Th, { width: 120, children: "Duration" }),
|
|
6241
|
-
/* @__PURE__ */ jsxRuntime.jsx(Th, { width: 120, children: "Spans" }),
|
|
6242
|
-
/* @__PURE__ */ jsxRuntime.jsx(Th, { width: 120, children: "Status" })
|
|
6243
|
-
] }),
|
|
6244
|
-
error ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableError, { error, colsCount }) : hasNoTraces ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableEmpty, { colsCount }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: traces.map((trace, index) => /* @__PURE__ */ jsxRuntime.jsx(TraceRow, { trace, index, isActive: index === currentTraceIndex }, trace.traceId)) }) })
|
|
6245
|
-
] });
|
|
6237
|
+
const SyntaxHighlighter$1 = ({ data }) => {
|
|
6238
|
+
const formattedCode = JSON.stringify(data, null, 2);
|
|
6239
|
+
const theme = useCodemirrorTheme();
|
|
6240
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md bg-[#1a1a1a] p-1 font-mono", children: /* @__PURE__ */ jsxRuntime.jsx(CodeMirror, { value: formattedCode, theme, extensions: [langJson.jsonLanguage] }) });
|
|
6246
6241
|
};
|
|
6247
6242
|
|
|
6248
|
-
const
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
const
|
|
6255
|
-
const
|
|
6256
|
-
const
|
|
6257
|
-
const dragStartXRef = React.useRef(0);
|
|
6258
|
-
const initialWidthRef = React.useRef(0);
|
|
6259
|
-
const handleMouseDown = (e) => {
|
|
6260
|
-
e.preventDefault();
|
|
6261
|
-
setIsDragging(true);
|
|
6262
|
-
dragStartXRef.current = e.clientX;
|
|
6263
|
-
initialWidthRef.current = sidebarWidth;
|
|
6264
|
-
};
|
|
6265
|
-
React.useEffect(() => {
|
|
6266
|
-
setSidebarWidth(defaultWidth);
|
|
6267
|
-
setCurrentWidth?.(defaultWidth);
|
|
6268
|
-
}, [defaultWidth]);
|
|
6243
|
+
const AgentAdvancedSettings = () => {
|
|
6244
|
+
const { settings, setSettings } = useAgentSettings();
|
|
6245
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
6246
|
+
const [providerOptionsValue, setProviderOptionsValue] = React.useState("");
|
|
6247
|
+
const [saved, setSaved] = React.useState(false);
|
|
6248
|
+
const [error, setError] = React.useState(null);
|
|
6249
|
+
const theme = useCodemirrorTheme();
|
|
6250
|
+
const { handleCopy } = useCopyToClipboard({ text: providerOptionsValue });
|
|
6251
|
+
const providerOptionsStr = JSON.stringify(settings?.modelSettings?.providerOptions ?? {});
|
|
6269
6252
|
React.useEffect(() => {
|
|
6270
|
-
const
|
|
6271
|
-
if (!
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
const
|
|
6276
|
-
|
|
6277
|
-
setCurrentWidth?.(newWidth);
|
|
6278
|
-
};
|
|
6279
|
-
const handleMouseUp = () => {
|
|
6280
|
-
setIsDragging(false);
|
|
6253
|
+
const run = async () => {
|
|
6254
|
+
if (!isValidJson(providerOptionsStr)) {
|
|
6255
|
+
setError("Invalid JSON");
|
|
6256
|
+
return;
|
|
6257
|
+
}
|
|
6258
|
+
const formatted = await formatJSON(providerOptionsStr);
|
|
6259
|
+
setProviderOptionsValue(formatted);
|
|
6281
6260
|
};
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6261
|
+
run();
|
|
6262
|
+
}, [providerOptionsStr]);
|
|
6263
|
+
const formatProviderOptions = async () => {
|
|
6264
|
+
setError(null);
|
|
6265
|
+
if (!isValidJson(providerOptionsValue)) {
|
|
6266
|
+
setError("Invalid JSON");
|
|
6267
|
+
return;
|
|
6285
6268
|
}
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
maximumWidth,
|
|
6299
|
-
className,
|
|
6300
|
-
disabled = false,
|
|
6301
|
-
setCurrentWidth,
|
|
6302
|
-
dividerPosition = "left"
|
|
6303
|
-
}) => {
|
|
6304
|
-
const { sidebarWidth, isDragging, handleMouseDown, containerRef } = useResizeColumn({
|
|
6305
|
-
defaultWidth: disabled ? 100 : defaultWidth,
|
|
6306
|
-
minimumWidth,
|
|
6307
|
-
maximumWidth,
|
|
6308
|
-
setCurrentWidth
|
|
6309
|
-
});
|
|
6310
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full h-full relative", className), ref: containerRef, style: { width: `${sidebarWidth}%` }, children: [
|
|
6311
|
-
!disabled && dividerPosition === "left" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6312
|
-
"div",
|
|
6313
|
-
{
|
|
6314
|
-
className: `w-px bg-border1 h-full cursor-col-resize hover:w-1.5 hover:bg-mastra-border-2 hover:bg-[#424242] active:bg-mastra-border-3 active:bg-[#3e3e3e] transition-colors absolute inset-y-0 z-10
|
|
6315
|
-
${isDragging ? "bg-border2 w-1.5 cursor- col-resize" : ""}`,
|
|
6316
|
-
onMouseDown: handleMouseDown
|
|
6317
|
-
}
|
|
6318
|
-
) : null,
|
|
6319
|
-
children,
|
|
6320
|
-
!disabled && dividerPosition === "right" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6321
|
-
"div",
|
|
6322
|
-
{
|
|
6323
|
-
className: `w-px bg-border1 h-full cursor-col-resize hover:w-1.5 hover:bg-border2 active:bg-border3 transition-colors absolute inset-y-0 z-10
|
|
6324
|
-
${isDragging ? "bg-border2 w-1.5 cursor- col-resize" : ""}`,
|
|
6325
|
-
onMouseDown: handleMouseDown
|
|
6326
|
-
}
|
|
6327
|
-
) : null
|
|
6328
|
-
] });
|
|
6329
|
-
};
|
|
6330
|
-
|
|
6331
|
-
const sizeClasses = {
|
|
6332
|
-
md: "h-button-md gap-md",
|
|
6333
|
-
lg: "h-button-lg gap-lg"
|
|
6334
|
-
};
|
|
6335
|
-
const variantClasses$1 = {
|
|
6336
|
-
default: "bg-surface2 hover:bg-surface4 text-icon3 hover:text-icon6",
|
|
6337
|
-
light: "bg-surface3 hover:bg-surface5 text-icon6"
|
|
6338
|
-
};
|
|
6339
|
-
const Button = ({ className, as, size = "md", variant = "default", ...props }) => {
|
|
6340
|
-
const Component = as || "button";
|
|
6341
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6342
|
-
Component,
|
|
6343
|
-
{
|
|
6344
|
-
className: clsx(
|
|
6345
|
-
"bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
|
|
6346
|
-
variantClasses$1[variant],
|
|
6347
|
-
sizeClasses[size],
|
|
6348
|
-
className,
|
|
6349
|
-
{
|
|
6350
|
-
"cursor-not-allowed": props.disabled
|
|
6269
|
+
const formatted = await formatJSON(providerOptionsValue);
|
|
6270
|
+
setProviderOptionsValue(formatted);
|
|
6271
|
+
};
|
|
6272
|
+
const saveProviderOptions = async () => {
|
|
6273
|
+
try {
|
|
6274
|
+
setError(null);
|
|
6275
|
+
const parsedContext = JSON.parse(providerOptionsValue);
|
|
6276
|
+
setSettings({
|
|
6277
|
+
...settings,
|
|
6278
|
+
modelSettings: {
|
|
6279
|
+
...settings?.modelSettings,
|
|
6280
|
+
providerOptions: parsedContext
|
|
6351
6281
|
}
|
|
6352
|
-
)
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
};
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
};
|
|
6361
|
-
|
|
6362
|
-
const variantClasses = {
|
|
6363
|
-
agent: "bg-accent1"
|
|
6364
|
-
};
|
|
6365
|
-
const Time = ({ durationMs, tokenCount, variant, progressPercent, offsetPercent }) => {
|
|
6366
|
-
const variantClass = variant ? variantClasses[variant] : "bg-accent3";
|
|
6367
|
-
const percent = Math.min(100, progressPercent);
|
|
6368
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[80px] xl:w-[166px] shrink-0", children: [
|
|
6369
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface4 relative h-[6px] w-full rounded-full p-px overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6370
|
-
"div",
|
|
6371
|
-
{
|
|
6372
|
-
className: clsx("absolute h-1 rounded-full", variantClass),
|
|
6373
|
-
style: { width: `${percent}%`, left: `${offsetPercent}%` }
|
|
6374
|
-
}
|
|
6375
|
-
) }),
|
|
6376
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 pt-0.5", children: [
|
|
6377
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon2 font-medium", children: [
|
|
6378
|
-
toSigFigs(durationMs, 3),
|
|
6379
|
-
"ms"
|
|
6380
|
-
] }),
|
|
6381
|
-
tokenCount && /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon2 font-medium", children: [
|
|
6382
|
-
tokenCount,
|
|
6383
|
-
"t"
|
|
6384
|
-
] })
|
|
6385
|
-
] })
|
|
6386
|
-
] });
|
|
6387
|
-
};
|
|
6388
|
-
|
|
6389
|
-
const spanIconMap = {
|
|
6390
|
-
tool: ToolsIcon,
|
|
6391
|
-
agent: AgentIcon,
|
|
6392
|
-
workflow: WorkflowIcon,
|
|
6393
|
-
memory: MemoryIcon,
|
|
6394
|
-
rag: TraceIcon,
|
|
6395
|
-
storage: DbIcon,
|
|
6396
|
-
eval: ScoreIcon,
|
|
6397
|
-
other: TraceIcon
|
|
6398
|
-
};
|
|
6399
|
-
const spanVariantClasses = {
|
|
6400
|
-
tool: "text-[#ECB047]",
|
|
6401
|
-
agent: "text-accent1",
|
|
6402
|
-
workflow: "text-accent3",
|
|
6403
|
-
memory: "text-accent2",
|
|
6404
|
-
rag: "text-accent2",
|
|
6405
|
-
storage: "text-accent2",
|
|
6406
|
-
eval: "text-accent4",
|
|
6407
|
-
other: "text-icon6"
|
|
6408
|
-
};
|
|
6409
|
-
const Span = ({
|
|
6410
|
-
children,
|
|
6411
|
-
durationMs,
|
|
6412
|
-
variant,
|
|
6413
|
-
tokenCount,
|
|
6414
|
-
spans,
|
|
6415
|
-
isRoot,
|
|
6416
|
-
onClick,
|
|
6417
|
-
isActive,
|
|
6418
|
-
offsetMs,
|
|
6419
|
-
totalDurationMs
|
|
6420
|
-
}) => {
|
|
6421
|
-
const [isExpanded, setIsExpanded] = React.useState(true);
|
|
6422
|
-
const VariantIcon = spanIconMap[variant];
|
|
6423
|
-
const variantClass = spanVariantClasses[variant];
|
|
6424
|
-
const progressPercent = durationMs / totalDurationMs * 100;
|
|
6425
|
-
const offsetPercent = offsetMs / totalDurationMs * 100;
|
|
6426
|
-
const TextEl = onClick ? "button" : "div";
|
|
6427
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
6428
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx("flex justify-between items-center gap-2 rounded-md pl-2", isActive && "bg-surface4"), children: [
|
|
6429
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-8 items-center gap-1 min-w-0", children: [
|
|
6430
|
-
spans ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6431
|
-
"button",
|
|
6432
|
-
{
|
|
6433
|
-
type: "button",
|
|
6434
|
-
"aria-label": isExpanded ? "Collapse span" : "Expand span",
|
|
6435
|
-
"aria-expanded": isExpanded,
|
|
6436
|
-
className: "text-icon3 flex h-4 w-4",
|
|
6437
|
-
onClick: () => setIsExpanded(!isExpanded),
|
|
6438
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(ChevronIcon, { className: clsx("transition-transform -rotate-90", { "rotate-0": isExpanded }) }) })
|
|
6439
|
-
}
|
|
6440
|
-
) : /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": true, className: "h-full w-4", children: !isRoot && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-[7px] h-full w-px rounded-full" }) }),
|
|
6441
|
-
/* @__PURE__ */ jsxRuntime.jsxs(TextEl, { className: "flex items-center gap-2 min-w-0", onClick, children: [
|
|
6442
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx("bg-surface4 flex items-center justify-center rounded-md p-[3px]", variantClass), children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(VariantIcon, {}) }) }),
|
|
6443
|
-
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-md", className: "text-icon6 truncate", children })
|
|
6444
|
-
] })
|
|
6445
|
-
] }),
|
|
6446
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6447
|
-
Time,
|
|
6448
|
-
{
|
|
6449
|
-
durationMs,
|
|
6450
|
-
tokenCount,
|
|
6451
|
-
variant: variant === "agent" ? "agent" : void 0,
|
|
6452
|
-
progressPercent,
|
|
6453
|
-
offsetPercent
|
|
6454
|
-
}
|
|
6455
|
-
)
|
|
6456
|
-
] }),
|
|
6457
|
-
isExpanded && spans && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-4", children: spans })
|
|
6458
|
-
] });
|
|
6459
|
-
};
|
|
6460
|
-
|
|
6461
|
-
const Spans = ({ children }) => {
|
|
6462
|
-
return /* @__PURE__ */ jsxRuntime.jsx("ol", { children });
|
|
6463
|
-
};
|
|
6464
|
-
|
|
6465
|
-
const Trace = ({
|
|
6466
|
-
name,
|
|
6467
|
-
spans,
|
|
6468
|
-
durationMs,
|
|
6469
|
-
tokenCount,
|
|
6470
|
-
onClick,
|
|
6471
|
-
variant,
|
|
6472
|
-
isActive,
|
|
6473
|
-
totalDurationMs
|
|
6474
|
-
}) => {
|
|
6475
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6476
|
-
Span,
|
|
6477
|
-
{
|
|
6478
|
-
isRoot: true,
|
|
6479
|
-
durationMs,
|
|
6480
|
-
variant,
|
|
6481
|
-
spans: /* @__PURE__ */ jsxRuntime.jsx(Spans, { children: spans }),
|
|
6482
|
-
onClick,
|
|
6483
|
-
isActive,
|
|
6484
|
-
offsetMs: 0,
|
|
6485
|
-
totalDurationMs,
|
|
6486
|
-
children: name
|
|
6487
|
-
}
|
|
6488
|
-
);
|
|
6489
|
-
};
|
|
6490
|
-
|
|
6491
|
-
const getSpanVariant = (span) => {
|
|
6492
|
-
const attributes = Object.keys(span.attributes || {}).map((k) => k.toLowerCase());
|
|
6493
|
-
const lowerCaseName = span.name.toLowerCase();
|
|
6494
|
-
const isAiSpan = lowerCaseName.startsWith("ai.");
|
|
6495
|
-
if (isAiSpan) {
|
|
6496
|
-
const isAiAboutTool = lowerCaseName.includes("tool");
|
|
6497
|
-
if (isAiAboutTool) return "tool";
|
|
6498
|
-
return "other";
|
|
6499
|
-
}
|
|
6500
|
-
const hasMemoryRelatedAttributes = attributes.some((key) => key.includes("memory") || key.includes("storage"));
|
|
6501
|
-
if (hasMemoryRelatedAttributes) return "memory";
|
|
6502
|
-
const hasToolRelatedAttributes = attributes.some((key) => key.includes("tool"));
|
|
6503
|
-
if (hasToolRelatedAttributes) return "tool";
|
|
6504
|
-
const hasAgentRelatedAttributes = attributes.some((key) => key.includes("agent."));
|
|
6505
|
-
if (hasAgentRelatedAttributes) return "agent";
|
|
6506
|
-
if (lowerCaseName.includes(".insert")) {
|
|
6507
|
-
const evalRelatedAttribute = attributes.find((key) => String(span.attributes?.[key])?.includes("mastra_evals"));
|
|
6508
|
-
if (evalRelatedAttribute) return "eval";
|
|
6509
|
-
}
|
|
6510
|
-
return "other";
|
|
6511
|
-
};
|
|
6512
|
-
|
|
6513
|
-
function buildTree(spans, minStartTime, totalDurationMs, parentSpanId = null) {
|
|
6514
|
-
return spans.filter((span) => span.parentSpanId === parentSpanId).map((span) => {
|
|
6515
|
-
return {
|
|
6516
|
-
...span,
|
|
6517
|
-
children: buildTree(spans, minStartTime, totalDurationMs, span.id),
|
|
6518
|
-
offset: (span.startTime - minStartTime) / 1e3,
|
|
6519
|
-
// ns to ms
|
|
6520
|
-
duration: span.duration / 1e3,
|
|
6521
|
-
totalDurationMs
|
|
6522
|
-
};
|
|
6523
|
-
});
|
|
6524
|
-
}
|
|
6525
|
-
const createSpanTree = (spans) => {
|
|
6526
|
-
if (spans.length === 0) return [];
|
|
6527
|
-
let minStartTime;
|
|
6528
|
-
let maxEndTime;
|
|
6529
|
-
const orderedTree = [];
|
|
6530
|
-
const listSize = spans.length;
|
|
6531
|
-
for (let i = listSize - 1; i >= 0; i--) {
|
|
6532
|
-
const span = spans[i];
|
|
6533
|
-
if (!minStartTime || span.startTime < minStartTime) {
|
|
6534
|
-
minStartTime = span.startTime;
|
|
6535
|
-
}
|
|
6536
|
-
if (!maxEndTime || span.endTime > maxEndTime) {
|
|
6537
|
-
maxEndTime = span.endTime;
|
|
6538
|
-
}
|
|
6539
|
-
if (span.name !== ".insert" && span.name !== "mastra.getStorage") {
|
|
6540
|
-
orderedTree.push(span);
|
|
6541
|
-
}
|
|
6542
|
-
}
|
|
6543
|
-
if (!minStartTime || !maxEndTime) return [];
|
|
6544
|
-
const totalDurationMs = (maxEndTime - minStartTime) / 1e3;
|
|
6545
|
-
return buildTree(orderedTree, minStartTime, totalDurationMs);
|
|
6546
|
-
};
|
|
6547
|
-
|
|
6548
|
-
const NestedSpans = ({ spanNodes }) => {
|
|
6549
|
-
const { span: activeSpan, setSpan } = React.useContext(TraceContext);
|
|
6550
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Spans, { children: spanNodes.map((spanNode) => {
|
|
6551
|
-
const isActive = spanNode.id === activeSpan?.id;
|
|
6552
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6553
|
-
Span,
|
|
6554
|
-
{
|
|
6555
|
-
spans: spanNode.children.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(NestedSpans, { spanNodes: spanNode.children }),
|
|
6556
|
-
durationMs: spanNode.duration,
|
|
6557
|
-
offsetMs: spanNode.offset,
|
|
6558
|
-
variant: getSpanVariant(spanNode),
|
|
6559
|
-
isActive,
|
|
6560
|
-
onClick: () => setSpan(spanNode),
|
|
6561
|
-
totalDurationMs: spanNode.totalDurationMs,
|
|
6562
|
-
children: spanNode.name
|
|
6563
|
-
},
|
|
6564
|
-
spanNode.id
|
|
6565
|
-
);
|
|
6566
|
-
}) });
|
|
6567
|
-
};
|
|
6568
|
-
function SpanView({ trace }) {
|
|
6569
|
-
const { span: activeSpan, setSpan } = React.useContext(TraceContext);
|
|
6570
|
-
const tree = createSpanTree(trace);
|
|
6571
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TraceTree, { children: tree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6572
|
-
Trace,
|
|
6573
|
-
{
|
|
6574
|
-
name: node.name,
|
|
6575
|
-
durationMs: node.duration,
|
|
6576
|
-
totalDurationMs: node.totalDurationMs,
|
|
6577
|
-
spans: /* @__PURE__ */ jsxRuntime.jsx(NestedSpans, { spanNodes: node.children }),
|
|
6578
|
-
variant: getSpanVariant(node),
|
|
6579
|
-
isActive: node.id === activeSpan?.id,
|
|
6580
|
-
onClick: () => setSpan(node)
|
|
6581
|
-
}
|
|
6582
|
-
)) });
|
|
6583
|
-
}
|
|
6584
|
-
|
|
6585
|
-
const Header = ({ children, border = true }) => {
|
|
6586
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6587
|
-
"header",
|
|
6588
|
-
{
|
|
6589
|
-
className: clsx("h-header-default z-50 flex w-full items-center gap-[18px] bg-transparent px-5", {
|
|
6590
|
-
"border-b-sm border-border1": border
|
|
6591
|
-
}),
|
|
6592
|
-
children
|
|
6593
|
-
}
|
|
6594
|
-
);
|
|
6595
|
-
};
|
|
6596
|
-
const HeaderTitle = ({ children }) => {
|
|
6597
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "h1", variant: "ui-lg", className: "font-medium text-white", children });
|
|
6598
|
-
};
|
|
6599
|
-
const HeaderAction = ({ children }) => {
|
|
6600
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto", children });
|
|
6601
|
-
};
|
|
6602
|
-
const HeaderGroup = ({ children }) => {
|
|
6603
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gap-lg flex items-center", children });
|
|
6604
|
-
};
|
|
6605
|
-
|
|
6606
|
-
function TraceDetails() {
|
|
6607
|
-
const { trace, currentTraceIndex, prevTrace, nextTrace, traces } = React.useContext(TraceContext);
|
|
6608
|
-
const actualTrace = traces[currentTraceIndex];
|
|
6609
|
-
if (!actualTrace || !trace) return null;
|
|
6610
|
-
const hasFailure = trace.some((span) => span.status.code !== 0);
|
|
6611
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("aside", { children: [
|
|
6612
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Header, { children: [
|
|
6613
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
6614
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { className: "bg-transparent border-none", onClick: prevTrace, disabled: currentTraceIndex === 0, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, {}) }) }),
|
|
6615
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6616
|
-
Button,
|
|
6617
|
-
{
|
|
6618
|
-
className: "bg-transparent border-none",
|
|
6619
|
-
onClick: nextTrace,
|
|
6620
|
-
disabled: currentTraceIndex === traces.length - 1,
|
|
6621
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {}) })
|
|
6622
|
-
}
|
|
6623
|
-
)
|
|
6624
|
-
] }),
|
|
6625
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 justify-between w-full", children: [
|
|
6626
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-lg", className: "font-medium text-icon5 shrink-0", children: [
|
|
6627
|
-
"Trace ",
|
|
6628
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-icon3", children: actualTrace.traceId.substring(0, 7) })
|
|
6629
|
-
] }),
|
|
6630
|
-
hasFailure && /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}), children: "Failed" })
|
|
6631
|
-
] })
|
|
6632
|
-
] }),
|
|
6633
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-5", children: /* @__PURE__ */ jsxRuntime.jsx(SpanView, { trace }) })
|
|
6634
|
-
] });
|
|
6635
|
-
}
|
|
6636
|
-
|
|
6637
|
-
const useCodemirrorTheme = () => {
|
|
6638
|
-
return React.useMemo(
|
|
6639
|
-
() => codemirrorThemeDracula.draculaInit({
|
|
6640
|
-
settings: {
|
|
6641
|
-
fontFamily: "var(--geist-mono)",
|
|
6642
|
-
fontSize: "0.8rem",
|
|
6643
|
-
lineHighlight: "transparent",
|
|
6644
|
-
gutterBackground: "transparent",
|
|
6645
|
-
gutterForeground: colors.Colors.surface3,
|
|
6646
|
-
background: "transparent"
|
|
6647
|
-
},
|
|
6648
|
-
styles: [{ tag: [highlight$1.tags.className, highlight$1.tags.propertyName] }]
|
|
6649
|
-
}),
|
|
6650
|
-
[]
|
|
6651
|
-
);
|
|
6652
|
-
};
|
|
6653
|
-
const SyntaxHighlighter$1 = ({ data }) => {
|
|
6654
|
-
const formattedCode = JSON.stringify(data, null, 2);
|
|
6655
|
-
const theme = useCodemirrorTheme();
|
|
6656
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md bg-[#1a1a1a] p-1 font-mono", children: /* @__PURE__ */ jsxRuntime.jsx(CodeMirror, { value: formattedCode, theme, extensions: [langJson.jsonLanguage] }) });
|
|
6657
|
-
};
|
|
6658
|
-
|
|
6659
|
-
function formatOtelTimestamp(otelTimestamp) {
|
|
6660
|
-
const date = new Date(otelTimestamp / 1e3);
|
|
6661
|
-
return new Intl.DateTimeFormat("en-US", {
|
|
6662
|
-
month: "numeric",
|
|
6663
|
-
day: "numeric",
|
|
6664
|
-
year: "numeric",
|
|
6665
|
-
hour: "numeric",
|
|
6666
|
-
minute: "numeric",
|
|
6667
|
-
second: "numeric",
|
|
6668
|
-
hour12: true
|
|
6669
|
-
}).format(date);
|
|
6670
|
-
}
|
|
6671
|
-
function formatOtelTimestamp2(otelTimestamp) {
|
|
6672
|
-
const date = new Date(otelTimestamp / 1e6);
|
|
6673
|
-
return new Intl.DateTimeFormat("en-US", {
|
|
6674
|
-
month: "numeric",
|
|
6675
|
-
day: "numeric",
|
|
6676
|
-
year: "numeric",
|
|
6677
|
-
hour: "numeric",
|
|
6678
|
-
minute: "numeric",
|
|
6679
|
-
second: "numeric",
|
|
6680
|
-
hour12: true
|
|
6681
|
-
}).format(date);
|
|
6682
|
-
}
|
|
6683
|
-
function transformKey(key) {
|
|
6684
|
-
if (key.includes(".argument.")) {
|
|
6685
|
-
return `Input`;
|
|
6686
|
-
}
|
|
6687
|
-
if (key.includes(".result")) {
|
|
6688
|
-
return "Output";
|
|
6689
|
-
}
|
|
6690
|
-
const newKey = key.split(".").join(" ").split("_").join(" ").replaceAll("ai", "AI");
|
|
6691
|
-
return newKey.substring(0, 1).toUpperCase() + newKey.substring(1);
|
|
6692
|
-
}
|
|
6693
|
-
|
|
6694
|
-
function SpanDetail() {
|
|
6695
|
-
const { span, setSpan, trace, setIsOpen } = React.useContext(TraceContext);
|
|
6696
|
-
if (!span || !trace) return null;
|
|
6697
|
-
const prevSpan = () => {
|
|
6698
|
-
const currentIndex = trace.findIndex((t) => t.id === span.id);
|
|
6699
|
-
if (currentIndex !== -1 && currentIndex < trace.length - 1) {
|
|
6700
|
-
setSpan(trace[currentIndex + 1]);
|
|
6701
|
-
}
|
|
6702
|
-
};
|
|
6703
|
-
const nextSpan = () => {
|
|
6704
|
-
const currentIndex = trace.findIndex((t) => t.id === span.id);
|
|
6705
|
-
if (currentIndex !== -1 && currentIndex > 0) {
|
|
6706
|
-
setSpan(trace[currentIndex - 1]);
|
|
6707
|
-
}
|
|
6708
|
-
};
|
|
6709
|
-
const SpanIcon = spanIconMap[getSpanVariant(span)];
|
|
6710
|
-
const variantClass = spanVariantClasses[getSpanVariant(span)];
|
|
6711
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("aside", { children: [
|
|
6712
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Header, { children: [
|
|
6713
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
6714
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { className: "bg-transparent border-none", onClick: prevSpan, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, {}) }) }),
|
|
6715
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { className: "bg-transparent border-none", onClick: nextSpan, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {}) }) })
|
|
6716
|
-
] }),
|
|
6717
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-lg", className: "font-medium text-icon5", as: "h2", children: [
|
|
6718
|
-
"Span ",
|
|
6719
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-icon3", children: span.id.substring(0, 7) })
|
|
6720
|
-
] }) }),
|
|
6721
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { className: "bg-transparent border-none", onClick: () => setIsOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}) }) }) })
|
|
6722
|
-
] }),
|
|
6723
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-5", children: [
|
|
6724
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "header-md", as: "h3", className: "text-icon-6 flex items-center gap-4 pb-3", children: [
|
|
6725
|
-
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "lg", className: "bg-surface4 p-1 rounded-md", children: /* @__PURE__ */ jsxRuntime.jsx(SpanIcon, { className: variantClass }) }),
|
|
6726
|
-
span.name
|
|
6727
|
-
] }),
|
|
6728
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row gap-2 items-center", children: span.status.code === 0 ? /* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(LatencyIcon, {}), variant: "success", children: [
|
|
6729
|
-
toSigFigs(span.duration, 3),
|
|
6730
|
-
"ms"
|
|
6731
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}), children: [
|
|
6732
|
-
"Failed in ",
|
|
6733
|
-
toSigFigs(span.duration, 3),
|
|
6734
|
-
"ms"
|
|
6735
|
-
] }) }),
|
|
6736
|
-
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
6737
|
-
/* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "grid grid-cols-2 justify-between gap-2", children: [
|
|
6738
|
-
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "ID" }),
|
|
6739
|
-
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: span.id }),
|
|
6740
|
-
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "Created at" }),
|
|
6741
|
-
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: span.startTime ? formatOtelTimestamp(span.startTime) : "" })
|
|
6742
|
-
] }),
|
|
6743
|
-
span.attributes && /* @__PURE__ */ jsxRuntime.jsx(Attributes, { attributes: span.attributes }),
|
|
6744
|
-
span.events?.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Events, { span })
|
|
6745
|
-
] })
|
|
6746
|
-
] });
|
|
6747
|
-
}
|
|
6748
|
-
function Attributes({ attributes }) {
|
|
6749
|
-
if (!attributes) return null;
|
|
6750
|
-
const entries = Object.entries(attributes);
|
|
6751
|
-
if (entries.length === 0) return null;
|
|
6752
|
-
const keysToHide = ["http.request_id", "componentName"];
|
|
6753
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: entries.filter(([key]) => !keysToHide.includes(key)).map(([key, val]) => {
|
|
6754
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
6755
|
-
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
6756
|
-
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "h4", variant: "ui-md", className: "text-icon3 pb-2", children: transformKey(key) }),
|
|
6757
|
-
/* @__PURE__ */ jsxRuntime.jsx(AttributeValue, { value: val })
|
|
6758
|
-
] }, key);
|
|
6759
|
-
}) });
|
|
6760
|
-
}
|
|
6761
|
-
const AttributeValue = ({ value }) => {
|
|
6762
|
-
if (!value)
|
|
6763
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: "N/A" });
|
|
6764
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
6765
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: String(value) });
|
|
6766
|
-
}
|
|
6767
|
-
if (typeof value === "object") {
|
|
6768
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$1, { data: value });
|
|
6769
|
-
}
|
|
6770
|
-
try {
|
|
6771
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$1, { data: JSON.parse(value) });
|
|
6772
|
-
} catch {
|
|
6773
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: String(value) });
|
|
6774
|
-
}
|
|
6775
|
-
};
|
|
6776
|
-
function Events({ span }) {
|
|
6777
|
-
if (!span.events) return null;
|
|
6778
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
6779
|
-
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
6780
|
-
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6 pb-2", children: "Events" }),
|
|
6781
|
-
span.events.map((event) => {
|
|
6782
|
-
const isLast = event === span.events[span.events.length - 1];
|
|
6783
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
6784
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
6785
|
-
/* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "grid grid-cols-2 justify-between gap-2 pb-2", children: [
|
|
6786
|
-
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "Name" }),
|
|
6787
|
-
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: event.name }),
|
|
6788
|
-
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "Time" }),
|
|
6789
|
-
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: event.timeUnixNano ? formatOtelTimestamp2(Number(event.timeUnixNano)) : "N/A" })
|
|
6790
|
-
] }),
|
|
6791
|
-
event.attributes?.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2", children: event.attributes.filter((attribute) => attribute !== null).map((attribute) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
6792
|
-
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "h4", variant: "ui-md", className: "text-icon3 pb-2", children: transformKey(attribute.key) }),
|
|
6793
|
-
/* @__PURE__ */ jsxRuntime.jsx(AttributeValue, { value: attribute.value })
|
|
6794
|
-
] }, attribute.key)) }) : null
|
|
6795
|
-
] }, event.name),
|
|
6796
|
-
!isLast && /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" })
|
|
6797
|
-
] }, event.name);
|
|
6798
|
-
})
|
|
6799
|
-
] });
|
|
6800
|
-
}
|
|
6801
|
-
|
|
6802
|
-
const TracesSidebar = ({ onResize }) => {
|
|
6803
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6804
|
-
MastraResizablePanel,
|
|
6805
|
-
{
|
|
6806
|
-
className: "h-full absolute right-0 inset-y-0 bg-surface2",
|
|
6807
|
-
defaultWidth: 80,
|
|
6808
|
-
minimumWidth: 50,
|
|
6809
|
-
maximumWidth: 80,
|
|
6810
|
-
setCurrentWidth: onResize,
|
|
6811
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full grid grid-cols-2", children: [
|
|
6812
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-scroll w-full h-[calc(100%-40px)]", children: /* @__PURE__ */ jsxRuntime.jsx(TraceDetails, {}) }),
|
|
6813
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-[calc(100%-40px)] overflow-x-scroll w-full border-l border-border1", children: /* @__PURE__ */ jsxRuntime.jsx(SpanDetail, {}) })
|
|
6814
|
-
] })
|
|
6815
|
-
}
|
|
6816
|
-
);
|
|
6817
|
-
};
|
|
6818
|
-
|
|
6819
|
-
function AgentTraces({ className, traces, error }) {
|
|
6820
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TraceProvider, { initialTraces: traces || [], children: /* @__PURE__ */ jsxRuntime.jsx(AgentTracesInner, { className, traces, error }) });
|
|
6821
|
-
}
|
|
6822
|
-
function AgentTracesInner({ className, traces, error }) {
|
|
6823
|
-
const [sidebarWidth, setSidebarWidth] = React.useState(100);
|
|
6824
|
-
const { isOpen: open } = React.useContext(TraceContext);
|
|
6825
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx("h-full relative overflow-hidden flex", className), children: [
|
|
6826
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-y-scroll w-full", children: /* @__PURE__ */ jsxRuntime.jsx(TracesTable, { traces, error }) }),
|
|
6827
|
-
open && /* @__PURE__ */ jsxRuntime.jsx(TracesSidebar, { width: sidebarWidth, onResize: setSidebarWidth })
|
|
6828
|
-
] });
|
|
6829
|
-
}
|
|
6830
|
-
|
|
6831
|
-
const Slider = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6832
|
-
SliderPrimitive__namespace.Root,
|
|
6833
|
-
{
|
|
6834
|
-
ref,
|
|
6835
|
-
className: cn("relative flex w-full touch-none select-none items-center", className),
|
|
6836
|
-
...props,
|
|
6837
|
-
children: [
|
|
6838
|
-
/* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Track, { className: "relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20", children: /* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Range, { className: "absolute h-full bg-primary/50" }) }),
|
|
6839
|
-
/* @__PURE__ */ jsxRuntime.jsx(SliderPrimitive__namespace.Thumb, { className: "block h-4 w-4 rounded-full border border-primary/50 bg-white shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" })
|
|
6840
|
-
]
|
|
6841
|
-
}
|
|
6842
|
-
));
|
|
6843
|
-
Slider.displayName = SliderPrimitive__namespace.Root.displayName;
|
|
6844
|
-
|
|
6845
|
-
const labelVariants = cva("text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
6846
|
-
const Label = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive__namespace.Root, { ref, className: cn(labelVariants(), className), ...props }));
|
|
6847
|
-
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
6848
|
-
|
|
6849
|
-
const RadioGroup = React__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
6850
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Root, { className: cn("grid gap-2", className), ...props, ref });
|
|
6851
|
-
});
|
|
6852
|
-
RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
|
|
6853
|
-
const RadioGroupItem = React__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
6854
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6855
|
-
RadioGroupPrimitive__namespace.Item,
|
|
6856
|
-
{
|
|
6857
|
-
ref,
|
|
6858
|
-
className: cn(
|
|
6859
|
-
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
6860
|
-
className
|
|
6861
|
-
),
|
|
6862
|
-
...props,
|
|
6863
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Indicator, { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { className: "h-2.5 w-2.5 fill-current text-current" }) })
|
|
6864
|
-
}
|
|
6865
|
-
);
|
|
6866
|
-
});
|
|
6867
|
-
RadioGroupItem.displayName = RadioGroupPrimitive__namespace.Item.displayName;
|
|
6868
|
-
|
|
6869
|
-
const Entry = ({ label, children }) => {
|
|
6870
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
6871
|
-
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon3", children: label }),
|
|
6872
|
-
children
|
|
6873
|
-
] });
|
|
6874
|
-
};
|
|
6875
|
-
|
|
6876
|
-
const Collapsible = CollapsiblePrimitive__namespace.Root;
|
|
6877
|
-
const CollapsibleTrigger = CollapsiblePrimitive__namespace.CollapsibleTrigger;
|
|
6878
|
-
const CollapsibleContent = CollapsiblePrimitive__namespace.CollapsibleContent;
|
|
6879
|
-
|
|
6880
|
-
const formatJSON = async (code) => {
|
|
6881
|
-
const formatted = await prettier.format(code, {
|
|
6882
|
-
semi: false,
|
|
6883
|
-
parser: "json",
|
|
6884
|
-
printWidth: 80,
|
|
6885
|
-
tabWidth: 2,
|
|
6886
|
-
plugins: [prettierPluginBabel, prettierPluginEstree]
|
|
6887
|
-
});
|
|
6888
|
-
return formatted;
|
|
6889
|
-
};
|
|
6890
|
-
const isValidJson = (str) => {
|
|
6891
|
-
try {
|
|
6892
|
-
const obj = JSON.parse(str);
|
|
6893
|
-
return !!obj && typeof obj === "object";
|
|
6894
|
-
} catch (e) {
|
|
6895
|
-
return false;
|
|
6896
|
-
}
|
|
6897
|
-
};
|
|
6898
|
-
|
|
6899
|
-
const AgentAdvancedSettings = () => {
|
|
6900
|
-
const { settings, setSettings } = useAgentSettings();
|
|
6901
|
-
const [isOpen, setIsOpen] = React.useState(false);
|
|
6902
|
-
const [providerOptionsValue, setProviderOptionsValue] = React.useState("");
|
|
6903
|
-
const [saved, setSaved] = React.useState(false);
|
|
6904
|
-
const [error, setError] = React.useState(null);
|
|
6905
|
-
const theme = useCodemirrorTheme();
|
|
6906
|
-
const { handleCopy } = useCopyToClipboard({ text: providerOptionsValue });
|
|
6907
|
-
const providerOptionsStr = JSON.stringify(settings?.modelSettings?.providerOptions ?? {});
|
|
6908
|
-
React.useEffect(() => {
|
|
6909
|
-
const run = async () => {
|
|
6910
|
-
if (!isValidJson(providerOptionsStr)) {
|
|
6911
|
-
setError("Invalid JSON");
|
|
6912
|
-
return;
|
|
6913
|
-
}
|
|
6914
|
-
const formatted = await formatJSON(providerOptionsStr);
|
|
6915
|
-
setProviderOptionsValue(formatted);
|
|
6916
|
-
};
|
|
6917
|
-
run();
|
|
6918
|
-
}, [providerOptionsStr]);
|
|
6919
|
-
const formatProviderOptions = async () => {
|
|
6920
|
-
setError(null);
|
|
6921
|
-
if (!isValidJson(providerOptionsValue)) {
|
|
6922
|
-
setError("Invalid JSON");
|
|
6923
|
-
return;
|
|
6924
|
-
}
|
|
6925
|
-
const formatted = await formatJSON(providerOptionsValue);
|
|
6926
|
-
setProviderOptionsValue(formatted);
|
|
6927
|
-
};
|
|
6928
|
-
const saveProviderOptions = async () => {
|
|
6929
|
-
try {
|
|
6930
|
-
setError(null);
|
|
6931
|
-
const parsedContext = JSON.parse(providerOptionsValue);
|
|
6932
|
-
setSettings({
|
|
6933
|
-
...settings,
|
|
6934
|
-
modelSettings: {
|
|
6935
|
-
...settings?.modelSettings,
|
|
6936
|
-
providerOptions: parsedContext
|
|
6937
|
-
}
|
|
6938
|
-
});
|
|
6939
|
-
setSaved(true);
|
|
6940
|
-
setTimeout(() => {
|
|
6941
|
-
setSaved(false);
|
|
6942
|
-
}, 1e3);
|
|
6943
|
-
} catch (error2) {
|
|
6944
|
-
console.error("error", error2);
|
|
6945
|
-
setError("Invalid JSON");
|
|
6282
|
+
});
|
|
6283
|
+
setSaved(true);
|
|
6284
|
+
setTimeout(() => {
|
|
6285
|
+
setSaved(false);
|
|
6286
|
+
}, 1e3);
|
|
6287
|
+
} catch (error2) {
|
|
6288
|
+
console.error("error", error2);
|
|
6289
|
+
setError("Invalid JSON");
|
|
6946
6290
|
}
|
|
6947
6291
|
};
|
|
6948
6292
|
const collapsibleClassName = "rounded-lg border-sm border-border1 bg-surface3 overflow-clip";
|
|
@@ -7181,6 +6525,93 @@ const EmptyState = ({
|
|
|
7181
6525
|
] });
|
|
7182
6526
|
};
|
|
7183
6527
|
|
|
6528
|
+
const rowSize = {
|
|
6529
|
+
default: "[&>tbody>tr]:h-table-row",
|
|
6530
|
+
small: "[&>tbody>tr]:h-table-row-small"
|
|
6531
|
+
};
|
|
6532
|
+
const Table = ({ className, children, size = "default" }) => {
|
|
6533
|
+
return /* @__PURE__ */ jsxRuntime.jsx("table", { className: clsx("w-full", rowSize[size], className), children });
|
|
6534
|
+
};
|
|
6535
|
+
const Thead = ({ className, children }) => {
|
|
6536
|
+
return /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { className: clsx("h-table-header border-b-sm border-border1", className), children }) });
|
|
6537
|
+
};
|
|
6538
|
+
const Th = ({ className, children, ...props }) => {
|
|
6539
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6540
|
+
"th",
|
|
6541
|
+
{
|
|
6542
|
+
className: clsx(
|
|
6543
|
+
"text-icon3 text-ui-sm h-full text-left font-normal uppercase first:pl-5 last:pr-5 whitespace-nowrap",
|
|
6544
|
+
className
|
|
6545
|
+
),
|
|
6546
|
+
...props,
|
|
6547
|
+
children
|
|
6548
|
+
}
|
|
6549
|
+
);
|
|
6550
|
+
};
|
|
6551
|
+
const Tbody = ({ className, children }) => {
|
|
6552
|
+
return /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: clsx("", className), children });
|
|
6553
|
+
};
|
|
6554
|
+
const Row = ({ className, children, selected = false, onClick }) => {
|
|
6555
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6556
|
+
"tr",
|
|
6557
|
+
{
|
|
6558
|
+
className: clsx(
|
|
6559
|
+
"border-b-sm border-border1 hover:bg-surface3",
|
|
6560
|
+
selected && "bg-surface4",
|
|
6561
|
+
onClick && "cursor-pointer",
|
|
6562
|
+
className
|
|
6563
|
+
),
|
|
6564
|
+
onClick,
|
|
6565
|
+
children
|
|
6566
|
+
}
|
|
6567
|
+
);
|
|
6568
|
+
};
|
|
6569
|
+
|
|
6570
|
+
const formatDateCell = (date) => {
|
|
6571
|
+
const month = new Intl.DateTimeFormat("en-US", { month: "short" }).format(date).toUpperCase();
|
|
6572
|
+
const day = date.getDate();
|
|
6573
|
+
const formattedDay = `${month} ${day}`;
|
|
6574
|
+
const time = new Intl.DateTimeFormat("en-US", {
|
|
6575
|
+
hour: "2-digit",
|
|
6576
|
+
minute: "2-digit",
|
|
6577
|
+
second: "2-digit",
|
|
6578
|
+
hour12: false
|
|
6579
|
+
// Use 24-hour format
|
|
6580
|
+
}).format(date);
|
|
6581
|
+
return { day: formattedDay, time };
|
|
6582
|
+
};
|
|
6583
|
+
|
|
6584
|
+
const Cell = ({ className, children, ...props }) => {
|
|
6585
|
+
return /* @__PURE__ */ jsxRuntime.jsx("td", { className: clsx("text-icon5 first:pl-5 last:pr-5", className), ...props, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx("flex h-full w-full shrink-0 items-center"), children }) });
|
|
6586
|
+
};
|
|
6587
|
+
const TxtCell = ({ className, children }) => {
|
|
6588
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Cell, { className, children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", className: "w-full truncate", children }) });
|
|
6589
|
+
};
|
|
6590
|
+
const UnitCell = ({ className, children, unit }) => {
|
|
6591
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Cell, { className, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center", children: [
|
|
6592
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", className: "shrink-0", children }),
|
|
6593
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3 w-full truncate", children: unit })
|
|
6594
|
+
] }) });
|
|
6595
|
+
};
|
|
6596
|
+
const DateTimeCell = ({ dateTime, ...props }) => {
|
|
6597
|
+
const { day, time } = formatDateCell(dateTime);
|
|
6598
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Cell, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0", children: [
|
|
6599
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3", children: day }),
|
|
6600
|
+
" ",
|
|
6601
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", children: time })
|
|
6602
|
+
] }) });
|
|
6603
|
+
};
|
|
6604
|
+
const EntryCell = ({ name, description, icon, meta, ...props }) => {
|
|
6605
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Cell, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[14px]", children: [
|
|
6606
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "lg", className: "text-icon5", children: icon }),
|
|
6607
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-0", children: [
|
|
6608
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", className: "text-icon6 font-medium !leading-tight", children: name }),
|
|
6609
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-xs", className: "text-icon3 w-full max-w-[300px] truncate !leading-tight", children: description })
|
|
6610
|
+
] }),
|
|
6611
|
+
meta
|
|
6612
|
+
] }) });
|
|
6613
|
+
};
|
|
6614
|
+
|
|
7184
6615
|
const INDICATOR_WIDTH = 40;
|
|
7185
6616
|
const INDICATOR_HEIGHT = 150;
|
|
7186
6617
|
const INDICATOR_SPACE = 10;
|
|
@@ -7807,6 +7238,7 @@ const columns$2 = [
|
|
|
7807
7238
|
{
|
|
7808
7239
|
variant: "default",
|
|
7809
7240
|
icon: providerMapToIcon[row.original.provider] || /* @__PURE__ */ jsxRuntime.jsx(OpenAIIcon, {}),
|
|
7241
|
+
className: "truncate",
|
|
7810
7242
|
children: row.original.modelId || "N/A"
|
|
7811
7243
|
}
|
|
7812
7244
|
) });
|
|
@@ -7932,49 +7364,540 @@ const RuntimeContext = () => {
|
|
|
7932
7364
|
sonner.toast.error("Invalid JSON");
|
|
7933
7365
|
return;
|
|
7934
7366
|
}
|
|
7935
|
-
const formatted = await formatJSON(runtimeContextValue);
|
|
7936
|
-
setRuntimeContextValue(formatted);
|
|
7937
|
-
};
|
|
7938
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
7939
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between pb-2", children: [
|
|
7940
|
-
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "label", variant: "ui-md", className: "text-icon3", children: "Runtime Context (JSON)" }),
|
|
7941
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
7942
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
7943
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: formatRuntimeContext, className: buttonClass, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Braces, {}) }) }) }),
|
|
7944
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: "Format the Runtime Context JSON" })
|
|
7945
|
-
] }),
|
|
7946
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
7947
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: handleCopy, className: buttonClass, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, {}) }) }) }),
|
|
7948
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: "Copy Runtime Context" })
|
|
7949
|
-
] })
|
|
7367
|
+
const formatted = await formatJSON(runtimeContextValue);
|
|
7368
|
+
setRuntimeContextValue(formatted);
|
|
7369
|
+
};
|
|
7370
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
7371
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between pb-2", children: [
|
|
7372
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "label", variant: "ui-md", className: "text-icon3", children: "Runtime Context (JSON)" }),
|
|
7373
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
7374
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
7375
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: formatRuntimeContext, className: buttonClass, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Braces, {}) }) }) }),
|
|
7376
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: "Format the Runtime Context JSON" })
|
|
7377
|
+
] }),
|
|
7378
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
7379
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: handleCopy, className: buttonClass, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, {}) }) }) }),
|
|
7380
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: "Copy Runtime Context" })
|
|
7381
|
+
] })
|
|
7382
|
+
] })
|
|
7383
|
+
] }),
|
|
7384
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7385
|
+
CodeMirror,
|
|
7386
|
+
{
|
|
7387
|
+
value: runtimeContextValue,
|
|
7388
|
+
onChange: setRuntimeContextValue,
|
|
7389
|
+
theme,
|
|
7390
|
+
extensions: [langJson.jsonLanguage],
|
|
7391
|
+
className: "h-[400px] overflow-y-scroll bg-surface3 rounded-lg overflow-hidden p-3"
|
|
7392
|
+
}
|
|
7393
|
+
),
|
|
7394
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end pt-2", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: handleSaveRuntimeContext, children: "Save" }) })
|
|
7395
|
+
] }) });
|
|
7396
|
+
};
|
|
7397
|
+
const RuntimeContextWrapper = ({ children }) => {
|
|
7398
|
+
const { Link } = useLinkComponent();
|
|
7399
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-3xl p-5 overflow-y-scroll h-full", children: [
|
|
7400
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg p-4 pb-5 bg-surface4 shadow-md space-y-3 border border-border1 mb-5", children: [
|
|
7401
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-lg", className: "text-icon3", children: "Mastra provides runtime context, which is a system based on dependency injection that enables you to configure your agents and tools with runtime variables. If you find yourself creating several different agents that do very similar things, runtime context allows you to combine them into one agent." }),
|
|
7402
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button, { as: Link, to: "https://mastra.ai/en/docs/agents/runtime-variables", target: "_blank", children: [
|
|
7403
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, {}) }),
|
|
7404
|
+
"See documentation"
|
|
7405
|
+
] })
|
|
7406
|
+
] }),
|
|
7407
|
+
children
|
|
7408
|
+
] });
|
|
7409
|
+
};
|
|
7410
|
+
|
|
7411
|
+
const AgentMetadataSection = ({ title, children, hint }) => {
|
|
7412
|
+
const { Link } = useLinkComponent();
|
|
7413
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-2 pb-7 last:pb-0", children: [
|
|
7414
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { as: "h3", variant: "ui-md", className: "text-icon3 flex items-center gap-1", children: [
|
|
7415
|
+
title,
|
|
7416
|
+
hint && /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
7417
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: hint.link, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "text-icon3", size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, {}) }) }) }),
|
|
7418
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: hint.title })
|
|
7419
|
+
] }) })
|
|
7420
|
+
] }),
|
|
7421
|
+
children
|
|
7422
|
+
] });
|
|
7423
|
+
};
|
|
7424
|
+
|
|
7425
|
+
const AgentMetadataList = ({ children }) => {
|
|
7426
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-wrap gap-2", children });
|
|
7427
|
+
};
|
|
7428
|
+
const AgentMetadataListItem = ({ children }) => {
|
|
7429
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { className: "shrink-0 font-medium", children });
|
|
7430
|
+
};
|
|
7431
|
+
const AgentMetadataListEmpty = ({ children }) => {
|
|
7432
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon6", children });
|
|
7433
|
+
};
|
|
7434
|
+
|
|
7435
|
+
const AgentMetadataWrapper = ({ children }) => {
|
|
7436
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-2 overflow-y-auto h-full px-5", children });
|
|
7437
|
+
};
|
|
7438
|
+
|
|
7439
|
+
const useScoresByEntityId = (entityId, entityType, page = 0) => {
|
|
7440
|
+
const client = useMastraClient();
|
|
7441
|
+
const [scores, setScores] = React.useState(null);
|
|
7442
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
7443
|
+
React.useEffect(() => {
|
|
7444
|
+
const fetchScores = async () => {
|
|
7445
|
+
setIsLoading(true);
|
|
7446
|
+
try {
|
|
7447
|
+
const res = await client.getScoresByEntityId({
|
|
7448
|
+
entityId,
|
|
7449
|
+
entityType,
|
|
7450
|
+
page: page || 0,
|
|
7451
|
+
perPage: 10
|
|
7452
|
+
});
|
|
7453
|
+
setScores(res);
|
|
7454
|
+
setIsLoading(false);
|
|
7455
|
+
} catch (error) {
|
|
7456
|
+
setScores(null);
|
|
7457
|
+
setIsLoading(false);
|
|
7458
|
+
}
|
|
7459
|
+
};
|
|
7460
|
+
fetchScores();
|
|
7461
|
+
}, [entityId, entityType, page]);
|
|
7462
|
+
return { scores, isLoading };
|
|
7463
|
+
};
|
|
7464
|
+
const useScoresByScorerId = ({ scorerId, page = 0, entityId, entityType }) => {
|
|
7465
|
+
const client = useMastraClient();
|
|
7466
|
+
const [scores, setScores] = React.useState(null);
|
|
7467
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
7468
|
+
React.useEffect(() => {
|
|
7469
|
+
const fetchScores = async () => {
|
|
7470
|
+
setIsLoading(true);
|
|
7471
|
+
try {
|
|
7472
|
+
const res = await client.getScoresByScorerId({
|
|
7473
|
+
scorerId,
|
|
7474
|
+
page: page || 0,
|
|
7475
|
+
entityId: entityId || void 0,
|
|
7476
|
+
entityType: entityType || void 0,
|
|
7477
|
+
perPage: 10
|
|
7478
|
+
});
|
|
7479
|
+
setScores(res);
|
|
7480
|
+
setIsLoading(false);
|
|
7481
|
+
} catch (error) {
|
|
7482
|
+
setScores(null);
|
|
7483
|
+
setIsLoading(false);
|
|
7484
|
+
}
|
|
7485
|
+
};
|
|
7486
|
+
fetchScores();
|
|
7487
|
+
}, [scorerId, page, entityId, entityType]);
|
|
7488
|
+
return { scores, isLoading };
|
|
7489
|
+
};
|
|
7490
|
+
const useScorer = (scorerId) => {
|
|
7491
|
+
const client = useMastraClient();
|
|
7492
|
+
const [scorer, setScorer] = React.useState(null);
|
|
7493
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
7494
|
+
React.useEffect(() => {
|
|
7495
|
+
const fetchScorer = async () => {
|
|
7496
|
+
setIsLoading(true);
|
|
7497
|
+
try {
|
|
7498
|
+
const res = await client.getScorer(scorerId);
|
|
7499
|
+
setScorer(res);
|
|
7500
|
+
} catch (error) {
|
|
7501
|
+
setScorer(null);
|
|
7502
|
+
console.error("Error fetching scorer", error);
|
|
7503
|
+
sonner.toast.error("Error fetching scorer");
|
|
7504
|
+
} finally {
|
|
7505
|
+
setIsLoading(false);
|
|
7506
|
+
}
|
|
7507
|
+
};
|
|
7508
|
+
fetchScorer();
|
|
7509
|
+
}, [scorerId]);
|
|
7510
|
+
return { scorer, isLoading };
|
|
7511
|
+
};
|
|
7512
|
+
const useScorers = () => {
|
|
7513
|
+
const client = useMastraClient();
|
|
7514
|
+
const [scorers, setScorers] = React.useState({});
|
|
7515
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
7516
|
+
React.useEffect(() => {
|
|
7517
|
+
const fetchScorers = async () => {
|
|
7518
|
+
setIsLoading(true);
|
|
7519
|
+
try {
|
|
7520
|
+
const res = await client.getScorers();
|
|
7521
|
+
setScorers(res);
|
|
7522
|
+
} catch (error) {
|
|
7523
|
+
setScorers({});
|
|
7524
|
+
console.error("Error fetching agents", error);
|
|
7525
|
+
sonner.toast.error("Error fetching agents");
|
|
7526
|
+
} finally {
|
|
7527
|
+
setIsLoading(false);
|
|
7528
|
+
}
|
|
7529
|
+
};
|
|
7530
|
+
fetchScorers();
|
|
7531
|
+
}, []);
|
|
7532
|
+
return { scorers, isLoading };
|
|
7533
|
+
};
|
|
7534
|
+
|
|
7535
|
+
const Entity = ({ children, className, onClick }) => {
|
|
7536
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7537
|
+
"div",
|
|
7538
|
+
{
|
|
7539
|
+
tabIndex: onClick ? 0 : void 0,
|
|
7540
|
+
onKeyDown: (e) => {
|
|
7541
|
+
if (!onClick) return;
|
|
7542
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
7543
|
+
e.preventDefault();
|
|
7544
|
+
onClick?.();
|
|
7545
|
+
}
|
|
7546
|
+
},
|
|
7547
|
+
className: clsx(
|
|
7548
|
+
"flex gap-3 group/entity bg-surface3 rounded-lg border-sm border-border1 py-3 px-4",
|
|
7549
|
+
onClick && "cursor-pointer hover:bg-surface4 transition-all",
|
|
7550
|
+
className
|
|
7551
|
+
),
|
|
7552
|
+
onClick,
|
|
7553
|
+
children
|
|
7554
|
+
}
|
|
7555
|
+
);
|
|
7556
|
+
};
|
|
7557
|
+
const EntityIcon = ({ children, className }) => {
|
|
7558
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "lg", className: clsx("text-icon3 mt-1", className), children });
|
|
7559
|
+
};
|
|
7560
|
+
const EntityName = ({ children, className }) => {
|
|
7561
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-lg", className: clsx("text-icon6 font-medium", className), children });
|
|
7562
|
+
};
|
|
7563
|
+
const EntityDescription = ({ children, className }) => {
|
|
7564
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-sm", className: clsx("text-icon3", className), children });
|
|
7565
|
+
};
|
|
7566
|
+
const EntityContent = ({ children, className }) => {
|
|
7567
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children });
|
|
7568
|
+
};
|
|
7569
|
+
|
|
7570
|
+
const ScorerList = ({ entityId, entityType }) => {
|
|
7571
|
+
const { scorers, isLoading } = useScorers();
|
|
7572
|
+
if (isLoading) {
|
|
7573
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ScorerSkeleton, {});
|
|
7574
|
+
}
|
|
7575
|
+
const scorerList = Object.keys(scorers).filter((scorerKey) => {
|
|
7576
|
+
const scorer = scorers[scorerKey];
|
|
7577
|
+
if (entityType === "AGENT") {
|
|
7578
|
+
return scorer.agentIds.includes(entityId);
|
|
7579
|
+
}
|
|
7580
|
+
return scorer.workflowIds.includes(entityId);
|
|
7581
|
+
}).map((scorerKey) => ({ ...scorers[scorerKey], id: scorerKey }));
|
|
7582
|
+
if (scorerList.length === 0) {
|
|
7583
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EmptyScorerList, {});
|
|
7584
|
+
}
|
|
7585
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2", children: scorerList.map((scorer) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(ScorerEntity, { scorer }) }, scorer.id)) });
|
|
7586
|
+
};
|
|
7587
|
+
const EmptyScorerList = () => {
|
|
7588
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-lg", className: "text-icon6", children: "No scorers were attached to this agent." });
|
|
7589
|
+
};
|
|
7590
|
+
const ScorerSkeleton = () => {
|
|
7591
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
7592
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-24" }),
|
|
7593
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-24" })
|
|
7594
|
+
] });
|
|
7595
|
+
};
|
|
7596
|
+
const ScorerEntity = ({ scorer }) => {
|
|
7597
|
+
const { Link } = useLinkComponent();
|
|
7598
|
+
const linkRef = React.useRef(null);
|
|
7599
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Entity, { onClick: () => linkRef.current?.click(), children: [
|
|
7600
|
+
/* @__PURE__ */ jsxRuntime.jsx(EntityIcon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GaugeIcon, { className: "group-hover/entity:text-accent3" }) }),
|
|
7601
|
+
/* @__PURE__ */ jsxRuntime.jsxs(EntityContent, { children: [
|
|
7602
|
+
/* @__PURE__ */ jsxRuntime.jsx(EntityName, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { ref: linkRef, href: `/scorers/${scorer.id}`, children: scorer.scorer.name }) }),
|
|
7603
|
+
/* @__PURE__ */ jsxRuntime.jsx(EntityDescription, { children: scorer.scorer.description }),
|
|
7604
|
+
scorer.sampling?.type === "ratio" && /* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { children: [
|
|
7605
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-icon3", children: "Sample rate:" }),
|
|
7606
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-icon6", children: scorer.sampling.rate })
|
|
7950
7607
|
] })
|
|
7951
|
-
] })
|
|
7608
|
+
] })
|
|
7609
|
+
] });
|
|
7610
|
+
};
|
|
7611
|
+
|
|
7612
|
+
const AgentMetadata = ({
|
|
7613
|
+
agent,
|
|
7614
|
+
promptSlot,
|
|
7615
|
+
hasMemoryEnabled,
|
|
7616
|
+
computeToolLink,
|
|
7617
|
+
computeWorkflowLink
|
|
7618
|
+
}) => {
|
|
7619
|
+
const providerIcon = providerMapToIcon[agent.provider || "openai.chat"];
|
|
7620
|
+
const agentTools = agent.tools ?? {};
|
|
7621
|
+
const tools = Object.keys(agentTools).map((key) => agentTools[key]);
|
|
7622
|
+
const agentWorkflows = agent.workflows ?? {};
|
|
7623
|
+
const workflows = Object.keys(agentWorkflows).map((key) => agentWorkflows[key]);
|
|
7624
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(AgentMetadataWrapper, { children: [
|
|
7625
|
+
/* @__PURE__ */ jsxRuntime.jsx(AgentMetadataSection, { title: "Model", children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: providerIcon, className: "font-medium", children: agent.modelId || "N/A" }) }),
|
|
7952
7626
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7953
|
-
|
|
7627
|
+
AgentMetadataSection,
|
|
7954
7628
|
{
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7629
|
+
title: "Memory",
|
|
7630
|
+
hint: {
|
|
7631
|
+
link: "https://mastra.ai/en/docs/agents/agent-memory",
|
|
7632
|
+
title: "Agent Memory documentation"
|
|
7633
|
+
},
|
|
7634
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(MemoryIcon, {}), variant: hasMemoryEnabled ? "success" : "error", className: "font-medium", children: hasMemoryEnabled ? "On" : "Off" })
|
|
7960
7635
|
}
|
|
7961
7636
|
),
|
|
7962
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7963
|
-
|
|
7637
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7638
|
+
AgentMetadataSection,
|
|
7639
|
+
{
|
|
7640
|
+
title: "Tools",
|
|
7641
|
+
hint: {
|
|
7642
|
+
link: "https://mastra.ai/en/docs/agents/using-tools-and-mcp",
|
|
7643
|
+
title: "Using Tools and MCP documentation"
|
|
7644
|
+
},
|
|
7645
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataToolList, { tools, computeToolLink })
|
|
7646
|
+
}
|
|
7647
|
+
),
|
|
7648
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7649
|
+
AgentMetadataSection,
|
|
7650
|
+
{
|
|
7651
|
+
title: "Workflows",
|
|
7652
|
+
hint: {
|
|
7653
|
+
link: "https://mastra.ai/en/docs/workflows/overview",
|
|
7654
|
+
title: "Workflows documentation"
|
|
7655
|
+
},
|
|
7656
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataWorkflowList, { workflows, computeWorkflowLink })
|
|
7657
|
+
}
|
|
7658
|
+
),
|
|
7659
|
+
/* @__PURE__ */ jsxRuntime.jsx(AgentMetadataSection, { title: "Scorers", children: /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataScorerList, { entityId: agent.name }) }),
|
|
7660
|
+
/* @__PURE__ */ jsxRuntime.jsx(AgentMetadataSection, { title: "System Prompt", children: promptSlot })
|
|
7661
|
+
] });
|
|
7964
7662
|
};
|
|
7965
|
-
const
|
|
7663
|
+
const AgentMetadataToolList = ({ tools, computeToolLink }) => {
|
|
7966
7664
|
const { Link } = useLinkComponent();
|
|
7967
|
-
|
|
7968
|
-
/* @__PURE__ */ jsxRuntime.
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7665
|
+
if (tools.length === 0) {
|
|
7666
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListEmpty, { children: "No tools" });
|
|
7667
|
+
}
|
|
7668
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: tools.map((tool) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: computeToolLink(tool), children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(ToolsIcon, { className: "text-[#ECB047]" }), children: tool.id }) }) }, tool.id)) });
|
|
7669
|
+
};
|
|
7670
|
+
const AgentMetadataScorerList = ({ entityId }) => {
|
|
7671
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-5 pb-5", children: /* @__PURE__ */ jsxRuntime.jsx(ScorerList, { entityId, entityType: "AGENT" }) });
|
|
7672
|
+
};
|
|
7673
|
+
const AgentMetadataWorkflowList = ({ workflows, computeWorkflowLink }) => {
|
|
7674
|
+
const { Link } = useLinkComponent();
|
|
7675
|
+
if (workflows.length === 0) {
|
|
7676
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListEmpty, { children: "No workflows" });
|
|
7677
|
+
}
|
|
7678
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: workflows.map((workflow) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: computeWorkflowLink(workflow), children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(WorkflowIcon, { className: "text-accent3" }), children: workflow.name }) }) }, workflow.name)) });
|
|
7679
|
+
};
|
|
7680
|
+
|
|
7681
|
+
const AgentMetadataPrompt = ({ prompt }) => {
|
|
7682
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "bg-surface4 text-icon6 whitespace-pre-wrap rounded-lg px-2 py-1.5 text-sm", children: prompt });
|
|
7683
|
+
};
|
|
7684
|
+
|
|
7685
|
+
const EntityHeader = ({ icon, title, isLoading, children }) => {
|
|
7686
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-5", children: [
|
|
7687
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-icon6 flex items-center gap-2", children: [
|
|
7688
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "lg", className: "bg-surface4 rounded-md p-1", children: icon }),
|
|
7689
|
+
isLoading ? /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-3 w-1/3" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-w-0 items-center gap-4", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "header-md", as: "h2", className: "truncate font-medium", children: title }) })
|
|
7974
7690
|
] }),
|
|
7975
|
-
children
|
|
7691
|
+
children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-2", children })
|
|
7692
|
+
] });
|
|
7693
|
+
};
|
|
7694
|
+
|
|
7695
|
+
const AgentEntityHeader = ({ agentId, isLoading, agentName }) => {
|
|
7696
|
+
const { handleCopy } = useCopyToClipboard({ text: agentId });
|
|
7697
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(EntityHeader, { icon: /* @__PURE__ */ jsxRuntime.jsx(AgentIcon, {}), title: agentName, isLoading, children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
7698
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: handleCopy, className: "h-badge-default shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CopyIcon, {}), variant: "default", children: agentId }) }) }),
|
|
7699
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: "Copy Agent ID for use in code" })
|
|
7700
|
+
] }) }) });
|
|
7701
|
+
};
|
|
7702
|
+
|
|
7703
|
+
const Threads = ({ children }) => {
|
|
7704
|
+
return /* @__PURE__ */ jsxRuntime.jsx("nav", { className: "bg-surface2 border-r-sm border-border1 min-h-full overflow-hidden", children });
|
|
7705
|
+
};
|
|
7706
|
+
const ThreadLink = ({ children, as: Component = "a", href, className, prefetch, to }) => {
|
|
7707
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7708
|
+
Component,
|
|
7709
|
+
{
|
|
7710
|
+
href,
|
|
7711
|
+
prefetch,
|
|
7712
|
+
to,
|
|
7713
|
+
className: clsx("text-ui-sm flex h-full w-full flex-col justify-center font-medium", className),
|
|
7714
|
+
children
|
|
7715
|
+
}
|
|
7716
|
+
);
|
|
7717
|
+
};
|
|
7718
|
+
const ThreadList = ({ children }) => {
|
|
7719
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { children });
|
|
7720
|
+
};
|
|
7721
|
+
const ThreadItem = ({ children, isActive }) => {
|
|
7722
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7723
|
+
"li",
|
|
7724
|
+
{
|
|
7725
|
+
className: clsx(
|
|
7726
|
+
"border-b-sm border-border1 hover:bg-surface3 group flex h-[54px] items-center justify-between gap-2 pl-5 py-2",
|
|
7727
|
+
isActive && "bg-surface4"
|
|
7728
|
+
),
|
|
7729
|
+
children
|
|
7730
|
+
}
|
|
7731
|
+
);
|
|
7732
|
+
};
|
|
7733
|
+
const ThreadDeleteButton = ({ onClick }) => {
|
|
7734
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7735
|
+
Button,
|
|
7736
|
+
{
|
|
7737
|
+
className: "shrink-0 border-none bg-transparent opacity-0 transition-all group-focus-within:opacity-100 group-hover:opacity-100",
|
|
7738
|
+
onClick,
|
|
7739
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-label": "delete thread", className: "text-icon3" }) })
|
|
7740
|
+
}
|
|
7741
|
+
);
|
|
7742
|
+
};
|
|
7743
|
+
|
|
7744
|
+
const AlertDialogRoot = AlertDialogPrimitive__namespace.Root;
|
|
7745
|
+
const AlertDialogTrigger = AlertDialogPrimitive__namespace.Trigger;
|
|
7746
|
+
const AlertDialogPortal = AlertDialogPrimitive__namespace.Portal;
|
|
7747
|
+
function AlertDialog({
|
|
7748
|
+
open,
|
|
7749
|
+
onOpenChange,
|
|
7750
|
+
children
|
|
7751
|
+
}) {
|
|
7752
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AlertDialogRoot, { open, onOpenChange, children });
|
|
7753
|
+
}
|
|
7754
|
+
const AlertDialogOverlay = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7755
|
+
AlertDialogPrimitive__namespace.Overlay,
|
|
7756
|
+
{
|
|
7757
|
+
className: cn(
|
|
7758
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
7759
|
+
className
|
|
7760
|
+
),
|
|
7761
|
+
...props,
|
|
7762
|
+
ref
|
|
7763
|
+
}
|
|
7764
|
+
));
|
|
7765
|
+
AlertDialogOverlay.displayName = AlertDialogPrimitive__namespace.Overlay.displayName;
|
|
7766
|
+
const AlertDialogContent = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogPortal, { children: [
|
|
7767
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogOverlay, {}),
|
|
7768
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7769
|
+
AlertDialogPrimitive__namespace.Content,
|
|
7770
|
+
{
|
|
7771
|
+
ref,
|
|
7772
|
+
className: cn(
|
|
7773
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-[#141414] p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
7774
|
+
className
|
|
7775
|
+
),
|
|
7776
|
+
...props
|
|
7777
|
+
}
|
|
7778
|
+
)
|
|
7779
|
+
] }));
|
|
7780
|
+
AlertDialogContent.displayName = AlertDialogPrimitive__namespace.Content.displayName;
|
|
7781
|
+
const AlertDialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex flex-col space-y-2 text-center sm:text-left", className), ...props });
|
|
7782
|
+
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
7783
|
+
const AlertDialogFooter = ({ className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className), ...props });
|
|
7784
|
+
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
7785
|
+
const AlertDialogTitle = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Title, { ref, className: cn("text-lg font-semibold", className), ...props }));
|
|
7786
|
+
AlertDialogTitle.displayName = AlertDialogPrimitive__namespace.Title.displayName;
|
|
7787
|
+
const AlertDialogDescription = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
7788
|
+
AlertDialogDescription.displayName = AlertDialogPrimitive__namespace.Description.displayName;
|
|
7789
|
+
const AlertDialogAction = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(AlertDialogPrimitive__namespace.Action, { ref, className: cn(buttonVariants(), className), ...props }));
|
|
7790
|
+
AlertDialogAction.displayName = AlertDialogPrimitive__namespace.Action.displayName;
|
|
7791
|
+
const AlertDialogCancel = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7792
|
+
AlertDialogPrimitive__namespace.Cancel,
|
|
7793
|
+
{
|
|
7794
|
+
ref,
|
|
7795
|
+
className: cn(buttonVariants({ variant: "outline" }), "mt-2 sm:mt-0", className),
|
|
7796
|
+
...props
|
|
7797
|
+
}
|
|
7798
|
+
));
|
|
7799
|
+
AlertDialogCancel.displayName = AlertDialogPrimitive__namespace.Cancel.displayName;
|
|
7800
|
+
AlertDialog.Trigger = AlertDialogTrigger;
|
|
7801
|
+
AlertDialog.Portal = AlertDialogPortal;
|
|
7802
|
+
AlertDialog.Overlay = AlertDialogOverlay;
|
|
7803
|
+
AlertDialog.Content = AlertDialogContent;
|
|
7804
|
+
AlertDialog.Header = AlertDialogHeader;
|
|
7805
|
+
AlertDialog.Footer = AlertDialogFooter;
|
|
7806
|
+
AlertDialog.Title = AlertDialogTitle;
|
|
7807
|
+
AlertDialog.Description = AlertDialogDescription;
|
|
7808
|
+
AlertDialog.Action = AlertDialogAction;
|
|
7809
|
+
AlertDialog.Cancel = AlertDialogCancel;
|
|
7810
|
+
|
|
7811
|
+
const ChatThreads = ({
|
|
7812
|
+
computeNewThreadLink,
|
|
7813
|
+
computeThreadLink,
|
|
7814
|
+
threads,
|
|
7815
|
+
isLoading,
|
|
7816
|
+
threadId,
|
|
7817
|
+
onDelete
|
|
7818
|
+
}) => {
|
|
7819
|
+
const { Link } = useLinkComponent();
|
|
7820
|
+
const [deleteId, setDeleteId] = React.useState(null);
|
|
7821
|
+
if (isLoading) {
|
|
7822
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChatThreadSkeleton, {});
|
|
7823
|
+
}
|
|
7824
|
+
const reverseThreads = [...threads].reverse();
|
|
7825
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-y-auto h-full w-full", children: [
|
|
7826
|
+
/* @__PURE__ */ jsxRuntime.jsx(Threads, { children: /* @__PURE__ */ jsxRuntime.jsxs(ThreadList, { children: [
|
|
7827
|
+
/* @__PURE__ */ jsxRuntime.jsx(ThreadItem, { children: /* @__PURE__ */ jsxRuntime.jsx(ThreadLink, { as: Link, to: computeNewThreadLink(), children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-accent1 flex items-center gap-4", children: [
|
|
7828
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "bg-surface4 rounded-lg", size: "lg", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, {}) }),
|
|
7829
|
+
"New Chat"
|
|
7830
|
+
] }) }) }),
|
|
7831
|
+
reverseThreads.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-sm", className: "text-icon3 py-3 px-5 max-w-[12rem]", children: "Your conversations will appear here once you start chatting!" }),
|
|
7832
|
+
reverseThreads.map((thread) => {
|
|
7833
|
+
const isActive = thread.id === threadId;
|
|
7834
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ThreadItem, { isActive, children: [
|
|
7835
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ThreadLink, { as: Link, to: computeThreadLink(thread.id), children: [
|
|
7836
|
+
/* @__PURE__ */ jsxRuntime.jsx(ThreadTitle, { title: thread.title }),
|
|
7837
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDay(thread.createdAt) })
|
|
7838
|
+
] }),
|
|
7839
|
+
/* @__PURE__ */ jsxRuntime.jsx(ThreadDeleteButton, { onClick: () => setDeleteId(thread.id) })
|
|
7840
|
+
] }, thread.id);
|
|
7841
|
+
})
|
|
7842
|
+
] }) }),
|
|
7843
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7844
|
+
DeleteThreadDialog,
|
|
7845
|
+
{
|
|
7846
|
+
open: !!deleteId,
|
|
7847
|
+
onOpenChange: () => setDeleteId(null),
|
|
7848
|
+
onDelete: () => {
|
|
7849
|
+
if (deleteId) {
|
|
7850
|
+
onDelete(deleteId);
|
|
7851
|
+
}
|
|
7852
|
+
}
|
|
7853
|
+
}
|
|
7854
|
+
)
|
|
7976
7855
|
] });
|
|
7977
7856
|
};
|
|
7857
|
+
const DeleteThreadDialog = ({ open, onOpenChange, onDelete }) => {
|
|
7858
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AlertDialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(AlertDialog.Content, { children: [
|
|
7859
|
+
/* @__PURE__ */ jsxRuntime.jsxs(AlertDialog.Header, { children: [
|
|
7860
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDialog.Title, { children: "Are you absolutely sure?" }),
|
|
7861
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDialog.Description, { children: "This action cannot be undone. This will permanently delete your chat and remove it from our servers." })
|
|
7862
|
+
] }),
|
|
7863
|
+
/* @__PURE__ */ jsxRuntime.jsxs(AlertDialog.Footer, { children: [
|
|
7864
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDialog.Cancel, { children: "Cancel" }),
|
|
7865
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDialog.Action, { onClick: onDelete, children: "Continue" })
|
|
7866
|
+
] })
|
|
7867
|
+
] }) });
|
|
7868
|
+
};
|
|
7869
|
+
const ChatThreadSkeleton = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4 w-full h-full space-y-2", children: [
|
|
7870
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-9 w-9" }) }),
|
|
7871
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4" }),
|
|
7872
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4" }),
|
|
7873
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4" }),
|
|
7874
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4" }),
|
|
7875
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4" })
|
|
7876
|
+
] });
|
|
7877
|
+
function isDefaultThreadName(name) {
|
|
7878
|
+
const defaultPattern = /^New Thread \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
|
|
7879
|
+
return defaultPattern.test(name);
|
|
7880
|
+
}
|
|
7881
|
+
function ThreadTitle({ title }) {
|
|
7882
|
+
if (!title) {
|
|
7883
|
+
return null;
|
|
7884
|
+
}
|
|
7885
|
+
if (isDefaultThreadName(title)) {
|
|
7886
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Chat from" });
|
|
7887
|
+
}
|
|
7888
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate max-w-[14rem]", children: title });
|
|
7889
|
+
}
|
|
7890
|
+
const formatDay = (date) => {
|
|
7891
|
+
const options = {
|
|
7892
|
+
month: "short",
|
|
7893
|
+
day: "numeric",
|
|
7894
|
+
hour: "numeric",
|
|
7895
|
+
minute: "numeric",
|
|
7896
|
+
second: "numeric",
|
|
7897
|
+
hour12: true
|
|
7898
|
+
};
|
|
7899
|
+
return new Date(date).toLocaleString("en-us", options).replace(",", " at");
|
|
7900
|
+
};
|
|
7978
7901
|
|
|
7979
7902
|
const convertMessage$1 = (message) => {
|
|
7980
7903
|
return message;
|
|
@@ -8440,6 +8363,10 @@ const useVNextNetworkChat = () => {
|
|
|
8440
8363
|
return context;
|
|
8441
8364
|
};
|
|
8442
8365
|
|
|
8366
|
+
const toSigFigs = (num, sigFigs) => {
|
|
8367
|
+
return Number(num.toPrecision(sigFigs));
|
|
8368
|
+
};
|
|
8369
|
+
|
|
8443
8370
|
const Clock = ({ startedAt, endedAt }) => {
|
|
8444
8371
|
const [time, setTime] = React.useState(startedAt);
|
|
8445
8372
|
React.useEffect(() => {
|
|
@@ -9418,7 +9345,8 @@ const WorkflowStepActionBar = ({
|
|
|
9418
9345
|
onShowTrace,
|
|
9419
9346
|
onShowNestedGraph,
|
|
9420
9347
|
onSendEvent,
|
|
9421
|
-
runId
|
|
9348
|
+
runId,
|
|
9349
|
+
status
|
|
9422
9350
|
}) => {
|
|
9423
9351
|
const [isInputOpen, setIsInputOpen] = React.useState(false);
|
|
9424
9352
|
const [isOutputOpen, setIsOutputOpen] = React.useState(false);
|
|
@@ -9429,71 +9357,84 @@ const WorkflowStepActionBar = ({
|
|
|
9429
9357
|
const dialogContentClass = "bg-surface2 rounded-lg border-sm border-border1 max-w-4xl w-full px-0";
|
|
9430
9358
|
const dialogTitleClass = "border-b-sm border-border1 pb-4 px-6";
|
|
9431
9359
|
const showEventForm = event && onSendEvent && runId;
|
|
9432
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: (input || output || error || mapConfig || resumeData || onShowNestedGraph || showEventForm) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
|
|
9360
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: (input || output || error || mapConfig || resumeData || onShowNestedGraph || showEventForm) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
9361
|
+
"div",
|
|
9362
|
+
{
|
|
9363
|
+
className: cn(
|
|
9364
|
+
"flex flex-wrap items-center bg-surface4 border-t-sm border-border1 px-2 py-1 gap-2 rounded-b-lg",
|
|
9365
|
+
status === "success" && "bg-accent1Dark",
|
|
9366
|
+
status === "failed" && "bg-accent2Dark",
|
|
9367
|
+
status === "suspended" && "bg-accent3Dark",
|
|
9368
|
+
status === "waiting" && "bg-accent5Dark",
|
|
9369
|
+
status === "running" && "bg-accent6Dark"
|
|
9370
|
+
),
|
|
9371
|
+
children: [
|
|
9372
|
+
onShowNestedGraph && /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: onShowNestedGraph, children: "View nested graph" }),
|
|
9373
|
+
mapConfig && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9374
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsMapConfigOpen(true), children: "Map config" }),
|
|
9375
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isMapConfigOpen, onOpenChange: setIsMapConfigOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
9376
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
9377
|
+
stepName,
|
|
9378
|
+
" map config"
|
|
9379
|
+
] }),
|
|
9380
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: mapConfig }) })
|
|
9381
|
+
] }) })
|
|
9450
9382
|
] }),
|
|
9451
|
-
/* @__PURE__ */ jsxRuntime.
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9459
|
-
|
|
9383
|
+
input && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9384
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsInputOpen(true), children: "Input" }),
|
|
9385
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isInputOpen, onOpenChange: setIsInputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
9386
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
9387
|
+
stepName,
|
|
9388
|
+
" input"
|
|
9389
|
+
] }),
|
|
9390
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: input }) })
|
|
9391
|
+
] }) })
|
|
9460
9392
|
] }),
|
|
9461
|
-
/* @__PURE__ */ jsxRuntime.
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9393
|
+
resumeData && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9394
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsResumeDataOpen(true), children: "Resume data" }),
|
|
9395
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isResumeDataOpen, onOpenChange: setIsResumeDataOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
9396
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
9397
|
+
stepName,
|
|
9398
|
+
" resume data"
|
|
9399
|
+
] }),
|
|
9400
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: resumeData }) })
|
|
9401
|
+
] }) })
|
|
9470
9402
|
] }),
|
|
9471
|
-
/* @__PURE__ */ jsxRuntime.
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9403
|
+
output && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9404
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsOutputOpen(true), children: "Output" }),
|
|
9405
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOutputOpen, onOpenChange: setIsOutputOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
9406
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
9407
|
+
stepName,
|
|
9408
|
+
" output"
|
|
9409
|
+
] }),
|
|
9410
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: output }) })
|
|
9411
|
+
] }) })
|
|
9480
9412
|
] }),
|
|
9481
|
-
/* @__PURE__ */ jsxRuntime.
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
event,
|
|
9491
|
-
" event"
|
|
9413
|
+
error && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9414
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: () => setIsErrorOpen(true), children: "Error" }),
|
|
9415
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isErrorOpen, onOpenChange: setIsErrorOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
9416
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
9417
|
+
stepName,
|
|
9418
|
+
" error"
|
|
9419
|
+
] }),
|
|
9420
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(CodeDialogContent, { data: error }) })
|
|
9421
|
+
] }) })
|
|
9492
9422
|
] }),
|
|
9493
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9423
|
+
onShowTrace && /* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: onShowTrace, children: "Show trace" }),
|
|
9424
|
+
showEventForm && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9425
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { className: "ring-1 ring-accent5 !text-accent5", onClick: () => setIsEventFormOpen(true), children: "Send event" }),
|
|
9426
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isEventFormOpen, onOpenChange: setIsEventFormOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: dialogContentClass, children: [
|
|
9427
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: dialogTitleClass, children: [
|
|
9428
|
+
"Send ",
|
|
9429
|
+
event,
|
|
9430
|
+
" event"
|
|
9431
|
+
] }),
|
|
9432
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowRunEventForm, { event, runId, onSendEvent }) })
|
|
9433
|
+
] }) })
|
|
9434
|
+
] })
|
|
9435
|
+
]
|
|
9436
|
+
}
|
|
9437
|
+
) });
|
|
9497
9438
|
};
|
|
9498
9439
|
|
|
9499
9440
|
function WorkflowConditionNode({ data }) {
|
|
@@ -9512,8 +9453,8 @@ function WorkflowConditionNode({ data }) {
|
|
|
9512
9453
|
{
|
|
9513
9454
|
className: cn(
|
|
9514
9455
|
"bg-surface3 rounded-lg w-[300px] border-sm border-border1",
|
|
9515
|
-
previousStep?.status === "success" && nextStep && "ring-2 ring-accent1",
|
|
9516
|
-
previousStep?.status === "failed" && nextStep && "ring-2 ring-accent2"
|
|
9456
|
+
previousStep?.status === "success" && nextStep && "ring-2 ring-accent1 bg-accent1Darker",
|
|
9457
|
+
previousStep?.status === "failed" && nextStep && "ring-2 ring-accent2 bg-accent2Darker"
|
|
9517
9458
|
),
|
|
9518
9459
|
children: [
|
|
9519
9460
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -9542,7 +9483,12 @@ function WorkflowConditionNode({ data }) {
|
|
|
9542
9483
|
/* @__PURE__ */ jsxRuntime.jsx(prismReactRenderer.Highlight, { theme: prismReactRenderer.themes.oneDark, code: String(condition.fnString).trim(), language: "javascript", children: ({ className, style, tokens, getLineProps, getTokenProps }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
9543
9484
|
"pre",
|
|
9544
9485
|
{
|
|
9545
|
-
className:
|
|
9486
|
+
className: cn(
|
|
9487
|
+
"relative font-mono p-3 w-full cursor-pointer rounded-lg text-xs !bg-surface4 overflow-scroll",
|
|
9488
|
+
className,
|
|
9489
|
+
previousStep?.status === "success" && nextStep && "!bg-accent1Dark",
|
|
9490
|
+
previousStep?.status === "failed" && nextStep && "!bg-accent2Dark"
|
|
9491
|
+
),
|
|
9546
9492
|
onClick: () => setOpenDialog(true),
|
|
9547
9493
|
style,
|
|
9548
9494
|
children: tokens.map((line, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { ...getLineProps({ line }), children: [
|
|
@@ -9591,7 +9537,15 @@ function WorkflowConditionNode({ data }) {
|
|
|
9591
9537
|
]
|
|
9592
9538
|
}
|
|
9593
9539
|
),
|
|
9594
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9540
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9541
|
+
WorkflowStepActionBar,
|
|
9542
|
+
{
|
|
9543
|
+
stepName: nextStepId,
|
|
9544
|
+
input: previousStep?.output,
|
|
9545
|
+
mapConfig: data.mapConfig,
|
|
9546
|
+
status: nextStep ? previousStep?.status : void 0
|
|
9547
|
+
}
|
|
9548
|
+
)
|
|
9595
9549
|
]
|
|
9596
9550
|
}
|
|
9597
9551
|
),
|
|
@@ -9616,11 +9570,11 @@ function WorkflowDefaultNode({
|
|
|
9616
9570
|
{
|
|
9617
9571
|
className: cn(
|
|
9618
9572
|
"bg-surface3 rounded-lg w-[274px] border-sm border-border1 pt-2",
|
|
9619
|
-
step?.status === "success" && "ring-2 ring-accent1",
|
|
9620
|
-
step?.status === "failed" && "ring-2 ring-accent2",
|
|
9621
|
-
step?.status === "suspended" && "ring-2 ring-accent3",
|
|
9622
|
-
step?.status === "waiting" && "ring-2 ring-accent5",
|
|
9623
|
-
step?.status === "running" && "ring-2 ring-accent6"
|
|
9573
|
+
step?.status === "success" && "ring-2 ring-accent1 bg-accent1Darker",
|
|
9574
|
+
step?.status === "failed" && "ring-2 ring-accent2 bg-accent2Darker",
|
|
9575
|
+
step?.status === "suspended" && "ring-2 ring-accent3 bg-accent3Darker",
|
|
9576
|
+
step?.status === "waiting" && "ring-2 ring-accent5 bg-accent5Darker",
|
|
9577
|
+
step?.status === "running" && "ring-2 ring-accent6 bg-accent6Darker"
|
|
9624
9578
|
),
|
|
9625
9579
|
children: [
|
|
9626
9580
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center gap-2 px-3", !description && "pb-2"), children: [
|
|
@@ -9666,7 +9620,8 @@ function WorkflowDefaultNode({
|
|
|
9666
9620
|
event: step?.status === "waiting" ? event : void 0,
|
|
9667
9621
|
onShowTrace: runId && onShowTrace ? () => onShowTrace?.({ runId, stepName: fullLabel }) : void 0,
|
|
9668
9622
|
runId,
|
|
9669
|
-
onSendEvent
|
|
9623
|
+
onSendEvent,
|
|
9624
|
+
status: step?.status
|
|
9670
9625
|
}
|
|
9671
9626
|
)
|
|
9672
9627
|
]
|
|
@@ -9919,11 +9874,11 @@ function WorkflowNestedNode({
|
|
|
9919
9874
|
{
|
|
9920
9875
|
className: cn(
|
|
9921
9876
|
"bg-surface3 rounded-lg w-[274px] border-sm border-border1 pt-2",
|
|
9922
|
-
step?.status === "success" && "ring-2 ring-accent1",
|
|
9923
|
-
step?.status === "failed" && "ring-2 ring-accent2",
|
|
9924
|
-
step?.status === "suspended" && "ring-2 ring-accent3",
|
|
9925
|
-
step?.status === "waiting" && "ring-2 ring-accent5",
|
|
9926
|
-
step?.status === "running" && "ring-2 ring-accent6"
|
|
9877
|
+
step?.status === "success" && "ring-2 ring-accent1 bg-accent1Darker",
|
|
9878
|
+
step?.status === "failed" && "ring-2 ring-accent2 bg-accent2Darker",
|
|
9879
|
+
step?.status === "suspended" && "ring-2 ring-accent3 bg-accent3Darker",
|
|
9880
|
+
step?.status === "waiting" && "ring-2 ring-accent5 bg-accent5Darker",
|
|
9881
|
+
step?.status === "running" && "ring-2 ring-accent6 bg-accent6Darker"
|
|
9927
9882
|
),
|
|
9928
9883
|
children: [
|
|
9929
9884
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center gap-2 px-3", !description && "pb-2"), children: [
|
|
@@ -9955,7 +9910,8 @@ function WorkflowNestedNode({
|
|
|
9955
9910
|
onShowNestedGraph: () => showNestedGraph({ label, fullStep: fullLabel, stepGraph }),
|
|
9956
9911
|
onSendEvent,
|
|
9957
9912
|
event: step?.status === "waiting" ? event : void 0,
|
|
9958
|
-
runId
|
|
9913
|
+
runId,
|
|
9914
|
+
status: step?.status
|
|
9959
9915
|
}
|
|
9960
9916
|
)
|
|
9961
9917
|
]
|
|
@@ -11156,7 +11112,7 @@ const columns$1 = [
|
|
|
11156
11112
|
{
|
|
11157
11113
|
id: "model",
|
|
11158
11114
|
header: "Routing Models",
|
|
11159
|
-
cell: ({ row }) => /* @__PURE__ */ jsxRuntime.jsxs(Cell, { children: [
|
|
11115
|
+
cell: ({ row }) => /* @__PURE__ */ jsxRuntime.jsxs(Cell, { className: "truncate", children: [
|
|
11160
11116
|
/* @__PURE__ */ jsxRuntime.jsx(Badge$1, { variant: "default", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Brain, {}), children: row.original.routingModel }),
|
|
11161
11117
|
row.original.isVNext ? /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { className: "!text-accent1 ml-2", children: "vNext" }) : null
|
|
11162
11118
|
] })
|
|
@@ -11245,46 +11201,11 @@ const NetworkTableSkeleton = () => {
|
|
|
11245
11201
|
/* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: Array.from({ length: 3 }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsxs(Row, { children: [
|
|
11246
11202
|
/* @__PURE__ */ jsxRuntime.jsx(Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-1/2" }) }),
|
|
11247
11203
|
/* @__PURE__ */ jsxRuntime.jsx(Cell, { width: 160, children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-1/2" }) }),
|
|
11248
|
-
/* @__PURE__ */ jsxRuntime.jsx(Cell, { width: 160, children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-1/2" }) }),
|
|
11249
|
-
/* @__PURE__ */ jsxRuntime.jsx(Cell, { width: 160, children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-1/2" }) }),
|
|
11250
|
-
/* @__PURE__ */ jsxRuntime.jsx(Cell, { width: 160, children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-1/2" }) })
|
|
11251
|
-
] }, index)) })
|
|
11252
|
-
] });
|
|
11253
|
-
};
|
|
11254
|
-
|
|
11255
|
-
const Entity = ({ children, className, onClick }) => {
|
|
11256
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11257
|
-
"div",
|
|
11258
|
-
{
|
|
11259
|
-
tabIndex: onClick ? 0 : void 0,
|
|
11260
|
-
onKeyDown: (e) => {
|
|
11261
|
-
if (!onClick) return;
|
|
11262
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
11263
|
-
e.preventDefault();
|
|
11264
|
-
onClick?.();
|
|
11265
|
-
}
|
|
11266
|
-
},
|
|
11267
|
-
className: clsx(
|
|
11268
|
-
"flex gap-3 group/entity bg-surface3 rounded-lg border-sm border-border1 py-3 px-4",
|
|
11269
|
-
onClick && "cursor-pointer hover:bg-surface4 transition-all",
|
|
11270
|
-
className
|
|
11271
|
-
),
|
|
11272
|
-
onClick,
|
|
11273
|
-
children
|
|
11274
|
-
}
|
|
11275
|
-
);
|
|
11276
|
-
};
|
|
11277
|
-
const EntityIcon = ({ children, className }) => {
|
|
11278
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "lg", className: clsx("text-icon3 mt-1", className), children });
|
|
11279
|
-
};
|
|
11280
|
-
const EntityName = ({ children, className }) => {
|
|
11281
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-lg", className: clsx("text-icon6 font-medium", className), children });
|
|
11282
|
-
};
|
|
11283
|
-
const EntityDescription = ({ children, className }) => {
|
|
11284
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-sm", className: clsx("text-icon3", className), children });
|
|
11285
|
-
};
|
|
11286
|
-
const EntityContent = ({ children, className }) => {
|
|
11287
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children });
|
|
11204
|
+
/* @__PURE__ */ jsxRuntime.jsx(Cell, { width: 160, children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-1/2" }) }),
|
|
11205
|
+
/* @__PURE__ */ jsxRuntime.jsx(Cell, { width: 160, children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-1/2" }) }),
|
|
11206
|
+
/* @__PURE__ */ jsxRuntime.jsx(Cell, { width: 160, children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-1/2" }) })
|
|
11207
|
+
] }, index)) })
|
|
11208
|
+
] });
|
|
11288
11209
|
};
|
|
11289
11210
|
|
|
11290
11211
|
const ToolList = ({ tools, agents, isLoading, computeLink, computeAgentLink }) => {
|
|
@@ -11421,31 +11342,6 @@ const prepareAgents = (tools, agents) => {
|
|
|
11421
11342
|
return Array.from(toolsWithAgents.values());
|
|
11422
11343
|
};
|
|
11423
11344
|
|
|
11424
|
-
function WorkflowTraces({ traces, error, runId, stepName }) {
|
|
11425
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TraceProvider, { initialTraces: traces || [], children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowTracesInner, { traces, error, runId, stepName }) });
|
|
11426
|
-
}
|
|
11427
|
-
function WorkflowTracesInner({ traces, error, runId, stepName }) {
|
|
11428
|
-
const hasRunRef = React.useRef(false);
|
|
11429
|
-
const [sidebarWidth, setSidebarWidth] = React.useState(100);
|
|
11430
|
-
const { isOpen: open, setTrace, setIsOpen, setSpan } = React.useContext(TraceContext);
|
|
11431
|
-
React.useEffect(() => {
|
|
11432
|
-
if (hasRunRef.current) return;
|
|
11433
|
-
if (!runId || !stepName) return;
|
|
11434
|
-
const matchingTrace = traces.find((trace) => trace.runId === runId);
|
|
11435
|
-
if (!matchingTrace) return;
|
|
11436
|
-
const matchingSpan = matchingTrace.trace.find((span) => span.name.includes(stepName));
|
|
11437
|
-
if (!matchingSpan) return;
|
|
11438
|
-
setTrace(matchingTrace.trace);
|
|
11439
|
-
setSpan(matchingSpan);
|
|
11440
|
-
setIsOpen(true);
|
|
11441
|
-
hasRunRef.current = true;
|
|
11442
|
-
}, [runId, traces, setTrace]);
|
|
11443
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "h-full relative overflow-hidden flex", children: [
|
|
11444
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-y-scroll w-full", children: /* @__PURE__ */ jsxRuntime.jsx(TracesTable, { traces, error }) }),
|
|
11445
|
-
open && /* @__PURE__ */ jsxRuntime.jsx(TracesSidebar, { width: sidebarWidth, onResize: setSidebarWidth })
|
|
11446
|
-
] });
|
|
11447
|
-
}
|
|
11448
|
-
|
|
11449
11345
|
function LegacyWorkflowNestedGraph({
|
|
11450
11346
|
stepGraph,
|
|
11451
11347
|
stepSubscriberGraph,
|
|
@@ -11843,7 +11739,7 @@ const DatePicker = ({
|
|
|
11843
11739
|
DatePickerOnly,
|
|
11844
11740
|
{
|
|
11845
11741
|
value,
|
|
11846
|
-
setValue
|
|
11742
|
+
setValue,
|
|
11847
11743
|
clearable: props.clearable,
|
|
11848
11744
|
setOpenPopover,
|
|
11849
11745
|
...props
|
|
@@ -12475,31 +12371,280 @@ const WorkflowResult = ({ jsonResult, sanitizedJsonResult }) => {
|
|
|
12475
12371
|
);
|
|
12476
12372
|
};
|
|
12477
12373
|
|
|
12478
|
-
function LegacyWorkflowTrigger({
|
|
12374
|
+
function LegacyWorkflowTrigger({
|
|
12375
|
+
workflowId,
|
|
12376
|
+
setRunId
|
|
12377
|
+
}) {
|
|
12378
|
+
const { legacyResult: result, setLegacyResult: setResult, payload, setPayload } = React.useContext(WorkflowRunContext);
|
|
12379
|
+
const { isLoading, legacyWorkflow: workflow } = useLegacyWorkflow(workflowId);
|
|
12380
|
+
const { createLegacyWorkflowRun: createWorkflowRun, startLegacyWorkflowRun: startWorkflowRun } = useExecuteWorkflow();
|
|
12381
|
+
const {
|
|
12382
|
+
watchLegacyWorkflow: watchWorkflow,
|
|
12383
|
+
legacyWatchResult: watchResult,
|
|
12384
|
+
isWatchingLegacyWorkflow: isWatchingWorkflow
|
|
12385
|
+
} = useWatchWorkflow();
|
|
12386
|
+
const { resumeLegacyWorkflow: resumeWorkflow, isResumingLegacyWorkflow: isResumingWorkflow } = useResumeWorkflow();
|
|
12387
|
+
const [suspendedSteps, setSuspendedSteps] = React.useState([]);
|
|
12388
|
+
const [isRunning, setIsRunning] = React.useState(false);
|
|
12389
|
+
const triggerSchema = workflow?.triggerSchema;
|
|
12390
|
+
const handleExecuteWorkflow = async (data) => {
|
|
12391
|
+
try {
|
|
12392
|
+
if (!workflow) return;
|
|
12393
|
+
setIsRunning(true);
|
|
12394
|
+
setResult(null);
|
|
12395
|
+
const { runId } = await createWorkflowRun({ workflowId });
|
|
12396
|
+
setRunId?.(runId);
|
|
12397
|
+
watchWorkflow({ workflowId, runId });
|
|
12398
|
+
startWorkflowRun({ workflowId, runId, input: data });
|
|
12399
|
+
} catch (err) {
|
|
12400
|
+
setIsRunning(false);
|
|
12401
|
+
sonner.toast.error("Error executing workflow");
|
|
12402
|
+
}
|
|
12403
|
+
};
|
|
12404
|
+
const handleResumeWorkflow = async (step) => {
|
|
12405
|
+
if (!workflow) return;
|
|
12406
|
+
const { stepId, runId: prevRunId, context } = step;
|
|
12407
|
+
const { runId } = await createWorkflowRun({ workflowId, prevRunId });
|
|
12408
|
+
watchWorkflow({ workflowId, runId });
|
|
12409
|
+
await resumeWorkflow({
|
|
12410
|
+
stepId,
|
|
12411
|
+
runId,
|
|
12412
|
+
context,
|
|
12413
|
+
workflowId
|
|
12414
|
+
});
|
|
12415
|
+
};
|
|
12416
|
+
const watchResultToUse = result ?? watchResult;
|
|
12417
|
+
const workflowActivePaths = watchResultToUse?.activePaths ?? {};
|
|
12418
|
+
React.useEffect(() => {
|
|
12419
|
+
setIsRunning(isWatchingWorkflow);
|
|
12420
|
+
}, [isWatchingWorkflow]);
|
|
12421
|
+
React.useEffect(() => {
|
|
12422
|
+
if (!watchResultToUse?.activePaths || !result?.runId) return;
|
|
12423
|
+
const suspended = Object.entries(watchResultToUse.activePaths).filter(([_, { status }]) => status === "suspended").map(([stepId, { suspendPayload }]) => ({
|
|
12424
|
+
stepId,
|
|
12425
|
+
runId: result.runId,
|
|
12426
|
+
suspendPayload
|
|
12427
|
+
}));
|
|
12428
|
+
setSuspendedSteps(suspended);
|
|
12429
|
+
}, [watchResultToUse, result]);
|
|
12430
|
+
React.useEffect(() => {
|
|
12431
|
+
if (watchResult) {
|
|
12432
|
+
setResult(watchResult);
|
|
12433
|
+
}
|
|
12434
|
+
}, [watchResult]);
|
|
12435
|
+
if (isLoading) {
|
|
12436
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
12437
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-10" }),
|
|
12438
|
+
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-10" })
|
|
12439
|
+
] }) });
|
|
12440
|
+
}
|
|
12441
|
+
if (!workflow) return null;
|
|
12442
|
+
const isSuspendedSteps = suspendedSteps.length > 0;
|
|
12443
|
+
const zodInputSchema = triggerSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(triggerSchema))) : null;
|
|
12444
|
+
const { sanitizedOutput, ...restResult } = result ?? {};
|
|
12445
|
+
const hasWorkflowActivePaths = Object.values(workflowActivePaths).length > 0;
|
|
12446
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full px-5 pt-3 pb-12", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
12447
|
+
isResumingWorkflow && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-2 px-5 flex items-center gap-2 bg-surface5 -mx-5 -mt-5 border-b-sm border-border1", children: [
|
|
12448
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin text-icon6" }) }),
|
|
12449
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { children: "Resuming workflow" })
|
|
12450
|
+
] }),
|
|
12451
|
+
!isSuspendedSteps && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: zodInputSchema ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
12452
|
+
DynamicForm,
|
|
12453
|
+
{
|
|
12454
|
+
schema: zodInputSchema,
|
|
12455
|
+
defaultValues: payload,
|
|
12456
|
+
isSubmitLoading: isWatchingWorkflow,
|
|
12457
|
+
submitButtonLabel: "Run",
|
|
12458
|
+
onSubmit: (data) => {
|
|
12459
|
+
setPayload(data);
|
|
12460
|
+
handleExecuteWorkflow(data);
|
|
12461
|
+
}
|
|
12462
|
+
}
|
|
12463
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
12464
|
+
Button,
|
|
12465
|
+
{
|
|
12466
|
+
className: "w-full",
|
|
12467
|
+
variant: "light",
|
|
12468
|
+
disabled: isRunning,
|
|
12469
|
+
onClick: () => handleExecuteWorkflow(null),
|
|
12470
|
+
children: isRunning ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) }) : "Trigger"
|
|
12471
|
+
}
|
|
12472
|
+
) }),
|
|
12473
|
+
isSuspendedSteps && suspendedSteps?.map((step) => {
|
|
12474
|
+
const stepDefinition = workflow.steps[step.stepId];
|
|
12475
|
+
const stepSchema = stepDefinition?.inputSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(stepDefinition.inputSchema))) : z.z.record(z.z.string(), z.z.any());
|
|
12476
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col px-4", children: [
|
|
12477
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
|
|
12478
|
+
step.suspendPayload && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12479
|
+
CodeBlockDemo,
|
|
12480
|
+
{
|
|
12481
|
+
className: "w-full overflow-x-auto p-2",
|
|
12482
|
+
code: JSON.stringify(step.suspendPayload, null, 2),
|
|
12483
|
+
language: "json"
|
|
12484
|
+
}
|
|
12485
|
+
) }),
|
|
12486
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12487
|
+
DynamicForm,
|
|
12488
|
+
{
|
|
12489
|
+
schema: stepSchema,
|
|
12490
|
+
isSubmitLoading: isResumingWorkflow,
|
|
12491
|
+
submitButtonLabel: "Resume",
|
|
12492
|
+
onSubmit: (data) => {
|
|
12493
|
+
handleResumeWorkflow({
|
|
12494
|
+
stepId: step.stepId,
|
|
12495
|
+
runId: step.runId,
|
|
12496
|
+
suspendPayload: step.suspendPayload,
|
|
12497
|
+
context: data
|
|
12498
|
+
});
|
|
12499
|
+
}
|
|
12500
|
+
}
|
|
12501
|
+
)
|
|
12502
|
+
] });
|
|
12503
|
+
}),
|
|
12504
|
+
hasWorkflowActivePaths && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12505
|
+
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
12506
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4", children: Object.entries(workflowActivePaths)?.map(([stepId, { status: pathStatus, stepPath }]) => {
|
|
12507
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1", children: stepPath?.map((path, idx) => {
|
|
12508
|
+
return /* @__PURE__ */ jsxRuntime.jsx(LegacyWorkflowStatus, { stepId, pathStatus, path }, idx);
|
|
12509
|
+
}) }, stepId);
|
|
12510
|
+
}) })
|
|
12511
|
+
] }),
|
|
12512
|
+
result && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12513
|
+
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
12514
|
+
/* @__PURE__ */ jsxRuntime.jsx(WorkflowResult, { sanitizedJsonResult: sanitizedOutput, jsonResult: JSON.stringify(restResult, null, 2) })
|
|
12515
|
+
] })
|
|
12516
|
+
] }) });
|
|
12517
|
+
}
|
|
12518
|
+
|
|
12519
|
+
const WorkflowStatus = ({ stepId, status, result }) => {
|
|
12520
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12521
|
+
WorkflowCard,
|
|
12522
|
+
{
|
|
12523
|
+
header: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
12524
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Icon, { children: [
|
|
12525
|
+
status === "success" && /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { className: "text-accent1" }),
|
|
12526
|
+
status === "failed" && /* @__PURE__ */ jsxRuntime.jsx(CrossIcon, { className: "text-accent2" }),
|
|
12527
|
+
status === "suspended" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CirclePause, { className: "text-accent3" }),
|
|
12528
|
+
status === "waiting" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.HourglassIcon, { className: "text-accent5" }),
|
|
12529
|
+
status === "running" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "text-accent6 animate-spin" })
|
|
12530
|
+
] }),
|
|
12531
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-lg", className: "text-icon6 font-medium", children: stepId.charAt(0).toUpperCase() + stepId.slice(1) })
|
|
12532
|
+
] }),
|
|
12533
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md bg-surface4 p-1 font-mono relative", children: [
|
|
12534
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyButton, { content: JSON.stringify(result, null, 2), className: "absolute top-2 right-2 z-10" }),
|
|
12535
|
+
/* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$1, { data: result })
|
|
12536
|
+
] })
|
|
12537
|
+
}
|
|
12538
|
+
);
|
|
12539
|
+
};
|
|
12540
|
+
|
|
12541
|
+
const WorkflowInputData = ({
|
|
12542
|
+
schema,
|
|
12543
|
+
defaultValues,
|
|
12544
|
+
isSubmitLoading,
|
|
12545
|
+
submitButtonLabel,
|
|
12546
|
+
onSubmit
|
|
12547
|
+
}) => {
|
|
12548
|
+
const [type, setType] = React.useState("form");
|
|
12549
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12550
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadioGroup, { value: type, onValueChange: (value) => setType(value), className: "pb-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row gap-4", children: [
|
|
12551
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
12552
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadioGroupItem, { value: "form", id: "form" }),
|
|
12553
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "form", className: "!text-icon3 text-ui-sm", children: "Form" })
|
|
12554
|
+
] }),
|
|
12555
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
12556
|
+
/* @__PURE__ */ jsxRuntime.jsx(RadioGroupItem, { value: "json", id: "json" }),
|
|
12557
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "json", className: "!text-icon3 text-ui-sm", children: "JSON" })
|
|
12558
|
+
] })
|
|
12559
|
+
] }) }),
|
|
12560
|
+
type === "form" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
12561
|
+
DynamicForm,
|
|
12562
|
+
{
|
|
12563
|
+
schema,
|
|
12564
|
+
defaultValues,
|
|
12565
|
+
isSubmitLoading,
|
|
12566
|
+
submitButtonLabel,
|
|
12567
|
+
onSubmit
|
|
12568
|
+
}
|
|
12569
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
12570
|
+
JSONInput,
|
|
12571
|
+
{
|
|
12572
|
+
schema,
|
|
12573
|
+
defaultValues,
|
|
12574
|
+
isSubmitLoading,
|
|
12575
|
+
submitButtonLabel,
|
|
12576
|
+
onSubmit
|
|
12577
|
+
}
|
|
12578
|
+
)
|
|
12579
|
+
] });
|
|
12580
|
+
};
|
|
12581
|
+
const JSONInput = ({ schema, defaultValues, isSubmitLoading, submitButtonLabel, onSubmit }) => {
|
|
12582
|
+
const [errors, setErrors] = React.useState([]);
|
|
12583
|
+
const [inputData, setInputData] = React.useState(JSON.stringify(defaultValues ?? {}, null, 2));
|
|
12584
|
+
const handleSubmit = () => {
|
|
12585
|
+
setErrors([]);
|
|
12586
|
+
try {
|
|
12587
|
+
const result = schema.safeParse(JSON.parse(inputData));
|
|
12588
|
+
if (!result.success) {
|
|
12589
|
+
setErrors(result.error.issues.map((e) => `[${e.path.join(".")}] ${e.message}`));
|
|
12590
|
+
} else {
|
|
12591
|
+
onSubmit(result.data);
|
|
12592
|
+
}
|
|
12593
|
+
} catch (e) {
|
|
12594
|
+
setErrors(["Invalid JSON provided"]);
|
|
12595
|
+
}
|
|
12596
|
+
};
|
|
12597
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
12598
|
+
errors.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-sm border-accent2 rounded-lg p-2", children: [
|
|
12599
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { as: "p", variant: "ui-md", className: "text-accent2 font-semibold", children: [
|
|
12600
|
+
errors.length,
|
|
12601
|
+
" errors found"
|
|
12602
|
+
] }),
|
|
12603
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "list-disc list-inside", children: errors.map((error, idx) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "text-ui-sm text-accent2", children: error }, idx)) })
|
|
12604
|
+
] }),
|
|
12605
|
+
/* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter, { data: inputData, onChange: setInputData }),
|
|
12606
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "light", onClick: handleSubmit, className: "w-full", size: "lg", children: isSubmitLoading ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) : submitButtonLabel })
|
|
12607
|
+
] });
|
|
12608
|
+
};
|
|
12609
|
+
const SyntaxHighlighter = ({ data, onChange }) => {
|
|
12610
|
+
const theme = useCodemirrorTheme$1();
|
|
12611
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md bg-[#1a1a1a] p-1 font-mono", children: [
|
|
12612
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyButton, { content: data, className: "absolute top-2 right-2 z-10" }),
|
|
12613
|
+
/* @__PURE__ */ jsxRuntime.jsx(CodeMirror, { value: data, theme, extensions: [langJson.jsonLanguage], onChange })
|
|
12614
|
+
] });
|
|
12615
|
+
};
|
|
12616
|
+
|
|
12617
|
+
function WorkflowTrigger({
|
|
12479
12618
|
workflowId,
|
|
12480
|
-
setRunId
|
|
12619
|
+
setRunId,
|
|
12620
|
+
workflow,
|
|
12621
|
+
isLoading,
|
|
12622
|
+
createWorkflowRun,
|
|
12623
|
+
resumeWorkflow,
|
|
12624
|
+
streamWorkflow,
|
|
12625
|
+
isStreamingWorkflow,
|
|
12626
|
+
streamResult,
|
|
12627
|
+
isResumingWorkflow,
|
|
12628
|
+
isCancellingWorkflowRun,
|
|
12629
|
+
cancelWorkflowRun
|
|
12481
12630
|
}) {
|
|
12482
|
-
const {
|
|
12483
|
-
const {
|
|
12484
|
-
const { createLegacyWorkflowRun: createWorkflowRun, startLegacyWorkflowRun: startWorkflowRun } = useExecuteWorkflow();
|
|
12485
|
-
const {
|
|
12486
|
-
watchLegacyWorkflow: watchWorkflow,
|
|
12487
|
-
legacyWatchResult: watchResult,
|
|
12488
|
-
isWatchingLegacyWorkflow: isWatchingWorkflow
|
|
12489
|
-
} = useWatchWorkflow();
|
|
12490
|
-
const { resumeLegacyWorkflow: resumeWorkflow, isResumingLegacyWorkflow: isResumingWorkflow } = useResumeWorkflow();
|
|
12631
|
+
const { runtimeContext } = usePlaygroundStore();
|
|
12632
|
+
const { result, setResult, payload, setPayload } = React.useContext(WorkflowRunContext);
|
|
12491
12633
|
const [suspendedSteps, setSuspendedSteps] = React.useState([]);
|
|
12492
12634
|
const [isRunning, setIsRunning] = React.useState(false);
|
|
12493
|
-
const
|
|
12635
|
+
const [innerRunId, setInnerRunId] = React.useState("");
|
|
12636
|
+
const [cancelResponse, setCancelResponse] = React.useState(null);
|
|
12637
|
+
const triggerSchema = workflow?.inputSchema;
|
|
12494
12638
|
const handleExecuteWorkflow = async (data) => {
|
|
12495
12639
|
try {
|
|
12496
12640
|
if (!workflow) return;
|
|
12497
12641
|
setIsRunning(true);
|
|
12642
|
+
setCancelResponse(null);
|
|
12498
12643
|
setResult(null);
|
|
12499
12644
|
const { runId } = await createWorkflowRun({ workflowId });
|
|
12500
12645
|
setRunId?.(runId);
|
|
12501
|
-
|
|
12502
|
-
|
|
12646
|
+
setInnerRunId(runId);
|
|
12647
|
+
streamWorkflow({ workflowId, runId, inputData: data, runtimeContext });
|
|
12503
12648
|
} catch (err) {
|
|
12504
12649
|
setIsRunning(false);
|
|
12505
12650
|
sonner.toast.error("Error executing workflow");
|
|
@@ -12507,533 +12652,1004 @@ function LegacyWorkflowTrigger({
|
|
|
12507
12652
|
};
|
|
12508
12653
|
const handleResumeWorkflow = async (step) => {
|
|
12509
12654
|
if (!workflow) return;
|
|
12510
|
-
|
|
12655
|
+
setCancelResponse(null);
|
|
12656
|
+
const { stepId, runId: prevRunId, resumeData } = step;
|
|
12511
12657
|
const { runId } = await createWorkflowRun({ workflowId, prevRunId });
|
|
12512
|
-
watchWorkflow({ workflowId, runId });
|
|
12513
12658
|
await resumeWorkflow({
|
|
12514
|
-
stepId,
|
|
12659
|
+
step: stepId,
|
|
12515
12660
|
runId,
|
|
12516
|
-
|
|
12517
|
-
workflowId
|
|
12661
|
+
resumeData,
|
|
12662
|
+
workflowId,
|
|
12663
|
+
runtimeContext
|
|
12518
12664
|
});
|
|
12519
12665
|
};
|
|
12520
|
-
const
|
|
12521
|
-
|
|
12666
|
+
const handleCancelWorkflowRun = async () => {
|
|
12667
|
+
const response = await cancelWorkflowRun({ workflowId, runId: innerRunId });
|
|
12668
|
+
setCancelResponse(response);
|
|
12669
|
+
};
|
|
12670
|
+
const streamResultToUse = result ?? streamResult;
|
|
12522
12671
|
React.useEffect(() => {
|
|
12523
|
-
setIsRunning(
|
|
12524
|
-
}, [
|
|
12672
|
+
setIsRunning(isStreamingWorkflow);
|
|
12673
|
+
}, [isStreamingWorkflow]);
|
|
12525
12674
|
React.useEffect(() => {
|
|
12526
|
-
if (!
|
|
12527
|
-
const suspended = Object.entries(
|
|
12675
|
+
if (!streamResultToUse?.payload?.workflowState?.steps || !result?.runId) return;
|
|
12676
|
+
const suspended = Object.entries(streamResultToUse.payload.workflowState.steps).filter(([_, { status }]) => status === "suspended").map(([stepId, { payload: payload2 }]) => ({
|
|
12528
12677
|
stepId,
|
|
12529
12678
|
runId: result.runId,
|
|
12530
|
-
suspendPayload
|
|
12679
|
+
suspendPayload: payload2,
|
|
12680
|
+
isLoading: false
|
|
12531
12681
|
}));
|
|
12532
12682
|
setSuspendedSteps(suspended);
|
|
12533
|
-
}, [
|
|
12683
|
+
}, [streamResultToUse, result]);
|
|
12534
12684
|
React.useEffect(() => {
|
|
12535
|
-
if (
|
|
12536
|
-
setResult(
|
|
12685
|
+
if (streamResult) {
|
|
12686
|
+
setResult(streamResult);
|
|
12537
12687
|
}
|
|
12538
|
-
}, [
|
|
12688
|
+
}, [streamResult]);
|
|
12539
12689
|
if (isLoading) {
|
|
12540
12690
|
return /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
12541
12691
|
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-10" }),
|
|
12542
12692
|
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-10" })
|
|
12543
12693
|
] }) });
|
|
12544
12694
|
}
|
|
12545
|
-
if (!workflow) return null;
|
|
12546
|
-
const isSuspendedSteps = suspendedSteps.length > 0;
|
|
12547
|
-
const zodInputSchema = triggerSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(triggerSchema))) : null;
|
|
12548
|
-
const
|
|
12549
|
-
const hasWorkflowActivePaths = Object.values(workflowActivePaths).length > 0;
|
|
12550
|
-
|
|
12551
|
-
|
|
12552
|
-
|
|
12553
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12554
|
-
|
|
12555
|
-
|
|
12556
|
-
|
|
12557
|
-
{
|
|
12558
|
-
|
|
12559
|
-
|
|
12560
|
-
|
|
12561
|
-
|
|
12562
|
-
|
|
12563
|
-
|
|
12564
|
-
|
|
12565
|
-
|
|
12566
|
-
|
|
12567
|
-
|
|
12695
|
+
if (!workflow) return null;
|
|
12696
|
+
const isSuspendedSteps = suspendedSteps.length > 0;
|
|
12697
|
+
const zodInputSchema = triggerSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(triggerSchema))) : null;
|
|
12698
|
+
const workflowActivePaths = streamResultToUse?.payload?.workflowState?.steps ?? {};
|
|
12699
|
+
const hasWorkflowActivePaths = Object.values(workflowActivePaths).length > 0;
|
|
12700
|
+
const doneStatuses = ["success", "failed", "canceled"];
|
|
12701
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full pt-3 pb-12", children: [
|
|
12702
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 px-5 pb-5 border-b-sm border-border1", children: [
|
|
12703
|
+
(isResumingWorkflow || isSuspendedSteps && isStreamingWorkflow) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-2 px-5 flex items-center gap-2 bg-surface5 -mx-5 -mt-5 border-b-sm border-border1", children: [
|
|
12704
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin text-icon6" }) }),
|
|
12705
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { children: "Resuming workflow" })
|
|
12706
|
+
] }),
|
|
12707
|
+
!isSuspendedSteps && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: zodInputSchema ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
12708
|
+
WorkflowInputData,
|
|
12709
|
+
{
|
|
12710
|
+
schema: zodInputSchema,
|
|
12711
|
+
defaultValues: payload,
|
|
12712
|
+
isSubmitLoading: isStreamingWorkflow,
|
|
12713
|
+
submitButtonLabel: "Run",
|
|
12714
|
+
onSubmit: (data) => {
|
|
12715
|
+
setPayload(data);
|
|
12716
|
+
handleExecuteWorkflow(data);
|
|
12717
|
+
}
|
|
12718
|
+
}
|
|
12719
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
12720
|
+
Button,
|
|
12721
|
+
{
|
|
12722
|
+
className: "w-full",
|
|
12723
|
+
variant: "light",
|
|
12724
|
+
disabled: isRunning,
|
|
12725
|
+
onClick: () => handleExecuteWorkflow(null),
|
|
12726
|
+
children: isRunning ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) }) : "Trigger"
|
|
12727
|
+
}
|
|
12728
|
+
) }),
|
|
12729
|
+
!isStreamingWorkflow && isSuspendedSteps && suspendedSteps?.map((step) => {
|
|
12730
|
+
const stepDefinition = workflow.allSteps[step.stepId];
|
|
12731
|
+
if (!stepDefinition || stepDefinition.isWorkflow) return null;
|
|
12732
|
+
const stepSchema = stepDefinition?.resumeSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(stepDefinition.resumeSchema))) : z.z.record(z.z.string(), z.z.any());
|
|
12733
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col px-4", children: [
|
|
12734
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
|
|
12735
|
+
step.suspendPayload && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12736
|
+
CodeBlockDemo,
|
|
12737
|
+
{
|
|
12738
|
+
className: "w-full overflow-x-auto p-2",
|
|
12739
|
+
code: JSON.stringify(step.suspendPayload, null, 2),
|
|
12740
|
+
language: "json"
|
|
12741
|
+
}
|
|
12742
|
+
) }),
|
|
12743
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12744
|
+
WorkflowInputData,
|
|
12745
|
+
{
|
|
12746
|
+
schema: stepSchema,
|
|
12747
|
+
isSubmitLoading: isResumingWorkflow,
|
|
12748
|
+
submitButtonLabel: "Resume",
|
|
12749
|
+
onSubmit: (data) => {
|
|
12750
|
+
const stepIds = step.stepId?.split(".");
|
|
12751
|
+
handleResumeWorkflow({
|
|
12752
|
+
stepId: stepIds,
|
|
12753
|
+
runId: step.runId,
|
|
12754
|
+
suspendPayload: step.suspendPayload,
|
|
12755
|
+
resumeData: data});
|
|
12756
|
+
}
|
|
12757
|
+
}
|
|
12758
|
+
)
|
|
12759
|
+
] }, step.stepId);
|
|
12760
|
+
}),
|
|
12761
|
+
result?.runId && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12762
|
+
Button,
|
|
12763
|
+
{
|
|
12764
|
+
variant: "light",
|
|
12765
|
+
className: "w-full",
|
|
12766
|
+
size: "lg",
|
|
12767
|
+
onClick: handleCancelWorkflowRun,
|
|
12768
|
+
disabled: !!cancelResponse?.message || isCancellingWorkflowRun || result?.payload?.workflowState?.status && doneStatuses.includes(result?.payload?.workflowState?.status),
|
|
12769
|
+
children: [
|
|
12770
|
+
isCancellingWorkflowRun ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) }) : /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.StopCircle, {}) }),
|
|
12771
|
+
cancelResponse?.message || "Cancel Workflow Run"
|
|
12772
|
+
]
|
|
12773
|
+
}
|
|
12774
|
+
),
|
|
12775
|
+
hasWorkflowActivePaths && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12776
|
+
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
12777
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
12778
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "secondary", className: "px-4 text-mastra-el-3", size: "xs", children: "Status" }),
|
|
12779
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-4 flex flex-col gap-4", children: Object.entries(workflowActivePaths).filter(([key, _]) => key !== "input" && !key.endsWith(".input")).map(([stepId, { status, output }]) => {
|
|
12780
|
+
return /* @__PURE__ */ jsxRuntime.jsx(WorkflowStatus, { stepId, status, result: output ?? {} }, stepId);
|
|
12781
|
+
}) })
|
|
12782
|
+
] })
|
|
12783
|
+
] })
|
|
12784
|
+
] }),
|
|
12785
|
+
result && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-5 border-b-sm border-border1", children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowJsonDialog, { result }) })
|
|
12786
|
+
] });
|
|
12787
|
+
}
|
|
12788
|
+
const WorkflowJsonDialog = ({ result }) => {
|
|
12789
|
+
const [open, setOpen] = React.useState(false);
|
|
12790
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12791
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "light", onClick: () => setOpen(true), className: "w-full", size: "lg", children: [
|
|
12792
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Braces, { className: "text-icon3" }) }),
|
|
12793
|
+
"Open Workflow Execution (JSON)"
|
|
12794
|
+
] }),
|
|
12795
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsx(DialogPortal, { children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "max-w-6xl max-h-[90vh] overflow-y-auto overflow-x-hidden bg-surface2", children: [
|
|
12796
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Workflow Execution (JSON)" }),
|
|
12797
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full overflow-x-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$2, { data: result, className: "p-4" }) })
|
|
12798
|
+
] }) }) })
|
|
12799
|
+
] });
|
|
12800
|
+
};
|
|
12801
|
+
|
|
12802
|
+
const WorkflowRuns = ({ workflowId, runId, isLoading, runs, onPressRun }) => {
|
|
12803
|
+
if (isLoading) {
|
|
12804
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-[600px]" }) });
|
|
12805
|
+
}
|
|
12806
|
+
if (runs.length === 0) {
|
|
12807
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-md", className: "text-icon6 text-center", children: "No previous run" }) });
|
|
12808
|
+
}
|
|
12809
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "pb-10", children: runs.map((run) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12810
|
+
"button",
|
|
12811
|
+
{
|
|
12812
|
+
onClick: () => onPressRun({ workflowId, runId: run.runId }),
|
|
12813
|
+
className: clsx("px-3 py-2 border-b-sm border-border1 block w-full hover:bg-surface4 text-left", {
|
|
12814
|
+
"bg-surface4": run.runId === runId
|
|
12815
|
+
}),
|
|
12816
|
+
children: [
|
|
12817
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-lg", className: "font-medium text-icon6 truncate", as: "p", children: run.runId }),
|
|
12818
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "font-medium text-icon3 truncate", as: "p", children: typeof run?.snapshot === "string" ? "" : run?.snapshot?.timestamp ? dateFns.formatDate(run?.snapshot?.timestamp, "MMM d, yyyy h:mm a") : "" })
|
|
12819
|
+
]
|
|
12820
|
+
}
|
|
12821
|
+
) }, run.runId)) });
|
|
12822
|
+
};
|
|
12823
|
+
|
|
12824
|
+
const columns = [
|
|
12825
|
+
{
|
|
12826
|
+
id: "name",
|
|
12827
|
+
header: "Name",
|
|
12828
|
+
cell: ({ row }) => {
|
|
12829
|
+
const { Link } = useLinkComponent();
|
|
12830
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12831
|
+
EntryCell,
|
|
12832
|
+
{
|
|
12833
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(WorkflowIcon, {}),
|
|
12834
|
+
name: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: row.original.link, children: row.original.name }),
|
|
12835
|
+
description: void 0,
|
|
12836
|
+
meta: void 0
|
|
12837
|
+
}
|
|
12838
|
+
);
|
|
12839
|
+
},
|
|
12840
|
+
meta: {
|
|
12841
|
+
width: "auto"
|
|
12842
|
+
}
|
|
12843
|
+
},
|
|
12844
|
+
{
|
|
12845
|
+
id: "stepsCount",
|
|
12846
|
+
header: "Steps",
|
|
12847
|
+
size: 300,
|
|
12848
|
+
cell: ({ row }) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end items-center gap-2", children: [
|
|
12849
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Footprints, {}), className: "!h-button-md", children: [
|
|
12850
|
+
row.original.stepsCount,
|
|
12851
|
+
" step",
|
|
12852
|
+
row.original.stepsCount > 1 ? "s" : ""
|
|
12853
|
+
] }),
|
|
12854
|
+
row.original.isLegacy ? /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { className: "!text-foreground/80 !h-button-md", children: "Legacy" }) : null
|
|
12855
|
+
] }) })
|
|
12856
|
+
}
|
|
12857
|
+
];
|
|
12858
|
+
|
|
12859
|
+
function WorkflowTable({ workflows, legacyWorkflows, isLoading, computeLink }) {
|
|
12860
|
+
const { navigate } = useLinkComponent();
|
|
12861
|
+
const workflowData = React.useMemo(() => {
|
|
12862
|
+
const _workflowsData = Object.keys(workflows ?? {}).map((key) => {
|
|
12863
|
+
const workflow = workflows?.[key];
|
|
12864
|
+
return {
|
|
12865
|
+
id: key,
|
|
12866
|
+
name: workflow?.name || "N/A",
|
|
12867
|
+
stepsCount: Object.keys(workflow?.steps ?? {})?.length,
|
|
12868
|
+
isLegacy: false,
|
|
12869
|
+
link: computeLink(key)
|
|
12870
|
+
};
|
|
12871
|
+
});
|
|
12872
|
+
const legacyWorkflowsData = Object.keys(legacyWorkflows ?? {}).map((key) => {
|
|
12873
|
+
const workflow = legacyWorkflows?.[key];
|
|
12874
|
+
return {
|
|
12875
|
+
id: key,
|
|
12876
|
+
name: workflow?.name || "N/A",
|
|
12877
|
+
stepsCount: Object.keys(workflow?.steps ?? {})?.length,
|
|
12878
|
+
isLegacy: true,
|
|
12879
|
+
link: computeLink(key)
|
|
12880
|
+
};
|
|
12881
|
+
});
|
|
12882
|
+
return [..._workflowsData, ...legacyWorkflowsData];
|
|
12883
|
+
}, [workflows, legacyWorkflows]);
|
|
12884
|
+
const table = reactTable.useReactTable({
|
|
12885
|
+
data: workflowData,
|
|
12886
|
+
columns,
|
|
12887
|
+
getCoreRowModel: reactTable.getCoreRowModel()
|
|
12888
|
+
});
|
|
12889
|
+
if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(WorkflowTableSkeleton, {});
|
|
12890
|
+
const ths = table.getHeaderGroups()[0];
|
|
12891
|
+
const rows = table.getRowModel().rows.concat();
|
|
12892
|
+
if (rows.length === 0) {
|
|
12893
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EmptyWorkflowsTable, {});
|
|
12894
|
+
}
|
|
12895
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
|
|
12896
|
+
/* @__PURE__ */ jsxRuntime.jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsxRuntime.jsx(Th, { style: { width: header.index === 0 ? "auto" : header.column.getSize() }, children: reactTable.flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
|
|
12897
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsx(Row, { onClick: () => navigate(row.original.link), children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)) }, row.id)) })
|
|
12898
|
+
] }) });
|
|
12899
|
+
}
|
|
12900
|
+
const WorkflowTableSkeleton = () => /* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
|
|
12901
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Thead, { children: [
|
|
12902
|
+
/* @__PURE__ */ jsxRuntime.jsx(Th, { children: "Name" }),
|
|
12903
|
+
/* @__PURE__ */ jsxRuntime.jsx(Th, { width: 300, children: "Steps" })
|
|
12904
|
+
] }),
|
|
12905
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: Array.from({ length: 3 }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsxs(Row, { children: [
|
|
12906
|
+
/* @__PURE__ */ jsxRuntime.jsx(Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-1/2" }) }),
|
|
12907
|
+
/* @__PURE__ */ jsxRuntime.jsx(Cell, { width: 300, children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-1/2" }) })
|
|
12908
|
+
] }, index)) })
|
|
12909
|
+
] });
|
|
12910
|
+
const EmptyWorkflowsTable = () => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12911
|
+
EmptyState,
|
|
12912
|
+
{
|
|
12913
|
+
iconSlot: /* @__PURE__ */ jsxRuntime.jsx(WorkflowCoinIcon, {}),
|
|
12914
|
+
titleSlot: "Configure Workflows",
|
|
12915
|
+
descriptionSlot: "Mastra workflows are not configured yet. You can find more information in the documentation.",
|
|
12916
|
+
actionSlot: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12568
12917
|
Button,
|
|
12569
12918
|
{
|
|
12919
|
+
size: "lg",
|
|
12570
12920
|
className: "w-full",
|
|
12571
12921
|
variant: "light",
|
|
12572
|
-
|
|
12573
|
-
|
|
12574
|
-
|
|
12922
|
+
as: "a",
|
|
12923
|
+
href: "https://mastra.ai/en/docs/workflows/overview",
|
|
12924
|
+
target: "_blank",
|
|
12925
|
+
children: [
|
|
12926
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowIcon, {}) }),
|
|
12927
|
+
"Docs"
|
|
12928
|
+
]
|
|
12575
12929
|
}
|
|
12576
|
-
)
|
|
12577
|
-
|
|
12578
|
-
|
|
12579
|
-
const stepSchema = stepDefinition?.inputSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(stepDefinition.inputSchema))) : z.z.record(z.z.string(), z.z.any());
|
|
12580
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col px-4", children: [
|
|
12581
|
-
/* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
|
|
12582
|
-
step.suspendPayload && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12583
|
-
CodeBlockDemo,
|
|
12584
|
-
{
|
|
12585
|
-
className: "w-full overflow-x-auto p-2",
|
|
12586
|
-
code: JSON.stringify(step.suspendPayload, null, 2),
|
|
12587
|
-
language: "json"
|
|
12588
|
-
}
|
|
12589
|
-
) }),
|
|
12590
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12591
|
-
DynamicForm,
|
|
12592
|
-
{
|
|
12593
|
-
schema: stepSchema,
|
|
12594
|
-
isSubmitLoading: isResumingWorkflow,
|
|
12595
|
-
submitButtonLabel: "Resume",
|
|
12596
|
-
onSubmit: (data) => {
|
|
12597
|
-
handleResumeWorkflow({
|
|
12598
|
-
stepId: step.stepId,
|
|
12599
|
-
runId: step.runId,
|
|
12600
|
-
suspendPayload: step.suspendPayload,
|
|
12601
|
-
context: data
|
|
12602
|
-
});
|
|
12603
|
-
}
|
|
12604
|
-
}
|
|
12605
|
-
)
|
|
12606
|
-
] });
|
|
12607
|
-
}),
|
|
12608
|
-
hasWorkflowActivePaths && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12609
|
-
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
12610
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4", children: Object.entries(workflowActivePaths)?.map(([stepId, { status: pathStatus, stepPath }]) => {
|
|
12611
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1", children: stepPath?.map((path, idx) => {
|
|
12612
|
-
return /* @__PURE__ */ jsxRuntime.jsx(LegacyWorkflowStatus, { stepId, pathStatus, path }, idx);
|
|
12613
|
-
}) }, stepId);
|
|
12614
|
-
}) })
|
|
12615
|
-
] }),
|
|
12616
|
-
result && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12617
|
-
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
12618
|
-
/* @__PURE__ */ jsxRuntime.jsx(WorkflowResult, { sanitizedJsonResult: sanitizedOutput, jsonResult: JSON.stringify(restResult, null, 2) })
|
|
12619
|
-
] })
|
|
12620
|
-
] }) });
|
|
12621
|
-
}
|
|
12930
|
+
)
|
|
12931
|
+
}
|
|
12932
|
+
) });
|
|
12622
12933
|
|
|
12623
|
-
const
|
|
12934
|
+
const TraceContext = React.createContext({});
|
|
12935
|
+
function TraceProvider({
|
|
12936
|
+
children,
|
|
12937
|
+
initialTraces: traces = []
|
|
12938
|
+
}) {
|
|
12939
|
+
const [open, setOpen] = React.useState(false);
|
|
12940
|
+
const [trace, setTrace] = React.useState(null);
|
|
12941
|
+
const [currentTraceIndex, setCurrentTraceIndex] = React.useState(0);
|
|
12942
|
+
const [span, setSpan] = React.useState(null);
|
|
12943
|
+
const nextTrace = () => {
|
|
12944
|
+
if (currentTraceIndex < traces.length - 1) {
|
|
12945
|
+
const nextIndex = currentTraceIndex + 1;
|
|
12946
|
+
setCurrentTraceIndex(nextIndex);
|
|
12947
|
+
const nextTrace2 = traces[nextIndex].trace;
|
|
12948
|
+
setTrace(nextTrace2);
|
|
12949
|
+
const parentSpan = nextTrace2.find((span2) => span2.parentSpanId === null) || nextTrace2[0];
|
|
12950
|
+
setSpan(parentSpan);
|
|
12951
|
+
}
|
|
12952
|
+
};
|
|
12953
|
+
const prevTrace = () => {
|
|
12954
|
+
if (currentTraceIndex > 0) {
|
|
12955
|
+
const prevIndex = currentTraceIndex - 1;
|
|
12956
|
+
setCurrentTraceIndex(prevIndex);
|
|
12957
|
+
const prevTrace2 = traces[prevIndex].trace;
|
|
12958
|
+
setTrace(prevTrace2);
|
|
12959
|
+
const parentSpan = prevTrace2.find((span2) => span2.parentSpanId === null) || prevTrace2[0];
|
|
12960
|
+
setSpan(parentSpan);
|
|
12961
|
+
}
|
|
12962
|
+
};
|
|
12963
|
+
const clearData = () => {
|
|
12964
|
+
setOpen(false);
|
|
12965
|
+
setTrace(null);
|
|
12966
|
+
setSpan(null);
|
|
12967
|
+
};
|
|
12624
12968
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12625
|
-
|
|
12969
|
+
TraceContext.Provider,
|
|
12626
12970
|
{
|
|
12627
|
-
|
|
12628
|
-
|
|
12629
|
-
|
|
12630
|
-
|
|
12631
|
-
|
|
12632
|
-
|
|
12633
|
-
|
|
12634
|
-
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
|
|
12640
|
-
|
|
12971
|
+
value: {
|
|
12972
|
+
isOpen: open,
|
|
12973
|
+
setIsOpen: setOpen,
|
|
12974
|
+
trace,
|
|
12975
|
+
setTrace,
|
|
12976
|
+
traces,
|
|
12977
|
+
currentTraceIndex,
|
|
12978
|
+
setCurrentTraceIndex,
|
|
12979
|
+
nextTrace,
|
|
12980
|
+
prevTrace,
|
|
12981
|
+
span,
|
|
12982
|
+
setSpan,
|
|
12983
|
+
clearData
|
|
12984
|
+
},
|
|
12985
|
+
children
|
|
12986
|
+
}
|
|
12987
|
+
);
|
|
12988
|
+
}
|
|
12989
|
+
|
|
12990
|
+
const useOpenTrace = () => {
|
|
12991
|
+
const {
|
|
12992
|
+
setTrace,
|
|
12993
|
+
isOpen: open,
|
|
12994
|
+
setIsOpen: setOpen,
|
|
12995
|
+
trace: currentTrace,
|
|
12996
|
+
setSpan,
|
|
12997
|
+
setCurrentTraceIndex
|
|
12998
|
+
} = React.useContext(TraceContext);
|
|
12999
|
+
const openTrace = (trace, traceIndex) => {
|
|
13000
|
+
setTrace(trace);
|
|
13001
|
+
const parentSpan = trace.find((span) => span.parentSpanId === null) || trace[0];
|
|
13002
|
+
setSpan(parentSpan);
|
|
13003
|
+
setCurrentTraceIndex(traceIndex);
|
|
13004
|
+
if (open && currentTrace?.[0]?.id !== trace[0].id) return;
|
|
13005
|
+
setOpen((prev) => !prev);
|
|
13006
|
+
};
|
|
13007
|
+
return { openTrace };
|
|
13008
|
+
};
|
|
13009
|
+
|
|
13010
|
+
const TracesTableEmpty = ({ colsCount }) => {
|
|
13011
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: /* @__PURE__ */ jsxRuntime.jsx(Row, { children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { colSpan: colsCount, className: "text-center py-4", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { children: "No traces found" }) }) }) });
|
|
13012
|
+
};
|
|
13013
|
+
const TracesTableError = ({ error, colsCount }) => {
|
|
13014
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: /* @__PURE__ */ jsxRuntime.jsx(Row, { children: /* @__PURE__ */ jsxRuntime.jsx(Cell, { colSpan: colsCount, className: "text-center py-4", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { children: error.message }) }) }) });
|
|
13015
|
+
};
|
|
13016
|
+
const TraceRow = ({ trace, index, isActive }) => {
|
|
13017
|
+
const { openTrace } = useOpenTrace();
|
|
13018
|
+
const hasFailure = trace.trace.some((span) => span.status.code !== 0);
|
|
13019
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Row, { className: isActive ? "bg-surface4" : "", onClick: () => openTrace(trace.trace, index), children: [
|
|
13020
|
+
/* @__PURE__ */ jsxRuntime.jsx(DateTimeCell, { dateTime: new Date(trace.started / 1e3) }),
|
|
13021
|
+
/* @__PURE__ */ jsxRuntime.jsxs(TxtCell, { title: trace.traceId, children: [
|
|
13022
|
+
trace.traceId.substring(0, 7),
|
|
13023
|
+
"..."
|
|
13024
|
+
] }),
|
|
13025
|
+
/* @__PURE__ */ jsxRuntime.jsx(UnitCell, { unit: "ms", children: toSigFigs(trace.duration / 1e3, 3) }),
|
|
13026
|
+
/* @__PURE__ */ jsxRuntime.jsx(Cell, { children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => openTrace(trace.trace, index), children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(TraceIcon, {}), children: trace.trace.length }) }) }),
|
|
13027
|
+
/* @__PURE__ */ jsxRuntime.jsx(Cell, { children: hasFailure ? /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}), children: "Failed" }) : /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, {}), variant: "success", children: "Success" }) })
|
|
13028
|
+
] });
|
|
13029
|
+
};
|
|
13030
|
+
const TracesTable = ({ traces, error }) => {
|
|
13031
|
+
const hasNoTraces = !traces || traces.length === 0;
|
|
13032
|
+
const { currentTraceIndex } = React.useContext(TraceContext);
|
|
13033
|
+
const colsCount = 4;
|
|
13034
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Table, { size: "small", children: [
|
|
13035
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Thead, { children: [
|
|
13036
|
+
/* @__PURE__ */ jsxRuntime.jsx(Th, { width: 120, children: "Time" }),
|
|
13037
|
+
/* @__PURE__ */ jsxRuntime.jsx(Th, { width: "auto", children: "Trace Id" }),
|
|
13038
|
+
/* @__PURE__ */ jsxRuntime.jsx(Th, { width: 120, children: "Duration" }),
|
|
13039
|
+
/* @__PURE__ */ jsxRuntime.jsx(Th, { width: 120, children: "Spans" }),
|
|
13040
|
+
/* @__PURE__ */ jsxRuntime.jsx(Th, { width: 120, children: "Status" })
|
|
13041
|
+
] }),
|
|
13042
|
+
error ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableError, { error, colsCount }) : hasNoTraces ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableEmpty, { colsCount }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: traces.map((trace, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
13043
|
+
TraceRow,
|
|
13044
|
+
{
|
|
13045
|
+
trace,
|
|
13046
|
+
index,
|
|
13047
|
+
isActive: index === currentTraceIndex
|
|
13048
|
+
},
|
|
13049
|
+
trace.traceId + index
|
|
13050
|
+
)) }) })
|
|
13051
|
+
] });
|
|
13052
|
+
};
|
|
13053
|
+
|
|
13054
|
+
const useResizeColumn = ({
|
|
13055
|
+
defaultWidth,
|
|
13056
|
+
minimumWidth,
|
|
13057
|
+
maximumWidth,
|
|
13058
|
+
setCurrentWidth
|
|
13059
|
+
}) => {
|
|
13060
|
+
const [isDragging, setIsDragging] = React.useState(false);
|
|
13061
|
+
const [sidebarWidth, setSidebarWidth] = React.useState(defaultWidth);
|
|
13062
|
+
const containerRef = React.useRef(null);
|
|
13063
|
+
const dragStartXRef = React.useRef(0);
|
|
13064
|
+
const initialWidthRef = React.useRef(0);
|
|
13065
|
+
const handleMouseDown = (e) => {
|
|
13066
|
+
e.preventDefault();
|
|
13067
|
+
setIsDragging(true);
|
|
13068
|
+
dragStartXRef.current = e.clientX;
|
|
13069
|
+
initialWidthRef.current = sidebarWidth;
|
|
13070
|
+
};
|
|
13071
|
+
React.useEffect(() => {
|
|
13072
|
+
setSidebarWidth(defaultWidth);
|
|
13073
|
+
setCurrentWidth?.(defaultWidth);
|
|
13074
|
+
}, [defaultWidth]);
|
|
13075
|
+
React.useEffect(() => {
|
|
13076
|
+
const handleMouseMove = (e) => {
|
|
13077
|
+
if (!isDragging || !containerRef.current) return;
|
|
13078
|
+
const containerWidth = containerRef.current.offsetWidth;
|
|
13079
|
+
const deltaX = dragStartXRef.current - e.clientX;
|
|
13080
|
+
const deltaPercentage = deltaX / containerWidth * 100;
|
|
13081
|
+
const newWidth = Math.min(Math.max(initialWidthRef.current + deltaPercentage, minimumWidth), maximumWidth);
|
|
13082
|
+
setSidebarWidth(newWidth);
|
|
13083
|
+
setCurrentWidth?.(newWidth);
|
|
13084
|
+
};
|
|
13085
|
+
const handleMouseUp = () => {
|
|
13086
|
+
setIsDragging(false);
|
|
13087
|
+
};
|
|
13088
|
+
if (isDragging) {
|
|
13089
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
13090
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
12641
13091
|
}
|
|
12642
|
-
|
|
13092
|
+
return () => {
|
|
13093
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
13094
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
13095
|
+
};
|
|
13096
|
+
}, [isDragging]);
|
|
13097
|
+
return { sidebarWidth, isDragging, handleMouseDown, containerRef };
|
|
12643
13098
|
};
|
|
12644
13099
|
|
|
12645
|
-
const
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
13100
|
+
const MastraResizablePanel = ({
|
|
13101
|
+
children,
|
|
13102
|
+
defaultWidth,
|
|
13103
|
+
minimumWidth,
|
|
13104
|
+
maximumWidth,
|
|
13105
|
+
className,
|
|
13106
|
+
disabled = false,
|
|
13107
|
+
setCurrentWidth,
|
|
13108
|
+
dividerPosition = "left"
|
|
12651
13109
|
}) => {
|
|
12652
|
-
const
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "json", className: "!text-icon3 text-ui-sm", children: "JSON" })
|
|
12662
|
-
] })
|
|
12663
|
-
] }) }),
|
|
12664
|
-
type === "form" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
12665
|
-
DynamicForm,
|
|
13110
|
+
const { sidebarWidth, isDragging, handleMouseDown, containerRef } = useResizeColumn({
|
|
13111
|
+
defaultWidth: disabled ? 100 : defaultWidth,
|
|
13112
|
+
minimumWidth,
|
|
13113
|
+
maximumWidth,
|
|
13114
|
+
setCurrentWidth
|
|
13115
|
+
});
|
|
13116
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full h-full relative", className), ref: containerRef, style: { width: `${sidebarWidth}%` }, children: [
|
|
13117
|
+
!disabled && dividerPosition === "left" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
13118
|
+
"div",
|
|
12666
13119
|
{
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
|
|
12670
|
-
submitButtonLabel,
|
|
12671
|
-
onSubmit
|
|
13120
|
+
className: `w-px bg-border1 h-full cursor-col-resize hover:w-1.5 hover:bg-mastra-border-2 hover:bg-[#424242] active:bg-mastra-border-3 active:bg-[#3e3e3e] transition-colors absolute inset-y-0 z-10
|
|
13121
|
+
${isDragging ? "bg-border2 w-1.5 cursor- col-resize" : ""}`,
|
|
13122
|
+
onMouseDown: handleMouseDown
|
|
12672
13123
|
}
|
|
12673
|
-
) :
|
|
12674
|
-
|
|
13124
|
+
) : null,
|
|
13125
|
+
children,
|
|
13126
|
+
!disabled && dividerPosition === "right" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
13127
|
+
"div",
|
|
12675
13128
|
{
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
submitButtonLabel,
|
|
12680
|
-
onSubmit
|
|
13129
|
+
className: `w-px bg-border1 h-full cursor-col-resize hover:w-1.5 hover:bg-border2 active:bg-border3 transition-colors absolute inset-y-0 z-10
|
|
13130
|
+
${isDragging ? "bg-border2 w-1.5 cursor- col-resize" : ""}`,
|
|
13131
|
+
onMouseDown: handleMouseDown
|
|
12681
13132
|
}
|
|
12682
|
-
)
|
|
13133
|
+
) : null
|
|
12683
13134
|
] });
|
|
12684
13135
|
};
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
|
|
12695
|
-
|
|
13136
|
+
|
|
13137
|
+
const TraceTree = ({ children }) => {
|
|
13138
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { children });
|
|
13139
|
+
};
|
|
13140
|
+
|
|
13141
|
+
const variantClasses = {
|
|
13142
|
+
agent: "bg-accent1"
|
|
13143
|
+
};
|
|
13144
|
+
const Time = ({ durationMs, tokenCount, variant, progressPercent, offsetPercent }) => {
|
|
13145
|
+
const variantClass = variant ? variantClasses[variant] : "bg-accent3";
|
|
13146
|
+
const percent = Math.min(100, progressPercent);
|
|
13147
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[80px] xl:w-[166px] shrink-0", children: [
|
|
13148
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface4 relative h-[6px] w-full rounded-full p-px overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13149
|
+
"div",
|
|
13150
|
+
{
|
|
13151
|
+
className: clsx("absolute h-1 rounded-full", variantClass),
|
|
13152
|
+
style: { width: `${percent}%`, left: `${offsetPercent}%` }
|
|
12696
13153
|
}
|
|
12697
|
-
}
|
|
12698
|
-
|
|
12699
|
-
|
|
12700
|
-
|
|
12701
|
-
|
|
12702
|
-
errors.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-sm border-accent2 rounded-lg p-2", children: [
|
|
12703
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { as: "p", variant: "ui-md", className: "text-accent2 font-semibold", children: [
|
|
12704
|
-
errors.length,
|
|
12705
|
-
" errors found"
|
|
13154
|
+
) }),
|
|
13155
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 pt-0.5", children: [
|
|
13156
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon2 font-medium", children: [
|
|
13157
|
+
toSigFigs(durationMs, 3),
|
|
13158
|
+
"ms"
|
|
12706
13159
|
] }),
|
|
12707
|
-
/* @__PURE__ */ jsxRuntime.
|
|
13160
|
+
tokenCount && /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon2 font-medium", children: [
|
|
13161
|
+
tokenCount,
|
|
13162
|
+
"t"
|
|
13163
|
+
] })
|
|
13164
|
+
] })
|
|
13165
|
+
] });
|
|
13166
|
+
};
|
|
13167
|
+
|
|
13168
|
+
const spanIconMap = {
|
|
13169
|
+
tool: ToolsIcon,
|
|
13170
|
+
agent: AgentIcon,
|
|
13171
|
+
workflow: WorkflowIcon,
|
|
13172
|
+
memory: MemoryIcon,
|
|
13173
|
+
rag: TraceIcon,
|
|
13174
|
+
storage: DbIcon,
|
|
13175
|
+
eval: ScoreIcon,
|
|
13176
|
+
other: TraceIcon
|
|
13177
|
+
};
|
|
13178
|
+
const spanVariantClasses = {
|
|
13179
|
+
tool: "text-[#ECB047]",
|
|
13180
|
+
agent: "text-accent1",
|
|
13181
|
+
workflow: "text-accent3",
|
|
13182
|
+
memory: "text-accent2",
|
|
13183
|
+
rag: "text-accent2",
|
|
13184
|
+
storage: "text-accent2",
|
|
13185
|
+
eval: "text-accent4",
|
|
13186
|
+
other: "text-icon6"
|
|
13187
|
+
};
|
|
13188
|
+
const Span = ({
|
|
13189
|
+
children,
|
|
13190
|
+
durationMs,
|
|
13191
|
+
variant,
|
|
13192
|
+
tokenCount,
|
|
13193
|
+
spans,
|
|
13194
|
+
isRoot,
|
|
13195
|
+
onClick,
|
|
13196
|
+
isActive,
|
|
13197
|
+
offsetMs,
|
|
13198
|
+
totalDurationMs
|
|
13199
|
+
}) => {
|
|
13200
|
+
const [isExpanded, setIsExpanded] = React.useState(true);
|
|
13201
|
+
const VariantIcon = spanIconMap[variant];
|
|
13202
|
+
const variantClass = spanVariantClasses[variant];
|
|
13203
|
+
const progressPercent = durationMs / totalDurationMs * 100;
|
|
13204
|
+
const offsetPercent = offsetMs / totalDurationMs * 100;
|
|
13205
|
+
const TextEl = onClick ? "button" : "div";
|
|
13206
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
13207
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx("flex justify-between items-center gap-2 rounded-md pl-2", isActive && "bg-surface4"), children: [
|
|
13208
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-8 items-center gap-1 min-w-0", children: [
|
|
13209
|
+
spans ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
13210
|
+
"button",
|
|
13211
|
+
{
|
|
13212
|
+
type: "button",
|
|
13213
|
+
"aria-label": isExpanded ? "Collapse span" : "Expand span",
|
|
13214
|
+
"aria-expanded": isExpanded,
|
|
13215
|
+
className: "text-icon3 flex h-4 w-4",
|
|
13216
|
+
onClick: () => setIsExpanded(!isExpanded),
|
|
13217
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(ChevronIcon, { className: clsx("transition-transform -rotate-90", { "rotate-0": isExpanded }) }) })
|
|
13218
|
+
}
|
|
13219
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": true, className: "h-full w-4", children: !isRoot && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-[7px] h-full w-px rounded-full" }) }),
|
|
13220
|
+
/* @__PURE__ */ jsxRuntime.jsxs(TextEl, { className: "flex items-center gap-2 min-w-0", onClick, children: [
|
|
13221
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx("bg-surface4 flex items-center justify-center rounded-md p-[3px]", variantClass), children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(VariantIcon, {}) }) }),
|
|
13222
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-md", className: "text-icon6 truncate", children })
|
|
13223
|
+
] })
|
|
13224
|
+
] }),
|
|
13225
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13226
|
+
Time,
|
|
13227
|
+
{
|
|
13228
|
+
durationMs,
|
|
13229
|
+
tokenCount,
|
|
13230
|
+
variant: variant === "agent" ? "agent" : void 0,
|
|
13231
|
+
progressPercent,
|
|
13232
|
+
offsetPercent
|
|
13233
|
+
}
|
|
13234
|
+
)
|
|
12708
13235
|
] }),
|
|
12709
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12710
|
-
/* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "light", onClick: handleSubmit, className: "w-full", size: "lg", children: isSubmitLoading ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) : submitButtonLabel })
|
|
13236
|
+
isExpanded && spans && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-4", children: spans })
|
|
12711
13237
|
] });
|
|
12712
13238
|
};
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
12716
|
-
|
|
12717
|
-
|
|
12718
|
-
|
|
13239
|
+
|
|
13240
|
+
const Spans = ({ children }) => {
|
|
13241
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ol", { children });
|
|
13242
|
+
};
|
|
13243
|
+
|
|
13244
|
+
const Trace = ({
|
|
13245
|
+
name,
|
|
13246
|
+
spans,
|
|
13247
|
+
durationMs,
|
|
13248
|
+
tokenCount,
|
|
13249
|
+
onClick,
|
|
13250
|
+
variant,
|
|
13251
|
+
isActive,
|
|
13252
|
+
totalDurationMs
|
|
13253
|
+
}) => {
|
|
13254
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13255
|
+
Span,
|
|
13256
|
+
{
|
|
13257
|
+
isRoot: true,
|
|
13258
|
+
durationMs,
|
|
13259
|
+
variant,
|
|
13260
|
+
spans: /* @__PURE__ */ jsxRuntime.jsx(Spans, { children: spans }),
|
|
13261
|
+
onClick,
|
|
13262
|
+
isActive,
|
|
13263
|
+
offsetMs: 0,
|
|
13264
|
+
totalDurationMs,
|
|
13265
|
+
children: name
|
|
13266
|
+
}
|
|
13267
|
+
);
|
|
13268
|
+
};
|
|
13269
|
+
|
|
13270
|
+
const getSpanVariant = (span) => {
|
|
13271
|
+
const attributes = Object.keys(span.attributes || {}).map((k) => k.toLowerCase());
|
|
13272
|
+
const lowerCaseName = span.name.toLowerCase();
|
|
13273
|
+
const isAiSpan = lowerCaseName.startsWith("ai.");
|
|
13274
|
+
if (isAiSpan) {
|
|
13275
|
+
const isAiAboutTool = lowerCaseName.includes("tool");
|
|
13276
|
+
if (isAiAboutTool) return "tool";
|
|
13277
|
+
return "other";
|
|
13278
|
+
}
|
|
13279
|
+
const hasMemoryRelatedAttributes = attributes.some((key) => key.includes("memory") || key.includes("storage"));
|
|
13280
|
+
if (hasMemoryRelatedAttributes) return "memory";
|
|
13281
|
+
const hasToolRelatedAttributes = attributes.some((key) => key.includes("tool"));
|
|
13282
|
+
if (hasToolRelatedAttributes) return "tool";
|
|
13283
|
+
const hasAgentRelatedAttributes = attributes.some((key) => key.includes("agent."));
|
|
13284
|
+
if (hasAgentRelatedAttributes) return "agent";
|
|
13285
|
+
if (lowerCaseName.includes(".insert")) {
|
|
13286
|
+
const evalRelatedAttribute = attributes.find((key) => String(span.attributes?.[key])?.includes("mastra_evals"));
|
|
13287
|
+
if (evalRelatedAttribute) return "eval";
|
|
13288
|
+
}
|
|
13289
|
+
return "other";
|
|
12719
13290
|
};
|
|
12720
13291
|
|
|
12721
|
-
function
|
|
12722
|
-
|
|
12723
|
-
|
|
12724
|
-
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
const
|
|
12738
|
-
const
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
try {
|
|
12744
|
-
if (!workflow) return;
|
|
12745
|
-
setIsRunning(true);
|
|
12746
|
-
setCancelResponse(null);
|
|
12747
|
-
setResult(null);
|
|
12748
|
-
const { runId } = await createWorkflowRun({ workflowId });
|
|
12749
|
-
setRunId?.(runId);
|
|
12750
|
-
setInnerRunId(runId);
|
|
12751
|
-
streamWorkflow({ workflowId, runId, inputData: data, runtimeContext });
|
|
12752
|
-
} catch (err) {
|
|
12753
|
-
setIsRunning(false);
|
|
12754
|
-
sonner.toast.error("Error executing workflow");
|
|
13292
|
+
function buildTree(spans, minStartTime, totalDurationMs, parentSpanId = null) {
|
|
13293
|
+
return spans.filter((span) => span.parentSpanId === parentSpanId).map((span) => {
|
|
13294
|
+
return {
|
|
13295
|
+
...span,
|
|
13296
|
+
children: buildTree(spans, minStartTime, totalDurationMs, span.id),
|
|
13297
|
+
offset: (span.startTime - minStartTime) / 1e3,
|
|
13298
|
+
// ns to ms
|
|
13299
|
+
duration: span.duration / 1e3,
|
|
13300
|
+
totalDurationMs
|
|
13301
|
+
};
|
|
13302
|
+
});
|
|
13303
|
+
}
|
|
13304
|
+
const createSpanTree = (spans) => {
|
|
13305
|
+
if (spans.length === 0) return [];
|
|
13306
|
+
let minStartTime;
|
|
13307
|
+
let maxEndTime;
|
|
13308
|
+
const orderedTree = [];
|
|
13309
|
+
const listSize = spans.length;
|
|
13310
|
+
for (let i = listSize - 1; i >= 0; i--) {
|
|
13311
|
+
const span = spans[i];
|
|
13312
|
+
if (!minStartTime || span.startTime < minStartTime) {
|
|
13313
|
+
minStartTime = span.startTime;
|
|
12755
13314
|
}
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
const { runId } = await createWorkflowRun({ workflowId, prevRunId });
|
|
12762
|
-
await resumeWorkflow({
|
|
12763
|
-
step: stepId,
|
|
12764
|
-
runId,
|
|
12765
|
-
resumeData,
|
|
12766
|
-
workflowId,
|
|
12767
|
-
runtimeContext
|
|
12768
|
-
});
|
|
12769
|
-
};
|
|
12770
|
-
const handleCancelWorkflowRun = async () => {
|
|
12771
|
-
const response = await cancelWorkflowRun({ workflowId, runId: innerRunId });
|
|
12772
|
-
setCancelResponse(response);
|
|
12773
|
-
};
|
|
12774
|
-
const streamResultToUse = result ?? streamResult;
|
|
12775
|
-
React.useEffect(() => {
|
|
12776
|
-
setIsRunning(isStreamingWorkflow);
|
|
12777
|
-
}, [isStreamingWorkflow]);
|
|
12778
|
-
React.useEffect(() => {
|
|
12779
|
-
if (!streamResultToUse?.payload?.workflowState?.steps || !result?.runId) return;
|
|
12780
|
-
const suspended = Object.entries(streamResultToUse.payload.workflowState.steps).filter(([_, { status }]) => status === "suspended").map(([stepId, { payload: payload2 }]) => ({
|
|
12781
|
-
stepId,
|
|
12782
|
-
runId: result.runId,
|
|
12783
|
-
suspendPayload: payload2,
|
|
12784
|
-
isLoading: false
|
|
12785
|
-
}));
|
|
12786
|
-
setSuspendedSteps(suspended);
|
|
12787
|
-
}, [streamResultToUse, result]);
|
|
12788
|
-
React.useEffect(() => {
|
|
12789
|
-
if (streamResult) {
|
|
12790
|
-
setResult(streamResult);
|
|
13315
|
+
if (!maxEndTime || span.endTime > maxEndTime) {
|
|
13316
|
+
maxEndTime = span.endTime;
|
|
13317
|
+
}
|
|
13318
|
+
if (span.name !== ".insert" && span.name !== "mastra.getStorage") {
|
|
13319
|
+
orderedTree.push(span);
|
|
12791
13320
|
}
|
|
12792
|
-
}, [streamResult]);
|
|
12793
|
-
if (isLoading) {
|
|
12794
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
12795
|
-
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-10" }),
|
|
12796
|
-
/* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-10" })
|
|
12797
|
-
] }) });
|
|
12798
13321
|
}
|
|
12799
|
-
if (!
|
|
12800
|
-
const
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
12861
|
-
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
13322
|
+
if (!minStartTime || !maxEndTime) return [];
|
|
13323
|
+
const totalDurationMs = (maxEndTime - minStartTime) / 1e3;
|
|
13324
|
+
return buildTree(orderedTree, minStartTime, totalDurationMs);
|
|
13325
|
+
};
|
|
13326
|
+
|
|
13327
|
+
const NestedSpans = ({ spanNodes }) => {
|
|
13328
|
+
const { span: activeSpan, setSpan } = React.useContext(TraceContext);
|
|
13329
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Spans, { children: spanNodes.map((spanNode) => {
|
|
13330
|
+
const isActive = spanNode.id === activeSpan?.id;
|
|
13331
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13332
|
+
Span,
|
|
13333
|
+
{
|
|
13334
|
+
spans: spanNode.children.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(NestedSpans, { spanNodes: spanNode.children }),
|
|
13335
|
+
durationMs: spanNode.duration,
|
|
13336
|
+
offsetMs: spanNode.offset,
|
|
13337
|
+
variant: getSpanVariant(spanNode),
|
|
13338
|
+
isActive,
|
|
13339
|
+
onClick: () => setSpan(spanNode),
|
|
13340
|
+
totalDurationMs: spanNode.totalDurationMs,
|
|
13341
|
+
children: spanNode.name
|
|
13342
|
+
},
|
|
13343
|
+
spanNode.id
|
|
13344
|
+
);
|
|
13345
|
+
}) });
|
|
13346
|
+
};
|
|
13347
|
+
function SpanView({ trace }) {
|
|
13348
|
+
const { span: activeSpan, setSpan } = React.useContext(TraceContext);
|
|
13349
|
+
const tree = createSpanTree(trace);
|
|
13350
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TraceTree, { children: tree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
13351
|
+
Trace,
|
|
13352
|
+
{
|
|
13353
|
+
name: node.name,
|
|
13354
|
+
durationMs: node.duration,
|
|
13355
|
+
totalDurationMs: node.totalDurationMs,
|
|
13356
|
+
spans: /* @__PURE__ */ jsxRuntime.jsx(NestedSpans, { spanNodes: node.children }),
|
|
13357
|
+
variant: getSpanVariant(node),
|
|
13358
|
+
isActive: node.id === activeSpan?.id,
|
|
13359
|
+
onClick: () => setSpan(node)
|
|
13360
|
+
}
|
|
13361
|
+
)) });
|
|
13362
|
+
}
|
|
13363
|
+
|
|
13364
|
+
const Header = ({ children, border = true }) => {
|
|
13365
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13366
|
+
"header",
|
|
13367
|
+
{
|
|
13368
|
+
className: clsx("h-header-default z-50 flex w-full items-center gap-[18px] bg-transparent px-5", {
|
|
13369
|
+
"border-b-sm border-border1": border
|
|
13370
|
+
}),
|
|
13371
|
+
children
|
|
13372
|
+
}
|
|
13373
|
+
);
|
|
13374
|
+
};
|
|
13375
|
+
const HeaderTitle = ({ children }) => {
|
|
13376
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "h1", variant: "ui-lg", className: "font-medium text-white", children });
|
|
13377
|
+
};
|
|
13378
|
+
const HeaderAction = ({ children }) => {
|
|
13379
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto", children });
|
|
13380
|
+
};
|
|
13381
|
+
const HeaderGroup = ({ children }) => {
|
|
13382
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gap-lg flex items-center", children });
|
|
13383
|
+
};
|
|
13384
|
+
|
|
13385
|
+
function TraceDetails() {
|
|
13386
|
+
const { trace, currentTraceIndex, prevTrace, nextTrace, traces } = React.useContext(TraceContext);
|
|
13387
|
+
const actualTrace = traces[currentTraceIndex];
|
|
13388
|
+
if (!actualTrace || !trace) return null;
|
|
13389
|
+
const hasFailure = trace.some((span) => span.status.code !== 0);
|
|
13390
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("aside", { children: [
|
|
13391
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Header, { children: [
|
|
13392
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
13393
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { className: "bg-transparent border-none", onClick: prevTrace, disabled: currentTraceIndex === 0, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, {}) }) }),
|
|
13394
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13395
|
+
Button,
|
|
13396
|
+
{
|
|
13397
|
+
className: "bg-transparent border-none",
|
|
13398
|
+
onClick: nextTrace,
|
|
13399
|
+
disabled: currentTraceIndex === traces.length - 1,
|
|
13400
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {}) })
|
|
13401
|
+
}
|
|
13402
|
+
)
|
|
13403
|
+
] }),
|
|
13404
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 justify-between w-full", children: [
|
|
13405
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-lg", className: "font-medium text-icon5 shrink-0", children: [
|
|
13406
|
+
"Trace ",
|
|
13407
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-icon3", children: actualTrace.traceId.substring(0, 7) })
|
|
13408
|
+
] }),
|
|
13409
|
+
hasFailure && /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}), children: "Failed" })
|
|
12887
13410
|
] })
|
|
12888
13411
|
] }),
|
|
12889
|
-
|
|
13412
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-5", children: /* @__PURE__ */ jsxRuntime.jsx(SpanView, { trace }) })
|
|
12890
13413
|
] });
|
|
12891
13414
|
}
|
|
12892
|
-
const WorkflowJsonDialog = ({ result }) => {
|
|
12893
|
-
const [open, setOpen] = React.useState(false);
|
|
12894
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12895
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "light", onClick: () => setOpen(true), className: "w-full", size: "lg", children: [
|
|
12896
|
-
/* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Braces, { className: "text-icon3" }) }),
|
|
12897
|
-
"Open Workflow Execution (JSON)"
|
|
12898
|
-
] }),
|
|
12899
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsx(DialogPortal, { children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "max-w-6xl max-h-[90vh] overflow-y-auto overflow-x-hidden bg-surface2", children: [
|
|
12900
|
-
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Workflow Execution (JSON)" }),
|
|
12901
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full overflow-x-scroll", children: /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$2, { data: result, className: "p-4" }) })
|
|
12902
|
-
] }) }) })
|
|
12903
|
-
] });
|
|
12904
|
-
};
|
|
12905
13415
|
|
|
12906
|
-
|
|
12907
|
-
|
|
12908
|
-
|
|
13416
|
+
function formatDuration(duration, fixedPoint = 2) {
|
|
13417
|
+
const durationInSecs = duration / 1e3;
|
|
13418
|
+
return durationInSecs.toFixed(fixedPoint);
|
|
13419
|
+
}
|
|
13420
|
+
function formatOtelTimestamp(otelTimestamp) {
|
|
13421
|
+
const date = new Date(otelTimestamp / 1e3);
|
|
13422
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
13423
|
+
month: "numeric",
|
|
13424
|
+
day: "numeric",
|
|
13425
|
+
year: "numeric",
|
|
13426
|
+
hour: "numeric",
|
|
13427
|
+
minute: "numeric",
|
|
13428
|
+
second: "numeric",
|
|
13429
|
+
hour12: true
|
|
13430
|
+
}).format(date);
|
|
13431
|
+
}
|
|
13432
|
+
function formatOtelTimestamp2(otelTimestamp) {
|
|
13433
|
+
const date = new Date(otelTimestamp / 1e6);
|
|
13434
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
13435
|
+
month: "numeric",
|
|
13436
|
+
day: "numeric",
|
|
13437
|
+
year: "numeric",
|
|
13438
|
+
hour: "numeric",
|
|
13439
|
+
minute: "numeric",
|
|
13440
|
+
second: "numeric",
|
|
13441
|
+
hour12: true
|
|
13442
|
+
}).format(date);
|
|
13443
|
+
}
|
|
13444
|
+
function transformKey(key) {
|
|
13445
|
+
if (key.includes(".argument.")) {
|
|
13446
|
+
return `Input`;
|
|
12909
13447
|
}
|
|
12910
|
-
if (
|
|
12911
|
-
return
|
|
13448
|
+
if (key.includes(".result")) {
|
|
13449
|
+
return "Output";
|
|
12912
13450
|
}
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
13451
|
+
const newKey = key.split(".").join(" ").split("_").join(" ").replaceAll("ai", "AI");
|
|
13452
|
+
return newKey.substring(0, 1).toUpperCase() + newKey.substring(1);
|
|
13453
|
+
}
|
|
13454
|
+
function cleanString(string) {
|
|
13455
|
+
return string.replace(/\\n/g, "").replace(/\n/g, "").replace(/\s+/g, " ").trim();
|
|
13456
|
+
}
|
|
13457
|
+
const allowedAiSpanAttributes = [
|
|
13458
|
+
"operation.name",
|
|
13459
|
+
"ai.operationId",
|
|
13460
|
+
"ai.model.provider",
|
|
13461
|
+
"ai.model.id",
|
|
13462
|
+
"ai.prompt.format",
|
|
13463
|
+
"ai.prompt.messages",
|
|
13464
|
+
"ai.prompt.tools",
|
|
13465
|
+
"ai.prompt.toolChoice",
|
|
13466
|
+
"ai.settings.toolChoice",
|
|
13467
|
+
"ai.schema",
|
|
13468
|
+
"ai.settings.output",
|
|
13469
|
+
"ai.response.object",
|
|
13470
|
+
"ai.response.text",
|
|
13471
|
+
"ai.response.timestamp",
|
|
13472
|
+
"componentName",
|
|
13473
|
+
"ai.usage.promptTokens",
|
|
13474
|
+
"ai.usage.completionTokens"
|
|
13475
|
+
];
|
|
13476
|
+
|
|
13477
|
+
function SpanDetail() {
|
|
13478
|
+
const { span, setSpan, trace, setIsOpen } = React.useContext(TraceContext);
|
|
13479
|
+
if (!span || !trace) return null;
|
|
13480
|
+
const prevSpan = () => {
|
|
13481
|
+
const currentIndex = trace.findIndex((t) => t.id === span.id);
|
|
13482
|
+
if (currentIndex !== -1 && currentIndex < trace.length - 1) {
|
|
13483
|
+
setSpan(trace[currentIndex + 1]);
|
|
12924
13484
|
}
|
|
12925
|
-
|
|
13485
|
+
};
|
|
13486
|
+
const nextSpan = () => {
|
|
13487
|
+
const currentIndex = trace.findIndex((t) => t.id === span.id);
|
|
13488
|
+
if (currentIndex !== -1 && currentIndex > 0) {
|
|
13489
|
+
setSpan(trace[currentIndex - 1]);
|
|
13490
|
+
}
|
|
13491
|
+
};
|
|
13492
|
+
const SpanIcon = spanIconMap[getSpanVariant(span)];
|
|
13493
|
+
const variantClass = spanVariantClasses[getSpanVariant(span)];
|
|
13494
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("aside", { children: [
|
|
13495
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Header, { children: [
|
|
13496
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
13497
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { className: "bg-transparent border-none", onClick: prevSpan, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, {}) }) }),
|
|
13498
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { className: "bg-transparent border-none", onClick: nextSpan, children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {}) }) })
|
|
13499
|
+
] }),
|
|
13500
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-lg", className: "font-medium text-icon5", as: "h2", children: [
|
|
13501
|
+
"Span ",
|
|
13502
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-icon3", children: span.id.substring(0, 7) })
|
|
13503
|
+
] }) }),
|
|
13504
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { className: "bg-transparent border-none", onClick: () => setIsOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}) }) }) })
|
|
13505
|
+
] }),
|
|
13506
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-5", children: [
|
|
13507
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "header-md", as: "h3", className: "text-icon-6 flex items-center gap-4 pb-3", children: [
|
|
13508
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "lg", className: "bg-surface4 p-1 rounded-md", children: /* @__PURE__ */ jsxRuntime.jsx(SpanIcon, { className: variantClass }) }),
|
|
13509
|
+
span.name
|
|
13510
|
+
] }),
|
|
13511
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-row gap-2 items-center", children: span.status.code === 0 ? /* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(LatencyIcon, {}), variant: "success", children: [
|
|
13512
|
+
toSigFigs(span.duration, 3),
|
|
13513
|
+
"ms"
|
|
13514
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { variant: "error", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}), children: [
|
|
13515
|
+
"Failed in ",
|
|
13516
|
+
toSigFigs(span.duration, 3),
|
|
13517
|
+
"ms"
|
|
13518
|
+
] }) }),
|
|
13519
|
+
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
13520
|
+
/* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "grid grid-cols-2 justify-between gap-2", children: [
|
|
13521
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "ID" }),
|
|
13522
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: span.id }),
|
|
13523
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "Created at" }),
|
|
13524
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: span.startTime ? formatOtelTimestamp(span.startTime) : "" })
|
|
13525
|
+
] }),
|
|
13526
|
+
span.attributes && /* @__PURE__ */ jsxRuntime.jsx(Attributes, { attributes: span.attributes }),
|
|
13527
|
+
span.events?.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Events, { span })
|
|
13528
|
+
] })
|
|
13529
|
+
] });
|
|
13530
|
+
}
|
|
13531
|
+
function Attributes({ attributes }) {
|
|
13532
|
+
if (!attributes) return null;
|
|
13533
|
+
const entries = Object.entries(attributes);
|
|
13534
|
+
if (entries.length === 0) return null;
|
|
13535
|
+
const keysToHide = ["http.request_id", "componentName"];
|
|
13536
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: entries.filter(([key]) => !keysToHide.includes(key)).map(([key, val]) => {
|
|
13537
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
13538
|
+
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
13539
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "h4", variant: "ui-md", className: "text-icon3 pb-2", children: transformKey(key) }),
|
|
13540
|
+
/* @__PURE__ */ jsxRuntime.jsx(AttributeValue, { value: val })
|
|
13541
|
+
] }, key);
|
|
13542
|
+
}) });
|
|
13543
|
+
}
|
|
13544
|
+
const AttributeValue = ({ value }) => {
|
|
13545
|
+
if (!value)
|
|
13546
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: "N/A" });
|
|
13547
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
13548
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: String(value) });
|
|
13549
|
+
}
|
|
13550
|
+
if (typeof value === "object") {
|
|
13551
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$1, { data: value });
|
|
13552
|
+
}
|
|
13553
|
+
try {
|
|
13554
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$1, { data: JSON.parse(value) });
|
|
13555
|
+
} catch {
|
|
13556
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6", children: String(value) });
|
|
13557
|
+
}
|
|
12926
13558
|
};
|
|
13559
|
+
function Events({ span }) {
|
|
13560
|
+
if (!span.events) return null;
|
|
13561
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
13562
|
+
/* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" }),
|
|
13563
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "p", variant: "ui-md", className: "text-icon6 pb-2", children: "Events" }),
|
|
13564
|
+
span.events.map((event) => {
|
|
13565
|
+
const isLast = event === span.events[span.events.length - 1];
|
|
13566
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
13567
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
13568
|
+
/* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "grid grid-cols-2 justify-between gap-2 pb-2", children: [
|
|
13569
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "Name" }),
|
|
13570
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: event.name }),
|
|
13571
|
+
/* @__PURE__ */ jsxRuntime.jsx("dt", { className: "font-medium text-ui-md text-icon3", children: "Time" }),
|
|
13572
|
+
/* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-ui-md text-icon6", children: event.timeUnixNano ? formatOtelTimestamp2(Number(event.timeUnixNano)) : "N/A" })
|
|
13573
|
+
] }),
|
|
13574
|
+
event.attributes?.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2", children: event.attributes.filter((attribute) => attribute !== null).map((attribute) => /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
13575
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "h4", variant: "ui-md", className: "text-icon3 pb-2", children: transformKey(attribute.key) }),
|
|
13576
|
+
/* @__PURE__ */ jsxRuntime.jsx(AttributeValue, { value: attribute.value })
|
|
13577
|
+
] }, attribute.key)) }) : null
|
|
13578
|
+
] }, event.name),
|
|
13579
|
+
!isLast && /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-border1 border-sm my-5" })
|
|
13580
|
+
] }, event.name);
|
|
13581
|
+
})
|
|
13582
|
+
] });
|
|
13583
|
+
}
|
|
12927
13584
|
|
|
12928
|
-
const
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
|
|
12938
|
-
|
|
12939
|
-
|
|
12940
|
-
|
|
12941
|
-
}
|
|
12942
|
-
);
|
|
12943
|
-
},
|
|
12944
|
-
meta: {
|
|
12945
|
-
width: "auto"
|
|
13585
|
+
const TracesSidebar = ({ onResize }) => {
|
|
13586
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13587
|
+
MastraResizablePanel,
|
|
13588
|
+
{
|
|
13589
|
+
className: "h-full absolute right-0 inset-y-0 bg-surface2",
|
|
13590
|
+
defaultWidth: 80,
|
|
13591
|
+
minimumWidth: 50,
|
|
13592
|
+
maximumWidth: 80,
|
|
13593
|
+
setCurrentWidth: onResize,
|
|
13594
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full grid grid-cols-2", children: [
|
|
13595
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-scroll w-full h-[calc(100%-40px)]", children: /* @__PURE__ */ jsxRuntime.jsx(TraceDetails, {}) }),
|
|
13596
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-[calc(100%-40px)] overflow-x-scroll w-full border-l border-border1", children: /* @__PURE__ */ jsxRuntime.jsx(SpanDetail, {}) })
|
|
13597
|
+
] })
|
|
12946
13598
|
}
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
id: "stepsCount",
|
|
12950
|
-
header: "Steps",
|
|
12951
|
-
size: 300,
|
|
12952
|
-
cell: ({ row }) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end items-center gap-2", children: [
|
|
12953
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Footprints, {}), className: "!h-button-md", children: [
|
|
12954
|
-
row.original.stepsCount,
|
|
12955
|
-
" step",
|
|
12956
|
-
row.original.stepsCount > 1 ? "s" : ""
|
|
12957
|
-
] }),
|
|
12958
|
-
row.original.isLegacy ? /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { className: "!text-foreground/80 !h-button-md", children: "Legacy" }) : null
|
|
12959
|
-
] }) })
|
|
12960
|
-
}
|
|
12961
|
-
];
|
|
13599
|
+
);
|
|
13600
|
+
};
|
|
12962
13601
|
|
|
12963
|
-
function
|
|
12964
|
-
|
|
12965
|
-
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
|
|
12971
|
-
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
};
|
|
12975
|
-
});
|
|
12976
|
-
const legacyWorkflowsData = Object.keys(legacyWorkflows ?? {}).map((key) => {
|
|
12977
|
-
const workflow = legacyWorkflows?.[key];
|
|
12978
|
-
return {
|
|
12979
|
-
id: key,
|
|
12980
|
-
name: workflow?.name || "N/A",
|
|
12981
|
-
stepsCount: Object.keys(workflow?.steps ?? {})?.length,
|
|
12982
|
-
isLegacy: true,
|
|
12983
|
-
link: computeLink(key)
|
|
12984
|
-
};
|
|
12985
|
-
});
|
|
12986
|
-
return [..._workflowsData, ...legacyWorkflowsData];
|
|
12987
|
-
}, [workflows, legacyWorkflows]);
|
|
12988
|
-
const table = reactTable.useReactTable({
|
|
12989
|
-
data: workflowData,
|
|
12990
|
-
columns,
|
|
12991
|
-
getCoreRowModel: reactTable.getCoreRowModel()
|
|
12992
|
-
});
|
|
12993
|
-
if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(WorkflowTableSkeleton, {});
|
|
12994
|
-
const ths = table.getHeaderGroups()[0];
|
|
12995
|
-
const rows = table.getRowModel().rows.concat();
|
|
12996
|
-
if (rows.length === 0) {
|
|
12997
|
-
return /* @__PURE__ */ jsxRuntime.jsx(EmptyWorkflowsTable, {});
|
|
13602
|
+
function TracesView({
|
|
13603
|
+
isLoading,
|
|
13604
|
+
error,
|
|
13605
|
+
traces,
|
|
13606
|
+
runId,
|
|
13607
|
+
stepName,
|
|
13608
|
+
className,
|
|
13609
|
+
setEndOfListElement
|
|
13610
|
+
}) {
|
|
13611
|
+
if (isLoading) {
|
|
13612
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TracesViewSkeleton, {});
|
|
12998
13613
|
}
|
|
12999
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13000
|
-
|
|
13001
|
-
|
|
13002
|
-
|
|
13614
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TraceProvider, { initialTraces: traces || [], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
13615
|
+
TracesViewInner,
|
|
13616
|
+
{
|
|
13617
|
+
traces,
|
|
13618
|
+
error,
|
|
13619
|
+
runId,
|
|
13620
|
+
stepName,
|
|
13621
|
+
className,
|
|
13622
|
+
setEndOfListElement
|
|
13623
|
+
}
|
|
13624
|
+
) });
|
|
13003
13625
|
}
|
|
13004
|
-
|
|
13005
|
-
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
{
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
"Docs"
|
|
13032
|
-
]
|
|
13033
|
-
}
|
|
13034
|
-
)
|
|
13035
|
-
}
|
|
13036
|
-
) });
|
|
13626
|
+
function TracesViewInner({ traces, error, runId, stepName, className, setEndOfListElement }) {
|
|
13627
|
+
const hasRunRef = React.useRef(false);
|
|
13628
|
+
const [sidebarWidth, setSidebarWidth] = React.useState(100);
|
|
13629
|
+
const { isOpen: open, setTrace, setIsOpen, setSpan } = React.useContext(TraceContext);
|
|
13630
|
+
React.useEffect(() => {
|
|
13631
|
+
if (hasRunRef.current) return;
|
|
13632
|
+
if (!runId || !stepName) return;
|
|
13633
|
+
const matchingTrace = traces.find((trace) => trace.runId === runId);
|
|
13634
|
+
if (!matchingTrace) return;
|
|
13635
|
+
const matchingSpan = matchingTrace.trace.find((span) => span.name.includes(stepName));
|
|
13636
|
+
if (!matchingSpan) return;
|
|
13637
|
+
setTrace(matchingTrace.trace);
|
|
13638
|
+
setSpan(matchingSpan);
|
|
13639
|
+
setIsOpen(true);
|
|
13640
|
+
hasRunRef.current = true;
|
|
13641
|
+
}, [runId, traces, setTrace]);
|
|
13642
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx("h-full relative overflow-hidden flex", className), children: [
|
|
13643
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full overflow-y-scroll w-full", children: [
|
|
13644
|
+
/* @__PURE__ */ jsxRuntime.jsx(TracesTable, { traces, error }),
|
|
13645
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": true, ref: setEndOfListElement })
|
|
13646
|
+
] }),
|
|
13647
|
+
open && /* @__PURE__ */ jsxRuntime.jsx(TracesSidebar, { width: sidebarWidth, onResize: setSidebarWidth })
|
|
13648
|
+
] });
|
|
13649
|
+
}
|
|
13650
|
+
const TracesViewSkeleton = () => {
|
|
13651
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full relative overflow-hidden flex", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-y-scroll w-full", children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-10" }) }) });
|
|
13652
|
+
};
|
|
13037
13653
|
|
|
13038
13654
|
const DataTable = ({
|
|
13039
13655
|
columns,
|
|
@@ -13173,47 +13789,6 @@ function devUIStyleRequested(name) {
|
|
|
13173
13789
|
}
|
|
13174
13790
|
}
|
|
13175
13791
|
|
|
13176
|
-
const Threads = ({ children }) => {
|
|
13177
|
-
return /* @__PURE__ */ jsxRuntime.jsx("nav", { className: "bg-surface2 border-r-sm border-border1 min-h-full overflow-hidden", children });
|
|
13178
|
-
};
|
|
13179
|
-
const ThreadLink = ({ children, as: Component = "a", href, className, prefetch, to }) => {
|
|
13180
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13181
|
-
Component,
|
|
13182
|
-
{
|
|
13183
|
-
href,
|
|
13184
|
-
prefetch,
|
|
13185
|
-
to,
|
|
13186
|
-
className: clsx("text-ui-sm flex h-full w-full flex-col justify-center font-medium", className),
|
|
13187
|
-
children
|
|
13188
|
-
}
|
|
13189
|
-
);
|
|
13190
|
-
};
|
|
13191
|
-
const ThreadList = ({ children }) => {
|
|
13192
|
-
return /* @__PURE__ */ jsxRuntime.jsx("ol", { children });
|
|
13193
|
-
};
|
|
13194
|
-
const ThreadItem = ({ children, isActive }) => {
|
|
13195
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13196
|
-
"li",
|
|
13197
|
-
{
|
|
13198
|
-
className: clsx(
|
|
13199
|
-
"border-b-sm border-border1 hover:bg-surface3 group flex h-[54px] items-center justify-between gap-2 pl-5 py-2",
|
|
13200
|
-
isActive && "bg-surface4"
|
|
13201
|
-
),
|
|
13202
|
-
children
|
|
13203
|
-
}
|
|
13204
|
-
);
|
|
13205
|
-
};
|
|
13206
|
-
const ThreadDeleteButton = ({ onClick }) => {
|
|
13207
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13208
|
-
Button,
|
|
13209
|
-
{
|
|
13210
|
-
className: "shrink-0 border-none bg-transparent opacity-0 transition-all group-focus-within:opacity-100 group-hover:opacity-100",
|
|
13211
|
-
onClick,
|
|
13212
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-label": "delete thread", className: "text-icon3" }) })
|
|
13213
|
-
}
|
|
13214
|
-
);
|
|
13215
|
-
};
|
|
13216
|
-
|
|
13217
13792
|
const Breadcrumb = ({ children, label }) => {
|
|
13218
13793
|
return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": label, children: /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "gap-sm flex items-center", children }) });
|
|
13219
13794
|
};
|
|
@@ -13396,24 +13971,318 @@ function usePolling({
|
|
|
13396
13971
|
};
|
|
13397
13972
|
}
|
|
13398
13973
|
|
|
13974
|
+
const useInView = () => {
|
|
13975
|
+
const [inView, setInView] = React.useState(false);
|
|
13976
|
+
const setRef = React.useCallback((node) => {
|
|
13977
|
+
if (node) {
|
|
13978
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
13979
|
+
setInView(entry.isIntersecting);
|
|
13980
|
+
});
|
|
13981
|
+
observer.observe(node);
|
|
13982
|
+
return () => observer.disconnect();
|
|
13983
|
+
}
|
|
13984
|
+
}, []);
|
|
13985
|
+
return { inView, setRef };
|
|
13986
|
+
};
|
|
13987
|
+
|
|
13988
|
+
const PlaygroundQueryClient = ({ children }) => {
|
|
13989
|
+
const queryClient = new reactQuery.QueryClient();
|
|
13990
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClient, children });
|
|
13991
|
+
};
|
|
13992
|
+
|
|
13993
|
+
const formatRelativeTime = (date) => {
|
|
13994
|
+
const now = /* @__PURE__ */ new Date();
|
|
13995
|
+
const seconds = Math.floor((now.getTime() - date.getTime()) / 1e3);
|
|
13996
|
+
if (seconds < 60) return "just now";
|
|
13997
|
+
if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
|
|
13998
|
+
if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`;
|
|
13999
|
+
if (seconds < 604800) return `${Math.floor(seconds / 86400)}d ago`;
|
|
14000
|
+
return date.toLocaleDateString();
|
|
14001
|
+
};
|
|
14002
|
+
const MemorySearch = ({
|
|
14003
|
+
searchMemory,
|
|
14004
|
+
onResultClick,
|
|
14005
|
+
className,
|
|
14006
|
+
currentThreadId,
|
|
14007
|
+
chatInputValue
|
|
14008
|
+
}) => {
|
|
14009
|
+
const [query, setQuery] = React.useState("");
|
|
14010
|
+
const [results, setResults] = React.useState([]);
|
|
14011
|
+
const [isSearching, setIsSearching] = React.useState(false);
|
|
14012
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
14013
|
+
const [error, setError] = React.useState(null);
|
|
14014
|
+
const searchTimeoutRef = React.useRef(void 0);
|
|
14015
|
+
const dropdownRef = React.useRef(null);
|
|
14016
|
+
const prevThreadIdRef = React.useRef(currentThreadId);
|
|
14017
|
+
const lastSearchTimeRef = React.useRef(0);
|
|
14018
|
+
const pendingSearchRef = React.useRef(null);
|
|
14019
|
+
const handleSearch = React.useCallback(
|
|
14020
|
+
async (searchQuery) => {
|
|
14021
|
+
if (!searchQuery.trim()) {
|
|
14022
|
+
setError(null);
|
|
14023
|
+
return;
|
|
14024
|
+
}
|
|
14025
|
+
setIsSearching(true);
|
|
14026
|
+
setError(null);
|
|
14027
|
+
try {
|
|
14028
|
+
const response = await searchMemory(searchQuery);
|
|
14029
|
+
setResults(response.results);
|
|
14030
|
+
setIsOpen((prev) => prev || response.results.length > 0);
|
|
14031
|
+
} catch (err) {
|
|
14032
|
+
setError("Failed to search memory");
|
|
14033
|
+
console.error("Memory search error:", err);
|
|
14034
|
+
} finally {
|
|
14035
|
+
setIsSearching(false);
|
|
14036
|
+
}
|
|
14037
|
+
},
|
|
14038
|
+
[searchMemory]
|
|
14039
|
+
);
|
|
14040
|
+
const handleInputChange = React.useCallback(
|
|
14041
|
+
(e) => {
|
|
14042
|
+
const value = e.target.value;
|
|
14043
|
+
setQuery(value);
|
|
14044
|
+
if (searchTimeoutRef.current) {
|
|
14045
|
+
clearTimeout(searchTimeoutRef.current);
|
|
14046
|
+
}
|
|
14047
|
+
if (value.trim()) {
|
|
14048
|
+
const now = Date.now();
|
|
14049
|
+
const timeSinceLastSearch = now - lastSearchTimeRef.current;
|
|
14050
|
+
if (timeSinceLastSearch >= 500) {
|
|
14051
|
+
setIsSearching(true);
|
|
14052
|
+
handleSearch(value);
|
|
14053
|
+
lastSearchTimeRef.current = now;
|
|
14054
|
+
} else {
|
|
14055
|
+
setIsSearching(true);
|
|
14056
|
+
pendingSearchRef.current = value;
|
|
14057
|
+
const remainingTime = 500 - timeSinceLastSearch;
|
|
14058
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
14059
|
+
if (pendingSearchRef.current) {
|
|
14060
|
+
handleSearch(pendingSearchRef.current);
|
|
14061
|
+
lastSearchTimeRef.current = Date.now();
|
|
14062
|
+
pendingSearchRef.current = null;
|
|
14063
|
+
}
|
|
14064
|
+
}, remainingTime);
|
|
14065
|
+
}
|
|
14066
|
+
} else {
|
|
14067
|
+
setResults([]);
|
|
14068
|
+
setIsOpen(false);
|
|
14069
|
+
setIsSearching(false);
|
|
14070
|
+
pendingSearchRef.current = null;
|
|
14071
|
+
}
|
|
14072
|
+
},
|
|
14073
|
+
[handleSearch]
|
|
14074
|
+
);
|
|
14075
|
+
const handleKeyDown = React.useCallback(
|
|
14076
|
+
(e) => {
|
|
14077
|
+
if (e.key === "Enter") {
|
|
14078
|
+
e.preventDefault();
|
|
14079
|
+
if (searchTimeoutRef.current) {
|
|
14080
|
+
clearTimeout(searchTimeoutRef.current);
|
|
14081
|
+
}
|
|
14082
|
+
handleSearch(query);
|
|
14083
|
+
}
|
|
14084
|
+
},
|
|
14085
|
+
[query, handleSearch]
|
|
14086
|
+
);
|
|
14087
|
+
React.useEffect(() => {
|
|
14088
|
+
return () => {
|
|
14089
|
+
if (searchTimeoutRef.current) {
|
|
14090
|
+
clearTimeout(searchTimeoutRef.current);
|
|
14091
|
+
}
|
|
14092
|
+
};
|
|
14093
|
+
}, []);
|
|
14094
|
+
React.useEffect(() => {
|
|
14095
|
+
const handleClickOutside = (event) => {
|
|
14096
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
14097
|
+
setIsOpen(false);
|
|
14098
|
+
}
|
|
14099
|
+
};
|
|
14100
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
14101
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
14102
|
+
}, []);
|
|
14103
|
+
React.useEffect(() => {
|
|
14104
|
+
if (prevThreadIdRef.current !== currentThreadId && query.trim()) {
|
|
14105
|
+
handleSearch(query);
|
|
14106
|
+
}
|
|
14107
|
+
prevThreadIdRef.current = currentThreadId;
|
|
14108
|
+
}, [currentThreadId, query, handleSearch]);
|
|
14109
|
+
React.useEffect(() => {
|
|
14110
|
+
if (chatInputValue !== void 0 && chatInputValue !== query) {
|
|
14111
|
+
setQuery(chatInputValue);
|
|
14112
|
+
if (searchTimeoutRef.current) {
|
|
14113
|
+
clearTimeout(searchTimeoutRef.current);
|
|
14114
|
+
}
|
|
14115
|
+
if (chatInputValue.trim()) {
|
|
14116
|
+
const now = Date.now();
|
|
14117
|
+
const timeSinceLastSearch = now - lastSearchTimeRef.current;
|
|
14118
|
+
if (timeSinceLastSearch >= 500) {
|
|
14119
|
+
setIsSearching(true);
|
|
14120
|
+
handleSearch(chatInputValue);
|
|
14121
|
+
lastSearchTimeRef.current = now;
|
|
14122
|
+
} else {
|
|
14123
|
+
setIsSearching(true);
|
|
14124
|
+
pendingSearchRef.current = chatInputValue;
|
|
14125
|
+
const remainingTime = 500 - timeSinceLastSearch;
|
|
14126
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
14127
|
+
if (pendingSearchRef.current) {
|
|
14128
|
+
handleSearch(pendingSearchRef.current);
|
|
14129
|
+
lastSearchTimeRef.current = Date.now();
|
|
14130
|
+
pendingSearchRef.current = null;
|
|
14131
|
+
}
|
|
14132
|
+
}, remainingTime);
|
|
14133
|
+
}
|
|
14134
|
+
} else {
|
|
14135
|
+
setResults([]);
|
|
14136
|
+
setIsOpen(false);
|
|
14137
|
+
setIsSearching(false);
|
|
14138
|
+
pendingSearchRef.current = null;
|
|
14139
|
+
}
|
|
14140
|
+
}
|
|
14141
|
+
return () => {
|
|
14142
|
+
if (searchTimeoutRef.current) {
|
|
14143
|
+
clearTimeout(searchTimeoutRef.current);
|
|
14144
|
+
}
|
|
14145
|
+
};
|
|
14146
|
+
}, [chatInputValue]);
|
|
14147
|
+
const handleResultClick = (messageId, threadId) => {
|
|
14148
|
+
onResultClick?.(messageId, threadId);
|
|
14149
|
+
};
|
|
14150
|
+
const clearSearch = () => {
|
|
14151
|
+
setQuery("");
|
|
14152
|
+
setResults([]);
|
|
14153
|
+
setIsOpen(false);
|
|
14154
|
+
setError(null);
|
|
14155
|
+
if (searchTimeoutRef.current) {
|
|
14156
|
+
clearTimeout(searchTimeoutRef.current);
|
|
14157
|
+
}
|
|
14158
|
+
};
|
|
14159
|
+
const truncateContent = (content, maxLength = 100) => {
|
|
14160
|
+
if (content.length <= maxLength) return content;
|
|
14161
|
+
return content.substring(0, maxLength) + "...";
|
|
14162
|
+
};
|
|
14163
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col h-full", className), ref: dropdownRef, children: [
|
|
14164
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative shrink-0", children: [
|
|
14165
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-icon3" }),
|
|
14166
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
14167
|
+
Input,
|
|
14168
|
+
{
|
|
14169
|
+
type: "text",
|
|
14170
|
+
value: query,
|
|
14171
|
+
onChange: handleInputChange,
|
|
14172
|
+
onKeyDown: handleKeyDown,
|
|
14173
|
+
placeholder: "Search memory...",
|
|
14174
|
+
className: "pl-10 pr-10 bg-surface3 border-border1"
|
|
14175
|
+
}
|
|
14176
|
+
),
|
|
14177
|
+
query && /* @__PURE__ */ jsxRuntime.jsx(
|
|
14178
|
+
Button$1,
|
|
14179
|
+
{
|
|
14180
|
+
onClick: clearSearch,
|
|
14181
|
+
variant: "ghost",
|
|
14182
|
+
size: "sm",
|
|
14183
|
+
className: "absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0",
|
|
14184
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" })
|
|
14185
|
+
}
|
|
14186
|
+
)
|
|
14187
|
+
] }),
|
|
14188
|
+
(isOpen || query && (isSearching || results.length === 0)) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 flex-1 bg-surface3 border border-border1 rounded-lg shadow-lg overflow-y-auto", children: error ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-red-500", children: error }) }) : isSearching && results.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon3", children: "Searching..." }) }) : results.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxRuntime.jsxs(Txt, { variant: "ui-sm", className: "text-icon3", children: [
|
|
14189
|
+
'No results found for "',
|
|
14190
|
+
query,
|
|
14191
|
+
'"'
|
|
14192
|
+
] }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-2", children: results.map((result) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
14193
|
+
"button",
|
|
14194
|
+
{
|
|
14195
|
+
onClick: () => handleResultClick(result.id, result.threadId),
|
|
14196
|
+
className: cn(
|
|
14197
|
+
"w-full px-4 py-3 hover:bg-surface4 transition-colors duration-150 text-left border-b border-border1 last:border-b-0",
|
|
14198
|
+
result.threadId !== currentThreadId && "border-l-2 border-l-blue-400"
|
|
14199
|
+
),
|
|
14200
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
14201
|
+
result.context?.before && result.context.before.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "opacity-50 text-xs space-y-1", children: result.context.before.map((msg, idx) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
|
|
14202
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
|
|
14203
|
+
msg.role,
|
|
14204
|
+
":"
|
|
14205
|
+
] }),
|
|
14206
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-icon3", children: truncateContent(msg.content, 50) })
|
|
14207
|
+
] }, idx)) }),
|
|
14208
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-start justify-between gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
14209
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 mb-1", children: [
|
|
14210
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
14211
|
+
"span",
|
|
14212
|
+
{
|
|
14213
|
+
className: cn(
|
|
14214
|
+
"text-xs font-medium px-2 py-0.5 rounded",
|
|
14215
|
+
result.role === "user" ? "bg-blue-500/20 text-blue-400" : "bg-green-500/20 text-green-400"
|
|
14216
|
+
),
|
|
14217
|
+
children: result.role
|
|
14218
|
+
}
|
|
14219
|
+
),
|
|
14220
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-xs", className: "text-icon3", children: formatRelativeTime(new Date(result.createdAt)) }),
|
|
14221
|
+
result.threadTitle && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
14222
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
14223
|
+
Txt,
|
|
14224
|
+
{
|
|
14225
|
+
variant: "ui-xs",
|
|
14226
|
+
className: cn(
|
|
14227
|
+
"truncate max-w-[150px]",
|
|
14228
|
+
result.threadId !== currentThreadId ? "text-blue-400 font-medium" : "text-icon3"
|
|
14229
|
+
),
|
|
14230
|
+
title: result.threadTitle,
|
|
14231
|
+
children: [
|
|
14232
|
+
"• ",
|
|
14233
|
+
result.threadTitle
|
|
14234
|
+
]
|
|
14235
|
+
}
|
|
14236
|
+
),
|
|
14237
|
+
result.threadId !== currentThreadId && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { className: "w-3 h-3 text-blue-400" })
|
|
14238
|
+
] })
|
|
14239
|
+
] }),
|
|
14240
|
+
/* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-sm", className: "text-icon5 break-words", children: truncateContent(result.content) })
|
|
14241
|
+
] }) }),
|
|
14242
|
+
result.context?.after && result.context.after.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "opacity-50 text-xs space-y-1", children: result.context.after.map((msg, idx) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
|
|
14243
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
|
|
14244
|
+
msg.role,
|
|
14245
|
+
":"
|
|
14246
|
+
] }),
|
|
14247
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-icon3", children: truncateContent(msg.content, 50) })
|
|
14248
|
+
] }, idx)) })
|
|
14249
|
+
] })
|
|
14250
|
+
},
|
|
14251
|
+
result.id
|
|
14252
|
+
)) }) })
|
|
14253
|
+
] });
|
|
14254
|
+
};
|
|
14255
|
+
|
|
13399
14256
|
exports.AgentChat = AgentChat;
|
|
13400
14257
|
exports.AgentCoinIcon = AgentCoinIcon;
|
|
14258
|
+
exports.AgentEntityHeader = AgentEntityHeader;
|
|
13401
14259
|
exports.AgentEvals = AgentEvals;
|
|
13402
14260
|
exports.AgentIcon = AgentIcon;
|
|
14261
|
+
exports.AgentMetadata = AgentMetadata;
|
|
14262
|
+
exports.AgentMetadataList = AgentMetadataList;
|
|
14263
|
+
exports.AgentMetadataListEmpty = AgentMetadataListEmpty;
|
|
14264
|
+
exports.AgentMetadataListItem = AgentMetadataListItem;
|
|
14265
|
+
exports.AgentMetadataPrompt = AgentMetadataPrompt;
|
|
14266
|
+
exports.AgentMetadataScorerList = AgentMetadataScorerList;
|
|
14267
|
+
exports.AgentMetadataSection = AgentMetadataSection;
|
|
14268
|
+
exports.AgentMetadataToolList = AgentMetadataToolList;
|
|
14269
|
+
exports.AgentMetadataWorkflowList = AgentMetadataWorkflowList;
|
|
14270
|
+
exports.AgentMetadataWrapper = AgentMetadataWrapper;
|
|
13403
14271
|
exports.AgentNetworkCoinIcon = AgentNetworkCoinIcon;
|
|
13404
14272
|
exports.AgentSettings = AgentSettings;
|
|
13405
14273
|
exports.AgentSettingsContext = AgentSettingsContext;
|
|
13406
14274
|
exports.AgentSettingsProvider = AgentSettingsProvider;
|
|
13407
|
-
exports.AgentTraces = AgentTraces;
|
|
13408
14275
|
exports.AgentsTable = AgentsTable;
|
|
13409
14276
|
exports.AgentsTableSkeleton = AgentsTableSkeleton;
|
|
13410
14277
|
exports.AiIcon = AiIcon;
|
|
14278
|
+
exports.AlertDialog = AlertDialog;
|
|
13411
14279
|
exports.ApiIcon = ApiIcon;
|
|
13412
14280
|
exports.Badge = Badge$1;
|
|
13413
14281
|
exports.BranchIcon = BranchIcon;
|
|
13414
14282
|
exports.Breadcrumb = Breadcrumb;
|
|
13415
14283
|
exports.Button = Button;
|
|
13416
14284
|
exports.Cell = Cell;
|
|
14285
|
+
exports.ChatThreads = ChatThreads;
|
|
13417
14286
|
exports.CheckIcon = CheckIcon;
|
|
13418
14287
|
exports.ChevronIcon = ChevronIcon;
|
|
13419
14288
|
exports.CommitIcon = CommitIcon;
|
|
@@ -13429,11 +14298,13 @@ exports.DividerIcon = DividerIcon;
|
|
|
13429
14298
|
exports.DocsIcon = DocsIcon;
|
|
13430
14299
|
exports.DynamicForm = DynamicForm;
|
|
13431
14300
|
exports.EmptyAgentsTable = EmptyAgentsTable;
|
|
14301
|
+
exports.EmptyScorerList = EmptyScorerList;
|
|
13432
14302
|
exports.EmptyState = EmptyState;
|
|
13433
14303
|
exports.EmptyWorkflowsTable = EmptyWorkflowsTable;
|
|
13434
14304
|
exports.Entity = Entity;
|
|
13435
14305
|
exports.EntityContent = EntityContent;
|
|
13436
14306
|
exports.EntityDescription = EntityDescription;
|
|
14307
|
+
exports.EntityHeader = EntityHeader;
|
|
13437
14308
|
exports.EntityIcon = EntityIcon;
|
|
13438
14309
|
exports.EntityName = EntityName;
|
|
13439
14310
|
exports.Entry = Entry;
|
|
@@ -13465,6 +14336,7 @@ exports.MastraResizablePanel = MastraResizablePanel;
|
|
|
13465
14336
|
exports.McpCoinIcon = McpCoinIcon;
|
|
13466
14337
|
exports.McpServerIcon = McpServerIcon;
|
|
13467
14338
|
exports.MemoryIcon = MemoryIcon;
|
|
14339
|
+
exports.MemorySearch = MemorySearch;
|
|
13468
14340
|
exports.NetworkChat = NetworkChat;
|
|
13469
14341
|
exports.NetworkContext = NetworkContext;
|
|
13470
14342
|
exports.NetworkProvider = NetworkProvider;
|
|
@@ -13472,6 +14344,8 @@ exports.NetworkTable = NetworkTable;
|
|
|
13472
14344
|
exports.NetworkTableEmpty = NetworkTableEmpty;
|
|
13473
14345
|
exports.NetworkTableSkeleton = NetworkTableSkeleton;
|
|
13474
14346
|
exports.OpenAIIcon = OpenAIIcon;
|
|
14347
|
+
exports.PlaygroundQueryClient = PlaygroundQueryClient;
|
|
14348
|
+
exports.PlaygroundTabs = PlaygroundTabs;
|
|
13475
14349
|
exports.PromptIcon = PromptIcon;
|
|
13476
14350
|
exports.RadioGroup = RadioGroup;
|
|
13477
14351
|
exports.RadioGroupItem = RadioGroupItem;
|
|
@@ -13480,8 +14354,13 @@ exports.Row = Row;
|
|
|
13480
14354
|
exports.RuntimeContext = RuntimeContext;
|
|
13481
14355
|
exports.RuntimeContextWrapper = RuntimeContextWrapper;
|
|
13482
14356
|
exports.ScoreIcon = ScoreIcon;
|
|
14357
|
+
exports.ScorerList = ScorerList;
|
|
14358
|
+
exports.ScorerSkeleton = ScorerSkeleton;
|
|
13483
14359
|
exports.SettingsIcon = SettingsIcon;
|
|
13484
14360
|
exports.SlashIcon = SlashIcon;
|
|
14361
|
+
exports.Tab = Tab;
|
|
14362
|
+
exports.TabContent = TabContent;
|
|
14363
|
+
exports.TabList = TabList;
|
|
13485
14364
|
exports.Table = Table;
|
|
13486
14365
|
exports.Tbody = Tbody;
|
|
13487
14366
|
exports.Th = Th;
|
|
@@ -13497,6 +14376,8 @@ exports.ToolListEmpty = ToolListEmpty;
|
|
|
13497
14376
|
exports.ToolListSkeleton = ToolListSkeleton;
|
|
13498
14377
|
exports.ToolsIcon = ToolsIcon;
|
|
13499
14378
|
exports.TraceIcon = TraceIcon;
|
|
14379
|
+
exports.TracesView = TracesView;
|
|
14380
|
+
exports.TracesViewSkeleton = TracesViewSkeleton;
|
|
13500
14381
|
exports.TsIcon = TsIcon;
|
|
13501
14382
|
exports.Txt = Txt;
|
|
13502
14383
|
exports.TxtCell = TxtCell;
|
|
@@ -13511,17 +14392,33 @@ exports.WorkflowRunProvider = WorkflowRunProvider;
|
|
|
13511
14392
|
exports.WorkflowRuns = WorkflowRuns;
|
|
13512
14393
|
exports.WorkflowTable = WorkflowTable;
|
|
13513
14394
|
exports.WorkflowTableSkeleton = WorkflowTableSkeleton;
|
|
13514
|
-
exports.WorkflowTraces = WorkflowTraces;
|
|
13515
14395
|
exports.WorkflowTrigger = WorkflowTrigger;
|
|
13516
14396
|
exports.WorkingMemoryContext = WorkingMemoryContext;
|
|
13517
14397
|
exports.WorkingMemoryProvider = WorkingMemoryProvider;
|
|
14398
|
+
exports.allowedAiSpanAttributes = allowedAiSpanAttributes;
|
|
14399
|
+
exports.cleanString = cleanString;
|
|
14400
|
+
exports.formatDuration = formatDuration;
|
|
14401
|
+
exports.formatOtelTimestamp = formatOtelTimestamp;
|
|
14402
|
+
exports.formatOtelTimestamp2 = formatOtelTimestamp2;
|
|
13518
14403
|
exports.providerMapToIcon = providerMapToIcon;
|
|
14404
|
+
exports.transformKey = transformKey;
|
|
13519
14405
|
exports.useAgentSettings = useAgentSettings;
|
|
13520
14406
|
exports.useCurrentRun = useCurrentRun;
|
|
14407
|
+
exports.useInView = useInView;
|
|
13521
14408
|
exports.useLinkComponent = useLinkComponent;
|
|
13522
14409
|
exports.useMastraClient = useMastraClient;
|
|
13523
14410
|
exports.usePlaygroundStore = usePlaygroundStore;
|
|
13524
14411
|
exports.usePolling = usePolling;
|
|
14412
|
+
exports.useScorer = useScorer;
|
|
14413
|
+
exports.useScorers = useScorers;
|
|
14414
|
+
exports.useScoresByEntityId = useScoresByEntityId;
|
|
14415
|
+
exports.useScoresByScorerId = useScoresByScorerId;
|
|
13525
14416
|
exports.useSpeechRecognition = useSpeechRecognition;
|
|
13526
14417
|
exports.useWorkingMemory = useWorkingMemory;
|
|
14418
|
+
Object.keys(reactQuery).forEach(k => {
|
|
14419
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
14420
|
+
enumerable: true,
|
|
14421
|
+
get: () => reactQuery[k]
|
|
14422
|
+
});
|
|
14423
|
+
});
|
|
13527
14424
|
//# sourceMappingURL=index.cjs.js.map
|