@cognizant-ai-lab/ui-common 1.10.0 → 1.12.0-main.6dcd6d5.144
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.d.ts +5 -0
- package/dist/components/AgentChat/ChatCommon/ChatCommon.js +28 -7
- package/dist/components/AgentChat/ChatCommon/Const.d.ts +1 -0
- package/dist/components/AgentChat/ChatCommon/Const.js +2 -0
- package/dist/components/AgentChat/ChatCommon/SlyDataDialog.d.ts +34 -0
- package/dist/components/AgentChat/ChatCommon/SlyDataDialog.js +191 -0
- package/dist/components/AgentChat/Common/LlmChatButton.d.ts +4 -6
- package/dist/components/AgentChat/Common/LlmChatButton.js +0 -2
- package/dist/components/Common/ConfirmationModal.d.ts +3 -2
- package/dist/components/Common/GoogleAnalytics.d.ts +16 -0
- package/dist/components/Common/GoogleAnalytics.js +32 -0
- package/dist/components/Common/Navbar.d.ts +2 -1
- package/dist/components/Common/Navbar.js +3 -3
- package/dist/components/ErrorPage/ErrorPage.js +4 -4
- package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.d.ts +7 -7
- package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.js +143 -390
- package/dist/components/MultiAgentAccelerator/Editor/AgentNodeEditor.d.ts +24 -0
- package/dist/components/MultiAgentAccelerator/Editor/AgentNodeEditor.js +128 -0
- package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.d.ts +21 -0
- package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.js +305 -0
- package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +109 -62
- package/dist/components/MultiAgentAccelerator/NeuroSanStudioCallout.d.ts +2 -0
- package/dist/components/MultiAgentAccelerator/NeuroSanStudioCallout.js +38 -0
- package/dist/components/MultiAgentAccelerator/PanelSeparator.d.ts +5 -0
- package/dist/components/MultiAgentAccelerator/PanelSeparator.js +46 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +4 -3
- package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.js +8 -6
- package/dist/components/MultiAgentAccelerator/const.d.ts +1 -0
- package/dist/components/MultiAgentAccelerator/const.js +2 -0
- package/dist/components/Settings/ApiKeyErrorBanner.d.ts +22 -0
- package/dist/components/Settings/ApiKeyErrorBanner.js +26 -0
- package/dist/components/Settings/ApiKeyInput.d.ts +5 -2
- package/dist/components/Settings/ApiKeyInput.js +10 -4
- package/dist/components/Settings/SettingsDialog.js +22 -5
- package/dist/const.d.ts +0 -1
- package/dist/const.js +0 -1
- package/dist/controller/llm/Providers.d.ts +19 -2
- package/dist/controller/llm/Providers.js +45 -31
- package/dist/state/Announcements.d.ts +24 -0
- package/dist/state/Announcements.js +29 -0
- package/dist/state/ChatHistory.d.ts +10 -1
- package/dist/state/ChatHistory.js +8 -0
- package/dist/state/Environment.d.ts +2 -0
- package/dist/state/Environment.js +2 -0
- package/dist/state/Settings.d.ts +14 -0
- package/dist/state/Settings.js +6 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/Authentication.d.ts +7 -0
- package/dist/utils/Authentication.js +19 -5
- package/dist/utils/SlyData.d.ts +56 -0
- package/dist/utils/SlyData.js +106 -0
- package/dist/utils/SlyDataSchema.d.ts +31 -0
- package/dist/utils/SlyDataSchema.js +149 -0
- package/package.json +9 -8
- package/dist/components/MultiAgentAccelerator/AgentNodePopup.d.ts +0 -30
- package/dist/components/MultiAgentAccelerator/AgentNodePopup.js +0 -80
|
@@ -99,6 +99,11 @@ export interface ChatCommonProps {
|
|
|
99
99
|
* If true, indicates that the user is missing API keys for one or more LLM providers.
|
|
100
100
|
*/
|
|
101
101
|
readonly hasMissingApiKeys?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* The sly_data_schema the selected network's front man advertises, if any. Enables schema hints in the
|
|
104
|
+
* sly_data dialog.
|
|
105
|
+
*/
|
|
106
|
+
readonly slyDataSchema?: Record<string, unknown>;
|
|
102
107
|
}
|
|
103
108
|
export type ChatCommonHandle = {
|
|
104
109
|
handleStop: () => void;
|
|
@@ -21,6 +21,7 @@ import { AIMessage, HumanMessage } from "@langchain/core/messages";
|
|
|
21
21
|
import AddBoxRounded from "@mui/icons-material/AddBoxRounded";
|
|
22
22
|
import ClearIcon from "@mui/icons-material/Clear";
|
|
23
23
|
import CloseIcon from "@mui/icons-material/Close";
|
|
24
|
+
import DataObjectIcon from "@mui/icons-material/DataObject";
|
|
24
25
|
import TuneIcon from "@mui/icons-material/Tune";
|
|
25
26
|
import Box from "@mui/material/Box";
|
|
26
27
|
import Checkbox from "@mui/material/Checkbox";
|
|
@@ -38,12 +39,13 @@ import { isEmpty } from "lodash-es";
|
|
|
38
39
|
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState, } from "react";
|
|
39
40
|
import { v4 as uuid } from "uuid";
|
|
40
41
|
import { ChatHistory, toTurns } from "./ChatHistory.js";
|
|
41
|
-
import { MAX_TURNS } from "./Const.js";
|
|
42
|
+
import { MAX_TURNS, SLY_DATA_LOGIN_KEY } from "./Const.js";
|
|
42
43
|
import { ControlButtons } from "./ControlButtons.js";
|
|
43
44
|
import { Conversation } from "./Conversation.js";
|
|
44
45
|
import { MessageRole } from "./ConversationTurn.js";
|
|
45
46
|
import { SampleQueries } from "./SampleQueries.js";
|
|
46
47
|
import { SendButton } from "./SendButton.js";
|
|
48
|
+
import { SlyDataDialog } from "./SlyDataDialog.js";
|
|
47
49
|
import { Thinking } from "./Thinking.js";
|
|
48
50
|
import { sendChatQuery } from "../../../controller/agent/Agent.js";
|
|
49
51
|
import { sendLlmRequest, StreamingUnit } from "../../../controller/llm/LlmChat.js";
|
|
@@ -95,7 +97,7 @@ export const roleToExportLabel = (role) => EXPORT_ROLE_LABELS[role];
|
|
|
95
97
|
* agent responses. Customization for inputs and outputs is provided via event handlers-like props.
|
|
96
98
|
*/
|
|
97
99
|
export const ChatCommon = ({ ref, ...props }) => {
|
|
98
|
-
const { agentPlaceholders = EMPTY, backgroundColor, currentUser, customAgentGreetings = EMPTY, extraParams, extraSlyData, id, isAwaitingLlm, legacyAgentEndpoint, hasMissingApiKeys = false, networkDescription, neuroSanURL, onChunkReceived, onClose, onSend, onStreamingComplete, onStreamingStarted, sampleQueries, selectedNetwork, setIsAwaitingLlm, setPreviousResponse, setSelectedNetwork, title, } = props;
|
|
100
|
+
const { agentPlaceholders = EMPTY, backgroundColor, currentUser, customAgentGreetings = EMPTY, extraParams, extraSlyData, id, isAwaitingLlm, legacyAgentEndpoint, hasMissingApiKeys = false, networkDescription, neuroSanURL, onChunkReceived, onClose, onSend, onStreamingComplete, onStreamingStarted, sampleQueries, selectedNetwork, setIsAwaitingLlm, setPreviousResponse, setSelectedNetwork, slyDataSchema, title, } = props;
|
|
99
101
|
// MUI theme
|
|
100
102
|
const theme = useTheme();
|
|
101
103
|
// User LLM chat input
|
|
@@ -120,6 +122,8 @@ export const ChatCommon = ({ ref, ...props }) => {
|
|
|
120
122
|
// Options menu control
|
|
121
123
|
const [optionsMenuAnchorEl, setOptionsMenuAnchorEl] = useState(null);
|
|
122
124
|
const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);
|
|
125
|
+
// Whether the sly_data editor is showing
|
|
126
|
+
const [slyDataDialogOpen, setSlyDataDialogOpen] = useState(false);
|
|
123
127
|
// Persistent agent chat history store, which is where we store both kinds of chat histories
|
|
124
128
|
// (see store implementation for details)
|
|
125
129
|
const storedChatHistory = useAgentChatHistoryStore((state) => selectedNetwork ? state?.history?.[selectedNetwork] : undefined);
|
|
@@ -223,9 +227,12 @@ export const ChatCommon = ({ ref, ...props }) => {
|
|
|
223
227
|
// But don't want to spam output by logging errors for every bad message.
|
|
224
228
|
return;
|
|
225
229
|
}
|
|
226
|
-
// Shallow merge existing slyData with incoming chatMessage.sly_data
|
|
230
|
+
// Shallow merge existing slyData with incoming chatMessage.sly_data.
|
|
231
|
+
// Defense in depth: never let BYOK API keys enter the persistent store, even if a network echoes
|
|
232
|
+
// them back -- the store is displayed and exportable via the sly_data editor.
|
|
227
233
|
if (chatMessage.sly_data) {
|
|
228
|
-
|
|
234
|
+
const { llm_config: _, ...echoedSlyData } = chatMessage.sly_data;
|
|
235
|
+
updateSlyData(selectedNetwork, echoedSlyData);
|
|
229
236
|
}
|
|
230
237
|
// It's a ChatMessage. Does it have chat context? Only AGENT_FRAMEWORK messages can have chat context.
|
|
231
238
|
if (chatMessage.type === ChatMessageType.AGENT_FRAMEWORK && chatMessage.chat_context) {
|
|
@@ -311,7 +318,11 @@ export const ChatCommon = ({ ref, ...props }) => {
|
|
|
311
318
|
else {
|
|
312
319
|
// It's a Neuro-san agent.
|
|
313
320
|
// Some coded tools (data generator...) expect the username provided in slyData.
|
|
314
|
-
const slyDataWithUsername = {
|
|
321
|
+
const slyDataWithUsername = {
|
|
322
|
+
...agentChatHistory?.slyData,
|
|
323
|
+
...extraSlyData,
|
|
324
|
+
[SLY_DATA_LOGIN_KEY]: currentUser,
|
|
325
|
+
};
|
|
315
326
|
await sendChatQuery(neuroSanURL, controller?.current.signal, query, selectedNetwork, handleChunk, agentChatHistory.chatContext, slyDataWithUsername, currentUser, StreamingUnit.Line);
|
|
316
327
|
}
|
|
317
328
|
}
|
|
@@ -605,6 +616,16 @@ export const ChatCommon = ({ ref, ...props }) => {
|
|
|
605
616
|
const handleToggleWrapOutput = () => {
|
|
606
617
|
setShouldWrapOutput((prev) => !prev);
|
|
607
618
|
};
|
|
619
|
+
const handleShowSlyData = () => {
|
|
620
|
+
handleOptionsMenuClose();
|
|
621
|
+
setSlyDataDialogOpen(true);
|
|
622
|
+
};
|
|
623
|
+
/**
|
|
624
|
+
* The sly_data keys that this component merges in on every request, on top of whatever is in the store. The
|
|
625
|
+
* sly_data editor lists them so that the user isn't surprised by keys arriving at the server that they never
|
|
626
|
+
* typed -- and, for the API keys among them, so that we never have to display their values.
|
|
627
|
+
*/
|
|
628
|
+
const getMergedSlyDataKeys = () => [...Object.keys(extraSlyData ?? {}), SLY_DATA_LOGIN_KEY];
|
|
608
629
|
const getOptionsMenu = () => (_jsxs(Menu, { id: `${id}-options-menu`, anchorEl: optionsMenuAnchorEl, open: optionsMenuOpen, onClose: handleOptionsMenuClose, slotProps: {
|
|
609
630
|
list: {
|
|
610
631
|
dense: true,
|
|
@@ -615,7 +636,7 @@ export const ChatCommon = ({ ref, ...props }) => {
|
|
|
615
636
|
"& .MuiListItemText-primary": { fontSize: "smaller" },
|
|
616
637
|
},
|
|
617
638
|
},
|
|
618
|
-
}, children: [_jsxs(MenuItem, { onClick: handleToggleAutoScroll, children: [_jsx(ListItemIcon, { children: _jsx(Checkbox, { checked: autoScrollEnabled, tabIndex: -1, sx: { pointerEvents: "none" } }) }), _jsx(ListItemText, { primary: "Auto-scroll output" })] }), _jsxs(MenuItem, { onClick: handleToggleWrapOutput, children: [_jsx(ListItemIcon, { children: _jsx(Checkbox, { checked: shouldWrapOutput, tabIndex: -1, sx: { pointerEvents: "none" } }) }), _jsx(ListItemText, { primary: "Wrap output" })] })] }));
|
|
639
|
+
}, children: [_jsxs(MenuItem, { onClick: handleToggleAutoScroll, children: [_jsx(ListItemIcon, { children: _jsx(Checkbox, { checked: autoScrollEnabled, tabIndex: -1, sx: { pointerEvents: "none" } }) }), _jsx(ListItemText, { primary: "Auto-scroll output" })] }), _jsxs(MenuItem, { onClick: handleToggleWrapOutput, children: [_jsx(ListItemIcon, { children: _jsx(Checkbox, { checked: shouldWrapOutput, tabIndex: -1, sx: { pointerEvents: "none" } }) }), _jsx(ListItemText, { primary: "Wrap output" })] }), !isLegacyAgentType(selectedNetwork) && (_jsxs(MenuItem, { id: `${id}-sly-data-menu-item`, onClick: handleShowSlyData, children: [_jsx(ListItemIcon, { children: _jsx(DataObjectIcon, { fontSize: "small" }) }), _jsx(ListItemText, { primary: "Sly data..." })] }))] }));
|
|
619
640
|
const getNetworkIntro = () => (_jsxs(Box, { sx: { marginBottom: "0.5rem", marginTop: "1rem" }, children: [_jsxs(Typography, { component: "span", sx: { fontWeight: 700 }, variant: "inherit", children: [networkDisplayName, networkDescription && ":"] }), networkDescription && (_jsxs(Typography, { component: "span", sx: { ml: 0.5 }, variant: "inherit", children: [" ", networkDescription] }))] }));
|
|
620
641
|
const getChatHistory = () => (_jsx(_Fragment, { children: agentChatHistory?.chatHistory?.length > 0 && (_jsx(Box, { sx: { my: "0.5rem" }, children: _jsx(ChatHistory, { id: id, messages: agentChatHistory.chatHistory }) })) }));
|
|
621
642
|
const getAgentGreeting = () => _jsx(Box, { sx: { marginBottom: "0.5rem", marginTop: "1rem" }, children: agentGreeting });
|
|
@@ -649,7 +670,7 @@ export const ChatCommon = ({ ref, ...props }) => {
|
|
|
649
670
|
resetHistory(selectedNetwork);
|
|
650
671
|
setPreviousUserQuery("");
|
|
651
672
|
currentResponse.current = "";
|
|
652
|
-
}, okBtnLabel: "Yes, clear chat", title: `Clear all chat including history for ${networkDisplayName}?` })) : null, _jsxs(Box, { id: "llm-responses", ref: chatOutputRef, sx: {
|
|
673
|
+
}, okBtnLabel: "Yes, clear chat", title: `Clear all chat including history for ${networkDisplayName}?` })) : null, slyDataDialogOpen ? (_jsx(SlyDataDialog, { extraSlyDataKeys: getMergedSlyDataKeys(), id: `${id}-sly-data-dialog`, isOpen: slyDataDialogOpen, networkDisplayName: networkDisplayName, networkId: selectedNetwork, onClose: () => setSlyDataDialogOpen(false), slyDataSchema: slyDataSchema })) : null, _jsxs(Box, { id: "llm-responses", ref: chatOutputRef, sx: {
|
|
653
674
|
backgroundColor,
|
|
654
675
|
borderRadius: "0.5rem",
|
|
655
676
|
fontSize: "16px",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
export interface SlyDataDialogProps {
|
|
3
|
+
/**
|
|
4
|
+
* Names of the sly_data keys that the UI itself merges into each request (API keys, agent network definition,
|
|
5
|
+
* login...). Shown to the user as names only -- never values, since some of them are secrets.
|
|
6
|
+
*/
|
|
7
|
+
readonly extraSlyDataKeys?: readonly string[];
|
|
8
|
+
/** HTML id to use for the outer component */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly isOpen: boolean;
|
|
11
|
+
/** The network whose sly_data is being edited. Sly data is stored per network. */
|
|
12
|
+
readonly networkId: string;
|
|
13
|
+
/** Human-readable name of the network, for display only */
|
|
14
|
+
readonly networkDisplayName: string;
|
|
15
|
+
readonly onClose: () => void;
|
|
16
|
+
/**
|
|
17
|
+
* The sly_data_schema the network's front man advertises, if any. When present and usable, the dialog lists
|
|
18
|
+
* the expected keys and offers to seed them as a template.
|
|
19
|
+
*/
|
|
20
|
+
readonly slyDataSchema?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Dialog for viewing and editing the sly_data of the selected agent network.
|
|
24
|
+
* <br>
|
|
25
|
+
* sly_data is the side-channel payload that rides along with every request: the server echoes it back as the
|
|
26
|
+
* conversation progresses, and the UI bounces it to the server on the next request. Until now it was invisible.
|
|
27
|
+
* This dialog exposes it as editable JSON, so a user can inspect what the agents are passing around and seed values
|
|
28
|
+
* of their own before the first turn.
|
|
29
|
+
* <br>
|
|
30
|
+
* Edits are written straight into the per-network chat history store, which is the same place the streaming code
|
|
31
|
+
* writes server-echoed sly_data and the same place the send path reads from. There is therefore no separate plumbing
|
|
32
|
+
* to the server: whatever is saved here goes out with the next request.
|
|
33
|
+
*/
|
|
34
|
+
export declare const SlyDataDialog: FC<SlyDataDialogProps>;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2025 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 DataObjectIcon from "@mui/icons-material/DataObject";
|
|
18
|
+
import DeleteOutlined from "@mui/icons-material/DeleteOutlined";
|
|
19
|
+
import FileDownloadOutlined from "@mui/icons-material/FileDownloadOutlined";
|
|
20
|
+
import FileUploadOutlined from "@mui/icons-material/FileUploadOutlined";
|
|
21
|
+
import PlaylistAddOutlined from "@mui/icons-material/PlaylistAddOutlined";
|
|
22
|
+
import Alert from "@mui/material/Alert";
|
|
23
|
+
import Box from "@mui/material/Box";
|
|
24
|
+
import IconButton from "@mui/material/IconButton";
|
|
25
|
+
import { styled } from "@mui/material/styles";
|
|
26
|
+
import TextField from "@mui/material/TextField";
|
|
27
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
28
|
+
import Typography from "@mui/material/Typography";
|
|
29
|
+
import { Fragment, useMemo, useRef, useState } from "react";
|
|
30
|
+
import { useAgentChatHistoryStore } from "../../../state/ChatHistory.js";
|
|
31
|
+
import { downloadFile, toSafeFilename } from "../../../utils/File.js";
|
|
32
|
+
import { findImageValues, formatSlyData, parseSlyData } from "../../../utils/SlyData.js";
|
|
33
|
+
import { buildSlyDataTemplate, describeSlyDataSchema } from "../../../utils/SlyDataSchema.js";
|
|
34
|
+
import { StyledButton } from "../../Common/ConfirmationModal.js";
|
|
35
|
+
import { MUIDialog } from "../../Common/MUIDialog.js";
|
|
36
|
+
import InfoTip from "../../Settings/InfoTip.js";
|
|
37
|
+
//#endregion: Types
|
|
38
|
+
//#region: Constants
|
|
39
|
+
// Avoids a new array literal as a default prop value on every render
|
|
40
|
+
const NO_EXTRA_KEYS = [];
|
|
41
|
+
// Height of the JSON editor, in rows. Big enough to see a realistic payload without dominating the screen.
|
|
42
|
+
const EDITOR_ROWS = 14;
|
|
43
|
+
// Edge length of the image previews, in pixels
|
|
44
|
+
const IMAGE_PREVIEW_SIZE = 96;
|
|
45
|
+
// Tooltip explaining what sly data is, in end-user terms: it exists to carry values (credentials included) that
|
|
46
|
+
// belong with the request but must stay out of the LLM conversation.
|
|
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.";
|
|
51
|
+
//#endregion: Constants
|
|
52
|
+
// A sly_data key name rendered as an inline code chip
|
|
53
|
+
const KeyChip = styled("code")(({ theme }) => ({
|
|
54
|
+
backgroundColor: theme.palette.action.hover,
|
|
55
|
+
borderRadius: `calc(${theme.shape.borderRadius}px * 0.5)`,
|
|
56
|
+
fontFamily: "monospace",
|
|
57
|
+
paddingLeft: theme.spacing(0.5),
|
|
58
|
+
paddingRight: theme.spacing(0.5),
|
|
59
|
+
}));
|
|
60
|
+
/**
|
|
61
|
+
* Renders the parenthetical qualifiers after a schema key name, eg. " (float, required)".
|
|
62
|
+
* Empty when the schema declares neither a type nor requiredness.
|
|
63
|
+
* @param entry The schema entry to describe.
|
|
64
|
+
* @returns The qualifier text, with a leading space, or an empty string.
|
|
65
|
+
*/
|
|
66
|
+
const describeEntryQualifiers = (entry) => {
|
|
67
|
+
const qualifiers = [entry.type, entry.isRequired ? "required" : undefined].filter(Boolean);
|
|
68
|
+
return qualifiers.length > 0 ? ` (${qualifiers.join(", ")})` : "";
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Dialog for viewing and editing the sly_data of the selected agent network.
|
|
72
|
+
* <br>
|
|
73
|
+
* sly_data is the side-channel payload that rides along with every request: the server echoes it back as the
|
|
74
|
+
* conversation progresses, and the UI bounces it to the server on the next request. Until now it was invisible.
|
|
75
|
+
* This dialog exposes it as editable JSON, so a user can inspect what the agents are passing around and seed values
|
|
76
|
+
* of their own before the first turn.
|
|
77
|
+
* <br>
|
|
78
|
+
* Edits are written straight into the per-network chat history store, which is the same place the streaming code
|
|
79
|
+
* writes server-echoed sly_data and the same place the send path reads from. There is therefore no separate plumbing
|
|
80
|
+
* to the server: whatever is saved here goes out with the next request.
|
|
81
|
+
*/
|
|
82
|
+
export const SlyDataDialog = ({ extraSlyDataKeys = NO_EXTRA_KEYS, id, isOpen, networkId, networkDisplayName, onClose, slyDataSchema, }) => {
|
|
83
|
+
const storedSlyData = useAgentChatHistoryStore((state) => networkId ? state.history[networkId]?.slyData : undefined);
|
|
84
|
+
const setSlyData = useAgentChatHistoryStore((state) => state.setSlyData);
|
|
85
|
+
const storedText = useMemo(() => formatSlyData(storedSlyData), [storedSlyData]);
|
|
86
|
+
// The keys the network says it expects, minus the ones the app supplies on its own. Empty for the many
|
|
87
|
+
// networks that do not advertise a schema, in which case the dialog looks exactly as it always has.
|
|
88
|
+
const schemaEntries = useMemo(() => describeSlyDataSchema(slyDataSchema, extraSlyDataKeys), [slyDataSchema, extraSlyDataKeys]);
|
|
89
|
+
// The network's sly_data skeleton, pretty-printed, or null when it advertises no usable schema
|
|
90
|
+
const templateText = useMemo(() => schemaEntries.length > 0 ? formatSlyData(buildSlyDataTemplate(slyDataSchema, {}, extraSlyDataKeys)) : null, [schemaEntries, slyDataSchema, extraSlyDataKeys]);
|
|
91
|
+
// When the dialog opens onto an empty store and the network declares a schema, start from the template so
|
|
92
|
+
// the user fills in blanks instead of typing structure. It is an ordinary unsaved draft: nothing touches
|
|
93
|
+
// the store unless they save. The dialog is mounted fresh on every open, so this is per-open behavior.
|
|
94
|
+
const prefillText = storedText === "{}" ? templateText : null;
|
|
95
|
+
// The user's unsaved edit, or null while they have none. While null, the editor simply renders the store,
|
|
96
|
+
// so server-echoed updates show up without any syncing code. Once the user edits, their draft is what
|
|
97
|
+
// renders, and we offer a reload instead of overwriting it (see below).
|
|
98
|
+
const [draft, setDraft] = useState(prefillText);
|
|
99
|
+
// What the store held when the user started editing, so we can tell "the server changed sly_data" apart
|
|
100
|
+
// from "the user changed sly_data"
|
|
101
|
+
const [draftBaseline, setDraftBaseline] = useState(prefillText === null ? null : storedText);
|
|
102
|
+
const fileInputRef = useRef(null);
|
|
103
|
+
// Derived rather than stored: dirtiness is simply "a draft exists"
|
|
104
|
+
const isDirty = draft !== null;
|
|
105
|
+
const text = draft ?? storedText;
|
|
106
|
+
const parseResult = useMemo(() => parseSlyData(text), [text]);
|
|
107
|
+
const images = useMemo(() => findImageValues(parseResult.value), [parseResult]);
|
|
108
|
+
// The server echoed new sly_data while the user had unsaved edits. Saying so beats silently discarding
|
|
109
|
+
// either side's version.
|
|
110
|
+
const wasUpdatedByServer = isDirty && storedText !== draftBaseline;
|
|
111
|
+
/** Records a user edit, snapshotting what the store held when editing began. */
|
|
112
|
+
const startOrUpdateDraft = (newText) => {
|
|
113
|
+
if (draft === null) {
|
|
114
|
+
setDraftBaseline(storedText);
|
|
115
|
+
}
|
|
116
|
+
setDraft(newText);
|
|
117
|
+
};
|
|
118
|
+
const handleTextChange = (event) => {
|
|
119
|
+
startOrUpdateDraft(event.target.value);
|
|
120
|
+
};
|
|
121
|
+
const handleReload = () => {
|
|
122
|
+
setDraft(null);
|
|
123
|
+
setDraftBaseline(null);
|
|
124
|
+
};
|
|
125
|
+
// On a network with a schema, "clear" means back to the blank template rather than to nothing:
|
|
126
|
+
// stranding the user on {} would force them to rebuild the structure the network just told us about.
|
|
127
|
+
const handleClear = () => {
|
|
128
|
+
startOrUpdateDraft(templateText ?? "{}");
|
|
129
|
+
};
|
|
130
|
+
const handleFillTemplate = () => {
|
|
131
|
+
startOrUpdateDraft(formatSlyData(buildSlyDataTemplate(slyDataSchema, parseResult.value, extraSlyDataKeys)));
|
|
132
|
+
};
|
|
133
|
+
const handleExport = () => {
|
|
134
|
+
if (parseResult.error) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const filename = `${toSafeFilename(`${networkId}-sly-data`)}.json`;
|
|
138
|
+
downloadFile(formatSlyData(parseResult.value), filename, "application/json");
|
|
139
|
+
};
|
|
140
|
+
const handleFileSelected = async (event) => {
|
|
141
|
+
const file = event.target.files?.[0];
|
|
142
|
+
// Reset the input so that picking the same file again still fires a change event
|
|
143
|
+
event.target.value = "";
|
|
144
|
+
if (!file) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
// Whatever the file contains goes into the editor as-is. If it isn't usable sly_data, the same validation
|
|
148
|
+
// that guards typing will explain why.
|
|
149
|
+
startOrUpdateDraft(await file.text());
|
|
150
|
+
};
|
|
151
|
+
const handleSave = () => {
|
|
152
|
+
if (parseResult.error) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
setSlyData(networkId, parseResult.value);
|
|
156
|
+
onClose();
|
|
157
|
+
};
|
|
158
|
+
const getTitle = () => (_jsxs(Box, { sx: { alignItems: "center", display: "flex", gap: 0.75 }, children: [_jsx(DataObjectIcon, { fontSize: "small", id: `${id}-title-icon` }), _jsxs("span", { children: ["Sly data for ", networkDisplayName] }), _jsx(InfoTip, { title: SLY_DATA_EXPLAINER })] }));
|
|
159
|
+
const getToolbar = () => (_jsxs(Box, { sx: { display: "flex", gap: 0.5, justifyContent: "flex-end" }, children: [schemaEntries.length > 0 && (_jsx(Tooltip, { title: "Insert the keys this network expects (keeps your values)", children: _jsx("span", { children: _jsx(IconButton, { "aria-label": "Fill sly data template", disabled: Boolean(parseResult.error), id: `${id}-template-button`, onClick: handleFillTemplate, size: "small", children: _jsx(PlaylistAddOutlined, { fontSize: "small" }) }) }) })), _jsx(Tooltip, { title: "Import from a JSON file", children: _jsx("span", { children: _jsx(IconButton, { "aria-label": "Import sly data", id: `${id}-import-button`, onClick: () => fileInputRef.current?.click(), size: "small", children: _jsx(FileUploadOutlined, { fontSize: "small" }) }) }) }), _jsx(Tooltip, { title: "Export to a JSON file", children: _jsx("span", { children: _jsx(IconButton, { "aria-label": "Export sly data", disabled: Boolean(parseResult.error), id: `${id}-export-button`, onClick: handleExport, size: "small", children: _jsx(FileDownloadOutlined, { fontSize: "small" }) }) }) }), _jsx(Tooltip, { title: templateText === null
|
|
160
|
+
? "Clear all sly data (takes effect when you save)"
|
|
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" })] }));
|
|
162
|
+
/**
|
|
163
|
+
* Lists the keys the network says it expects, so the user knows what to fill in without reading the
|
|
164
|
+
* network's source. When the network advertises nothing for the user to supply, says so instead of leaving
|
|
165
|
+
* an unexplained empty editor.
|
|
166
|
+
*/
|
|
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 }));
|
|
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." }));
|
|
169
|
+
/**
|
|
170
|
+
* Preview strip for any values that look like images. Read-only: the underlying value stays editable as text.
|
|
171
|
+
* Agent networks do not have a settled convention for passing images over sly_data yet, so this displays what
|
|
172
|
+
* it can recognize rather than assuming a shape.
|
|
173
|
+
*/
|
|
174
|
+
const getImagePreviews = () => images.length > 0 && (_jsxs(Box, { id: `${id}-images`, children: [_jsx(Typography, { sx: { fontSize: "0.75rem", mt: 1 }, variant: "caption", children: "Images in sly data" }), _jsx(Box, { sx: { display: "flex", flexWrap: "wrap", gap: 1, mt: 0.5 }, children: images.map((image) => (_jsxs(Box, { sx: { maxWidth: IMAGE_PREVIEW_SIZE, textAlign: "center" }, children: [_jsx("img", { alt: image.path, loading: "lazy", referrerPolicy: "no-referrer", src: image.src, style: {
|
|
175
|
+
height: IMAGE_PREVIEW_SIZE,
|
|
176
|
+
objectFit: "contain",
|
|
177
|
+
width: IMAGE_PREVIEW_SIZE,
|
|
178
|
+
} }), _jsx(Typography, { sx: { display: "block", fontSize: "0.7rem", overflowWrap: "anywhere" }, variant: "caption", children: image.path })] }, image.path))) })] }));
|
|
179
|
+
/**
|
|
180
|
+
* Explains the keys that this dialog deliberately does not show, so that their absence doesn't look like a bug.
|
|
181
|
+
*/
|
|
182
|
+
const getMergedKeysNote = () => extraSlyDataKeys.length > 0 && (_jsxs(Alert, { id: `${id}-merged-keys`, severity: "info", sx: { mt: 0.5, py: 0, "& .MuiAlert-message": { fontSize: "0.75rem" } }, children: ["Sent automatically with every request:", " ", [...extraSlyDataKeys].sort().map((key, index) => (_jsxs(Fragment, { children: [index > 0 && ", ", _jsx(KeyChip, { children: key })] }, key))), ". Supplied by the app, not from this editor."] }));
|
|
183
|
+
const getFooter = () => (_jsxs(_Fragment, { children: [_jsx(StyledButton, { id: `${id}-cancel-button`, onClick: onClose, variant: "outlined", children: "Cancel" }), _jsx(StyledButton, { disabled: Boolean(parseResult.error), id: `${id}-save-button`, onClick: handleSave, variant: "contained", children: "Save" })] }));
|
|
184
|
+
return (_jsxs(MUIDialog, { contentSx: { minWidth: "550px", paddingTop: "0" }, footer: getFooter(), id: id, isOpen: isOpen, onClose: onClose, paperProps: { maxWidth: "800px", width: "80vw" }, title: getTitle(), children: [getToolbar(), getSchemaHints(), getServerUpdateAlert(), _jsx(TextField, { error: Boolean(parseResult.error), fullWidth: true, helperText: parseResult.error ?? " ", id: `${id}-editor`, maxRows: EDITOR_ROWS, minRows: EDITOR_ROWS, multiline: true, onChange: handleTextChange, slotProps: {
|
|
185
|
+
htmlInput: {
|
|
186
|
+
"aria-label": "Sly data",
|
|
187
|
+
spellCheck: false,
|
|
188
|
+
style: { fontFamily: "monospace", fontSize: "0.8rem" },
|
|
189
|
+
},
|
|
190
|
+
}, value: text }), getImagePreviews(), getMergedKeysNote()] }));
|
|
191
|
+
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const SmallLlmChatButton: import("@emotion/styled").StyledComponent<import("@mui/material/Button").ButtonOwnProps & Omit<import("@mui/material/ButtonBase").ButtonBaseOwnProps, keyof import("@mui/material/Button").ButtonOwnProps> & Omit<import("@mui/material/ButtonBase").ButtonBaseOwnProps, "tabIndex" | "type" | "action" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "nativeButton" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | keyof import("@mui/material/Button").ButtonOwnProps> & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "style" | "children" | "sx" | "className" | "tabIndex" | "color" | "href" | "type" | "classes" | "variant" | "action" | "size" | "disabled" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "nativeButton" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "loading" | "loadingIndicator" | "disableElevation" | "endIcon" | "fullWidth" | "loadingPosition" | "startIcon"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & LLMChatGroupConfigBtnProps, {}, {}>;
|
|
6
|
-
export {};
|
|
1
|
+
import { ButtonProps } from "@mui/material/Button";
|
|
2
|
+
import { ComponentType } from "react";
|
|
3
|
+
export declare const LlmChatButton: ComponentType<ButtonProps>;
|
|
4
|
+
export declare const SmallLlmChatButton: ComponentType<ButtonProps>;
|
|
@@ -15,8 +15,6 @@ limitations under the License.
|
|
|
15
15
|
*/
|
|
16
16
|
import Button from "@mui/material/Button";
|
|
17
17
|
import { styled } from "@mui/material/styles";
|
|
18
|
-
//#endregion: Types
|
|
19
|
-
// In LlmChatButton.tsx
|
|
20
18
|
export const LlmChatButton = styled(Button)(({ disabled, theme }) => ({
|
|
21
19
|
backgroundColor: theme.palette.background.paper,
|
|
22
20
|
borderRadius: "var(--bs-border-radius)",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ButtonProps } from "@mui/material/Button";
|
|
2
|
+
import { ComponentType, FC, ReactNode } from "react";
|
|
3
|
+
export declare const StyledButton: ComponentType<ButtonProps>;
|
|
3
4
|
interface ConfirmationModalProps {
|
|
4
5
|
cancelBtnLabel?: string;
|
|
5
6
|
closeable?: boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
export declare const GOOGLE_ANALYTICS_URL = "https://www.googletagmanager.com/gtag/js";
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
dataLayer: unknown[];
|
|
6
|
+
gtag: (...args: unknown[]) => void;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
interface GoogleAnalyticsProps {
|
|
10
|
+
readonly gaMeasurementID: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* This component injects the Google Analytics tracking script
|
|
14
|
+
*/
|
|
15
|
+
export declare const GoogleAnalytics: FC<GoogleAnalyticsProps>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
// The URL for the Google Analytics script
|
|
3
|
+
export const GOOGLE_ANALYTICS_URL = "https://www.googletagmanager.com/gtag/js";
|
|
4
|
+
/**
|
|
5
|
+
* This component injects the Google Analytics tracking script
|
|
6
|
+
*/
|
|
7
|
+
export const GoogleAnalytics = ({ gaMeasurementID }) => {
|
|
8
|
+
/*
|
|
9
|
+
Effect to inject the Google Analytics script into the document head.
|
|
10
|
+
This has to be an Effect because React intentionally does not run inline <script> elements that it creates
|
|
11
|
+
in the browser. By making this an Effect, we can create a <script> element and append it to the document head,
|
|
12
|
+
which will cause the browser to execute it.
|
|
13
|
+
*/
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const script = document.createElement("script");
|
|
16
|
+
script.async = true;
|
|
17
|
+
script.src = `${GOOGLE_ANALYTICS_URL}?id=${gaMeasurementID}`;
|
|
18
|
+
document.head.append(script);
|
|
19
|
+
window.dataLayer = window.dataLayer || [];
|
|
20
|
+
window.gtag = function () {
|
|
21
|
+
// gtag must push the `arguments` object itself, not an array, for GA to process it
|
|
22
|
+
// eslint-disable-next-line prefer-rest-params
|
|
23
|
+
window.dataLayer.push(arguments);
|
|
24
|
+
};
|
|
25
|
+
window.gtag("js", new Date());
|
|
26
|
+
window.gtag("config", gaMeasurementID);
|
|
27
|
+
return () => {
|
|
28
|
+
script.remove();
|
|
29
|
+
};
|
|
30
|
+
}, [gaMeasurementID]);
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
@@ -8,6 +8,7 @@ export interface NavbarProps {
|
|
|
8
8
|
name: string;
|
|
9
9
|
image: string;
|
|
10
10
|
};
|
|
11
|
+
readonly enableAuthentication: boolean;
|
|
11
12
|
readonly authenticationType: string;
|
|
12
13
|
readonly signOut: () => void;
|
|
13
14
|
readonly supportEmailAddress: string;
|
|
@@ -15,4 +16,4 @@ export interface NavbarProps {
|
|
|
15
16
|
readonly showSettingsButton?: boolean;
|
|
16
17
|
readonly onStartTour?: () => void;
|
|
17
18
|
}
|
|
18
|
-
export declare const Navbar: ({ authenticationType, id, logo, logoServiceToken, onStartTour, pathname, query, showSettingsButton, signOut, supportEmailAddress, userInfo, }: NavbarProps) => ReactJSX.Element;
|
|
19
|
+
export declare const Navbar: ({ enableAuthentication, authenticationType, id, logo, logoServiceToken, onStartTour, pathname, query, showSettingsButton, signOut, supportEmailAddress, userInfo, }: NavbarProps) => ReactJSX.Element;
|
|
@@ -31,7 +31,7 @@ import Tooltip from "@mui/material/Tooltip";
|
|
|
31
31
|
import Typography from "@mui/material/Typography";
|
|
32
32
|
import { useState } from "react";
|
|
33
33
|
import { ConfirmationModal } from "./ConfirmationModal.js";
|
|
34
|
-
import {
|
|
34
|
+
import { DEFAULT_USER_IMAGE, getContactUsConfirmationText, NEURO_SAN_UI_VERSION } from "../../const.js";
|
|
35
35
|
import { useSettingsStore } from "../../state/Settings.js";
|
|
36
36
|
import { isDarkMode } from "../../Theme/Theme.js";
|
|
37
37
|
import { navigateToUrl } from "../../utils/BrowserNavigation.js";
|
|
@@ -53,7 +53,7 @@ const DISABLE_OUTLINE_PROPS = {
|
|
|
53
53
|
outline: "none",
|
|
54
54
|
},
|
|
55
55
|
};
|
|
56
|
-
export const Navbar = ({ authenticationType, id, logo, logoServiceToken, onStartTour, pathname, query, showSettingsButton = true, signOut, supportEmailAddress, userInfo, }) => {
|
|
56
|
+
export const Navbar = ({ enableAuthentication, authenticationType, id, logo, logoServiceToken, onStartTour, pathname, query, showSettingsButton = true, signOut, supportEmailAddress, userInfo, }) => {
|
|
57
57
|
// For email dialog
|
|
58
58
|
const [emailDialogOpen, setEmailDialogOpen] = useState(false);
|
|
59
59
|
// Dark mode
|
|
@@ -149,7 +149,7 @@ export const Navbar = ({ authenticationType, id, logo, logoServiceToken, onStart
|
|
|
149
149
|
whiteSpace: "normal",
|
|
150
150
|
wordWrap: "break-word",
|
|
151
151
|
fontSize: "smaller",
|
|
152
|
-
}, children: userInfo.name }), _jsx(MenuItem, { id: "auth-type-title", disabled: true, sx: { fontWeight: "bold" }, children: "Authentication" }), _jsx(MenuItem, { id: "authentication-type-menu-item", disabled: true, sx: { fontSize: "smaller" }, children: authenticationType }),
|
|
152
|
+
}, children: userInfo.name }), _jsx(MenuItem, { id: "auth-type-title", disabled: true, sx: { fontWeight: "bold" }, children: "Authentication" }), _jsx(MenuItem, { id: "authentication-type-menu-item", disabled: true, sx: { fontSize: "smaller" }, children: authenticationType }), enableAuthentication && (_jsx(MenuItem, { id: "user-sign-out", sx: { ...DISABLE_OUTLINE_PROPS, fontWeight: "bold" }, onClick: signOut, children: "Sign out" }))] })] })) : null, _jsx(Tooltip, { id: "dark-mode-toggle", title: hasCustomer
|
|
153
153
|
? "Dark mode toggle is not available when customer branding is active. Reset via Settings menu."
|
|
154
154
|
: "Toggle dark mode", children: _jsx(DarkModeIcon, { id: "dark-mode-icon", sx: {
|
|
155
155
|
marginRight: "1rem",
|
|
@@ -19,7 +19,7 @@ import { useRouter } from "next/router.js";
|
|
|
19
19
|
import { LOGO } from "../../const.js";
|
|
20
20
|
import { useEnvironmentStore } from "../../state/Environment.js";
|
|
21
21
|
import { useUserInfoStore } from "../../state/UserInfo.js";
|
|
22
|
-
import { smartSignOut, useAuthentication } from "../../utils/Authentication.js";
|
|
22
|
+
import { getAuthenticationType, smartSignOut, useAuthentication } from "../../utils/Authentication.js";
|
|
23
23
|
import { NeuroAIBreadcrumbs } from "../Common/Breadcrumbs.js";
|
|
24
24
|
import { Footer } from "../Common/Footer.js";
|
|
25
25
|
import { Navbar } from "../Common/Navbar.js";
|
|
@@ -29,13 +29,13 @@ import { Navbar } from "../Common/Navbar.js";
|
|
|
29
29
|
* @param errorText Error text to be displayed
|
|
30
30
|
*/
|
|
31
31
|
const ErrorPage = ({ id, errorText }) => {
|
|
32
|
-
const { auth0ClientId, auth0Domain,
|
|
32
|
+
const { auth0ClientId, auth0Domain, enableAuthentication, logoServiceToken, supportEmailAddress } = useEnvironmentStore();
|
|
33
33
|
// Access Next.js router
|
|
34
34
|
const router = useRouter();
|
|
35
35
|
// Access user info store
|
|
36
36
|
const { currentUser, setCurrentUser, setPicture, oidcProvider } = useUserInfoStore();
|
|
37
37
|
// Infer authentication type
|
|
38
|
-
const authenticationType = currentUser
|
|
38
|
+
const authenticationType = getAuthenticationType(enableAuthentication, currentUser, oidcProvider);
|
|
39
39
|
const { data: { user: userInfo } = {} } = useAuthentication();
|
|
40
40
|
const handleSignOut = async () => {
|
|
41
41
|
// Clear our state storage variables
|
|
@@ -43,6 +43,6 @@ const ErrorPage = ({ id, errorText }) => {
|
|
|
43
43
|
setPicture(undefined);
|
|
44
44
|
await smartSignOut(currentUser, auth0Domain, auth0ClientId, oidcProvider);
|
|
45
45
|
};
|
|
46
|
-
return (_jsxs(_Fragment, { children: [_jsx(Navbar, { authenticationType: authenticationType, id: "nav-bar", logo: LOGO, logoServiceToken: logoServiceToken, pathname: router.pathname, query: router.query, signOut: handleSignOut, supportEmailAddress: supportEmailAddress, userInfo: userInfo }), _jsxs(Box, { id: id, sx: { marginLeft: "1rem" }, children: [_jsx(NeuroAIBreadcrumbs, {}), _jsx("h4", { id: "error-header", style: { color: "var(--bs-red)", marginTop: "1rem" }, children: "Oops, an internal error occurred on our end." }), _jsxs("div", { id: "error-div-1", children: [_jsxs(Box, { id: "no-need-to-worry", sx: { marginBottom: "1.5rem" }, children: [_jsx("b", { id: "bold-1", children: "There's no need to worry \u2013 you didn't do anything wrong." }), " This is a bug in our server and we'll fix it as soon as possible."] }), _jsx(Box, { id: "try-these-steps", sx: { marginBottom: "1.5rem" }, children: "To attempt to recover from the error, try these steps:" }), _jsx(Box, { id: "refresh-page", sx: { marginBottom: "1.5rem" }, children: _jsxs("ul", { id: "error-boundary-advice-list", className: "list-decimal list-inside", children: [_jsx("li", { id: "error-advice-refresh", children: "Refresh the page to see if the error goes away." }), _jsx("li", { id: "error-advice-reload", children: "Close and re-open your browser, then navigate back to the page where you encountered the error." })] }) }), "If none of that helps, please report the following error to the LEAF team:"] }), _jsx("div", { id: "error-text-div", style: { fontFamily: "monospace", marginTop: "1.5rem", marginBottom: "1.5rem" }, children: errorText }), "More information may be available in the browser console. Please include such information in your report if possible."] }), _jsx(Footer, { supportEmailAddress: supportEmailAddress, logoLinkUrl: "https://www.cognizant.com/", logoUrl: "/cognizant-logo-white.svg" })] }));
|
|
46
|
+
return (_jsxs(_Fragment, { children: [_jsx(Navbar, { enableAuthentication: enableAuthentication, authenticationType: authenticationType, id: "nav-bar", logo: LOGO, logoServiceToken: logoServiceToken, pathname: router.pathname, query: router.query, signOut: handleSignOut, supportEmailAddress: supportEmailAddress, userInfo: userInfo }), _jsxs(Box, { id: id, sx: { marginLeft: "1rem" }, children: [_jsx(NeuroAIBreadcrumbs, {}), _jsx("h4", { id: "error-header", style: { color: "var(--bs-red)", marginTop: "1rem" }, children: "Oops, an internal error occurred on our end." }), _jsxs("div", { id: "error-div-1", children: [_jsxs(Box, { id: "no-need-to-worry", sx: { marginBottom: "1.5rem" }, children: [_jsx("b", { id: "bold-1", children: "There's no need to worry \u2013 you didn't do anything wrong." }), " This is a bug in our server and we'll fix it as soon as possible."] }), _jsx(Box, { id: "try-these-steps", sx: { marginBottom: "1.5rem" }, children: "To attempt to recover from the error, try these steps:" }), _jsx(Box, { id: "refresh-page", sx: { marginBottom: "1.5rem" }, children: _jsxs("ul", { id: "error-boundary-advice-list", className: "list-decimal list-inside", children: [_jsx("li", { id: "error-advice-refresh", children: "Refresh the page to see if the error goes away." }), _jsx("li", { id: "error-advice-reload", children: "Close and re-open your browser, then navigate back to the page where you encountered the error." })] }) }), "If none of that helps, please report the following error to the LEAF team:"] }), _jsx("div", { id: "error-text-div", style: { fontFamily: "monospace", marginTop: "1.5rem", marginBottom: "1.5rem" }, children: errorText }), "More information may be available in the browser console. Please include such information in your report if possible."] }), _jsx(Footer, { supportEmailAddress: supportEmailAddress, logoLinkUrl: "https://www.cognizant.com/", logoUrl: "/cognizant-logo-white.svg" })] }));
|
|
47
47
|
};
|
|
48
48
|
export default ErrorPage;
|
|
@@ -15,9 +15,9 @@ export interface AgentFlowProps {
|
|
|
15
15
|
readonly id: string;
|
|
16
16
|
readonly isAwaitingLlm?: boolean;
|
|
17
17
|
readonly isAgentNetworkDesignerMode?: boolean;
|
|
18
|
-
readonly
|
|
18
|
+
readonly isEditingNetwork?: boolean;
|
|
19
19
|
readonly isStreaming?: boolean;
|
|
20
|
-
readonly
|
|
20
|
+
readonly isTemporaryNetwork?: boolean;
|
|
21
21
|
/** The history key for the currently selected network (used to scope sly_data reads/writes per network). */
|
|
22
22
|
readonly networkId?: string;
|
|
23
23
|
readonly neuroSanURL?: string;
|
|
@@ -27,10 +27,11 @@ export interface AgentFlowProps {
|
|
|
27
27
|
* @param newNetworkId The agent_name of the replacement network to navigate to.
|
|
28
28
|
*/
|
|
29
29
|
readonly networkDisplayName?: string;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
readonly
|
|
30
|
+
/**
|
|
31
|
+
* Setter for changing the selected network.
|
|
32
|
+
*/
|
|
33
|
+
readonly setSelectedNetwork?: (network: string | null) => void;
|
|
34
|
+
readonly setIsEditingNetwork?: (value: boolean) => void;
|
|
34
35
|
readonly onSaveAgent?: (agentName: string, updated: AgentNetworkDefinitionEntry[], agentNetworkName: string | undefined, signal: AbortSignal) => Promise<void>;
|
|
35
36
|
readonly thoughtBubbleEdges: Map<string, {
|
|
36
37
|
edge: ThoughtBubbleEdgeShape;
|
|
@@ -41,7 +42,6 @@ export interface AgentFlowProps {
|
|
|
41
42
|
timestamp: number;
|
|
42
43
|
}>>>;
|
|
43
44
|
}
|
|
44
|
-
export declare const DOCK_BANNER_AUTO_DISMISS_MS = 5000;
|
|
45
45
|
/**
|
|
46
46
|
* Filters node events based on the current mode. Don't allow any topological-modifying events (adding, deleting nodes)
|
|
47
47
|
* and in Agent Network Designer mode, don't allow dragging nodes (position changes) either.
|