@mastra/playground-ui 5.1.13-alpha.0 → 5.1.13-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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, Suspense, Fragment as Fragment$1 } from 'react';
3
+ import React__default, { createContext, useContext, forwardRef, memo, useState, useEffect, useRef, useCallback, useMemo, Suspense, Fragment as Fragment$1, startTransition } from 'react';
4
4
  import { MastraClient } from '@mastra/client-js';
5
5
  import { useMessage, MessagePrimitive, ActionBarPrimitive, useAttachment, AttachmentPrimitive, useComposerRuntime, ComposerPrimitive, ThreadPrimitive, useExternalStoreRuntime, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, AssistantRuntimeProvider } from '@assistant-ui/react';
6
- import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, BrainIcon, X, FileText, CircleXIcon, Mic, PlusIcon, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, ChevronUp, ChevronDown, Circle, Braces, SaveIcon, RefreshCw, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Loader2, Network, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Minus, Plus, Maximize, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Brackets, TrashIcon, CirclePause, StopCircle } from 'lucide-react';
6
+ import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, BrainIcon, X, FileText, CircleXIcon, Mic, PlusIcon, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, ChevronUp, ChevronDown, Circle, Braces, SaveIcon, RefreshCw, ExternalLink, LoaderCircle, ChevronDownIcon, ExternalLinkIcon, Loader2, Network, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Minus, Plus, Maximize, Workflow, AlertCircleIcon, Users, Brain, NetworkIcon, SearchIcon, AlertCircle, CalendarIcon, Brackets, TrashIcon, CirclePause, StopCircle } 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';
@@ -20,7 +20,7 @@ import CodeMirror from '@uiw/react-codemirror';
20
20
  import { toast } from 'sonner';
21
21
  import { useShallow } from 'zustand/shallow';
22
22
  import * as DialogPrimitive from '@radix-ui/react-dialog';
23
- import { RuntimeContext } from '@mastra/core/di';
23
+ import { RuntimeContext as RuntimeContext$1 } from '@mastra/core/di';
24
24
  import { create } from 'zustand';
25
25
  import { persist } from 'zustand/middleware';
26
26
  import { format, formatDistanceToNow, isValid, formatDate } from 'date-fns';
@@ -44,7 +44,7 @@ import { Highlight, themes } from 'prism-react-renderer';
44
44
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
45
45
  import { useDebouncedCallback } from 'use-debounce';
46
46
  import { v4 } from '@lukeed/uuid';
47
- import { RuntimeContext as RuntimeContext$1 } from '@mastra/core/runtime-context';
47
+ import { RuntimeContext as RuntimeContext$2 } from '@mastra/core/runtime-context';
48
48
  import jsonSchemaToZod from 'json-schema-to-zod';
49
49
  import { parse } from 'superjson';
50
50
  import z$1, { z, ZodObject } from 'zod';
@@ -5176,7 +5176,7 @@ function MastraRuntimeProvider({
5176
5176
  providerOptions
5177
5177
  } = settings?.modelSettings ?? {};
5178
5178
  const toolCallIdToName = useRef({});
5179
- const runtimeContextInstance = new RuntimeContext();
5179
+ const runtimeContextInstance = new RuntimeContext$1();
5180
5180
  Object.entries(runtimeContext ?? {}).forEach(([key, value]) => {
5181
5181
  runtimeContextInstance.set(key, value);
5182
5182
  });
@@ -7725,7 +7725,11 @@ const LinkComponentProvider = ({ children, Link }) => {
7725
7725
  return /* @__PURE__ */ jsx(LinkComponentContext.Provider, { value: { Link }, children });
7726
7726
  };
7727
7727
  const useLinkComponent = () => {
7728
- return useContext(LinkComponentContext);
7728
+ const ctx = useContext(LinkComponentContext);
7729
+ if (!ctx) {
7730
+ throw new Error("useLinkComponent must be used within a LinkComponentProvider");
7731
+ }
7732
+ return ctx;
7729
7733
  };
7730
7734
 
7731
7735
  const providerMapToIcon = {
@@ -7751,7 +7755,7 @@ const NameCell = ({ row }) => {
7751
7755
  }
7752
7756
  );
7753
7757
  };
7754
- const columns = [
7758
+ const columns$2 = [
7755
7759
  {
7756
7760
  header: "Name",
7757
7761
  accessorKey: "name",
@@ -7788,24 +7792,27 @@ const columns = [
7788
7792
  ];
7789
7793
 
7790
7794
  function AgentsTable({ agents, isLoading, onClickRow }) {
7791
- const _agents = agents || {};
7792
- const projectData = Object.keys(_agents).map((key) => {
7793
- const agent = _agents[key];
7794
- return {
7795
- id: key,
7796
- name: agent.name,
7797
- instructions: agent.instructions,
7798
- provider: agent.provider,
7799
- branch: void 0,
7800
- executedAt: void 0,
7801
- repoUrl: void 0,
7802
- tools: agent.tools,
7803
- modelId: agent.modelId
7804
- };
7805
- });
7795
+ const projectData = useMemo(
7796
+ () => Object.keys(agents).map((key) => {
7797
+ const agent = agents[key];
7798
+ return {
7799
+ id: key,
7800
+ name: agent.name,
7801
+ instructions: agent.instructions,
7802
+ provider: agent.provider,
7803
+ branch: void 0,
7804
+ executedAt: void 0,
7805
+ repoUrl: void 0,
7806
+ tools: agent.tools,
7807
+ modelId: agent.modelId,
7808
+ link: `/agents/${key}/chat/new`
7809
+ };
7810
+ }),
7811
+ [agents]
7812
+ );
7806
7813
  const table = useReactTable({
7807
7814
  data: projectData,
7808
- columns,
7815
+ columns: columns$2,
7809
7816
  getCoreRowModel: getCoreRowModel()
7810
7817
  });
7811
7818
  if (isLoading) return /* @__PURE__ */ jsx(AgentsTableSkeleton, {});
@@ -7855,6 +7862,83 @@ const EmptyAgentsTable = () => /* @__PURE__ */ jsx("div", { className: "flex h-f
7855
7862
  }
7856
7863
  ) });
7857
7864
 
7865
+ const RuntimeContext = () => {
7866
+ const { runtimeContext, setRuntimeContext } = usePlaygroundStore();
7867
+ const [runtimeContextValue, setRuntimeContextValue] = useState("");
7868
+ const theme = useCodemirrorTheme();
7869
+ const { handleCopy } = useCopyToClipboard({ text: runtimeContextValue });
7870
+ const runtimeContextStr = JSON.stringify(runtimeContext);
7871
+ useEffect(() => {
7872
+ const run = async () => {
7873
+ if (!isValidJson(runtimeContextStr)) {
7874
+ toast.error("Invalid JSON");
7875
+ return;
7876
+ }
7877
+ const formatted = await formatJSON(runtimeContextStr);
7878
+ setRuntimeContextValue(formatted);
7879
+ };
7880
+ run();
7881
+ }, [runtimeContextStr]);
7882
+ const handleSaveRuntimeContext = () => {
7883
+ try {
7884
+ const parsedContext = JSON.parse(runtimeContextValue);
7885
+ setRuntimeContext(parsedContext);
7886
+ toast.success("Runtime context saved successfully");
7887
+ } catch (error) {
7888
+ console.error("error", error);
7889
+ toast.error("Invalid JSON");
7890
+ }
7891
+ };
7892
+ const buttonClass = "text-icon3 hover:text-icon6";
7893
+ const formatRuntimeContext = async () => {
7894
+ if (!isValidJson(runtimeContextValue)) {
7895
+ toast.error("Invalid JSON");
7896
+ return;
7897
+ }
7898
+ const formatted = await formatJSON(runtimeContextValue);
7899
+ setRuntimeContextValue(formatted);
7900
+ };
7901
+ return /* @__PURE__ */ jsxs("div", { children: [
7902
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pb-2", children: [
7903
+ /* @__PURE__ */ jsx(Txt, { as: "label", variant: "ui-md", className: "text-icon3", children: "Runtime Context (JSON)" }),
7904
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
7905
+ /* @__PURE__ */ jsxs(Tooltip, { children: [
7906
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { onClick: formatRuntimeContext, className: buttonClass, children: /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Braces, {}) }) }) }),
7907
+ /* @__PURE__ */ jsx(TooltipContent, { children: "Format the Runtime Context JSON" })
7908
+ ] }),
7909
+ /* @__PURE__ */ jsxs(Tooltip, { children: [
7910
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { onClick: handleCopy, className: buttonClass, children: /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(CopyIcon, {}) }) }) }),
7911
+ /* @__PURE__ */ jsx(TooltipContent, { children: "Copy Runtime Context" })
7912
+ ] })
7913
+ ] })
7914
+ ] }),
7915
+ /* @__PURE__ */ jsx(
7916
+ CodeMirror,
7917
+ {
7918
+ value: runtimeContextValue,
7919
+ onChange: setRuntimeContextValue,
7920
+ theme,
7921
+ extensions: [jsonLanguage],
7922
+ className: "h-[400px] overflow-y-scroll bg-surface3 rounded-lg overflow-hidden p-3"
7923
+ }
7924
+ ),
7925
+ /* @__PURE__ */ jsx("div", { className: "flex justify-end pt-2", children: /* @__PURE__ */ jsx(Button, { onClick: handleSaveRuntimeContext, children: "Save" }) })
7926
+ ] });
7927
+ };
7928
+ const RuntimeContextWrapper = ({ children }) => {
7929
+ const { Link } = useLinkComponent();
7930
+ return /* @__PURE__ */ jsxs("div", { className: "max-w-3xl p-5 overflow-y-scroll h-full", children: [
7931
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg p-4 pb-5 bg-surface4 shadow-md space-y-3 border border-border1 mb-5", children: [
7932
+ /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-lg", className: "text-icon3", children: "Mastra provides runtime context, which is a system based on dependency injection that enables you to configure your agents and tools with runtime variables. If you find yourself creating several different agents that do very similar things, runtime context allows you to combine them into one agent." }),
7933
+ /* @__PURE__ */ jsxs(Button, { as: Link, to: "https://mastra.ai/en/docs/agents/runtime-variables", target: "_blank", children: [
7934
+ /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(ExternalLink, {}) }),
7935
+ "See documentation"
7936
+ ] })
7937
+ ] }),
7938
+ children
7939
+ ] });
7940
+ };
7941
+
7858
7942
  const convertMessage$1 = (message) => {
7859
7943
  return message;
7860
7944
  };
@@ -10497,7 +10581,7 @@ function VNextMastraNetworkRuntimeProvider({
10497
10581
  const { chatWithLoop, maxIterations } = useContext(NetworkContext);
10498
10582
  const id = runIdRef.current;
10499
10583
  const currentState = id ? state[id] : void 0;
10500
- const runtimeContextInstance = new RuntimeContext$1();
10584
+ const runtimeContextInstance = new RuntimeContext$2();
10501
10585
  Object.entries(runtimeContext ?? {}).forEach(([key, value]) => {
10502
10586
  runtimeContextInstance.set(key, value);
10503
10587
  });
@@ -10989,6 +11073,309 @@ const VNextNetworkChat = ({
10989
11073
  ) }, threadId) }, threadId);
10990
11074
  };
10991
11075
 
11076
+ const columns$1 = [
11077
+ {
11078
+ id: "name",
11079
+ header: "Name",
11080
+ cell: ({ row }) => {
11081
+ const { Link } = useLinkComponent();
11082
+ return /* @__PURE__ */ jsx(
11083
+ EntryCell,
11084
+ {
11085
+ icon: /* @__PURE__ */ jsx(AgentIcon, {}),
11086
+ name: /* @__PURE__ */ jsx(
11087
+ Link,
11088
+ {
11089
+ className: "w-full space-y-0",
11090
+ href: `/networks${row.original.isVNext ? "/v-next" : ""}/${row.original.id}/chat`,
11091
+ children: row.original.name
11092
+ }
11093
+ ),
11094
+ description: row.original.instructions
11095
+ }
11096
+ );
11097
+ },
11098
+ meta: {
11099
+ width: "auto"
11100
+ }
11101
+ },
11102
+ {
11103
+ id: "agents",
11104
+ header: "Agents",
11105
+ cell: ({ row }) => /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(Users, {}), children: row.original.agentsSize }) })
11106
+ },
11107
+ {
11108
+ id: "workflows",
11109
+ header: "Workflows",
11110
+ cell: ({ row }) => /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(WorkflowIcon, {}), children: row.original.workflowsSize }) })
11111
+ },
11112
+ {
11113
+ id: "tools",
11114
+ header: "Tools",
11115
+ cell: ({ row }) => /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(ToolsIcon, {}), children: row.original.toolsSize }) })
11116
+ },
11117
+ {
11118
+ id: "model",
11119
+ header: "Routing Models",
11120
+ cell: ({ row }) => /* @__PURE__ */ jsxs(Cell, { children: [
11121
+ /* @__PURE__ */ jsx(Badge$1, { variant: "default", icon: /* @__PURE__ */ jsx(Brain, {}), children: row.original.routingModel }),
11122
+ row.original.isVNext ? /* @__PURE__ */ jsx(Badge$1, { className: "!text-accent1 ml-2", children: "vNext" }) : null
11123
+ ] })
11124
+ }
11125
+ ];
11126
+
11127
+ const NetworkTable = ({ legacyNetworks, networks, isLoading, onClickRow }) => {
11128
+ const allNetworks = useMemo(
11129
+ () => [
11130
+ ...legacyNetworks?.map((network) => ({
11131
+ ...network,
11132
+ routingModel: network.routingModel.modelId,
11133
+ agentsSize: network.agents.length,
11134
+ isVNext: false
11135
+ })) ?? [],
11136
+ ...networks?.map((network) => ({
11137
+ ...network,
11138
+ routingModel: network.routingModel.modelId,
11139
+ agentsSize: network.agents.length,
11140
+ workflowsSize: network.workflows.length,
11141
+ toolsSize: network.tools.length,
11142
+ isVNext: true
11143
+ })) ?? []
11144
+ ],
11145
+ [networks, legacyNetworks]
11146
+ );
11147
+ const table = useReactTable({
11148
+ data: allNetworks,
11149
+ columns: columns$1,
11150
+ getCoreRowModel: getCoreRowModel()
11151
+ });
11152
+ if (isLoading) return /* @__PURE__ */ jsx(NetworkTableSkeleton, {});
11153
+ const ths = table.getHeaderGroups()[0];
11154
+ const rows = table.getRowModel().rows.concat();
11155
+ if (rows.length === 0) {
11156
+ return /* @__PURE__ */ jsx(NetworkTableEmpty, {});
11157
+ }
11158
+ return /* @__PURE__ */ jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxs(Table, { children: [
11159
+ /* @__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)) }),
11160
+ /* @__PURE__ */ jsx(Tbody, { children: rows.map((row) => /* @__PURE__ */ jsx(Row, { onClick: () => onClickRow(row.original.id, row.original.isVNext || false), children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(React__default.Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)) }, row.id)) })
11161
+ ] }) });
11162
+ };
11163
+ const NetworkTableEmpty = () => {
11164
+ return /* @__PURE__ */ jsx(
11165
+ EmptyState,
11166
+ {
11167
+ iconSlot: /* @__PURE__ */ jsx(AgentNetworkCoinIcon, {}),
11168
+ titleSlot: "Configure Agent Networks",
11169
+ descriptionSlot: "Mastra agent networks are not configured yet. You can find more information in the documentation.",
11170
+ actionSlot: /* @__PURE__ */ jsxs(
11171
+ Button,
11172
+ {
11173
+ size: "lg",
11174
+ className: "w-full",
11175
+ variant: "light",
11176
+ as: "a",
11177
+ href: "https://mastra.ai/en/reference/networks/agent-network",
11178
+ target: "_blank",
11179
+ children: [
11180
+ /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(NetworkIcon, {}) }),
11181
+ "Docs"
11182
+ ]
11183
+ }
11184
+ )
11185
+ }
11186
+ );
11187
+ };
11188
+ const NetworkTableSkeleton = () => {
11189
+ return /* @__PURE__ */ jsxs(Table, { children: [
11190
+ /* @__PURE__ */ jsxs(Thead, { children: [
11191
+ /* @__PURE__ */ jsx(Th, { children: "Name" }),
11192
+ /* @__PURE__ */ jsx(Th, { width: 160, children: "Agents" }),
11193
+ /* @__PURE__ */ jsx(Th, { width: 160, children: "Workflows" }),
11194
+ /* @__PURE__ */ jsx(Th, { width: 160, children: "Tools" }),
11195
+ /* @__PURE__ */ jsx(Th, { width: 160, children: "Routing Models" })
11196
+ ] }),
11197
+ /* @__PURE__ */ jsx(Tbody, { children: Array.from({ length: 3 }).map((_, index) => /* @__PURE__ */ jsxs(Row, { children: [
11198
+ /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" }) }),
11199
+ /* @__PURE__ */ jsx(Cell, { width: 160, children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" }) }),
11200
+ /* @__PURE__ */ jsx(Cell, { width: 160, children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" }) }),
11201
+ /* @__PURE__ */ jsx(Cell, { width: 160, children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" }) }),
11202
+ /* @__PURE__ */ jsx(Cell, { width: 160, children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" }) })
11203
+ ] }, index)) })
11204
+ ] });
11205
+ };
11206
+
11207
+ const Entity = ({ children, className, onClick }) => {
11208
+ return /* @__PURE__ */ jsx(
11209
+ "div",
11210
+ {
11211
+ tabIndex: onClick ? 0 : void 0,
11212
+ onKeyDown: (e) => {
11213
+ if (!onClick) return;
11214
+ if (e.key === "Enter" || e.key === " ") {
11215
+ e.preventDefault();
11216
+ onClick?.();
11217
+ }
11218
+ },
11219
+ className: clsx(
11220
+ "flex gap-3 group/entity bg-surface3 rounded-lg border-sm border-border1 py-3 px-4",
11221
+ onClick && "cursor-pointer hover:bg-surface4 transition-all",
11222
+ className
11223
+ ),
11224
+ onClick,
11225
+ children
11226
+ }
11227
+ );
11228
+ };
11229
+ const EntityIcon = ({ children, className }) => {
11230
+ return /* @__PURE__ */ jsx(Icon, { size: "lg", className: clsx("text-icon3 mt-1", className), children });
11231
+ };
11232
+ const EntityName = ({ children, className }) => {
11233
+ return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-lg", className: clsx("text-icon6 font-medium", className), children });
11234
+ };
11235
+ const EntityDescription = ({ children, className }) => {
11236
+ return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-sm", className: clsx("text-icon3", className), children });
11237
+ };
11238
+ const EntityContent = ({ children, className }) => {
11239
+ return /* @__PURE__ */ jsx("div", { className, children });
11240
+ };
11241
+
11242
+ const ToolList = ({ tools, agents, isLoading }) => {
11243
+ const toolsWithAgents = useMemo(() => prepareAgents(tools, agents), [tools, agents]);
11244
+ if (isLoading)
11245
+ return /* @__PURE__ */ jsx("div", { className: "max-w-5xl w-full mx-auto px-4 pt-8", children: /* @__PURE__ */ jsx(ToolListSkeleton, {}) });
11246
+ return /* @__PURE__ */ jsx(ToolListInner, { toolsWithAgents });
11247
+ };
11248
+ const ToolListInner = ({ toolsWithAgents }) => {
11249
+ const [filteredTools, setFilteredTools] = useState(toolsWithAgents);
11250
+ const [value, setValue] = useState("");
11251
+ if (filteredTools.length === 0 && !value) return /* @__PURE__ */ jsx(ToolListEmpty, {});
11252
+ const handleSearch = (e) => {
11253
+ const value2 = e.target.value;
11254
+ setValue(value2);
11255
+ startTransition(() => {
11256
+ setFilteredTools(
11257
+ toolsWithAgents.filter(
11258
+ (tool) => tool.id.toLowerCase().includes(value2.toLowerCase()) || tool.description.toLowerCase().includes(value2.toLowerCase()) || tool.agents.some(
11259
+ (agent) => agent.name.toLowerCase().includes(value2.toLowerCase()) || agent.id.toLowerCase().includes(value2.toLowerCase())
11260
+ )
11261
+ )
11262
+ );
11263
+ });
11264
+ };
11265
+ return /* @__PURE__ */ jsxs("div", { children: [
11266
+ /* @__PURE__ */ jsxs("div", { className: "max-w-5xl w-full mx-auto px-4 pt-8", children: [
11267
+ /* @__PURE__ */ jsxs("div", { className: "px-4 flex items-center gap-2 rounded-lg bg-surface5 focus-within:ring-2 focus-within:ring-accent3", children: [
11268
+ /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(SearchIcon, {}) }),
11269
+ /* @__PURE__ */ jsx(
11270
+ "input",
11271
+ {
11272
+ type: "text",
11273
+ placeholder: "Search for a tool",
11274
+ className: "w-full py-2 bg-transparent text-icon3 focus:text-icon6 placeholder:text-icon3 outline-none",
11275
+ value,
11276
+ onChange: handleSearch
11277
+ }
11278
+ )
11279
+ ] }),
11280
+ filteredTools.length === 0 && /* @__PURE__ */ jsx(Txt, { as: "p", className: "text-icon3 py-2", children: "No tools found matching your search." })
11281
+ ] }),
11282
+ /* @__PURE__ */ jsx("div", { className: "grid md:grid-cols-2 xl:grid-cols-3 gap-4 max-w-5xl mx-auto py-8", children: filteredTools.map((tool) => /* @__PURE__ */ jsx(ToolEntity, { tool }, tool.id)) })
11283
+ ] });
11284
+ };
11285
+ const ToolEntity = ({ tool }) => {
11286
+ const linkRef = useRef(null);
11287
+ const { Link } = useLinkComponent();
11288
+ return /* @__PURE__ */ jsxs(Entity, { onClick: () => linkRef.current?.click(), children: [
11289
+ /* @__PURE__ */ jsx(EntityIcon, { children: /* @__PURE__ */ jsx(ToolsIcon, { className: "group-hover/entity:text-[#ECB047]" }) }),
11290
+ /* @__PURE__ */ jsxs(EntityContent, { children: [
11291
+ /* @__PURE__ */ jsx(EntityName, { children: /* @__PURE__ */ jsx(
11292
+ Link,
11293
+ {
11294
+ ref: linkRef,
11295
+ href: tool.agents.length > 0 ? `/tools/${tool.agents[0].id}/${tool.id}` : `/tools/all/${tool.id}`,
11296
+ children: tool.id
11297
+ }
11298
+ ) }),
11299
+ /* @__PURE__ */ jsx(EntityDescription, { children: tool.description }),
11300
+ /* @__PURE__ */ jsx("div", { className: "inline-flex flex-wrap gap-2 pt-4", children: tool.agents.map((agent) => {
11301
+ return /* @__PURE__ */ jsx(
11302
+ Link,
11303
+ {
11304
+ href: `/agents/${agent.id}/chat`,
11305
+ onClick: (e) => e.stopPropagation(),
11306
+ className: "group/link",
11307
+ children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(AgentIcon, { className: "group-hover/link:text-accent3" }), className: "bg-surface5 ", children: agent.name })
11308
+ },
11309
+ agent.id
11310
+ );
11311
+ }) })
11312
+ ] })
11313
+ ] });
11314
+ };
11315
+ const ToolListSkeleton = () => {
11316
+ return /* @__PURE__ */ jsxs("div", { children: [
11317
+ /* @__PURE__ */ jsx("div", { className: "max-w-5xl w-full mx-auto px-4 pt-8", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full" }) }),
11318
+ /* @__PURE__ */ jsxs("div", { className: "grid md:grid-cols-2 xl:grid-cols-3 gap-4 max-w-5xl mx-auto py-8", children: [
11319
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-40 w-full" }),
11320
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-40 w-full" }),
11321
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-40 w-full" })
11322
+ ] })
11323
+ ] });
11324
+ };
11325
+ const ToolListEmpty = () => {
11326
+ return /* @__PURE__ */ jsx(
11327
+ EmptyState,
11328
+ {
11329
+ iconSlot: /* @__PURE__ */ jsx(ToolCoinIcon, {}),
11330
+ titleSlot: "Configure Tools",
11331
+ descriptionSlot: "Mastra tools are not configured yet. You can find more information in the documentation.",
11332
+ actionSlot: /* @__PURE__ */ jsxs(
11333
+ Button,
11334
+ {
11335
+ size: "lg",
11336
+ className: "w-full",
11337
+ variant: "light",
11338
+ as: "a",
11339
+ href: "https://mastra.ai/en/docs/agents/using-tools-and-mcp",
11340
+ target: "_blank",
11341
+ children: [
11342
+ /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(ToolsIcon, {}) }),
11343
+ "Docs"
11344
+ ]
11345
+ }
11346
+ )
11347
+ }
11348
+ );
11349
+ };
11350
+ const prepareAgents = (tools, agents) => {
11351
+ const toolsWithAgents = /* @__PURE__ */ new Map();
11352
+ const agentsKeys = Object.keys(agents);
11353
+ for (const k of agentsKeys) {
11354
+ const agent = agents[k];
11355
+ const agentToolsDict = agent.tools;
11356
+ const agentToolsKeys = Object.keys(agentToolsDict);
11357
+ for (const key of agentToolsKeys) {
11358
+ const tool = agentToolsDict[key];
11359
+ if (!toolsWithAgents.has(tool.id)) {
11360
+ toolsWithAgents.set(tool.id, {
11361
+ ...tool,
11362
+ agents: []
11363
+ });
11364
+ }
11365
+ toolsWithAgents.get(tool.id).agents.push({ id: k, name: agent.name });
11366
+ }
11367
+ }
11368
+ for (const [_, tool] of Object.entries(tools)) {
11369
+ if (!toolsWithAgents.has(tool.id)) {
11370
+ toolsWithAgents.set(tool.id, {
11371
+ ...tool,
11372
+ agents: []
11373
+ });
11374
+ }
11375
+ }
11376
+ return Array.from(toolsWithAgents.values());
11377
+ };
11378
+
10992
11379
  function WorkflowTraces({ traces, error, runId, stepName }) {
10993
11380
  return /* @__PURE__ */ jsx(TraceProvider, { initialTraces: traces || [], children: /* @__PURE__ */ jsx(WorkflowTracesInner, { traces, error, runId, stepName }) });
10994
11381
  }
@@ -12492,6 +12879,115 @@ const WorkflowRuns = ({ workflowId, runId, isLoading, runs, onPressRun }) => {
12492
12879
  ) }, run.runId)) });
12493
12880
  };
12494
12881
 
12882
+ const columns = [
12883
+ {
12884
+ id: "name",
12885
+ header: "Name",
12886
+ cell: ({ row }) => {
12887
+ const { Link } = useLinkComponent();
12888
+ return /* @__PURE__ */ jsx(
12889
+ EntryCell,
12890
+ {
12891
+ icon: /* @__PURE__ */ jsx(WorkflowIcon, {}),
12892
+ name: /* @__PURE__ */ jsx(Link, { href: row.original.link, children: row.original.name }),
12893
+ description: void 0,
12894
+ meta: void 0
12895
+ }
12896
+ );
12897
+ },
12898
+ meta: {
12899
+ width: "auto"
12900
+ }
12901
+ },
12902
+ {
12903
+ id: "stepsCount",
12904
+ header: "Steps",
12905
+ size: 300,
12906
+ cell: ({ row }) => /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end items-center gap-2", children: [
12907
+ /* @__PURE__ */ jsxs(Badge$1, { icon: /* @__PURE__ */ jsx(Footprints, {}), className: "!h-button-md", children: [
12908
+ row.original.stepsCount,
12909
+ " step",
12910
+ row.original.stepsCount > 1 ? "s" : ""
12911
+ ] }),
12912
+ row.original.isLegacy ? /* @__PURE__ */ jsx(Badge$1, { className: "!text-foreground/80 !h-button-md", children: "Legacy" }) : null
12913
+ ] }) })
12914
+ }
12915
+ ];
12916
+
12917
+ function WorkflowTable({ workflows, legacyWorkflows, isLoading, onClickRow }) {
12918
+ const workflowData = useMemo(() => {
12919
+ const _workflowsData = Object.keys(workflows ?? {}).map((key) => {
12920
+ const workflow = workflows?.[key];
12921
+ return {
12922
+ id: key,
12923
+ name: workflow?.name || "N/A",
12924
+ stepsCount: Object.keys(workflow?.steps ?? {})?.length,
12925
+ isLegacy: false,
12926
+ link: `/workflows/${key}/graph`
12927
+ };
12928
+ });
12929
+ const legacyWorkflowsData = Object.keys(legacyWorkflows ?? {}).map((key) => {
12930
+ const workflow = legacyWorkflows?.[key];
12931
+ return {
12932
+ id: key,
12933
+ name: workflow?.name || "N/A",
12934
+ stepsCount: Object.keys(workflow?.steps ?? {})?.length,
12935
+ isLegacy: true,
12936
+ link: `/workflows/legacy/${key}/graph`
12937
+ };
12938
+ });
12939
+ return [..._workflowsData, ...legacyWorkflowsData];
12940
+ }, [workflows, legacyWorkflows]);
12941
+ const table = useReactTable({
12942
+ data: workflowData,
12943
+ columns,
12944
+ getCoreRowModel: getCoreRowModel()
12945
+ });
12946
+ if (isLoading) return /* @__PURE__ */ jsx(WorkflowTableSkeleton, {});
12947
+ const ths = table.getHeaderGroups()[0];
12948
+ const rows = table.getRowModel().rows.concat();
12949
+ if (rows.length === 0) {
12950
+ return /* @__PURE__ */ jsx(EmptyWorkflowsTable, {});
12951
+ }
12952
+ return /* @__PURE__ */ jsx(ScrollableContainer, { children: /* @__PURE__ */ jsxs(Table, { children: [
12953
+ /* @__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)) }),
12954
+ /* @__PURE__ */ jsx(Tbody, { children: rows.map((row) => /* @__PURE__ */ jsx(Row, { onClick: () => onClickRow(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)) })
12955
+ ] }) });
12956
+ }
12957
+ const WorkflowTableSkeleton = () => /* @__PURE__ */ jsxs(Table, { children: [
12958
+ /* @__PURE__ */ jsxs(Thead, { children: [
12959
+ /* @__PURE__ */ jsx(Th, { children: "Name" }),
12960
+ /* @__PURE__ */ jsx(Th, { width: 300, children: "Steps" })
12961
+ ] }),
12962
+ /* @__PURE__ */ jsx(Tbody, { children: Array.from({ length: 3 }).map((_, index) => /* @__PURE__ */ jsxs(Row, { children: [
12963
+ /* @__PURE__ */ jsx(Cell, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" }) }),
12964
+ /* @__PURE__ */ jsx(Cell, { width: 300, children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/2" }) })
12965
+ ] }, index)) })
12966
+ ] });
12967
+ const EmptyWorkflowsTable = () => /* @__PURE__ */ jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsx(
12968
+ EmptyState,
12969
+ {
12970
+ iconSlot: /* @__PURE__ */ jsx(WorkflowCoinIcon, {}),
12971
+ titleSlot: "Configure Workflows",
12972
+ descriptionSlot: "Mastra workflows are not configured yet. You can find more information in the documentation.",
12973
+ actionSlot: /* @__PURE__ */ jsxs(
12974
+ Button,
12975
+ {
12976
+ size: "lg",
12977
+ className: "w-full",
12978
+ variant: "light",
12979
+ as: "a",
12980
+ href: "https://mastra.ai/en/docs/workflows/overview",
12981
+ target: "_blank",
12982
+ children: [
12983
+ /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(WorkflowIcon, {}) }),
12984
+ "Docs"
12985
+ ]
12986
+ }
12987
+ )
12988
+ }
12989
+ ) });
12990
+
12495
12991
  const DataTable = ({
12496
12992
  columns,
12497
12993
  data,
@@ -12746,41 +13242,6 @@ const DarkLogo = (props) => /* @__PURE__ */ jsxs("svg", { width: "100", height:
12746
13242
  )
12747
13243
  ] });
12748
13244
 
12749
- const Entity = ({ children, className, onClick }) => {
12750
- return /* @__PURE__ */ jsx(
12751
- "div",
12752
- {
12753
- tabIndex: onClick ? 0 : void 0,
12754
- onKeyDown: (e) => {
12755
- if (!onClick) return;
12756
- if (e.key === "Enter" || e.key === " ") {
12757
- e.preventDefault();
12758
- onClick?.();
12759
- }
12760
- },
12761
- className: clsx(
12762
- "flex gap-3 group/entity bg-surface3 rounded-lg border-sm border-border1 py-3 px-4",
12763
- onClick && "cursor-pointer hover:bg-surface4 transition-all",
12764
- className
12765
- ),
12766
- onClick,
12767
- children
12768
- }
12769
- );
12770
- };
12771
- const EntityIcon = ({ children, className }) => {
12772
- return /* @__PURE__ */ jsx(Icon, { size: "lg", className: clsx("text-icon3 mt-1", className), children });
12773
- };
12774
- const EntityName = ({ children, className }) => {
12775
- return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-lg", className: clsx("text-icon6 font-medium", className), children });
12776
- };
12777
- const EntityDescription = ({ children, className }) => {
12778
- return /* @__PURE__ */ jsx(Txt, { as: "p", variant: "ui-sm", className: clsx("text-icon3", className), children });
12779
- };
12780
- const EntityContent = ({ children, className }) => {
12781
- return /* @__PURE__ */ jsx("div", { className, children });
12782
- };
12783
-
12784
13245
  function usePolling({
12785
13246
  fetchFn,
12786
13247
  interval = 3e3,
@@ -12888,5 +13349,5 @@ function usePolling({
12888
13349
  };
12889
13350
  }
12890
13351
 
12891
- export { AgentChat, AgentCoinIcon, AgentEvals, AgentIcon, AgentNetworkCoinIcon, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentTraces, AgentsTable, AgentsTableSkeleton, AiIcon, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button, Cell, CheckIcon, ChevronIcon, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DbIcon, DebugIcon, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyAgentsTable, EmptyState, Entity, EntityContent, EntityDescription, EntityIcon, EntityName, Entry, EntryCell, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, JudgeIcon, LatencyIcon, LegacyWorkflowGraph, LegacyWorkflowTrigger, LinkComponentProvider, LogsIcon, MainContentContent, MainContentLayout, MastraClientProvider, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, NetworkChat, NetworkContext, NetworkProvider, OpenAIIcon, PromptIcon, RadioGroup, RadioGroupItem, RepoIcon, Row, ScoreIcon, SettingsIcon, SlashIcon, Table, Tbody, Th, Thead, ThreadDeleteButton, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolsIcon, TraceIcon, TsIcon, Txt, TxtCell, UnitCell, VNextNetworkChat, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunProvider, WorkflowRuns, WorkflowTraces, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, useAgentSettings, useCurrentRun, useLinkComponent, useMastraClient, usePlaygroundStore, usePolling, useSpeechRecognition, useWorkingMemory };
13352
+ export { AgentChat, AgentCoinIcon, AgentEvals, AgentIcon, AgentNetworkCoinIcon, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentTraces, AgentsTable, AgentsTableSkeleton, AiIcon, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button, Cell, CheckIcon, ChevronIcon, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DbIcon, DebugIcon, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyAgentsTable, EmptyState, EmptyWorkflowsTable, Entity, EntityContent, EntityDescription, EntityIcon, EntityName, Entry, EntryCell, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, JudgeIcon, LatencyIcon, LegacyWorkflowGraph, LegacyWorkflowTrigger, LinkComponentProvider, LogsIcon, MainContentContent, MainContentLayout, MastraClientProvider, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, NetworkChat, NetworkContext, NetworkProvider, NetworkTable, NetworkTableEmpty, NetworkTableSkeleton, OpenAIIcon, PromptIcon, RadioGroup, RadioGroupItem, RepoIcon, Row, RuntimeContext, RuntimeContextWrapper, ScoreIcon, SettingsIcon, SlashIcon, Table, Tbody, Th, Thead, ThreadDeleteButton, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolList, ToolListEmpty, ToolListSkeleton, ToolsIcon, TraceIcon, TsIcon, Txt, TxtCell, UnitCell, VNextNetworkChat, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunProvider, WorkflowRuns, WorkflowTable, WorkflowTableSkeleton, WorkflowTraces, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, useAgentSettings, useCurrentRun, useLinkComponent, useMastraClient, usePlaygroundStore, usePolling, useSpeechRecognition, useWorkingMemory };
12892
13353
  //# sourceMappingURL=index.es.js.map