@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.
- package/README.md +3 -3
- package/dist/Theme/Palettes.d.ts +0 -9
- package/dist/Theme/Palettes.js +0 -18
- package/dist/components/AgentChat/ChatCommon/ChatCommon.d.ts +13 -4
- package/dist/components/AgentChat/ChatCommon/ChatCommon.js +131 -38
- package/dist/components/AgentChat/ChatCommon/ChatHistory.d.ts +7 -0
- package/dist/components/AgentChat/ChatCommon/ChatHistory.js +1 -1
- package/dist/components/AgentChat/ChatCommon/Const.d.ts +1 -0
- package/dist/components/AgentChat/ChatCommon/Const.js +2 -0
- package/dist/components/AgentChat/ChatCommon/ControlButtons.d.ts +5 -3
- package/dist/components/AgentChat/ChatCommon/ControlButtons.js +13 -4
- package/dist/components/AgentChat/ChatCommon/ConversationTurn.d.ts +5 -5
- package/dist/components/AgentChat/ChatCommon/ConversationTurn.js +1 -0
- package/dist/components/AgentChat/ChatCommon/FormattedMarkdown.js +3 -0
- package/dist/components/AgentChat/ChatCommon/SendButton.js +7 -6
- package/dist/components/AgentChat/ChatCommon/SyntaxHighlighterThemes.js +1 -1
- package/dist/components/AgentChat/ChatCommon/Thinking.d.ts +1 -0
- package/dist/components/AgentChat/ChatCommon/Thinking.js +10 -7
- package/dist/components/AgentChat/Common/LlmChatButton.d.ts +0 -2
- package/dist/components/AgentChat/Common/LlmChatButton.js +6 -9
- package/dist/components/AgentChat/Common/Utils.d.ts +4 -0
- package/dist/components/AgentChat/Common/Utils.js +5 -1
- package/dist/components/AgentChat/VoiceChat/MicrophoneButton.js +12 -10
- package/dist/components/Common/Breadcrumbs.js +1 -1
- package/dist/components/Common/Navbar.js +24 -22
- package/dist/components/Common/StatusLight.d.ts +9 -0
- package/dist/components/Common/StatusLight.js +21 -0
- package/dist/components/Common/notification.d.ts +4 -4
- package/dist/components/ErrorPage/ErrorBoundary.js +1 -1
- package/dist/components/ErrorPage/ErrorPage.d.ts +3 -3
- package/dist/components/ErrorPage/ErrorPage.js +4 -3
- package/dist/components/Logo/Common.d.ts +4 -0
- package/dist/components/Logo/Common.js +8 -0
- package/dist/components/Logo/CustomerLogo.d.ts +23 -0
- package/dist/components/Logo/CustomerLogo.js +41 -0
- package/dist/components/MultiAgentAccelerator/AgentConversations.js +0 -1
- package/dist/components/MultiAgentAccelerator/{AgentFlow.d.ts → AgentFlow/AgentFlow.d.ts} +15 -5
- package/dist/components/MultiAgentAccelerator/{AgentFlow.js → AgentFlow/AgentFlow.js} +125 -84
- package/dist/components/MultiAgentAccelerator/{AgentNode.d.ts → AgentFlow/AgentNode.d.ts} +1 -1
- package/dist/components/MultiAgentAccelerator/{AgentNode.js → AgentFlow/AgentNode.js} +26 -30
- package/dist/components/MultiAgentAccelerator/AgentFlow/GraphLayouts.d.ts +43 -0
- package/dist/components/MultiAgentAccelerator/{GraphLayouts.js → AgentFlow/GraphLayouts.js} +10 -41
- package/dist/components/MultiAgentAccelerator/AgentFlow/GraphStructure.d.ts +21 -0
- package/dist/components/MultiAgentAccelerator/AgentFlow/GraphStructure.js +27 -0
- package/dist/components/MultiAgentAccelerator/AgentFlow/PlasmaEdge.d.ts +7 -0
- package/dist/components/MultiAgentAccelerator/{PlasmaEdge.js → AgentFlow/PlasmaEdge.js} +13 -8
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.d.ts +3 -9
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +137 -103
- package/dist/components/MultiAgentAccelerator/Schema/SlyData.d.ts +17 -0
- package/dist/components/MultiAgentAccelerator/Schema/SlyData.js +23 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.d.ts +0 -5
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +38 -28
- package/dist/components/MultiAgentAccelerator/Sidebar/ImportNetworkModal.d.ts +67 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/ImportNetworkModal.js +585 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +5 -4
- package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +77 -168
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +31 -13
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +177 -100
- package/dist/components/MultiAgentAccelerator/TemporaryNetworks.d.ts +22 -0
- package/dist/components/MultiAgentAccelerator/TemporaryNetworks.js +74 -3
- package/dist/components/MultiAgentAccelerator/{ThoughtBubbleEdge.d.ts → ThoughtBubbles/ThoughtBubbleEdge.d.ts} +1 -1
- package/dist/components/MultiAgentAccelerator/{ThoughtBubbleOverlay.js → ThoughtBubbles/ThoughtBubbleOverlay.js} +1 -1
- package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.js +15 -8
- package/dist/components/MultiAgentAccelerator/const.d.ts +3 -0
- package/dist/components/MultiAgentAccelerator/const.js +6 -0
- package/dist/components/Settings/ApiKeyInput.js +7 -8
- package/dist/components/Settings/InfoTip.d.ts +8 -0
- package/dist/components/Settings/InfoTip.js +14 -0
- package/dist/components/Settings/SettingsDialog.js +373 -183
- package/dist/components/Settings/SettingsRow.d.ts +18 -0
- package/dist/components/Settings/SettingsRow.js +35 -0
- package/dist/controller/agent/Agent.d.ts +16 -25
- package/dist/controller/agent/Agent.js +24 -54
- package/dist/controller/agent/IconSuggestions.d.ts +35 -0
- package/dist/controller/agent/IconSuggestions.js +85 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -3
- package/dist/state/IconSuggestions.d.ts +27 -0
- package/dist/state/IconSuggestions.js +50 -0
- package/dist/state/Settings.d.ts +97 -6
- package/dist/state/Settings.js +110 -8
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/BrowserNavigation.js +2 -0
- package/dist/utils/File.d.ts +4 -1
- package/dist/utils/File.js +4 -9
- package/dist/utils/text.js +3 -7
- package/dist/utils/title.js +1 -1
- package/package.json +9 -6
- package/dist/components/Common/CustomerLogo.d.ts +0 -17
- package/dist/components/Common/CustomerLogo.js +0 -47
- package/dist/components/Common/MUIAccordion.d.ts +0 -17
- package/dist/components/Common/MUIAccordion.js +0 -66
- package/dist/components/MultiAgentAccelerator/GraphLayouts.d.ts +0 -36
- package/dist/components/MultiAgentAccelerator/PlasmaEdge.d.ts +0 -3
- package/dist/utils/useLocalStorage.d.ts +0 -1
- package/dist/utils/useLocalStorage.js +0 -55
- /package/dist/components/MultiAgentAccelerator/{ThoughtBubbleEdge.js → ThoughtBubbles/ThoughtBubbleEdge.js} +0 -0
- /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 {
|
|
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,
|
|
48
|
-
const
|
|
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
|
|
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 =
|
|
64
|
+
const expirationTime = item?.temporaryNetworkExpirationTime;
|
|
71
65
|
const isTemporaryNetwork = Boolean(expirationTime);
|
|
72
66
|
const isExpired = isChild && isTemporaryNetwork && isTemporaryNetworkExpired(expirationTime);
|
|
73
|
-
const
|
|
74
|
-
const iconNameSuggestion =
|
|
75
|
-
let muiIconElement
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
81
|
-
|
|
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:
|
|
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: [
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
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>;
|