@epam/ai-dial-mcp-apps 1.3.0-dev.305 → 1.3.0-dev.310
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/index.js +43 -37
- package/package.json +4 -4
- package/utils/mcp-app.d.ts +3 -2
- package/utils/mcp-app.d.ts.map +1 -1
package/index.js
CHANGED
|
@@ -10,14 +10,14 @@ var T = {
|
|
|
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
|
-
}({}), D = (e) => {
|
|
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 T = {
|
|
|
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,21 +40,21 @@ var T = {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
return t;
|
|
43
|
-
},
|
|
44
|
-
let t = e.replace(
|
|
45
|
-
return t !== "" && !/^[a-zA-Z_]/.test(t) && (t = `_${t}`), t.slice(0,
|
|
46
|
-
},
|
|
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) => {
|
|
47
47
|
let t = /* @__PURE__ */ new Set();
|
|
48
|
-
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);
|
|
49
49
|
return t;
|
|
50
|
-
},
|
|
50
|
+
}, I = (e, t) => {
|
|
51
51
|
if (t.length === 0 || e.role !== n.Assistant) return;
|
|
52
|
-
let r = new Set([...
|
|
52
|
+
let r = new Set([...j(e.custom_content?.state).values()].filter((e) => e.result != null).map((e) => e.name));
|
|
53
53
|
return t.find((e) => r.has(e.toolName)) || t.find((e) => e.discovery === "direct");
|
|
54
|
-
},
|
|
54
|
+
}, L = (e) => `${e}:mcp-app`, R = (e) => e == null ? void 0 : JSON.stringify(e.toolInput ?? null), z = (e, t) => {
|
|
55
55
|
let n = e.custom_content?.state;
|
|
56
56
|
if (!n) return;
|
|
57
|
-
let r = [...
|
|
57
|
+
let r = [...j(n).values()].reverse().find((e) => e.name === t);
|
|
58
58
|
if (r) return {
|
|
59
59
|
toolInput: r.args,
|
|
60
60
|
toolResult: r.result == null ? void 0 : { content: [{
|
|
@@ -62,24 +62,30 @@ var T = {
|
|
|
62
62
|
text: r.result
|
|
63
63
|
}] }
|
|
64
64
|
};
|
|
65
|
-
},
|
|
65
|
+
}, B = async (e, t, n) => {
|
|
66
66
|
if (e.discovery !== "direct" && t?.toolInput == null) return t?.toolResult;
|
|
67
|
+
let r = () => n(e.toolsetId, e.mcpToolName, t?.toolInput ?? {}, e.kind);
|
|
67
68
|
try {
|
|
68
|
-
return await
|
|
69
|
+
return await r();
|
|
70
|
+
} catch {
|
|
71
|
+
await k(D + Math.random() * O);
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
return await r();
|
|
69
75
|
} catch {
|
|
70
76
|
return t?.toolResult;
|
|
71
77
|
}
|
|
72
|
-
},
|
|
78
|
+
}, V = (t, n, r, i, a, o) => {
|
|
73
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);
|
|
74
80
|
v(() => {
|
|
75
81
|
S.current = n;
|
|
76
82
|
});
|
|
77
|
-
let C =
|
|
83
|
+
let C = R(n), [w, T] = x(() => t == null || l == null ? E.Unavailable : E.Loading), [D, O] = x(0), k = _(() => {
|
|
78
84
|
r.invalidate(i), O((e) => e + 1);
|
|
79
85
|
}, [r, i]), A = _(async (e) => {
|
|
80
86
|
if (t != null && l != null) try {
|
|
81
87
|
let n = S.current, { html: a, toolResult: o } = await r.getOrFetch(i, C, async () => {
|
|
82
|
-
let [e, r] = await Promise.all([u(t.toolsetId, t.resourceUri),
|
|
88
|
+
let [e, r] = await Promise.all([u(t.toolsetId, t.resourceUri), B(t, n, d)]);
|
|
83
89
|
return {
|
|
84
90
|
html: e,
|
|
85
91
|
toolResult: r
|
|
@@ -138,17 +144,17 @@ var T = {
|
|
|
138
144
|
onRequestDisplayMode: o
|
|
139
145
|
}
|
|
140
146
|
};
|
|
141
|
-
},
|
|
147
|
+
}, H = {
|
|
142
148
|
preview: "_preview_1xqr3_10",
|
|
143
149
|
previewHeader: "_previewHeader_1xqr3_22",
|
|
144
150
|
headerText: "_headerText_1xqr3_26",
|
|
145
151
|
placeholderText: "_placeholderText_1xqr3_30",
|
|
146
152
|
errorIcon: "_errorIcon_1xqr3_34",
|
|
147
153
|
errorText: "_errorText_1xqr3_38"
|
|
148
|
-
},
|
|
149
|
-
let { headerNameClassName: I = "dial-tiny-lead-semi-text", versionClassName: L = "dial-caption-text", messageClassName:
|
|
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, isOpenedInCanvas: M = !1, openedInCanvasLabel: N, colors: P, typography: F }) => {
|
|
155
|
+
let { headerNameClassName: I = "dial-tiny-lead-semi-text", versionClassName: L = "dial-caption-text", messageClassName: R = "dial-body-text" } = F ?? {}, [z, B] = x(void 0);
|
|
150
156
|
v(() => {
|
|
151
|
-
|
|
157
|
+
B(void 0);
|
|
152
158
|
}, [y]);
|
|
153
159
|
let U = _((e) => e === "fullscreen" ? (D(), "fullscreen") : "inline", [D]), W = r({
|
|
154
160
|
"--mcpapp-preview-bg": P?.previewBackground,
|
|
@@ -158,14 +164,14 @@ var T = {
|
|
|
158
164
|
"--mcpapp-placeholder-text": P?.placeholderText,
|
|
159
165
|
"--mcpapp-error-icon": P?.errorIcon,
|
|
160
166
|
"--mcpapp-error-text": P?.errorText
|
|
161
|
-
}), { status: G, content: K, reload: q, attemptId: J } =
|
|
167
|
+
}), { status: G, content: K, reload: q, attemptId: J } = V(e, n, g, y, b, U);
|
|
162
168
|
return G === E.Unavailable ? null : /* @__PURE__ */ w("div", {
|
|
163
169
|
style: W,
|
|
164
|
-
className: f(
|
|
170
|
+
className: f(H.preview, "flex w-full min-w-0 flex-col overflow-hidden rounded-xl border", T.preview),
|
|
165
171
|
children: [/* @__PURE__ */ w("div", {
|
|
166
|
-
className: f(
|
|
172
|
+
className: f(H.previewHeader, "flex min-h-10 items-center justify-between gap-2 border-b px-4 py-2", T.previewHeader),
|
|
167
173
|
children: [/* @__PURE__ */ C(s, {
|
|
168
|
-
text:
|
|
174
|
+
text: z == null ? /* @__PURE__ */ C("span", {
|
|
169
175
|
className: I,
|
|
170
176
|
children: e.mcpToolName
|
|
171
177
|
}) : /* @__PURE__ */ w(S, { children: [
|
|
@@ -179,14 +185,14 @@ var T = {
|
|
|
179
185
|
}),
|
|
180
186
|
/* @__PURE__ */ C("span", {
|
|
181
187
|
className: I,
|
|
182
|
-
children:
|
|
188
|
+
children: z.name
|
|
183
189
|
}),
|
|
184
|
-
|
|
190
|
+
z.version && /* @__PURE__ */ C("span", {
|
|
185
191
|
className: f(L, "ms-2"),
|
|
186
|
-
children:
|
|
192
|
+
children: z.version
|
|
187
193
|
})
|
|
188
194
|
] }),
|
|
189
|
-
className:
|
|
195
|
+
className: H.headerText
|
|
190
196
|
}), /* @__PURE__ */ w("div", {
|
|
191
197
|
role: "toolbar",
|
|
192
198
|
"aria-label": A,
|
|
@@ -221,7 +227,7 @@ var T = {
|
|
|
221
227
|
"aria-hidden": !0,
|
|
222
228
|
className: "absolute inset-0 flex items-center justify-center p-4",
|
|
223
229
|
children: /* @__PURE__ */ C("span", {
|
|
224
|
-
className: f(
|
|
230
|
+
className: f(R, "text-center", H.placeholderText),
|
|
225
231
|
children: N
|
|
226
232
|
})
|
|
227
233
|
}) : /* @__PURE__ */ w(S, { children: [
|
|
@@ -235,33 +241,33 @@ var T = {
|
|
|
235
241
|
size: 40,
|
|
236
242
|
stroke: a,
|
|
237
243
|
"aria-hidden": !0,
|
|
238
|
-
className:
|
|
244
|
+
className: H.errorIcon
|
|
239
245
|
}), /* @__PURE__ */ C("p", {
|
|
240
246
|
role: "status",
|
|
241
|
-
className: f(
|
|
247
|
+
className: f(R, "text-center", H.errorText),
|
|
242
248
|
children: j
|
|
243
249
|
})]
|
|
244
250
|
}),
|
|
245
251
|
G === E.Ready && K && /* @__PURE__ */ C(t, {
|
|
246
252
|
content: K,
|
|
247
253
|
errorLabel: j,
|
|
248
|
-
onAppInfo:
|
|
254
|
+
onAppInfo: B
|
|
249
255
|
}, J)
|
|
250
256
|
] })]
|
|
251
257
|
})]
|
|
252
258
|
});
|
|
253
|
-
}),
|
|
259
|
+
}), W = 9e5, G = (e) => {
|
|
254
260
|
let t = b(/* @__PURE__ */ new Map()), n = b(/* @__PURE__ */ new Map());
|
|
255
261
|
return y(() => {
|
|
256
262
|
let r = (t) => `${e}:${t}`, i = (e, t) => `${r(e)}::${t ?? ""}`, a = (e, n) => {
|
|
257
263
|
let i = t.current.get(r(e));
|
|
258
|
-
if (i != null && i.seedKey === n && !(Date.now() - i.cachedAt >
|
|
264
|
+
if (i != null && i.seedKey === n && !(Date.now() - i.cachedAt > W)) return {
|
|
259
265
|
html: i.html,
|
|
260
266
|
toolResult: i.toolResult
|
|
261
267
|
};
|
|
262
268
|
}, o = (e, n, i) => {
|
|
263
269
|
let a = Date.now();
|
|
264
|
-
for (let [e, n] of t.current) a - n.cachedAt >
|
|
270
|
+
for (let [e, n] of t.current) a - n.cachedAt > W && t.current.delete(e);
|
|
265
271
|
t.current.set(r(e), {
|
|
266
272
|
...n,
|
|
267
273
|
seedKey: i,
|
|
@@ -288,4 +294,4 @@ var T = {
|
|
|
288
294
|
}, [e]);
|
|
289
295
|
};
|
|
290
296
|
//#endregion
|
|
291
|
-
export { T as MCP_APPS_CLASS,
|
|
297
|
+
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/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.310",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@tabler/icons-react": "^3.50.0",
|
|
21
21
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
22
|
-
"@epam/ai-dial-attachment-canvas": "1.3.0-dev.
|
|
22
|
+
"@epam/ai-dial-attachment-canvas": "1.3.0-dev.310"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@epam/ai-dial-chat-shared": "1.3.0-dev.
|
|
26
|
-
"@epam/ai-dial-ui-kit": "^0.16.0-dev.
|
|
25
|
+
"@epam/ai-dial-chat-shared": "1.3.0-dev.310",
|
|
26
|
+
"@epam/ai-dial-ui-kit": "^0.16.0-dev.71",
|
|
27
27
|
"react": "^19.2.8"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
package/utils/mcp-app.d.ts
CHANGED
|
@@ -96,8 +96,9 @@ export declare const resolveMcpAppToolCallSeed: (message: Message, toolName: str
|
|
|
96
96
|
* An `indirect` match with no seed is skipped — that toolset/tool pairing
|
|
97
97
|
* is unconfirmed, and re-calling it could hit the wrong tool or re-trigger a
|
|
98
98
|
* non-idempotent side effect; it keeps `seed?.toolResult` as-is. Falls back to
|
|
99
|
-
* `seed?.toolResult` if an attempted live call fails (e.g. the
|
|
100
|
-
* has no live MCP session outside the original conversation turn).
|
|
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.
|
|
101
102
|
*/
|
|
102
103
|
export declare const resolveMcpAppToolResult: (match: McpAppToolRef, seed: McpAppToolCallSeed | undefined, callTool: CallMcpAppTool) => Promise<CallToolResult | undefined>;
|
|
103
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,EAC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