@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.
- package/dist/components/AgentChat/ChatCommon/ChatCommon.js +32 -10
- 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 +29 -0
- package/dist/components/AgentChat/ChatCommon/SlyDataDialog.js +150 -0
- package/dist/components/AgentChat/ChatCommon/Thinking.js +2 -2
- package/dist/components/AgentChat/Common/LlmChatButton.d.ts +4 -6
- package/dist/components/AgentChat/Common/LlmChatButton.js +0 -2
- package/dist/components/AgentChat/Common/Utils.d.ts +0 -11
- package/dist/components/AgentChat/Common/Utils.js +0 -16
- package/dist/components/Common/ConfirmationModal.d.ts +3 -2
- package/dist/components/Common/Footer.js +4 -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 +161 -376
- package/dist/components/MultiAgentAccelerator/AgentFlow/AgentNode.js +7 -5
- package/dist/components/MultiAgentAccelerator/AgentFlow/GraphLayouts.js +10 -7
- package/dist/components/MultiAgentAccelerator/AgentFlow/GraphStructure.d.ts +1 -1
- 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 +112 -116
- 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/AgentNetworkTreeItem.d.ts +2 -0
- package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +23 -31
- package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.d.ts +0 -2
- package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +11 -9
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +2 -2
- package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +13 -13
- package/dist/components/MultiAgentAccelerator/TemporaryNetworks.d.ts +3 -17
- package/dist/components/MultiAgentAccelerator/TemporaryNetworks.js +17 -40
- package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.js +10 -8
- package/dist/components/MultiAgentAccelerator/const.d.ts +12 -11
- package/dist/components/MultiAgentAccelerator/const.js +24 -22
- 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/state/TemporaryNetworks.js +12 -21
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/AgentName.d.ts +17 -0
- package/dist/utils/AgentName.js +46 -0
- 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/package.json +7 -6
- package/dist/components/MultiAgentAccelerator/AgentNodePopup.d.ts +0 -30
- package/dist/components/MultiAgentAccelerator/AgentNodePopup.js +0 -80
- package/dist/components/MultiAgentAccelerator/Sidebar/ImportNetworkModal.d.ts +0 -67
- package/dist/components/MultiAgentAccelerator/Sidebar/ImportNetworkModal.js +0 -585
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strip a trailing UUID appended to an agent name or reservation_id, e.g.
|
|
3
|
+
* `copy_cat-hello_world-14ecb260-4389-44f3-afad-ea315dfa1966` → `copy_cat-hello_world`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const removeTrailingUuid: (agentName: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Convert FOO_BAR to more human "Foo Bar".
|
|
8
|
+
* @param agentName Agent name in SNAKE_CASE format.
|
|
9
|
+
* @returns User-friendly agent name.
|
|
10
|
+
*/
|
|
11
|
+
export declare const cleanUpAgentName: (agentName: string) => string;
|
|
12
|
+
/**
|
|
13
|
+
* Beautify a raw agent name for display: strip any trailing UUID and title-case the rest
|
|
14
|
+
* (e.g. `my_network_683b0dfb_4816_464d_9c83_7e59ce6497d3` → `My Network`). With `useNativeNames`
|
|
15
|
+
* on, the raw name is returned verbatim to match the appearance preference honored across the app.
|
|
16
|
+
*/
|
|
17
|
+
export declare const toDisplayName: (rawName: string, useNativeNames?: boolean) => string;
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
/**
|
|
17
|
+
* One-stop shop for turning a raw agent-network name (or reservation_id) into the beautified name
|
|
18
|
+
* shown in the UI.
|
|
19
|
+
*/
|
|
20
|
+
import startCase from "lodash-es/startCase";
|
|
21
|
+
/**
|
|
22
|
+
* Trailing UUID on an agent name or reservation_id.
|
|
23
|
+
*
|
|
24
|
+
* Each separator is `[_-]` because the canonical form is hyphen-delimited (e.g.
|
|
25
|
+
* `copy_cat-hello_world-14ecb260-4389-44f3-afad-ea315dfa1966`), but filename sanitization
|
|
26
|
+
* (`toSafeFilename`, neuro-san exports) flattens those hyphens to underscores. Matching either
|
|
27
|
+
* separator strips the UUID in both forms.
|
|
28
|
+
*/
|
|
29
|
+
const TRAILING_UUID_PATTERN = /[_-][0-9a-fA-F]{8}[_-][0-9a-fA-F]{4}[_-][0-9a-fA-F]{4}[_-][0-9a-fA-F]{4}[_-][0-9a-fA-F]{12}$/u;
|
|
30
|
+
/**
|
|
31
|
+
* Strip a trailing UUID appended to an agent name or reservation_id, e.g.
|
|
32
|
+
* `copy_cat-hello_world-14ecb260-4389-44f3-afad-ea315dfa1966` → `copy_cat-hello_world`.
|
|
33
|
+
*/
|
|
34
|
+
export const removeTrailingUuid = (agentName) => agentName?.replace(TRAILING_UUID_PATTERN, "");
|
|
35
|
+
/**
|
|
36
|
+
* Convert FOO_BAR to more human "Foo Bar".
|
|
37
|
+
* @param agentName Agent name in SNAKE_CASE format.
|
|
38
|
+
* @returns User-friendly agent name.
|
|
39
|
+
*/
|
|
40
|
+
export const cleanUpAgentName = (agentName) => startCase(agentName);
|
|
41
|
+
/**
|
|
42
|
+
* Beautify a raw agent name for display: strip any trailing UUID and title-case the rest
|
|
43
|
+
* (e.g. `my_network_683b0dfb_4816_464d_9c83_7e59ce6497d3` → `My Network`). With `useNativeNames`
|
|
44
|
+
* on, the raw name is returned verbatim to match the appearance preference honored across the app.
|
|
45
|
+
*/
|
|
46
|
+
export const toDisplayName = (rawName, useNativeNames = false) => useNativeNames ? rawName : cleanUpAgentName(removeTrailingUuid(rawName));
|
|
@@ -29,3 +29,10 @@ export declare const useAuthentication: () => {
|
|
|
29
29
|
*
|
|
30
30
|
*/
|
|
31
31
|
export declare const smartSignOut: (currentUser: string, auth0Domain: string, auth0ClientId: string, oidcProvider: OidcProvider) => Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Infer authentication type
|
|
34
|
+
* @param enableAuthentication Flag indicating whether authentication is enabled or not
|
|
35
|
+
* @param currentUser The current user, if any.
|
|
36
|
+
* @param oidcProvider Type of OIDC provider, if there is one.
|
|
37
|
+
*/
|
|
38
|
+
export declare const getAuthenticationType: (enableAuthentication: boolean, currentUser: string, oidcProvider: OidcProvider) => string;
|
|
@@ -16,7 +16,8 @@ limitations under the License.
|
|
|
16
16
|
// See main function comment for more details.
|
|
17
17
|
import { signOut, useSession } from "next-auth/react";
|
|
18
18
|
import { navigateToUrl } from "./BrowserNavigation.js";
|
|
19
|
-
import {
|
|
19
|
+
import { DEFAULT_USER_IMAGE, DEFAULT_USERNAME } from "../const.js";
|
|
20
|
+
import { useEnvironmentStore } from "../state/Environment.js";
|
|
20
21
|
import { useUserInfoStore } from "../state/UserInfo.js";
|
|
21
22
|
/**
|
|
22
23
|
* The Azure AD tenant ID.
|
|
@@ -28,12 +29,17 @@ export const AD_TENANT_ID = "de08c407-19b9-427d-9fe8-edf254300ca7";
|
|
|
28
29
|
* of NextAuth's useSession hook.
|
|
29
30
|
*/
|
|
30
31
|
export const useAuthentication = () => {
|
|
31
|
-
|
|
32
|
+
const enableAuthentication = useEnvironmentStore((state) => state.enableAuthentication);
|
|
33
|
+
if (enableAuthentication === undefined) {
|
|
34
|
+
throw new Error("useAuthentication called before authentication mode was loaded");
|
|
35
|
+
}
|
|
36
|
+
if (!enableAuthentication) {
|
|
32
37
|
// Auth disabled: return a stub
|
|
33
38
|
return { data: { user: { name: DEFAULT_USERNAME, image: DEFAULT_USER_IMAGE } } };
|
|
34
39
|
}
|
|
35
|
-
// Auth
|
|
36
|
-
//
|
|
40
|
+
// Auth mode is runtime configuration, not a build-time constant.
|
|
41
|
+
// This hook relies on the app shell gating render until enableAuthentication is known.
|
|
42
|
+
// Components that can remain mounted while enableAuthentication changes must not use this hook.
|
|
37
43
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
38
44
|
const { data: session } = useSession();
|
|
39
45
|
const { currentUser: albUser, picture: albPicture } = useUserInfoStore();
|
|
@@ -81,7 +87,8 @@ const createAuth0LogoutUrl = (oidcProvider, auth0Domain, auth0ClientId) => {
|
|
|
81
87
|
*
|
|
82
88
|
*/
|
|
83
89
|
export const smartSignOut = async (currentUser, auth0Domain, auth0ClientId, oidcProvider) => {
|
|
84
|
-
|
|
90
|
+
const enableAuthentication = useEnvironmentStore.getState().enableAuthentication;
|
|
91
|
+
if (currentUser === undefined || !enableAuthentication) {
|
|
85
92
|
// Don't know what authentication provider we're using, so just return
|
|
86
93
|
return;
|
|
87
94
|
}
|
|
@@ -101,3 +108,10 @@ export const smartSignOut = async (currentUser, auth0Domain, auth0ClientId, oidc
|
|
|
101
108
|
navigateToUrl(createAuth0LogoutUrl(oidcProvider, auth0Domain, auth0ClientId));
|
|
102
109
|
}
|
|
103
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Infer authentication type
|
|
113
|
+
* @param enableAuthentication Flag indicating whether authentication is enabled or not
|
|
114
|
+
* @param currentUser The current user, if any.
|
|
115
|
+
* @param oidcProvider Type of OIDC provider, if there is one.
|
|
116
|
+
*/
|
|
117
|
+
export const getAuthenticationType = (enableAuthentication, currentUser, oidcProvider) => (enableAuthentication ? (currentUser ? `ALB using ${oidcProvider}` : "NextAuth") : "None");
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for viewing and editing sly_data as JSON.
|
|
3
|
+
*
|
|
4
|
+
* sly_data is the side-channel payload that travels with each request to an agent network. It never reaches the LLM,
|
|
5
|
+
* but coded tools read from and write to it. It is "super loose": any JSON object the agent network cares to define.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A sly_data payload. Deliberately loose: the shape is defined by each agent network, so the UI can only assume
|
|
9
|
+
* "a JSON object".
|
|
10
|
+
*/
|
|
11
|
+
export type SlyData = Record<string, unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* An image found somewhere inside a sly_data payload.
|
|
14
|
+
*/
|
|
15
|
+
export interface SlyDataImage {
|
|
16
|
+
/** Where the image was found, as a readable key path, eg. `"report.charts[0]"` */
|
|
17
|
+
readonly path: string;
|
|
18
|
+
/** The value itself, suitable for use as the `src` of an `img` element */
|
|
19
|
+
readonly src: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The outcome of parsing user-supplied sly_data text.
|
|
23
|
+
* @note Deliberately not a discriminated union: this repo compiles with `strictNullChecks` off, where narrowing on
|
|
24
|
+
* a boolean discriminant is unreliable.
|
|
25
|
+
*/
|
|
26
|
+
export interface SlyDataParseResult {
|
|
27
|
+
/** Why the text cannot be used as sly_data, or undefined if it parsed fine */
|
|
28
|
+
readonly error?: string;
|
|
29
|
+
/** The parsed sly_data. Empty when `error` is set. */
|
|
30
|
+
readonly value: SlyData;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders sly_data as pretty-printed JSON for display in an editor.
|
|
34
|
+
* @param data The sly_data to render. May be undefined, in which case an empty object is rendered.
|
|
35
|
+
* @returns The sly_data as indented JSON text.
|
|
36
|
+
*/
|
|
37
|
+
export declare const formatSlyData: (data?: SlyData) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Parses sly_data text supplied by the user, rejecting anything that is not a JSON object.
|
|
40
|
+
* <br>
|
|
41
|
+
* The root has to be an object because that is what the server expects: sly_data is a map of keys to values, and
|
|
42
|
+
* an array or a primitive at the root cannot be merged with the entries the UI itself supplies (API keys, login...).
|
|
43
|
+
* @param text The text to parse. Empty or whitespace-only text is treated as an empty object.
|
|
44
|
+
* @returns The parsed object, or a message describing why the text is not usable as sly_data.
|
|
45
|
+
*/
|
|
46
|
+
export declare const parseSlyData: (text: string) => SlyDataParseResult;
|
|
47
|
+
/**
|
|
48
|
+
* Finds every value inside a sly_data payload that can be displayed as an image.
|
|
49
|
+
* <br>
|
|
50
|
+
* This is the extension point for image support: agent networks do not yet have an agreed convention for passing
|
|
51
|
+
* images over sly_data, so we recognize the two encodings that are unambiguous today (data URIs and image URLs).
|
|
52
|
+
* Supporting a new encoding means teaching {@link isImageValue} about it -- nothing else needs to change.
|
|
53
|
+
* @param data Any part of a sly_data payload. Objects and arrays are searched recursively.
|
|
54
|
+
* @returns The images found, in document order, capped at a sane maximum.
|
|
55
|
+
*/
|
|
56
|
+
export declare const findImageValues: (data: unknown) => readonly SlyDataImage[];
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 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
|
+
// How many levels deep to look for image values. Deep enough for realistic payloads, shallow enough that a
|
|
17
|
+
// pathological structure can't lock up the browser.
|
|
18
|
+
const MAX_IMAGE_SEARCH_DEPTH = 6;
|
|
19
|
+
// Upper bound on how many images we will display, to keep the dialog usable.
|
|
20
|
+
const MAX_IMAGE_RESULTS = 20;
|
|
21
|
+
// Prefix of a base64-encoded image supplied as a data URI, eg. "data:image/png;base64,iVBORw0KG..."
|
|
22
|
+
const IMAGE_DATA_URI_PREFIX = "data:image/";
|
|
23
|
+
// File extensions we recognize as images when a value is an http(s) URL
|
|
24
|
+
const IMAGE_FILE_EXTENSIONS = [".apng", ".avif", ".bmp", ".gif", ".jpeg", ".jpg", ".png", ".svg", ".webp"];
|
|
25
|
+
/**
|
|
26
|
+
* Renders sly_data as pretty-printed JSON for display in an editor.
|
|
27
|
+
* @param data The sly_data to render. May be undefined, in which case an empty object is rendered.
|
|
28
|
+
* @returns The sly_data as indented JSON text.
|
|
29
|
+
*/
|
|
30
|
+
export const formatSlyData = (data) => JSON.stringify(data ?? {}, null, 2);
|
|
31
|
+
/**
|
|
32
|
+
* Parses sly_data text supplied by the user, rejecting anything that is not a JSON object.
|
|
33
|
+
* <br>
|
|
34
|
+
* The root has to be an object because that is what the server expects: sly_data is a map of keys to values, and
|
|
35
|
+
* an array or a primitive at the root cannot be merged with the entries the UI itself supplies (API keys, login...).
|
|
36
|
+
* @param text The text to parse. Empty or whitespace-only text is treated as an empty object.
|
|
37
|
+
* @returns The parsed object, or a message describing why the text is not usable as sly_data.
|
|
38
|
+
*/
|
|
39
|
+
export const parseSlyData = (text) => {
|
|
40
|
+
const trimmed = text?.trim() ?? "";
|
|
41
|
+
if (trimmed.length === 0) {
|
|
42
|
+
return { value: {} };
|
|
43
|
+
}
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = JSON.parse(trimmed);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return { error: error instanceof Error ? error.message : "Invalid JSON.", value: {} };
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(parsed)) {
|
|
52
|
+
return { error: "Sly data must be a JSON object, not an array.", value: {} };
|
|
53
|
+
}
|
|
54
|
+
if (parsed === null || typeof parsed !== "object") {
|
|
55
|
+
return { error: "Sly data must be a JSON object, not a primitive value.", value: {} };
|
|
56
|
+
}
|
|
57
|
+
return { value: parsed };
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Determines whether a string value looks like something we can display as an image.
|
|
61
|
+
* @param value The string to test.
|
|
62
|
+
* @returns True if the value is an image data URI or an http(s) URL with an image file extension.
|
|
63
|
+
*/
|
|
64
|
+
const isImageValue = (value) => {
|
|
65
|
+
if (value.startsWith(IMAGE_DATA_URI_PREFIX)) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (!value.startsWith("http://") && !value.startsWith("https://")) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
// Ignore any query string or fragment so that eg. "https://example.com/a.png?size=large" still matches
|
|
72
|
+
const withoutQuery = value.split("?", 1)[0].split("#", 1)[0].toLowerCase();
|
|
73
|
+
return IMAGE_FILE_EXTENSIONS.some((extension) => withoutQuery.endsWith(extension));
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Finds every value inside a sly_data payload that can be displayed as an image.
|
|
77
|
+
* <br>
|
|
78
|
+
* This is the extension point for image support: agent networks do not yet have an agreed convention for passing
|
|
79
|
+
* images over sly_data, so we recognize the two encodings that are unambiguous today (data URIs and image URLs).
|
|
80
|
+
* Supporting a new encoding means teaching {@link isImageValue} about it -- nothing else needs to change.
|
|
81
|
+
* @param data Any part of a sly_data payload. Objects and arrays are searched recursively.
|
|
82
|
+
* @returns The images found, in document order, capped at a sane maximum.
|
|
83
|
+
*/
|
|
84
|
+
export const findImageValues = (data) => {
|
|
85
|
+
const found = [];
|
|
86
|
+
const walk = (value, path, depth) => {
|
|
87
|
+
if (depth > MAX_IMAGE_SEARCH_DEPTH || found.length >= MAX_IMAGE_RESULTS) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (typeof value === "string") {
|
|
91
|
+
if (isImageValue(value)) {
|
|
92
|
+
found.push({ path, src: value });
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (Array.isArray(value)) {
|
|
97
|
+
value.forEach((item, index) => walk(item, `${path}[${index}]`, depth + 1));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (value !== null && typeof value === "object") {
|
|
101
|
+
Object.entries(value).forEach(([key, item]) => walk(item, path.length > 0 ? `${path}.${key}` : key, depth + 1));
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
walk(data, "", 0);
|
|
105
|
+
return found;
|
|
106
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognizant-ai-lab/ui-common",
|
|
3
3
|
"description": "A shared UI component library for Cognizant AI Labs projects",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.11.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "yarn clean && yarn generate && yarn run --top-level tsc --project tsconfig.build.json && fix-esm-import-path dist > /dev/null",
|
|
@@ -11,25 +11,26 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@dagrejs/dagre": "1.0.4",
|
|
14
|
-
"@langchain/core": "1.
|
|
14
|
+
"@langchain/core": "1.2.4",
|
|
15
15
|
"@xyflow/react": "12.10.1",
|
|
16
16
|
"http-status": "1.7.3",
|
|
17
17
|
"lodash-es": "4.18.1",
|
|
18
18
|
"notistack": "3.0.2",
|
|
19
19
|
"react-joyride": "3.1.0",
|
|
20
20
|
"react-markdown": "10.1.0",
|
|
21
|
+
"react-resizable-panels": "4.12.2",
|
|
21
22
|
"react-syntax-highlighter": "16.1.0",
|
|
22
23
|
"rehype-raw": "7.0.0",
|
|
23
24
|
"rehype-slug": "6.0.0",
|
|
24
25
|
"remark-gfm": "4.0.1",
|
|
25
|
-
"uuid": "14.0.
|
|
26
|
+
"uuid": "14.0.1",
|
|
26
27
|
"zod": "4.4.3",
|
|
27
28
|
"zustand": "4.5.7"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@mui/icons-material": "9.0.1",
|
|
31
32
|
"@mui/material": "9.0.1",
|
|
32
|
-
"@mui/system": "9.
|
|
33
|
+
"@mui/system": "9.2.0",
|
|
33
34
|
"@mui/x-tree-view": "9.1.0",
|
|
34
35
|
"@testing-library/dom": "10.4.1",
|
|
35
36
|
"@testing-library/react": "16.3.0",
|
|
@@ -55,8 +56,8 @@
|
|
|
55
56
|
"@mui/material": "^9.0.0",
|
|
56
57
|
"@mui/system": "^9.0.0",
|
|
57
58
|
"@mui/x-tree-view": "^9.1.0",
|
|
58
|
-
"next": "^16.
|
|
59
|
-
"next-auth": "5.0.0-beta.
|
|
59
|
+
"next": "^16.3.0",
|
|
60
|
+
"next-auth": "5.0.0-beta.32",
|
|
60
61
|
"react": "^19.2.4",
|
|
61
62
|
"react-dom": "^19.2.4",
|
|
62
63
|
"typescript": "^5.9.3"
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
|
-
export interface AgentNodePopupProps {
|
|
3
|
-
/** The agent's display name — shown read-only in the dialog header area. */
|
|
4
|
-
readonly agentName: string;
|
|
5
|
-
/** Whether the dialog is open. */
|
|
6
|
-
readonly isOpen: boolean;
|
|
7
|
-
/** Called when the user closes or cancels the dialog without saving. */
|
|
8
|
-
readonly onClose: () => void;
|
|
9
|
-
/**
|
|
10
|
-
* Called when the user saves the edited fields.
|
|
11
|
-
* @param agentName The agent's name (unchanged).
|
|
12
|
-
* @param instructions The updated instructions text.
|
|
13
|
-
* @param description The updated description text.
|
|
14
|
-
*/
|
|
15
|
-
readonly onSave: (agentName: string, instructions: string, description: string) => void;
|
|
16
|
-
/** Initial instructions text shown in the editable field. Defaults to an empty string. */
|
|
17
|
-
readonly initialInstructions?: string;
|
|
18
|
-
/** Initial description text shown in the editable field. Defaults to an empty string. */
|
|
19
|
-
readonly initialDescription?: string;
|
|
20
|
-
/** When true the save API call is in-flight; shows an "Applying changes..." button and disables both actions. */
|
|
21
|
-
readonly isSaving?: boolean;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* A popup dialog for viewing and editing an agent node's instructions and description.
|
|
25
|
-
*
|
|
26
|
-
* - Agent name is displayed read-only in the dialog header.
|
|
27
|
-
* - Both instructions and description are editable.
|
|
28
|
-
* - Saving is a no-op until the API endpoint is wired up; `onSave` receives the current values.
|
|
29
|
-
*/
|
|
30
|
-
export declare const AgentNodePopup: FC<AgentNodePopupProps>;
|
|
@@ -1,80 +0,0 @@
|
|
|
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 Box from "@mui/material/Box";
|
|
18
|
-
import Button from "@mui/material/Button";
|
|
19
|
-
import CircularProgress from "@mui/material/CircularProgress";
|
|
20
|
-
import TextField from "@mui/material/TextField";
|
|
21
|
-
import { useEffect, useState } from "react";
|
|
22
|
-
import { ConfirmationModal } from "../Common/ConfirmationModal.js";
|
|
23
|
-
import { MUIDialog } from "../Common/MUIDialog.js";
|
|
24
|
-
// #endregion: Types
|
|
25
|
-
/**
|
|
26
|
-
* A popup dialog for viewing and editing an agent node's instructions and description.
|
|
27
|
-
*
|
|
28
|
-
* - Agent name is displayed read-only in the dialog header.
|
|
29
|
-
* - Both instructions and description are editable.
|
|
30
|
-
* - Saving is a no-op until the API endpoint is wired up; `onSave` receives the current values.
|
|
31
|
-
*/
|
|
32
|
-
export const AgentNodePopup = ({ agentName, isOpen, onClose, onSave, initialInstructions = "", initialDescription = "", isSaving = false, }) => {
|
|
33
|
-
const [instructionsText, setInstructionsText] = useState(initialInstructions);
|
|
34
|
-
const [descriptionText, setDescriptionText] = useState(initialDescription);
|
|
35
|
-
const isDirty = instructionsText !== initialInstructions || descriptionText !== initialDescription;
|
|
36
|
-
const [displayConfirmationModal, setDisplayConfirmationModal] = useState(false);
|
|
37
|
-
// Keep local fields in sync when the dialog opens or if initial values change while open.
|
|
38
|
-
// Guarding on isOpen prevents resetting the text during the close animation, which would cause a visible flash.
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (isOpen) {
|
|
41
|
-
setInstructionsText(initialInstructions);
|
|
42
|
-
setDescriptionText(initialDescription);
|
|
43
|
-
}
|
|
44
|
-
}, [initialInstructions, initialDescription, isOpen]);
|
|
45
|
-
const handleSave = () => {
|
|
46
|
-
onSave(agentName, instructionsText, descriptionText);
|
|
47
|
-
};
|
|
48
|
-
const handleClose = () => {
|
|
49
|
-
if (isSaving) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (isDirty) {
|
|
53
|
-
setDisplayConfirmationModal(true);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
setInstructionsText(initialInstructions);
|
|
57
|
-
setDescriptionText(initialDescription);
|
|
58
|
-
onClose();
|
|
59
|
-
};
|
|
60
|
-
const footer = (_jsx(Box, { sx: {
|
|
61
|
-
display: "flex",
|
|
62
|
-
alignItems: "flex-start",
|
|
63
|
-
justifyContent: "flex-end",
|
|
64
|
-
width: "100%",
|
|
65
|
-
gap: 1,
|
|
66
|
-
}, children: _jsxs(Box, { sx: { display: "flex", gap: 1 }, children: [_jsx(Button, { id: "agent-node-popup-cancel-btn", onClick: handleClose, variant: "outlined", size: "small", disabled: isSaving, children: "Cancel" }), _jsx(Button, { id: "agent-node-popup-save-btn", onClick: handleSave, variant: "contained", size: "small", disabled: isSaving || !isDirty, startIcon: isSaving ? (_jsx(CircularProgress, { size: 14, color: "inherit" })) : undefined, children: isSaving ? "Applying changes..." : "Save" })] }) }));
|
|
67
|
-
const getConfirmationModal = () => (_jsx(ConfirmationModal, { id: "agent-node-popup-unsaved-changes-modal", cancelBtnLabel: "Discard changes", closeable: false, content: _jsx("p", { children: "You have unsaved edits. Are you sure you want to discard your changes and close the dialog?" }), handleCancel: () => {
|
|
68
|
-
setDisplayConfirmationModal(false);
|
|
69
|
-
setInstructionsText(initialInstructions);
|
|
70
|
-
setDescriptionText(initialDescription);
|
|
71
|
-
onClose();
|
|
72
|
-
}, handleOk: handleSave, maskCloseable: false, okBtnLabel: "Save changes", title: "Unsaved Changes" }));
|
|
73
|
-
return (_jsxs(_Fragment, { children: [displayConfirmationModal && getConfirmationModal(), _jsxs(MUIDialog, { footer: footer, id: "agent-node-popup", isOpen: isOpen, onClose: handleClose, paperProps: { minWidth: "480px", maxWidth: "600px", width: "100%" }, title: agentName, children: [_jsx(TextField, { disabled: isSaving, fullWidth: true, id: "agent-node-popup-description-field", label: "Description", multiline: true, onChange: (e) => setDescriptionText(e.target.value), onKeyDown: (e) => {
|
|
74
|
-
if (e.key !== "Escape")
|
|
75
|
-
e.stopPropagation();
|
|
76
|
-
}, placeholder: "Enter a short description of this agent\u2026", rows: 6, slotProps: { htmlInput: { style: { fontSize: "0.85rem" } } }, size: "small", value: descriptionText }), _jsx(TextField, { autoFocus: true, disabled: isSaving, fullWidth: true, id: "agent-node-popup-instructions-field", label: "Instructions", multiline: true, onChange: (e) => setInstructionsText(e.target.value), onKeyDown: (e) => {
|
|
77
|
-
if (e.key !== "Escape")
|
|
78
|
-
e.stopPropagation();
|
|
79
|
-
}, placeholder: "Enter instructions for this agent\u2026", rows: 6, slotProps: { htmlInput: { style: { fontSize: "0.85rem" } } }, size: "small", sx: { marginTop: 2 }, value: instructionsText })] })] }));
|
|
80
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { FC } from "react";
|
|
2
|
-
import { AgentNetworkDefinitionEntry } from "../const.js";
|
|
3
|
-
export declare const IMPORT_MODAL_MAX_FILE_SIZE_BYTES: number;
|
|
4
|
-
export type ImportFileValidation = "valid" | "unsupported_type" | "too_large";
|
|
5
|
-
export interface ImportNetworkModalProps {
|
|
6
|
-
readonly existingNetworkNames?: readonly string[];
|
|
7
|
-
readonly isOpen: boolean;
|
|
8
|
-
readonly onClose: () => void;
|
|
9
|
-
readonly onImport?: (name: string, content: string) => void;
|
|
10
|
-
}
|
|
11
|
-
export interface NetworkSummary {
|
|
12
|
-
readonly agents: number;
|
|
13
|
-
readonly codedTools: number;
|
|
14
|
-
readonly externalAgents: number;
|
|
15
|
-
readonly frontman: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Parse and validate a network definition file. Imports are JSON only.
|
|
19
|
-
*
|
|
20
|
-
* Returns the parsed value on success, or an error message on failure. The value is typed `unknown`,
|
|
21
|
-
* so callers narrow it (see `jsonToNetworkDefinition`) or stringify it as needed.
|
|
22
|
-
*/
|
|
23
|
-
export declare const parseNetworkFileContent: (text: string) => {
|
|
24
|
-
success: true;
|
|
25
|
-
data: unknown;
|
|
26
|
-
} | {
|
|
27
|
-
success: false;
|
|
28
|
-
error: string;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Converts a parsed network definition into an array of AgentNetworkDefinitionEntry objects
|
|
32
|
-
* suitable for sendNetworkDesignerRequest.
|
|
33
|
-
*
|
|
34
|
-
* Expects the top-level array shape — each entry carrying `origin`, `tools`, `display_as`, etc.
|
|
35
|
-
* Anything that isn't an array yields an empty result, and entries without a string `origin`
|
|
36
|
-
* are dropped. The `instructions` and `description` fields are trimmed when present.
|
|
37
|
-
*/
|
|
38
|
-
export declare const jsonToNetworkDefinition: (parsed: unknown) => AgentNetworkDefinitionEntry[];
|
|
39
|
-
export declare const summarizeNetworkDefinition: (networkDef: AgentNetworkDefinitionEntry[]) => NetworkSummary;
|
|
40
|
-
export declare const formatFileSize: (bytes: number) => string;
|
|
41
|
-
/**
|
|
42
|
-
* Validate a selected file against the advertised constraints before reading it.
|
|
43
|
-
*
|
|
44
|
-
* The `<input accept>` attribute only filters the file-picker dialog and is bypassed
|
|
45
|
-
* entirely by drag/drop, so we re-check the extension here. We also enforce the
|
|
46
|
-
* advertised size limit — purely a client-side guard so a pathological file can't be
|
|
47
|
-
* fed into the synchronous parsing/regex pass and freeze the UI; the server imposes
|
|
48
|
-
* no such limit.
|
|
49
|
-
*
|
|
50
|
-
* Returns a status the caller can branch on; rendering a message is left to the caller
|
|
51
|
-
* (see `importFileValidationMessage`).
|
|
52
|
-
*/
|
|
53
|
-
export declare const validateImportFile: (file: File) => ImportFileValidation;
|
|
54
|
-
export declare const importFileValidationMessage: (validation: ImportFileValidation, file: File) => string | null;
|
|
55
|
-
/** Convert a filename stem to a display-friendly network name.
|
|
56
|
-
*
|
|
57
|
-
* Strips a trailing UUID that neuro-san appends to exported filenames (e.g.
|
|
58
|
-
* `my_network_683b0dfb_4816_464d_9c83_7e59ce6497d3.json` → `My Network`).
|
|
59
|
-
*/
|
|
60
|
-
export declare const filenameToNetworkName: (filename: string) => string;
|
|
61
|
-
/** Pick the first non-colliding name by appending an incrementing index (" 2", " 3", …).
|
|
62
|
-
*
|
|
63
|
-
* Starts at 2 and skips any index already in use, so importing "My Network" alongside an existing
|
|
64
|
-
* "My Network" yields "My Network (2)" — or "My Network (3)" if "My Network (2)" is also taken.
|
|
65
|
-
*/
|
|
66
|
-
export declare const nextAvailableNetworkName: (baseName: string, existingNames: readonly string[]) => string;
|
|
67
|
-
export declare const ImportNetworkModal: FC<ImportNetworkModalProps>;
|