@mastra/playground-ui 4.0.4-alpha.4 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -19,7 +19,6 @@ const dateFns = require('date-fns');
19
19
  const TabsPrimitive = require('@radix-ui/react-tabs');
20
20
  const sonner = require('sonner');
21
21
  const react$1 = require('motion/react');
22
- const ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
23
22
  const langJson = require('@codemirror/lang-json');
24
23
  const highlight$1 = require('@lezer/highlight');
25
24
  const codemirrorThemeGithub = require('@uiw/codemirror-theme-github');
@@ -33,6 +32,7 @@ const Dagre = require('@dagrejs/dagre');
33
32
  const prismReactRenderer = require('prism-react-renderer');
34
33
  const CollapsiblePrimitive = require('@radix-ui/react-collapsible');
35
34
  const DialogPrimitive = require('@radix-ui/react-dialog');
35
+ const ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
36
36
  const jsonSchemaToZod = require('json-schema-to-zod');
37
37
  const superjson = require('superjson');
38
38
  const z = require('zod');
@@ -68,9 +68,9 @@ const React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
68
68
  const TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(TooltipPrimitive);
69
69
  const AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(AvatarPrimitive);
70
70
  const TabsPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(TabsPrimitive);
71
- const ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(ScrollAreaPrimitive);
72
71
  const CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(CollapsiblePrimitive);
73
72
  const DialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DialogPrimitive);
73
+ const ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(ScrollAreaPrimitive);
74
74
  const LabelPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(LabelPrimitive);
75
75
  const CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(CheckboxPrimitive);
76
76
  const PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(PopoverPrimitive);
@@ -4307,126 +4307,6 @@ function EvalTable({ evals, isCIMode = false }) {
4307
4307
  }
4308
4308
  }
4309
4309
 
4310
- const useResizeColumn = ({
4311
- defaultWidth,
4312
- minimumWidth,
4313
- maximumWidth,
4314
- setCurrentWidth
4315
- }) => {
4316
- const [isDragging, setIsDragging] = React.useState(false);
4317
- const [sidebarWidth, setSidebarWidth] = React.useState(defaultWidth);
4318
- const containerRef = React.useRef(null);
4319
- const dragStartXRef = React.useRef(0);
4320
- const initialWidthRef = React.useRef(0);
4321
- const handleMouseDown = (e) => {
4322
- e.preventDefault();
4323
- setIsDragging(true);
4324
- dragStartXRef.current = e.clientX;
4325
- initialWidthRef.current = sidebarWidth;
4326
- };
4327
- React.useEffect(() => {
4328
- setSidebarWidth(defaultWidth);
4329
- setCurrentWidth?.(defaultWidth);
4330
- }, [defaultWidth]);
4331
- React.useEffect(() => {
4332
- const handleMouseMove = (e) => {
4333
- if (!isDragging || !containerRef.current) return;
4334
- const containerWidth = containerRef.current.offsetWidth;
4335
- const deltaX = dragStartXRef.current - e.clientX;
4336
- const deltaPercentage = deltaX / containerWidth * 100;
4337
- const newWidth = Math.min(Math.max(initialWidthRef.current + deltaPercentage, minimumWidth), maximumWidth);
4338
- setSidebarWidth(newWidth);
4339
- setCurrentWidth?.(newWidth);
4340
- };
4341
- const handleMouseUp = () => {
4342
- setIsDragging(false);
4343
- };
4344
- if (isDragging) {
4345
- window.addEventListener("mousemove", handleMouseMove);
4346
- window.addEventListener("mouseup", handleMouseUp);
4347
- }
4348
- return () => {
4349
- window.removeEventListener("mousemove", handleMouseMove);
4350
- window.removeEventListener("mouseup", handleMouseUp);
4351
- };
4352
- }, [isDragging]);
4353
- return { sidebarWidth, isDragging, handleMouseDown, containerRef };
4354
- };
4355
-
4356
- const MastraResizablePanel = ({
4357
- children,
4358
- defaultWidth,
4359
- minimumWidth,
4360
- maximumWidth,
4361
- className,
4362
- disabled = false,
4363
- setCurrentWidth,
4364
- dividerPosition = "left"
4365
- }) => {
4366
- const { sidebarWidth, isDragging, handleMouseDown, containerRef } = useResizeColumn({
4367
- defaultWidth: disabled ? 100 : defaultWidth,
4368
- minimumWidth,
4369
- maximumWidth,
4370
- setCurrentWidth
4371
- });
4372
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full h-full relative", className), ref: containerRef, style: { width: `${sidebarWidth}%` }, children: [
4373
- !disabled && dividerPosition === "left" ? /* @__PURE__ */ jsxRuntime.jsx(
4374
- "div",
4375
- {
4376
- 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
4377
- ${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
4378
- onMouseDown: handleMouseDown
4379
- }
4380
- ) : null,
4381
- children,
4382
- !disabled && dividerPosition === "right" ? /* @__PURE__ */ jsxRuntime.jsx(
4383
- "div",
4384
- {
4385
- 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
4386
- ${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
4387
- onMouseDown: handleMouseDown
4388
- }
4389
- ) : null
4390
- ] });
4391
- };
4392
-
4393
- const ScrollArea = React__namespace.forwardRef(
4394
- ({ className, children, viewPortClassName, maxHeight, autoScroll = false, ...props }, ref) => {
4395
- const areaRef = React__namespace.useRef(null);
4396
- useAutoscroll(areaRef, { enabled: autoScroll });
4397
- return /* @__PURE__ */ jsxRuntime.jsxs(ScrollAreaPrimitive__namespace.Root, { ref, className: cn("relative overflow-hidden", className), ...props, children: [
4398
- /* @__PURE__ */ jsxRuntime.jsx(
4399
- ScrollAreaPrimitive__namespace.Viewport,
4400
- {
4401
- ref: areaRef,
4402
- className: cn("h-full w-full rounded-[inherit] [&>div]:!block", viewPortClassName),
4403
- style: maxHeight ? { maxHeight } : void 0,
4404
- children
4405
- }
4406
- ),
4407
- /* @__PURE__ */ jsxRuntime.jsx(ScrollBar, {}),
4408
- /* @__PURE__ */ jsxRuntime.jsx(ScrollAreaPrimitive__namespace.Corner, {})
4409
- ] });
4410
- }
4411
- );
4412
- ScrollArea.displayName = ScrollAreaPrimitive__namespace.Root.displayName;
4413
- const ScrollBar = React__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
4414
- ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
4415
- {
4416
- ref,
4417
- orientation,
4418
- className: cn(
4419
- "flex touch-none select-none transition-colors",
4420
- orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
4421
- orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
4422
- className
4423
- ),
4424
- ...props,
4425
- children: /* @__PURE__ */ jsxRuntime.jsx(ScrollAreaPrimitive__namespace.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
4426
- }
4427
- ));
4428
- ScrollBar.displayName = ScrollAreaPrimitive__namespace.ScrollAreaScrollbar.displayName;
4429
-
4430
4310
  const TraceContext = React.createContext({});
4431
4311
  function TraceProvider({ children }) {
4432
4312
  const [open, setOpen] = React.useState(false);
@@ -4486,6 +4366,113 @@ function TraceProvider({ children }) {
4486
4366
  );
4487
4367
  }
4488
4368
 
4369
+ function usePolling({
4370
+ fetchFn,
4371
+ interval = 3e3,
4372
+ enabled = false,
4373
+ onSuccess,
4374
+ onError,
4375
+ shouldContinue = () => true,
4376
+ restartPolling = false
4377
+ }) {
4378
+ const [isPolling, setIsPolling] = React.useState(enabled);
4379
+ const [error, setError] = React.useState(null);
4380
+ const [data, setData] = React.useState(null);
4381
+ const [isLoading, setIsLoading] = React.useState(false);
4382
+ const [firstCallLoading, setFirstCallLoading] = React.useState(false);
4383
+ const timeoutRef = React.useRef(null);
4384
+ const mountedRef = React.useRef(true);
4385
+ const [restart, setRestart] = React.useState(restartPolling);
4386
+ const cleanup = React.useCallback(() => {
4387
+ console.log("cleanup");
4388
+ if (timeoutRef.current) {
4389
+ clearTimeout(timeoutRef.current);
4390
+ timeoutRef.current = null;
4391
+ }
4392
+ }, []);
4393
+ const stopPolling = React.useCallback(() => {
4394
+ console.log("stopPolling");
4395
+ setIsPolling(false);
4396
+ cleanup();
4397
+ }, [cleanup]);
4398
+ const startPolling = React.useCallback(() => {
4399
+ console.log("startPolling");
4400
+ setIsPolling(true);
4401
+ setError(null);
4402
+ }, []);
4403
+ const executePoll = React.useCallback(
4404
+ async (refetch2 = true) => {
4405
+ if (!mountedRef.current) return;
4406
+ setIsLoading(true);
4407
+ try {
4408
+ const result = await fetchFn();
4409
+ setData(result);
4410
+ setError(null);
4411
+ onSuccess?.(result);
4412
+ if (shouldContinue(result) && refetch2) {
4413
+ timeoutRef.current = setTimeout(executePoll, interval);
4414
+ } else {
4415
+ stopPolling();
4416
+ }
4417
+ } catch (err) {
4418
+ if (!mountedRef.current) return;
4419
+ setError(err);
4420
+ onError?.(err);
4421
+ stopPolling();
4422
+ } finally {
4423
+ if (mountedRef.current) {
4424
+ setFirstCallLoading(false);
4425
+ setIsLoading(false);
4426
+ }
4427
+ }
4428
+ },
4429
+ [fetchFn, interval, onSuccess, onError, shouldContinue, stopPolling]
4430
+ );
4431
+ const refetch = React.useCallback(
4432
+ (withPolling = false) => {
4433
+ console.log("refetch", { withPolling });
4434
+ if (withPolling) {
4435
+ setIsPolling(true);
4436
+ } else {
4437
+ executePoll(false);
4438
+ }
4439
+ setError(null);
4440
+ },
4441
+ [executePoll]
4442
+ );
4443
+ React.useEffect(() => {
4444
+ mountedRef.current = true;
4445
+ if (enabled && isPolling) {
4446
+ executePoll(true);
4447
+ }
4448
+ return () => {
4449
+ console.log("cleanup poll");
4450
+ mountedRef.current = false;
4451
+ cleanup();
4452
+ };
4453
+ }, [enabled, isPolling, executePoll, cleanup]);
4454
+ React.useEffect(() => {
4455
+ setRestart(restartPolling);
4456
+ }, [restartPolling]);
4457
+ React.useEffect(() => {
4458
+ if (restart && !isPolling) {
4459
+ setIsPolling(true);
4460
+ executePoll();
4461
+ setRestart(false);
4462
+ }
4463
+ }, [restart]);
4464
+ return {
4465
+ isPolling,
4466
+ isLoading,
4467
+ error,
4468
+ data,
4469
+ startPolling,
4470
+ stopPolling,
4471
+ firstCallLoading,
4472
+ refetch
4473
+ };
4474
+ }
4475
+
4489
4476
  function formatDuration(duration, fixedPoint = 2) {
4490
4477
  const durationInSecs = duration / 1e3;
4491
4478
  return durationInSecs.toFixed(fixedPoint);
@@ -4581,68 +4568,187 @@ const allowedAiSpanAttributes = [
4581
4568
  "ai.usage.completionTokens"
4582
4569
  ];
4583
4570
 
4584
- function Traces({ traces }) {
4585
- const { trace: currentTrace } = React.useContext(TraceContext);
4586
- const [prevTracesId, setPrevTracesId] = React.useState(/* @__PURE__ */ new Set());
4587
- React.useEffect(() => {
4588
- if (!prevTracesId.size && traces) {
4589
- setPrevTracesId(new Set(traces.map((trace) => trace.traceId)));
4571
+ const useTraces = (componentName, baseUrl, isWorkflow = false) => {
4572
+ const [traces, setTraces] = React.useState([]);
4573
+ const { setTraces: setTraceContextTraces } = React.useContext(TraceContext);
4574
+ const client = React.useMemo(
4575
+ () => new clientJs.MastraClient({
4576
+ baseUrl: baseUrl || ""
4577
+ }),
4578
+ [baseUrl]
4579
+ );
4580
+ const fetchFn = React.useCallback(async () => {
4581
+ try {
4582
+ const res = await client.getTelemetry({
4583
+ attribute: {
4584
+ componentName
4585
+ }
4586
+ });
4587
+ if (!res.traces) {
4588
+ throw new Error("Error fetching traces");
4589
+ }
4590
+ const refinedTraces = refineTraces(res?.traces || [], isWorkflow);
4591
+ return refinedTraces;
4592
+ } catch (error2) {
4593
+ throw error2;
4590
4594
  }
4591
- }, [traces]);
4592
- const isNew = (traceId) => {
4593
- if (!prevTracesId.size) return false;
4594
- return !prevTracesId.has(traceId);
4595
- };
4596
- const currentTraceParentSpan = currentTrace?.find((span) => span.parentSpanId === void 0) || currentTrace?.[0];
4597
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-[calc(100%_-_325px)]", children: /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
4598
- /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { className: "sticky top-0 z-10 bg-[#0F0F0F]", style: { outline: "1px solid 0_0%_20.4%" }, children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: "border-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
4599
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Trace" }),
4600
- /* @__PURE__ */ jsxRuntime.jsxs(TableHead, { className: "text-mastra-el-3 flex items-center gap-1 h-10", children: [
4601
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Braces, { className: "h-3 w-3" }),
4602
- " Trace Id"
4603
- ] }),
4604
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Started" }),
4605
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Total Duration" })
4606
- ] }) }),
4607
- /* @__PURE__ */ jsxRuntime.jsx(TableBody, { className: "border-b border-gray-6", children: !traces.length ? /* @__PURE__ */ jsxRuntime.jsx(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: /* @__PURE__ */ jsxRuntime.jsx(TableCell, { colSpan: 4, className: "h-24 text-center", children: "No traces found" }) }) : traces.map((trace, index) => /* @__PURE__ */ jsxRuntime.jsxs(
4608
- TableRow,
4609
- {
4610
- className: cn(
4611
- "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",
4612
- isNew(trace.traceId) ? "animate-fade-in" : "not-new",
4613
- {
4614
- "bg-muted/50": currentTraceParentSpan?.traceId === trace.traceId
4615
- }
4616
- ),
4617
- children: [
4618
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(
4619
- TraceButton,
4620
- {
4621
- trace: trace.trace,
4622
- name: trace.serviceName,
4623
- traceIndex: index,
4624
- status: trace.status
4625
- }
4626
- ) }),
4627
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "text-mastra-el-5", children: trace.traceId }),
4628
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "text-mastra-el-5 text-sm", children: formatOtelTimestamp(trace.started) }),
4629
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-2 text-[#F1CA5E]", children: [
4630
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock1, { className: "h-3 w-3" }),
4631
- formatDuration(trace.duration, 3),
4632
- "ms"
4633
- ] }) })
4634
- ]
4635
- },
4636
- trace.traceId
4637
- )) })
4638
- ] }) }) });
4639
- }
4640
- function TraceButton({
4641
- trace,
4642
- name,
4643
- traceIndex,
4644
- status
4645
- }) {
4595
+ }, [client, componentName, isWorkflow]);
4596
+ const onSuccess = React.useCallback(
4597
+ (newTraces) => {
4598
+ if (newTraces.length > 0) {
4599
+ setTraces(() => newTraces);
4600
+ setTraceContextTraces(() => newTraces);
4601
+ }
4602
+ },
4603
+ [setTraceContextTraces]
4604
+ );
4605
+ const onError = React.useCallback((error2) => {
4606
+ sonner.toast.error(error2.message);
4607
+ }, []);
4608
+ const shouldContinue = React.useCallback(() => {
4609
+ return true;
4610
+ }, []);
4611
+ const { firstCallLoading, error } = usePolling({
4612
+ fetchFn,
4613
+ interval: 3e3,
4614
+ onSuccess,
4615
+ onError,
4616
+ shouldContinue,
4617
+ enabled: true
4618
+ });
4619
+ return { traces, firstCallLoading, error };
4620
+ };
4621
+
4622
+ const rowSize = {
4623
+ default: "[&>tbody>tr]:h-table-row",
4624
+ small: "[&>tbody>tr]:h-table-row-small"
4625
+ };
4626
+ const Table = ({ className, children, size = "default" }) => {
4627
+ return /* @__PURE__ */ jsxRuntime.jsx("table", { className: clsx("w-full", rowSize[size], className), children });
4628
+ };
4629
+ const Thead = ({ className, children }) => {
4630
+ return /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { className: clsx("h-table-header border-b-sm border-border1", className), children }) });
4631
+ };
4632
+ const Th = ({ className, children, ...props }) => {
4633
+ return /* @__PURE__ */ jsxRuntime.jsx(
4634
+ "th",
4635
+ {
4636
+ className: clsx("text-icon3 text-ui-sm h-full text-left font-normal uppercase first:pl-5 last:pr-5", className),
4637
+ ...props,
4638
+ children
4639
+ }
4640
+ );
4641
+ };
4642
+ const Tbody = ({ className, children }) => {
4643
+ return /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: clsx("", className), children });
4644
+ };
4645
+ const Row = ({ className, children, selected = false }) => {
4646
+ return /* @__PURE__ */ jsxRuntime.jsx("tr", { className: clsx("border-b-sm border-border1 hover:bg-surface3", selected && "bg-surface4", className), children });
4647
+ };
4648
+
4649
+ const sizes = {
4650
+ default: "[&>svg]:h-icon-default [&>svg]:w-icon-default",
4651
+ lg: "[&>svg]:h-icon-lg [&>svg]:w-icon-lg"
4652
+ };
4653
+ const Icon = ({ children, className, size = "default", ...props }) => {
4654
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx(sizes[size], className), ...props, children });
4655
+ };
4656
+
4657
+ const variants = {
4658
+ "header-md": "text-header-md leading-header-md",
4659
+ "ui-lg": "text-ui-lg leading-ui-lg",
4660
+ "ui-md": "text-ui-md leading-ui-md",
4661
+ "ui-sm": "text-ui-sm leading-ui-sm",
4662
+ "ui-xs": "text-ui-xs leading-ui-xs"
4663
+ };
4664
+ const fonts = {
4665
+ mono: "font-mono"
4666
+ };
4667
+ const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) => {
4668
+ return /* @__PURE__ */ jsxRuntime.jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
4669
+ };
4670
+
4671
+ const formatDateCell = (date) => {
4672
+ const month = new Intl.DateTimeFormat("en-US", { month: "short" }).format(date).toUpperCase();
4673
+ const day = date.getDate();
4674
+ const formattedDay = `${month} ${day}`;
4675
+ const time = new Intl.DateTimeFormat("en-US", {
4676
+ hour: "2-digit",
4677
+ minute: "2-digit",
4678
+ second: "2-digit",
4679
+ hour12: false
4680
+ // Use 24-hour format
4681
+ }).format(date);
4682
+ return { day: formattedDay, time };
4683
+ };
4684
+
4685
+ const Cell = ({ className, children, ...props }) => {
4686
+ 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 }) });
4687
+ };
4688
+ const TxtCell = ({ className, children }) => {
4689
+ return /* @__PURE__ */ jsxRuntime.jsx(Cell, { className, children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", className: "w-full truncate", children }) });
4690
+ };
4691
+ const UnitCell = ({ className, children, unit }) => {
4692
+ return /* @__PURE__ */ jsxRuntime.jsx(Cell, { className, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center", children: [
4693
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", className: "shrink-0", children }),
4694
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3 w-full truncate", children: unit })
4695
+ ] }) });
4696
+ };
4697
+ const DateTimeCell = ({ dateTime, ...props }) => {
4698
+ const { day, time } = formatDateCell(dateTime);
4699
+ return /* @__PURE__ */ jsxRuntime.jsx(Cell, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0", children: [
4700
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3", children: day }),
4701
+ " ",
4702
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", children: time })
4703
+ ] }) });
4704
+ };
4705
+ const EntryCell = ({ name, description, icon, meta, ...props }) => {
4706
+ return /* @__PURE__ */ jsxRuntime.jsx(Cell, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[14px]", children: [
4707
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "lg", className: "text-icon5", children: icon }),
4708
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-0", children: [
4709
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", className: "text-icon6 font-medium !leading-tight", children: name }),
4710
+ description && /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-xs", className: "text-icon3 w-full max-w-[300px] truncate !leading-tight", children: description })
4711
+ ] }),
4712
+ meta
4713
+ ] }) });
4714
+ };
4715
+
4716
+ const variantClasses = {
4717
+ default: "text-icon3",
4718
+ success: "text-accent1",
4719
+ error: "text-accent2",
4720
+ info: "text-accent3"
4721
+ };
4722
+ const Badge = ({ icon, variant = "default", className, children, ...props }) => {
4723
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4724
+ "div",
4725
+ {
4726
+ className: clsx(
4727
+ "bg-surface4 text-ui-sm gap-md h-badge-default inline-flex items-center rounded-md",
4728
+ icon ? "pl-md pr-1.5" : "px-1.5",
4729
+ icon || variant === "default" ? "text-icon5" : variantClasses[variant],
4730
+ className
4731
+ ),
4732
+ ...props,
4733
+ children: [
4734
+ icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: variantClasses[variant], children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: icon }) }),
4735
+ children
4736
+ ]
4737
+ }
4738
+ );
4739
+ };
4740
+
4741
+ const SpanIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "15", height: "8", viewBox: "0 0 15 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
4742
+ "path",
4743
+ {
4744
+ fillRule: "evenodd",
4745
+ clipRule: "evenodd",
4746
+ 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",
4747
+ fill: "currentColor"
4748
+ }
4749
+ ) });
4750
+
4751
+ const useOpenTrace = () => {
4646
4752
  const {
4647
4753
  setTrace,
4648
4754
  isOpen: open,
@@ -4652,53 +4758,136 @@ function TraceButton({
4652
4758
  setOpenDetail,
4653
4759
  setCurrentTraceIndex
4654
4760
  } = React.useContext(TraceContext);
4655
- return /* @__PURE__ */ jsxRuntime.jsxs(
4656
- Button$1,
4657
- {
4658
- variant: "ghost",
4659
- className: "flex h-0 items-center gap-2 p-0",
4660
- onClick: () => {
4661
- setTrace(trace);
4662
- const parentSpan = trace.find((span) => span.parentSpanId === null) || trace[0];
4663
- setSpan(parentSpan);
4664
- setCurrentTraceIndex(traceIndex);
4665
- if (open && currentTrace?.[0]?.id !== trace[0].id) return;
4666
- setOpen((prev) => !prev);
4667
- setOpenDetail((prev) => !prev);
4668
- },
4669
- children: [
4670
- status.code === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
4671
- "svg",
4672
- {
4673
- className: "h-3 w-3",
4674
- xmlns: "http://www.w3.org/2000/svg",
4675
- width: "13",
4676
- height: "12",
4677
- viewBox: "0 0 13 12",
4678
- fill: "none",
4679
- children: /* @__PURE__ */ jsxRuntime.jsx(
4680
- "path",
4681
- {
4682
- fillRule: "evenodd",
4683
- clipRule: "evenodd",
4684
- d: "M6.37695 12C9.69067 12 12.377 9.31371 12.377 6C12.377 2.68629 9.69067 0 6.37695 0C3.06325 0 0.376953 2.68629 0.376953 6C0.376953 9.31371 3.06325 12 6.37695 12ZM9.62004 4.65344C9.87907 4.36036 9.8651 3.90005 9.58884 3.6253C9.3125 3.35055 8.87861 3.3654 8.61958 3.65847L5.6477 7.02105L4.08967 5.55197C3.80661 5.28508 3.37319 5.31213 3.12159 5.61237C2.87 5.91262 2.89549 6.37239 3.17854 6.63927L4.90294 8.26517C5.36588 8.70171 6.07235 8.6676 6.49598 8.18829L9.62004 4.65344Z",
4685
- fill: "#6CD063"
4686
- }
4687
- )
4688
- }
4689
- ) : /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#FF4500", width: "13", height: "12", children: /* @__PURE__ */ jsxRuntime.jsx(
4690
- "path",
4691
- {
4692
- fillRule: "evenodd",
4693
- d: "M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25Zm-1.72 6.97a.75.75 0 1 0-1.06 1.06L10.94 12l-1.72 1.72a.75.75 0 1 0 1.06 1.06L12 13.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L13.06 12l1.72-1.72a.75.75 0 1 0-1.06-1.06L12 10.94l-1.72-1.72Z",
4694
- clipRule: "evenodd"
4695
- }
4696
- ) }),
4697
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate max-w-[150px]", children: name })
4698
- ]
4761
+ const openTrace = (trace, traceIndex) => {
4762
+ setTrace(trace);
4763
+ const parentSpan = trace.find((span) => span.parentSpanId === null) || trace[0];
4764
+ setSpan(parentSpan);
4765
+ setCurrentTraceIndex(traceIndex);
4766
+ if (open && currentTrace?.[0]?.id !== trace[0].id) return;
4767
+ setOpen((prev) => !prev);
4768
+ setOpenDetail((prev) => !prev);
4769
+ };
4770
+ return { openTrace };
4771
+ };
4772
+
4773
+ const TracesTableSkeleton = ({ colsCount }) => {
4774
+ return /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: /* @__PURE__ */ jsxRuntime.jsx(Row, { children: Array.from({ length: colsCount }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "w-1/2" }) }, index)) }) });
4775
+ };
4776
+ const TracesTableEmpty = ({ colsCount }) => {
4777
+ 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" }) }) }) });
4778
+ };
4779
+ const TracesTableError = ({ error, colsCount }) => {
4780
+ 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 }) }) }) });
4781
+ };
4782
+ const TraceRow = ({ trace, index }) => {
4783
+ const { openTrace } = useOpenTrace();
4784
+ return /* @__PURE__ */ jsxRuntime.jsxs(Row, { children: [
4785
+ /* @__PURE__ */ jsxRuntime.jsx(DateTimeCell, { dateTime: new Date(trace.started / 1e3) }),
4786
+ /* @__PURE__ */ jsxRuntime.jsx(TxtCell, { children: trace.traceId }),
4787
+ /* @__PURE__ */ jsxRuntime.jsx(UnitCell, { unit: "ms", children: trace.duration }),
4788
+ /* @__PURE__ */ jsxRuntime.jsx(Cell, { children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => openTrace(trace.trace, index), children: /* @__PURE__ */ jsxRuntime.jsxs(Badge, { icon: /* @__PURE__ */ jsxRuntime.jsx(SpanIcon, {}), children: [
4789
+ trace.trace.length,
4790
+ " span",
4791
+ trace.trace.length > 1 ? "s" : ""
4792
+ ] }) }) })
4793
+ ] });
4794
+ };
4795
+ const TracesTable = ({ traces, isLoading, error }) => {
4796
+ const hasNoTraces = !traces || traces.length === 0;
4797
+ const colsCount = 4;
4798
+ return /* @__PURE__ */ jsxRuntime.jsxs(Table, { size: "small", children: [
4799
+ /* @__PURE__ */ jsxRuntime.jsxs(Thead, { children: [
4800
+ /* @__PURE__ */ jsxRuntime.jsx(Th, { width: 160, children: "Time" }),
4801
+ /* @__PURE__ */ jsxRuntime.jsx(Th, { width: "auto", children: "Trace Id" }),
4802
+ /* @__PURE__ */ jsxRuntime.jsx(Th, { width: 160, children: "Duration" }),
4803
+ /* @__PURE__ */ jsxRuntime.jsx(Th, { width: 160, children: "Spans" })
4804
+ ] }),
4805
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableSkeleton, { colsCount }) : error ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableError, { error, colsCount }) : hasNoTraces ? /* @__PURE__ */ jsxRuntime.jsx(TracesTableEmpty, { colsCount }) : /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: traces.map((trace, index) => /* @__PURE__ */ jsxRuntime.jsx(TraceRow, { trace, index }, trace.traceId)) })
4806
+ ] });
4807
+ };
4808
+
4809
+ const useResizeColumn = ({
4810
+ defaultWidth,
4811
+ minimumWidth,
4812
+ maximumWidth,
4813
+ setCurrentWidth
4814
+ }) => {
4815
+ const [isDragging, setIsDragging] = React.useState(false);
4816
+ const [sidebarWidth, setSidebarWidth] = React.useState(defaultWidth);
4817
+ const containerRef = React.useRef(null);
4818
+ const dragStartXRef = React.useRef(0);
4819
+ const initialWidthRef = React.useRef(0);
4820
+ const handleMouseDown = (e) => {
4821
+ e.preventDefault();
4822
+ setIsDragging(true);
4823
+ dragStartXRef.current = e.clientX;
4824
+ initialWidthRef.current = sidebarWidth;
4825
+ };
4826
+ React.useEffect(() => {
4827
+ setSidebarWidth(defaultWidth);
4828
+ setCurrentWidth?.(defaultWidth);
4829
+ }, [defaultWidth]);
4830
+ React.useEffect(() => {
4831
+ const handleMouseMove = (e) => {
4832
+ if (!isDragging || !containerRef.current) return;
4833
+ const containerWidth = containerRef.current.offsetWidth;
4834
+ const deltaX = dragStartXRef.current - e.clientX;
4835
+ const deltaPercentage = deltaX / containerWidth * 100;
4836
+ const newWidth = Math.min(Math.max(initialWidthRef.current + deltaPercentage, minimumWidth), maximumWidth);
4837
+ setSidebarWidth(newWidth);
4838
+ setCurrentWidth?.(newWidth);
4839
+ };
4840
+ const handleMouseUp = () => {
4841
+ setIsDragging(false);
4842
+ };
4843
+ if (isDragging) {
4844
+ window.addEventListener("mousemove", handleMouseMove);
4845
+ window.addEventListener("mouseup", handleMouseUp);
4699
4846
  }
4700
- );
4701
- }
4847
+ return () => {
4848
+ window.removeEventListener("mousemove", handleMouseMove);
4849
+ window.removeEventListener("mouseup", handleMouseUp);
4850
+ };
4851
+ }, [isDragging]);
4852
+ return { sidebarWidth, isDragging, handleMouseDown, containerRef };
4853
+ };
4854
+
4855
+ const MastraResizablePanel = ({
4856
+ children,
4857
+ defaultWidth,
4858
+ minimumWidth,
4859
+ maximumWidth,
4860
+ className,
4861
+ disabled = false,
4862
+ setCurrentWidth,
4863
+ dividerPosition = "left"
4864
+ }) => {
4865
+ const { sidebarWidth, isDragging, handleMouseDown, containerRef } = useResizeColumn({
4866
+ defaultWidth: disabled ? 100 : defaultWidth,
4867
+ minimumWidth,
4868
+ maximumWidth,
4869
+ setCurrentWidth
4870
+ });
4871
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("w-full h-full relative", className), ref: containerRef, style: { width: `${sidebarWidth}%` }, children: [
4872
+ !disabled && dividerPosition === "left" ? /* @__PURE__ */ jsxRuntime.jsx(
4873
+ "div",
4874
+ {
4875
+ 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
4876
+ ${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
4877
+ onMouseDown: handleMouseDown
4878
+ }
4879
+ ) : null,
4880
+ children,
4881
+ !disabled && dividerPosition === "right" ? /* @__PURE__ */ jsxRuntime.jsx(
4882
+ "div",
4883
+ {
4884
+ 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
4885
+ ${isDragging ? "bg-mastra-border-2 bg-[#424242] w-1.5 cursor- col-resize" : ""}`,
4886
+ onMouseDown: handleMouseDown
4887
+ }
4888
+ ) : null
4889
+ ] });
4890
+ };
4702
4891
 
4703
4892
  function TreeNode({ node, depth = 0 }) {
4704
4893
  const [isExpanded, setIsExpanded] = React.useState(true);
@@ -4974,278 +5163,62 @@ function AttributesValues({
4974
5163
  keyName
4975
5164
  }) {
4976
5165
  if (attributes === null || attributes === void 0 || Array.isArray(attributes) && attributes.length === 0 || typeof attributes === "object" && attributes !== null && Object.keys(attributes).length === 0) {
4977
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm overflow-x-scroll", children: "N/A" });
4978
- }
4979
- if (typeof attributes === "string") {
4980
- try {
4981
- const attr = JSON.parse(attributes);
4982
- if (typeof attr === "object" || Array.isArray(attr)) {
4983
- return /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter, { data: attr });
4984
- }
4985
- } catch {
4986
- const val = attributes ? cleanString(attributes.toString()) : "N/A";
4987
- if (keyName === "Input" && val === "[Not Serializable]") {
4988
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm overflow-x-scroll", children: "No input" });
4989
- }
4990
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm overflow-x-scroll", children: attributes ? cleanString(attributes.toString()) : "N/A" });
4991
- }
4992
- }
4993
- const processedValue = attributes;
4994
- if (Array.isArray(processedValue)) {
4995
- if (processedValue.length === 0) return null;
4996
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 gap-3", children: processedValue.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsxRuntime.jsx(AttributesValues, { attributes: item, depth: depth + 1 }, index) }, index)) }) });
4997
- }
4998
- if (typeof processedValue === "object") {
4999
- const entries = Object.entries(processedValue);
5000
- if (entries.length === 0) return null;
5001
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: entries.map(([key, val]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 p-2 pl-0", children: [
5002
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm capitalize text-mastra-el-3", children: transformKey(key) }),
5003
- /* @__PURE__ */ jsxRuntime.jsx(AttributesValues, { attributes: val, depth: depth + 1, keyName: transformKey(key) })
5004
- ] }, key)) }) });
5005
- }
5006
- if (typeof processedValue === "boolean")
5007
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-sm", children: processedValue.toString() || "N/A" });
5008
- if (typeof processedValue === "number") return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-sm", children: processedValue.toString() });
5009
- if (typeof processedValue === "string")
5010
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-sm", children: processedValue ? cleanString(processedValue.toString()) : "N/A" });
5011
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400", children: String(processedValue) });
5012
- }
5013
-
5014
- function usePolling({
5015
- fetchFn,
5016
- interval = 3e3,
5017
- enabled = false,
5018
- onSuccess,
5019
- onError,
5020
- shouldContinue = () => true,
5021
- restartPolling = false
5022
- }) {
5023
- const [isPolling, setIsPolling] = React.useState(enabled);
5024
- const [error, setError] = React.useState(null);
5025
- const [data, setData] = React.useState(null);
5026
- const [isLoading, setIsLoading] = React.useState(false);
5027
- const [firstCallLoading, setFirstCallLoading] = React.useState(false);
5028
- const timeoutRef = React.useRef(null);
5029
- const mountedRef = React.useRef(true);
5030
- const [restart, setRestart] = React.useState(restartPolling);
5031
- const cleanup = React.useCallback(() => {
5032
- console.log("cleanup");
5033
- if (timeoutRef.current) {
5034
- clearTimeout(timeoutRef.current);
5035
- timeoutRef.current = null;
5036
- }
5037
- }, []);
5038
- const stopPolling = React.useCallback(() => {
5039
- console.log("stopPolling");
5040
- setIsPolling(false);
5041
- cleanup();
5042
- }, [cleanup]);
5043
- const startPolling = React.useCallback(() => {
5044
- console.log("startPolling");
5045
- setIsPolling(true);
5046
- setError(null);
5047
- }, []);
5048
- const executePoll = React.useCallback(
5049
- async (refetch2 = true) => {
5050
- if (!mountedRef.current) return;
5051
- setIsLoading(true);
5052
- try {
5053
- const result = await fetchFn();
5054
- setData(result);
5055
- setError(null);
5056
- onSuccess?.(result);
5057
- if (shouldContinue(result) && refetch2) {
5058
- timeoutRef.current = setTimeout(executePoll, interval);
5059
- } else {
5060
- stopPolling();
5061
- }
5062
- } catch (err) {
5063
- if (!mountedRef.current) return;
5064
- setError(err);
5065
- onError?.(err);
5066
- stopPolling();
5067
- } finally {
5068
- if (mountedRef.current) {
5069
- setFirstCallLoading(false);
5070
- setIsLoading(false);
5071
- }
5072
- }
5073
- },
5074
- [fetchFn, interval, onSuccess, onError, shouldContinue, stopPolling]
5075
- );
5076
- const refetch = React.useCallback(
5077
- (withPolling = false) => {
5078
- console.log("refetch", { withPolling });
5079
- if (withPolling) {
5080
- setIsPolling(true);
5081
- } else {
5082
- executePoll(false);
5083
- }
5084
- setError(null);
5085
- },
5086
- [executePoll]
5087
- );
5088
- React.useEffect(() => {
5089
- mountedRef.current = true;
5090
- if (enabled && isPolling) {
5091
- executePoll(true);
5092
- }
5093
- return () => {
5094
- console.log("cleanup poll");
5095
- mountedRef.current = false;
5096
- cleanup();
5097
- };
5098
- }, [enabled, isPolling, executePoll, cleanup]);
5099
- React.useEffect(() => {
5100
- setRestart(restartPolling);
5101
- }, [restartPolling]);
5102
- React.useEffect(() => {
5103
- if (restart && !isPolling) {
5104
- setIsPolling(true);
5105
- executePoll();
5106
- setRestart(false);
5107
- }
5108
- }, [restart]);
5109
- return {
5110
- isPolling,
5111
- isLoading,
5112
- error,
5113
- data,
5114
- startPolling,
5115
- stopPolling,
5116
- firstCallLoading,
5117
- refetch
5118
- };
5119
- }
5120
-
5121
- const useTraces = (componentName, baseUrl, isWorkflow = false) => {
5122
- const [traces, setTraces] = React.useState([]);
5123
- const { setTraces: setTraceContextTraces } = React.useContext(TraceContext);
5124
- const client = React.useMemo(
5125
- () => new clientJs.MastraClient({
5126
- baseUrl: baseUrl || ""
5127
- }),
5128
- [baseUrl]
5129
- );
5130
- const fetchFn = React.useCallback(async () => {
5131
- try {
5132
- const res = await client.getTelemetry({
5133
- attribute: {
5134
- componentName
5135
- }
5136
- });
5137
- if (!res.traces) {
5138
- throw new Error("Error fetching traces");
5139
- }
5140
- const refinedTraces = refineTraces(res?.traces || [], isWorkflow);
5141
- return refinedTraces;
5142
- } catch (error2) {
5143
- throw error2;
5144
- }
5145
- }, [client, componentName, isWorkflow]);
5146
- const onSuccess = React.useCallback(
5147
- (newTraces) => {
5148
- if (newTraces.length > 0) {
5149
- setTraces(() => newTraces);
5150
- setTraceContextTraces(() => newTraces);
5151
- }
5152
- },
5153
- [setTraceContextTraces]
5154
- );
5155
- const onError = React.useCallback((error2) => {
5156
- sonner.toast.error(error2.message);
5157
- }, []);
5158
- const shouldContinue = React.useCallback(() => {
5159
- return true;
5160
- }, []);
5161
- const { firstCallLoading, error } = usePolling({
5162
- fetchFn,
5163
- interval: 3e3,
5164
- onSuccess,
5165
- onError,
5166
- shouldContinue,
5167
- enabled: true
5168
- });
5169
- return { traces, firstCallLoading, error };
5170
- };
5171
-
5172
- function AgentTraces({
5173
- agentName,
5174
- baseUrl,
5175
- sidebarChild
5176
- }) {
5177
- return /* @__PURE__ */ jsxRuntime.jsx(TraceProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(AgentTracesInner, { agentName, baseUrl, sidebarChild }) });
5178
- }
5179
- function AgentTracesInner({
5180
- agentName,
5181
- baseUrl,
5182
- sidebarChild
5183
- }) {
5184
- const { traces, error, firstCallLoading } = useTraces(agentName, baseUrl);
5185
- const { isOpen: open } = React.useContext(TraceContext);
5186
- if (firstCallLoading) {
5187
- return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "flex-1 relative overflow-hidden h-full", children: [
5188
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-[calc(100%_-_325px)]", children: /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
5189
- /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { className: "sticky top-0 z-10 bg-[#0F0F0F]", children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: "border-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
5190
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Trace" }),
5191
- /* @__PURE__ */ jsxRuntime.jsxs(TableHead, { className: "text-mastra-el-3 flex items-center gap-1 h-10", children: [
5192
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Braces, { className: "h-3 w-3" }),
5193
- " Trace Id"
5194
- ] }),
5195
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Started" }),
5196
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Total Duration" })
5197
- ] }) }),
5198
- /* @__PURE__ */ jsxRuntime.jsx(TableBody, { className: "border-b border-gray-6", children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
5199
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-8 w-full" }) }),
5200
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-8 w-full" }) }),
5201
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-8 w-full" }) }),
5202
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-8 w-full" }) })
5203
- ] }) })
5204
- ] }) }),
5205
- /* @__PURE__ */ jsxRuntime.jsx(SidebarItems$1, { sidebarChild, className: "min-w-[325px]" })
5206
- ] });
5166
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm overflow-x-scroll", children: "N/A" });
5207
5167
  }
5208
- if (!traces || traces.length === 0) {
5209
- return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "flex-1 h-full relative overflow-hidden", children: [
5210
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-[calc(100%_-_325px)]", children: /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
5211
- /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { className: "sticky top-0 z-10 bg-[#0F0F0F]", children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: "border-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
5212
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Trace" }),
5213
- /* @__PURE__ */ jsxRuntime.jsxs(TableHead, { className: "text-mastra-el-3 flex items-center gap-1 h-10", children: [
5214
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Braces, { className: "h-3 w-3" }),
5215
- " Trace Id"
5216
- ] }),
5217
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Started" }),
5218
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Total Duration" })
5219
- ] }) }),
5220
- /* @__PURE__ */ jsxRuntime.jsx(TableBody, { className: "border-b border-gray-6", children: /* @__PURE__ */ jsxRuntime.jsx(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: /* @__PURE__ */ jsxRuntime.jsx(TableCell, { colSpan: 4, className: "h-24 text-center", children: error?.message || "No traces found" }) }) })
5221
- ] }) }),
5222
- /* @__PURE__ */ jsxRuntime.jsx(SidebarItems$1, { sidebarChild, className: "min-w-[325px]" })
5223
- ] });
5168
+ if (typeof attributes === "string") {
5169
+ try {
5170
+ const attr = JSON.parse(attributes);
5171
+ if (typeof attr === "object" || Array.isArray(attr)) {
5172
+ return /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter, { data: attr });
5173
+ }
5174
+ } catch {
5175
+ const val = attributes ? cleanString(attributes.toString()) : "N/A";
5176
+ if (keyName === "Input" && val === "[Not Serializable]") {
5177
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm overflow-x-scroll", children: "No input" });
5178
+ }
5179
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm overflow-x-scroll", children: attributes ? cleanString(attributes.toString()) : "N/A" });
5180
+ }
5224
5181
  }
5225
- return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "flex-1 h-full relative overflow-hidden", children: [
5226
- /* @__PURE__ */ jsxRuntime.jsx(Traces, { traces }),
5227
- /* @__PURE__ */ jsxRuntime.jsx(SidebarItems$1, { sidebarChild, className: cn(open ? "grid grid-cols-2 w-[60%]" : "min-w-[325px]") })
5228
- ] });
5182
+ const processedValue = attributes;
5183
+ if (Array.isArray(processedValue)) {
5184
+ if (processedValue.length === 0) return null;
5185
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 gap-3", children: processedValue.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsxRuntime.jsx(AttributesValues, { attributes: item, depth: depth + 1 }, index) }, index)) }) });
5186
+ }
5187
+ if (typeof processedValue === "object") {
5188
+ const entries = Object.entries(processedValue);
5189
+ if (entries.length === 0) return null;
5190
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: entries.map(([key, val]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 p-2 pl-0", children: [
5191
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm capitalize text-mastra-el-3", children: transformKey(key) }),
5192
+ /* @__PURE__ */ jsxRuntime.jsx(AttributesValues, { attributes: val, depth: depth + 1, keyName: transformKey(key) })
5193
+ ] }, key)) }) });
5194
+ }
5195
+ if (typeof processedValue === "boolean")
5196
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-sm", children: processedValue.toString() || "N/A" });
5197
+ if (typeof processedValue === "number") return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-sm", children: processedValue.toString() });
5198
+ if (typeof processedValue === "string")
5199
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-sm", children: processedValue ? cleanString(processedValue.toString()) : "N/A" });
5200
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400", children: String(processedValue) });
5229
5201
  }
5230
- function SidebarItems$1({ sidebarChild, className }) {
5202
+
5203
+ const TracesSidebar = ({ className, onResize, width, children }) => {
5231
5204
  const { openDetail, isOpen: open } = React.useContext(TraceContext);
5232
- const [rightSidebarWidth, setRightSidebarWidth] = React.useState(40);
5233
5205
  return /* @__PURE__ */ jsxRuntime.jsxs(
5234
5206
  MastraResizablePanel,
5235
5207
  {
5236
5208
  className: cn(
5237
- "absolute right-0 top-0 h-full z-20 overflow-x-scroll border-l-[0.5px] bg-mastra-bg-1 bg-[#121212]",
5209
+ "absolute top-0 bottom-0 right-0 h-full z-20 overflow-x-scroll border-l-[0.5px] bg-mastra-bg-1 bg-[#121212]",
5238
5210
  className
5239
5211
  ),
5240
- defaultWidth: open ? 60 : 20,
5241
- minimumWidth: open ? 50 : 20,
5242
- maximumWidth: open ? 90 : 60,
5212
+ defaultWidth: open ? 50 : 30,
5213
+ minimumWidth: open ? 50 : 30,
5214
+ maximumWidth: open ? 90 : 50,
5215
+ setCurrentWidth: onResize,
5243
5216
  children: [
5244
5217
  open && /* @__PURE__ */ jsxRuntime.jsx(
5245
5218
  "div",
5246
5219
  {
5247
5220
  className: "h-full overflow-x-scroll px-0 absolute left-0 top-0 min-w-[50%] bg-mastra-bg-1 bg-[#121212]",
5248
- style: { width: `${100 - rightSidebarWidth}%` },
5221
+ style: { width: `${width}%` },
5249
5222
  children: /* @__PURE__ */ jsxRuntime.jsx(TraceDetails, {})
5250
5223
  }
5251
5224
  ),
@@ -5260,13 +5233,33 @@ function SidebarItems$1({ sidebarChild, className }) {
5260
5233
  "unset-position": !open
5261
5234
  }),
5262
5235
  disabled: !open,
5263
- setCurrentWidth: setRightSidebarWidth,
5264
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-y-scroll", children: !openDetail ? sidebarChild : /* @__PURE__ */ jsxRuntime.jsx(SpanDetail, {}) })
5236
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-y-scroll", children: !openDetail ? children : /* @__PURE__ */ jsxRuntime.jsx(SpanDetail, {}) })
5265
5237
  }
5266
5238
  )
5267
5239
  ]
5268
5240
  }
5269
5241
  );
5242
+ };
5243
+
5244
+ function AgentTraces({ agentName, baseUrl, sidebarChild }) {
5245
+ return /* @__PURE__ */ jsxRuntime.jsx(TraceProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(AgentTracesInner, { agentName, baseUrl, sidebarChild }) });
5246
+ }
5247
+ function AgentTracesInner({ agentName, baseUrl, sidebarChild }) {
5248
+ const [sidebarWidth, setSidebarWidth] = React.useState(30);
5249
+ const { traces, firstCallLoading, error } = useTraces(agentName, baseUrl);
5250
+ const { isOpen: open } = React.useContext(TraceContext);
5251
+ return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "h-full relative overflow-hidden flex flex-row", children: [
5252
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 block mr-[30%]", children: /* @__PURE__ */ jsxRuntime.jsx(TracesTable, { traces, isLoading: firstCallLoading, error }) }),
5253
+ /* @__PURE__ */ jsxRuntime.jsx(
5254
+ TracesSidebar,
5255
+ {
5256
+ className: cn(open ? "grid grid-cols-2 w-[60%]" : "min-w-[325px]"),
5257
+ width: 100 - sidebarWidth,
5258
+ onResize: setSidebarWidth,
5259
+ children: sidebarChild
5260
+ }
5261
+ )
5262
+ ] });
5270
5263
  }
5271
5264
 
5272
5265
  const convertMessage = (message) => {
@@ -5697,105 +5690,26 @@ const NetworkChat = ({ agentId, memory }) => {
5697
5690
  return /* @__PURE__ */ jsxRuntime.jsx(MastraNetworkRuntimeProvider, { agentId, memory, children: /* @__PURE__ */ jsxRuntime.jsx(Thread, { memory, ToolFallback }) });
5698
5691
  };
5699
5692
 
5700
- function WorkflowTraces({
5701
- workflowName,
5702
- baseUrl,
5703
- sidebarChild
5704
- }) {
5693
+ function WorkflowTraces({ workflowName, baseUrl, sidebarChild }) {
5705
5694
  return /* @__PURE__ */ jsxRuntime.jsx(TraceProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowTracesInner, { workflowName, baseUrl, sidebarChild }) });
5706
5695
  }
5707
- function WorkflowTracesInner({
5708
- workflowName,
5709
- baseUrl,
5710
- sidebarChild
5711
- }) {
5696
+ function WorkflowTracesInner({ workflowName, baseUrl, sidebarChild }) {
5697
+ const [sidebarWidth, setSidebarWidth] = React.useState(30);
5712
5698
  const { traces, error, firstCallLoading } = useTraces(workflowName, baseUrl, true);
5713
5699
  const { isOpen: open } = React.useContext(TraceContext);
5714
- if (firstCallLoading) {
5715
- return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "flex-1 h-full relative overflow-hidden", children: [
5716
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-[calc(100%_-_325px)]", children: /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
5717
- /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { className: "sticky top-0 z-10 bg-[#0F0F0F]", children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: "border-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
5718
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Trace" }),
5719
- /* @__PURE__ */ jsxRuntime.jsxs(TableHead, { className: "text-mastra-el-3 flex items-center gap-1 h-10", children: [
5720
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Braces, { className: "h-3 w-3" }),
5721
- " Trace Id"
5722
- ] }),
5723
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Started" }),
5724
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Total Duration" })
5725
- ] }) }),
5726
- /* @__PURE__ */ jsxRuntime.jsx(TableBody, { className: "border-b border-gray-6", children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
5727
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-8 w-full" }) }),
5728
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-8 w-full" }) }),
5729
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-8 w-full" }) }),
5730
- /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-8 w-full" }) })
5731
- ] }) })
5732
- ] }) }),
5733
- /* @__PURE__ */ jsxRuntime.jsx(SidebarItems, { sidebarChild, className: "min-w-[325px]" })
5734
- ] });
5735
- }
5736
- if (!traces || traces.length === 0) {
5737
- return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "flex-1 h-full relative overflow-hidden", children: [
5738
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full w-[calc(100%_-_325px)]", children: /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
5739
- /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { className: "sticky top-0 z-10 bg-[#0F0F0F]", children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: "border-gray-6 border-b-[0.1px] text-[0.8125rem]", children: [
5740
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Trace" }),
5741
- /* @__PURE__ */ jsxRuntime.jsxs(TableHead, { className: "text-mastra-el-3 flex items-center gap-1 h-10", children: [
5742
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Braces, { className: "h-3 w-3" }),
5743
- " Trace Id"
5744
- ] }),
5745
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Started" }),
5746
- /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "text-mastra-el-3 h-10", children: "Total Duration" })
5747
- ] }) }),
5748
- /* @__PURE__ */ jsxRuntime.jsx(TableBody, { className: "border-b border-gray-6", children: /* @__PURE__ */ jsxRuntime.jsx(TableRow, { className: "border-b-gray-6 border-b-[0.1px] text-[0.8125rem]", children: /* @__PURE__ */ jsxRuntime.jsx(TableCell, { colSpan: 4, className: "h-24 text-center", children: error?.message || "No traces found" }) }) })
5749
- ] }) }),
5750
- /* @__PURE__ */ jsxRuntime.jsx(SidebarItems, { sidebarChild, className: "min-w-[325px]" })
5751
- ] });
5752
- }
5753
- return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "flex-1 h-full relative overflow-hidden", children: [
5754
- /* @__PURE__ */ jsxRuntime.jsx(Traces, { traces }),
5755
- /* @__PURE__ */ jsxRuntime.jsx(SidebarItems, { className: cn(open ? "grid grid-cols-2 w-[60%]" : "min-w-[325px]"), sidebarChild })
5700
+ return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "h-full relative overflow-hidden flex flex-row", children: [
5701
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 block mr-[30%]", children: /* @__PURE__ */ jsxRuntime.jsx(TracesTable, { traces, isLoading: firstCallLoading, error }) }),
5702
+ /* @__PURE__ */ jsxRuntime.jsx(
5703
+ TracesSidebar,
5704
+ {
5705
+ className: cn(open ? "grid grid-cols-2 w-[60%]" : "min-w-[325px]"),
5706
+ width: 100 - sidebarWidth,
5707
+ onResize: setSidebarWidth,
5708
+ children: sidebarChild
5709
+ }
5710
+ )
5756
5711
  ] });
5757
5712
  }
5758
- function SidebarItems({ sidebarChild, className }) {
5759
- const { openDetail, isOpen: open } = React.useContext(TraceContext);
5760
- const [rightSidebarWidth, setRightSidebarWidth] = React.useState(40);
5761
- return /* @__PURE__ */ jsxRuntime.jsxs(
5762
- MastraResizablePanel,
5763
- {
5764
- className: cn(
5765
- "absolute right-0 top-0 h-full z-20 overflow-x-scroll border-l-[0.5px] bg-mastra-bg-1 bg-[#121212]",
5766
- className
5767
- ),
5768
- defaultWidth: open ? 60 : 20,
5769
- minimumWidth: open ? 50 : 20,
5770
- maximumWidth: open ? 90 : 60,
5771
- children: [
5772
- open && /* @__PURE__ */ jsxRuntime.jsx(
5773
- "div",
5774
- {
5775
- className: "h-full overflow-x-scroll px-0 absolute left-0 top-0 min-w-[50%] bg-mastra-bg-1 bg-[#121212]",
5776
- style: { width: `${100 - rightSidebarWidth}%` },
5777
- children: /* @__PURE__ */ jsxRuntime.jsx(TraceDetails, {})
5778
- }
5779
- ),
5780
- /* @__PURE__ */ jsxRuntime.jsx(
5781
- MastraResizablePanel,
5782
- {
5783
- defaultWidth: 50,
5784
- minimumWidth: 30,
5785
- maximumWidth: 80,
5786
- className: cn("h-full overflow-y-hidden border-l-[0.5px] right-0 top-0 z-20 bg-mastra-bg-1 bg-[#121212]", {
5787
- absolute: open,
5788
- "unset-position": !open
5789
- }),
5790
- disabled: !open,
5791
- setCurrentWidth: setRightSidebarWidth,
5792
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-y-scroll", children: !openDetail ? sidebarChild : /* @__PURE__ */ jsxRuntime.jsx(SpanDetail, {}) })
5793
- }
5794
- )
5795
- ]
5796
- }
5797
- );
5798
- }
5799
5713
 
5800
5714
  const useWorkflow = (workflowId, baseUrl) => {
5801
5715
  const [workflow, setWorkflow] = React.useState(null);
@@ -6392,6 +6306,43 @@ DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
6392
6306
  const DialogDescription = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
6393
6307
  DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
6394
6308
 
6309
+ const ScrollArea = React__namespace.forwardRef(
6310
+ ({ className, children, viewPortClassName, maxHeight, autoScroll = false, ...props }, ref) => {
6311
+ const areaRef = React__namespace.useRef(null);
6312
+ useAutoscroll(areaRef, { enabled: autoScroll });
6313
+ return /* @__PURE__ */ jsxRuntime.jsxs(ScrollAreaPrimitive__namespace.Root, { ref, className: cn("relative overflow-hidden", className), ...props, children: [
6314
+ /* @__PURE__ */ jsxRuntime.jsx(
6315
+ ScrollAreaPrimitive__namespace.Viewport,
6316
+ {
6317
+ ref: areaRef,
6318
+ className: cn("h-full w-full rounded-[inherit] [&>div]:!block", viewPortClassName),
6319
+ style: maxHeight ? { maxHeight } : void 0,
6320
+ children
6321
+ }
6322
+ ),
6323
+ /* @__PURE__ */ jsxRuntime.jsx(ScrollBar, {}),
6324
+ /* @__PURE__ */ jsxRuntime.jsx(ScrollAreaPrimitive__namespace.Corner, {})
6325
+ ] });
6326
+ }
6327
+ );
6328
+ ScrollArea.displayName = ScrollAreaPrimitive__namespace.Root.displayName;
6329
+ const ScrollBar = React__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
6330
+ ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
6331
+ {
6332
+ ref,
6333
+ orientation,
6334
+ className: cn(
6335
+ "flex touch-none select-none transition-colors",
6336
+ orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
6337
+ orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
6338
+ className
6339
+ ),
6340
+ ...props,
6341
+ children: /* @__PURE__ */ jsxRuntime.jsx(ScrollAreaPrimitive__namespace.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
6342
+ }
6343
+ ));
6344
+ ScrollBar.displayName = ScrollAreaPrimitive__namespace.ScrollAreaScrollbar.displayName;
6345
+
6395
6346
  function WorkflowConditionNode({ data }) {
6396
6347
  const { conditions } = data;
6397
6348
  const [open, setOpen] = React.useState(true);
@@ -7182,7 +7133,7 @@ const SelectField = ({ field, inputProps, error, id }) => {
7182
7133
  const syntheticEvent = {
7183
7134
  target: {
7184
7135
  value,
7185
- name: field.key
7136
+ name: inputProps.name
7186
7137
  }
7187
7138
  };
7188
7139
  props.onChange(syntheticEvent);
@@ -7671,100 +7622,6 @@ function WorkflowTrigger({
7671
7622
  ] }) });
7672
7623
  }
7673
7624
 
7674
- const rowSize = {
7675
- default: "[&>tbody>tr]:h-table-row",
7676
- small: "[&>tbody>tr]:h-table-row-small"
7677
- };
7678
- const Table = ({ className, children, size = "default" }) => {
7679
- return /* @__PURE__ */ jsxRuntime.jsx("table", { className: clsx("w-full", rowSize[size], className), children });
7680
- };
7681
- const Thead = ({ className, children }) => {
7682
- return /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { className: clsx("h-table-header border-b-sm border-border1", className), children }) });
7683
- };
7684
- const Th = ({ className, children, ...props }) => {
7685
- return /* @__PURE__ */ jsxRuntime.jsx(
7686
- "th",
7687
- {
7688
- className: clsx("text-icon3 text-ui-sm h-full text-left font-normal uppercase first:pl-5 last:pr-5", className),
7689
- ...props,
7690
- children
7691
- }
7692
- );
7693
- };
7694
- const Tbody = ({ className, children }) => {
7695
- return /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: clsx("", className), children });
7696
- };
7697
- const Row = ({ className, children, selected = false }) => {
7698
- return /* @__PURE__ */ jsxRuntime.jsx("tr", { className: clsx("border-b-sm border-border1 hover:bg-surface3", selected && "bg-surface4", className), children });
7699
- };
7700
-
7701
- const sizes = {
7702
- default: "[&>svg]:h-icon-default [&>svg]:w-icon-default",
7703
- lg: "[&>svg]:h-icon-lg [&>svg]:w-icon-lg"
7704
- };
7705
- const Icon = ({ children, className, size = "default", ...props }) => {
7706
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx(sizes[size], className), ...props, children });
7707
- };
7708
-
7709
- const variants = {
7710
- "header-md": "text-header-md leading-header-md",
7711
- "ui-lg": "text-ui-lg leading-ui-lg",
7712
- "ui-md": "text-ui-md leading-ui-md",
7713
- "ui-sm": "text-ui-sm leading-ui-sm",
7714
- "ui-xs": "text-ui-xs leading-ui-xs"
7715
- };
7716
- const fonts = {
7717
- mono: "font-mono"
7718
- };
7719
- const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) => {
7720
- return /* @__PURE__ */ jsxRuntime.jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
7721
- };
7722
-
7723
- const formatDateCell = (date) => {
7724
- const month = new Intl.DateTimeFormat("en-US", { month: "short" }).format(date).toUpperCase();
7725
- const day = date.getDate();
7726
- const formattedDay = `${month} ${day}`;
7727
- const time = new Intl.DateTimeFormat("en-US", {
7728
- hour: "2-digit",
7729
- minute: "2-digit",
7730
- second: "2-digit",
7731
- hour12: false
7732
- // Use 24-hour format
7733
- }).format(date);
7734
- return { day: formattedDay, time };
7735
- };
7736
-
7737
- const Cell = ({ className, children, ...props }) => {
7738
- 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 }) });
7739
- };
7740
- const TxtCell = ({ className, children }) => {
7741
- return /* @__PURE__ */ jsxRuntime.jsx(Cell, { className, children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", className: "w-full truncate", children }) });
7742
- };
7743
- const UnitCell = ({ className, children, unit }) => {
7744
- return /* @__PURE__ */ jsxRuntime.jsx(Cell, { className, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center", children: [
7745
- /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", className: "shrink-0", children }),
7746
- /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3 w-full truncate", children: unit })
7747
- ] }) });
7748
- };
7749
- const DateTimeCell = ({ dateTime, ...props }) => {
7750
- const { day, time } = formatDateCell(dateTime);
7751
- return /* @__PURE__ */ jsxRuntime.jsx(Cell, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0", children: [
7752
- /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-sm", className: "text-icon3", children: day }),
7753
- " ",
7754
- /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", children: time })
7755
- ] }) });
7756
- };
7757
- const EntryCell = ({ name, description, icon, meta, ...props }) => {
7758
- return /* @__PURE__ */ jsxRuntime.jsx(Cell, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[14px]", children: [
7759
- /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "lg", className: "text-icon5", children: icon }),
7760
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-0", children: [
7761
- /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-md", className: "text-icon6 font-medium !leading-tight", children: name }),
7762
- description && /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "span", variant: "ui-xs", className: "text-icon3 w-full max-w-[300px] truncate !leading-tight", children: description })
7763
- ] }),
7764
- meta
7765
- ] }) });
7766
- };
7767
-
7768
7625
  const DataTable = ({
7769
7626
  columns,
7770
7627
  data,
@@ -7837,31 +7694,6 @@ const DataTable = ({
7837
7694
  ] });
7838
7695
  };
7839
7696
 
7840
- const variantClasses = {
7841
- default: "text-icon3",
7842
- success: "text-accent1",
7843
- error: "text-accent2",
7844
- info: "text-accent3"
7845
- };
7846
- const Badge = ({ icon, variant = "default", className, children, ...props }) => {
7847
- return /* @__PURE__ */ jsxRuntime.jsxs(
7848
- "div",
7849
- {
7850
- className: clsx(
7851
- "bg-surface4 text-ui-sm gap-md h-badge-default inline-flex items-center rounded-md",
7852
- icon ? "pl-md pr-1.5" : "px-1.5",
7853
- icon || variant === "default" ? "text-icon5" : variantClasses[variant],
7854
- className
7855
- ),
7856
- ...props,
7857
- children: [
7858
- icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: variantClasses[variant], children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: icon }) }),
7859
- children
7860
- ]
7861
- }
7862
- );
7863
- };
7864
-
7865
7697
  const Button = ({ className, as, ...props }) => {
7866
7698
  const Component = as || "button";
7867
7699
  return /* @__PURE__ */ jsxRuntime.jsx(