@cognizant-ai-lab/ui-common 1.4.2 → 1.5.0-main.0f5f5ff.78
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/dist/components/AgentChat/ChatCommon/AgentConnectivity.d.ts +14 -0
- package/dist/components/AgentChat/ChatCommon/AgentConnectivity.js +23 -0
- package/dist/components/AgentChat/ChatCommon/AgentIntro.d.ts +12 -0
- package/dist/components/AgentChat/ChatCommon/AgentIntro.js +19 -0
- package/dist/components/AgentChat/ChatCommon/AgentMetadata.d.ts +14 -0
- package/dist/components/AgentChat/ChatCommon/AgentMetadata.js +43 -0
- package/dist/components/AgentChat/{ChatCommon.d.ts → ChatCommon/ChatCommon.d.ts} +9 -4
- package/dist/components/AgentChat/ChatCommon/ChatCommon.js +545 -0
- package/dist/components/AgentChat/ChatCommon/ChatHistory.d.ts +17 -0
- package/dist/components/AgentChat/ChatCommon/ChatHistory.js +27 -0
- package/dist/components/AgentChat/ChatCommon/Const.d.ts +1 -0
- package/dist/components/AgentChat/ChatCommon/Const.js +2 -0
- package/dist/components/AgentChat/{ControlButtons.d.ts → ChatCommon/ControlButtons.d.ts} +1 -1
- package/dist/components/AgentChat/ChatCommon/ControlButtons.js +26 -0
- package/dist/components/AgentChat/ChatCommon/Conversation.d.ts +15 -0
- package/dist/components/AgentChat/ChatCommon/Conversation.js +102 -0
- package/dist/components/AgentChat/ChatCommon/ConversationTurn.d.ts +19 -0
- package/dist/components/AgentChat/ChatCommon/ConversationTurn.js +10 -0
- package/dist/components/AgentChat/{FormattedMarkdown.js → ChatCommon/FormattedMarkdown.js} +1 -1
- package/dist/components/AgentChat/ChatCommon/Greetings.d.ts +1 -0
- package/dist/components/AgentChat/{Greetings.js → ChatCommon/Greetings.js} +1 -1
- package/dist/components/AgentChat/ChatCommon/SampleQueries.d.ts +16 -0
- package/dist/components/AgentChat/ChatCommon/SampleQueries.js +29 -0
- package/dist/components/AgentChat/{SendButton.js → ChatCommon/SendButton.js} +1 -1
- package/dist/components/AgentChat/ChatCommon/UserQueryDisplay.d.ts +7 -0
- package/dist/components/AgentChat/{UserQueryDisplay.js → ChatCommon/UserQueryDisplay.js} +4 -3
- package/dist/components/AgentChat/Common/LlmChatButton.d.ts +8 -0
- package/dist/components/AgentChat/{Utils.d.ts → Common/Utils.d.ts} +1 -1
- package/dist/components/AgentChat/{Utils.js → Common/Utils.js} +2 -1
- package/dist/components/AgentChat/VoiceChat/MicrophoneButton.js +1 -1
- package/dist/components/ChatBot/ChatBot.js +2 -2
- package/dist/components/Common/ConfirmationModal.d.ts +1 -0
- package/dist/components/Common/ConfirmationModal.js +1 -1
- package/dist/components/Common/CustomerLogo.js +2 -2
- package/dist/components/Common/LlmChatOptionsButton.d.ts +1 -1
- package/dist/components/Common/MUIDialog.d.ts +1 -0
- package/dist/components/Common/MUIDialog.js +2 -2
- package/dist/components/Common/Navbar.d.ts +2 -1
- package/dist/components/Common/Navbar.js +6 -3
- package/dist/components/Common/notification.d.ts +1 -1
- package/dist/components/Common/notification.js +16 -11
- package/dist/components/MultiAgentAccelerator/AgentCounts.d.ts +2 -2
- package/dist/components/MultiAgentAccelerator/AgentFlow.d.ts +20 -1
- package/dist/components/MultiAgentAccelerator/AgentFlow.js +281 -22
- package/dist/components/MultiAgentAccelerator/AgentNetworkDesigner.d.ts +10 -0
- package/dist/components/MultiAgentAccelerator/AgentNetworkDesigner.js +20 -0
- package/dist/components/MultiAgentAccelerator/AgentNode.d.ts +2 -0
- package/dist/components/MultiAgentAccelerator/AgentNode.js +25 -6
- package/dist/components/MultiAgentAccelerator/AgentNodePopup.d.ts +30 -0
- package/dist/components/MultiAgentAccelerator/AgentNodePopup.js +80 -0
- package/dist/components/MultiAgentAccelerator/GraphLayouts.d.ts +4 -4
- package/dist/components/MultiAgentAccelerator/GraphLayouts.js +14 -8
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.d.ts +3 -2
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +319 -72
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.d.ts +1 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +29 -12
- package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +2 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +40 -24
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +1 -1
- package/dist/components/MultiAgentAccelerator/TemporaryNetworks.d.ts +31 -0
- package/dist/components/MultiAgentAccelerator/TemporaryNetworks.js +61 -1
- package/dist/components/MultiAgentAccelerator/ThoughtBubbleOverlay.js +30 -16
- package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.d.ts +7 -0
- package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.js +88 -0
- package/dist/components/MultiAgentAccelerator/const.d.ts +21 -0
- package/dist/components/MultiAgentAccelerator/const.js +18 -0
- package/dist/const.d.ts +5 -1
- package/dist/const.js +5 -2
- package/dist/controller/agent/Agent.d.ts +10 -0
- package/dist/controller/agent/Agent.js +17 -1
- package/dist/controller/llm/LlmChat.js +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.js +8 -7
- package/dist/state/ChatHistory.d.ts +50 -0
- package/dist/state/ChatHistory.js +98 -0
- package/dist/state/IndexedDBStorage.d.ts +14 -0
- package/dist/state/IndexedDBStorage.js +65 -0
- package/dist/state/TemporaryNetworks.d.ts +13 -0
- package/dist/state/TemporaryNetworks.js +24 -0
- package/dist/state/Tour.d.ts +29 -0
- package/dist/state/Tour.js +22 -0
- package/dist/state/UserInfo.d.ts +2 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/Authentication.js +10 -3
- package/dist/utils/File.d.ts +7 -0
- package/dist/utils/File.js +12 -1
- package/dist/utils/zIndexLayers.js +3 -0
- package/package.json +17 -7
- package/dist/components/AgentChat/ChatCommon.js +0 -617
- package/dist/components/AgentChat/ControlButtons.js +0 -26
- package/dist/components/AgentChat/Greetings.d.ts +0 -1
- package/dist/components/AgentChat/LlmChatButton.d.ts +0 -8
- package/dist/components/AgentChat/UserQueryDisplay.d.ts +0 -5
- /package/dist/components/AgentChat/{FormattedMarkdown.d.ts → ChatCommon/FormattedMarkdown.d.ts} +0 -0
- /package/dist/components/AgentChat/{SendButton.d.ts → ChatCommon/SendButton.d.ts} +0 -0
- /package/dist/components/AgentChat/{SyntaxHighlighterThemes.d.ts → ChatCommon/SyntaxHighlighterThemes.d.ts} +0 -0
- /package/dist/components/AgentChat/{SyntaxHighlighterThemes.js → ChatCommon/SyntaxHighlighterThemes.js} +0 -0
- /package/dist/components/AgentChat/{LlmChatButton.js → Common/LlmChatButton.js} +0 -0
- /package/dist/components/AgentChat/{Types.d.ts → Common/Types.d.ts} +0 -0
- /package/dist/components/AgentChat/{Types.js → Common/Types.js} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { ConnectivityInfo } from "../../../generated/neuro-san/NeuroSanClient.js";
|
|
3
|
+
interface AgentConnectivityProps {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly connectivityInfo?: readonly ConnectivityInfo[];
|
|
7
|
+
readonly targetAgent: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Render the connectivity info as a list of origins and their tools
|
|
11
|
+
* @returns A MUIAccordion representing the connectivity info with agents and their tools
|
|
12
|
+
*/
|
|
13
|
+
export declare const AgentConnectivity: FC<AgentConnectivityProps>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { MUIAccordion } from "../../Common/MUIAccordion.js";
|
|
3
|
+
const renderConnectivityInfo = (targetAgent, connectivityInfo) => (_jsx(_Fragment, { children: connectivityInfo
|
|
4
|
+
// Don't show connection to self
|
|
5
|
+
?.filter((info) => info.origin.toLowerCase() !== targetAgent.toLowerCase())
|
|
6
|
+
// Sort by origin name
|
|
7
|
+
.sort((a, b) => a.origin.localeCompare(b.origin))
|
|
8
|
+
// Render each origin and its tools
|
|
9
|
+
.map((info) => (_jsxs("li", { id: info.origin, children: [_jsx("b", { children: info.origin }), _jsx("ul", { id: `${info.origin}-tools`, style: { marginLeft: "8px" }, children: info?.tools?.map((tool) => (_jsx("li", { children: tool }, tool))) })] }, info.origin))) }));
|
|
10
|
+
/**
|
|
11
|
+
* Render the connectivity info as a list of origins and their tools
|
|
12
|
+
* @returns A MUIAccordion representing the connectivity info with agents and their tools
|
|
13
|
+
*/
|
|
14
|
+
export const AgentConnectivity = ({ connectivityInfo, description, id, targetAgent }) => (_jsx(MUIAccordion, { id: `${id}-agent-details`, sx: { marginTop: "1rem", marginBottom: "1rem" }, items: [
|
|
15
|
+
{
|
|
16
|
+
title: "Network Details",
|
|
17
|
+
content: [
|
|
18
|
+
`My description is: "${description}"`,
|
|
19
|
+
_jsx("h6", { id: "connectivity-header", style: { marginTop: "1rem" }, children: "I can connect you to the following agents" }, "item-1"),
|
|
20
|
+
_jsx("ul", { id: "connectivity-list", "aria-labelledby": "connectivity-header", style: { marginTop: "1rem" }, children: renderConnectivityInfo(targetAgent, connectivityInfo) }, "item-2"),
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
] }));
|
|
@@ -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
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, Ref, SetStateAction } from "react";
|
|
2
|
-
import { CombinedAgentType } from "
|
|
2
|
+
import { CombinedAgentType } from "../Common/Types.js";
|
|
3
3
|
export interface ChatCommonProps {
|
|
4
4
|
/**
|
|
5
5
|
* HTML id to use for the outer component
|
|
@@ -57,10 +57,9 @@ export interface ChatCommonProps {
|
|
|
57
57
|
*/
|
|
58
58
|
readonly agentPlaceholders?: Partial<Record<CombinedAgentType, string>>;
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
61
|
-
* Defaults to not clearing the chat.
|
|
60
|
+
* Optional greetings for specific agents to display
|
|
62
61
|
*/
|
|
63
|
-
readonly
|
|
62
|
+
readonly customAgentGreetings?: Partial<Record<CombinedAgentType, string>>;
|
|
64
63
|
/**
|
|
65
64
|
* Extra parameters to send to the server to be forwarded to the agent or used by the server.
|
|
66
65
|
* @note This is only used for legacy agents to aid in UI consolidation, only Neuro-san agents.
|
|
@@ -82,9 +81,15 @@ export interface ChatCommonProps {
|
|
|
82
81
|
* The neuro-san server URL
|
|
83
82
|
*/
|
|
84
83
|
readonly neuroSanURL?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Extra sly_data entries to merge into each outgoing request. Used by parent components (e.g. temp networks)
|
|
86
|
+
* to re-supply data that lives outside the IndexedDB slyData store (e.g. localStorage).
|
|
87
|
+
*/
|
|
88
|
+
readonly extraSlyData?: Record<string, unknown>;
|
|
85
89
|
}
|
|
86
90
|
export type ChatCommonHandle = {
|
|
87
91
|
handleStop: () => void;
|
|
92
|
+
handleClearChat: () => void;
|
|
88
93
|
};
|
|
89
94
|
/**
|
|
90
95
|
* Common chat component for agent chat. This component is used by all agent chat components to provide a consistent
|