@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SxProps, Theme } from "@mui/material/styles";
|
|
2
|
+
import { FC, ReactNode } from "react";
|
|
3
|
+
import { useCheckmarkFade } from "./FadingCheckmark.js";
|
|
4
|
+
interface SettingsRowProps {
|
|
5
|
+
readonly checkmark?: ReturnType<typeof useCheckmarkFade>;
|
|
6
|
+
readonly children: ReactNode;
|
|
7
|
+
readonly disabled?: boolean;
|
|
8
|
+
readonly id?: string;
|
|
9
|
+
readonly label: ReactNode;
|
|
10
|
+
readonly labelWidth?: string | number;
|
|
11
|
+
readonly sx?: SxProps<Theme>;
|
|
12
|
+
readonly tooltip: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Lightweight component to encapsulate a row in the Settings page.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SettingsRow: FC<SettingsRowProps>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Box from "@mui/material/Box";
|
|
3
|
+
import FormLabel from "@mui/material/FormLabel";
|
|
4
|
+
import { useTheme } from "@mui/material/styles";
|
|
5
|
+
import { FadingCheckmark } from "./FadingCheckmark.js";
|
|
6
|
+
import InfoTip from "./InfoTip.js";
|
|
7
|
+
/**
|
|
8
|
+
* Lightweight component to encapsulate a row in the Settings page.
|
|
9
|
+
*/
|
|
10
|
+
export const SettingsRow = ({ checkmark, children, disabled = false, id, label, labelWidth = "8rem", sx, tooltip, }) => {
|
|
11
|
+
const theme = useTheme();
|
|
12
|
+
return (_jsxs(Box, { "data-testid": id, sx: [
|
|
13
|
+
{
|
|
14
|
+
alignItems: "center",
|
|
15
|
+
display: "flex",
|
|
16
|
+
flexDirection: "row",
|
|
17
|
+
gap: theme.spacing(2),
|
|
18
|
+
opacity: disabled ? 0.5 : 1,
|
|
19
|
+
width: "100%",
|
|
20
|
+
},
|
|
21
|
+
// Can't spread sx directly because it can be an array or object
|
|
22
|
+
...(sx ? (Array.isArray(sx) ? sx : [sx]) : []),
|
|
23
|
+
], children: [label ? (_jsx(Box, { sx: {
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
display: "flex",
|
|
26
|
+
flexBasis: labelWidth,
|
|
27
|
+
flexShrink: 0,
|
|
28
|
+
}, children: _jsx(FormLabel, { children: label }) })) : null, _jsxs(Box, { sx: {
|
|
29
|
+
alignItems: "center",
|
|
30
|
+
display: "flex",
|
|
31
|
+
flex: 1,
|
|
32
|
+
gap: theme.spacing(2),
|
|
33
|
+
minWidth: 0,
|
|
34
|
+
}, children: [children, checkmark ? _jsx(FadingCheckmark, { show: checkmark.show }) : null] }), _jsx(Box, { sx: { flexShrink: 0 }, children: _jsx(InfoTip, { title: tooltip }) })] }));
|
|
35
|
+
};
|
|
@@ -1,36 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Controller module for interacting with the Agent LLM API.
|
|
3
|
-
*/
|
|
4
1
|
import { AgentNetworkDefinitionEntry } from "../../components/MultiAgentAccelerator/const.js";
|
|
5
2
|
import { AgentInfo, ChatContext, ChatResponse, ConnectivityResponse, FunctionResponse } from "../../generated/neuro-san/NeuroSanClient.js";
|
|
6
3
|
import { StreamingUnit } from "../llm/LlmChat.js";
|
|
7
|
-
import { AgentIconSuggestions } from "../Types/AgentIconSuggestions.js";
|
|
8
4
|
import { BrandingSuggestions } from "../Types/Branding.js";
|
|
9
|
-
|
|
5
|
+
export interface HealthCheckResponse {
|
|
6
|
+
readonly service?: string;
|
|
7
|
+
readonly status?: string;
|
|
8
|
+
readonly versions?: {
|
|
9
|
+
readonly "neuro-san-studio"?: string;
|
|
10
|
+
readonly "neuro-san"?: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
10
13
|
export interface TestConnectionResult {
|
|
14
|
+
readonly healthCheckResponse?: HealthCheckResponse;
|
|
15
|
+
readonly httpStatus?: number;
|
|
16
|
+
readonly statusText?: string;
|
|
11
17
|
readonly success: boolean;
|
|
12
|
-
readonly status?: string;
|
|
13
|
-
readonly version?: string;
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
16
20
|
* Test connection for a neuro-san server.
|
|
17
21
|
* @param url The neuro-san server URL.
|
|
18
|
-
* @returns
|
|
22
|
+
* @returns An object with information about the connection test result
|
|
19
23
|
*/
|
|
20
24
|
export declare const testConnection: (url: string) => Promise<TestConnectionResult>;
|
|
21
|
-
/**
|
|
22
|
-
* Get LLM suggestions for network icons.
|
|
23
|
-
* @param networks The list of networks to get icon suggestions for.
|
|
24
|
-
* @returns A promise that resolves to a record mapping network names to icon names.
|
|
25
|
-
*/
|
|
26
|
-
export declare const getNetworkIconSuggestions: (networks: readonly AgentInfo[]) => Promise<NetworkIconSuggestions>;
|
|
27
|
-
/**
|
|
28
|
-
* Get LLM suggestions for agent icons based on their descriptions from Neuro-san
|
|
29
|
-
* @param connectivity The connectivity information for the agents in the network, including their descriptions,
|
|
30
|
-
* tools, and connections.
|
|
31
|
-
* @return A promise that resolves to a record mapping agent names to suggested icon names.
|
|
32
|
-
*/
|
|
33
|
-
export declare const getAgentIconSuggestions: (connectivity: ConnectivityResponse) => Promise<AgentIconSuggestions>;
|
|
34
25
|
/**
|
|
35
26
|
* Get LLM suggestions for branding colors based on the company name. This is used to customize the UI colors
|
|
36
27
|
* to match the user's company branding.
|
|
@@ -81,8 +72,8 @@ export declare const getConnectivity: (url: string, network: string, userId: str
|
|
|
81
72
|
*/
|
|
82
73
|
export declare const getAgentFunction: (url: string, agent: string, userId: string) => Promise<FunctionResponse>;
|
|
83
74
|
/**
|
|
84
|
-
* Streams the Agent Network Designer endpoint with an
|
|
85
|
-
* Calls `onChunk` for each line received; callers are
|
|
86
|
-
* reservations / networks out of each chunk.
|
|
75
|
+
* Streams the Agent Network Designer endpoint with an agent definition, either updating an
|
|
76
|
+
* existing network or adding a fresh one. Calls `onChunk` for each line received; callers are
|
|
77
|
+
* responsible for parsing reservations / networks out of each chunk.
|
|
87
78
|
*/
|
|
88
|
-
export declare const
|
|
79
|
+
export declare const sendNetworkDesignerRequest: (url: string, signal: AbortSignal, agentName: string, updated: AgentNetworkDefinitionEntry[], agentNetworkName: string | undefined, currentUser: string, onChunk: (chunk: string) => void) => Promise<void>;
|
|
@@ -16,6 +16,7 @@ limitations under the License.
|
|
|
16
16
|
/**
|
|
17
17
|
* Controller module for interacting with the Agent LLM API.
|
|
18
18
|
*/
|
|
19
|
+
import { postJsonRequest } from "./IconSuggestions.js";
|
|
19
20
|
import { AGENT_NETWORK_DEFINITION_KEY, AGENT_NETWORK_DESIGNER_ID, AGENT_NETWORK_NAME_KEY, TEMPORARY_NETWORK_FOLDER, } from "../../components/MultiAgentAccelerator/const.js";
|
|
20
21
|
import { ApiPaths,
|
|
21
22
|
// eslint-disable-next-line camelcase
|
|
@@ -40,7 +41,7 @@ const insertTargetAgent = (agent, path) => {
|
|
|
40
41
|
/**
|
|
41
42
|
* Test connection for a neuro-san server.
|
|
42
43
|
* @param url The neuro-san server URL.
|
|
43
|
-
* @returns
|
|
44
|
+
* @returns An object with information about the connection test result
|
|
44
45
|
*/
|
|
45
46
|
export const testConnection = async (url) => {
|
|
46
47
|
const controller = new AbortController();
|
|
@@ -48,64 +49,33 @@ export const testConnection = async (url) => {
|
|
|
48
49
|
try {
|
|
49
50
|
const response = await fetch(url, { signal: controller.signal });
|
|
50
51
|
if (!response.ok) {
|
|
51
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
httpStatus: response.status,
|
|
54
|
+
statusText: response.statusText,
|
|
55
|
+
success: false,
|
|
56
|
+
};
|
|
52
57
|
}
|
|
53
58
|
const jsonResponse = await response.json();
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
const statusText = jsonResponse?.status;
|
|
60
|
+
const success = statusText === "ok";
|
|
61
|
+
return {
|
|
62
|
+
healthCheckResponse: jsonResponse,
|
|
63
|
+
httpStatus: response.status,
|
|
64
|
+
statusText,
|
|
65
|
+
success,
|
|
66
|
+
};
|
|
61
67
|
}
|
|
62
68
|
catch (error) {
|
|
63
69
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
64
|
-
return {
|
|
70
|
+
return {
|
|
71
|
+
statusText: errorMessage,
|
|
72
|
+
success: false,
|
|
73
|
+
};
|
|
65
74
|
}
|
|
66
75
|
finally {
|
|
67
76
|
clearTimeout(timeout);
|
|
68
77
|
}
|
|
69
78
|
};
|
|
70
|
-
/**
|
|
71
|
-
* Utility function to send POST requests with JSON body and handle errors.
|
|
72
|
-
* Used for getting LLM suggestions for icons and branding colors.
|
|
73
|
-
* @template T The expected response type from the server.
|
|
74
|
-
* @param endpoint The API endpoint to send the request to.
|
|
75
|
-
* @param body The request body to send, which will be stringified to JSON.
|
|
76
|
-
* @returns The response from the server parsed as JSON.
|
|
77
|
-
* @throws An error if the request fails or the response is not ok.
|
|
78
|
-
*/
|
|
79
|
-
const postJsonRequest = async (endpoint, body) => {
|
|
80
|
-
const response = await fetch(endpoint, {
|
|
81
|
-
method: "POST",
|
|
82
|
-
headers: {
|
|
83
|
-
"Content-Type": "application/json",
|
|
84
|
-
},
|
|
85
|
-
body: JSON.stringify(body),
|
|
86
|
-
});
|
|
87
|
-
const jsonResponse = await response.json();
|
|
88
|
-
if (!response.ok || jsonResponse.error) {
|
|
89
|
-
throw new Error(jsonResponse.error || response.statusText);
|
|
90
|
-
}
|
|
91
|
-
return jsonResponse;
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Get LLM suggestions for network icons.
|
|
95
|
-
* @param networks The list of networks to get icon suggestions for.
|
|
96
|
-
* @returns A promise that resolves to a record mapping network names to icon names.
|
|
97
|
-
*/
|
|
98
|
-
export const getNetworkIconSuggestions = async (networks) => postJsonRequest("/api/networkIconSuggestions", { networks });
|
|
99
|
-
/**
|
|
100
|
-
* Get LLM suggestions for agent icons based on their descriptions from Neuro-san
|
|
101
|
-
* @param connectivity The connectivity information for the agents in the network, including their descriptions,
|
|
102
|
-
* tools, and connections.
|
|
103
|
-
* @return A promise that resolves to a record mapping agent names to suggested icon names.
|
|
104
|
-
*/
|
|
105
|
-
export const getAgentIconSuggestions = async (connectivity) => postJsonRequest("/api/agentIconSuggestions", {
|
|
106
|
-
connectivity_info: connectivity.connectivity_info,
|
|
107
|
-
metadata: connectivity.metadata,
|
|
108
|
-
});
|
|
109
79
|
/**
|
|
110
80
|
* Get LLM suggestions for branding colors based on the company name. This is used to customize the UI colors
|
|
111
81
|
* to match the user's company branding.
|
|
@@ -214,13 +184,13 @@ export const getAgentFunction = async (url, agent, userId) => {
|
|
|
214
184
|
return response.json();
|
|
215
185
|
};
|
|
216
186
|
/**
|
|
217
|
-
* Streams the Agent Network Designer endpoint with an
|
|
218
|
-
* Calls `onChunk` for each line received; callers are
|
|
219
|
-
* reservations / networks out of each chunk.
|
|
187
|
+
* Streams the Agent Network Designer endpoint with an agent definition, either updating an
|
|
188
|
+
* existing network or adding a fresh one. Calls `onChunk` for each line received; callers are
|
|
189
|
+
* responsible for parsing reservations / networks out of each chunk.
|
|
220
190
|
*/
|
|
221
|
-
export const
|
|
191
|
+
export const sendNetworkDesignerRequest = async (url, signal, agentName, updated, agentNetworkName, currentUser, onChunk) => {
|
|
222
192
|
await sendChatQuery(url, signal,
|
|
223
|
-
// Shouldn't have to pass a user message, but API behaves
|
|
193
|
+
// Shouldn't have to pass a user message, but API behaves differently without it
|
|
224
194
|
`Update instructions for agent "${agentName}"`, AGENT_NETWORK_DESIGNER_ID, onChunk, null, {
|
|
225
195
|
[AGENT_NETWORK_DEFINITION_KEY]: updated,
|
|
226
196
|
// Use the backend's canonical name, not the local UUID-based key.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AgentInfo, ConnectivityResponse } from "../../generated/neuro-san/NeuroSanClient.js";
|
|
2
|
+
import { AgentIconSuggestions } from "../Types/AgentIconSuggestions.js";
|
|
3
|
+
import { NetworkIconSuggestions } from "../Types/NetworkIconSuggestions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Utility function to send POST requests with JSON body and handle errors.
|
|
6
|
+
* Used for getting LLM suggestions for icons and branding colors.
|
|
7
|
+
* @template T The expected response type from the server.
|
|
8
|
+
* @param endpoint The API endpoint to send the request to.
|
|
9
|
+
* @param body The request body to send, which will be stringified to JSON.
|
|
10
|
+
* @returns The response from the server parsed as JSON.
|
|
11
|
+
* @throws An error if the request fails or the response is not ok.
|
|
12
|
+
*/
|
|
13
|
+
export declare const postJsonRequest: <T>(endpoint: string, body: Record<string, unknown>) => Promise<T>;
|
|
14
|
+
/**
|
|
15
|
+
* Get LLM suggestions for network icons.
|
|
16
|
+
*
|
|
17
|
+
* @note Will use cached suggestions if available to avoid unnecessary LLM calls
|
|
18
|
+
*
|
|
19
|
+
* @param networks The list of networks to get icon suggestions for.
|
|
20
|
+
* @returns A promise that resolves to a record mapping network names to suggested MUI icon names.
|
|
21
|
+
*/
|
|
22
|
+
export declare const getNetworkIconSuggestions: (networks: readonly AgentInfo[]) => Promise<NetworkIconSuggestions>;
|
|
23
|
+
/**
|
|
24
|
+
* Get LLM suggestions for agent icons based on their descriptions from Neuro-san.
|
|
25
|
+
*
|
|
26
|
+
* @note The entire connectivity information and metadata are sent as input to the LLM to help the LLM come up with
|
|
27
|
+
* better suggestions.
|
|
28
|
+
*
|
|
29
|
+
* @note Will use cached suggestions if available to avoid unnecessary LLM calls
|
|
30
|
+
*
|
|
31
|
+
* @param connectivity The connectivity information for the agents in the network, including their descriptions,
|
|
32
|
+
* tools, and connections.
|
|
33
|
+
* @return A promise that resolves to a record mapping agent names to suggested MUI icon names.
|
|
34
|
+
*/
|
|
35
|
+
export declare const getAgentIconSuggestions: (connectivity: ConnectivityResponse) => Promise<AgentIconSuggestions>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useIconSuggestionsStore } from "../../state/IconSuggestions.js";
|
|
2
|
+
/**
|
|
3
|
+
* Utility function to send POST requests with JSON body and handle errors.
|
|
4
|
+
* Used for getting LLM suggestions for icons and branding colors.
|
|
5
|
+
* @template T The expected response type from the server.
|
|
6
|
+
* @param endpoint The API endpoint to send the request to.
|
|
7
|
+
* @param body The request body to send, which will be stringified to JSON.
|
|
8
|
+
* @returns The response from the server parsed as JSON.
|
|
9
|
+
* @throws An error if the request fails or the response is not ok.
|
|
10
|
+
*/
|
|
11
|
+
export const postJsonRequest = async (endpoint, body) => {
|
|
12
|
+
const response = await fetch(endpoint, {
|
|
13
|
+
method: "POST",
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
},
|
|
17
|
+
body: JSON.stringify(body),
|
|
18
|
+
});
|
|
19
|
+
const jsonResponse = await response.json();
|
|
20
|
+
if (!response.ok || jsonResponse?.error) {
|
|
21
|
+
throw new Error(jsonResponse?.error || response?.statusText);
|
|
22
|
+
}
|
|
23
|
+
return jsonResponse;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Utility function to get icon suggestions from the cache or fetch from the server if not available in the cache.
|
|
27
|
+
*
|
|
28
|
+
* @param keys - The list of keys (agent names or network names) to get suggestions for.
|
|
29
|
+
* @param storeKey - The key in the cache (zustand store) to save the suggestions under.
|
|
30
|
+
* @param fetchSuggestions - Fetch function to query the LLM for suggestions
|
|
31
|
+
* @returns A promise that resolves to a record mapping the keys to suggested MUI icon names.
|
|
32
|
+
*/
|
|
33
|
+
const getSuggestions = async (keys, storeKey, fetchSuggestions) => {
|
|
34
|
+
// Check the cache for suggestions for all the keys.
|
|
35
|
+
// If any key is missing, we will fetch suggestions for all keys to keep it simple.
|
|
36
|
+
const cache = useIconSuggestionsStore.getState()[storeKey];
|
|
37
|
+
// Get the cached suggestions for the keys that are available in the cache
|
|
38
|
+
const cachedSuggestions = keys.reduce((acc, key) => {
|
|
39
|
+
const cached = cache[key];
|
|
40
|
+
if (cached) {
|
|
41
|
+
acc[key] = cached;
|
|
42
|
+
}
|
|
43
|
+
return acc;
|
|
44
|
+
}, {});
|
|
45
|
+
// If we have cached suggestions for all keys, return them
|
|
46
|
+
if (Object.keys(cachedSuggestions).length === keys.length) {
|
|
47
|
+
return cachedSuggestions;
|
|
48
|
+
}
|
|
49
|
+
// Cache miss. Request suggestions from LLM
|
|
50
|
+
const fetched = await fetchSuggestions();
|
|
51
|
+
// Write-through cache.
|
|
52
|
+
const state = useIconSuggestionsStore.getState();
|
|
53
|
+
if (storeKey === "agentIconSuggestions") {
|
|
54
|
+
state.setAgentIconSuggestions(fetched);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
state.setNetworkIconSuggestions(fetched);
|
|
58
|
+
}
|
|
59
|
+
return fetched;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Get LLM suggestions for network icons.
|
|
63
|
+
*
|
|
64
|
+
* @note Will use cached suggestions if available to avoid unnecessary LLM calls
|
|
65
|
+
*
|
|
66
|
+
* @param networks The list of networks to get icon suggestions for.
|
|
67
|
+
* @returns A promise that resolves to a record mapping network names to suggested MUI icon names.
|
|
68
|
+
*/
|
|
69
|
+
export const getNetworkIconSuggestions = async (networks) => getSuggestions(networks.map((network) => network.agent_name), "networkIconSuggestions", () => postJsonRequest("/api/networkIconSuggestions", { networks }));
|
|
70
|
+
/**
|
|
71
|
+
* Get LLM suggestions for agent icons based on their descriptions from Neuro-san.
|
|
72
|
+
*
|
|
73
|
+
* @note The entire connectivity information and metadata are sent as input to the LLM to help the LLM come up with
|
|
74
|
+
* better suggestions.
|
|
75
|
+
*
|
|
76
|
+
* @note Will use cached suggestions if available to avoid unnecessary LLM calls
|
|
77
|
+
*
|
|
78
|
+
* @param connectivity The connectivity information for the agents in the network, including their descriptions,
|
|
79
|
+
* tools, and connections.
|
|
80
|
+
* @return A promise that resolves to a record mapping agent names to suggested MUI icon names.
|
|
81
|
+
*/
|
|
82
|
+
export const getAgentIconSuggestions = async (connectivity) => getSuggestions(connectivity.connectivity_info.map((agent) => agent.origin), "agentIconSuggestions", () => postJsonRequest("/api/agentIconSuggestions", {
|
|
83
|
+
connectivity_info: connectivity.connectivity_info,
|
|
84
|
+
metadata: connectivity.metadata,
|
|
85
|
+
}));
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export * from "./components/Common/Breadcrumbs.js";
|
|
|
14
14
|
export * from "./components/Common/ConfirmationModal.js";
|
|
15
15
|
export * from "./components/Common/Footer.js";
|
|
16
16
|
export * from "./components/Common/LoadingSpinner.js";
|
|
17
|
-
export * from "./components/Common/MUIAccordion.js";
|
|
18
17
|
export * from "./components/Common/MUIAlert.js";
|
|
19
18
|
export * from "./components/Common/MUIDialog.js";
|
|
20
19
|
export * from "./components/Common/Navbar.js";
|
|
@@ -24,7 +23,7 @@ export * from "./components/Common/notification.js";
|
|
|
24
23
|
export * from "./components/ErrorPage/ErrorBoundary.js";
|
|
25
24
|
export * from "./components/MultiAgentAccelerator/AgentConversations.js";
|
|
26
25
|
export * from "./components/MultiAgentAccelerator/AgentCounts.js";
|
|
27
|
-
export * from "./components/MultiAgentAccelerator/AgentFlow.js";
|
|
26
|
+
export * from "./components/MultiAgentAccelerator/AgentFlow/AgentFlow.js";
|
|
28
27
|
export * from "./components/MultiAgentAccelerator/MultiAgentAccelerator.js";
|
|
29
28
|
export * from "./components/MultiAgentAccelerator/Sidebar/Sidebar.js";
|
|
30
29
|
export * from "./components/MultiAgentAccelerator/TemporaryNetworks.js";
|
|
@@ -38,5 +37,4 @@ export * from "./utils/Authentication.js";
|
|
|
38
37
|
export * from "./utils/File.js";
|
|
39
38
|
export * from "./utils/text.js";
|
|
40
39
|
export * from "./utils/title.js";
|
|
41
|
-
export * from "./utils/useLocalStorage.js";
|
|
42
40
|
export * from "./utils/zIndexLayers.js";
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,6 @@ export * from "./components/Common/Breadcrumbs.js";
|
|
|
29
29
|
export * from "./components/Common/ConfirmationModal.js";
|
|
30
30
|
export * from "./components/Common/Footer.js";
|
|
31
31
|
export * from "./components/Common/LoadingSpinner.js";
|
|
32
|
-
export * from "./components/Common/MUIAccordion.js";
|
|
33
32
|
export * from "./components/Common/MUIAlert.js";
|
|
34
33
|
export * from "./components/Common/MUIDialog.js";
|
|
35
34
|
export * from "./components/Common/Navbar.js";
|
|
@@ -39,7 +38,7 @@ export * from "./components/Common/notification.js";
|
|
|
39
38
|
export * from "./components/ErrorPage/ErrorBoundary.js";
|
|
40
39
|
export * from "./components/MultiAgentAccelerator/AgentConversations.js";
|
|
41
40
|
export * from "./components/MultiAgentAccelerator/AgentCounts.js";
|
|
42
|
-
export * from "./components/MultiAgentAccelerator/AgentFlow.js";
|
|
41
|
+
export * from "./components/MultiAgentAccelerator/AgentFlow/AgentFlow.js";
|
|
43
42
|
export * from "./components/MultiAgentAccelerator/MultiAgentAccelerator.js";
|
|
44
43
|
export * from "./components/MultiAgentAccelerator/Sidebar/Sidebar.js";
|
|
45
44
|
export * from "./components/MultiAgentAccelerator/TemporaryNetworks.js";
|
|
@@ -53,5 +52,4 @@ export * from "./utils/Authentication.js";
|
|
|
53
52
|
export * from "./utils/File.js";
|
|
54
53
|
export * from "./utils/text.js";
|
|
55
54
|
export * from "./utils/title.js";
|
|
56
|
-
export * from "./utils/useLocalStorage.js";
|
|
57
55
|
export * from "./utils/zIndexLayers.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AgentIconSuggestions } from "../controller/Types/AgentIconSuggestions.js";
|
|
2
|
+
import { NetworkIconSuggestions } from "../controller/Types/NetworkIconSuggestions.js";
|
|
3
|
+
export declare const MAX_SUGGESTIONS = 250;
|
|
4
|
+
/**
|
|
5
|
+
* Zustand state store for temporary networks, such as vibe coded networks created by the user.
|
|
6
|
+
*/
|
|
7
|
+
interface IconSuggestionsStore {
|
|
8
|
+
readonly networkIconSuggestions: NetworkIconSuggestions;
|
|
9
|
+
readonly setNetworkIconSuggestions: (networkIconSuggestions: NetworkIconSuggestions) => void;
|
|
10
|
+
readonly agentIconSuggestions: AgentIconSuggestions;
|
|
11
|
+
readonly setAgentIconSuggestions: (agentIconSuggestions: AgentIconSuggestions) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The hook that lets apps use the store.
|
|
15
|
+
*/
|
|
16
|
+
export declare const useIconSuggestionsStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<IconSuggestionsStore>, "persist"> & {
|
|
17
|
+
persist: {
|
|
18
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<IconSuggestionsStore, IconSuggestionsStore>>) => void;
|
|
19
|
+
clearStorage: () => void;
|
|
20
|
+
rehydrate: () => Promise<void> | void;
|
|
21
|
+
hasHydrated: () => boolean;
|
|
22
|
+
onHydrate: (fn: (state: IconSuggestionsStore) => void) => () => void;
|
|
23
|
+
onFinishHydration: (fn: (state: IconSuggestionsStore) => void) => () => void;
|
|
24
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<IconSuggestionsStore, IconSuggestionsStore>>;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Cognizant Technology Solutions Corp, www.cognizant.com.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { create } from "zustand";
|
|
17
|
+
import { persist } from "zustand/middleware";
|
|
18
|
+
// Store this many suggestions of each type before we start discarding the oldest ones.
|
|
19
|
+
export const MAX_SUGGESTIONS = 250;
|
|
20
|
+
/**
|
|
21
|
+
* Combines new suggestions with existing ones and truncates the result to MAX_SUGGESTIONS (cache eviction)
|
|
22
|
+
*
|
|
23
|
+
* @param current - The current suggestion object.
|
|
24
|
+
* @param newSuggestions - The new suggestions to add.
|
|
25
|
+
* @returns The updated and trimmed suggestion object.
|
|
26
|
+
**/
|
|
27
|
+
const updateSuggestions = (current, newSuggestions) => {
|
|
28
|
+
const combined = { ...current, ...newSuggestions };
|
|
29
|
+
const entries = Object.entries(combined);
|
|
30
|
+
if (entries.length > MAX_SUGGESTIONS) {
|
|
31
|
+
const sliced = entries.slice(entries.length - MAX_SUGGESTIONS);
|
|
32
|
+
return Object.fromEntries(sliced);
|
|
33
|
+
}
|
|
34
|
+
return combined;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The hook that lets apps use the store.
|
|
38
|
+
*/
|
|
39
|
+
export const useIconSuggestionsStore = create()(persist((set) => ({
|
|
40
|
+
networkIconSuggestions: {},
|
|
41
|
+
setNetworkIconSuggestions: (newSuggestions) => set((state) => ({
|
|
42
|
+
networkIconSuggestions: updateSuggestions(state.networkIconSuggestions, newSuggestions),
|
|
43
|
+
})),
|
|
44
|
+
agentIconSuggestions: {},
|
|
45
|
+
setAgentIconSuggestions: (newSuggestions) => set((state) => ({
|
|
46
|
+
agentIconSuggestions: updateSuggestions(state.agentIconSuggestions, newSuggestions),
|
|
47
|
+
})),
|
|
48
|
+
}), {
|
|
49
|
+
name: "icon-suggestions-store",
|
|
50
|
+
}));
|
package/dist/state/Settings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PALETTES } from "../Theme/Palettes.js";
|
|
2
2
|
/**
|
|
3
3
|
* A utility type that makes all properties in T deeply optional, since TypeScript's built-in Partial<T>
|
|
4
4
|
* only makes the top-level properties optional.
|
|
@@ -10,6 +10,14 @@ type DeepPartial<T> = {
|
|
|
10
10
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
11
11
|
};
|
|
12
12
|
export type LLMProvider = "OpenAI" | "Anthropic";
|
|
13
|
+
export type LogoSource = "none" | "generic" | "auto";
|
|
14
|
+
export type ByokKeyField = (typeof LLM_PROVIDER_API_KEY_FIELD)[LLMProvider];
|
|
15
|
+
interface ApiKeyEntry {
|
|
16
|
+
readonly value: string;
|
|
17
|
+
readonly expiresAt: number;
|
|
18
|
+
}
|
|
19
|
+
type ApiKeys = Partial<Record<LLMProvider, ApiKeyEntry>>;
|
|
20
|
+
export type PaletteKey = keyof typeof PALETTES | "brand";
|
|
13
21
|
/**
|
|
14
22
|
* User preference settings
|
|
15
23
|
*/
|
|
@@ -20,6 +28,7 @@ interface Settings {
|
|
|
20
28
|
readonly autoAgentIconColor: boolean;
|
|
21
29
|
readonly plasmaColor: string;
|
|
22
30
|
readonly rangePalette: PaletteKey;
|
|
31
|
+
readonly useNativeNames: boolean;
|
|
23
32
|
};
|
|
24
33
|
readonly branding: {
|
|
25
34
|
readonly customer: string | null;
|
|
@@ -28,37 +37,119 @@ interface Settings {
|
|
|
28
37
|
readonly background: string | null;
|
|
29
38
|
readonly rangePalette: string[] | null;
|
|
30
39
|
readonly iconSuggestion: string | null;
|
|
31
|
-
readonly logoSource:
|
|
40
|
+
readonly logoSource: LogoSource;
|
|
32
41
|
};
|
|
33
42
|
readonly behavior: {
|
|
34
43
|
readonly enableZenMode: boolean;
|
|
35
44
|
};
|
|
36
|
-
readonly apiKeys:
|
|
45
|
+
readonly apiKeys: ApiKeys;
|
|
46
|
+
readonly externalServices: {
|
|
47
|
+
neuroSanUrl: string | null;
|
|
48
|
+
};
|
|
37
49
|
}
|
|
38
50
|
/**
|
|
39
51
|
* Zustand state store for user preferences/Settings
|
|
40
52
|
*/
|
|
41
|
-
|
|
53
|
+
interface SettingsStore {
|
|
42
54
|
readonly settings: Settings;
|
|
43
55
|
readonly updateSettings: (updates: DeepPartial<Settings>) => void;
|
|
44
56
|
readonly resetSettings: () => void;
|
|
45
57
|
}
|
|
58
|
+
export declare const LLM_PROVIDER_API_KEY_FIELD: {
|
|
59
|
+
readonly OpenAI: "openai_api_key";
|
|
60
|
+
readonly Anthropic: "anthropic_api_key";
|
|
61
|
+
};
|
|
46
62
|
/**
|
|
47
63
|
* Default settings, used on first load and on reset
|
|
48
64
|
*/
|
|
49
65
|
export declare const DEFAULT_SETTINGS: Settings;
|
|
66
|
+
export declare const APP_SETTINGS_STORAGE_KEY = "app-settings";
|
|
67
|
+
export declare const SESSION_API_KEYS_STORAGE_KEY = "app-settings-api-keys";
|
|
68
|
+
export declare const API_KEYS_TTL_MS: number;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the API key for the given provider if it exists and is not expired, otherwise returns undefined.
|
|
71
|
+
* This helper should be used to retrieve API keys from the settings store, rather than accessing the store directly,
|
|
72
|
+
* to ensure that expired keys are not returned.
|
|
73
|
+
* @param apiKeys Set of API keys stored in the settings store
|
|
74
|
+
* @param provider The LLM provider for which to retrieve the API key
|
|
75
|
+
*/
|
|
76
|
+
export declare const getApiKey: (apiKeys: ApiKeys, provider: LLMProvider) => string;
|
|
50
77
|
/**
|
|
51
78
|
* The hook that lets apps use the store
|
|
52
79
|
*/
|
|
53
80
|
export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<SettingsStore>, "persist"> & {
|
|
54
81
|
persist: {
|
|
55
|
-
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<SettingsStore,
|
|
82
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<SettingsStore, {
|
|
83
|
+
settings: {
|
|
84
|
+
appearance: {
|
|
85
|
+
readonly agentIconColor: string;
|
|
86
|
+
readonly agentNodeColor: string;
|
|
87
|
+
readonly autoAgentIconColor: boolean;
|
|
88
|
+
readonly plasmaColor: string;
|
|
89
|
+
readonly rangePalette: PaletteKey;
|
|
90
|
+
readonly useNativeNames: boolean;
|
|
91
|
+
};
|
|
92
|
+
branding: {
|
|
93
|
+
readonly customer: string | null;
|
|
94
|
+
readonly primary: string | null;
|
|
95
|
+
readonly secondary: string | null;
|
|
96
|
+
readonly background: string | null;
|
|
97
|
+
readonly rangePalette: string[] | null;
|
|
98
|
+
readonly iconSuggestion: string | null;
|
|
99
|
+
readonly logoSource: LogoSource;
|
|
100
|
+
};
|
|
101
|
+
behavior: {
|
|
102
|
+
readonly enableZenMode: boolean;
|
|
103
|
+
};
|
|
104
|
+
externalServices: {
|
|
105
|
+
neuroSanUrl: string | null;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
updateSettings: (updates: DeepPartial<Settings>) => void;
|
|
109
|
+
resetSettings: () => void;
|
|
110
|
+
}>>) => void;
|
|
56
111
|
clearStorage: () => void;
|
|
57
112
|
rehydrate: () => Promise<void> | void;
|
|
58
113
|
hasHydrated: () => boolean;
|
|
59
114
|
onHydrate: (fn: (state: SettingsStore) => void) => () => void;
|
|
60
115
|
onFinishHydration: (fn: (state: SettingsStore) => void) => () => void;
|
|
61
|
-
getOptions: () => Partial<import("zustand/middleware").PersistOptions<SettingsStore,
|
|
116
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<SettingsStore, {
|
|
117
|
+
settings: {
|
|
118
|
+
appearance: {
|
|
119
|
+
readonly agentIconColor: string;
|
|
120
|
+
readonly agentNodeColor: string;
|
|
121
|
+
readonly autoAgentIconColor: boolean;
|
|
122
|
+
readonly plasmaColor: string;
|
|
123
|
+
readonly rangePalette: PaletteKey;
|
|
124
|
+
readonly useNativeNames: boolean;
|
|
125
|
+
};
|
|
126
|
+
branding: {
|
|
127
|
+
readonly customer: string | null;
|
|
128
|
+
readonly primary: string | null;
|
|
129
|
+
readonly secondary: string | null;
|
|
130
|
+
readonly background: string | null;
|
|
131
|
+
readonly rangePalette: string[] | null;
|
|
132
|
+
readonly iconSuggestion: string | null;
|
|
133
|
+
readonly logoSource: LogoSource;
|
|
134
|
+
};
|
|
135
|
+
behavior: {
|
|
136
|
+
readonly enableZenMode: boolean;
|
|
137
|
+
};
|
|
138
|
+
externalServices: {
|
|
139
|
+
neuroSanUrl: string | null;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
updateSettings: (updates: DeepPartial<Settings>) => void;
|
|
143
|
+
resetSettings: () => void;
|
|
144
|
+
}>>;
|
|
62
145
|
};
|
|
63
146
|
}>;
|
|
147
|
+
/**
|
|
148
|
+
* Custom hook to get the current color palette based on user settings.
|
|
149
|
+
* If the user has selected custom branding, it will return the palette for that.
|
|
150
|
+
* Otherwise, it will return one of the predefined palettes from the PALETTES object based on the user's selection.
|
|
151
|
+
*
|
|
152
|
+
* @returns An array of color hex codes representing the current color palette.
|
|
153
|
+
*/
|
|
154
|
+
export declare const usePalette: () => string[];
|
|
64
155
|
export {};
|