@cognizant-ai-lab/ui-common 1.9.0 → 1.11.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 (70) hide show
  1. package/dist/components/AgentChat/ChatCommon/ChatCommon.js +32 -10
  2. package/dist/components/AgentChat/ChatCommon/Const.d.ts +1 -0
  3. package/dist/components/AgentChat/ChatCommon/Const.js +2 -0
  4. package/dist/components/AgentChat/ChatCommon/SlyDataDialog.d.ts +29 -0
  5. package/dist/components/AgentChat/ChatCommon/SlyDataDialog.js +150 -0
  6. package/dist/components/AgentChat/ChatCommon/Thinking.js +2 -2
  7. package/dist/components/AgentChat/Common/LlmChatButton.d.ts +4 -6
  8. package/dist/components/AgentChat/Common/LlmChatButton.js +0 -2
  9. package/dist/components/AgentChat/Common/Utils.d.ts +0 -11
  10. package/dist/components/AgentChat/Common/Utils.js +0 -16
  11. package/dist/components/Common/ConfirmationModal.d.ts +3 -2
  12. package/dist/components/Common/Footer.js +4 -0
  13. package/dist/components/Common/Navbar.d.ts +2 -1
  14. package/dist/components/Common/Navbar.js +3 -3
  15. package/dist/components/ErrorPage/ErrorPage.js +4 -4
  16. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.d.ts +7 -7
  17. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.js +161 -376
  18. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentNode.js +7 -5
  19. package/dist/components/MultiAgentAccelerator/AgentFlow/GraphLayouts.js +10 -7
  20. package/dist/components/MultiAgentAccelerator/AgentFlow/GraphStructure.d.ts +1 -1
  21. package/dist/components/MultiAgentAccelerator/Editor/AgentNodeEditor.d.ts +24 -0
  22. package/dist/components/MultiAgentAccelerator/Editor/AgentNodeEditor.js +128 -0
  23. package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.d.ts +21 -0
  24. package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.js +305 -0
  25. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +112 -116
  26. package/dist/components/MultiAgentAccelerator/NeuroSanStudioCallout.d.ts +2 -0
  27. package/dist/components/MultiAgentAccelerator/NeuroSanStudioCallout.js +38 -0
  28. package/dist/components/MultiAgentAccelerator/PanelSeparator.d.ts +5 -0
  29. package/dist/components/MultiAgentAccelerator/PanelSeparator.js +46 -0
  30. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.d.ts +2 -0
  31. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +23 -31
  32. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +0 -2
  33. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +11 -9
  34. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +2 -2
  35. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +13 -13
  36. package/dist/components/MultiAgentAccelerator/TemporaryNetworks.d.ts +3 -17
  37. package/dist/components/MultiAgentAccelerator/TemporaryNetworks.js +17 -40
  38. package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.js +10 -8
  39. package/dist/components/MultiAgentAccelerator/const.d.ts +12 -11
  40. package/dist/components/MultiAgentAccelerator/const.js +24 -22
  41. package/dist/components/Settings/ApiKeyErrorBanner.d.ts +22 -0
  42. package/dist/components/Settings/ApiKeyErrorBanner.js +26 -0
  43. package/dist/components/Settings/ApiKeyInput.d.ts +5 -2
  44. package/dist/components/Settings/ApiKeyInput.js +10 -4
  45. package/dist/components/Settings/SettingsDialog.js +22 -5
  46. package/dist/const.d.ts +0 -1
  47. package/dist/const.js +0 -1
  48. package/dist/controller/llm/Providers.d.ts +19 -2
  49. package/dist/controller/llm/Providers.js +45 -31
  50. package/dist/state/Announcements.d.ts +24 -0
  51. package/dist/state/Announcements.js +29 -0
  52. package/dist/state/ChatHistory.d.ts +10 -1
  53. package/dist/state/ChatHistory.js +8 -0
  54. package/dist/state/Environment.d.ts +2 -0
  55. package/dist/state/Environment.js +2 -0
  56. package/dist/state/Settings.d.ts +14 -0
  57. package/dist/state/Settings.js +6 -2
  58. package/dist/state/TemporaryNetworks.js +12 -21
  59. package/dist/tsconfig.build.tsbuildinfo +1 -1
  60. package/dist/utils/AgentName.d.ts +17 -0
  61. package/dist/utils/AgentName.js +46 -0
  62. package/dist/utils/Authentication.d.ts +7 -0
  63. package/dist/utils/Authentication.js +19 -5
  64. package/dist/utils/SlyData.d.ts +56 -0
  65. package/dist/utils/SlyData.js +106 -0
  66. package/package.json +7 -6
  67. package/dist/components/MultiAgentAccelerator/AgentNodePopup.d.ts +0 -30
  68. package/dist/components/MultiAgentAccelerator/AgentNodePopup.js +0 -80
  69. package/dist/components/MultiAgentAccelerator/Sidebar/ImportNetworkModal.d.ts +0 -67
  70. package/dist/components/MultiAgentAccelerator/Sidebar/ImportNetworkModal.js +0 -585
@@ -15,7 +15,6 @@ See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
  */
17
17
  import AddBoxRounded from "@mui/icons-material/AddBoxRounded";
18
- import FileUploadOutlinedIcon from "@mui/icons-material/FileUploadOutlined";
19
18
  import Box from "@mui/material/Box";
20
19
  import Button from "@mui/material/Button";
21
20
  import { keyframes, styled } from "@mui/material/styles";
@@ -76,12 +75,13 @@ const NEURO_SAN_PING_INTERVAL_MS = 30_000;
76
75
  //#region: Styled Components
77
76
  // Styled component for Sidebar aside element, including styles for the sparkle highlight animation
78
77
  // when a new temporary network is added.
79
- const SidebarAside = styled("aside")({
78
+ const SidebarAside = styled("aside")(({ theme }) => ({
80
79
  borderRightStyle: "solid",
81
80
  borderRightWidth: "1px",
82
81
  height: "100%",
82
+ marginRight: theme.spacing(1),
83
83
  overflowY: "auto",
84
- paddingRight: "0.75rem",
84
+ paddingRight: theme.spacing(1.5),
85
85
  [`& .${SPARKLE_HIGHLIGHT_CLASS}`]: {
86
86
  background: "linear-gradient(90deg, gold, orange, cyan, magenta, gold)",
87
87
  backgroundSize: "400% 100%",
@@ -90,7 +90,7 @@ const SidebarAside = styled("aside")({
90
90
  borderRadius: "4px",
91
91
  opacity: 1,
92
92
  },
93
- });
93
+ }));
94
94
  // Styled component for the sidebar heading, which is sticky at the top of the sidebar.
95
95
  const SidebarHeading = styled("h2")(({ theme }) => ({
96
96
  alignItems: "center",
@@ -116,7 +116,7 @@ const ServerStatusTooltip = styled(({ className, ...props }) => (_jsx(Tooltip, {
116
116
  },
117
117
  });
118
118
  //#endregion: Types
119
- export const Sidebar = ({ id, isAwaitingLlm, isImporting, networkIconSuggestions, networks, neuroSanServerURL, newlyAddedTemporaryNetworks, onDeleteNetwork, onEditNetwork, onImportClick, setSelectedNetwork, temporaryNetworks = EMPTY_ARRAY, }) => {
119
+ export const Sidebar = ({ id, isAwaitingLlm, networkIconSuggestions, networks, neuroSanServerURL, newlyAddedTemporaryNetworks, onDeleteNetwork, onEditNetwork, setSelectedNetwork, temporaryNetworks = EMPTY_ARRAY, }) => {
120
120
  const [expandedItems, setExpandedItems] = useState([]);
121
121
  const [selectedItem, setSelectedItem] = useState(null);
122
122
  // Display option for agent/network names
@@ -215,10 +215,12 @@ export const Sidebar = ({ id, isAwaitingLlm, isImporting, networkIconSuggestions
215
215
  "aria-label": "Neuro-san server status",
216
216
  },
217
217
  }, title: _jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 0.5 }, children: [_jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "Status:" }), " ", mapStatus(neuroSanServerStatus?.statusText)] }), _jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "URL:" }), " ", neuroSanServerURL || "unknown"] }), _jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "Service:" }), " ", neuroSanServerStatus?.healthCheckResponse?.service || "unknown"] }), _jsx(Typography, { sx: { fontWeight: "bold" }, variant: "body2", children: "Versions:" }), _jsxs(Box, { sx: { ml: 1 }, children: [_jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "Neuro SAN:" }), " ", neuroSanServerStatus?.healthCheckResponse?.versions?.["neuro-san"] ?? "unknown"] }), _jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "Neuro SAN Studio:" }), " ", neuroSanServerStatus?.healthCheckResponse?.versions?.["neuro-san-studio"] ?? "unknown"] })] }), !neuroSanServerStatus?.success && neuroSanServerStatus?.httpStatus && (_jsx(_Fragment, { children: _jsxs(Typography, { variant: "body2", children: [_jsx("strong", { children: "HTTP status:" }), " ", `${neuroSanServerStatus.httpStatus} (${httpStatus[neuroSanServerStatus.httpStatus] ?? "Unknown status"})`] }) }))] }), placement: "right", children: _jsx("span", { children: _jsx(StatusLight, { id: `${id}-agent-network-status-light`, statusValue: toStatusColor() }) }) }));
218
- const getAddNetworkButton = () => (_jsxs(Box, { sx: { display: "flex" }, children: [_jsx(Button, { "aria-label": "Add New Network", disabled: isAwaitingLlm, id: "add-network-btn", onClick: () => {
219
- setSelectedItem(AGENT_NETWORK_DESIGNER_ID);
220
- setSelectedNetwork(AGENT_NETWORK_DESIGNER_ID);
221
- }, sx: { display: "inline-block", minWidth: "40px" }, children: _jsx(Tooltip, { title: "Create your own agent network", placement: "top", children: _jsx(AddBoxRounded, { id: "add-network-icon", sx: { color: "var(--bs-secondary)" } }) }) }), _jsx(Button, { "aria-label": "Import Network Definition", disabled: isAwaitingLlm || isImporting, id: "import-network-btn", onClick: onImportClick, sx: { display: "inline-block", minWidth: "40px" }, children: _jsx(Tooltip, { title: "Import a network definition file", placement: "top", children: _jsx(FileUploadOutlinedIcon, { id: "import-network-icon", sx: { color: isAwaitingLlm || isImporting ? "rgba(0, 0, 0, 0.12)" : "var(--bs-secondary)" } }) }) })] }));
218
+ const getAddNetworkButton = () => (_jsx(Box, { sx: { display: "flex" }, children: _jsx(Button, { "aria-label": "Add New Network", disabled: isAwaitingLlm, id: "add-network-btn", onClick: () => {
219
+ setSelectedItem(AGENT_NETWORK_DESIGNER_ID);
220
+ setSelectedNetwork(AGENT_NETWORK_DESIGNER_ID);
221
+ }, sx: { display: "inline-block", minWidth: "40px" }, children: _jsx(Tooltip, { title: "Create your own agent network", placement: "top", children: _jsx(AddBoxRounded, { id: "add-network-icon", sx: (theme) => ({
222
+ color: isAwaitingLlm ? theme.palette.action.disabled : "var(--bs-secondary)",
223
+ }) }) }) }) }));
222
224
  const getSidebarHeading = () => (_jsxs(SidebarHeading, { id: `${id}-heading`, children: [_jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: (theme) => theme.spacing(1.5) }, children: [getStatusLight(), "Agent Networks"] }), getAddNetworkButton()] }));
223
225
  const getSidebarNetworksTree = () => (_jsx(RichTreeView, { disableSelection: isAwaitingLlm, expandedItems: expandedItems, items: treeViewItems, multiSelect: false, onExpandedItemsChange: (_event, itemIds) => setExpandedItems(itemIds), onSelectedItemsChange: handleSelectedItemsChange, selectedItems: selectedItem, slotProps: {
224
226
  item: { onDeleteNetwork, onEditNetwork: handleEditNetworkWithSelect },
@@ -1,7 +1,6 @@
1
1
  import { TreeViewDefaultItemModelProperties } from "@mui/x-tree-view/models";
2
2
  import { AgentInfo } from "../../../generated/neuro-san/NeuroSanClient.js";
3
3
  import { TemporaryNetwork } from "../../../state/TemporaryNetworks.js";
4
- import { AgentNetworkDefinitionEntry } from "../const.js";
5
4
  /**
6
5
  * Represents either a category (folder) or a network (leaf) in the tree view.
7
6
  * Note that we omit the `children` property from the parent as we want to use read-only semantics
@@ -9,11 +8,12 @@ import { AgentNetworkDefinitionEntry } from "../const.js";
9
8
  export interface AgentNetworkTreeItemModel extends Omit<TreeViewDefaultItemModelProperties, "children"> {
10
9
  readonly children?: readonly AgentNetworkTreeItemModel[];
11
10
  readonly displayName: string;
11
+ readonly downloadFileName?: string;
12
12
  readonly iconSuggestion?: string;
13
13
  readonly isNetwork: boolean;
14
14
  readonly tags?: readonly string[];
15
15
  readonly temporaryNetworkExpirationTime?: Date;
16
- readonly temporaryNetworkDefinition?: readonly AgentNetworkDefinitionEntry[];
16
+ readonly temporaryNetworkHocon?: string | null;
17
17
  }
18
18
  /**
19
19
  * Recursively searches for a tree item with the specified ID within the given list of tree items.
@@ -1,4 +1,5 @@
1
- import { cleanUpAgentName, removeTrailingUuid } from "../../AgentChat/Common/Utils.js";
1
+ import { cleanUpAgentName, removeTrailingUuid, toDisplayName } from "../../../utils/AgentName.js";
2
+ import { toSafeFilename } from "../../../utils/File.js";
2
3
  //#endregion Types and Interfaces
3
4
  /**
4
5
  * Recursively searches for a tree item with the specified ID within the given list of tree items.
@@ -20,14 +21,6 @@ export const findTreeItemById = (items, itemId) => {
20
21
  }
21
22
  return undefined;
22
23
  };
23
- /**
24
- * Converts a raw agent name into a display name for the tree view, respecting the user's preference for native
25
- * vs cleaned names.
26
- * @param itemName - The raw agent name from the API
27
- * @param useNativeNames - Whether to use native names or cleaned-up names for display
28
- * @returns The display name to show in the tree view
29
- */
30
- const toDisplayName = (itemName, useNativeNames) => useNativeNames ? itemName : cleanUpAgentName(removeTrailingUuid(itemName));
31
24
  /**
32
25
  * Computes the display name for a network (leaf) node.
33
26
  * @param label - The label to use for the tree item (usually derived from the agent name)
@@ -45,6 +38,14 @@ const toLeafDisplayName = (label, useNativeNames, displayNameOverride) => {
45
38
  const cleanedName = cleanUpAgentName(displayNameOverride ?? removeTrailingUuid(label));
46
39
  return cleanedName;
47
40
  };
41
+ /**
42
+ * Computes the filename used when exporting a network's HOCON to disk. The trailing reservation
43
+ * UUID is stripped first so the export carries a clean name (toSafeFilename would otherwise flatten
44
+ * the UUID's hyphens to underscores).
45
+ * @param label - The label to use for the tree item (usually derived from the agent name)
46
+ * @returns The sanitized `.hocon` filename for the exported network HOCON
47
+ */
48
+ const toDownloadFileName = (label) => `${toSafeFilename(removeTrailingUuid(label))}.hocon`;
48
49
  /**
49
50
  * Converts an AgentInfo object into a tree item model representing a network (leaf node).
50
51
  * @param network - The AgentInfo object containing details about the network
@@ -57,11 +58,12 @@ const toNetworkLeaf = (network, label, useNativeNames, metadata = {}) => ({
57
58
  id: network.agent_name,
58
59
  label,
59
60
  displayName: toLeafDisplayName(label, useNativeNames, metadata.displayNameOverride),
61
+ downloadFileName: metadata.temporaryNetworkHocon ? toDownloadFileName(label) : undefined,
60
62
  iconSuggestion: metadata.iconSuggestion,
61
63
  isNetwork: true,
62
64
  tags: network.tags,
63
65
  temporaryNetworkExpirationTime: metadata.temporaryNetworkExpirationTime,
64
- temporaryNetworkDefinition: metadata.temporaryNetworkDefinition,
66
+ temporaryNetworkHocon: metadata.temporaryNetworkHocon,
65
67
  });
66
68
  /**
67
69
  * Recursively sort tree nodes and their children by display name
@@ -174,9 +176,7 @@ export const buildTreeViewItems = (useNativeNames, regularNetworks = [], tempora
174
176
  tree = withNetworkAdded(tree, temporaryNetwork.agentInfo, useNativeNames, {
175
177
  iconSuggestion: "HourglassTop",
176
178
  temporaryNetworkExpirationTime: new Date(temporaryNetwork.reservation.expiration_time_in_seconds * 1000),
177
- // The structured definition is carried through and serialized at download time (it's the same shape
178
- // the import modal reads back in).
179
- temporaryNetworkDefinition: temporaryNetwork.agentNetworkDefinition,
179
+ temporaryNetworkHocon: temporaryNetwork.networkHocon,
180
180
  displayNameOverride: temporaryNetwork.agentNetworkName,
181
181
  });
182
182
  }
@@ -65,22 +65,8 @@ export declare const mergeNetworks: (target: TemporaryNetwork[], incoming: Tempo
65
65
  /** Logs and notifies about a save error. Suppresses AbortError (user-canceled). */
66
66
  export declare const notifySaveError: (agentName: string, e: unknown) => void;
67
67
  /**
68
- * Streams a network definition through the network designer, collecting the
69
- * reservations returned across every chunk. Returns the accumulated networks
70
- * (empty if the designer returned no reservation).
68
+ * Streams a network definition through the network designer to obtain its reservation.
69
+ * Returns the single updated network as a one-element list (empty if the designer returned
70
+ * no reservation).
71
71
  */
72
72
  export declare const streamNetworkDesignerUpsert: (neuroSanURL: string, signal: AbortSignal, frontman: string, networkDef: AgentNetworkDefinitionEntry[], agentNetworkName: string | undefined, username: string) => Promise<TemporaryNetwork[]>;
73
- /** Reasons an import can fail before its networks reach the store. */
74
- export type ImportFailureReason = "invalid-definition" | "no-reservation";
75
- export type ImportNetworkResult = {
76
- networks: TemporaryNetwork[];
77
- } | {
78
- failure: ImportFailureReason;
79
- };
80
- export declare const IMPORT_FAILURE_DETAIL: Record<ImportFailureReason, string>;
81
- /**
82
- * Converts imported JSON into a network definition and streams it through the
83
- * network designer to obtain reservations. Returns the resulting networks, or a
84
- * failure reason if the content is not a valid definition or no reservation is returned.
85
- */
86
- export declare const importNetworkFromJson: (content: string, agentNetworkName: string, neuroSanURL: string, username: string) => Promise<ImportNetworkResult>;
@@ -1,10 +1,11 @@
1
- import { getFrontman } from "./AgentFlow/GraphStructure.js";
1
+ import { keyBy, mergeWith } from "lodash-es";
2
2
  import { AGENT_NETWORK_DEFINITION_KEY, AGENT_NETWORK_HOCON, AGENT_RESERVATIONS_KEY, DisplayAs, TEMPORARY_NETWORK_FOLDER, } from "./const.js";
3
- import { jsonToNetworkDefinition } from "./Sidebar/ImportNetworkModal.js";
4
3
  import { sendNetworkDesignerRequest } from "../../controller/agent/Agent.js";
5
4
  import { ChatMessageType } from "../../generated/neuro-san/NeuroSanClient.js";
6
- import { chatMessageFromChunk, removeTrailingUuid } from "../AgentChat/Common/Utils.js";
5
+ import { removeTrailingUuid } from "../../utils/AgentName.js";
6
+ import { chatMessageFromChunk } from "../AgentChat/Common/Utils.js";
7
7
  import { NotificationType, sendNotification } from "../Common/notification.js";
8
+ //#endregion: Types
8
9
  /**
9
10
  * Extracts agent reservations from a chat message, if they exist.
10
11
  * @param message The chat message to extract reservations from. We expect reservations to be present in messages of
@@ -90,22 +91,17 @@ export const isTemporaryNetwork = (agentName, networks) => agentName !== null &&
90
91
  * Merges incoming networks into target, keeping the entry with the highest expiration time.
91
92
  * Returns a new array; does not mutate either argument.
92
93
  */
93
- export const mergeNetworks = (target, incoming) => incoming.reduce((result, n) => {
94
- const existingIdx = result.findIndex((e) => e.agentNetworkName === n.agentNetworkName);
95
- // No existing entry with this name - append.
96
- if (existingIdx < 0)
97
- return [...result, n];
98
- // Existing entry found - keep whichever reservation expires later.
99
- if (n.reservation.expiration_time_in_seconds > result[existingIdx].reservation.expiration_time_in_seconds) {
100
- return result.map((e, i) => (i === existingIdx ? n : e));
101
- }
102
- return result;
103
- }, [...target]);
94
+ export const mergeNetworks = (target, incoming) => Object.values(mergeWith(keyBy(target, "agentNetworkName"), keyBy(incoming, "agentNetworkName"),
95
+ // Both collections share a name: keep whichever reservation expires later, existing wins ties.
96
+ (existing, candidate) => existing &&
97
+ existing.reservation.expiration_time_in_seconds >= candidate.reservation.expiration_time_in_seconds
98
+ ? existing
99
+ : candidate));
104
100
  /**
105
101
  * Extracts TemporaryNetworks from a single streamed chunk, merging into `accumulated`.
106
102
  * Returns `accumulated` unchanged if the chunk yields no reservations or on parse error.
107
103
  */
108
- const collectNetworksFromChunk = (chunk, updated, accumulated) => {
104
+ const collectNetworkFromChunk = (chunk, updated, accumulated) => {
109
105
  try {
110
106
  const chatMessage = chatMessageFromChunk(chunk);
111
107
  if (!chatMessage)
@@ -132,35 +128,16 @@ export const notifySaveError = (agentName, e) => {
132
128
  sendNotification(NotificationType.error, `Failed to update network "${agentName}".`, detail);
133
129
  };
134
130
  /**
135
- * Streams a network definition through the network designer, collecting the
136
- * reservations returned across every chunk. Returns the accumulated networks
137
- * (empty if the designer returned no reservation).
131
+ * Streams a network definition through the network designer to obtain its reservation.
132
+ * Returns the single updated network as a one-element list (empty if the designer returned
133
+ * no reservation).
138
134
  */
139
135
  export const streamNetworkDesignerUpsert = async (neuroSanURL, signal, frontman, networkDef, agentNetworkName, username) => {
140
136
  let newNetworks = [];
141
137
  await sendNetworkDesignerRequest(neuroSanURL, signal, frontman, networkDef, agentNetworkName, username, (chunk) => {
142
- newNetworks = collectNetworksFromChunk(chunk, networkDef, newNetworks);
138
+ // There is only one network. The designer echoes it across streamed chunks. Merge by name so the
139
+ // repeated echoes collapse into that single entry rather than appending duplicates.
140
+ newNetworks = collectNetworkFromChunk(chunk, networkDef, newNetworks);
143
141
  });
144
142
  return newNetworks;
145
143
  };
146
- export const IMPORT_FAILURE_DETAIL = {
147
- "invalid-definition": "The file does not contain a valid network definition.",
148
- "no-reservation": "The network designer did not return a reservation. Please try again.",
149
- };
150
- /**
151
- * Converts imported JSON into a network definition and streams it through the
152
- * network designer to obtain reservations. Returns the resulting networks, or a
153
- * failure reason if the content is not a valid definition or no reservation is returned.
154
- */
155
- export const importNetworkFromJson = async (content, agentNetworkName, neuroSanURL, username) => {
156
- const networkDef = jsonToNetworkDefinition(JSON.parse(content));
157
- if (networkDef.length === 0) {
158
- return { failure: "invalid-definition" };
159
- }
160
- const frontman = getFrontman(networkDef)?.origin ?? networkDef[0]?.origin ?? "agent";
161
- const networks = await streamNetworkDesignerUpsert(neuroSanURL, new AbortController().signal, frontman, networkDef, agentNetworkName, username);
162
- if (networks.length === 0) {
163
- return { failure: "no-reservation" };
164
- }
165
- return { networks };
166
- };
@@ -1,3 +1,6 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Typography from "@mui/material/Typography";
3
+ import { NeuroSanStudioCallout } from "../NeuroSanStudioCallout.js";
1
4
  /**
2
5
  * This file defines the steps for the main tour of the Multi-Agent Accelerator application.
3
6
  *
@@ -8,18 +11,17 @@ export const MAIN_TOUR_STEPS = [
8
11
  // First step doesn't refer to any particular UI element, just a welcome message
9
12
  content: "Welcome to Cognizant AI Lab Multi-Agent Accelerator! This tour will give you a quick overview of " +
10
13
  "the application.",
11
- target: () => document.querySelector("#multi-agent-accelerator-grid"),
14
+ target: () => document.querySelector("#multi-agent-accelerator-center-panel"),
12
15
  placement: "center",
13
16
  },
14
17
  {
15
18
  content: "This is the list of agent networks available on the server. Select a network to see its agents and " +
16
19
  "start interacting with it!",
17
- target: () => document.querySelector("#multi-agent-accelerator-sidebar-heading"),
20
+ target: () => document.querySelector(".MuiRichTreeView-root"),
18
21
  placement: "bottom",
19
22
  },
20
23
  {
21
- content: "Agent Network Designer: Click here to create and edit your own network, with the help of a " +
22
- "powerful AI assistant.",
24
+ content: (_jsxs(_Fragment, { children: ["Agent Network Designer: Click here to create and edit your own network, with the help of a powerful AI assistant.", _jsx("br", {}), _jsx("br", {}), "Networks you create can be downloaded from the sidebar as a HOCON file and run in neuro-san or neuro-san-studio. See the User Guide (under Help) for more information."] })),
23
25
  target: () => document.querySelector("#add-network-icon"),
24
26
  placement: "bottom",
25
27
  },
@@ -33,7 +35,7 @@ export const MAIN_TOUR_STEPS = [
33
35
  content: "These are the agents within the current network. The arrows show the flow of information between " +
34
36
  "them and the tools used by each agent. For networks you have created, you can click on an agent " +
35
37
  "to edit it",
36
- target: () => document.querySelector("#multi-agent-accelerator-grid-agent-flow"),
38
+ target: () => document.querySelector("#multi-agent-accelerator-center-panel"),
37
39
  placement: "auto",
38
40
  },
39
41
  {
@@ -63,7 +65,8 @@ export const MAIN_TOUR_STEPS = [
63
65
  placement: "top",
64
66
  },
65
67
  {
66
- content: "Click this button to display a menu that allows you to choose how content is displayed in the chat window",
68
+ content: "Click this button to display a menu that allows you to choose how content is displayed in the chat " +
69
+ "window. Here you can also enter any sly_data items required by the network (advanced).",
67
70
  target: () => document.querySelector("#agent-network-ui-options-menu-button-container"),
68
71
  placement: "bottom",
69
72
  },
@@ -87,8 +90,7 @@ export const MAIN_TOUR_STEPS = [
87
90
  placement: "top",
88
91
  },
89
92
  {
90
- content: "If you want to take the tour again, or if you have any questions or need help, click here to access " +
91
- "the help information or to contact the Cognizant AI Labs team. We'd love to hear from you!",
93
+ content: (_jsxs(_Fragment, { children: [_jsx(Typography, { sx: { mb: 1 }, variant: "body2", children: "Need help, want to retake the tour, or have feedback? Use this menu to find help resources and contact the Cognizant AI Labs team." }), _jsx(NeuroSanStudioCallout, {})] })),
92
94
  target: () => document.querySelector("#help-dropdown"),
93
95
  placement: "top",
94
96
  },
@@ -1,16 +1,10 @@
1
1
  import { ConnectivityInfo } from "../../generated/neuro-san/NeuroSanClient.js";
2
- export declare const DEFAULT_FRONTMAN_X_POS = 150;
3
- export declare const DEFAULT_FRONTMAN_Y_POS = 450;
4
- export declare const BASE_RADIUS = 100;
5
- export declare const LEVEL_SPACING = 150;
6
- export declare const TEMPORARY_NETWORK_FOLDER = "temporary";
7
- export declare const AGENT_RESERVATIONS_KEY = "agent_reservations";
8
- export declare const AGENT_NETWORK_HOCON = "agent_network_hocon_text";
9
- export declare const AGENT_PROGRESS_CONNECTIVITY_KEY = "connectivity_info";
10
- export declare const AGENT_NETWORK_DESIGNER_ID = "agent_network_designer";
11
2
  export declare const AGENT_NETWORK_DEFINITION_KEY = "agent_network_definition";
3
+ export declare const AGENT_NETWORK_DESIGNER_ID = "agent_network_designer";
4
+ export declare const AGENT_NETWORK_HOCON = "agent_network_hocon_text";
12
5
  export declare const AGENT_NETWORK_NAME_KEY = "agent_network_name";
13
- export declare const TRIGGER_APP_TOUR_EVENT_NAME = "trigger-app-tour";
6
+ export declare const AGENT_PROGRESS_CONNECTIVITY_KEY = "connectivity_info";
7
+ export declare const AGENT_RESERVATIONS_KEY = "agent_reservations";
14
8
  /**
15
9
  * A single agent entry within an agent network definition, as received in sly_data from the backend.
16
10
  * Extends ConnectivityInfo with editable instructions and description fields for the Agent Network Designer.
@@ -19,6 +13,9 @@ export type AgentNetworkDefinitionEntry = ConnectivityInfo & {
19
13
  readonly instructions?: string;
20
14
  readonly description?: string;
21
15
  };
16
+ export declare const BASE_RADIUS = 100;
17
+ export declare const DEFAULT_FRONTMAN_X_POS = 150;
18
+ export declare const DEFAULT_FRONTMAN_Y_POS = 450;
22
19
  /** Possible values for the `display_as` field in ConnectivityInfo / AgentNetworkDefinitionEntry. */
23
20
  export declare enum DisplayAs {
24
21
  LLM_AGENT = "llm_agent",
@@ -26,6 +23,10 @@ export declare enum DisplayAs {
26
23
  LANGCHAIN_TOOL = "langchain_tool",
27
24
  EXTERNAL_AGENT = "external_agent"
28
25
  }
26
+ export declare const EXPIRED_NETWORKS_CHECK_INTERVAL_MS: number;
29
27
  export declare const GRACE_PERIOD_MS: number;
28
+ export declare const LEVEL_SPACING = 150;
30
29
  export declare const SHOW_TOUR_DELAY_MS = 5000;
31
- export declare const EXPIRED_NETWORKS_CHECK_INTERVAL_MS: number;
30
+ export declare const NEURO_SAN_CALLOUT_DELAY_MS = 5000;
31
+ export declare const TEMPORARY_NETWORK_FOLDER = "temporary";
32
+ export declare const TRIGGER_APP_TOUR_EVENT_NAME = "trigger-app-tour";
@@ -13,30 +13,22 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */
16
- export const DEFAULT_FRONTMAN_X_POS = 150;
17
- export const DEFAULT_FRONTMAN_Y_POS = 450;
18
- // Minimum distance from center
19
- export const BASE_RADIUS = 100;
20
- // Distance between depth levels
21
- export const LEVEL_SPACING = 150;
22
- // Temporary folder name for networks created from agent reservations. These networks are not "in a folder" when
23
- // they come from the backend, but we need to put them somewhere in the UI, and this makes it clear that they're
24
- // temporary.
25
- export const TEMPORARY_NETWORK_FOLDER = "temporary";
26
- // We expect the agent reservations to be stored in sly_data under this key
27
- export const AGENT_RESERVATIONS_KEY = "agent_reservations";
28
- // We expect the agent network HOCON to be stored in sly_data under this key, if it is provided by the backend
29
- export const AGENT_NETWORK_HOCON = "agent_network_hocon_text";
30
- // The key in the message structure where connectivity info is stored for agent progress messages
31
- export const AGENT_PROGRESS_CONNECTIVITY_KEY = "connectivity_info";
32
- // Agent name for the special "Agent Network Designer" network
33
- export const AGENT_NETWORK_DESIGNER_ID = "agent_network_designer";
34
16
  // The key in sly_data where the agent network definition is stored
35
17
  export const AGENT_NETWORK_DEFINITION_KEY = "agent_network_definition";
18
+ // Agent name for the special "Agent Network Designer" network
19
+ export const AGENT_NETWORK_DESIGNER_ID = "agent_network_designer";
20
+ // We expect the agent network HOCON to be stored in sly_data under this key, if it is provided by the backend
21
+ export const AGENT_NETWORK_HOCON = "agent_network_hocon_text";
36
22
  // The key in sly_data where the agent network name is stored
37
23
  export const AGENT_NETWORK_NAME_KEY = "agent_network_name";
38
- // The event name that needs to be fired for the app tour to start
39
- export const TRIGGER_APP_TOUR_EVENT_NAME = "trigger-app-tour";
24
+ // The key in the message structure where connectivity info is stored for agent progress messages
25
+ export const AGENT_PROGRESS_CONNECTIVITY_KEY = "connectivity_info";
26
+ // We expect the agent reservations to be stored in sly_data under this key
27
+ export const AGENT_RESERVATIONS_KEY = "agent_reservations";
28
+ // Minimum distance from center
29
+ export const BASE_RADIUS = 100;
30
+ export const DEFAULT_FRONTMAN_X_POS = 150;
31
+ export const DEFAULT_FRONTMAN_Y_POS = 450;
40
32
  /** Possible values for the `display_as` field in ConnectivityInfo / AgentNetworkDefinitionEntry. */
41
33
  export var DisplayAs;
42
34
  (function (DisplayAs) {
@@ -45,9 +37,19 @@ export var DisplayAs;
45
37
  DisplayAs["LANGCHAIN_TOOL"] = "langchain_tool";
46
38
  DisplayAs["EXTERNAL_AGENT"] = "external_agent";
47
39
  })(DisplayAs || (DisplayAs = {}));
40
+ // Check for expired networks every this many milliseconds
41
+ export const EXPIRED_NETWORKS_CHECK_INTERVAL_MS = 10 * 1000;
48
42
  // Display expired temporary networks for this amount of time after they expire so users can see what happened
49
43
  export const GRACE_PERIOD_MS = 5 * 60 * 1000; // 5 minutes
44
+ // Distance between depth levels
45
+ export const LEVEL_SPACING = 150;
50
46
  // We show the tour modal after this amount of time so as not to "pounce" on the user when they first open the app
51
47
  export const SHOW_TOUR_DELAY_MS = 5000;
52
- // Check for expired networks every this many milliseconds
53
- export const EXPIRED_NETWORKS_CHECK_INTERVAL_MS = 10 * 1000;
48
+ // Show the Neuro SAN Studio callout after this many MS
49
+ export const NEURO_SAN_CALLOUT_DELAY_MS = 5000;
50
+ // Temporary folder name for networks created from agent reservations. These networks are not "in a folder" when
51
+ // they come from the backend, but we need to put them somewhere in the UI, and this makes it clear that they're
52
+ // temporary.
53
+ export const TEMPORARY_NETWORK_FOLDER = "temporary";
54
+ // The event name that needs to be fired for the app tour to start
55
+ export const TRIGGER_APP_TOUR_EVENT_NAME = "trigger-app-tour";
@@ -0,0 +1,22 @@
1
+ import { FC } from "react";
2
+ import { KeyValidationFailure } from "../../controller/llm/Providers.js";
3
+ import { LLMProvider } from "../../state/Settings.js";
4
+ interface ApiKeyErrorBannerProps {
5
+ readonly id: string;
6
+ readonly failures: readonly ApiKeyFailure[];
7
+ }
8
+ export interface ApiKeyFailure {
9
+ readonly vendor: LLMProvider;
10
+ readonly result: KeyValidationFailure;
11
+ }
12
+ /**
13
+ * The banner header for a failure: `<vendor> — <reason phrase> (<status>)`, falling back to
14
+ * `<vendor> — Request failed` when the status has no reason phrase, or `<vendor> — Request failed`
15
+ * with no code when the failure carries no status at all.
16
+ */
17
+ export declare const errorTitle: ({ vendor, result: { status: statusCode } }: ApiKeyFailure) => string;
18
+ /**
19
+ * A banner shown at the top of the API Keys section that aggregates all failing key-test results.
20
+ */
21
+ export declare const ApiKeyErrorBanner: FC<ApiKeyErrorBannerProps>;
22
+ export {};
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Box from "@mui/material/Box";
3
+ import Typography from "@mui/material/Typography";
4
+ import httpStatus from "http-status";
5
+ import { MUIAlert } from "../Common/MUIAlert.js";
6
+ /**
7
+ * The banner header for a failure: `<vendor> — <reason phrase> (<status>)`, falling back to
8
+ * `<vendor> — Request failed` when the status has no reason phrase, or `<vendor> — Request failed`
9
+ * with no code when the failure carries no status at all.
10
+ */
11
+ export const errorTitle = ({ vendor, result: { status: statusCode } }) => statusCode !== undefined
12
+ ? `${vendor} — ${httpStatus[statusCode] ?? "Unknown status"} (${statusCode})`
13
+ : `${vendor} — Request failed`;
14
+ const FailureRow = ({ id, failure }) => {
15
+ const { message } = failure.result;
16
+ return (_jsxs(Box, { "data-testid": `${id}-failure`, children: [_jsx(Typography, { sx: { fontWeight: 700 }, variant: "body2", children: errorTitle(failure) }), message ? (_jsx(Typography, { "data-testid": `${id}-message`, sx: { mt: 0.25, overflowWrap: "anywhere" }, variant: "body2", children: message })) : null] }));
17
+ };
18
+ /**
19
+ * A banner shown at the top of the API Keys section that aggregates all failing key-test results.
20
+ */
21
+ export const ApiKeyErrorBanner = ({ id, failures }) => {
22
+ if (failures.length === 0) {
23
+ return null;
24
+ }
25
+ return (_jsx(MUIAlert, { id: id, severity: "error", sx: { width: "100%" }, children: _jsx(Box, { sx: { display: "flex", flexDirection: "column", gap: 1.5, minWidth: 0 }, children: failures.map((failure) => (_jsx(FailureRow, { failure: failure, id: `${id}-${failure.vendor.toLowerCase()}` }, failure.vendor))) }) }));
26
+ };
@@ -1,13 +1,16 @@
1
1
  import { FC } from "react";
2
+ import { KeyValidationFailure, KeyValidationResult } from "../../controller/llm/Providers.js";
3
+ import { LLMProvider } from "../../state/Settings.js";
2
4
  interface ApiKeyInputProps {
3
5
  readonly forgetKey: () => void;
4
6
  readonly id: string;
5
7
  readonly logo: string;
8
+ readonly onResultChange?: (vendor: LLMProvider, result: KeyValidationFailure | null) => void;
6
9
  readonly onSave: (key: string) => void;
7
- readonly onTest: (key: string) => Promise<boolean>;
10
+ readonly onTest: (key: string) => Promise<KeyValidationResult>;
8
11
  readonly persistedValue: string;
9
12
  readonly placeholder: string;
10
- readonly vendor: string;
13
+ readonly vendor: LLMProvider;
11
14
  }
12
15
  /**
13
16
  * Component for inputting an API key for a given vendor, with the ability to test the key and forget the saved key.
@@ -10,12 +10,13 @@ import InputAdornment from "@mui/material/InputAdornment";
10
10
  import TextField from "@mui/material/TextField";
11
11
  import Tooltip from "@mui/material/Tooltip";
12
12
  import { useEffect, useState } from "react";
13
+ import { isKeyValidationFailure } from "../../controller/llm/Providers.js";
13
14
  import { ConfirmationModal } from "../Common/ConfirmationModal.js";
14
15
  import { StatusLight } from "../Common/StatusLight.js";
15
16
  /**
16
17
  * Component for inputting an API key for a given vendor, with the ability to test the key and forget the saved key.
17
18
  */
18
- export const ApiKeyInput = ({ forgetKey, id, logo, onSave, onTest, persistedValue, placeholder, vendor, }) => {
19
+ export const ApiKeyInput = ({ forgetKey, id, logo, onResultChange, onSave, onTest, persistedValue, placeholder, vendor, }) => {
19
20
  const [inputValue, setInputValue] = useState(persistedValue ?? "");
20
21
  const [keyValidated, setKeyValidated] = useState(null);
21
22
  const [isValidating, setIsValidating] = useState(false);
@@ -23,14 +24,17 @@ export const ApiKeyInput = ({ forgetKey, id, logo, onSave, onTest, persistedValu
23
24
  const [showKey, setShowKey] = useState(false);
24
25
  const handleValueChange = (e) => {
25
26
  setKeyValidated(null);
27
+ onResultChange?.(vendor, null);
26
28
  setInputValue(e.target.value);
27
29
  };
28
30
  const handleOnTest = async () => {
29
31
  setIsValidating(true);
30
32
  setKeyValidated(null);
33
+ onResultChange?.(vendor, null);
31
34
  try {
32
- const isValid = await onTest(inputValue);
33
- setKeyValidated(isValid);
35
+ const result = await onTest(inputValue);
36
+ setKeyValidated(result.ok);
37
+ onResultChange?.(vendor, isKeyValidationFailure(result) ? result : null);
34
38
  }
35
39
  finally {
36
40
  setIsValidating(false);
@@ -41,10 +45,12 @@ export const ApiKeyInput = ({ forgetKey, id, logo, onSave, onTest, persistedValu
41
45
  useEffect(() => {
42
46
  setInputValue(persistedValue ?? "");
43
47
  setKeyValidated(null);
44
- }, [persistedValue]);
48
+ onResultChange?.(vendor, null);
49
+ }, [persistedValue, vendor, onResultChange]);
45
50
  const handleClearInput = () => {
46
51
  setInputValue("");
47
52
  setKeyValidated(null);
53
+ onResultChange?.(vendor, null);
48
54
  };
49
55
  return (_jsxs(Box, { "data-testid": `${id}-input`, sx: { display: "flex", alignItems: "center", width: "100%", gap: 2 }, children: [confirmationDialogOpen ? (_jsx(ConfirmationModal, { id: `${id}-forget-key-confirmation-modal`, content: `This will forget the currently saved API key for ${vendor} and you will need to enter ` +
50
56
  " the key again to use networks that require it. Are you sure you want to continue?", handleCancel: () => {