@cognizant-ai-lab/ui-common 1.7.0 → 1.8.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 (67) hide show
  1. package/dist/Theme/Palettes.d.ts +0 -9
  2. package/dist/Theme/Palettes.js +0 -18
  3. package/dist/components/AgentChat/ChatCommon/ChatCommon.d.ts +4 -1
  4. package/dist/components/AgentChat/ChatCommon/ChatCommon.js +74 -47
  5. package/dist/components/AgentChat/ChatCommon/Const.d.ts +1 -0
  6. package/dist/components/AgentChat/ChatCommon/Const.js +2 -0
  7. package/dist/components/AgentChat/ChatCommon/ControlButtons.d.ts +1 -1
  8. package/dist/components/AgentChat/ChatCommon/ControlButtons.js +7 -4
  9. package/dist/components/AgentChat/ChatCommon/FormattedMarkdown.js +3 -0
  10. package/dist/components/AgentChat/ChatCommon/SendButton.js +7 -6
  11. package/dist/components/AgentChat/ChatCommon/SyntaxHighlighterThemes.js +1 -1
  12. package/dist/components/AgentChat/ChatCommon/Thinking.d.ts +1 -0
  13. package/dist/components/AgentChat/ChatCommon/Thinking.js +10 -7
  14. package/dist/components/AgentChat/Common/LlmChatButton.d.ts +0 -2
  15. package/dist/components/AgentChat/Common/LlmChatButton.js +6 -9
  16. package/dist/components/AgentChat/VoiceChat/MicrophoneButton.js +12 -10
  17. package/dist/components/Common/Navbar.js +24 -22
  18. package/dist/components/Common/StatusLight.d.ts +9 -0
  19. package/dist/components/Common/StatusLight.js +21 -0
  20. package/dist/components/ErrorPage/ErrorBoundary.js +1 -1
  21. package/dist/components/ErrorPage/ErrorPage.d.ts +3 -3
  22. package/dist/components/ErrorPage/ErrorPage.js +4 -3
  23. package/dist/components/Logo/Common.d.ts +4 -0
  24. package/dist/components/Logo/Common.js +8 -0
  25. package/dist/components/Logo/CustomerLogo.d.ts +23 -0
  26. package/dist/components/Logo/CustomerLogo.js +41 -0
  27. package/dist/components/MultiAgentAccelerator/AgentConversations.js +0 -1
  28. package/dist/components/MultiAgentAccelerator/AgentFlow.js +85 -53
  29. package/dist/components/MultiAgentAccelerator/AgentNode.js +23 -27
  30. package/dist/components/MultiAgentAccelerator/GraphLayouts.d.ts +17 -10
  31. package/dist/components/MultiAgentAccelerator/GraphLayouts.js +4 -6
  32. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.d.ts +3 -9
  33. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +28 -32
  34. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.d.ts +0 -5
  35. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +30 -25
  36. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +3 -4
  37. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +84 -168
  38. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +30 -13
  39. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +157 -100
  40. package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.js +10 -8
  41. package/dist/components/MultiAgentAccelerator/const.d.ts +2 -0
  42. package/dist/components/MultiAgentAccelerator/const.js +4 -0
  43. package/dist/components/Settings/ApiKeyInput.js +7 -8
  44. package/dist/components/Settings/InfoTip.d.ts +8 -0
  45. package/dist/components/Settings/InfoTip.js +14 -0
  46. package/dist/components/Settings/SettingsDialog.js +355 -181
  47. package/dist/components/Settings/SettingsRow.d.ts +18 -0
  48. package/dist/components/Settings/SettingsRow.js +35 -0
  49. package/dist/controller/agent/Agent.d.ts +3 -20
  50. package/dist/controller/agent/Agent.js +9 -43
  51. package/dist/controller/agent/IconSuggestions.d.ts +35 -0
  52. package/dist/controller/agent/IconSuggestions.js +85 -0
  53. package/dist/index.d.ts +0 -2
  54. package/dist/index.js +0 -2
  55. package/dist/state/IconSuggestions.d.ts +27 -0
  56. package/dist/state/IconSuggestions.js +50 -0
  57. package/dist/state/Settings.d.ts +17 -3
  58. package/dist/state/Settings.js +23 -1
  59. package/dist/tsconfig.build.tsbuildinfo +1 -1
  60. package/dist/utils/title.js +1 -1
  61. package/package.json +5 -1
  62. package/dist/components/Common/CustomerLogo.d.ts +0 -17
  63. package/dist/components/Common/CustomerLogo.js +0 -47
  64. package/dist/components/Common/MUIAccordion.d.ts +0 -17
  65. package/dist/components/Common/MUIAccordion.js +0 -66
  66. package/dist/utils/useLocalStorage.d.ts +0 -1
  67. package/dist/utils/useLocalStorage.js +0 -55
@@ -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,19 @@
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
- import { NetworkIconSuggestions } from "../Types/NetworkIconSuggestions.js";
10
5
  export interface TestConnectionResult {
11
- readonly success: boolean;
6
+ readonly httpStatus?: number;
12
7
  readonly status?: string;
8
+ readonly success: boolean;
13
9
  readonly version?: string;
14
10
  }
15
11
  /**
16
12
  * Test connection for a neuro-san server.
17
13
  * @param url The neuro-san server URL.
18
- * @returns A boolean indicating whether the connection was successful.
14
+ * @returns An object with information about the connection test result
19
15
  */
20
16
  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
17
  /**
35
18
  * Get LLM suggestions for branding colors based on the company name. This is used to customize the UI colors
36
19
  * to match the user's company branding.
@@ -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 A boolean indicating whether the connection was successful.
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,7 +49,11 @@ 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 { success: false, status: response.statusText };
52
+ return {
53
+ success: false,
54
+ httpStatus: response.status,
55
+ status: response.statusText,
56
+ };
52
57
  }
53
58
  const jsonResponse = await response.json();
54
59
  // eslint-disable-next-line no-shadow
@@ -57,7 +62,7 @@ export const testConnection = async (url) => {
57
62
  const success = status === "healthy" || status === "ok";
58
63
  // For now, just capture the Neuro-san version since that's all the server returns. More can be added later.
59
64
  const version = jsonResponse?.versions?.["neuro-san"];
60
- return { success, status, version };
65
+ return { httpStatus: response.status, success, status, version };
61
66
  }
62
67
  catch (error) {
63
68
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -67,45 +72,6 @@ export const testConnection = async (url) => {
67
72
  clearTimeout(timeout);
68
73
  }
69
74
  };
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
75
  /**
110
76
  * Get LLM suggestions for branding colors based on the company name. This is used to customize the UI colors
111
77
  * to match the user's company branding.
@@ -220,7 +186,7 @@ export const getAgentFunction = async (url, agent, userId) => {
220
186
  */
221
187
  export const sendNetworkDesignerUpdate = async (url, signal, agentName, updated, agentNetworkName, currentUser, onChunk) => {
222
188
  await sendChatQuery(url, signal,
223
- // Shouldn't have to pass a user message, but API behaves different without it
189
+ // Shouldn't have to pass a user message, but API behaves differently without it
224
190
  `Update instructions for agent "${agentName}"`, AGENT_NETWORK_DESIGNER_ID, onChunk, null, {
225
191
  [AGENT_NETWORK_DEFINITION_KEY]: updated,
226
192
  // 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";
@@ -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";
@@ -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
+ }));
@@ -1,4 +1,4 @@
1
- import { PaletteKey } from "../Theme/Palettes.js";
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,7 @@ 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";
13
14
  /**
14
15
  * User preference settings
15
16
  */
@@ -20,6 +21,7 @@ interface Settings {
20
21
  readonly autoAgentIconColor: boolean;
21
22
  readonly plasmaColor: string;
22
23
  readonly rangePalette: PaletteKey;
24
+ readonly useNativeNames: boolean;
23
25
  };
24
26
  readonly branding: {
25
27
  readonly customer: string | null;
@@ -28,17 +30,20 @@ interface Settings {
28
30
  readonly background: string | null;
29
31
  readonly rangePalette: string[] | null;
30
32
  readonly iconSuggestion: string | null;
31
- readonly logoSource: "none" | "generic" | "auto" | null;
33
+ readonly logoSource: LogoSource;
32
34
  };
33
35
  readonly behavior: {
34
36
  readonly enableZenMode: boolean;
35
37
  };
36
38
  readonly apiKeys: Partial<Record<LLMProvider, string>>;
39
+ readonly externalServices: {
40
+ neuroSanUrl: string | null;
41
+ };
37
42
  }
38
43
  /**
39
44
  * Zustand state store for user preferences/Settings
40
45
  */
41
- export interface SettingsStore {
46
+ interface SettingsStore {
42
47
  readonly settings: Settings;
43
48
  readonly updateSettings: (updates: DeepPartial<Settings>) => void;
44
49
  readonly resetSettings: () => void;
@@ -61,4 +66,13 @@ export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<impo
61
66
  getOptions: () => Partial<import("zustand/middleware").PersistOptions<SettingsStore, SettingsStore>>;
62
67
  };
63
68
  }>;
69
+ export type PaletteKey = keyof typeof PALETTES | "brand";
70
+ /**
71
+ * Custom hook to get the current color palette based on user settings.
72
+ * If the user has selected custom branding, it will return the palette for that.
73
+ * Otherwise, it will return one of the predefined palettes from the PALETTES object based on the user's selection.
74
+ *
75
+ * @returns An array of color hex codes representing the current color palette.
76
+ */
77
+ export declare const usePalette: () => string[];
64
78
  export {};
@@ -16,6 +16,7 @@ limitations under the License.
16
16
  import { merge } from "lodash-es";
17
17
  import { create } from "zustand";
18
18
  import { persist } from "zustand/middleware";
19
+ import { PALETTES } from "../Theme/Palettes.js";
19
20
  /**
20
21
  * Default settings, used on first load and on reset
21
22
  */
@@ -27,12 +28,13 @@ export const DEFAULT_SETTINGS = {
27
28
  autoAgentIconColor: true,
28
29
  rangePalette: "blue",
29
30
  plasmaColor: "#2db81f",
31
+ useNativeNames: false,
30
32
  },
31
33
  branding: {
32
34
  background: null,
33
35
  customer: null,
34
36
  iconSuggestion: null,
35
- logoSource: null,
37
+ logoSource: "none",
36
38
  primary: null,
37
39
  rangePalette: null,
38
40
  secondary: null,
@@ -41,6 +43,9 @@ export const DEFAULT_SETTINGS = {
41
43
  enableZenMode: true,
42
44
  },
43
45
  apiKeys: {},
46
+ externalServices: {
47
+ neuroSanUrl: null,
48
+ },
44
49
  };
45
50
  /**
46
51
  * The hook that lets apps use the store
@@ -61,3 +66,20 @@ export const useSettingsStore = create()(persist((set) => ({
61
66
  };
62
67
  },
63
68
  }));
69
+ /**
70
+ * Custom hook to get the current color palette based on user settings.
71
+ * If the user has selected custom branding, it will return the palette for that.
72
+ * Otherwise, it will return one of the predefined palettes from the PALETTES object based on the user's selection.
73
+ *
74
+ * @returns An array of color hex codes representing the current color palette.
75
+ */
76
+ export const usePalette = () => {
77
+ const brandPalette = useSettingsStore((state) => state.settings.branding.rangePalette);
78
+ const paletteKey = useSettingsStore((state) => state.settings.appearance.rangePalette);
79
+ if (paletteKey === "brand" && brandPalette) {
80
+ return brandPalette;
81
+ }
82
+ else {
83
+ return PALETTES[paletteKey];
84
+ }
85
+ };