@mastra/playground-ui 6.4.1 → 6.5.0-alpha.1

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/index.cjs.js +1869 -1918
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.es.js +1844 -1902
  5. package/dist/index.es.js.map +1 -1
  6. package/dist/src/components/assistant-ui/messages/assistant-message.d.ts +1 -3
  7. package/dist/src/components/assistant-ui/thread.d.ts +1 -3
  8. package/dist/src/components/assistant-ui/tools/badges/agent-badge.d.ts +5 -8
  9. package/dist/src/components/assistant-ui/tools/badges/badge-wrapper.d.ts +2 -1
  10. package/dist/src/components/assistant-ui/tools/badges/tool-badge.d.ts +3 -5
  11. package/dist/src/components/assistant-ui/tools/badges/workflow-badge.d.ts +3 -5
  12. package/dist/src/components/assistant-ui/tools/tool-fallback.d.ts +6 -2
  13. package/dist/src/components/ui/containers/buttons-group.d.ts +6 -0
  14. package/dist/src/components/ui/containers/index.d.ts +2 -0
  15. package/dist/src/components/ui/containers/sections.d.ts +6 -0
  16. package/dist/src/components/ui/elements/entry-list/entry-list-entries-skeleton.d.ts +6 -0
  17. package/dist/src/components/ui/elements/entry-list/entry-list-entries.d.ts +6 -0
  18. package/dist/src/components/ui/elements/entry-list/entry-list-entry-col.d.ts +7 -0
  19. package/dist/src/components/ui/elements/entry-list/entry-list-entry.d.ts +11 -0
  20. package/dist/src/components/ui/elements/entry-list/entry-list-header.d.ts +6 -0
  21. package/dist/src/components/ui/elements/entry-list/entry-list-message.d.ts +8 -0
  22. package/dist/src/components/ui/elements/entry-list/entry-list-next-page-loading.d.ts +9 -0
  23. package/dist/src/components/ui/elements/entry-list/entry-list-pagination.d.ts +8 -0
  24. package/dist/src/components/ui/elements/entry-list/entry-list-root.d.ts +6 -0
  25. package/dist/src/components/ui/elements/entry-list/entry-list-skeleton.d.ts +2 -0
  26. package/dist/src/components/ui/elements/entry-list/entry-list-trim.d.ts +6 -0
  27. package/dist/src/components/ui/elements/entry-list/entry-list.d.ts +20 -18
  28. package/dist/src/components/ui/elements/entry-list/helpers.d.ts +10 -0
  29. package/dist/src/components/ui/elements/entry-list/index.d.ts +3 -4
  30. package/dist/src/components/ui/elements/entry-list/shared.d.ts +1 -5
  31. package/dist/src/components/ui/elements/entry-list/types.d.ts +5 -0
  32. package/dist/src/components/ui/elements/headers/page-header.d.ts +2 -2
  33. package/dist/src/components/ui/elements/index.d.ts +3 -0
  34. package/dist/src/components/ui/elements/main-sidebar/index.d.ts +1 -0
  35. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-bottom.d.ts +6 -0
  36. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-context.d.ts +12 -0
  37. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav-header.d.ts +8 -0
  38. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav-link.d.ts +17 -0
  39. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav-list.d.ts +12 -0
  40. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav-section.d.ts +13 -0
  41. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav-separator.d.ts +5 -0
  42. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-nav.d.ts +6 -0
  43. package/dist/src/components/ui/elements/main-sidebar/main-sidebar-root.d.ts +6 -0
  44. package/dist/src/components/ui/elements/main-sidebar/main-sidebar.d.ts +21 -0
  45. package/dist/src/components/ui/elements/notification/index.d.ts +1 -0
  46. package/dist/src/components/ui/elements/notification/notification.d.ts +9 -0
  47. package/dist/src/components/ui/elements/section/index.d.ts +1 -0
  48. package/dist/src/components/ui/elements/section/section-header.d.ts +7 -0
  49. package/dist/src/components/ui/elements/section/section-heading.d.ts +8 -0
  50. package/dist/src/components/ui/elements/section/section-root.d.ts +5 -0
  51. package/dist/src/components/ui/elements/section/section.d.ts +8 -0
  52. package/dist/src/components/ui/elements/side-dialog/index.d.ts +0 -6
  53. package/dist/src/components/ui/elements/side-dialog/side-dialog-code-section.d.ts +3 -1
  54. package/dist/src/components/ui/elements/side-dialog/side-dialog-content.d.ts +1 -14
  55. package/dist/src/components/ui/elements/side-dialog/side-dialog-nav.d.ts +6 -0
  56. package/dist/src/components/ui/elements/side-dialog/side-dialog-root.d.ts +11 -0
  57. package/dist/src/components/ui/elements/side-dialog/side-dialog-top.d.ts +2 -4
  58. package/dist/src/components/ui/elements/side-dialog/side-dialog.d.ts +16 -12
  59. package/dist/src/components/ui/elements/tabs/tabs-content.d.ts +7 -0
  60. package/dist/src/components/ui/elements/tabs/tabs-list.d.ts +7 -0
  61. package/dist/src/components/ui/elements/tabs/tabs-root.d.ts +9 -0
  62. package/dist/src/components/ui/elements/tabs/tabs-tab.d.ts +8 -0
  63. package/dist/src/components/ui/elements/tabs/tabs.d.ts +20 -36
  64. package/dist/src/domains/agents/components/agent-chat.d.ts +1 -1
  65. package/dist/src/domains/agents/index.d.ts +1 -0
  66. package/dist/src/domains/agents/utils/__tests__/extractPrompt.test.d.ts +1 -0
  67. package/dist/src/domains/agents/utils/extractPrompt.d.ts +2 -0
  68. package/dist/src/domains/observability/components/index.d.ts +4 -0
  69. package/dist/src/domains/observability/components/span-details.d.ts +1 -2
  70. package/dist/src/domains/observability/components/span-dialog.d.ts +8 -2
  71. package/dist/src/domains/observability/components/span-score-list.d.ts +17 -0
  72. package/dist/src/domains/observability/components/span-scoring.d.ts +6 -0
  73. package/dist/src/domains/observability/components/span-tabs.d.ts +16 -0
  74. package/dist/src/domains/observability/components/trace-dialog.d.ts +4 -2
  75. package/dist/src/domains/observability/components/trace-timeline.d.ts +1 -4
  76. package/dist/src/domains/observability/components/traces-list.d.ts +22 -0
  77. package/dist/src/domains/scores/components/score-dialog.d.ts +5 -3
  78. package/dist/src/domains/scores/components/scores-list.d.ts +21 -0
  79. package/dist/src/domains/scores/hooks/use-trace-span-scores.d.ts +7 -0
  80. package/dist/src/domains/scores/hooks/use-trigger-scorer.d.ts +1 -1
  81. package/dist/src/domains/scores/index.d.ts +2 -0
  82. package/dist/src/index.d.ts +1 -0
  83. package/dist/src/services/mastra-runtime-provider.d.ts +1 -1
  84. package/dist/src/types.d.ts +3 -1
  85. package/package.json +12 -10
  86. package/dist/src/components/ui/elements/entry-list/entry-list-cell.d.ts +0 -7
  87. package/dist/src/components/ui/elements/entry-list/entry-list-item.d.ts +0 -9
  88. package/dist/src/components/ui/elements/entry-list/entry-list-page-header.d.ts +0 -8
  89. package/dist/src/domains/scores/components/scorers-dropdown.d.ts +0 -8
  90. package/dist/src/services/agent-network-message.d.ts +0 -2
  91. package/dist/src/services/stream-chunk-message.d.ts +0 -32
  92. package/dist/src/services/vnext-message-provider.d.ts +0 -10
package/dist/index.cjs.js CHANGED
@@ -64,7 +64,6 @@ const dnd = require('@hello-pangea/dnd');
64
64
  const SwitchPrimitives = require('@radix-ui/react-switch');
65
65
  const AlertDialogPrimitive = require('@radix-ui/react-alert-dialog');
66
66
  const format = require('date-fns/format');
67
- const DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
68
67
 
69
68
  function _interopNamespaceDefault(e) {
70
69
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
@@ -100,7 +99,6 @@ const VisuallyHidden__namespace = /*#__PURE__*/_interopNamespaceDefault(Visually
100
99
  const HoverCard__namespace = /*#__PURE__*/_interopNamespaceDefault(HoverCard);
101
100
  const SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespaceDefault(SwitchPrimitives);
102
101
  const AlertDialogPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(AlertDialogPrimitive);
103
- const DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(DropdownMenuPrimitive);
104
102
 
105
103
  function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
106
104
 
@@ -3450,42 +3448,6 @@ const defaultComponents = reactMarkdown.unstable_memoizeMarkdownComponents({
3450
3448
  img: ImageWithFallback
3451
3449
  });
3452
3450
 
3453
- const ErrorAwareText = () => {
3454
- const part = react.useMessagePart();
3455
- const text = part.text || "";
3456
- try {
3457
- const trimmedText = text.trim();
3458
- if (trimmedText.startsWith("__ERROR__:")) {
3459
- const errorMessage = trimmedText.substring("__ERROR__:".length);
3460
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3 p-4 rounded-lg bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-900/50", children: [
3461
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-5 h-5 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0" }),
3462
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
3463
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-red-800 dark:text-red-200 mb-1", children: "Error" }),
3464
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: errorMessage })
3465
- ] })
3466
- ] });
3467
- } else if (trimmedText.startsWith("Error:")) {
3468
- const errorMessage = trimmedText.substring("Error:".length).trim();
3469
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3 p-4 rounded-lg bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-900/50", children: [
3470
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-5 h-5 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0" }),
3471
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
3472
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-red-800 dark:text-red-200 mb-1", children: "Error" }),
3473
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: errorMessage })
3474
- ] })
3475
- ] });
3476
- }
3477
- return /* @__PURE__ */ jsxRuntime.jsx(MarkdownText, {});
3478
- } catch (error) {
3479
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3 p-4 rounded-lg bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-900/50", children: [
3480
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-5 h-5 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0" }),
3481
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
3482
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-red-800 dark:text-red-200 mb-1", children: "Error" }),
3483
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: String(text) })
3484
- ] })
3485
- ] });
3486
- }
3487
- };
3488
-
3489
3451
  const AgentIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "17", height: "16", viewBox: "0 0 17 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
3490
3452
  /* @__PURE__ */ jsxRuntime.jsx(
3491
3453
  "path",
@@ -4278,6 +4240,91 @@ const AgentNetworkCoinIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", {
4278
4240
  ) }) })
4279
4241
  ] });
4280
4242
 
4243
+ const variants = {
4244
+ "header-md": "text-header-md leading-header-md",
4245
+ "ui-lg": "text-ui-lg leading-ui-lg",
4246
+ "ui-md": "text-ui-md leading-ui-md",
4247
+ "ui-sm": "text-ui-sm leading-ui-sm",
4248
+ "ui-xs": "text-ui-xs leading-ui-xs"
4249
+ };
4250
+ const fonts = {
4251
+ mono: "font-mono"
4252
+ };
4253
+ const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) => {
4254
+ return /* @__PURE__ */ jsxRuntime.jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
4255
+ };
4256
+
4257
+ const variantClasses$3 = {
4258
+ warning: "bg-yellow-900/20 border-sm border-yellow-200 text-yellow-200",
4259
+ destructive: "bg-red-900/20 border-sm border-red-200 text-red-200"
4260
+ };
4261
+ const variantIcons = {
4262
+ warning: lucideReact.TriangleAlert,
4263
+ destructive: lucideReact.AlertCircle
4264
+ };
4265
+ const Alert$1 = ({ children, variant = "destructive" }) => {
4266
+ const Ico = variantIcons[variant];
4267
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx(variantClasses$3[variant], "p-2 rounded-md"), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
4268
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "mt-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(Ico, {}) }),
4269
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children })
4270
+ ] }) });
4271
+ };
4272
+ const AlertTitle$1 = ({ children, as: As = "h5" }) => {
4273
+ return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: As, variant: "ui-md", className: "font-semibold", children });
4274
+ };
4275
+ const AlertDescription$1 = ({ children, as: As = "p" }) => {
4276
+ return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: As, variant: "ui-sm", children });
4277
+ };
4278
+
4279
+ const ErrorAwareText = () => {
4280
+ const part = react.useMessagePart();
4281
+ const text = part.text || "";
4282
+ const metadata = part.metadata || {};
4283
+ if (metadata?.status === "warning") {
4284
+ return /* @__PURE__ */ jsxRuntime.jsxs(Alert$1, { variant: "warning", children: [
4285
+ /* @__PURE__ */ jsxRuntime.jsx(AlertTitle$1, { as: "h5", children: "Warning" }),
4286
+ /* @__PURE__ */ jsxRuntime.jsx(AlertDescription$1, { as: "p", children: text })
4287
+ ] });
4288
+ }
4289
+ if (metadata?.status === "error") {
4290
+ return /* @__PURE__ */ jsxRuntime.jsxs(Alert$1, { variant: "destructive", children: [
4291
+ /* @__PURE__ */ jsxRuntime.jsx(AlertTitle$1, { as: "h5", children: "Error" }),
4292
+ /* @__PURE__ */ jsxRuntime.jsx(AlertDescription$1, { as: "p", children: text })
4293
+ ] });
4294
+ }
4295
+ try {
4296
+ const trimmedText = text.trim();
4297
+ if (trimmedText.startsWith("__ERROR__:")) {
4298
+ const errorMessage = trimmedText.substring("__ERROR__:".length);
4299
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3 p-4 rounded-lg bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-900/50", children: [
4300
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-5 h-5 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0" }),
4301
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
4302
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-red-800 dark:text-red-200 mb-1", children: "Error" }),
4303
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: errorMessage })
4304
+ ] })
4305
+ ] });
4306
+ } else if (trimmedText.startsWith("Error:")) {
4307
+ const errorMessage = trimmedText.substring("Error:".length).trim();
4308
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3 p-4 rounded-lg bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-900/50", children: [
4309
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-5 h-5 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0" }),
4310
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
4311
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-red-800 dark:text-red-200 mb-1", children: "Error" }),
4312
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: errorMessage })
4313
+ ] })
4314
+ ] });
4315
+ }
4316
+ return /* @__PURE__ */ jsxRuntime.jsx(MarkdownText, {});
4317
+ } catch (error) {
4318
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3 p-4 rounded-lg bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-900/50", children: [
4319
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-5 h-5 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0" }),
4320
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
4321
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-red-800 dark:text-red-200 mb-1", children: "Error" }),
4322
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: String(text) })
4323
+ ] })
4324
+ ] });
4325
+ }
4326
+ };
4327
+
4281
4328
  function useCopyToClipboard({ text, copyMessage = "Copied to clipboard!" }) {
4282
4329
  const [isCopied, setIsCopied] = React.useState(false);
4283
4330
  const timeoutRef = React.useRef(null);
@@ -4343,12 +4390,12 @@ const SyntaxHighlighter$2 = ({
4343
4390
  const formattedCode = JSON.stringify(data, null, 2);
4344
4391
  const theme = useCodemirrorTheme$2();
4345
4392
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx("rounded-md bg-surface4 p-1 font-mono relative", className), children: [
4346
- /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { content: formattedCode, className: "absolute top-2 right-2 z-[9999]" }),
4393
+ /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { content: formattedCode, className: "absolute top-2 right-2 z-20" }),
4347
4394
  /* @__PURE__ */ jsxRuntime.jsx(CodeMirror, { value: formattedCode, theme, extensions: [langJson.jsonLanguage] })
4348
4395
  ] });
4349
4396
  };
4350
4397
 
4351
- const variantClasses$3 = {
4398
+ const variantClasses$2 = {
4352
4399
  default: "text-icon3",
4353
4400
  success: "text-accent1",
4354
4401
  error: "text-accent2",
@@ -4361,12 +4408,12 @@ const Badge$1 = ({ icon, variant = "default", className, children, ...props }) =
4361
4408
  className: clsx(
4362
4409
  "font-mono bg-surface4 text-ui-sm gap-md h-badge-default inline-flex items-center rounded-md shrink-0",
4363
4410
  icon ? "pl-md pr-1.5" : "px-1.5",
4364
- icon || variant === "default" ? "text-icon5" : variantClasses$3[variant],
4411
+ icon || variant === "default" ? "text-icon5" : variantClasses$2[variant],
4365
4412
  className
4366
4413
  ),
4367
4414
  ...props,
4368
4415
  children: [
4369
- icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: variantClasses$3[variant], children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: icon }) }),
4416
+ icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: variantClasses$2[variant], children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: icon }) }),
4370
4417
  children
4371
4418
  ]
4372
4419
  }
@@ -4379,10 +4426,11 @@ const BadgeWrapper = ({
4379
4426
  icon,
4380
4427
  title,
4381
4428
  collapsible = true,
4382
- extraInfo
4429
+ extraInfo,
4430
+ "data-testid": dataTestId
4383
4431
  }) => {
4384
4432
  const [isCollapsed, setIsCollapsed] = React.useState(initialCollapsed);
4385
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", children: [
4433
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", "data-testid": dataTestId, children: [
4386
4434
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row gap-2 items-center justify-between", children: [
4387
4435
  /* @__PURE__ */ jsxRuntime.jsxs(
4388
4436
  "button",
@@ -4453,20 +4501,6 @@ DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
4453
4501
  const DialogDescription = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
4454
4502
  DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
4455
4503
 
4456
- const variants = {
4457
- "header-md": "text-header-md leading-header-md",
4458
- "ui-lg": "text-ui-lg leading-ui-lg",
4459
- "ui-md": "text-ui-md leading-ui-md",
4460
- "ui-sm": "text-ui-sm leading-ui-sm",
4461
- "ui-xs": "text-ui-xs leading-ui-xs"
4462
- };
4463
- const fonts = {
4464
- mono: "font-mono"
4465
- };
4466
- const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) => {
4467
- return /* @__PURE__ */ jsxRuntime.jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
4468
- };
4469
-
4470
4504
  const NetworkChoiceMetadata = ({ selectionReason, open, onOpenChange, input }) => {
4471
4505
  let inputSlot = null;
4472
4506
  if (input) {
@@ -4512,7 +4546,7 @@ const NetworkChoiceMetadataDialogTrigger = ({
4512
4546
  ] });
4513
4547
  };
4514
4548
 
4515
- const ToolBadge = ({ toolName, args, result, networkMetadata, toolOutput }) => {
4549
+ const ToolBadge = ({ toolName, args, result, metadata, toolOutput }) => {
4516
4550
  let argSlot = null;
4517
4551
  try {
4518
4552
  const { __mastraMetadata: _, ...formattedArgs } = typeof args === "object" ? args : JSON.parse(args);
@@ -4521,16 +4555,19 @@ const ToolBadge = ({ toolName, args, result, networkMetadata, toolOutput }) => {
4521
4555
  argSlot = /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap", children: args });
4522
4556
  }
4523
4557
  let resultSlot = typeof result === "string" ? /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap bg-surface4 p-4 rounded-md", children: result }) : /* @__PURE__ */ jsxRuntime.jsx(SyntaxHighlighter$2, { data: result });
4558
+ const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
4559
+ const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
4524
4560
  return /* @__PURE__ */ jsxRuntime.jsx(
4525
4561
  BadgeWrapper,
4526
4562
  {
4563
+ "data-testid": "tool-badge",
4527
4564
  icon: /* @__PURE__ */ jsxRuntime.jsx(ToolsIcon, { className: "text-[#ECB047]" }),
4528
4565
  title: toolName,
4529
- extraInfo: networkMetadata && /* @__PURE__ */ jsxRuntime.jsx(
4566
+ extraInfo: metadata?.mode === "network" && /* @__PURE__ */ jsxRuntime.jsx(
4530
4567
  NetworkChoiceMetadataDialogTrigger,
4531
4568
  {
4532
- selectionReason: networkMetadata?.selectionReason || "",
4533
- input: networkMetadata?.input
4569
+ selectionReason: selectionReason || "",
4570
+ input: agentNetworkInput
4534
4571
  }
4535
4572
  ),
4536
4573
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
@@ -5136,7 +5173,7 @@ const sizeClasses = {
5136
5173
  md: "h-button-md gap-md",
5137
5174
  lg: "h-button-lg gap-lg"
5138
5175
  };
5139
- const variantClasses$2 = {
5176
+ const variantClasses$1 = {
5140
5177
  default: "bg-surface2 hover:bg-surface4 text-icon3 hover:text-icon6",
5141
5178
  light: "bg-surface3 hover:bg-surface5 text-icon6"
5142
5179
  };
@@ -5147,7 +5184,7 @@ const Button$1 = ({ className, as, size = "md", variant = "default", ...props })
5147
5184
  {
5148
5185
  className: clsx(
5149
5186
  "bg-surface2 border-sm border-border1 px-lg text-ui-md inline-flex items-center justify-center rounded-md border",
5150
- variantClasses$2[variant],
5187
+ variantClasses$1[variant],
5151
5188
  sizeClasses[size],
5152
5189
  className,
5153
5190
  {
@@ -6106,20 +6143,20 @@ const alertVariants = cva(
6106
6143
  }
6107
6144
  }
6108
6145
  );
6109
- const Alert$1 = React__namespace.forwardRef(({ className, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, role: "alert", className: cn(alertVariants({ variant }), className), ...props }));
6110
- Alert$1.displayName = "Alert";
6111
- const AlertTitle$1 = React__namespace.forwardRef(
6146
+ const Alert = React__namespace.forwardRef(({ className, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, role: "alert", className: cn(alertVariants({ variant }), className), ...props }));
6147
+ Alert.displayName = "Alert";
6148
+ const AlertTitle = React__namespace.forwardRef(
6112
6149
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("h5", { ref, className: cn("mb-1 font-medium leading-none tracking-tight", className), ...props })
6113
6150
  );
6114
- AlertTitle$1.displayName = "AlertTitle";
6115
- const AlertDescription$1 = React__namespace.forwardRef(
6151
+ AlertTitle.displayName = "AlertTitle";
6152
+ const AlertDescription = React__namespace.forwardRef(
6116
6153
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("text-sm [&_p]:leading-relaxed", className), ...props })
6117
6154
  );
6118
- AlertDescription$1.displayName = "AlertDescription";
6155
+ AlertDescription.displayName = "AlertDescription";
6119
6156
 
6120
- const ErrorMessage = ({ error }) => /* @__PURE__ */ jsxRuntime.jsxs(Alert$1, { variant: "destructive", children: [
6157
+ const ErrorMessage = ({ error }) => /* @__PURE__ */ jsxRuntime.jsxs(Alert, { variant: "destructive", children: [
6121
6158
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-4 w-4" }),
6122
- /* @__PURE__ */ jsxRuntime.jsx(AlertTitle$1, { children: error })
6159
+ /* @__PURE__ */ jsxRuntime.jsx(AlertTitle, { children: error })
6123
6160
  ] });
6124
6161
 
6125
6162
  const SubmitButton = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(Button$2, { type: "submit", children });
@@ -6901,7 +6938,8 @@ function DynamicForm({
6901
6938
  },
6902
6939
  defaultValues: isNotZodObject ? defaultValues ? { "​": defaultValues } : void 0 : defaultValues,
6903
6940
  formProps: {
6904
- className
6941
+ className,
6942
+ noValidate: true
6905
6943
  },
6906
6944
  uiComponents: {
6907
6945
  SubmitButton: ({ children }) => onSubmit ? /* @__PURE__ */ jsxRuntime.jsx(Button$1, { variant: "light", className: "w-full", size: "lg", disabled: isSubmitLoading, children: isSubmitLoading ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin" }) }) : submitButtonLabel || children }) : null
@@ -7694,7 +7732,7 @@ function WorkflowTable({ workflows, isLoading }) {
7694
7732
  return /* @__PURE__ */ jsxRuntime.jsx(EmptyWorkflowsTable, {});
7695
7733
  }
7696
7734
  const filteredRows = rows.filter((row) => row.original.name.toLowerCase().includes(search.toLowerCase()));
7697
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7735
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
7698
7736
  /* @__PURE__ */ jsxRuntime.jsx(SearchbarWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(Searchbar, { onSearch: setSearch, label: "Search workflows", placeholder: "Search workflows" }) }),
7699
7737
  isLoading ? /* @__PURE__ */ jsxRuntime.jsx(WorkflowTableSkeleton, {}) : /* @__PURE__ */ jsxRuntime.jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
7700
7738
  /* @__PURE__ */ jsxRuntime.jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsxRuntime.jsx(Th, { style: { width: header.index === 0 ? "auto" : header.column.getSize() }, children: reactTable.flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
@@ -7736,24 +7774,27 @@ const EmptyWorkflowsTable = () => /* @__PURE__ */ jsxRuntime.jsx("div", { classN
7736
7774
  }
7737
7775
  ) });
7738
7776
 
7739
- const WorkflowBadge = ({ workflow, runId, workflowId, isStreaming, networkMetadata }) => {
7777
+ const WorkflowBadge = ({ workflow, runId, workflowId, isStreaming, metadata }) => {
7740
7778
  const { data: runs, isLoading: isRunsLoading } = useWorkflowRuns(workflowId, {
7741
7779
  enabled: Boolean(runId) && !isStreaming
7742
7780
  });
7743
7781
  const run = runs?.runs.find((run2) => run2.runId === runId);
7744
7782
  const isLoading = isRunsLoading || !run;
7745
7783
  const snapshot = typeof run?.snapshot === "object" ? run?.snapshot : void 0;
7784
+ const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
7785
+ const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
7746
7786
  return /* @__PURE__ */ jsxRuntime.jsxs(
7747
7787
  BadgeWrapper,
7748
7788
  {
7789
+ "data-testid": "workflow-badge",
7749
7790
  icon: /* @__PURE__ */ jsxRuntime.jsx(WorkflowIcon, { className: "text-accent3" }),
7750
7791
  title: workflow.name,
7751
7792
  initialCollapsed: false,
7752
- extraInfo: networkMetadata && /* @__PURE__ */ jsxRuntime.jsx(
7793
+ extraInfo: metadata?.mode === "network" && /* @__PURE__ */ jsxRuntime.jsx(
7753
7794
  NetworkChoiceMetadataDialogTrigger,
7754
7795
  {
7755
- selectionReason: networkMetadata?.selectionReason || "",
7756
- input: networkMetadata?.input
7796
+ selectionReason: selectionReason ?? "",
7797
+ input: agentNetworkInput
7757
7798
  }
7758
7799
  ),
7759
7800
  children: [
@@ -7805,18 +7846,21 @@ const LoadingBadge = () => {
7805
7846
  );
7806
7847
  };
7807
7848
 
7808
- const AgentBadge = ({ agentId, messages = [], networkMetadata }) => {
7849
+ const AgentBadge = ({ agentId, messages = [], metadata }) => {
7850
+ const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
7851
+ const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
7809
7852
  return /* @__PURE__ */ jsxRuntime.jsx(
7810
7853
  BadgeWrapper,
7811
7854
  {
7855
+ "data-testid": "agent-badge",
7812
7856
  icon: /* @__PURE__ */ jsxRuntime.jsx(AgentIcon, { className: "text-accent1" }),
7813
7857
  title: agentId,
7814
7858
  initialCollapsed: false,
7815
- extraInfo: networkMetadata && /* @__PURE__ */ jsxRuntime.jsx(
7859
+ extraInfo: metadata?.mode === "network" && /* @__PURE__ */ jsxRuntime.jsx(
7816
7860
  NetworkChoiceMetadataDialogTrigger,
7817
7861
  {
7818
- selectionReason: networkMetadata?.selectionReason || "",
7819
- input: networkMetadata?.input
7862
+ selectionReason: selectionReason ?? "",
7863
+ input: agentNetworkInput
7820
7864
  }
7821
7865
  ),
7822
7866
  children: messages.map((message, index) => {
@@ -7835,6 +7879,9 @@ const AgentBadge = ({ agentId, messages = [], networkMetadata }) => {
7835
7879
  type: "tool-call",
7836
7880
  toolCallId: message.toolCallId,
7837
7881
  addResult: () => {
7882
+ },
7883
+ metadata: {
7884
+ mode: "stream"
7838
7885
  }
7839
7886
  }
7840
7887
  ) }, index);
@@ -7846,30 +7893,25 @@ const AgentBadge = ({ agentId, messages = [], networkMetadata }) => {
7846
7893
  const ToolFallback = ({ toolName, result, args, ...props }) => {
7847
7894
  return /* @__PURE__ */ jsxRuntime.jsx(WorkflowRunProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackInner, { toolName, result, args, ...props }) });
7848
7895
  };
7849
- const ToolFallbackInner = ({ toolName, result, args }) => {
7850
- useWorkflowStream(args.__mastraMetadata?.workflowFullState);
7896
+ const ToolFallbackInner = ({ toolName, result, args, metadata, ...props }) => {
7897
+ useWorkflowStream(result);
7851
7898
  const { data: workflow, isLoading } = useWorkflow(toolName);
7852
- const isAgent = args.__mastraMetadata?.from === "AGENT";
7899
+ const isAgent = metadata?.mode === "network" && metadata.from === "AGENT";
7853
7900
  if (isAgent) {
7854
- return /* @__PURE__ */ jsxRuntime.jsx(
7855
- AgentBadge,
7856
- {
7857
- agentId: toolName,
7858
- messages: args?.__mastraMetadata?.messages,
7859
- networkMetadata: args?.__mastraMetadata?.networkMetadata
7860
- }
7861
- );
7901
+ const messages = result?.childMessages ?? [];
7902
+ return /* @__PURE__ */ jsxRuntime.jsx(AgentBadge, { agentId: toolName, messages, metadata });
7862
7903
  }
7863
7904
  if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(LoadingBadge, {});
7864
7905
  if (workflow) {
7906
+ const isStreaming = metadata?.mode === "stream" || metadata?.mode === "network";
7865
7907
  return /* @__PURE__ */ jsxRuntime.jsx(
7866
7908
  WorkflowBadge,
7867
7909
  {
7868
7910
  workflowId: toolName,
7869
7911
  workflow,
7870
- isStreaming: args.__mastraMetadata?.isStreaming,
7912
+ isStreaming,
7871
7913
  runId: result?.runId,
7872
- networkMetadata: args?.__mastraMetadata?.networkMetadata
7914
+ metadata
7873
7915
  }
7874
7916
  );
7875
7917
  }
@@ -7879,8 +7921,8 @@ const ToolFallbackInner = ({ toolName, result, args }) => {
7879
7921
  toolName,
7880
7922
  args,
7881
7923
  result,
7882
- toolOutput: args?.__mastraMetadata?.toolOutput || [],
7883
- networkMetadata: args?.__mastraMetadata?.networkMetadata
7924
+ toolOutput: result?.toolOutput || [],
7925
+ metadata
7884
7926
  }
7885
7927
  );
7886
7928
  };
@@ -8445,32 +8487,23 @@ const ProviderLogo = ({ providerId, className = "", size = 20 }) => {
8445
8487
  );
8446
8488
  };
8447
8489
 
8448
- const statusClasses = {
8449
- warning: "bg-yellow-900/20 border-sm border-yellow-200 text-yellow-200 rounded-lg px-4 py-2 flex gap-4 items-center",
8450
- default: ""
8451
- };
8452
- const AssistantMessage = ({ ToolFallback: ToolFallbackCustom, hasModelList }) => {
8490
+ const AssistantMessage = ({ hasModelList }) => {
8453
8491
  const data = react.useMessage();
8454
8492
  const messageId = data.id;
8455
8493
  const isToolCallAndOrReasoning = data.content.every(({ type }) => type === "tool-call" || type === "reasoning");
8456
8494
  const modelMetadata = data.metadata?.custom?.modelMetadata;
8457
- const messageStatus = data.metadata?.custom?.status;
8458
- const statusClass = statusClasses[messageStatus || "default"];
8459
8495
  const showModelUsed = hasModelList && modelMetadata;
8460
8496
  return /* @__PURE__ */ jsxRuntime.jsxs(react.MessagePrimitive.Root, { className: "max-w-full", "data-message-id": messageId, children: [
8461
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx("text-icon6 text-ui-lg leading-ui-lg", statusClass), children: [
8462
- messageStatus === "warning" && /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "lg", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TriangleAlert, {}) }),
8463
- /* @__PURE__ */ jsxRuntime.jsx(
8464
- react.MessagePrimitive.Parts,
8465
- {
8466
- components: {
8467
- Text: ErrorAwareText,
8468
- tools: { Fallback: ToolFallbackCustom || ToolFallback },
8469
- Reasoning
8470
- }
8497
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-icon6 text-ui-lg leading-ui-lg", children: /* @__PURE__ */ jsxRuntime.jsx(
8498
+ react.MessagePrimitive.Parts,
8499
+ {
8500
+ components: {
8501
+ Text: ErrorAwareText,
8502
+ tools: { Fallback: ToolFallback },
8503
+ Reasoning
8471
8504
  }
8472
- )
8473
- ] }),
8505
+ }
8506
+ ) }),
8474
8507
  !isToolCallAndOrReasoning && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("h-6 pt-4 flex gap-2 items-center", { "pb-1": showModelUsed }), children: [
8475
8508
  showModelUsed && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
8476
8509
  /* @__PURE__ */ jsxRuntime.jsx(ProviderLogo, { providerId: modelMetadata.modelProvider, size: 14 }),
@@ -9067,11 +9100,11 @@ const useThreadInput = () => {
9067
9100
  return React.useContext(ThreadInputContext);
9068
9101
  };
9069
9102
 
9070
- const Thread = ({ ToolFallback, agentName, agentId, hasMemory, hasModelList }) => {
9103
+ const Thread = ({ agentName, agentId, hasMemory, hasModelList }) => {
9071
9104
  const areaRef = React.useRef(null);
9072
9105
  useAutoscroll(areaRef, { enabled: true });
9073
9106
  const WrappedAssistantMessage = (props) => {
9074
- return /* @__PURE__ */ jsxRuntime.jsx(AssistantMessage, { ...props, ToolFallback, hasModelList });
9107
+ return /* @__PURE__ */ jsxRuntime.jsx(AssistantMessage, { ...props, hasModelList });
9075
9108
  };
9076
9109
  return /* @__PURE__ */ jsxRuntime.jsxs(ThreadWrapper, { children: [
9077
9110
  /* @__PURE__ */ jsxRuntime.jsxs(react.ThreadPrimitive.Viewport, { ref: areaRef, autoScroll: false, className: "overflow-y-scroll scroll-smooth h-full", children: [
@@ -9447,645 +9480,72 @@ const useAdapters = (agentId) => {
9447
9480
  };
9448
9481
  };
9449
9482
 
9450
- const handleNetworkMessageFromMemory = (content) => {
9451
- if (content.primitiveType === "workflow") {
9452
- return {
9453
- role: "assistant",
9454
- content: [
9455
- {
9456
- type: "tool-call",
9457
- toolCallId: content.finalResult.runId,
9458
- toolName: content.primitiveId,
9459
- result: { runId: content.finalResult.runId },
9460
- args: {
9461
- __mastraMetadata: {
9462
- from: "WORKFLOW",
9463
- networkMetadata: {
9464
- selectionReason: content?.selectionReason,
9465
- input: content?.input
9466
- }
9467
- }
9468
- }
9469
- }
9470
- ]
9471
- };
9483
+ const handleFinishReason = (finishReason) => {
9484
+ switch (finishReason) {
9485
+ case "tool-calls":
9486
+ throw new Error("Stream finished with reason tool-calls, try increasing maxSteps");
9472
9487
  }
9473
- if (content.primitiveType === "agent") {
9474
- const badgeMessages = [];
9475
- let toolCalls = {};
9476
- const messages = content.finalResult.messages.slice(1);
9477
- for (const message of messages) {
9478
- if (typeof message.content === "string") {
9479
- badgeMessages.push({
9480
- type: "text",
9481
- content: message.content
9482
- });
9483
- continue;
9484
- }
9485
- for (const part of message.content) {
9486
- if (part.type === "text") {
9487
- badgeMessages.push({
9488
- type: "text",
9489
- content: part.content
9490
- });
9491
- } else if (part.type === "tool-result") {
9492
- badgeMessages.push({
9493
- type: "tool",
9494
- toolName: part.toolName,
9495
- toolOutput: part.result,
9496
- // tool output
9497
- toolCallId: part.toolCallId,
9498
- args: toolCalls?.[part.toolCallId]?.args || {}
9499
- });
9500
- } else if (part.type === "tool-call") {
9501
- toolCalls[part.toolCallId] = part;
9502
- }
9488
+ };
9489
+ const convertToAIAttachments = async (attachments) => {
9490
+ const promises = (attachments ?? []).filter((attachment) => attachment.type === "image" || attachment.type === "document").map(async (attachment) => {
9491
+ const isFileFromURL = attachment.name.startsWith("https://");
9492
+ if (attachment.type === "document") {
9493
+ if (attachment.contentType === "application/pdf") {
9494
+ const pdfText = attachment.content?.[0]?.text || "";
9495
+ return {
9496
+ role: "user",
9497
+ content: [
9498
+ {
9499
+ type: "file",
9500
+ data: isFileFromURL ? attachment.name : `data:application/pdf;base64,${pdfText}`,
9501
+ mimeType: attachment.contentType,
9502
+ filename: attachment.name
9503
+ }
9504
+ ]
9505
+ };
9503
9506
  }
9507
+ return {
9508
+ role: "user",
9509
+ // @ts-expect-error - TODO: fix this type issue somehow
9510
+ content: attachment.content[0]?.text || ""
9511
+ };
9504
9512
  }
9505
9513
  return {
9506
- role: "assistant",
9507
- content: [
9508
- {
9509
- type: "tool-call",
9510
- toolCallId: content.finalResult.runId,
9511
- toolName: content.primitiveId,
9512
- result: { runId: content.finalResult.runId },
9513
- args: {
9514
- __mastraMetadata: {
9515
- from: "AGENT",
9516
- networkMetadata: {
9517
- selectionReason: content?.selectionReason || "",
9518
- input: content?.input || ""
9519
- },
9520
- messages: badgeMessages
9521
- }
9522
- }
9523
- }
9524
- ]
9525
- };
9526
- }
9527
- if (content.primitiveType === "tool") {
9528
- return {
9529
- role: "assistant",
9514
+ role: "user",
9530
9515
  content: [
9531
9516
  {
9532
- type: "tool-call",
9533
- toolCallId: content.finalResult.toolCallId,
9534
- toolName: content.primitiveId,
9535
- result: content.finalResult.result,
9536
- args: {
9537
- ...content?.input,
9538
- __mastraMetadata: {
9539
- networkMetadata: {
9540
- selectionReason: content?.selectionReason || "",
9541
- input: content?.input || ""
9542
- }
9543
- }
9544
- }
9517
+ type: "image",
9518
+ image: isFileFromURL ? attachment.name : await fileToBase64(attachment.file),
9519
+ mimeType: attachment.file.type
9545
9520
  }
9546
9521
  ]
9547
9522
  };
9548
- }
9549
- return { role: "assistant", content: [{ type: "text", text: "Unknown response" }] };
9523
+ });
9524
+ return Promise.all(promises);
9550
9525
  };
9551
-
9552
- const handleStreamChunk = ({ chunk, conversation }) => {
9553
- switch (chunk.type) {
9554
- case "tripwire": {
9555
- return [
9556
- ...conversation,
9557
- {
9558
- role: "assistant",
9559
- metadata: {
9560
- custom: {
9561
- status: "warning"
9562
- }
9563
- },
9564
- content: [
9565
- {
9566
- type: "text",
9567
- text: chunk.payload.tripwireReason
9568
- }
9569
- ]
9570
- }
9571
- ];
9572
- }
9573
- case "start": {
9574
- const newMessage = {
9575
- role: "assistant",
9576
- content: []
9577
- };
9578
- return [...conversation, newMessage];
9579
- }
9580
- case "text-start":
9581
- case "text-delta": {
9582
- const lastMessage = conversation[conversation.length - 1];
9583
- if (!lastMessage) return conversation;
9584
- if (lastMessage.role === "assistant" && typeof lastMessage.content !== `string` && (!lastMessage.content || lastMessage.content.length === 0 || lastMessage.content[lastMessage.content.length - 1]?.type !== `text`)) {
9585
- return [
9586
- ...conversation.slice(0, -1),
9587
- {
9588
- ...lastMessage,
9589
- content: [...lastMessage.content || [], { type: "text", text: "" }]
9590
- }
9591
- ];
9592
- }
9593
- if (chunk.type === `text-start`) return conversation;
9594
- if (typeof lastMessage.content === `string`) {
9595
- return [
9596
- ...conversation.slice(0, -1),
9597
- {
9598
- ...lastMessage,
9599
- content: lastMessage.content + chunk.payload.text
9600
- }
9601
- ];
9526
+ const initializeMessageState = (initialMessages) => {
9527
+ const convertedMessages = initialMessages?.map((message) => {
9528
+ const attachmentsAsContentParts = (message.experimental_attachments || []).map((image) => ({
9529
+ type: image.contentType.startsWith(`image/`) ? "image" : image.contentType.startsWith(`audio/`) ? "audio" : "file",
9530
+ mimeType: image.contentType,
9531
+ image: image.url
9532
+ }));
9533
+ const formattedParts = (message.parts || []).map((part) => {
9534
+ if (part.type === "reasoning") {
9535
+ return {
9536
+ type: "reasoning",
9537
+ text: part.reasoning || part?.details?.filter((detail) => detail.type === "text")?.map((detail) => detail.text).join(" ")
9538
+ };
9602
9539
  }
9603
- const lastPart = lastMessage.content?.[lastMessage.content.length - 1];
9604
- if (!lastPart || lastPart.type !== `text`) return conversation;
9605
- return [
9606
- ...conversation.slice(0, -1),
9607
- {
9608
- ...lastMessage,
9609
- content: [...lastMessage.content.slice(0, -1), { ...lastPart, text: lastPart.text + chunk.payload.text }]
9610
- }
9611
- ];
9612
- }
9613
- case "tool-output": {
9614
- if (chunk.payload.output?.type.startsWith("workflow-")) {
9615
- return handleWorkflowChunk({
9616
- workflowChunk: chunk.payload.output,
9617
- conversation,
9618
- entityName: chunk.payload.toolName
9619
- });
9620
- }
9621
- const lastMessage = conversation[conversation.length - 1];
9622
- if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
9623
- const updatedContent = lastMessage.content.map((part) => {
9624
- if (typeof part === "object" && part.type === "tool-call" && part.toolCallId === chunk.payload.toolCallId) {
9625
- const existingToolOutput = part.args?.__mastraMetadata?.toolOutput || [];
9626
- return {
9627
- ...part,
9628
- args: {
9629
- ...part.args,
9630
- __mastraMetadata: {
9631
- ...part.args?.__mastraMetadata,
9632
- toolOutput: [...existingToolOutput, chunk?.payload?.output]
9633
- }
9634
- }
9635
- };
9636
- }
9637
- return part;
9638
- });
9639
- const updatedMessage = {
9640
- ...lastMessage,
9641
- content: updatedContent
9642
- };
9643
- return [...conversation.slice(0, -1), updatedMessage];
9644
- }
9645
- return [...conversation];
9646
- }
9647
- case "tool-call": {
9648
- const lastMessage = conversation[conversation.length - 1];
9649
- if (lastMessage && lastMessage.role === "assistant") {
9650
- const updatedMessage = {
9651
- ...lastMessage,
9652
- content: Array.isArray(lastMessage.content) ? [
9653
- ...lastMessage.content,
9654
- {
9655
- type: "tool-call",
9656
- toolCallId: chunk.payload.toolCallId,
9657
- toolName: chunk.payload.toolName,
9658
- args: {
9659
- ...chunk.payload.args,
9660
- __mastraMetadata: {
9661
- ...chunk.payload.args?.__mastraMetadata,
9662
- isStreaming: true
9663
- }
9664
- }
9665
- }
9666
- ] : [
9667
- ...typeof lastMessage.content === "string" ? [{ type: "text", text: lastMessage.content }] : [],
9668
- {
9669
- type: "tool-call",
9670
- toolCallId: chunk.payload.toolCallId,
9671
- toolName: chunk.payload.toolName,
9672
- args: {
9673
- ...chunk.payload.args,
9674
- __mastraMetadata: {
9675
- ...chunk.payload.args?.__mastraMetadata,
9676
- isStreaming: true
9677
- }
9678
- }
9679
- }
9680
- ]
9681
- };
9682
- return [...conversation.slice(0, -1), updatedMessage];
9683
- }
9684
- const newMessage = {
9685
- role: "assistant",
9686
- content: [
9687
- {
9688
- type: "tool-call",
9689
- toolCallId: chunk.payload.toolCallId,
9690
- toolName: chunk.payload.toolName,
9691
- args: {
9692
- ...chunk.payload.args,
9693
- __mastraMetadata: {
9694
- ...chunk.payload.args?.__mastraMetadata,
9695
- isStreaming: true
9696
- }
9697
- }
9698
- }
9699
- ]
9700
- };
9701
- return [...conversation, newMessage];
9702
- }
9703
- case "tool-result": {
9704
- const lastMessage = conversation[conversation.length - 1];
9705
- if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
9706
- const updatedContent = lastMessage.content.map((part) => {
9707
- if (typeof part === "object" && part.type === "tool-call" && part.toolCallId === chunk.payload.toolCallId) {
9708
- return {
9709
- ...part,
9710
- result: chunk.payload.result
9711
- };
9712
- }
9713
- return part;
9714
- });
9715
- const updatedMessage = {
9716
- ...lastMessage,
9717
- content: updatedContent
9718
- };
9719
- return [...conversation.slice(0, -1), updatedMessage];
9720
- }
9721
- return [...conversation];
9722
- }
9723
- case "error": {
9724
- if (typeof chunk.payload.error === "string") {
9725
- const errorMessage = {
9726
- role: "assistant",
9727
- content: `Error: ${chunk.payload.error}`
9728
- };
9729
- return [...conversation, errorMessage];
9730
- }
9731
- return [...conversation];
9732
- }
9733
- case "finish": {
9734
- const lastMessage = conversation[conversation.length - 1];
9735
- handleFinishReason$1(chunk.payload.stepResult.reason);
9736
- if (lastMessage && lastMessage.role === "assistant") {
9737
- const updatedMessage = {
9738
- ...lastMessage,
9739
- metadata: {
9740
- custom: {
9741
- modelMetadata: chunk.payload.metadata.modelMetadata
9742
- }
9743
- }
9744
- };
9745
- return [...conversation.slice(0, -1), updatedMessage];
9746
- }
9747
- return [...conversation];
9748
- }
9749
- case "reasoning-delta": {
9750
- const lastMessage = conversation[conversation.length - 1];
9751
- if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
9752
- const updatedContent = lastMessage.content.map((part) => {
9753
- if (typeof part === "object" && part.type === "reasoning") {
9754
- return {
9755
- ...part,
9756
- text: part.text + chunk.payload.text
9757
- };
9758
- }
9759
- return part;
9760
- });
9761
- const updatedMessage = {
9762
- ...lastMessage,
9763
- content: updatedContent
9764
- };
9765
- return [...conversation.slice(0, -1), updatedMessage];
9766
- }
9767
- const newMessage = {
9768
- role: "assistant",
9769
- content: [
9770
- {
9771
- type: "reasoning",
9772
- text: chunk.payload.text
9773
- }
9774
- ]
9775
- };
9776
- return [...conversation, newMessage];
9777
- }
9778
- default:
9779
- return [...conversation];
9780
- }
9781
- };
9782
- const handleFinishReason$1 = (finishReason) => {
9783
- switch (finishReason) {
9784
- case "tool-calls":
9785
- throw new Error("Stream finished with reason tool-calls, try increasing maxSteps");
9786
- }
9787
- };
9788
- const handleWorkflowChunk = ({
9789
- workflowChunk,
9790
- conversation,
9791
- entityName
9792
- }) => {
9793
- const lastMessage = conversation[conversation.length - 1];
9794
- const contentArray = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
9795
- const newMessage = {
9796
- ...lastMessage,
9797
- content: contentArray.map((part) => {
9798
- if (part.type === "tool-call") {
9799
- return {
9800
- ...part,
9801
- toolName: part?.entityName || entityName,
9802
- args: {
9803
- ...part.args,
9804
- __mastraMetadata: {
9805
- ...part.args?.__mastraMetadata,
9806
- workflowFullState: react$3.mapWorkflowStreamChunkToWatchResult(
9807
- part.args?.__mastraMetadata?.workflowFullState || {},
9808
- workflowChunk
9809
- ),
9810
- isStreaming: true
9811
- }
9812
- }
9813
- };
9814
- }
9815
- return part;
9816
- })
9817
- };
9818
- return [...conversation.slice(0, -1), newMessage];
9819
- };
9820
- const handleAgentChunk = ({
9821
- agentChunk,
9822
- conversation,
9823
- entityName
9824
- }) => {
9825
- switch (agentChunk.type) {
9826
- case "tool-result": {
9827
- const lastMessage = conversation[conversation.length - 1];
9828
- const contentArray = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
9829
- const newMessage = {
9830
- ...lastMessage,
9831
- content: contentArray.map((part) => {
9832
- if (part.type === "tool-call") {
9833
- const messages = part.args?.__mastraMetadata?.messages || [];
9834
- const next = {
9835
- ...part,
9836
- toolName: part?.entityName || entityName,
9837
- args: {
9838
- ...part.args,
9839
- __mastraMetadata: {
9840
- ...part.args?.__mastraMetadata,
9841
- isStreaming: true,
9842
- messages: [
9843
- ...messages.slice(0, -1),
9844
- {
9845
- ...messages[messages.length - 1],
9846
- type: "tool",
9847
- toolName: agentChunk.payload.toolName,
9848
- args: agentChunk.payload.args,
9849
- toolOutput: agentChunk.payload.result
9850
- }
9851
- ]
9852
- }
9853
- }
9854
- };
9855
- return next;
9856
- }
9857
- return part;
9858
- })
9859
- };
9860
- return [...conversation.slice(0, -1), newMessage];
9861
- }
9862
- case "tool-call": {
9863
- const lastMessage = conversation[conversation.length - 1];
9864
- const contentArray = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
9865
- const newMessage = {
9866
- ...lastMessage,
9867
- content: contentArray.map((part) => {
9868
- if (part.type === "tool-call") {
9869
- const messages = part.args?.__mastraMetadata?.messages || [];
9870
- const next = {
9871
- ...part,
9872
- toolName: part?.entityName || entityName,
9873
- args: {
9874
- ...part.args,
9875
- __mastraMetadata: {
9876
- ...part.args?.__mastraMetadata,
9877
- isStreaming: true,
9878
- messages: [
9879
- ...messages,
9880
- {
9881
- type: "tool",
9882
- toolCallId: agentChunk.payload.toolCallId,
9883
- toolName: agentChunk.payload.toolName,
9884
- args: {
9885
- ...agentChunk.payload.args,
9886
- __mastraMetadata: {
9887
- ...agentChunk.payload.args?.__mastraMetadata,
9888
- isStreaming: true
9889
- }
9890
- }
9891
- }
9892
- ]
9893
- }
9894
- }
9895
- };
9896
- return next;
9897
- }
9898
- return part;
9899
- })
9900
- };
9901
- return [...conversation.slice(0, -1), newMessage];
9902
- }
9903
- case "text-delta": {
9904
- const lastMessage = conversation[conversation.length - 1];
9905
- const contentArray = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
9906
- const newMessage = {
9907
- ...lastMessage,
9908
- content: contentArray.map((part) => {
9909
- if (part.type === "tool-call") {
9910
- const messages = part.args?.__mastraMetadata?.messages || [];
9911
- const lastMastraMessage = messages[messages.length - 1];
9912
- const nextMessages = lastMastraMessage?.type === "text" ? [
9913
- ...messages.slice(0, -1),
9914
- { type: "text", content: (lastMastraMessage?.content || "") + agentChunk.payload.text }
9915
- ] : [...messages, { type: "text", content: agentChunk.payload.text }];
9916
- return {
9917
- ...part,
9918
- toolName: part?.entityName || entityName,
9919
- args: {
9920
- ...part.args,
9921
- __mastraMetadata: {
9922
- ...part.args?.__mastraMetadata,
9923
- isStreaming: true,
9924
- messages: nextMessages
9925
- }
9926
- }
9927
- };
9928
- }
9929
- return part;
9930
- })
9931
- };
9932
- return [...conversation.slice(0, -1), newMessage];
9933
- }
9934
- case "tool-output": {
9935
- if (!agentChunk.payload.output.type.startsWith("workflow-")) return [...conversation];
9936
- const lastMessage = conversation[conversation.length - 1];
9937
- const contentArray = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
9938
- const newMessage = {
9939
- ...lastMessage,
9940
- content: contentArray.map((part) => {
9941
- if (part.type === "tool-call") {
9942
- const messages = part.args?.__mastraMetadata?.messages || [];
9943
- const lastMastraMessage = messages[messages.length - 1];
9944
- const nextMessages = lastMastraMessage?.type === "tool" ? [
9945
- ...messages.slice(0, -1),
9946
- {
9947
- ...lastMastraMessage,
9948
- args: {
9949
- ...agentChunk.payload.args,
9950
- __mastraMetadata: {
9951
- ...agentChunk.payload.args?.__mastraMetadata,
9952
- workflowFullState: react$3.mapWorkflowStreamChunkToWatchResult(
9953
- lastMastraMessage.args?.__mastraMetadata?.workflowFullState || {},
9954
- agentChunk.payload.output
9955
- ),
9956
- isStreaming: true
9957
- }
9958
- }
9959
- }
9960
- ] : messages;
9961
- return {
9962
- ...part,
9963
- toolName: part?.entityName || entityName,
9964
- args: {
9965
- ...part.args,
9966
- __mastraMetadata: {
9967
- ...part.args?.__mastraMetadata,
9968
- isStreaming: true,
9969
- messages: nextMessages
9970
- }
9971
- }
9972
- };
9973
- }
9974
- return part;
9975
- })
9976
- };
9977
- return [...conversation.slice(0, -1), newMessage];
9978
- }
9979
- default:
9980
- case "agent-execution-end":
9981
- return [...conversation];
9982
- }
9983
- };
9984
- const createRootToolAssistantMessage = ({
9985
- chunk,
9986
- entityName,
9987
- conversation,
9988
- runId,
9989
- from,
9990
- networkMetadata
9991
- }) => {
9992
- if (!entityName || !runId) return [...conversation];
9993
- const newMessage = {
9994
- role: "assistant",
9995
- content: [
9996
- {
9997
- type: "tool-call",
9998
- toolCallId: runId,
9999
- toolName: entityName,
10000
- args: {
10001
- ...chunk?.payload?.args,
10002
- __mastraMetadata: {
10003
- from,
10004
- networkMetadata,
10005
- ...chunk.payload.args?.__mastraMetadata,
10006
- isStreaming: true
10007
- }
10008
- }
10009
- }
10010
- ]
10011
- };
10012
- return [...conversation, newMessage];
10013
- };
10014
-
10015
- const handleFinishReason = (finishReason) => {
10016
- switch (finishReason) {
10017
- case "tool-calls":
10018
- throw new Error("Stream finished with reason tool-calls, try increasing maxSteps");
10019
- }
10020
- };
10021
- const convertToAIAttachments = async (attachments) => {
10022
- const promises = (attachments ?? []).filter((attachment) => attachment.type === "image" || attachment.type === "document").map(async (attachment) => {
10023
- const isFileFromURL = attachment.name.startsWith("https://");
10024
- if (attachment.type === "document") {
10025
- if (attachment.contentType === "application/pdf") {
10026
- const pdfText = attachment.content?.[0]?.text || "";
10027
- return {
10028
- role: "user",
10029
- content: [
10030
- {
10031
- type: "file",
10032
- data: isFileFromURL ? attachment.name : `data:application/pdf;base64,${pdfText}`,
10033
- mimeType: attachment.contentType,
10034
- filename: attachment.name
10035
- }
10036
- ]
10037
- };
10038
- }
10039
- return {
10040
- role: "user",
10041
- // @ts-expect-error - TODO: fix this type issue somehow
10042
- content: attachment.content[0]?.text || ""
10043
- };
10044
- }
10045
- return {
10046
- role: "user",
10047
- content: [
10048
- {
10049
- type: "image",
10050
- image: isFileFromURL ? attachment.name : await fileToBase64(attachment.file),
10051
- mimeType: attachment.file.type
10052
- }
10053
- ]
10054
- };
10055
- });
10056
- return Promise.all(promises);
10057
- };
10058
- const initializeMessageState = (initialMessages) => {
10059
- const convertedMessages = initialMessages?.map((message) => {
10060
- let content;
10061
- try {
10062
- content = JSON.parse(message.content);
10063
- if (content.isNetwork) {
10064
- return handleNetworkMessageFromMemory(content);
10065
- }
10066
- } catch (e) {
10067
- }
10068
- const attachmentsAsContentParts = (message.experimental_attachments || []).map((image) => ({
10069
- type: image.contentType.startsWith(`image/`) ? "image" : image.contentType.startsWith(`audio/`) ? "audio" : "file",
10070
- mimeType: image.contentType,
10071
- image: image.url
10072
- }));
10073
- const formattedParts = (message.parts || []).map((part) => {
10074
- if (part.type === "reasoning") {
10075
- return {
10076
- type: "reasoning",
10077
- text: part.reasoning || part?.details?.filter((detail) => detail.type === "text")?.map((detail) => detail.text).join(" ")
10078
- };
10079
- }
10080
- if (part.type === "tool-invocation") {
10081
- if (part.toolInvocation.state === "result") {
10082
- return {
10083
- type: "tool-call",
10084
- toolCallId: part.toolInvocation.toolCallId,
10085
- toolName: part.toolInvocation.toolName,
10086
- args: part.toolInvocation.args,
10087
- result: part.toolInvocation.result
10088
- };
9540
+ if (part.type === "tool-invocation") {
9541
+ if (part.toolInvocation.state === "result") {
9542
+ return {
9543
+ type: "tool-call",
9544
+ toolCallId: part.toolInvocation.toolCallId,
9545
+ toolName: part.toolInvocation.toolName,
9546
+ args: part.toolInvocation.args,
9547
+ result: part.toolInvocation.result
9548
+ };
10089
9549
  }
10090
9550
  }
10091
9551
  if (part.type === "file") {
@@ -10113,6 +9573,7 @@ function MastraRuntimeProvider({
10113
9573
  children,
10114
9574
  agentId,
10115
9575
  initialMessages,
9576
+ initialLegacyMessages,
10116
9577
  memory,
10117
9578
  threadId,
10118
9579
  refreshThreadList,
@@ -10120,20 +9581,19 @@ function MastraRuntimeProvider({
10120
9581
  runtimeContext,
10121
9582
  modelVersion
10122
9583
  }) {
10123
- const initializeMessages = () => memory ? initializeMessageState(initialMessages || []) : [];
10124
9584
  const [isLegacyRunning, setIsLegacyRunning] = React.useState(false);
10125
- const [legacyMessages, setLegacyMessages] = React.useState(initializeMessages());
9585
+ const [legacyMessages, setLegacyMessages] = React.useState(
9586
+ () => memory ? initializeMessageState(initialLegacyMessages || []) : []
9587
+ );
10126
9588
  const {
10127
- setMessages,
10128
9589
  messages,
10129
- generate,
10130
- stream,
10131
- network,
9590
+ sendMessage,
10132
9591
  cancelRun,
10133
- isRunning: isRunningStream
9592
+ isRunning: isRunningStream,
9593
+ setMessages
10134
9594
  } = react$3.useChat({
10135
9595
  agentId,
10136
- initializeMessages
9596
+ initializeMessages: () => initialMessages || []
10137
9597
  });
10138
9598
  const { refetch: refreshWorkingMemory } = useWorkingMemory();
10139
9599
  const abortControllerRef = React.useRef(null);
@@ -10166,7 +9626,8 @@ function MastraRuntimeProvider({
10166
9626
  topP,
10167
9627
  maxTokens,
10168
9628
  instructions,
10169
- providerOptions
9629
+ providerOptions,
9630
+ maxSteps
10170
9631
  };
10171
9632
  const baseClient = react$3.useMastraClient();
10172
9633
  const isVNext = modelVersion === "v2";
@@ -10174,9 +9635,7 @@ function MastraRuntimeProvider({
10174
9635
  if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
10175
9636
  const attachments = await convertToAIAttachments(message.attachments);
10176
9637
  const input = message.content[0].text;
10177
- if (isVNext) {
10178
- setMessages((s) => [...s, { role: "user", content: input, attachments: message.attachments }]);
10179
- } else {
9638
+ if (!isVNext) {
10180
9639
  setLegacyMessages((s) => [...s, { role: "user", content: input, attachments: message.attachments }]);
10181
9640
  }
10182
9641
  const controller = new AbortController();
@@ -10189,134 +9648,44 @@ function MastraRuntimeProvider({
10189
9648
  try {
10190
9649
  if (isVNext) {
10191
9650
  if (chatWithNetwork) {
10192
- let currentEntityId;
10193
- await network({
10194
- coreUserMessages: [
10195
- {
10196
- role: "user",
10197
- content: input
10198
- },
10199
- ...attachments
10200
- ],
9651
+ await sendMessage({
9652
+ message: input,
9653
+ mode: "network",
9654
+ coreUserMessages: attachments,
10201
9655
  runtimeContext: runtimeContextInstance,
10202
9656
  threadId,
10203
9657
  modelSettings: modelSettingsArgs,
10204
9658
  signal: controller.signal,
10205
- onNetworkChunk: (chunk, conversation) => {
10206
- if (chunk.type.startsWith("agent-execution-event-")) {
10207
- const agentChunk = chunk.payload;
10208
- if (!currentEntityId) return conversation;
10209
- return handleAgentChunk({ agentChunk, conversation, entityName: currentEntityId });
10210
- } else if (chunk.type === "tool-execution-start") {
10211
- const { args: argsData } = chunk.payload;
10212
- const nestedArgs = argsData.args || {};
10213
- const mastraMetadata = argsData.__mastraMetadata || {};
10214
- const selectionReason = argsData.selectionReason || "";
10215
- return handleStreamChunk({
10216
- chunk: {
10217
- ...chunk,
10218
- type: "tool-call",
10219
- payload: {
10220
- ...chunk.payload,
10221
- toolCallId: argsData.toolCallId || "unknown",
10222
- toolName: argsData.toolName || "unknown",
10223
- args: {
10224
- ...nestedArgs,
10225
- __mastraMetadata: {
10226
- ...mastraMetadata,
10227
- networkMetadata: {
10228
- selectionReason,
10229
- input: nestedArgs
10230
- }
10231
- }
10232
- }
10233
- }
10234
- },
10235
- conversation
10236
- });
10237
- } else if (chunk.type === "tool-execution-end") {
10238
- const next = handleStreamChunk({
10239
- chunk: { ...chunk, type: "tool-result" },
10240
- conversation
10241
- });
10242
- if (chunk.payload?.toolName === "updateWorkingMemory" && typeof chunk.payload.result === "object" && "success" in chunk.payload.result && chunk.payload.result?.success) {
10243
- refreshWorkingMemory?.();
10244
- }
10245
- return next;
10246
- } else if (chunk.type.startsWith("workflow-execution-event-")) {
10247
- const workflowChunk = chunk.payload;
10248
- if (!currentEntityId) return conversation;
10249
- return handleWorkflowChunk({ workflowChunk, conversation, entityName: currentEntityId });
10250
- } else if (chunk.type === "workflow-execution-start" || chunk.type === "agent-execution-start") {
10251
- currentEntityId = chunk.payload?.args?.primitiveId;
10252
- const runId = chunk.payload.runId;
10253
- if (!currentEntityId || !runId) return conversation;
10254
- return createRootToolAssistantMessage({
10255
- entityName: currentEntityId,
10256
- conversation,
10257
- runId,
10258
- chunk,
10259
- from: chunk.type === "agent-execution-start" ? "AGENT" : "WORKFLOW",
10260
- networkMetadata: {
10261
- selectionReason: chunk?.payload?.args?.selectionReason || "",
10262
- input: chunk?.payload?.args?.prompt
10263
- }
10264
- });
10265
- } else if (chunk.type === "network-execution-event-step-finish") {
10266
- return [
10267
- ...conversation,
10268
- { role: "assistant", content: [{ type: "text", text: chunk?.payload?.result || "" }] }
10269
- ];
10270
- } else {
10271
- return handleStreamChunk({ chunk, conversation });
9659
+ onNetworkChunk: async (chunk) => {
9660
+ if (chunk.type === "tool-execution-end" && chunk.payload?.toolName === "updateWorkingMemory" && typeof chunk.payload.result === "object" && "success" in chunk.payload.result && chunk.payload.result?.success) {
9661
+ refreshWorkingMemory?.();
10272
9662
  }
10273
9663
  }
10274
9664
  });
10275
9665
  } else {
10276
9666
  if (chatWithGenerate) {
10277
- await generate({
10278
- coreUserMessages: [
10279
- {
10280
- role: "user",
10281
- content: input
10282
- },
10283
- ...attachments
10284
- ],
9667
+ await sendMessage({
9668
+ message: input,
9669
+ mode: "generate",
9670
+ coreUserMessages: attachments,
10285
9671
  runtimeContext: runtimeContextInstance,
10286
9672
  threadId,
10287
9673
  modelSettings: modelSettingsArgs,
10288
- signal: controller.signal,
10289
- onFinish: ({ messages: messages2, tripwireReason }) => {
10290
- const next = messages2.length > 0 ? messages2.map((message2) => react$3.toAssistantUIMessage(message2)) : [];
10291
- if (tripwireReason) {
10292
- next.push({
10293
- role: "assistant",
10294
- content: [{ type: "text", text: tripwireReason }],
10295
- metadata: { custom: { status: "warning" } }
10296
- });
10297
- }
10298
- return next;
10299
- }
9674
+ signal: controller.signal
10300
9675
  });
10301
9676
  return;
10302
9677
  } else {
10303
- await stream({
10304
- coreUserMessages: [
10305
- {
10306
- role: "user",
10307
- content: input
10308
- },
10309
- ...attachments
10310
- ],
9678
+ await sendMessage({
9679
+ message: input,
9680
+ mode: "stream",
9681
+ coreUserMessages: attachments,
10311
9682
  runtimeContext: runtimeContextInstance,
10312
9683
  threadId,
10313
9684
  modelSettings: modelSettingsArgs,
10314
- onChunk: (chunk, conversation) => {
10315
- const next = handleStreamChunk({ chunk, conversation });
9685
+ onChunk: async (chunk) => {
10316
9686
  if (chunk.type === "tool-result" && chunk.payload?.toolName === "updateWorkingMemory" && typeof chunk.payload.result === "object" && "success" in chunk.payload.result && chunk.payload.result?.success) {
10317
9687
  refreshWorkingMemory?.();
10318
9688
  }
10319
- return next;
10320
9689
  },
10321
9690
  signal: controller.signal
10322
9691
  });
@@ -10611,7 +9980,7 @@ function MastraRuntimeProvider({
10611
9980
  if (isVNext) {
10612
9981
  setMessages((currentConversation) => [
10613
9982
  ...currentConversation,
10614
- { role: "assistant", content: [{ type: "text", text: `${error}` }] }
9983
+ { role: "assistant", parts: [{ type: "text", text: `${error}` }] }
10615
9984
  ]);
10616
9985
  } else {
10617
9986
  setLegacyMessages((currentConversation) => [
@@ -10632,20 +10001,17 @@ function MastraRuntimeProvider({
10632
10001
  }
10633
10002
  };
10634
10003
  const { adapters, isReady } = useAdapters(agentId);
10004
+ const vnextmessages = messages.map(react$3.toAssistantUIMessage);
10635
10005
  const runtime = react.useExternalStoreRuntime({
10636
10006
  isRunning: isLegacyRunning || isRunningStream,
10637
- messages: isVNext ? messages : legacyMessages,
10007
+ messages: isVNext ? vnextmessages : legacyMessages,
10638
10008
  convertMessage: (x) => x,
10639
10009
  onNew,
10640
10010
  onCancel,
10641
10011
  adapters: isReady ? adapters : void 0
10642
10012
  });
10643
10013
  if (!isReady) return null;
10644
- return /* @__PURE__ */ jsxRuntime.jsxs(react.AssistantRuntimeProvider, { runtime, children: [
10645
- " ",
10646
- children,
10647
- " "
10648
- ] });
10014
+ return /* @__PURE__ */ jsxRuntime.jsx(react.AssistantRuntimeProvider, { runtime, children });
10649
10015
  }
10650
10016
 
10651
10017
  const defaultSettings = {
@@ -10713,6 +10079,7 @@ const AgentChat = ({
10713
10079
  agentName,
10714
10080
  threadId,
10715
10081
  initialMessages,
10082
+ initialLegacyMessages,
10716
10083
  memory,
10717
10084
  refreshThreadList,
10718
10085
  modelVersion,
@@ -10728,6 +10095,7 @@ const AgentChat = ({
10728
10095
  modelVersion,
10729
10096
  threadId,
10730
10097
  initialMessages,
10098
+ initialLegacyMessages,
10731
10099
  memory,
10732
10100
  refreshThreadList,
10733
10101
  settings,
@@ -10848,7 +10216,7 @@ const TableCaption = React__namespace.forwardRef(
10848
10216
  );
10849
10217
  TableCaption.displayName = "TableCaption";
10850
10218
 
10851
- const Tabs = TabsPrimitive__namespace.Root;
10219
+ const Tabs$1 = TabsPrimitive__namespace.Root;
10852
10220
  const TabsList = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
10853
10221
  TabsPrimitive__namespace.List,
10854
10222
  {
@@ -10891,12 +10259,12 @@ const PlaygroundTabs = ({
10891
10259
  setInternalTab(typedValue);
10892
10260
  }
10893
10261
  };
10894
- return /* @__PURE__ */ jsxRuntime.jsx(Tabs, { value: currentTab, onValueChange: handleTabChange, className: cn("h-full", className), children });
10262
+ return /* @__PURE__ */ jsxRuntime.jsx(Tabs$1, { value: currentTab, onValueChange: handleTabChange, className: cn("h-full", className), children });
10895
10263
  };
10896
- const TabList = ({ children, className }) => {
10264
+ const TabList$1 = ({ children, className }) => {
10897
10265
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("w-full overflow-x-auto", className), children: /* @__PURE__ */ jsxRuntime.jsx(TabsList, { className: "border-b border-border1 flex min-w-full shrink-0", children }) });
10898
10266
  };
10899
- const Tab = ({ children, value, onClick }) => {
10267
+ const Tab$1 = ({ children, value, onClick }) => {
10900
10268
  return /* @__PURE__ */ jsxRuntime.jsx(
10901
10269
  TabsTrigger,
10902
10270
  {
@@ -10907,7 +10275,7 @@ const Tab = ({ children, value, onClick }) => {
10907
10275
  }
10908
10276
  );
10909
10277
  };
10910
- const TabContent = ({ children, value }) => {
10278
+ const TabContent$1 = ({ children, value }) => {
10911
10279
  return /* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value, className: "h-full overflow-hidden flex flex-col", children });
10912
10280
  };
10913
10281
 
@@ -10932,12 +10300,12 @@ function AgentEvals({ liveEvals, ciEvals, onRefetchLiveEvals, onRefetchCiEvals }
10932
10300
  return onRefetchCiEvals();
10933
10301
  }
10934
10302
  return /* @__PURE__ */ jsxRuntime.jsxs(PlaygroundTabs, { defaultTab: "live", children: [
10935
- /* @__PURE__ */ jsxRuntime.jsxs(TabList, { children: [
10936
- /* @__PURE__ */ jsxRuntime.jsx(Tab, { value: "live", children: "Live" }),
10937
- /* @__PURE__ */ jsxRuntime.jsx(Tab, { value: "ci", children: "CI" })
10303
+ /* @__PURE__ */ jsxRuntime.jsxs(TabList$1, { children: [
10304
+ /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "live", children: "Live" }),
10305
+ /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "ci", children: "CI" })
10938
10306
  ] }),
10939
- /* @__PURE__ */ jsxRuntime.jsx(TabContent, { value: "live", children: /* @__PURE__ */ jsxRuntime.jsx(EvalTable, { evals: liveEvals, isCIMode: false, onRefresh: handleRefresh }) }),
10940
- /* @__PURE__ */ jsxRuntime.jsx(TabContent, { value: "ci", children: /* @__PURE__ */ jsxRuntime.jsx(EvalTable, { evals: ciEvals, isCIMode: true, onRefresh: handleRefresh }) })
10307
+ /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "live", children: /* @__PURE__ */ jsxRuntime.jsx(EvalTable, { evals: liveEvals, isCIMode: false, onRefresh: handleRefresh }) }),
10308
+ /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "ci", children: /* @__PURE__ */ jsxRuntime.jsx(EvalTable, { evals: ciEvals, isCIMode: true, onRefresh: handleRefresh }) })
10941
10309
  ] });
10942
10310
  }
10943
10311
  function EvalTable({ evals, isCIMode = false, onRefresh }) {
@@ -11486,13 +10854,35 @@ const AgentSettings = ({ modelVersion, hasMemory = false, hasSubAgents = false }
11486
10854
  ] });
11487
10855
  };
11488
10856
 
10857
+ const resolveInstructionPart = (part) => {
10858
+ if (typeof part === "string") {
10859
+ return part.trim();
10860
+ }
10861
+ return part.text?.trim() || "";
10862
+ };
10863
+ const extractPrompt = (instructions) => {
10864
+ if (typeof instructions === "string") {
10865
+ return instructions.trim();
10866
+ }
10867
+ if (typeof instructions === "object" && "content" in instructions) {
10868
+ if (Array.isArray(instructions.content)) {
10869
+ return instructions.content.map(resolveInstructionPart).join("\n\n").trim();
10870
+ }
10871
+ return instructions.content.trim();
10872
+ }
10873
+ if (Array.isArray(instructions)) {
10874
+ return instructions.map(extractPrompt).join("\n\n").trim();
10875
+ }
10876
+ return "";
10877
+ };
10878
+
11489
10879
  const NameCell$3 = ({ row }) => {
11490
10880
  const { Link, paths } = useLinkComponent();
11491
10881
  return /* @__PURE__ */ jsxRuntime.jsx(
11492
10882
  EntryCell,
11493
10883
  {
11494
10884
  name: /* @__PURE__ */ jsxRuntime.jsx(Link, { className: "w-full space-y-0", href: paths.agentLink(row.original.id), children: row.original.name }),
11495
- description: row.original.instructions
10885
+ description: extractPrompt(row.original.instructions)
11496
10886
  }
11497
10887
  );
11498
10888
  };
@@ -11587,7 +10977,7 @@ function AgentsTable({ agents, isLoading }) {
11587
10977
  return /* @__PURE__ */ jsxRuntime.jsx(EmptyAgentsTable, {});
11588
10978
  }
11589
10979
  const filteredRows = rows.filter((row) => row.original.name.toLowerCase().includes(search.toLowerCase()));
11590
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10980
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11591
10981
  /* @__PURE__ */ jsxRuntime.jsx(SearchbarWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(Searchbar, { onSearch: setSearch, label: "Search agents", placeholder: "Search agents" }) }),
11592
10982
  isLoading ? /* @__PURE__ */ jsxRuntime.jsx(AgentsTableSkeleton, {}) : /* @__PURE__ */ jsxRuntime.jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
11593
10983
  /* @__PURE__ */ jsxRuntime.jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsxRuntime.jsx(Th, { style: { width: header.column.getSize() ?? "auto" }, children: reactTable.flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
@@ -12211,36 +11601,8 @@ function RelationWrapper({ description, children }) {
12211
11601
  ] }) : children;
12212
11602
  }
12213
11603
 
12214
- function EntryListTextCell({ children, isLoading }) {
12215
- const [randomWidth, setRandomWidth] = React.useState(void 0);
12216
- React.useEffect(() => {
12217
- setRandomWidth(Math.floor(Math.random() * (90 - 50 + 1)) + 50);
12218
- }, []);
12219
- if (!randomWidth) return null;
12220
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-icon4 text-[0.875rem] truncate ", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(
12221
- "div",
12222
- {
12223
- className: "bg-surface4 rounded-md animate-pulse text-transparent h-[1rem] select-none",
12224
- style: { width: `${randomWidth}%` }
12225
- }
12226
- ) : children });
12227
- }
12228
- function EntryListStatusCell({ status }) {
12229
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex justify-center items-center w-full relative"), children: [
12230
- status ? /* @__PURE__ */ jsxRuntime.jsx(
12231
- "div",
12232
- {
12233
- className: cn("w-[0.6rem] h-[0.6rem] rounded-full", {
12234
- "bg-green-600": status === "success",
12235
- "bg-red-700": status === "failed"
12236
- })
12237
- }
12238
- ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-icon2 text-[0.75rem] leading-none", children: "-" }),
12239
- /* @__PURE__ */ jsxRuntime.jsxs(VisuallyHidden.VisuallyHidden, { children: [
12240
- "Status: ",
12241
- status ? status : "not provided"
12242
- ] })
12243
- ] });
11604
+ function EntryListRoot({ children }) {
11605
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid", children });
12244
11606
  }
12245
11607
 
12246
11608
  function getColumnTemplate(columns) {
@@ -12252,33 +11614,53 @@ function getColumnTemplate(columns) {
12252
11614
  }).join(" ");
12253
11615
  }
12254
11616
 
12255
- function EntryListItem({
12256
- item,
12257
- selectedItemId,
12258
- onClick,
12259
- children,
12260
- columns,
12261
- isLoading
12262
- }) {
12263
- const isSelected = selectedItemId === item.id;
11617
+ function EntryListHeader({ columns }) {
11618
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("sticky top-0 bg-surface4 z-[1] rounded-t-lg px-[1.5rem]"), children: /* @__PURE__ */ jsxRuntime.jsx(
11619
+ "div",
11620
+ {
11621
+ className: cn("grid gap-[1.5rem] text-left uppercase py-[.75rem] text-icon3 text-[0.75rem]"),
11622
+ style: { gridTemplateColumns: getColumnTemplate(columns) },
11623
+ children: columns?.map((col) => /* @__PURE__ */ jsxRuntime.jsx("span", { children: col.label || col.name }, col.name))
11624
+ }
11625
+ ) });
11626
+ }
11627
+
11628
+ function EntryListEntries({ children }) {
11629
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "grid bg-surface3 overflow-y-auto", children });
11630
+ }
11631
+
11632
+ function EntryListTrim({ children }) {
11633
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("rounded-lg border border-border1 overflow-clip"), children });
11634
+ }
11635
+
11636
+ function EntryListEntry({ entry, isSelected, onClick, children, columns }) {
12264
11637
  const handleClick = () => {
12265
- return onClick && onClick(item?.id);
11638
+ onClick?.(entry?.id);
12266
11639
  };
12267
11640
  return /* @__PURE__ */ jsxRuntime.jsx(
12268
11641
  "li",
12269
11642
  {
12270
- className: cn("border-b text-[#ccc] border-border1 last:border-b-0 text-[0.875rem]", {
12271
- "bg-surface5": isSelected
12272
- }),
12273
- children: /* @__PURE__ */ jsxRuntime.jsx(
11643
+ className: cn(
11644
+ "border-t text-[#ccc] border-border1 last:border-b-0 text-[0.875rem]",
11645
+ "[&:last-child>button]:rounded-b-lg",
11646
+ {
11647
+ "bg-surface5": isSelected
11648
+ }
11649
+ ),
11650
+ children: /* @__PURE__ */ jsxRuntime.jsx(
12274
11651
  "button",
12275
11652
  {
12276
11653
  onClick: handleClick,
12277
- className: cn("grid w-full px-[1.5rem] gap-[2rem] text-left items-center min-h-[3rem]", {
12278
- "hover:bg-surface5": !isLoading
12279
- }),
11654
+ className: cn(
11655
+ "grid w-full px-[1.5rem] gap-[1.5rem] text-left items-center min-h-[3rem]",
11656
+ "focus-visible:outline-none focus-visible:shadow-[inset_0_0_0_1px_rgba(24,251,111,.75)]",
11657
+ {
11658
+ // hover effect only not for skeleton and selected
11659
+ "hover:bg-surface4": entry && !isSelected
11660
+ }
11661
+ ),
12280
11662
  style: { gridTemplateColumns: getColumnTemplate(columns) },
12281
- disabled: isLoading,
11663
+ disabled: !entry,
12282
11664
  children
12283
11665
  }
12284
11666
  )
@@ -12286,178 +11668,180 @@ function EntryListItem({
12286
11668
  );
12287
11669
  }
12288
11670
 
12289
- function EntryList({
12290
- items: dataItems,
12291
- selectedItemId,
12292
- onItemClick,
11671
+ function EntryListMessage({ children, message, className, type }) {
11672
+ if (!children && !message) {
11673
+ return null;
11674
+ }
11675
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("grid border-t border-border1", className), children: message ? /* @__PURE__ */ jsxRuntime.jsxs(
11676
+ "p",
11677
+ {
11678
+ className: cn(
11679
+ "text-icon3 text-[0.875rem] text-center grid p-[2rem] justify-center justify-items-center gap-[.5rem]",
11680
+ "[&>svg]:w-[1.5em] [&>svg]:h-[1.5em] [&>svg]:opacity-75",
11681
+ {
11682
+ "[&>svg]:text-red-500": type === "error"
11683
+ }
11684
+ ),
11685
+ children: [
11686
+ type === "error" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TriangleAlertIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, {}),
11687
+ " ",
11688
+ message
11689
+ ]
11690
+ }
11691
+ ) : children });
11692
+ }
11693
+
11694
+ function EntryListNextPageLoading({
12293
11695
  isLoading,
12294
- isLoadingNextPage,
12295
- total,
12296
- page,
12297
11696
  hasMore,
12298
- onNextPage,
12299
- onPrevPage,
12300
- perPage,
12301
- columns,
12302
- searchTerm,
12303
11697
  setEndOfListElement,
12304
- errorMsg
11698
+ loadingText = "Loading more data...",
11699
+ noMoreDataText = "No more data to load"
12305
11700
  }) {
12306
- const loadingItems = Array.from({ length: 3 }).map((_, index) => {
12307
- return {
12308
- id: `loading-${index + 1}`,
12309
- ...(columns || []).reduce(
12310
- (acc, col) => {
12311
- acc[col.name] = `...`;
12312
- return acc;
12313
- },
12314
- {}
12315
- )
12316
- };
12317
- });
12318
- const items = isLoading ? loadingItems : dataItems;
12319
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid mb-[3rem]", children: [
12320
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("sticky top-0 bg-surface4 z-[1] rounded-t-lg border border-border1 px-[1.5rem]"), children: /* @__PURE__ */ jsxRuntime.jsx(
11701
+ if (!setEndOfListElement) {
11702
+ return null;
11703
+ }
11704
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: setEndOfListElement, className: "text-[0.875rem] text-icon3 opacity-50 flex mt-[2rem] justify-center", children: [
11705
+ isLoading && loadingText,
11706
+ !hasMore && !isLoading && noMoreDataText
11707
+ ] });
11708
+ }
11709
+
11710
+ function EntryListPagination({ currentPage, hasMore, onNextPage, onPrevPage }) {
11711
+ const showNavigation = typeof currentPage === "number" && currentPage > 0 || hasMore;
11712
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex pt-[1.5rem] items-center justify-center text-icon3 text-[0.875rem] gap-[2rem] "), children: [
11713
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
11714
+ "Page ",
11715
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: currentPage ? currentPage + 1 : "1" })
11716
+ ] }),
11717
+ showNavigation && /* @__PURE__ */ jsxRuntime.jsxs(
12321
11718
  "div",
12322
- {
12323
- className: cn("grid gap-[2rem] text-left uppercase py-[.75rem] text-icon3 text-[0.75rem]"),
12324
- style: { gridTemplateColumns: getColumnTemplate(columns) },
12325
- children: columns?.map((col) => /* @__PURE__ */ jsxRuntime.jsx("span", { children: col.label || col.name }, col.name))
12326
- }
12327
- ) }),
12328
- errorMsg && !isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid border border-border1 border-t-0 bg-surface3 rounded-xl rounded-t-none", children: /* @__PURE__ */ jsxRuntime.jsxs(
12329
- "p",
12330
11719
  {
12331
11720
  className: cn(
12332
- "text-[0.875rem] text-center items-center flex justify-center p-[2.5rem] gap-[1rem] text-icon3",
12333
- "[&>svg]:w-[1.5em]",
12334
- "[&>svg]:h-[1.5em]",
12335
- "[&>svg]:text-red-500"
11721
+ "flex gap-[1rem]",
11722
+ "[&>button]:flex [&>button]:items-center [&>button]:gap-[0.5rem] [&>button]:text-icon4 [&>button:hover]:text-icon5 [&>button]:transition-colors [&>button]:border [&>button]:border-border1 [&>button]:p-[0.25rem] [&>button]:px-[0.5rem] [&>button]:rounded-md",
11723
+ "[&_svg]:w-[1em] [&_svg]:h-[1em] [&_svg]:text-icon3"
12336
11724
  ),
12337
11725
  children: [
12338
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TriangleAlertIcon, {}),
12339
- " ",
12340
- errorMsg || "Something went wrong while fetching the data."
11726
+ typeof currentPage === "number" && currentPage > 0 && /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: onPrevPage, children: [
11727
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeftIcon, {}),
11728
+ "Previous"
11729
+ ] }),
11730
+ hasMore && /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: onNextPage, children: [
11731
+ "Next",
11732
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRightIcon, {})
11733
+ ] })
12341
11734
  ]
12342
11735
  }
12343
- ) }),
12344
- !isLoading && !errorMsg && items?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid border border-border1 border-t-0 bg-surface3 rounded-xl rounded-t-none", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-icon3 text-[0.875rem] text-center h-[3.5rem] items-center flex justify-center", children: searchTerm ? `No results found for "${searchTerm}"` : "No entries found" }) }),
12345
- !errorMsg && items?.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12346
- /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "grid border border-border1 border-t-0 bg-surface3 rounded-xl rounded-t-none overflow-y-auto", children: items.map((item) => {
12347
- return /* @__PURE__ */ jsxRuntime.jsx(
12348
- EntryListItem,
12349
- {
12350
- item,
12351
- selectedItemId,
12352
- onClick: isLoading ? void 0 : onItemClick,
12353
- columns,
12354
- isLoading,
12355
- children: (columns || []).map((col, index) => {
12356
- const isValidReactElement = React.isValidElement(item?.[col.name]);
12357
- const key = `${index}-${item.id}`;
12358
- return isValidReactElement ? /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: item?.[col.name] }, key) : /* @__PURE__ */ jsxRuntime.jsx(EntryListTextCell, { isLoading, children: item?.[col.name] }, key);
12359
- })
12360
- },
12361
- item.id
12362
- );
12363
- }) }),
12364
- setEndOfListElement && /* @__PURE__ */ jsxRuntime.jsxs(
12365
- "div",
12366
- {
12367
- ref: setEndOfListElement,
12368
- className: "text-[0.875rem] text-icon3 opacity-50 flex mt-[2rem] justify-center",
12369
- children: [
12370
- isLoadingNextPage && "Loading...",
12371
- !hasMore && !isLoadingNextPage && !isLoading && "No more data to load"
12372
- ]
12373
- }
12374
- ),
12375
- typeof page === "number" && typeof perPage === "number" && typeof total === "number" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex pt-[1.5rem] items-center justify-center text-icon3 text-[0.875rem] gap-[2rem]"), children: [
12376
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
12377
- "Page ",
12378
- page ? page + 1 : "1"
12379
- ] }),
12380
- /* @__PURE__ */ jsxRuntime.jsxs(
12381
- "div",
12382
- {
12383
- className: cn(
12384
- "flex gap-[1rem]",
12385
- "[&>button]:flex [&>button]:items-center [&>button]:gap-[0.5rem] [&>button]:text-icon4 [&>button:hover]:text-icon5 [&>button]:transition-colors [&>button]:border [&>button]:border-border1 [&>button]:p-[0.25rem] [&>button]:px-[0.5rem] [&>button]:rounded-md",
12386
- " [&_svg]:w-[1em] [&_svg]:h-[1em] [&_svg]:text-icon3"
12387
- ),
12388
- children: [
12389
- typeof page === "number" && page > 0 && /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: onPrevPage, disabled: page === 0, children: [
12390
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeftIcon, {}),
12391
- "Previous"
12392
- ] }),
12393
- hasMore && /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: onNextPage, disabled: !hasMore, children: [
12394
- "Next",
12395
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRightIcon, {})
12396
- ] })
12397
- ]
12398
- }
12399
- )
12400
- ] })
11736
+ )
11737
+ ] });
11738
+ }
11739
+
11740
+ function EntryListEntryTextCol({ children, isLoading }) {
11741
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-icon4 text-[0.875rem] truncate ", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface4 rounded-md animate-pulse text-transparent h-[1rem] select-none" }) : children });
11742
+ }
11743
+ function EntryListEntryStatusCol({ status }) {
11744
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex justify-center items-center w-full relative"), children: [
11745
+ status ? /* @__PURE__ */ jsxRuntime.jsx(
11746
+ "div",
11747
+ {
11748
+ className: cn("w-[0.6rem] h-[0.6rem] rounded-full", {
11749
+ "bg-green-600": status === "success",
11750
+ "bg-red-700": status === "failed"
11751
+ })
11752
+ }
11753
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-icon2 text-[0.75rem] leading-none", children: "-" }),
11754
+ /* @__PURE__ */ jsxRuntime.jsxs(VisuallyHidden.VisuallyHidden, { children: [
11755
+ "Status: ",
11756
+ status ? status : "not provided"
12401
11757
  ] })
12402
11758
  ] });
12403
11759
  }
12404
11760
 
12405
- function EntryListToolbar({ children, className }) {
12406
- return /* @__PURE__ */ jsxRuntime.jsx(
12407
- "div",
12408
- {
12409
- className: cn("flex justify-between bg-surface4 z-[1] mt-[1rem] mb-[1rem] rounded-lg px-[1.5rem] ", className),
12410
- children
12411
- }
12412
- );
11761
+ const EntryList = Object.assign(EntryListRoot, {
11762
+ Header: EntryListHeader,
11763
+ Trim: EntryListTrim,
11764
+ Entries: EntryListEntries,
11765
+ Entry: EntryListEntry,
11766
+ Message: EntryListMessage,
11767
+ NextPageLoading: EntryListNextPageLoading,
11768
+ Pagination: EntryListPagination,
11769
+ EntryText: EntryListEntryTextCol,
11770
+ EntryStatus: EntryListEntryStatusCol
11771
+ });
11772
+
11773
+ const widths = ["75%", "50%", "65%", "90%", "60%", "80%"];
11774
+ function EntryListEntriesSkeleton({ columns, numberOfRows = 3 }) {
11775
+ const getPseudoRandomWidth = (rowIdx, colIdx) => {
11776
+ const index = (rowIdx + colIdx + (columns?.length || 0) + (numberOfRows || 0)) % widths.length;
11777
+ return widths[index];
11778
+ };
11779
+ return /* @__PURE__ */ jsxRuntime.jsx(EntryListEntries, { children: Array.from({ length: numberOfRows }).map((_, rowIdx) => /* @__PURE__ */ jsxRuntime.jsx(EntryListEntry, { columns, children: (columns || []).map((col, colIdx) => {
11780
+ const key = `${col.name}-${colIdx}`;
11781
+ return /* @__PURE__ */ jsxRuntime.jsx(
11782
+ "div",
11783
+ {
11784
+ className: "bg-surface4 rounded-md animate-pulse text-transparent h-[1rem] select-none",
11785
+ style: { width: `${getPseudoRandomWidth(rowIdx, colIdx)}` }
11786
+ },
11787
+ key
11788
+ );
11789
+ }) }, rowIdx)) });
12413
11790
  }
12414
11791
 
12415
- function EntryListPageHeader({ title, description, icon, children }) {
12416
- return /* @__PURE__ */ jsxRuntime.jsxs(
12417
- "div",
12418
- {
12419
- className: cn(
12420
- "grid z-[1] top-0 gap-y-[0.5rem] text-icon4 bg-surface2 py-[3rem]",
12421
- "3xl:h-full 3xl:content-start 3xl:grid-rows-[auto_1fr] h-full 3xl:overflow-y-auto"
12422
- ),
12423
- children: [
12424
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-[1rem] w", children: [
12425
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex gap-[.75em] items-center", "[&>svg]:w-[1.1em] [&>svg]:h-[1.1em] [&>svg]:text-icon4"), children: [
12426
- icon,
12427
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-icon6 text-[1.25rem]", children: title })
12428
- ] }),
12429
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 text-[0.875rem]", children: description })
12430
- ] }),
12431
- children
12432
- ]
12433
- }
12434
- );
11792
+ function EntryListSkeleton({ columns, numberOfRows }) {
11793
+ return /* @__PURE__ */ jsxRuntime.jsx(EntryList, { children: /* @__PURE__ */ jsxRuntime.jsxs(EntryListTrim, { children: [
11794
+ /* @__PURE__ */ jsxRuntime.jsx(EntryListHeader, { columns }),
11795
+ /* @__PURE__ */ jsxRuntime.jsx(EntryListEntriesSkeleton, { columns, numberOfRows })
11796
+ ] }) });
12435
11797
  }
12436
11798
 
12437
- function SideDialog({
11799
+ function getToNextEntryFn({ entries, id, update }) {
11800
+ const currentIndex = entries.findIndex((entry) => entry.id === id);
11801
+ const thereIsNextItem = currentIndex < entries.length - 1;
11802
+ if (thereIsNextItem) {
11803
+ return () => {
11804
+ const nextItem = entries[currentIndex + 1];
11805
+ update(nextItem.id);
11806
+ };
11807
+ }
11808
+ return void 0;
11809
+ }
11810
+ function getToPreviousEntryFn({ entries, id, update }) {
11811
+ const currentIndex = entries.findIndex((entry) => entry.id === id);
11812
+ const thereIsPreviousItem = currentIndex > 0;
11813
+ if (thereIsPreviousItem) {
11814
+ return () => {
11815
+ const previousItem = entries[currentIndex - 1];
11816
+ update(previousItem.id);
11817
+ };
11818
+ }
11819
+ return void 0;
11820
+ }
11821
+
11822
+ function SideDialogRoot({
12438
11823
  dialogTitle,
12439
11824
  dialogDescription,
12440
11825
  isOpen,
12441
11826
  onClose,
12442
11827
  children,
12443
11828
  variant = "default",
12444
- hasCloseButton = true,
11829
+ level = 1,
12445
11830
  className
12446
11831
  }) {
12447
11832
  const isConfirmation = variant === "confirmation";
12448
11833
  return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Root, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Portal, { children: [
12449
- !isConfirmation && /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Overlay, { className: cn("bg-black top-0 bottom-0 right-0 left-0 fixed z-50 opacity-[0.25]") }),
11834
+ !isConfirmation && /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Overlay, { className: cn("bg-black top-0 bottom-0 right-0 left-0 fixed z-50 opacity-40") }),
12450
11835
  /* @__PURE__ */ jsxRuntime.jsxs(
12451
11836
  DialogPrimitive__namespace.Content,
12452
11837
  {
12453
11838
  className: cn(
12454
- "fixed top-0 bottom-0 right-0 border-l border-border1 z-50 bg-surface4",
12455
- "w-[calc(100vw-20rem)] max-w-[50rem]",
12456
- "3xl:max-w-[60rem]",
12457
- "4xl:max-w-[50%]",
12458
- "data-[state=closed]:animate-out data-[state=closed]:fade-out-0",
11839
+ "fixed top-0 bottom-0 right-0 border-l border-border2 z-50 bg-surface2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 ",
12459
11840
  {
12460
- "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-right-1/4": !isConfirmation,
11841
+ "w-[75vw] 2xl:w-[65vw] 4xl:w-[55vw]": level === 1,
11842
+ "w-[70vw] 2xl:w-[59vw] 4xl:w-[48vw]": level === 2,
11843
+ "w-[65vw] 2xl:w-[53vw] 4xl:w-[41vw]": level === 3,
11844
+ "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-right-1/4 shadow-[-3rem_0_2rem_0_rgba(0,0,0,0.75)]": !isConfirmation,
12461
11845
  "bg-surface2/70": isConfirmation
12462
11846
  },
12463
11847
  className
@@ -12467,15 +11851,15 @@ function SideDialog({
12467
11851
  /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Title, { children: dialogTitle }),
12468
11852
  /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Description, { children: dialogDescription })
12469
11853
  ] }),
12470
- !isConfirmation && hasCloseButton && /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
11854
+ !isConfirmation && /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
12471
11855
  "button",
12472
11856
  {
12473
11857
  className: cn(
12474
- "flex appearance-none items-center justify-center rounded-bl-lg h-[3.5rem] w-[3.5rem] absolute too-0 left-[-3.5rem] bg-surface4 text-icon4 border-l border-b border-border1",
11858
+ "flex appearance-none items-center justify-center rounded-bl-lg h-[3.5rem] w-[3.5rem] absolute top-0 left-[-3.5rem] bg-surface2 text-icon4 border-l border-b border-border2",
12475
11859
  "hover:surface5 hover:text-icon5"
12476
11860
  ),
12477
11861
  "aria-label": "Close",
12478
- children: isConfirmation ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsRightIcon, {})
11862
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsRightIcon, {})
12479
11863
  }
12480
11864
  ) }),
12481
11865
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -12493,125 +11877,97 @@ function SideDialog({
12493
11877
  ] }) });
12494
11878
  }
12495
11879
 
12496
- function SideDialogHeader({ children, className }) {
12497
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex justify-between items-center pb-[1rem]", className), children });
11880
+ function MainContentLayout({
11881
+ children,
11882
+ className,
11883
+ style
11884
+ }) {
11885
+ const devStyleRequested = devUIStyleRequested("MainContentLayout");
11886
+ return /* @__PURE__ */ jsxRuntime.jsx(
11887
+ "main",
11888
+ {
11889
+ className: cn(`grid grid-rows-[auto_1fr] h-full items-start content-start`, className),
11890
+ style: { ...style, ...devStyleRequested ? { border: "3px dotted red" } : {} },
11891
+ children
11892
+ }
11893
+ );
12498
11894
  }
12499
-
12500
- function SideDialogFooter({ children, onNext, onPrevious, showInnerNav }) {
12501
- const handleOnNext = () => {
12502
- onNext?.();
12503
- };
12504
- const handleOnPrevious = () => {
12505
- onPrevious?.();
12506
- };
12507
- return /* @__PURE__ */ jsxRuntime.jsxs(
11895
+ function MainContentContent({
11896
+ children,
11897
+ className,
11898
+ isCentered = false,
11899
+ isDivided = false,
11900
+ hasLeftServiceColumn = false,
11901
+ style
11902
+ }) {
11903
+ const devStyleRequested = devUIStyleRequested("MainContentContent");
11904
+ return /* @__PURE__ */ jsxRuntime.jsx(
12508
11905
  "div",
12509
11906
  {
12510
11907
  className: cn(
12511
- "flex items-center justify-end gap-[1rem] px-[1.5rem] py-[1rem] min-h-[4rem] border-t border-border1",
11908
+ `grid overflow-y-auto h-full `,
11909
+ `overflow-x-auto min-w-[min-content]`,
12512
11910
  {
12513
- "justify-between": showInnerNav
12514
- }
11911
+ "items-start content-start": !isCentered && !isDivided && !hasLeftServiceColumn,
11912
+ "grid place-items-center": isCentered,
11913
+ "grid-cols-[1fr_1fr]": isDivided && !hasLeftServiceColumn,
11914
+ "grid-cols-[12rem_1fr_1fr]": isDivided && hasLeftServiceColumn,
11915
+ "grid-cols-[auto_1fr]": !isDivided && hasLeftServiceColumn
11916
+ },
11917
+ className
12515
11918
  ),
12516
- children: [
12517
- (onNext || onPrevious) && showInnerNav && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex gap-[1rem]"), children: [
12518
- /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: handleOnNext, disabled: !onNext, variant: "ghost", children: [
12519
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, {}),
12520
- "Close"
12521
- ] }) }),
12522
- /* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: handleOnNext, disabled: !onNext, variant: "ghost", children: [
12523
- "Next",
12524
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUpIcon, {})
12525
- ] }),
12526
- /* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: handleOnPrevious, disabled: !onPrevious, variant: "ghost", children: [
12527
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDownIcon, {}),
12528
- "Previous"
12529
- ] })
12530
- ] }),
12531
- /* @__PURE__ */ jsxRuntime.jsx("div", { children })
12532
- ]
11919
+ style: { ...style, ...devStyleRequested ? { border: "3px dotted orange" } : {} },
11920
+ children
12533
11921
  }
12534
11922
  );
12535
11923
  }
12536
- function SideDialogFooterGroup({ children }) {
12537
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-baseline gap-[1rem]", children });
11924
+ function devUIStyleRequested(name) {
11925
+ try {
11926
+ const raw = localStorage.getItem("add-dev-style-to-components");
11927
+ if (!raw) return false;
11928
+ const components = raw.split(",").map((c) => c.trim()).filter(Boolean);
11929
+ return components.includes(name);
11930
+ } catch (error) {
11931
+ console.error("Error reading or parsing localStorage:", error);
11932
+ return false;
11933
+ }
12538
11934
  }
12539
11935
 
12540
- function SideDialogContent({ children, className, isCentered, isFullHeight, variant }) {
12541
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("p-[3rem] py-[2rem] overflow-y-scroll", className), children: /* @__PURE__ */ jsxRuntime.jsx(
12542
- "div",
12543
- {
12544
- className: cn("grid gap-[2rem] max-w-[50rem] w-full mx-auto pb-[1rem] ", {
12545
- "items-center justify-center h-full content-center": isCentered,
12546
- "min-h-full": isFullHeight,
12547
- "content-start": !isFullHeight && !isCentered
12548
- }),
12549
- children
12550
- }
12551
- ) });
11936
+ function ButtonsGroup({ children, className }) {
11937
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(`flex gap-2 items-center`, "[&>button]:flex-grow", className), children });
11938
+ }
11939
+
11940
+ function Sections({ children, className }) {
11941
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("grid gap-[3rem]", className), children });
11942
+ }
11943
+
11944
+ function SectionRoot({ children, className }) {
11945
+ return /* @__PURE__ */ jsxRuntime.jsx("section", { className: cn(`grid gap-[1rem]`, className), children });
11946
+ }
11947
+
11948
+ function SectionHeader({ children, className }) {
11949
+ return /* @__PURE__ */ jsxRuntime.jsx("header", { className: cn("grid items-center grid-cols-[1fr_auto]", className), children });
12552
11950
  }
12553
- function SideDialogSection({ children }) {
11951
+
11952
+ function SectionHeading({ headingLevel = "h2", children, className }) {
11953
+ const HeadingTag = headingLevel;
12554
11954
  return /* @__PURE__ */ jsxRuntime.jsx(
12555
- "div",
11955
+ HeadingTag,
12556
11956
  {
12557
11957
  className: cn(
12558
- "grid text-[0.875rem] text-icon5 gap-[1rem] justify-items-start",
12559
- "[&>h3]:text-icon3 [&>h3]:text-[1rem] [&>h3]:font-semibold [&>h3]:border-b [&>h3]:border-border1 [&>h3]:pb-[1rem] [&>h3]:pr-[1rem] [&>h3]:inline-flex [&>h3]:gap-[.5rem] [&>h3]:items-center",
12560
- "[&>h3>svg]:w-[1em] [&>h3>svg]:h-[1em] [&>h3>svg]:text-icon3"
11958
+ "flex items-center gap-[0.5em] text-[0.9375rem] font-bold text-icon4",
11959
+ "[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-50",
11960
+ className
12561
11961
  ),
12562
11962
  children
12563
11963
  }
12564
11964
  );
12565
11965
  }
12566
- function SideDialogKeyValueList({ items, className }) {
12567
- return /* @__PURE__ */ jsxRuntime.jsx("dl", { className: cn("grid grid-cols-[auto_1fr] gap-x-[2rem] gap-y-[.5rem] text-[0.875rem] content-start", className), children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12568
- /* @__PURE__ */ jsxRuntime.jsxs("dt", { className: "text-icon3", children: [
12569
- item.key,
12570
- ":"
12571
- ] }),
12572
- /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "text-icon4", children: item.value })
12573
- ] })) });
12574
- }
12575
11966
 
12576
- function SideDialogTop({ children, onNext, onPrevious, showInnerNav, className }) {
12577
- const handleOnNext = () => {
12578
- onNext?.();
12579
- };
12580
- const handleOnPrevious = () => {
12581
- onPrevious?.();
12582
- };
12583
- return /* @__PURE__ */ jsxRuntime.jsx(
12584
- "div",
12585
- {
12586
- className: cn(`flex justify-between h-[3.5rem] items-center text-icon5 text-[.875rem] pl-[1.5rem]`, className),
12587
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center gap-[2rem]", "[&_svg]:w-[1.1em] [&_svg]:h-[1.1em] [&_svg]:text-icon3"), children: [
12588
- children,
12589
- (onNext || onPrevious) && showInnerNav && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12590
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-icon3", children: "|" }),
12591
- /* @__PURE__ */ jsxRuntime.jsxs(
12592
- "div",
12593
- {
12594
- className: cn(
12595
- "flex gap-[1rem] items-baseline"
12596
- // '[&>button]:text-[0.875rem] [&>button]:flex [&>button]:items-center [&>button]:px-[0.5rem] [&>button]:py-[0.8rem] [&>button]:leading-[1]',
12597
- ),
12598
- children: [
12599
- /* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: handleOnPrevious, disabled: !onPrevious, variant: "ghost", children: [
12600
- "Previous",
12601
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUpIcon, {})
12602
- ] }),
12603
- /* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: handleOnNext, disabled: !onNext, variant: "ghost", children: [
12604
- "Next",
12605
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDownIcon, {})
12606
- ] })
12607
- ]
12608
- }
12609
- )
12610
- ] })
12611
- ] })
12612
- }
12613
- );
12614
- }
11967
+ const Section = Object.assign(SectionRoot, {
11968
+ Header: SectionHeader,
11969
+ Heading: SectionHeading
11970
+ });
12615
11971
 
12616
11972
  const useCodemirrorTheme = () => {
12617
11973
  return React.useMemo(
@@ -12629,7 +11985,7 @@ const useCodemirrorTheme = () => {
12629
11985
  []
12630
11986
  );
12631
11987
  };
12632
- function SideDialogCodeSection({ codeStr = "", title, simplified = false }) {
11988
+ function SideDialogCodeSection({ codeStr = "", title, icon, simplified = false }) {
12633
11989
  const theme = useCodemirrorTheme();
12634
11990
  const [showAsMultilineText, setShowAsMultilineText] = React.useState(false);
12635
11991
  const hasMultilineText = React.useMemo(() => {
@@ -12641,22 +11997,19 @@ function SideDialogCodeSection({ codeStr = "", title, simplified = false }) {
12641
11997
  }
12642
11998
  }, [codeStr]);
12643
11999
  const finalCodeStr = showAsMultilineText ? codeStr?.replace(/\\n/g, "\n") : codeStr;
12644
- return /* @__PURE__ */ jsxRuntime.jsx("section", { className: "border border-border1 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-b border-border1 last:border-b-0 grid", children: [
12645
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-[1rem] px-[1.5rem] border-b border-border1 grid grid-cols-[1fr_auto]", children: [
12646
- /* @__PURE__ */ jsxRuntime.jsx("h3", { children: title }),
12647
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 items-center justify-end", children: [
12000
+ return /* @__PURE__ */ jsxRuntime.jsxs(Section, { children: [
12001
+ /* @__PURE__ */ jsxRuntime.jsxs(Section.Header, { children: [
12002
+ /* @__PURE__ */ jsxRuntime.jsxs(Section.Heading, { children: [
12003
+ icon,
12004
+ title
12005
+ ] }),
12006
+ /* @__PURE__ */ jsxRuntime.jsxs(ButtonsGroup, { children: [
12648
12007
  /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { content: codeStr || "No content" }),
12649
12008
  hasMultilineText && /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", onClick: () => setShowAsMultilineText(!showAsMultilineText), children: showAsMultilineText ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignLeftIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignJustifyIcon, {}) })
12650
12009
  ] })
12651
12010
  ] }),
12652
- /* @__PURE__ */ jsxRuntime.jsx(
12653
- "div",
12654
- {
12655
- className: cn("bg-surface3 p-[1rem] overflow-auto text-icon4 text-[0.875rem] [&>div]:border-none break-all"),
12656
- children: codeStr && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: simplified ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-icon4 text-[0.875rem] py-[1rem] font-mono break-all mx-[1.5rem]", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-wrap", children: codeStr }) }) : /* @__PURE__ */ jsxRuntime.jsx(CodeMirror, { extensions: [langJson.json(), CodeMirror.EditorView.lineWrapping], theme, value: finalCodeStr }) })
12657
- }
12658
- )
12659
- ] }) });
12011
+ codeStr && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-black/20 p-[1rem] overflow-hidden rounded-xl border border-white/10 text-icon4 text-[0.875rem] break-all", children: simplified ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-icon4 font-mono break-all px-[0.5rem]", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-wrap", children: codeStr }) }) : /* @__PURE__ */ jsxRuntime.jsx(CodeMirror, { extensions: [langJson.json(), CodeMirror.EditorView.lineWrapping], theme, value: finalCodeStr }) })
12012
+ ] });
12660
12013
  }
12661
12014
  function containsInnerNewline(obj) {
12662
12015
  if (typeof obj === "string") {
@@ -12689,6 +12042,69 @@ function SideDialogHeading({ children, className, as = "h1" }) {
12689
12042
  );
12690
12043
  }
12691
12044
 
12045
+ function SideDialogContent({ children, className }) {
12046
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("p-[1.5rem] pl-[2.25rem] overflow-y-scroll grid gap-[1.5rem] content-start", className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("grid gap-[1.5rem] mb-[2rem] "), children }) });
12047
+ }
12048
+
12049
+ function SideDialogHeader({ children, className }) {
12050
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex justify-between items-center pb-[1rem]", className), children });
12051
+ }
12052
+
12053
+ function SideDialogTop({ children, withTopSeparator, className }) {
12054
+ return /* @__PURE__ */ jsxRuntime.jsx(
12055
+ "div",
12056
+ {
12057
+ className: cn(
12058
+ `flex h-[3.5rem] items-center text-icon5 text-[.875rem] pl-[1.5rem] relative gap-[1rem]`,
12059
+ '[&:after]:content-[""] [&:after]:absolute [&:after]:left-[1.5rem] [&:after]:right-[1.5rem] [&:after]:bottom-0 [&:after]:border-b [&:after]:border-border1',
12060
+ {
12061
+ '[&:before]:content-[""] [&:before]:absolute [&:before]:left-[1.5rem] [&:before]:right-[1.5rem] [&:before]:top-0 [&:before]:border-t [&:before]:border-border1': withTopSeparator
12062
+ },
12063
+ className
12064
+ ),
12065
+ children
12066
+ }
12067
+ );
12068
+ }
12069
+
12070
+ function SideDialogNav({ onNext, onPrevious, className }) {
12071
+ const handleOnNext = () => {
12072
+ onNext?.();
12073
+ };
12074
+ const handleOnPrevious = () => {
12075
+ onPrevious?.();
12076
+ };
12077
+ return /* @__PURE__ */ jsxRuntime.jsx(
12078
+ "div",
12079
+ {
12080
+ className: cn(
12081
+ "flex items-center gap-[1rem]",
12082
+ "[&_svg]:w-[1.1em] [&_svg]:h-[1.1em] [&_svg]:text-icon3",
12083
+ className
12084
+ ),
12085
+ children: (onNext || onPrevious) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex gap-[1rem] items-baseline"), children: [
12086
+ /* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: handleOnPrevious, disabled: !onPrevious, variant: "ghost", children: [
12087
+ "Previous",
12088
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUpIcon, {})
12089
+ ] }),
12090
+ /* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: handleOnNext, disabled: !onNext, variant: "ghost", children: [
12091
+ "Next",
12092
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDownIcon, {})
12093
+ ] })
12094
+ ] })
12095
+ }
12096
+ );
12097
+ }
12098
+
12099
+ const SideDialog = Object.assign(SideDialogRoot, {
12100
+ Top: SideDialogTop,
12101
+ Header: SideDialogHeader,
12102
+ Heading: SideDialogHeading,
12103
+ Content: SideDialogContent,
12104
+ CodeSection: SideDialogCodeSection,
12105
+ Nav: SideDialogNav
12106
+ });
12107
+
12692
12108
  function EntityMainHeader({
12693
12109
  title,
12694
12110
  description,
@@ -12723,26 +12139,36 @@ function EntityMainHeader({
12723
12139
  }
12724
12140
 
12725
12141
  function PageHeader({ title, description, icon, className }) {
12726
- return /* @__PURE__ */ jsxRuntime.jsxs(
12727
- "header",
12728
- {
12729
- className: cn(
12730
- "grid gap-[.5rem] pt-[2rem] pb-[2rem]",
12731
- "[&>h1]:text-icon6 [&>h1]:text-[1.25rem] [&>h1]:font-normal [&>h1]:flex [&>h1]:items-center [&>h1]:gap-[0.5rem]",
12732
- "[&_svg]:w-[1.4rem] [&_svg]:h-[1.4rem] [&_svg]:text-icon3",
12733
- "[&>p]:text-icon4 [&>p]:text-[0.875rem] [&>p]:m-0",
12734
- className
12735
- ),
12736
- children: [
12737
- /* @__PURE__ */ jsxRuntime.jsxs("h1", { children: [
12142
+ const titleIsLoading = title === "loading";
12143
+ const descriptionIsLoading = description === "loading";
12144
+ return /* @__PURE__ */ jsxRuntime.jsxs("header", { className: cn("grid gap-[.5rem] pt-[2rem] pb-[2rem]", className), children: [
12145
+ /* @__PURE__ */ jsxRuntime.jsx(
12146
+ "h1",
12147
+ {
12148
+ className: cn(
12149
+ "text-icon6 text-[1.25rem] font-normal flex items-center gap-[0.5rem]",
12150
+ "[&>svg]:w-[1.4rem] [&>svg]:h-[1.4rem] [&>svg]:text-icon3",
12151
+ {
12152
+ "bg-surface4 w-[15rem] max-w-[50%] rounded-md animate-pulse": titleIsLoading
12153
+ }
12154
+ ),
12155
+ children: titleIsLoading ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: " " }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12738
12156
  icon && icon,
12739
12157
  " ",
12740
12158
  title
12741
- ] }),
12742
- description && /* @__PURE__ */ jsxRuntime.jsx("p", { children: description })
12743
- ]
12744
- }
12745
- );
12159
+ ] })
12160
+ }
12161
+ ),
12162
+ description && /* @__PURE__ */ jsxRuntime.jsx(
12163
+ "p",
12164
+ {
12165
+ className: cn("text-icon4 text-[0.875rem] m-0", {
12166
+ "bg-surface4 w-[40rem] max-w-[80%] rounded-md animate-pulse": descriptionIsLoading
12167
+ }),
12168
+ children: descriptionIsLoading ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: " " }) : description
12169
+ }
12170
+ )
12171
+ ] });
12746
12172
  }
12747
12173
 
12748
12174
  function DatePicker({ className, classNames, showOutsideDays = true, ...props }) {
@@ -13053,67 +12479,357 @@ const DateTimePickerContent = ({
13053
12479
  }
13054
12480
  ),
13055
12481
  /* @__PURE__ */ jsxRuntime.jsx(
13056
- TimePicker,
12482
+ TimePicker,
12483
+ {
12484
+ onValueChange: handleTimeStrChange,
12485
+ className: "m-4 mt-0 w-auto",
12486
+ defaultValue: value ? dateFns.formatDate(new Date(value), "hh:mm a") : defaultTimeStrValue
12487
+ }
12488
+ ),
12489
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[1fr_auto] gap-[0.5rem] m-4 mt-0", children: [
12490
+ /* @__PURE__ */ jsxRuntime.jsx(
12491
+ Button,
12492
+ {
12493
+ variant: "primary",
12494
+ tabIndex: 0,
12495
+ onClick: () => {
12496
+ dateInputValueIsValid ? handleApply() : handleCancel();
12497
+ },
12498
+ children: newValueDefined ? `Apply` : `Cancel`
12499
+ }
12500
+ ),
12501
+ newValueDefined && /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outline", tabIndex: 0, onClick: handleClear, children: "Clear" })
12502
+ ] })
12503
+ ]
12504
+ }
12505
+ );
12506
+ };
12507
+ const DefaultTrigger = React__namespace.forwardRef(
12508
+ ({ value, placeholder, className, ...props }, ref) => {
12509
+ return /* @__PURE__ */ jsxRuntime.jsxs(Button, { ref, variant: "outline", className: cn("justify-start", className), ...props, children: [
12510
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, { className: "h-4 w-4" }),
12511
+ value ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-white", children: dateFns.format(value, "PP p") }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray", children: placeholder ?? "Pick a date" })
12512
+ ] });
12513
+ }
12514
+ );
12515
+
12516
+ function TextAndIcon({ children, className }) {
12517
+ return /* @__PURE__ */ jsxRuntime.jsx(
12518
+ "span",
12519
+ {
12520
+ className: cn(
12521
+ "flex items-center gap-[0.5em] text-icon4 text-[0.875rem]",
12522
+ "[&>svg]:w-[1.1em] [&>svg]:h-[1.1em] [&>svg]:opacity-50 [&_svg]:flex-shrink-0",
12523
+ className
12524
+ ),
12525
+ children
12526
+ }
12527
+ );
12528
+ }
12529
+
12530
+ function getShortId(id) {
12531
+ if (!id) return void 0;
12532
+ return id.slice(0, 8);
12533
+ }
12534
+
12535
+ function Notification({ children, className, isVisible, autoDismiss = true, dismissTime = 5e3 }) {
12536
+ const [localIsVisible, setLocalIsVisible] = React.useState(isVisible);
12537
+ React.useEffect(() => {
12538
+ if (autoDismiss && isVisible) {
12539
+ const timer = setTimeout(() => {
12540
+ setLocalIsVisible(false);
12541
+ }, dismissTime);
12542
+ return () => clearTimeout(timer);
12543
+ }
12544
+ }, [autoDismiss, isVisible, dismissTime]);
12545
+ React.useEffect(() => {
12546
+ setLocalIsVisible(isVisible);
12547
+ }, [isVisible]);
12548
+ if (!localIsVisible) return null;
12549
+ return /* @__PURE__ */ jsxRuntime.jsxs(
12550
+ "div",
12551
+ {
12552
+ className: cn(
12553
+ "grid grid-cols-[1fr_auto] gap-[0.5rem] rounded-l bg-white/5 p-[1.5rem] py-[1rem] text-[0.875rem] text-icon3 items-center",
12554
+ "[&>svg]:w-[1.1em] [&>svg]:h-[1.1em] [&>svg]:opacity-50",
12555
+ className
12556
+ ),
12557
+ children: [
12558
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-[0.5rem] items-center", children }),
12559
+ /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", onClick: () => setLocalIsVisible(false), children: [
12560
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, {}),
12561
+ /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden.VisuallyHidden, { children: "Dismiss" })
12562
+ ] })
12563
+ ]
12564
+ }
12565
+ );
12566
+ }
12567
+
12568
+ function MainSidebarNavSeparator({ className }) {
12569
+ return /* @__PURE__ */ jsxRuntime.jsx(
12570
+ "div",
12571
+ {
12572
+ className: cn(
12573
+ "min-h-[1.3rem] relative",
12574
+ '[&:after]:content-[""] [&:after]:block [&:after]:absolute [&:after]:h-[0px] [&:after]:border-border1 [&:after]:border-t [&:after]:top-[48%] [&:after]:left-[0.75rem] [&:after]:right-[0.75rem]',
12575
+ className
12576
+ )
12577
+ }
12578
+ );
12579
+ }
12580
+
12581
+ function MainSidebarRoot({ children, className }) {
12582
+ const { state, toggleSidebar } = useMainSidebar();
12583
+ const isCollapsed = state === "collapsed";
12584
+ return /* @__PURE__ */ jsxRuntime.jsxs(
12585
+ "div",
12586
+ {
12587
+ className: cn(
12588
+ "flex flex-col h-full px-[1rem] pb-[1rem] relative overflow-y-auto",
12589
+ {
12590
+ "lg:min-w-[13rem] xl:min-w-[14rem] 2xl:min-w-[15rem] 3xl:min-w-[16rem] 4xl:min-w-[17rem]": !isCollapsed
12591
+ },
12592
+ className
12593
+ ),
12594
+ children: [
12595
+ children,
12596
+ /* @__PURE__ */ jsxRuntime.jsx(MainSidebarNavSeparator, {}),
12597
+ /* @__PURE__ */ jsxRuntime.jsx(
12598
+ "button",
12599
+ {
12600
+ onClick: toggleSidebar,
12601
+ className: cn(
12602
+ "inline-flex w-auto items-center text-icon3 h-[2rem] px-[0.75rem] rounded-md",
12603
+ "hover:bg-surface4",
12604
+ "[&_svg]:w-[1rem] [&_svg]:h-[1rem] [&_svg]:text-icon3",
12605
+ {
12606
+ "ml-auto": !isCollapsed
12607
+ }
12608
+ ),
12609
+ "aria-label": "Toggle sidebar",
12610
+ children: /* @__PURE__ */ jsxRuntime.jsx(
12611
+ lucideReact.PanelRightIcon,
12612
+ {
12613
+ className: cn({
12614
+ "rotate-180": isCollapsed
12615
+ })
12616
+ }
12617
+ )
12618
+ }
12619
+ ),
12620
+ /* @__PURE__ */ jsxRuntime.jsx(
12621
+ "button",
13057
12622
  {
13058
- onValueChange: handleTimeStrChange,
13059
- className: "m-4 mt-0 w-auto",
13060
- defaultValue: value ? dateFns.formatDate(new Date(value), "hh:mm a") : defaultTimeStrValue
12623
+ onClick: toggleSidebar,
12624
+ className: cn("w-[.75rem] h-full right-0 top-0 absolute opacity-10", {
12625
+ "cursor-w-resize": !isCollapsed,
12626
+ "cursor-e-resize": isCollapsed
12627
+ }),
12628
+ "aria-label": "Toggle sidebar"
13061
12629
  }
13062
- ),
13063
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[1fr_auto] gap-[0.5rem] m-4 mt-0", children: [
13064
- /* @__PURE__ */ jsxRuntime.jsx(
13065
- Button,
13066
- {
13067
- variant: "primary",
13068
- tabIndex: 0,
13069
- onClick: () => {
13070
- dateInputValueIsValid ? handleApply() : handleCancel();
13071
- },
13072
- children: newValueDefined ? `Apply` : `Cancel`
13073
- }
13074
- ),
13075
- newValueDefined && /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "outline", tabIndex: 0, onClick: handleClear, children: "Clear" })
13076
- ] })
12630
+ )
13077
12631
  ]
13078
12632
  }
13079
12633
  );
13080
- };
13081
- const DefaultTrigger = React__namespace.forwardRef(
13082
- ({ value, placeholder, className, ...props }, ref) => {
13083
- return /* @__PURE__ */ jsxRuntime.jsxs(Button, { ref, variant: "outline", className: cn("justify-start", className), ...props, children: [
13084
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarIcon, { className: "h-4 w-4" }),
13085
- value ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-white", children: dateFns.format(value, "PP p") }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray", children: placeholder ?? "Pick a date" })
13086
- ] });
13087
- }
13088
- );
12634
+ }
13089
12635
 
13090
- function TextAndIcon({ children, className }) {
12636
+ function MainSidebarBottom({ children, className }) {
12637
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("mt-auto", className), children });
12638
+ }
12639
+
12640
+ function MainSidebarNav({ children, className }) {
12641
+ return /* @__PURE__ */ jsxRuntime.jsx("nav", { className: cn("", className), children });
12642
+ }
12643
+
12644
+ function MainSidebarNavSection({ children, className }) {
12645
+ return /* @__PURE__ */ jsxRuntime.jsx("section", { className: cn("grid items-start content-center relative", className), children });
12646
+ }
12647
+
12648
+ function MainSidebarNavLink({
12649
+ link,
12650
+ state = "default",
12651
+ children,
12652
+ isActive,
12653
+ className
12654
+ }) {
12655
+ const { Link } = useLinkComponent();
12656
+ const isDefaultState = state === "default";
12657
+ const isFeatured = link?.variant === "featured";
12658
+ const linkParams = link?.url?.startsWith("http") ? { target: "_blank", rel: "noreferrer" } : {};
13091
12659
  return /* @__PURE__ */ jsxRuntime.jsx(
13092
- "span",
12660
+ "li",
13093
12661
  {
13094
12662
  className: cn(
13095
- "flex items-center gap-[0.5em] text-icon4 text-[0.875rem]",
13096
- "[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-50 [&_svg]:flex-shrink-0",
12663
+ "flex ",
12664
+ "[&>a]:flex [&>a]:items-center [&>a]:min-h-[2rem] [&>a]:gap-[10px] [&>a]:text-[0.8125rem] [&>a]:text-icon3 [&>a]:py-[6px] [&>a]:px-[0.75rem] [&>a]:w-full [&>a]:rounded-lg [&>a]:justify-center",
12665
+ "[&_svg]:w-[1rem] [&_svg]:h-[1rem] [&_svg]:text-icon3/60",
12666
+ "[&>a:hover]:bg-surface4 [&>a:hover]:text-icon5 [&>a:hover_svg]:text-icon3",
12667
+ {
12668
+ "[&>a]:text-icon5 [&>a]:bg-surface3": isActive,
12669
+ "[&_svg]:text-icon5": isActive,
12670
+ "[&>a]:justify-start ": isDefaultState,
12671
+ "[&_svg]:text-icon3": !isDefaultState,
12672
+ "[&>a]:rounded-md [&>a]:my-[0.5rem] [&>a]:bg-accent1/75 [&>a:hover]:bg-accent1/85 [&>a]:text-black [&>a:hover]:text-black": isFeatured,
12673
+ "[&_svg]:text-black/75": isFeatured
12674
+ },
13097
12675
  className
13098
12676
  ),
13099
- children
12677
+ children: link ? /* @__PURE__ */ jsxRuntime.jsxs(Link, { href: link.url, ...linkParams, children: [
12678
+ isDefaultState ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: link.icon && link.icon }) : /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
12679
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: link.icon && link.icon }),
12680
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "right", align: "center", className: "bg-border1 text-icon6 ml-[1rem]", children: link.name })
12681
+ ] }),
12682
+ isDefaultState ? link.name : /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden.VisuallyHidden, { children: link.name }),
12683
+ " ",
12684
+ children
12685
+ ] }) : children
13100
12686
  }
13101
12687
  );
13102
12688
  }
13103
12689
 
13104
- function getShortId(id) {
13105
- if (!id) return void 0;
13106
- return id.slice(0, 8);
12690
+ function MainSidebarNavHeader({ children, className, state = "default" }) {
12691
+ const isDefaultState = state === "default";
12692
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("grid grid-cols-[auto_1fr] items-center min-h-[2.8rem] ", className), children: [
12693
+ /* @__PURE__ */ jsxRuntime.jsx(
12694
+ "header",
12695
+ {
12696
+ className: cn("text-[0.6875rem] uppercase text-icon3/75 tracking-widest", {
12697
+ "pl-[0.75rem]": isDefaultState
12698
+ }),
12699
+ children: isDefaultState ? children : /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden.VisuallyHidden, { children })
12700
+ }
12701
+ ),
12702
+ /* @__PURE__ */ jsxRuntime.jsx(MainSidebarNavSeparator, {})
12703
+ ] });
12704
+ }
12705
+
12706
+ function MainSidebarNavList({ children, className }) {
12707
+ return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: cn("grid gap-[0.25rem] items-start content-center ", className), children });
12708
+ }
12709
+
12710
+ const SIDEBAR_COOKIE_NAME = "sidebar:state";
12711
+ const MainSidebarContext = React.createContext(null);
12712
+ function useMainSidebar() {
12713
+ const context = React.useContext(MainSidebarContext);
12714
+ if (!context) {
12715
+ throw new Error("useMainSidebar must be used within a MainSidebarProvider.");
12716
+ }
12717
+ return context;
12718
+ }
12719
+ function stateInitializer() {
12720
+ const storedState = window.localStorage.getItem(SIDEBAR_COOKIE_NAME);
12721
+ return storedState === "collapsed" ? "collapsed" : "default";
12722
+ }
12723
+ const setLocalStorage = (value) => {
12724
+ window.localStorage.setItem(SIDEBAR_COOKIE_NAME, value.toString());
12725
+ };
12726
+ function MainSidebarProvider({ children }) {
12727
+ const [state, setState] = React.useState(stateInitializer);
12728
+ const toggleSidebar = React.useCallback(() => {
12729
+ setLocalStorage(state === "default" ? "collapsed" : "default");
12730
+ setState(state === "default" ? "collapsed" : "default");
12731
+ }, [state]);
12732
+ const contextValue = React.useMemo(
12733
+ () => ({
12734
+ state,
12735
+ toggleSidebar
12736
+ }),
12737
+ [state, toggleSidebar]
12738
+ );
12739
+ return /* @__PURE__ */ jsxRuntime.jsx(MainSidebarContext.Provider, { value: contextValue, children });
12740
+ }
12741
+
12742
+ const MainSidebar = Object.assign(MainSidebarRoot, {
12743
+ Bottom: MainSidebarBottom,
12744
+ Nav: MainSidebarNav,
12745
+ NavSection: MainSidebarNavSection,
12746
+ NavLink: MainSidebarNavLink,
12747
+ NavHeader: MainSidebarNavHeader,
12748
+ NavList: MainSidebarNavList,
12749
+ NavSeparator: MainSidebarNavSeparator
12750
+ });
12751
+
12752
+ const scoresListColumns = [
12753
+ { name: "date", label: "Date", size: "4.5rem" },
12754
+ { name: "time", label: "Time", size: "6.5rem" },
12755
+ { name: "input", label: "Input", size: "1fr" },
12756
+ { name: "entityId", label: "Entity", size: "10rem" },
12757
+ { name: "score", label: "Score", size: "3rem" }
12758
+ ];
12759
+ function ScoresList({
12760
+ scores,
12761
+ pagination,
12762
+ onScoreClick,
12763
+ onPageChange,
12764
+ errorMsg,
12765
+ selectedScoreId
12766
+ }) {
12767
+ if (!scores) {
12768
+ return null;
12769
+ }
12770
+ const scoresHasMore = pagination?.hasMore;
12771
+ const handleNextPage = () => {
12772
+ if (scoresHasMore) {
12773
+ onPageChange?.(pagination.page + 1);
12774
+ }
12775
+ };
12776
+ const handlePrevPage = () => {
12777
+ if (pagination?.page && pagination.page > 0) {
12778
+ onPageChange?.(pagination.page - 1);
12779
+ }
12780
+ };
12781
+ return /* @__PURE__ */ jsxRuntime.jsxs(EntryList, { children: [
12782
+ /* @__PURE__ */ jsxRuntime.jsxs(EntryList.Trim, { children: [
12783
+ /* @__PURE__ */ jsxRuntime.jsx(EntryList.Header, { columns: scoresListColumns }),
12784
+ errorMsg ? /* @__PURE__ */ jsxRuntime.jsx(EntryList.Message, { message: errorMsg, type: "error" }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: scores.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(EntryList.Entries, { children: scores.map((score) => {
12785
+ const createdAtDate = new Date(score.createdAt);
12786
+ const isTodayDate = dateFns.isToday(createdAtDate);
12787
+ const entry = {
12788
+ id: score.id,
12789
+ date: isTodayDate ? "Today" : dateFns.format(createdAtDate, "MMM dd"),
12790
+ time: dateFns.format(createdAtDate, "h:mm:ss aaa"),
12791
+ input: JSON.stringify(score?.input),
12792
+ entityId: score.entityId,
12793
+ score: score.score
12794
+ };
12795
+ return /* @__PURE__ */ jsxRuntime.jsx(
12796
+ EntryList.Entry,
12797
+ {
12798
+ entry,
12799
+ isSelected: selectedScoreId === score.id,
12800
+ columns: scoresListColumns,
12801
+ onClick: onScoreClick,
12802
+ children: scoresListColumns.map((col, index) => {
12803
+ const key = `${index}-${score.id}`;
12804
+ return /* @__PURE__ */ jsxRuntime.jsx(EntryList.EntryText, { children: entry?.[col.name] }, key);
12805
+ })
12806
+ },
12807
+ entry.id
12808
+ );
12809
+ }) }) : /* @__PURE__ */ jsxRuntime.jsx(EntryList.Message, { message: "No scores for this scorer yet" }) })
12810
+ ] }),
12811
+ /* @__PURE__ */ jsxRuntime.jsx(
12812
+ EntryList.Pagination,
12813
+ {
12814
+ currentPage: pagination?.page || 0,
12815
+ onNextPage: handleNextPage,
12816
+ onPrevPage: handlePrevPage,
12817
+ hasMore: scoresHasMore
12818
+ }
12819
+ )
12820
+ ] });
13107
12821
  }
13108
12822
 
13109
12823
  function ScoreDialog({
13110
- scorer,
13111
12824
  score,
12825
+ scorerName,
13112
12826
  isOpen,
13113
12827
  onClose,
13114
12828
  onNext,
13115
12829
  onPrevious,
13116
- computeTraceLink
12830
+ computeTraceLink,
12831
+ dialogLevel = 1,
12832
+ usageContext = "scorerPage"
13117
12833
  }) {
13118
12834
  const { Link } = useLinkComponent();
13119
12835
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -13123,77 +12839,144 @@ function ScoreDialog({
13123
12839
  dialogDescription: "View and analyze score details",
13124
12840
  isOpen,
13125
12841
  onClose,
13126
- className: cn("w-[calc(100vw-20rem)] max-w-[80%]", "3xl:max-w-[65%]", "4xl:max-w-[55%]"),
12842
+ level: dialogLevel,
13127
12843
  children: [
13128
- /* @__PURE__ */ jsxRuntime.jsx(SideDialogTop, { onNext, onPrevious, showInnerNav: true, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[1rem] text-icon4 text-[0.875rem]", children: [
13129
- /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
12844
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Top, { children: [
12845
+ usageContext === "scorerPage" && /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
13130
12846
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GaugeIcon, {}),
13131
12847
  " ",
13132
- scorer?.config?.name
12848
+ scorerName
12849
+ ] }),
12850
+ usageContext === "aiSpanDialog" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12851
+ /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
12852
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeIcon, {}),
12853
+ " ",
12854
+ getShortId(score?.traceId)
12855
+ ] }),
12856
+ score?.spanId && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12857
+ "›",
12858
+ /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
12859
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeftRightEllipsisIcon, {}),
12860
+ getShortId(score?.spanId)
12861
+ ] })
12862
+ ] })
13133
12863
  ] }),
13134
12864
  "›",
13135
12865
  /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
13136
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.HashIcon, {}),
13137
- score?.id
13138
- ] })
13139
- ] }) }),
13140
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-[1.5rem] px-[2.5rem] overflow-y-auto grid gap-[1.5rem] content-start", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-[1.5rem] mb-[2rem]", children: [
13141
- score?.traceId && /* @__PURE__ */ jsxRuntime.jsx(
13142
- KeyValueList,
13143
- {
13144
- data: [
13145
- {
13146
- label: "Trace ID",
13147
- value: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: computeTraceLink(score?.traceId), children: score?.traceId }),
13148
- key: "traceId"
13149
- },
13150
- ...score?.spanId ? [
12866
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalculatorIcon, {}),
12867
+ getShortId(score?.id)
12868
+ ] }),
12869
+ "|",
12870
+ /* @__PURE__ */ jsxRuntime.jsx(SideDialog.Nav, { onNext, onPrevious })
12871
+ ] }),
12872
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Content, { children: [
12873
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Header, { children: [
12874
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Heading, { children: [
12875
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalculatorIcon, {}),
12876
+ " Score"
12877
+ ] }),
12878
+ /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
12879
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.HashIcon, {}),
12880
+ " ",
12881
+ score?.id
12882
+ ] })
12883
+ ] }),
12884
+ /* @__PURE__ */ jsxRuntime.jsxs(Sections, { children: [
12885
+ /* @__PURE__ */ jsxRuntime.jsx(
12886
+ KeyValueList,
12887
+ {
12888
+ data: [
12889
+ ...usageContext === "aiSpanDialog" ? [
12890
+ {
12891
+ label: "Scorer",
12892
+ value: score?.scorer?.name || "-",
12893
+ key: "scorer-name"
12894
+ }
12895
+ ] : [],
13151
12896
  {
13152
- label: "Span ID",
13153
- value: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: computeTraceLink(score?.traceId, score?.spanId), children: score?.spanId }),
13154
- key: "spanId"
13155
- }
13156
- ] : []
13157
- ],
13158
- LinkComponent: Link
13159
- }
13160
- ),
13161
- /* @__PURE__ */ jsxRuntime.jsx(
13162
- SideDialogCodeSection,
13163
- {
13164
- title: `Score: ${Number.isNaN(score?.score) ? "n/a" : score?.score}`,
13165
- codeStr: score?.reason,
13166
- simplified: true
13167
- }
13168
- ),
13169
- /* @__PURE__ */ jsxRuntime.jsx(SideDialogCodeSection, { title: "Input", codeStr: JSON.stringify(score?.input || null, null, 2) }),
13170
- /* @__PURE__ */ jsxRuntime.jsx(SideDialogCodeSection, { title: "Output", codeStr: JSON.stringify(score?.output || null, null, 2) }),
13171
- /* @__PURE__ */ jsxRuntime.jsx(
13172
- SideDialogCodeSection,
13173
- {
13174
- title: "Preprocess Prompt",
13175
- codeStr: score?.preprocessPrompt || "null",
13176
- simplified: true
13177
- }
13178
- ),
13179
- /* @__PURE__ */ jsxRuntime.jsx(SideDialogCodeSection, { title: "Analyze Prompt", codeStr: score?.analyzePrompt || "null", simplified: true }),
13180
- /* @__PURE__ */ jsxRuntime.jsx(
13181
- SideDialogCodeSection,
13182
- {
13183
- title: "Generate Score Prompt",
13184
- codeStr: score?.generateScorePrompt || "null",
13185
- simplified: true
13186
- }
13187
- ),
13188
- /* @__PURE__ */ jsxRuntime.jsx(
13189
- SideDialogCodeSection,
13190
- {
13191
- title: "Generate Reason Prompt",
13192
- codeStr: score?.generateReasonPrompt || "null",
13193
- simplified: true
13194
- }
13195
- )
13196
- ] }) })
12897
+ label: "Created at",
12898
+ value: score?.createdAt ? format.format(new Date(score?.createdAt), "MMM d, h:mm:ss aaa") : "n/a",
12899
+ key: "date"
12900
+ },
12901
+ ...usageContext !== "aiSpanDialog" ? [
12902
+ {
12903
+ label: "Trace ID",
12904
+ value: score?.traceId ? /* @__PURE__ */ jsxRuntime.jsx(Link, { href: computeTraceLink(score?.traceId), children: score?.traceId }) : "n/a",
12905
+ key: "traceId"
12906
+ },
12907
+ {
12908
+ label: "Span ID",
12909
+ value: score?.traceId && score?.spanId ? /* @__PURE__ */ jsxRuntime.jsx(Link, { href: computeTraceLink(score?.traceId, score?.spanId), children: score?.spanId }) : "n/a",
12910
+ key: "spanId"
12911
+ }
12912
+ ] : []
12913
+ ],
12914
+ LinkComponent: Link
12915
+ }
12916
+ ),
12917
+ /* @__PURE__ */ jsxRuntime.jsx(
12918
+ SideDialog.CodeSection,
12919
+ {
12920
+ title: `Score: ${Number.isNaN(score?.score) ? "n/a" : score?.score}`,
12921
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GaugeIcon, {}),
12922
+ codeStr: score?.reason || "null",
12923
+ simplified: true
12924
+ }
12925
+ ),
12926
+ /* @__PURE__ */ jsxRuntime.jsx(
12927
+ SideDialog.CodeSection,
12928
+ {
12929
+ title: "Input",
12930
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileInputIcon, {}),
12931
+ codeStr: JSON.stringify(score?.input || null, null, 2)
12932
+ }
12933
+ ),
12934
+ /* @__PURE__ */ jsxRuntime.jsx(
12935
+ SideDialog.CodeSection,
12936
+ {
12937
+ title: "Output",
12938
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileOutputIcon, {}),
12939
+ codeStr: JSON.stringify(score?.output || null, null, 2)
12940
+ }
12941
+ ),
12942
+ /* @__PURE__ */ jsxRuntime.jsx(
12943
+ SideDialog.CodeSection,
12944
+ {
12945
+ title: "Preprocess Prompt",
12946
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ReceiptText, {}),
12947
+ codeStr: score?.preprocessPrompt || "null",
12948
+ simplified: true
12949
+ }
12950
+ ),
12951
+ /* @__PURE__ */ jsxRuntime.jsx(
12952
+ SideDialog.CodeSection,
12953
+ {
12954
+ title: "Analyze Prompt",
12955
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ReceiptText, {}),
12956
+ codeStr: score?.analyzePrompt || "null",
12957
+ simplified: true
12958
+ }
12959
+ ),
12960
+ /* @__PURE__ */ jsxRuntime.jsx(
12961
+ SideDialog.CodeSection,
12962
+ {
12963
+ title: "Generate Score Prompt",
12964
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ReceiptText, {}),
12965
+ codeStr: score?.generateScorePrompt || "null",
12966
+ simplified: true
12967
+ }
12968
+ ),
12969
+ /* @__PURE__ */ jsxRuntime.jsx(
12970
+ SideDialog.CodeSection,
12971
+ {
12972
+ title: "Generate Reason Prompt",
12973
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ReceiptText, {}),
12974
+ codeStr: score?.generateReasonPrompt || "null",
12975
+ simplified: true
12976
+ }
12977
+ )
12978
+ ] })
12979
+ ] })
13197
12980
  ]
13198
12981
  }
13199
12982
  );
@@ -13334,7 +13117,7 @@ function ScorersTable({ scorers, isLoading }) {
13334
13117
  return /* @__PURE__ */ jsxRuntime.jsx(EmptyScorersTable, {});
13335
13118
  }
13336
13119
  const filteredRows = rows.filter((row) => row.original.scorer.config.name.toLowerCase().includes(search.toLowerCase()));
13337
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13120
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
13338
13121
  /* @__PURE__ */ jsxRuntime.jsx(SearchbarWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(Searchbar, { onSearch: setSearch, label: "Search scorers", placeholder: "Search scorers" }) }),
13339
13122
  isLoading ? /* @__PURE__ */ jsxRuntime.jsx(ScorersTableSkeleton, {}) : /* @__PURE__ */ jsxRuntime.jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
13340
13123
  /* @__PURE__ */ jsxRuntime.jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsxRuntime.jsx(Th, { style: { width: header.index === 0 ? "auto" : header.column.getSize() }, children: reactTable.flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
@@ -13370,26 +13153,16 @@ const EmptyScorersTable = () => /* @__PURE__ */ jsxRuntime.jsx("div", { classNam
13370
13153
  }
13371
13154
  ) });
13372
13155
 
13373
- const variantClasses$1 = {
13374
- warning: "bg-yellow-900/20 border-sm border-yellow-200 text-yellow-200",
13375
- destructive: "bg-red-900/20 border-sm border-red-200 text-red-200"
13376
- };
13377
- const variantIcons = {
13378
- warning: lucideReact.TriangleAlert,
13379
- destructive: lucideReact.AlertCircle
13380
- };
13381
- const Alert = ({ children, variant = "destructive" }) => {
13382
- const Ico = variantIcons[variant];
13383
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: clsx(variantClasses$1[variant], "p-2 rounded-md"), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
13384
- /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "mt-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(Ico, {}) }),
13385
- /* @__PURE__ */ jsxRuntime.jsx("div", { children })
13386
- ] }) });
13387
- };
13388
- const AlertTitle = ({ children, as: As = "h5" }) => {
13389
- return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: As, variant: "ui-md", className: "font-semibold", children });
13390
- };
13391
- const AlertDescription = ({ children, as: As = "p" }) => {
13392
- return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: As, variant: "ui-sm", children });
13156
+ const useTraceSpanScores = ({ traceId = "", spanId = "", page }) => {
13157
+ const client = react$3.useMastraClient();
13158
+ return reactQuery.useQuery({
13159
+ queryKey: ["trace-span-scores", traceId, spanId, page],
13160
+ queryFn: () => client.getScoresBySpan({ traceId, spanId, page: page || 0, perPage: 10 }),
13161
+ enabled: !!traceId && !!spanId,
13162
+ refetchInterval: 3e3,
13163
+ gcTime: 0,
13164
+ staleTime: 0
13165
+ });
13393
13166
  };
13394
13167
 
13395
13168
  const AgentMetadataModelSwitcher = ({
@@ -13398,6 +13171,8 @@ const AgentMetadataModelSwitcher = ({
13398
13171
  updateModel,
13399
13172
  apiUrl = "/api/agents/providers"
13400
13173
  }) => {
13174
+ const [originalProvider] = React.useState(defaultProvider);
13175
+ const [originalModel] = React.useState(defaultModel);
13401
13176
  const [selectedModel, setSelectedModel] = React.useState(defaultModel);
13402
13177
  const [showModelSuggestions, setShowModelSuggestions] = React.useState(false);
13403
13178
  const [selectedProvider, setSelectedProvider] = React.useState(defaultProvider || "");
@@ -13528,15 +13303,15 @@ const AgentMetadataModelSwitcher = ({
13528
13303
  if (modelInputRef.current === document.activeElement || providerInputRef.current === document.activeElement || showProviderSuggestions || showModelSuggestions) {
13529
13304
  return;
13530
13305
  }
13531
- const providerChanged = currentModelProvider && currentModelProvider !== defaultProvider;
13306
+ const providerChanged = currentModelProvider && currentModelProvider !== originalProvider;
13532
13307
  const modelEmpty = !selectedModel || selectedModel === "";
13533
13308
  if (providerChanged && modelEmpty) {
13534
- setSelectedProvider(cleanProviderId(defaultProvider));
13535
- setSelectedModel(defaultModel);
13536
- if (defaultProvider && defaultModel) {
13309
+ setSelectedProvider(cleanProviderId(originalProvider));
13310
+ setSelectedModel(originalModel);
13311
+ if (originalProvider && originalModel) {
13537
13312
  updateModel({
13538
- provider: defaultProvider,
13539
- modelId: defaultModel
13313
+ provider: originalProvider,
13314
+ modelId: originalModel
13540
13315
  }).catch((error) => {
13541
13316
  console.error("Failed to reset model:", error);
13542
13317
  });
@@ -13551,8 +13326,8 @@ const AgentMetadataModelSwitcher = ({
13551
13326
  registerResetFn,
13552
13327
  currentModelProvider,
13553
13328
  selectedModel,
13554
- defaultProvider,
13555
- defaultModel,
13329
+ originalProvider,
13330
+ originalModel,
13556
13331
  updateModel,
13557
13332
  showProviderSuggestions,
13558
13333
  showModelSuggestions
@@ -13563,6 +13338,27 @@ const AgentMetadataModelSwitcher = ({
13563
13338
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-500", children: "Loading providers..." })
13564
13339
  ] });
13565
13340
  }
13341
+ const handleReset = async () => {
13342
+ setSelectedProvider(cleanProviderId(originalProvider));
13343
+ setSelectedModel(originalModel);
13344
+ setProviderSearch("");
13345
+ setModelSearch("");
13346
+ setIsSearchingProvider(false);
13347
+ setIsSearchingModel(false);
13348
+ setShowProviderSuggestions(false);
13349
+ setShowModelSuggestions(false);
13350
+ try {
13351
+ setLoading(true);
13352
+ await updateModel({
13353
+ provider: originalProvider,
13354
+ modelId: originalModel
13355
+ });
13356
+ } catch (error) {
13357
+ console.error("Failed to reset model:", error);
13358
+ } finally {
13359
+ setLoading(false);
13360
+ }
13361
+ };
13566
13362
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13567
13363
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col xl:flex-row items-stretch xl:items-center gap-2 w-full", children: [
13568
13364
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -13615,6 +13411,7 @@ const AgentMetadataModelSwitcher = ({
13615
13411
  /* @__PURE__ */ jsxRuntime.jsx(
13616
13412
  Input,
13617
13413
  {
13414
+ "aria-label": "Search providers",
13618
13415
  spellCheck: "false",
13619
13416
  ref: providerInputRef,
13620
13417
  className: `w-full ${!isSearchingProvider && currentModelProvider ? "pl-8 pr-8" : ""}`,
@@ -13653,20 +13450,6 @@ const AgentMetadataModelSwitcher = ({
13653
13450
  handleProviderSelect(provider);
13654
13451
  }
13655
13452
  break;
13656
- case "Tab":
13657
- if (!e.shiftKey) {
13658
- e.preventDefault();
13659
- if (highlightedProviderIndex >= 0 && highlightedProviderIndex < filteredProviders2.length) {
13660
- const provider = filteredProviders2[highlightedProviderIndex];
13661
- handleProviderSelect(provider);
13662
- } else {
13663
- setShowProviderSuggestions(false);
13664
- setIsSearchingProvider(false);
13665
- setProviderSearch("");
13666
- setHighlightedProviderIndex(-1);
13667
- }
13668
- }
13669
- break;
13670
13453
  case "Escape":
13671
13454
  e.preventDefault();
13672
13455
  setIsSearchingProvider(false);
@@ -13675,8 +13458,6 @@ const AgentMetadataModelSwitcher = ({
13675
13458
  setShowProviderSuggestions(false);
13676
13459
  break;
13677
13460
  }
13678
- } else if (e.key === "Tab") {
13679
- return;
13680
13461
  }
13681
13462
  },
13682
13463
  onFocus: () => {
@@ -13768,6 +13549,7 @@ const AgentMetadataModelSwitcher = ({
13768
13549
  /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
13769
13550
  Input,
13770
13551
  {
13552
+ "aria-label": "Search models",
13771
13553
  spellCheck: "false",
13772
13554
  ref: modelInputRef,
13773
13555
  className: "w-full xl:w-3/5",
@@ -13820,7 +13602,6 @@ const AgentMetadataModelSwitcher = ({
13820
13602
  }, 0);
13821
13603
  break;
13822
13604
  case "Enter":
13823
- case "Tab":
13824
13605
  e.preventDefault();
13825
13606
  if (highlightedModelIndex >= 0 && highlightedModelIndex < filteredModels.length) {
13826
13607
  const model = filteredModels[highlightedModelIndex];
@@ -13905,14 +13686,26 @@ const AgentMetadataModelSwitcher = ({
13905
13686
  )
13906
13687
  ]
13907
13688
  }
13689
+ ),
13690
+ /* @__PURE__ */ jsxRuntime.jsx(
13691
+ Button$1,
13692
+ {
13693
+ variant: "light",
13694
+ size: "md",
13695
+ onClick: handleReset,
13696
+ disabled: loading,
13697
+ className: "flex items-center gap-1.5 text-xs whitespace-nowrap !border-0",
13698
+ title: "Reset to original model",
13699
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RotateCcw, { className: "w-3.5 h-3.5" })
13700
+ }
13908
13701
  )
13909
13702
  ] }),
13910
13703
  (() => {
13911
13704
  const currentProvider = providers.find((p) => p.id === currentModelProvider);
13912
13705
  if (currentProvider && !currentProvider.connected) {
13913
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-2 p-2", children: /* @__PURE__ */ jsxRuntime.jsxs(Alert, { variant: "warning", children: [
13914
- /* @__PURE__ */ jsxRuntime.jsx(AlertTitle, { as: "h5", children: "Provider not connected" }),
13915
- /* @__PURE__ */ jsxRuntime.jsxs(AlertDescription, { as: "p", children: [
13706
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-2 p-2", children: /* @__PURE__ */ jsxRuntime.jsxs(Alert$1, { variant: "warning", children: [
13707
+ /* @__PURE__ */ jsxRuntime.jsx(AlertTitle$1, { as: "h5", children: "Provider not connected" }),
13708
+ /* @__PURE__ */ jsxRuntime.jsxs(AlertDescription$1, { as: "p", children: [
13916
13709
  "Set the",
13917
13710
  " ",
13918
13711
  /* @__PURE__ */ jsxRuntime.jsx("code", { className: "px-1 py-0.5 bg-yellow-100 dark:bg-yellow-900/50 rounded", children: Array.isArray(currentProvider.envVar) ? currentProvider.envVar.join(", ") : currentProvider.envVar }),
@@ -14053,7 +13846,7 @@ const AgentMetadataNetworkList = ({ agents }) => {
14053
13846
  if (agents.length === 0) {
14054
13847
  return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListEmpty, { children: "No agents" });
14055
13848
  }
14056
- return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: agents.map((agent) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: paths.agentLink(agent.id), children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { variant: "success", icon: /* @__PURE__ */ jsxRuntime.jsx(AgentIcon, {}), children: agent.name }) }) }, agent.id)) });
13849
+ return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: agents.map((agent) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: paths.agentLink(agent.id), "data-testid": "agent-badge", children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { variant: "success", icon: /* @__PURE__ */ jsxRuntime.jsx(AgentIcon, {}), children: agent.name }) }) }, agent.id)) });
14057
13850
  };
14058
13851
  const AgentMetadata = ({
14059
13852
  agentId,
@@ -14086,7 +13879,7 @@ const AgentMetadata = ({
14086
13879
  {
14087
13880
  title: "Model",
14088
13881
  hint: modelVersion === "v2" ? void 0 : {
14089
- link: "https://mastra.ai/en/reference/agents/migration-guide",
13882
+ link: "https://mastra.ai/guides/migrations/vnext-to-standard-apis",
14090
13883
  title: "You are using a legacy v1 model",
14091
13884
  icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangleIcon, { fontSize: 14, className: "mb-0.5" })
14092
13885
  },
@@ -14109,9 +13902,12 @@ const AgentMetadata = ({
14109
13902
  link: "https://mastra.ai/en/docs/agents/agent-memory",
14110
13903
  title: "Agent Memory documentation"
14111
13904
  },
14112
- children: hasMemoryEnabled ? /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(MemoryIcon, {}), variant: "success", className: "font-medium", children: "On" }) : /* @__PURE__ */ jsxRuntime.jsxs(Alert, { variant: "warning", children: [
14113
- /* @__PURE__ */ jsxRuntime.jsx(AlertTitle, { as: "h5", children: "Memory not enabled" }),
14114
- /* @__PURE__ */ jsxRuntime.jsxs(AlertDescription, { as: "p", children: [
13905
+ children: hasMemoryEnabled ? /* @__PURE__ */ jsxRuntime.jsxs(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(MemoryIcon, {}), variant: "success", className: "font-medium", children: [
13906
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Memory is enabled" }),
13907
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: "On" })
13908
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(Alert$1, { variant: "warning", children: [
13909
+ /* @__PURE__ */ jsxRuntime.jsx(AlertTitle$1, { as: "h5", children: "Memory not enabled" }),
13910
+ /* @__PURE__ */ jsxRuntime.jsxs(AlertDescription$1, { as: "p", children: [
14115
13911
  "Thread messages will not be stored. To activate memory, see the",
14116
13912
  " ",
14117
13913
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -14171,14 +13967,14 @@ const AgentMetadataToolList = ({ tools, agentId }) => {
14171
13967
  if (tools.length === 0) {
14172
13968
  return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListEmpty, { children: "No tools" });
14173
13969
  }
14174
- return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: tools.map((tool) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: paths.agentToolLink(agentId, tool.id), children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(ToolsIcon, { className: "text-[#ECB047]" }), children: tool.id }) }) }, tool.id)) });
13970
+ return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: tools.map((tool) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: paths.agentToolLink(agentId, tool.id), "data-testid": "tool-badge", children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(ToolsIcon, { className: "text-[#ECB047]" }), children: tool.id }) }) }, tool.id)) });
14175
13971
  };
14176
13972
  const AgentMetadataWorkflowList = ({ workflows }) => {
14177
13973
  const { Link, paths } = useLinkComponent();
14178
13974
  if (workflows.length === 0) {
14179
13975
  return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListEmpty, { children: "No workflows" });
14180
13976
  }
14181
- return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: workflows.map((workflow) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: paths.workflowLink(workflow.id), children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(WorkflowIcon, { className: "text-accent3" }), children: workflow.name }) }) }, workflow.id)) });
13977
+ return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: workflows.map((workflow) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: paths.workflowLink(workflow.id), "data-testid": "workflow-badge", children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(WorkflowIcon, { className: "text-accent3" }), children: workflow.name }) }) }, workflow.id)) });
14182
13978
  };
14183
13979
  const AgentMetadataScorerList = ({ entityId, entityType }) => {
14184
13980
  const { Link, paths } = useLinkComponent();
@@ -14196,7 +13992,7 @@ const AgentMetadataScorerList = ({ entityId, entityType }) => {
14196
13992
  if (scorerList.length === 0) {
14197
13993
  return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListEmpty, { children: "No Scorers" });
14198
13994
  }
14199
- return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: scorerList.map((scorer) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: paths.scorerLink(scorer.id), children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GaugeIcon, { className: "text-icon3" }), children: scorer.scorer.config.name }) }) }, scorer.id)) });
13995
+ return /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataList, { children: scorerList.map((scorer) => /* @__PURE__ */ jsxRuntime.jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: paths.scorerLink(scorer.id), "data-testid": "scorer-badge", children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GaugeIcon, { className: "text-icon3" }), children: scorer.scorer.config.name }) }) }, scorer.id)) });
14200
13996
  };
14201
13997
 
14202
13998
  const AgentMetadataPrompt = ({ prompt }) => {
@@ -14491,7 +14287,7 @@ function ToolTable({ tools, agents, isLoading }) {
14491
14287
  return /* @__PURE__ */ jsxRuntime.jsx(EmptyToolsTable, {});
14492
14288
  }
14493
14289
  const filteredRows = rows.filter((row) => row.original.id.toLowerCase().includes(search.toLowerCase()));
14494
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
14290
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
14495
14291
  /* @__PURE__ */ jsxRuntime.jsx(SearchbarWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(Searchbar, { onSearch: setSearch, label: "Search tools", placeholder: "Search tools" }) }),
14496
14292
  isLoading ? /* @__PURE__ */ jsxRuntime.jsx(ToolTableSkeleton, {}) : /* @__PURE__ */ jsxRuntime.jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
14497
14293
  /* @__PURE__ */ jsxRuntime.jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsxRuntime.jsx(Th, { style: { width: header.column.getSize() ?? "auto" }, children: reactTable.flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
@@ -16194,12 +15990,51 @@ function TreePositionMark({ isLastChild, hasChildren = false }) {
16194
15990
  'after:content-[""] after:absolute after:left-0 after:top-0 after:bottom-0 after:w-[0px] after:border-r-[0.5px] after:border-white after:border-dashed',
16195
15991
  'before:content-[""] before:absolute before:left-0 before:top-[50%] before:w-full before:h-[0px] before:border-b-[0.5px] before:border-white before:border-dashed',
16196
15992
  {
16197
- "after:bottom-[50%]": isLastChild
16198
- }
16199
- ),
16200
- children: hasChildren && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute -right-[1px] top-[50%] bottom-0 w-[0px] border-r-[0.5px] border-white border-dashed" })
15993
+ "after:bottom-[50%]": isLastChild
15994
+ }
15995
+ ),
15996
+ children: hasChildren && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute -right-[1px] top-[50%] bottom-0 w-[0px] border-r-[0.5px] border-white border-dashed" })
15997
+ }
15998
+ );
15999
+ }
16000
+
16001
+ function TraceTimeline({ hierarchicalSpans = [], onSpanClick, selectedSpanId, isLoading }) {
16002
+ const overallLatency = hierarchicalSpans?.[0]?.latency || 0;
16003
+ const overallStartTime = hierarchicalSpans?.[0]?.startTime || "";
16004
+ const overallEndTime = hierarchicalSpans?.[0]?.endTime || "";
16005
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs(
16006
+ "div",
16007
+ {
16008
+ className: cn(
16009
+ "flex items-center text-[0.875rem] gap-[1rem] bg-surface3/50 rounded-md p-[1.5rem] justify-center text-icon3",
16010
+ "[&_svg]:w-[1.25em] [&_svg]:h-[1.25em] [&_svg]:opacity-50"
16011
+ ),
16012
+ children: [
16013
+ /* @__PURE__ */ jsxRuntime.jsx(Spinner, {}),
16014
+ " Loading Trace Timeline ..."
16015
+ ]
16016
+ }
16017
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
16018
+ "div",
16019
+ {
16020
+ className: cn("grid items-start content-start gap-y-[2px] overflow-hidden", "xl:gap-x-[1rem] xl:py-[1rem]", {
16021
+ "xl:grid-cols-[3fr_auto]": !overallEndTime,
16022
+ "xl:grid-cols-[3fr_2fr]": overallEndTime
16023
+ }),
16024
+ children: hierarchicalSpans?.map((span) => /* @__PURE__ */ jsxRuntime.jsx(
16025
+ TraceTimelineSpan,
16026
+ {
16027
+ span,
16028
+ onSpanClick,
16029
+ selectedSpanId,
16030
+ overallLatency,
16031
+ overallStartTime,
16032
+ overallEndTime
16033
+ },
16034
+ span.id
16035
+ ))
16201
16036
  }
16202
- );
16037
+ ) });
16203
16038
  }
16204
16039
 
16205
16040
  function TraceTimelineLegend({ spans = [] }) {
@@ -16215,65 +16050,6 @@ function TraceTimelineLegend({ spans = [] }) {
16215
16050
  }) });
16216
16051
  }
16217
16052
 
16218
- function TraceTimeline({
16219
- spans = [],
16220
- hierarchicalSpans = [],
16221
- onSpanClick,
16222
- selectedSpanId,
16223
- isLoading,
16224
- className
16225
- }) {
16226
- const overallLatency = hierarchicalSpans?.[0]?.latency || 0;
16227
- const overallStartTime = hierarchicalSpans?.[0]?.startTime || "";
16228
- const overallEndTime = hierarchicalSpans?.[0]?.endTime || "";
16229
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("grid gap-[1rem]", className), children: [
16230
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full justify-between pr-[2.5rem]", children: [
16231
- /* @__PURE__ */ jsxRuntime.jsxs(SideDialogHeading, { as: "h2", children: [
16232
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListTreeIcon, {}),
16233
- " Timeline"
16234
- ] }),
16235
- /* @__PURE__ */ jsxRuntime.jsx(TraceTimelineLegend, { spans })
16236
- ] }),
16237
- isLoading ? /* @__PURE__ */ jsxRuntime.jsxs(
16238
- "div",
16239
- {
16240
- className: cn(
16241
- "flex items-center text-[0.875rem] gap-[1rem] bg-surface3/50 rounded-md p-[1.5rem] mr-[1.5rem] justify-center text-icon3 mt-[.5rem]",
16242
- "[&_svg]:w-[1.25em] [&_svg]:h-[1.25em] [&_svg]:opacity-50"
16243
- ),
16244
- children: [
16245
- /* @__PURE__ */ jsxRuntime.jsx(Spinner, {}),
16246
- " Loading Trace Timeline ..."
16247
- ]
16248
- }
16249
- ) : /* @__PURE__ */ jsxRuntime.jsx(
16250
- "div",
16251
- {
16252
- className: cn(
16253
- "grid items-start content-start gap-y-[2px] bg-surface2 rounded-lg overflow-hidden pl-[1.5rem] py-[1.5rem]",
16254
- "xl:gap-x-[1rem] xl:py-[1rem]",
16255
- {
16256
- "xl:grid-cols-[3fr_auto]": !overallEndTime,
16257
- "xl:grid-cols-[3fr_2fr]": overallEndTime
16258
- }
16259
- ),
16260
- children: hierarchicalSpans?.map((span) => /* @__PURE__ */ jsxRuntime.jsx(
16261
- TraceTimelineSpan,
16262
- {
16263
- span,
16264
- onSpanClick,
16265
- selectedSpanId,
16266
- overallLatency,
16267
- overallStartTime,
16268
- overallEndTime
16269
- },
16270
- span.id
16271
- ))
16272
- }
16273
- )
16274
- ] });
16275
- }
16276
-
16277
16053
  function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
16278
16054
  if (!traceUsage && !spanUsage) {
16279
16055
  console.warn("No usage data available");
@@ -16386,12 +16162,11 @@ function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
16386
16162
  icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CoinsIcon, {})
16387
16163
  }
16388
16164
  };
16389
- let tokenPresentations = {};
16390
- if (hasV5Format) {
16391
- tokenPresentations = { ...commonTokenPresentations, ...v5TokenPresentations };
16392
- } else {
16393
- tokenPresentations = { ...commonTokenPresentations, ...legacyTokenPresentations };
16394
- }
16165
+ let tokenPresentations = {
16166
+ ...commonTokenPresentations,
16167
+ ...v5TokenPresentations,
16168
+ ...legacyTokenPresentations
16169
+ };
16395
16170
  let usageKeyOrder = [];
16396
16171
  if (hasV5Format) {
16397
16172
  usageKeyOrder = ["totalTokens", "inputTokens", "outputTokens", "reasoningTokens", "cachedInputTokens"];
@@ -16399,55 +16174,42 @@ function TraceSpanUsage({ traceUsage, traceSpans = [], spanUsage, className }) {
16399
16174
  usageKeyOrder = ["totalTokens", "promptTokens", "completionTokens"];
16400
16175
  }
16401
16176
  const usageAsArray = Object.entries(traceUsage || spanUsage || {}).map(([key, value]) => ({ key, value })).sort((a, b) => usageKeyOrder.indexOf(a.key) - usageKeyOrder.indexOf(b.key));
16402
- return /* @__PURE__ */ jsxRuntime.jsx(
16177
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex gap-[1.5rem] flex-wrap", className), children: usageAsArray.map(({ key, value }) => /* @__PURE__ */ jsxRuntime.jsxs(
16403
16178
  "div",
16404
16179
  {
16405
- className: cn(
16406
- "grid gap-[1.5rem]",
16407
- {
16408
- "xl:grid-cols-3": usageAsArray.length === 3,
16409
- "xl:grid-cols-2": usageAsArray.length === 2
16410
- },
16411
- className
16412
- ),
16413
- children: usageAsArray.map(({ key, value }) => /* @__PURE__ */ jsxRuntime.jsxs(
16414
- "div",
16415
- {
16416
- className: cn("bg-white/5 p-[1rem] px-[1.25rem] rounded-lg text-[0.875rem]", {
16417
- "min-h-[5.5rem]": traceUsage
16418
- }),
16419
- children: [
16420
- /* @__PURE__ */ jsxRuntime.jsxs(
16421
- "div",
16422
- {
16423
- className: cn(
16424
- "grid grid-cols-[1.5rem_1fr_auto] gap-[.5rem] items-center",
16425
- "[&>svg]:w-[1.5em] [&>svg]:h-[1.5em] [&>svg]:opacity-70"
16426
- ),
16427
- children: [
16428
- tokenPresentations?.[key]?.icon,
16429
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[0.875rem]", children: tokenPresentations?.[key]?.label }),
16430
- /* @__PURE__ */ jsxRuntime.jsx("b", { className: "text-[1rem]", children: value })
16431
- ]
16432
- }
16180
+ className: cn("bg-white/5 p-[.75rem] px-[1rem] rounded-lg text-[0.875rem] flex-grow", {
16181
+ "min-h-[5.5rem]": traceUsage
16182
+ }),
16183
+ children: [
16184
+ /* @__PURE__ */ jsxRuntime.jsxs(
16185
+ "div",
16186
+ {
16187
+ className: cn(
16188
+ "grid grid-cols-[1.5rem_1fr_auto] gap-[.5rem] items-center",
16189
+ "[&>svg]:w-[1.5em] [&>svg]:h-[1.5em] [&>svg]:opacity-70"
16433
16190
  ),
16434
- tokensByProviderValid && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[0.875rem] mt-[0.5rem] pl-[2rem] ", children: Object.entries(tokensByProvider).map(([provider, providerTokens]) => /* @__PURE__ */ jsxRuntime.jsxs(
16435
- "dl",
16436
- {
16437
- className: "grid grid-cols-[1fr_auto] gap-x-[1rem] gap-y-[.25rem] justify-between text-icon3",
16438
- children: [
16439
- /* @__PURE__ */ jsxRuntime.jsx("dt", { children: provider }),
16440
- /* @__PURE__ */ jsxRuntime.jsx("dd", { children: providerTokens?.[key] })
16441
- ]
16442
- },
16443
- provider
16444
- )) })
16445
- ]
16446
- },
16447
- key
16448
- ))
16449
- }
16450
- );
16191
+ children: [
16192
+ tokenPresentations?.[key]?.icon,
16193
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[0.875rem]", children: tokenPresentations?.[key]?.label }),
16194
+ /* @__PURE__ */ jsxRuntime.jsx("b", { className: "text-[1rem]", children: value })
16195
+ ]
16196
+ }
16197
+ ),
16198
+ tokensByProviderValid && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[0.875rem] mt-[0.5rem] pl-[2rem]", children: Object.entries(tokensByProvider).map(([provider, providerTokens]) => /* @__PURE__ */ jsxRuntime.jsxs(
16199
+ "dl",
16200
+ {
16201
+ className: "grid grid-cols-[1fr_auto] gap-x-[1rem] gap-y-[.25rem] justify-between text-icon3",
16202
+ children: [
16203
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { children: provider }),
16204
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { children: providerTokens?.[key] })
16205
+ ]
16206
+ },
16207
+ provider
16208
+ )) })
16209
+ ]
16210
+ },
16211
+ key
16212
+ )) });
16451
16213
  }
16452
16214
 
16453
16215
  function useTraceInfo(trace) {
@@ -16530,253 +16292,199 @@ function getSpanInfo({ span, withTraceId = true, withSpanId = true }) {
16530
16292
  return baseInfo;
16531
16293
  }
16532
16294
 
16533
- const ScoreTable = ({ scores, onItemClick }) => {
16534
- return /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
16535
- /* @__PURE__ */ jsxRuntime.jsxs(Thead, { children: [
16536
- /* @__PURE__ */ jsxRuntime.jsx(Th, { children: "Type" }),
16537
- /* @__PURE__ */ jsxRuntime.jsx(Th, { children: "Scorer" }),
16538
- /* @__PURE__ */ jsxRuntime.jsx(Th, { children: "Score" }),
16539
- /* @__PURE__ */ jsxRuntime.jsx(Th, { children: "Created At" })
16540
- ] }),
16541
- /* @__PURE__ */ jsxRuntime.jsx(Tbody, { children: scores.map((score) => /* @__PURE__ */ jsxRuntime.jsxs(Row, { onClick: () => onItemClick(score.scorerName), children: [
16542
- /* @__PURE__ */ jsxRuntime.jsx(TxtCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { children: score.type }) }),
16543
- /* @__PURE__ */ jsxRuntime.jsx(TxtCell, { children: score.scorerName }),
16544
- /* @__PURE__ */ jsxRuntime.jsx(TxtCell, { children: score.score }),
16545
- /* @__PURE__ */ jsxRuntime.jsx(DateTimeCell, { dateTime: new Date(score.createdAt) })
16546
- ] }, score.scoreId)) })
16547
- ] });
16295
+ const TabsRoot = ({
16296
+ children,
16297
+ defaultTab,
16298
+ value,
16299
+ onValueChange,
16300
+ className
16301
+ }) => {
16302
+ const [internalTab, setInternalTab] = React.useState(defaultTab);
16303
+ const isControlled = value !== void 0 && onValueChange !== void 0;
16304
+ const currentTab = isControlled ? value : internalTab;
16305
+ const handleTabChange = (newValue) => {
16306
+ const typedValue = newValue;
16307
+ if (isControlled) {
16308
+ onValueChange(typedValue);
16309
+ } else {
16310
+ setInternalTab(typedValue);
16311
+ }
16312
+ };
16313
+ return /* @__PURE__ */ jsxRuntime.jsx(
16314
+ TabsPrimitive__namespace.Root,
16315
+ {
16316
+ value: currentTab,
16317
+ onValueChange: handleTabChange,
16318
+ className: cn("grid gap-[3rem] overflow-y-auto", className),
16319
+ children
16320
+ }
16321
+ );
16548
16322
  };
16549
16323
 
16550
- function SpanDetails({ span, onScorerTriggered }) {
16551
- if (!span) {
16552
- return null;
16553
- }
16554
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-[1.5rem] mb-[2rem]", children: [
16555
- /* @__PURE__ */ jsxRuntime.jsx(SideDialogCodeSection, { title: "Input", codeStr: JSON.stringify(span.input || null, null, 2) }),
16556
- /* @__PURE__ */ jsxRuntime.jsx(SideDialogCodeSection, { title: "Output", codeStr: JSON.stringify(span.output || null, null, 2) }),
16557
- /* @__PURE__ */ jsxRuntime.jsx(SideDialogCodeSection, { title: "Metadata", codeStr: JSON.stringify(span.metadata || null, null, 2) }),
16558
- /* @__PURE__ */ jsxRuntime.jsx(SideDialogCodeSection, { title: "Attributes", codeStr: JSON.stringify(span.attributes || null, null, 2) }),
16559
- span?.links?.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-[2.5rem] pr-[2.5rem]", children: [
16560
- /* @__PURE__ */ jsxRuntime.jsxs(SideDialogHeading, { as: "h2", className: "pb-[1rem]", children: [
16561
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GaugeIcon, {}),
16562
- " Scores"
16563
- ] }),
16564
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface2 rounded-lg overflow-hidden border-sm border-border1", children: /* @__PURE__ */ jsxRuntime.jsx(
16565
- ScoreTable,
16324
+ const TabList = ({ children, variant = "default", className }) => {
16325
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("w-full overflow-x-auto", className), children: /* @__PURE__ */ jsxRuntime.jsx(
16326
+ TabsPrimitive__namespace.List,
16327
+ {
16328
+ className: cn(
16329
+ "flex items-center",
16566
16330
  {
16567
- scores: span?.links,
16568
- onItemClick: (scorerName) => onScorerTriggered(scorerName, span.traceId, span.spanId)
16569
- }
16570
- ) })
16571
- ] })
16572
- ] });
16573
- }
16331
+ // variant: default
16332
+ "text-[0.9375rem]": variant === "default",
16333
+ "[&>button]:py-[0.5rem] [&>button]:px-[1.5rem] [&>button]:font-normal [&>button]:text-icon3 [&>button]:flex-1 [&>button]:border-b [&>button]:border-border1": variant === "default",
16334
+ "[&>button[data-state=active]]:text-icon5 [&>button[data-state=active]]:transition-colors [&>button[data-state=active]]:duration-200 [&>button[data-state=active]]:border-icon3": variant === "default",
16335
+ // variant: buttons
16336
+ "border border-border1 flex justify-stretch rounded-md overflow-hidden text-[0.875rem] min-h-[2.5rem]": variant === "buttons",
16337
+ "[&>button]:flex-1 [&>button]:py-[0.5rem] [&>button]:px-[1rem] [&>button]:text-icon3": variant === "buttons",
16338
+ "[&>button[data-state=active]]:text-icon5 [&>button[data-state=active]]:bg-[#222]": variant === "buttons"
16339
+ },
16340
+ className
16341
+ ),
16342
+ children
16343
+ }
16344
+ ) });
16345
+ };
16574
16346
 
16575
- const DropdownMenu = DropdownMenuPrimitive__namespace.Root;
16576
- const DropdownMenuGroup = DropdownMenuPrimitive__namespace.Group;
16577
- const DropdownMenuPortal = DropdownMenuPrimitive__namespace.Portal;
16578
- const DropdownMenuSub = DropdownMenuPrimitive__namespace.Sub;
16579
- const DropdownMenuRadioGroup = DropdownMenuPrimitive__namespace.RadioGroup;
16580
- const DropdownMenuTrigger = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Trigger, { ref, className: cn("cursor-pointer focus-visible:rounded", className), ...props, children }));
16581
- DropdownMenuTrigger.displayName = DropdownMenuPrimitive__namespace.Trigger.displayName;
16582
- const DropdownMenuSubTrigger = React__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
16583
- DropdownMenuPrimitive__namespace.SubTrigger,
16584
- {
16585
- ref,
16586
- className: cn(
16587
- "focus:bg-accent data-[state=open]:bg-accent flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm",
16588
- inset && "pl-8",
16589
- className
16590
- ),
16591
- ...props,
16592
- children: [
16593
- children,
16594
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "ml-auto -rotate-90" })
16595
- ]
16596
- }
16597
- ));
16598
- DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
16599
- const DropdownMenuSubContent = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16600
- DropdownMenuPrimitive__namespace.SubContent,
16601
- {
16602
- ref,
16603
- className: cn(
16604
- "popover-background data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 min-w-[8rem] overflow-auto overflow-x-hidden rounded-none p-1",
16605
- className
16606
- ),
16607
- ...props
16608
- }
16609
- ));
16610
- DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
16611
- const DropdownMenuContent = React__namespace.forwardRef(({ className, container, sideOffset = 4, ...props }, ref) => {
16612
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { container, children: /* @__PURE__ */ jsxRuntime.jsx(
16613
- DropdownMenuPrimitive__namespace.Content,
16347
+ const Tab = ({ children, value, onClick, className }) => {
16348
+ return /* @__PURE__ */ jsxRuntime.jsx(TabsPrimitive__namespace.Trigger, { value, className: cn("hover:text-icon5", className), onClick, children });
16349
+ };
16350
+
16351
+ const TabContent = ({ children, value, className }) => {
16352
+ return /* @__PURE__ */ jsxRuntime.jsx(
16353
+ TabsPrimitive__namespace.Content,
16614
16354
  {
16615
- ref,
16616
- sideOffset,
16617
- className: clsx(
16618
- "data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 bg-surface2 text-icon3 border-sm border-border1 z-50 min-w-[8rem] overflow-auto rounded-md p-1 shadow-md",
16355
+ value,
16356
+ className: cn(
16357
+ "grid overflow-y-auto ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:none",
16619
16358
  className
16620
16359
  ),
16621
- ...props
16360
+ children
16622
16361
  }
16623
- ) });
16362
+ );
16363
+ };
16364
+
16365
+ const Tabs = Object.assign(TabsRoot, {
16366
+ List: TabList,
16367
+ Tab,
16368
+ Content: TabContent
16624
16369
  });
16625
- DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
16626
- const DropdownMenuItem = React__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16627
- DropdownMenuPrimitive__namespace.Item,
16628
- {
16629
- ref,
16630
- className: cn(
16631
- "focus:text-accent-foreground relative flex cursor-default cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 font-sans text-[0.8125rem] transition-colors focus:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:truncate",
16632
- inset && "pl-8",
16633
- className
16634
- ),
16635
- ...props
16370
+
16371
+ function SpanDetails({ span }) {
16372
+ if (!span) {
16373
+ return null;
16636
16374
  }
16637
- ));
16638
- DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
16639
- const DropdownMenuCheckboxItem = React__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
16640
- DropdownMenuPrimitive__namespace.CheckboxItem,
16641
- {
16642
- ref,
16643
- className: cn(
16644
- "focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-default cursor-pointer select-none items-center gap-4 rounded-sm px-2 py-1.5 text-sm transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
16645
- className
16375
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
16376
+ /* @__PURE__ */ jsxRuntime.jsx(
16377
+ SideDialog.CodeSection,
16378
+ {
16379
+ title: "Input",
16380
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileInputIcon, {}),
16381
+ codeStr: JSON.stringify(span.input || null, null, 2)
16382
+ }
16646
16383
  ),
16647
- checked,
16648
- ...props,
16649
- children: [
16650
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-sm border-border1 flex h-4 w-4 items-center justify-center rounded-sm", children: checked && /* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, {}) }) }),
16651
- children
16652
- ]
16653
- }
16654
- ));
16655
- DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
16656
- const DropdownMenuRadioItem = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
16657
- DropdownMenuPrimitive__namespace.RadioItem,
16658
- {
16659
- ref,
16660
- className: cn(
16661
- "focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm transition-colors focus:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
16662
- className
16384
+ /* @__PURE__ */ jsxRuntime.jsx(
16385
+ SideDialog.CodeSection,
16386
+ {
16387
+ title: "Output",
16388
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileOutputIcon, {}),
16389
+ codeStr: JSON.stringify(span.output || null, null, 2)
16390
+ }
16663
16391
  ),
16664
- ...props,
16665
- children: [
16666
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Circle, { className: "h-2 w-2 fill-current" }) }) }),
16667
- children
16668
- ]
16669
- }
16670
- ));
16671
- DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
16672
- const DropdownMenuLabel = React__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16673
- DropdownMenuPrimitive__namespace.Label,
16674
- {
16675
- ref,
16676
- className: cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className),
16677
- ...props
16678
- }
16679
- ));
16680
- DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
16681
- const DropdownMenuSeparator = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16682
- DropdownMenuPrimitive__namespace.Separator,
16683
- {
16684
- ref,
16685
- className: cn("popover-dividers-bg -mx-1 my-1 h-px", className),
16686
- ...props
16687
- }
16688
- ));
16689
- DropdownMenuSeparator.displayName = DropdownMenuPrimitive__namespace.Separator.displayName;
16690
- const DropdownMenuShortcut = ({ className, ...props }) => {
16691
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("ml-auto text-xs tracking-widest opacity-60", className), ...props });
16692
- };
16693
- DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
16694
- function Dropdown({
16695
- open,
16696
- onOpenChange,
16697
- children,
16698
- modal
16699
- }) {
16700
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu, { modal, open, onOpenChange, children });
16392
+ /* @__PURE__ */ jsxRuntime.jsx(
16393
+ SideDialog.CodeSection,
16394
+ {
16395
+ title: "Metadata",
16396
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.BracesIcon, {}),
16397
+ codeStr: JSON.stringify(span.metadata || null, null, 2)
16398
+ }
16399
+ ),
16400
+ /* @__PURE__ */ jsxRuntime.jsx(
16401
+ SideDialog.CodeSection,
16402
+ {
16403
+ title: "Attributes",
16404
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.BracesIcon, {}),
16405
+ codeStr: JSON.stringify(span.attributes || null, null, 2)
16406
+ }
16407
+ )
16408
+ ] });
16701
16409
  }
16702
- Dropdown.Trigger = DropdownMenuTrigger;
16703
- Dropdown.Content = DropdownMenuContent;
16704
- Dropdown.Group = DropdownMenuGroup;
16705
- Dropdown.Portal = DropdownMenuPortal;
16706
- Dropdown.Item = DropdownMenuItem;
16707
- Dropdown.CheckboxItem = DropdownMenuCheckboxItem;
16708
- Dropdown.RadioItem = DropdownMenuRadioItem;
16709
- Dropdown.Label = DropdownMenuLabel;
16710
- Dropdown.Separator = DropdownMenuSeparator;
16711
- Dropdown.Shortcut = DropdownMenuShortcut;
16712
- Dropdown.Sub = DropdownMenuSub;
16713
- Dropdown.SubContent = DropdownMenuSubContent;
16714
- Dropdown.SubTrigger = DropdownMenuSubTrigger;
16715
- Dropdown.RadioGroup = DropdownMenuRadioGroup;
16716
-
16717
- const useTriggerScorer = (onScorerTriggered) => {
16718
- const client = react$3.useMastraClient();
16719
- return reactQuery.useMutation({
16720
- mutationFn: async ({ scorerName, traceId, spanId }) => {
16721
- const response = await client.score({
16722
- scorerName,
16723
- targets: [{ traceId, spanId }]
16724
- });
16725
- return response;
16726
- },
16727
- onSuccess: (_, variables) => {
16728
- sonner.toast.success("Scorer triggered successfully");
16729
- onScorerTriggered(variables.scorerName, variables.traceId, variables.spanId);
16730
- },
16731
- onError: () => {
16732
- sonner.toast.error("Error triggering scorer");
16733
- }
16734
- });
16735
- };
16736
16410
 
16737
- const ScorersDropdown = ({ trace, spanId, onScorerTriggered, entityType }) => {
16738
- const { data: scorers = {}, isLoading } = useScorers();
16739
- const { mutate: triggerScorer, isPending } = useTriggerScorer(onScorerTriggered);
16740
- let scorerList = Object.entries(scorers).map(([key, scorer]) => ({
16741
- id: key,
16742
- name: scorer.scorer.config.name,
16743
- description: scorer.scorer.config.description,
16744
- isRegistered: scorer.isRegistered,
16745
- type: scorer.scorer.config.type
16746
- })).filter((scorer) => scorer.isRegistered);
16747
- if (entityType !== "Agent" || spanId) {
16748
- scorerList = scorerList.filter((scorer) => scorer.type !== "agent");
16411
+ function SpanTabs({
16412
+ trace,
16413
+ span,
16414
+ spanScoresData,
16415
+ onSpanScoresPageChange,
16416
+ isLoadingSpanScoresData,
16417
+ spanInfo = [],
16418
+ defaultActiveTab = "details",
16419
+ initialScoreId,
16420
+ computeTraceLink
16421
+ }) {
16422
+ const { Link } = useLinkComponent();
16423
+ let entityType;
16424
+ if (span?.attributes?.agentId) {
16425
+ entityType = "Agent";
16426
+ } else if (span?.attributes?.workflowId) {
16427
+ entityType = "Workflow";
16749
16428
  }
16750
- const isWaiting = isPending || isLoading;
16751
- return /* @__PURE__ */ jsxRuntime.jsxs(Dropdown, { children: [
16752
- /* @__PURE__ */ jsxRuntime.jsx(Dropdown.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(Button$1, { variant: "light", disabled: isWaiting, children: [
16753
- isWaiting ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GaugeIcon, {}) }),
16754
- "Run scorer",
16755
- /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, {}) })
16429
+ return /* @__PURE__ */ jsxRuntime.jsxs(Tabs, { defaultTab: defaultActiveTab, children: [
16430
+ /* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { children: [
16431
+ /* @__PURE__ */ jsxRuntime.jsx(Tabs.Tab, { value: "details", children: "Details" }),
16432
+ /* @__PURE__ */ jsxRuntime.jsxs(Tabs.Tab, { value: "scores", children: [
16433
+ "Scoring ",
16434
+ spanScoresData?.pagination && `(${spanScoresData.pagination.total || 0})`
16435
+ ] })
16436
+ ] }),
16437
+ /* @__PURE__ */ jsxRuntime.jsx(Tabs.Content, { value: "details", children: /* @__PURE__ */ jsxRuntime.jsxs(Sections, { children: [
16438
+ span?.attributes?.usage && /* @__PURE__ */ jsxRuntime.jsx(TraceSpanUsage, { spanUsage: span.attributes.usage }),
16439
+ /* @__PURE__ */ jsxRuntime.jsx(KeyValueList, { data: spanInfo, LinkComponent: Link }),
16440
+ /* @__PURE__ */ jsxRuntime.jsx(SpanDetails, { span })
16756
16441
  ] }) }),
16757
- /* @__PURE__ */ jsxRuntime.jsx(Dropdown.Content, { children: scorerList.map((scorer) => /* @__PURE__ */ jsxRuntime.jsx(
16758
- Dropdown.Item,
16759
- {
16760
- onClick: () => triggerScorer({ scorerName: scorer.name, traceId: trace.traceId, spanId }),
16761
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: scorer.name })
16762
- },
16763
- scorer.id
16764
- )) })
16442
+ /* @__PURE__ */ jsxRuntime.jsx(Tabs.Content, { value: "scores", children: /* @__PURE__ */ jsxRuntime.jsxs(Sections, { children: [
16443
+ /* @__PURE__ */ jsxRuntime.jsxs(Section, { children: [
16444
+ /* @__PURE__ */ jsxRuntime.jsx(Section.Header, { children: /* @__PURE__ */ jsxRuntime.jsxs(Section.Heading, { children: [
16445
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleGaugeIcon, {}),
16446
+ " Scoring"
16447
+ ] }) }),
16448
+ /* @__PURE__ */ jsxRuntime.jsx(SpanScoring, { traceId: trace?.traceId, spanId: span?.spanId, entityType })
16449
+ ] }),
16450
+ /* @__PURE__ */ jsxRuntime.jsxs(Section, { children: [
16451
+ /* @__PURE__ */ jsxRuntime.jsx(Section.Header, { children: /* @__PURE__ */ jsxRuntime.jsxs(Section.Heading, { children: [
16452
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleGaugeIcon, {}),
16453
+ " Scores"
16454
+ ] }) }),
16455
+ /* @__PURE__ */ jsxRuntime.jsx(
16456
+ SpanScoreList,
16457
+ {
16458
+ scoresData: spanScoresData,
16459
+ onPageChange: onSpanScoresPageChange,
16460
+ isLoadingScoresData: isLoadingSpanScoresData,
16461
+ initialScoreId,
16462
+ traceId: trace?.traceId,
16463
+ spanId: span?.spanId,
16464
+ computeTraceLink
16465
+ }
16466
+ )
16467
+ ] })
16468
+ ] }) })
16765
16469
  ] });
16766
- };
16470
+ }
16767
16471
 
16768
16472
  function SpanDialog({
16769
16473
  trace,
16770
16474
  span,
16475
+ spanScoresData,
16476
+ onSpanScoresPageChange,
16477
+ isLoadingSpanScoresData,
16771
16478
  isOpen,
16772
16479
  onClose,
16773
16480
  onNext,
16774
16481
  onPrevious,
16775
16482
  onViewToggle,
16776
16483
  spanInfo = [],
16777
- onScorerTriggered
16484
+ defaultActiveTab = "details",
16485
+ initialScoreId,
16486
+ computeTraceLink
16778
16487
  }) {
16779
- const { Link } = useLinkComponent();
16780
16488
  return /* @__PURE__ */ jsxRuntime.jsxs(
16781
16489
  SideDialog,
16782
16490
  {
@@ -16784,43 +16492,53 @@ function SpanDialog({
16784
16492
  dialogDescription: "View and analyze span details",
16785
16493
  isOpen,
16786
16494
  onClose,
16787
- hasCloseButton: true,
16788
- className: cn("w-[calc(100vw-25rem)] max-w-[65%]", "3xl:max-w-[50%]", "4xl:max-w-[40%]"),
16495
+ level: 2,
16789
16496
  children: [
16790
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between pr-[1.5rem]", children: [
16791
- /* @__PURE__ */ jsxRuntime.jsx(SideDialogTop, { onNext, onPrevious, showInnerNav: true, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[1rem] text-icon4 text-[0.875rem]", children: [
16792
- /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16793
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeIcon, {}),
16497
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Top, { children: [
16498
+ /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16499
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeIcon, {}),
16500
+ " ",
16501
+ getShortId(span?.traceId)
16502
+ ] }),
16503
+ "›",
16504
+ /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16505
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeftRightEllipsisIcon, {}),
16506
+ getShortId(span?.spanId)
16507
+ ] }),
16508
+ "|",
16509
+ /* @__PURE__ */ jsxRuntime.jsx(SideDialog.Nav, { onNext, onPrevious }),
16510
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "ml-auto mr-[2rem]", onClick: onViewToggle, children: [
16511
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelTopIcon, {}),
16512
+ /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden.VisuallyHidden, { children: "Switch to dialog view" })
16513
+ ] })
16514
+ ] }),
16515
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Content, { children: [
16516
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Header, { children: [
16517
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Heading, { children: [
16518
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeftRightEllipsisIcon, {}),
16794
16519
  " ",
16795
- getShortId(span?.traceId)
16520
+ span?.name
16796
16521
  ] }),
16797
- "›",
16798
16522
  /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16799
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeftRightEllipsisIcon, {}),
16800
- getShortId(span?.spanId)
16523
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.HashIcon, {}),
16524
+ " ",
16525
+ span?.spanId
16801
16526
  ] })
16802
- ] }) }),
16803
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: "flex items-center gap-1", onClick: onViewToggle, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelTopIcon, {}) })
16804
- ] }),
16805
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-[1.5rem] px-[2.5rem] overflow-y-auto grid gap-[1.5rem] content-start", children: [
16806
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
16807
- /* @__PURE__ */ jsxRuntime.jsxs(SideDialogHeader, { className: "flex gap-[1rem] items-baseline pr-[2.5rem]", children: [
16808
- /* @__PURE__ */ jsxRuntime.jsxs(SideDialogHeading, { children: [
16809
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeftRightEllipsisIcon, {}),
16810
- " ",
16811
- span?.name
16812
- ] }),
16813
- /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16814
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.HashIcon, {}),
16815
- " ",
16816
- span?.spanId
16817
- ] })
16818
- ] }),
16819
- span?.traceId && span?.spanId && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(ScorersDropdown, { trace, spanId: span?.spanId, onScorerTriggered }) })
16820
16527
  ] }),
16821
- span?.attributes?.usage && /* @__PURE__ */ jsxRuntime.jsx(TraceSpanUsage, { spanUsage: span.attributes.usage, className: "mt-[1.5rem]" }),
16822
- /* @__PURE__ */ jsxRuntime.jsx(KeyValueList, { data: spanInfo, LinkComponent: Link, className: "mt-[1.5rem]" }),
16823
- /* @__PURE__ */ jsxRuntime.jsx(SpanDetails, { span, onScorerTriggered })
16528
+ /* @__PURE__ */ jsxRuntime.jsx(
16529
+ SpanTabs,
16530
+ {
16531
+ trace,
16532
+ span,
16533
+ spanScoresData,
16534
+ onSpanScoresPageChange,
16535
+ isLoadingSpanScoresData,
16536
+ spanInfo,
16537
+ defaultActiveTab,
16538
+ initialScoreId,
16539
+ computeTraceLink
16540
+ }
16541
+ )
16824
16542
  ] })
16825
16543
  ]
16826
16544
  }
@@ -16838,15 +16556,30 @@ function TraceDialog({
16838
16556
  isLoadingSpans,
16839
16557
  computeAgentsLink,
16840
16558
  computeWorkflowsLink,
16841
- onScorerTriggered,
16842
- initialSpanId
16559
+ computeTraceLink,
16560
+ initialSpanId,
16561
+ initialSpanTab,
16562
+ initialScoreId
16843
16563
  }) {
16844
- const { Link } = useLinkComponent();
16564
+ const { Link, navigate } = useLinkComponent();
16845
16565
  const [dialogIsOpen, setDialogIsOpen] = React.useState(Boolean(initialSpanId));
16846
16566
  const [selectedSpanId, setSelectedSpanId] = React.useState(initialSpanId);
16847
16567
  const [combinedView, setCombinedView] = React.useState(false);
16568
+ const [spanDialogDefaultTab, setSpanDialogDefaultTab] = React.useState(initialSpanTab || "details");
16848
16569
  const selectedSpan = traceSpans.find((span) => span.spanId === selectedSpanId);
16849
16570
  const traceInfo = useTraceInfo(traceDetails);
16571
+ const [spanScoresPage, setSpanScoresPage] = React.useState(0);
16572
+ React.useEffect(() => {
16573
+ if (initialSpanId) {
16574
+ setSelectedSpanId(initialSpanId);
16575
+ setDialogIsOpen(true);
16576
+ }
16577
+ }, [initialSpanId]);
16578
+ React.useEffect(() => {
16579
+ if (spanScoresPage > 0) {
16580
+ setSpanScoresPage(0);
16581
+ }
16582
+ }, [selectedSpanId]);
16850
16583
  const hierarchicalSpans = React.useMemo(() => {
16851
16584
  return formatHierarchicalSpans(traceSpans);
16852
16585
  }, [traceSpans]);
@@ -16864,39 +16597,38 @@ function TraceDialog({
16864
16597
  };
16865
16598
  return flattenSpans(hierarchicalSpans);
16866
16599
  }, [hierarchicalSpans]);
16600
+ const { data: spanScoresData, isLoading: isLoadingSpanScoresData } = useTraceSpanScores({
16601
+ traceId,
16602
+ spanId: selectedSpanId || flatSpans?.[0]?.id,
16603
+ page: spanScoresPage
16604
+ });
16867
16605
  const handleSpanClick = (id) => {
16868
16606
  setSelectedSpanId(id);
16607
+ setSpanDialogDefaultTab("details");
16869
16608
  setDialogIsOpen(true);
16870
16609
  };
16871
- const toNextSpan = () => {
16872
- const currentIndex = flatSpans.findIndex((span) => span.id === selectedSpanId);
16873
- const nextItem = flatSpans[currentIndex + 1];
16874
- if (nextItem) {
16875
- setSelectedSpanId(nextItem.id);
16610
+ const handleToScoring = () => {
16611
+ setSelectedSpanId(hierarchicalSpans[0]?.id);
16612
+ setSpanDialogDefaultTab("scores");
16613
+ if (traceId) {
16614
+ navigate(`${computeTraceLink(traceId, hierarchicalSpans?.[0]?.id)}&tab=scores`);
16876
16615
  }
16877
16616
  };
16878
- const toPreviousSpan = () => {
16879
- const currentIndex = flatSpans.findIndex((span) => span.id === selectedSpanId);
16880
- const previousItem = flatSpans[currentIndex - 1];
16881
- if (previousItem) {
16882
- setSelectedSpanId(previousItem.id);
16617
+ const handleToLastScore = () => {
16618
+ setSelectedSpanId(hierarchicalSpans[0]?.id);
16619
+ setSpanDialogDefaultTab("scores");
16620
+ if (traceId) {
16621
+ navigate(
16622
+ `${computeTraceLink(
16623
+ traceId,
16624
+ hierarchicalSpans?.[0]?.id
16625
+ )}&tab=scores&scoreId=${spanScoresData?.scores?.[0]?.id}`
16626
+ );
16883
16627
  }
16884
16628
  };
16885
- const thereIsNextSpan = () => {
16886
- const currentIndex = flatSpans.findIndex((span) => span.id === selectedSpanId);
16887
- return currentIndex < flatSpans.length - 1;
16888
- };
16889
- const thereIsPreviousSpan = () => {
16890
- const currentIndex = flatSpans.findIndex((span) => span.id === selectedSpanId);
16891
- return currentIndex > 0;
16892
- };
16893
16629
  const selectedSpanInfo = getSpanInfo({ span: selectedSpan, withTraceId: !combinedView, withSpanId: combinedView });
16894
- let entityType;
16895
- if (traceDetails?.attributes?.agentId) {
16896
- entityType = "Agent";
16897
- } else if (traceDetails?.attributes?.workflowId) {
16898
- entityType = "Workflow";
16899
- }
16630
+ const toNextSpan = getToNextEntryFn({ entries: flatSpans, id: selectedSpanId, update: setSelectedSpanId });
16631
+ const toPreviousSpan = getToPreviousEntryFn({ entries: flatSpans, id: selectedSpanId, update: setSelectedSpanId });
16900
16632
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
16901
16633
  /* @__PURE__ */ jsxRuntime.jsxs(
16902
16634
  SideDialog,
@@ -16905,111 +16637,100 @@ function TraceDialog({
16905
16637
  dialogDescription: "View and analyze trace details",
16906
16638
  isOpen,
16907
16639
  onClose,
16908
- hasCloseButton: !dialogIsOpen || combinedView,
16909
- className: cn("w-[calc(100vw-20rem)] max-w-[80%]", "3xl:max-w-[65%]", "4xl:max-w-[55%]"),
16640
+ level: 1,
16910
16641
  children: [
16911
- /* @__PURE__ */ jsxRuntime.jsx(SideDialogTop, { onNext, onPrevious, showInnerNav: true, children: /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16912
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeIcon, {}),
16913
- " ",
16914
- getShortId(traceId)
16915
- ] }) }),
16642
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Top, { children: [
16643
+ /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16644
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeIcon, {}),
16645
+ " ",
16646
+ getShortId(traceId)
16647
+ ] }),
16648
+ "|",
16649
+ /* @__PURE__ */ jsxRuntime.jsx(SideDialog.Nav, { onNext, onPrevious })
16650
+ ] }),
16916
16651
  /* @__PURE__ */ jsxRuntime.jsxs(
16917
16652
  "div",
16918
16653
  {
16919
- className: cn("pt-[1.5rem] pl-[2.5rem] grid-rows-[auto_1fr] grid h-full overflow-y-auto", {
16920
- "grid-rows-[auto_1fr_1fr]": selectedSpan && combinedView
16654
+ className: cn("overflow-y-auto", {
16655
+ "grid grid-rows-[2fr_3fr]": Boolean(selectedSpan && combinedView)
16921
16656
  }),
16922
16657
  children: [
16923
- /* @__PURE__ */ jsxRuntime.jsxs(SideDialogHeader, { className: "pr-[2.5rem]", children: [
16924
- /* @__PURE__ */ jsxRuntime.jsxs(SideDialogHeading, { children: [
16925
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeIcon, {}),
16926
- " ",
16927
- traceDetails?.name
16928
- ] }),
16929
- /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16930
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.HashIcon, {}),
16931
- " ",
16932
- traceId
16933
- ] })
16934
- ] }),
16935
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("overflow-y-auto pb-[2.5rem]"), children: [
16936
- traceDetails && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
16937
- ScorersDropdown,
16938
- {
16939
- trace: traceDetails,
16940
- spanId: selectedSpanId,
16941
- onScorerTriggered,
16942
- entityType
16943
- }
16944
- ) }),
16945
- traceDetails?.metadata?.usage && /* @__PURE__ */ jsxRuntime.jsx(
16946
- TraceSpanUsage,
16947
- {
16948
- traceUsage: traceDetails?.metadata?.usage,
16949
- traceSpans,
16950
- className: "mt-[2rem] pr-[1.5rem]"
16951
- }
16952
- ),
16953
- /* @__PURE__ */ jsxRuntime.jsx(KeyValueList, { data: traceInfo, LinkComponent: Link, className: "mt-[2rem]" }),
16954
- /* @__PURE__ */ jsxRuntime.jsx(
16955
- TraceTimeline,
16956
- {
16957
- hierarchicalSpans,
16958
- spans: traceSpans,
16959
- onSpanClick: handleSpanClick,
16960
- selectedSpanId,
16961
- isLoading: isLoadingSpans,
16962
- className: "pr-[2.5rem] pt-[2.5rem]"
16963
- }
16964
- ),
16965
- traceDetails?.links?.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-[2.5rem] pr-[2.5rem]", children: [
16966
- /* @__PURE__ */ jsxRuntime.jsxs(SideDialogHeading, { as: "h2", className: "pb-[1rem]", children: [
16967
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GaugeIcon, {}),
16968
- " Scores"
16658
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Content, { children: [
16659
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Header, { children: [
16660
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Heading, { children: [
16661
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeIcon, {}),
16662
+ " ",
16663
+ traceDetails?.name
16969
16664
  ] }),
16970
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface2 rounded-lg overflow-hidden border-sm border-border1", children: /* @__PURE__ */ jsxRuntime.jsx(
16971
- ScoreTable,
16972
- {
16973
- scores: traceDetails?.links,
16974
- onItemClick: (scorerName) => onScorerTriggered(scorerName, traceDetails.traceId, selectedSpanId)
16975
- }
16976
- ) })
16977
- ] })
16978
- ] }),
16979
- selectedSpan && combinedView && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-y-auto grid grid-rows-[auto_1fr] relative", children: [
16980
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute left-0 right-[2.5rem] h-[.5rem] bg-surface1 rounded-full top-0" }),
16981
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between pb-[.5rem] pt-[1rem] border-b border-border1 pr-[2.5rem]", children: [
16982
- /* @__PURE__ */ jsxRuntime.jsx(
16983
- SideDialogTop,
16984
- {
16985
- onNext: thereIsNextSpan() ? toNextSpan : void 0,
16986
- onPrevious: thereIsPreviousSpan() ? toPreviousSpan : void 0,
16987
- showInnerNav: true,
16988
- className: "pl-0",
16989
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-[1rem] text-icon4 text-[0.875rem]", children: [
16990
- /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16991
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeIcon, {}),
16992
- " ",
16993
- getShortId(traceId)
16665
+ /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16666
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.HashIcon, {}),
16667
+ " ",
16668
+ traceId
16669
+ ] })
16670
+ ] }),
16671
+ traceDetails && /* @__PURE__ */ jsxRuntime.jsxs(Sections, { children: [
16672
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid xl:grid-cols-[3fr_2fr] gap-[1rem] items-start", children: [
16673
+ /* @__PURE__ */ jsxRuntime.jsx(KeyValueList, { data: traceInfo, LinkComponent: Link }),
16674
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-surface3 p-[1.5rem] rounded-lg grid gap-[1rem]", children: [
16675
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-[1rem]", children: /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16676
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GaugeIcon, {}),
16677
+ " Evaluate trace"
16678
+ ] }) }),
16679
+ /* @__PURE__ */ jsxRuntime.jsxs(ButtonsGroup, { className: "w-full", children: [
16680
+ /* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: handleToScoring, children: [
16681
+ "Scoring ",
16682
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleGaugeIcon, {}),
16683
+ " "
16994
16684
  ] }),
16995
- "›",
16996
- /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16997
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeftRightEllipsisIcon, {}),
16998
- " ",
16999
- getShortId(selectedSpanId)
16685
+ spanScoresData?.scores?.[0] && /* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: handleToLastScore, children: [
16686
+ "Last score: ",
16687
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: spanScoresData?.scores?.[0]?.score })
17000
16688
  ] })
17001
16689
  ] })
17002
- }
17003
- ),
17004
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-[1rem]", children: /* @__PURE__ */ jsxRuntime.jsx("button", { className: "flex items-center gap-1", onClick: () => setCombinedView(false), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelLeftIcon, {}) }) })
16690
+ ] })
16691
+ ] }),
16692
+ /* @__PURE__ */ jsxRuntime.jsxs(Section, { children: [
16693
+ /* @__PURE__ */ jsxRuntime.jsxs(Section.Header, { children: [
16694
+ /* @__PURE__ */ jsxRuntime.jsxs(Section.Heading, { children: [
16695
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListTreeIcon, {}),
16696
+ " Timeline"
16697
+ ] }),
16698
+ /* @__PURE__ */ jsxRuntime.jsx(TraceTimelineLegend, { spans: traceSpans })
16699
+ ] }),
16700
+ /* @__PURE__ */ jsxRuntime.jsx(
16701
+ TraceTimeline,
16702
+ {
16703
+ hierarchicalSpans,
16704
+ onSpanClick: handleSpanClick,
16705
+ selectedSpanId,
16706
+ isLoading: isLoadingSpans
16707
+ }
16708
+ )
16709
+ ] })
16710
+ ] })
16711
+ ] }),
16712
+ selectedSpan && combinedView && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-rows-[auto_1fr] relative overflow-y-auto", children: [
16713
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Top, { withTopSeparator: true, children: [
16714
+ /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { children: [
16715
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeftRightEllipsisIcon, {}),
16716
+ " ",
16717
+ getShortId(selectedSpanId)
16718
+ ] }),
16719
+ "|",
16720
+ /* @__PURE__ */ jsxRuntime.jsx(SideDialog.Nav, { onNext: toNextSpan, onPrevious: toPreviousSpan }),
16721
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "ml-auto mr-[2rem]", onClick: () => setCombinedView(false), children: [
16722
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelLeftIcon, {}),
16723
+ " ",
16724
+ /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden.VisuallyHidden, { children: "Switch to dialog view" })
16725
+ ] })
17005
16726
  ] }),
17006
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[20rem_1fr] gap-[1rem] overflow-y-auto", children: [
17007
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-y-auto grid content-start p-[1.5rem] pl-0 gap-[2rem]", children: [
17008
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs(SideDialogHeading, { as: "h2", children: [
16727
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("h-full overflow-y-auto grid gap-[2rem] grid-cols-[20rem_1fr]"), children: [
16728
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-y-auto grid content-start p-[2rem] gap-[2rem]", children: [
16729
+ /* @__PURE__ */ jsxRuntime.jsxs(SideDialog.Heading, { as: "h2", children: [
17009
16730
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeftRightEllipsisIcon, {}),
17010
16731
  " ",
17011
16732
  selectedSpan?.name
17012
- ] }) }),
16733
+ ] }),
17013
16734
  selectedSpan?.attributes?.usage && /* @__PURE__ */ jsxRuntime.jsx(
17014
16735
  TraceSpanUsage,
17015
16736
  {
@@ -17019,7 +16740,20 @@ function TraceDialog({
17019
16740
  ),
17020
16741
  /* @__PURE__ */ jsxRuntime.jsx(KeyValueList, { data: selectedSpanInfo, LinkComponent: Link })
17021
16742
  ] }),
17022
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto pr-[2.5rem] pt-[2rem]", children: /* @__PURE__ */ jsxRuntime.jsx(SpanDetails, { span: selectedSpan, onScorerTriggered }) })
16743
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto pr-[2rem] pt-[2rem] h-full", children: /* @__PURE__ */ jsxRuntime.jsx(
16744
+ SpanTabs,
16745
+ {
16746
+ trace: traceDetails,
16747
+ span: selectedSpan,
16748
+ spanScoresData,
16749
+ onSpanScoresPageChange: setSpanScoresPage,
16750
+ isLoadingSpanScoresData,
16751
+ spanInfo: selectedSpanInfo,
16752
+ defaultActiveTab: spanDialogDefaultTab,
16753
+ initialScoreId,
16754
+ computeTraceLink
16755
+ }
16756
+ ) })
17023
16757
  ] })
17024
16758
  ] })
17025
16759
  ]
@@ -17033,16 +16767,22 @@ function TraceDialog({
17033
16767
  {
17034
16768
  trace: traceDetails,
17035
16769
  span: selectedSpan,
16770
+ spanScoresData,
16771
+ onSpanScoresPageChange: setSpanScoresPage,
16772
+ isLoadingSpanScoresData,
17036
16773
  isOpen: Boolean(dialogIsOpen && selectedSpanId && !combinedView),
17037
16774
  onClose: () => {
16775
+ navigate(computeTraceLink(traceId || ""));
17038
16776
  setDialogIsOpen(false);
17039
16777
  setSelectedSpanId(void 0);
17040
16778
  },
17041
- onNext: thereIsNextSpan() ? toNextSpan : void 0,
17042
- onPrevious: thereIsPreviousSpan() ? toPreviousSpan : void 0,
16779
+ onNext: toNextSpan,
16780
+ onPrevious: toPreviousSpan,
17043
16781
  onViewToggle: () => setCombinedView(!combinedView),
17044
16782
  spanInfo: selectedSpanInfo,
17045
- onScorerTriggered
16783
+ defaultActiveTab: spanDialogDefaultTab,
16784
+ initialScoreId,
16785
+ computeTraceLink
17046
16786
  }
17047
16787
  )
17048
16788
  ] });
@@ -17111,61 +16851,262 @@ function TracesTools({
17111
16851
  ] });
17112
16852
  }
17113
16853
 
17114
- function MainContentLayout({
17115
- children,
17116
- className,
17117
- style
16854
+ const tracesListColumns = [
16855
+ { name: "shortId", label: "ID", size: "6rem" },
16856
+ { name: "date", label: "Date", size: "4.5rem" },
16857
+ { name: "time", label: "Time", size: "6.5rem" },
16858
+ { name: "name", label: "Name", size: "1fr" },
16859
+ { name: "entityId", label: "Entity", size: "10rem" },
16860
+ { name: "status", label: "Status", size: "3rem" }
16861
+ ];
16862
+ function TracesList({
16863
+ traces,
16864
+ selectedTraceId,
16865
+ onTraceClick,
16866
+ errorMsg,
16867
+ setEndOfListElement,
16868
+ filtersApplied,
16869
+ isFetchingNextPage,
16870
+ hasNextPage
17118
16871
  }) {
17119
- const devStyleRequested = devUIStyleRequested("MainContentLayout");
17120
- return /* @__PURE__ */ jsxRuntime.jsx(
17121
- "main",
17122
- {
17123
- className: cn(`grid grid-rows-[auto_1fr] h-full items-start content-start`, className),
17124
- style: { ...style, ...devStyleRequested ? { border: "3px dotted red" } : {} },
17125
- children
17126
- }
17127
- );
16872
+ if (!traces) {
16873
+ return null;
16874
+ }
16875
+ return /* @__PURE__ */ jsxRuntime.jsxs(EntryList, { children: [
16876
+ /* @__PURE__ */ jsxRuntime.jsxs(EntryList.Trim, { children: [
16877
+ /* @__PURE__ */ jsxRuntime.jsx(EntryList.Header, { columns: tracesListColumns }),
16878
+ errorMsg ? /* @__PURE__ */ jsxRuntime.jsx(EntryList.Message, { message: errorMsg, type: "error" }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: traces.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(EntryList.Entries, { children: traces.map((trace) => {
16879
+ const createdAtDate = new Date(trace.createdAt);
16880
+ const isTodayDate = dateFns.isToday(createdAtDate);
16881
+ const entry = {
16882
+ id: trace.traceId,
16883
+ shortId: getShortId(trace?.traceId) || "n/a",
16884
+ date: isTodayDate ? "Today" : dateFns.format(createdAtDate, "MMM dd"),
16885
+ time: dateFns.format(createdAtDate, "h:mm:ss aaa"),
16886
+ name: trace?.name,
16887
+ entityId: trace?.attributes?.agentId || trace?.attributes?.workflowId,
16888
+ status: trace?.attributes?.status
16889
+ };
16890
+ return /* @__PURE__ */ jsxRuntime.jsx(
16891
+ EntryList.Entry,
16892
+ {
16893
+ entry,
16894
+ isSelected: selectedTraceId === trace.traceId,
16895
+ columns: tracesListColumns,
16896
+ onClick: onTraceClick,
16897
+ children: tracesListColumns.map((col, index) => {
16898
+ const key = `${index}-${trace.traceId}`;
16899
+ return col.name === "status" ? /* @__PURE__ */ jsxRuntime.jsx(EntryList.EntryStatus, { status: entry?.[col.name] }, key) : /* @__PURE__ */ jsxRuntime.jsx(EntryList.EntryText, { children: entry?.[col.name] }, key);
16900
+ })
16901
+ },
16902
+ entry.id
16903
+ );
16904
+ }) }) : /* @__PURE__ */ jsxRuntime.jsx(
16905
+ EntryList.Message,
16906
+ {
16907
+ message: filtersApplied ? "No traces found for applied filters" : "No traces found yet"
16908
+ }
16909
+ ) })
16910
+ ] }),
16911
+ /* @__PURE__ */ jsxRuntime.jsx(
16912
+ EntryList.NextPageLoading,
16913
+ {
16914
+ setEndOfListElement,
16915
+ loadingText: "Loading more traces...",
16916
+ noMoreDataText: "All traces loaded",
16917
+ isLoading: isFetchingNextPage,
16918
+ hasMore: hasNextPage
16919
+ }
16920
+ )
16921
+ ] });
17128
16922
  }
17129
- function MainContentContent({
17130
- children,
17131
- className,
17132
- isCentered = false,
17133
- isDivided = false,
17134
- hasLeftServiceColumn = false,
17135
- style
16923
+
16924
+ const traceScoresListColumns = [
16925
+ { name: "shortId", label: "ID", size: "1fr" },
16926
+ { name: "date", label: "Date", size: "1fr" },
16927
+ { name: "time", label: "Time", size: "1fr" },
16928
+ { name: "score", label: "Score", size: "1fr" },
16929
+ { name: "scorer", label: "Scorer", size: "1fr" }
16930
+ ];
16931
+ function SpanScoreList({
16932
+ scoresData,
16933
+ isLoadingScoresData,
16934
+ traceId,
16935
+ spanId,
16936
+ initialScoreId,
16937
+ onPageChange,
16938
+ computeTraceLink
17136
16939
  }) {
17137
- const devStyleRequested = devUIStyleRequested("MainContentContent");
17138
- return /* @__PURE__ */ jsxRuntime.jsx(
17139
- "div",
17140
- {
17141
- className: cn(
17142
- `grid overflow-y-auto h-full `,
17143
- `overflow-x-auto min-w-[min-content]`,
16940
+ const { navigate } = useLinkComponent();
16941
+ const [dialogIsOpen, setDialogIsOpen] = React.useState(false);
16942
+ const [selectedScore, setSelectedScore] = React.useState();
16943
+ React.useEffect(() => {
16944
+ if (initialScoreId) {
16945
+ handleOnScore(initialScoreId);
16946
+ }
16947
+ }, [initialScoreId]);
16948
+ const handleOnScore = (scoreId) => {
16949
+ const score = scoresData?.scores?.find((s) => s?.id === scoreId);
16950
+ setSelectedScore(score);
16951
+ setDialogIsOpen(true);
16952
+ };
16953
+ if (isLoadingScoresData) {
16954
+ return /* @__PURE__ */ jsxRuntime.jsx(EntryListSkeleton, { columns: traceScoresListColumns });
16955
+ }
16956
+ const updateSelectedScore = (scoreId) => {
16957
+ const score = scoresData?.scores?.find((s) => s?.id === scoreId);
16958
+ setSelectedScore(score);
16959
+ };
16960
+ const toNextScore = getToNextEntryFn({
16961
+ entries: scoresData?.scores || [],
16962
+ id: selectedScore?.id,
16963
+ update: updateSelectedScore
16964
+ });
16965
+ const toPreviousScore = getToPreviousEntryFn({
16966
+ entries: scoresData?.scores || [],
16967
+ id: selectedScore?.id,
16968
+ update: updateSelectedScore
16969
+ });
16970
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
16971
+ /* @__PURE__ */ jsxRuntime.jsxs(EntryList, { children: [
16972
+ /* @__PURE__ */ jsxRuntime.jsxs(EntryList.Trim, { children: [
16973
+ /* @__PURE__ */ jsxRuntime.jsx(EntryList.Header, { columns: traceScoresListColumns }),
16974
+ scoresData?.scores && scoresData.scores.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(EntryList.Entries, { children: scoresData?.scores?.map((score) => {
16975
+ const createdAtDate = new Date(score.createdAt);
16976
+ const isTodayDate = dateFns.isToday(createdAtDate);
16977
+ const entry = {
16978
+ id: score?.id,
16979
+ shortId: getShortId(score?.id) || "n/a",
16980
+ date: isTodayDate ? "Today" : dateFns.format(createdAtDate, "MMM dd"),
16981
+ time: dateFns.format(createdAtDate, "h:mm:ss aaa"),
16982
+ score: score?.score,
16983
+ scorer: score?.scorer?.name
16984
+ };
16985
+ return /* @__PURE__ */ jsxRuntime.jsx(
16986
+ EntryList.Entry,
16987
+ {
16988
+ columns: traceScoresListColumns,
16989
+ onClick: () => handleOnScore(score.id),
16990
+ entry,
16991
+ children: traceScoresListColumns.map((col) => {
16992
+ const key = `col-${col.name}`;
16993
+ return /* @__PURE__ */ jsxRuntime.jsx(EntryList.EntryText, { children: entry?.[col.name] }, key);
16994
+ })
16995
+ },
16996
+ score.id
16997
+ );
16998
+ }) }) : /* @__PURE__ */ jsxRuntime.jsx(EntryList.Message, { message: "No scores found", type: "info" })
16999
+ ] }),
17000
+ /* @__PURE__ */ jsxRuntime.jsx(
17001
+ EntryList.Pagination,
17144
17002
  {
17145
- "items-start content-start": !isCentered && !isDivided && !hasLeftServiceColumn,
17146
- "grid place-items-center": isCentered,
17147
- "grid-cols-[1fr_1fr]": isDivided && !hasLeftServiceColumn,
17148
- "grid-cols-[12rem_1fr_1fr]": isDivided && hasLeftServiceColumn,
17149
- "grid-cols-[auto_1fr]": !isDivided && hasLeftServiceColumn
17003
+ currentPage: scoresData?.pagination?.page || 0,
17004
+ hasMore: scoresData?.pagination?.hasMore,
17005
+ onNextPage: () => onPageChange && onPageChange((scoresData?.pagination?.page || 0) + 1),
17006
+ onPrevPage: () => onPageChange && onPageChange((scoresData?.pagination?.page || 0) - 1)
17007
+ }
17008
+ )
17009
+ ] }),
17010
+ /* @__PURE__ */ jsxRuntime.jsx(
17011
+ ScoreDialog,
17012
+ {
17013
+ scorerName: selectedScore?.scorer?.name || "",
17014
+ score: selectedScore,
17015
+ isOpen: dialogIsOpen,
17016
+ onClose: () => {
17017
+ if (traceId) {
17018
+ navigate(`${computeTraceLink(traceId, spanId)}&tab=scores`);
17019
+ }
17020
+ setDialogIsOpen(false);
17150
17021
  },
17151
- className
17152
- ),
17153
- style: { ...style, ...devStyleRequested ? { border: "3px dotted orange" } : {} },
17154
- children
17155
- }
17156
- );
17022
+ dialogLevel: 3,
17023
+ onNext: toNextScore,
17024
+ onPrevious: toPreviousScore,
17025
+ computeTraceLink: (traceId2, spanId2) => `/observability?traceId=${traceId2}${spanId2 ? `&spanId=${spanId2}` : ""}`,
17026
+ usageContext: "aiSpanDialog"
17027
+ }
17028
+ )
17029
+ ] });
17157
17030
  }
17158
- function devUIStyleRequested(name) {
17159
- try {
17160
- const raw = localStorage.getItem("add-dev-style-to-components");
17161
- if (!raw) return false;
17162
- const components = raw.split(",").map((c) => c.trim()).filter(Boolean);
17163
- return components.includes(name);
17164
- } catch (error) {
17165
- console.error("Error reading or parsing localStorage:", error);
17166
- return false;
17031
+
17032
+ const useTriggerScorer = () => {
17033
+ const client = react$3.useMastraClient();
17034
+ return reactQuery.useMutation({
17035
+ mutationFn: async ({ scorerName, traceId, spanId }) => {
17036
+ const response = await client.score({
17037
+ scorerName,
17038
+ targets: [{ traceId, spanId }]
17039
+ });
17040
+ return response;
17041
+ }
17042
+ });
17043
+ };
17044
+
17045
+ const SpanScoring = ({ traceId, spanId, entityType }) => {
17046
+ const { data: scorers = {}, isLoading } = useScorers();
17047
+ const [selectedScorer, setSelectedScorer] = React.useState(null);
17048
+ const { mutate: triggerScorer, isPending, isSuccess } = useTriggerScorer();
17049
+ const [notificationIsVisible, setNotificationIsVisible] = React.useState(false);
17050
+ React.useEffect(() => {
17051
+ if (isSuccess) {
17052
+ setNotificationIsVisible(true);
17053
+ }
17054
+ }, [isSuccess]);
17055
+ let scorerList = Object.entries(scorers).map(([key, scorer]) => ({
17056
+ id: key,
17057
+ name: scorer.scorer.config.name,
17058
+ description: scorer.scorer.config.description,
17059
+ isRegistered: scorer.isRegistered,
17060
+ type: scorer.scorer.config.type
17061
+ })).filter((scorer) => scorer.isRegistered);
17062
+ if (entityType !== "Agent" || spanId) {
17063
+ scorerList = scorerList.filter((scorer) => scorer.type !== "agent");
17167
17064
  }
17168
- }
17065
+ const isWaiting = isPending || isLoading;
17066
+ const handleStartScoring = () => {
17067
+ if (selectedScorer) {
17068
+ setNotificationIsVisible(false);
17069
+ triggerScorer({
17070
+ scorerName: selectedScorer,
17071
+ traceId: traceId || "",
17072
+ spanId
17073
+ });
17074
+ }
17075
+ };
17076
+ const handleScorerChange = (val) => {
17077
+ setSelectedScorer(val);
17078
+ setNotificationIsVisible(false);
17079
+ };
17080
+ const selectedScorerDescription = scorerList.find((s) => s.name === selectedScorer)?.description || "";
17081
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
17082
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[3fr_1fr] gap-[1rem] items-start", children: [
17083
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-[0.5rem]", children: [
17084
+ /* @__PURE__ */ jsxRuntime.jsx(
17085
+ SelectField,
17086
+ {
17087
+ name: "select-scorer",
17088
+ placeholder: "Select a scorer...",
17089
+ options: scorerList.map((scorer) => ({ label: scorer.name, value: scorer.name })),
17090
+ onValueChange: handleScorerChange,
17091
+ value: selectedScorer || "",
17092
+ className: "min-w-[20rem]",
17093
+ disabled: isWaiting
17094
+ }
17095
+ ),
17096
+ selectedScorerDescription && /* @__PURE__ */ jsxRuntime.jsxs(TextAndIcon, { className: "text-icon3", children: [
17097
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, {}),
17098
+ " ",
17099
+ selectedScorerDescription
17100
+ ] })
17101
+ ] }),
17102
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { disabled: !selectedScorer || isWaiting, onClick: handleStartScoring, children: isPending ? "Starting..." : "Start Scoring" })
17103
+ ] }),
17104
+ /* @__PURE__ */ jsxRuntime.jsxs(Notification, { isVisible: notificationIsVisible, className: "mt-[1rem]", children: [
17105
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, {}),
17106
+ " Scorer triggered! When finished successfully, it will appear in the list below. It could take a moment."
17107
+ ] })
17108
+ ] });
17109
+ };
17169
17110
 
17170
17111
  const Breadcrumb = ({ children, label }) => {
17171
17112
  return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": label, children: /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "gap-sm flex items-center", children }) });
@@ -17772,7 +17713,7 @@ function MCPTable({ mcpServers, isLoading }) {
17772
17713
  return /* @__PURE__ */ jsxRuntime.jsx(EmptyMCPTable, {});
17773
17714
  }
17774
17715
  const filteredRows = rows.filter((row) => row.original.name.toLowerCase().includes(search.toLowerCase()));
17775
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
17716
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
17776
17717
  /* @__PURE__ */ jsxRuntime.jsx(SearchbarWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(Searchbar, { onSearch: setSearch, label: "Search MCP servers", placeholder: "Search MCP servers" }) }),
17777
17718
  isLoading ? /* @__PURE__ */ jsxRuntime.jsx(MCPTableSkeleton, {}) : /* @__PURE__ */ jsxRuntime.jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Table$1, { children: [
17778
17719
  /* @__PURE__ */ jsxRuntime.jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsxRuntime.jsx(Th, { style: { width: header.column.getSize() ?? "auto" }, children: reactTable.flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
@@ -17880,15 +17821,16 @@ exports.AgentSettingsContext = AgentSettingsContext;
17880
17821
  exports.AgentSettingsProvider = AgentSettingsProvider;
17881
17822
  exports.AgentsTable = AgentsTable;
17882
17823
  exports.AiIcon = AiIcon;
17883
- exports.Alert = Alert;
17884
- exports.AlertDescription = AlertDescription;
17824
+ exports.Alert = Alert$1;
17825
+ exports.AlertDescription = AlertDescription$1;
17885
17826
  exports.AlertDialog = AlertDialog;
17886
- exports.AlertTitle = AlertTitle;
17827
+ exports.AlertTitle = AlertTitle$1;
17887
17828
  exports.ApiIcon = ApiIcon;
17888
17829
  exports.Badge = Badge$1;
17889
17830
  exports.BranchIcon = BranchIcon;
17890
17831
  exports.Breadcrumb = Breadcrumb;
17891
17832
  exports.Button = Button$1;
17833
+ exports.ButtonsGroup = ButtonsGroup;
17892
17834
  exports.Cell = Cell;
17893
17835
  exports.ChatThreads = ChatThreads;
17894
17836
  exports.CheckIcon = CheckIcon;
@@ -17921,11 +17863,7 @@ exports.EntityName = EntityName;
17921
17863
  exports.Entry = Entry;
17922
17864
  exports.EntryCell = EntryCell;
17923
17865
  exports.EntryList = EntryList;
17924
- exports.EntryListItem = EntryListItem;
17925
- exports.EntryListPageHeader = EntryListPageHeader;
17926
- exports.EntryListStatusCell = EntryListStatusCell;
17927
- exports.EntryListTextCell = EntryListTextCell;
17928
- exports.EntryListToolbar = EntryListToolbar;
17866
+ exports.EntryListSkeleton = EntryListSkeleton;
17929
17867
  exports.EnvIcon = EnvIcon;
17930
17868
  exports.EvaluatorCoinIcon = EvaluatorCoinIcon;
17931
17869
  exports.FiltersIcon = FiltersIcon;
@@ -17951,12 +17889,15 @@ exports.LogsIcon = LogsIcon;
17951
17889
  exports.MCPTable = MCPTable;
17952
17890
  exports.MainContentContent = MainContentContent;
17953
17891
  exports.MainContentLayout = MainContentLayout;
17892
+ exports.MainSidebar = MainSidebar;
17893
+ exports.MainSidebarProvider = MainSidebarProvider;
17954
17894
  exports.MastraResizablePanel = MastraResizablePanel;
17955
17895
  exports.McpCoinIcon = McpCoinIcon;
17956
17896
  exports.McpServerIcon = McpServerIcon;
17957
17897
  exports.MemoryIcon = MemoryIcon;
17958
17898
  exports.MemorySearch = MemorySearch;
17959
17899
  exports.ModelResetProvider = ModelResetProvider;
17900
+ exports.Notification = Notification;
17960
17901
  exports.OpenAIIcon = OpenAIIcon;
17961
17902
  exports.PageHeader = PageHeader;
17962
17903
  exports.PlaygroundQueryClient = PlaygroundQueryClient;
@@ -17972,27 +17913,24 @@ exports.RuntimeContextWrapper = RuntimeContextWrapper;
17972
17913
  exports.ScoreDialog = ScoreDialog;
17973
17914
  exports.ScoreIcon = ScoreIcon;
17974
17915
  exports.ScorersTable = ScorersTable;
17916
+ exports.ScoresList = ScoresList;
17975
17917
  exports.ScoresTools = ScoresTools;
17976
17918
  exports.SearchField = SearchField;
17977
17919
  exports.Searchbar = Searchbar;
17978
17920
  exports.SearchbarWrapper = SearchbarWrapper;
17921
+ exports.Section = Section;
17922
+ exports.Sections = Sections;
17979
17923
  exports.SelectField = SelectField;
17980
17924
  exports.SettingsIcon = SettingsIcon;
17981
17925
  exports.SideDialog = SideDialog;
17982
- exports.SideDialogCodeSection = SideDialogCodeSection;
17983
- exports.SideDialogContent = SideDialogContent;
17984
- exports.SideDialogFooter = SideDialogFooter;
17985
- exports.SideDialogFooterGroup = SideDialogFooterGroup;
17986
- exports.SideDialogHeader = SideDialogHeader;
17987
- exports.SideDialogHeading = SideDialogHeading;
17988
- exports.SideDialogKeyValueList = SideDialogKeyValueList;
17989
- exports.SideDialogSection = SideDialogSection;
17990
- exports.SideDialogTop = SideDialogTop;
17991
17926
  exports.SlashIcon = SlashIcon;
17992
17927
  exports.SliderField = SliderField;
17993
- exports.Tab = Tab;
17994
- exports.TabContent = TabContent;
17995
- exports.TabList = TabList;
17928
+ exports.SpanScoreList = SpanScoreList;
17929
+ exports.SpanScoring = SpanScoring;
17930
+ exports.SpanTabs = SpanTabs;
17931
+ exports.Tab = Tab$1;
17932
+ exports.TabContent = TabContent$1;
17933
+ exports.TabList = TabList$1;
17996
17934
  exports.Table = Table$1;
17997
17935
  exports.Tbody = Tbody;
17998
17936
  exports.TemplateFailure = TemplateFailure;
@@ -18016,11 +17954,16 @@ exports.ToolCoinIcon = ToolCoinIcon;
18016
17954
  exports.ToolFallback = ToolFallback;
18017
17955
  exports.ToolTable = ToolTable;
18018
17956
  exports.ToolsIcon = ToolsIcon;
17957
+ exports.Tooltip = Tooltip;
17958
+ exports.TooltipContent = TooltipContent;
17959
+ exports.TooltipProvider = TooltipProvider;
17960
+ exports.TooltipTrigger = TooltipTrigger;
18019
17961
  exports.TraceDialog = TraceDialog;
18020
17962
  exports.TraceIcon = TraceIcon;
18021
17963
  exports.TraceTimeline = TraceTimeline;
18022
17964
  exports.TraceTimelineLegend = TraceTimelineLegend;
18023
17965
  exports.TraceTimelineSpan = TraceTimelineSpan;
17966
+ exports.TracesList = TracesList;
18024
17967
  exports.TracesTools = TracesTools;
18025
17968
  exports.TracesView = TracesView;
18026
17969
  exports.TracesViewSkeleton = TracesViewSkeleton;
@@ -18043,6 +17986,7 @@ exports.WorkingMemoryProvider = WorkingMemoryProvider;
18043
17986
  exports.allowedAiSpanAttributes = allowedAiSpanAttributes;
18044
17987
  exports.cleanString = cleanString;
18045
17988
  exports.convertWorkflowRunStateToStreamResult = convertWorkflowRunStateToStreamResult;
17989
+ exports.extractPrompt = extractPrompt;
18046
17990
  exports.formatDuration = formatDuration;
18047
17991
  exports.formatHierarchicalSpans = formatHierarchicalSpans;
18048
17992
  exports.formatOtelTimestamp = formatOtelTimestamp;
@@ -18050,15 +17994,21 @@ exports.formatOtelTimestamp2 = formatOtelTimestamp2;
18050
17994
  exports.getColumnTemplate = getColumnTemplate;
18051
17995
  exports.getShortId = getShortId;
18052
17996
  exports.getSpanTypeUi = getSpanTypeUi;
17997
+ exports.getToNextEntryFn = getToNextEntryFn;
17998
+ exports.getToPreviousEntryFn = getToPreviousEntryFn;
18053
17999
  exports.parseError = parseError;
18054
18000
  exports.providerMapToIcon = providerMapToIcon;
18001
+ exports.scoresListColumns = scoresListColumns;
18055
18002
  exports.spanTypePrefixes = spanTypePrefixes;
18003
+ exports.traceScoresListColumns = traceScoresListColumns;
18004
+ exports.tracesListColumns = tracesListColumns;
18056
18005
  exports.transformKey = transformKey;
18057
18006
  exports.useAgentSettings = useAgentSettings;
18058
18007
  exports.useCurrentRun = useCurrentRun;
18059
18008
  exports.useInView = useInView;
18060
18009
  exports.useLinkComponent = useLinkComponent;
18061
18010
  exports.useMCPServerTools = useMCPServerTools;
18011
+ exports.useMainSidebar = useMainSidebar;
18062
18012
  exports.useModelReset = useModelReset;
18063
18013
  exports.usePlaygroundStore = usePlaygroundStore;
18064
18014
  exports.usePolling = usePolling;
@@ -18068,6 +18018,7 @@ exports.useScoresByEntityId = useScoresByEntityId;
18068
18018
  exports.useScoresByScorerId = useScoresByScorerId;
18069
18019
  exports.useSpeechRecognition = useSpeechRecognition;
18070
18020
  exports.useThreadInput = useThreadInput;
18021
+ exports.useTraceSpanScores = useTraceSpanScores;
18071
18022
  exports.useWorkflow = useWorkflow;
18072
18023
  exports.useWorkflowRuns = useWorkflowRuns;
18073
18024
  exports.useWorkingMemory = useWorkingMemory;