@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.
- package/dist/components/AgentChat/ChatCommon/ChatCommon.js +9 -3
- package/dist/components/AgentChat/ChatCommon/Const.js +1 -1
- package/dist/components/AgentChat/ChatCommon/SlyDataDialog.js +6 -2
- package/dist/components/Common/Snackbar.js +12 -12
- package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.js +12 -5
- package/dist/components/MultiAgentAccelerator/Editor/Const.d.ts +2 -0
- package/dist/components/MultiAgentAccelerator/Editor/Const.js +5 -0
- package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.d.ts +0 -1
- package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.js +3 -5
- package/dist/components/MultiAgentAccelerator/PanelSeparator.js +2 -2
- package/dist/components/MultiAgentAccelerator/Publish/Publish.d.ts +36 -0
- package/dist/components/MultiAgentAccelerator/Publish/Publish.js +99 -0
- package/dist/components/MultiAgentAccelerator/Publish/PublishButton.d.ts +16 -0
- package/dist/components/MultiAgentAccelerator/Publish/PublishButton.js +98 -0
- package/dist/components/MultiAgentAccelerator/Publish/PublishConfirmation.d.ts +15 -0
- package/dist/components/MultiAgentAccelerator/Publish/PublishConfirmation.js +8 -0
- package/dist/components/MultiAgentAccelerator/Publish/PublishIconButton.d.ts +17 -0
- package/dist/components/MultiAgentAccelerator/Publish/PublishIconButton.js +72 -0
- package/dist/components/MultiAgentAccelerator/Publish/PublishPanel.d.ts +13 -0
- package/dist/components/MultiAgentAccelerator/Publish/PublishPanel.js +28 -0
- package/dist/components/MultiAgentAccelerator/Publish/PublishedNetworkUrl.d.ts +11 -0
- package/dist/components/MultiAgentAccelerator/Publish/PublishedNetworkUrl.js +64 -0
- package/dist/components/MultiAgentAccelerator/Publish/usePublishTarget.d.ts +6 -0
- package/dist/components/MultiAgentAccelerator/Publish/usePublishTarget.js +33 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +9 -2
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +2 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +2 -0
- package/dist/components/Settings/ApiKeyInput.d.ts +1 -0
- package/dist/components/Settings/ApiKeyInput.js +8 -3
- package/dist/components/Settings/Byok/ByokDialog.d.ts +24 -0
- package/dist/components/Settings/Byok/ByokDialog.js +42 -0
- package/dist/components/Settings/Byok/ByokInputs.d.ts +38 -0
- package/dist/components/Settings/Byok/ByokInputs.js +35 -0
- package/dist/components/Settings/Byok/ByokStorageTooltip.d.ts +7 -0
- package/dist/components/Settings/Byok/ByokStorageTooltip.js +41 -0
- package/dist/components/Settings/Byok/ByokUnsavedChangesModal.d.ts +23 -0
- package/dist/components/Settings/Byok/ByokUnsavedChangesModal.js +19 -0
- package/dist/components/Settings/Byok/index.d.ts +5 -0
- package/dist/components/Settings/Byok/index.js +20 -0
- package/dist/components/Settings/Byok/useByokKeyManager.d.ts +59 -0
- package/dist/components/Settings/Byok/useByokKeyManager.js +135 -0
- package/dist/components/Settings/PublishSettings.d.ts +15 -0
- package/dist/components/Settings/PublishSettings.js +109 -0
- package/dist/components/Settings/SettingsDialog.js +17 -133
- package/dist/components/Settings/SettingsLayout.d.ts +13 -0
- package/dist/components/Settings/SettingsLayout.js +59 -0
- package/dist/controller/publish/Publish.d.ts +29 -0
- package/dist/controller/publish/Publish.js +94 -0
- package/dist/generated/neuro-san/NeuroSanClient.d.ts +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/state/Environment.d.ts +4 -0
- package/dist/state/Environment.js +4 -0
- package/dist/state/Publish.d.ts +39 -0
- package/dist/state/Publish.js +41 -0
- package/dist/state/Settings.d.ts +18 -0
- package/dist/state/Settings.js +4 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/Url.d.ts +12 -0
- package/dist/utils/Url.js +32 -0
- package/package.json +1 -1
|
@@ -69,6 +69,8 @@ const EMPTY = {};
|
|
|
69
69
|
// How many times to retry the entire agent interaction process. Some networks have a well-defined success condition.
|
|
70
70
|
// For others, it's just "whenever the stream is done".
|
|
71
71
|
const MAX_AGENT_RETRIES = 3;
|
|
72
|
+
// Keep long prompts navigable without allowing the input to take over the chat window.
|
|
73
|
+
const MAX_CHAT_INPUT_ROWS = 8;
|
|
72
74
|
/**
|
|
73
75
|
* Extract the final answer from the response from a legacy agent
|
|
74
76
|
* @param response The response from the legacy agent
|
|
@@ -196,7 +198,8 @@ export const ChatCommon = ({ ref, ...props }) => {
|
|
|
196
198
|
const addTurn = useCallback((turn) => {
|
|
197
199
|
setTurns((current) => {
|
|
198
200
|
const next = [...current, turn];
|
|
199
|
-
|
|
201
|
+
// Keep user queries visible even when a network streams more than MAX_TURNS responses.
|
|
202
|
+
return next.filter((item, index) => item.role === MessageRole.User || index >= next.length - MAX_TURNS);
|
|
200
203
|
});
|
|
201
204
|
}, []);
|
|
202
205
|
// We use this to update the same "turn" as chunks come in from legacy agents
|
|
@@ -681,14 +684,14 @@ export const ChatCommon = ({ ref, ...props }) => {
|
|
|
681
684
|
paddingTop: "7.5px",
|
|
682
685
|
scrollbarGutter: "stable",
|
|
683
686
|
width: "100%",
|
|
684
|
-
}, tabIndex: -1, children: [getOptionsMenu(), getOptionsMenuButton(), getChatHistory(), getNetworkIntro(), getAgentGreeting(), _jsx(SampleQueries, { disabled: isAwaitingLlm, handleSend: handleSend, sampleQueries: sampleQueries }), _jsx(Conversation, { id: id, includeAgentMessages: !givesFinalAnswer(selectedNetwork), shouldWrapOutput: shouldWrapOutput, turns: turns }), getThinking(), getWorkingSpinner(), getControlButtons()] })] }));
|
|
687
|
+
}, tabIndex: -1, children: [getOptionsMenu(), getOptionsMenuButton(), getChatHistory(), getNetworkIntro(), getAgentGreeting(), _jsx(SampleQueries, { disabled: isAwaitingLlm, handleSend: handleSend, sampleQueries: sampleQueries }), _jsx(Box, { role: "region", "aria-label": "Current conversation", children: _jsx(Conversation, { id: id, includeAgentMessages: !givesFinalAnswer(selectedNetwork), shouldWrapOutput: shouldWrapOutput, turns: turns }) }), getThinking(), getWorkingSpinner(), getControlButtons()] })] }));
|
|
685
688
|
const getUserInputBox = () => (_jsxs(Box, { id: "user-input-div", sx: {
|
|
686
689
|
...divStyle,
|
|
687
690
|
alignItems: "center",
|
|
688
691
|
display: "flex",
|
|
689
692
|
margin: "10px",
|
|
690
693
|
position: "relative",
|
|
691
|
-
}, children: [_jsx(Input, { autoComplete: "off", id: "user-input", multiline: true, placeholder: getPlaceholder(), ref: chatInputRef, sx: {
|
|
694
|
+
}, children: [_jsx(Input, { autoComplete: "off", id: "user-input", maxRows: MAX_CHAT_INPUT_ROWS, multiline: true, placeholder: getPlaceholder(), ref: chatInputRef, sx: {
|
|
692
695
|
border: "var(--bs-border-style) var(--bs-border-width) var(--bs-gray-light)",
|
|
693
696
|
borderRadius: "var(--bs-border-radius)",
|
|
694
697
|
display: "flex",
|
|
@@ -700,6 +703,9 @@ export const ChatCommon = ({ ref, ...props }) => {
|
|
|
700
703
|
paddingLeft: "1rem",
|
|
701
704
|
paddingRight: "1rem",
|
|
702
705
|
transition: "margin-right 0.2s",
|
|
706
|
+
"& textarea": {
|
|
707
|
+
overflowY: "auto",
|
|
708
|
+
},
|
|
703
709
|
}, onChange: (event) => {
|
|
704
710
|
setChatInput(event.target.value);
|
|
705
711
|
}, onKeyDown: async (event) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Maximum number of turns to save
|
|
1
|
+
// Maximum number of recent turns to save, in addition to older user queries.
|
|
2
2
|
export const MAX_TURNS = 50;
|
|
3
3
|
// The sly_data key under which we supply the current username. Some coded tools (data generator...) expect it.
|
|
4
4
|
export const SLY_DATA_LOGIN_KEY = "login";
|
|
@@ -45,6 +45,9 @@ const IMAGE_PREVIEW_SIZE = 96;
|
|
|
45
45
|
// Tooltip explaining what sly data is, in end-user terms: it exists to carry values (credentials included) that
|
|
46
46
|
// belong with the request but must stay out of the LLM conversation.
|
|
47
47
|
const SLY_DATA_EXPLAINER = "Data is sent to the agent network in a private channel with each request but kept out of the LLM.";
|
|
48
|
+
// Shown in place of the schema hints when the network lists nothing for the user to supply. Worded so it stays
|
|
49
|
+
// true when a network uses sly data without advertising a schema, or only declares keys the app supplies itself.
|
|
50
|
+
const NO_SCHEMA_HINT = "This network doesn't list any sly data for you to fill in.";
|
|
48
51
|
//#endregion: Constants
|
|
49
52
|
// A sly_data key name rendered as an inline code chip
|
|
50
53
|
const KeyChip = styled("code")(({ theme }) => ({
|
|
@@ -158,9 +161,10 @@ export const SlyDataDialog = ({ extraSlyDataKeys = NO_EXTRA_KEYS, id, isOpen, ne
|
|
|
158
161
|
: "Reset to the network's expected keys (takes effect when you save)", children: _jsx("span", { children: _jsx(IconButton, { "aria-label": "Clear sly data", id: `${id}-clear-button`, onClick: handleClear, size: "small", sx: { "&:hover": { color: "error.main" } }, children: _jsx(DeleteOutlined, { fontSize: "small" }) }) }) }), _jsx("input", { accept: "application/json, .json", "aria-label": "Sly data file", "data-testid": `${id}-file-input`, id: `${id}-file-input`, onChange: handleFileSelected, ref: fileInputRef, style: { display: "none" }, type: "file" })] }));
|
|
159
162
|
/**
|
|
160
163
|
* Lists the keys the network says it expects, so the user knows what to fill in without reading the
|
|
161
|
-
* network's source.
|
|
164
|
+
* network's source. When the network advertises nothing for the user to supply, says so instead of leaving
|
|
165
|
+
* an unexplained empty editor.
|
|
162
166
|
*/
|
|
163
|
-
const getSchemaHints = () => schemaEntries.length > 0
|
|
167
|
+
const getSchemaHints = () => schemaEntries.length > 0 ? (_jsxs(Box, { "data-testid": `${id}-schema-hints`, id: `${id}-schema-hints`, sx: { mb: 0.5 }, children: [_jsx(Typography, { sx: { fontSize: "0.75rem" }, variant: "caption", children: "This network expects:" }), _jsx(Box, { component: "ul", sx: { listStyle: "none", m: 0, pl: 1.5 }, children: schemaEntries.map((entry) => (_jsxs(Typography, { component: "li", sx: { display: "block", fontSize: "0.75rem" }, variant: "caption", children: [_jsx(KeyChip, { children: entry.key }), describeEntryQualifiers(entry), entry.description ? `: ${entry.description}` : ""] }, entry.key))) })] })) : (_jsx(Typography, { id: `${id}-no-schema-hint`, sx: { display: "block", fontSize: "0.75rem", mb: 0.5 }, variant: "caption", children: NO_SCHEMA_HINT }));
|
|
164
168
|
const getServerUpdateAlert = () => wasUpdatedByServer && (_jsx(Alert, { action: _jsx(StyledButton, { id: `${id}-reload-button`, onClick: handleReload, variant: "outlined", children: "Reload" }), id: `${id}-server-update-alert`, severity: "info", sx: { my: 1 }, children: "The agents updated sly data while you were editing. Reloading discards your changes." }));
|
|
165
169
|
/**
|
|
166
170
|
* Preview strip for any values that look like images. Read-only: the underlying value stays editable as text.
|
|
@@ -21,8 +21,7 @@ import { alpha, styled, useTheme } from "@mui/material/styles";
|
|
|
21
21
|
import { SnackbarContent, useSnackbar } from "notistack";
|
|
22
22
|
// #region: Styled Components
|
|
23
23
|
const IconBox = styled(Box)({
|
|
24
|
-
|
|
25
|
-
bottom: "2px",
|
|
24
|
+
display: "flex",
|
|
26
25
|
"&.success": {
|
|
27
26
|
color: "var(--bs-success)",
|
|
28
27
|
},
|
|
@@ -45,26 +44,27 @@ export const Snackbar = ({ ref, description, hideIconVariant = false, iconVarian
|
|
|
45
44
|
const theme = useTheme();
|
|
46
45
|
const shadowColor = theme.palette.mode === "dark" ? theme.palette.common.white : theme.palette.common.black;
|
|
47
46
|
return (_jsx(SnackbarContent, { ref: ref, role: "alert", children: _jsxs(Box, { className: `${variant}-snackbar-notification`, id: `${id}-snackbar-box`, "data-testid": `${id}-snackbar-box`, sx: {
|
|
47
|
+
// A single line of text centers on the icon. With a description, the icon stays at the top.
|
|
48
|
+
alignItems: description ? "flex-start" : "center",
|
|
48
49
|
background: theme.palette.background.paper,
|
|
49
50
|
borderColor: "transparent",
|
|
50
51
|
borderRadius: "var(--bs-border-radius)",
|
|
51
52
|
borderWidth: "1px",
|
|
52
53
|
boxShadow: `0 6px 16px 0 ${alpha(shadowColor, 0.08)}, 0 3px 6px -4px ${alpha(shadowColor, 0.12)},
|
|
53
54
|
0 9px 28px 8px ${alpha(shadowColor, 0.05)}`,
|
|
55
|
+
display: "flex",
|
|
54
56
|
maxWidth: "450px",
|
|
55
57
|
minWidth: "250px",
|
|
56
58
|
padding: "0.9rem",
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
display: "block",
|
|
59
|
+
// Room for the close button
|
|
60
|
+
paddingRight: "2.5rem",
|
|
61
|
+
}, children: [!hideIconVariant && (_jsx(Box, { id: `${id}-snackbar-icon-box-container`,
|
|
62
|
+
// With a description, as tall as the title's first line so the icon centers on it
|
|
63
|
+
sx: description
|
|
64
|
+
? { alignItems: "center", display: "flex", fontSize: "0.95rem", height: "1.5em" }
|
|
65
|
+
: {}, children: _jsx(IconBox, { className: variant, "data-testid": `${id}-snackbar-icon-box`, id: `${id}-snackbar-icon-box`, children: icon }) })), _jsxs(Box, { id: `${id}-snackbar-content-box`, sx: { flex: 1, minWidth: 0, wordWrap: "break-word" }, children: [_jsx(Box, { id: `${id}-snackbar-message-box`, sx: {
|
|
65
66
|
// If no description, this is the only message, so reduce font size
|
|
66
67
|
fontSize: description ? "0.95rem" : "0.85rem",
|
|
67
|
-
paddingRight: "25px",
|
|
68
68
|
}, children: message }), _jsx(IconButton, { "aria-label": "close", id: `${id}-close-icon-btn`, onClick: handleCloseSnackbar, sx: {
|
|
69
69
|
position: "absolute",
|
|
70
70
|
right: 4,
|
|
@@ -72,5 +72,5 @@ export const Snackbar = ({ ref, description, hideIconVariant = false, iconVarian
|
|
|
72
72
|
}, children: _jsx(CloseIcon, { "data-testid": `${id}-close-icon`, id: `${id}-close-icon`, sx: {
|
|
73
73
|
color: "var(--bs-gray-medium)",
|
|
74
74
|
fontSize: "0.6em",
|
|
75
|
-
} }) }), description && (_jsx(Box, { id: `${id}-snackbar-description-box`, sx: { fontSize: "0.8rem", paddingTop: "10px"
|
|
75
|
+
} }) }), description && (_jsx(Box, { id: `${id}-snackbar-description-box`, sx: { fontSize: "0.8rem", paddingTop: "10px" }, children: description }))] })] }) }));
|
|
76
76
|
};
|
|
@@ -32,11 +32,14 @@ import { AgentNode, NODE_HEIGHT, NODE_WIDTH } from "./AgentNode.js";
|
|
|
32
32
|
import { BASE_RADIUS, DEFAULT_FRONTMAN_X_POS, DEFAULT_FRONTMAN_Y_POS, LEVEL_SPACING, } from "../const.js";
|
|
33
33
|
import { addThoughtBubbleEdge, layoutLinear, layoutRadial } from "./GraphLayouts.js";
|
|
34
34
|
import { PlasmaEdge } from "./PlasmaEdge.js";
|
|
35
|
+
import { useEnvironmentStore } from "../../../state/Environment.js";
|
|
36
|
+
import { usePublishServerUrl } from "../../../state/Publish.js";
|
|
35
37
|
import { usePalette, useSettingsStore } from "../../../state/Settings.js";
|
|
36
38
|
import { useTempNetworksStore } from "../../../state/TemporaryNetworks.js";
|
|
37
39
|
import { getZIndex } from "../../../utils/zIndexLayers.js";
|
|
38
40
|
import { AgentNodeEditor } from "../Editor/AgentNodeEditor.js";
|
|
39
41
|
import { NetworkEditorDock } from "../Editor/NetworkEditorDock.js";
|
|
42
|
+
import { PublishButton } from "../Publish/PublishButton.js";
|
|
40
43
|
import { isEditableAgent } from "../TemporaryNetworks.js";
|
|
41
44
|
import { ThoughtBubbleEdge } from "../ThoughtBubbles/ThoughtBubbleEdge.js";
|
|
42
45
|
import { ThoughtBubbleOverlay } from "../ThoughtBubbles/ThoughtBubbleOverlay.js";
|
|
@@ -66,6 +69,7 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
|
|
|
66
69
|
const { fitView } = useReactFlow();
|
|
67
70
|
const flowWrapperRef = useRef(null);
|
|
68
71
|
const fitViewFrameRef = useRef(null);
|
|
72
|
+
const enablePublishing = useEnvironmentStore((state) => state.enablePublishing);
|
|
69
73
|
const scheduleFitView = useCallback(() => {
|
|
70
74
|
if (fitViewFrameRef.current !== null) {
|
|
71
75
|
window.cancelAnimationFrame(fitViewFrameRef.current);
|
|
@@ -136,6 +140,8 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
|
|
|
136
140
|
};
|
|
137
141
|
// Read temporary networks to find agent_network_definition for the currently selected network.
|
|
138
142
|
const tempNetworks = useTempNetworksStore((state) => state.tempNetworks);
|
|
143
|
+
const publishServerUrl = usePublishServerUrl();
|
|
144
|
+
const currentTempNetwork = useMemo(() => (networkId ? tempNetworks.find((n) => n.agentInfo.agent_name === networkId) : undefined), [networkId, tempNetworks]);
|
|
139
145
|
// Track conversation IDs we've already processed to prevent re-adding after expiry
|
|
140
146
|
const processedConversationIdsRef = useRef(new Set());
|
|
141
147
|
// Track which bubble is currently being hovered
|
|
@@ -304,9 +310,6 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
|
|
|
304
310
|
if (!isEditableAgent(node.data.displayAs))
|
|
305
311
|
return;
|
|
306
312
|
// Find the agent's existing instructions and description from the temp network definition.
|
|
307
|
-
const currentTempNetwork = networkId
|
|
308
|
-
? tempNetworks.find((n) => n.agentInfo.agent_name === networkId)
|
|
309
|
-
: undefined;
|
|
310
313
|
const currentAgentDefinition = currentTempNetwork?.agentNetworkDefinition?.find((e) => e.origin === node.id);
|
|
311
314
|
setSelectedAgent({
|
|
312
315
|
agentId: node.id,
|
|
@@ -315,7 +318,7 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
|
|
|
315
318
|
initialDescription: currentAgentDefinition?.description ?? "",
|
|
316
319
|
});
|
|
317
320
|
setIsPopupOpen(true);
|
|
318
|
-
}, [
|
|
321
|
+
}, [currentTempNetwork, isTemporaryNetwork]);
|
|
319
322
|
const handleNodeClick = useCallback((_event, node) => openNodeEditor(node), [openNodeEditor]);
|
|
320
323
|
// ReactFlow makes nodes focusable and selects them on Enter, but it never fires onNodeClick from the keyboard.
|
|
321
324
|
// Route Enter on a focused node to the editor so keyboard users can open a node the same way a click does.
|
|
@@ -448,6 +451,10 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
|
|
|
448
451
|
const getTitle = () => {
|
|
449
452
|
if (!networkDisplayName)
|
|
450
453
|
return null;
|
|
454
|
+
const isPublishingSetUp = enablePublishing && Boolean(publishServerUrl);
|
|
455
|
+
const isViewingNetwork = !isAgentNetworkDesignerMode && !isEditingNetwork;
|
|
456
|
+
const hoconToPublish = currentTempNetwork?.networkHocon;
|
|
457
|
+
const showPublishButton = isPublishingSetUp && isViewingNetwork && currentTempNetwork?.agentNetworkName && hoconToPublish;
|
|
451
458
|
return (_jsxs(Box, { id: `${id}-network-title-bar`, sx: {
|
|
452
459
|
alignItems: "center",
|
|
453
460
|
display: "flex",
|
|
@@ -478,7 +485,7 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
|
|
|
478
485
|
}, children: networkDisplayName }) }), isTemporaryNetwork && !isEditingNetwork && !isAwaitingLlm && (_jsx(Button, { id: `${id}-enter-edit-mode-btn`, variant: "contained", size: "small", onClick: () => setIsEditingNetwork(true), startIcon: _jsx(EditIcon, {}), sx: {
|
|
479
486
|
pointerEvents: "auto",
|
|
480
487
|
"&:hover": { backgroundColor: theme.palette.primary.main },
|
|
481
|
-
}, children: "Edit" }))] }));
|
|
488
|
+
}, children: "Edit" })), showPublishButton && (_jsx(Box, { sx: { pointerEvents: "auto" }, children: _jsx(PublishButton, { displayName: networkDisplayName, hocon: hoconToPublish, id: `${id}-publish-button`, networkId: currentTempNetwork.agentInfo.agent_name, networkName: currentTempNetwork.agentNetworkName }) }))] }));
|
|
482
489
|
};
|
|
483
490
|
return (_jsxs(Box, { id: `${id}-outer-box`, sx: {
|
|
484
491
|
display: "flex",
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Timeout in milliseconds for the network designer streaming response.
|
|
2
|
+
export const STREAM_TIMEOUT_MS = 3 * 60 * 1000;
|
|
3
|
+
// How long the dock's status banner stays visible before auto-dismissing. Error banners persist until dismissed.
|
|
4
|
+
// Exported for tests.
|
|
5
|
+
export const BANNER_AUTO_DISMISS_MS = 5_000;
|
|
@@ -19,12 +19,9 @@ import { chatMessageFromChunk } from "../../AgentChat/Common/Utils.js";
|
|
|
19
19
|
import { MUIAlert } from "../../Common/MUIAlert.js";
|
|
20
20
|
import { AGENT_NETWORK_DEFINITION_KEY, AGENT_NETWORK_DESIGNER_ID, AGENT_NETWORK_NAME_KEY, } from "../const.js";
|
|
21
21
|
import { convertReservationsToNetworks, extractNetworkHocon, extractReservations, mergeNetworks, } from "../TemporaryNetworks.js";
|
|
22
|
+
import { BANNER_AUTO_DISMISS_MS, STREAM_TIMEOUT_MS } from "./Const.js";
|
|
22
23
|
//#region Constants
|
|
23
24
|
const PROMPT_PLACEHOLDER = "Describe a change to the network";
|
|
24
|
-
const STREAM_TIMEOUT_MS = 120_000;
|
|
25
|
-
// How long the dock's status banner stays visible before auto-dismissing. Error banners persist until dismissed.
|
|
26
|
-
// Exported for tests.
|
|
27
|
-
export const BANNER_AUTO_DISMISS_MS = 5_000;
|
|
28
25
|
//#endregion Interfaces and Types
|
|
29
26
|
/**
|
|
30
27
|
* Implements the dock that appears at the bottom of the screen when the user is editing a network. Allows user to
|
|
@@ -236,7 +233,8 @@ export const NetworkEditorDock = ({ neuroSanURL, currentUser, id, isEditingNetwo
|
|
|
236
233
|
py: 2.5,
|
|
237
234
|
borderRadius: 2,
|
|
238
235
|
maxWidth: 480,
|
|
239
|
-
|
|
236
|
+
width: "calc(100% - 32px)",
|
|
237
|
+
}, children: [_jsx(CircularProgress, { size: 24 }), _jsxs(Box, { sx: { flex: 1, minWidth: 0 }, children: [_jsx(Typography, { variant: "body1", sx: { fontWeight: "bold" }, children: "Applying changes to network" }), dockPrompt && (_jsx(Typography, { variant: "body2", color: "text.secondary", sx: { mt: 0.25, overflowWrap: "anywhere" }, children: dockPrompt }))] }), _jsx(Button, { variant: "outlined", size: "small", startIcon: _jsx("span", { style: { fontSize: "0.65rem" }, children: "\u25A0" }), onClick: handleStopClick, sx: {
|
|
240
238
|
whiteSpace: "nowrap",
|
|
241
239
|
flexShrink: 0,
|
|
242
240
|
color: theme.palette.common.white,
|
|
@@ -6,14 +6,14 @@ import { Separator } from "react-resizable-panels";
|
|
|
6
6
|
* Styled Separator that wraps the default react-resizable-panels Separator component. It adds some visual flair.
|
|
7
7
|
*/
|
|
8
8
|
export const PanelSeparator = () => (_jsx(Separator, { style: {
|
|
9
|
-
width: "
|
|
9
|
+
width: "18px",
|
|
10
10
|
cursor: "col-resize",
|
|
11
11
|
display: "flex",
|
|
12
12
|
alignItems: "center",
|
|
13
13
|
justifyContent: "center",
|
|
14
14
|
flexShrink: 0,
|
|
15
15
|
}, children: _jsx(Box, { sx: {
|
|
16
|
-
width: "
|
|
16
|
+
width: "18px",
|
|
17
17
|
height: "100%",
|
|
18
18
|
display: "flex",
|
|
19
19
|
alignItems: "center",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Published } from "../../../state/Publish.js";
|
|
2
|
+
export declare const PUBLISH_SETTINGS_REQUIRED_MESSAGE = "Add a publish server and org name in Settings > External Services to publish";
|
|
3
|
+
export declare const PUBLISHED_MESSAGE = "Published and opened in a new tab";
|
|
4
|
+
export declare const PUBLISHED_TAB_BLOCKED_MESSAGE = "Published. Click View live to open it.";
|
|
5
|
+
/** Where networks are published, from Settings */
|
|
6
|
+
export interface PublishTarget {
|
|
7
|
+
readonly serverUrl: string;
|
|
8
|
+
readonly orgName: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PublishNetwork {
|
|
11
|
+
/** The network's id in the app, which the publish store is keyed by */
|
|
12
|
+
readonly id: string;
|
|
13
|
+
/** The agent network name, which it's published under */
|
|
14
|
+
readonly name: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Opens a URL in a new tab, cut off from this page.
|
|
18
|
+
* @returns Whether the tab opened. False when the browser blocked it as a popup.
|
|
19
|
+
* @note Sets `opener` by hand because the "noopener" feature makes window.open always return null, which would hide
|
|
20
|
+
* whether the tab opened.
|
|
21
|
+
*/
|
|
22
|
+
export declare const openInNewTab: (url: string) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Asks the server whether the network is already live, for example after a reload, and remembers it if so. Does
|
|
25
|
+
* nothing if we already know the network's publish state.
|
|
26
|
+
*/
|
|
27
|
+
export declare const checkIfPublished: (network: PublishNetwork, { serverUrl, orgName }: PublishTarget) => Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Publishes the network's HOCON, the same file Download gives, waits for it to go live, then opens it in a new tab.
|
|
30
|
+
* Tells the user how it went either way.
|
|
31
|
+
*/
|
|
32
|
+
export declare const publish: (network: PublishNetwork, hocon: string, { serverUrl, orgName }: PublishTarget) => Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Takes a live network offline, on the server it was published to.
|
|
35
|
+
*/
|
|
36
|
+
export declare const unpublish: (network: PublishNetwork, published: Published) => Promise<void>;
|
|
@@ -0,0 +1,99 @@
|
|
|
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 { listPublishedNetworks, publishNetwork, unpublishNetwork } from "../../../controller/publish/Publish.js";
|
|
17
|
+
import { PublishStatus, usePublishStore } from "../../../state/Publish.js";
|
|
18
|
+
import { NotificationType, sendNotification } from "../../Common/notification.js";
|
|
19
|
+
export const PUBLISH_SETTINGS_REQUIRED_MESSAGE = "Add a publish server and org name in Settings > External Services to publish";
|
|
20
|
+
export const PUBLISHED_MESSAGE = "Published and opened in a new tab";
|
|
21
|
+
export const PUBLISHED_TAB_BLOCKED_MESSAGE = "Published. Click View live to open it.";
|
|
22
|
+
/**
|
|
23
|
+
* Opens a URL in a new tab, cut off from this page.
|
|
24
|
+
* @returns Whether the tab opened. False when the browser blocked it as a popup.
|
|
25
|
+
* @note Sets `opener` by hand because the "noopener" feature makes window.open always return null, which would hide
|
|
26
|
+
* whether the tab opened.
|
|
27
|
+
*/
|
|
28
|
+
export const openInNewTab = (url) => {
|
|
29
|
+
const tab = window.open(url, "_blank");
|
|
30
|
+
if (!tab)
|
|
31
|
+
return false;
|
|
32
|
+
tab.opener = null;
|
|
33
|
+
return true;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Asks the server whether the network is already live, for example after a reload, and remembers it if so. Does
|
|
37
|
+
* nothing if we already know the network's publish state.
|
|
38
|
+
*/
|
|
39
|
+
export const checkIfPublished = async (network, { serverUrl, orgName }) => {
|
|
40
|
+
const { networks, publishedList, setPublishedList } = usePublishStore.getState();
|
|
41
|
+
if (networks[network.id])
|
|
42
|
+
return;
|
|
43
|
+
// Every network on screen asks, so they share one request for the org's list
|
|
44
|
+
const key = `${serverUrl} ${orgName}`;
|
|
45
|
+
let request = publishedList?.key === key ? publishedList.request : null;
|
|
46
|
+
if (!request) {
|
|
47
|
+
request = listPublishedNetworks(serverUrl, orgName);
|
|
48
|
+
setPublishedList({ key, request });
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const published = (await request).find((candidate) => candidate.name === network.name);
|
|
52
|
+
// Don't overwrite a publish the user started while we were asking
|
|
53
|
+
if (!published || usePublishStore.getState().networks[network.id])
|
|
54
|
+
return;
|
|
55
|
+
usePublishStore.getState().setPublishState(network.id, {
|
|
56
|
+
status: PublishStatus.Published,
|
|
57
|
+
serverUrl,
|
|
58
|
+
publishId: published.id,
|
|
59
|
+
url: published.url,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
setPublishedList(null);
|
|
64
|
+
console.warn(`Unable to check whether "${network.name}" is published:`, e);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Publishes the network's HOCON, the same file Download gives, waits for it to go live, then opens it in a new tab.
|
|
69
|
+
* Tells the user how it went either way.
|
|
70
|
+
*/
|
|
71
|
+
export const publish = async (network, hocon, { serverUrl, orgName }) => {
|
|
72
|
+
const { clearPublishState, setPublishState } = usePublishStore.getState();
|
|
73
|
+
setPublishState(network.id, { status: PublishStatus.Publishing });
|
|
74
|
+
try {
|
|
75
|
+
const ready = await publishNetwork({ serverUrl, orgName, networkName: network.name, hocon });
|
|
76
|
+
setPublishState(network.id, { status: PublishStatus.Published, serverUrl, publishId: ready.id, url: ready.url });
|
|
77
|
+
const message = openInNewTab(ready.url) ? PUBLISHED_MESSAGE : PUBLISHED_TAB_BLOCKED_MESSAGE;
|
|
78
|
+
sendNotification(NotificationType.success, message, "", { vertical: "bottom", horizontal: "center" });
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
clearPublishState(network.id);
|
|
82
|
+
sendNotification(NotificationType.error, `Failed to publish "${network.name}".`, String(e));
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Takes a live network offline, on the server it was published to.
|
|
87
|
+
*/
|
|
88
|
+
export const unpublish = async (network, published) => {
|
|
89
|
+
try {
|
|
90
|
+
await unpublishNetwork(published.serverUrl, published.publishId);
|
|
91
|
+
// The shared list still has it as live, so drop the list too
|
|
92
|
+
const { clearPublishState, setPublishedList } = usePublishStore.getState();
|
|
93
|
+
clearPublishState(network.id);
|
|
94
|
+
setPublishedList(null);
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
sendNotification(NotificationType.error, `Failed to unpublish "${network.name}".`, String(e));
|
|
98
|
+
}
|
|
99
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
export declare const SHOW_DETAILS_LABEL = "Show publish details";
|
|
3
|
+
interface PublishButtonProps {
|
|
4
|
+
/** The network's name as people read it, for the confirmation */
|
|
5
|
+
readonly displayName: string;
|
|
6
|
+
readonly hocon: string;
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly networkId: string;
|
|
9
|
+
readonly networkName: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Split button for publishing a network: "Publish", then "Publishing..." while it goes live, then "View live". The
|
|
13
|
+
* dropdown opens a panel with the progress, or the live URL and Unpublish.
|
|
14
|
+
*/
|
|
15
|
+
export declare const PublishButton: FC<PublishButtonProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
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 KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
|
18
|
+
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
|
|
19
|
+
import PublicIcon from "@mui/icons-material/Public";
|
|
20
|
+
import Button from "@mui/material/Button";
|
|
21
|
+
import ButtonGroup from "@mui/material/ButtonGroup";
|
|
22
|
+
import CircularProgress from "@mui/material/CircularProgress";
|
|
23
|
+
import Popover from "@mui/material/Popover";
|
|
24
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
25
|
+
import { useState } from "react";
|
|
26
|
+
import { openInNewTab, publish, PUBLISH_SETTINGS_REQUIRED_MESSAGE, unpublish, } from "./Publish.js";
|
|
27
|
+
import { PublishConfirmation } from "./PublishConfirmation.js";
|
|
28
|
+
import { PublishPanel } from "./PublishPanel.js";
|
|
29
|
+
import { usePublishTarget } from "./usePublishTarget.js";
|
|
30
|
+
import { PublishStatus, usePublishStore } from "../../../state/Publish.js";
|
|
31
|
+
import { ConfirmationModal } from "../../Common/ConfirmationModal.js";
|
|
32
|
+
export const SHOW_DETAILS_LABEL = "Show publish details";
|
|
33
|
+
/**
|
|
34
|
+
* Split button for publishing a network: "Publish", then "Publishing..." while it goes live, then "View live". The
|
|
35
|
+
* dropdown opens a panel with the progress, or the live URL and Unpublish.
|
|
36
|
+
*/
|
|
37
|
+
export const PublishButton = ({ displayName, hocon, id, networkId, networkName }) => {
|
|
38
|
+
const publishState = usePublishStore((state) => state.networks[networkId]);
|
|
39
|
+
const target = usePublishTarget(networkId, networkName);
|
|
40
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
41
|
+
const [isPublishConfirmOpen, setIsPublishConfirmOpen] = useState(false);
|
|
42
|
+
const [isPanelOpen, setIsPanelOpen] = useState(false);
|
|
43
|
+
const [isUnpublishing, setIsUnpublishing] = useState(false);
|
|
44
|
+
// The live network waiting on the user to confirm unpublishing it
|
|
45
|
+
const [networkToUnpublish, setNetworkToUnpublish] = useState(null);
|
|
46
|
+
const network = { id: networkId, name: networkName };
|
|
47
|
+
const handlePublish = async (publishTarget) => {
|
|
48
|
+
setIsPanelOpen(true);
|
|
49
|
+
await publish(network, hocon, publishTarget);
|
|
50
|
+
setIsPanelOpen(false);
|
|
51
|
+
};
|
|
52
|
+
const handleUnpublish = async (published) => {
|
|
53
|
+
setIsUnpublishing(true);
|
|
54
|
+
await unpublish(network, published);
|
|
55
|
+
setIsUnpublishing(false);
|
|
56
|
+
setIsPanelOpen(false);
|
|
57
|
+
};
|
|
58
|
+
const getMainAction = () => {
|
|
59
|
+
switch (publishState?.status) {
|
|
60
|
+
case PublishStatus.Publishing:
|
|
61
|
+
return {
|
|
62
|
+
color: "primary",
|
|
63
|
+
icon: (_jsx(CircularProgress, { color: "inherit", size: "1rem" })),
|
|
64
|
+
label: "Publishing...",
|
|
65
|
+
handleClick: () => setIsPanelOpen(true),
|
|
66
|
+
};
|
|
67
|
+
case PublishStatus.Published:
|
|
68
|
+
return {
|
|
69
|
+
color: "success",
|
|
70
|
+
icon: _jsx(OpenInNewIcon, {}),
|
|
71
|
+
label: "View live",
|
|
72
|
+
handleClick: () => openInNewTab(publishState.url),
|
|
73
|
+
};
|
|
74
|
+
default:
|
|
75
|
+
return {
|
|
76
|
+
color: "primary",
|
|
77
|
+
icon: _jsx(PublicIcon, {}),
|
|
78
|
+
label: "Publish",
|
|
79
|
+
handleClick: () => setIsPublishConfirmOpen(true),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const mainAction = getMainAction();
|
|
84
|
+
const isPublishBlocked = !publishState && !target;
|
|
85
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ButtonGroup, { color: mainAction.color, id: id, ref: setAnchorEl, size: "small",
|
|
86
|
+
// White text on green (the theme's contrast text is dark there), and icons that follow the text color
|
|
87
|
+
sx: {
|
|
88
|
+
"& .MuiButton-root:not(.Mui-disabled)": { color: "common.white" },
|
|
89
|
+
"& .MuiSvgIcon-root": { color: "inherit" },
|
|
90
|
+
}, variant: "contained", children: [_jsx(Tooltip, { title: isPublishBlocked ? PUBLISH_SETTINGS_REQUIRED_MESSAGE : "", children: _jsx("span", { children: _jsx(Button, { disabled: isPublishBlocked, id: `${id}-main`, onClick: mainAction.handleClick, startIcon: mainAction.icon, sx: { whiteSpace: "nowrap" }, children: mainAction.label }) }) }), publishState && (_jsx(Button, { "aria-expanded": isPanelOpen, "aria-label": SHOW_DETAILS_LABEL, id: `${id}-toggle`, onClick: () => setIsPanelOpen((isOpen) => !isOpen), children: _jsx(KeyboardArrowDownIcon, { sx: { fontSize: 18 } }) }))] }), publishState && (_jsx(Popover, { anchorEl: anchorEl, anchorOrigin: { vertical: "bottom", horizontal: "right" }, onClose: () => setIsPanelOpen(false), open: isPanelOpen, slotProps: { paper: { sx: { mt: 1 } } }, transformOrigin: { vertical: "top", horizontal: "right" }, children: _jsx(PublishPanel, { publishState: publishState, id: `${id}-panel`, isUnpublishing: isUnpublishing, onUnpublish: setNetworkToUnpublish }) })), isPublishConfirmOpen && target && (_jsx(PublishConfirmation, { displayName: displayName, id: `${id}-confirm`, onCancel: () => setIsPublishConfirmOpen(false), onConfirm: () => {
|
|
91
|
+
setIsPublishConfirmOpen(false);
|
|
92
|
+
void handlePublish(target);
|
|
93
|
+
}, target: target })), networkToUnpublish && (_jsx(ConfirmationModal, { content: `"${displayName}" will be taken offline at ${networkToUnpublish.url}. ` +
|
|
94
|
+
"Anyone using the link will lose access.", handleCancel: () => setNetworkToUnpublish(null), handleOk: () => {
|
|
95
|
+
setNetworkToUnpublish(null);
|
|
96
|
+
void handleUnpublish(networkToUnpublish);
|
|
97
|
+
}, id: `${id}-unpublish-confirm`, okBtnLabel: "Unpublish", title: "Unpublish this network?" }))] }));
|
|
98
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { PublishTarget } from "./Publish.js";
|
|
3
|
+
export declare const PUBLIC_ACCESS_WARNING = "Anyone with the link can see and use it. There's no sign-in or access control.";
|
|
4
|
+
interface PublishConfirmationProps {
|
|
5
|
+
readonly displayName: string;
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly onCancel: () => void;
|
|
8
|
+
readonly onConfirm: () => void;
|
|
9
|
+
readonly target: PublishTarget;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Asks before publishing, naming where it goes and warning that it'll be public.
|
|
13
|
+
*/
|
|
14
|
+
export declare const PublishConfirmation: FC<PublishConfirmationProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ConfirmationModal } from "../../Common/ConfirmationModal.js";
|
|
3
|
+
export const PUBLIC_ACCESS_WARNING = "Anyone with the link can see and use it. There's no sign-in or access control.";
|
|
4
|
+
/**
|
|
5
|
+
* Asks before publishing, naming where it goes and warning that it'll be public.
|
|
6
|
+
*/
|
|
7
|
+
export const PublishConfirmation = ({ displayName, id, onCancel, onConfirm, target }) => (_jsx(ConfirmationModal, { content: `"${displayName}" will be published to ${target.serverUrl} ` +
|
|
8
|
+
`under the org "${target.orgName}". ${PUBLIC_ACCESS_WARNING}`, handleCancel: onCancel, handleOk: onConfirm, id: id, okBtnLabel: "Publish", title: "Publish this network?" }));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
interface PublishIconButtonProps {
|
|
3
|
+
/** The network's name as people read it, for the confirmation */
|
|
4
|
+
readonly displayName: string;
|
|
5
|
+
readonly hocon: string;
|
|
6
|
+
readonly id: string;
|
|
7
|
+
/** An expired network can't be published, but its live site still opens */
|
|
8
|
+
readonly isExpired: boolean;
|
|
9
|
+
readonly networkId: string;
|
|
10
|
+
readonly networkName: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Small globe button for publishing a network from the sidebar. Publishes after asking, spins while publishing, and
|
|
14
|
+
* turns green once the network is live, when it opens the live site instead.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PublishIconButton: FC<PublishIconButtonProps>;
|
|
17
|
+
export {};
|