@epam/ai-dial-mcp-apps 1.4.0-dev.146 → 1.4.0-dev.150

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.
@@ -23,6 +23,12 @@ export interface McpAppInlinePreviewProps {
23
23
  loadErrorLabel: string;
24
24
  /** Accessible label of the spinner shown while the app loads. Defaults to `'Loading app'`. */
25
25
  loadingAriaLabel?: string;
26
+ /**
27
+ * Called with the error when the renderer fails to load or throws while
28
+ * rendering, so the host can log it; the preview then shows
29
+ * `loadErrorLabel`.
30
+ */
31
+ onRendererError?: (error: Error) => void;
26
32
  /**
27
33
  * Whether this message's MCP App is currently open in the full-width
28
34
  * canvas. When `true`, the header stays (so the tool/app identity is still
@@ -1 +1 @@
1
- {"version":3,"file":"McpAppInlinePreview.d.ts","sourceRoot":"","sources":["../../../src/components/McpAppInlinePreview/McpAppInlinePreview.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAG/B,qDAAqD;AACrD,MAAM,WAAW,wBAAwB;IACvC,uCAAuC;IACvC,KAAK,EAAE,aAAa,CAAC;IACrB,sFAAsF;IACtF,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,uIAAuI;IACvI,KAAK,EAAE,mBAAmB,CAAC;IAC3B,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,6GAA6G;IAC7G,WAAW,EAAE,iBAAiB,CAAC;IAC/B,kEAAkE;IAClE,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,wDAAwD;IACxD,eAAe,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,eAAe,EAAE,MAAM,CAAC;IACxB,uFAAuF;IACvF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,oFAAoF;IACpF,cAAc,EAAE,MAAM,CAAC;IACvB,8FAA8F;IAC9F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,4EAA4E;IAC5E,mBAAmB,EAAE,MAAM,CAAC;IAC5B,8EAA8E;IAC9E,MAAM,CAAC,EAAE,yBAAyB,CAAC;IACnC,sEAAsE;IACtE,UAAU,CAAC,EAAE,6BAA6B,CAAC;CAC5C;AA0MD,iHAAiH;AACjH,eAAO,MAAM,mBAAmB,gEAAgC,CAAC"}
1
+ {"version":3,"file":"McpAppInlinePreview.d.ts","sourceRoot":"","sources":["../../../src/components/McpAppInlinePreview/McpAppInlinePreview.tsx"],"names":[],"mappings":"AA+BA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAuB/B,qDAAqD;AACrD,MAAM,WAAW,wBAAwB;IACvC,uCAAuC;IACvC,KAAK,EAAE,aAAa,CAAC;IACrB,sFAAsF;IACtF,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,uIAAuI;IACvI,KAAK,EAAE,mBAAmB,CAAC;IAC3B,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,6GAA6G;IAC7G,WAAW,EAAE,iBAAiB,CAAC;IAC/B,kEAAkE;IAClE,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,wDAAwD;IACxD,eAAe,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,eAAe,EAAE,MAAM,CAAC;IACxB,uFAAuF;IACvF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,oFAAoF;IACpF,cAAc,EAAE,MAAM,CAAC;IACvB,8FAA8F;IAC9F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACzC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,4EAA4E;IAC5E,mBAAmB,EAAE,MAAM,CAAC;IAC5B,8EAA8E;IAC9E,MAAM,CAAC,EAAE,yBAAyB,CAAC;IACnC,sEAAsE;IACtE,UAAU,CAAC,EAAE,6BAA6B,CAAC;CAC5C;AAyOD,iHAAiH;AACjH,eAAO,MAAM,mBAAmB,gEAAgC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { Component, ReactNode } from 'react';
2
+ /** Props for the internal `RendererLoadBoundary`. */
3
+ export interface RendererLoadBoundaryProps {
4
+ /** The lazily loaded renderer. */
5
+ children: ReactNode;
6
+ /** Called once with the thrown error when loading or rendering `children` fails. */
7
+ onError: (error: Error) => void;
8
+ }
9
+ interface RendererLoadBoundaryState {
10
+ hasError: boolean;
11
+ }
12
+ /**
13
+ * Catches a rejected renderer import (or a render error) under
14
+ * `McpAppInlinePreview` and reports it through `onError`, rendering nothing
15
+ * itself: the preview shows its own error state, so the announcing
16
+ * `LiveRegion` stays outside this boundary. The preview keys it on its load
17
+ * attempt, so a reload remounts it with a fresh import.
18
+ */
19
+ export declare class RendererLoadBoundary extends Component<RendererLoadBoundaryProps, RendererLoadBoundaryState> {
20
+ state: RendererLoadBoundaryState;
21
+ static getDerivedStateFromError(): RendererLoadBoundaryState;
22
+ componentDidCatch(error: unknown): void;
23
+ render(): ReactNode;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=RendererLoadBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RendererLoadBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/RendererLoadBoundary/RendererLoadBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD,qDAAqD;AACrD,MAAM,WAAW,yBAAyB;IACxC,kCAAkC;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB,oFAAoF;IACpF,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACjC;AAED,UAAU,yBAAyB;IACjC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,SAAS,CACjD,yBAAyB,EACzB,yBAAyB,CAC1B;IACU,KAAK,EAAE,yBAAyB,CAAuB;IAEhE,MAAM,CAAC,wBAAwB,IAAI,yBAAyB;IAInD,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAMvC,MAAM,IAAI,SAAS;CAG7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"useMcpAppInlinePreview.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMcpAppInlinePreview/useMcpAppInlinePreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACvB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAM/B,kDAAkD;AAClD,MAAM,WAAW,wBAAwB;IACvC,iDAAiD;IACjD,MAAM,EAAE,yBAAyB,CAAC;IAClC,6CAA6C;IAC7C,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,+FAA+F;IAC/F,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,sLAAsL;IACtL,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,aAAa,GAAG,SAAS,EAChC,UAAU,kBAAkB,GAAG,SAAS,EACxC,OAAO,mBAAmB,EAC1B,UAAU,MAAM,EAChB,aAAa,iBAAiB,EAC9B,uBAAuB,CAAC,IAAI,EAAE,iBAAiB,KAAK,iBAAiB,GAAG,IAAI,KAC3E,wBAmHF,CAAC"}
1
+ {"version":3,"file":"useMcpAppInlinePreview.d.ts","sourceRoot":"","sources":["../../../src/hooks/useMcpAppInlinePreview/useMcpAppInlinePreview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AAe/B,kDAAkD;AAClD,MAAM,WAAW,wBAAwB;IACvC,iDAAiD;IACjD,MAAM,EAAE,yBAAyB,CAAC;IAClC,6CAA6C;IAC7C,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,+FAA+F;IAC/F,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,sLAAsL;IACtL,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,aAAa,GAAG,SAAS,EAChC,UAAU,kBAAkB,GAAG,SAAS,EACxC,OAAO,mBAAmB,EAC1B,UAAU,MAAM,EAChB,aAAa,iBAAiB,EAC9B,uBAAuB,CAAC,IAAI,EAAE,iBAAiB,KAAK,iBAAiB,GAAG,IAAI,KAC3E,wBAmHF,CAAC"}
package/index.css CHANGED
@@ -1,3 +1,3 @@
1
1
  ._preview_1xqr3_10{background:var(--mcpapp-preview-bg,var(--bg-layer-raised,#fcfcfc));border-color:var(--mcpapp-preview-border,var(--stroke-tertiary,#e0e6f0))}._previewHeader_1xqr3_22{border-bottom-color:var(--mcpapp-preview-header-border,var(--stroke-tertiary,#e0e6f0))}._headerText_1xqr3_26{color:var(--mcpapp-header-text,var(--text-secondary,#57647a))}._placeholderText_1xqr3_30{color:var(--mcpapp-placeholder-text,var(--text-secondary,#57647a))}._errorIcon_1xqr3_34{color:var(--mcpapp-error-icon,var(--text-error,#ae2f2f))}._errorText_1xqr3_38{color:var(--mcpapp-error-text,var(--text-primary,#161b2d))}
2
2
  /*$vite$:1*//*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
3
- @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid}}}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.mx-1\.5{margin-inline:.375rem}.block{display:block}.flex{display:flex}.inline{display:inline}.inline-block{display:inline-block}.h-3{height:.75rem}.min-h-10{min-height:2.5rem}.min-h-\[100px\]{min-height:100px}.w-0{width:0}.w-full{width:100%}.min-w-0{min-width:0}.shrink-0{flex-shrink:0}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.overflow-hidden{overflow:hidden}.rounded-xl{border-radius:.75rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-s{border-inline-start-style:var(--tw-border-style);border-inline-start-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-current{border-color:currentColor}.p-4{padding:1rem}.px-4{padding-inline:1rem}.py-2{padding-block:.5rem}.text-center{text-align:center}.align-middle{vertical-align:middle}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}
3
+ @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid}}}.absolute{position:absolute}.relative{position:relative}.static{position:static}.inset-0{inset:0}.mx-1\.5{margin-inline:.375rem}.block{display:block}.flex{display:flex}.inline{display:inline}.inline-block{display:inline-block}.h-3{height:.75rem}.min-h-10{min-height:2.5rem}.min-h-\[100px\]{min-height:100px}.w-0{width:0}.w-full{width:100%}.min-w-0{min-width:0}.shrink-0{flex-shrink:0}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.overflow-hidden{overflow:hidden}.rounded-xl{border-radius:.75rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-s{border-inline-start-style:var(--tw-border-style);border-inline-start-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-current{border-color:currentColor}.p-4{padding:1rem}.px-4{padding-inline:1rem}.py-2{padding-block:.5rem}.text-center{text-align:center}.align-middle{vertical-align:middle}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}
package/index.js CHANGED
@@ -1,27 +1,26 @@
1
- import { AttachmentContentType as e, McpAppCanvasRenderer as t } from "@epam/ai-dial-attachment-canvas";
2
- import { MessageRole as n, buildCssVars as r } from "@epam/ai-dial-chat-shared";
3
- import { DIAL_ICON_SIZE as i, DIAL_KIT_ICON_STROKE as a, ElementSize as o, EllipsisTooltip as s, GhostIconButton as c, LiveRegion as l, LiveRegionElement as u, Spinner as d, mergeClasses as f } from "@epam/ai-dial-ui-kit";
4
- import { IconAlertTriangle as p, IconArrowsMaximize as m, IconRefresh as h } from "@tabler/icons-react";
5
- import { memo as g, useCallback as _, useEffect as v, useMemo as y, useRef as b, useState as x } from "react";
6
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
1
+ import { MessageRole as e, buildCssVars as t } from "@epam/ai-dial-chat-shared";
2
+ import { DIAL_ICON_SIZE as n, DIAL_KIT_ICON_STROKE as r, ElementSize as i, EllipsisTooltip as a, GhostIconButton as o, LiveRegion as s, LiveRegionElement as c, Spinner as l, mergeClasses as u } from "@epam/ai-dial-ui-kit";
3
+ import { IconAlertTriangle as d, IconArrowsMaximize as f, IconRefresh as p } from "@tabler/icons-react";
4
+ import { Component as m, Suspense as h, lazy as g, memo as _, useCallback as v, useEffect as y, useMemo as b, useRef as x, useState as S } from "react";
5
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
7
6
  //#region src/constants/public-class-names.ts
8
- var T = {
7
+ var E = {
9
8
  preview: "dial-mcp-apps-preview",
10
9
  previewHeader: "dial-mcp-apps-preview-header"
11
- }, E = /* @__PURE__ */ function(e) {
10
+ }, D = /* @__PURE__ */ function(e) {
12
11
  return e.Loading = "loading", e.Ready = "ready", e.Error = "error", e.Unavailable = "unavailable", e;
13
- }({}), D = /* @__PURE__ */ function(e) {
14
- return e.Toolset = "toolset", e.Application = "application", e;
15
12
  }({}), O = /* @__PURE__ */ function(e) {
13
+ return e.Toolset = "toolset", e.Application = "application", e;
14
+ }({}), k = /* @__PURE__ */ function(e) {
16
15
  return e.Direct = "direct", e.Indirect = "indirect", e;
17
- }({}), k = 500, A = 500, j = (e) => new Promise((t) => setTimeout(t, e)), M = (e) => {
16
+ }({}), A = 500, j = 500, M = (e) => new Promise((t) => setTimeout(t, e)), N = (e) => {
18
17
  try {
19
18
  let t = JSON.parse(e);
20
19
  return typeof t == "object" && t ? t : {};
21
20
  } catch {
22
21
  return {};
23
22
  }
24
- }, N = (e) => {
23
+ }, P = (e) => {
25
24
  let t = /* @__PURE__ */ new Map();
26
25
  for (let n of e?.tool_messages ?? []) {
27
26
  for (let e of n.tool_calls ?? []) t.set(e.id, {
@@ -36,7 +35,7 @@ var T = {
36
35
  for (let n of e?.tool_execution_history ?? []) {
37
36
  for (let e of n.tool_calls ?? []) t.set(e.id, {
38
37
  name: e.function.name,
39
- args: M(e.function.arguments)
38
+ args: N(e.function.arguments)
40
39
  });
41
40
  if (n.role === "tool" && n.tool_call_id) {
42
41
  let e = t.get(n.tool_call_id);
@@ -44,21 +43,21 @@ var T = {
44
43
  }
45
44
  }
46
45
  return t;
47
- }, P = /[^a-zA-Z0-9_-]+/g, F = 64, I = (e) => {
48
- let t = e.replace(P, "_");
49
- return t !== "" && !/^[a-zA-Z_]/.test(t) && (t = `_${t}`), t.slice(0, F);
50
- }, L = (e) => {
46
+ }, F = /[^a-zA-Z0-9_-]+/g, I = 64, L = (e) => {
47
+ let t = e.replace(F, "_");
48
+ return t !== "" && !/^[a-zA-Z_]/.test(t) && (t = `_${t}`), t.slice(0, I);
49
+ }, R = (e) => {
51
50
  let t = /* @__PURE__ */ new Set();
52
- for (let n of e) for (let e of N(n.custom_content?.state).values()) t.add(e.name);
51
+ for (let n of e) for (let e of P(n.custom_content?.state).values()) t.add(e.name);
53
52
  return t;
54
- }, R = (e, t) => {
55
- if (t.length === 0 || e.role !== n.Assistant) return;
56
- let r = new Set([...N(e.custom_content?.state).values()].filter((e) => e.result != null).map((e) => e.name));
57
- return t.find((e) => r.has(e.toolName)) || t.find((e) => e.discovery === O.Direct);
58
- }, z = (e) => `${e}:mcp-app`, B = (e) => e == null ? void 0 : JSON.stringify(e.toolInput ?? null), V = (e, t) => {
53
+ }, z = (t, n) => {
54
+ if (n.length === 0 || t.role !== e.Assistant) return;
55
+ let r = new Set([...P(t.custom_content?.state).values()].filter((e) => e.result != null).map((e) => e.name));
56
+ return n.find((e) => r.has(e.toolName)) || n.find((e) => e.discovery === k.Direct);
57
+ }, B = (e) => `${e}:mcp-app`, V = (e) => e == null ? void 0 : JSON.stringify(e.toolInput ?? null), H = (e, t) => {
59
58
  let n = e.custom_content?.state;
60
59
  if (!n) return;
61
- let r = [...N(n).values()].reverse().find((e) => e.name === t);
60
+ let r = [...P(n).values()].reverse().find((e) => e.name === t);
62
61
  if (r) return {
63
62
  toolInput: r.args,
64
63
  toolResult: r.result == null ? void 0 : { content: [{
@@ -66,210 +65,235 @@ var T = {
66
65
  text: r.result
67
66
  }] }
68
67
  };
69
- }, H = async (e, t, n) => {
70
- if (e.discovery !== O.Direct && t?.toolInput == null) return t?.toolResult;
68
+ }, U = async (e, t, n) => {
69
+ if (e.discovery !== k.Direct && t?.toolInput == null) return t?.toolResult;
71
70
  let r = () => n(e.toolsetId, e.mcpToolName, t?.toolInput ?? {}, e.kind);
72
71
  try {
73
72
  return await r();
74
73
  } catch {
75
- await j(k + Math.random() * A);
74
+ await M(A + Math.random() * j);
76
75
  }
77
76
  try {
78
77
  return await r();
79
78
  } catch {
80
79
  return t?.toolResult;
81
80
  }
82
- }, U = (t, n, r, i, a, o) => {
83
- let { hostContext: s, hostInfo: c, sandboxUrl: l, fetchResourceHtml: u, callTool: d } = a, [f, p] = x(), [m, h] = x(), [g, y] = x(), S = b(n);
84
- v(() => {
85
- S.current = n;
81
+ }, W = "mcp_app", G = (e, t, n, r, i, a) => {
82
+ let { hostContext: o, hostInfo: s, sandboxUrl: c, fetchResourceHtml: l, callTool: u } = i, [d, f] = S(), [p, m] = S(), [h, g] = S(), _ = x(t);
83
+ y(() => {
84
+ _.current = t;
86
85
  });
87
- let C = B(n), [w, T] = x(() => t == null || l == null ? E.Unavailable : E.Loading), [D, O] = x(0), k = _(() => {
88
- r.invalidate(i), O((e) => e + 1);
89
- }, [r, i]), A = _(async (e) => {
90
- if (t != null && l != null) try {
91
- let n = S.current, { html: a, toolResult: o } = await r.getOrFetch(i, C, async () => {
92
- let [e, r] = await Promise.all([u(t.toolsetId, t.resourceUri), H(t, n, d)]);
86
+ let b = V(t), [C, w] = S(() => e == null || c == null ? D.Unavailable : D.Loading), [T, E] = S(0), O = v(() => {
87
+ n.invalidate(r), E((e) => e + 1);
88
+ }, [n, r]), k = v(async (t) => {
89
+ if (e != null && c != null) try {
90
+ let i = _.current, { html: a, toolResult: o } = await n.getOrFetch(r, b, async () => {
91
+ let [t, n] = await Promise.all([l(e.toolsetId, e.resourceUri), U(e, i, u)]);
93
92
  return {
94
- html: e,
95
- toolResult: r
93
+ html: t,
94
+ toolResult: n
96
95
  };
97
96
  });
98
- if (e()) return;
99
- p(a), h(n?.toolInput), y(o), T(E.Ready);
97
+ if (t()) return;
98
+ f(a), m(i?.toolInput), g(o), w(D.Ready);
100
99
  } catch {
101
- e() || T(E.Error);
100
+ t() || w(D.Error);
102
101
  }
103
102
  }, [
104
- t,
105
- C,
106
- l,
103
+ e,
104
+ b,
105
+ c,
106
+ n,
107
107
  r,
108
- i,
109
- u,
110
- d
108
+ l,
109
+ u
111
110
  ]);
112
- v(() => {
113
- if (t == null || l == null) {
114
- T(E.Unavailable);
111
+ y(() => {
112
+ if (e == null || c == null) {
113
+ w(D.Unavailable);
115
114
  return;
116
115
  }
117
- let e = !1;
118
- return T(E.Loading), A(() => e), () => {
119
- e = !0;
116
+ let t = !1;
117
+ return w(D.Loading), k(() => t), () => {
118
+ t = !0;
120
119
  };
121
120
  }, [
122
- t,
123
- l,
124
- A,
125
- D
121
+ e,
122
+ c,
123
+ k,
124
+ T
126
125
  ]);
127
- let j = _(async (e, n) => {
128
- if (t == null) throw Error(`Tool call "${e}" failed: no matching MCP App`);
129
- return d(t.toolsetId, e, n, t.kind);
130
- }, [t, d]);
131
- return w !== E.Ready || t == null || l == null || f == null ? {
132
- status: w,
133
- reload: k,
134
- attemptId: D
126
+ let A = v(async (t, n) => {
127
+ if (e == null) throw Error(`Tool call "${t}" failed: no matching MCP App`);
128
+ return u(e.toolsetId, t, n, e.kind);
129
+ }, [e, u]);
130
+ return C !== D.Ready || e == null || c == null || d == null ? {
131
+ status: C,
132
+ reload: O,
133
+ attemptId: T
135
134
  } : {
136
- status: w,
137
- reload: k,
138
- attemptId: D,
135
+ status: C,
136
+ reload: O,
137
+ attemptId: T,
139
138
  content: {
140
- type: e.McpApp,
141
- html: f,
142
- sandboxUrl: l,
143
- toolInput: m,
144
- toolResult: g,
145
- hostContext: s,
146
- hostInfo: c,
147
- onToolCall: j,
148
- onRequestDisplayMode: o
139
+ type: W,
140
+ html: d,
141
+ sandboxUrl: c,
142
+ toolInput: p,
143
+ toolResult: h,
144
+ hostContext: o,
145
+ hostInfo: s,
146
+ onToolCall: A,
147
+ onRequestDisplayMode: a
149
148
  }
150
149
  };
151
- }, W = {
150
+ }, ee = class extends m {
151
+ state = { hasError: !1 };
152
+ static getDerivedStateFromError() {
153
+ return { hasError: !0 };
154
+ }
155
+ componentDidCatch(e) {
156
+ this.props.onError(e instanceof Error ? e : Error(String(e)));
157
+ }
158
+ render() {
159
+ return this.state.hasError ? null : this.props.children;
160
+ }
161
+ }, K = {
152
162
  preview: "_preview_1xqr3_10",
153
163
  previewHeader: "_previewHeader_1xqr3_22",
154
164
  headerText: "_headerText_1xqr3_26",
155
165
  placeholderText: "_placeholderText_1xqr3_30",
156
166
  errorIcon: "_errorIcon_1xqr3_34",
157
167
  errorText: "_errorText_1xqr3_38"
158
- }, G = g(({ match: e, toolCall: n, cache: g, cacheKey: y, hostAdapter: b, onExpand: D, expandAriaLabel: O, reloadAriaLabel: k, actionsGroupAriaLabel: A = "MCP app actions", loadErrorLabel: j, loadingAriaLabel: M = "Loading app", isOpenedInCanvas: N = !1, openedInCanvasLabel: P, colors: F, typography: I }) => {
159
- let { headerNameClassName: L = "dial-tiny-lead-semi-text", messageClassName: R = "dial-body-text" } = I ?? {}, [z, B] = x(void 0);
160
- v(() => {
161
- B(void 0);
162
- }, [y]);
163
- let V = _((e) => e === "fullscreen" ? (D(), "fullscreen") : "inline", [D]), H = r({
164
- "--mcpapp-preview-bg": F?.previewBackground,
165
- "--mcpapp-preview-border": F?.previewBorder,
166
- "--mcpapp-preview-header-border": F?.previewHeaderBorder,
167
- "--mcpapp-header-text": F?.headerText,
168
- "--mcpapp-placeholder-text": F?.placeholderText,
169
- "--mcpapp-error-icon": F?.errorIcon,
170
- "--mcpapp-error-text": F?.errorText
171
- }), { status: G, content: K, reload: q, attemptId: J } = U(e, n, g, y, b, V);
172
- if (G === E.Unavailable) return null;
173
- let Y = "";
174
- return N ? Y = P : G === E.Error && (Y = j), /* @__PURE__ */ w("div", {
175
- style: H,
176
- className: f(W.preview, "flex w-full min-w-0 flex-col overflow-hidden rounded-xl border", T.preview),
177
- children: [/* @__PURE__ */ w("div", {
178
- className: f(W.previewHeader, "flex min-h-10 items-center justify-between gap-2 border-b px-4 py-2", T.previewHeader),
179
- children: [/* @__PURE__ */ C(s, {
180
- text: z == null ? /* @__PURE__ */ C("span", {
181
- className: L,
168
+ }, q = async () => ({ default: (await import("@epam/ai-dial-attachment-canvas/mcp-app-renderer")).McpAppCanvasRenderer }), te = () => g(q), J = _(({ match: e, toolCall: m, cache: g, cacheKey: _, hostAdapter: x, onExpand: O, expandAriaLabel: k, reloadAriaLabel: A, actionsGroupAriaLabel: j = "MCP app actions", loadErrorLabel: M, loadingAriaLabel: N = "Loading app", onRendererError: P, isOpenedInCanvas: F = !1, openedInCanvasLabel: I, colors: L, typography: R }) => {
169
+ let { headerNameClassName: z = "dial-tiny-lead-semi-text", messageClassName: B = "dial-body-text" } = R ?? {}, [V, H] = S(void 0);
170
+ y(() => {
171
+ H(void 0);
172
+ }, [_]);
173
+ let U = v((e) => e === "fullscreen" ? (O(), "fullscreen") : "inline", [O]), W = t({
174
+ "--mcpapp-preview-bg": L?.previewBackground,
175
+ "--mcpapp-preview-border": L?.previewBorder,
176
+ "--mcpapp-preview-header-border": L?.previewHeaderBorder,
177
+ "--mcpapp-header-text": L?.headerText,
178
+ "--mcpapp-placeholder-text": L?.placeholderText,
179
+ "--mcpapp-error-icon": L?.errorIcon,
180
+ "--mcpapp-error-text": L?.errorText
181
+ }), { status: J, content: Y, reload: X, attemptId: Z } = G(e, m, g, _, x, U);
182
+ y(() => {
183
+ q().catch(() => void 0);
184
+ }, []);
185
+ let ne = b(te, [Z]), [re, ie] = S(void 0), Q = re === Z, ae = v((e) => {
186
+ ie(Z), P?.(e);
187
+ }, [Z, P]);
188
+ if (J === D.Unavailable) return null;
189
+ let oe = J === D.Error || Q, $ = "";
190
+ F ? $ = I : oe && ($ = M);
191
+ let se = /* @__PURE__ */ w("div", {
192
+ className: "absolute inset-0 flex items-center justify-center",
193
+ children: /* @__PURE__ */ w(l, { ariaLabel: N })
194
+ });
195
+ return /* @__PURE__ */ T("div", {
196
+ style: W,
197
+ className: u(K.preview, "flex w-full min-w-0 flex-col overflow-hidden rounded-xl border", E.preview),
198
+ children: [/* @__PURE__ */ T("div", {
199
+ className: u(K.previewHeader, "flex min-h-10 items-center justify-between gap-2 border-b px-4 py-2", E.previewHeader),
200
+ children: [/* @__PURE__ */ w(a, {
201
+ text: V == null ? /* @__PURE__ */ w("span", {
202
+ className: z,
182
203
  children: e.mcpToolName
183
- }) : /* @__PURE__ */ w(S, { children: [
184
- /* @__PURE__ */ C("span", {
185
- className: L,
204
+ }) : /* @__PURE__ */ T(C, { children: [
205
+ /* @__PURE__ */ w("span", {
206
+ className: z,
186
207
  children: e.mcpToolName
187
208
  }),
188
- /* @__PURE__ */ C("span", {
209
+ /* @__PURE__ */ w("span", {
189
210
  "aria-hidden": !0,
190
211
  className: "mx-1.5 inline-block h-3 w-0 border-s border-current align-middle"
191
212
  }),
192
- /* @__PURE__ */ C("span", {
193
- className: L,
194
- children: z.name
213
+ /* @__PURE__ */ w("span", {
214
+ className: z,
215
+ children: V.name
195
216
  })
196
217
  ] }),
197
- className: W.headerText
198
- }), /* @__PURE__ */ w("div", {
218
+ className: K.headerText
219
+ }), /* @__PURE__ */ T("div", {
199
220
  role: "toolbar",
200
- "aria-label": A,
221
+ "aria-label": j,
201
222
  className: "flex shrink-0 items-center gap-1",
202
- children: [/* @__PURE__ */ C(c, {
203
- icon: /* @__PURE__ */ C(h, {
204
- size: i.SM,
205
- stroke: a,
223
+ children: [/* @__PURE__ */ w(o, {
224
+ icon: /* @__PURE__ */ w(p, {
225
+ size: n.SM,
226
+ stroke: r,
206
227
  "aria-hidden": !0
207
228
  }),
208
- "aria-label": k,
209
- size: o.Small,
210
- onClick: q
211
- }), /* @__PURE__ */ C(c, {
212
- icon: /* @__PURE__ */ C(m, {
213
- size: i.SM,
214
- stroke: a,
229
+ "aria-label": A,
230
+ size: i.Small,
231
+ onClick: X
232
+ }), /* @__PURE__ */ w(o, {
233
+ icon: /* @__PURE__ */ w(f, {
234
+ size: n.SM,
235
+ stroke: r,
215
236
  "aria-hidden": !0
216
237
  }),
217
- "aria-label": O,
218
- size: o.Small,
219
- onClick: D
238
+ "aria-label": k,
239
+ size: i.Small,
240
+ onClick: O
220
241
  })]
221
242
  })]
222
- }), /* @__PURE__ */ w("div", {
243
+ }), /* @__PURE__ */ T("div", {
223
244
  className: "relative min-h-[100px] w-full",
224
- children: [/* @__PURE__ */ C(l, {
245
+ children: [/* @__PURE__ */ w(s, {
225
246
  visuallyHidden: !0,
226
- as: u.Span,
227
- children: Y
228
- }), N ? /* @__PURE__ */ C("div", {
247
+ as: c.Span,
248
+ children: $
249
+ }), F ? /* @__PURE__ */ w("div", {
229
250
  "aria-hidden": !0,
230
251
  className: "absolute inset-0 flex items-center justify-center p-4",
231
- children: /* @__PURE__ */ C("span", {
232
- className: f(R, "text-center", W.placeholderText),
233
- children: P
252
+ children: /* @__PURE__ */ w("span", {
253
+ className: u(B, "text-center", K.placeholderText),
254
+ children: I
234
255
  })
235
- }) : /* @__PURE__ */ w(S, { children: [
236
- G === E.Loading && /* @__PURE__ */ C("div", {
237
- className: "absolute inset-0 flex items-center justify-center",
238
- children: /* @__PURE__ */ C(d, { ariaLabel: M })
239
- }),
240
- G === E.Error && /* @__PURE__ */ w("div", {
256
+ }) : /* @__PURE__ */ T(C, { children: [
257
+ J === D.Loading && se,
258
+ oe && /* @__PURE__ */ T("div", {
241
259
  className: "absolute inset-0 flex flex-col items-center justify-center gap-2 p-4",
242
- children: [/* @__PURE__ */ C(p, {
260
+ children: [/* @__PURE__ */ w(d, {
243
261
  size: 40,
244
- stroke: a,
262
+ stroke: r,
245
263
  "aria-hidden": !0,
246
- className: W.errorIcon
247
- }), /* @__PURE__ */ C("p", {
264
+ className: K.errorIcon
265
+ }), /* @__PURE__ */ w("p", {
248
266
  "aria-hidden": !0,
249
- className: f(R, "text-center", W.errorText),
250
- children: j
267
+ className: u(B, "text-center", K.errorText),
268
+ children: M
251
269
  })]
252
270
  }),
253
- G === E.Ready && K && /* @__PURE__ */ C(t, {
254
- content: K,
255
- errorLabel: j,
256
- onAppInfo: B
257
- }, J)
271
+ J === D.Ready && Y && !Q && /* @__PURE__ */ w(ee, {
272
+ onError: ae,
273
+ children: /* @__PURE__ */ w(h, {
274
+ fallback: se,
275
+ children: /* @__PURE__ */ w(ne, {
276
+ content: Y,
277
+ errorLabel: M,
278
+ onAppInfo: H
279
+ })
280
+ })
281
+ }, Z)
258
282
  ] })]
259
283
  })]
260
284
  });
261
- }), K = 9e5, q = (e) => {
262
- let t = b(/* @__PURE__ */ new Map()), n = b(/* @__PURE__ */ new Map());
263
- return y(() => {
285
+ }), Y = 9e5, X = (e) => {
286
+ let t = x(/* @__PURE__ */ new Map()), n = x(/* @__PURE__ */ new Map());
287
+ return b(() => {
264
288
  let r = (t) => `${e}:${t}`, i = (e, t) => `${r(e)}::${t ?? ""}`, a = (e, n) => {
265
289
  let i = t.current.get(r(e));
266
- if (i != null && i.seedKey === n && !(Date.now() - i.cachedAt > K)) return {
290
+ if (i != null && i.seedKey === n && !(Date.now() - i.cachedAt > Y)) return {
267
291
  html: i.html,
268
292
  toolResult: i.toolResult
269
293
  };
270
294
  }, o = (e, n, i) => {
271
295
  let a = Date.now();
272
- for (let [e, n] of t.current) a - n.cachedAt > K && t.current.delete(e);
296
+ for (let [e, n] of t.current) a - n.cachedAt > Y && t.current.delete(e);
273
297
  t.current.set(r(e), {
274
298
  ...n,
275
299
  seedKey: i,
@@ -296,4 +320,4 @@ var T = {
296
320
  }, [e]);
297
321
  };
298
322
  //#endregion
299
- export { T as MCP_APPS_CLASS, G as McpAppInlinePreview, E as McpAppInlinePreviewStatus, O as McpAppToolDiscovery, D as McpDeploymentKind, L as collectToolCallNames, B as computeMcpAppSeedKey, R as findMcpAppForMessage, z as mcpAppCanvasKey, V as resolveMcpAppToolCallSeed, H as resolveMcpAppToolResult, I as sanitizeToolName, U as useMcpAppInlinePreview, q as useMcpAppResponseCache };
323
+ export { E as MCP_APPS_CLASS, J as McpAppInlinePreview, D as McpAppInlinePreviewStatus, k as McpAppToolDiscovery, O as McpDeploymentKind, R as collectToolCallNames, V as computeMcpAppSeedKey, z as findMcpAppForMessage, B as mcpAppCanvasKey, H as resolveMcpAppToolCallSeed, U as resolveMcpAppToolResult, L as sanitizeToolName, G as useMcpAppInlinePreview, X as useMcpAppResponseCache };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-mcp-apps",
3
3
  "description": "Host-agnostic MCP Apps building blocks — tool-call/message matching, the response cache, and the inline preview hook/component shared by the full-width canvas and inline surfaces",
4
- "version": "1.4.0-dev.146",
4
+ "version": "1.4.0-dev.150",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": [
7
7
  "**/*.css",
@@ -23,10 +23,10 @@
23
23
  "dependencies": {
24
24
  "@tabler/icons-react": "^3.50.0",
25
25
  "@modelcontextprotocol/sdk": "^1.32.2",
26
- "@epam/ai-dial-attachment-canvas": "1.4.0-dev.146"
26
+ "@epam/ai-dial-attachment-canvas": "1.4.0-dev.150"
27
27
  },
28
28
  "peerDependencies": {
29
- "@epam/ai-dial-chat-shared": "1.4.0-dev.146",
29
+ "@epam/ai-dial-chat-shared": "1.4.0-dev.150",
30
30
  "@epam/ai-dial-ui-kit": "^0.16.0",
31
31
  "react": "^19.2.8"
32
32
  },