@epam/ai-dial-mcp-apps 1.1.0-dev.467 → 1.1.0-dev.471

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.d.ts CHANGED
@@ -4,5 +4,4 @@ export { useMcpAppResponseCache } from './hooks/useMcpAppResponseCache/useMcpApp
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
6
  export { collectToolCallNames, findMcpAppForMessage, mcpAppCanvasKey, computeMcpAppSeedKey, resolveMcpAppToolCallSeed, resolveMcpAppToolResult, } from './utils/mcp-app';
7
- export { MCP_CLIENT_INFO, MCP_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION_HEADER, MCP_SESSION_ID_HEADER, } from './constants/mcp-protocol';
8
7
  //# 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,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,0BAA0B,CAAC"}
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,GACxB,MAAM,iBAAiB,CAAC"}
package/index.js CHANGED
@@ -1,21 +1,20 @@
1
- import { MCP_CLIENT_INFO as e, MCP_PROTOCOL_VERSION as t, MCP_PROTOCOL_VERSION_HEADER as n, MCP_SESSION_ID_HEADER as r } from "./constants.js";
2
- import { AttachmentContentType as i, McpAppCanvasRenderer as a } from "@epam/ai-dial-attachment-canvas";
3
- import { DIAL_ICON_SIZE as o, DIAL_KIT_ICON_STROKE as s, ElementSize as c, GhostIconButton as l, Spinner as u } from "@epam/ai-dial-ui-kit";
4
- import { IconAlertTriangle as d, IconArrowsMaximize as f, IconRefresh as p } from "@tabler/icons-react";
5
- import { memo as m, useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
6
- import { MessageRole as b } from "@epam/ai-dial-chat-shared";
7
- import { jsx as x, jsxs as S } from "react/jsx-runtime";
1
+ import { AttachmentContentType as e, McpAppCanvasRenderer as t } from "@epam/ai-dial-attachment-canvas";
2
+ import { DIAL_ICON_SIZE as n, DIAL_KIT_ICON_STROKE as r, ElementSize as i, GhostIconButton as a, Spinner as o } from "@epam/ai-dial-ui-kit";
3
+ import { IconAlertTriangle as s, IconArrowsMaximize as c, IconRefresh as l } from "@tabler/icons-react";
4
+ import { memo as u, useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
5
+ import { MessageRole as g } from "@epam/ai-dial-chat-shared";
6
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
8
7
  //#region src/models/mcp-apps.ts
9
- var C = /* @__PURE__ */ function(e) {
8
+ var y = /* @__PURE__ */ function(e) {
10
9
  return e.Loading = "loading", e.Ready = "ready", e.Error = "error", e.Unavailable = "unavailable", e;
11
- }({}), w = (e) => {
10
+ }({}), b = (e) => {
12
11
  try {
13
12
  let t = JSON.parse(e);
14
13
  return typeof t == "object" && t ? t : {};
15
14
  } catch {
16
15
  return {};
17
16
  }
18
- }, T = (e) => {
17
+ }, x = (e) => {
19
18
  let t = /* @__PURE__ */ new Map();
20
19
  for (let n of e?.tool_messages ?? []) {
21
20
  for (let e of n.tool_calls ?? []) t.set(e.id, {
@@ -30,7 +29,7 @@ var C = /* @__PURE__ */ function(e) {
30
29
  for (let n of e?.tool_execution_history ?? []) {
31
30
  for (let e of n.tool_calls ?? []) t.set(e.id, {
32
31
  name: e.function.name,
33
- args: w(e.function.arguments)
32
+ args: b(e.function.arguments)
34
33
  });
35
34
  if (n.role === "tool" && n.tool_call_id) {
36
35
  let e = t.get(n.tool_call_id);
@@ -38,18 +37,18 @@ var C = /* @__PURE__ */ function(e) {
38
37
  }
39
38
  }
40
39
  return t;
41
- }, E = (e) => {
40
+ }, S = (e) => {
42
41
  let t = /* @__PURE__ */ new Set();
43
- for (let n of e) for (let e of T(n.custom_content?.state).values()) t.add(e.name);
42
+ for (let n of e) for (let e of x(n.custom_content?.state).values()) t.add(e.name);
44
43
  return t;
45
- }, D = (e, t, n) => {
46
- if (t.length === 0 || e.role !== b.Assistant) return;
47
- let r = new Set([...T(e.custom_content?.state).values()].map((e) => e.name));
44
+ }, C = (e, t, n) => {
45
+ if (t.length === 0 || e.role !== g.Assistant) return;
46
+ let r = new Set([...x(e.custom_content?.state).values()].map((e) => e.name));
48
47
  return t.find((e) => r.has(e.toolName)) || t.find((e) => e.discovery === "direct") || (n ? t[0] : void 0);
49
- }, O = (e) => `${e}:mcp-app`, k = (e) => e == null ? void 0 : JSON.stringify(e.toolInput ?? null), A = (e, t) => {
48
+ }, w = (e) => `${e}:mcp-app`, T = (e) => e == null ? void 0 : JSON.stringify(e.toolInput ?? null), E = (e, t) => {
50
49
  let n = e.custom_content?.state;
51
50
  if (!n) return;
52
- let r = [...T(n).values()].reverse().find((e) => e.name === t);
51
+ let r = [...x(n).values()].reverse().find((e) => e.name === t);
53
52
  if (r) return {
54
53
  toolInput: r.args,
55
54
  toolResult: r.result == null ? void 0 : { content: [{
@@ -57,144 +56,144 @@ var C = /* @__PURE__ */ function(e) {
57
56
  text: r.result
58
57
  }] }
59
58
  };
60
- }, j = async (e, t, n) => {
59
+ }, D = async (e, t, n) => {
61
60
  if (!(e.discovery === "direct" || t?.toolInput != null)) return t?.toolResult;
62
61
  try {
63
62
  return await n(e.toolsetId, e.mcpToolName, t?.toolInput ?? {}, e.kind);
64
63
  } catch {
65
64
  return t?.toolResult;
66
65
  }
67
- }, M = (e, t, n, r, a, o) => {
68
- let { hostContext: s, sandboxUrl: c, fetchResourceHtml: l, callTool: u } = a, [d, f] = y(), [p, m] = y(), [_, v] = y(() => e == null || c == null ? C.Unavailable : C.Loading), [b, x] = y(0), S = h(() => {
69
- n.invalidate(r), x((e) => e + 1);
70
- }, [n, r]), w = h(async (i) => {
71
- if (!(e == null || c == null)) try {
72
- let a = k(t), { html: o, toolResult: s } = await n.getOrFetch(r, a, async () => {
73
- let [n, r] = await Promise.all([l(e.toolsetId, e.resourceUri), j(e, t, u)]);
66
+ }, O = (t, n, r, i, a, o) => {
67
+ let { hostContext: s, sandboxUrl: c, fetchResourceHtml: l, callTool: u } = a, [p, m] = h(), [g, _] = h(), [v, b] = h(() => t == null || c == null ? y.Unavailable : y.Loading), [x, S] = h(0), C = d(() => {
68
+ r.invalidate(i), S((e) => e + 1);
69
+ }, [r, i]), w = d(async (e) => {
70
+ if (!(t == null || c == null)) try {
71
+ let a = T(n), { html: o, toolResult: s } = await r.getOrFetch(i, a, async () => {
72
+ let [e, r] = await Promise.all([l(t.toolsetId, t.resourceUri), D(t, n, u)]);
74
73
  return {
75
- html: n,
74
+ html: e,
76
75
  toolResult: r
77
76
  };
78
77
  });
79
- if (i()) return;
80
- f(o), m(s), v(C.Ready);
78
+ if (e()) return;
79
+ m(o), _(s), b(y.Ready);
81
80
  } catch {
82
- i() || v(C.Error);
81
+ e() || b(y.Error);
83
82
  }
84
83
  }, [
85
- e,
86
84
  t,
87
- c,
88
85
  n,
86
+ c,
89
87
  r,
88
+ i,
90
89
  l,
91
90
  u
92
91
  ]);
93
- g(() => {
94
- if (e == null || c == null) {
95
- v(C.Unavailable);
92
+ f(() => {
93
+ if (t == null || c == null) {
94
+ b(y.Unavailable);
96
95
  return;
97
96
  }
98
- let t = !1;
99
- return v(C.Loading), w(() => t), () => {
100
- t = !0;
97
+ let e = !1;
98
+ return b(y.Loading), w(() => e), () => {
99
+ e = !0;
101
100
  };
102
101
  }, [
103
- e,
102
+ t,
104
103
  c,
105
104
  w,
106
- b
105
+ x
107
106
  ]);
108
- let T = h(async (t, n) => {
109
- if (e == null) throw Error(`Tool call "${t}" failed: no matching MCP App`);
110
- return u(e.toolsetId, t, n, e.kind);
111
- }, [e, u]);
112
- return _ !== C.Ready || e == null || c == null || d == null ? {
113
- status: _,
114
- reload: S
107
+ let E = d(async (e, n) => {
108
+ if (t == null) throw Error(`Tool call "${e}" failed: no matching MCP App`);
109
+ return u(t.toolsetId, e, n, t.kind);
110
+ }, [t, u]);
111
+ return v !== y.Ready || t == null || c == null || p == null ? {
112
+ status: v,
113
+ reload: C
115
114
  } : {
116
- status: _,
117
- reload: S,
115
+ status: v,
116
+ reload: C,
118
117
  content: {
119
- type: i.McpApp,
120
- html: d,
118
+ type: e.McpApp,
119
+ html: p,
121
120
  sandboxUrl: c,
122
- toolInput: t?.toolInput,
123
- toolResult: p,
121
+ toolInput: n?.toolInput,
122
+ toolResult: g,
124
123
  hostContext: s,
125
- onToolCall: T,
124
+ onToolCall: E,
126
125
  onRequestDisplayMode: o
127
126
  }
128
127
  };
129
- }, N = m(({ match: e, toolCall: t, cache: n, cacheKey: r, hostAdapter: i, onExpand: m, expandAriaLabel: g, reloadAriaLabel: _, actionsGroupAriaLabel: v = "MCP app actions", loadErrorLabel: y }) => {
130
- let { status: b, content: w, reload: T } = M(e, t, n, r, i, h((e) => e === "fullscreen" ? (m(), "fullscreen") : "inline", [m]));
131
- return b === C.Unavailable ? null : /* @__PURE__ */ S("div", {
128
+ }, k = u(({ match: e, toolCall: u, cache: f, cacheKey: p, hostAdapter: m, onExpand: h, expandAriaLabel: g, reloadAriaLabel: b, actionsGroupAriaLabel: x = "MCP app actions", loadErrorLabel: S }) => {
129
+ let { status: C, content: w, reload: T } = O(e, u, f, p, m, d((e) => e === "fullscreen" ? (h(), "fullscreen") : "inline", [h]));
130
+ return C === y.Unavailable ? null : /* @__PURE__ */ v("div", {
132
131
  className: "bg-layer-2 flex w-full min-w-0 flex-col overflow-hidden rounded-xl border border-tertiary",
133
- children: [/* @__PURE__ */ x("div", {
132
+ children: [/* @__PURE__ */ _("div", {
134
133
  className: "flex min-h-10 items-center justify-end border-b border-tertiary px-4 py-2",
135
- children: /* @__PURE__ */ S("div", {
134
+ children: /* @__PURE__ */ v("div", {
136
135
  role: "toolbar",
137
- "aria-label": v,
136
+ "aria-label": x,
138
137
  className: "flex items-center gap-1",
139
- children: [/* @__PURE__ */ x(l, {
140
- icon: /* @__PURE__ */ x(p, {
141
- size: o.SM,
142
- stroke: s,
138
+ children: [/* @__PURE__ */ _(a, {
139
+ icon: /* @__PURE__ */ _(l, {
140
+ size: n.SM,
141
+ stroke: r,
143
142
  "aria-hidden": !0
144
143
  }),
145
- "aria-label": _,
146
- size: c.Small,
144
+ "aria-label": b,
145
+ size: i.Small,
147
146
  onClick: T
148
- }), /* @__PURE__ */ x(l, {
149
- icon: /* @__PURE__ */ x(f, {
150
- size: o.SM,
151
- stroke: s,
147
+ }), /* @__PURE__ */ _(a, {
148
+ icon: /* @__PURE__ */ _(c, {
149
+ size: n.SM,
150
+ stroke: r,
152
151
  "aria-hidden": !0
153
152
  }),
154
153
  "aria-label": g,
155
- size: c.Small,
156
- onClick: m
154
+ size: i.Small,
155
+ onClick: h
157
156
  })]
158
157
  })
159
- }), /* @__PURE__ */ S("div", {
158
+ }), /* @__PURE__ */ v("div", {
160
159
  className: "relative min-h-[200px] w-full",
161
160
  children: [
162
- b === C.Loading && /* @__PURE__ */ x("div", {
161
+ C === y.Loading && /* @__PURE__ */ _("div", {
163
162
  className: "absolute inset-0 flex items-center justify-center",
164
- children: /* @__PURE__ */ x(u, {})
163
+ children: /* @__PURE__ */ _(o, {})
165
164
  }),
166
- b === C.Error && /* @__PURE__ */ S("div", {
165
+ C === y.Error && /* @__PURE__ */ v("div", {
167
166
  className: "absolute inset-0 flex flex-col items-center justify-center gap-2 p-4",
168
- children: [/* @__PURE__ */ x(d, {
167
+ children: [/* @__PURE__ */ _(s, {
169
168
  size: 40,
170
- stroke: s,
169
+ stroke: r,
171
170
  "aria-hidden": !0,
172
171
  className: "text-error"
173
- }), /* @__PURE__ */ x("p", {
172
+ }), /* @__PURE__ */ _("p", {
174
173
  role: "alert",
175
174
  className: "dial-body-text text-center text-primary",
176
- children: y
175
+ children: S
177
176
  })]
178
177
  }),
179
- b === C.Ready && w && /* @__PURE__ */ x(a, {
178
+ C === y.Ready && w && /* @__PURE__ */ _(t, {
180
179
  content: w,
181
- errorLabel: y
180
+ errorLabel: S
182
181
  })
183
182
  ]
184
183
  })]
185
184
  });
186
- }), P = 900 * 1e3, F = (e) => {
187
- let t = v(/* @__PURE__ */ new Map()), n = v(/* @__PURE__ */ new Map());
188
- return _(() => {
185
+ }), A = 900 * 1e3, j = (e) => {
186
+ let t = m(/* @__PURE__ */ new Map()), n = m(/* @__PURE__ */ new Map());
187
+ return p(() => {
189
188
  let r = (t) => `${e}:${t}`, i = (e, t) => `${r(e)}::${t ?? ""}`, a = (e, n) => {
190
189
  let i = t.current.get(r(e));
191
- if (i != null && i.seedKey === n && !(Date.now() - i.cachedAt > P)) return {
190
+ if (i != null && i.seedKey === n && !(Date.now() - i.cachedAt > A)) return {
192
191
  html: i.html,
193
192
  toolResult: i.toolResult
194
193
  };
195
194
  }, o = (e, n, i) => {
196
195
  let a = Date.now();
197
- for (let [e, n] of t.current) a - n.cachedAt > P && t.current.delete(e);
196
+ for (let [e, n] of t.current) a - n.cachedAt > A && t.current.delete(e);
198
197
  t.current.set(r(e), {
199
198
  ...n,
200
199
  seedKey: i,
@@ -221,4 +220,4 @@ var C = /* @__PURE__ */ function(e) {
221
220
  }, [e]);
222
221
  };
223
222
  //#endregion
224
- export { e as MCP_CLIENT_INFO, t as MCP_PROTOCOL_VERSION, n as MCP_PROTOCOL_VERSION_HEADER, r as MCP_SESSION_ID_HEADER, N as McpAppInlinePreview, C as McpAppInlinePreviewStatus, E as collectToolCallNames, k as computeMcpAppSeedKey, D as findMcpAppForMessage, O as mcpAppCanvasKey, A as resolveMcpAppToolCallSeed, j as resolveMcpAppToolResult, M as useMcpAppInlinePreview, F as useMcpAppResponseCache };
223
+ export { k as McpAppInlinePreview, y as McpAppInlinePreviewStatus, S as collectToolCallNames, T as computeMcpAppSeedKey, C as findMcpAppForMessage, w as mcpAppCanvasKey, E as resolveMcpAppToolCallSeed, D as resolveMcpAppToolResult, O as useMcpAppInlinePreview, j 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.1.0-dev.467",
4
+ "version": "1.1.0-dev.471",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -13,20 +13,17 @@
13
13
  "types": "./index.d.ts",
14
14
  "import": "./index.js",
15
15
  "default": "./index.js"
16
- },
17
- "./constants": {
18
- "types": "./constants/mcp-protocol.d.ts",
19
- "import": "./constants.js",
20
- "default": "./constants.js"
21
16
  }
22
17
  },
18
+ "dependencies": {
19
+ "@tabler/icons-react": "^3.44.0",
20
+ "@mcp-ui/client": "^7.1.1",
21
+ "@modelcontextprotocol/sdk": "^1.29.0",
22
+ "@epam/ai-dial-attachment-canvas": "1.1.0-dev.471"
23
+ },
23
24
  "peerDependencies": {
24
- "@epam/ai-dial-attachment-canvas": "1.1.0-dev.467",
25
- "@epam/ai-dial-chat-shared": "1.1.0-dev.467",
25
+ "@epam/ai-dial-chat-shared": "1.1.0-dev.471",
26
26
  "@epam/ai-dial-ui-kit": "^0.14.0-dev.15",
27
- "@mcp-ui/client": "^7.1.1",
28
- "@modelcontextprotocol/sdk": "^1.27.1",
29
- "@tabler/icons-react": "^3.44.0",
30
27
  "react": "^19.0.0"
31
28
  },
32
29
  "repository": {
@@ -1,17 +0,0 @@
1
- /** MCP protocol version advertised in the `initialize` handshake. */
2
- export declare const MCP_PROTOCOL_VERSION = "2024-11-05";
3
- /** Header the MCP Streamable HTTP transport uses to carry the session id. */
4
- export declare const MCP_SESSION_ID_HEADER = "mcp-session-id";
5
- /**
6
- * Header carrying the protocol version the server negotiated in its
7
- * `initialize` result. The MCP lifecycle requires it on every request that
8
- * follows a completed handshake, so a server that supports several versions
9
- * keeps answering in the one it agreed on.
10
- */
11
- export declare const MCP_PROTOCOL_VERSION_HEADER = "mcp-protocol-version";
12
- /** Client identity advertised in the `initialize` handshake. */
13
- export declare const MCP_CLIENT_INFO: {
14
- name: string;
15
- version: string;
16
- };
17
- //# sourceMappingURL=mcp-protocol.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mcp-protocol.d.ts","sourceRoot":"","sources":["../../src/constants/mcp-protocol.ts"],"names":[],"mappings":"AAOA,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAEjD,6EAA6E;AAC7E,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAElE,gEAAgE;AAChE,eAAO,MAAM,eAAe;;;CAA6C,CAAC"}
package/constants.js DELETED
@@ -1,7 +0,0 @@
1
- //#region src/constants/mcp-protocol.ts
2
- var e = "2024-11-05", t = "mcp-session-id", n = "mcp-protocol-version", r = {
3
- name: "ai-dial-chat",
4
- version: "1.0.0"
5
- };
6
- //#endregion
7
- export { r as MCP_CLIENT_INFO, e as MCP_PROTOCOL_VERSION, n as MCP_PROTOCOL_VERSION_HEADER, t as MCP_SESSION_ID_HEADER };