@cognizant-ai-lab/ui-common 1.9.0 → 1.10.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 +5 -4
- package/dist/components/AgentChat/ChatCommon/Thinking.js +2 -2
- package/dist/components/AgentChat/Common/Utils.d.ts +0 -11
- package/dist/components/AgentChat/Common/Utils.js +0 -16
- package/dist/components/Common/Footer.js +4 -0
- package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.js +56 -24
- 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/MultiAgentAccelerator.js +9 -56
- 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 +7 -6
- 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 +2 -2
- package/dist/components/MultiAgentAccelerator/const.d.ts +11 -11
- package/dist/components/MultiAgentAccelerator/const.js +22 -22
- 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/package.json +1 -1
- 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));
|
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.10.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",
|
|
@@ -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>;
|