@mastra/playground-ui 6.1.4-alpha.2 → 6.2.0-alpha.3
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 +22 -0
- package/dist/index.cjs.js +340 -783
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +340 -783
- package/dist/index.es.js.map +1 -1
- package/dist/src/domains/agents/components/agent-metadata/agent-metadata.d.ts +9 -1
- package/dist/src/domains/networks/components/network-table/network-table.d.ts +3 -4
- package/dist/src/domains/networks/components/network-table/types.d.ts +0 -1
- package/dist/src/domains/networks/index.d.ts +0 -1
- package/dist/src/domains/scores/components/scorers-table/columns.d.ts +3 -0
- package/dist/src/domains/scores/components/scorers-table/scorers-table.d.ts +9 -0
- package/dist/src/domains/scores/components/scorers-table/types.d.ts +5 -0
- package/dist/src/domains/scores/index.d.ts +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/store/playground-store.d.ts +5 -3
- package/package.json +6 -6
- package/dist/src/components/ui/data-table.d.ts +0 -39
- package/dist/src/domains/networks/network-chat.d.ts +0 -2
- package/dist/src/domains/scores/components/scorer-list.d.ts +0 -7
- package/dist/src/services/network-runtime-provider.d.ts +0 -7
package/dist/index.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { createContext, useContext, forwardRef, memo, useState, useEffect, useRef, useCallback, useMemo, Fragment as Fragment$1, isValidElement,
|
|
3
|
+
import React__default, { createContext, useContext, forwardRef, memo, useState, useEffect, useRef, useCallback, useMemo, Fragment as Fragment$1, isValidElement, useId, startTransition } from 'react';
|
|
4
4
|
import { MastraClient } from '@mastra/client-js';
|
|
5
5
|
import { useMessage, MessagePrimitive, ActionBarPrimitive, useAttachment, AttachmentPrimitive, useComposerRuntime, ComposerPrimitive, useComposer, ThreadPrimitive, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechSynthesisAdapter, useExternalStoreRuntime, AssistantRuntimeProvider } from '@assistant-ui/react';
|
|
6
|
-
import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, X, Share2, Braces, Loader2, Network, ChevronDown, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Brackets, PlusIcon, TrashIcon, Plus, ChevronDownIcon, Minus, Maximize, CirclePause, Circle, StopCircle, BrainIcon, AudioLinesIcon, StopCircleIcon, FileText, CircleXIcon, Link, CloudUpload, Mic, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, SaveIcon, RefreshCw, ExternalLink, InfoIcon as InfoIcon$1,
|
|
6
|
+
import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, X, Share2, Braces, Loader2, Network, ChevronDown, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Brackets, PlusIcon, TrashIcon, Plus, ChevronDownIcon, Minus, Maximize, CirclePause, Circle, StopCircle, BrainIcon, AudioLinesIcon, StopCircleIcon, FileText, CircleXIcon, Link, CloudUpload, Mic, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, SaveIcon, RefreshCw, ExternalLink, InfoIcon as InfoIcon$1, TriangleAlertIcon, ChevronRightIcon, ArrowLeftIcon, ArrowRightIcon, XIcon, ChevronsRightIcon, ArrowUpIcon, ArrowDownIcon, AlignLeftIcon, AlignJustifyIcon, CircleAlertIcon, GaugeIcon, HashIcon, EditIcon, Users, Brain, NetworkIcon, SearchIcon, WorkflowIcon as WorkflowIcon$1, PackageIcon, GitBranchIcon, PackageOpenIcon, OctagonXIcon, AlertTriangleIcon, FrownIcon, ChevronUp, ChevronsLeftRight, TimerIcon, ChevronsLeftRightIcon, ChevronFirstIcon, ChevronLastIcon, ListTreeIcon, ArrowRightToLineIcon, CoinsIcon, EyeIcon, ChevronsLeftRightEllipsisIcon, PanelTopIcon, PanelLeftIcon } from 'lucide-react';
|
|
7
7
|
import { Slot } from '@radix-ui/react-slot';
|
|
8
8
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
9
9
|
import { TooltipProvider as TooltipProvider$1 } from '@radix-ui/react-tooltip';
|
|
@@ -47,7 +47,7 @@ import { v4 } from '@lukeed/uuid';
|
|
|
47
47
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
48
48
|
import { ZodProvider, getFieldConfigInZodStack, getDefaultValueInZodStack } from '@autoform/zod/v4';
|
|
49
49
|
import { z as z$1 } from 'zod/v3';
|
|
50
|
-
import { CodeBlock
|
|
50
|
+
import { CodeBlock } from 'react-code-block';
|
|
51
51
|
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
52
52
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
53
53
|
import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
@@ -60,10 +60,9 @@ import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
|
60
60
|
import * as VisuallyHidden from '@radix-ui/react-visually-hidden';
|
|
61
61
|
import { VisuallyHidden as VisuallyHidden$1 } from '@radix-ui/react-visually-hidden';
|
|
62
62
|
import * as HoverCard from '@radix-ui/react-hover-card';
|
|
63
|
-
import
|
|
63
|
+
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
64
64
|
import { RuntimeContext as RuntimeContext$2 } from '@mastra/core/runtime-context';
|
|
65
65
|
import { format as format$1 } from 'date-fns/format';
|
|
66
|
-
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
67
66
|
|
|
68
67
|
const createMastraClient = (baseUrl, mastraClientHeaders = {}) => {
|
|
69
68
|
return new MastraClient({
|
|
@@ -4296,19 +4295,6 @@ const SyntaxHighlighter$2 = ({ data, className }) => {
|
|
|
4296
4295
|
/* @__PURE__ */ jsx(CodeMirror, { value: formattedCode, theme, extensions: [jsonLanguage] })
|
|
4297
4296
|
] });
|
|
4298
4297
|
};
|
|
4299
|
-
async function highlight(code, language) {
|
|
4300
|
-
const { codeToTokens, bundledLanguages } = await import('shiki');
|
|
4301
|
-
if (!(language in bundledLanguages)) return null;
|
|
4302
|
-
const { tokens } = await codeToTokens(code, {
|
|
4303
|
-
lang: language,
|
|
4304
|
-
defaultColor: false,
|
|
4305
|
-
themes: {
|
|
4306
|
-
light: "github-light",
|
|
4307
|
-
dark: "github-dark"
|
|
4308
|
-
}
|
|
4309
|
-
});
|
|
4310
|
-
return tokens;
|
|
4311
|
-
}
|
|
4312
4298
|
|
|
4313
4299
|
const variantClasses$2 = {
|
|
4314
4300
|
default: "text-icon3",
|
|
@@ -7310,15 +7296,15 @@ function CodeBlockDemo({
|
|
|
7310
7296
|
filename,
|
|
7311
7297
|
className
|
|
7312
7298
|
}) {
|
|
7313
|
-
return /* @__PURE__ */ jsxs(CodeBlock
|
|
7299
|
+
return /* @__PURE__ */ jsxs(CodeBlock, { code, language, theme: themes.oneDark, children: [
|
|
7314
7300
|
filename ? /* @__PURE__ */ jsx("div", { className: "absolute w-full px-6 py-2 pl-4 text-sm rounded bg-mastra-bg-2 text-mastra-el-6/50", children: filename }) : null,
|
|
7315
7301
|
/* @__PURE__ */ jsx(
|
|
7316
|
-
CodeBlock
|
|
7302
|
+
CodeBlock.Code,
|
|
7317
7303
|
{
|
|
7318
7304
|
className: cn("bg-transparent h-full p-6 rounded-xl whitespace-pre-wrap", filename ? "pt-10" : "", className),
|
|
7319
7305
|
children: /* @__PURE__ */ jsx("div", { className: "table-row", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
7320
|
-
/* @__PURE__ */ jsx(CodeBlock
|
|
7321
|
-
/* @__PURE__ */ jsx(CodeBlock
|
|
7306
|
+
/* @__PURE__ */ jsx(CodeBlock.LineNumber, { className: "table-cell pr-4 text-sm text-right select-none text-gray-500/50" }),
|
|
7307
|
+
/* @__PURE__ */ jsx(CodeBlock.LineContent, { className: "flex", children: /* @__PURE__ */ jsx(CodeBlock.Token, { className: "font-mono text-sm mastra-token" }) })
|
|
7322
7308
|
] }) })
|
|
7323
7309
|
}
|
|
7324
7310
|
)
|
|
@@ -8488,7 +8474,7 @@ const useLinkComponent = () => {
|
|
|
8488
8474
|
return ctx;
|
|
8489
8475
|
};
|
|
8490
8476
|
|
|
8491
|
-
const columns$
|
|
8477
|
+
const columns$3 = [
|
|
8492
8478
|
{
|
|
8493
8479
|
id: "name",
|
|
8494
8480
|
header: "Name",
|
|
@@ -8550,7 +8536,7 @@ function WorkflowTable({ workflows, legacyWorkflows, isLoading, computeLink }) {
|
|
|
8550
8536
|
}, [workflows, legacyWorkflows]);
|
|
8551
8537
|
const table = useReactTable({
|
|
8552
8538
|
data: workflowData,
|
|
8553
|
-
columns: columns$
|
|
8539
|
+
columns: columns$3,
|
|
8554
8540
|
getCoreRowModel: getCoreRowModel()
|
|
8555
8541
|
});
|
|
8556
8542
|
if (isLoading) return /* @__PURE__ */ jsx(WorkflowTableSkeleton, {});
|
|
@@ -8674,7 +8660,7 @@ const AgentBadge = ({ agentId, messages = [], networkMetadata }) => {
|
|
|
8674
8660
|
}
|
|
8675
8661
|
const result = typeof message.toolOutput === "string" ? JSON.parse(message.toolOutput) : message.toolOutput;
|
|
8676
8662
|
return /* @__PURE__ */ jsx(React__default.Fragment, { children: /* @__PURE__ */ jsx(
|
|
8677
|
-
ToolFallback
|
|
8663
|
+
ToolFallback,
|
|
8678
8664
|
{
|
|
8679
8665
|
toolName: message.toolName,
|
|
8680
8666
|
argsText: typeof message.args === "string" ? message.args : JSON.stringify(message.args),
|
|
@@ -8692,7 +8678,7 @@ const AgentBadge = ({ agentId, messages = [], networkMetadata }) => {
|
|
|
8692
8678
|
);
|
|
8693
8679
|
};
|
|
8694
8680
|
|
|
8695
|
-
const ToolFallback
|
|
8681
|
+
const ToolFallback = ({ toolName, result, args, ...props }) => {
|
|
8696
8682
|
return /* @__PURE__ */ jsx(WorkflowRunProvider, { children: /* @__PURE__ */ jsx(ToolFallbackInner, { toolName, result, args, ...props }) });
|
|
8697
8683
|
};
|
|
8698
8684
|
const ToolFallbackInner = ({ toolName, result, args }) => {
|
|
@@ -8757,7 +8743,7 @@ const AssistantMessage = ({ ToolFallback: ToolFallbackCustom }) => {
|
|
|
8757
8743
|
{
|
|
8758
8744
|
components: {
|
|
8759
8745
|
Text: MarkdownText,
|
|
8760
|
-
tools: { Fallback: ToolFallbackCustom || ToolFallback
|
|
8746
|
+
tools: { Fallback: ToolFallbackCustom || ToolFallback },
|
|
8761
8747
|
Reasoning
|
|
8762
8748
|
}
|
|
8763
8749
|
}
|
|
@@ -10263,7 +10249,7 @@ const createRootToolAssistantMessage = ({
|
|
|
10263
10249
|
});
|
|
10264
10250
|
};
|
|
10265
10251
|
|
|
10266
|
-
const convertMessage$
|
|
10252
|
+
const convertMessage$1 = (message) => {
|
|
10267
10253
|
return message;
|
|
10268
10254
|
};
|
|
10269
10255
|
const handleFinishReason = (finishReason) => {
|
|
@@ -10977,7 +10963,7 @@ function MastraRuntimeProvider({
|
|
|
10977
10963
|
const runtime = useExternalStoreRuntime({
|
|
10978
10964
|
isRunning,
|
|
10979
10965
|
messages,
|
|
10980
|
-
convertMessage: convertMessage$
|
|
10966
|
+
convertMessage: convertMessage$1,
|
|
10981
10967
|
onNew,
|
|
10982
10968
|
onCancel,
|
|
10983
10969
|
adapters: isReady ? adapters : void 0
|
|
@@ -12207,7 +12193,7 @@ const providerMapToIcon = {
|
|
|
12207
12193
|
MISTRAL: /* @__PURE__ */ jsx(MistralIcon, {})
|
|
12208
12194
|
};
|
|
12209
12195
|
|
|
12210
|
-
const NameCell = ({ row }) => {
|
|
12196
|
+
const NameCell$1 = ({ row }) => {
|
|
12211
12197
|
const { Link } = useLinkComponent();
|
|
12212
12198
|
return /* @__PURE__ */ jsx(
|
|
12213
12199
|
EntryCell,
|
|
@@ -12218,11 +12204,11 @@ const NameCell = ({ row }) => {
|
|
|
12218
12204
|
}
|
|
12219
12205
|
);
|
|
12220
12206
|
};
|
|
12221
|
-
const columns$
|
|
12207
|
+
const columns$2 = [
|
|
12222
12208
|
{
|
|
12223
12209
|
header: "Name",
|
|
12224
12210
|
accessorKey: "name",
|
|
12225
|
-
cell: NameCell
|
|
12211
|
+
cell: NameCell$1
|
|
12226
12212
|
},
|
|
12227
12213
|
{
|
|
12228
12214
|
header: "Model",
|
|
@@ -12277,7 +12263,7 @@ function AgentsTable({ agents, isLoading, computeLink }) {
|
|
|
12277
12263
|
);
|
|
12278
12264
|
const table = useReactTable({
|
|
12279
12265
|
data: projectData,
|
|
12280
|
-
columns: columns$
|
|
12266
|
+
columns: columns$2,
|
|
12281
12267
|
getCoreRowModel: getCoreRowModel()
|
|
12282
12268
|
});
|
|
12283
12269
|
if (isLoading) return /* @__PURE__ */ jsx(AgentsTableSkeleton, {});
|
|
@@ -12432,176 +12418,6 @@ const AgentMetadataWrapper = ({ children }) => {
|
|
|
12432
12418
|
return /* @__PURE__ */ jsx("div", { className: "py-2 overflow-y-auto h-full px-5", children });
|
|
12433
12419
|
};
|
|
12434
12420
|
|
|
12435
|
-
const useScoresByEntityId = (entityId, entityType, page = 0) => {
|
|
12436
|
-
const client = useMastraClient();
|
|
12437
|
-
const [scores, setScores] = useState(null);
|
|
12438
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
12439
|
-
useEffect(() => {
|
|
12440
|
-
const fetchScores = async () => {
|
|
12441
|
-
setIsLoading(true);
|
|
12442
|
-
try {
|
|
12443
|
-
const res = await client.getScoresByEntityId({
|
|
12444
|
-
entityId,
|
|
12445
|
-
entityType,
|
|
12446
|
-
page: page || 0,
|
|
12447
|
-
perPage: 10
|
|
12448
|
-
});
|
|
12449
|
-
setScores(res);
|
|
12450
|
-
setIsLoading(false);
|
|
12451
|
-
} catch (error) {
|
|
12452
|
-
setScores(null);
|
|
12453
|
-
setIsLoading(false);
|
|
12454
|
-
}
|
|
12455
|
-
};
|
|
12456
|
-
fetchScores();
|
|
12457
|
-
}, [entityId, entityType, page]);
|
|
12458
|
-
return { scores, isLoading };
|
|
12459
|
-
};
|
|
12460
|
-
const useScoresByScorerId = ({ scorerId, page = 0, entityId, entityType }) => {
|
|
12461
|
-
const client = useMastraClient();
|
|
12462
|
-
const [scores, setScores] = useState(null);
|
|
12463
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
12464
|
-
useEffect(() => {
|
|
12465
|
-
const fetchScores = async () => {
|
|
12466
|
-
setIsLoading(true);
|
|
12467
|
-
try {
|
|
12468
|
-
const res = await client.getScoresByScorerId({
|
|
12469
|
-
scorerId,
|
|
12470
|
-
page: page || 0,
|
|
12471
|
-
entityId: entityId || void 0,
|
|
12472
|
-
entityType: entityType || void 0,
|
|
12473
|
-
perPage: 10
|
|
12474
|
-
});
|
|
12475
|
-
setScores(res);
|
|
12476
|
-
setIsLoading(false);
|
|
12477
|
-
} catch (error) {
|
|
12478
|
-
setScores(null);
|
|
12479
|
-
setIsLoading(false);
|
|
12480
|
-
}
|
|
12481
|
-
};
|
|
12482
|
-
fetchScores();
|
|
12483
|
-
}, [scorerId, page, entityId, entityType]);
|
|
12484
|
-
return { scores, isLoading };
|
|
12485
|
-
};
|
|
12486
|
-
const useScorer = (scorerId) => {
|
|
12487
|
-
const client = useMastraClient();
|
|
12488
|
-
const [scorer, setScorer] = useState(null);
|
|
12489
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
12490
|
-
useEffect(() => {
|
|
12491
|
-
const fetchScorer = async () => {
|
|
12492
|
-
setIsLoading(true);
|
|
12493
|
-
try {
|
|
12494
|
-
const res = await client.getScorer(scorerId);
|
|
12495
|
-
setScorer(res);
|
|
12496
|
-
} catch (error) {
|
|
12497
|
-
setScorer(null);
|
|
12498
|
-
console.error("Error fetching scorer", error);
|
|
12499
|
-
toast.error("Error fetching scorer");
|
|
12500
|
-
} finally {
|
|
12501
|
-
setIsLoading(false);
|
|
12502
|
-
}
|
|
12503
|
-
};
|
|
12504
|
-
fetchScorer();
|
|
12505
|
-
}, [scorerId]);
|
|
12506
|
-
return { scorer, isLoading };
|
|
12507
|
-
};
|
|
12508
|
-
const useScorers = () => {
|
|
12509
|
-
const client = useMastraClient();
|
|
12510
|
-
const [scorers, setScorers] = useState({});
|
|
12511
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
12512
|
-
useEffect(() => {
|
|
12513
|
-
const fetchScorers = async () => {
|
|
12514
|
-
setIsLoading(true);
|
|
12515
|
-
try {
|
|
12516
|
-
const res = await client.getScorers();
|
|
12517
|
-
setScorers(res);
|
|
12518
|
-
} catch (error) {
|
|
12519
|
-
setScorers({});
|
|
12520
|
-
console.error("Error fetching agents", error);
|
|
12521
|
-
toast.error("Error fetching agents");
|
|
12522
|
-
} finally {
|
|
12523
|
-
setIsLoading(false);
|
|
12524
|
-
}
|
|
12525
|
-
};
|
|
12526
|
-
fetchScorers();
|
|
12527
|
-
}, []);
|
|
12528
|
-
return { scorers, isLoading };
|
|
12529
|
-
};
|
|
12530
|
-
|
|
12531
|
-
const Entity = ({ children, className, onClick }) => {
|
|
12532
|
-
return /* @__PURE__ */ jsx(
|
|
12533
|
-
"div",
|
|
12534
|
-
{
|
|
12535
|
-
tabIndex: onClick ? 0 : void 0,
|
|
12536
|
-
onKeyDown: (e) => {
|
|
12537
|
-
if (!onClick) return;
|
|
12538
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
12539
|
-
e.preventDefault();
|
|
12540
|
-
onClick?.();
|
|
12541
|
-
}
|
|
12542
|
-
},
|
|
12543
|
-
className: clsx(
|
|
12544
|
-
"flex gap-3 group/entity bg-surface3 rounded-lg border-sm border-border1 py-3 px-4",
|
|
12545
|
-
onClick && "cursor-pointer hover:bg-surface4 transition-all",
|
|
12546
|
-
className
|
|
12547
|
-
),
|
|
12548
|
-
onClick,
|
|
12549
|
-
children
|
|
12550
|
-
}
|
|
12551
|
-
);
|
|
12552
|
-
};
|
|
12553
|
-
const EntityIcon = ({ children, className }) => {
|
|
12554
|
-
return /* @__PURE__ */ jsx(Icon, { size: "lg", className: clsx("text-icon3 mt-1", className), children });
|
|
12555
|
-
};
|
|
12556
|
-
const EntityName = ({ children, className }) => {
|
|
12557
|
-
return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-lg", className: clsx("text-icon6 font-medium", className), children });
|
|
12558
|
-
};
|
|
12559
|
-
const EntityDescription = ({ children, className }) => {
|
|
12560
|
-
return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-sm", className: clsx("text-icon3", className), children });
|
|
12561
|
-
};
|
|
12562
|
-
const EntityContent = ({ children, className }) => {
|
|
12563
|
-
return /* @__PURE__ */ jsx("div", { className, children });
|
|
12564
|
-
};
|
|
12565
|
-
|
|
12566
|
-
const ScorerList = ({ entityId, entityType }) => {
|
|
12567
|
-
const { scorers, isLoading } = useScorers();
|
|
12568
|
-
if (isLoading) {
|
|
12569
|
-
return /* @__PURE__ */ jsx(ScorerSkeleton, {});
|
|
12570
|
-
}
|
|
12571
|
-
const scorerList = Object.keys(scorers).filter((scorerKey) => {
|
|
12572
|
-
const scorer = scorers[scorerKey];
|
|
12573
|
-
if (entityType === "AGENT") {
|
|
12574
|
-
return scorer.agentIds.includes(entityId);
|
|
12575
|
-
}
|
|
12576
|
-
return scorer.workflowIds.includes(entityId);
|
|
12577
|
-
}).map((scorerKey) => ({ ...scorers[scorerKey], id: scorerKey }));
|
|
12578
|
-
if (scorerList.length === 0) {
|
|
12579
|
-
return /* @__PURE__ */ jsx(AgentMetadataListEmpty, { children: "No scorers were attached to this agent." });
|
|
12580
|
-
}
|
|
12581
|
-
return /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: scorerList.map((scorer) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(ScorerEntity, { scorer }) }, scorer.id)) });
|
|
12582
|
-
};
|
|
12583
|
-
const ScorerSkeleton = () => {
|
|
12584
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
12585
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" }),
|
|
12586
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" })
|
|
12587
|
-
] });
|
|
12588
|
-
};
|
|
12589
|
-
const ScorerEntity = ({ scorer }) => {
|
|
12590
|
-
const { Link } = useLinkComponent();
|
|
12591
|
-
const linkRef = useRef(null);
|
|
12592
|
-
return /* @__PURE__ */ jsxs(Entity, { onClick: () => linkRef.current?.click(), children: [
|
|
12593
|
-
/* @__PURE__ */ jsx(EntityIcon, { children: /* @__PURE__ */ jsx(GaugeIcon, { className: "group-hover/entity:text-accent3" }) }),
|
|
12594
|
-
/* @__PURE__ */ jsxs(EntityContent, { children: [
|
|
12595
|
-
/* @__PURE__ */ jsx(EntityName, { children: /* @__PURE__ */ jsx(Link, { ref: linkRef, href: `/scorers/${scorer.id}`, children: scorer.scorer.config.name }) }),
|
|
12596
|
-
/* @__PURE__ */ jsx(EntityDescription, { children: scorer.scorer.config.description }),
|
|
12597
|
-
scorer.sampling?.type === "ratio" && /* @__PURE__ */ jsxs(Badge$1, { children: [
|
|
12598
|
-
/* @__PURE__ */ jsx("span", { className: "text-icon3", children: "Sample rate:" }),
|
|
12599
|
-
/* @__PURE__ */ jsx("span", { className: "text-icon6", children: scorer.sampling.rate })
|
|
12600
|
-
] })
|
|
12601
|
-
] })
|
|
12602
|
-
] });
|
|
12603
|
-
};
|
|
12604
|
-
|
|
12605
12421
|
function SearchField(props) {
|
|
12606
12422
|
return /* @__PURE__ */ jsx(
|
|
12607
12423
|
InputField,
|
|
@@ -14063,92 +13879,264 @@ function ScoresTools({ onEntityChange, onReset, selectedEntity, entityOptions, i
|
|
|
14063
13879
|
] });
|
|
14064
13880
|
}
|
|
14065
13881
|
|
|
14066
|
-
const
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14091
|
-
|
|
14092
|
-
|
|
14093
|
-
|
|
14094
|
-
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
const
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
|
|
14135
|
-
|
|
14136
|
-
|
|
14137
|
-
|
|
14138
|
-
|
|
14139
|
-
|
|
14140
|
-
|
|
14141
|
-
|
|
14142
|
-
|
|
14143
|
-
|
|
14144
|
-
|
|
14145
|
-
|
|
14146
|
-
|
|
14147
|
-
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
|
|
14151
|
-
|
|
13882
|
+
const useScoresByEntityId = (entityId, entityType, page = 0) => {
|
|
13883
|
+
const client = useMastraClient();
|
|
13884
|
+
const [scores, setScores] = useState(null);
|
|
13885
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
13886
|
+
useEffect(() => {
|
|
13887
|
+
const fetchScores = async () => {
|
|
13888
|
+
setIsLoading(true);
|
|
13889
|
+
try {
|
|
13890
|
+
const res = await client.getScoresByEntityId({
|
|
13891
|
+
entityId,
|
|
13892
|
+
entityType,
|
|
13893
|
+
page: page || 0,
|
|
13894
|
+
perPage: 10
|
|
13895
|
+
});
|
|
13896
|
+
setScores(res);
|
|
13897
|
+
setIsLoading(false);
|
|
13898
|
+
} catch (error) {
|
|
13899
|
+
setScores(null);
|
|
13900
|
+
setIsLoading(false);
|
|
13901
|
+
}
|
|
13902
|
+
};
|
|
13903
|
+
fetchScores();
|
|
13904
|
+
}, [entityId, entityType, page]);
|
|
13905
|
+
return { scores, isLoading };
|
|
13906
|
+
};
|
|
13907
|
+
const useScoresByScorerId = ({ scorerId, page = 0, entityId, entityType }) => {
|
|
13908
|
+
const client = useMastraClient();
|
|
13909
|
+
const [scores, setScores] = useState(null);
|
|
13910
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
13911
|
+
useEffect(() => {
|
|
13912
|
+
const fetchScores = async () => {
|
|
13913
|
+
setIsLoading(true);
|
|
13914
|
+
try {
|
|
13915
|
+
const res = await client.getScoresByScorerId({
|
|
13916
|
+
scorerId,
|
|
13917
|
+
page: page || 0,
|
|
13918
|
+
entityId: entityId || void 0,
|
|
13919
|
+
entityType: entityType || void 0,
|
|
13920
|
+
perPage: 10
|
|
13921
|
+
});
|
|
13922
|
+
setScores(res);
|
|
13923
|
+
setIsLoading(false);
|
|
13924
|
+
} catch (error) {
|
|
13925
|
+
setScores(null);
|
|
13926
|
+
setIsLoading(false);
|
|
13927
|
+
}
|
|
13928
|
+
};
|
|
13929
|
+
fetchScores();
|
|
13930
|
+
}, [scorerId, page, entityId, entityType]);
|
|
13931
|
+
return { scores, isLoading };
|
|
13932
|
+
};
|
|
13933
|
+
const useScorer = (scorerId) => {
|
|
13934
|
+
const client = useMastraClient();
|
|
13935
|
+
const [scorer, setScorer] = useState(null);
|
|
13936
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
13937
|
+
useEffect(() => {
|
|
13938
|
+
const fetchScorer = async () => {
|
|
13939
|
+
setIsLoading(true);
|
|
13940
|
+
try {
|
|
13941
|
+
const res = await client.getScorer(scorerId);
|
|
13942
|
+
setScorer(res);
|
|
13943
|
+
} catch (error) {
|
|
13944
|
+
setScorer(null);
|
|
13945
|
+
console.error("Error fetching scorer", error);
|
|
13946
|
+
toast.error("Error fetching scorer");
|
|
13947
|
+
} finally {
|
|
13948
|
+
setIsLoading(false);
|
|
13949
|
+
}
|
|
13950
|
+
};
|
|
13951
|
+
fetchScorer();
|
|
13952
|
+
}, [scorerId]);
|
|
13953
|
+
return { scorer, isLoading };
|
|
13954
|
+
};
|
|
13955
|
+
const useScorers = () => {
|
|
13956
|
+
const client = useMastraClient();
|
|
13957
|
+
const [scorers, setScorers] = useState({});
|
|
13958
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
13959
|
+
useEffect(() => {
|
|
13960
|
+
const fetchScorers = async () => {
|
|
13961
|
+
setIsLoading(true);
|
|
13962
|
+
try {
|
|
13963
|
+
const res = await client.getScorers();
|
|
13964
|
+
setScorers(res);
|
|
13965
|
+
} catch (error) {
|
|
13966
|
+
setScorers({});
|
|
13967
|
+
console.error("Error fetching agents", error);
|
|
13968
|
+
toast.error("Error fetching agents");
|
|
13969
|
+
} finally {
|
|
13970
|
+
setIsLoading(false);
|
|
13971
|
+
}
|
|
13972
|
+
};
|
|
13973
|
+
fetchScorers();
|
|
13974
|
+
}, []);
|
|
13975
|
+
return { scorers, isLoading };
|
|
13976
|
+
};
|
|
13977
|
+
|
|
13978
|
+
const NameCell = ({ row }) => {
|
|
13979
|
+
const { Link } = useLinkComponent();
|
|
13980
|
+
return /* @__PURE__ */ jsx(
|
|
13981
|
+
EntryCell,
|
|
13982
|
+
{
|
|
13983
|
+
icon: /* @__PURE__ */ jsx(GaugeIcon, {}),
|
|
13984
|
+
name: /* @__PURE__ */ jsx(Link, { className: "w-full space-y-0", href: row.original.id, children: row.original.name }),
|
|
13985
|
+
description: row.original.description
|
|
13986
|
+
}
|
|
13987
|
+
);
|
|
13988
|
+
};
|
|
13989
|
+
const columns$1 = [
|
|
13990
|
+
{
|
|
13991
|
+
header: "Name",
|
|
13992
|
+
accessorKey: "name",
|
|
13993
|
+
cell: NameCell
|
|
13994
|
+
}
|
|
13995
|
+
];
|
|
13996
|
+
|
|
13997
|
+
function ScorersTable({ scorers, isLoading, computeScorerLink }) {
|
|
13998
|
+
const { navigate } = useLinkComponent();
|
|
13999
|
+
const scorersData = useMemo(
|
|
14000
|
+
() => Object.keys(scorers).map((key) => {
|
|
14001
|
+
const scorer = scorers[key];
|
|
14002
|
+
return {
|
|
14003
|
+
id: key,
|
|
14004
|
+
name: scorer.scorer.config.name,
|
|
14005
|
+
description: scorer.scorer.config.description
|
|
14006
|
+
};
|
|
14007
|
+
}),
|
|
14008
|
+
[scorers]
|
|
14009
|
+
);
|
|
14010
|
+
const table = useReactTable({
|
|
14011
|
+
data: scorersData,
|
|
14012
|
+
columns: columns$1,
|
|
14013
|
+
getCoreRowModel: getCoreRowModel()
|
|
14014
|
+
});
|
|
14015
|
+
if (isLoading) return /* @__PURE__ */ jsx(ScorersTableSkeleton, {});
|
|
14016
|
+
const ths = table.getHeaderGroups()[0];
|
|
14017
|
+
const rows = table.getRowModel().rows.concat();
|
|
14018
|
+
if (rows.length === 0) {
|
|
14019
|
+
return /* @__PURE__ */ jsx(EmptyScorersTable, {});
|
|
14020
|
+
}
|
|
14021
|
+
return /* @__PURE__ */ jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxs(Table$1, { children: [
|
|
14022
|
+
/* @__PURE__ */ jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsx(Th, { style: { width: header.index === 0 ? "auto" : header.column.getSize() }, children: flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
|
|
14023
|
+
/* @__PURE__ */ jsx(Tbody, { children: rows.map((row) => /* @__PURE__ */ jsx(Row, { onClick: () => navigate(computeScorerLink(row.original.id)), children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(React__default.Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)) }, row.id)) })
|
|
14024
|
+
] }) });
|
|
14025
|
+
}
|
|
14026
|
+
const ScorersTableSkeleton = () => /* @__PURE__ */ jsxs(Table$1, { children: [
|
|
14027
|
+
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsx(Th, { children: "Name" }) }),
|
|
14028
|
+
/* @__PURE__ */ jsx(Tbody, { children: Array.from({ length: 3 }).map((_, index) => /* @__PURE__ */ jsx(Row, { children: /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" }) }) }, index)) })
|
|
14029
|
+
] });
|
|
14030
|
+
const EmptyScorersTable = () => /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
14031
|
+
EmptyState,
|
|
14032
|
+
{
|
|
14033
|
+
iconSlot: /* @__PURE__ */ jsx(AgentCoinIcon, {}),
|
|
14034
|
+
titleSlot: "Configure Scorers",
|
|
14035
|
+
descriptionSlot: "Mastra scorers are not configured yet. You can find more information in the documentation.",
|
|
14036
|
+
actionSlot: /* @__PURE__ */ jsxs(
|
|
14037
|
+
Button$1,
|
|
14038
|
+
{
|
|
14039
|
+
size: "lg",
|
|
14040
|
+
className: "w-full",
|
|
14041
|
+
variant: "light",
|
|
14042
|
+
as: "a",
|
|
14043
|
+
href: "https://mastra.ai/en/docs/scorers/overview",
|
|
14044
|
+
target: "_blank",
|
|
14045
|
+
children: [
|
|
14046
|
+
/* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(AgentIcon, {}) }),
|
|
14047
|
+
"Docs"
|
|
14048
|
+
]
|
|
14049
|
+
}
|
|
14050
|
+
)
|
|
14051
|
+
}
|
|
14052
|
+
) });
|
|
14053
|
+
|
|
14054
|
+
const openaiModels = [
|
|
14055
|
+
"o1",
|
|
14056
|
+
"o1-2024-12-17",
|
|
14057
|
+
"o3-mini",
|
|
14058
|
+
"o3-mini-2025-01-31",
|
|
14059
|
+
"o3",
|
|
14060
|
+
"o3-2025-04-16",
|
|
14061
|
+
"o4-mini",
|
|
14062
|
+
"o4-mini-2025-04-16",
|
|
14063
|
+
"codex-mini-latest",
|
|
14064
|
+
"computer-use-preview",
|
|
14065
|
+
"gpt-4.1",
|
|
14066
|
+
"gpt-4.1-2025-04-14",
|
|
14067
|
+
"gpt-4.1-mini",
|
|
14068
|
+
"gpt-4.1-mini-2025-04-14",
|
|
14069
|
+
"gpt-4.1-nano",
|
|
14070
|
+
"gpt-4.1-nano-2025-04-14",
|
|
14071
|
+
"gpt-4o",
|
|
14072
|
+
"gpt-4o-2024-05-13",
|
|
14073
|
+
"gpt-4o-2024-08-06",
|
|
14074
|
+
"gpt-4o-2024-11-20",
|
|
14075
|
+
"gpt-4o-audio-preview",
|
|
14076
|
+
"gpt-4o-audio-preview-2024-10-01",
|
|
14077
|
+
"gpt-4o-audio-preview-2024-12-17",
|
|
14078
|
+
"gpt-4o-search-preview",
|
|
14079
|
+
"gpt-4o-search-preview-2025-03-11",
|
|
14080
|
+
"gpt-4o-mini-search-preview",
|
|
14081
|
+
"gpt-4o-mini-search-preview-2025-03-11",
|
|
14082
|
+
"gpt-4o-mini",
|
|
14083
|
+
"gpt-4o-mini-2024-07-18",
|
|
14084
|
+
"gpt-4-turbo",
|
|
14085
|
+
"gpt-4-turbo-2024-04-09",
|
|
14086
|
+
"gpt-4-turbo-preview",
|
|
14087
|
+
"gpt-4-0125-preview",
|
|
14088
|
+
"gpt-4-1106-preview",
|
|
14089
|
+
"gpt-4",
|
|
14090
|
+
"gpt-4-0613",
|
|
14091
|
+
"gpt-4.5-preview",
|
|
14092
|
+
"gpt-4.5-preview-2025-02-27",
|
|
14093
|
+
"gpt-3.5-turbo-0125",
|
|
14094
|
+
"gpt-3.5-turbo",
|
|
14095
|
+
"gpt-3.5-turbo-1106",
|
|
14096
|
+
"chatgpt-4o-latest",
|
|
14097
|
+
"gpt-5",
|
|
14098
|
+
"gpt-5-2025-08-07",
|
|
14099
|
+
"gpt-5-mini",
|
|
14100
|
+
"gpt-5-mini-2025-08-07",
|
|
14101
|
+
"gpt-5-nano",
|
|
14102
|
+
"gpt-5-nano-2025-08-07",
|
|
14103
|
+
"gpt-5-chat-latest"
|
|
14104
|
+
];
|
|
14105
|
+
const anthropicModels = [
|
|
14106
|
+
"claude-opus-4-20250514",
|
|
14107
|
+
"claude-sonnet-4-20250514",
|
|
14108
|
+
"claude-3-7-sonnet-20250219",
|
|
14109
|
+
"claude-3-5-sonnet-latest",
|
|
14110
|
+
"claude-3-5-sonnet-20241022",
|
|
14111
|
+
"claude-3-5-sonnet-20240620",
|
|
14112
|
+
"claude-3-5-haiku-latest",
|
|
14113
|
+
"claude-3-5-haiku-20241022",
|
|
14114
|
+
"claude-3-opus-latest",
|
|
14115
|
+
"claude-3-opus-20240229",
|
|
14116
|
+
"claude-3-sonnet-20240229",
|
|
14117
|
+
"claude-3-haiku-20240307"
|
|
14118
|
+
];
|
|
14119
|
+
const googleModels = [
|
|
14120
|
+
"gemini-1.5-flash",
|
|
14121
|
+
"gemini-1.5-flash-latest",
|
|
14122
|
+
"gemini-1.5-flash-001",
|
|
14123
|
+
"gemini-1.5-flash-002",
|
|
14124
|
+
"gemini-1.5-flash-8b",
|
|
14125
|
+
"gemini-1.5-flash-8b-latest",
|
|
14126
|
+
"gemini-1.5-flash-8b-001",
|
|
14127
|
+
"gemini-1.5-pro",
|
|
14128
|
+
"gemini-1.5-pro-latest",
|
|
14129
|
+
"gemini-1.5-pro-001",
|
|
14130
|
+
"gemini-1.5-pro-002",
|
|
14131
|
+
"gemini-2.0-flash",
|
|
14132
|
+
"gemini-2.0-flash-001",
|
|
14133
|
+
"gemini-2.0-flash-live-001",
|
|
14134
|
+
"gemini-2.0-flash-lite",
|
|
14135
|
+
"gemini-2.0-pro-exp-02-05",
|
|
14136
|
+
"gemini-2.0-flash-thinking-exp-01-21",
|
|
14137
|
+
"gemini-2.0-flash-exp",
|
|
14138
|
+
"gemini-2.5-pro",
|
|
14139
|
+
"gemini-2.5-flash",
|
|
14152
14140
|
"gemini-2.5-flash-lite",
|
|
14153
14141
|
"gemini-2.5-pro-exp-03-25",
|
|
14154
14142
|
"gemini-2.5-flash-preview-04-17",
|
|
@@ -14331,6 +14319,7 @@ const AgentMetadata = ({
|
|
|
14331
14319
|
computeAgentLink,
|
|
14332
14320
|
computeToolLink,
|
|
14333
14321
|
computeWorkflowLink,
|
|
14322
|
+
computeScorerLink,
|
|
14334
14323
|
updateModel,
|
|
14335
14324
|
modelProviders
|
|
14336
14325
|
}) => {
|
|
@@ -14409,7 +14398,7 @@ const AgentMetadata = ({
|
|
|
14409
14398
|
children: /* @__PURE__ */ jsx(AgentMetadataWorkflowList, { workflows, computeWorkflowLink })
|
|
14410
14399
|
}
|
|
14411
14400
|
),
|
|
14412
|
-
/* @__PURE__ */ jsx(AgentMetadataSection, { title: "Scorers", children: /* @__PURE__ */ jsx(
|
|
14401
|
+
/* @__PURE__ */ jsx(AgentMetadataSection, { title: "Scorers", children: /* @__PURE__ */ jsx(AgentMetadataScorerList, { entityId: agent.name, entityType: "AGENT", computeScorerLink }) }),
|
|
14413
14402
|
/* @__PURE__ */ jsx(AgentMetadataSection, { title: "System Prompt", children: promptSlot })
|
|
14414
14403
|
] });
|
|
14415
14404
|
};
|
|
@@ -14427,6 +14416,24 @@ const AgentMetadataWorkflowList = ({ workflows, computeWorkflowLink }) => {
|
|
|
14427
14416
|
}
|
|
14428
14417
|
return /* @__PURE__ */ jsx(AgentMetadataList, { children: workflows.map((workflow) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: computeWorkflowLink(workflow.id, workflow), children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(WorkflowIcon, { className: "text-accent3" }), children: workflow.name }) }) }, workflow.id)) });
|
|
14429
14418
|
};
|
|
14419
|
+
const AgentMetadataScorerList = ({ entityId, entityType, computeScorerLink }) => {
|
|
14420
|
+
const { Link } = useLinkComponent();
|
|
14421
|
+
const { scorers, isLoading } = useScorers();
|
|
14422
|
+
const scorerList = Object.keys(scorers).filter((scorerKey) => {
|
|
14423
|
+
const scorer = scorers[scorerKey];
|
|
14424
|
+
if (entityType === "AGENT") {
|
|
14425
|
+
return scorer.agentIds.includes(entityId);
|
|
14426
|
+
}
|
|
14427
|
+
return scorer.workflowIds.includes(entityId);
|
|
14428
|
+
}).map((scorerKey) => ({ ...scorers[scorerKey], id: scorerKey }));
|
|
14429
|
+
if (isLoading) {
|
|
14430
|
+
return /* @__PURE__ */ jsx(LoadingBadge, {});
|
|
14431
|
+
}
|
|
14432
|
+
if (scorerList.length === 0) {
|
|
14433
|
+
return /* @__PURE__ */ jsx(AgentMetadataListEmpty, { children: "No Scorers" });
|
|
14434
|
+
}
|
|
14435
|
+
return /* @__PURE__ */ jsx(AgentMetadataList, { children: scorerList.map((scorer) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: computeScorerLink(scorer.id), children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(GaugeIcon, { className: "text-icon3" }), children: scorer.scorer.config.name }) }) }, scorer.id)) });
|
|
14436
|
+
};
|
|
14430
14437
|
|
|
14431
14438
|
const AgentMetadataPrompt = ({ prompt }) => {
|
|
14432
14439
|
return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-md", className: "bg-surface4 text-icon6 whitespace-pre-wrap rounded-lg px-2 py-1.5 text-sm", children: prompt });
|
|
@@ -14649,379 +14656,6 @@ const formatDay = (date) => {
|
|
|
14649
14656
|
return new Date(date).toLocaleString("en-us", options).replace(",", " at");
|
|
14650
14657
|
};
|
|
14651
14658
|
|
|
14652
|
-
const convertMessage$1 = (message) => {
|
|
14653
|
-
return message;
|
|
14654
|
-
};
|
|
14655
|
-
function MastraNetworkRuntimeProvider({
|
|
14656
|
-
children,
|
|
14657
|
-
agentId,
|
|
14658
|
-
initialMessages,
|
|
14659
|
-
memory,
|
|
14660
|
-
threadId,
|
|
14661
|
-
modelSettings
|
|
14662
|
-
}) {
|
|
14663
|
-
const [isRunning, setIsRunning] = useState(false);
|
|
14664
|
-
const [messages, setMessages] = useState(initialMessages || []);
|
|
14665
|
-
const [currentThreadId, setCurrentThreadId] = useState(threadId);
|
|
14666
|
-
const { frequencyPenalty, presencePenalty, maxRetries, maxSteps, maxTokens, temperature, topK, topP, instructions } = modelSettings;
|
|
14667
|
-
useEffect(() => {
|
|
14668
|
-
if (messages.length === 0 || currentThreadId !== threadId) {
|
|
14669
|
-
if (initialMessages && threadId && memory) {
|
|
14670
|
-
setMessages(initialMessages);
|
|
14671
|
-
setCurrentThreadId(threadId);
|
|
14672
|
-
}
|
|
14673
|
-
}
|
|
14674
|
-
}, [initialMessages, threadId, memory, messages]);
|
|
14675
|
-
const mastra = useMastraClient();
|
|
14676
|
-
const network = mastra.getNetwork(agentId);
|
|
14677
|
-
const onNew = async (message) => {
|
|
14678
|
-
if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
|
|
14679
|
-
const input = message.content[0].text;
|
|
14680
|
-
setMessages((currentConversation) => [...currentConversation, { role: "user", content: input }]);
|
|
14681
|
-
setIsRunning(true);
|
|
14682
|
-
try {
|
|
14683
|
-
let updater = function() {
|
|
14684
|
-
setMessages((currentConversation) => {
|
|
14685
|
-
const message2 = {
|
|
14686
|
-
role: "assistant",
|
|
14687
|
-
content: [{ type: "text", text: content }]
|
|
14688
|
-
};
|
|
14689
|
-
if (!assistantMessageAdded) {
|
|
14690
|
-
assistantMessageAdded = true;
|
|
14691
|
-
return [...currentConversation, message2];
|
|
14692
|
-
}
|
|
14693
|
-
return [...currentConversation.slice(0, -1), message2];
|
|
14694
|
-
});
|
|
14695
|
-
};
|
|
14696
|
-
const response = await network.stream({
|
|
14697
|
-
messages: [
|
|
14698
|
-
{
|
|
14699
|
-
role: "user",
|
|
14700
|
-
content: input
|
|
14701
|
-
}
|
|
14702
|
-
],
|
|
14703
|
-
runId: agentId,
|
|
14704
|
-
frequencyPenalty,
|
|
14705
|
-
presencePenalty,
|
|
14706
|
-
maxRetries,
|
|
14707
|
-
maxSteps,
|
|
14708
|
-
maxTokens,
|
|
14709
|
-
temperature,
|
|
14710
|
-
topK,
|
|
14711
|
-
topP,
|
|
14712
|
-
instructions,
|
|
14713
|
-
...memory ? { threadId, resourceId: agentId } : {}
|
|
14714
|
-
});
|
|
14715
|
-
if (!response.body) {
|
|
14716
|
-
throw new Error("No response body");
|
|
14717
|
-
}
|
|
14718
|
-
const parts = [];
|
|
14719
|
-
let content = "";
|
|
14720
|
-
let currentTextPart = null;
|
|
14721
|
-
let assistantMessageAdded = false;
|
|
14722
|
-
await processDataStream({
|
|
14723
|
-
stream: response.body,
|
|
14724
|
-
onTextPart(value) {
|
|
14725
|
-
if (currentTextPart == null) {
|
|
14726
|
-
currentTextPart = {
|
|
14727
|
-
type: "text",
|
|
14728
|
-
text: value
|
|
14729
|
-
};
|
|
14730
|
-
parts.push(currentTextPart);
|
|
14731
|
-
} else {
|
|
14732
|
-
currentTextPart.text += value;
|
|
14733
|
-
}
|
|
14734
|
-
content += value;
|
|
14735
|
-
updater();
|
|
14736
|
-
},
|
|
14737
|
-
async onToolCallPart(value) {
|
|
14738
|
-
console.log("Tool call received:", value);
|
|
14739
|
-
setMessages((currentConversation) => {
|
|
14740
|
-
const lastMessage = currentConversation[currentConversation.length - 1];
|
|
14741
|
-
if (lastMessage && lastMessage.role === "assistant") {
|
|
14742
|
-
const updatedMessage = {
|
|
14743
|
-
...lastMessage,
|
|
14744
|
-
content: Array.isArray(lastMessage.content) ? [
|
|
14745
|
-
...lastMessage.content,
|
|
14746
|
-
{
|
|
14747
|
-
type: "tool-call",
|
|
14748
|
-
toolCallId: value.toolCallId,
|
|
14749
|
-
toolName: value.toolName,
|
|
14750
|
-
args: value.args
|
|
14751
|
-
}
|
|
14752
|
-
] : [
|
|
14753
|
-
...typeof lastMessage.content === "string" ? [{ type: "text", text: lastMessage.content }] : [],
|
|
14754
|
-
{
|
|
14755
|
-
type: "tool-call",
|
|
14756
|
-
toolCallId: value.toolCallId,
|
|
14757
|
-
toolName: value.toolName,
|
|
14758
|
-
args: value.args
|
|
14759
|
-
}
|
|
14760
|
-
]
|
|
14761
|
-
};
|
|
14762
|
-
return [...currentConversation.slice(0, -1), updatedMessage];
|
|
14763
|
-
}
|
|
14764
|
-
const newMessage = {
|
|
14765
|
-
role: "assistant",
|
|
14766
|
-
content: [
|
|
14767
|
-
{ type: "text", text: content },
|
|
14768
|
-
{
|
|
14769
|
-
type: "tool-call",
|
|
14770
|
-
toolCallId: value.toolCallId,
|
|
14771
|
-
toolName: value.toolName,
|
|
14772
|
-
args: value.args
|
|
14773
|
-
}
|
|
14774
|
-
]
|
|
14775
|
-
};
|
|
14776
|
-
return [...currentConversation, newMessage];
|
|
14777
|
-
});
|
|
14778
|
-
},
|
|
14779
|
-
async onToolResultPart(value) {
|
|
14780
|
-
console.log("Tool call result received:", value);
|
|
14781
|
-
setMessages((currentConversation) => {
|
|
14782
|
-
const lastMessage = currentConversation[currentConversation.length - 1];
|
|
14783
|
-
if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
|
|
14784
|
-
const updatedContent = lastMessage.content.map((part) => {
|
|
14785
|
-
if (typeof part === "object" && part.type === "tool-call" && part.toolCallId === value.toolCallId) {
|
|
14786
|
-
return {
|
|
14787
|
-
...part,
|
|
14788
|
-
result: value.result
|
|
14789
|
-
};
|
|
14790
|
-
}
|
|
14791
|
-
return part;
|
|
14792
|
-
});
|
|
14793
|
-
const updatedMessage = {
|
|
14794
|
-
...lastMessage,
|
|
14795
|
-
content: updatedContent
|
|
14796
|
-
};
|
|
14797
|
-
return [...currentConversation.slice(0, -1), updatedMessage];
|
|
14798
|
-
}
|
|
14799
|
-
return currentConversation;
|
|
14800
|
-
});
|
|
14801
|
-
},
|
|
14802
|
-
onErrorPart(error) {
|
|
14803
|
-
throw new Error(error);
|
|
14804
|
-
}
|
|
14805
|
-
});
|
|
14806
|
-
console.log(messages);
|
|
14807
|
-
setIsRunning(false);
|
|
14808
|
-
} catch (error) {
|
|
14809
|
-
console.error("Error occurred in MastraRuntimeProvider", error);
|
|
14810
|
-
setIsRunning(false);
|
|
14811
|
-
}
|
|
14812
|
-
};
|
|
14813
|
-
const runtime = useExternalStoreRuntime({
|
|
14814
|
-
isRunning,
|
|
14815
|
-
messages,
|
|
14816
|
-
convertMessage: convertMessage$1,
|
|
14817
|
-
onNew
|
|
14818
|
-
});
|
|
14819
|
-
return /* @__PURE__ */ jsxs(AssistantRuntimeProvider, { runtime, children: [
|
|
14820
|
-
" ",
|
|
14821
|
-
children,
|
|
14822
|
-
" "
|
|
14823
|
-
] });
|
|
14824
|
-
}
|
|
14825
|
-
|
|
14826
|
-
function MarkdownRenderer({ children }) {
|
|
14827
|
-
const processedText = children.replace(/\\n/g, "\n");
|
|
14828
|
-
return /* @__PURE__ */ jsx(Markdown, { remarkPlugins: [remarkGfm], components: COMPONENTS, className: "space-y-3", children: processedText });
|
|
14829
|
-
}
|
|
14830
|
-
const HighlightedPre = React__default.memo(({ children, language, ...props }) => {
|
|
14831
|
-
const [tokens, setTokens] = useState([]);
|
|
14832
|
-
useEffect(() => {
|
|
14833
|
-
highlight(children, language).then((tokens2) => {
|
|
14834
|
-
if (tokens2) setTokens(tokens2);
|
|
14835
|
-
});
|
|
14836
|
-
}, [children, language]);
|
|
14837
|
-
if (!tokens.length) {
|
|
14838
|
-
return /* @__PURE__ */ jsx("pre", { ...props, children });
|
|
14839
|
-
}
|
|
14840
|
-
return /* @__PURE__ */ jsx("pre", { ...props, children: /* @__PURE__ */ jsx("code", { children: tokens.map((line, lineIndex) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14841
|
-
/* @__PURE__ */ jsx("span", { children: line.map((token, tokenIndex) => {
|
|
14842
|
-
const style = typeof token.htmlStyle === "string" ? void 0 : token.htmlStyle;
|
|
14843
|
-
return /* @__PURE__ */ jsx(
|
|
14844
|
-
"span",
|
|
14845
|
-
{
|
|
14846
|
-
className: "text-shiki-light bg-shiki-light-bg dark:text-shiki-dark dark:bg-shiki-dark-bg",
|
|
14847
|
-
style,
|
|
14848
|
-
children: token.content
|
|
14849
|
-
},
|
|
14850
|
-
tokenIndex
|
|
14851
|
-
);
|
|
14852
|
-
}) }, lineIndex),
|
|
14853
|
-
lineIndex !== tokens.length - 1 && "\n"
|
|
14854
|
-
] })) }) });
|
|
14855
|
-
});
|
|
14856
|
-
HighlightedPre.displayName = "HighlightedCode";
|
|
14857
|
-
const CodeBlock = ({ children, className, language, ...restProps }) => {
|
|
14858
|
-
const code = typeof children === "string" ? children : childrenTakeAllStringContents(children);
|
|
14859
|
-
const preClass = cn(
|
|
14860
|
-
"overflow-x-scroll rounded-md border bg-background/50 p-4 font-mono text-sm [scrollbar-width:none]",
|
|
14861
|
-
className
|
|
14862
|
-
);
|
|
14863
|
-
return /* @__PURE__ */ jsxs("div", { className: "group/code relative mb-4", children: [
|
|
14864
|
-
/* @__PURE__ */ jsx(
|
|
14865
|
-
Suspense,
|
|
14866
|
-
{
|
|
14867
|
-
fallback: /* @__PURE__ */ jsx("pre", { className: preClass, ...restProps, children }),
|
|
14868
|
-
children: /* @__PURE__ */ jsx(HighlightedPre, { language, className: preClass, children: code })
|
|
14869
|
-
}
|
|
14870
|
-
),
|
|
14871
|
-
/* @__PURE__ */ jsx("div", { className: "invisible absolute right-2 top-2 flex space-x-1 rounded-lg p-1 opacity-0 transition-all duration-200 group-hover/code:visible group-hover/code:opacity-100", children: /* @__PURE__ */ jsx(CopyButton, { content: code, copyMessage: "Copied code to clipboard" }) })
|
|
14872
|
-
] });
|
|
14873
|
-
};
|
|
14874
|
-
function childrenTakeAllStringContents(element) {
|
|
14875
|
-
if (typeof element === "string") {
|
|
14876
|
-
return element;
|
|
14877
|
-
}
|
|
14878
|
-
if (element?.props?.children) {
|
|
14879
|
-
let children = element.props.children;
|
|
14880
|
-
if (Array.isArray(children)) {
|
|
14881
|
-
return children.map((child) => childrenTakeAllStringContents(child)).join("");
|
|
14882
|
-
} else {
|
|
14883
|
-
return childrenTakeAllStringContents(children);
|
|
14884
|
-
}
|
|
14885
|
-
}
|
|
14886
|
-
return "";
|
|
14887
|
-
}
|
|
14888
|
-
const COMPONENTS = {
|
|
14889
|
-
h1: ({ children, ...props }) => /* @__PURE__ */ jsx("h1", { className: "text-2xl font-semibold", ...props, children }),
|
|
14890
|
-
h2: ({ children, ...props }) => /* @__PURE__ */ jsx("h2", { className: "font-semibold text-xl", ...props, children }),
|
|
14891
|
-
h3: ({ children, ...props }) => /* @__PURE__ */ jsx("h3", { className: "font-semibold text-lg", ...props, children }),
|
|
14892
|
-
h4: ({ children, ...props }) => /* @__PURE__ */ jsx("h4", { className: "font-semibold text-base", ...props, children }),
|
|
14893
|
-
h5: ({ children, ...props }) => /* @__PURE__ */ jsx("h5", { className: "font-medium", ...props, children }),
|
|
14894
|
-
strong: ({ children, ...props }) => /* @__PURE__ */ jsx("strong", { className: "font-semibold", ...props, children }),
|
|
14895
|
-
a: ({ children, ...props }) => /* @__PURE__ */ jsx("a", { className: "underline underline-offset-2", ...props, children }),
|
|
14896
|
-
blockquote: ({ children, ...props }) => /* @__PURE__ */ jsx("blockquote", { className: "border-l-2 border-primary pl-4", ...props, children }),
|
|
14897
|
-
code: ({ children, className, ...rest }) => {
|
|
14898
|
-
const match = /language-(\w+)/.exec(className || "");
|
|
14899
|
-
return match ? /* @__PURE__ */ jsx(CodeBlock, { className, language: match[1], ...rest, children }) : /* @__PURE__ */ jsx(
|
|
14900
|
-
"code",
|
|
14901
|
-
{
|
|
14902
|
-
className: cn(
|
|
14903
|
-
"font-mono [:not(pre)>&]:rounded-md [:not(pre)>&]:bg-background/50 [:not(pre)>&]:px-1 [:not(pre)>&]:py-0.5"
|
|
14904
|
-
),
|
|
14905
|
-
...rest,
|
|
14906
|
-
children
|
|
14907
|
-
}
|
|
14908
|
-
);
|
|
14909
|
-
},
|
|
14910
|
-
pre: ({ children }) => children,
|
|
14911
|
-
ol: ({ children, ...props }) => /* @__PURE__ */ jsx("ol", { className: "list-decimal space-y-2 pl-6", ...props, children }),
|
|
14912
|
-
ul: ({ children, ...props }) => /* @__PURE__ */ jsx("ul", { className: "list-disc space-y-2 pl-6", ...props, children }),
|
|
14913
|
-
li: ({ children, ...props }) => /* @__PURE__ */ jsx("li", { className: "my-1.5", ...props, children }),
|
|
14914
|
-
table: ({ children, ...props }) => /* @__PURE__ */ jsx("table", { className: "w-full border-collapse overflow-y-auto rounded-md border border-foreground/20", ...props, children }),
|
|
14915
|
-
th: ({ children, ...props }) => /* @__PURE__ */ jsx(
|
|
14916
|
-
"th",
|
|
14917
|
-
{
|
|
14918
|
-
className: "border border-foreground/20 px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right",
|
|
14919
|
-
...props,
|
|
14920
|
-
children
|
|
14921
|
-
}
|
|
14922
|
-
),
|
|
14923
|
-
td: ({ children, ...props }) => /* @__PURE__ */ jsx(
|
|
14924
|
-
"td",
|
|
14925
|
-
{
|
|
14926
|
-
className: "border border-foreground/20 px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right",
|
|
14927
|
-
...props,
|
|
14928
|
-
children
|
|
14929
|
-
}
|
|
14930
|
-
),
|
|
14931
|
-
tr: ({ children, ...props }) => /* @__PURE__ */ jsx("tr", { className: "m-0 border-t p-0 even:bg-muted", ...props, children }),
|
|
14932
|
-
p: ({ children, ...props }) => /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap leading-relaxed", ...props, children }),
|
|
14933
|
-
hr: ({ ...props }) => /* @__PURE__ */ jsx("hr", { className: "border-foreground/20", ...props })
|
|
14934
|
-
};
|
|
14935
|
-
|
|
14936
|
-
const purpleClasses = {
|
|
14937
|
-
bg: "bg-[rgba(124,80,175,0.25)]",
|
|
14938
|
-
text: "text-[rgb(180,140,230)]",
|
|
14939
|
-
hover: "hover:text-[rgb(200,160,250)]"};
|
|
14940
|
-
const ToolFallback = (props) => {
|
|
14941
|
-
const { toolCallId, toolName, args, argsText, result, status } = props;
|
|
14942
|
-
const [expandedAgents, setExpandedAgents] = useState({});
|
|
14943
|
-
const actions = args?.actions || [];
|
|
14944
|
-
if (actions.length === 0) {
|
|
14945
|
-
return null;
|
|
14946
|
-
}
|
|
14947
|
-
const toggleAgent = (agentId) => {
|
|
14948
|
-
setExpandedAgents((prev) => ({
|
|
14949
|
-
...prev,
|
|
14950
|
-
[agentId]: !prev[agentId]
|
|
14951
|
-
}));
|
|
14952
|
-
};
|
|
14953
|
-
const extractUrls = (text) => {
|
|
14954
|
-
if (typeof text !== "string") return [];
|
|
14955
|
-
const urlRegex = /(https?:\/\/[^\s]+)/g;
|
|
14956
|
-
return text.match(urlRegex) || [];
|
|
14957
|
-
};
|
|
14958
|
-
return /* @__PURE__ */ jsx("div", { className: "mb-4 w-full rounded-lg border border-gray-700 overflow-hidden shadow-md", children: actions.map((action, index) => {
|
|
14959
|
-
const agentId = `${toolCallId || "tool"}-${action.agent}-${index}`;
|
|
14960
|
-
const isExpanded = expandedAgents[agentId] || false;
|
|
14961
|
-
const urls = result ? extractUrls(result) : [];
|
|
14962
|
-
return /* @__PURE__ */ jsxs("div", { className: `border-b border-gray-700 ${index === actions.length - 1 ? "border-b-0" : ""}`, children: [
|
|
14963
|
-
/* @__PURE__ */ jsxs(
|
|
14964
|
-
"div",
|
|
14965
|
-
{
|
|
14966
|
-
className: "flex items-center justify-between px-4 py-3 bg-gray-900 hover:bg-gray-800 cursor-pointer",
|
|
14967
|
-
onClick: () => toggleAgent(agentId),
|
|
14968
|
-
children: [
|
|
14969
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
14970
|
-
/* @__PURE__ */ jsx("div", { className: cn("flex h-6 w-6 items-center justify-center rounded-full", purpleClasses.bg), children: status?.type === "running" ? /* @__PURE__ */ jsx(LoaderCircle, { className: cn("h-4 w-4 animate-spin", purpleClasses.text) }) : /* @__PURE__ */ jsx(CheckIcon$1, { className: cn("h-4 w-4", purpleClasses.text) }) }),
|
|
14971
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("p", { className: "font-medium text-sm text-gray-100", children: action.agent?.replaceAll("_", " ") }) })
|
|
14972
|
-
] }),
|
|
14973
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
14974
|
-
/* @__PURE__ */ jsx("span", { className: cn("text-xs px-2 py-1 rounded-full", purpleClasses.bg, purpleClasses.text), children: status?.type === "running" ? "Processing..." : "Complete" }),
|
|
14975
|
-
isExpanded ? /* @__PURE__ */ jsx(ChevronUpIcon, { className: "h-4 w-4 text-gray-300" }) : /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-gray-300" })
|
|
14976
|
-
] })
|
|
14977
|
-
]
|
|
14978
|
-
}
|
|
14979
|
-
),
|
|
14980
|
-
isExpanded && /* @__PURE__ */ jsxs("div", { className: "px-4 py-3 bg-[#111]", children: [
|
|
14981
|
-
/* @__PURE__ */ jsxs("div", { className: "mb-3", children: [
|
|
14982
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold text-gray-300 mb-1", children: "Query:" }),
|
|
14983
|
-
/* @__PURE__ */ jsx("div", { className: "p-2 bg-gray-900 rounded border border-gray-700", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-200 whitespace-pre-wrap", children: action.input }) })
|
|
14984
|
-
] }),
|
|
14985
|
-
result && /* @__PURE__ */ jsxs("div", { children: [
|
|
14986
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold text-gray-300 mb-1", children: "Result:" }),
|
|
14987
|
-
/* @__PURE__ */ jsx("div", { className: "p-2 bg-gray-900 rounded border border-gray-700 max-h-60 overflow-auto", children: typeof result === "string" ? /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-200", children: /* @__PURE__ */ jsx(MarkdownRenderer, { children: result }) }) : /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-200 whitespace-pre-wrap", children: JSON.stringify(result, null, 2) }) }),
|
|
14988
|
-
urls.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-2", children: [
|
|
14989
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold text-gray-300 mb-1", children: "Sources:" }),
|
|
14990
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
14991
|
-
urls.slice(0, 3).map((url, i) => /* @__PURE__ */ jsxs(
|
|
14992
|
-
"a",
|
|
14993
|
-
{
|
|
14994
|
-
href: url,
|
|
14995
|
-
target: "_blank",
|
|
14996
|
-
rel: "noopener noreferrer",
|
|
14997
|
-
className: cn(
|
|
14998
|
-
"inline-flex items-center gap-1 text-xs hover:underline",
|
|
14999
|
-
purpleClasses.text,
|
|
15000
|
-
purpleClasses.hover
|
|
15001
|
-
),
|
|
15002
|
-
children: [
|
|
15003
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
15004
|
-
"Source ",
|
|
15005
|
-
i + 1
|
|
15006
|
-
] }),
|
|
15007
|
-
/* @__PURE__ */ jsx(ExternalLinkIcon, { className: "h-3 w-3" })
|
|
15008
|
-
]
|
|
15009
|
-
},
|
|
15010
|
-
i
|
|
15011
|
-
)),
|
|
15012
|
-
urls.length > 3 && /* @__PURE__ */ jsxs("span", { className: "text-xs text-gray-400", children: [
|
|
15013
|
-
"+",
|
|
15014
|
-
urls.length - 3,
|
|
15015
|
-
" more"
|
|
15016
|
-
] })
|
|
15017
|
-
] })
|
|
15018
|
-
] })
|
|
15019
|
-
] })
|
|
15020
|
-
] })
|
|
15021
|
-
] }, agentId);
|
|
15022
|
-
}) });
|
|
15023
|
-
};
|
|
15024
|
-
|
|
15025
14659
|
const defaultModelSettings = {
|
|
15026
14660
|
maxRetries: 2,
|
|
15027
14661
|
maxSteps: 5,
|
|
@@ -15055,11 +14689,6 @@ function NetworkProvider({ children }) {
|
|
|
15055
14689
|
);
|
|
15056
14690
|
}
|
|
15057
14691
|
|
|
15058
|
-
const NetworkChat = ({ agentId, memory }) => {
|
|
15059
|
-
const { modelSettings } = useContext(NetworkContext);
|
|
15060
|
-
return /* @__PURE__ */ jsx(MastraNetworkRuntimeProvider, { agentId, memory, modelSettings, children: /* @__PURE__ */ jsx(Thread, { ToolFallback }) });
|
|
15061
|
-
};
|
|
15062
|
-
|
|
15063
14692
|
const VNextNetworkChatContext = createContext(void 0);
|
|
15064
14693
|
const VNextNetworkChatProvider = ({ children }) => {
|
|
15065
14694
|
const [state, setState] = useState({});
|
|
@@ -15281,7 +14910,7 @@ const NextAssistantMessage = ({
|
|
|
15281
14910
|
{
|
|
15282
14911
|
components: {
|
|
15283
14912
|
Text: MarkdownText,
|
|
15284
|
-
tools: { Fallback: ToolFallbackCustom || ToolFallback
|
|
14913
|
+
tools: { Fallback: ToolFallbackCustom || ToolFallback }
|
|
15285
14914
|
}
|
|
15286
14915
|
}
|
|
15287
14916
|
) }),
|
|
@@ -15979,14 +15608,7 @@ const columns = [
|
|
|
15979
15608
|
EntryCell,
|
|
15980
15609
|
{
|
|
15981
15610
|
icon: /* @__PURE__ */ jsx(AgentIcon, {}),
|
|
15982
|
-
name: /* @__PURE__ */ jsx(
|
|
15983
|
-
Link,
|
|
15984
|
-
{
|
|
15985
|
-
className: "w-full space-y-0",
|
|
15986
|
-
href: `/networks${row.original.isVNext ? "/v-next" : ""}/${row.original.id}/chat`,
|
|
15987
|
-
children: row.original.name
|
|
15988
|
-
}
|
|
15989
|
-
),
|
|
15611
|
+
name: /* @__PURE__ */ jsx(Link, { className: "w-full space-y-0", href: `/networks/v-next/${row.original.id}/chat`, children: row.original.name }),
|
|
15990
15612
|
description: row.original.instructions
|
|
15991
15613
|
}
|
|
15992
15614
|
);
|
|
@@ -16013,33 +15635,23 @@ const columns = [
|
|
|
16013
15635
|
{
|
|
16014
15636
|
id: "model",
|
|
16015
15637
|
header: "Routing Models",
|
|
16016
|
-
cell: ({ row }) => /* @__PURE__ */
|
|
16017
|
-
/* @__PURE__ */ jsx(Badge$1, { variant: "default", icon: /* @__PURE__ */ jsx(Brain, {}), children: row.original.routingModel }),
|
|
16018
|
-
row.original.isVNext ? /* @__PURE__ */ jsx(Badge$1, { className: "!text-accent1 ml-2", children: "vNext" }) : null
|
|
16019
|
-
] })
|
|
15638
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(Cell, { className: "truncate", children: /* @__PURE__ */ jsx(Badge$1, { variant: "default", icon: /* @__PURE__ */ jsx(Brain, {}), children: row.original.routingModel }) })
|
|
16020
15639
|
}
|
|
16021
15640
|
];
|
|
16022
15641
|
|
|
16023
|
-
const NetworkTable = ({
|
|
15642
|
+
const NetworkTable = ({ networks, isLoading, computeLink }) => {
|
|
16024
15643
|
const { navigate } = useLinkComponent();
|
|
16025
15644
|
const allNetworks = useMemo(
|
|
16026
15645
|
() => [
|
|
16027
|
-
...legacyNetworks?.map((network) => ({
|
|
16028
|
-
...network,
|
|
16029
|
-
routingModel: network.routingModel.modelId,
|
|
16030
|
-
agentsSize: network.agents.length,
|
|
16031
|
-
isVNext: false
|
|
16032
|
-
})) ?? [],
|
|
16033
15646
|
...networks?.map((network) => ({
|
|
16034
15647
|
...network,
|
|
16035
15648
|
routingModel: network.routingModel.modelId,
|
|
16036
15649
|
agentsSize: network.agents.length,
|
|
16037
15650
|
workflowsSize: network.workflows.length,
|
|
16038
|
-
toolsSize: network.tools.length
|
|
16039
|
-
isVNext: true
|
|
15651
|
+
toolsSize: network.tools.length
|
|
16040
15652
|
})) ?? []
|
|
16041
15653
|
],
|
|
16042
|
-
[networks
|
|
15654
|
+
[networks]
|
|
16043
15655
|
);
|
|
16044
15656
|
const table = useReactTable({
|
|
16045
15657
|
data: allNetworks,
|
|
@@ -16054,15 +15666,7 @@ const NetworkTable = ({ legacyNetworks, networks, isLoading, computeLink }) => {
|
|
|
16054
15666
|
}
|
|
16055
15667
|
return /* @__PURE__ */ jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxs(Table$1, { children: [
|
|
16056
15668
|
/* @__PURE__ */ jsx(Thead, { className: "sticky top-0", children: ths.headers.map((header) => /* @__PURE__ */ jsx(Th, { style: { width: header.index === 0 ? "auto" : header.column.getSize() }, children: flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }),
|
|
16057
|
-
/* @__PURE__ */ jsx(Tbody, { children: rows.map((row) => /* @__PURE__ */ jsx(
|
|
16058
|
-
Row,
|
|
16059
|
-
{
|
|
16060
|
-
onClick: () => navigate(computeLink(row.original.id, row.original.isVNext || false)),
|
|
16061
|
-
className: "cursor-pointer",
|
|
16062
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(React__default.Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
|
|
16063
|
-
},
|
|
16064
|
-
row.id
|
|
16065
|
-
)) })
|
|
15669
|
+
/* @__PURE__ */ jsx(Tbody, { children: rows.map((row) => /* @__PURE__ */ jsx(Row, { onClick: () => navigate(computeLink(row.original.id)), className: "cursor-pointer", children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(React__default.Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)) }, row.id)) })
|
|
16066
15670
|
] }) });
|
|
16067
15671
|
};
|
|
16068
15672
|
const NetworkTableEmpty = () => {
|
|
@@ -16168,6 +15772,41 @@ const Searchbar = ({ onSearch, label, placeholder }) => {
|
|
|
16168
15772
|
);
|
|
16169
15773
|
};
|
|
16170
15774
|
|
|
15775
|
+
const Entity = ({ children, className, onClick }) => {
|
|
15776
|
+
return /* @__PURE__ */ jsx(
|
|
15777
|
+
"div",
|
|
15778
|
+
{
|
|
15779
|
+
tabIndex: onClick ? 0 : void 0,
|
|
15780
|
+
onKeyDown: (e) => {
|
|
15781
|
+
if (!onClick) return;
|
|
15782
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
15783
|
+
e.preventDefault();
|
|
15784
|
+
onClick?.();
|
|
15785
|
+
}
|
|
15786
|
+
},
|
|
15787
|
+
className: clsx(
|
|
15788
|
+
"flex gap-3 group/entity bg-surface3 rounded-lg border-sm border-border1 py-3 px-4",
|
|
15789
|
+
onClick && "cursor-pointer hover:bg-surface4 transition-all",
|
|
15790
|
+
className
|
|
15791
|
+
),
|
|
15792
|
+
onClick,
|
|
15793
|
+
children
|
|
15794
|
+
}
|
|
15795
|
+
);
|
|
15796
|
+
};
|
|
15797
|
+
const EntityIcon = ({ children, className }) => {
|
|
15798
|
+
return /* @__PURE__ */ jsx(Icon, { size: "lg", className: clsx("text-icon3 mt-1", className), children });
|
|
15799
|
+
};
|
|
15800
|
+
const EntityName = ({ children, className }) => {
|
|
15801
|
+
return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-lg", className: clsx("text-icon6 font-medium", className), children });
|
|
15802
|
+
};
|
|
15803
|
+
const EntityDescription = ({ children, className }) => {
|
|
15804
|
+
return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-sm", className: clsx("text-icon3", className), children });
|
|
15805
|
+
};
|
|
15806
|
+
const EntityContent = ({ children, className }) => {
|
|
15807
|
+
return /* @__PURE__ */ jsx("div", { className, children });
|
|
15808
|
+
};
|
|
15809
|
+
|
|
16171
15810
|
const ToolList = ({ tools, agents, isLoading, computeLink, computeAgentLink }) => {
|
|
16172
15811
|
const toolsWithAgents = useMemo(() => prepareAgents(tools, agents), [tools, agents]);
|
|
16173
15812
|
if (isLoading)
|
|
@@ -18515,88 +18154,6 @@ function TracesTools({
|
|
|
18515
18154
|
] });
|
|
18516
18155
|
}
|
|
18517
18156
|
|
|
18518
|
-
const DataTable = ({
|
|
18519
|
-
columns,
|
|
18520
|
-
data,
|
|
18521
|
-
pagination,
|
|
18522
|
-
gotoNextPage,
|
|
18523
|
-
gotoPreviousPage,
|
|
18524
|
-
getRowId,
|
|
18525
|
-
selectedRowId,
|
|
18526
|
-
isLoading,
|
|
18527
|
-
emptyText,
|
|
18528
|
-
onClick
|
|
18529
|
-
}) => {
|
|
18530
|
-
const [sorting, setSorting] = useState([]);
|
|
18531
|
-
const [{ pageIndex, pageSize }, setPagination] = useState({
|
|
18532
|
-
pageIndex: pagination ? Math.floor(pagination.offset / pagination.limit) : 0,
|
|
18533
|
-
pageSize: pagination?.limit ?? 10
|
|
18534
|
-
});
|
|
18535
|
-
const [rowSelection, setRowSelection] = useState({});
|
|
18536
|
-
const table = useReactTable({
|
|
18537
|
-
data,
|
|
18538
|
-
columns,
|
|
18539
|
-
getCoreRowModel: getCoreRowModel(),
|
|
18540
|
-
manualPagination: true,
|
|
18541
|
-
pageCount: pagination ? Math.ceil(pagination.total / pagination.limit) : -1,
|
|
18542
|
-
state: {
|
|
18543
|
-
sorting,
|
|
18544
|
-
pagination: {
|
|
18545
|
-
pageIndex,
|
|
18546
|
-
pageSize
|
|
18547
|
-
},
|
|
18548
|
-
rowSelection
|
|
18549
|
-
},
|
|
18550
|
-
getRowId,
|
|
18551
|
-
onPaginationChange: setPagination,
|
|
18552
|
-
onSortingChange: setSorting,
|
|
18553
|
-
enableRowSelection: true,
|
|
18554
|
-
enableMultiRowSelection: false,
|
|
18555
|
-
onRowSelectionChange: setRowSelection
|
|
18556
|
-
});
|
|
18557
|
-
const emptyNode = /* @__PURE__ */ jsx(Row, { children: /* @__PURE__ */ jsx(Cell, { colSpan: columns.length, children: /* @__PURE__ */ jsxs("div", { className: "py-12 text-center w-full", children: [
|
|
18558
|
-
"No ",
|
|
18559
|
-
emptyText || "results"
|
|
18560
|
-
] }) }) });
|
|
18561
|
-
const ths = table.getHeaderGroups()[0];
|
|
18562
|
-
const rows = table.getRowModel().rows;
|
|
18563
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
18564
|
-
/* @__PURE__ */ jsxs(Table$1, { children: [
|
|
18565
|
-
/* @__PURE__ */ jsx(Thead, { className: "sticky top-0 bg-surface2", children: ths.headers.map((header) => {
|
|
18566
|
-
const size = header.column.getSize();
|
|
18567
|
-
const meta = header.column.columnDef.meta;
|
|
18568
|
-
return /* @__PURE__ */ jsx(Th, { style: { width: meta?.width || size || "auto" }, children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) }, header.id);
|
|
18569
|
-
}) }),
|
|
18570
|
-
/* @__PURE__ */ jsx(Tbody, { children: isLoading ? /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: 3 }).map((_, rowIndex) => /* @__PURE__ */ jsx(Row, { onClick: () => {
|
|
18571
|
-
}, children: Array.from({ length: columns.length }).map((_2, cellIndex) => /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" }) }, `row-${rowIndex}-cell-${cellIndex}`)) }, rowIndex)) }) : rows?.length > 0 ? rows.map((row) => /* @__PURE__ */ jsx(
|
|
18572
|
-
Row,
|
|
18573
|
-
{
|
|
18574
|
-
"data-state": (row.getIsSelected() || row.id === selectedRowId) && "selected",
|
|
18575
|
-
onClick: () => onClick?.(row.original),
|
|
18576
|
-
children: row.getVisibleCells().map((cell) => flexRender(cell.column.columnDef.cell, cell.getContext()))
|
|
18577
|
-
},
|
|
18578
|
-
row.id
|
|
18579
|
-
)) : emptyNode })
|
|
18580
|
-
] }),
|
|
18581
|
-
pagination && /* @__PURE__ */ jsxs("div", { className: "mt-4 flex items-center justify-between px-2", children: [
|
|
18582
|
-
/* @__PURE__ */ jsxs("div", { className: "text-muted-foreground text-sm", children: [
|
|
18583
|
-
"Showing ",
|
|
18584
|
-
pagination.offset + 1,
|
|
18585
|
-
" to ",
|
|
18586
|
-
Math.min(pagination.offset + data.length, pagination.total),
|
|
18587
|
-
" of",
|
|
18588
|
-
" ",
|
|
18589
|
-
pagination.total,
|
|
18590
|
-
" results"
|
|
18591
|
-
] }),
|
|
18592
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center space-x-6 lg:space-x-8", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
18593
|
-
/* @__PURE__ */ jsx(Button$2, { variant: "outline", size: "sm", onClick: gotoPreviousPage, disabled: !pagination.offset, children: "Previous" }),
|
|
18594
|
-
/* @__PURE__ */ jsx(Button$2, { variant: "outline", size: "sm", onClick: gotoNextPage, disabled: !pagination.hasMore, children: "Next" })
|
|
18595
|
-
] }) })
|
|
18596
|
-
] })
|
|
18597
|
-
] });
|
|
18598
|
-
};
|
|
18599
|
-
|
|
18600
18157
|
function MainContentLayout({
|
|
18601
18158
|
children,
|
|
18602
18159
|
className,
|
|
@@ -19117,5 +18674,5 @@ const MemorySearch = ({
|
|
|
19117
18674
|
] });
|
|
19118
18675
|
};
|
|
19119
18676
|
|
|
19120
|
-
export { AgentChat, AgentCoinIcon, AgentEntityHeader, AgentEvals, AgentIcon, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataNetworkList, AgentMetadataPrompt, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentsTable, AgentsTableSkeleton, AiIcon, AlertDialog, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button$1 as Button, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, CommitIcon, CrossIcon, Crumb, DarkLogo,
|
|
18677
|
+
export { AgentChat, AgentCoinIcon, AgentEntityHeader, AgentEvals, AgentIcon, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataNetworkList, AgentMetadataPrompt, AgentMetadataScorerList, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentsTable, AgentsTableSkeleton, AiIcon, AlertDialog, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button$1 as Button, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, CommitIcon, CrossIcon, Crumb, DarkLogo, DateTimeCell, DateTimePicker, DateTimePickerContent, DbIcon, DebugIcon, DefaultTrigger, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyAgentsTable, EmptyScorersTable, EmptyState, EmptyWorkflowsTable, Entity, EntityContent, EntityDescription, EntityHeader, EntityIcon, EntityMainHeader, EntityName, Entry, EntryCell, EntryList, EntryListItem, EntryListPageHeader, EntryListStatusCell, EntryListTextCell, EntryListToolbar, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, FormActions, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, InputField, JudgeIcon, Kbd, KeyValueList, LatencyIcon, LegacyWorkflowGraph, LegacyWorkflowTrigger, LinkComponentProvider, LogsIcon, MainContentContent, MainContentLayout, MastraClientProvider, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, MemorySearch, NetworkContext, NetworkProvider, NetworkTable, NetworkTableEmpty, NetworkTableSkeleton, OpenAIIcon, PageHeader, PlaygroundQueryClient, PlaygroundTabs, PromptIcon, RadioGroup, RadioGroupField, RadioGroupItem, RepoIcon, Row, RuntimeContext, RuntimeContextWrapper, ScoreDialog, ScoreIcon, ScorersTable, ScorersTableSkeleton, ScoresTools, SearchField, Searchbar, SelectField, SettingsIcon, SideDialog, SideDialogCodeSection, SideDialogContent, SideDialogFooter, SideDialogFooterGroup, SideDialogHeader, SideDialogHeading, SideDialogKeyValueList, SideDialogSection, SideDialogTop, SlashIcon, SliderField, Tab, TabContent, TabList, Table$1 as Table, Tbody, TemplateFailure, TemplateForm, TemplateInfo, TemplateInstallation, TemplateSuccess, TemplatesList, TemplatesTools, TextAndIcon, TextareaField, Th, Thead, ThreadDeleteButton, ThreadInputProvider, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolList, ToolListEmpty, ToolListSkeleton, ToolsIcon, TraceDialog, TraceIcon, TraceTimeline, TraceTimelineLegend, TraceTimelineSpan, TracesTools, TracesView, TracesViewSkeleton, TsIcon, Txt, TxtCell, UnitCell, VNextNetworkChat, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunProvider, WorkflowRuns, WorkflowTable, WorkflowTableSkeleton, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, allowedAiSpanAttributes, cleanString, convertWorkflowRunStateToWatchResult, formatDuration, formatHierarchicalSpans, formatOtelTimestamp, formatOtelTimestamp2, getColumnTemplate, getShortId, getSpanTypeUi, mapWorkflowStreamChunkToWatchResult, providerMapToIcon, spanTypePrefixes, transformKey, useAgentSettings, useCurrentRun, useExecuteWorkflow, useInView, useLegacyWorkflow, useLinkComponent, useMastraClient, usePlaygroundStore, usePolling, useResumeWorkflow, useScorer, useScorers, useScoresByEntityId, useScoresByScorerId, useSpeechRecognition, useThreadInput, useWatchWorkflow, useWorkflow, useWorkflowRuns, useWorkingMemory };
|
|
19121
18678
|
//# sourceMappingURL=index.es.js.map
|