@mastra/playground-ui 4.0.4-alpha.4 → 4.0.4-alpha.6
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/domains/agents/agent/agent-traces.d.ts +3 -2
- package/dist/domains/traces/hooks/use-open-trace.d.ts +5 -0
- package/dist/domains/traces/traces-sidebar.d.ts +9 -0
- package/dist/domains/traces/traces-table.d.ts +10 -0
- package/dist/domains/workflows/workflow/workflow-traces.d.ts +3 -2
- package/dist/ds/icons/SpanIcon.d.ts +3 -0
- package/dist/index.cjs.js +533 -701
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +534 -702
- package/dist/index.es.js.map +1 -1
- package/package.json +3 -3
- package/dist/domains/traces/index.d.ts +0 -5
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { MessagePrimitive, ActionBarPrimitive, BranchPickerPrimitive, ThreadPrimitive, ComposerPrimitive, useExternalStoreRuntime, AssistantRuntimeProvider } from '@assistant-ui/react';
|
|
3
|
-
import { CheckIcon as CheckIcon$1, CopyIcon, ChevronUpIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc,
|
|
3
|
+
import { CheckIcon as CheckIcon$1, CopyIcon, ChevronUpIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ArrowUp, Copy, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, ChevronDown, XIcon, Check, LoaderCircle, ExternalLinkIcon, X, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, PlusIcon, TrashIcon, Plus, Loader2 } from 'lucide-react';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import React__default, { forwardRef, memo, useState, useRef, useEffect, createContext, useContext,
|
|
5
|
+
import React__default, { forwardRef, memo, useState, useRef, useEffect, createContext, useContext, useCallback, useMemo, Suspense, Fragment as Fragment$1 } from 'react';
|
|
6
6
|
import { Slot } from '@radix-ui/react-slot';
|
|
7
7
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
8
8
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
@@ -16,7 +16,6 @@ import { format, formatDistanceToNow, isValid } from 'date-fns';
|
|
|
16
16
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
17
17
|
import { toast } from 'sonner';
|
|
18
18
|
import { AnimatePresence } from 'motion/react';
|
|
19
|
-
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
20
19
|
import { jsonLanguage } from '@codemirror/lang-json';
|
|
21
20
|
import { tags } from '@lezer/highlight';
|
|
22
21
|
import { githubDarkInit } from '@uiw/codemirror-theme-github';
|
|
@@ -30,6 +29,7 @@ import Dagre from '@dagrejs/dagre';
|
|
|
30
29
|
import { Highlight, themes } from 'prism-react-renderer';
|
|
31
30
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
32
31
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
32
|
+
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
33
33
|
import jsonSchemaToZod from 'json-schema-to-zod';
|
|
34
34
|
import { parse } from 'superjson';
|
|
35
35
|
import z$1, { z } from 'zod';
|
|
@@ -4275,126 +4275,6 @@ function EvalTable({ evals, isCIMode = false }) {
|
|
|
4275
4275
|
}
|
|
4276
4276
|
}
|
|
4277
4277
|
|
|
4278
|
-
const useResizeColumn = ({
|
|
4279
|
-
defaultWidth,
|
|
4280
|
-
minimumWidth,
|
|
4281
|
-
maximumWidth,
|
|
4282
|
-
setCurrentWidth
|
|
4283
|
-
}) => {
|
|
4284
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
4285
|
-
const [sidebarWidth, setSidebarWidth] = useState(defaultWidth);
|
|
4286
|
-
const containerRef = useRef(null);
|
|
4287
|
-
const dragStartXRef = useRef(0);
|
|
4288
|
-
const initialWidthRef = useRef(0);
|
|
4289
|
-
const handleMouseDown = (e) => {
|
|
4290
|
-
e.preventDefault();
|
|
4291
|
-
setIsDragging(true);
|
|
4292
|
-
dragStartXRef.current = e.clientX;
|
|
4293
|
-
initialWidthRef.current = sidebarWidth;
|
|
4294
|
-
};
|
|
4295
|
-
useEffect(() => {
|
|
4296
|
-
setSidebarWidth(defaultWidth);
|
|
4297
|
-
setCurrentWidth?.(defaultWidth);
|
|
4298
|
-
}, [defaultWidth]);
|
|
4299
|
-
useEffect(() => {
|
|
4300
|
-
const handleMouseMove = (e) => {
|
|
4301
|
-
if (!isDragging || !containerRef.current) return;
|
|
4302
|
-
const containerWidth = containerRef.current.offsetWidth;
|
|
4303
|
-
const deltaX = dragStartXRef.current - e.clientX;
|
|
4304
|
-
const deltaPercentage = deltaX / containerWidth * 100;
|
|
4305
|
-
const newWidth = Math.min(Math.max(initialWidthRef.current + deltaPercentage, minimumWidth), maximumWidth);
|
|
4306
|
-
setSidebarWidth(newWidth);
|
|
4307
|
-
setCurrentWidth?.(newWidth);
|
|
4308
|
-
};
|
|
4309
|
-
const handleMouseUp = () => {
|
|
4310
|
-
setIsDragging(false);
|
|
4311
|
-
};
|
|
4312
|
-
if (isDragging) {
|
|
4313
|
-
window.addEventListener("mousemove", handleMouseMove);
|
|
4314
|
-
window.addEventListener("mouseup", handleMouseUp);
|
|
4315
|
-
}
|
|
4316
|
-
return () => {
|
|
4317
|
-
window.removeEventListener("mousemove", handleMouseMove);
|
|
4318
|
-
window.removeEventListener("mouseup", handleMouseUp);
|
|
4319
|
-
};
|
|
4320
|
-
}, [isDragging]);
|
|
4321
|
-
return { sidebarWidth, isDragging, handleMouseDown, containerRef };
|
|
4322
|
-
};
|
|
4323
|
-
|
|
4324
|
-
const MastraResizablePanel = ({
|
|
4325
|
-
children,
|
|
4326
|
-
defaultWidth,
|
|
4327
|
-
minimumWidth,
|
|
4328
|
-
maximumWidth,
|
|
4329
|
-
className,
|
|
4330
|
-
disabled = false,
|
|
4331
|
-
setCurrentWidth,
|
|
4332
|
-
dividerPosition = "left"
|
|
4333
|
-
}) => {
|
|
4334
|
-
const { sidebarWidth, isDragging, handleMouseDown, containerRef } = useResizeColumn({
|
|
4335
|
-
defaultWidth: disabled ? 100 : defaultWidth,
|
|
4336
|
-
minimumWidth,
|
|
4337
|
-
maximumWidth,
|
|
4338
|
-
setCurrentWidth
|
|
4339
|
-
});
|
|
4340
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("w-full h-full relative", className), ref: containerRef, style: { width: `${sidebarWidth}%` }, children: [
|
|
4341
|
-
!disabled && dividerPosition === "left" ? /* @__PURE__ */ jsx(
|
|
4342
|
-
"div",
|
|
4343
|
-
{
|
|
4344
|
-
className: `w-1 bg-mastra-bg-1 bg-[#121212] 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 -left-1 -right-1 z-10
|
|
4345
|
-
${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
|
|
4346
|
-
onMouseDown: handleMouseDown
|
|
4347
|
-
}
|
|
4348
|
-
) : null,
|
|
4349
|
-
children,
|
|
4350
|
-
!disabled && dividerPosition === "right" ? /* @__PURE__ */ jsx(
|
|
4351
|
-
"div",
|
|
4352
|
-
{
|
|
4353
|
-
className: `w-1 bg-mastra-bg-1 bg-[#121212] 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 -left-1 -right-1 z-10
|
|
4354
|
-
${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
|
|
4355
|
-
onMouseDown: handleMouseDown
|
|
4356
|
-
}
|
|
4357
|
-
) : null
|
|
4358
|
-
] });
|
|
4359
|
-
};
|
|
4360
|
-
|
|
4361
|
-
const ScrollArea = React.forwardRef(
|
|
4362
|
-
({ className, children, viewPortClassName, maxHeight, autoScroll = false, ...props }, ref) => {
|
|
4363
|
-
const areaRef = React.useRef(null);
|
|
4364
|
-
useAutoscroll(areaRef, { enabled: autoScroll });
|
|
4365
|
-
return /* @__PURE__ */ jsxs(ScrollAreaPrimitive.Root, { ref, className: cn("relative overflow-hidden", className), ...props, children: [
|
|
4366
|
-
/* @__PURE__ */ jsx(
|
|
4367
|
-
ScrollAreaPrimitive.Viewport,
|
|
4368
|
-
{
|
|
4369
|
-
ref: areaRef,
|
|
4370
|
-
className: cn("h-full w-full rounded-[inherit] [&>div]:!block", viewPortClassName),
|
|
4371
|
-
style: maxHeight ? { maxHeight } : void 0,
|
|
4372
|
-
children
|
|
4373
|
-
}
|
|
4374
|
-
),
|
|
4375
|
-
/* @__PURE__ */ jsx(ScrollBar, {}),
|
|
4376
|
-
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
|
|
4377
|
-
] });
|
|
4378
|
-
}
|
|
4379
|
-
);
|
|
4380
|
-
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
|
4381
|
-
const ScrollBar = React.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(
|
|
4382
|
-
ScrollAreaPrimitive.ScrollAreaScrollbar,
|
|
4383
|
-
{
|
|
4384
|
-
ref,
|
|
4385
|
-
orientation,
|
|
4386
|
-
className: cn(
|
|
4387
|
-
"flex touch-none select-none transition-colors",
|
|
4388
|
-
orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
|
|
4389
|
-
orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
|
4390
|
-
className
|
|
4391
|
-
),
|
|
4392
|
-
...props,
|
|
4393
|
-
children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
|
|
4394
|
-
}
|
|
4395
|
-
));
|
|
4396
|
-
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
4397
|
-
|
|
4398
4278
|
const TraceContext = createContext({});
|
|
4399
4279
|
function TraceProvider({ children }) {
|
|
4400
4280
|
const [open, setOpen] = useState(false);
|
|
@@ -4454,6 +4334,113 @@ function TraceProvider({ children }) {
|
|
|
4454
4334
|
);
|
|
4455
4335
|
}
|
|
4456
4336
|
|
|
4337
|
+
function usePolling({
|
|
4338
|
+
fetchFn,
|
|
4339
|
+
interval = 3e3,
|
|
4340
|
+
enabled = false,
|
|
4341
|
+
onSuccess,
|
|
4342
|
+
onError,
|
|
4343
|
+
shouldContinue = () => true,
|
|
4344
|
+
restartPolling = false
|
|
4345
|
+
}) {
|
|
4346
|
+
const [isPolling, setIsPolling] = useState(enabled);
|
|
4347
|
+
const [error, setError] = useState(null);
|
|
4348
|
+
const [data, setData] = useState(null);
|
|
4349
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
4350
|
+
const [firstCallLoading, setFirstCallLoading] = useState(false);
|
|
4351
|
+
const timeoutRef = useRef(null);
|
|
4352
|
+
const mountedRef = useRef(true);
|
|
4353
|
+
const [restart, setRestart] = useState(restartPolling);
|
|
4354
|
+
const cleanup = useCallback(() => {
|
|
4355
|
+
console.log("cleanup");
|
|
4356
|
+
if (timeoutRef.current) {
|
|
4357
|
+
clearTimeout(timeoutRef.current);
|
|
4358
|
+
timeoutRef.current = null;
|
|
4359
|
+
}
|
|
4360
|
+
}, []);
|
|
4361
|
+
const stopPolling = useCallback(() => {
|
|
4362
|
+
console.log("stopPolling");
|
|
4363
|
+
setIsPolling(false);
|
|
4364
|
+
cleanup();
|
|
4365
|
+
}, [cleanup]);
|
|
4366
|
+
const startPolling = useCallback(() => {
|
|
4367
|
+
console.log("startPolling");
|
|
4368
|
+
setIsPolling(true);
|
|
4369
|
+
setError(null);
|
|
4370
|
+
}, []);
|
|
4371
|
+
const executePoll = useCallback(
|
|
4372
|
+
async (refetch2 = true) => {
|
|
4373
|
+
if (!mountedRef.current) return;
|
|
4374
|
+
setIsLoading(true);
|
|
4375
|
+
try {
|
|
4376
|
+
const result = await fetchFn();
|
|
4377
|
+
setData(result);
|
|
4378
|
+
setError(null);
|
|
4379
|
+
onSuccess?.(result);
|
|
4380
|
+
if (shouldContinue(result) && refetch2) {
|
|
4381
|
+
timeoutRef.current = setTimeout(executePoll, interval);
|
|
4382
|
+
} else {
|
|
4383
|
+
stopPolling();
|
|
4384
|
+
}
|
|
4385
|
+
} catch (err) {
|
|
4386
|
+
if (!mountedRef.current) return;
|
|
4387
|
+
setError(err);
|
|
4388
|
+
onError?.(err);
|
|
4389
|
+
stopPolling();
|
|
4390
|
+
} finally {
|
|
4391
|
+
if (mountedRef.current) {
|
|
4392
|
+
setFirstCallLoading(false);
|
|
4393
|
+
setIsLoading(false);
|
|
4394
|
+
}
|
|
4395
|
+
}
|
|
4396
|
+
},
|
|
4397
|
+
[fetchFn, interval, onSuccess, onError, shouldContinue, stopPolling]
|
|
4398
|
+
);
|
|
4399
|
+
const refetch = useCallback(
|
|
4400
|
+
(withPolling = false) => {
|
|
4401
|
+
console.log("refetch", { withPolling });
|
|
4402
|
+
if (withPolling) {
|
|
4403
|
+
setIsPolling(true);
|
|
4404
|
+
} else {
|
|
4405
|
+
executePoll(false);
|
|
4406
|
+
}
|
|
4407
|
+
setError(null);
|
|
4408
|
+
},
|
|
4409
|
+
[executePoll]
|
|
4410
|
+
);
|
|
4411
|
+
useEffect(() => {
|
|
4412
|
+
mountedRef.current = true;
|
|
4413
|
+
if (enabled && isPolling) {
|
|
4414
|
+
executePoll(true);
|
|
4415
|
+
}
|
|
4416
|
+
return () => {
|
|
4417
|
+
console.log("cleanup poll");
|
|
4418
|
+
mountedRef.current = false;
|
|
4419
|
+
cleanup();
|
|
4420
|
+
};
|
|
4421
|
+
}, [enabled, isPolling, executePoll, cleanup]);
|
|
4422
|
+
useEffect(() => {
|
|
4423
|
+
setRestart(restartPolling);
|
|
4424
|
+
}, [restartPolling]);
|
|
4425
|
+
useEffect(() => {
|
|
4426
|
+
if (restart && !isPolling) {
|
|
4427
|
+
setIsPolling(true);
|
|
4428
|
+
executePoll();
|
|
4429
|
+
setRestart(false);
|
|
4430
|
+
}
|
|
4431
|
+
}, [restart]);
|
|
4432
|
+
return {
|
|
4433
|
+
isPolling,
|
|
4434
|
+
isLoading,
|
|
4435
|
+
error,
|
|
4436
|
+
data,
|
|
4437
|
+
startPolling,
|
|
4438
|
+
stopPolling,
|
|
4439
|
+
firstCallLoading,
|
|
4440
|
+
refetch
|
|
4441
|
+
};
|
|
4442
|
+
}
|
|
4443
|
+
|
|
4457
4444
|
function formatDuration(duration, fixedPoint = 2) {
|
|
4458
4445
|
const durationInSecs = duration / 1e3;
|
|
4459
4446
|
return durationInSecs.toFixed(fixedPoint);
|
|
@@ -4549,68 +4536,187 @@ const allowedAiSpanAttributes = [
|
|
|
4549
4536
|
"ai.usage.completionTokens"
|
|
4550
4537
|
];
|
|
4551
4538
|
|
|
4552
|
-
|
|
4553
|
-
const
|
|
4554
|
-
const
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4539
|
+
const useTraces = (componentName, baseUrl, isWorkflow = false) => {
|
|
4540
|
+
const [traces, setTraces] = useState([]);
|
|
4541
|
+
const { setTraces: setTraceContextTraces } = useContext(TraceContext);
|
|
4542
|
+
const client = useMemo(
|
|
4543
|
+
() => new MastraClient({
|
|
4544
|
+
baseUrl: baseUrl || ""
|
|
4545
|
+
}),
|
|
4546
|
+
[baseUrl]
|
|
4547
|
+
);
|
|
4548
|
+
const fetchFn = useCallback(async () => {
|
|
4549
|
+
try {
|
|
4550
|
+
const res = await client.getTelemetry({
|
|
4551
|
+
attribute: {
|
|
4552
|
+
componentName
|
|
4553
|
+
}
|
|
4554
|
+
});
|
|
4555
|
+
if (!res.traces) {
|
|
4556
|
+
throw new Error("Error fetching traces");
|
|
4557
|
+
}
|
|
4558
|
+
const refinedTraces = refineTraces(res?.traces || [], isWorkflow);
|
|
4559
|
+
return refinedTraces;
|
|
4560
|
+
} catch (error2) {
|
|
4561
|
+
throw error2;
|
|
4558
4562
|
}
|
|
4559
|
-
}, [
|
|
4560
|
-
const
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
}
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4563
|
+
}, [client, componentName, isWorkflow]);
|
|
4564
|
+
const onSuccess = useCallback(
|
|
4565
|
+
(newTraces) => {
|
|
4566
|
+
if (newTraces.length > 0) {
|
|
4567
|
+
setTraces(() => newTraces);
|
|
4568
|
+
setTraceContextTraces(() => newTraces);
|
|
4569
|
+
}
|
|
4570
|
+
},
|
|
4571
|
+
[setTraceContextTraces]
|
|
4572
|
+
);
|
|
4573
|
+
const onError = useCallback((error2) => {
|
|
4574
|
+
toast.error(error2.message);
|
|
4575
|
+
}, []);
|
|
4576
|
+
const shouldContinue = useCallback(() => {
|
|
4577
|
+
return true;
|
|
4578
|
+
}, []);
|
|
4579
|
+
const { firstCallLoading, error } = usePolling({
|
|
4580
|
+
fetchFn,
|
|
4581
|
+
interval: 3e3,
|
|
4582
|
+
onSuccess,
|
|
4583
|
+
onError,
|
|
4584
|
+
shouldContinue,
|
|
4585
|
+
enabled: true
|
|
4586
|
+
});
|
|
4587
|
+
return { traces, firstCallLoading, error };
|
|
4588
|
+
};
|
|
4589
|
+
|
|
4590
|
+
const rowSize = {
|
|
4591
|
+
default: "[&>tbody>tr]:h-table-row",
|
|
4592
|
+
small: "[&>tbody>tr]:h-table-row-small"
|
|
4593
|
+
};
|
|
4594
|
+
const Table = ({ className, children, size = "default" }) => {
|
|
4595
|
+
return /* @__PURE__ */ jsx("table", { className: clsx("w-full", rowSize[size], className), children });
|
|
4596
|
+
};
|
|
4597
|
+
const Thead = ({ className, children }) => {
|
|
4598
|
+
return /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: clsx("h-table-header border-b-sm border-border1", className), children }) });
|
|
4599
|
+
};
|
|
4600
|
+
const Th = ({ className, children, ...props }) => {
|
|
4601
|
+
return /* @__PURE__ */ jsx(
|
|
4602
|
+
"th",
|
|
4603
|
+
{
|
|
4604
|
+
className: clsx("text-icon3 text-ui-sm h-full text-left font-normal uppercase first:pl-5 last:pr-5", className),
|
|
4605
|
+
...props,
|
|
4606
|
+
children
|
|
4607
|
+
}
|
|
4608
|
+
);
|
|
4609
|
+
};
|
|
4610
|
+
const Tbody = ({ className, children }) => {
|
|
4611
|
+
return /* @__PURE__ */ jsx("tbody", { className: clsx("", className), children });
|
|
4612
|
+
};
|
|
4613
|
+
const Row = ({ className, children, selected = false }) => {
|
|
4614
|
+
return /* @__PURE__ */ jsx("tr", { className: clsx("border-b-sm border-border1 hover:bg-surface3", selected && "bg-surface4", className), children });
|
|
4615
|
+
};
|
|
4616
|
+
|
|
4617
|
+
const sizes = {
|
|
4618
|
+
default: "[&>svg]:h-icon-default [&>svg]:w-icon-default",
|
|
4619
|
+
lg: "[&>svg]:h-icon-lg [&>svg]:w-icon-lg"
|
|
4620
|
+
};
|
|
4621
|
+
const Icon = ({ children, className, size = "default", ...props }) => {
|
|
4622
|
+
return /* @__PURE__ */ jsx("div", { className: clsx(sizes[size], className), ...props, children });
|
|
4623
|
+
};
|
|
4624
|
+
|
|
4625
|
+
const variants = {
|
|
4626
|
+
"header-md": "text-header-md leading-header-md",
|
|
4627
|
+
"ui-lg": "text-ui-lg leading-ui-lg",
|
|
4628
|
+
"ui-md": "text-ui-md leading-ui-md",
|
|
4629
|
+
"ui-sm": "text-ui-sm leading-ui-sm",
|
|
4630
|
+
"ui-xs": "text-ui-xs leading-ui-xs"
|
|
4631
|
+
};
|
|
4632
|
+
const fonts = {
|
|
4633
|
+
mono: "font-mono"
|
|
4634
|
+
};
|
|
4635
|
+
const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) => {
|
|
4636
|
+
return /* @__PURE__ */ jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
|
|
4637
|
+
};
|
|
4638
|
+
|
|
4639
|
+
const formatDateCell = (date) => {
|
|
4640
|
+
const month = new Intl.DateTimeFormat("en-US", { month: "short" }).format(date).toUpperCase();
|
|
4641
|
+
const day = date.getDate();
|
|
4642
|
+
const formattedDay = `${month} ${day}`;
|
|
4643
|
+
const time = new Intl.DateTimeFormat("en-US", {
|
|
4644
|
+
hour: "2-digit",
|
|
4645
|
+
minute: "2-digit",
|
|
4646
|
+
second: "2-digit",
|
|
4647
|
+
hour12: false
|
|
4648
|
+
// Use 24-hour format
|
|
4649
|
+
}).format(date);
|
|
4650
|
+
return { day: formattedDay, time };
|
|
4651
|
+
};
|
|
4652
|
+
|
|
4653
|
+
const Cell = ({ className, children, ...props }) => {
|
|
4654
|
+
return /* @__PURE__ */ jsx("td", { className: clsx("text-icon5 first:pl-5 last:pr-5", className), ...props, children: /* @__PURE__ */ jsx("div", { className: clsx("flex h-full w-full shrink-0 items-center"), children }) });
|
|
4655
|
+
};
|
|
4656
|
+
const TxtCell = ({ className, children }) => {
|
|
4657
|
+
return /* @__PURE__ */ jsx(Cell, { className, children: /* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-md", className: "w-full truncate", children }) });
|
|
4658
|
+
};
|
|
4659
|
+
const UnitCell = ({ className, children, unit }) => {
|
|
4660
|
+
return /* @__PURE__ */ jsx(Cell, { className, children: /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center", children: [
|
|
4661
|
+
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-md", className: "shrink-0", children }),
|
|
4662
|
+
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3 w-full truncate", children: unit })
|
|
4663
|
+
] }) });
|
|
4664
|
+
};
|
|
4665
|
+
const DateTimeCell = ({ dateTime, ...props }) => {
|
|
4666
|
+
const { day, time } = formatDateCell(dateTime);
|
|
4667
|
+
return /* @__PURE__ */ jsx(Cell, { ...props, children: /* @__PURE__ */ jsxs("div", { className: "shrink-0", children: [
|
|
4668
|
+
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3", children: day }),
|
|
4669
|
+
" ",
|
|
4670
|
+
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-md", children: time })
|
|
4671
|
+
] }) });
|
|
4672
|
+
};
|
|
4673
|
+
const EntryCell = ({ name, description, icon, meta, ...props }) => {
|
|
4674
|
+
return /* @__PURE__ */ jsx(Cell, { ...props, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-[14px]", children: [
|
|
4675
|
+
/* @__PURE__ */ jsx(Icon, { size: "lg", className: "text-icon5", children: icon }),
|
|
4676
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0", children: [
|
|
4677
|
+
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-md", className: "text-icon6 font-medium !leading-tight", children: name }),
|
|
4678
|
+
description && /* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-xs", className: "text-icon3 w-full max-w-[300px] truncate !leading-tight", children: description })
|
|
4679
|
+
] }),
|
|
4680
|
+
meta
|
|
4681
|
+
] }) });
|
|
4682
|
+
};
|
|
4683
|
+
|
|
4684
|
+
const variantClasses = {
|
|
4685
|
+
default: "text-icon3",
|
|
4686
|
+
success: "text-accent1",
|
|
4687
|
+
error: "text-accent2",
|
|
4688
|
+
info: "text-accent3"
|
|
4689
|
+
};
|
|
4690
|
+
const Badge = ({ icon, variant = "default", className, children, ...props }) => {
|
|
4691
|
+
return /* @__PURE__ */ jsxs(
|
|
4692
|
+
"div",
|
|
4693
|
+
{
|
|
4694
|
+
className: clsx(
|
|
4695
|
+
"bg-surface4 text-ui-sm gap-md h-badge-default inline-flex items-center rounded-md",
|
|
4696
|
+
icon ? "pl-md pr-1.5" : "px-1.5",
|
|
4697
|
+
icon || variant === "default" ? "text-icon5" : variantClasses[variant],
|
|
4698
|
+
className
|
|
4699
|
+
),
|
|
4700
|
+
...props,
|
|
4701
|
+
children: [
|
|
4702
|
+
icon && /* @__PURE__ */ jsx("span", { className: variantClasses[variant], children: /* @__PURE__ */ jsx(Icon, { children: icon }) }),
|
|
4703
|
+
children
|
|
4704
|
+
]
|
|
4705
|
+
}
|
|
4706
|
+
);
|
|
4707
|
+
};
|
|
4708
|
+
|
|
4709
|
+
const SpanIcon = (props) => /* @__PURE__ */ jsx("svg", { width: "15", height: "8", viewBox: "0 0 15 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx(
|
|
4710
|
+
"path",
|
|
4711
|
+
{
|
|
4712
|
+
fillRule: "evenodd",
|
|
4713
|
+
clipRule: "evenodd",
|
|
4714
|
+
d: "M5.17473 0.385409C5.45323 0.663917 5.45323 1.11547 5.17473 1.39397L3.62152 2.94718C3.49553 3.07317 3.58476 3.2886 3.76294 3.2886L11.2361 3.2886C11.4142 3.2886 11.5035 3.07317 11.3775 2.94718L9.82428 1.39397C9.54577 1.11547 9.54577 0.663917 9.82428 0.385409C10.1028 0.106902 10.5543 0.106902 10.8328 0.385409L14.0956 3.64821C14.2909 3.84347 14.2909 4.16006 14.0956 4.35532L10.8363 7.61462C10.5578 7.89313 10.1063 7.89313 9.82778 7.61462C9.54927 7.33611 9.54927 6.88456 9.82778 6.60605L11.3775 5.05635C11.5035 4.93036 11.4142 4.71493 11.2361 4.71493L3.76294 4.71493C3.58476 4.71493 3.49553 4.93036 3.62152 5.05635L5.17123 6.60605C5.44973 6.88456 5.44973 7.33611 5.17123 7.61462C4.89272 7.89313 4.44117 7.89313 4.16266 7.61462L0.903358 4.35532C0.708096 4.16006 0.708096 3.84347 0.903358 3.64821L4.16616 0.385409C4.44467 0.106902 4.89622 0.106902 5.17473 0.385409Z",
|
|
4715
|
+
fill: "currentColor"
|
|
4716
|
+
}
|
|
4717
|
+
) });
|
|
4718
|
+
|
|
4719
|
+
const useOpenTrace = () => {
|
|
4614
4720
|
const {
|
|
4615
4721
|
setTrace,
|
|
4616
4722
|
isOpen: open,
|
|
@@ -4620,53 +4726,136 @@ function TraceButton({
|
|
|
4620
4726
|
setOpenDetail,
|
|
4621
4727
|
setCurrentTraceIndex
|
|
4622
4728
|
} = useContext(TraceContext);
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4729
|
+
const openTrace = (trace, traceIndex) => {
|
|
4730
|
+
setTrace(trace);
|
|
4731
|
+
const parentSpan = trace.find((span) => span.parentSpanId === null) || trace[0];
|
|
4732
|
+
setSpan(parentSpan);
|
|
4733
|
+
setCurrentTraceIndex(traceIndex);
|
|
4734
|
+
if (open && currentTrace?.[0]?.id !== trace[0].id) return;
|
|
4735
|
+
setOpen((prev) => !prev);
|
|
4736
|
+
setOpenDetail((prev) => !prev);
|
|
4737
|
+
};
|
|
4738
|
+
return { openTrace };
|
|
4739
|
+
};
|
|
4740
|
+
|
|
4741
|
+
const TracesTableSkeleton = ({ colsCount }) => {
|
|
4742
|
+
return /* @__PURE__ */ jsx(Tbody, { children: /* @__PURE__ */ jsx(Row, { children: Array.from({ length: colsCount }).map((_, index) => /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "w-1/2" }) }, index)) }) });
|
|
4743
|
+
};
|
|
4744
|
+
const TracesTableEmpty = ({ colsCount }) => {
|
|
4745
|
+
return /* @__PURE__ */ jsx(Tbody, { children: /* @__PURE__ */ jsx(Row, { children: /* @__PURE__ */ jsx(Cell, { colSpan: colsCount, className: "text-center py-4", children: /* @__PURE__ */ jsx(Txt, { children: "No traces found" }) }) }) });
|
|
4746
|
+
};
|
|
4747
|
+
const TracesTableError = ({ error, colsCount }) => {
|
|
4748
|
+
return /* @__PURE__ */ jsx(Tbody, { children: /* @__PURE__ */ jsx(Row, { children: /* @__PURE__ */ jsx(Cell, { colSpan: colsCount, className: "text-center py-4", children: /* @__PURE__ */ jsx(Txt, { children: error.message }) }) }) });
|
|
4749
|
+
};
|
|
4750
|
+
const TraceRow = ({ trace, index }) => {
|
|
4751
|
+
const { openTrace } = useOpenTrace();
|
|
4752
|
+
return /* @__PURE__ */ jsxs(Row, { children: [
|
|
4753
|
+
/* @__PURE__ */ jsx(DateTimeCell, { dateTime: new Date(trace.started / 1e3) }),
|
|
4754
|
+
/* @__PURE__ */ jsx(TxtCell, { children: trace.traceId }),
|
|
4755
|
+
/* @__PURE__ */ jsx(UnitCell, { unit: "ms", children: trace.duration }),
|
|
4756
|
+
/* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx("button", { onClick: () => openTrace(trace.trace, index), children: /* @__PURE__ */ jsxs(Badge, { icon: /* @__PURE__ */ jsx(SpanIcon, {}), children: [
|
|
4757
|
+
trace.trace.length,
|
|
4758
|
+
" span",
|
|
4759
|
+
trace.trace.length > 1 ? "s" : ""
|
|
4760
|
+
] }) }) })
|
|
4761
|
+
] });
|
|
4762
|
+
};
|
|
4763
|
+
const TracesTable = ({ traces, isLoading, error }) => {
|
|
4764
|
+
const hasNoTraces = !traces || traces.length === 0;
|
|
4765
|
+
const colsCount = 4;
|
|
4766
|
+
return /* @__PURE__ */ jsxs(Table, { size: "small", children: [
|
|
4767
|
+
/* @__PURE__ */ jsxs(Thead, { children: [
|
|
4768
|
+
/* @__PURE__ */ jsx(Th, { width: 160, children: "Time" }),
|
|
4769
|
+
/* @__PURE__ */ jsx(Th, { width: "auto", children: "Trace Id" }),
|
|
4770
|
+
/* @__PURE__ */ jsx(Th, { width: 160, children: "Duration" }),
|
|
4771
|
+
/* @__PURE__ */ jsx(Th, { width: 160, children: "Spans" })
|
|
4772
|
+
] }),
|
|
4773
|
+
isLoading ? /* @__PURE__ */ jsx(TracesTableSkeleton, { colsCount }) : error ? /* @__PURE__ */ jsx(TracesTableError, { error, colsCount }) : hasNoTraces ? /* @__PURE__ */ jsx(TracesTableEmpty, { colsCount }) : /* @__PURE__ */ jsx(Tbody, { children: traces.map((trace, index) => /* @__PURE__ */ jsx(TraceRow, { trace, index }, trace.traceId)) })
|
|
4774
|
+
] });
|
|
4775
|
+
};
|
|
4776
|
+
|
|
4777
|
+
const useResizeColumn = ({
|
|
4778
|
+
defaultWidth,
|
|
4779
|
+
minimumWidth,
|
|
4780
|
+
maximumWidth,
|
|
4781
|
+
setCurrentWidth
|
|
4782
|
+
}) => {
|
|
4783
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
4784
|
+
const [sidebarWidth, setSidebarWidth] = useState(defaultWidth);
|
|
4785
|
+
const containerRef = useRef(null);
|
|
4786
|
+
const dragStartXRef = useRef(0);
|
|
4787
|
+
const initialWidthRef = useRef(0);
|
|
4788
|
+
const handleMouseDown = (e) => {
|
|
4789
|
+
e.preventDefault();
|
|
4790
|
+
setIsDragging(true);
|
|
4791
|
+
dragStartXRef.current = e.clientX;
|
|
4792
|
+
initialWidthRef.current = sidebarWidth;
|
|
4793
|
+
};
|
|
4794
|
+
useEffect(() => {
|
|
4795
|
+
setSidebarWidth(defaultWidth);
|
|
4796
|
+
setCurrentWidth?.(defaultWidth);
|
|
4797
|
+
}, [defaultWidth]);
|
|
4798
|
+
useEffect(() => {
|
|
4799
|
+
const handleMouseMove = (e) => {
|
|
4800
|
+
if (!isDragging || !containerRef.current) return;
|
|
4801
|
+
const containerWidth = containerRef.current.offsetWidth;
|
|
4802
|
+
const deltaX = dragStartXRef.current - e.clientX;
|
|
4803
|
+
const deltaPercentage = deltaX / containerWidth * 100;
|
|
4804
|
+
const newWidth = Math.min(Math.max(initialWidthRef.current + deltaPercentage, minimumWidth), maximumWidth);
|
|
4805
|
+
setSidebarWidth(newWidth);
|
|
4806
|
+
setCurrentWidth?.(newWidth);
|
|
4807
|
+
};
|
|
4808
|
+
const handleMouseUp = () => {
|
|
4809
|
+
setIsDragging(false);
|
|
4810
|
+
};
|
|
4811
|
+
if (isDragging) {
|
|
4812
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
4813
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
4667
4814
|
}
|
|
4668
|
-
|
|
4669
|
-
|
|
4815
|
+
return () => {
|
|
4816
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
4817
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
4818
|
+
};
|
|
4819
|
+
}, [isDragging]);
|
|
4820
|
+
return { sidebarWidth, isDragging, handleMouseDown, containerRef };
|
|
4821
|
+
};
|
|
4822
|
+
|
|
4823
|
+
const MastraResizablePanel = ({
|
|
4824
|
+
children,
|
|
4825
|
+
defaultWidth,
|
|
4826
|
+
minimumWidth,
|
|
4827
|
+
maximumWidth,
|
|
4828
|
+
className,
|
|
4829
|
+
disabled = false,
|
|
4830
|
+
setCurrentWidth,
|
|
4831
|
+
dividerPosition = "left"
|
|
4832
|
+
}) => {
|
|
4833
|
+
const { sidebarWidth, isDragging, handleMouseDown, containerRef } = useResizeColumn({
|
|
4834
|
+
defaultWidth: disabled ? 100 : defaultWidth,
|
|
4835
|
+
minimumWidth,
|
|
4836
|
+
maximumWidth,
|
|
4837
|
+
setCurrentWidth
|
|
4838
|
+
});
|
|
4839
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("w-full h-full relative", className), ref: containerRef, style: { width: `${sidebarWidth}%` }, children: [
|
|
4840
|
+
!disabled && dividerPosition === "left" ? /* @__PURE__ */ jsx(
|
|
4841
|
+
"div",
|
|
4842
|
+
{
|
|
4843
|
+
className: `w-1 bg-mastra-bg-1 bg-[#121212] 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 -left-1 -right-1 z-10
|
|
4844
|
+
${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
|
|
4845
|
+
onMouseDown: handleMouseDown
|
|
4846
|
+
}
|
|
4847
|
+
) : null,
|
|
4848
|
+
children,
|
|
4849
|
+
!disabled && dividerPosition === "right" ? /* @__PURE__ */ jsx(
|
|
4850
|
+
"div",
|
|
4851
|
+
{
|
|
4852
|
+
className: `w-1 bg-mastra-bg-1 bg-[#121212] 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 -left-1 -right-1 z-10
|
|
4853
|
+
${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
|
|
4854
|
+
onMouseDown: handleMouseDown
|
|
4855
|
+
}
|
|
4856
|
+
) : null
|
|
4857
|
+
] });
|
|
4858
|
+
};
|
|
4670
4859
|
|
|
4671
4860
|
function TreeNode({ node, depth = 0 }) {
|
|
4672
4861
|
const [isExpanded, setIsExpanded] = useState(true);
|
|
@@ -4942,278 +5131,62 @@ function AttributesValues({
|
|
|
4942
5131
|
keyName
|
|
4943
5132
|
}) {
|
|
4944
5133
|
if (attributes === null || attributes === void 0 || Array.isArray(attributes) && attributes.length === 0 || typeof attributes === "object" && attributes !== null && Object.keys(attributes).length === 0) {
|
|
4945
|
-
return /* @__PURE__ */ jsx("span", { className: "text-sm overflow-x-scroll", children: "N/A" });
|
|
4946
|
-
}
|
|
4947
|
-
if (typeof attributes === "string") {
|
|
4948
|
-
try {
|
|
4949
|
-
const attr = JSON.parse(attributes);
|
|
4950
|
-
if (typeof attr === "object" || Array.isArray(attr)) {
|
|
4951
|
-
return /* @__PURE__ */ jsx(SyntaxHighlighter, { data: attr });
|
|
4952
|
-
}
|
|
4953
|
-
} catch {
|
|
4954
|
-
const val = attributes ? cleanString(attributes.toString()) : "N/A";
|
|
4955
|
-
if (keyName === "Input" && val === "[Not Serializable]") {
|
|
4956
|
-
return /* @__PURE__ */ jsx("span", { className: "text-sm overflow-x-scroll", children: "No input" });
|
|
4957
|
-
}
|
|
4958
|
-
return /* @__PURE__ */ jsx("span", { className: "text-sm overflow-x-scroll", children: attributes ? cleanString(attributes.toString()) : "N/A" });
|
|
4959
|
-
}
|
|
4960
|
-
}
|
|
4961
|
-
const processedValue = attributes;
|
|
4962
|
-
if (Array.isArray(processedValue)) {
|
|
4963
|
-
if (processedValue.length === 0) return null;
|
|
4964
|
-
return /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx("div", { className: "mt-1 gap-3", children: processedValue.map((item, index) => /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsx(AttributesValues, { attributes: item, depth: depth + 1 }, index) }, index)) }) });
|
|
4965
|
-
}
|
|
4966
|
-
if (typeof processedValue === "object") {
|
|
4967
|
-
const entries = Object.entries(processedValue);
|
|
4968
|
-
if (entries.length === 0) return null;
|
|
4969
|
-
return /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx("div", { className: "mt-1", children: entries.map(([key, val]) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 p-2 pl-0", children: [
|
|
4970
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm capitalize text-mastra-el-3", children: transformKey(key) }),
|
|
4971
|
-
/* @__PURE__ */ jsx(AttributesValues, { attributes: val, depth: depth + 1, keyName: transformKey(key) })
|
|
4972
|
-
] }, key)) }) });
|
|
4973
|
-
}
|
|
4974
|
-
if (typeof processedValue === "boolean")
|
|
4975
|
-
return /* @__PURE__ */ jsx("span", { className: "font-mono text-sm", children: processedValue.toString() || "N/A" });
|
|
4976
|
-
if (typeof processedValue === "number") return /* @__PURE__ */ jsx("span", { className: "font-mono text-sm", children: processedValue.toString() });
|
|
4977
|
-
if (typeof processedValue === "string")
|
|
4978
|
-
return /* @__PURE__ */ jsx("span", { className: "font-mono text-sm", children: processedValue ? cleanString(processedValue.toString()) : "N/A" });
|
|
4979
|
-
return /* @__PURE__ */ jsx("span", { className: "text-gray-400", children: String(processedValue) });
|
|
4980
|
-
}
|
|
4981
|
-
|
|
4982
|
-
function usePolling({
|
|
4983
|
-
fetchFn,
|
|
4984
|
-
interval = 3e3,
|
|
4985
|
-
enabled = false,
|
|
4986
|
-
onSuccess,
|
|
4987
|
-
onError,
|
|
4988
|
-
shouldContinue = () => true,
|
|
4989
|
-
restartPolling = false
|
|
4990
|
-
}) {
|
|
4991
|
-
const [isPolling, setIsPolling] = useState(enabled);
|
|
4992
|
-
const [error, setError] = useState(null);
|
|
4993
|
-
const [data, setData] = useState(null);
|
|
4994
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
4995
|
-
const [firstCallLoading, setFirstCallLoading] = useState(false);
|
|
4996
|
-
const timeoutRef = useRef(null);
|
|
4997
|
-
const mountedRef = useRef(true);
|
|
4998
|
-
const [restart, setRestart] = useState(restartPolling);
|
|
4999
|
-
const cleanup = useCallback(() => {
|
|
5000
|
-
console.log("cleanup");
|
|
5001
|
-
if (timeoutRef.current) {
|
|
5002
|
-
clearTimeout(timeoutRef.current);
|
|
5003
|
-
timeoutRef.current = null;
|
|
5004
|
-
}
|
|
5005
|
-
}, []);
|
|
5006
|
-
const stopPolling = useCallback(() => {
|
|
5007
|
-
console.log("stopPolling");
|
|
5008
|
-
setIsPolling(false);
|
|
5009
|
-
cleanup();
|
|
5010
|
-
}, [cleanup]);
|
|
5011
|
-
const startPolling = useCallback(() => {
|
|
5012
|
-
console.log("startPolling");
|
|
5013
|
-
setIsPolling(true);
|
|
5014
|
-
setError(null);
|
|
5015
|
-
}, []);
|
|
5016
|
-
const executePoll = useCallback(
|
|
5017
|
-
async (refetch2 = true) => {
|
|
5018
|
-
if (!mountedRef.current) return;
|
|
5019
|
-
setIsLoading(true);
|
|
5020
|
-
try {
|
|
5021
|
-
const result = await fetchFn();
|
|
5022
|
-
setData(result);
|
|
5023
|
-
setError(null);
|
|
5024
|
-
onSuccess?.(result);
|
|
5025
|
-
if (shouldContinue(result) && refetch2) {
|
|
5026
|
-
timeoutRef.current = setTimeout(executePoll, interval);
|
|
5027
|
-
} else {
|
|
5028
|
-
stopPolling();
|
|
5029
|
-
}
|
|
5030
|
-
} catch (err) {
|
|
5031
|
-
if (!mountedRef.current) return;
|
|
5032
|
-
setError(err);
|
|
5033
|
-
onError?.(err);
|
|
5034
|
-
stopPolling();
|
|
5035
|
-
} finally {
|
|
5036
|
-
if (mountedRef.current) {
|
|
5037
|
-
setFirstCallLoading(false);
|
|
5038
|
-
setIsLoading(false);
|
|
5039
|
-
}
|
|
5040
|
-
}
|
|
5041
|
-
},
|
|
5042
|
-
[fetchFn, interval, onSuccess, onError, shouldContinue, stopPolling]
|
|
5043
|
-
);
|
|
5044
|
-
const refetch = useCallback(
|
|
5045
|
-
(withPolling = false) => {
|
|
5046
|
-
console.log("refetch", { withPolling });
|
|
5047
|
-
if (withPolling) {
|
|
5048
|
-
setIsPolling(true);
|
|
5049
|
-
} else {
|
|
5050
|
-
executePoll(false);
|
|
5051
|
-
}
|
|
5052
|
-
setError(null);
|
|
5053
|
-
},
|
|
5054
|
-
[executePoll]
|
|
5055
|
-
);
|
|
5056
|
-
useEffect(() => {
|
|
5057
|
-
mountedRef.current = true;
|
|
5058
|
-
if (enabled && isPolling) {
|
|
5059
|
-
executePoll(true);
|
|
5060
|
-
}
|
|
5061
|
-
return () => {
|
|
5062
|
-
console.log("cleanup poll");
|
|
5063
|
-
mountedRef.current = false;
|
|
5064
|
-
cleanup();
|
|
5065
|
-
};
|
|
5066
|
-
}, [enabled, isPolling, executePoll, cleanup]);
|
|
5067
|
-
useEffect(() => {
|
|
5068
|
-
setRestart(restartPolling);
|
|
5069
|
-
}, [restartPolling]);
|
|
5070
|
-
useEffect(() => {
|
|
5071
|
-
if (restart && !isPolling) {
|
|
5072
|
-
setIsPolling(true);
|
|
5073
|
-
executePoll();
|
|
5074
|
-
setRestart(false);
|
|
5075
|
-
}
|
|
5076
|
-
}, [restart]);
|
|
5077
|
-
return {
|
|
5078
|
-
isPolling,
|
|
5079
|
-
isLoading,
|
|
5080
|
-
error,
|
|
5081
|
-
data,
|
|
5082
|
-
startPolling,
|
|
5083
|
-
stopPolling,
|
|
5084
|
-
firstCallLoading,
|
|
5085
|
-
refetch
|
|
5086
|
-
};
|
|
5087
|
-
}
|
|
5088
|
-
|
|
5089
|
-
const useTraces = (componentName, baseUrl, isWorkflow = false) => {
|
|
5090
|
-
const [traces, setTraces] = useState([]);
|
|
5091
|
-
const { setTraces: setTraceContextTraces } = useContext(TraceContext);
|
|
5092
|
-
const client = useMemo(
|
|
5093
|
-
() => new MastraClient({
|
|
5094
|
-
baseUrl: baseUrl || ""
|
|
5095
|
-
}),
|
|
5096
|
-
[baseUrl]
|
|
5097
|
-
);
|
|
5098
|
-
const fetchFn = useCallback(async () => {
|
|
5099
|
-
try {
|
|
5100
|
-
const res = await client.getTelemetry({
|
|
5101
|
-
attribute: {
|
|
5102
|
-
componentName
|
|
5103
|
-
}
|
|
5104
|
-
});
|
|
5105
|
-
if (!res.traces) {
|
|
5106
|
-
throw new Error("Error fetching traces");
|
|
5107
|
-
}
|
|
5108
|
-
const refinedTraces = refineTraces(res?.traces || [], isWorkflow);
|
|
5109
|
-
return refinedTraces;
|
|
5110
|
-
} catch (error2) {
|
|
5111
|
-
throw error2;
|
|
5112
|
-
}
|
|
5113
|
-
}, [client, componentName, isWorkflow]);
|
|
5114
|
-
const onSuccess = useCallback(
|
|
5115
|
-
(newTraces) => {
|
|
5116
|
-
if (newTraces.length > 0) {
|
|
5117
|
-
setTraces(() => newTraces);
|
|
5118
|
-
setTraceContextTraces(() => newTraces);
|
|
5119
|
-
}
|
|
5120
|
-
},
|
|
5121
|
-
[setTraceContextTraces]
|
|
5122
|
-
);
|
|
5123
|
-
const onError = useCallback((error2) => {
|
|
5124
|
-
toast.error(error2.message);
|
|
5125
|
-
}, []);
|
|
5126
|
-
const shouldContinue = useCallback(() => {
|
|
5127
|
-
return true;
|
|
5128
|
-
}, []);
|
|
5129
|
-
const { firstCallLoading, error } = usePolling({
|
|
5130
|
-
fetchFn,
|
|
5131
|
-
interval: 3e3,
|
|
5132
|
-
onSuccess,
|
|
5133
|
-
onError,
|
|
5134
|
-
shouldContinue,
|
|
5135
|
-
enabled: true
|
|
5136
|
-
});
|
|
5137
|
-
return { traces, firstCallLoading, error };
|
|
5138
|
-
};
|
|
5139
|
-
|
|
5140
|
-
function AgentTraces({
|
|
5141
|
-
agentName,
|
|
5142
|
-
baseUrl,
|
|
5143
|
-
sidebarChild
|
|
5144
|
-
}) {
|
|
5145
|
-
return /* @__PURE__ */ jsx(TraceProvider, { children: /* @__PURE__ */ jsx(AgentTracesInner, { agentName, baseUrl, sidebarChild }) });
|
|
5146
|
-
}
|
|
5147
|
-
function AgentTracesInner({
|
|
5148
|
-
agentName,
|
|
5149
|
-
baseUrl,
|
|
5150
|
-
sidebarChild
|
|
5151
|
-
}) {
|
|
5152
|
-
const { traces, error, firstCallLoading } = useTraces(agentName, baseUrl);
|
|
5153
|
-
const { isOpen: open } = useContext(TraceContext);
|
|
5154
|
-
if (firstCallLoading) {
|
|
5155
|
-
return /* @__PURE__ */ jsxs("main", { className: "flex-1 relative overflow-hidden h-full", children: [
|
|
5156
|
-
/* @__PURE__ */ jsx("div", { className: "h-full w-[calc(100%_-_325px)]", children: /* @__PURE__ */ jsxs(Table$1, { children: [
|
|
5157
|
-
/* @__PURE__ */ jsx(TableHeader, { className: "sticky top-0 z-10 bg-[#0F0F0F]", children: /* @__PURE__ */ jsxs(TableRow, { className: "border-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
|
|
5158
|
-
/* @__PURE__ */ jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Trace" }),
|
|
5159
|
-
/* @__PURE__ */ jsxs(TableHead, { className: "text-mastra-el-3 flex items-center gap-1 h-10", children: [
|
|
5160
|
-
/* @__PURE__ */ jsx(Braces, { className: "h-3 w-3" }),
|
|
5161
|
-
" Trace Id"
|
|
5162
|
-
] }),
|
|
5163
|
-
/* @__PURE__ */ jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Started" }),
|
|
5164
|
-
/* @__PURE__ */ jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Total Duration" })
|
|
5165
|
-
] }) }),
|
|
5166
|
-
/* @__PURE__ */ jsx(TableBody, { className: "border-b border-gray-6", children: /* @__PURE__ */ jsxs(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
|
|
5167
|
-
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-full" }) }),
|
|
5168
|
-
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-full" }) }),
|
|
5169
|
-
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-full" }) }),
|
|
5170
|
-
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-full" }) })
|
|
5171
|
-
] }) })
|
|
5172
|
-
] }) }),
|
|
5173
|
-
/* @__PURE__ */ jsx(SidebarItems$1, { sidebarChild, className: "min-w-[325px]" })
|
|
5174
|
-
] });
|
|
5134
|
+
return /* @__PURE__ */ jsx("span", { className: "text-sm overflow-x-scroll", children: "N/A" });
|
|
5175
5135
|
}
|
|
5176
|
-
if (
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
] }) }),
|
|
5190
|
-
/* @__PURE__ */ jsx(SidebarItems$1, { sidebarChild, className: "min-w-[325px]" })
|
|
5191
|
-
] });
|
|
5136
|
+
if (typeof attributes === "string") {
|
|
5137
|
+
try {
|
|
5138
|
+
const attr = JSON.parse(attributes);
|
|
5139
|
+
if (typeof attr === "object" || Array.isArray(attr)) {
|
|
5140
|
+
return /* @__PURE__ */ jsx(SyntaxHighlighter, { data: attr });
|
|
5141
|
+
}
|
|
5142
|
+
} catch {
|
|
5143
|
+
const val = attributes ? cleanString(attributes.toString()) : "N/A";
|
|
5144
|
+
if (keyName === "Input" && val === "[Not Serializable]") {
|
|
5145
|
+
return /* @__PURE__ */ jsx("span", { className: "text-sm overflow-x-scroll", children: "No input" });
|
|
5146
|
+
}
|
|
5147
|
+
return /* @__PURE__ */ jsx("span", { className: "text-sm overflow-x-scroll", children: attributes ? cleanString(attributes.toString()) : "N/A" });
|
|
5148
|
+
}
|
|
5192
5149
|
}
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5150
|
+
const processedValue = attributes;
|
|
5151
|
+
if (Array.isArray(processedValue)) {
|
|
5152
|
+
if (processedValue.length === 0) return null;
|
|
5153
|
+
return /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx("div", { className: "mt-1 gap-3", children: processedValue.map((item, index) => /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsx(AttributesValues, { attributes: item, depth: depth + 1 }, index) }, index)) }) });
|
|
5154
|
+
}
|
|
5155
|
+
if (typeof processedValue === "object") {
|
|
5156
|
+
const entries = Object.entries(processedValue);
|
|
5157
|
+
if (entries.length === 0) return null;
|
|
5158
|
+
return /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx("div", { className: "mt-1", children: entries.map(([key, val]) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 p-2 pl-0", children: [
|
|
5159
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm capitalize text-mastra-el-3", children: transformKey(key) }),
|
|
5160
|
+
/* @__PURE__ */ jsx(AttributesValues, { attributes: val, depth: depth + 1, keyName: transformKey(key) })
|
|
5161
|
+
] }, key)) }) });
|
|
5162
|
+
}
|
|
5163
|
+
if (typeof processedValue === "boolean")
|
|
5164
|
+
return /* @__PURE__ */ jsx("span", { className: "font-mono text-sm", children: processedValue.toString() || "N/A" });
|
|
5165
|
+
if (typeof processedValue === "number") return /* @__PURE__ */ jsx("span", { className: "font-mono text-sm", children: processedValue.toString() });
|
|
5166
|
+
if (typeof processedValue === "string")
|
|
5167
|
+
return /* @__PURE__ */ jsx("span", { className: "font-mono text-sm", children: processedValue ? cleanString(processedValue.toString()) : "N/A" });
|
|
5168
|
+
return /* @__PURE__ */ jsx("span", { className: "text-gray-400", children: String(processedValue) });
|
|
5197
5169
|
}
|
|
5198
|
-
|
|
5170
|
+
|
|
5171
|
+
const TracesSidebar = ({ className, onResize, width, children }) => {
|
|
5199
5172
|
const { openDetail, isOpen: open } = useContext(TraceContext);
|
|
5200
|
-
const [rightSidebarWidth, setRightSidebarWidth] = useState(40);
|
|
5201
5173
|
return /* @__PURE__ */ jsxs(
|
|
5202
5174
|
MastraResizablePanel,
|
|
5203
5175
|
{
|
|
5204
5176
|
className: cn(
|
|
5205
|
-
"absolute
|
|
5177
|
+
"absolute top-0 bottom-0 right-0 h-full z-20 overflow-x-scroll border-l-[0.5px] bg-mastra-bg-1 bg-[#121212]",
|
|
5206
5178
|
className
|
|
5207
5179
|
),
|
|
5208
|
-
defaultWidth: open ?
|
|
5209
|
-
minimumWidth: open ? 50 :
|
|
5210
|
-
maximumWidth: open ? 90 :
|
|
5180
|
+
defaultWidth: open ? 50 : 30,
|
|
5181
|
+
minimumWidth: open ? 50 : 30,
|
|
5182
|
+
maximumWidth: open ? 90 : 50,
|
|
5183
|
+
setCurrentWidth: onResize,
|
|
5211
5184
|
children: [
|
|
5212
5185
|
open && /* @__PURE__ */ jsx(
|
|
5213
5186
|
"div",
|
|
5214
5187
|
{
|
|
5215
5188
|
className: "h-full overflow-x-scroll px-0 absolute left-0 top-0 min-w-[50%] bg-mastra-bg-1 bg-[#121212]",
|
|
5216
|
-
style: { width: `${
|
|
5189
|
+
style: { width: `${width}%` },
|
|
5217
5190
|
children: /* @__PURE__ */ jsx(TraceDetails, {})
|
|
5218
5191
|
}
|
|
5219
5192
|
),
|
|
@@ -5228,13 +5201,33 @@ function SidebarItems$1({ sidebarChild, className }) {
|
|
|
5228
5201
|
"unset-position": !open
|
|
5229
5202
|
}),
|
|
5230
5203
|
disabled: !open,
|
|
5231
|
-
|
|
5232
|
-
children: /* @__PURE__ */ jsx("div", { className: "h-full overflow-y-scroll", children: !openDetail ? sidebarChild : /* @__PURE__ */ jsx(SpanDetail, {}) })
|
|
5204
|
+
children: /* @__PURE__ */ jsx("div", { className: "h-full overflow-y-scroll", children: !openDetail ? children : /* @__PURE__ */ jsx(SpanDetail, {}) })
|
|
5233
5205
|
}
|
|
5234
5206
|
)
|
|
5235
5207
|
]
|
|
5236
5208
|
}
|
|
5237
5209
|
);
|
|
5210
|
+
};
|
|
5211
|
+
|
|
5212
|
+
function AgentTraces({ agentName, baseUrl, sidebarChild }) {
|
|
5213
|
+
return /* @__PURE__ */ jsx(TraceProvider, { children: /* @__PURE__ */ jsx(AgentTracesInner, { agentName, baseUrl, sidebarChild }) });
|
|
5214
|
+
}
|
|
5215
|
+
function AgentTracesInner({ agentName, baseUrl, sidebarChild }) {
|
|
5216
|
+
const [sidebarWidth, setSidebarWidth] = useState(30);
|
|
5217
|
+
const { traces, firstCallLoading, error } = useTraces(agentName, baseUrl);
|
|
5218
|
+
const { isOpen: open } = useContext(TraceContext);
|
|
5219
|
+
return /* @__PURE__ */ jsxs("main", { className: "h-full relative overflow-hidden flex flex-row", children: [
|
|
5220
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 block mr-[30%]", children: /* @__PURE__ */ jsx(TracesTable, { traces, isLoading: firstCallLoading, error }) }),
|
|
5221
|
+
/* @__PURE__ */ jsx(
|
|
5222
|
+
TracesSidebar,
|
|
5223
|
+
{
|
|
5224
|
+
className: cn(open ? "grid grid-cols-2 w-[60%]" : "min-w-[325px]"),
|
|
5225
|
+
width: 100 - sidebarWidth,
|
|
5226
|
+
onResize: setSidebarWidth,
|
|
5227
|
+
children: sidebarChild
|
|
5228
|
+
}
|
|
5229
|
+
)
|
|
5230
|
+
] });
|
|
5238
5231
|
}
|
|
5239
5232
|
|
|
5240
5233
|
const convertMessage = (message) => {
|
|
@@ -5665,105 +5658,26 @@ const NetworkChat = ({ agentId, memory }) => {
|
|
|
5665
5658
|
return /* @__PURE__ */ jsx(MastraNetworkRuntimeProvider, { agentId, memory, children: /* @__PURE__ */ jsx(Thread, { memory, ToolFallback }) });
|
|
5666
5659
|
};
|
|
5667
5660
|
|
|
5668
|
-
function WorkflowTraces({
|
|
5669
|
-
workflowName,
|
|
5670
|
-
baseUrl,
|
|
5671
|
-
sidebarChild
|
|
5672
|
-
}) {
|
|
5661
|
+
function WorkflowTraces({ workflowName, baseUrl, sidebarChild }) {
|
|
5673
5662
|
return /* @__PURE__ */ jsx(TraceProvider, { children: /* @__PURE__ */ jsx(WorkflowTracesInner, { workflowName, baseUrl, sidebarChild }) });
|
|
5674
5663
|
}
|
|
5675
|
-
function WorkflowTracesInner({
|
|
5676
|
-
|
|
5677
|
-
baseUrl,
|
|
5678
|
-
sidebarChild
|
|
5679
|
-
}) {
|
|
5664
|
+
function WorkflowTracesInner({ workflowName, baseUrl, sidebarChild }) {
|
|
5665
|
+
const [sidebarWidth, setSidebarWidth] = useState(30);
|
|
5680
5666
|
const { traces, error, firstCallLoading } = useTraces(workflowName, baseUrl, true);
|
|
5681
5667
|
const { isOpen: open } = useContext(TraceContext);
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
] }) }),
|
|
5694
|
-
/* @__PURE__ */ jsx(TableBody, { className: "border-b border-gray-6", children: /* @__PURE__ */ jsxs(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
|
|
5695
|
-
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-full" }) }),
|
|
5696
|
-
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-full" }) }),
|
|
5697
|
-
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-full" }) }),
|
|
5698
|
-
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-full" }) })
|
|
5699
|
-
] }) })
|
|
5700
|
-
] }) }),
|
|
5701
|
-
/* @__PURE__ */ jsx(SidebarItems, { sidebarChild, className: "min-w-[325px]" })
|
|
5702
|
-
] });
|
|
5703
|
-
}
|
|
5704
|
-
if (!traces || traces.length === 0) {
|
|
5705
|
-
return /* @__PURE__ */ jsxs("main", { className: "flex-1 h-full relative overflow-hidden", children: [
|
|
5706
|
-
/* @__PURE__ */ jsx("div", { className: "h-full w-[calc(100%_-_325px)]", children: /* @__PURE__ */ jsxs(Table$1, { children: [
|
|
5707
|
-
/* @__PURE__ */ jsx(TableHeader, { className: "sticky top-0 z-10 bg-[#0F0F0F]", children: /* @__PURE__ */ jsxs(TableRow, { className: "border-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
|
|
5708
|
-
/* @__PURE__ */ jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Trace" }),
|
|
5709
|
-
/* @__PURE__ */ jsxs(TableHead, { className: "text-mastra-el-3 flex items-center gap-1 h-10", children: [
|
|
5710
|
-
/* @__PURE__ */ jsx(Braces, { className: "h-3 w-3" }),
|
|
5711
|
-
" Trace Id"
|
|
5712
|
-
] }),
|
|
5713
|
-
/* @__PURE__ */ jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Started" }),
|
|
5714
|
-
/* @__PURE__ */ jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Total Duration" })
|
|
5715
|
-
] }) }),
|
|
5716
|
-
/* @__PURE__ */ jsx(TableBody, { className: "border-b border-gray-6", children: /* @__PURE__ */ jsx(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: /* @__PURE__ */ jsx(TableCell, { colSpan: 4, className: "h-24 text-center", children: error?.message || "No traces found" }) }) })
|
|
5717
|
-
] }) }),
|
|
5718
|
-
/* @__PURE__ */ jsx(SidebarItems, { sidebarChild, className: "min-w-[325px]" })
|
|
5719
|
-
] });
|
|
5720
|
-
}
|
|
5721
|
-
return /* @__PURE__ */ jsxs("main", { className: "flex-1 h-full relative overflow-hidden", children: [
|
|
5722
|
-
/* @__PURE__ */ jsx(Traces, { traces }),
|
|
5723
|
-
/* @__PURE__ */ jsx(SidebarItems, { className: cn(open ? "grid grid-cols-2 w-[60%]" : "min-w-[325px]"), sidebarChild })
|
|
5668
|
+
return /* @__PURE__ */ jsxs("main", { className: "h-full relative overflow-hidden flex flex-row", children: [
|
|
5669
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 block mr-[30%]", children: /* @__PURE__ */ jsx(TracesTable, { traces, isLoading: firstCallLoading, error }) }),
|
|
5670
|
+
/* @__PURE__ */ jsx(
|
|
5671
|
+
TracesSidebar,
|
|
5672
|
+
{
|
|
5673
|
+
className: cn(open ? "grid grid-cols-2 w-[60%]" : "min-w-[325px]"),
|
|
5674
|
+
width: 100 - sidebarWidth,
|
|
5675
|
+
onResize: setSidebarWidth,
|
|
5676
|
+
children: sidebarChild
|
|
5677
|
+
}
|
|
5678
|
+
)
|
|
5724
5679
|
] });
|
|
5725
5680
|
}
|
|
5726
|
-
function SidebarItems({ sidebarChild, className }) {
|
|
5727
|
-
const { openDetail, isOpen: open } = useContext(TraceContext);
|
|
5728
|
-
const [rightSidebarWidth, setRightSidebarWidth] = useState(40);
|
|
5729
|
-
return /* @__PURE__ */ jsxs(
|
|
5730
|
-
MastraResizablePanel,
|
|
5731
|
-
{
|
|
5732
|
-
className: cn(
|
|
5733
|
-
"absolute right-0 top-0 h-full z-20 overflow-x-scroll border-l-[0.5px] bg-mastra-bg-1 bg-[#121212]",
|
|
5734
|
-
className
|
|
5735
|
-
),
|
|
5736
|
-
defaultWidth: open ? 60 : 20,
|
|
5737
|
-
minimumWidth: open ? 50 : 20,
|
|
5738
|
-
maximumWidth: open ? 90 : 60,
|
|
5739
|
-
children: [
|
|
5740
|
-
open && /* @__PURE__ */ jsx(
|
|
5741
|
-
"div",
|
|
5742
|
-
{
|
|
5743
|
-
className: "h-full overflow-x-scroll px-0 absolute left-0 top-0 min-w-[50%] bg-mastra-bg-1 bg-[#121212]",
|
|
5744
|
-
style: { width: `${100 - rightSidebarWidth}%` },
|
|
5745
|
-
children: /* @__PURE__ */ jsx(TraceDetails, {})
|
|
5746
|
-
}
|
|
5747
|
-
),
|
|
5748
|
-
/* @__PURE__ */ jsx(
|
|
5749
|
-
MastraResizablePanel,
|
|
5750
|
-
{
|
|
5751
|
-
defaultWidth: 50,
|
|
5752
|
-
minimumWidth: 30,
|
|
5753
|
-
maximumWidth: 80,
|
|
5754
|
-
className: cn("h-full overflow-y-hidden border-l-[0.5px] right-0 top-0 z-20 bg-mastra-bg-1 bg-[#121212]", {
|
|
5755
|
-
absolute: open,
|
|
5756
|
-
"unset-position": !open
|
|
5757
|
-
}),
|
|
5758
|
-
disabled: !open,
|
|
5759
|
-
setCurrentWidth: setRightSidebarWidth,
|
|
5760
|
-
children: /* @__PURE__ */ jsx("div", { className: "h-full overflow-y-scroll", children: !openDetail ? sidebarChild : /* @__PURE__ */ jsx(SpanDetail, {}) })
|
|
5761
|
-
}
|
|
5762
|
-
)
|
|
5763
|
-
]
|
|
5764
|
-
}
|
|
5765
|
-
);
|
|
5766
|
-
}
|
|
5767
5681
|
|
|
5768
5682
|
const useWorkflow = (workflowId, baseUrl) => {
|
|
5769
5683
|
const [workflow, setWorkflow] = useState(null);
|
|
@@ -6360,6 +6274,43 @@ DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
|
6360
6274
|
const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(DialogPrimitive.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
6361
6275
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
6362
6276
|
|
|
6277
|
+
const ScrollArea = React.forwardRef(
|
|
6278
|
+
({ className, children, viewPortClassName, maxHeight, autoScroll = false, ...props }, ref) => {
|
|
6279
|
+
const areaRef = React.useRef(null);
|
|
6280
|
+
useAutoscroll(areaRef, { enabled: autoScroll });
|
|
6281
|
+
return /* @__PURE__ */ jsxs(ScrollAreaPrimitive.Root, { ref, className: cn("relative overflow-hidden", className), ...props, children: [
|
|
6282
|
+
/* @__PURE__ */ jsx(
|
|
6283
|
+
ScrollAreaPrimitive.Viewport,
|
|
6284
|
+
{
|
|
6285
|
+
ref: areaRef,
|
|
6286
|
+
className: cn("h-full w-full rounded-[inherit] [&>div]:!block", viewPortClassName),
|
|
6287
|
+
style: maxHeight ? { maxHeight } : void 0,
|
|
6288
|
+
children
|
|
6289
|
+
}
|
|
6290
|
+
),
|
|
6291
|
+
/* @__PURE__ */ jsx(ScrollBar, {}),
|
|
6292
|
+
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, {})
|
|
6293
|
+
] });
|
|
6294
|
+
}
|
|
6295
|
+
);
|
|
6296
|
+
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
|
6297
|
+
const ScrollBar = React.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsx(
|
|
6298
|
+
ScrollAreaPrimitive.ScrollAreaScrollbar,
|
|
6299
|
+
{
|
|
6300
|
+
ref,
|
|
6301
|
+
orientation,
|
|
6302
|
+
className: cn(
|
|
6303
|
+
"flex touch-none select-none transition-colors",
|
|
6304
|
+
orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
|
|
6305
|
+
orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
|
6306
|
+
className
|
|
6307
|
+
),
|
|
6308
|
+
...props,
|
|
6309
|
+
children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
|
|
6310
|
+
}
|
|
6311
|
+
));
|
|
6312
|
+
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
6313
|
+
|
|
6363
6314
|
function WorkflowConditionNode({ data }) {
|
|
6364
6315
|
const { conditions } = data;
|
|
6365
6316
|
const [open, setOpen] = useState(true);
|
|
@@ -7150,7 +7101,7 @@ const SelectField = ({ field, inputProps, error, id }) => {
|
|
|
7150
7101
|
const syntheticEvent = {
|
|
7151
7102
|
target: {
|
|
7152
7103
|
value,
|
|
7153
|
-
name:
|
|
7104
|
+
name: inputProps.name
|
|
7154
7105
|
}
|
|
7155
7106
|
};
|
|
7156
7107
|
props.onChange(syntheticEvent);
|
|
@@ -7639,100 +7590,6 @@ function WorkflowTrigger({
|
|
|
7639
7590
|
] }) });
|
|
7640
7591
|
}
|
|
7641
7592
|
|
|
7642
|
-
const rowSize = {
|
|
7643
|
-
default: "[&>tbody>tr]:h-table-row",
|
|
7644
|
-
small: "[&>tbody>tr]:h-table-row-small"
|
|
7645
|
-
};
|
|
7646
|
-
const Table = ({ className, children, size = "default" }) => {
|
|
7647
|
-
return /* @__PURE__ */ jsx("table", { className: clsx("w-full", rowSize[size], className), children });
|
|
7648
|
-
};
|
|
7649
|
-
const Thead = ({ className, children }) => {
|
|
7650
|
-
return /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: clsx("h-table-header border-b-sm border-border1", className), children }) });
|
|
7651
|
-
};
|
|
7652
|
-
const Th = ({ className, children, ...props }) => {
|
|
7653
|
-
return /* @__PURE__ */ jsx(
|
|
7654
|
-
"th",
|
|
7655
|
-
{
|
|
7656
|
-
className: clsx("text-icon3 text-ui-sm h-full text-left font-normal uppercase first:pl-5 last:pr-5", className),
|
|
7657
|
-
...props,
|
|
7658
|
-
children
|
|
7659
|
-
}
|
|
7660
|
-
);
|
|
7661
|
-
};
|
|
7662
|
-
const Tbody = ({ className, children }) => {
|
|
7663
|
-
return /* @__PURE__ */ jsx("tbody", { className: clsx("", className), children });
|
|
7664
|
-
};
|
|
7665
|
-
const Row = ({ className, children, selected = false }) => {
|
|
7666
|
-
return /* @__PURE__ */ jsx("tr", { className: clsx("border-b-sm border-border1 hover:bg-surface3", selected && "bg-surface4", className), children });
|
|
7667
|
-
};
|
|
7668
|
-
|
|
7669
|
-
const sizes = {
|
|
7670
|
-
default: "[&>svg]:h-icon-default [&>svg]:w-icon-default",
|
|
7671
|
-
lg: "[&>svg]:h-icon-lg [&>svg]:w-icon-lg"
|
|
7672
|
-
};
|
|
7673
|
-
const Icon = ({ children, className, size = "default", ...props }) => {
|
|
7674
|
-
return /* @__PURE__ */ jsx("div", { className: clsx(sizes[size], className), ...props, children });
|
|
7675
|
-
};
|
|
7676
|
-
|
|
7677
|
-
const variants = {
|
|
7678
|
-
"header-md": "text-header-md leading-header-md",
|
|
7679
|
-
"ui-lg": "text-ui-lg leading-ui-lg",
|
|
7680
|
-
"ui-md": "text-ui-md leading-ui-md",
|
|
7681
|
-
"ui-sm": "text-ui-sm leading-ui-sm",
|
|
7682
|
-
"ui-xs": "text-ui-xs leading-ui-xs"
|
|
7683
|
-
};
|
|
7684
|
-
const fonts = {
|
|
7685
|
-
mono: "font-mono"
|
|
7686
|
-
};
|
|
7687
|
-
const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) => {
|
|
7688
|
-
return /* @__PURE__ */ jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
|
|
7689
|
-
};
|
|
7690
|
-
|
|
7691
|
-
const formatDateCell = (date) => {
|
|
7692
|
-
const month = new Intl.DateTimeFormat("en-US", { month: "short" }).format(date).toUpperCase();
|
|
7693
|
-
const day = date.getDate();
|
|
7694
|
-
const formattedDay = `${month} ${day}`;
|
|
7695
|
-
const time = new Intl.DateTimeFormat("en-US", {
|
|
7696
|
-
hour: "2-digit",
|
|
7697
|
-
minute: "2-digit",
|
|
7698
|
-
second: "2-digit",
|
|
7699
|
-
hour12: false
|
|
7700
|
-
// Use 24-hour format
|
|
7701
|
-
}).format(date);
|
|
7702
|
-
return { day: formattedDay, time };
|
|
7703
|
-
};
|
|
7704
|
-
|
|
7705
|
-
const Cell = ({ className, children, ...props }) => {
|
|
7706
|
-
return /* @__PURE__ */ jsx("td", { className: clsx("text-icon5 first:pl-5 last:pr-5", className), ...props, children: /* @__PURE__ */ jsx("div", { className: clsx("flex h-full w-full shrink-0 items-center"), children }) });
|
|
7707
|
-
};
|
|
7708
|
-
const TxtCell = ({ className, children }) => {
|
|
7709
|
-
return /* @__PURE__ */ jsx(Cell, { className, children: /* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-md", className: "w-full truncate", children }) });
|
|
7710
|
-
};
|
|
7711
|
-
const UnitCell = ({ className, children, unit }) => {
|
|
7712
|
-
return /* @__PURE__ */ jsx(Cell, { className, children: /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center", children: [
|
|
7713
|
-
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-md", className: "shrink-0", children }),
|
|
7714
|
-
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3 w-full truncate", children: unit })
|
|
7715
|
-
] }) });
|
|
7716
|
-
};
|
|
7717
|
-
const DateTimeCell = ({ dateTime, ...props }) => {
|
|
7718
|
-
const { day, time } = formatDateCell(dateTime);
|
|
7719
|
-
return /* @__PURE__ */ jsx(Cell, { ...props, children: /* @__PURE__ */ jsxs("div", { className: "shrink-0", children: [
|
|
7720
|
-
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3", children: day }),
|
|
7721
|
-
" ",
|
|
7722
|
-
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-md", children: time })
|
|
7723
|
-
] }) });
|
|
7724
|
-
};
|
|
7725
|
-
const EntryCell = ({ name, description, icon, meta, ...props }) => {
|
|
7726
|
-
return /* @__PURE__ */ jsx(Cell, { ...props, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-[14px]", children: [
|
|
7727
|
-
/* @__PURE__ */ jsx(Icon, { size: "lg", className: "text-icon5", children: icon }),
|
|
7728
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0", children: [
|
|
7729
|
-
/* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-md", className: "text-icon6 font-medium !leading-tight", children: name }),
|
|
7730
|
-
description && /* @__PURE__ */ jsx(Txt, { as: "span", variant: "ui-xs", className: "text-icon3 w-full max-w-[300px] truncate !leading-tight", children: description })
|
|
7731
|
-
] }),
|
|
7732
|
-
meta
|
|
7733
|
-
] }) });
|
|
7734
|
-
};
|
|
7735
|
-
|
|
7736
7593
|
const DataTable = ({
|
|
7737
7594
|
columns,
|
|
7738
7595
|
data,
|
|
@@ -7805,31 +7662,6 @@ const DataTable = ({
|
|
|
7805
7662
|
] });
|
|
7806
7663
|
};
|
|
7807
7664
|
|
|
7808
|
-
const variantClasses = {
|
|
7809
|
-
default: "text-icon3",
|
|
7810
|
-
success: "text-accent1",
|
|
7811
|
-
error: "text-accent2",
|
|
7812
|
-
info: "text-accent3"
|
|
7813
|
-
};
|
|
7814
|
-
const Badge = ({ icon, variant = "default", className, children, ...props }) => {
|
|
7815
|
-
return /* @__PURE__ */ jsxs(
|
|
7816
|
-
"div",
|
|
7817
|
-
{
|
|
7818
|
-
className: clsx(
|
|
7819
|
-
"bg-surface4 text-ui-sm gap-md h-badge-default inline-flex items-center rounded-md",
|
|
7820
|
-
icon ? "pl-md pr-1.5" : "px-1.5",
|
|
7821
|
-
icon || variant === "default" ? "text-icon5" : variantClasses[variant],
|
|
7822
|
-
className
|
|
7823
|
-
),
|
|
7824
|
-
...props,
|
|
7825
|
-
children: [
|
|
7826
|
-
icon && /* @__PURE__ */ jsx("span", { className: variantClasses[variant], children: /* @__PURE__ */ jsx(Icon, { children: icon }) }),
|
|
7827
|
-
children
|
|
7828
|
-
]
|
|
7829
|
-
}
|
|
7830
|
-
);
|
|
7831
|
-
};
|
|
7832
|
-
|
|
7833
7665
|
const Button = ({ className, as, ...props }) => {
|
|
7834
7666
|
const Component = as || "button";
|
|
7835
7667
|
return /* @__PURE__ */ jsx(
|