@mastra/playground-ui 6.4.1-alpha.1 → 6.5.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/dist/index.cjs.js +639 -1074
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +633 -1071
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/assistant-ui/messages/assistant-message.d.ts +1 -3
- package/dist/src/components/assistant-ui/thread.d.ts +1 -3
- package/dist/src/components/assistant-ui/tools/badges/agent-badge.d.ts +5 -8
- package/dist/src/components/assistant-ui/tools/badges/tool-badge.d.ts +3 -5
- package/dist/src/components/assistant-ui/tools/badges/workflow-badge.d.ts +3 -5
- package/dist/src/components/assistant-ui/tools/tool-fallback.d.ts +6 -2
- package/dist/src/components/ui/elements/entry-list/entry-list-entries-skeleton.d.ts +6 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-entries.d.ts +6 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-entry-col.d.ts +7 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-entry.d.ts +11 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-header.d.ts +6 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-message.d.ts +8 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-next-page-loading.d.ts +9 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-pagination.d.ts +8 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-root.d.ts +6 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-skeleton.d.ts +2 -0
- package/dist/src/components/ui/elements/entry-list/entry-list-trim.d.ts +6 -0
- package/dist/src/components/ui/elements/entry-list/entry-list.d.ts +20 -18
- package/dist/src/components/ui/elements/entry-list/helpers.d.ts +10 -0
- package/dist/src/components/ui/elements/entry-list/index.d.ts +3 -4
- package/dist/src/components/ui/elements/entry-list/shared.d.ts +1 -5
- package/dist/src/components/ui/elements/entry-list/types.d.ts +5 -0
- package/dist/src/components/ui/elements/headers/page-header.d.ts +2 -2
- package/dist/src/domains/agents/components/agent-chat.d.ts +1 -1
- package/dist/src/domains/agents/index.d.ts +1 -0
- package/dist/src/domains/agents/utils/extractPrompt.d.ts +2 -0
- package/dist/src/domains/observability/components/index.d.ts +1 -0
- package/dist/src/domains/observability/components/traces-list.d.ts +18 -0
- package/dist/src/domains/scores/components/scores-list.d.ts +21 -0
- package/dist/src/domains/scores/index.d.ts +1 -0
- package/dist/src/services/mastra-runtime-provider.d.ts +1 -1
- package/dist/src/types.d.ts +3 -1
- package/package.json +7 -7
- package/dist/src/components/ui/elements/entry-list/entry-list-cell.d.ts +0 -7
- package/dist/src/components/ui/elements/entry-list/entry-list-item.d.ts +0 -9
- package/dist/src/components/ui/elements/entry-list/entry-list-page-header.d.ts +0 -8
- package/dist/src/services/agent-network-message.d.ts +0 -2
- package/dist/src/services/stream-chunk-message.d.ts +0 -32
- package/dist/src/services/vnext-message-provider.d.ts +0 -10
package/dist/index.cjs.js
CHANGED
|
@@ -3450,42 +3450,6 @@ const defaultComponents = reactMarkdown.unstable_memoizeMarkdownComponents({
|
|
|
3450
3450
|
img: ImageWithFallback
|
|
3451
3451
|
});
|
|
3452
3452
|
|
|
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
3453
|
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
3454
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3491
3455
|
"path",
|
|
@@ -4278,6 +4242,91 @@ const AgentNetworkCoinIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", {
|
|
|
4278
4242
|
) }) })
|
|
4279
4243
|
] });
|
|
4280
4244
|
|
|
4245
|
+
const variants = {
|
|
4246
|
+
"header-md": "text-header-md leading-header-md",
|
|
4247
|
+
"ui-lg": "text-ui-lg leading-ui-lg",
|
|
4248
|
+
"ui-md": "text-ui-md leading-ui-md",
|
|
4249
|
+
"ui-sm": "text-ui-sm leading-ui-sm",
|
|
4250
|
+
"ui-xs": "text-ui-xs leading-ui-xs"
|
|
4251
|
+
};
|
|
4252
|
+
const fonts = {
|
|
4253
|
+
mono: "font-mono"
|
|
4254
|
+
};
|
|
4255
|
+
const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) => {
|
|
4256
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
|
|
4257
|
+
};
|
|
4258
|
+
|
|
4259
|
+
const variantClasses$3 = {
|
|
4260
|
+
warning: "bg-yellow-900/20 border-sm border-yellow-200 text-yellow-200",
|
|
4261
|
+
destructive: "bg-red-900/20 border-sm border-red-200 text-red-200"
|
|
4262
|
+
};
|
|
4263
|
+
const variantIcons = {
|
|
4264
|
+
warning: lucideReact.TriangleAlert,
|
|
4265
|
+
destructive: lucideReact.AlertCircle
|
|
4266
|
+
};
|
|
4267
|
+
const Alert$1 = ({ children, variant = "destructive" }) => {
|
|
4268
|
+
const Ico = variantIcons[variant];
|
|
4269
|
+
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: [
|
|
4270
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "mt-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(Ico, {}) }),
|
|
4271
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children })
|
|
4272
|
+
] }) });
|
|
4273
|
+
};
|
|
4274
|
+
const AlertTitle$1 = ({ children, as: As = "h5" }) => {
|
|
4275
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: As, variant: "ui-md", className: "font-semibold", children });
|
|
4276
|
+
};
|
|
4277
|
+
const AlertDescription$1 = ({ children, as: As = "p" }) => {
|
|
4278
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: As, variant: "ui-sm", children });
|
|
4279
|
+
};
|
|
4280
|
+
|
|
4281
|
+
const ErrorAwareText = () => {
|
|
4282
|
+
const part = react.useMessagePart();
|
|
4283
|
+
const text = part.text || "";
|
|
4284
|
+
const metadata = part.metadata || {};
|
|
4285
|
+
if (metadata?.status === "warning") {
|
|
4286
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Alert$1, { variant: "warning", children: [
|
|
4287
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertTitle$1, { as: "h5", children: "Warning" }),
|
|
4288
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDescription$1, { as: "p", children: text })
|
|
4289
|
+
] });
|
|
4290
|
+
}
|
|
4291
|
+
if (metadata?.status === "error") {
|
|
4292
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Alert$1, { variant: "destructive", children: [
|
|
4293
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertTitle$1, { as: "h5", children: "Error" }),
|
|
4294
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertDescription$1, { as: "p", children: text })
|
|
4295
|
+
] });
|
|
4296
|
+
}
|
|
4297
|
+
try {
|
|
4298
|
+
const trimmedText = text.trim();
|
|
4299
|
+
if (trimmedText.startsWith("__ERROR__:")) {
|
|
4300
|
+
const errorMessage = trimmedText.substring("__ERROR__:".length);
|
|
4301
|
+
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: [
|
|
4302
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-5 h-5 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0" }),
|
|
4303
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
4304
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-red-800 dark:text-red-200 mb-1", children: "Error" }),
|
|
4305
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: errorMessage })
|
|
4306
|
+
] })
|
|
4307
|
+
] });
|
|
4308
|
+
} else if (trimmedText.startsWith("Error:")) {
|
|
4309
|
+
const errorMessage = trimmedText.substring("Error:".length).trim();
|
|
4310
|
+
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: [
|
|
4311
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-5 h-5 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0" }),
|
|
4312
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
4313
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-red-800 dark:text-red-200 mb-1", children: "Error" }),
|
|
4314
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: errorMessage })
|
|
4315
|
+
] })
|
|
4316
|
+
] });
|
|
4317
|
+
}
|
|
4318
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MarkdownText, {});
|
|
4319
|
+
} catch (error) {
|
|
4320
|
+
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: [
|
|
4321
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-5 h-5 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0" }),
|
|
4322
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
4323
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-red-800 dark:text-red-200 mb-1", children: "Error" }),
|
|
4324
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: String(text) })
|
|
4325
|
+
] })
|
|
4326
|
+
] });
|
|
4327
|
+
}
|
|
4328
|
+
};
|
|
4329
|
+
|
|
4281
4330
|
function useCopyToClipboard({ text, copyMessage = "Copied to clipboard!" }) {
|
|
4282
4331
|
const [isCopied, setIsCopied] = React.useState(false);
|
|
4283
4332
|
const timeoutRef = React.useRef(null);
|
|
@@ -4343,12 +4392,12 @@ const SyntaxHighlighter$2 = ({
|
|
|
4343
4392
|
const formattedCode = JSON.stringify(data, null, 2);
|
|
4344
4393
|
const theme = useCodemirrorTheme$2();
|
|
4345
4394
|
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-
|
|
4395
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyButton, { content: formattedCode, className: "absolute top-2 right-2 z-20" }),
|
|
4347
4396
|
/* @__PURE__ */ jsxRuntime.jsx(CodeMirror, { value: formattedCode, theme, extensions: [langJson.jsonLanguage] })
|
|
4348
4397
|
] });
|
|
4349
4398
|
};
|
|
4350
4399
|
|
|
4351
|
-
const variantClasses$
|
|
4400
|
+
const variantClasses$2 = {
|
|
4352
4401
|
default: "text-icon3",
|
|
4353
4402
|
success: "text-accent1",
|
|
4354
4403
|
error: "text-accent2",
|
|
@@ -4361,12 +4410,12 @@ const Badge$1 = ({ icon, variant = "default", className, children, ...props }) =
|
|
|
4361
4410
|
className: clsx(
|
|
4362
4411
|
"font-mono bg-surface4 text-ui-sm gap-md h-badge-default inline-flex items-center rounded-md shrink-0",
|
|
4363
4412
|
icon ? "pl-md pr-1.5" : "px-1.5",
|
|
4364
|
-
icon || variant === "default" ? "text-icon5" : variantClasses$
|
|
4413
|
+
icon || variant === "default" ? "text-icon5" : variantClasses$2[variant],
|
|
4365
4414
|
className
|
|
4366
4415
|
),
|
|
4367
4416
|
...props,
|
|
4368
4417
|
children: [
|
|
4369
|
-
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: variantClasses$
|
|
4418
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: variantClasses$2[variant], children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: icon }) }),
|
|
4370
4419
|
children
|
|
4371
4420
|
]
|
|
4372
4421
|
}
|
|
@@ -4453,20 +4502,6 @@ DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
|
|
|
4453
4502
|
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
4503
|
DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
|
|
4455
4504
|
|
|
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
4505
|
const NetworkChoiceMetadata = ({ selectionReason, open, onOpenChange, input }) => {
|
|
4471
4506
|
let inputSlot = null;
|
|
4472
4507
|
if (input) {
|
|
@@ -4512,7 +4547,7 @@ const NetworkChoiceMetadataDialogTrigger = ({
|
|
|
4512
4547
|
] });
|
|
4513
4548
|
};
|
|
4514
4549
|
|
|
4515
|
-
const ToolBadge = ({ toolName, args, result,
|
|
4550
|
+
const ToolBadge = ({ toolName, args, result, metadata, toolOutput }) => {
|
|
4516
4551
|
let argSlot = null;
|
|
4517
4552
|
try {
|
|
4518
4553
|
const { __mastraMetadata: _, ...formattedArgs } = typeof args === "object" ? args : JSON.parse(args);
|
|
@@ -4521,16 +4556,18 @@ const ToolBadge = ({ toolName, args, result, networkMetadata, toolOutput }) => {
|
|
|
4521
4556
|
argSlot = /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap", children: args });
|
|
4522
4557
|
}
|
|
4523
4558
|
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 });
|
|
4559
|
+
const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
|
|
4560
|
+
const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
|
|
4524
4561
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4525
4562
|
BadgeWrapper,
|
|
4526
4563
|
{
|
|
4527
4564
|
icon: /* @__PURE__ */ jsxRuntime.jsx(ToolsIcon, { className: "text-[#ECB047]" }),
|
|
4528
4565
|
title: toolName,
|
|
4529
|
-
extraInfo:
|
|
4566
|
+
extraInfo: metadata?.mode === "network" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4530
4567
|
NetworkChoiceMetadataDialogTrigger,
|
|
4531
4568
|
{
|
|
4532
|
-
selectionReason:
|
|
4533
|
-
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$
|
|
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$
|
|
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
|
|
6110
|
-
Alert
|
|
6111
|
-
const AlertTitle
|
|
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
|
|
6115
|
-
const AlertDescription
|
|
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
|
|
6155
|
+
AlertDescription.displayName = "AlertDescription";
|
|
6119
6156
|
|
|
6120
|
-
const ErrorMessage = ({ error }) => /* @__PURE__ */ jsxRuntime.jsxs(Alert
|
|
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
|
|
6159
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertTitle, { children: error })
|
|
6123
6160
|
] });
|
|
6124
6161
|
|
|
6125
6162
|
const SubmitButton = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(Button$2, { type: "submit", children });
|
|
@@ -7736,24 +7773,26 @@ const EmptyWorkflowsTable = () => /* @__PURE__ */ jsxRuntime.jsx("div", { classN
|
|
|
7736
7773
|
}
|
|
7737
7774
|
) });
|
|
7738
7775
|
|
|
7739
|
-
const WorkflowBadge = ({ workflow, runId, workflowId, isStreaming,
|
|
7776
|
+
const WorkflowBadge = ({ workflow, runId, workflowId, isStreaming, metadata }) => {
|
|
7740
7777
|
const { data: runs, isLoading: isRunsLoading } = useWorkflowRuns(workflowId, {
|
|
7741
7778
|
enabled: Boolean(runId) && !isStreaming
|
|
7742
7779
|
});
|
|
7743
7780
|
const run = runs?.runs.find((run2) => run2.runId === runId);
|
|
7744
7781
|
const isLoading = isRunsLoading || !run;
|
|
7745
7782
|
const snapshot = typeof run?.snapshot === "object" ? run?.snapshot : void 0;
|
|
7783
|
+
const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
|
|
7784
|
+
const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
|
|
7746
7785
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7747
7786
|
BadgeWrapper,
|
|
7748
7787
|
{
|
|
7749
7788
|
icon: /* @__PURE__ */ jsxRuntime.jsx(WorkflowIcon, { className: "text-accent3" }),
|
|
7750
7789
|
title: workflow.name,
|
|
7751
7790
|
initialCollapsed: false,
|
|
7752
|
-
extraInfo:
|
|
7791
|
+
extraInfo: metadata?.mode === "network" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
7753
7792
|
NetworkChoiceMetadataDialogTrigger,
|
|
7754
7793
|
{
|
|
7755
|
-
selectionReason:
|
|
7756
|
-
input:
|
|
7794
|
+
selectionReason: selectionReason ?? "",
|
|
7795
|
+
input: agentNetworkInput
|
|
7757
7796
|
}
|
|
7758
7797
|
),
|
|
7759
7798
|
children: [
|
|
@@ -7805,18 +7844,20 @@ const LoadingBadge = () => {
|
|
|
7805
7844
|
);
|
|
7806
7845
|
};
|
|
7807
7846
|
|
|
7808
|
-
const AgentBadge = ({ agentId, messages = [],
|
|
7847
|
+
const AgentBadge = ({ agentId, messages = [], metadata }) => {
|
|
7848
|
+
const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
|
|
7849
|
+
const agentNetworkInput = metadata?.mode === "network" ? metadata.agentInput : void 0;
|
|
7809
7850
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7810
7851
|
BadgeWrapper,
|
|
7811
7852
|
{
|
|
7812
7853
|
icon: /* @__PURE__ */ jsxRuntime.jsx(AgentIcon, { className: "text-accent1" }),
|
|
7813
7854
|
title: agentId,
|
|
7814
7855
|
initialCollapsed: false,
|
|
7815
|
-
extraInfo:
|
|
7856
|
+
extraInfo: metadata?.mode === "network" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
7816
7857
|
NetworkChoiceMetadataDialogTrigger,
|
|
7817
7858
|
{
|
|
7818
|
-
selectionReason:
|
|
7819
|
-
input:
|
|
7859
|
+
selectionReason: selectionReason ?? "",
|
|
7860
|
+
input: agentNetworkInput
|
|
7820
7861
|
}
|
|
7821
7862
|
),
|
|
7822
7863
|
children: messages.map((message, index) => {
|
|
@@ -7835,6 +7876,9 @@ const AgentBadge = ({ agentId, messages = [], networkMetadata }) => {
|
|
|
7835
7876
|
type: "tool-call",
|
|
7836
7877
|
toolCallId: message.toolCallId,
|
|
7837
7878
|
addResult: () => {
|
|
7879
|
+
},
|
|
7880
|
+
metadata: {
|
|
7881
|
+
mode: "stream"
|
|
7838
7882
|
}
|
|
7839
7883
|
}
|
|
7840
7884
|
) }, index);
|
|
@@ -7846,30 +7890,25 @@ const AgentBadge = ({ agentId, messages = [], networkMetadata }) => {
|
|
|
7846
7890
|
const ToolFallback = ({ toolName, result, args, ...props }) => {
|
|
7847
7891
|
return /* @__PURE__ */ jsxRuntime.jsx(WorkflowRunProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(ToolFallbackInner, { toolName, result, args, ...props }) });
|
|
7848
7892
|
};
|
|
7849
|
-
const ToolFallbackInner = ({ toolName, result, args }) => {
|
|
7850
|
-
useWorkflowStream(
|
|
7893
|
+
const ToolFallbackInner = ({ toolName, result, args, metadata, ...props }) => {
|
|
7894
|
+
useWorkflowStream(result);
|
|
7851
7895
|
const { data: workflow, isLoading } = useWorkflow(toolName);
|
|
7852
|
-
const isAgent =
|
|
7896
|
+
const isAgent = metadata?.mode === "network" && metadata.from === "AGENT";
|
|
7853
7897
|
if (isAgent) {
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
{
|
|
7857
|
-
agentId: toolName,
|
|
7858
|
-
messages: args?.__mastraMetadata?.messages,
|
|
7859
|
-
networkMetadata: args?.__mastraMetadata?.networkMetadata
|
|
7860
|
-
}
|
|
7861
|
-
);
|
|
7898
|
+
const messages = result?.childMessages ?? [];
|
|
7899
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AgentBadge, { agentId: toolName, messages, metadata });
|
|
7862
7900
|
}
|
|
7863
7901
|
if (isLoading) return /* @__PURE__ */ jsxRuntime.jsx(LoadingBadge, {});
|
|
7864
7902
|
if (workflow) {
|
|
7903
|
+
const isStreaming = metadata?.mode === "stream" || metadata?.mode === "network";
|
|
7865
7904
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7866
7905
|
WorkflowBadge,
|
|
7867
7906
|
{
|
|
7868
7907
|
workflowId: toolName,
|
|
7869
7908
|
workflow,
|
|
7870
|
-
isStreaming
|
|
7909
|
+
isStreaming,
|
|
7871
7910
|
runId: result?.runId,
|
|
7872
|
-
|
|
7911
|
+
metadata
|
|
7873
7912
|
}
|
|
7874
7913
|
);
|
|
7875
7914
|
}
|
|
@@ -7879,8 +7918,8 @@ const ToolFallbackInner = ({ toolName, result, args }) => {
|
|
|
7879
7918
|
toolName,
|
|
7880
7919
|
args,
|
|
7881
7920
|
result,
|
|
7882
|
-
toolOutput:
|
|
7883
|
-
|
|
7921
|
+
toolOutput: result?.toolOutput || [],
|
|
7922
|
+
metadata
|
|
7884
7923
|
}
|
|
7885
7924
|
);
|
|
7886
7925
|
};
|
|
@@ -8445,32 +8484,23 @@ const ProviderLogo = ({ providerId, className = "", size = 20 }) => {
|
|
|
8445
8484
|
);
|
|
8446
8485
|
};
|
|
8447
8486
|
|
|
8448
|
-
const
|
|
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 }) => {
|
|
8487
|
+
const AssistantMessage = ({ hasModelList }) => {
|
|
8453
8488
|
const data = react.useMessage();
|
|
8454
8489
|
const messageId = data.id;
|
|
8455
8490
|
const isToolCallAndOrReasoning = data.content.every(({ type }) => type === "tool-call" || type === "reasoning");
|
|
8456
8491
|
const modelMetadata = data.metadata?.custom?.modelMetadata;
|
|
8457
|
-
const messageStatus = data.metadata?.custom?.status;
|
|
8458
|
-
const statusClass = statusClasses[messageStatus || "default"];
|
|
8459
8492
|
const showModelUsed = hasModelList && modelMetadata;
|
|
8460
8493
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.MessagePrimitive.Root, { className: "max-w-full", "data-message-id": messageId, children: [
|
|
8461
|
-
/* @__PURE__ */ jsxRuntime.
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
tools: { Fallback: ToolFallbackCustom || ToolFallback },
|
|
8469
|
-
Reasoning
|
|
8470
|
-
}
|
|
8494
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-icon6 text-ui-lg leading-ui-lg", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8495
|
+
react.MessagePrimitive.Parts,
|
|
8496
|
+
{
|
|
8497
|
+
components: {
|
|
8498
|
+
Text: ErrorAwareText,
|
|
8499
|
+
tools: { Fallback: ToolFallback },
|
|
8500
|
+
Reasoning
|
|
8471
8501
|
}
|
|
8472
|
-
|
|
8473
|
-
|
|
8502
|
+
}
|
|
8503
|
+
) }),
|
|
8474
8504
|
!isToolCallAndOrReasoning && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("h-6 pt-4 flex gap-2 items-center", { "pb-1": showModelUsed }), children: [
|
|
8475
8505
|
showModelUsed && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
8476
8506
|
/* @__PURE__ */ jsxRuntime.jsx(ProviderLogo, { providerId: modelMetadata.modelProvider, size: 14 }),
|
|
@@ -9067,11 +9097,11 @@ const useThreadInput = () => {
|
|
|
9067
9097
|
return React.useContext(ThreadInputContext);
|
|
9068
9098
|
};
|
|
9069
9099
|
|
|
9070
|
-
const Thread = ({
|
|
9100
|
+
const Thread = ({ agentName, agentId, hasMemory, hasModelList }) => {
|
|
9071
9101
|
const areaRef = React.useRef(null);
|
|
9072
9102
|
useAutoscroll(areaRef, { enabled: true });
|
|
9073
9103
|
const WrappedAssistantMessage = (props) => {
|
|
9074
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AssistantMessage, { ...props,
|
|
9104
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AssistantMessage, { ...props, hasModelList });
|
|
9075
9105
|
};
|
|
9076
9106
|
return /* @__PURE__ */ jsxRuntime.jsxs(ThreadWrapper, { children: [
|
|
9077
9107
|
/* @__PURE__ */ jsxRuntime.jsxs(react.ThreadPrimitive.Viewport, { ref: areaRef, autoScroll: false, className: "overflow-y-scroll scroll-smooth h-full", children: [
|
|
@@ -9447,645 +9477,72 @@ const useAdapters = (agentId) => {
|
|
|
9447
9477
|
};
|
|
9448
9478
|
};
|
|
9449
9479
|
|
|
9450
|
-
const
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
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
|
-
};
|
|
9480
|
+
const handleFinishReason = (finishReason) => {
|
|
9481
|
+
switch (finishReason) {
|
|
9482
|
+
case "tool-calls":
|
|
9483
|
+
throw new Error("Stream finished with reason tool-calls, try increasing maxSteps");
|
|
9472
9484
|
}
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
const
|
|
9477
|
-
|
|
9478
|
-
if (
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
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
|
-
}
|
|
9485
|
+
};
|
|
9486
|
+
const convertToAIAttachments = async (attachments) => {
|
|
9487
|
+
const promises = (attachments ?? []).filter((attachment) => attachment.type === "image" || attachment.type === "document").map(async (attachment) => {
|
|
9488
|
+
const isFileFromURL = attachment.name.startsWith("https://");
|
|
9489
|
+
if (attachment.type === "document") {
|
|
9490
|
+
if (attachment.contentType === "application/pdf") {
|
|
9491
|
+
const pdfText = attachment.content?.[0]?.text || "";
|
|
9492
|
+
return {
|
|
9493
|
+
role: "user",
|
|
9494
|
+
content: [
|
|
9495
|
+
{
|
|
9496
|
+
type: "file",
|
|
9497
|
+
data: isFileFromURL ? attachment.name : `data:application/pdf;base64,${pdfText}`,
|
|
9498
|
+
mimeType: attachment.contentType,
|
|
9499
|
+
filename: attachment.name
|
|
9500
|
+
}
|
|
9501
|
+
]
|
|
9502
|
+
};
|
|
9503
9503
|
}
|
|
9504
|
+
return {
|
|
9505
|
+
role: "user",
|
|
9506
|
+
// @ts-expect-error - TODO: fix this type issue somehow
|
|
9507
|
+
content: attachment.content[0]?.text || ""
|
|
9508
|
+
};
|
|
9504
9509
|
}
|
|
9505
9510
|
return {
|
|
9506
|
-
role: "
|
|
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",
|
|
9511
|
+
role: "user",
|
|
9530
9512
|
content: [
|
|
9531
9513
|
{
|
|
9532
|
-
type: "
|
|
9533
|
-
|
|
9534
|
-
|
|
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
|
-
}
|
|
9514
|
+
type: "image",
|
|
9515
|
+
image: isFileFromURL ? attachment.name : await fileToBase64(attachment.file),
|
|
9516
|
+
mimeType: attachment.file.type
|
|
9545
9517
|
}
|
|
9546
9518
|
]
|
|
9547
9519
|
};
|
|
9548
|
-
}
|
|
9549
|
-
return
|
|
9520
|
+
});
|
|
9521
|
+
return Promise.all(promises);
|
|
9550
9522
|
};
|
|
9551
|
-
|
|
9552
|
-
const
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
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
|
-
];
|
|
9523
|
+
const initializeMessageState = (initialMessages) => {
|
|
9524
|
+
const convertedMessages = initialMessages?.map((message) => {
|
|
9525
|
+
const attachmentsAsContentParts = (message.experimental_attachments || []).map((image) => ({
|
|
9526
|
+
type: image.contentType.startsWith(`image/`) ? "image" : image.contentType.startsWith(`audio/`) ? "audio" : "file",
|
|
9527
|
+
mimeType: image.contentType,
|
|
9528
|
+
image: image.url
|
|
9529
|
+
}));
|
|
9530
|
+
const formattedParts = (message.parts || []).map((part) => {
|
|
9531
|
+
if (part.type === "reasoning") {
|
|
9532
|
+
return {
|
|
9533
|
+
type: "reasoning",
|
|
9534
|
+
text: part.reasoning || part?.details?.filter((detail) => detail.type === "text")?.map((detail) => detail.text).join(" ")
|
|
9535
|
+
};
|
|
9602
9536
|
}
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
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
|
-
};
|
|
9537
|
+
if (part.type === "tool-invocation") {
|
|
9538
|
+
if (part.toolInvocation.state === "result") {
|
|
9539
|
+
return {
|
|
9540
|
+
type: "tool-call",
|
|
9541
|
+
toolCallId: part.toolInvocation.toolCallId,
|
|
9542
|
+
toolName: part.toolInvocation.toolName,
|
|
9543
|
+
args: part.toolInvocation.args,
|
|
9544
|
+
result: part.toolInvocation.result
|
|
9545
|
+
};
|
|
10089
9546
|
}
|
|
10090
9547
|
}
|
|
10091
9548
|
if (part.type === "file") {
|
|
@@ -10113,6 +9570,7 @@ function MastraRuntimeProvider({
|
|
|
10113
9570
|
children,
|
|
10114
9571
|
agentId,
|
|
10115
9572
|
initialMessages,
|
|
9573
|
+
initialLegacyMessages,
|
|
10116
9574
|
memory,
|
|
10117
9575
|
threadId,
|
|
10118
9576
|
refreshThreadList,
|
|
@@ -10120,9 +9578,10 @@ function MastraRuntimeProvider({
|
|
|
10120
9578
|
runtimeContext,
|
|
10121
9579
|
modelVersion
|
|
10122
9580
|
}) {
|
|
10123
|
-
const initializeMessages = () => memory ? initializeMessageState(initialMessages || []) : [];
|
|
10124
9581
|
const [isLegacyRunning, setIsLegacyRunning] = React.useState(false);
|
|
10125
|
-
const [legacyMessages, setLegacyMessages] = React.useState(
|
|
9582
|
+
const [legacyMessages, setLegacyMessages] = React.useState(
|
|
9583
|
+
() => memory ? initializeMessageState(initialLegacyMessages || []) : []
|
|
9584
|
+
);
|
|
10126
9585
|
const {
|
|
10127
9586
|
setMessages,
|
|
10128
9587
|
messages,
|
|
@@ -10133,7 +9592,7 @@ function MastraRuntimeProvider({
|
|
|
10133
9592
|
isRunning: isRunningStream
|
|
10134
9593
|
} = react$3.useChat({
|
|
10135
9594
|
agentId,
|
|
10136
|
-
initializeMessages
|
|
9595
|
+
initializeMessages: () => initialMessages || []
|
|
10137
9596
|
});
|
|
10138
9597
|
const { refetch: refreshWorkingMemory } = useWorkingMemory();
|
|
10139
9598
|
const abortControllerRef = React.useRef(null);
|
|
@@ -10166,7 +9625,8 @@ function MastraRuntimeProvider({
|
|
|
10166
9625
|
topP,
|
|
10167
9626
|
maxTokens,
|
|
10168
9627
|
instructions,
|
|
10169
|
-
providerOptions
|
|
9628
|
+
providerOptions,
|
|
9629
|
+
maxSteps
|
|
10170
9630
|
};
|
|
10171
9631
|
const baseClient = react$3.useMastraClient();
|
|
10172
9632
|
const isVNext = modelVersion === "v2";
|
|
@@ -10175,7 +9635,7 @@ function MastraRuntimeProvider({
|
|
|
10175
9635
|
const attachments = await convertToAIAttachments(message.attachments);
|
|
10176
9636
|
const input = message.content[0].text;
|
|
10177
9637
|
if (isVNext) {
|
|
10178
|
-
setMessages((s) => [...s, { role: "user",
|
|
9638
|
+
setMessages((s) => [...s, { role: "user", parts: [{ type: "text", text: input }] }]);
|
|
10179
9639
|
} else {
|
|
10180
9640
|
setLegacyMessages((s) => [...s, { role: "user", content: input, attachments: message.attachments }]);
|
|
10181
9641
|
}
|
|
@@ -10189,7 +9649,6 @@ function MastraRuntimeProvider({
|
|
|
10189
9649
|
try {
|
|
10190
9650
|
if (isVNext) {
|
|
10191
9651
|
if (chatWithNetwork) {
|
|
10192
|
-
let currentEntityId;
|
|
10193
9652
|
await network({
|
|
10194
9653
|
coreUserMessages: [
|
|
10195
9654
|
{
|
|
@@ -10202,73 +9661,9 @@ function MastraRuntimeProvider({
|
|
|
10202
9661
|
threadId,
|
|
10203
9662
|
modelSettings: modelSettingsArgs,
|
|
10204
9663
|
signal: controller.signal,
|
|
10205
|
-
onNetworkChunk: (chunk
|
|
10206
|
-
if (chunk.type
|
|
10207
|
-
|
|
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 });
|
|
9664
|
+
onNetworkChunk: async (chunk) => {
|
|
9665
|
+
if (chunk.type === "tool-execution-end" && chunk.payload?.toolName === "updateWorkingMemory" && typeof chunk.payload.result === "object" && "success" in chunk.payload.result && chunk.payload.result?.success) {
|
|
9666
|
+
refreshWorkingMemory?.();
|
|
10272
9667
|
}
|
|
10273
9668
|
}
|
|
10274
9669
|
});
|
|
@@ -10285,18 +9680,7 @@ function MastraRuntimeProvider({
|
|
|
10285
9680
|
runtimeContext: runtimeContextInstance,
|
|
10286
9681
|
threadId,
|
|
10287
9682
|
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
|
-
}
|
|
9683
|
+
signal: controller.signal
|
|
10300
9684
|
});
|
|
10301
9685
|
return;
|
|
10302
9686
|
} else {
|
|
@@ -10311,12 +9695,10 @@ function MastraRuntimeProvider({
|
|
|
10311
9695
|
runtimeContext: runtimeContextInstance,
|
|
10312
9696
|
threadId,
|
|
10313
9697
|
modelSettings: modelSettingsArgs,
|
|
10314
|
-
onChunk: (chunk
|
|
10315
|
-
const next = handleStreamChunk({ chunk, conversation });
|
|
9698
|
+
onChunk: async (chunk) => {
|
|
10316
9699
|
if (chunk.type === "tool-result" && chunk.payload?.toolName === "updateWorkingMemory" && typeof chunk.payload.result === "object" && "success" in chunk.payload.result && chunk.payload.result?.success) {
|
|
10317
9700
|
refreshWorkingMemory?.();
|
|
10318
9701
|
}
|
|
10319
|
-
return next;
|
|
10320
9702
|
},
|
|
10321
9703
|
signal: controller.signal
|
|
10322
9704
|
});
|
|
@@ -10611,7 +9993,7 @@ function MastraRuntimeProvider({
|
|
|
10611
9993
|
if (isVNext) {
|
|
10612
9994
|
setMessages((currentConversation) => [
|
|
10613
9995
|
...currentConversation,
|
|
10614
|
-
{ role: "assistant",
|
|
9996
|
+
{ role: "assistant", parts: [{ type: "text", text: `${error}` }] }
|
|
10615
9997
|
]);
|
|
10616
9998
|
} else {
|
|
10617
9999
|
setLegacyMessages((currentConversation) => [
|
|
@@ -10632,20 +10014,17 @@ function MastraRuntimeProvider({
|
|
|
10632
10014
|
}
|
|
10633
10015
|
};
|
|
10634
10016
|
const { adapters, isReady } = useAdapters(agentId);
|
|
10017
|
+
const vnextmessages = messages.map(react$3.toAssistantUIMessage);
|
|
10635
10018
|
const runtime = react.useExternalStoreRuntime({
|
|
10636
10019
|
isRunning: isLegacyRunning || isRunningStream,
|
|
10637
|
-
messages: isVNext ?
|
|
10020
|
+
messages: isVNext ? vnextmessages : legacyMessages,
|
|
10638
10021
|
convertMessage: (x) => x,
|
|
10639
10022
|
onNew,
|
|
10640
10023
|
onCancel,
|
|
10641
10024
|
adapters: isReady ? adapters : void 0
|
|
10642
10025
|
});
|
|
10643
10026
|
if (!isReady) return null;
|
|
10644
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
10645
|
-
" ",
|
|
10646
|
-
children,
|
|
10647
|
-
" "
|
|
10648
|
-
] });
|
|
10027
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.AssistantRuntimeProvider, { runtime, children });
|
|
10649
10028
|
}
|
|
10650
10029
|
|
|
10651
10030
|
const defaultSettings = {
|
|
@@ -10713,6 +10092,7 @@ const AgentChat = ({
|
|
|
10713
10092
|
agentName,
|
|
10714
10093
|
threadId,
|
|
10715
10094
|
initialMessages,
|
|
10095
|
+
initialLegacyMessages,
|
|
10716
10096
|
memory,
|
|
10717
10097
|
refreshThreadList,
|
|
10718
10098
|
modelVersion,
|
|
@@ -10728,6 +10108,7 @@ const AgentChat = ({
|
|
|
10728
10108
|
modelVersion,
|
|
10729
10109
|
threadId,
|
|
10730
10110
|
initialMessages,
|
|
10111
|
+
initialLegacyMessages,
|
|
10731
10112
|
memory,
|
|
10732
10113
|
refreshThreadList,
|
|
10733
10114
|
settings,
|
|
@@ -11486,13 +10867,35 @@ const AgentSettings = ({ modelVersion, hasMemory = false, hasSubAgents = false }
|
|
|
11486
10867
|
] });
|
|
11487
10868
|
};
|
|
11488
10869
|
|
|
10870
|
+
const resolveInstructionPart = (part) => {
|
|
10871
|
+
if (typeof part === "string") {
|
|
10872
|
+
return part.trim();
|
|
10873
|
+
}
|
|
10874
|
+
return part.text?.trim() || "";
|
|
10875
|
+
};
|
|
10876
|
+
const extractPrompt = (instructions) => {
|
|
10877
|
+
if (typeof instructions === "string") {
|
|
10878
|
+
return instructions.trim();
|
|
10879
|
+
}
|
|
10880
|
+
if (typeof instructions === "object" && "content" in instructions) {
|
|
10881
|
+
if (Array.isArray(instructions.content)) {
|
|
10882
|
+
return instructions.content.map(resolveInstructionPart).join("\n\n").trim();
|
|
10883
|
+
}
|
|
10884
|
+
return instructions.content.trim();
|
|
10885
|
+
}
|
|
10886
|
+
if (Array.isArray(instructions)) {
|
|
10887
|
+
return instructions.map(extractPrompt).join("\n\n").trim();
|
|
10888
|
+
}
|
|
10889
|
+
return "";
|
|
10890
|
+
};
|
|
10891
|
+
|
|
11489
10892
|
const NameCell$3 = ({ row }) => {
|
|
11490
10893
|
const { Link, paths } = useLinkComponent();
|
|
11491
10894
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11492
10895
|
EntryCell,
|
|
11493
10896
|
{
|
|
11494
10897
|
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
|
|
10898
|
+
description: extractPrompt(row.original.instructions)
|
|
11496
10899
|
}
|
|
11497
10900
|
);
|
|
11498
10901
|
};
|
|
@@ -12211,36 +11614,8 @@ function RelationWrapper({ description, children }) {
|
|
|
12211
11614
|
] }) : children;
|
|
12212
11615
|
}
|
|
12213
11616
|
|
|
12214
|
-
function
|
|
12215
|
-
|
|
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
|
-
] });
|
|
11617
|
+
function EntryListRoot({ children }) {
|
|
11618
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid mb-[3rem]", children });
|
|
12244
11619
|
}
|
|
12245
11620
|
|
|
12246
11621
|
function getColumnTemplate(columns) {
|
|
@@ -12252,33 +11627,53 @@ function getColumnTemplate(columns) {
|
|
|
12252
11627
|
}).join(" ");
|
|
12253
11628
|
}
|
|
12254
11629
|
|
|
12255
|
-
function
|
|
12256
|
-
|
|
12257
|
-
|
|
12258
|
-
|
|
12259
|
-
|
|
12260
|
-
|
|
12261
|
-
|
|
12262
|
-
}
|
|
12263
|
-
|
|
11630
|
+
function EntryListHeader({ columns }) {
|
|
11631
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("sticky top-0 bg-surface4 z-[1] rounded-t-lg px-[1.5rem]"), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11632
|
+
"div",
|
|
11633
|
+
{
|
|
11634
|
+
className: cn("grid gap-[1.5rem] text-left uppercase py-[.75rem] text-icon3 text-[0.75rem]"),
|
|
11635
|
+
style: { gridTemplateColumns: getColumnTemplate(columns) },
|
|
11636
|
+
children: columns?.map((col) => /* @__PURE__ */ jsxRuntime.jsx("span", { children: col.label || col.name }, col.name))
|
|
11637
|
+
}
|
|
11638
|
+
) });
|
|
11639
|
+
}
|
|
11640
|
+
|
|
11641
|
+
function EntryListEntries({ children }) {
|
|
11642
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "grid bg-surface3 overflow-y-auto", children });
|
|
11643
|
+
}
|
|
11644
|
+
|
|
11645
|
+
function EntryListTrim({ children }) {
|
|
11646
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("rounded-lg border border-border1 overflow-clip"), children });
|
|
11647
|
+
}
|
|
11648
|
+
|
|
11649
|
+
function EntryListEntry({ entry, isSelected, onClick, children, columns }) {
|
|
12264
11650
|
const handleClick = () => {
|
|
12265
|
-
|
|
11651
|
+
onClick?.(entry?.id);
|
|
12266
11652
|
};
|
|
12267
11653
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12268
11654
|
"li",
|
|
12269
11655
|
{
|
|
12270
|
-
className: cn(
|
|
12271
|
-
"
|
|
12272
|
-
|
|
11656
|
+
className: cn(
|
|
11657
|
+
"border-t text-[#ccc] border-border1 last:border-b-0 text-[0.875rem]",
|
|
11658
|
+
"[&:last-child>button]:rounded-b-lg",
|
|
11659
|
+
{
|
|
11660
|
+
"bg-surface5": isSelected
|
|
11661
|
+
}
|
|
11662
|
+
),
|
|
12273
11663
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12274
11664
|
"button",
|
|
12275
11665
|
{
|
|
12276
11666
|
onClick: handleClick,
|
|
12277
|
-
className: cn(
|
|
12278
|
-
"
|
|
12279
|
-
|
|
11667
|
+
className: cn(
|
|
11668
|
+
"grid w-full px-[1.5rem] gap-[1.5rem] text-left items-center min-h-[3rem]",
|
|
11669
|
+
"focus-visible:outline-none focus-visible:shadow-[inset_0_0_0_1px_rgba(24,251,111,.75)]",
|
|
11670
|
+
{
|
|
11671
|
+
// hover effect only not for skeleton and selected
|
|
11672
|
+
"hover:bg-surface4": entry && !isSelected
|
|
11673
|
+
}
|
|
11674
|
+
),
|
|
12280
11675
|
style: { gridTemplateColumns: getColumnTemplate(columns) },
|
|
12281
|
-
disabled:
|
|
11676
|
+
disabled: !entry,
|
|
12282
11677
|
children
|
|
12283
11678
|
}
|
|
12284
11679
|
)
|
|
@@ -12286,152 +11681,155 @@ function EntryListItem({
|
|
|
12286
11681
|
);
|
|
12287
11682
|
}
|
|
12288
11683
|
|
|
12289
|
-
function
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
|
|
11684
|
+
function EntryListMessage({ children, message, className, type }) {
|
|
11685
|
+
if (!children && !message) {
|
|
11686
|
+
return null;
|
|
11687
|
+
}
|
|
11688
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("grid border-t border-border1", className), children: message ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11689
|
+
"p",
|
|
11690
|
+
{
|
|
11691
|
+
className: cn(
|
|
11692
|
+
"text-icon3 text-[0.875rem] text-center grid p-[2rem] justify-center justify-items-center gap-[.5rem]",
|
|
11693
|
+
"[&>svg]:w-[1.5em] [&>svg]:h-[1.5em] [&>svg]:opacity-75",
|
|
11694
|
+
{
|
|
11695
|
+
"[&>svg]:text-red-500": type === "error"
|
|
11696
|
+
}
|
|
11697
|
+
),
|
|
11698
|
+
children: [
|
|
11699
|
+
type === "error" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TriangleAlertIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, {}),
|
|
11700
|
+
" ",
|
|
11701
|
+
message
|
|
11702
|
+
]
|
|
11703
|
+
}
|
|
11704
|
+
) : children });
|
|
11705
|
+
}
|
|
11706
|
+
|
|
11707
|
+
function EntryListNextPageLoading({
|
|
12293
11708
|
isLoading,
|
|
12294
|
-
isLoadingNextPage,
|
|
12295
|
-
total,
|
|
12296
|
-
page,
|
|
12297
11709
|
hasMore,
|
|
12298
|
-
onNextPage,
|
|
12299
|
-
onPrevPage,
|
|
12300
|
-
perPage,
|
|
12301
|
-
columns,
|
|
12302
|
-
searchTerm,
|
|
12303
11710
|
setEndOfListElement,
|
|
12304
|
-
|
|
11711
|
+
loadingText = "Loading more data...",
|
|
11712
|
+
noMoreDataText = "No more data to load"
|
|
12305
11713
|
}) {
|
|
12306
|
-
|
|
12307
|
-
return
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
11714
|
+
if (!setEndOfListElement) {
|
|
11715
|
+
return null;
|
|
11716
|
+
}
|
|
11717
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: setEndOfListElement, className: "text-[0.875rem] text-icon3 opacity-50 flex mt-[2rem] justify-center", children: [
|
|
11718
|
+
isLoading && loadingText,
|
|
11719
|
+
!hasMore && !isLoading && noMoreDataText
|
|
11720
|
+
] });
|
|
11721
|
+
}
|
|
11722
|
+
|
|
11723
|
+
function EntryListPagination({ currentPage, hasMore, onNextPage, onPrevPage }) {
|
|
11724
|
+
const showNavigation = typeof currentPage === "number" && currentPage > 0 || hasMore;
|
|
11725
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex pt-[1.5rem] items-center justify-center text-icon3 text-[0.875rem] gap-[2rem] "), children: [
|
|
11726
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
11727
|
+
"Page ",
|
|
11728
|
+
/* @__PURE__ */ jsxRuntime.jsx("b", { children: currentPage ? currentPage + 1 : "1" })
|
|
11729
|
+
] }),
|
|
11730
|
+
showNavigation && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12321
11731
|
"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
11732
|
{
|
|
12331
11733
|
className: cn(
|
|
12332
|
-
"
|
|
12333
|
-
"[&>
|
|
12334
|
-
"[
|
|
12335
|
-
"[&>svg]:text-red-500"
|
|
11734
|
+
"flex gap-[1rem]",
|
|
11735
|
+
"[&>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",
|
|
11736
|
+
"[&_svg]:w-[1em] [&_svg]:h-[1em] [&_svg]:text-icon3"
|
|
12336
11737
|
),
|
|
12337
11738
|
children: [
|
|
12338
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12339
|
-
|
|
12340
|
-
|
|
11739
|
+
typeof currentPage === "number" && currentPage > 0 && /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: onPrevPage, children: [
|
|
11740
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeftIcon, {}),
|
|
11741
|
+
"Previous"
|
|
11742
|
+
] }),
|
|
11743
|
+
hasMore && /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: onNextPage, children: [
|
|
11744
|
+
"Next",
|
|
11745
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRightIcon, {})
|
|
11746
|
+
] })
|
|
12341
11747
|
]
|
|
12342
11748
|
}
|
|
12343
|
-
)
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
12348
|
-
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
|
-
|
|
12357
|
-
|
|
12358
|
-
|
|
12359
|
-
|
|
12360
|
-
|
|
12361
|
-
|
|
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
|
-
] })
|
|
11749
|
+
)
|
|
11750
|
+
] });
|
|
11751
|
+
}
|
|
11752
|
+
|
|
11753
|
+
function EntryListEntryTextCol({ children, isLoading }) {
|
|
11754
|
+
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 });
|
|
11755
|
+
}
|
|
11756
|
+
function EntryListEntryStatusCol({ status }) {
|
|
11757
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex justify-center items-center w-full relative"), children: [
|
|
11758
|
+
status ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
11759
|
+
"div",
|
|
11760
|
+
{
|
|
11761
|
+
className: cn("w-[0.6rem] h-[0.6rem] rounded-full", {
|
|
11762
|
+
"bg-green-600": status === "success",
|
|
11763
|
+
"bg-red-700": status === "failed"
|
|
11764
|
+
})
|
|
11765
|
+
}
|
|
11766
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-icon2 text-[0.75rem] leading-none", children: "-" }),
|
|
11767
|
+
/* @__PURE__ */ jsxRuntime.jsxs(VisuallyHidden.VisuallyHidden, { children: [
|
|
11768
|
+
"Status: ",
|
|
11769
|
+
status ? status : "not provided"
|
|
12401
11770
|
] })
|
|
12402
11771
|
] });
|
|
12403
11772
|
}
|
|
12404
11773
|
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12410
|
-
|
|
12411
|
-
|
|
12412
|
-
|
|
11774
|
+
const EntryList = Object.assign(EntryListRoot, {
|
|
11775
|
+
Header: EntryListHeader,
|
|
11776
|
+
Trim: EntryListTrim,
|
|
11777
|
+
Entries: EntryListEntries,
|
|
11778
|
+
Entry: EntryListEntry,
|
|
11779
|
+
Message: EntryListMessage,
|
|
11780
|
+
NextPageLoading: EntryListNextPageLoading,
|
|
11781
|
+
Pagination: EntryListPagination,
|
|
11782
|
+
EntryText: EntryListEntryTextCol,
|
|
11783
|
+
EntryStatus: EntryListEntryStatusCol
|
|
11784
|
+
});
|
|
11785
|
+
|
|
11786
|
+
const widths = ["75%", "50%", "65%", "90%", "60%", "80%"];
|
|
11787
|
+
function EntryListEntriesSkeleton({ columns, numberOfRows = 3 }) {
|
|
11788
|
+
const getPseudoRandomWidth = (rowIdx, colIdx) => {
|
|
11789
|
+
const index = (rowIdx + colIdx + (columns?.length || 0) + (numberOfRows || 0)) % widths.length;
|
|
11790
|
+
return widths[index];
|
|
11791
|
+
};
|
|
11792
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EntryListEntries, { children: Array.from({ length: numberOfRows }).map((_, rowIdx) => /* @__PURE__ */ jsxRuntime.jsx(EntryListEntry, { columns, children: (columns || []).map((col, colIdx) => {
|
|
11793
|
+
const key = `${col.name}-${colIdx}`;
|
|
11794
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11795
|
+
"div",
|
|
11796
|
+
{
|
|
11797
|
+
className: "bg-surface4 rounded-md animate-pulse text-transparent h-[1rem] select-none",
|
|
11798
|
+
style: { width: `${getPseudoRandomWidth(rowIdx, colIdx)}` }
|
|
11799
|
+
},
|
|
11800
|
+
key
|
|
11801
|
+
);
|
|
11802
|
+
}) }, rowIdx)) });
|
|
12413
11803
|
}
|
|
12414
11804
|
|
|
12415
|
-
function
|
|
12416
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12417
|
-
|
|
12418
|
-
{
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12432
|
-
|
|
12433
|
-
|
|
12434
|
-
);
|
|
11805
|
+
function EntryListSkeleton({ columns, numberOfRows }) {
|
|
11806
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EntryList, { children: /* @__PURE__ */ jsxRuntime.jsxs(EntryListTrim, { children: [
|
|
11807
|
+
/* @__PURE__ */ jsxRuntime.jsx(EntryListHeader, { columns }),
|
|
11808
|
+
/* @__PURE__ */ jsxRuntime.jsx(EntryListEntriesSkeleton, { columns, numberOfRows })
|
|
11809
|
+
] }) });
|
|
11810
|
+
}
|
|
11811
|
+
|
|
11812
|
+
function getToNextEntryFn({ entries, id, update }) {
|
|
11813
|
+
const currentIndex = entries.findIndex((entry) => entry.id === id);
|
|
11814
|
+
const thereIsNextItem = currentIndex < entries.length - 1;
|
|
11815
|
+
if (thereIsNextItem) {
|
|
11816
|
+
return () => {
|
|
11817
|
+
const nextItem = entries[currentIndex + 1];
|
|
11818
|
+
update(nextItem.id);
|
|
11819
|
+
};
|
|
11820
|
+
}
|
|
11821
|
+
return void 0;
|
|
11822
|
+
}
|
|
11823
|
+
function getToPreviousEntryFn({ entries, id, update }) {
|
|
11824
|
+
const currentIndex = entries.findIndex((entry) => entry.id === id);
|
|
11825
|
+
const thereIsPreviousItem = currentIndex > 0;
|
|
11826
|
+
if (thereIsPreviousItem) {
|
|
11827
|
+
return () => {
|
|
11828
|
+
const previousItem = entries[currentIndex - 1];
|
|
11829
|
+
update(previousItem.id);
|
|
11830
|
+
};
|
|
11831
|
+
}
|
|
11832
|
+
return void 0;
|
|
12435
11833
|
}
|
|
12436
11834
|
|
|
12437
11835
|
function SideDialog({
|
|
@@ -12723,26 +12121,36 @@ function EntityMainHeader({
|
|
|
12723
12121
|
}
|
|
12724
12122
|
|
|
12725
12123
|
function PageHeader({ title, description, icon, className }) {
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12124
|
+
const titleIsLoading = title === "loading";
|
|
12125
|
+
const descriptionIsLoading = description === "loading";
|
|
12126
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("header", { className: cn("grid gap-[.5rem] pt-[2rem] pb-[2rem]", className), children: [
|
|
12127
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12128
|
+
"h1",
|
|
12129
|
+
{
|
|
12130
|
+
className: cn(
|
|
12131
|
+
"text-icon6 text-[1.25rem] font-normal flex items-center gap-[0.5rem]",
|
|
12132
|
+
"[&>svg]:w-[1.4rem] [&>svg]:h-[1.4rem] [&>svg]:text-icon3",
|
|
12133
|
+
{
|
|
12134
|
+
"bg-surface4 w-[15rem] max-w-[50%] rounded-md animate-pulse": titleIsLoading
|
|
12135
|
+
}
|
|
12136
|
+
),
|
|
12137
|
+
children: titleIsLoading ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: " " }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
12738
12138
|
icon && icon,
|
|
12739
12139
|
" ",
|
|
12740
12140
|
title
|
|
12741
|
-
] })
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12141
|
+
] })
|
|
12142
|
+
}
|
|
12143
|
+
),
|
|
12144
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
12145
|
+
"p",
|
|
12146
|
+
{
|
|
12147
|
+
className: cn("text-icon4 text-[0.875rem] m-0", {
|
|
12148
|
+
"bg-surface4 w-[40rem] max-w-[80%] rounded-md animate-pulse": descriptionIsLoading
|
|
12149
|
+
}),
|
|
12150
|
+
children: descriptionIsLoading ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: " " }) : description
|
|
12151
|
+
}
|
|
12152
|
+
)
|
|
12153
|
+
] });
|
|
12746
12154
|
}
|
|
12747
12155
|
|
|
12748
12156
|
function DatePicker({ className, classNames, showOutsideDays = true, ...props }) {
|
|
@@ -13106,6 +12514,77 @@ function getShortId(id) {
|
|
|
13106
12514
|
return id.slice(0, 8);
|
|
13107
12515
|
}
|
|
13108
12516
|
|
|
12517
|
+
const scoresListColumns = [
|
|
12518
|
+
{ name: "date", label: "Date", size: "4.5rem" },
|
|
12519
|
+
{ name: "time", label: "Time", size: "6.5rem" },
|
|
12520
|
+
{ name: "input", label: "Input", size: "1fr" },
|
|
12521
|
+
{ name: "entityId", label: "Entity", size: "10rem" },
|
|
12522
|
+
{ name: "score", label: "Score", size: "3rem" }
|
|
12523
|
+
];
|
|
12524
|
+
function ScoresList({
|
|
12525
|
+
scores,
|
|
12526
|
+
pagination,
|
|
12527
|
+
onScoreClick,
|
|
12528
|
+
onPageChange,
|
|
12529
|
+
errorMsg,
|
|
12530
|
+
selectedScoreId
|
|
12531
|
+
}) {
|
|
12532
|
+
if (!scores) {
|
|
12533
|
+
return null;
|
|
12534
|
+
}
|
|
12535
|
+
const scoresHasMore = pagination?.hasMore;
|
|
12536
|
+
const handleNextPage = () => {
|
|
12537
|
+
if (scoresHasMore) {
|
|
12538
|
+
onPageChange?.(pagination.page + 1);
|
|
12539
|
+
}
|
|
12540
|
+
};
|
|
12541
|
+
const handlePrevPage = () => {
|
|
12542
|
+
if (pagination?.page && pagination.page > 0) {
|
|
12543
|
+
onPageChange?.(pagination.page - 1);
|
|
12544
|
+
}
|
|
12545
|
+
};
|
|
12546
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(EntryList, { children: [
|
|
12547
|
+
/* @__PURE__ */ jsxRuntime.jsxs(EntryList.Trim, { children: [
|
|
12548
|
+
/* @__PURE__ */ jsxRuntime.jsx(EntryList.Header, { columns: scoresListColumns }),
|
|
12549
|
+
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) => {
|
|
12550
|
+
const createdAtDate = new Date(score.createdAt);
|
|
12551
|
+
const isTodayDate = dateFns.isToday(createdAtDate);
|
|
12552
|
+
const entry = {
|
|
12553
|
+
id: score.id,
|
|
12554
|
+
date: isTodayDate ? "Today" : dateFns.format(createdAtDate, "MMM dd"),
|
|
12555
|
+
time: dateFns.format(createdAtDate, "h:mm:ss aaa"),
|
|
12556
|
+
input: JSON.stringify(score?.input),
|
|
12557
|
+
entityId: score.entityId,
|
|
12558
|
+
score: score.score
|
|
12559
|
+
};
|
|
12560
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12561
|
+
EntryList.Entry,
|
|
12562
|
+
{
|
|
12563
|
+
entry,
|
|
12564
|
+
isSelected: selectedScoreId === score.id,
|
|
12565
|
+
columns: scoresListColumns,
|
|
12566
|
+
onClick: onScoreClick,
|
|
12567
|
+
children: scoresListColumns.map((col, index) => {
|
|
12568
|
+
const key = `${index}-${score.id}`;
|
|
12569
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EntryList.EntryText, { children: entry?.[col.name] }, key);
|
|
12570
|
+
})
|
|
12571
|
+
},
|
|
12572
|
+
entry.id
|
|
12573
|
+
);
|
|
12574
|
+
}) }) : /* @__PURE__ */ jsxRuntime.jsx(EntryList.Message, { message: "No scores for this scorer yet" }) })
|
|
12575
|
+
] }),
|
|
12576
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12577
|
+
EntryList.Pagination,
|
|
12578
|
+
{
|
|
12579
|
+
currentPage: pagination?.page || 0,
|
|
12580
|
+
onNextPage: handleNextPage,
|
|
12581
|
+
onPrevPage: handlePrevPage,
|
|
12582
|
+
hasMore: scoresHasMore
|
|
12583
|
+
}
|
|
12584
|
+
)
|
|
12585
|
+
] });
|
|
12586
|
+
}
|
|
12587
|
+
|
|
13109
12588
|
function ScoreDialog({
|
|
13110
12589
|
scorer,
|
|
13111
12590
|
score,
|
|
@@ -13370,34 +12849,14 @@ const EmptyScorersTable = () => /* @__PURE__ */ jsxRuntime.jsx("div", { classNam
|
|
|
13370
12849
|
}
|
|
13371
12850
|
) });
|
|
13372
12851
|
|
|
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 });
|
|
13393
|
-
};
|
|
13394
|
-
|
|
13395
12852
|
const AgentMetadataModelSwitcher = ({
|
|
13396
12853
|
defaultProvider,
|
|
13397
12854
|
defaultModel,
|
|
13398
12855
|
updateModel,
|
|
13399
12856
|
apiUrl = "/api/agents/providers"
|
|
13400
12857
|
}) => {
|
|
12858
|
+
const [originalProvider] = React.useState(defaultProvider);
|
|
12859
|
+
const [originalModel] = React.useState(defaultModel);
|
|
13401
12860
|
const [selectedModel, setSelectedModel] = React.useState(defaultModel);
|
|
13402
12861
|
const [showModelSuggestions, setShowModelSuggestions] = React.useState(false);
|
|
13403
12862
|
const [selectedProvider, setSelectedProvider] = React.useState(defaultProvider || "");
|
|
@@ -13528,15 +12987,15 @@ const AgentMetadataModelSwitcher = ({
|
|
|
13528
12987
|
if (modelInputRef.current === document.activeElement || providerInputRef.current === document.activeElement || showProviderSuggestions || showModelSuggestions) {
|
|
13529
12988
|
return;
|
|
13530
12989
|
}
|
|
13531
|
-
const providerChanged = currentModelProvider && currentModelProvider !==
|
|
12990
|
+
const providerChanged = currentModelProvider && currentModelProvider !== originalProvider;
|
|
13532
12991
|
const modelEmpty = !selectedModel || selectedModel === "";
|
|
13533
12992
|
if (providerChanged && modelEmpty) {
|
|
13534
|
-
setSelectedProvider(cleanProviderId(
|
|
13535
|
-
setSelectedModel(
|
|
13536
|
-
if (
|
|
12993
|
+
setSelectedProvider(cleanProviderId(originalProvider));
|
|
12994
|
+
setSelectedModel(originalModel);
|
|
12995
|
+
if (originalProvider && originalModel) {
|
|
13537
12996
|
updateModel({
|
|
13538
|
-
provider:
|
|
13539
|
-
modelId:
|
|
12997
|
+
provider: originalProvider,
|
|
12998
|
+
modelId: originalModel
|
|
13540
12999
|
}).catch((error) => {
|
|
13541
13000
|
console.error("Failed to reset model:", error);
|
|
13542
13001
|
});
|
|
@@ -13551,8 +13010,8 @@ const AgentMetadataModelSwitcher = ({
|
|
|
13551
13010
|
registerResetFn,
|
|
13552
13011
|
currentModelProvider,
|
|
13553
13012
|
selectedModel,
|
|
13554
|
-
|
|
13555
|
-
|
|
13013
|
+
originalProvider,
|
|
13014
|
+
originalModel,
|
|
13556
13015
|
updateModel,
|
|
13557
13016
|
showProviderSuggestions,
|
|
13558
13017
|
showModelSuggestions
|
|
@@ -13563,6 +13022,27 @@ const AgentMetadataModelSwitcher = ({
|
|
|
13563
13022
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-500", children: "Loading providers..." })
|
|
13564
13023
|
] });
|
|
13565
13024
|
}
|
|
13025
|
+
const handleReset = async () => {
|
|
13026
|
+
setSelectedProvider(cleanProviderId(originalProvider));
|
|
13027
|
+
setSelectedModel(originalModel);
|
|
13028
|
+
setProviderSearch("");
|
|
13029
|
+
setModelSearch("");
|
|
13030
|
+
setIsSearchingProvider(false);
|
|
13031
|
+
setIsSearchingModel(false);
|
|
13032
|
+
setShowProviderSuggestions(false);
|
|
13033
|
+
setShowModelSuggestions(false);
|
|
13034
|
+
try {
|
|
13035
|
+
setLoading(true);
|
|
13036
|
+
await updateModel({
|
|
13037
|
+
provider: originalProvider,
|
|
13038
|
+
modelId: originalModel
|
|
13039
|
+
});
|
|
13040
|
+
} catch (error) {
|
|
13041
|
+
console.error("Failed to reset model:", error);
|
|
13042
|
+
} finally {
|
|
13043
|
+
setLoading(false);
|
|
13044
|
+
}
|
|
13045
|
+
};
|
|
13566
13046
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
13567
13047
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col xl:flex-row items-stretch xl:items-center gap-2 w-full", children: [
|
|
13568
13048
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -13905,14 +13385,26 @@ const AgentMetadataModelSwitcher = ({
|
|
|
13905
13385
|
)
|
|
13906
13386
|
]
|
|
13907
13387
|
}
|
|
13388
|
+
),
|
|
13389
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13390
|
+
Button$1,
|
|
13391
|
+
{
|
|
13392
|
+
variant: "light",
|
|
13393
|
+
size: "md",
|
|
13394
|
+
onClick: handleReset,
|
|
13395
|
+
disabled: loading,
|
|
13396
|
+
className: "flex items-center gap-1.5 text-xs whitespace-nowrap !border-0",
|
|
13397
|
+
title: "Reset to original model",
|
|
13398
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RotateCcw, { className: "w-3.5 h-3.5" })
|
|
13399
|
+
}
|
|
13908
13400
|
)
|
|
13909
13401
|
] }),
|
|
13910
13402
|
(() => {
|
|
13911
13403
|
const currentProvider = providers.find((p) => p.id === currentModelProvider);
|
|
13912
13404
|
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: [
|
|
13405
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-2 p-2", children: /* @__PURE__ */ jsxRuntime.jsxs(Alert$1, { variant: "warning", children: [
|
|
13406
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertTitle$1, { as: "h5", children: "Provider not connected" }),
|
|
13407
|
+
/* @__PURE__ */ jsxRuntime.jsxs(AlertDescription$1, { as: "p", children: [
|
|
13916
13408
|
"Set the",
|
|
13917
13409
|
" ",
|
|
13918
13410
|
/* @__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 }),
|
|
@@ -14086,7 +13578,7 @@ const AgentMetadata = ({
|
|
|
14086
13578
|
{
|
|
14087
13579
|
title: "Model",
|
|
14088
13580
|
hint: modelVersion === "v2" ? void 0 : {
|
|
14089
|
-
link: "https://mastra.ai/
|
|
13581
|
+
link: "https://mastra.ai/guides/migrations/vnext-to-standard-apis",
|
|
14090
13582
|
title: "You are using a legacy v1 model",
|
|
14091
13583
|
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangleIcon, { fontSize: 14, className: "mb-0.5" })
|
|
14092
13584
|
},
|
|
@@ -14109,9 +13601,9 @@ const AgentMetadata = ({
|
|
|
14109
13601
|
link: "https://mastra.ai/en/docs/agents/agent-memory",
|
|
14110
13602
|
title: "Agent Memory documentation"
|
|
14111
13603
|
},
|
|
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: [
|
|
13604
|
+
children: hasMemoryEnabled ? /* @__PURE__ */ jsxRuntime.jsx(Badge$1, { icon: /* @__PURE__ */ jsxRuntime.jsx(MemoryIcon, {}), variant: "success", className: "font-medium", children: "On" }) : /* @__PURE__ */ jsxRuntime.jsxs(Alert$1, { variant: "warning", children: [
|
|
13605
|
+
/* @__PURE__ */ jsxRuntime.jsx(AlertTitle$1, { as: "h5", children: "Memory not enabled" }),
|
|
13606
|
+
/* @__PURE__ */ jsxRuntime.jsxs(AlertDescription$1, { as: "p", children: [
|
|
14115
13607
|
"Thread messages will not be stored. To activate memory, see the",
|
|
14116
13608
|
" ",
|
|
14117
13609
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -17111,6 +16603,76 @@ function TracesTools({
|
|
|
17111
16603
|
] });
|
|
17112
16604
|
}
|
|
17113
16605
|
|
|
16606
|
+
const tracesListColumns = [
|
|
16607
|
+
{ name: "shortId", label: "ID", size: "6rem" },
|
|
16608
|
+
{ name: "date", label: "Date", size: "4.5rem" },
|
|
16609
|
+
{ name: "time", label: "Time", size: "6.5rem" },
|
|
16610
|
+
{ name: "name", label: "Name", size: "1fr" },
|
|
16611
|
+
{ name: "entityId", label: "Entity", size: "10rem" },
|
|
16612
|
+
{ name: "status", label: "Status", size: "3rem" }
|
|
16613
|
+
];
|
|
16614
|
+
function TracesList({
|
|
16615
|
+
traces,
|
|
16616
|
+
selectedTraceId,
|
|
16617
|
+
onTraceClick,
|
|
16618
|
+
errorMsg,
|
|
16619
|
+
setEndOfListElement,
|
|
16620
|
+
filtersApplied,
|
|
16621
|
+
isFetchingNextPage,
|
|
16622
|
+
hasNextPage
|
|
16623
|
+
}) {
|
|
16624
|
+
if (!traces) {
|
|
16625
|
+
return null;
|
|
16626
|
+
}
|
|
16627
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(EntryList, { children: [
|
|
16628
|
+
/* @__PURE__ */ jsxRuntime.jsxs(EntryList.Trim, { children: [
|
|
16629
|
+
/* @__PURE__ */ jsxRuntime.jsx(EntryList.Header, { columns: tracesListColumns }),
|
|
16630
|
+
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) => {
|
|
16631
|
+
const createdAtDate = new Date(trace.createdAt);
|
|
16632
|
+
const isTodayDate = dateFns.isToday(createdAtDate);
|
|
16633
|
+
const entry = {
|
|
16634
|
+
id: trace.traceId,
|
|
16635
|
+
shortId: getShortId(trace?.traceId) || "n/a",
|
|
16636
|
+
date: isTodayDate ? "Today" : dateFns.format(createdAtDate, "MMM dd"),
|
|
16637
|
+
time: dateFns.format(createdAtDate, "h:mm:ss aaa"),
|
|
16638
|
+
name: trace?.name,
|
|
16639
|
+
entityId: trace?.attributes?.agentId || trace?.attributes?.workflowId,
|
|
16640
|
+
status: trace?.attributes?.status
|
|
16641
|
+
};
|
|
16642
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16643
|
+
EntryList.Entry,
|
|
16644
|
+
{
|
|
16645
|
+
entry,
|
|
16646
|
+
isSelected: selectedTraceId === trace.traceId,
|
|
16647
|
+
columns: tracesListColumns,
|
|
16648
|
+
onClick: onTraceClick,
|
|
16649
|
+
children: tracesListColumns.map((col, index) => {
|
|
16650
|
+
const key = `${index}-${trace.traceId}`;
|
|
16651
|
+
return col.name === "status" ? /* @__PURE__ */ jsxRuntime.jsx(EntryList.EntryStatus, { status: entry?.[col.name] }, key) : /* @__PURE__ */ jsxRuntime.jsx(EntryList.EntryText, { children: entry?.[col.name] }, key);
|
|
16652
|
+
})
|
|
16653
|
+
},
|
|
16654
|
+
entry.id
|
|
16655
|
+
);
|
|
16656
|
+
}) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
16657
|
+
EntryList.Message,
|
|
16658
|
+
{
|
|
16659
|
+
message: filtersApplied ? "No traces found for applied filters" : "No traces found yet"
|
|
16660
|
+
}
|
|
16661
|
+
) })
|
|
16662
|
+
] }),
|
|
16663
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
16664
|
+
EntryList.NextPageLoading,
|
|
16665
|
+
{
|
|
16666
|
+
setEndOfListElement,
|
|
16667
|
+
loadingText: "Loading more traces...",
|
|
16668
|
+
noMoreDataText: "All traces loaded",
|
|
16669
|
+
isLoading: isFetchingNextPage,
|
|
16670
|
+
hasMore: hasNextPage
|
|
16671
|
+
}
|
|
16672
|
+
)
|
|
16673
|
+
] });
|
|
16674
|
+
}
|
|
16675
|
+
|
|
17114
16676
|
function MainContentLayout({
|
|
17115
16677
|
children,
|
|
17116
16678
|
className,
|
|
@@ -17880,10 +17442,10 @@ exports.AgentSettingsContext = AgentSettingsContext;
|
|
|
17880
17442
|
exports.AgentSettingsProvider = AgentSettingsProvider;
|
|
17881
17443
|
exports.AgentsTable = AgentsTable;
|
|
17882
17444
|
exports.AiIcon = AiIcon;
|
|
17883
|
-
exports.Alert = Alert;
|
|
17884
|
-
exports.AlertDescription = AlertDescription;
|
|
17445
|
+
exports.Alert = Alert$1;
|
|
17446
|
+
exports.AlertDescription = AlertDescription$1;
|
|
17885
17447
|
exports.AlertDialog = AlertDialog;
|
|
17886
|
-
exports.AlertTitle = AlertTitle;
|
|
17448
|
+
exports.AlertTitle = AlertTitle$1;
|
|
17887
17449
|
exports.ApiIcon = ApiIcon;
|
|
17888
17450
|
exports.Badge = Badge$1;
|
|
17889
17451
|
exports.BranchIcon = BranchIcon;
|
|
@@ -17921,11 +17483,7 @@ exports.EntityName = EntityName;
|
|
|
17921
17483
|
exports.Entry = Entry;
|
|
17922
17484
|
exports.EntryCell = EntryCell;
|
|
17923
17485
|
exports.EntryList = EntryList;
|
|
17924
|
-
exports.
|
|
17925
|
-
exports.EntryListPageHeader = EntryListPageHeader;
|
|
17926
|
-
exports.EntryListStatusCell = EntryListStatusCell;
|
|
17927
|
-
exports.EntryListTextCell = EntryListTextCell;
|
|
17928
|
-
exports.EntryListToolbar = EntryListToolbar;
|
|
17486
|
+
exports.EntryListSkeleton = EntryListSkeleton;
|
|
17929
17487
|
exports.EnvIcon = EnvIcon;
|
|
17930
17488
|
exports.EvaluatorCoinIcon = EvaluatorCoinIcon;
|
|
17931
17489
|
exports.FiltersIcon = FiltersIcon;
|
|
@@ -17972,6 +17530,7 @@ exports.RuntimeContextWrapper = RuntimeContextWrapper;
|
|
|
17972
17530
|
exports.ScoreDialog = ScoreDialog;
|
|
17973
17531
|
exports.ScoreIcon = ScoreIcon;
|
|
17974
17532
|
exports.ScorersTable = ScorersTable;
|
|
17533
|
+
exports.ScoresList = ScoresList;
|
|
17975
17534
|
exports.ScoresTools = ScoresTools;
|
|
17976
17535
|
exports.SearchField = SearchField;
|
|
17977
17536
|
exports.Searchbar = Searchbar;
|
|
@@ -18021,6 +17580,7 @@ exports.TraceIcon = TraceIcon;
|
|
|
18021
17580
|
exports.TraceTimeline = TraceTimeline;
|
|
18022
17581
|
exports.TraceTimelineLegend = TraceTimelineLegend;
|
|
18023
17582
|
exports.TraceTimelineSpan = TraceTimelineSpan;
|
|
17583
|
+
exports.TracesList = TracesList;
|
|
18024
17584
|
exports.TracesTools = TracesTools;
|
|
18025
17585
|
exports.TracesView = TracesView;
|
|
18026
17586
|
exports.TracesViewSkeleton = TracesViewSkeleton;
|
|
@@ -18043,6 +17603,7 @@ exports.WorkingMemoryProvider = WorkingMemoryProvider;
|
|
|
18043
17603
|
exports.allowedAiSpanAttributes = allowedAiSpanAttributes;
|
|
18044
17604
|
exports.cleanString = cleanString;
|
|
18045
17605
|
exports.convertWorkflowRunStateToStreamResult = convertWorkflowRunStateToStreamResult;
|
|
17606
|
+
exports.extractPrompt = extractPrompt;
|
|
18046
17607
|
exports.formatDuration = formatDuration;
|
|
18047
17608
|
exports.formatHierarchicalSpans = formatHierarchicalSpans;
|
|
18048
17609
|
exports.formatOtelTimestamp = formatOtelTimestamp;
|
|
@@ -18050,9 +17611,13 @@ exports.formatOtelTimestamp2 = formatOtelTimestamp2;
|
|
|
18050
17611
|
exports.getColumnTemplate = getColumnTemplate;
|
|
18051
17612
|
exports.getShortId = getShortId;
|
|
18052
17613
|
exports.getSpanTypeUi = getSpanTypeUi;
|
|
17614
|
+
exports.getToNextEntryFn = getToNextEntryFn;
|
|
17615
|
+
exports.getToPreviousEntryFn = getToPreviousEntryFn;
|
|
18053
17616
|
exports.parseError = parseError;
|
|
18054
17617
|
exports.providerMapToIcon = providerMapToIcon;
|
|
17618
|
+
exports.scoresListColumns = scoresListColumns;
|
|
18055
17619
|
exports.spanTypePrefixes = spanTypePrefixes;
|
|
17620
|
+
exports.tracesListColumns = tracesListColumns;
|
|
18056
17621
|
exports.transformKey = transformKey;
|
|
18057
17622
|
exports.useAgentSettings = useAgentSettings;
|
|
18058
17623
|
exports.useCurrentRun = useCurrentRun;
|