@cognizant-ai-lab/ui-common 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +3 -3
  2. package/dist/Theme/Palettes.d.ts +0 -9
  3. package/dist/Theme/Palettes.js +0 -18
  4. package/dist/components/AgentChat/ChatCommon/ChatCommon.d.ts +13 -4
  5. package/dist/components/AgentChat/ChatCommon/ChatCommon.js +131 -38
  6. package/dist/components/AgentChat/ChatCommon/ChatHistory.d.ts +7 -0
  7. package/dist/components/AgentChat/ChatCommon/ChatHistory.js +1 -1
  8. package/dist/components/AgentChat/ChatCommon/Const.d.ts +1 -0
  9. package/dist/components/AgentChat/ChatCommon/Const.js +2 -0
  10. package/dist/components/AgentChat/ChatCommon/ControlButtons.d.ts +5 -3
  11. package/dist/components/AgentChat/ChatCommon/ControlButtons.js +13 -4
  12. package/dist/components/AgentChat/ChatCommon/ConversationTurn.d.ts +5 -5
  13. package/dist/components/AgentChat/ChatCommon/ConversationTurn.js +1 -0
  14. package/dist/components/AgentChat/ChatCommon/FormattedMarkdown.js +3 -0
  15. package/dist/components/AgentChat/ChatCommon/SendButton.js +7 -6
  16. package/dist/components/AgentChat/ChatCommon/SyntaxHighlighterThemes.js +1 -1
  17. package/dist/components/AgentChat/ChatCommon/Thinking.d.ts +1 -0
  18. package/dist/components/AgentChat/ChatCommon/Thinking.js +10 -7
  19. package/dist/components/AgentChat/Common/LlmChatButton.d.ts +0 -2
  20. package/dist/components/AgentChat/Common/LlmChatButton.js +6 -9
  21. package/dist/components/AgentChat/Common/Utils.d.ts +4 -0
  22. package/dist/components/AgentChat/Common/Utils.js +5 -1
  23. package/dist/components/AgentChat/VoiceChat/MicrophoneButton.js +12 -10
  24. package/dist/components/Common/Breadcrumbs.js +1 -1
  25. package/dist/components/Common/Navbar.js +24 -22
  26. package/dist/components/Common/StatusLight.d.ts +9 -0
  27. package/dist/components/Common/StatusLight.js +21 -0
  28. package/dist/components/Common/notification.d.ts +4 -4
  29. package/dist/components/ErrorPage/ErrorBoundary.js +1 -1
  30. package/dist/components/ErrorPage/ErrorPage.d.ts +3 -3
  31. package/dist/components/ErrorPage/ErrorPage.js +4 -3
  32. package/dist/components/Logo/Common.d.ts +4 -0
  33. package/dist/components/Logo/Common.js +8 -0
  34. package/dist/components/Logo/CustomerLogo.d.ts +23 -0
  35. package/dist/components/Logo/CustomerLogo.js +41 -0
  36. package/dist/components/MultiAgentAccelerator/AgentConversations.js +0 -1
  37. package/dist/components/MultiAgentAccelerator/{AgentFlow.d.ts → AgentFlow/AgentFlow.d.ts} +15 -5
  38. package/dist/components/MultiAgentAccelerator/{AgentFlow.js → AgentFlow/AgentFlow.js} +125 -84
  39. package/dist/components/MultiAgentAccelerator/{AgentNode.d.ts → AgentFlow/AgentNode.d.ts} +1 -1
  40. package/dist/components/MultiAgentAccelerator/{AgentNode.js → AgentFlow/AgentNode.js} +26 -30
  41. package/dist/components/MultiAgentAccelerator/AgentFlow/GraphLayouts.d.ts +43 -0
  42. package/dist/components/MultiAgentAccelerator/{GraphLayouts.js → AgentFlow/GraphLayouts.js} +10 -41
  43. package/dist/components/MultiAgentAccelerator/AgentFlow/GraphStructure.d.ts +21 -0
  44. package/dist/components/MultiAgentAccelerator/AgentFlow/GraphStructure.js +27 -0
  45. package/dist/components/MultiAgentAccelerator/AgentFlow/PlasmaEdge.d.ts +7 -0
  46. package/dist/components/MultiAgentAccelerator/{PlasmaEdge.js → AgentFlow/PlasmaEdge.js} +13 -8
  47. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.d.ts +3 -9
  48. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +137 -103
  49. package/dist/components/MultiAgentAccelerator/Schema/SlyData.d.ts +17 -0
  50. package/dist/components/MultiAgentAccelerator/Schema/SlyData.js +23 -0
  51. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.d.ts +0 -5
  52. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +38 -28
  53. package/dist/components/MultiAgentAccelerator/Sidebar/ImportNetworkModal.d.ts +67 -0
  54. package/dist/components/MultiAgentAccelerator/Sidebar/ImportNetworkModal.js +585 -0
  55. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +5 -4
  56. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +77 -168
  57. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +31 -13
  58. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +177 -100
  59. package/dist/components/MultiAgentAccelerator/TemporaryNetworks.d.ts +22 -0
  60. package/dist/components/MultiAgentAccelerator/TemporaryNetworks.js +74 -3
  61. package/dist/components/MultiAgentAccelerator/{ThoughtBubbleEdge.d.ts → ThoughtBubbles/ThoughtBubbleEdge.d.ts} +1 -1
  62. package/dist/components/MultiAgentAccelerator/{ThoughtBubbleOverlay.js → ThoughtBubbles/ThoughtBubbleOverlay.js} +1 -1
  63. package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.js +15 -8
  64. package/dist/components/MultiAgentAccelerator/const.d.ts +3 -0
  65. package/dist/components/MultiAgentAccelerator/const.js +6 -0
  66. package/dist/components/Settings/ApiKeyInput.js +7 -8
  67. package/dist/components/Settings/InfoTip.d.ts +8 -0
  68. package/dist/components/Settings/InfoTip.js +14 -0
  69. package/dist/components/Settings/SettingsDialog.js +373 -183
  70. package/dist/components/Settings/SettingsRow.d.ts +18 -0
  71. package/dist/components/Settings/SettingsRow.js +35 -0
  72. package/dist/controller/agent/Agent.d.ts +16 -25
  73. package/dist/controller/agent/Agent.js +24 -54
  74. package/dist/controller/agent/IconSuggestions.d.ts +35 -0
  75. package/dist/controller/agent/IconSuggestions.js +85 -0
  76. package/dist/index.d.ts +1 -3
  77. package/dist/index.js +1 -3
  78. package/dist/state/IconSuggestions.d.ts +27 -0
  79. package/dist/state/IconSuggestions.js +50 -0
  80. package/dist/state/Settings.d.ts +97 -6
  81. package/dist/state/Settings.js +110 -8
  82. package/dist/tsconfig.build.tsbuildinfo +1 -1
  83. package/dist/utils/BrowserNavigation.js +2 -0
  84. package/dist/utils/File.d.ts +4 -1
  85. package/dist/utils/File.js +4 -9
  86. package/dist/utils/text.js +3 -7
  87. package/dist/utils/title.js +1 -1
  88. package/package.json +9 -6
  89. package/dist/components/Common/CustomerLogo.d.ts +0 -17
  90. package/dist/components/Common/CustomerLogo.js +0 -47
  91. package/dist/components/Common/MUIAccordion.d.ts +0 -17
  92. package/dist/components/Common/MUIAccordion.js +0 -66
  93. package/dist/components/MultiAgentAccelerator/GraphLayouts.d.ts +0 -36
  94. package/dist/components/MultiAgentAccelerator/PlasmaEdge.d.ts +0 -3
  95. package/dist/utils/useLocalStorage.d.ts +0 -1
  96. package/dist/utils/useLocalStorage.js +0 -55
  97. /package/dist/components/MultiAgentAccelerator/{ThoughtBubbleEdge.js → ThoughtBubbles/ThoughtBubbleEdge.js} +0 -0
  98. /package/dist/components/MultiAgentAccelerator/{ThoughtBubbleOverlay.d.ts → ThoughtBubbles/ThoughtBubbleOverlay.d.ts} +0 -0
@@ -9,14 +9,14 @@ import Edit from "@mui/icons-material/Edit";
9
9
  import Box from "@mui/material/Box";
10
10
  import Chip from "@mui/material/Chip";
11
11
  import IconButton from "@mui/material/IconButton";
12
- import { useTheme } from "@mui/material/styles";
13
12
  import Tooltip from "@mui/material/Tooltip";
13
+ import { useTreeItemModel } from "@mui/x-tree-view/hooks";
14
14
  import { TreeItemContent, TreeItemGroupTransition, TreeItemLabel, TreeItemRoot, } from "@mui/x-tree-view/TreeItem";
15
15
  import { TreeItemProvider } from "@mui/x-tree-view/TreeItemProvider";
16
16
  import { useTreeItem } from "@mui/x-tree-view/useTreeItem";
17
17
  import { useRef } from "react";
18
18
  import { downloadFile, toSafeFilename } from "../../../utils/File.js";
19
- import { cleanUpAgentName } from "../../AgentChat/Common/Utils.js";
19
+ import { removeTrailingUuid } from "../../AgentChat/Common/Utils.js";
20
20
  // Palette of colors we can use for tags
21
21
  const TAG_COLORS = [
22
22
  "--bs-accent2-light",
@@ -44,21 +44,15 @@ const isTemporaryNetworkExpired = (expirationDate) => {
44
44
  * @param props - see AgentNetworkNode interface
45
45
  * @returns JSX.Element containing the custom tree item
46
46
  */
47
- export const AgentNetworkTreeItem = ({ children, disabled, itemId, label, networkIconSuggestions, nodeIndex, onDeleteNetwork, onEditNetwork, temporaryNetworkExpirationTimes, temporaryNetworkHoconStrings, }) => {
48
- const theme = useTheme();
47
+ export const AgentNetworkTreeItem = ({ children, disabled, itemId, label, onDeleteNetwork, onEditNetwork, }) => {
48
+ const item = useTreeItemModel(itemId);
49
49
  // We know all labels are strings because we set them that way in the tree view items
50
50
  const labelString = label;
51
- const displayLabel = nodeIndex.get(itemId)?.displayName || cleanUpAgentName(labelString);
52
51
  const { getContextProviderProps, getRootProps, getContentProps, getLabelProps, getGroupTransitionProps } = useTreeItem({ itemId, children, label, disabled });
53
52
  const rootRef = useRef(null);
54
53
  const isParent = Array.isArray(children) && children.length > 0;
55
54
  const isChild = !isParent;
56
- const agentNode = nodeIndex?.get(itemId)?.agentInfo;
57
- // Only child items (the actual networks, not the containing folders) have tags. Retrieve tags from the
58
- // networkFolders data structure passed in as a prop. This could in theory be a custom property for the
59
- // RichTreeView item, but that isn't well-supported at this time.
60
- // Discussion: https://stackoverflow.com/questions/69481071/material-ui-how-to-pass-custom-props-to-a-custom-treeitem
61
- const tags = isChild ? agentNode?.tags || [] : [];
55
+ const tags = item.tags ?? [];
62
56
  // Assign colors to tags as needed and store in tagsToColors map
63
57
  for (const tag of tags) {
64
58
  if (!tagsToColors.has(tag)) {
@@ -67,18 +61,33 @@ export const AgentNetworkTreeItem = ({ children, disabled, itemId, label, networ
67
61
  }
68
62
  }
69
63
  // Determine if expired (temporary networks only)
70
- const expirationTime = temporaryNetworkExpirationTimes?.[itemId];
64
+ const expirationTime = item?.temporaryNetworkExpirationTime;
71
65
  const isTemporaryNetwork = Boolean(expirationTime);
72
66
  const isExpired = isChild && isTemporaryNetwork && isTemporaryNetworkExpired(expirationTime);
73
- const networkHocon = isTemporaryNetwork ? temporaryNetworkHoconStrings?.[itemId] : null;
74
- const iconNameSuggestion = isTemporaryNetwork ? "HourglassTop" : isChild ? networkIconSuggestions?.[itemId] : null;
75
- let muiIconElement = null;
76
- if (iconNameSuggestion && MuiIcons[iconNameSuggestion]) {
77
- const IconComponent = MuiIcons[iconNameSuggestion];
78
- muiIconElement = _jsx(IconComponent, { sx: { fontSize: "1rem" } });
67
+ const networkDefinition = item?.temporaryNetworkDefinition ?? null;
68
+ const iconNameSuggestion = item.iconSuggestion;
69
+ let muiIconElement;
70
+ // If the item is a child (i.e., a network), we want to render an icon next to it.
71
+ if (isChild) {
72
+ if (iconNameSuggestion) {
73
+ if (MuiIcons[iconNameSuggestion]) {
74
+ // If the icon name suggestion is valid, use it to render the icon
75
+ const IconComponent = MuiIcons[iconNameSuggestion];
76
+ muiIconElement = _jsx(IconComponent, { sx: { fontSize: "1rem" } });
77
+ }
78
+ else {
79
+ // If the icon name suggestion is not valid, use a default icon
80
+ muiIconElement = _jsx(MuiIcons.Hub, { sx: { fontSize: "1rem" } });
81
+ }
82
+ }
83
+ else {
84
+ // If no icon name suggestion is provided, use a default icon
85
+ muiIconElement = _jsx(MuiIcons.Hub, { sx: { fontSize: "1rem" } });
86
+ }
79
87
  }
80
- else if (iconNameSuggestion) {
81
- console.warn(`Icon "${iconNameSuggestion}" not found in MUI icons library.`);
88
+ else {
89
+ // Use folder icon for parent items (i.e., folders)
90
+ muiIconElement = _jsx(MuiIcons.Folder, { sx: { fontSize: "1rem" } });
82
91
  }
83
92
  return (_jsx(TreeItemProvider, { ...getContextProviderProps(), children: _jsxs(TreeItemRoot, { ...getRootProps(), ref: rootRef, "data-itemid": itemId, children: [_jsx(TreeItemContent, { ...getContentProps(), sx: {
84
93
  cursor: isExpired ? "not-allowed" : "pointer",
@@ -92,18 +101,19 @@ export const AgentNetworkTreeItem = ({ children, disabled, itemId, label, networ
92
101
  "&:hover": {
93
102
  textDecoration: "underline",
94
103
  },
95
- }, children: displayLabel })] }) }), isChild && tags?.length > 0 ? (_jsx(Tooltip, { title: [...tags]
104
+ }, children: item.displayName })] }) }), isChild && tags.length > 0 ? (_jsx(Tooltip, { title: [...tags]
96
105
  .sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
97
106
  .map((tag) => (_jsx(Chip, { label: tag, style: {
98
107
  margin: "0.25rem",
99
108
  backgroundColor: `var(${tagsToColors.get(tag) || TAG_COLORS[0]})`,
100
- } }, tag))), placement: "right", arrow: true, children: _jsx(BookmarkIcon, { sx: { fontSize: "0.75rem", color: "var(--bs-accent1-medium)" } }) })) : null] }), isChild && isTemporaryNetwork && (_jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: "0.25rem", marginLeft: "auto" }, children: [networkHocon && (_jsx(Tooltip, { title: isExpired ? "Expired" : "Download network definition", children: _jsx("span", { children: _jsx(IconButton, { onClick: (e) => {
109
+ } }, tag))), placement: "right", arrow: true, children: _jsx(BookmarkIcon, { sx: { fontSize: "0.75rem", color: "var(--bs-accent1-medium)" } }) })) : null] }), isChild && isTemporaryNetwork && (_jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: "0.25rem", marginLeft: "auto" }, children: [networkDefinition && (_jsx(Tooltip, { title: isExpired ? "Expired" : "Download network definition", children: _jsx("span", { children: _jsx(IconButton, { onClick: (e) => {
101
110
  e.stopPropagation();
102
- if (isExpired) {
103
- return;
104
- }
105
- const fileName = `${toSafeFilename(labelString)}.hocon`;
106
- downloadFile(networkHocon, fileName);
111
+ // Strip the reservation UUID before building the filename so
112
+ // exported files carry a clean name (toSafeFilename would
113
+ // otherwise flatten the UUID's hyphens to underscores).
114
+ const cleanName = removeTrailingUuid(labelString);
115
+ const fileName = `${toSafeFilename(cleanName)}.json`;
116
+ downloadFile(JSON.stringify(networkDefinition, null, 2), fileName, "application/json");
107
117
  }, disabled: isExpired, "aria-label": "Download network definition", size: "small", sx: {
108
118
  padding: 0,
109
119
  color: "var(--bs-secondary)",
@@ -128,7 +138,7 @@ export const AgentNetworkTreeItem = ({ children, disabled, itemId, label, networ
128
138
  onDeleteNetwork?.(itemId, isExpired);
129
139
  }, sx: {
130
140
  color: "var(--bs-secondary)",
131
- "&:hover": { color: theme.palette.warning.main },
141
+ "&:hover": { color: (theme) => theme.palette.warning.main },
132
142
  "&.Mui-disabled": {
133
143
  color: "var(--bs-secondary)",
134
144
  opacity: 0.3,
@@ -0,0 +1,67 @@
1
+ import { FC } from "react";
2
+ import { AgentNetworkDefinitionEntry } from "../const.js";
3
+ export declare const IMPORT_MODAL_MAX_FILE_SIZE_BYTES: number;
4
+ export type ImportFileValidation = "valid" | "unsupported_type" | "too_large";
5
+ export interface ImportNetworkModalProps {
6
+ readonly existingNetworkNames?: readonly string[];
7
+ readonly isOpen: boolean;
8
+ readonly onClose: () => void;
9
+ readonly onImport?: (name: string, content: string) => void;
10
+ }
11
+ export interface NetworkSummary {
12
+ readonly agents: number;
13
+ readonly codedTools: number;
14
+ readonly externalAgents: number;
15
+ readonly frontman: string;
16
+ }
17
+ /**
18
+ * Parse and validate a network definition file. Imports are JSON only.
19
+ *
20
+ * Returns the parsed value on success, or an error message on failure. The value is typed `unknown`,
21
+ * so callers narrow it (see `jsonToNetworkDefinition`) or stringify it as needed.
22
+ */
23
+ export declare const parseNetworkFileContent: (text: string) => {
24
+ success: true;
25
+ data: unknown;
26
+ } | {
27
+ success: false;
28
+ error: string;
29
+ };
30
+ /**
31
+ * Converts a parsed network definition into an array of AgentNetworkDefinitionEntry objects
32
+ * suitable for sendNetworkDesignerRequest.
33
+ *
34
+ * Expects the top-level array shape — each entry carrying `origin`, `tools`, `display_as`, etc.
35
+ * Anything that isn't an array yields an empty result, and entries without a string `origin`
36
+ * are dropped. The `instructions` and `description` fields are trimmed when present.
37
+ */
38
+ export declare const jsonToNetworkDefinition: (parsed: unknown) => AgentNetworkDefinitionEntry[];
39
+ export declare const summarizeNetworkDefinition: (networkDef: AgentNetworkDefinitionEntry[]) => NetworkSummary;
40
+ export declare const formatFileSize: (bytes: number) => string;
41
+ /**
42
+ * Validate a selected file against the advertised constraints before reading it.
43
+ *
44
+ * The `<input accept>` attribute only filters the file-picker dialog and is bypassed
45
+ * entirely by drag/drop, so we re-check the extension here. We also enforce the
46
+ * advertised size limit — purely a client-side guard so a pathological file can't be
47
+ * fed into the synchronous parsing/regex pass and freeze the UI; the server imposes
48
+ * no such limit.
49
+ *
50
+ * Returns a status the caller can branch on; rendering a message is left to the caller
51
+ * (see `importFileValidationMessage`).
52
+ */
53
+ export declare const validateImportFile: (file: File) => ImportFileValidation;
54
+ export declare const importFileValidationMessage: (validation: ImportFileValidation, file: File) => string | null;
55
+ /** Convert a filename stem to a display-friendly network name.
56
+ *
57
+ * Strips a trailing UUID that neuro-san appends to exported filenames (e.g.
58
+ * `my_network_683b0dfb_4816_464d_9c83_7e59ce6497d3.json` → `My Network`).
59
+ */
60
+ export declare const filenameToNetworkName: (filename: string) => string;
61
+ /** Pick the first non-colliding name by appending an incrementing index (" 2", " 3", …).
62
+ *
63
+ * Starts at 2 and skips any index already in use, so importing "My Network" alongside an existing
64
+ * "My Network" yields "My Network (2)" — or "My Network (3)" if "My Network (2)" is also taken.
65
+ */
66
+ export declare const nextAvailableNetworkName: (baseName: string, existingNames: readonly string[]) => string;
67
+ export declare const ImportNetworkModal: FC<ImportNetworkModalProps>;