@cognizant-ai-lab/ui-common 1.5.0 → 1.5.1

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 (66) hide show
  1. package/dist/Theme/Theme.js +3 -3
  2. package/dist/components/AgentChat/ChatCommon/AgentIntro.d.ts +12 -0
  3. package/dist/components/AgentChat/ChatCommon/AgentIntro.js +19 -0
  4. package/dist/components/AgentChat/ChatCommon/AgentMetadata.d.ts +14 -0
  5. package/dist/components/AgentChat/ChatCommon/AgentMetadata.js +43 -0
  6. package/dist/components/AgentChat/ChatCommon/ChatCommon.d.ts +2 -1
  7. package/dist/components/AgentChat/ChatCommon/ChatCommon.js +131 -214
  8. package/dist/components/AgentChat/ChatCommon/Const.d.ts +1 -0
  9. package/dist/components/AgentChat/ChatCommon/Const.js +2 -0
  10. package/dist/components/AgentChat/ChatCommon/ControlButtons.js +2 -2
  11. package/dist/components/AgentChat/ChatCommon/Conversation.d.ts +15 -0
  12. package/dist/components/AgentChat/ChatCommon/Conversation.js +102 -0
  13. package/dist/components/AgentChat/ChatCommon/ConversationTurn.d.ts +19 -0
  14. package/dist/components/AgentChat/ChatCommon/ConversationTurn.js +10 -0
  15. package/dist/components/AgentChat/ChatCommon/Greetings.d.ts +1 -1
  16. package/dist/components/AgentChat/ChatCommon/Greetings.js +1 -1
  17. package/dist/components/AgentChat/Common/LlmChatButton.d.ts +2 -2
  18. package/dist/components/AgentChat/Common/Utils.js +1 -2
  19. package/dist/components/Common/ConfirmationModal.d.ts +1 -0
  20. package/dist/components/Common/ConfirmationModal.js +1 -1
  21. package/dist/components/Common/CustomerLogo.js +1 -1
  22. package/dist/components/Common/LlmChatOptionsButton.d.ts +1 -1
  23. package/dist/components/Common/Navbar.d.ts +2 -1
  24. package/dist/components/Common/Navbar.js +8 -4
  25. package/dist/components/Common/notification.d.ts +1 -1
  26. package/dist/components/Common/notification.js +17 -12
  27. package/dist/components/MultiAgentAccelerator/AgentFlow.d.ts +7 -0
  28. package/dist/components/MultiAgentAccelerator/AgentFlow.js +178 -73
  29. package/dist/components/MultiAgentAccelerator/AgentNode.d.ts +2 -1
  30. package/dist/components/MultiAgentAccelerator/AgentNode.js +52 -17
  31. package/dist/components/MultiAgentAccelerator/AgentNodePopup.d.ts +1 -4
  32. package/dist/components/MultiAgentAccelerator/AgentNodePopup.js +4 -5
  33. package/dist/components/MultiAgentAccelerator/GraphLayouts.js +7 -5
  34. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.d.ts +2 -2
  35. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +239 -51
  36. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.d.ts +1 -0
  37. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +28 -12
  38. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +1 -0
  39. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +21 -5
  40. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +4 -3
  41. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +8 -2
  42. package/dist/components/MultiAgentAccelerator/TemporaryNetworks.d.ts +19 -2
  43. package/dist/components/MultiAgentAccelerator/TemporaryNetworks.js +40 -5
  44. package/dist/components/MultiAgentAccelerator/ThoughtBubbleOverlay.js +27 -14
  45. package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.d.ts +7 -0
  46. package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.js +88 -0
  47. package/dist/components/MultiAgentAccelerator/const.d.ts +7 -10
  48. package/dist/components/MultiAgentAccelerator/const.js +9 -10
  49. package/dist/const.d.ts +5 -1
  50. package/dist/const.js +5 -2
  51. package/dist/controller/agent/Agent.d.ts +10 -0
  52. package/dist/controller/agent/Agent.js +17 -1
  53. package/dist/controller/llm/LlmChat.js +2 -2
  54. package/dist/state/TemporaryNetworks.d.ts +5 -15
  55. package/dist/state/TemporaryNetworks.js +15 -34
  56. package/dist/state/Tour.d.ts +29 -0
  57. package/dist/state/Tour.js +22 -0
  58. package/dist/state/UserInfo.d.ts +2 -1
  59. package/dist/tsconfig.build.tsbuildinfo +1 -1
  60. package/dist/utils/Authentication.js +12 -3
  61. package/dist/utils/File.d.ts +7 -0
  62. package/dist/utils/File.js +14 -3
  63. package/dist/utils/text.js +2 -2
  64. package/dist/utils/title.js +1 -1
  65. package/dist/utils/zIndexLayers.js +3 -0
  66. package/package.json +14 -10
@@ -48,9 +48,9 @@ export const isLightColor = (color) => {
48
48
  // Remove # if present
49
49
  const colorWithoutHash = hexColor.replace("#", "");
50
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);
51
+ const r = parseInt(colorWithoutHash.slice(0, 2), 16);
52
+ const g = parseInt(colorWithoutHash.slice(2, 4), 16);
53
+ const b = parseInt(colorWithoutHash.slice(4, 6), 16);
54
54
  // Calculate relative luminance (perceived brightness)
55
55
  const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
56
56
  // Return true if light (threshold 0.5)
@@ -0,0 +1,12 @@
1
+ import { FC } from "react";
2
+ import { CombinedAgentType } from "../Common/Types.js";
3
+ interface AgentIntroProps {
4
+ readonly agentDisplayName: string;
5
+ readonly customAgentGreetings?: Partial<Record<CombinedAgentType, string>>;
6
+ readonly targetAgent: string;
7
+ }
8
+ /**
9
+ * Component to display agent intro, including agent name, image, and greeting.
10
+ */
11
+ export declare const AgentIntro: FC<AgentIntroProps>;
12
+ export {};
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { AGENT_IMAGE } from "./Const.js";
4
+ import { GENERIC_AGENT_GREETINGS } from "./Greetings.js";
5
+ import { UserQueryDisplay } from "./UserQueryDisplay.js";
6
+ /**
7
+ * Component to display agent intro, including agent name, image, and greeting.
8
+ */
9
+ export const AgentIntro = ({ agentDisplayName, customAgentGreetings, targetAgent }) => {
10
+ // eslint-disable-next-line react/hook-use-state -- we want to set this an "on mount" value only and never update
11
+ const [greeting] = useState(() => {
12
+ if (customAgentGreetings?.[targetAgent]) {
13
+ return customAgentGreetings[targetAgent];
14
+ }
15
+ const randomIndex = Math.floor(Math.random() * GENERIC_AGENT_GREETINGS.length);
16
+ return GENERIC_AGENT_GREETINGS[randomIndex];
17
+ });
18
+ return (_jsxs(_Fragment, { children: [_jsx(UserQueryDisplay, { userQuery: agentDisplayName, title: targetAgent, userImage: AGENT_IMAGE }), greeting] }));
19
+ };
@@ -0,0 +1,14 @@
1
+ import { FC } from "react";
2
+ interface AgentMetadataDisplayProps {
3
+ readonly currentUser: string;
4
+ readonly disableQueries: boolean;
5
+ readonly handleSend: (query: string) => Promise<void>;
6
+ readonly id: string;
7
+ readonly neuroSanURL: string;
8
+ readonly targetAgent: string;
9
+ }
10
+ /**
11
+ * Component to display agent metadata, including connectivity info and sample queries.
12
+ */
13
+ export declare const AgentMetadata: FC<AgentMetadataDisplayProps>;
14
+ export {};
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { AgentConnectivity } from "./AgentConnectivity.js";
4
+ import { SampleQueries } from "./SampleQueries.js";
5
+ import { getAgentFunction, getConnectivity } from "../../../controller/agent/Agent.js";
6
+ import { NotificationType, sendNotification } from "../../Common/notification.js";
7
+ import { isLegacyAgentType } from "../Common/Types.js";
8
+ /**
9
+ * Component to display agent metadata, including connectivity info and sample queries.
10
+ */
11
+ export const AgentMetadata = ({ currentUser, disableQueries, handleSend, id, neuroSanURL, targetAgent, }) => {
12
+ const [sampleQueries, setSampleQueries] = useState([]);
13
+ const [connectivityInfo, setConnectivityInfo] = useState([]);
14
+ const [description, setDescription] = useState("");
15
+ useEffect(() => {
16
+ const fetchAgentDetails = async () => {
17
+ // It is a Neuro-san agent, so get the function and connectivity info
18
+ try {
19
+ const agentFunction = await getAgentFunction(neuroSanURL, targetAgent, currentUser);
20
+ setDescription(agentFunction?.function?.description || "");
21
+ }
22
+ catch {
23
+ // For now, just return. May be a legacy agent without a functional description in Neuro-san.
24
+ return;
25
+ }
26
+ try {
27
+ const connectivity = await getConnectivity(neuroSanURL, targetAgent, currentUser);
28
+ setConnectivityInfo(connectivity?.connectivity_info);
29
+ const sampleQueriesTmp = (connectivity?.metadata?.["sample_queries"] || []);
30
+ setSampleQueries(sampleQueriesTmp);
31
+ }
32
+ catch (e) {
33
+ // If we got here, it means we got the agent function successfully, but failed to get connectivity info.
34
+ // This is unexpected.
35
+ sendNotification(NotificationType.error, `Failed to get connectivity info for ${targetAgent}. Error: ${e}`);
36
+ }
37
+ };
38
+ if (targetAgent && !isLegacyAgentType(targetAgent)) {
39
+ void fetchAgentDetails();
40
+ }
41
+ }, [currentUser, neuroSanURL, targetAgent]);
42
+ return (_jsxs(_Fragment, { children: [description && connectivityInfo?.length > 0 && (_jsx(AgentConnectivity, { connectivityInfo: connectivityInfo, description: description, id: `${id}-connectivity`, targetAgent: targetAgent })), sampleQueries?.length > 0 && (_jsx(SampleQueries, { disabled: disableQueries, handleSend: handleSend, sampleQueries: sampleQueries }))] }));
43
+ };
@@ -59,7 +59,7 @@ export interface ChatCommonProps {
59
59
  /**
60
60
  * Optional greetings for specific agents to display
61
61
  */
62
- readonly agentGreetings?: Partial<Record<CombinedAgentType, string>>;
62
+ readonly customAgentGreetings?: Partial<Record<CombinedAgentType, string>>;
63
63
  /**
64
64
  * Extra parameters to send to the server to be forwarded to the agent or used by the server.
65
65
  * @note This is only used for legacy agents to aid in UI consolidation, only Neuro-san agents.
@@ -89,6 +89,7 @@ export interface ChatCommonProps {
89
89
  }
90
90
  export type ChatCommonHandle = {
91
91
  handleStop: () => void;
92
+ handleClearChat: () => void;
92
93
  };
93
94
  /**
94
95
  * Common chat component for agent chat. This component is used by all agent chat components to provide a consistent