@cognizant-ai-lab/ui-common 1.3.3 → 1.4.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 +287 -0
- package/dist/Theme/Palettes.d.ts +18 -0
- package/dist/Theme/Palettes.js +94 -0
- package/dist/Theme/Theme.d.ts +22 -0
- package/dist/Theme/Theme.js +58 -0
- package/dist/components/AgentChat/ChatCommon.d.ts +4 -2
- package/dist/components/AgentChat/ChatCommon.js +141 -105
- package/dist/components/AgentChat/ControlButtons.js +3 -1
- package/dist/components/AgentChat/FormattedMarkdown.d.ts +4 -4
- package/dist/components/AgentChat/FormattedMarkdown.js +5 -7
- package/dist/components/AgentChat/LlmChatButton.d.ts +2 -6
- package/dist/components/AgentChat/LlmChatButton.js +3 -3
- package/dist/components/AgentChat/UserQueryDisplay.js +2 -4
- package/dist/components/AgentChat/Utils.d.ts +2 -1
- package/dist/components/AgentChat/Utils.js +4 -1
- package/dist/components/AgentChat/VoiceChat/MicrophoneButton.d.ts +2 -2
- package/dist/components/AgentChat/VoiceChat/VoiceChat.d.ts +3 -3
- package/dist/components/AgentChat/VoiceChat/VoiceChat.js +5 -5
- package/dist/components/ChatBot/ChatBot.js +2 -2
- package/dist/components/Common/Breadcrumbs.js +1 -1
- package/dist/components/Common/{confirmationModal.js → ConfirmationModal.js} +2 -5
- package/dist/components/Common/CustomerLogo.d.ts +17 -0
- package/dist/components/Common/CustomerLogo.js +49 -0
- package/dist/components/Common/Footer.d.ts +18 -0
- package/dist/components/Common/Footer.js +59 -0
- package/dist/components/Common/LlmChatOptionsButton.d.ts +1 -4
- package/dist/components/Common/LlmChatOptionsButton.js +4 -4
- package/dist/components/Common/LoadingSpinner.js +1 -1
- package/dist/components/Common/MUIAccordion.d.ts +2 -2
- package/dist/components/Common/MUIAccordion.js +2 -12
- package/dist/components/Common/MUIAlert.d.ts +2 -1
- package/dist/components/Common/MUIAlert.js +4 -1
- package/dist/components/Common/MUIDialog.d.ts +1 -1
- package/dist/components/Common/MUIDialog.js +1 -1
- package/dist/components/Common/Navbar.d.ts +3 -1
- package/dist/components/Common/Navbar.js +60 -35
- package/dist/components/Common/PageLoader.js +3 -4
- package/dist/components/Common/Snackbar.d.ts +4 -1
- package/dist/components/Common/Snackbar.js +11 -19
- package/dist/components/Common/notification.d.ts +3 -3
- package/dist/components/Common/notification.js +6 -6
- package/dist/components/ErrorPage/ErrorBoundary.d.ts +2 -2
- package/dist/components/ErrorPage/ErrorBoundary.js +1 -1
- package/dist/components/ErrorPage/ErrorPage.js +6 -5
- package/dist/components/MultiAgentAccelerator/AgentConversations.d.ts +17 -0
- package/dist/components/MultiAgentAccelerator/AgentConversations.js +77 -0
- package/dist/components/MultiAgentAccelerator/AgentCounts.d.ts +12 -0
- package/dist/components/MultiAgentAccelerator/AgentCounts.js +21 -0
- package/dist/components/MultiAgentAccelerator/AgentFlow.d.ts +6 -4
- package/dist/components/MultiAgentAccelerator/AgentFlow.js +106 -185
- package/dist/components/MultiAgentAccelerator/AgentNode.d.ts +7 -5
- package/dist/components/MultiAgentAccelerator/AgentNode.js +93 -50
- package/dist/components/MultiAgentAccelerator/GraphLayouts.d.ts +20 -17
- package/dist/components/MultiAgentAccelerator/GraphLayouts.js +16 -14
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.d.ts +2 -3
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +214 -55
- package/dist/components/MultiAgentAccelerator/PlasmaEdge.d.ts +1 -1
- package/dist/components/MultiAgentAccelerator/PlasmaEdge.js +14 -12
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.d.ts +15 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +104 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +17 -0
- package/dist/components/MultiAgentAccelerator/{Sidebar.js → Sidebar/Sidebar.js} +146 -59
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +19 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +113 -0
- package/dist/components/MultiAgentAccelerator/TemporaryNetworks.d.ts +26 -0
- package/dist/components/MultiAgentAccelerator/TemporaryNetworks.js +20 -0
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleEdge.d.ts +10 -8
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleEdge.js +1 -1
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleOverlay.d.ts +3 -2
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleOverlay.js +10 -13
- package/dist/components/MultiAgentAccelerator/const.d.ts +1 -3
- package/dist/components/MultiAgentAccelerator/const.js +4 -18
- package/dist/components/Settings/FadingCheckmark.d.ts +14 -0
- package/dist/components/Settings/FadingCheckmark.js +43 -0
- package/dist/components/Settings/SettingsDialog.d.ts +9 -0
- package/dist/components/Settings/SettingsDialog.js +265 -0
- package/dist/const.d.ts +1 -2
- package/dist/const.js +2 -3
- package/dist/controller/Types/AgentIconSuggestions.d.ts +4 -0
- package/dist/controller/Types/AgentIconSuggestions.js +1 -0
- package/dist/controller/Types/Branding.d.ts +12 -0
- package/dist/controller/Types/Branding.js +1 -0
- package/dist/controller/Types/NetworkIconSuggestions.d.ts +4 -0
- package/dist/controller/Types/NetworkIconSuggestions.js +1 -0
- package/dist/controller/agent/Agent.d.ts +32 -12
- package/dist/controller/agent/Agent.js +71 -19
- package/dist/controller/llm/LlmChat.d.ts +1 -1
- package/dist/controller/llm/LlmChat.js +2 -2
- package/dist/index.d.ts +10 -5
- package/dist/index.js +10 -5
- package/dist/state/{environment.d.ts → Environment.d.ts} +2 -0
- package/dist/state/{environment.js → Environment.js} +2 -0
- package/dist/state/Settings.d.ts +62 -0
- package/dist/state/Settings.js +62 -0
- package/dist/state/TemporaryNetworks.d.ts +32 -0
- package/dist/state/TemporaryNetworks.js +26 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/Authentication.d.ts +2 -2
- package/dist/utils/Authentication.js +6 -6
- package/dist/utils/text.d.ts +2 -2
- package/dist/utils/text.js +3 -5
- package/dist/utils/title.d.ts +1 -1
- package/dist/utils/title.js +2 -2
- package/dist/utils/useLocalStorage.d.ts +1 -1
- package/dist/utils/useLocalStorage.js +3 -3
- package/dist/utils/zIndexLayers.d.ts +1 -1
- package/dist/utils/zIndexLayers.js +3 -15
- package/package.json +23 -21
- package/dist/components/MultiAgentAccelerator/Sidebar.d.ts +0 -12
- package/dist/utils/Theme.d.ts +0 -7
- package/dist/utils/Theme.js +0 -7
- package/dist/utils/agentConversations.d.ts +0 -24
- package/dist/utils/agentConversations.js +0 -113
- /package/dist/components/Common/{confirmationModal.d.ts → ConfirmationModal.d.ts} +0 -0
|
@@ -14,14 +14,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
14
14
|
See the License for the specific language governing permissions and
|
|
15
15
|
limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
// We have to disable the restricted imports rule here because we need to dynamically access MUI icons by name.
|
|
18
|
+
// eslint-disable-next-line no-restricted-imports
|
|
19
|
+
import * as MuiIcons from "@mui/icons-material";
|
|
17
20
|
import AutoAwesomeIcon from "@mui/icons-material/AutoAwesome";
|
|
18
21
|
import HandymanIcon from "@mui/icons-material/Handyman";
|
|
19
22
|
import PersonIcon from "@mui/icons-material/Person";
|
|
20
23
|
import TravelExploreIcon from "@mui/icons-material/TravelExplore";
|
|
21
|
-
import {
|
|
24
|
+
import { keyframes, styled, useTheme } from "@mui/material/styles";
|
|
25
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
22
26
|
import Typography from "@mui/material/Typography";
|
|
23
|
-
import { Handle, Position } from "
|
|
24
|
-
import {
|
|
27
|
+
import { Handle, Position } from "@xyflow/react";
|
|
28
|
+
import { useSettingsStore } from "../../state/Settings.js";
|
|
29
|
+
import { usePalette } from "../../Theme/Palettes.js";
|
|
30
|
+
import { isLightColor } from "../../Theme/Theme.js";
|
|
25
31
|
import { getZIndex } from "../../utils/zIndexLayers.js";
|
|
26
32
|
// Node dimensions
|
|
27
33
|
export const NODE_HEIGHT = 100;
|
|
@@ -30,90 +36,127 @@ export const NODE_WIDTH = 100;
|
|
|
30
36
|
// These are used to set the size of the icons displayed in the agent nodes.
|
|
31
37
|
const AGENT_ICON_SIZE = "2.25rem";
|
|
32
38
|
const FRONTMAN_ICON_SIZE = "4.5rem";
|
|
39
|
+
// Pulsing glow animation for when an agent is active.
|
|
40
|
+
const glowKeyFrames = (color) => keyframes `
|
|
41
|
+
0% {
|
|
42
|
+
box-shadow: 0 0 10px 4px ${color};
|
|
43
|
+
opacity: 0.6;
|
|
44
|
+
}
|
|
45
|
+
50% {
|
|
46
|
+
box-shadow: 0 0 30px 12px ${color};
|
|
47
|
+
opacity: 0.9;
|
|
48
|
+
}
|
|
49
|
+
100% {
|
|
50
|
+
box-shadow: 0 0 10px 4px ${color};
|
|
51
|
+
opacity: 1.0;
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
// Styled component for the agent nodes, applies glow animation if active
|
|
55
|
+
const AnimatedNode = styled("div", {
|
|
56
|
+
shouldForwardProp: (prop) => prop !== "glowColor" && prop !== "isActive",
|
|
57
|
+
})(({ glowColor, isActive }) => ({
|
|
58
|
+
alignItems: "center",
|
|
59
|
+
borderRadius: "50%",
|
|
60
|
+
display: "flex",
|
|
61
|
+
justifyContent: "center",
|
|
62
|
+
position: "relative",
|
|
63
|
+
shapeOutside: "circle(50%)",
|
|
64
|
+
textAlign: "center",
|
|
65
|
+
...(isActive && {
|
|
66
|
+
animation: `${glowKeyFrames(glowColor)} 2s infinite`,
|
|
67
|
+
}),
|
|
68
|
+
}));
|
|
33
69
|
/**
|
|
34
70
|
* A node representing an agent in the network for use in react-flow.
|
|
35
71
|
* @param props See AgentNodeProps
|
|
36
72
|
*/
|
|
37
73
|
export const AgentNode = (props) => {
|
|
38
74
|
const theme = useTheme();
|
|
75
|
+
// Agent node color from settings store
|
|
76
|
+
const agentNodeColor = useSettingsStore((state) => state.settings.appearance.agentNodeColor);
|
|
77
|
+
// Agent node icon color from settings store
|
|
78
|
+
const agentNodeIconColor = useSettingsStore((state) => state.settings.appearance.agentIconColor);
|
|
79
|
+
const autoAgentIconColor = useSettingsStore((state) => state.settings.appearance.autoAgentIconColor);
|
|
80
|
+
// Color palette for depth/heatmap coloring
|
|
81
|
+
const palette = usePalette();
|
|
39
82
|
// Unpack the node-specific data
|
|
40
83
|
const data = props.data;
|
|
41
|
-
const { agentCounts, agentName, depth, displayAs, getConversations, isAwaitingLlm } = data;
|
|
84
|
+
const { agentCounts, agentName, depth, displayAs, getConversations, agentIconSuggestion, isAwaitingLlm } = data;
|
|
85
|
+
// Determine if this is the Frontman node (depth 0)
|
|
42
86
|
const isFrontman = depth === 0;
|
|
87
|
+
// Determine max agent count for heatmap scaling
|
|
43
88
|
const maxAgentCount = agentCounts ? Math.max(...Array.from(agentCounts.values())) : 0;
|
|
44
89
|
// Unpack the node-specific id
|
|
45
90
|
const agentId = props.id;
|
|
46
91
|
// "Active" agents are those at either end of the current communication from the incoming chat messages.
|
|
47
|
-
// We highlight them with a
|
|
92
|
+
// We highlight them with a different color
|
|
48
93
|
const conversations = getConversations();
|
|
49
94
|
const isActiveAgent = conversations?.some((conversation) => conversation.agents.has(agentId)) ?? false;
|
|
95
|
+
// Determine background color based on active status, heatmap, or depth
|
|
50
96
|
let backgroundColor;
|
|
51
|
-
|
|
52
|
-
|
|
97
|
+
// HACK: parent passes in agentCounts as undefined when not using heatmap mode. We distinguish between
|
|
98
|
+
// "undefined" (no heatmap) and "defined but empty" (heatmap with zero counts).
|
|
99
|
+
const isHeatmap = agentCounts !== undefined;
|
|
53
100
|
if (isActiveAgent) {
|
|
54
|
-
|
|
55
|
-
|
|
101
|
+
// Highlight active agents with a distinct color
|
|
102
|
+
backgroundColor = agentNodeColor;
|
|
56
103
|
}
|
|
57
104
|
else if (isHeatmap) {
|
|
105
|
+
// Color by "heatmap" of agent invocation counts
|
|
58
106
|
const agentCount = agentCounts.has(agentId) ? agentCounts.get(agentId) : 0;
|
|
59
107
|
// Calculate "heat" as a fraction of the times this agent was invoked compared to the maximum agent count.
|
|
60
|
-
const colorIndex = Math.floor((agentCount / maxAgentCount) * (
|
|
61
|
-
backgroundColor =
|
|
62
|
-
const isDarkBackground = colorIndex >= BACKGROUND_COLORS_DARK_IDX;
|
|
63
|
-
color = isDarkBackground ? "var(--bs-white)" : "var(--bs-dark)";
|
|
108
|
+
const colorIndex = Math.floor((agentCount / maxAgentCount) * (palette.length - 1));
|
|
109
|
+
backgroundColor = palette[colorIndex];
|
|
64
110
|
}
|
|
65
111
|
else {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
color = isDarkBackground ? "var(--bs-white)" : "var(--bs-dark)";
|
|
112
|
+
// Color by depth in the agent graph
|
|
113
|
+
const colorIndex = depth % palette.length;
|
|
114
|
+
backgroundColor = palette[colorIndex];
|
|
70
115
|
}
|
|
71
|
-
// Animation style for making active agent glow and pulse
|
|
72
|
-
// TODO: more idiomatic MUI/style= way of doing this?
|
|
73
|
-
const glowAnimation = isActiveAgent
|
|
74
|
-
? `@keyframes glow {
|
|
75
|
-
0% { box-shadow: 0 0 10px 4px ${backgroundColor}; opacity: 0.60; }
|
|
76
|
-
50% { box-shadow: 0 0 30px 12px ${backgroundColor}; opacity: 0.90; }
|
|
77
|
-
100% { box-shadow: 0 0 10px 4px ${backgroundColor}; opacity: 1.0; }
|
|
78
|
-
}`
|
|
79
|
-
: "none";
|
|
80
|
-
const boxShadow = isActiveAgent ? "0 0 30px 12px var(--bs-primary), 0 0 60px 24px var(--bs-primary)" : undefined;
|
|
81
116
|
// Hide handles when awaiting LLM response ("zen mode")
|
|
82
117
|
const handleVisibility = isAwaitingLlm ? "none" : "block";
|
|
83
118
|
// Determine which icon to display based on the agent type whether it is Frontman or not
|
|
84
119
|
const getDisplayAsIcon = () => {
|
|
85
120
|
const id = `${agentId}-icon`;
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
_jsx(PersonIcon, { id: id, sx: { fontSize: FRONTMAN_ICON_SIZE } }));
|
|
121
|
+
if (agentIconSuggestion && MuiIcons[agentIconSuggestion]) {
|
|
122
|
+
const IconComponent = MuiIcons[agentIconSuggestion];
|
|
123
|
+
return _jsx(IconComponent, { sx: { fontSize: AGENT_ICON_SIZE } });
|
|
90
124
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
125
|
+
else {
|
|
126
|
+
if (agentIconSuggestion) {
|
|
127
|
+
console.warn(`Invalid MUI icon suggestion: ${agentIconSuggestion}`);
|
|
128
|
+
}
|
|
129
|
+
if (isFrontman) {
|
|
130
|
+
return (
|
|
131
|
+
// Use special icon and larger size for Frontman
|
|
132
|
+
_jsx(PersonIcon, { id: id, sx: { fontSize: FRONTMAN_ICON_SIZE } }));
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
switch (displayAs) {
|
|
136
|
+
case "external_agent":
|
|
137
|
+
return (_jsx(TravelExploreIcon, { id: id, sx: { fontSize: AGENT_ICON_SIZE } }));
|
|
138
|
+
case "coded_tool":
|
|
139
|
+
return (_jsx(HandymanIcon, { id: id, sx: { fontSize: AGENT_ICON_SIZE } }));
|
|
140
|
+
case "llm_agent":
|
|
141
|
+
default:
|
|
142
|
+
return (_jsx(AutoAwesomeIcon, { id: id, sx: { fontSize: AGENT_ICON_SIZE } }));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
99
145
|
}
|
|
100
146
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
147
|
+
// Determine icon color based on settings. If auto color is enabled, use contrasting color for readability.
|
|
148
|
+
const color = autoAgentIconColor ? theme.palette.getContrastText(backgroundColor) : agentNodeIconColor;
|
|
149
|
+
// Choose a glow color that contrasts with the background for visibility.
|
|
150
|
+
const glowColor = isLightColor(theme.palette.background.default)
|
|
151
|
+
? theme.palette.common.black
|
|
152
|
+
: theme.palette.common.white;
|
|
153
|
+
return (_jsxs(_Fragment, { children: [_jsxs(AnimatedNode, { id: agentId, "data-testid": agentId, glowColor: glowColor, isActive: isActiveAgent, sx: {
|
|
104
154
|
backgroundColor,
|
|
105
|
-
borderRadius: "50%",
|
|
106
|
-
boxShadow,
|
|
107
155
|
color,
|
|
108
|
-
display: "flex",
|
|
109
156
|
height: NODE_HEIGHT * (isFrontman ? 1.25 : 1.0),
|
|
110
|
-
justifyContent: "center",
|
|
111
|
-
shapeOutside: "circle(50%)",
|
|
112
|
-
textAlign: "center",
|
|
113
157
|
width: NODE_WIDTH * (isFrontman ? 1.25 : 1.0),
|
|
114
158
|
zIndex: getZIndex(1, theme),
|
|
115
|
-
|
|
116
|
-
}, children: [_jsx("style", { id: `${agentId}-glow-animation`, children: glowAnimation }), getDisplayAsIcon(), _jsx(Handle, { id: `${agentId}-left-handle`, position: Position.Left, type: "source", style: { display: handleVisibility } }), _jsx(Handle, { id: `${agentId}-right-handle`, position: Position.Right, type: "source", style: { display: handleVisibility } }), _jsx(Handle, { id: `${agentId}-top-handle`, position: Position.Top, type: "source", style: { display: handleVisibility } }), _jsx(Handle, { id: `${agentId}-bottom-handle`, position: Position.Bottom, type: "source", style: { display: handleVisibility } })] }), _jsx(Tooltip, { id: `${agentId}-tooltip`, title: agentName, placement: "top", disableInteractive: true, children: _jsx(Typography, { id: `${agentId}-name`, sx: {
|
|
159
|
+
}, children: [getDisplayAsIcon(), _jsx(Handle, { id: `${agentId}-left-handle`, position: Position.Left, type: "source", style: { display: handleVisibility } }), _jsx(Handle, { id: `${agentId}-right-handle`, position: Position.Right, type: "source", style: { display: handleVisibility } }), _jsx(Handle, { id: `${agentId}-top-handle`, position: Position.Top, type: "source", style: { display: handleVisibility } }), _jsx(Handle, { id: `${agentId}-bottom-handle`, position: Position.Bottom, type: "source", style: { display: handleVisibility } })] }), _jsx(Tooltip, { id: `${agentId}-tooltip`, title: agentName, placement: "top", disableInteractive: true, children: _jsx(Typography, { id: `${agentId}-name`, sx: {
|
|
117
160
|
display: "-webkit-box",
|
|
118
161
|
fontSize: "18px",
|
|
119
162
|
fontWeight: "bold",
|
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import { Edge,
|
|
1
|
+
import { Edge, Node as RFNode } from "@xyflow/react";
|
|
2
|
+
import { AgentConversation } from "./AgentConversations.js";
|
|
2
3
|
import { AgentNodeProps } from "./AgentNode.js";
|
|
4
|
+
import { ThoughtBubbleEdgeShape } from "./ThoughtBubbleEdge.js";
|
|
5
|
+
import { AgentIconSuggestions } from "../../controller/Types/AgentIconSuggestions.js";
|
|
3
6
|
import { ConnectivityInfo } from "../../generated/neuro-san/NeuroSanClient.js";
|
|
4
|
-
import { AgentConversation } from "../../utils/agentConversations.js";
|
|
5
7
|
export declare const MAX_GLOBAL_THOUGHT_BUBBLES = 5;
|
|
8
|
+
/**
|
|
9
|
+
* Result of the layout algorithms, containing the nodes and edges with their computed positions and properties.
|
|
10
|
+
*/
|
|
11
|
+
export type LayoutResult = {
|
|
12
|
+
nodes: RFNode<AgentNodeProps>[];
|
|
13
|
+
edges: Edge[];
|
|
14
|
+
};
|
|
6
15
|
export declare const addThoughtBubbleEdge: (thoughtBubbleEdges: Map<string, {
|
|
7
|
-
edge:
|
|
16
|
+
edge: ThoughtBubbleEdgeShape;
|
|
8
17
|
timestamp: number;
|
|
9
|
-
}>, conversationId: string, edge:
|
|
18
|
+
}>, conversationId: string, edge: ThoughtBubbleEdgeShape) => void;
|
|
10
19
|
export declare const removeThoughtBubbleEdge: (thoughtBubbleEdges: Map<string, {
|
|
11
|
-
edge:
|
|
20
|
+
edge: ThoughtBubbleEdgeShape;
|
|
12
21
|
timestamp: number;
|
|
13
22
|
}>, conversationId: string) => void;
|
|
14
23
|
export declare const getThoughtBubbleEdges: (thoughtBubbleEdges: Map<string, {
|
|
15
|
-
edge:
|
|
24
|
+
edge: ThoughtBubbleEdgeShape;
|
|
16
25
|
timestamp: number;
|
|
17
|
-
}>) =>
|
|
26
|
+
}>) => ThoughtBubbleEdgeShape[];
|
|
18
27
|
export declare const layoutRadial: (agentCounts: Map<string, number>, agentsInNetwork: ConnectivityInfo[], currentConversations: AgentConversation[] | null, // For plasma edges (live) and node highlighting
|
|
19
28
|
isAwaitingLlm: boolean, thoughtBubbleEdges: Map<string, {
|
|
20
|
-
edge:
|
|
29
|
+
edge: ThoughtBubbleEdgeShape;
|
|
21
30
|
timestamp: number;
|
|
22
|
-
}
|
|
23
|
-
nodes: RFNode<AgentNodeProps>[];
|
|
24
|
-
edges: Edge<EdgeProps>[];
|
|
25
|
-
};
|
|
31
|
+
}>, agentIconSuggestions?: AgentIconSuggestions) => LayoutResult;
|
|
26
32
|
export declare const layoutLinear: (agentCounts: Map<string, number>, agentsInNetwork: ConnectivityInfo[], currentConversations: AgentConversation[] | null, // For plasma edges (live) and node highlighting
|
|
27
33
|
isAwaitingLlm: boolean, thoughtBubbleEdges: Map<string, {
|
|
28
|
-
edge:
|
|
34
|
+
edge: ThoughtBubbleEdgeShape;
|
|
29
35
|
timestamp: number;
|
|
30
|
-
}
|
|
31
|
-
nodes: RFNode<AgentNodeProps>[];
|
|
32
|
-
edges: Edge<EdgeProps>[];
|
|
33
|
-
};
|
|
36
|
+
}>, agentIconSuggestions?: AgentIconSuggestions) => LayoutResult;
|
|
@@ -16,9 +16,9 @@ limitations under the License.
|
|
|
16
16
|
/**
|
|
17
17
|
* Graph layout algorithms and associated functions for the agent network.
|
|
18
18
|
*/
|
|
19
|
-
import dagre from "dagre";
|
|
19
|
+
import dagre from "@dagrejs/dagre";
|
|
20
|
+
import { MarkerType } from "@xyflow/react";
|
|
20
21
|
import cloneDeep from "lodash-es/cloneDeep.js";
|
|
21
|
-
import { MarkerType } from "reactflow";
|
|
22
22
|
import { NODE_HEIGHT, NODE_WIDTH } from "./AgentNode.js";
|
|
23
23
|
import { BASE_RADIUS, DEFAULT_FRONTMAN_X_POS, DEFAULT_FRONTMAN_Y_POS, LEVEL_SPACING } from "./const.js";
|
|
24
24
|
import { cleanUpAgentName, KNOWN_MESSAGE_TYPES_FOR_PLASMA } from "../AgentChat/Utils.js";
|
|
@@ -100,7 +100,7 @@ const getEdgeProperties = (sourceId, targetId, sourceHandle, targetHandle, isAni
|
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
102
|
export const layoutRadial = (agentCounts, agentsInNetwork, currentConversations, // For plasma edges (live) and node highlighting
|
|
103
|
-
isAwaitingLlm, thoughtBubbleEdges) => {
|
|
103
|
+
isAwaitingLlm, thoughtBubbleEdges, agentIconSuggestions = null) => {
|
|
104
104
|
const nodesInNetwork = [];
|
|
105
105
|
const edgesInNetwork = [];
|
|
106
106
|
// Compute depth of each node using breadth-first traversal
|
|
@@ -187,6 +187,7 @@ isAwaitingLlm, thoughtBubbleEdges) => {
|
|
|
187
187
|
// Use current conversations for node highlighting (cleared at end)
|
|
188
188
|
getConversations: () => currentConversations,
|
|
189
189
|
isAwaitingLlm,
|
|
190
|
+
agentIconSuggestion: agentIconSuggestions?.[nodeId],
|
|
190
191
|
},
|
|
191
192
|
position: isFrontman ? { x: DEFAULT_FRONTMAN_X_POS, y: DEFAULT_FRONTMAN_Y_POS } : { x, y },
|
|
192
193
|
style: {
|
|
@@ -206,27 +207,28 @@ isAwaitingLlm, thoughtBubbleEdges) => {
|
|
|
206
207
|
return { nodes: nodesInNetwork, edges: edgesInNetwork };
|
|
207
208
|
};
|
|
208
209
|
export const layoutLinear = (agentCounts, agentsInNetwork, currentConversations, // For plasma edges (live) and node highlighting
|
|
209
|
-
isAwaitingLlm, thoughtBubbleEdges) => {
|
|
210
|
+
isAwaitingLlm, thoughtBubbleEdges, agentIconSuggestions = null) => {
|
|
210
211
|
const nodesInNetwork = [];
|
|
211
212
|
const edgesInNetwork = [];
|
|
212
213
|
// Do these calculations outside the loop for efficiency
|
|
213
214
|
const parentAgents = getParentAgents(agentsInNetwork);
|
|
214
215
|
const childAgents = getChildAgents(parentAgents);
|
|
215
216
|
const frontman = getFrontman(parentAgents, childAgents);
|
|
216
|
-
agentsInNetwork.forEach(({ origin:
|
|
217
|
-
const parentIds = getParents(
|
|
218
|
-
const isFrontman = frontman?.origin ===
|
|
217
|
+
agentsInNetwork.forEach(({ origin: nodeId }) => {
|
|
218
|
+
const parentIds = getParents(nodeId, parentAgents);
|
|
219
|
+
const isFrontman = frontman?.origin === nodeId;
|
|
219
220
|
nodesInNetwork.push({
|
|
220
|
-
id:
|
|
221
|
+
id: nodeId,
|
|
221
222
|
type: AGENT_NODE_TYPE_NAME,
|
|
222
223
|
data: {
|
|
223
224
|
agentCounts,
|
|
224
|
-
agentName: cleanUpAgentName(
|
|
225
|
-
displayAs: agentsInNetwork.find((a) => a.origin ===
|
|
225
|
+
agentName: cleanUpAgentName(nodeId),
|
|
226
|
+
displayAs: agentsInNetwork.find((a) => a.origin === nodeId)?.display_as,
|
|
226
227
|
// Use current conversations for node highlighting (cleared at end)
|
|
227
228
|
getConversations: () => currentConversations,
|
|
228
229
|
isAwaitingLlm,
|
|
229
|
-
depth: undefined, // Depth will be computed later
|
|
230
|
+
depth: undefined, // Depth will be computed later,
|
|
231
|
+
agentIconSuggestion: agentIconSuggestions?.[nodeId],
|
|
230
232
|
},
|
|
231
233
|
position: isFrontman ? { x: DEFAULT_FRONTMAN_X_POS, y: DEFAULT_FRONTMAN_Y_POS } : { x: 0, y: 0 },
|
|
232
234
|
style: {
|
|
@@ -240,10 +242,10 @@ isAwaitingLlm, thoughtBubbleEdges) => {
|
|
|
240
242
|
if (!isFrontman) {
|
|
241
243
|
for (const parentNode of parentIds) {
|
|
242
244
|
// Add edges from parents to node
|
|
243
|
-
const isEdgeAnimated = areInSameConversation(currentConversations, parentNode,
|
|
245
|
+
const isEdgeAnimated = areInSameConversation(currentConversations, parentNode, nodeId);
|
|
244
246
|
// Include all edges here, since dagre needs them to compute the layout correctly.
|
|
245
247
|
// We will filter them later if we're in "awaiting LLM" mode.
|
|
246
|
-
edgesInNetwork.push(getEdgeProperties(parentNode,
|
|
248
|
+
edgesInNetwork.push(getEdgeProperties(parentNode, nodeId, `${parentNode}-right-handle`, `${nodeId}-left-handle`, isEdgeAnimated));
|
|
247
249
|
}
|
|
248
250
|
}
|
|
249
251
|
});
|
|
@@ -271,7 +273,7 @@ isAwaitingLlm, thoughtBubbleEdges) => {
|
|
|
271
273
|
// Convert dagre's layout to what our flow graph needs
|
|
272
274
|
nodesTmp.forEach((node) => {
|
|
273
275
|
const nodeWithPosition = dagreGraph.node(node.id);
|
|
274
|
-
// We are shifting the dagre node position (anchor=center
|
|
276
|
+
// We are shifting the dagre node position (anchor=center) to the top left
|
|
275
277
|
// so it matches the React Flow node anchor point (top left).
|
|
276
278
|
node.position = {
|
|
277
279
|
x: nodeWithPosition.x - NODE_WIDTH / 2,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FC } from "react";
|
|
2
2
|
interface MultiAgentAcceleratorProps {
|
|
3
3
|
readonly userInfo: {
|
|
4
4
|
userName: string;
|
|
5
5
|
userImage: string;
|
|
6
6
|
};
|
|
7
7
|
readonly backendNeuroSanApiUrl: string;
|
|
8
|
-
readonly darkMode: boolean;
|
|
9
8
|
}
|
|
10
9
|
/**
|
|
11
10
|
* Main Multi-Agent Accelerator component that contains the sidebar, agent flow, and chat components.
|
|
@@ -13,5 +12,5 @@ interface MultiAgentAcceleratorProps {
|
|
|
13
12
|
* @param darkMode Whether dark mode is enabled.
|
|
14
13
|
* @param userInfo Information about the current user, including userName and userImage.
|
|
15
14
|
*/
|
|
16
|
-
export declare const MultiAgentAccelerator:
|
|
15
|
+
export declare const MultiAgentAccelerator: FC<MultiAgentAcceleratorProps>;
|
|
17
16
|
export {};
|