@epam/ai-dial-mcp-apps 1.3.0-dev.35 → 1.3.0-dev.354
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 +5 -1
- package/components/McpAppInlinePreview/McpAppInlinePreview.d.ts.map +1 -1
- package/hooks/useMcpAppInlinePreview/useMcpAppInlinePreview.d.ts.map +1 -1
- package/index.css +3 -2
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +141 -119
- package/models/mcp-apps.d.ts +18 -1
- package/models/mcp-apps.d.ts.map +1 -1
- package/package.json +6 -7
- package/utils/mcp-app.d.ts +31 -20
- package/utils/mcp-app.d.ts.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { McpAppHostAdapter, McpAppInlinePreviewColors, McpAppResponseCache, McpAppToolCallSeed, McpAppToolRef } from '../../models/mcp-apps';
|
|
1
|
+
import { McpAppHostAdapter, McpAppInlinePreviewColors, McpAppInlinePreviewTypography, McpAppResponseCache, McpAppToolCallSeed, McpAppToolRef } from '../../models/mcp-apps';
|
|
2
2
|
/** Props for the `McpAppInlinePreview` component. */
|
|
3
3
|
export interface McpAppInlinePreviewProps {
|
|
4
4
|
/** Matched MCP App tool to preview. */
|
|
@@ -21,6 +21,8 @@ export interface McpAppInlinePreviewProps {
|
|
|
21
21
|
actionsGroupAriaLabel?: string;
|
|
22
22
|
/** Message shown when the resource fails to load or the app fails to initialize. */
|
|
23
23
|
loadErrorLabel: string;
|
|
24
|
+
/** Accessible label of the spinner shown while the app loads. Defaults to `'Loading app'`. */
|
|
25
|
+
loadingAriaLabel?: string;
|
|
24
26
|
/**
|
|
25
27
|
* Whether this message's MCP App is currently open in the full-width
|
|
26
28
|
* canvas. When `true`, the header stays (so the tool/app identity is still
|
|
@@ -32,6 +34,8 @@ export interface McpAppInlinePreviewProps {
|
|
|
32
34
|
openedInCanvasLabel: string;
|
|
33
35
|
/** Color overrides applied as CSS custom properties on the preview's root. */
|
|
34
36
|
colors?: McpAppInlinePreviewColors;
|
|
37
|
+
/** Typography class overrides; each field has a kit scale default. */
|
|
38
|
+
typography?: McpAppInlinePreviewTypography;
|
|
35
39
|
}
|
|
36
40
|
/** Renders a compact, always-visible preview of a message's matched MCP App — see `McpAppInlinePreviewProps`. */
|
|
37
41
|
export declare const McpAppInlinePreview: import('react').NamedExoticComponent<McpAppInlinePreviewProps>;
|
|
@@ -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":"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 +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,
|
|
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"}
|
package/index.css
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
.
|
|
2
|
-
/*$vite$: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
|
+
/*$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}
|
package/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { useMcpAppInlinePreview, type McpAppInlinePreviewState, } from './hooks/
|
|
|
3
3
|
export { useMcpAppResponseCache } from './hooks/useMcpAppResponseCache/useMcpAppResponseCache';
|
|
4
4
|
export type { McpDeploymentKind, McpAppToolDiscovery, McpAppToolRef, McpAppToolCallSeed, FetchMcpAppResourceHtml, CallMcpAppTool, CachedMcpAppResponse, McpAppResponseCache, McpAppHostAdapter, } from './models/mcp-apps';
|
|
5
5
|
export { McpAppInlinePreviewStatus } from './models/mcp-apps';
|
|
6
|
-
export { collectToolCallNames, findMcpAppForMessage, mcpAppCanvasKey, computeMcpAppSeedKey, resolveMcpAppToolCallSeed, resolveMcpAppToolResult, } from './utils/mcp-app';
|
|
6
|
+
export { collectToolCallNames, findMcpAppForMessage, mcpAppCanvasKey, computeMcpAppSeedKey, resolveMcpAppToolCallSeed, resolveMcpAppToolResult, sanitizeToolName, } from './utils/mcp-app';
|
|
7
7
|
export { MCP_APPS_CLASS } from './constants/public-class-names';
|
|
8
|
-
export type { McpAppInlinePreviewColors } from './models/mcp-apps';
|
|
8
|
+
export type { McpAppInlinePreviewColors, McpAppInlinePreviewTypography, } from './models/mcp-apps';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,GAC9B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EACL,sBAAsB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uDAAuD,CAAC;AAC/F,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,GAC9B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EACL,sBAAsB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uDAAuD,CAAC;AAC/F,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,YAAY,EACV,yBAAyB,EACzB,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { AttachmentContentType as e, McpAppCanvasRenderer as t } from "@epam/ai-dial-attachment-canvas";
|
|
2
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,
|
|
4
|
-
import { IconAlertTriangle as
|
|
5
|
-
import { memo as
|
|
6
|
-
import { Fragment as
|
|
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";
|
|
7
7
|
//#region src/constants/public-class-names.ts
|
|
8
|
-
var
|
|
8
|
+
var T = {
|
|
9
9
|
preview: "dial-mcp-apps-preview",
|
|
10
10
|
previewHeader: "dial-mcp-apps-preview-header"
|
|
11
|
-
},
|
|
11
|
+
}, E = /* @__PURE__ */ function(e) {
|
|
12
12
|
return e.Loading = "loading", e.Ready = "ready", e.Error = "error", e.Unavailable = "unavailable", e;
|
|
13
|
-
}({}),
|
|
13
|
+
}({}), D = 500, O = 500, k = (e) => new Promise((t) => setTimeout(t, e)), A = (e) => {
|
|
14
14
|
try {
|
|
15
15
|
let t = JSON.parse(e);
|
|
16
16
|
return typeof t == "object" && t ? t : {};
|
|
17
17
|
} catch {
|
|
18
18
|
return {};
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, j = (e) => {
|
|
21
21
|
let t = /* @__PURE__ */ new Map();
|
|
22
22
|
for (let n of e?.tool_messages ?? []) {
|
|
23
23
|
for (let e of n.tool_calls ?? []) t.set(e.id, {
|
|
@@ -32,7 +32,7 @@ var C = {
|
|
|
32
32
|
for (let n of e?.tool_execution_history ?? []) {
|
|
33
33
|
for (let e of n.tool_calls ?? []) t.set(e.id, {
|
|
34
34
|
name: e.function.name,
|
|
35
|
-
args:
|
|
35
|
+
args: A(e.function.arguments)
|
|
36
36
|
});
|
|
37
37
|
if (n.role === "tool" && n.tool_call_id) {
|
|
38
38
|
let e = t.get(n.tool_call_id);
|
|
@@ -40,18 +40,21 @@ var C = {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
return t;
|
|
43
|
-
},
|
|
43
|
+
}, M = /[^a-zA-Z0-9_-]+/g, N = 64, P = (e) => {
|
|
44
|
+
let t = e.replace(M, "_");
|
|
45
|
+
return t !== "" && !/^[a-zA-Z_]/.test(t) && (t = `_${t}`), t.slice(0, N);
|
|
46
|
+
}, F = (e) => {
|
|
44
47
|
let t = /* @__PURE__ */ new Set();
|
|
45
|
-
for (let n of e) for (let e of
|
|
48
|
+
for (let n of e) for (let e of j(n.custom_content?.state).values()) t.add(e.name);
|
|
46
49
|
return t;
|
|
47
|
-
},
|
|
50
|
+
}, I = (e, t) => {
|
|
48
51
|
if (t.length === 0 || e.role !== n.Assistant) return;
|
|
49
|
-
let
|
|
50
|
-
return t.find((e) =>
|
|
51
|
-
},
|
|
52
|
+
let r = new Set([...j(e.custom_content?.state).values()].filter((e) => e.result != null).map((e) => e.name));
|
|
53
|
+
return t.find((e) => r.has(e.toolName)) || t.find((e) => e.discovery === "direct");
|
|
54
|
+
}, L = (e) => `${e}:mcp-app`, R = (e) => e == null ? void 0 : JSON.stringify(e.toolInput ?? null), z = (e, t) => {
|
|
52
55
|
let n = e.custom_content?.state;
|
|
53
56
|
if (!n) return;
|
|
54
|
-
let r = [...
|
|
57
|
+
let r = [...j(n).values()].reverse().find((e) => e.name === t);
|
|
55
58
|
if (r) return {
|
|
56
59
|
toolInput: r.args,
|
|
57
60
|
toolResult: r.result == null ? void 0 : { content: [{
|
|
@@ -59,191 +62,210 @@ var C = {
|
|
|
59
62
|
text: r.result
|
|
60
63
|
}] }
|
|
61
64
|
};
|
|
62
|
-
},
|
|
63
|
-
if (
|
|
65
|
+
}, B = async (e, t, n) => {
|
|
66
|
+
if (e.discovery !== "direct" && t?.toolInput == null) return t?.toolResult;
|
|
67
|
+
let r = () => n(e.toolsetId, e.mcpToolName, t?.toolInput ?? {}, e.kind);
|
|
64
68
|
try {
|
|
65
|
-
return await
|
|
69
|
+
return await r();
|
|
70
|
+
} catch {
|
|
71
|
+
await k(D + Math.random() * O);
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
return await r();
|
|
66
75
|
} catch {
|
|
67
76
|
return t?.toolResult;
|
|
68
77
|
}
|
|
69
|
-
},
|
|
70
|
-
let { hostContext: s, hostInfo: c, sandboxUrl: l, fetchResourceHtml: u, callTool: d } = a, [f, p] =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
}, V = (t, n, r, i, a, o) => {
|
|
79
|
+
let { hostContext: s, hostInfo: c, sandboxUrl: l, fetchResourceHtml: u, callTool: d } = a, [f, p] = x(), [m, h] = x(), [g, y] = x(), S = b(n);
|
|
80
|
+
v(() => {
|
|
81
|
+
S.current = n;
|
|
82
|
+
});
|
|
83
|
+
let C = R(n), [w, T] = x(() => t == null || l == null ? E.Unavailable : E.Loading), [D, O] = x(0), k = _(() => {
|
|
84
|
+
r.invalidate(i), O((e) => e + 1);
|
|
85
|
+
}, [r, i]), A = _(async (e) => {
|
|
86
|
+
if (t != null && l != null) try {
|
|
87
|
+
let n = S.current, { html: a, toolResult: o } = await r.getOrFetch(i, C, async () => {
|
|
88
|
+
let [e, r] = await Promise.all([u(t.toolsetId, t.resourceUri), B(t, n, d)]);
|
|
76
89
|
return {
|
|
77
90
|
html: e,
|
|
78
91
|
toolResult: r
|
|
79
92
|
};
|
|
80
93
|
});
|
|
81
94
|
if (e()) return;
|
|
82
|
-
p(
|
|
95
|
+
p(a), h(n?.toolInput), y(o), T(E.Ready);
|
|
83
96
|
} catch {
|
|
84
|
-
e() ||
|
|
97
|
+
e() || T(E.Error);
|
|
85
98
|
}
|
|
86
99
|
}, [
|
|
87
100
|
t,
|
|
88
|
-
|
|
101
|
+
C,
|
|
89
102
|
l,
|
|
90
103
|
r,
|
|
91
104
|
i,
|
|
92
105
|
u,
|
|
93
106
|
d
|
|
94
107
|
]);
|
|
95
|
-
|
|
108
|
+
v(() => {
|
|
96
109
|
if (t == null || l == null) {
|
|
97
|
-
|
|
110
|
+
T(E.Unavailable);
|
|
98
111
|
return;
|
|
99
112
|
}
|
|
100
113
|
let e = !1;
|
|
101
|
-
return
|
|
114
|
+
return T(E.Loading), A(() => e), () => {
|
|
102
115
|
e = !0;
|
|
103
116
|
};
|
|
104
117
|
}, [
|
|
105
118
|
t,
|
|
106
119
|
l,
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
A,
|
|
121
|
+
D
|
|
109
122
|
]);
|
|
110
|
-
let
|
|
123
|
+
let j = _(async (e, n) => {
|
|
111
124
|
if (t == null) throw Error(`Tool call "${e}" failed: no matching MCP App`);
|
|
112
125
|
return d(t.toolsetId, e, n, t.kind);
|
|
113
126
|
}, [t, d]);
|
|
114
|
-
return
|
|
115
|
-
status:
|
|
116
|
-
reload:
|
|
117
|
-
attemptId:
|
|
127
|
+
return w !== E.Ready || t == null || l == null || f == null ? {
|
|
128
|
+
status: w,
|
|
129
|
+
reload: k,
|
|
130
|
+
attemptId: D
|
|
118
131
|
} : {
|
|
119
|
-
status:
|
|
120
|
-
reload:
|
|
121
|
-
attemptId:
|
|
132
|
+
status: w,
|
|
133
|
+
reload: k,
|
|
134
|
+
attemptId: D,
|
|
122
135
|
content: {
|
|
123
136
|
type: e.McpApp,
|
|
124
137
|
html: f,
|
|
125
138
|
sandboxUrl: l,
|
|
126
|
-
toolInput:
|
|
127
|
-
toolResult:
|
|
139
|
+
toolInput: m,
|
|
140
|
+
toolResult: g,
|
|
128
141
|
hostContext: s,
|
|
129
142
|
hostInfo: c,
|
|
130
|
-
onToolCall:
|
|
143
|
+
onToolCall: j,
|
|
131
144
|
onRequestDisplayMode: o
|
|
132
145
|
}
|
|
133
146
|
};
|
|
134
|
-
},
|
|
135
|
-
preview: "
|
|
136
|
-
previewHeader: "
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
let L =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
}, H = {
|
|
148
|
+
preview: "_preview_1xqr3_10",
|
|
149
|
+
previewHeader: "_previewHeader_1xqr3_22",
|
|
150
|
+
headerText: "_headerText_1xqr3_26",
|
|
151
|
+
placeholderText: "_placeholderText_1xqr3_30",
|
|
152
|
+
errorIcon: "_errorIcon_1xqr3_34",
|
|
153
|
+
errorText: "_errorText_1xqr3_38"
|
|
154
|
+
}, U = 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 }) => {
|
|
155
|
+
let { headerNameClassName: L = "dial-tiny-lead-semi-text", messageClassName: R = "dial-body-text" } = I ?? {}, [z, B] = x(void 0);
|
|
156
|
+
v(() => {
|
|
157
|
+
B(void 0);
|
|
158
|
+
}, [y]);
|
|
159
|
+
let U = _((e) => e === "fullscreen" ? (D(), "fullscreen") : "inline", [D]), W = r({
|
|
160
|
+
"--mcpapp-preview-bg": F?.previewBackground,
|
|
161
|
+
"--mcpapp-preview-border": F?.previewBorder,
|
|
162
|
+
"--mcpapp-preview-header-border": F?.previewHeaderBorder,
|
|
163
|
+
"--mcpapp-header-text": F?.headerText,
|
|
164
|
+
"--mcpapp-placeholder-text": F?.placeholderText,
|
|
165
|
+
"--mcpapp-error-icon": F?.errorIcon,
|
|
166
|
+
"--mcpapp-error-text": F?.errorText
|
|
167
|
+
}), { status: G, content: K, reload: q, attemptId: J } = V(e, n, g, y, b, U);
|
|
168
|
+
if (G === E.Unavailable) return null;
|
|
169
|
+
let Y = "";
|
|
170
|
+
return N ? Y = P : G === E.Error && (Y = j), /* @__PURE__ */ w("div", {
|
|
171
|
+
style: W,
|
|
172
|
+
className: f(H.preview, "flex w-full min-w-0 flex-col overflow-hidden rounded-xl border", T.preview),
|
|
173
|
+
children: [/* @__PURE__ */ w("div", {
|
|
174
|
+
className: f(H.previewHeader, "flex min-h-10 items-center justify-between gap-2 border-b px-4 py-2", T.previewHeader),
|
|
175
|
+
children: [/* @__PURE__ */ C(s, {
|
|
176
|
+
text: z == null ? /* @__PURE__ */ C("span", {
|
|
177
|
+
className: L,
|
|
155
178
|
children: e.mcpToolName
|
|
156
|
-
}) : /* @__PURE__ */ S
|
|
157
|
-
/* @__PURE__ */
|
|
158
|
-
className:
|
|
179
|
+
}) : /* @__PURE__ */ w(S, { children: [
|
|
180
|
+
/* @__PURE__ */ C("span", {
|
|
181
|
+
className: L,
|
|
159
182
|
children: e.mcpToolName
|
|
160
183
|
}),
|
|
161
|
-
/* @__PURE__ */
|
|
184
|
+
/* @__PURE__ */ C("span", {
|
|
162
185
|
"aria-hidden": !0,
|
|
163
|
-
className: "
|
|
164
|
-
}),
|
|
165
|
-
/* @__PURE__ */ x("span", {
|
|
166
|
-
className: "dial-tiny-lead-semi-text",
|
|
167
|
-
children: F.name
|
|
186
|
+
className: "mx-1.5 inline-block h-3 w-0 border-s border-current align-middle"
|
|
168
187
|
}),
|
|
169
|
-
|
|
170
|
-
className:
|
|
171
|
-
children:
|
|
188
|
+
/* @__PURE__ */ C("span", {
|
|
189
|
+
className: L,
|
|
190
|
+
children: z.name
|
|
172
191
|
})
|
|
173
192
|
] }),
|
|
174
|
-
className:
|
|
175
|
-
}), /* @__PURE__ */
|
|
193
|
+
className: H.headerText
|
|
194
|
+
}), /* @__PURE__ */ w("div", {
|
|
176
195
|
role: "toolbar",
|
|
177
|
-
"aria-label":
|
|
196
|
+
"aria-label": A,
|
|
178
197
|
className: "flex shrink-0 items-center gap-1",
|
|
179
|
-
children: [/* @__PURE__ */
|
|
180
|
-
icon: /* @__PURE__ */
|
|
198
|
+
children: [/* @__PURE__ */ C(c, {
|
|
199
|
+
icon: /* @__PURE__ */ C(h, {
|
|
181
200
|
size: i.SM,
|
|
182
201
|
stroke: a,
|
|
183
202
|
"aria-hidden": !0
|
|
184
203
|
}),
|
|
185
|
-
"aria-label":
|
|
204
|
+
"aria-label": k,
|
|
186
205
|
size: o.Small,
|
|
187
|
-
onClick:
|
|
188
|
-
}), /* @__PURE__ */
|
|
189
|
-
icon: /* @__PURE__ */
|
|
206
|
+
onClick: q
|
|
207
|
+
}), /* @__PURE__ */ C(c, {
|
|
208
|
+
icon: /* @__PURE__ */ C(m, {
|
|
190
209
|
size: i.SM,
|
|
191
210
|
stroke: a,
|
|
192
211
|
"aria-hidden": !0
|
|
193
212
|
}),
|
|
194
|
-
"aria-label":
|
|
213
|
+
"aria-label": O,
|
|
195
214
|
size: o.Small,
|
|
196
|
-
onClick:
|
|
215
|
+
onClick: D
|
|
197
216
|
})]
|
|
198
217
|
})]
|
|
199
|
-
}), /* @__PURE__ */
|
|
200
|
-
className: "relative min-h-[
|
|
201
|
-
children:
|
|
202
|
-
|
|
203
|
-
|
|
218
|
+
}), /* @__PURE__ */ w("div", {
|
|
219
|
+
className: "relative min-h-[100px] w-full",
|
|
220
|
+
children: [/* @__PURE__ */ C(l, {
|
|
221
|
+
visuallyHidden: !0,
|
|
222
|
+
as: u.Span,
|
|
223
|
+
children: Y
|
|
224
|
+
}), N ? /* @__PURE__ */ C("div", {
|
|
225
|
+
"aria-hidden": !0,
|
|
204
226
|
className: "absolute inset-0 flex items-center justify-center p-4",
|
|
205
|
-
children: /* @__PURE__ */
|
|
206
|
-
className: "
|
|
207
|
-
children:
|
|
227
|
+
children: /* @__PURE__ */ C("span", {
|
|
228
|
+
className: f(R, "text-center", H.placeholderText),
|
|
229
|
+
children: P
|
|
208
230
|
})
|
|
209
|
-
}) : /* @__PURE__ */ S
|
|
210
|
-
|
|
231
|
+
}) : /* @__PURE__ */ w(S, { children: [
|
|
232
|
+
G === E.Loading && /* @__PURE__ */ C("div", {
|
|
211
233
|
className: "absolute inset-0 flex items-center justify-center",
|
|
212
|
-
children: /* @__PURE__ */
|
|
234
|
+
children: /* @__PURE__ */ C(d, { ariaLabel: M })
|
|
213
235
|
}),
|
|
214
|
-
|
|
236
|
+
G === E.Error && /* @__PURE__ */ w("div", {
|
|
215
237
|
className: "absolute inset-0 flex flex-col items-center justify-center gap-2 p-4",
|
|
216
|
-
children: [/* @__PURE__ */
|
|
238
|
+
children: [/* @__PURE__ */ C(p, {
|
|
217
239
|
size: 40,
|
|
218
240
|
stroke: a,
|
|
219
241
|
"aria-hidden": !0,
|
|
220
|
-
className:
|
|
221
|
-
}), /* @__PURE__ */
|
|
222
|
-
|
|
223
|
-
className: "
|
|
224
|
-
children:
|
|
242
|
+
className: H.errorIcon
|
|
243
|
+
}), /* @__PURE__ */ C("p", {
|
|
244
|
+
"aria-hidden": !0,
|
|
245
|
+
className: f(R, "text-center", H.errorText),
|
|
246
|
+
children: j
|
|
225
247
|
})]
|
|
226
248
|
}),
|
|
227
|
-
|
|
228
|
-
content:
|
|
229
|
-
errorLabel:
|
|
230
|
-
onAppInfo:
|
|
231
|
-
},
|
|
232
|
-
] })
|
|
249
|
+
G === E.Ready && K && /* @__PURE__ */ C(t, {
|
|
250
|
+
content: K,
|
|
251
|
+
errorLabel: j,
|
|
252
|
+
onAppInfo: B
|
|
253
|
+
}, J)
|
|
254
|
+
] })]
|
|
233
255
|
})]
|
|
234
256
|
});
|
|
235
|
-
}),
|
|
236
|
-
let t =
|
|
237
|
-
return
|
|
257
|
+
}), W = 9e5, G = (e) => {
|
|
258
|
+
let t = b(/* @__PURE__ */ new Map()), n = b(/* @__PURE__ */ new Map());
|
|
259
|
+
return y(() => {
|
|
238
260
|
let r = (t) => `${e}:${t}`, i = (e, t) => `${r(e)}::${t ?? ""}`, a = (e, n) => {
|
|
239
261
|
let i = t.current.get(r(e));
|
|
240
|
-
if (i != null && i.seedKey === n && !(Date.now() - i.cachedAt >
|
|
262
|
+
if (i != null && i.seedKey === n && !(Date.now() - i.cachedAt > W)) return {
|
|
241
263
|
html: i.html,
|
|
242
264
|
toolResult: i.toolResult
|
|
243
265
|
};
|
|
244
266
|
}, o = (e, n, i) => {
|
|
245
267
|
let a = Date.now();
|
|
246
|
-
for (let [e, n] of t.current) a - n.cachedAt >
|
|
268
|
+
for (let [e, n] of t.current) a - n.cachedAt > W && t.current.delete(e);
|
|
247
269
|
t.current.set(r(e), {
|
|
248
270
|
...n,
|
|
249
271
|
seedKey: i,
|
|
@@ -270,4 +292,4 @@ var C = {
|
|
|
270
292
|
}, [e]);
|
|
271
293
|
};
|
|
272
294
|
//#endregion
|
|
273
|
-
export {
|
|
295
|
+
export { T as MCP_APPS_CLASS, U as McpAppInlinePreview, E as McpAppInlinePreviewStatus, F as collectToolCallNames, R as computeMcpAppSeedKey, I as findMcpAppForMessage, L as mcpAppCanvasKey, z as resolveMcpAppToolCallSeed, B as resolveMcpAppToolResult, P as sanitizeToolName, V as useMcpAppInlinePreview, G as useMcpAppResponseCache };
|
package/models/mcp-apps.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { McpAppCanvasContent } from '@epam/ai-dial-attachment-canvas';
|
|
2
2
|
import { CallToolResult, Implementation } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
type McpUiHostContext = NonNullable<McpAppCanvasContent['hostContext']>;
|
|
3
4
|
/** Which of the host's two MCP proxy routes a deployment id resolves through — a plain toolset, or an application that is itself an MCP server. */
|
|
4
5
|
export type McpDeploymentKind = 'toolset' | 'application';
|
|
5
6
|
/**
|
|
@@ -112,5 +113,21 @@ export interface McpAppInlinePreviewColors {
|
|
|
112
113
|
previewBorder?: string;
|
|
113
114
|
/** Divider under the header strip. Fallback: `--stroke-tertiary`. */
|
|
114
115
|
previewHeaderBorder?: string;
|
|
116
|
+
/** Text color of the header strip's app or tool name. Fallback: `--text-secondary`. */
|
|
117
|
+
headerText?: string;
|
|
118
|
+
/** Text color of the "opened in canvas" placeholder. Fallback: `--text-secondary`. */
|
|
119
|
+
placeholderText?: string;
|
|
120
|
+
/** Color of the load-error icon. Fallback: `--text-error`. */
|
|
121
|
+
errorIcon?: string;
|
|
122
|
+
/** Text color of the load-error message. Fallback: `--text-primary`. */
|
|
123
|
+
errorText?: string;
|
|
115
124
|
}
|
|
125
|
+
/** Typography class overrides for `McpAppInlinePreview`. */
|
|
126
|
+
export interface McpAppInlinePreviewTypography {
|
|
127
|
+
/** Typography class of the header strip's tool and app names. Defaults to `'dial-tiny-lead-semi-text'`. */
|
|
128
|
+
headerNameClassName?: string;
|
|
129
|
+
/** Typography class of the "opened in canvas" and load-error messages. Defaults to `'dial-body-text'`. */
|
|
130
|
+
messageClassName?: string;
|
|
131
|
+
}
|
|
132
|
+
export {};
|
|
116
133
|
//# sourceMappingURL=mcp-apps.d.ts.map
|
package/models/mcp-apps.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-apps.d.ts","sourceRoot":"","sources":["../../src/models/mcp-apps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"mcp-apps.d.ts","sourceRoot":"","sources":["../../src/models/mcp-apps.ts"],"names":[],"mappings":"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"}
|
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.3.0-dev.
|
|
4
|
+
"version": "1.3.0-dev.354",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -17,14 +17,13 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@tabler/icons-react": "^3.
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"@epam/ai-dial-attachment-canvas": "1.3.0-dev.35"
|
|
20
|
+
"@tabler/icons-react": "^3.50.0",
|
|
21
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
22
|
+
"@epam/ai-dial-attachment-canvas": "1.3.0-dev.354"
|
|
24
23
|
},
|
|
25
24
|
"peerDependencies": {
|
|
26
|
-
"@epam/ai-dial-chat-shared": "1.3.0-dev.
|
|
27
|
-
"@epam/ai-dial-ui-kit": "^0.
|
|
25
|
+
"@epam/ai-dial-chat-shared": "1.3.0-dev.354",
|
|
26
|
+
"@epam/ai-dial-ui-kit": "^0.16.0",
|
|
28
27
|
"react": "^19.2.8"
|
|
29
28
|
},
|
|
30
29
|
"repository": {
|
package/utils/mcp-app.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { Message } from '@epam/ai-dial-chat-shared';
|
|
2
2
|
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
import { CallMcpAppTool, McpAppToolCallSeed, McpAppToolRef } from '../models/mcp-apps';
|
|
4
|
+
/**
|
|
5
|
+
* Reproduces the tool-name sanitization QuickApps applies to
|
|
6
|
+
* `${toolsetName}_${toolName}` before sending a tool to the LLM
|
|
7
|
+
* (`sanitize_toolname` in `epam/ai-dial-quickapps-backend`,
|
|
8
|
+
* `src/quickapp/common/utils.py`): every run of characters outside
|
|
9
|
+
* `[a-zA-Z0-9_-]` becomes a single `_`, a name not starting with a letter or `_`
|
|
10
|
+
* gets a leading `_`, and the result is cut to 64 characters.
|
|
11
|
+
*
|
|
12
|
+
* Temporary heuristic: the host has no toolset id on a tool call, so it can only
|
|
13
|
+
* correlate a call with a toolset by guessing this name. Replace it once MCP Apps
|
|
14
|
+
* are fully supported and the orchestrator reports the toolset a call belongs to.
|
|
15
|
+
* @param input - raw `${toolsetName}_${toolName}` (or `${toolsetName}_` prefix)
|
|
16
|
+
*/
|
|
17
|
+
export declare const sanitizeToolName: (input: string) => string;
|
|
4
18
|
/**
|
|
5
19
|
* Collects every real tool-call name seen across `messages`' `custom_content.state`
|
|
6
20
|
* (in whichever known orchestrator shape is present). Used to discover an MCP-capable
|
|
@@ -9,8 +23,9 @@ import { CallMcpAppTool, McpAppToolCallSeed, McpAppToolRef } from '../models/mcp
|
|
|
9
23
|
export declare const collectToolCallNames: (messages: Message[]) => Set<string>;
|
|
10
24
|
/**
|
|
11
25
|
* Returns the `mcpAppTools` entry that best matches this message: the one
|
|
12
|
-
* whose name was actually called
|
|
13
|
-
* of its two known orchestrator-specific
|
|
26
|
+
* whose name was actually called and has returned a result (per
|
|
27
|
+
* `custom_content.state`, in whichever of its two known orchestrator-specific
|
|
28
|
+
* shapes is present).
|
|
14
29
|
*
|
|
15
30
|
* If no real call matches, a `discovery: 'direct'` tool (the deployment
|
|
16
31
|
* itself IS this MCP server, whether it's a bare Toolset or an Application —
|
|
@@ -23,18 +38,16 @@ export declare const collectToolCallNames: (messages: Message[]) => Set<string>;
|
|
|
23
38
|
*
|
|
24
39
|
* Otherwise (a `discovery: 'indirect'` match — a real MCP-capable toolset a
|
|
25
40
|
* different, tool-calling deployment delegates to, guessed by name-prefix), a
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* never show the trigger, even though the deployment supports MCP Apps in
|
|
32
|
-
* general.
|
|
41
|
+
* call to that tool that has already returned a result is required, whether
|
|
42
|
+
* the message is streaming or settled. A call without a result is still
|
|
43
|
+
* running, and with no call at all the model may never call the tool, so
|
|
44
|
+
* guessing earlier would mount the app on every answer in a conversation that
|
|
45
|
+
* once used it, and the app would wait for data that never arrives.
|
|
33
46
|
*
|
|
34
47
|
* Returns `undefined` for non-assistant messages or when the deployment has
|
|
35
48
|
* no MCP-Apps-capable tool at all.
|
|
36
49
|
*/
|
|
37
|
-
export declare const findMcpAppForMessage: (message: Message, mcpAppTools: McpAppToolRef[]
|
|
50
|
+
export declare const findMcpAppForMessage: (message: Message, mcpAppTools: McpAppToolRef[]) => McpAppToolRef | undefined;
|
|
38
51
|
/** Stable key identifying a message's MCP App canvas in an attachment canvas's `attachmentId` tracking, mirroring the `${messageIndex}:${attachmentId}` scheme used for regular attachment tiles. */
|
|
39
52
|
export declare const mcpAppCanvasKey: (messageIndex: number) => string;
|
|
40
53
|
/**
|
|
@@ -76,18 +89,16 @@ export declare const resolveMcpAppToolCallSeed: (message: Message, toolName: str
|
|
|
76
89
|
* - `seed?.toolInput != null` — a `discovery: 'indirect'` match (the toolset
|
|
77
90
|
* a *different*, tool-calling deployment appears to delegate to) whose
|
|
78
91
|
* `toolName` was matched against a *real* tool call actually seen in
|
|
79
|
-
* `custom_content.state` (`findMcpAppForMessage`'s name-match branch
|
|
80
|
-
*
|
|
81
|
-
* confirmed, re-calling it with the exact same `toolsetId`/args it was
|
|
92
|
+
* `custom_content.state` (`findMcpAppForMessage`'s name-match branch).
|
|
93
|
+
* Once a real call is confirmed, re-calling it with the exact same `toolsetId`/args it was
|
|
82
94
|
* really invoked with carries no more risk than the direct case.
|
|
83
95
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* has no live MCP session outside the original conversation turn).
|
|
96
|
+
* An `indirect` match with no seed is skipped — that toolset/tool pairing
|
|
97
|
+
* is unconfirmed, and re-calling it could hit the wrong tool or re-trigger a
|
|
98
|
+
* non-idempotent side effect; it keeps `seed?.toolResult` as-is. Falls back to
|
|
99
|
+
* `seed?.toolResult` if an attempted live call fails twice (e.g. the
|
|
100
|
+
* deployment has no live MCP session outside the original conversation turn).
|
|
101
|
+
* A failed live call is retried once after a short randomized delay.
|
|
91
102
|
*/
|
|
92
103
|
export declare const resolveMcpAppToolResult: (match: McpAppToolRef, seed: McpAppToolCallSeed | undefined, callTool: CallMcpAppTool) => Promise<CallToolResult | undefined>;
|
|
93
104
|
//# sourceMappingURL=mcp-app.d.ts.map
|
package/utils/mcp-app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-app.d.ts","sourceRoot":"","sources":["../../src/utils/mcp-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,aAAa,EACd,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-app.d.ts","sourceRoot":"","sources":["../../src/utils/mcp-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,aAAa,EACd,MAAM,oBAAoB,CAAC;AAwE5B;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,MAMhD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,OAAO,EAAE,KAAG,GAAG,CAAC,MAAM,CAUpE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,oBAAoB,GAC/B,SAAS,OAAO,EAChB,aAAa,aAAa,EAAE,KAC3B,aAAa,GAAG,SAYlB,CAAC;AAEF,qMAAqM;AACrM,eAAO,MAAM,eAAe,GAAI,cAAc,MAAM,KAAG,MAC5B,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,kBAAkB,GAAG,SAAS,KACvC,MAAM,GAAG,SAC+D,CAAC;AAE5E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,GACpC,SAAS,OAAO,EAChB,UAAU,MAAM,KACf,kBAAkB,GAAG,SAgBvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,uBAAuB,GAClC,OAAO,aAAa,EACpB,MAAM,kBAAkB,GAAG,SAAS,EACpC,UAAU,cAAc,KACvB,OAAO,CAAC,cAAc,GAAG,SAAS,CAiCpC,CAAC"}
|