@epam/ai-dial-mcp-apps 1.3.0-dev.98 → 1.3.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +2 -2
- package/index.d.ts +4 -3
- package/index.d.ts.map +1 -1
- package/index.js +144 -118
- package/models/mcp-apps.d.ts +19 -19
- package/models/mcp-apps.d.ts.map +1 -1
- package/package.json +6 -7
- package/types/mcp-apps.d.ts +25 -0
- package/types/mcp-apps.d.ts.map +1 -0
- package/utils/mcp-app.d.ts +35 -24
- 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,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}.
|
|
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
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { McpAppInlinePreview, type McpAppInlinePreviewProps, } from './components/McpAppInlinePreview/McpAppInlinePreview';
|
|
2
2
|
export { useMcpAppInlinePreview, type McpAppInlinePreviewState, } from './hooks/useMcpAppInlinePreview/useMcpAppInlinePreview';
|
|
3
3
|
export { useMcpAppResponseCache } from './hooks/useMcpAppResponseCache/useMcpAppResponseCache';
|
|
4
|
-
export
|
|
4
|
+
export { McpAppToolDiscovery, McpDeploymentKind } from './types/mcp-apps';
|
|
5
|
+
export type { McpAppToolRef, McpAppToolCallSeed, FetchMcpAppResourceHtml, CallMcpAppTool, CachedMcpAppResponse, McpAppResponseCache, McpAppHostAdapter, } from './models/mcp-apps';
|
|
5
6
|
export { McpAppInlinePreviewStatus } from './models/mcp-apps';
|
|
6
|
-
export { collectToolCallNames, findMcpAppForMessage, mcpAppCanvasKey, computeMcpAppSeedKey, resolveMcpAppToolCallSeed, resolveMcpAppToolResult, } from './utils/mcp-app';
|
|
7
|
+
export { collectToolCallNames, findMcpAppForMessage, mcpAppCanvasKey, computeMcpAppSeedKey, resolveMcpAppToolCallSeed, resolveMcpAppToolResult, sanitizeToolName, } from './utils/mcp-app';
|
|
7
8
|
export { MCP_APPS_CLASS } from './constants/public-class-names';
|
|
8
|
-
export type { McpAppInlinePreviewColors } from './models/mcp-apps';
|
|
9
|
+
export type { McpAppInlinePreviewColors, McpAppInlinePreviewTypography, } from './models/mcp-apps';
|
|
9
10
|
//# 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,
|
|
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,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,YAAY,EACV,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,27 @@
|
|
|
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 = /* @__PURE__ */ function(e) {
|
|
14
|
+
return e.Toolset = "toolset", e.Application = "application", e;
|
|
15
|
+
}({}), O = /* @__PURE__ */ function(e) {
|
|
16
|
+
return e.Direct = "direct", e.Indirect = "indirect", e;
|
|
17
|
+
}({}), k = 500, A = 500, j = (e) => new Promise((t) => setTimeout(t, e)), M = (e) => {
|
|
14
18
|
try {
|
|
15
19
|
let t = JSON.parse(e);
|
|
16
20
|
return typeof t == "object" && t ? t : {};
|
|
17
21
|
} catch {
|
|
18
22
|
return {};
|
|
19
23
|
}
|
|
20
|
-
},
|
|
24
|
+
}, N = (e) => {
|
|
21
25
|
let t = /* @__PURE__ */ new Map();
|
|
22
26
|
for (let n of e?.tool_messages ?? []) {
|
|
23
27
|
for (let e of n.tool_calls ?? []) t.set(e.id, {
|
|
@@ -32,7 +36,7 @@ var C = {
|
|
|
32
36
|
for (let n of e?.tool_execution_history ?? []) {
|
|
33
37
|
for (let e of n.tool_calls ?? []) t.set(e.id, {
|
|
34
38
|
name: e.function.name,
|
|
35
|
-
args:
|
|
39
|
+
args: M(e.function.arguments)
|
|
36
40
|
});
|
|
37
41
|
if (n.role === "tool" && n.tool_call_id) {
|
|
38
42
|
let e = t.get(n.tool_call_id);
|
|
@@ -40,18 +44,21 @@ var C = {
|
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
return t;
|
|
43
|
-
},
|
|
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) => {
|
|
44
51
|
let t = /* @__PURE__ */ new Set();
|
|
45
|
-
for (let n of e) for (let e of
|
|
52
|
+
for (let n of e) for (let e of N(n.custom_content?.state).values()) t.add(e.name);
|
|
46
53
|
return t;
|
|
47
|
-
},
|
|
54
|
+
}, R = (e, t) => {
|
|
48
55
|
if (t.length === 0 || e.role !== n.Assistant) return;
|
|
49
|
-
let
|
|
50
|
-
return t.find((e) =>
|
|
51
|
-
},
|
|
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) => {
|
|
52
59
|
let n = e.custom_content?.state;
|
|
53
60
|
if (!n) return;
|
|
54
|
-
let r = [...
|
|
61
|
+
let r = [...N(n).values()].reverse().find((e) => e.name === t);
|
|
55
62
|
if (r) return {
|
|
56
63
|
toolInput: r.args,
|
|
57
64
|
toolResult: r.result == null ? void 0 : { content: [{
|
|
@@ -59,191 +66,210 @@ var C = {
|
|
|
59
66
|
text: r.result
|
|
60
67
|
}] }
|
|
61
68
|
};
|
|
62
|
-
},
|
|
63
|
-
if (
|
|
69
|
+
}, H = async (e, t, n) => {
|
|
70
|
+
if (e.discovery !== O.Direct && t?.toolInput == null) return t?.toolResult;
|
|
71
|
+
let r = () => n(e.toolsetId, e.mcpToolName, t?.toolInput ?? {}, e.kind);
|
|
64
72
|
try {
|
|
65
|
-
return await
|
|
73
|
+
return await r();
|
|
74
|
+
} catch {
|
|
75
|
+
await j(k + Math.random() * A);
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
return await r();
|
|
66
79
|
} catch {
|
|
67
80
|
return t?.toolResult;
|
|
68
81
|
}
|
|
69
|
-
},
|
|
70
|
-
let { hostContext: s, hostInfo: c, sandboxUrl: l, fetchResourceHtml: u, callTool: d } = a, [f, p] =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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;
|
|
86
|
+
});
|
|
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)]);
|
|
76
93
|
return {
|
|
77
94
|
html: e,
|
|
78
95
|
toolResult: r
|
|
79
96
|
};
|
|
80
97
|
});
|
|
81
98
|
if (e()) return;
|
|
82
|
-
p(
|
|
99
|
+
p(a), h(n?.toolInput), y(o), T(E.Ready);
|
|
83
100
|
} catch {
|
|
84
|
-
e() ||
|
|
101
|
+
e() || T(E.Error);
|
|
85
102
|
}
|
|
86
103
|
}, [
|
|
87
104
|
t,
|
|
88
|
-
|
|
105
|
+
C,
|
|
89
106
|
l,
|
|
90
107
|
r,
|
|
91
108
|
i,
|
|
92
109
|
u,
|
|
93
110
|
d
|
|
94
111
|
]);
|
|
95
|
-
|
|
112
|
+
v(() => {
|
|
96
113
|
if (t == null || l == null) {
|
|
97
|
-
|
|
114
|
+
T(E.Unavailable);
|
|
98
115
|
return;
|
|
99
116
|
}
|
|
100
117
|
let e = !1;
|
|
101
|
-
return
|
|
118
|
+
return T(E.Loading), A(() => e), () => {
|
|
102
119
|
e = !0;
|
|
103
120
|
};
|
|
104
121
|
}, [
|
|
105
122
|
t,
|
|
106
123
|
l,
|
|
107
|
-
|
|
108
|
-
|
|
124
|
+
A,
|
|
125
|
+
D
|
|
109
126
|
]);
|
|
110
|
-
let
|
|
127
|
+
let j = _(async (e, n) => {
|
|
111
128
|
if (t == null) throw Error(`Tool call "${e}" failed: no matching MCP App`);
|
|
112
129
|
return d(t.toolsetId, e, n, t.kind);
|
|
113
130
|
}, [t, d]);
|
|
114
|
-
return
|
|
115
|
-
status:
|
|
116
|
-
reload:
|
|
117
|
-
attemptId:
|
|
131
|
+
return w !== E.Ready || t == null || l == null || f == null ? {
|
|
132
|
+
status: w,
|
|
133
|
+
reload: k,
|
|
134
|
+
attemptId: D
|
|
118
135
|
} : {
|
|
119
|
-
status:
|
|
120
|
-
reload:
|
|
121
|
-
attemptId:
|
|
136
|
+
status: w,
|
|
137
|
+
reload: k,
|
|
138
|
+
attemptId: D,
|
|
122
139
|
content: {
|
|
123
140
|
type: e.McpApp,
|
|
124
141
|
html: f,
|
|
125
142
|
sandboxUrl: l,
|
|
126
|
-
toolInput:
|
|
127
|
-
toolResult:
|
|
143
|
+
toolInput: m,
|
|
144
|
+
toolResult: g,
|
|
128
145
|
hostContext: s,
|
|
129
146
|
hostInfo: c,
|
|
130
|
-
onToolCall:
|
|
147
|
+
onToolCall: j,
|
|
131
148
|
onRequestDisplayMode: o
|
|
132
149
|
}
|
|
133
150
|
};
|
|
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
|
-
|
|
151
|
+
}, W = {
|
|
152
|
+
preview: "_preview_1xqr3_10",
|
|
153
|
+
previewHeader: "_previewHeader_1xqr3_22",
|
|
154
|
+
headerText: "_headerText_1xqr3_26",
|
|
155
|
+
placeholderText: "_placeholderText_1xqr3_30",
|
|
156
|
+
errorIcon: "_errorIcon_1xqr3_34",
|
|
157
|
+
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,
|
|
155
182
|
children: e.mcpToolName
|
|
156
|
-
}) : /* @__PURE__ */ S
|
|
157
|
-
/* @__PURE__ */
|
|
158
|
-
className:
|
|
183
|
+
}) : /* @__PURE__ */ w(S, { children: [
|
|
184
|
+
/* @__PURE__ */ C("span", {
|
|
185
|
+
className: L,
|
|
159
186
|
children: e.mcpToolName
|
|
160
187
|
}),
|
|
161
|
-
/* @__PURE__ */
|
|
188
|
+
/* @__PURE__ */ C("span", {
|
|
162
189
|
"aria-hidden": !0,
|
|
163
190
|
className: "mx-1.5 inline-block h-3 w-0 border-s border-current align-middle"
|
|
164
191
|
}),
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
className:
|
|
167
|
-
children:
|
|
168
|
-
}),
|
|
169
|
-
F.version && /* @__PURE__ */ x("span", {
|
|
170
|
-
className: "dial-caption-text ms-2",
|
|
171
|
-
children: F.version
|
|
192
|
+
/* @__PURE__ */ C("span", {
|
|
193
|
+
className: L,
|
|
194
|
+
children: z.name
|
|
172
195
|
})
|
|
173
196
|
] }),
|
|
174
|
-
className:
|
|
175
|
-
}), /* @__PURE__ */
|
|
197
|
+
className: W.headerText
|
|
198
|
+
}), /* @__PURE__ */ w("div", {
|
|
176
199
|
role: "toolbar",
|
|
177
|
-
"aria-label":
|
|
200
|
+
"aria-label": A,
|
|
178
201
|
className: "flex shrink-0 items-center gap-1",
|
|
179
|
-
children: [/* @__PURE__ */
|
|
180
|
-
icon: /* @__PURE__ */
|
|
202
|
+
children: [/* @__PURE__ */ C(c, {
|
|
203
|
+
icon: /* @__PURE__ */ C(h, {
|
|
181
204
|
size: i.SM,
|
|
182
205
|
stroke: a,
|
|
183
206
|
"aria-hidden": !0
|
|
184
207
|
}),
|
|
185
|
-
"aria-label":
|
|
208
|
+
"aria-label": k,
|
|
186
209
|
size: o.Small,
|
|
187
|
-
onClick:
|
|
188
|
-
}), /* @__PURE__ */
|
|
189
|
-
icon: /* @__PURE__ */
|
|
210
|
+
onClick: q
|
|
211
|
+
}), /* @__PURE__ */ C(c, {
|
|
212
|
+
icon: /* @__PURE__ */ C(m, {
|
|
190
213
|
size: i.SM,
|
|
191
214
|
stroke: a,
|
|
192
215
|
"aria-hidden": !0
|
|
193
216
|
}),
|
|
194
|
-
"aria-label":
|
|
217
|
+
"aria-label": O,
|
|
195
218
|
size: o.Small,
|
|
196
|
-
onClick:
|
|
219
|
+
onClick: D
|
|
197
220
|
})]
|
|
198
221
|
})]
|
|
199
|
-
}), /* @__PURE__ */
|
|
200
|
-
className: "relative min-h-[
|
|
201
|
-
children:
|
|
202
|
-
|
|
203
|
-
|
|
222
|
+
}), /* @__PURE__ */ w("div", {
|
|
223
|
+
className: "relative min-h-[100px] w-full",
|
|
224
|
+
children: [/* @__PURE__ */ C(l, {
|
|
225
|
+
visuallyHidden: !0,
|
|
226
|
+
as: u.Span,
|
|
227
|
+
children: Y
|
|
228
|
+
}), N ? /* @__PURE__ */ C("div", {
|
|
229
|
+
"aria-hidden": !0,
|
|
204
230
|
className: "absolute inset-0 flex items-center justify-center p-4",
|
|
205
|
-
children: /* @__PURE__ */
|
|
206
|
-
className: "
|
|
207
|
-
children:
|
|
231
|
+
children: /* @__PURE__ */ C("span", {
|
|
232
|
+
className: f(R, "text-center", W.placeholderText),
|
|
233
|
+
children: P
|
|
208
234
|
})
|
|
209
|
-
}) : /* @__PURE__ */ S
|
|
210
|
-
|
|
235
|
+
}) : /* @__PURE__ */ w(S, { children: [
|
|
236
|
+
G === E.Loading && /* @__PURE__ */ C("div", {
|
|
211
237
|
className: "absolute inset-0 flex items-center justify-center",
|
|
212
|
-
children: /* @__PURE__ */
|
|
238
|
+
children: /* @__PURE__ */ C(d, { ariaLabel: M })
|
|
213
239
|
}),
|
|
214
|
-
|
|
240
|
+
G === E.Error && /* @__PURE__ */ w("div", {
|
|
215
241
|
className: "absolute inset-0 flex flex-col items-center justify-center gap-2 p-4",
|
|
216
|
-
children: [/* @__PURE__ */
|
|
242
|
+
children: [/* @__PURE__ */ C(p, {
|
|
217
243
|
size: 40,
|
|
218
244
|
stroke: a,
|
|
219
245
|
"aria-hidden": !0,
|
|
220
|
-
className:
|
|
221
|
-
}), /* @__PURE__ */
|
|
222
|
-
|
|
223
|
-
className: "
|
|
224
|
-
children:
|
|
246
|
+
className: W.errorIcon
|
|
247
|
+
}), /* @__PURE__ */ C("p", {
|
|
248
|
+
"aria-hidden": !0,
|
|
249
|
+
className: f(R, "text-center", W.errorText),
|
|
250
|
+
children: j
|
|
225
251
|
})]
|
|
226
252
|
}),
|
|
227
|
-
|
|
228
|
-
content:
|
|
229
|
-
errorLabel:
|
|
230
|
-
onAppInfo:
|
|
231
|
-
},
|
|
232
|
-
] })
|
|
253
|
+
G === E.Ready && K && /* @__PURE__ */ C(t, {
|
|
254
|
+
content: K,
|
|
255
|
+
errorLabel: j,
|
|
256
|
+
onAppInfo: B
|
|
257
|
+
}, J)
|
|
258
|
+
] })]
|
|
233
259
|
})]
|
|
234
260
|
});
|
|
235
|
-
}),
|
|
236
|
-
let t =
|
|
237
|
-
return
|
|
261
|
+
}), K = 9e5, q = (e) => {
|
|
262
|
+
let t = b(/* @__PURE__ */ new Map()), n = b(/* @__PURE__ */ new Map());
|
|
263
|
+
return y(() => {
|
|
238
264
|
let r = (t) => `${e}:${t}`, i = (e, t) => `${r(e)}::${t ?? ""}`, a = (e, n) => {
|
|
239
265
|
let i = t.current.get(r(e));
|
|
240
|
-
if (i != null && i.seedKey === n && !(Date.now() - i.cachedAt >
|
|
266
|
+
if (i != null && i.seedKey === n && !(Date.now() - i.cachedAt > K)) return {
|
|
241
267
|
html: i.html,
|
|
242
268
|
toolResult: i.toolResult
|
|
243
269
|
};
|
|
244
270
|
}, o = (e, n, i) => {
|
|
245
271
|
let a = Date.now();
|
|
246
|
-
for (let [e, n] of t.current) a - n.cachedAt >
|
|
272
|
+
for (let [e, n] of t.current) a - n.cachedAt > K && t.current.delete(e);
|
|
247
273
|
t.current.set(r(e), {
|
|
248
274
|
...n,
|
|
249
275
|
seedKey: i,
|
|
@@ -270,4 +296,4 @@ var C = {
|
|
|
270
296
|
}, [e]);
|
|
271
297
|
};
|
|
272
298
|
//#endregion
|
|
273
|
-
export {
|
|
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 };
|
package/models/mcp-apps.d.ts
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { McpAppCanvasContent } from '@epam/ai-dial-attachment-canvas';
|
|
2
2
|
import { CallToolResult, Implementation } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* How a tool was discovered — determines whether it's safe to live-re-call
|
|
7
|
-
* (see `resolveMcpAppToolResult`) or treat as "always available" for a
|
|
8
|
-
* message with no other evidence (see `findMcpAppForMessage`).
|
|
9
|
-
*
|
|
10
|
-
* - `'direct'`: the active deployment itself IS this MCP server (whether
|
|
11
|
-
* it's a bare Toolset or an Application declaring `features.mcp`) — the
|
|
12
|
-
* host is talking to it directly, so which tool a mounted app's own
|
|
13
|
-
* invocation targets is unambiguous.
|
|
14
|
-
* - `'indirect'`: a different, tool-calling deployment's message happened to
|
|
15
|
-
* call a name prefixed with a toolset's display name; the toolset is a
|
|
16
|
-
* name-prefix *guess*, not a confirmed link the host was told about, so
|
|
17
|
-
* re-calling it live risks hitting the wrong tool or re-triggering a
|
|
18
|
-
* non-idempotent side effect.
|
|
19
|
-
*/
|
|
20
|
-
export type McpAppToolDiscovery = 'direct' | 'indirect';
|
|
3
|
+
import { McpAppToolDiscovery, McpDeploymentKind } from '../types/mcp-apps';
|
|
4
|
+
type McpUiHostContext = NonNullable<McpAppCanvasContent['hostContext']>;
|
|
21
5
|
/** A tool's declared MCP Apps UI resource, keyed by the toolset it was discovered on. */
|
|
22
6
|
export interface McpAppToolRef {
|
|
23
7
|
/** Id of the toolset/application this tool was discovered on. */
|
|
@@ -112,5 +96,21 @@ export interface McpAppInlinePreviewColors {
|
|
|
112
96
|
previewBorder?: string;
|
|
113
97
|
/** Divider under the header strip. Fallback: `--stroke-tertiary`. */
|
|
114
98
|
previewHeaderBorder?: string;
|
|
99
|
+
/** Text color of the header strip's app or tool name. Fallback: `--text-secondary`. */
|
|
100
|
+
headerText?: string;
|
|
101
|
+
/** Text color of the "opened in canvas" placeholder. Fallback: `--text-secondary`. */
|
|
102
|
+
placeholderText?: string;
|
|
103
|
+
/** Color of the load-error icon. Fallback: `--text-error`. */
|
|
104
|
+
errorIcon?: string;
|
|
105
|
+
/** Text color of the load-error message. Fallback: `--text-primary`. */
|
|
106
|
+
errorText?: string;
|
|
107
|
+
}
|
|
108
|
+
/** Typography class overrides for `McpAppInlinePreview`. */
|
|
109
|
+
export interface McpAppInlinePreviewTypography {
|
|
110
|
+
/** Typography class of the header strip's tool and app names. Defaults to `'dial-tiny-lead-semi-text'`. */
|
|
111
|
+
headerNameClassName?: string;
|
|
112
|
+
/** Typography class of the "opened in canvas" and load-error messages. Defaults to `'dial-body-text'`. */
|
|
113
|
+
messageClassName?: string;
|
|
115
114
|
}
|
|
115
|
+
export {};
|
|
116
116
|
//# 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-
|
|
4
|
+
"version": "1.3.0-rc.0",
|
|
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.98"
|
|
20
|
+
"@tabler/icons-react": "^3.50.0",
|
|
21
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
22
|
+
"@epam/ai-dial-attachment-canvas": "1.3.0-rc.0"
|
|
24
23
|
},
|
|
25
24
|
"peerDependencies": {
|
|
26
|
-
"@epam/ai-dial-chat-shared": "1.3.0-
|
|
27
|
-
"@epam/ai-dial-ui-kit": "^0.16.0
|
|
25
|
+
"@epam/ai-dial-chat-shared": "1.3.0-rc.0",
|
|
26
|
+
"@epam/ai-dial-ui-kit": "^0.16.0",
|
|
28
27
|
"react": "^19.2.8"
|
|
29
28
|
},
|
|
30
29
|
"repository": {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** 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. */
|
|
2
|
+
export declare enum McpDeploymentKind {
|
|
3
|
+
Toolset = "toolset",
|
|
4
|
+
Application = "application"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* How a tool was discovered — determines whether it's safe to live-re-call
|
|
8
|
+
* (see `resolveMcpAppToolResult`) or treat as "always available" for a
|
|
9
|
+
* message with no other evidence (see `findMcpAppForMessage`).
|
|
10
|
+
*
|
|
11
|
+
* - `Direct`: the active deployment itself IS this MCP server (whether
|
|
12
|
+
* it's a bare Toolset or an Application declaring `features.mcp`) — the
|
|
13
|
+
* host is talking to it directly, so which tool a mounted app's own
|
|
14
|
+
* invocation targets is unambiguous.
|
|
15
|
+
* - `Indirect`: a different, tool-calling deployment's message happened to
|
|
16
|
+
* call a name prefixed with a toolset's display name; the toolset is a
|
|
17
|
+
* name-prefix *guess*, not a confirmed link the host was told about, so
|
|
18
|
+
* re-calling it live risks hitting the wrong tool or re-triggering a
|
|
19
|
+
* non-idempotent side effect.
|
|
20
|
+
*/
|
|
21
|
+
export declare enum McpAppToolDiscovery {
|
|
22
|
+
Direct = "direct",
|
|
23
|
+
Indirect = "indirect"
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=mcp-apps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-apps.d.ts","sourceRoot":"","sources":["../../src/types/mcp-apps.ts"],"names":[],"mappings":"AAAA,mJAAmJ;AACnJ,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,WAAW,gBAAgB;CAC5B;AAED;;;;;;;;;;;;;;GAcG;AACH,oBAAY,mBAAmB;IAC7B,MAAM,WAAW;IACjB,QAAQ,aAAa;CACtB"}
|
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,10 +23,11 @@ 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
|
-
* If no real call matches, a `
|
|
30
|
+
* If no real call matches, a `McpAppToolDiscovery.Direct` tool (the deployment
|
|
16
31
|
* itself IS this MCP server, whether it's a bare Toolset or an Application —
|
|
17
32
|
* see `useMcpAppTools`) always wins regardless: such a deployment's own
|
|
18
33
|
* response IS its MCP App responding, and it typically never populates
|
|
@@ -21,20 +36,18 @@ export declare const collectToolCallNames: (messages: Message[]) => Set<string>;
|
|
|
21
36
|
* class of self-hosted-app gap `openspec/changes/archive/2026-09-30-mcp-apps-support/design.md`'s D9 "Known gap" documents for
|
|
22
37
|
* discovery — here it recurs at per-message matching).
|
|
23
38
|
*
|
|
24
|
-
* Otherwise (a `
|
|
39
|
+
* Otherwise (a `McpAppToolDiscovery.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
|
/**
|
|
@@ -66,28 +79,26 @@ export declare const resolveMcpAppToolCallSeed: (message: Message, toolName: str
|
|
|
66
79
|
* app's UI to render anything at all.
|
|
67
80
|
*
|
|
68
81
|
* Attempted whenever the call is confirmed safe:
|
|
69
|
-
* - `match.discovery ===
|
|
82
|
+
* - `match.discovery === McpAppToolDiscovery.Direct` — the deployment the host is talking to
|
|
70
83
|
* IS this MCP server (whether a bare Toolset or an Application), so
|
|
71
84
|
* `toolsetId`/`mcpToolName`/`kind` are unambiguous. Called even when `seed`
|
|
72
85
|
* has no `toolInput`, since a self-hosting MCP App never populates
|
|
73
86
|
* `custom_content.state` in the first place (see `findMcpAppForMessage`) —
|
|
74
87
|
* `{}` is passed instead, the same "give me your current/initial state"
|
|
75
88
|
* call the app's own resource would make on `ui/initialize`.
|
|
76
|
-
* - `seed?.toolInput != null` — a `
|
|
89
|
+
* - `seed?.toolInput != null` — a `McpAppToolDiscovery.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;AAyE5B;;;;;;;;;;;;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,SAclB,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,CAkCpC,CAAC"}
|