@epam/ai-dial-mcp-apps 1.4.0-dev.148 → 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.
- package/components/McpAppInlinePreview/McpAppInlinePreview.d.ts +6 -0
- package/components/McpAppInlinePreview/McpAppInlinePreview.d.ts.map +1 -1
- package/components/RendererLoadBoundary/RendererLoadBoundary.d.ts +26 -0
- package/components/RendererLoadBoundary/RendererLoadBoundary.d.ts.map +1 -0
- package/hooks/useMcpAppInlinePreview/useMcpAppInlinePreview.d.ts.map +1 -1
- package/index.css +1 -1
- package/index.js +182 -158
- package/package.json +3 -3
|
@@ -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":"
|
|
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,
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
|
7
|
+
var E = {
|
|
9
8
|
preview: "dial-mcp-apps-preview",
|
|
10
9
|
previewHeader: "dial-mcp-apps-preview-header"
|
|
11
|
-
},
|
|
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
|
-
}({}),
|
|
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
|
-
},
|
|
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:
|
|
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
|
-
},
|
|
48
|
-
let t = e.replace(
|
|
49
|
-
return t !== "" && !/^[a-zA-Z_]/.test(t) && (t = `_${t}`), t.slice(0,
|
|
50
|
-
},
|
|
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
|
|
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
|
-
},
|
|
55
|
-
if (
|
|
56
|
-
let r = new Set([...
|
|
57
|
-
return
|
|
58
|
-
},
|
|
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 = [...
|
|
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
|
-
},
|
|
70
|
-
if (e.discovery !==
|
|
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
|
|
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
|
-
},
|
|
83
|
-
let { hostContext:
|
|
84
|
-
|
|
85
|
-
|
|
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
|
|
88
|
-
|
|
89
|
-
}, [
|
|
90
|
-
if (
|
|
91
|
-
let
|
|
92
|
-
let [
|
|
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:
|
|
95
|
-
toolResult:
|
|
93
|
+
html: t,
|
|
94
|
+
toolResult: n
|
|
96
95
|
};
|
|
97
96
|
});
|
|
98
|
-
if (
|
|
99
|
-
|
|
97
|
+
if (t()) return;
|
|
98
|
+
f(a), m(i?.toolInput), g(o), w(D.Ready);
|
|
100
99
|
} catch {
|
|
101
|
-
|
|
100
|
+
t() || w(D.Error);
|
|
102
101
|
}
|
|
103
102
|
}, [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
e,
|
|
104
|
+
b,
|
|
105
|
+
c,
|
|
106
|
+
n,
|
|
107
107
|
r,
|
|
108
|
-
|
|
109
|
-
u
|
|
110
|
-
d
|
|
108
|
+
l,
|
|
109
|
+
u
|
|
111
110
|
]);
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
|
|
111
|
+
y(() => {
|
|
112
|
+
if (e == null || c == null) {
|
|
113
|
+
w(D.Unavailable);
|
|
115
114
|
return;
|
|
116
115
|
}
|
|
117
|
-
let
|
|
118
|
-
return
|
|
119
|
-
|
|
116
|
+
let t = !1;
|
|
117
|
+
return w(D.Loading), k(() => t), () => {
|
|
118
|
+
t = !0;
|
|
120
119
|
};
|
|
121
120
|
}, [
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
e,
|
|
122
|
+
c,
|
|
123
|
+
k,
|
|
124
|
+
T
|
|
126
125
|
]);
|
|
127
|
-
let
|
|
128
|
-
if (
|
|
129
|
-
return
|
|
130
|
-
}, [
|
|
131
|
-
return
|
|
132
|
-
status:
|
|
133
|
-
reload:
|
|
134
|
-
attemptId:
|
|
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:
|
|
137
|
-
reload:
|
|
138
|
-
attemptId:
|
|
135
|
+
status: C,
|
|
136
|
+
reload: O,
|
|
137
|
+
attemptId: T,
|
|
139
138
|
content: {
|
|
140
|
-
type:
|
|
141
|
-
html:
|
|
142
|
-
sandboxUrl:
|
|
143
|
-
toolInput:
|
|
144
|
-
toolResult:
|
|
145
|
-
hostContext:
|
|
146
|
-
hostInfo:
|
|
147
|
-
onToolCall:
|
|
148
|
-
onRequestDisplayMode:
|
|
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
|
-
},
|
|
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
|
-
},
|
|
159
|
-
let { headerNameClassName:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}, [
|
|
163
|
-
let
|
|
164
|
-
"--mcpapp-preview-bg":
|
|
165
|
-
"--mcpapp-preview-border":
|
|
166
|
-
"--mcpapp-preview-header-border":
|
|
167
|
-
"--mcpapp-header-text":
|
|
168
|
-
"--mcpapp-placeholder-text":
|
|
169
|
-
"--mcpapp-error-icon":
|
|
170
|
-
"--mcpapp-error-text":
|
|
171
|
-
}), { status:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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__ */
|
|
184
|
-
/* @__PURE__ */
|
|
185
|
-
className:
|
|
204
|
+
}) : /* @__PURE__ */ T(C, { children: [
|
|
205
|
+
/* @__PURE__ */ w("span", {
|
|
206
|
+
className: z,
|
|
186
207
|
children: e.mcpToolName
|
|
187
208
|
}),
|
|
188
|
-
/* @__PURE__ */
|
|
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__ */
|
|
193
|
-
className:
|
|
194
|
-
children:
|
|
213
|
+
/* @__PURE__ */ w("span", {
|
|
214
|
+
className: z,
|
|
215
|
+
children: V.name
|
|
195
216
|
})
|
|
196
217
|
] }),
|
|
197
|
-
className:
|
|
198
|
-
}), /* @__PURE__ */
|
|
218
|
+
className: K.headerText
|
|
219
|
+
}), /* @__PURE__ */ T("div", {
|
|
199
220
|
role: "toolbar",
|
|
200
|
-
"aria-label":
|
|
221
|
+
"aria-label": j,
|
|
201
222
|
className: "flex shrink-0 items-center gap-1",
|
|
202
|
-
children: [/* @__PURE__ */
|
|
203
|
-
icon: /* @__PURE__ */
|
|
204
|
-
size:
|
|
205
|
-
stroke:
|
|
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":
|
|
209
|
-
size:
|
|
210
|
-
onClick:
|
|
211
|
-
}), /* @__PURE__ */
|
|
212
|
-
icon: /* @__PURE__ */
|
|
213
|
-
size:
|
|
214
|
-
stroke:
|
|
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":
|
|
218
|
-
size:
|
|
219
|
-
onClick:
|
|
238
|
+
"aria-label": k,
|
|
239
|
+
size: i.Small,
|
|
240
|
+
onClick: O
|
|
220
241
|
})]
|
|
221
242
|
})]
|
|
222
|
-
}), /* @__PURE__ */
|
|
243
|
+
}), /* @__PURE__ */ T("div", {
|
|
223
244
|
className: "relative min-h-[100px] w-full",
|
|
224
|
-
children: [/* @__PURE__ */
|
|
245
|
+
children: [/* @__PURE__ */ w(s, {
|
|
225
246
|
visuallyHidden: !0,
|
|
226
|
-
as:
|
|
227
|
-
children:
|
|
228
|
-
}),
|
|
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__ */
|
|
232
|
-
className:
|
|
233
|
-
children:
|
|
252
|
+
children: /* @__PURE__ */ w("span", {
|
|
253
|
+
className: u(B, "text-center", K.placeholderText),
|
|
254
|
+
children: I
|
|
234
255
|
})
|
|
235
|
-
}) : /* @__PURE__ */
|
|
236
|
-
|
|
237
|
-
|
|
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__ */
|
|
260
|
+
children: [/* @__PURE__ */ w(d, {
|
|
243
261
|
size: 40,
|
|
244
|
-
stroke:
|
|
262
|
+
stroke: r,
|
|
245
263
|
"aria-hidden": !0,
|
|
246
|
-
className:
|
|
247
|
-
}), /* @__PURE__ */
|
|
264
|
+
className: K.errorIcon
|
|
265
|
+
}), /* @__PURE__ */ w("p", {
|
|
248
266
|
"aria-hidden": !0,
|
|
249
|
-
className:
|
|
250
|
-
children:
|
|
267
|
+
className: u(B, "text-center", K.errorText),
|
|
268
|
+
children: M
|
|
251
269
|
})]
|
|
252
270
|
}),
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
}),
|
|
262
|
-
let t =
|
|
263
|
-
return
|
|
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 >
|
|
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 >
|
|
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 {
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
},
|