@cognizant-ai-lab/ui-common 1.10.0 → 1.12.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 (56) hide show
  1. package/dist/components/AgentChat/ChatCommon/ChatCommon.d.ts +5 -0
  2. package/dist/components/AgentChat/ChatCommon/ChatCommon.js +28 -7
  3. package/dist/components/AgentChat/ChatCommon/Const.d.ts +1 -0
  4. package/dist/components/AgentChat/ChatCommon/Const.js +2 -0
  5. package/dist/components/AgentChat/ChatCommon/SlyDataDialog.d.ts +34 -0
  6. package/dist/components/AgentChat/ChatCommon/SlyDataDialog.js +187 -0
  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/Common/ConfirmationModal.d.ts +3 -2
  10. package/dist/components/Common/GoogleAnalytics.d.ts +16 -0
  11. package/dist/components/Common/GoogleAnalytics.js +32 -0
  12. package/dist/components/Common/Navbar.d.ts +2 -1
  13. package/dist/components/Common/Navbar.js +3 -3
  14. package/dist/components/ErrorPage/ErrorPage.js +4 -4
  15. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.d.ts +7 -7
  16. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.js +143 -390
  17. package/dist/components/MultiAgentAccelerator/Editor/AgentNodeEditor.d.ts +24 -0
  18. package/dist/components/MultiAgentAccelerator/Editor/AgentNodeEditor.js +128 -0
  19. package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.d.ts +21 -0
  20. package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.js +305 -0
  21. package/dist/components/MultiAgentAccelerator/MultiAgentAccelerator.js +109 -62
  22. package/dist/components/MultiAgentAccelerator/NeuroSanStudioCallout.d.ts +2 -0
  23. package/dist/components/MultiAgentAccelerator/NeuroSanStudioCallout.js +38 -0
  24. package/dist/components/MultiAgentAccelerator/PanelSeparator.d.ts +5 -0
  25. package/dist/components/MultiAgentAccelerator/PanelSeparator.js +46 -0
  26. package/dist/components/MultiAgentAccelerator/Sidebar/Sidebar.js +4 -3
  27. package/dist/components/MultiAgentAccelerator/Tour/MainTourSteps.js +8 -6
  28. package/dist/components/MultiAgentAccelerator/const.d.ts +1 -0
  29. package/dist/components/MultiAgentAccelerator/const.js +2 -0
  30. package/dist/components/Settings/ApiKeyErrorBanner.d.ts +22 -0
  31. package/dist/components/Settings/ApiKeyErrorBanner.js +26 -0
  32. package/dist/components/Settings/ApiKeyInput.d.ts +5 -2
  33. package/dist/components/Settings/ApiKeyInput.js +10 -4
  34. package/dist/components/Settings/SettingsDialog.js +22 -5
  35. package/dist/const.d.ts +0 -1
  36. package/dist/const.js +0 -1
  37. package/dist/controller/llm/Providers.d.ts +19 -2
  38. package/dist/controller/llm/Providers.js +45 -31
  39. package/dist/state/Announcements.d.ts +24 -0
  40. package/dist/state/Announcements.js +29 -0
  41. package/dist/state/ChatHistory.d.ts +10 -1
  42. package/dist/state/ChatHistory.js +8 -0
  43. package/dist/state/Environment.d.ts +2 -0
  44. package/dist/state/Environment.js +2 -0
  45. package/dist/state/Settings.d.ts +14 -0
  46. package/dist/state/Settings.js +6 -2
  47. package/dist/tsconfig.build.tsbuildinfo +1 -1
  48. package/dist/utils/Authentication.d.ts +7 -0
  49. package/dist/utils/Authentication.js +19 -5
  50. package/dist/utils/SlyData.d.ts +56 -0
  51. package/dist/utils/SlyData.js +106 -0
  52. package/dist/utils/SlyDataSchema.d.ts +31 -0
  53. package/dist/utils/SlyDataSchema.js +149 -0
  54. package/package.json +9 -8
  55. package/dist/components/MultiAgentAccelerator/AgentNodePopup.d.ts +0 -30
  56. package/dist/components/MultiAgentAccelerator/AgentNodePopup.js +0 -80
@@ -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 { authenticationEnabled, DEFAULT_USER_IMAGE, DEFAULT_USERNAME } from "../const.js";
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
- if (!authenticationEnabled()) {
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 enabled: safe to call hooks. Despite the conditional test above, we are guaranteed that
36
- // authenticationEnabled is constant for a given build, so we won't be violating the rules of hooks.
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
- if (currentUser === undefined || !authenticationEnabled()) {
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
+ };
@@ -0,0 +1,31 @@
1
+ import { SlyData } from "./SlyData.js";
2
+ /**
3
+ * A top-level sly_data key advertised by the network, in a shape ready for display.
4
+ */
5
+ export interface SlyDataSchemaEntry {
6
+ /** What the key is for, verbatim from the schema */
7
+ readonly description?: string;
8
+ /** True if the key appears in the schema's root `required` list */
9
+ readonly isRequired: boolean;
10
+ /** The property name, verbatim. Any string is legal here -- some networks use URLs as keys. */
11
+ readonly key: string;
12
+ /** The declared type name (neuro-san writes "int"/"float"/"string"/"bool"), or "object" when only inferable */
13
+ readonly type?: string;
14
+ }
15
+ /**
16
+ * Lists the top-level sly_data keys a network advertises, for display to the user.
17
+ * @param schema The network's sly_data_schema, as returned by the function endpoint. May be anything.
18
+ * @param excludeKeys Keys to leave out: the ones the UI itself supplies at send time (API keys, login...), which
19
+ * the user should not be prompted for.
20
+ * @returns One entry per declared key in declaration order, or an empty array when the schema is unusable.
21
+ */
22
+ export declare const describeSlyDataSchema: (schema: unknown, excludeKeys?: readonly string[]) => readonly SlyDataSchemaEntry[];
23
+ /**
24
+ * Builds a sly_data skeleton from the network's schema, layered under the user's existing values.
25
+ * @param schema The network's sly_data_schema. May be anything; an unusable schema returns `existing` untouched.
26
+ * @param existing The current sly_data. Every existing key survives verbatim; the template only adds what is missing.
27
+ * @param excludeKeys Top-level keys never to seed: the ones the UI supplies at send time. Keeping these out matters
28
+ * for more than tidiness -- `llm_config` holds API keys, which must never be led into the persistent store.
29
+ * @returns A new object; the input is not mutated.
30
+ */
31
+ export declare const buildSlyDataTemplate: (schema: unknown, existing: SlyData, excludeKeys?: readonly string[]) => SlyData;
@@ -0,0 +1,149 @@
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
+ import * as z from "zod";
17
+ /**
18
+ * Helpers for reading an agent network's `sly_data_schema`.
19
+ *
20
+ * A network's front man may advertise the sly_data it expects via `sly_data_schema` (see the neuro-san agent hocon
21
+ * reference). The document is OpenAI-tool-style JSON Schema -- `type`/`properties`/`required`/`description` -- with
22
+ * one quirk: scalar types use neuro-san's names `"int"`, `"float"`, `"string"`, `"bool"` rather than the JSON Schema
23
+ * names. Everything here is defensive: the schema is server-supplied data, and a malformed one must degrade to
24
+ * "no schema" rather than break the sly_data editor.
25
+ */
26
+ // How many levels of nested objects a template will materialize. Deep enough for every published schema
27
+ // (mcp-style http_headers nest three levels), shallow enough that a pathological schema cannot recurse away.
28
+ const MAX_TEMPLATE_DEPTH = 5;
29
+ // Default template value for each recognized scalar type name. Neuro-san's names are canonical, but the
30
+ // JSON Schema spellings cost nothing to accept and schema authors do write them.
31
+ const SCALAR_TYPE_DEFAULTS = {
32
+ bool: false,
33
+ boolean: false,
34
+ double: 0,
35
+ float: 0,
36
+ int: 0,
37
+ integer: 0,
38
+ number: 0,
39
+ string: "",
40
+ };
41
+ /**
42
+ * One node of a sly_data_schema document. Loose on purpose: extra keys are the schema author's business.
43
+ * The recursion mirrors JSON Schema's -- an object node describes its keys under `properties`.
44
+ */
45
+ const SchemaNode = z.looseObject({
46
+ description: z.string().optional(),
47
+ get properties() {
48
+ return z.record(z.string(), SchemaNode).optional();
49
+ },
50
+ required: z.array(z.string()).optional(),
51
+ type: z.string().optional(),
52
+ });
53
+ /**
54
+ * Whether a schema node describes an object. An explicit `type: "object"` counts, and so does an untyped node
55
+ * that declares `properties` -- schema authors routinely omit the redundant `type`.
56
+ * @param node The schema node to examine.
57
+ * @returns True if the node describes an object value.
58
+ */
59
+ const isObjectNode = (node) => node.type === "object" || (node.type === undefined && node.properties !== undefined);
60
+ /**
61
+ * Validates a server-supplied sly_data_schema and returns its root node, or null if there is nothing usable.
62
+ * A root is usable when it is object-shaped and declares at least one property.
63
+ * @param schema The sly_data_schema as received from the server. May be anything.
64
+ * @returns The validated root node, or null when the schema is absent or unusable.
65
+ */
66
+ const parseSchemaRoot = (schema) => {
67
+ if (schema === undefined || schema === null) {
68
+ return null;
69
+ }
70
+ const parsed = SchemaNode.safeParse(schema);
71
+ if (!parsed.success || !isObjectNode(parsed.data) || Object.keys(parsed.data.properties ?? {}).length === 0) {
72
+ // A bad schema is the network author's bug, not the user's: degrade to the schema-less experience.
73
+ console.warn("Ignoring unusable sly_data_schema:", schema);
74
+ return null;
75
+ }
76
+ return parsed.data;
77
+ };
78
+ /**
79
+ * Lists the top-level sly_data keys a network advertises, for display to the user.
80
+ * @param schema The network's sly_data_schema, as returned by the function endpoint. May be anything.
81
+ * @param excludeKeys Keys to leave out: the ones the UI itself supplies at send time (API keys, login...), which
82
+ * the user should not be prompted for.
83
+ * @returns One entry per declared key in declaration order, or an empty array when the schema is unusable.
84
+ */
85
+ export const describeSlyDataSchema = (schema, excludeKeys = []) => {
86
+ const root = parseSchemaRoot(schema);
87
+ if (root === null) {
88
+ return [];
89
+ }
90
+ const required = new Set(root.required);
91
+ return Object.entries(root.properties)
92
+ .filter(([key]) => !excludeKeys.includes(key))
93
+ .map(([key, node]) => ({
94
+ description: node.description,
95
+ isRequired: required.has(key),
96
+ key,
97
+ type: node.type ?? (isObjectNode(node) ? "object" : undefined),
98
+ }));
99
+ };
100
+ /**
101
+ * Produces the template value for one schema node, folding in whatever the user already has.
102
+ * An existing value always wins -- even one that contradicts the schema -- because a template must never
103
+ * destroy user input. Objects are merged recursively so a partially-filled nested value gains its missing keys.
104
+ * @param node The schema node describing this value.
105
+ * @param existing The value currently at this position, or undefined if there is none.
106
+ * @param depth How many object levels deep this node is, for the recursion cap.
107
+ * @returns The existing value, or a default appropriate for the declared type when there is none.
108
+ */
109
+ const templateValue = (node, existing, depth) => {
110
+ if (isObjectNode(node)) {
111
+ if (existing !== undefined && (existing === null || typeof existing !== "object" || Array.isArray(existing))) {
112
+ return existing;
113
+ }
114
+ if (depth >= MAX_TEMPLATE_DEPTH) {
115
+ return existing ?? {};
116
+ }
117
+ const merged = { ...existing };
118
+ Object.entries(node.properties ?? {}).forEach(([key, child]) => {
119
+ merged[key] = templateValue(child, merged[key], depth + 1);
120
+ });
121
+ return merged;
122
+ }
123
+ if (existing !== undefined) {
124
+ return existing;
125
+ }
126
+ // A type we do not understand maps to null: "fill me in" without guessing a shape
127
+ return SCALAR_TYPE_DEFAULTS[node.type] ?? null;
128
+ };
129
+ /**
130
+ * Builds a sly_data skeleton from the network's schema, layered under the user's existing values.
131
+ * @param schema The network's sly_data_schema. May be anything; an unusable schema returns `existing` untouched.
132
+ * @param existing The current sly_data. Every existing key survives verbatim; the template only adds what is missing.
133
+ * @param excludeKeys Top-level keys never to seed: the ones the UI supplies at send time. Keeping these out matters
134
+ * for more than tidiness -- `llm_config` holds API keys, which must never be led into the persistent store.
135
+ * @returns A new object; the input is not mutated.
136
+ */
137
+ export const buildSlyDataTemplate = (schema, existing, excludeKeys = []) => {
138
+ const root = parseSchemaRoot(schema);
139
+ if (root === null) {
140
+ return existing;
141
+ }
142
+ const merged = { ...existing };
143
+ Object.entries(root.properties)
144
+ .filter(([key]) => !excludeKeys.includes(key))
145
+ .forEach(([key, node]) => {
146
+ merged[key] = templateValue(node, merged[key], 1);
147
+ });
148
+ return merged;
149
+ };
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.10.0",
4
+ "version": "1.12.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.1.17",
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.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.1.2",
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",
@@ -42,11 +43,11 @@
42
43
  "fake-indexeddb": "6.2.5",
43
44
  "fix-esm-import-path": "1.10.3",
44
45
  "globals": "17.4.0",
45
- "openapi-typescript": "7.8.0",
46
+ "openapi-typescript": "7.13.0",
46
47
  "react": "19.2.4",
47
48
  "react-dom": "19.2.4",
48
49
  "typescript": "5.9.3",
49
- "vitest": "4.1.10"
50
+ "vitest": "4.1.11"
50
51
  },
51
52
  "peerDependencies": {
52
53
  "@emotion/react": "^11.14.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.2.6",
59
- "next-auth": "5.0.0-beta.30",
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
- };