@cognizant-ai-lab/ui-common 1.12.0 → 1.13.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 (61) hide show
  1. package/dist/components/AgentChat/ChatCommon/ChatCommon.js +9 -3
  2. package/dist/components/AgentChat/ChatCommon/Const.js +1 -1
  3. package/dist/components/AgentChat/ChatCommon/SlyDataDialog.js +6 -2
  4. package/dist/components/Common/Snackbar.js +12 -12
  5. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.js +12 -5
  6. package/dist/components/MultiAgentAccelerator/Editor/Const.d.ts +2 -0
  7. package/dist/components/MultiAgentAccelerator/Editor/Const.js +5 -0
  8. package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.d.ts +0 -1
  9. package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.js +3 -5
  10. package/dist/components/MultiAgentAccelerator/PanelSeparator.js +2 -2
  11. package/dist/components/MultiAgentAccelerator/Publish/Publish.d.ts +36 -0
  12. package/dist/components/MultiAgentAccelerator/Publish/Publish.js +99 -0
  13. package/dist/components/MultiAgentAccelerator/Publish/PublishButton.d.ts +16 -0
  14. package/dist/components/MultiAgentAccelerator/Publish/PublishButton.js +98 -0
  15. package/dist/components/MultiAgentAccelerator/Publish/PublishConfirmation.d.ts +15 -0
  16. package/dist/components/MultiAgentAccelerator/Publish/PublishConfirmation.js +8 -0
  17. package/dist/components/MultiAgentAccelerator/Publish/PublishIconButton.d.ts +17 -0
  18. package/dist/components/MultiAgentAccelerator/Publish/PublishIconButton.js +72 -0
  19. package/dist/components/MultiAgentAccelerator/Publish/PublishPanel.d.ts +13 -0
  20. package/dist/components/MultiAgentAccelerator/Publish/PublishPanel.js +28 -0
  21. package/dist/components/MultiAgentAccelerator/Publish/PublishedNetworkUrl.d.ts +11 -0
  22. package/dist/components/MultiAgentAccelerator/Publish/PublishedNetworkUrl.js +64 -0
  23. package/dist/components/MultiAgentAccelerator/Publish/usePublishTarget.d.ts +6 -0
  24. package/dist/components/MultiAgentAccelerator/Publish/usePublishTarget.js +33 -0
  25. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +9 -2
  26. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +2 -0
  27. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +2 -0
  28. package/dist/components/Settings/ApiKeyInput.d.ts +1 -0
  29. package/dist/components/Settings/ApiKeyInput.js +8 -3
  30. package/dist/components/Settings/Byok/ByokDialog.d.ts +24 -0
  31. package/dist/components/Settings/Byok/ByokDialog.js +42 -0
  32. package/dist/components/Settings/Byok/ByokInputs.d.ts +38 -0
  33. package/dist/components/Settings/Byok/ByokInputs.js +35 -0
  34. package/dist/components/Settings/Byok/ByokStorageTooltip.d.ts +7 -0
  35. package/dist/components/Settings/Byok/ByokStorageTooltip.js +41 -0
  36. package/dist/components/Settings/Byok/ByokUnsavedChangesModal.d.ts +23 -0
  37. package/dist/components/Settings/Byok/ByokUnsavedChangesModal.js +19 -0
  38. package/dist/components/Settings/Byok/index.d.ts +5 -0
  39. package/dist/components/Settings/Byok/index.js +20 -0
  40. package/dist/components/Settings/Byok/useByokKeyManager.d.ts +59 -0
  41. package/dist/components/Settings/Byok/useByokKeyManager.js +135 -0
  42. package/dist/components/Settings/PublishSettings.d.ts +15 -0
  43. package/dist/components/Settings/PublishSettings.js +109 -0
  44. package/dist/components/Settings/SettingsDialog.js +17 -133
  45. package/dist/components/Settings/SettingsLayout.d.ts +13 -0
  46. package/dist/components/Settings/SettingsLayout.js +59 -0
  47. package/dist/controller/publish/Publish.d.ts +29 -0
  48. package/dist/controller/publish/Publish.js +94 -0
  49. package/dist/generated/neuro-san/NeuroSanClient.d.ts +9 -0
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +1 -0
  52. package/dist/state/Environment.d.ts +4 -0
  53. package/dist/state/Environment.js +4 -0
  54. package/dist/state/Publish.d.ts +39 -0
  55. package/dist/state/Publish.js +41 -0
  56. package/dist/state/Settings.d.ts +18 -0
  57. package/dist/state/Settings.js +4 -0
  58. package/dist/tsconfig.build.tsbuildinfo +1 -1
  59. package/dist/utils/Url.d.ts +12 -0
  60. package/dist/utils/Url.js +32 -0
  61. package/package.json +1 -1
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+ import PublicIcon from "@mui/icons-material/Public";
18
+ import Box from "@mui/material/Box";
19
+ import CircularProgress from "@mui/material/CircularProgress";
20
+ import IconButton from "@mui/material/IconButton";
21
+ import Tooltip from "@mui/material/Tooltip";
22
+ import { useState } from "react";
23
+ import { openInNewTab, publish, PUBLISH_SETTINGS_REQUIRED_MESSAGE } from "./Publish.js";
24
+ import { PublishConfirmation } from "./PublishConfirmation.js";
25
+ import { usePublishTarget } from "./usePublishTarget.js";
26
+ import { PublishStatus, usePublishStore } from "../../../state/Publish.js";
27
+ /**
28
+ * Small globe button for publishing a network from the sidebar. Publishes after asking, spins while publishing, and
29
+ * turns green once the network is live, when it opens the live site instead.
30
+ */
31
+ export const PublishIconButton = ({ displayName, hocon, id, isExpired, networkId, networkName, }) => {
32
+ const publishStatus = usePublishStore((state) => state.networks[networkId]?.status);
33
+ const publishedUrl = usePublishStore((state) => {
34
+ const publishState = state.networks[networkId];
35
+ return publishState?.status === PublishStatus.Published ? publishState.url : null;
36
+ });
37
+ const target = usePublishTarget(networkId, networkName);
38
+ const [isConfirmOpen, setIsConfirmOpen] = useState(false);
39
+ const getLabel = () => {
40
+ if (publishedUrl)
41
+ return "View live";
42
+ if (publishStatus === PublishStatus.Publishing)
43
+ return "Publishing...";
44
+ if (isExpired)
45
+ return "Expired";
46
+ return target ? "Publish" : PUBLISH_SETTINGS_REQUIRED_MESSAGE;
47
+ };
48
+ const label = getLabel();
49
+ const isPublishing = publishStatus === PublishStatus.Publishing;
50
+ return (_jsxs(_Fragment, { children: [_jsx(Tooltip, { title: label, children: _jsx("span", { children: _jsx(IconButton, { "aria-label": label, disabled: isPublishing || (!publishedUrl && (isExpired || !target)), id: id, onClick: (e) => {
51
+ e.stopPropagation();
52
+ if (publishedUrl) {
53
+ openInNewTab(publishedUrl);
54
+ }
55
+ else {
56
+ setIsConfirmOpen(true);
57
+ }
58
+ }, size: "small", sx: {
59
+ color: "var(--bs-secondary)",
60
+ p: 0,
61
+ "&:hover": { color: "var(--bs-secondary-dark)" },
62
+ "&.Mui-disabled": { opacity: isPublishing ? 1 : 0.3 },
63
+ }, children: isPublishing ? (_jsx(CircularProgress, { size: "0.75rem", sx: { color: "var(--bs-secondary)" } })) : (
64
+ // Colored on the icon itself, since the app's global CSS colors icons inside buttons
65
+ _jsx(PublicIcon, { sx: { fontSize: "0.75rem", ...(publishedUrl && { color: "success.main" }) } })) }) }) }), isConfirmOpen && target && (
66
+ // The dialog is a portal, but its clicks still bubble up the React tree to the sidebar item, which
67
+ // would select the network
68
+ _jsx(Box, { component: "span", onClick: (e) => e.stopPropagation(), children: _jsx(PublishConfirmation, { displayName: displayName, id: `${id}-confirm`, onCancel: () => setIsConfirmOpen(false), onConfirm: () => {
69
+ setIsConfirmOpen(false);
70
+ void publish({ id: networkId, name: networkName }, hocon, target);
71
+ }, target: target }) }))] }));
72
+ };
@@ -0,0 +1,13 @@
1
+ import { FC } from "react";
2
+ import { Published, PublishState } from "../../../state/Publish.js";
3
+ interface PublishPanelProps {
4
+ readonly publishState: PublishState;
5
+ readonly id: string;
6
+ readonly isUnpublishing: boolean;
7
+ readonly onUnpublish: (published: Published) => void;
8
+ }
9
+ /**
10
+ * Details of publishing a network: progress while publishing, or the live URL once published.
11
+ */
12
+ export declare const PublishPanel: FC<PublishPanelProps>;
13
+ export {};
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+ import Box from "@mui/material/Box";
18
+ import Button from "@mui/material/Button";
19
+ import Divider from "@mui/material/Divider";
20
+ import LinearProgress from "@mui/material/LinearProgress";
21
+ import Typography from "@mui/material/Typography";
22
+ import { PublishedNetworkUrl } from "./PublishedNetworkUrl.js";
23
+ import { PublishStatus } from "../../../state/Publish.js";
24
+ import { StatusLight } from "../../Common/StatusLight.js";
25
+ /**
26
+ * Details of publishing a network: progress while publishing, or the live URL once published.
27
+ */
28
+ export const PublishPanel = ({ id, isUnpublishing, onUnpublish, publishState }) => (_jsx(Box, { id: id, sx: { display: "flex", flexDirection: "column", gap: 1.5, p: 2, width: "22rem" }, children: publishState.status === PublishStatus.Published ? (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: { alignItems: "center", display: "flex", gap: 1 }, children: [_jsx(StatusLight, { statusValue: "green" }), _jsx(Typography, { sx: { fontWeight: 600 }, children: "Live" })] }), _jsx(PublishedNetworkUrl, { url: publishState.url }), _jsx(Divider, {}), _jsx(Button, { disabled: isUnpublishing, onClick: () => onUnpublish(publishState), size: "small", sx: { alignSelf: "flex-start", color: "error.light", minWidth: 0, p: 0, textTransform: "none" }, children: isUnpublishing ? "Unpublishing..." : "Unpublish" })] })) : (_jsxs(_Fragment, { children: [_jsx(Typography, { sx: { fontWeight: 600 }, children: "Putting it online..." }), _jsx(LinearProgress, { "aria-label": "Publishing progress", sx: { "& .MuiLinearProgress-bar": { backgroundColor: "var(--bs-secondary)" } } }), _jsx(Typography, { color: "text.secondary", variant: "body2", children: "This can take a minute." })] })) }));
@@ -0,0 +1,11 @@
1
+ import { FC } from "react";
2
+ export declare const COPY_URL_LABEL = "Copy live URL";
3
+ export declare const OPEN_URL_LABEL = "Open live URL";
4
+ interface PublishedNetworkUrlProps {
5
+ readonly url: string;
6
+ }
7
+ /**
8
+ * Read-only display of a published network's URL, with icons to copy it or open it in a new tab.
9
+ */
10
+ export declare const PublishedNetworkUrl: FC<PublishedNetworkUrlProps>;
11
+ export {};
@@ -0,0 +1,64 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+ import ContentCopyIcon from "@mui/icons-material/ContentCopy";
18
+ import OpenInNewIcon from "@mui/icons-material/OpenInNew";
19
+ import Box from "@mui/material/Box";
20
+ import IconButton from "@mui/material/IconButton";
21
+ import Tooltip from "@mui/material/Tooltip";
22
+ import Typography from "@mui/material/Typography";
23
+ import { useState } from "react";
24
+ export const COPY_URL_LABEL = "Copy live URL";
25
+ export const OPEN_URL_LABEL = "Open live URL";
26
+ const COPY_TOOLTIPS = {
27
+ idle: COPY_URL_LABEL,
28
+ copied: "Copied",
29
+ failed: "Couldn't copy",
30
+ };
31
+ /**
32
+ * Read-only display of a published network's URL, with icons to copy it or open it in a new tab.
33
+ */
34
+ export const PublishedNetworkUrl = ({ url }) => {
35
+ const [copyStatus, setCopyStatus] = useState("idle");
36
+ const handleCopy = async () => {
37
+ try {
38
+ await navigator.clipboard.writeText(url);
39
+ setCopyStatus("copied");
40
+ }
41
+ catch {
42
+ setCopyStatus("failed");
43
+ }
44
+ };
45
+ return (_jsxs(Box, { sx: {
46
+ alignItems: "center",
47
+ backgroundColor: "action.hover",
48
+ border: 1,
49
+ borderColor: "divider",
50
+ borderRadius: 1,
51
+ display: "flex",
52
+ gap: 0.5,
53
+ pl: 1.5,
54
+ pr: 0.5,
55
+ py: 0.5,
56
+ }, children: [_jsx(Typography, { sx: {
57
+ flex: 1,
58
+ fontFamily: "monospace",
59
+ fontSize: "0.8rem",
60
+ overflow: "hidden",
61
+ textOverflow: "ellipsis",
62
+ whiteSpace: "nowrap",
63
+ }, title: url, children: url }), _jsx(Tooltip, { onClose: () => setCopyStatus("idle"), title: COPY_TOOLTIPS[copyStatus], children: _jsx(IconButton, { "aria-label": COPY_URL_LABEL, onClick: handleCopy, size: "small", children: _jsx(ContentCopyIcon, { fontSize: "inherit" }) }) }), _jsx(Tooltip, { title: OPEN_URL_LABEL, children: _jsx(IconButton, { "aria-label": OPEN_URL_LABEL, href: url, rel: "noopener noreferrer", size: "small", target: "_blank", children: _jsx(OpenInNewIcon, { fontSize: "inherit" }) }) })] }));
64
+ };
@@ -0,0 +1,6 @@
1
+ import { PublishTarget } from "./Publish.js";
2
+ /**
3
+ * Where to publish the network, or null until there's a server and an org name. Also asks the server whether the
4
+ * network is already live, since we only remember that in memory.
5
+ */
6
+ export declare const usePublishTarget: (networkId: string, networkName: string) => PublishTarget | null;
@@ -0,0 +1,33 @@
1
+ /*
2
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+ import { useEffect } from "react";
17
+ import { checkIfPublished } from "./Publish.js";
18
+ import { usePublishServerUrl } from "../../../state/Publish.js";
19
+ import { useSettingsStore } from "../../../state/Settings.js";
20
+ /**
21
+ * Where to publish the network, or null until there's a server and an org name. Also asks the server whether the
22
+ * network is already live, since we only remember that in memory.
23
+ */
24
+ export const usePublishTarget = (networkId, networkName) => {
25
+ const serverUrl = usePublishServerUrl();
26
+ const orgName = useSettingsStore((state) => state.settings.publish.orgName);
27
+ useEffect(() => {
28
+ if (serverUrl && orgName) {
29
+ void checkIfPublished({ id: networkId, name: networkName }, { serverUrl, orgName });
30
+ }
31
+ }, [networkId, networkName, orgName, serverUrl]);
32
+ return serverUrl && orgName ? { serverUrl, orgName } : null;
33
+ };
@@ -16,7 +16,10 @@ import { TreeItemContent, TreeItemGroupTransition, TreeItemLabel, TreeItemRoot,
16
16
  import { TreeItemProvider } from "@mui/x-tree-view/TreeItemProvider";
17
17
  import { useTreeItem } from "@mui/x-tree-view/useTreeItem";
18
18
  import { useRef } from "react";
19
+ import { useEnvironmentStore } from "../../../state/Environment.js";
20
+ import { usePublishServerUrl } from "../../../state/Publish.js";
19
21
  import { downloadFile } from "../../../utils/File.js";
22
+ import { PublishIconButton } from "../Publish/PublishIconButton.js";
20
23
  //#region Constants
21
24
  // Accessible names shared between each action's tooltip title and its aria-label.
22
25
  export const EDIT_NETWORK_LABEL = "Edit this network";
@@ -78,6 +81,10 @@ export const AgentNetworkTreeItem = ({ children, disabled, itemId, label, onDele
78
81
  const isTemporaryNetwork = Boolean(expirationTime);
79
82
  const isExpired = isChild && isTemporaryNetwork && isTemporaryNetworkExpired(expirationTime);
80
83
  const networkHocon = item?.temporaryNetworkHocon ?? null;
84
+ const enablePublishing = useEnvironmentStore((state) => state.enablePublishing);
85
+ const publishServerUrl = usePublishServerUrl();
86
+ const networkName = item?.temporaryNetworkName;
87
+ const showPublishButton = enablePublishing && Boolean(publishServerUrl) && networkHocon && networkName;
81
88
  const iconNameSuggestion = item.iconSuggestion;
82
89
  let muiIconElement;
83
90
  // If the item is a child (i.e., a network), we want to render an icon next to it.
@@ -119,7 +126,7 @@ export const AgentNetworkTreeItem = ({ children, disabled, itemId, label, onDele
119
126
  .map((tag) => (_jsx(Chip, { label: tag, style: {
120
127
  margin: "0.25rem",
121
128
  backgroundColor: `var(${tagsToColors.get(tag) || TAG_COLORS[0]})`,
122
- } }, tag))), placement: "right", arrow: true, children: _jsx(BookmarkIcon, { sx: { fontSize: "0.75rem", color: "var(--bs-accent1-medium)" } }) })) : null] }), isChild && isTemporaryNetwork && (_jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: "0.25rem", marginLeft: "auto" }, children: [networkHocon && (_jsx(Tooltip, { title: isExpired ? "Expired" : DOWNLOAD_NETWORK_DEFINITION_LABEL, children: _jsx("span", { children: _jsx(ActionIconButton, { onClick: (e) => {
129
+ } }, tag))), placement: "right", arrow: true, children: _jsx(BookmarkIcon, { sx: { fontSize: "0.75rem", color: "var(--bs-accent1-medium)" } }) })) : null] }), isChild && isTemporaryNetwork && (_jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: "0.25rem", marginLeft: "auto" }, children: [showPublishButton && (_jsx(PublishIconButton, { isExpired: isExpired, displayName: item.displayName, hocon: networkHocon, id: `${itemId}-publish`, networkId: itemId, networkName: networkName })), networkHocon && (_jsx(Tooltip, { title: isExpired ? "Expired" : DOWNLOAD_NETWORK_DEFINITION_LABEL, children: _jsx("span", { children: _jsx(ActionIconButton, { onClick: (e) => {
123
130
  // The button is disabled while expired, so no need to guard here.
124
131
  e.stopPropagation();
125
132
  downloadFile(networkHocon, item.downloadFileName, "text/plain");
@@ -136,6 +143,6 @@ export const AgentNetworkTreeItem = ({ children, disabled, itemId, label, onDele
136
143
  opacity: 0.3,
137
144
  },
138
145
  cursor: "pointer",
139
- fontSize: "1rem",
146
+ fontSize: "0.75rem",
140
147
  } }) })] }))] }) }), children && _jsx(TreeItemGroupTransition, { ...getGroupTransitionProps() })] }) }));
141
148
  };
@@ -14,6 +14,8 @@ export interface AgentNetworkTreeItemModel extends Omit<TreeViewDefaultItemModel
14
14
  readonly tags?: readonly string[];
15
15
  readonly temporaryNetworkExpirationTime?: Date;
16
16
  readonly temporaryNetworkHocon?: string | null;
17
+ /** The agent network name, which the network is published under */
18
+ readonly temporaryNetworkName?: string;
17
19
  }
18
20
  /**
19
21
  * Recursively searches for a tree item with the specified ID within the given list of tree items.
@@ -64,6 +64,7 @@ const toNetworkLeaf = (network, label, useNativeNames, metadata = {}) => ({
64
64
  tags: network.tags,
65
65
  temporaryNetworkExpirationTime: metadata.temporaryNetworkExpirationTime,
66
66
  temporaryNetworkHocon: metadata.temporaryNetworkHocon,
67
+ temporaryNetworkName: metadata.temporaryNetworkName,
67
68
  });
68
69
  /**
69
70
  * Recursively sort tree nodes and their children by display name
@@ -177,6 +178,7 @@ export const buildTreeViewItems = (useNativeNames, regularNetworks = [], tempora
177
178
  iconSuggestion: "HourglassTop",
178
179
  temporaryNetworkExpirationTime: new Date(temporaryNetwork.reservation.expiration_time_in_seconds * 1000),
179
180
  temporaryNetworkHocon: temporaryNetwork.networkHocon,
181
+ temporaryNetworkName: temporaryNetwork.agentNetworkName,
180
182
  displayNameOverride: temporaryNetwork.agentNetworkName,
181
183
  });
182
184
  }
@@ -8,6 +8,7 @@ interface ApiKeyInputProps {
8
8
  readonly onResultChange?: (vendor: LLMProvider, result: KeyValidationFailure | null) => void;
9
9
  readonly onSave: (key: string) => void;
10
10
  readonly onTest: (key: string) => Promise<KeyValidationResult>;
11
+ readonly onValueChange?: (vendor: LLMProvider, value: string) => void;
11
12
  readonly persistedValue: string;
12
13
  readonly placeholder: string;
13
14
  readonly vendor: LLMProvider;
@@ -16,16 +16,18 @@ import { StatusLight } from "../Common/StatusLight.js";
16
16
  /**
17
17
  * Component for inputting an API key for a given vendor, with the ability to test the key and forget the saved key.
18
18
  */
19
- export const ApiKeyInput = ({ forgetKey, id, logo, onResultChange, onSave, onTest, persistedValue, placeholder, vendor, }) => {
19
+ export const ApiKeyInput = ({ forgetKey, id, logo, onResultChange, onSave, onTest, onValueChange, persistedValue, placeholder, vendor, }) => {
20
20
  const [inputValue, setInputValue] = useState(persistedValue ?? "");
21
21
  const [keyValidated, setKeyValidated] = useState(null);
22
22
  const [isValidating, setIsValidating] = useState(false);
23
23
  const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false);
24
24
  const [showKey, setShowKey] = useState(false);
25
25
  const handleValueChange = (e) => {
26
+ const newValue = e.target.value;
26
27
  setKeyValidated(null);
27
28
  onResultChange?.(vendor, null);
28
- setInputValue(e.target.value);
29
+ setInputValue(newValue);
30
+ onValueChange?.(vendor, newValue);
29
31
  };
30
32
  const handleOnTest = async () => {
31
33
  setIsValidating(true);
@@ -46,11 +48,13 @@ export const ApiKeyInput = ({ forgetKey, id, logo, onResultChange, onSave, onTes
46
48
  setInputValue(persistedValue ?? "");
47
49
  setKeyValidated(null);
48
50
  onResultChange?.(vendor, null);
49
- }, [persistedValue, vendor, onResultChange]);
51
+ onValueChange?.(vendor, persistedValue ?? "");
52
+ }, [persistedValue, vendor, onResultChange, onValueChange]);
50
53
  const handleClearInput = () => {
51
54
  setInputValue("");
52
55
  setKeyValidated(null);
53
56
  onResultChange?.(vendor, null);
57
+ onValueChange?.(vendor, "");
54
58
  };
55
59
  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 ` +
56
60
  " the key again to use networks that require it. Are you sure you want to continue?", handleCancel: () => {
@@ -58,6 +62,7 @@ export const ApiKeyInput = ({ forgetKey, id, logo, onResultChange, onSave, onTes
58
62
  }, handleOk: () => {
59
63
  setConfirmationDialogOpen(false);
60
64
  setInputValue("");
65
+ onValueChange?.(vendor, "");
61
66
  forgetKey();
62
67
  }, okBtnLabel: "Yes, forget key", title: `Forget ${vendor} API key?` })) : null, _jsx(Box, { sx: {
63
68
  width: 25,
@@ -0,0 +1,24 @@
1
+ import { FC } from "react";
2
+ import { LLMProvider } from "../../../state/Settings.js";
3
+ export interface ByokDialogProps {
4
+ /** Base ID for DOM and test references. */
5
+ readonly id: string;
6
+ /** Whether the dialog is open. Defaults to true. */
7
+ readonly isOpen?: boolean;
8
+ /** Callback invoked when the dialog closes. */
9
+ readonly onClose?: () => void;
10
+ /** Optional filter for supported providers. */
11
+ readonly supportedProviders?: ReadonlySet<LLMProvider>;
12
+ }
13
+ /**
14
+ * Dialog for managing Bring Your Own Key (BYOK) API keys.
15
+ * Prompts the user with a confirmation modal before closing if unsaved edits exist.
16
+ *
17
+ * @param props Component properties
18
+ * @param props.id Base ID for DOM and test references
19
+ * @param props.isOpen Whether the dialog is visible
20
+ * @param props.onClose Callback invoked when dialog closes
21
+ * @param props.supportedProviders Optional filter for supported providers
22
+ * @return BYOK dialog element
23
+ */
24
+ export declare const ByokDialog: FC<ByokDialogProps>;
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+ import Box from "@mui/material/Box";
18
+ import Typography from "@mui/material/Typography";
19
+ import { ByokInputs } from "./ByokInputs.js";
20
+ import { ByokStorageTooltip } from "./ByokStorageTooltip.js";
21
+ import { ByokUnsavedChangesModal } from "./ByokUnsavedChangesModal.js";
22
+ import { useByokKeyManager } from "./useByokKeyManager.js";
23
+ import { MUIDialog } from "../../Common/MUIDialog.js";
24
+ /**
25
+ * Dialog for managing Bring Your Own Key (BYOK) API keys.
26
+ * Prompts the user with a confirmation modal before closing if unsaved edits exist.
27
+ *
28
+ * @param props Component properties
29
+ * @param props.id Base ID for DOM and test references
30
+ * @param props.isOpen Whether the dialog is visible
31
+ * @param props.onClose Callback invoked when dialog closes
32
+ * @param props.supportedProviders Optional filter for supported providers
33
+ * @return BYOK dialog element
34
+ */
35
+ export const ByokDialog = ({ id, isOpen = true, onClose, supportedProviders }) => {
36
+ const { activeConfigs, apiKeys, handleClose, handleDiscard, handleKeyResultChange, handleSave, handleValueChange, keyFailures, persistKey, showUnsavedChangesModal, } = useByokKeyManager({ onClose, supportedProviders });
37
+ return (_jsxs(_Fragment, { children: [showUnsavedChangesModal ? (_jsx(ByokUnsavedChangesModal, { id: id, onDiscard: handleDiscard, onSave: handleSave })) : null, _jsx(MUIDialog, { id: id, isOpen: isOpen, onClose: handleClose, paperProps: {
38
+ minWidth: "500px",
39
+ maxWidth: "700px",
40
+ border: "1px solid",
41
+ }, title: _jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [_jsx(Typography, { variant: "h6", children: "API Keys" }), _jsx(ByokStorageTooltip, {})] }), children: _jsx(ByokInputs, { apiKeys: apiKeys, configs: activeConfigs, id: id, keyFailures: keyFailures, onKeyResultChange: handleKeyResultChange, onPersistKey: persistKey, onValueChange: handleValueChange }) })] }));
42
+ };
@@ -0,0 +1,38 @@
1
+ import { FC } from "react";
2
+ import { ApiKeysMap, ByokProviderItem } from "./useByokKeyManager.js";
3
+ import { KeyValidationFailure } from "../../../controller/llm/Providers.js";
4
+ import { LLMProvider } from "../../../state/Settings.js";
5
+ import { ApiKeyFailure } from "../ApiKeyErrorBanner.js";
6
+ import { useCheckmarkFade } from "../FadingCheckmark.js";
7
+ type CheckmarkFade = ReturnType<typeof useCheckmarkFade>;
8
+ export interface ByokInputsProps {
9
+ /** Persisted API keys map to display in inputs. */
10
+ readonly apiKeys: ApiKeysMap | undefined;
11
+ /** Active provider input configurations. */
12
+ readonly configs: readonly ByokProviderItem[];
13
+ /** Base ID for DOM and testing references. */
14
+ readonly id: string;
15
+ /** Current test failures to display in error banner. */
16
+ readonly keyFailures: readonly ApiKeyFailure[];
17
+ /** Callback when a key validation test produces a result. */
18
+ readonly onKeyResultChange: (vendor: LLMProvider, result: KeyValidationFailure | null) => void;
19
+ /** Callback to persist an API key. */
20
+ readonly onPersistKey: (vendor: LLMProvider, key: string, checkmark: CheckmarkFade, now: number) => void;
21
+ /** Callback when an input value changes. */
22
+ readonly onValueChange: (vendor: LLMProvider, value: string) => void;
23
+ }
24
+ /**
25
+ * Presentational component rendering the list of BYOK API key inputs and error banner.
26
+ *
27
+ * @param props Component properties
28
+ * @param props.apiKeys Persisted API keys map
29
+ * @param props.configs Provider configurations to render
30
+ * @param props.id Base ID for DOM references
31
+ * @param props.keyFailures Active key validation failures
32
+ * @param props.onKeyResultChange Handler when key test result is obtained
33
+ * @param props.onPersistKey Handler to save or clear an API key
34
+ * @param props.onValueChange Handler when key input draft text changes
35
+ * @return Rendered BYOK inputs list with error banner
36
+ */
37
+ export declare const ByokInputs: FC<ByokInputsProps>;
38
+ export {};
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+ import Box from "@mui/material/Box";
18
+ import { getApiKey } from "../../../state/Settings.js";
19
+ import { ApiKeyErrorBanner } from "../ApiKeyErrorBanner.js";
20
+ import { ApiKeyInput } from "../ApiKeyInput.js";
21
+ import { SettingsRow } from "../SettingsRow.js";
22
+ /**
23
+ * Presentational component rendering the list of BYOK API key inputs and error banner.
24
+ *
25
+ * @param props Component properties
26
+ * @param props.apiKeys Persisted API keys map
27
+ * @param props.configs Provider configurations to render
28
+ * @param props.id Base ID for DOM references
29
+ * @param props.keyFailures Active key validation failures
30
+ * @param props.onKeyResultChange Handler when key test result is obtained
31
+ * @param props.onPersistKey Handler to save or clear an API key
32
+ * @param props.onValueChange Handler when key input draft text changes
33
+ * @return Rendered BYOK inputs list with error banner
34
+ */
35
+ export const ByokInputs = ({ apiKeys, configs, id, keyFailures, onKeyResultChange, onPersistKey, onValueChange, }) => (_jsxs(_Fragment, { children: [_jsx(ApiKeyErrorBanner, { failures: keyFailures, id: `${id}-api-key-error-banner` }), _jsx(Box, { sx: { display: "flex", flexDirection: "column", alignItems: "center", gap: 1.5, mt: 1, width: "100%" }, children: configs.map(({ checkmark, idSuffix, logo, onTest, placeholder, vendor }) => (_jsx(SettingsRow, { checkmark: checkmark, label: "", tooltip: `API key for ${vendor}.`, children: _jsx(ApiKeyInput, { forgetKey: () => onPersistKey(vendor, "", checkmark, 0), id: `${id}-${idSuffix}`, logo: logo, onResultChange: onKeyResultChange, onSave: (key) => onPersistKey(vendor, key, checkmark, Date.now()), onTest: onTest, onValueChange: onValueChange, persistedValue: getApiKey(apiKeys, vendor), placeholder: placeholder, vendor: vendor }) }, `${id}-${idSuffix}`))) })] }));
@@ -0,0 +1,7 @@
1
+ import { FC } from "react";
2
+ /**
3
+ * Tooltip explaining how user-provided API keys are stored in session memory and transmitted.
4
+ *
5
+ * @return Tooltip element with explanatory text
6
+ */
7
+ export declare const ByokStorageTooltip: FC;
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+ import Box from "@mui/material/Box";
18
+ import Tooltip from "@mui/material/Tooltip";
19
+ import Typography from "@mui/material/Typography";
20
+ const BYOK_TOOLTIP_TEXT = "API keys are stored locally in your browser's memory for the duration of your session only " +
21
+ "and are only sent to the Neuro SAN service for use with the associated LLM provider when you use " +
22
+ "this application to interact with networks.\n" +
23
+ "Your keys are never sent to any other servers or services and are not stored on our servers.\n" +
24
+ "When you close this tab or your browser, your keys will be permanently cleared from memory and " +
25
+ "you will need to enter them again to use services that require them.";
26
+ /**
27
+ * Tooltip explaining how user-provided API keys are stored in session memory and transmitted.
28
+ *
29
+ * @return Tooltip element with explanatory text
30
+ */
31
+ export const ByokStorageTooltip = () => (_jsx(Tooltip, { title: BYOK_TOOLTIP_TEXT, children: _jsxs(Typography, { sx: {
32
+ alignSelf: "flex-start",
33
+ color: "var(--bs-secondary)",
34
+ cursor: "help",
35
+ fontSize: "0.7rem",
36
+ lineHeight: 1,
37
+ mt: 0.5,
38
+ }, variant: "caption", children: [_jsx(Box, { component: "span", sx: { mr: 0.5 }, children: "\u24D8" }), _jsx(Box, { component: "span", sx: {
39
+ borderBottom: "1px dashed",
40
+ pb: 0.25,
41
+ }, children: "How are my keys stored and used?" })] }) }));
@@ -0,0 +1,23 @@
1
+ import { FC } from "react";
2
+ export interface ByokUnsavedChangesModalProps {
3
+ /** Base element ID for DOM and testing references. */
4
+ readonly id: string;
5
+ /** Whether the modal is open. Defaults to true. */
6
+ readonly isOpen?: boolean;
7
+ /** Callback when user chooses to discard unsaved changes. */
8
+ readonly onDiscard: () => void;
9
+ /** Callback when user chooses to save unsaved changes. */
10
+ readonly onSave: () => void;
11
+ }
12
+ /**
13
+ * Confirmation modal displayed when closing a dialog with unsaved BYOK API key changes.
14
+ * Offers options to save changes or discard them before closing.
15
+ *
16
+ * @param props Component properties
17
+ * @param props.id Base ID for the modal
18
+ * @param props.isOpen Whether the modal is currently open
19
+ * @param props.onDiscard Callback to discard unsaved changes and proceed
20
+ * @param props.onSave Callback to save unsaved changes and proceed
21
+ * @return Confirmation modal element, or null if not open
22
+ */
23
+ export declare const ByokUnsavedChangesModal: FC<ByokUnsavedChangesModalProps>;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ConfirmationModal } from "../../Common/ConfirmationModal.js";
3
+ /**
4
+ * Confirmation modal displayed when closing a dialog with unsaved BYOK API key changes.
5
+ * Offers options to save changes or discard them before closing.
6
+ *
7
+ * @param props Component properties
8
+ * @param props.id Base ID for the modal
9
+ * @param props.isOpen Whether the modal is currently open
10
+ * @param props.onDiscard Callback to discard unsaved changes and proceed
11
+ * @param props.onSave Callback to save unsaved changes and proceed
12
+ * @return Confirmation modal element, or null if not open
13
+ */
14
+ export const ByokUnsavedChangesModal = ({ id, isOpen = true, onDiscard, onSave }) => {
15
+ if (!isOpen) {
16
+ return null;
17
+ }
18
+ return (_jsx(ConfirmationModal, { cancelBtnLabel: "Discard changes", closeable: false, content: _jsx("p", { children: "You have unsaved edits. Would you like to save your changes, or discard them?" }), handleCancel: onDiscard, handleOk: onSave, id: `${id}-unsaved-changes-modal`, maskCloseable: false, okBtnLabel: "Save changes", title: "Unsaved Changes" }));
19
+ };
@@ -0,0 +1,5 @@
1
+ export * from "./ByokDialog.js";
2
+ export * from "./ByokInputs.js";
3
+ export * from "./ByokStorageTooltip.js";
4
+ export * from "./ByokUnsavedChangesModal.js";
5
+ export * from "./useByokKeyManager.js";
@@ -0,0 +1,20 @@
1
+ /*
2
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+ export * from "./ByokDialog.js";
17
+ export * from "./ByokInputs.js";
18
+ export * from "./ByokStorageTooltip.js";
19
+ export * from "./ByokUnsavedChangesModal.js";
20
+ export * from "./useByokKeyManager.js";