@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
package/dist/state/Settings.js
CHANGED
|
@@ -16,6 +16,14 @@ 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";
|
|
20
|
+
//#endregion Interfaces and Types
|
|
21
|
+
//#region Constants
|
|
22
|
+
// Mapping of LLM providers to their corresponding API key field names in the settings store.
|
|
23
|
+
export const LLM_PROVIDER_API_KEY_FIELD = {
|
|
24
|
+
OpenAI: "openai_api_key",
|
|
25
|
+
Anthropic: "anthropic_api_key",
|
|
26
|
+
};
|
|
19
27
|
/**
|
|
20
28
|
* Default settings, used on first load and on reset
|
|
21
29
|
*/
|
|
@@ -27,12 +35,13 @@ export const DEFAULT_SETTINGS = {
|
|
|
27
35
|
autoAgentIconColor: true,
|
|
28
36
|
rangePalette: "blue",
|
|
29
37
|
plasmaColor: "#2db81f",
|
|
38
|
+
useNativeNames: false,
|
|
30
39
|
},
|
|
31
40
|
branding: {
|
|
32
41
|
background: null,
|
|
33
42
|
customer: null,
|
|
34
43
|
iconSuggestion: null,
|
|
35
|
-
logoSource:
|
|
44
|
+
logoSource: "none",
|
|
36
45
|
primary: null,
|
|
37
46
|
rangePalette: null,
|
|
38
47
|
secondary: null,
|
|
@@ -41,23 +50,116 @@ export const DEFAULT_SETTINGS = {
|
|
|
41
50
|
enableZenMode: true,
|
|
42
51
|
},
|
|
43
52
|
apiKeys: {},
|
|
53
|
+
externalServices: {
|
|
54
|
+
neuroSanUrl: null,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
// Name for key where main app settings are saved
|
|
58
|
+
export const APP_SETTINGS_STORAGE_KEY = "app-settings";
|
|
59
|
+
// Name for key where API keys are saved in sessionStorage.
|
|
60
|
+
export const SESSION_API_KEYS_STORAGE_KEY = "app-settings-api-keys";
|
|
61
|
+
// TTL for API keys in sessionStorage. After this time, the keys will be cleared from sessionStorage.
|
|
62
|
+
// This is a backstop for cases where users rarely close their browser or tabs
|
|
63
|
+
export const API_KEYS_TTL_MS = 2 * 24 * 60 * 60 * 1000; // 2 days
|
|
64
|
+
//#endregion Constants
|
|
65
|
+
const hasPersistedSettings = (state) => typeof state === "object" &&
|
|
66
|
+
state !== null &&
|
|
67
|
+
"settings" in state &&
|
|
68
|
+
typeof state.settings === "object" &&
|
|
69
|
+
state.settings !== null;
|
|
70
|
+
/**
|
|
71
|
+
* Purges any persisted API keys from localStorage. This cleans up from previous versions of the cdoe.
|
|
72
|
+
* Once we are "reasonably sure" that no users are on old versions, we can remove this function.
|
|
73
|
+
*/
|
|
74
|
+
const purgePersistedApiKeys = () => {
|
|
75
|
+
const persisted = JSON.parse(localStorage.getItem(APP_SETTINGS_STORAGE_KEY) ?? "{}");
|
|
76
|
+
if (persisted.state?.settings) {
|
|
77
|
+
delete persisted.state.settings.apiKeys;
|
|
78
|
+
localStorage.setItem(APP_SETTINGS_STORAGE_KEY, JSON.stringify(persisted));
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Function to determine if an API key entry is valid (i.e., exists and is not expired).
|
|
83
|
+
* @param entry The API key entry to validate
|
|
84
|
+
* @returns True if the entry exists and is not expired, false otherwise
|
|
85
|
+
*/
|
|
86
|
+
const isApiKeyValid = (entry) => Boolean(entry) && entry.expiresAt > Date.now();
|
|
87
|
+
/**
|
|
88
|
+
* Returns the API key for the given provider if it exists and is not expired, otherwise returns undefined.
|
|
89
|
+
* This helper should be used to retrieve API keys from the settings store, rather than accessing the store directly,
|
|
90
|
+
* to ensure that expired keys are not returned.
|
|
91
|
+
* @param apiKeys Set of API keys stored in the settings store
|
|
92
|
+
* @param provider The LLM provider for which to retrieve the API key
|
|
93
|
+
*/
|
|
94
|
+
export const getApiKey = (apiKeys, provider) => {
|
|
95
|
+
const entry = apiKeys[provider];
|
|
96
|
+
return isApiKeyValid(entry) ? entry.value : undefined;
|
|
44
97
|
};
|
|
45
98
|
/**
|
|
46
99
|
* The hook that lets apps use the store
|
|
47
100
|
*/
|
|
48
101
|
export const useSettingsStore = create()(persist((set) => ({
|
|
49
102
|
settings: DEFAULT_SETTINGS,
|
|
50
|
-
updateSettings: (updates) => set((state) =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
103
|
+
updateSettings: (updates) => set((state) => {
|
|
104
|
+
const nextSettings = merge({}, state.settings, updates);
|
|
105
|
+
// Side effect: persist API keys in sessionStorage, unlike other Settings items which are persisted
|
|
106
|
+
// to localStorage (zustand default)
|
|
107
|
+
// Timestamp the API keys so we can purge them after a TTL.
|
|
108
|
+
if (updates.apiKeys) {
|
|
109
|
+
sessionStorage.setItem(SESSION_API_KEYS_STORAGE_KEY, JSON.stringify(nextSettings.apiKeys));
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
settings: nextSettings,
|
|
113
|
+
};
|
|
114
|
+
}),
|
|
115
|
+
resetSettings: () => {
|
|
116
|
+
sessionStorage.removeItem(SESSION_API_KEYS_STORAGE_KEY);
|
|
117
|
+
set({ settings: DEFAULT_SETTINGS });
|
|
118
|
+
},
|
|
54
119
|
}), {
|
|
55
|
-
name:
|
|
120
|
+
name: APP_SETTINGS_STORAGE_KEY,
|
|
121
|
+
// We don't want to persist API keys in localStorage, so we remove them before saving the state.
|
|
122
|
+
partialize: (state) => {
|
|
123
|
+
const { apiKeys: _apiKeys, ...settingsWithoutApiKeys } = state.settings;
|
|
124
|
+
return {
|
|
125
|
+
...state,
|
|
126
|
+
settings: settingsWithoutApiKeys,
|
|
127
|
+
};
|
|
128
|
+
},
|
|
56
129
|
merge: (persistedState, currentState) => {
|
|
57
|
-
//
|
|
130
|
+
// This is the hook that runs when the store is rehydrated from localStorage.
|
|
131
|
+
// We use it to purge any persisted API keys from previous versions of the code.
|
|
132
|
+
purgePersistedApiKeys();
|
|
133
|
+
// Now we can read the API keys from sessionStorage and filter out any expired keys.
|
|
134
|
+
const storedApiKeys = JSON.parse(sessionStorage.getItem(SESSION_API_KEYS_STORAGE_KEY) ?? "{}");
|
|
135
|
+
const sessionApiKeys = Object.fromEntries(Object.entries(storedApiKeys).filter(([, entry]) => isApiKeyValid(entry)));
|
|
136
|
+
sessionStorage.setItem(SESSION_API_KEYS_STORAGE_KEY, JSON.stringify(sessionApiKeys));
|
|
137
|
+
const persistedSettings = hasPersistedSettings(persistedState) ? persistedState.settings : {};
|
|
138
|
+
// Merge persisted settings with defaults to fill in any missing fields,
|
|
139
|
+
// then explicitly replace apiKeys with sessionStorage-backed keys.
|
|
58
140
|
return {
|
|
59
141
|
...currentState,
|
|
60
|
-
settings:
|
|
142
|
+
settings: {
|
|
143
|
+
...merge({}, DEFAULT_SETTINGS, persistedSettings),
|
|
144
|
+
apiKeys: sessionApiKeys,
|
|
145
|
+
},
|
|
61
146
|
};
|
|
62
147
|
},
|
|
63
148
|
}));
|
|
149
|
+
/**
|
|
150
|
+
* Custom hook to get the current color palette based on user settings.
|
|
151
|
+
* If the user has selected custom branding, it will return the palette for that.
|
|
152
|
+
* Otherwise, it will return one of the predefined palettes from the PALETTES object based on the user's selection.
|
|
153
|
+
*
|
|
154
|
+
* @returns An array of color hex codes representing the current color palette.
|
|
155
|
+
*/
|
|
156
|
+
export const usePalette = () => {
|
|
157
|
+
const brandPalette = useSettingsStore((state) => state.settings.branding.rangePalette);
|
|
158
|
+
const paletteKey = useSettingsStore((state) => state.settings.appearance.rangePalette);
|
|
159
|
+
if (paletteKey === "brand" && brandPalette) {
|
|
160
|
+
return brandPalette;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
return PALETTES[paletteKey];
|
|
164
|
+
}
|
|
165
|
+
};
|