@cognizant-ai-lab/ui-common 1.2.4-main.03d1f27.50

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 (137) hide show
  1. package/README.md +287 -0
  2. package/dist/Theme/Palettes.d.ts +18 -0
  3. package/dist/Theme/Palettes.js +94 -0
  4. package/dist/Theme/Theme.d.ts +22 -0
  5. package/dist/Theme/Theme.js +58 -0
  6. package/dist/components/AgentChat/ChatCommon.d.ts +96 -0
  7. package/dist/components/AgentChat/ChatCommon.js +617 -0
  8. package/dist/components/AgentChat/ControlButtons.d.ts +16 -0
  9. package/dist/components/AgentChat/ControlButtons.js +26 -0
  10. package/dist/components/AgentChat/FormattedMarkdown.d.ts +32 -0
  11. package/dist/components/AgentChat/FormattedMarkdown.js +80 -0
  12. package/dist/components/AgentChat/Greetings.d.ts +1 -0
  13. package/dist/components/AgentChat/Greetings.js +38 -0
  14. package/dist/components/AgentChat/LlmChatButton.d.ts +8 -0
  15. package/dist/components/AgentChat/LlmChatButton.js +33 -0
  16. package/dist/components/AgentChat/SendButton.d.ts +12 -0
  17. package/dist/components/AgentChat/SendButton.js +28 -0
  18. package/dist/components/AgentChat/SyntaxHighlighterThemes.d.ts +14 -0
  19. package/dist/components/AgentChat/SyntaxHighlighterThemes.js +27 -0
  20. package/dist/components/AgentChat/Types.d.ts +17 -0
  21. package/dist/components/AgentChat/Types.js +26 -0
  22. package/dist/components/AgentChat/UserQueryDisplay.d.ts +5 -0
  23. package/dist/components/AgentChat/UserQueryDisplay.js +31 -0
  24. package/dist/components/AgentChat/Utils.d.ts +12 -0
  25. package/dist/components/AgentChat/Utils.js +67 -0
  26. package/dist/components/AgentChat/VoiceChat/MicrophoneButton.d.ts +29 -0
  27. package/dist/components/AgentChat/VoiceChat/MicrophoneButton.js +55 -0
  28. package/dist/components/AgentChat/VoiceChat/VoiceChat.d.ts +33 -0
  29. package/dist/components/AgentChat/VoiceChat/VoiceChat.js +180 -0
  30. package/dist/components/Authentication/Auth.d.ts +14 -0
  31. package/dist/components/Authentication/Auth.js +58 -0
  32. package/dist/components/ChatBot/ChatBot.d.ts +20 -0
  33. package/dist/components/ChatBot/ChatBot.js +75 -0
  34. package/dist/components/Common/Breadcrumbs.d.ts +6 -0
  35. package/dist/components/Common/Breadcrumbs.js +36 -0
  36. package/dist/components/Common/ConfirmationModal.d.ts +14 -0
  37. package/dist/components/Common/ConfirmationModal.js +62 -0
  38. package/dist/components/Common/CustomerLogo.d.ts +17 -0
  39. package/dist/components/Common/CustomerLogo.js +49 -0
  40. package/dist/components/Common/Footer.d.ts +18 -0
  41. package/dist/components/Common/Footer.js +59 -0
  42. package/dist/components/Common/LlmChatOptionsButton.d.ts +6 -0
  43. package/dist/components/Common/LlmChatOptionsButton.js +31 -0
  44. package/dist/components/Common/LoadingSpinner.d.ts +10 -0
  45. package/dist/components/Common/LoadingSpinner.js +24 -0
  46. package/dist/components/Common/MUIAccordion.d.ts +17 -0
  47. package/dist/components/Common/MUIAccordion.js +66 -0
  48. package/dist/components/Common/MUIAlert.d.ts +12 -0
  49. package/dist/components/Common/MUIAlert.js +44 -0
  50. package/dist/components/Common/MUIDialog.d.ts +16 -0
  51. package/dist/components/Common/MUIDialog.js +40 -0
  52. package/dist/components/Common/Navbar.d.ts +17 -0
  53. package/dist/components/Common/Navbar.js +163 -0
  54. package/dist/components/Common/PageLoader.d.ts +5 -0
  55. package/dist/components/Common/PageLoader.js +25 -0
  56. package/dist/components/Common/Snackbar.d.ts +8 -0
  57. package/dist/components/Common/Snackbar.js +76 -0
  58. package/dist/components/Common/notification.d.ts +18 -0
  59. package/dist/components/Common/notification.js +79 -0
  60. package/dist/components/ErrorPage/ErrorBoundary.d.ts +38 -0
  61. package/dist/components/ErrorPage/ErrorBoundary.js +77 -0
  62. package/dist/components/ErrorPage/ErrorPage.d.ts +12 -0
  63. package/dist/components/ErrorPage/ErrorPage.js +47 -0
  64. package/dist/components/MultiAgentAccelerator/AgentConversations.d.ts +17 -0
  65. package/dist/components/MultiAgentAccelerator/AgentConversations.js +77 -0
  66. package/dist/components/MultiAgentAccelerator/AgentCounts.d.ts +12 -0
  67. package/dist/components/MultiAgentAccelerator/AgentCounts.js +21 -0
  68. package/dist/components/MultiAgentAccelerator/AgentFlow.d.ts +23 -0
  69. package/dist/components/MultiAgentAccelerator/AgentFlow.js +315 -0
  70. package/dist/components/MultiAgentAccelerator/AgentNode.d.ts +20 -0
  71. package/dist/components/MultiAgentAccelerator/AgentNode.js +172 -0
  72. package/dist/components/MultiAgentAccelerator/GraphLayouts.d.ts +36 -0
  73. package/dist/components/MultiAgentAccelerator/GraphLayouts.js +299 -0
  74. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.d.ts +16 -0
  75. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +367 -0
  76. package/dist/components/MultiAgentAccelerator/PlasmaEdge.d.ts +3 -0
  77. package/dist/components/MultiAgentAccelerator/PlasmaEdge.js +126 -0
  78. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.d.ts +15 -0
  79. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +104 -0
  80. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +17 -0
  81. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +291 -0
  82. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +19 -0
  83. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +113 -0
  84. package/dist/components/MultiAgentAccelerator/TemporaryNetworks.d.ts +26 -0
  85. package/dist/components/MultiAgentAccelerator/TemporaryNetworks.js +20 -0
  86. package/dist/components/MultiAgentAccelerator/ThoughtBubbleEdge.d.ts +14 -0
  87. package/dist/components/MultiAgentAccelerator/ThoughtBubbleEdge.js +15 -0
  88. package/dist/components/MultiAgentAccelerator/ThoughtBubbleOverlay.d.ts +12 -0
  89. package/dist/components/MultiAgentAccelerator/ThoughtBubbleOverlay.js +463 -0
  90. package/dist/components/MultiAgentAccelerator/const.d.ts +5 -0
  91. package/dist/components/MultiAgentAccelerator/const.js +25 -0
  92. package/dist/components/Settings/FadingCheckmark.d.ts +14 -0
  93. package/dist/components/Settings/FadingCheckmark.js +43 -0
  94. package/dist/components/Settings/SettingsDialog.d.ts +9 -0
  95. package/dist/components/Settings/SettingsDialog.js +265 -0
  96. package/dist/const.d.ts +9 -0
  97. package/dist/const.js +29 -0
  98. package/dist/controller/Types/AgentIconSuggestions.d.ts +4 -0
  99. package/dist/controller/Types/AgentIconSuggestions.js +1 -0
  100. package/dist/controller/Types/Branding.d.ts +12 -0
  101. package/dist/controller/Types/Branding.js +1 -0
  102. package/dist/controller/Types/NetworkIconSuggestions.d.ts +4 -0
  103. package/dist/controller/Types/NetworkIconSuggestions.js +1 -0
  104. package/dist/controller/agent/Agent.d.ts +78 -0
  105. package/dist/controller/agent/Agent.js +215 -0
  106. package/dist/controller/llm/LlmChat.d.ts +28 -0
  107. package/dist/controller/llm/LlmChat.js +112 -0
  108. package/dist/controller/llm/endpoints.d.ts +1 -0
  109. package/dist/controller/llm/endpoints.js +17 -0
  110. package/dist/generated/neuro-san/NeuroSanClient.d.ts +413 -0
  111. package/dist/generated/neuro-san/NeuroSanClient.js +28 -0
  112. package/dist/index.d.ts +42 -0
  113. package/dist/index.js +57 -0
  114. package/dist/state/Environment.d.ts +20 -0
  115. package/dist/state/Environment.js +35 -0
  116. package/dist/state/Settings.d.ts +62 -0
  117. package/dist/state/Settings.js +62 -0
  118. package/dist/state/TemporaryNetworks.d.ts +32 -0
  119. package/dist/state/TemporaryNetworks.js +26 -0
  120. package/dist/state/UserInfo.d.ts +16 -0
  121. package/dist/state/UserInfo.js +27 -0
  122. package/dist/tsconfig.build.tsbuildinfo +1 -0
  123. package/dist/utils/Authentication.d.ts +31 -0
  124. package/dist/utils/Authentication.js +94 -0
  125. package/dist/utils/BrowserNavigation.d.ts +5 -0
  126. package/dist/utils/BrowserNavigation.js +22 -0
  127. package/dist/utils/text.d.ts +28 -0
  128. package/dist/utils/text.js +62 -0
  129. package/dist/utils/title.d.ts +1 -0
  130. package/dist/utils/title.js +20 -0
  131. package/dist/utils/types.d.ts +17 -0
  132. package/dist/utils/types.js +16 -0
  133. package/dist/utils/useLocalStorage.d.ts +1 -0
  134. package/dist/utils/useLocalStorage.js +55 -0
  135. package/dist/utils/zIndexLayers.d.ts +2 -0
  136. package/dist/utils/zIndexLayers.js +17 -0
  137. package/package.json +71 -0
package/README.md ADDED
@@ -0,0 +1,287 @@
1
+ # @cognizant-ai-lab/ui-common
2
+
3
+ A comprehensive React component library and utilities package for building user interfaces for Neuro-san AI
4
+ applications. Contains components for chat interfaces, multi-agent flow visualization, theming and more.
5
+
6
+ ## Copyright
7
+
8
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ https://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ ## Quickstart
23
+
24
+ For this quickstart, we'll show how to use the `MultiAgentAccelerator` component, which is a demo application
25
+ showcasing the components in this package.
26
+
27
+ You will need access to a Neuro-san API backend to use the components in this package.
28
+
29
+ If you don't already have a ReactJS application, create one, for example, using [Create React App](https://create-react-app.dev/):
30
+ The following assumes you're using TypeScript (recommended):
31
+
32
+ ```bash
33
+ npx create-react-app my-app --template typescript
34
+ cd my-app
35
+ ```
36
+
37
+ Install the library:
38
+
39
+ ```bash
40
+ npm install @cognizant-ai-lab/ui-common
41
+ ```
42
+
43
+ Then edit `src/App.tsx` (assuming TypeScript) and replace the contents with the code below:
44
+
45
+ ```tsx
46
+ export default function MyApp() {
47
+ return (
48
+ <MultiAgentAccelerator
49
+ userInfo={{userName: "Alice", userImage: "https://example.com/alice.png"}}
50
+ backendNeuroSanApiUrl="https://my-neuro-san-api.example.com"
51
+ />
52
+ )
53
+ }
54
+ ```
55
+
56
+ Run your app with `npm start` or `yarn start`, and you should see the Multi-Agent Accelerator interface,
57
+ which is a demo application showcasing the components in this package. You can select an agent, chat with that agent
58
+ via the chat interface, and visualize the agent network flow.
59
+
60
+ ## Features
61
+
62
+ - **UI Components**: Ready-to-use React components for AI chat interfaces, navigation, dialogs, and more
63
+ - **Multi-Agent Visualization**: Interactive flow diagrams for visualizing agent networks
64
+ - **Authentication**: Built-in authentication components supporting multiple providers
65
+ - **State Management**: Zustand-based stores for environment, settings, and user info
66
+ - **Theme Support**: Dark mode support with customizable, MUI-based theming
67
+ - **Type Safety**: Full TypeScript support with generated OpenAPI types
68
+ - **LLM Integration**: Controllers for interacting with language models and AI agents
69
+
70
+ ## Technologies Used
71
+
72
+ Among the technologies and libraries used in this package are:
73
+
74
+ - ESLint and Prettier (for code quality)
75
+ - Jest and React Testing Library (for testing)
76
+ - MUI
77
+ - next-auth (for authentication)
78
+ - React
79
+ - React Flow (for multi-agent visualization)
80
+ - TypeScript
81
+ - Zustand
82
+
83
+ ## Package Structure
84
+
85
+ ```
86
+ ui-common/
87
+ ├── components/ # React components
88
+ │ ├── AgentChat/ # Chat interface components
89
+ │ ├── Authentication/ # Auth components
90
+ │ ├── ChatBot/ # ChatBot components
91
+ │ ├── Common/ # Common UI components (dialogs, navbar, etc.)
92
+ │ ├── ErrorPage/ # Error handling components
93
+ │ ├── MultiAgentAccelerator/ # Agent flow visualization
94
+ │ └── Settings/ # Settings dialog components
95
+ ├── controller/ # Backend interaction controllers
96
+ │ ├── agent/ # Agent API controllers
97
+ │ └── llm/ # LLM interaction controllers
98
+ ├── state/ # Zustand state stores
99
+ ├── Theme/ # Theming utilities
100
+ ├── utils/ # Utility functions
101
+ └── generated/ # Auto-generated API types
102
+ ```
103
+
104
+ ## Usage
105
+
106
+ #### Example application
107
+
108
+ Refer to [MAUI](https://github.com/cognizant-ai-lab/neuro-san-ui/tree/main/apps/main), the Multi-Agent Accelerator UI,
109
+ for a real-world application example that uses these components.
110
+
111
+ ### Basic Import
112
+
113
+ ```typescript
114
+ import {ChatCommon, Navbar, MUIDialog, LoadingSpinner, useEnvironment, useUserInfo} from "@cognizant-ai-lab/ui-common"
115
+ ```
116
+
117
+ ### Using Components
118
+
119
+ #### ChatCommon
120
+
121
+ See `ChatCommonProps` for all available props and their types. Here's a basic example of how to use the `ChatCommon`
122
+ component in a React application:
123
+
124
+ ```tsx
125
+ import {ChatCommon} from "@cognizant-ai-lab/ui-common"
126
+ import {AIMessage, HumanMessage} from "@langchain/core/messages"
127
+ import {useState} from "react"
128
+
129
+ function ChatInterface() {
130
+ const [isAwaitingLlm, setIsAwaitingLlm] = useState(false)
131
+
132
+ return (
133
+ <ChatCommon
134
+ id="agent-network-ui"
135
+ ref={chatRef} // If you need to access internal methods, like calling "Stop" when user clicks stop
136
+ neuroSanURL={neuroSanURL} // Base URL for Neuro-san API. Must point to a valid Neuro-san server
137
+ currentUser="Alice" // Current user's name, used for chat attribution in API calls and display
138
+ setIsAwaitingLlm={setIsAwaitingLlm} // Used to set whether we're currently waiting for an LLM response,
139
+ // which can be used to disable input and show loading states
140
+ isAwaitingLlm={isAwaitingLlm} // Used to indicate whether we're currently waiting for an LLM response
141
+ targetAgent={selectedNetwork} // The agent we're currently chatting with in Neuro-san.
142
+ onChunkReceived={onChunkReceived} // Callback function that will be called with each new chunk of response
143
+ // from the LLM. You can use this to update your UI in real time
144
+ // as the response comes in.
145
+ />
146
+ )
147
+ }
148
+ ```
149
+
150
+ ### Using Controllers
151
+
152
+ #### Test Agent Connection
153
+
154
+ Used for testing connectivity to a Neuro-san server and retrieving version information.
155
+
156
+ ```typescript
157
+ import {testConnection} from "@cognizant-ai-lab/ui-common"
158
+
159
+ async function checkServer() {
160
+ const result = await testConnection("https://api.example.com")
161
+
162
+ if (result.success) {
163
+ console.log(`Connected! Version: ${result.version}`)
164
+ } else {
165
+ console.error(`Connection failed: ${result.status}`)
166
+ }
167
+ }
168
+ ```
169
+
170
+ ### Send Chat Query
171
+
172
+ Send a chat query to the Agent LLM API. If you are using `ChatCommon`, you shouldn't need to call this directly.
173
+
174
+ ```typescript
175
+ import {sendChatQuery} from "@cognizant-ai-lab/ui-common"
176
+ async function sendMessage() {
177
+ const controller = new AbortController()
178
+
179
+ const response = await sendChatQuery(
180
+ neuroSanURL,
181
+ controller.signal,
182
+ "What is the weather in 90210 today?",
183
+ "weather_agent",
184
+ (chunk) => console.log("Received chunk:", chunk),
185
+ chatContext,
186
+ slyData,
187
+ currentUser
188
+ )
189
+ }
190
+ ```
191
+
192
+ #### Send LLM Request
193
+
194
+ Lower-level interface to send chat messages to a designated LLM and stream response tokens to the supplied callback
195
+ function. You should not need to call this directly if you are using `ChatCommon`. It is a lower-level interface than
196
+ `sendChatQuery` and is used by that function under the hood. This function can also be used to send messages to
197
+ "legacy" agents, which are not built using the Agent API but still accept chat messages via the LLM API.
198
+
199
+ ```typescript
200
+ import {sendLlmRequest} from "@cognizant-ai-lab/ui-common"
201
+ import {HumanMessage} from "@langchain/core/messages"
202
+
203
+ async function chatWithAgent() {
204
+ const controller = new AbortController()
205
+
206
+ await sendLlmRequest(
207
+ (token) => console.log("Received:", token),
208
+ controller.signal,
209
+ "/api/chat",
210
+ {temperature: 0.7},
211
+ "What is the weather?",
212
+ [new HumanMessage("Hello")],
213
+ "user-123"
214
+ )
215
+ }
216
+ ```
217
+
218
+ ### Theme Support
219
+
220
+ The package includes built-in theme support using MUI theming. The components will automatically respond to
221
+ the currently active MUI theme.
222
+
223
+ ## Available Components
224
+
225
+ ### AgentChat
226
+
227
+ - `ChatCommon` - Main chat interface component
228
+ - `ControlButtons` - Chat control buttons (clear, scroll, etc.)
229
+ - `LlmChatButton` - Button to initiate LLM chat
230
+ - `SendButton` - Message send button
231
+ - `UserQueryDisplay` - Display user queries
232
+
233
+ ### Multi-Agent Accelerator
234
+
235
+ - `MultiAgentAccelerator` - Main multi-agent flow component
236
+ - `AgentFlow` - Agent flow visualization
237
+ - `Sidebar` - Agent networks sidebar
238
+
239
+ ## API Controllers
240
+
241
+ ### Agent Controller
242
+
243
+ Various functions for interacting with the Neuro-san Agent API, such as retrieving lists of
244
+ agent networks and sending chat messages to agents.
245
+
246
+ ## TypeScript Support
247
+
248
+ This package is written in TypeScript and includes full type definitions. All components, utilities, and API types are
249
+ exported for use in your TypeScript projects.
250
+
251
+ ## Development
252
+
253
+ ### Building from Source
254
+
255
+ ```bash
256
+ # Install dependencies
257
+ yarn install
258
+
259
+ # Generate OpenAPI types
260
+ yarn generate
261
+
262
+ # Build the package
263
+ yarn build
264
+
265
+ ```
266
+
267
+ ## Contributing
268
+
269
+ This package is part of the [Neuro-san UI](https://github.com/cognizant-ai-lab/neuro-san-ui) project.
270
+ Please refer to the main repository [contribution guidelines](https://github.com/cognizant-ai-lab/neuro-san-ui/blob/main/CONTRIBUTING.md).
271
+
272
+ ## License
273
+
274
+ Apache License 2.0 - See LICENSE file for details
275
+
276
+ ## Support
277
+
278
+ For questions or issues, contact the Cognizant Neuro AI support team at NeuroAiSupport@cognizant.com
279
+
280
+ ## Related Projects
281
+
282
+ - [neuro-san](https://github.com/cognizant-ai-lab/neuro-san) - Neuro-san core library
283
+ - [neuro-san-studio](https://github.com/cognizant-ai-lab/neuro-san-studio) - Neuro-san examples and studio
284
+
285
+ ---
286
+
287
+ For more detailed documentation and examples, visit the [GitHub repository](https://github.com/cognizant-ai-lab/neuro-san-ui).
@@ -0,0 +1,18 @@
1
+ export declare const PALETTES: {
2
+ blue: string[];
3
+ red: string[];
4
+ green: string[];
5
+ yellow: string[];
6
+ grayScale: string[];
7
+ coldToHot: string[];
8
+ visionImpaired: string[];
9
+ };
10
+ export type PaletteKey = keyof typeof PALETTES | "brand";
11
+ /**
12
+ * Custom hook to get the current color palette based on user settings.
13
+ * If the user has selected custom branding, it will return the palette for that.
14
+ * Otherwise, it will return one of the predefined palettes from the PALETTES object based on the user's selection.
15
+ *
16
+ * @returns An array of color hex codes representing the current color palette.
17
+ */
18
+ export declare const usePalette: () => string[];
@@ -0,0 +1,94 @@
1
+ // Palettes for progressive coloring of nodes based on depth or heatmap value
2
+ import { useSettingsStore } from "../state/Settings.js";
3
+ export const PALETTES = {
4
+ blue: [
5
+ "#f7fbff",
6
+ "#deebf7",
7
+ "#c6dbef",
8
+ "#9ecae1",
9
+ "#6baed6",
10
+ "#4292c6",
11
+ "#2171b5",
12
+ "#08519c",
13
+ "#08306b",
14
+ "#041c45",
15
+ ],
16
+ red: ["#fff5f0", "#fee0d2", "#fcbba1", "#fc9272", "#fb6a4a", "#ef3b2c", "#cb181d", "#a50f15", "#67000d", "#3a0007"],
17
+ green: [
18
+ "#ffffe5",
19
+ "#f7fcb9",
20
+ "#d9f0a3",
21
+ "#addd8e",
22
+ "#78c679",
23
+ "#41ab5d",
24
+ "#238443",
25
+ "#006837",
26
+ "#004529",
27
+ "#002a1a",
28
+ ],
29
+ yellow: [
30
+ "#ffffe5",
31
+ "#fff7bc",
32
+ "#fee391",
33
+ "#fec44f",
34
+ "#fe9929",
35
+ "#ec7014",
36
+ "#cc4c02",
37
+ "#993404",
38
+ "#662506",
39
+ "#331203",
40
+ ],
41
+ grayScale: [
42
+ "#f7f7f7",
43
+ "#e1e1e1",
44
+ "#cfcfcf",
45
+ "#b1b1b1",
46
+ "#9e9e9e",
47
+ "#7e7e7e",
48
+ "#626262",
49
+ "#525252",
50
+ "#252525",
51
+ "#0d0d0d",
52
+ ],
53
+ coldToHot: [
54
+ "#313695",
55
+ "#4575b4",
56
+ "#74add1",
57
+ "#abd9e9",
58
+ "#e0f3f8",
59
+ "#fee090",
60
+ "#fdae61",
61
+ "#f46d43",
62
+ "#d73027",
63
+ "#a50026",
64
+ ],
65
+ visionImpaired: [
66
+ "#000000",
67
+ "#004949",
68
+ "#009292",
69
+ "#ff6db6",
70
+ "#ffb6db",
71
+ "#490092",
72
+ "#006ddb",
73
+ "#b66dff",
74
+ "#6db6ff",
75
+ "#b6dbff",
76
+ ],
77
+ };
78
+ /**
79
+ * Custom hook to get the current color palette based on user settings.
80
+ * If the user has selected custom branding, it will return the palette for that.
81
+ * Otherwise, it will return one of the predefined palettes from the PALETTES object based on the user's selection.
82
+ *
83
+ * @returns An array of color hex codes representing the current color palette.
84
+ */
85
+ export const usePalette = () => {
86
+ const brandPalette = useSettingsStore((state) => state.settings.branding.rangePalette);
87
+ const paletteKey = useSettingsStore((state) => state.settings.appearance.rangePalette);
88
+ if (paletteKey === "brand" && brandPalette) {
89
+ return brandPalette;
90
+ }
91
+ else {
92
+ return PALETTES[paletteKey];
93
+ }
94
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Helper to determine if dark mode is active based on mode and systemMode.
3
+ * @param mode Current mode setting: "light", "dark", or "system"
4
+ * @param systemMode If mode is "system", this indicates the system preference: "light" or "dark"
5
+ * @returns true if dark mode is active, false otherwise
6
+ */
7
+ export declare const isDarkMode: (mode: "light" | "dark" | "system", systemMode: "light" | "dark") => boolean;
8
+ /**
9
+ * Adjusts the brightness of a hex color by a given percentage.
10
+ * @param color - The hex color string (e.g., "#RRGGBB" or "#RGB").
11
+ * @param percent - The percentage to adjust brightness (-100 to 100). Positive values make the color lighter,
12
+ * negative values make it darker.
13
+ * @returns The adjusted hex color string.
14
+ */
15
+ export declare const adjustBrightness: (color: string, percent: number) => string;
16
+ /**
17
+ * Helper function to determine if a color is light
18
+ *
19
+ * @param color - The hex color string (e.g., "#RRGGBB" or "#RGB")
20
+ * @returns true if the color is light (per luminance calculation), false otherwise
21
+ */
22
+ export declare const isLightColor: (color: string) => boolean;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Helper to determine if dark mode is active based on mode and systemMode.
3
+ * @param mode Current mode setting: "light", "dark", or "system"
4
+ * @param systemMode If mode is "system", this indicates the system preference: "light" or "dark"
5
+ * @returns true if dark mode is active, false otherwise
6
+ */
7
+ export const isDarkMode = (mode, systemMode) => mode === "dark" || (mode === "system" && systemMode === "dark");
8
+ /**
9
+ * Expands 3-character hex colors to 6 characters.
10
+ * @param color - The hex color string (e.g., "#RGB" or "#RRGGBB")
11
+ * @returns The expanded hex color string (e.g., "#RRGGBB")
12
+ */
13
+ const expandHexColor = (color) => {
14
+ if (color.length === 4 && color.startsWith("#")) {
15
+ return `#${color[1]}${color[1]}${color[2]}${color[2]}${color[3]}${color[3]}`;
16
+ }
17
+ return color;
18
+ };
19
+ /**
20
+ * Adjusts the brightness of a hex color by a given percentage.
21
+ * @param color - The hex color string (e.g., "#RRGGBB" or "#RGB").
22
+ * @param percent - The percentage to adjust brightness (-100 to 100). Positive values make the color lighter,
23
+ * negative values make it darker.
24
+ * @returns The adjusted hex color string.
25
+ */
26
+ export const adjustBrightness = (color, percent) => {
27
+ if (!color?.startsWith("#") || (color?.length !== 7 && color?.length !== 4)) {
28
+ // Return original color if not in expected format
29
+ return color;
30
+ }
31
+ const hexColor = expandHexColor(color);
32
+ const num = parseInt(hexColor.replace("#", ""), 16);
33
+ const amt = Math.round(2.55 * percent);
34
+ const R = Math.min(255, Math.max(0, (num >> 16) + amt));
35
+ const G = Math.min(255, Math.max(0, ((num >> 8) & 0x00ff) + amt));
36
+ const B = Math.min(255, Math.max(0, (num & 0x0000ff) + amt));
37
+ return `#${((1 << 24) + (R << 16) + (G << 8) + B).toString(16).slice(1)}`;
38
+ };
39
+ /**
40
+ * Helper function to determine if a color is light
41
+ *
42
+ * @param color - The hex color string (e.g., "#RRGGBB" or "#RGB")
43
+ * @returns true if the color is light (per luminance calculation), false otherwise
44
+ */
45
+ export const isLightColor = (color) => {
46
+ // Expand 3-character hex to 6-character hex if needed.
47
+ const hexColor = expandHexColor(color);
48
+ // Remove # if present
49
+ const colorWithoutHash = hexColor.replace("#", "");
50
+ // Convert to RGB
51
+ const r = parseInt(colorWithoutHash.substring(0, 2), 16);
52
+ const g = parseInt(colorWithoutHash.substring(2, 4), 16);
53
+ const b = parseInt(colorWithoutHash.substring(4, 6), 16);
54
+ // Calculate relative luminance (perceived brightness)
55
+ const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
56
+ // Return true if light (threshold 0.5)
57
+ return luminance > 0.5;
58
+ };
@@ -0,0 +1,96 @@
1
+ import { Dispatch, Ref, SetStateAction } from "react";
2
+ import { CombinedAgentType } from "./Types.js";
3
+ export interface ChatCommonProps {
4
+ /**
5
+ * HTML id to use for the outer component
6
+ */
7
+ readonly id: string;
8
+ /**
9
+ * The current username of the logged-in user. Used for fetching things from APIs mainly
10
+ */
11
+ readonly currentUser: string;
12
+ /**
13
+ * Path to image for user avatar
14
+ */
15
+ readonly userImage: string;
16
+ /**
17
+ * Function to set the state of the component to indicate whether we are awaiting a response from the LLM
18
+ */
19
+ readonly setIsAwaitingLlm: Dispatch<SetStateAction<boolean>>;
20
+ /**
21
+ * Whether we are currently awaiting a response from the LLM
22
+ */
23
+ readonly isAwaitingLlm: boolean;
24
+ /**
25
+ * The agent to send the request to.
26
+ */
27
+ readonly targetAgent: string;
28
+ /**
29
+ * Special endpoint for legacy agents since they do not have a single unified endpoint like Neuro-san agents.
30
+ */
31
+ readonly legacyAgentEndpoint?: string;
32
+ /**
33
+ * Optional extra callback for containers to do extra things with the chunks as they are received. Parent
34
+ * returns true if it believes the chunk indicates that the interaction with the agent was successful and no
35
+ * retries are necessary.
36
+ */
37
+ readonly onChunkReceived?: (chunk: string) => boolean;
38
+ /**
39
+ * Will be called when the streaming is started, before any chunks are received.
40
+ */
41
+ readonly onStreamingStarted?: () => void;
42
+ /**
43
+ * Will be called when the streaming is complete, whatever the reason for termination (normal or error)
44
+ */
45
+ readonly onStreamingComplete?: () => void;
46
+ /**
47
+ * Optional callback to modify the query before sending it to the server. This is useful for adding extra
48
+ * information to the query before sending it or totally modifying the user query before sending.
49
+ */
50
+ readonly onSend?: (query: string) => string;
51
+ /**
52
+ * Lifted state for parent to manage the previous response from the agent.
53
+ */
54
+ readonly setPreviousResponse?: (agent: CombinedAgentType, response: string) => void;
55
+ /**
56
+ * Optional placeholders for input to agents.
57
+ */
58
+ readonly agentPlaceholders?: Partial<Record<CombinedAgentType, string>>;
59
+ /**
60
+ * Whether to clear the chat window and history when the user starts chatting with a new agent or network.
61
+ * Defaults to not clearing the chat.
62
+ */
63
+ readonly clearChatOnNewAgent?: boolean;
64
+ /**
65
+ * Extra parameters to send to the server to be forwarded to the agent or used by the server.
66
+ * @note This is only used for legacy agents to aid in UI consolidation, only Neuro-san agents.
67
+ */
68
+ readonly extraParams?: Record<string, unknown>;
69
+ /**
70
+ * Background color for the chat window. Helps when there are multiple chats on a single page.
71
+ */
72
+ readonly backgroundColor?: string;
73
+ /**
74
+ * If present, the chat window will have a title bar with this title.
75
+ */
76
+ readonly title?: string;
77
+ /**
78
+ * If present, the chat window will have a close button that will call this function when clicked.
79
+ */
80
+ readonly onClose?: () => void;
81
+ /**
82
+ * The neuro-san server URL
83
+ */
84
+ readonly neuroSanURL?: string;
85
+ }
86
+ export type ChatCommonHandle = {
87
+ handleStop: () => void;
88
+ };
89
+ /**
90
+ * Common chat component for agent chat. This component is used by all agent chat components to provide a consistent
91
+ * experience for users when chatting with agents. It handles user input as well as displaying and nicely formatting
92
+ * agent responses. Customization for inputs and outputs is provided via event handlers-like props.
93
+ */
94
+ export declare const ChatCommon: ({ ref, ...props }: ChatCommonProps & {
95
+ ref?: Ref<ChatCommonHandle>;
96
+ }) => import("react/jsx-runtime").JSX.Element;