@cognizant-ai-lab/ui-common 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/components/AgentChat/ChatCommon/ChatCommon.js +32 -10
  2. package/dist/components/AgentChat/ChatCommon/Const.d.ts +1 -0
  3. package/dist/components/AgentChat/ChatCommon/Const.js +2 -0
  4. package/dist/components/AgentChat/ChatCommon/SlyDataDialog.d.ts +29 -0
  5. package/dist/components/AgentChat/ChatCommon/SlyDataDialog.js +150 -0
  6. package/dist/components/AgentChat/ChatCommon/Thinking.js +2 -2
  7. package/dist/components/AgentChat/Common/LlmChatButton.d.ts +4 -6
  8. package/dist/components/AgentChat/Common/LlmChatButton.js +0 -2
  9. package/dist/components/AgentChat/Common/Utils.d.ts +0 -11
  10. package/dist/components/AgentChat/Common/Utils.js +0 -16
  11. package/dist/components/Common/ConfirmationModal.d.ts +3 -2
  12. package/dist/components/Common/Footer.js +4 -0
  13. package/dist/components/Common/Navbar.d.ts +2 -1
  14. package/dist/components/Common/Navbar.js +3 -3
  15. package/dist/components/ErrorPage/ErrorPage.js +4 -4
  16. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.d.ts +7 -7
  17. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.js +161 -376
  18. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentNode.js +7 -5
  19. package/dist/components/MultiAgentAccelerator/AgentFlow/GraphLayouts.js +10 -7
  20. package/dist/components/MultiAgentAccelerator/AgentFlow/GraphStructure.d.ts +1 -1
  21. package/dist/components/MultiAgentAccelerator/Editor/AgentNodeEditor.d.ts +24 -0
  22. package/dist/components/MultiAgentAccelerator/Editor/AgentNodeEditor.js +128 -0
  23. package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.d.ts +21 -0
  24. package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.js +305 -0
  25. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +112 -116
  26. package/dist/components/MultiAgentAccelerator/NeuroSanStudioCallout.d.ts +2 -0
  27. package/dist/components/MultiAgentAccelerator/NeuroSanStudioCallout.js +38 -0
  28. package/dist/components/MultiAgentAccelerator/PanelSeparator.d.ts +5 -0
  29. package/dist/components/MultiAgentAccelerator/PanelSeparator.js +46 -0
  30. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.d.ts +2 -0
  31. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +23 -31
  32. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +0 -2
  33. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +11 -9
  34. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +2 -2
  35. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +13 -13
  36. package/dist/components/MultiAgentAccelerator/TemporaryNetworks.d.ts +3 -17
  37. package/dist/components/MultiAgentAccelerator/TemporaryNetworks.js +17 -40
  38. package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.js +10 -8
  39. package/dist/components/MultiAgentAccelerator/const.d.ts +12 -11
  40. package/dist/components/MultiAgentAccelerator/const.js +24 -22
  41. package/dist/components/Settings/ApiKeyErrorBanner.d.ts +22 -0
  42. package/dist/components/Settings/ApiKeyErrorBanner.js +26 -0
  43. package/dist/components/Settings/ApiKeyInput.d.ts +5 -2
  44. package/dist/components/Settings/ApiKeyInput.js +10 -4
  45. package/dist/components/Settings/SettingsDialog.js +22 -5
  46. package/dist/const.d.ts +0 -1
  47. package/dist/const.js +0 -1
  48. package/dist/controller/llm/Providers.d.ts +19 -2
  49. package/dist/controller/llm/Providers.js +45 -31
  50. package/dist/state/Announcements.d.ts +24 -0
  51. package/dist/state/Announcements.js +29 -0
  52. package/dist/state/ChatHistory.d.ts +10 -1
  53. package/dist/state/ChatHistory.js +8 -0
  54. package/dist/state/Environment.d.ts +2 -0
  55. package/dist/state/Environment.js +2 -0
  56. package/dist/state/Settings.d.ts +14 -0
  57. package/dist/state/Settings.js +6 -2
  58. package/dist/state/TemporaryNetworks.js +12 -21
  59. package/dist/tsconfig.build.tsbuildinfo +1 -1
  60. package/dist/utils/AgentName.d.ts +17 -0
  61. package/dist/utils/AgentName.js +46 -0
  62. package/dist/utils/Authentication.d.ts +7 -0
  63. package/dist/utils/Authentication.js +19 -5
  64. package/dist/utils/SlyData.d.ts +56 -0
  65. package/dist/utils/SlyData.js +106 -0
  66. package/package.json +7 -6
  67. package/dist/components/MultiAgentAccelerator/AgentNodePopup.d.ts +0 -30
  68. package/dist/components/MultiAgentAccelerator/AgentNodePopup.js +0 -80
  69. package/dist/components/MultiAgentAccelerator/Sidebar/ImportNetworkModal.d.ts +0 -67
  70. package/dist/components/MultiAgentAccelerator/Sidebar/ImportNetworkModal.js +0 -585
@@ -16,12 +16,13 @@ import ToggleButton from "@mui/material/ToggleButton";
16
16
  import ToggleButtonGroup from "@mui/material/ToggleButtonGroup";
17
17
  import Tooltip from "@mui/material/Tooltip";
18
18
  import Typography from "@mui/material/Typography";
19
- import { useEffect, useMemo, useState, } from "react";
19
+ import { useCallback, useEffect, useMemo, useState, } from "react";
20
+ import { ApiKeyErrorBanner } from "./ApiKeyErrorBanner.js";
20
21
  import { ApiKeyInput } from "./ApiKeyInput.js";
21
22
  import { useCheckmarkFade } from "./FadingCheckmark.js";
22
23
  import { SettingsRow } from "./SettingsRow.js";
23
24
  import { getBrandingSuggestions, testConnection } from "../../controller/agent/Agent.js";
24
- import { isAnthropicKeyValid, isOpenAIKeyValid } from "../../controller/llm/Providers.js";
25
+ import { isAnthropicKeyValid, isOpenAIKeyValid, } from "../../controller/llm/Providers.js";
25
26
  import { useEnvironmentStore } from "../../state/Environment.js";
26
27
  import { API_KEYS_TTL_MS, DEFAULT_SETTINGS, getApiKey, useSettingsStore, } from "../../state/Settings.js";
27
28
  import { PALETTES } from "../../Theme/Palettes.js";
@@ -64,7 +65,6 @@ const SubSectionBody = styled(Box)(({ theme }) => ({
64
65
  width: "100%",
65
66
  }));
66
67
  //#endregion: Types and Interfaces
67
- // eslint-disable-next-line react/no-multi-comp -- only relevant to this module.
68
68
  const SettingsSubsection = ({ title, children }) => (_jsxs(SubSection, { children: [_jsx(SubsectionTitle, { variant: "subtitle1", children: title }), _jsx(SubSectionBody, { children: children })] }));
69
69
  const URL_PROTOCOL_REGEX = /^https?:\/\//iu;
70
70
  const HTTP_PROTOCOL_REGEX = /^http:\/\//iu;
@@ -83,7 +83,6 @@ const normalizeNeuroSanUrlInput = (value, fallbackProtocol) => {
83
83
  protocol: hasProtocol ? (HTTP_PROTOCOL_REGEX.test(trimmedValue) ? "http" : "https") : fallbackProtocol,
84
84
  };
85
85
  };
86
- // eslint-disable-next-line react/no-multi-comp -- styled component shim is only used in this module
87
86
  export const SettingsDialog = ({ id, isOpen, logoServiceToken, onClose }) => {
88
87
  // Settings store actions
89
88
  const updateSettings = useSettingsStore((state) => state.updateSettings);
@@ -119,6 +118,8 @@ export const SettingsDialog = ({ id, isOpen, logoServiceToken, onClose }) => {
119
118
  const apiKeys = useSettingsStore((state) => state.settings.apiKeys);
120
119
  const openAIKeyCheckmark = useCheckmarkFade();
121
120
  const anthropicKeyCheckmark = useCheckmarkFade();
121
+ // Failing key-test results, aggregated into the banner at the top of the API Keys section
122
+ const [keyTestResults, setKeyTestResults] = useState({});
122
123
  // Native names setting
123
124
  const useNativeNames = useSettingsStore((state) => state.settings.appearance.useNativeNames);
124
125
  const nativeNamesCheckmark = useCheckmarkFade();
@@ -234,6 +235,17 @@ export const SettingsDialog = ({ id, isOpen, logoServiceToken, onClose }) => {
234
235
  brandingCheckmark.trigger();
235
236
  logoCheckmark.trigger();
236
237
  };
238
+ /**
239
+ * Records the latest key-test result for a vendor, or clears it when result is null.
240
+ * @param vendor Vendor for this key: see the list in LLMProvider type
241
+ * @param result Validation failure to display, or null to clear
242
+ */
243
+ const handleKeyResultChange = useCallback((vendor, result) => {
244
+ setKeyTestResults((prev) => ({
245
+ ...prev,
246
+ [vendor]: result ? { vendor, result } : null,
247
+ }));
248
+ }, []);
237
249
  /**
238
250
  * Used for both saving and removing keys.
239
251
  * @param vendor Vendor for this key: see the list in LLMProvider type
@@ -333,6 +345,11 @@ export const SettingsDialog = ({ id, isOpen, logoServiceToken, onClose }) => {
333
345
  }, sx: { flex: 1 }, value: neuroSanUrlInput }), _jsx(StatusLight, { id: `${id}-status-light`, statusValue: statusLightValue }), _jsx(Button, { disabled: neuroSanUrlInput.trim().length === 0, onClick: handleTestConnection, size: "small", variant: "contained", children: "Test" }), _jsx(Button, { disabled: neuroSanUrlSaveDisabled, onClick: handleSaveNeuroSanUrl, size: "small", variant: "contained", children: "Save" }), _jsx(Button, { disabled: neuroSanUrlResetDisabled, onClick: handleResetNeuroSanUrl, size: "small", variant: "contained", children: "Default" })] }, `${id}-neuro-san-server-url`) }));
334
346
  };
335
347
  const getServicesSection = () => (_jsxs(Section, { children: [_jsx(SettingsSectionTitle, { children: "External Services" }), getNeuroSanSubsection()] }));
348
+ // Collect the current test failure for each vendor that has one.
349
+ const keyFailures = apiKeyConfigs.flatMap(({ vendor }) => {
350
+ const failure = keyTestResults[vendor];
351
+ return failure ? [failure] : [];
352
+ });
336
353
  const getApiKeysSection = () => (_jsxs(Section, { children: [_jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: theme.spacing(1) }, children: [_jsx(SettingsSectionTitle, { children: "API Keys" }), _jsx(Tooltip, { title: "API keys are stored locally in your browser's memory for the duration of your session only\n and are only sent to the Neuro SAN service for use with the associated LLM provider when you use\n this application to interact with networks.\n Your keys are never sent to any other servers or services and are not stored on our servers.\n When you close this tab or your browser, your keys will be permanently cleared from memory and\n you will need to enter them again to use services that require them.", children: _jsxs(Typography, { sx: {
337
354
  alignSelf: "flex-start",
338
355
  color: "var(--bs-secondary)",
@@ -343,7 +360,7 @@ export const SettingsDialog = ({ id, isOpen, logoServiceToken, onClose }) => {
343
360
  }, variant: "caption", children: [_jsx(Box, { component: "span", sx: { mr: 0.5 }, children: "\u24D8" }), _jsx(Box, { component: "span", sx: {
344
361
  borderBottom: "1px dashed",
345
362
  pb: 0.25,
346
- }, children: "How are my keys stored and used?" })] }) })] }), _jsx(SettingsSubsection, { title: "LLM Providers", children: _jsx(Box, { sx: { display: "flex", flexDirection: "column", alignItems: "center", gap: 1.5 }, children: apiKeyConfigs.map(({ checkmark, vendor, idSuffix, logo, onTest, placeholder }) => (_jsx(SettingsRow, { checkmark: checkmark, label: "", tooltip: `API key for ${vendor}.`, children: _jsx(ApiKeyInput, { forgetKey: () => persistKey(vendor, "", checkmark, 0), id: `${id}-${idSuffix}`, logo: logo, onSave: (key) => persistKey(vendor, key, checkmark, Date.now()), onTest: onTest, persistedValue: getApiKey(apiKeys, vendor), placeholder: placeholder, vendor: vendor }) }, `${id}-${idSuffix}`))) }) })] }));
363
+ }, children: "How are my keys stored and used?" })] }) })] }), _jsxs(SettingsSubsection, { title: "LLM Providers", children: [_jsx(ApiKeyErrorBanner, { failures: keyFailures, id: `${id}-api-key-error-banner` }), _jsx(Box, { sx: { display: "flex", flexDirection: "column", alignItems: "center", gap: 1.5 }, children: apiKeyConfigs.map(({ checkmark, vendor, idSuffix, logo, onTest, placeholder }) => (_jsx(SettingsRow, { checkmark: checkmark, label: "", tooltip: `API key for ${vendor}.`, children: _jsx(ApiKeyInput, { forgetKey: () => persistKey(vendor, "", checkmark, 0), id: `${id}-${idSuffix}`, logo: logo, onResultChange: handleKeyResultChange, onSave: (key) => persistKey(vendor, key, checkmark, Date.now()), onTest: onTest, persistedValue: getApiKey(apiKeys, vendor), placeholder: placeholder, vendor: vendor }) }, `${id}-${idSuffix}`))) })] })] }));
347
364
  const getBehaviorSection = () => (_jsxs(Section, { children: [_jsx(SettingsSectionTitle, { children: "Behavior" }), _jsx(SettingsSubsection, { title: "Zen mode", children: _jsx(SettingsRow, { label: 'Enable "Zen" mode:', checkmark: enableZenModeCheckmark, tooltip: "Hides most of the UI during agent network animations providing a more immersive " +
348
365
  "experience.", children: _jsx(Checkbox, { checked: enableZenMode, "data-testid": "zen-mode-checkbox", onChange: (_, checked) => {
349
366
  updateSettings({ behavior: { enableZenMode: checked } });
package/dist/const.d.ts CHANGED
@@ -10,4 +10,3 @@ export declare const DEFAULT_USERNAME = "Guest";
10
10
  * The default user image to use when the user does not have a profile picture.
11
11
  */
12
12
  export declare const DEFAULT_USER_IMAGE = "https://www.gravatar.com/avatar/?d=mp";
13
- export declare const authenticationEnabled: () => boolean;
package/dist/const.js CHANGED
@@ -29,4 +29,3 @@ export const DEFAULT_USERNAME = "Guest";
29
29
  * The default user image to use when the user does not have a profile picture.
30
30
  */
31
31
  export const DEFAULT_USER_IMAGE = "https://www.gravatar.com/avatar/?d=mp";
32
- export const authenticationEnabled = () => process.env["NEXT_PUBLIC_ENABLE_AUTHENTICATION"] !== "false";
@@ -1,2 +1,19 @@
1
- export declare const isOpenAIKeyValid: (key: string) => Promise<boolean>;
2
- export declare const isAnthropicKeyValid: (key: string) => Promise<boolean>;
1
+ interface KeyValidationSuccess {
2
+ ok: true;
3
+ }
4
+ /** A failed key test; {@link status} and {@link message} carry whatever detail could be recovered. */
5
+ export interface KeyValidationFailure {
6
+ ok: false;
7
+ status?: number;
8
+ message?: string;
9
+ }
10
+ /** Result of testing an API key: success, or a failure carrying whatever detail could be recovered. */
11
+ export type KeyValidationResult = KeyValidationSuccess | KeyValidationFailure;
12
+ /**
13
+ * Narrow a {@link KeyValidationResult} to its failure variant. Checking `!result.ok` inline should
14
+ * be enough, but doesn't narrow while `strictNullChecks` is off; this guard bridges that gap.
15
+ */
16
+ export declare const isKeyValidationFailure: (result: KeyValidationResult) => result is KeyValidationFailure;
17
+ export declare const isOpenAIKeyValid: (key: string) => Promise<KeyValidationResult>;
18
+ export declare const isAnthropicKeyValid: (key: string) => Promise<KeyValidationResult>;
19
+ export {};
@@ -1,41 +1,55 @@
1
- export const isOpenAIKeyValid = async (key) => {
1
+ //#region: Types and Interfaces
2
+ //#endregion: Types and Interfaces
3
+ /**
4
+ * Narrow a {@link KeyValidationResult} to its failure variant. Checking `!result.ok` inline should
5
+ * be enough, but doesn't narrow while `strictNullChecks` is off; this guard bridges that gap.
6
+ */
7
+ export const isKeyValidationFailure = (result) => !result.ok;
8
+ /**
9
+ * Read the provider's error message from a failed response, tolerating empty or non-JSON
10
+ * bodies (which cause {@link Response.json} to reject).
11
+ * @param res The failed response.
12
+ * @return The provider's error message, or `undefined` if none could be parsed.
13
+ */
14
+ const extractErrorMessage = async (res) => {
2
15
  try {
3
- // Just call the "list models" API with the supplied key.
4
- // We don't care about the result, just whether it succeeds or not
5
- const res = await fetch("https://api.openai.com/v1/models", {
6
- method: "GET",
7
- headers: {
8
- Accept: "application/json",
9
- Authorization: `Bearer ${key}`,
10
- },
11
- });
12
- return res.ok;
16
+ const body = await res.json();
17
+ return body?.error?.message;
13
18
  }
14
- catch (e) {
15
- console.error("Error validating API key:", e);
16
- return false;
19
+ catch {
20
+ return undefined;
17
21
  }
18
22
  };
19
- export const isAnthropicKeyValid = async (key) => {
23
+ /**
24
+ * Validate an API key by calling a provider's authenticated "list models" endpoint. The status is
25
+ * all we need: a 2xx means the key works; any other response is a failure whose status and message
26
+ * we surface. A thrown error (network failure, CORS rejection) is likewise reported as a failure.
27
+ * @param url The provider's "list models" endpoint.
28
+ * @param headers Request headers, including authentication for the supplied key.
29
+ * @return A {@link KeyValidationResult} describing the outcome.
30
+ */
31
+ const validateKey = async (url, headers) => {
20
32
  try {
21
- // Just call the "list models" API with the supplied key.
22
- // We don't care about the result, just whether it succeeds or not
23
- const res = await fetch("https://api.anthropic.com/v1/models", {
24
- method: "GET",
25
- headers: {
26
- Accept: "application/json",
27
- "anthropic-version": "2023-06-01",
28
- "X-Api-Key": key,
29
- // Request vendor to allow CORS for this endpoint
30
- // Reference: https://simonwillison.net/2024/Aug/23/anthropic-dangerous-direct-browser-access/
31
- // The request will be rejected without this.
32
- "anthropic-dangerous-direct-browser-access": "true",
33
- },
34
- });
35
- return res.ok;
33
+ const res = await fetch(url, { method: "GET", headers });
34
+ if (res.ok) {
35
+ return { ok: true };
36
+ }
37
+ return { ok: false, status: res.status, message: await extractErrorMessage(res) };
36
38
  }
37
39
  catch (e) {
38
40
  console.error("Error validating API key:", e);
39
- return false;
41
+ return { ok: false, message: e instanceof Error ? e.message : String(e) };
40
42
  }
41
43
  };
44
+ export const isOpenAIKeyValid = (key) => validateKey("https://api.openai.com/v1/models", {
45
+ Accept: "application/json",
46
+ Authorization: `Bearer ${key}`,
47
+ });
48
+ export const isAnthropicKeyValid = (key) => validateKey("https://api.anthropic.com/v1/models", {
49
+ Accept: "application/json",
50
+ "anthropic-version": "2023-06-01",
51
+ "X-Api-Key": key,
52
+ // Anthropic rejects direct browser-origin requests unless this header is present.
53
+ // https://simonwillison.net/2024/Aug/23/anthropic-dangerous-direct-browser-access/
54
+ "anthropic-dangerous-direct-browser-access": "true",
55
+ });
@@ -0,0 +1,24 @@
1
+ export declare enum AnnouncementId {
2
+ NeuroSanStudioGithubStar = "NeuroSanStudioGithubStar"
3
+ }
4
+ interface AnnouncementsStore {
5
+ readonly lastShownAt: Partial<Record<AnnouncementId, number>>;
6
+ readonly markShown: (id: AnnouncementId) => void;
7
+ readonly hasShown: (id: AnnouncementId) => boolean;
8
+ readonly reset: (id?: AnnouncementId) => void;
9
+ }
10
+ /**
11
+ * Persisted zustand store for announcements we want to show to the user once, or every some amount of time.
12
+ */
13
+ export declare const useAnnouncementsStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<AnnouncementsStore>, "persist"> & {
14
+ persist: {
15
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<AnnouncementsStore, AnnouncementsStore>>) => void;
16
+ clearStorage: () => void;
17
+ rehydrate: () => Promise<void> | void;
18
+ hasHydrated: () => boolean;
19
+ onHydrate: (fn: (state: AnnouncementsStore) => void) => () => void;
20
+ onFinishHydration: (fn: (state: AnnouncementsStore) => void) => () => void;
21
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<AnnouncementsStore, AnnouncementsStore>>;
22
+ };
23
+ }>;
24
+ export {};
@@ -0,0 +1,29 @@
1
+ import { create } from "zustand";
2
+ import { persist } from "zustand/middleware";
3
+ export var AnnouncementId;
4
+ (function (AnnouncementId) {
5
+ AnnouncementId["NeuroSanStudioGithubStar"] = "NeuroSanStudioGithubStar";
6
+ })(AnnouncementId || (AnnouncementId = {}));
7
+ const ANNOUNCEMENTS_STORAGE_KEY = "announcements";
8
+ /**
9
+ * Persisted zustand store for announcements we want to show to the user once, or every some amount of time.
10
+ */
11
+ export const useAnnouncementsStore = create()(persist((set, get) => ({
12
+ lastShownAt: {},
13
+ markShown: (id) => set((state) => ({
14
+ lastShownAt: {
15
+ ...state.lastShownAt,
16
+ [id]: Date.now(),
17
+ },
18
+ })),
19
+ hasShown: (id) => Boolean(get().lastShownAt[id]),
20
+ reset: (id) => set((state) => {
21
+ if (!id) {
22
+ return { lastShownAt: {} };
23
+ }
24
+ const { [id]: _removed, ...remaining } = state.lastShownAt;
25
+ return { lastShownAt: remaining };
26
+ }),
27
+ }), {
28
+ name: ANNOUNCEMENTS_STORAGE_KEY,
29
+ }));
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { BaseMessage, mapChatMessagesToStoredMessages } from "@langchain/core/messages";
6
6
  import { ChatContext } from "../generated/neuro-san/NeuroSanClient.js";
7
- type SlyData = Record<string, unknown>;
7
+ import { SlyData } from "../utils/SlyData.js";
8
8
  export declare const MAX_CHAT_HISTORY_ITEMS = 50;
9
9
  interface AgentChatHistory<T = BaseMessage[] | ReturnType<typeof mapChatMessagesToStoredMessages>> {
10
10
  readonly chatHistory: T;
@@ -17,8 +17,17 @@ interface AgentChatHistory<T = BaseMessage[] | ReturnType<typeof mapChatMessages
17
17
  interface ChatHistoryStore {
18
18
  readonly history: Record<string, AgentChatHistory<BaseMessage[]>>;
19
19
  resetHistory: (agentId: string) => void;
20
+ /**
21
+ * Replaces the sly_data for an agent outright, so that keys the caller left out are removed. Used by the
22
+ * sly_data editor, where the user has to be able to delete keys. Contrast with `updateSlyData`, which merges.
23
+ */
24
+ setSlyData: (agentId: string, slyData: SlyData) => void;
20
25
  updateChatContext: (agentId: string, chatContext: ChatContext) => void;
21
26
  updateChatHistory: (agentId: string, messages: BaseMessage[]) => void;
27
+ /**
28
+ * Merges incoming sly_data into whatever the agent already has. Used for sly_data echoed by the server during
29
+ * streaming, where each message carries only the keys that changed.
30
+ */
22
31
  updateSlyData: (agentId: string, slyData: SlyData) => void;
23
32
  /**
24
33
  * Copies the full history entry from `fromId` to `toId`. Used when a temporary network is replaced
@@ -76,6 +76,14 @@ export const useAgentChatHistoryStore = create()(persist((set) => ({
76
76
  const newHistory = { ...state.history, [agentId]: { ...existing, slyData: mergedSlyData } };
77
77
  return { history: newHistory };
78
78
  }),
79
+ setSlyData: (agentId, slyData) => set((state) => {
80
+ // The editor can save sly_data before any conversation exists, so initialize the rest of the
81
+ // entry with the same defaults readers expect instead of leaving the fields undefined.
82
+ const fallback = { chatHistory: [], chatContext: null, slyData };
83
+ const existing = state.history[agentId] ?? fallback;
84
+ const newHistory = { ...state.history, [agentId]: { ...existing, slyData } };
85
+ return { history: newHistory };
86
+ }),
79
87
  resetHistory: (agentId) => set((state) => {
80
88
  const { [agentId]: _, ...rest } = state.history;
81
89
  return { history: rest };
@@ -4,6 +4,8 @@
4
4
  interface EnvironmentStore {
5
5
  backendNeuroSanApiUrl: string;
6
6
  setBackendNeuroSanApiUrl: (backendNeuroSanApiUrl: string) => void;
7
+ enableAuthentication: boolean | undefined;
8
+ setEnableAuthentication: (enableAuthentication: boolean) => void;
7
9
  auth0ClientId: string;
8
10
  setAuth0ClientId: (auth0ClientId: string) => void;
9
11
  auth0Domain: string;
@@ -24,6 +24,8 @@ import { create } from "zustand";
24
24
  export const useEnvironmentStore = create((set) => ({
25
25
  backendNeuroSanApiUrl: null,
26
26
  setBackendNeuroSanApiUrl: (backendNeuroSanApiUrl) => set(() => ({ backendNeuroSanApiUrl })),
27
+ enableAuthentication: undefined,
28
+ setEnableAuthentication: (enableAuthentication) => set(() => ({ enableAuthentication })),
27
29
  auth0ClientId: null,
28
30
  setAuth0ClientId: (auth0ClientId) => set(() => ({ auth0ClientId })),
29
31
  auth0Domain: null,
@@ -18,6 +18,8 @@ interface ApiKeyEntry {
18
18
  }
19
19
  type ApiKeys = Partial<Record<LLMProvider, ApiKeyEntry>>;
20
20
  export type PaletteKey = keyof typeof PALETTES | "brand";
21
+ export type Layout = "radial" | "linear";
22
+ export type GraphColoringOption = "depth" | "heatmap";
21
23
  /**
22
24
  * User preference settings
23
25
  */
@@ -26,8 +28,12 @@ interface Settings {
26
28
  readonly agentIconColor: string;
27
29
  readonly agentNodeColor: string;
28
30
  readonly autoAgentIconColor: boolean;
31
+ readonly graphColoringOption: GraphColoringOption;
32
+ readonly layout: Layout;
29
33
  readonly plasmaColor: string;
30
34
  readonly rangePalette: PaletteKey;
35
+ readonly showRadialGuides: boolean;
36
+ readonly showThoughtBubbles: boolean;
31
37
  readonly useNativeNames: boolean;
32
38
  };
33
39
  readonly branding: {
@@ -85,8 +91,12 @@ export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<impo
85
91
  readonly agentIconColor: string;
86
92
  readonly agentNodeColor: string;
87
93
  readonly autoAgentIconColor: boolean;
94
+ readonly graphColoringOption: GraphColoringOption;
95
+ readonly layout: Layout;
88
96
  readonly plasmaColor: string;
89
97
  readonly rangePalette: PaletteKey;
98
+ readonly showRadialGuides: boolean;
99
+ readonly showThoughtBubbles: boolean;
90
100
  readonly useNativeNames: boolean;
91
101
  };
92
102
  branding: {
@@ -119,8 +129,12 @@ export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<impo
119
129
  readonly agentIconColor: string;
120
130
  readonly agentNodeColor: string;
121
131
  readonly autoAgentIconColor: boolean;
132
+ readonly graphColoringOption: GraphColoringOption;
133
+ readonly layout: Layout;
122
134
  readonly plasmaColor: string;
123
135
  readonly rangePalette: PaletteKey;
136
+ readonly showRadialGuides: boolean;
137
+ readonly showThoughtBubbles: boolean;
124
138
  readonly useNativeNames: boolean;
125
139
  };
126
140
  branding: {
@@ -30,11 +30,15 @@ export const LLM_PROVIDER_API_KEY_FIELD = {
30
30
  export const DEFAULT_SETTINGS = {
31
31
  appearance: {
32
32
  // CSS variables like --bs-green don't work here. TBD why.
33
- agentNodeColor: "#2db81f",
34
33
  agentIconColor: "black",
34
+ agentNodeColor: "#2db81f",
35
35
  autoAgentIconColor: true,
36
- rangePalette: "blue",
36
+ graphColoringOption: "depth",
37
+ layout: "radial",
37
38
  plasmaColor: "#2db81f",
39
+ rangePalette: "blue",
40
+ showRadialGuides: true,
41
+ showThoughtBubbles: true,
38
42
  useNativeNames: false,
39
43
  },
40
44
  branding: {
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */
16
+ import { keyBy } from "lodash-es";
16
17
  import { create } from "zustand";
17
18
  import { persist } from "zustand/middleware";
18
19
  /**
@@ -22,29 +23,19 @@ export const useTempNetworksStore = create()(persist((set) => ({
22
23
  tempNetworks: [],
23
24
  setTempNetworks: (tempNetworks) => set({ tempNetworks }),
24
25
  upsertTempNetworks: (incomingNetworks) => {
25
- set((state) => {
26
- const updated = [...state.tempNetworks];
27
- for (const incomingNetwork of incomingNetworks) {
28
- const existingIndex = updated.findIndex((network) => network.agentNetworkName === incomingNetwork.agentNetworkName);
29
- if (existingIndex >= 0) {
30
- updated[existingIndex] = incomingNetwork; // replace the existing entry in-place
31
- }
32
- else {
33
- updated.push(incomingNetwork); // no existing entry — add as new
34
- }
35
- }
36
- return { tempNetworks: updated };
37
- });
26
+ set((state) => ({
27
+ // Key both sides by name and let incoming win; existing entries keep their position,
28
+ // new ones are appended.
29
+ tempNetworks: Object.values({
30
+ ...keyBy(state.tempNetworks, "agentNetworkName"),
31
+ ...keyBy(incomingNetworks, "agentNetworkName"),
32
+ }),
33
+ }));
38
34
  return incomingNetworks;
39
35
  },
40
- updateTempNetworkDefinition: (networkName, agentNetworkDefinition) => set((state) => {
41
- const updated = [...state.tempNetworks];
42
- const existingIndex = updated.findIndex((network) => network.agentInfo.agent_name === networkName);
43
- if (existingIndex >= 0) {
44
- updated[existingIndex] = { ...updated[existingIndex], agentNetworkDefinition };
45
- }
46
- return { tempNetworks: updated };
47
- }),
36
+ updateTempNetworkDefinition: (networkName, agentNetworkDefinition) => set(({ tempNetworks }) => ({
37
+ tempNetworks: tempNetworks.map((network) => network.agentInfo.agent_name === networkName ? { ...network, agentNetworkDefinition } : network),
38
+ })),
48
39
  }), {
49
40
  name: "temp-networks",
50
41
  }));