@mastra/playground-ui 16.1.2 → 16.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useAssistantState, useAuiState, useMessage, MessagePrimitive, ActionBarPrimitive, useComposerRuntime, useAttachment, ComposerPrimitive, AttachmentPrimitive, useComposer, ThreadPrimitive, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechSynthesisAdapter, useExternalStoreRuntime, AssistantRuntimeProvider } from '@assistant-ui/react';
3
- import { CheckIcon as CheckIcon$1, CopyIcon, ShieldAlert, ChevronDown, ChevronRight, RefreshCw, Tag, Wand2, InfoIcon as InfoIcon$1, AlertCircle, TriangleAlert, ChevronUpIcon, CheckCircleIcon, X, CircleCheck, CircleX, CircleAlert, Info, Share2, Check, TerminalSquare, FolderTree, HardDrive, Clock as Clock$1, PlayCircle, Workflow, Layers, List, CalendarClock, Timer, CornerDownRight, GitBranch, Repeat, Repeat1, Network, TriangleAlertIcon, CalendarIcon, CircleAlertIcon, Braces, ChevronDownIcon, Brackets, PlusIcon, TrashIcon, Plus, Loader2, Circle, EyeOffIcon, EyeIcon, PauseIcon, HourglassIcon, CircleDashed, Footprints, Minus, Maximize, AlertCircleIcon, StopCircle, CirclePause, ShieldX, SearchIcon, Cpu, ChevronsUpDown, Search, ArrowRight, ArrowLeft, Brain, Unplug, XCircle, CloudCog, BrainIcon, AudioLinesIcon, StopCircleIcon, FileText, DatabaseIcon, Save, CircleXIcon, Link, CloudUpload, Mic, ArrowUp, SaveIcon, Database, Code2, Type, ToggleLeft, Hash, Ban, ListX, ChevronsLeft, ChevronsRight, ChevronLeft, Text, TextSearch, EqualNot, Equal, Component, Trash2, Ruler, Trash, ExternalLink, MoveRight, Copy, BookOpen, ArrowLeftIcon, ArrowRightIcon, ChevronsRightIcon, AlignLeftIcon, AlignJustifyIcon, ArrowUpIcon, ArrowDownIcon, ChevronRightIcon, CalculatorIcon, GaugeIcon, ChevronsLeftRightEllipsisIcon, HashIcon, FileInputIcon, FileOutputIcon, ReceiptText, XIcon, RotateCcw, GripVertical, Folder, CopyPlus, RefreshCcwIcon, AlignLeft, Trash2Icon, FileTextIcon, PenLine, Plug, LaptopMinimal, File as File$1, FolderOpen, Image, FileJson, FileCode, FolderPlus, Drill, Pencil, Eye, Wrench, Play, CheckCircle, MessageSquare, FormInput, FlaskConical, CircleChevronUpIcon, CircleChevronDownIcon, FileIcon, ChevronsUpIcon, ChevronsDownIcon, TimerIcon, ChevronsLeftRightIcon, ChevronFirstIcon, ChevronLastIcon, ArrowRightToLineIcon, CoinsIcon, AlertTriangleIcon, BracesIcon, CircleGaugeIcon, PanelTopIcon, CircleDashedIcon, ListTreeIcon, PanelLeftIcon, CheckCircle2, NetworkIcon, WorkflowIcon as WorkflowIcon$1, PackageIcon, GitBranchIcon, PackageOpenIcon, OctagonXIcon, FrownIcon, ClockIcon, BanIcon, Upload, MoveRightIcon, History, AmpersandIcon, GitCompareIcon, Download, FolderOutput, ChevronLeftIcon, EllipsisVerticalIcon, FileCodeIcon, Calendar1Icon, HistoryIcon, TagIcon, GitCompare, MoreVertical, AlertTriangle, PanelRightIcon, PlayIcon, OctagonAlertIcon, CrosshairIcon, TargetIcon, LayersIcon, EqualIcon, PenIcon, KeyboardIcon, CircleSlash, Cloud, Zap, Sparkles, FileCode2, Code, Server, Home, Package, Github } from 'lucide-react';
3
+ import { CheckIcon as CheckIcon$1, CopyIcon, ShieldAlert, ChevronDown, ChevronRight, RefreshCw, Tag, Wand2, InfoIcon as InfoIcon$1, AlertCircle, TriangleAlert, ChevronUpIcon, CheckCircleIcon, X, CircleCheck, CircleX, CircleAlert, Info, Share2, Check, TerminalSquare, FolderTree, HardDrive, Clock as Clock$1, PlayCircle, Workflow, Layers, List, CalendarClock, Timer, CornerDownRight, GitBranch, Repeat, Repeat1, Network, TriangleAlertIcon, CalendarIcon, CircleAlertIcon, Braces, ChevronDownIcon, Brackets, PlusIcon, TrashIcon, Plus, Loader2, Circle, EyeOffIcon, EyeIcon, PauseIcon, HourglassIcon, CircleDashed, Footprints, Minus, Maximize, AlertCircleIcon, StopCircle, CirclePause, ShieldX, SearchIcon, Cpu, ChevronsUpDown, Search, ArrowRight, ArrowLeft, Brain, Unplug, XCircle, CloudCog, BrainIcon, AudioLinesIcon, StopCircleIcon, FileText, DatabaseIcon, Save, CircleXIcon, Link, CloudUpload, Mic, ArrowUp, SaveIcon, Database, Code2, Type, ToggleLeft, Hash, Ban, ListX, ChevronsLeft, ChevronsRight, ChevronLeft, Text, TextSearch, EqualNot, Equal, Component, Trash2, Ruler, Trash, ExternalLink, MoveRight, Copy, BookOpen, ArrowLeftIcon, ArrowRightIcon, ChevronsRightIcon, AlignLeftIcon, AlignJustifyIcon, ArrowUpIcon, ArrowDownIcon, ChevronRightIcon, CalculatorIcon, GaugeIcon, ChevronsLeftRightEllipsisIcon, HashIcon, FileInputIcon, FileOutputIcon, ReceiptText, XIcon, RotateCcw, GripVertical, Folder, Pencil, CopyPlus, Link2, RefreshCcwIcon, AlignLeft, Trash2Icon, FileTextIcon, PenLine, Plug, LaptopMinimal, File as File$1, FolderOpen, Image, FileJson, FileCode, FolderPlus, Drill, Eye, Wrench, Play, CheckCircle, MessageSquare, FormInput, FlaskConical, CircleChevronUpIcon, CircleChevronDownIcon, FileIcon, ChevronsUpIcon, ChevronsDownIcon, TimerIcon, ChevronsLeftRightIcon, ChevronFirstIcon, ChevronLastIcon, ArrowRightToLineIcon, CoinsIcon, AlertTriangleIcon, BracesIcon, CircleGaugeIcon, PanelTopIcon, CircleDashedIcon, ListTreeIcon, PanelLeftIcon, CheckCircle2, NetworkIcon, WorkflowIcon as WorkflowIcon$1, PackageIcon, GitBranchIcon, PackageOpenIcon, OctagonXIcon, FrownIcon, ClockIcon, BanIcon, Upload, MoveRightIcon, History, AmpersandIcon, GitCompareIcon, Download, FolderOutput, ChevronLeftIcon, EllipsisVerticalIcon, FileCodeIcon, Calendar1Icon, HistoryIcon, TagIcon, GitCompare, MoreVertical, AlertTriangle, PanelRightIcon, PlayIcon, OctagonAlertIcon, CrosshairIcon, TargetIcon, LayersIcon, EqualIcon, PenIcon, KeyboardIcon, CircleSlash, Cloud, Zap, Sparkles, FileCode2, Code, Server, Home, Package, Github } from 'lucide-react';
4
4
  import * as React from 'react';
5
5
  import React__default, { useState, memo, useEffect, useRef, useCallback, forwardRef, useMemo, createContext, useContext, Fragment as Fragment$1, useId, Suspense, useEffectEvent, useLayoutEffect } from 'react';
6
6
  import { S as Shadows, G as Glows, B as BorderColors, C as Colors, a as Sizes, F as FontSizes, L as LineHeights, b as BorderRadius, c as Spacings } from './spacings-Be0ECz0K.js';
@@ -15438,7 +15438,7 @@ function getStateColor(state) {
15438
15438
  }
15439
15439
  }
15440
15440
 
15441
- const Thread = ({ agentName, agentId, hasMemory, hasModelList }) => {
15441
+ const Thread = ({ agentName, agentId, hasMemory, hasModelList, hideModelSwitcher }) => {
15442
15442
  const areaRef = useRef(null);
15443
15443
  const messagesContainerRef = useRef(null);
15444
15444
  useAutoscroll(areaRef, { enabled: true });
@@ -15466,7 +15466,15 @@ const Thread = ({ agentName, agentId, hasMemory, hasModelList }) => {
15466
15466
  /* @__PURE__ */ jsx("div", {})
15467
15467
  ] })
15468
15468
  ] }),
15469
- /* @__PURE__ */ jsx(Composer, { hasMemory, agentId, hasModelList })
15469
+ /* @__PURE__ */ jsx(
15470
+ Composer,
15471
+ {
15472
+ hasMemory,
15473
+ agentId,
15474
+ hasModelList,
15475
+ hideModelSwitcher
15476
+ }
15477
+ )
15470
15478
  ] });
15471
15479
  };
15472
15480
  const ThreadWrapper = ({ children }) => {
@@ -15478,7 +15486,7 @@ const ThreadWelcome = ({ agentName }) => {
15478
15486
  /* @__PURE__ */ jsx("p", { className: "mt-4 font-medium", children: "How can I help you today?" })
15479
15487
  ] }) });
15480
15488
  };
15481
- const Composer = ({ hasMemory, agentId, hasModelList }) => {
15489
+ const Composer = ({ hasMemory, agentId, hasModelList, hideModelSwitcher }) => {
15482
15490
  const { setThreadInput } = useThreadInput();
15483
15491
  const textareaRef = useRef(null);
15484
15492
  const { canExecute } = usePermissions();
@@ -15490,7 +15498,7 @@ const Composer = ({ hasMemory, agentId, hasModelList }) => {
15490
15498
  "textarea",
15491
15499
  {
15492
15500
  ref: textareaRef,
15493
- autoFocus: document.activeElement === document.body,
15501
+ autoFocus: false,
15494
15502
  className: "text-ui-lg leading-ui-lg placeholder:text-neutral3 text-neutral6 bg-transparent focus:outline-none resize-none outline-none disabled:cursor-not-allowed disabled:opacity-50",
15495
15503
  placeholder: canExecuteAgent ? "Enter your message..." : "You don't have permission to execute agents",
15496
15504
  name: "",
@@ -15500,7 +15508,7 @@ const Composer = ({ hasMemory, agentId, hasModelList }) => {
15500
15508
  }
15501
15509
  ) }),
15502
15510
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
15503
- agentId && !hasModelList && /* @__PURE__ */ jsx(ComposerModelSwitcher, { agentId }),
15511
+ agentId && !hasModelList && !hideModelSwitcher && /* @__PURE__ */ jsx(ComposerModelSwitcher, { agentId }),
15504
15512
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 ml-auto", children: [
15505
15513
  canExecuteAgent && /* @__PURE__ */ jsx(SpeechInput, { agentId }),
15506
15514
  /* @__PURE__ */ jsx(ComposerAction, { canExecute: canExecuteAgent })
@@ -17105,7 +17113,8 @@ const AgentChat = ({
17105
17113
  modelVersion,
17106
17114
  modelList,
17107
17115
  messageId,
17108
- isNewThread
17116
+ isNewThread,
17117
+ hideModelSwitcher
17109
17118
  }) => {
17110
17119
  const { settings } = useAgentSettings();
17111
17120
  const requestContext = useMergedRequestContext();
@@ -17146,7 +17155,16 @@ const AgentChat = ({
17146
17155
  refreshThreadList,
17147
17156
  settings,
17148
17157
  requestContext,
17149
- children: /* @__PURE__ */ jsx(Thread, { agentName: agentName ?? "", hasMemory: memory, agentId, hasModelList: Boolean(modelList) })
17158
+ children: /* @__PURE__ */ jsx(
17159
+ Thread,
17160
+ {
17161
+ agentName: agentName ?? "",
17162
+ hasMemory: memory,
17163
+ agentId,
17164
+ hasModelList: Boolean(modelList),
17165
+ hideModelSwitcher
17166
+ }
17167
+ )
17150
17168
  }
17151
17169
  );
17152
17170
  };
@@ -21952,6 +21970,11 @@ function AuthRequired({ children, loginUrl = "/login", signupUrl = "/signup" })
21952
21970
  const AgentEntityHeader = ({ agentId }) => {
21953
21971
  const { data: agent, isLoading } = useAgent(agentId);
21954
21972
  const { handleCopy } = useCopyToClipboard({ text: agentId });
21973
+ const sessionUrl = `${window.location.origin}/agents/${agentId}/session`;
21974
+ const { handleCopy: handleShareLink, isCopied: isShareCopied } = useCopyToClipboard({
21975
+ text: sessionUrl,
21976
+ copyMessage: "Session URL copied to clipboard!"
21977
+ });
21955
21978
  const { isCmsAvailable } = useIsCmsAvailable();
21956
21979
  const { navigate } = useLinkComponent();
21957
21980
  const { cloneAgent, isCloning } = useCloneAgent();
@@ -21966,22 +21989,30 @@ const AgentEntityHeader = ({ agentId }) => {
21966
21989
  navigate(`/agents/${clonedAgent.id}/chat`);
21967
21990
  }
21968
21991
  };
21969
- return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(
21992
+ return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(
21970
21993
  EntityHeader,
21971
21994
  {
21972
21995
  icon: isCmsAvailable ? /* @__PURE__ */ jsx(AgentSourceIcon, { source: agent?.source }) : /* @__PURE__ */ jsx(AgentIcon, {}),
21973
21996
  title: agentName,
21974
21997
  isLoading,
21975
- children: [
21998
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-3", children: [
21976
21999
  /* @__PURE__ */ jsxs(Tooltip, { children: [
21977
22000
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { onClick: handleCopy, className: "h-badge-default shrink-0", children: /* @__PURE__ */ jsx(Badge, { icon: /* @__PURE__ */ jsx(CopyIcon, {}), variant: "default", children: showStoredAgentBadge ? /* @__PURE__ */ jsx(Truncate, { untilChar: "-", withTooltip: false, children: agentId }) : agentId }) }) }),
21978
22001
  /* @__PURE__ */ jsx(TooltipContent, { children: "Copy Agent ID for use in code" })
21979
22002
  ] }),
21980
22003
  canWriteAgents && /* @__PURE__ */ jsxs(Tooltip, { children: [
21981
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { onClick: handleClone, disabled: isCloning, className: "h-badge-default shrink-0 ml-2", children: /* @__PURE__ */ jsx(Badge, { icon: /* @__PURE__ */ jsx(CopyPlus, {}), variant: "default", children: isCloning ? "Cloning..." : "Clone" }) }) }),
22004
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { onClick: () => navigate(`/cms/agents/${agentId}/edit`), className: "h-badge-default shrink-0", children: /* @__PURE__ */ jsx(Badge, { icon: /* @__PURE__ */ jsx(Pencil, {}), variant: "default", children: "Edit" }) }) }),
22005
+ /* @__PURE__ */ jsx(TooltipContent, { children: isStoredAgent ? "Edit agent configuration" : "Edit agent overrides" })
22006
+ ] }),
22007
+ canWriteAgents && /* @__PURE__ */ jsxs(Tooltip, { children: [
22008
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { onClick: handleClone, disabled: isCloning, className: "h-badge-default shrink-0", children: /* @__PURE__ */ jsx(Badge, { icon: /* @__PURE__ */ jsx(CopyPlus, {}), variant: "default", children: isCloning ? "Cloning..." : "Clone" }) }) }),
21982
22009
  /* @__PURE__ */ jsx(TooltipContent, { children: "Clone agent to a new stored agent" })
22010
+ ] }),
22011
+ /* @__PURE__ */ jsxs(Tooltip, { children: [
22012
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { onClick: handleShareLink, className: "h-badge-default shrink-0", children: /* @__PURE__ */ jsx(Badge, { icon: isShareCopied ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Link2, {}), variant: "default", children: "Share" }) }) }),
22013
+ /* @__PURE__ */ jsx(TooltipContent, { children: "Copy session URL to share with your team" })
21983
22014
  ] })
21984
- ]
22015
+ ] })
21985
22016
  }
21986
22017
  ) });
21987
22018
  };
@@ -36299,8 +36330,9 @@ function TemplateSuccess({ name, installedEntities, linkComponent }) {
36299
36330
  }
36300
36331
 
36301
36332
  function TemplateFailure({ errorMsg, validationErrors }) {
36302
- const isSchemaError = errorMsg?.includes("Invalid schema for function");
36303
- const isValidationError = errorMsg?.includes("validation issue") || validationErrors && validationErrors.length > 0;
36333
+ const errorString = typeof errorMsg === "string" ? errorMsg : errorMsg != null ? String(errorMsg) : void 0;
36334
+ const isSchemaError = errorString?.includes("Invalid schema for function");
36335
+ const isValidationError = errorString?.includes("validation issue") || validationErrors && validationErrors.length > 0;
36304
36336
  const getUserFriendlyMessage = () => {
36305
36337
  if (isValidationError) {
36306
36338
  return "Template installation completed but some validation issues remain. The template may still be functional, but you should review and fix these issues.";
@@ -36342,9 +36374,9 @@ function TemplateFailure({ errorMsg, validationErrors }) {
36342
36374
  /* @__PURE__ */ jsx("div", { className: "text-xs font-mono text-gray-700 dark:text-gray-300 mt-1 whitespace-pre-wrap break-words", children: error.message })
36343
36375
  ] }, index)) })
36344
36376
  ] }),
36345
- errorMsg && !isValidationError && /* @__PURE__ */ jsxs("details", { className: "text-xs", children: [
36377
+ errorString && !isValidationError && /* @__PURE__ */ jsxs("details", { className: "text-xs", children: [
36346
36378
  /* @__PURE__ */ jsx("summary", { className: "cursor-pointer text-neutral3 hover:text-neutral4 select-none text-center", children: "Show Details" }),
36347
- /* @__PURE__ */ jsx("div", { className: "mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs font-mono overflow-auto max-h-60 text-left", children: /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap break-words", children: errorMsg }) })
36379
+ /* @__PURE__ */ jsx("div", { className: "mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs font-mono overflow-auto max-h-60 text-left", children: /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap break-words", children: errorString }) })
36348
36380
  ] })
36349
36381
  ] });
36350
36382
  }