@mastra/playground-ui 7.0.0-beta.13 → 7.0.0-beta.14

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
@@ -9329,18 +9329,17 @@ const columns$4 = [
9329
9329
  }
9330
9330
  ];
9331
9331
 
9332
- const themeClasses = {
9333
- light: "bg-gray-100 border-gray-300 text-gray-700",
9334
- dark: "bg-surface4 border-border1 text-icon6"
9335
- };
9336
- const Kbd = ({ children, theme = "dark" }) => {
9337
- const themeClass = themeClasses[theme];
9338
- return /* @__PURE__ */ jsx("kbd", { className: clsx("border-sm rounded-md px-1 py-0.5 font-mono", themeClass), children });
9339
- };
9340
-
9341
- const Searchbar = ({ onSearch, label, placeholder }) => {
9332
+ const Searchbar = ({ onSearch, label, placeholder, debounceMs = 300 }) => {
9342
9333
  const id = useId();
9343
9334
  const inputRef = useRef(null);
9335
+ const debouncedSearch = useDebouncedCallback((value) => {
9336
+ onSearch(value);
9337
+ }, debounceMs);
9338
+ useEffect(() => {
9339
+ return () => {
9340
+ debouncedSearch.cancel();
9341
+ };
9342
+ }, [debouncedSearch]);
9344
9343
  useEffect(() => {
9345
9344
  const input = inputRef.current;
9346
9345
  if (!input) return;
@@ -9355,37 +9354,27 @@ const Searchbar = ({ onSearch, label, placeholder }) => {
9355
9354
  window.removeEventListener("keydown", handleKeyDown);
9356
9355
  };
9357
9356
  }, []);
9358
- const handleSubmit = (e) => {
9359
- e.preventDefault();
9360
- const formData = new FormData(e.target);
9361
- const search = formData.get(id);
9362
- onSearch(search);
9357
+ const handleChange = (e) => {
9358
+ debouncedSearch(e.target.value);
9363
9359
  };
9364
- return /* @__PURE__ */ jsxs(
9365
- "form",
9366
- {
9367
- onSubmit: handleSubmit,
9368
- className: "focus-within:outline focus-within:outline-accent1 -outline-offset-2 border-sm border-icon-3 flex h-8 w-full items-center gap-2 overflow-hidden rounded-lg pl-2 pr-1",
9369
- children: [
9370
- /* @__PURE__ */ jsx(SearchIcon, { className: "text-icon3 h-4 w-4" }),
9371
- /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
9372
- /* @__PURE__ */ jsx("label", { htmlFor: id, className: "sr-only", children: label }),
9373
- /* @__PURE__ */ jsx(
9374
- "input",
9375
- {
9376
- id,
9377
- type: "text",
9378
- placeholder,
9379
- className: "bg-surface2 text-ui-md placeholder:text-icon-3 block h-8 w-full px-2 outline-none",
9380
- name: id,
9381
- ref: inputRef
9382
- }
9383
- )
9384
- ] }),
9385
- /* @__PURE__ */ jsx("button", { type: "submit", className: "text-ui-sm text-icon3 flex flex-row items-center gap-1", children: /* @__PURE__ */ jsx(Kbd, { children: "↵ Enter" }) })
9386
- ]
9387
- }
9388
- );
9360
+ return /* @__PURE__ */ jsxs("div", { className: "focus-within:outline focus-within:outline-accent1 -outline-offset-2 border-sm border-icon-3 flex h-8 w-full items-center gap-2 overflow-hidden rounded-lg pl-2 pr-1", children: [
9361
+ /* @__PURE__ */ jsx(SearchIcon, { className: "text-icon3 h-4 w-4" }),
9362
+ /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
9363
+ /* @__PURE__ */ jsx("label", { htmlFor: id, className: "sr-only", children: label }),
9364
+ /* @__PURE__ */ jsx(
9365
+ "input",
9366
+ {
9367
+ id,
9368
+ type: "text",
9369
+ placeholder,
9370
+ className: "bg-surface2 text-ui-md placeholder:text-icon-3 block h-8 w-full px-2 outline-none",
9371
+ name: id,
9372
+ ref: inputRef,
9373
+ onChange: handleChange
9374
+ }
9375
+ )
9376
+ ] })
9377
+ ] });
9389
9378
  };
9390
9379
  const SearchbarWrapper = ({ children }) => {
9391
9380
  return /* @__PURE__ */ jsx("div", { className: "px-4 py-2 border-b-sm border-border1", children });
@@ -11984,12 +11973,12 @@ function MastraRuntimeProvider({
11984
11973
  requireToolApproval
11985
11974
  };
11986
11975
  const baseClient = useMastraClient();
11987
- const isVNext = modelVersion === "v2";
11976
+ const isSupportedModel = modelVersion === "v2" || modelVersion === "v3";
11988
11977
  const onNew = async (message) => {
11989
11978
  if (message.content[0]?.type !== "text") throw new Error("Only text messages are supported");
11990
11979
  const attachments = await convertToAIAttachments(message.attachments);
11991
11980
  const input = message.content[0].text;
11992
- if (!isVNext) {
11981
+ if (!isSupportedModel) {
11993
11982
  setLegacyMessages((s) => [...s, { role: "user", content: input, attachments: message.attachments }]);
11994
11983
  }
11995
11984
  const controller = new AbortController();
@@ -12000,7 +11989,7 @@ function MastraRuntimeProvider({
12000
11989
  });
12001
11990
  const agent = clientWithAbort.getAgent(agentId);
12002
11991
  try {
12003
- if (isVNext) {
11992
+ if (isSupportedModel) {
12004
11993
  if (chatWithNetwork) {
12005
11994
  await sendMessage({
12006
11995
  message: input,
@@ -12343,7 +12332,7 @@ function MastraRuntimeProvider({
12343
12332
  if (error.name === "AbortError") {
12344
12333
  return;
12345
12334
  }
12346
- if (isVNext) {
12335
+ if (isSupportedModel) {
12347
12336
  setMessages((currentConversation) => [
12348
12337
  ...currentConversation,
12349
12338
  { role: "assistant", parts: [{ type: "text", text: `${error}` }] }
@@ -12370,7 +12359,7 @@ function MastraRuntimeProvider({
12370
12359
  const vnextmessages = messages.map(toAssistantUIMessage);
12371
12360
  const runtime = useExternalStoreRuntime({
12372
12361
  isRunning: isLegacyRunning || isRunningStream,
12373
- messages: isVNext ? vnextmessages : legacyMessages,
12362
+ messages: isSupportedModel ? vnextmessages : legacyMessages,
12374
12363
  convertMessage: (x) => x,
12375
12364
  onNew,
12376
12365
  onCancel,
@@ -12820,8 +12809,9 @@ const AgentSettings = ({ agentId }) => {
12820
12809
  const hasMemory = Boolean(memory?.result);
12821
12810
  const hasSubAgents = Boolean(Object.keys(agent.agents || {}).length > 0);
12822
12811
  const modelVersion = agent.modelVersion;
12812
+ const isSupportedModel = modelVersion === "v2" || modelVersion === "v3";
12823
12813
  let radioValue;
12824
- if (modelVersion === "v2") {
12814
+ if (isSupportedModel) {
12825
12815
  if (settings?.modelSettings?.chatWithNetwork) {
12826
12816
  radioValue = "network";
12827
12817
  } else {
@@ -12848,23 +12838,23 @@ const AgentSettings = ({ agentId }) => {
12848
12838
  }),
12849
12839
  className: "flex flex-row gap-4",
12850
12840
  children: [
12851
- modelVersion !== "v2" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12841
+ !isSupportedModel && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12852
12842
  /* @__PURE__ */ jsx(RadioGroupItem, { value: "generateLegacy", id: "generateLegacy", className: "text-icon6" }),
12853
12843
  /* @__PURE__ */ jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "generateLegacy", children: "Generate (Legacy)" })
12854
12844
  ] }),
12855
- modelVersion === "v2" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12845
+ isSupportedModel && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12856
12846
  /* @__PURE__ */ jsx(RadioGroupItem, { value: "generate", id: "generate", className: "text-icon6" }),
12857
12847
  /* @__PURE__ */ jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "generate", children: "Generate" })
12858
12848
  ] }),
12859
- modelVersion !== "v2" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12849
+ !isSupportedModel && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12860
12850
  /* @__PURE__ */ jsx(RadioGroupItem, { value: "streamLegacy", id: "streamLegacy", className: "text-icon6" }),
12861
12851
  /* @__PURE__ */ jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "streamLegacy", children: "Stream (Legacy)" })
12862
12852
  ] }),
12863
- modelVersion === "v2" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12853
+ isSupportedModel && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12864
12854
  /* @__PURE__ */ jsx(RadioGroupItem, { value: "stream", id: "stream", className: "text-icon6" }),
12865
12855
  /* @__PURE__ */ jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "stream", children: "Stream" })
12866
12856
  ] }),
12867
- modelVersion === "v2" && /* @__PURE__ */ jsx(NetworkCheckbox, { hasMemory, hasSubAgents })
12857
+ isSupportedModel && /* @__PURE__ */ jsx(NetworkCheckbox, { hasMemory, hasSubAgents })
12868
12858
  ]
12869
12859
  }
12870
12860
  ) }),
@@ -15939,7 +15929,7 @@ const AgentMetadata = ({ agentId }) => {
15939
15929
  AgentMetadataSection,
15940
15930
  {
15941
15931
  title: "Model",
15942
- hint: agent.modelVersion === "v2" ? void 0 : {
15932
+ hint: agent.modelVersion === "v2" || agent.modelVersion === "v3" ? void 0 : {
15943
15933
  link: "https://mastra.ai/guides/migrations/vnext-to-standard-apis",
15944
15934
  title: "You are using a legacy v1 model",
15945
15935
  icon: /* @__PURE__ */ jsx(AlertTriangleIcon, { fontSize: 14, className: "mb-0.5" })
@@ -20086,6 +20076,15 @@ const PlaygroundQueryClient = ({ children, options }) => {
20086
20076
  return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children });
20087
20077
  };
20088
20078
 
20079
+ const themeClasses = {
20080
+ light: "bg-gray-100 border-gray-300 text-gray-700",
20081
+ dark: "bg-surface4 border-border1 text-icon6"
20082
+ };
20083
+ const Kbd = ({ children, theme = "dark" }) => {
20084
+ const themeClass = themeClasses[theme];
20085
+ return /* @__PURE__ */ jsx("kbd", { className: clsx("border-sm rounded-md px-1 py-0.5 font-mono", themeClass), children });
20086
+ };
20087
+
20089
20088
  const errorFallback = "Something went wrong while fetching the data.";
20090
20089
  const parseError = (error) => {
20091
20090
  try {