@copilotkit/react-core 1.70.0 → 1.70.1
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/dist/{copilotkit-BuzP0VeG.d.cts → copilotkit-CtF2clxZ.d.cts} +20 -20
- package/dist/copilotkit-CtF2clxZ.d.cts.map +1 -0
- package/dist/{copilotkit-BE76j111.cjs → copilotkit-CxLT6zFx.cjs} +145 -211
- package/dist/copilotkit-CxLT6zFx.cjs.map +1 -0
- package/dist/{copilotkit-B7aFKfQR.mjs → copilotkit-DiUK2Bhq.mjs} +145 -211
- package/dist/copilotkit-DiUK2Bhq.mjs.map +1 -0
- package/dist/{copilotkit-CbZGwElm.d.mts → copilotkit-DsWuxPUQ.d.mts} +20 -20
- package/dist/copilotkit-DsWuxPUQ.d.mts.map +1 -0
- package/dist/index.cjs +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -4
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +142 -207
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +2 -1
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.mjs +2 -1
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +144 -210
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +11 -8
- package/skills/react-core/SKILL.md +1 -1
- package/skills/react-core/references/threads.md +1 -1
- package/dist/copilotkit-B7aFKfQR.mjs.map +0 -1
- package/dist/copilotkit-BE76j111.cjs.map +0 -1
- package/dist/copilotkit-BuzP0VeG.d.cts.map +0 -1
- package/dist/copilotkit-CbZGwElm.d.mts.map +0 -1
|
@@ -1765,7 +1765,6 @@ async function ɵrunMcpFollowUp({ host, agent, capturedThreadId }) {
|
|
|
1765
1765
|
newMessages: []
|
|
1766
1766
|
};
|
|
1767
1767
|
}
|
|
1768
|
-
const PROTOCOL_VERSION = "2025-06-18";
|
|
1769
1768
|
function buildSandboxHTML(extraCspDomains) {
|
|
1770
1769
|
const baseScriptSrc = "'self' 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data: http://localhost:* https://localhost:*";
|
|
1771
1770
|
const baseFrameSrc = "* blob: data: http://localhost:* https://localhost:*";
|
|
@@ -1877,6 +1876,13 @@ var MCPAppsRequestQueue = class {
|
|
|
1877
1876
|
}
|
|
1878
1877
|
};
|
|
1879
1878
|
const mcpAppsRequestQueue = new MCPAppsRequestQueue();
|
|
1879
|
+
const MCP_OPEN_LINK_BLOCKED_SCHEMES = new Set([
|
|
1880
|
+
"javascript:",
|
|
1881
|
+
"data:",
|
|
1882
|
+
"vbscript:",
|
|
1883
|
+
"blob:",
|
|
1884
|
+
"file:"
|
|
1885
|
+
]);
|
|
1880
1886
|
/**
|
|
1881
1887
|
* Activity type for MCP Apps events - must match the middleware's MCPAppsActivityType
|
|
1882
1888
|
*/
|
|
@@ -1892,18 +1898,32 @@ const MCPAppsActivityContentSchema = zod.z.object({
|
|
|
1892
1898
|
serverId: zod.z.string().optional(),
|
|
1893
1899
|
toolInput: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
1894
1900
|
});
|
|
1895
|
-
function isRequest(msg) {
|
|
1896
|
-
return "id" in msg && "method" in msg;
|
|
1897
|
-
}
|
|
1898
|
-
function isNotification(msg) {
|
|
1899
|
-
return !("id" in msg) && "method" in msg;
|
|
1900
|
-
}
|
|
1901
1901
|
/**
|
|
1902
1902
|
* MCP Apps Extension Activity Renderer
|
|
1903
1903
|
*
|
|
1904
1904
|
* Renders MCP Apps UI in a sandboxed iframe with full protocol support.
|
|
1905
1905
|
* Fetches resource content on-demand via proxied MCP requests.
|
|
1906
1906
|
*/
|
|
1907
|
+
/**
|
|
1908
|
+
* Permissive `ui/message` schema. ext-apps restricts the request to
|
|
1909
|
+
* `role: "user"` with no `followUp`, but CopilotKit intentionally extends
|
|
1910
|
+
* `ui/message` with `role` ("user" | "assistant") and `followUp` (documented
|
|
1911
|
+
* behavior with dedicated tests). We register our own handler (instead of the
|
|
1912
|
+
* bridge's strict `onmessage`) so those extensions survive the migration.
|
|
1913
|
+
*
|
|
1914
|
+
* Going forward, widgets SHOULD pass the extensions under
|
|
1915
|
+
* `params._meta.copilotkit`; the top-level `role`/`followUp` fields are the
|
|
1916
|
+
* legacy channel, kept for backward compatibility and slated for deprecation.
|
|
1917
|
+
*/
|
|
1918
|
+
const CopilotKitUiMessageSchema = zod.z.object({
|
|
1919
|
+
method: zod.z.literal("ui/message"),
|
|
1920
|
+
params: zod.z.object({
|
|
1921
|
+
role: zod.z.string().optional(),
|
|
1922
|
+
content: zod.z.array(zod.z.any()).optional(),
|
|
1923
|
+
followUp: zod.z.boolean().optional(),
|
|
1924
|
+
_meta: zod.z.record(zod.z.string(), zod.z.any()).optional()
|
|
1925
|
+
}).passthrough()
|
|
1926
|
+
});
|
|
1907
1927
|
const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agent }) {
|
|
1908
1928
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
1909
1929
|
const containerRef = (0, react.useRef)(null);
|
|
@@ -1917,41 +1937,12 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
1917
1937
|
contentRef.current = content;
|
|
1918
1938
|
const agentRef = (0, react.useRef)(agent);
|
|
1919
1939
|
agentRef.current = agent;
|
|
1940
|
+
const bridgeRef = (0, react.useRef)(null);
|
|
1920
1941
|
const fetchStateRef = (0, react.useRef)({
|
|
1921
1942
|
inProgress: false,
|
|
1922
1943
|
promise: null,
|
|
1923
1944
|
resourceUri: null
|
|
1924
1945
|
});
|
|
1925
|
-
const sendToIframe = (0, react.useCallback)((msg) => {
|
|
1926
|
-
if (iframeRef.current?.contentWindow) {
|
|
1927
|
-
console.log("[MCPAppsRenderer] Sending to iframe:", msg);
|
|
1928
|
-
iframeRef.current.contentWindow.postMessage(msg, "*");
|
|
1929
|
-
}
|
|
1930
|
-
}, []);
|
|
1931
|
-
const sendResponse = (0, react.useCallback)((id, result) => {
|
|
1932
|
-
sendToIframe({
|
|
1933
|
-
jsonrpc: "2.0",
|
|
1934
|
-
id,
|
|
1935
|
-
result
|
|
1936
|
-
});
|
|
1937
|
-
}, [sendToIframe]);
|
|
1938
|
-
const sendErrorResponse = (0, react.useCallback)((id, code, message) => {
|
|
1939
|
-
sendToIframe({
|
|
1940
|
-
jsonrpc: "2.0",
|
|
1941
|
-
id,
|
|
1942
|
-
error: {
|
|
1943
|
-
code,
|
|
1944
|
-
message
|
|
1945
|
-
}
|
|
1946
|
-
});
|
|
1947
|
-
}, [sendToIframe]);
|
|
1948
|
-
const sendNotification = (0, react.useCallback)((method, params) => {
|
|
1949
|
-
sendToIframe({
|
|
1950
|
-
jsonrpc: "2.0",
|
|
1951
|
-
method,
|
|
1952
|
-
params: params || {}
|
|
1953
|
-
});
|
|
1954
|
-
}, [sendToIframe]);
|
|
1955
1946
|
(0, react.useEffect)(() => {
|
|
1956
1947
|
const { resourceUri, serverHash, serverId } = content;
|
|
1957
1948
|
if (fetchStateRef.current.inProgress && fetchStateRef.current.resourceUri === resourceUri) {
|
|
@@ -2006,11 +1997,15 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
2006
1997
|
const container = containerRef.current;
|
|
2007
1998
|
if (!container) return;
|
|
2008
1999
|
let mounted = true;
|
|
2009
|
-
let
|
|
2010
|
-
let initialListener = null;
|
|
2000
|
+
let bridge = null;
|
|
2011
2001
|
let createdIframe = null;
|
|
2012
2002
|
const setup = async () => {
|
|
2013
2003
|
try {
|
|
2004
|
+
const bridgeModule = await import("@modelcontextprotocol/ext-apps/app-bridge").catch((importErr) => {
|
|
2005
|
+
throw new Error("MCP Apps require '@modelcontextprotocol/ext-apps' and its peer '@modelcontextprotocol/sdk'. Install them with: npm install @modelcontextprotocol/ext-apps @modelcontextprotocol/sdk", { cause: importErr });
|
|
2006
|
+
});
|
|
2007
|
+
if (!mounted) return;
|
|
2008
|
+
const { AppBridge, PostMessageTransport } = bridgeModule;
|
|
2014
2009
|
const iframe = document.createElement("iframe");
|
|
2015
2010
|
createdIframe = iframe;
|
|
2016
2011
|
iframe.style.width = "100%";
|
|
@@ -2021,151 +2016,108 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
2021
2016
|
iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
|
|
2022
2017
|
iframe.setAttribute("data-testid", "mcp-app-iframe");
|
|
2023
2018
|
iframe.setAttribute("title", "Interactive MCP application");
|
|
2024
|
-
const sandboxReady = new Promise((resolve) => {
|
|
2025
|
-
initialListener = (event) => {
|
|
2026
|
-
if (event.source === iframe.contentWindow) {
|
|
2027
|
-
if (event.data?.method === "ui/notifications/sandbox-proxy-ready") {
|
|
2028
|
-
if (initialListener) {
|
|
2029
|
-
window.removeEventListener("message", initialListener);
|
|
2030
|
-
initialListener = null;
|
|
2031
|
-
}
|
|
2032
|
-
resolve();
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
};
|
|
2036
|
-
window.addEventListener("message", initialListener);
|
|
2037
|
-
});
|
|
2038
|
-
if (!mounted) {
|
|
2039
|
-
if (initialListener) {
|
|
2040
|
-
window.removeEventListener("message", initialListener);
|
|
2041
|
-
initialListener = null;
|
|
2042
|
-
}
|
|
2043
|
-
return;
|
|
2044
|
-
}
|
|
2045
2019
|
const cspDomains = fetchedResource._meta?.ui?.csp?.resourceDomains;
|
|
2046
2020
|
iframe.srcdoc = buildSandboxHTML(cspDomains);
|
|
2047
2021
|
iframeRef.current = iframe;
|
|
2048
2022
|
container.appendChild(iframe);
|
|
2049
|
-
|
|
2050
|
-
if (!
|
|
2051
|
-
console.log("[MCPAppsRenderer] Sandbox proxy ready");
|
|
2052
|
-
messageHandler = async (event) => {
|
|
2053
|
-
if (event.source !== iframe.contentWindow) return;
|
|
2054
|
-
const msg = event.data;
|
|
2055
|
-
if (!msg || typeof msg !== "object" || msg.jsonrpc !== "2.0") return;
|
|
2056
|
-
console.log("[MCPAppsRenderer] Received from iframe:", msg);
|
|
2057
|
-
if (isRequest(msg)) switch (msg.method) {
|
|
2058
|
-
case "ui/initialize":
|
|
2059
|
-
sendResponse(msg.id, {
|
|
2060
|
-
protocolVersion: PROTOCOL_VERSION,
|
|
2061
|
-
hostInfo: {
|
|
2062
|
-
name: "CopilotKit MCP Apps Host",
|
|
2063
|
-
version: "1.0.0"
|
|
2064
|
-
},
|
|
2065
|
-
hostCapabilities: {
|
|
2066
|
-
openLinks: {},
|
|
2067
|
-
logging: {}
|
|
2068
|
-
},
|
|
2069
|
-
hostContext: {
|
|
2070
|
-
theme: "light",
|
|
2071
|
-
platform: "web"
|
|
2072
|
-
}
|
|
2073
|
-
});
|
|
2074
|
-
break;
|
|
2075
|
-
case "ui/message": {
|
|
2076
|
-
const currentAgent = agentRef.current;
|
|
2077
|
-
if (!currentAgent) {
|
|
2078
|
-
console.warn("[MCPAppsRenderer] ui/message: No agent available");
|
|
2079
|
-
sendResponse(msg.id, { isError: false });
|
|
2080
|
-
break;
|
|
2081
|
-
}
|
|
2082
|
-
try {
|
|
2083
|
-
const params = msg.params;
|
|
2084
|
-
const role = params.role || "user";
|
|
2085
|
-
const textContent = params.content?.filter((c) => c.type === "text" && c.text).map((c) => c.text).join("\n") || "";
|
|
2086
|
-
if (textContent) currentAgent.addMessage({
|
|
2087
|
-
id: crypto.randomUUID(),
|
|
2088
|
-
role,
|
|
2089
|
-
content: textContent
|
|
2090
|
-
});
|
|
2091
|
-
sendResponse(msg.id, { isError: false });
|
|
2092
|
-
if ((params.followUp ?? role === "user") && textContent) {
|
|
2093
|
-
const capturedThreadId = currentAgent.threadId || "default";
|
|
2094
|
-
mcpAppsRequestQueue.enqueue(currentAgent, () => ɵrunMcpFollowUp({
|
|
2095
|
-
host: copilotkit,
|
|
2096
|
-
agent: currentAgent,
|
|
2097
|
-
capturedThreadId
|
|
2098
|
-
})).catch((err) => console.error("[MCPAppsRenderer] ui/message agent run failed:", err));
|
|
2099
|
-
}
|
|
2100
|
-
} catch (err) {
|
|
2101
|
-
console.error("[MCPAppsRenderer] ui/message error:", err);
|
|
2102
|
-
sendResponse(msg.id, { isError: true });
|
|
2103
|
-
}
|
|
2104
|
-
break;
|
|
2105
|
-
}
|
|
2106
|
-
case "ui/open-link": {
|
|
2107
|
-
const url = msg.params?.url;
|
|
2108
|
-
if (url) {
|
|
2109
|
-
window.open(url, "_blank", "noopener,noreferrer");
|
|
2110
|
-
sendResponse(msg.id, { isError: false });
|
|
2111
|
-
} else sendErrorResponse(msg.id, -32602, "Missing url parameter");
|
|
2112
|
-
break;
|
|
2113
|
-
}
|
|
2114
|
-
case "tools/call": {
|
|
2115
|
-
const { serverHash, serverId } = contentRef.current;
|
|
2116
|
-
const currentAgent = agentRef.current;
|
|
2117
|
-
if (!serverHash) {
|
|
2118
|
-
sendErrorResponse(msg.id, -32603, "No server hash available for proxying");
|
|
2119
|
-
break;
|
|
2120
|
-
}
|
|
2121
|
-
if (!currentAgent) {
|
|
2122
|
-
sendErrorResponse(msg.id, -32603, "No agent available for proxying");
|
|
2123
|
-
break;
|
|
2124
|
-
}
|
|
2125
|
-
try {
|
|
2126
|
-
const runResult = await mcpAppsRequestQueue.enqueue(currentAgent, () => currentAgent.runAgent({ forwardedProps: { __proxiedMCPRequest: {
|
|
2127
|
-
serverHash,
|
|
2128
|
-
serverId,
|
|
2129
|
-
method: "tools/call",
|
|
2130
|
-
params: msg.params
|
|
2131
|
-
} } }));
|
|
2132
|
-
sendResponse(msg.id, runResult.result || {});
|
|
2133
|
-
} catch (err) {
|
|
2134
|
-
console.error("[MCPAppsRenderer] tools/call error:", err);
|
|
2135
|
-
sendErrorResponse(msg.id, -32603, String(err));
|
|
2136
|
-
}
|
|
2137
|
-
break;
|
|
2138
|
-
}
|
|
2139
|
-
default: sendErrorResponse(msg.id, -32601, `Method not found: ${msg.method}`);
|
|
2140
|
-
}
|
|
2141
|
-
if (isNotification(msg)) switch (msg.method) {
|
|
2142
|
-
case "ui/notifications/initialized":
|
|
2143
|
-
console.log("[MCPAppsRenderer] Inner iframe initialized");
|
|
2144
|
-
if (mounted) setIframeReady(true);
|
|
2145
|
-
break;
|
|
2146
|
-
case "ui/notifications/size-changed": {
|
|
2147
|
-
const { width, height } = msg.params || {};
|
|
2148
|
-
console.log("[MCPAppsRenderer] Size change:", {
|
|
2149
|
-
width,
|
|
2150
|
-
height
|
|
2151
|
-
});
|
|
2152
|
-
if (mounted) setIframeSize({
|
|
2153
|
-
width: typeof width === "number" ? width : void 0,
|
|
2154
|
-
height: typeof height === "number" ? height : void 0
|
|
2155
|
-
});
|
|
2156
|
-
break;
|
|
2157
|
-
}
|
|
2158
|
-
case "notifications/message":
|
|
2159
|
-
console.log("[MCPAppsRenderer] App log:", msg.params);
|
|
2160
|
-
break;
|
|
2161
|
-
}
|
|
2162
|
-
};
|
|
2163
|
-
window.addEventListener("message", messageHandler);
|
|
2023
|
+
const win = iframe.contentWindow;
|
|
2024
|
+
if (!win) throw new Error("Sandbox iframe has no contentWindow");
|
|
2164
2025
|
let html;
|
|
2165
2026
|
if (fetchedResource.text) html = fetchedResource.text;
|
|
2166
2027
|
else if (fetchedResource.blob) html = atob(fetchedResource.blob);
|
|
2167
2028
|
else throw new Error("Resource has no text or blob content");
|
|
2168
|
-
|
|
2029
|
+
bridge = new AppBridge(null, {
|
|
2030
|
+
name: "CopilotKit MCP Apps Host",
|
|
2031
|
+
version: "1.0.0"
|
|
2032
|
+
}, {
|
|
2033
|
+
openLinks: {},
|
|
2034
|
+
logging: {},
|
|
2035
|
+
message: { text: {} }
|
|
2036
|
+
}, { hostContext: {
|
|
2037
|
+
theme: "light",
|
|
2038
|
+
platform: "web"
|
|
2039
|
+
} });
|
|
2040
|
+
bridge.onsandboxready = () => {
|
|
2041
|
+
bridge?.sendSandboxResourceReady({ html });
|
|
2042
|
+
};
|
|
2043
|
+
bridge.setRequestHandler(CopilotKitUiMessageSchema, async (req) => {
|
|
2044
|
+
const currentAgent = agentRef.current;
|
|
2045
|
+
if (!currentAgent) {
|
|
2046
|
+
console.warn("[MCPAppsRenderer] ui/message: No agent available");
|
|
2047
|
+
return { isError: false };
|
|
2048
|
+
}
|
|
2049
|
+
try {
|
|
2050
|
+
const params = req.params;
|
|
2051
|
+
const ck = params._meta?.copilotkit ?? {};
|
|
2052
|
+
const role = ck.role || params.role || "user";
|
|
2053
|
+
const textContent = params.content?.filter((c) => c.type === "text" && c.text).map((c) => c.text).join("\n") || "";
|
|
2054
|
+
if (textContent) currentAgent.addMessage({
|
|
2055
|
+
id: crypto.randomUUID(),
|
|
2056
|
+
role,
|
|
2057
|
+
content: textContent
|
|
2058
|
+
});
|
|
2059
|
+
if ((ck.followUp ?? params.followUp ?? role === "user") && textContent) {
|
|
2060
|
+
const capturedThreadId = currentAgent.threadId || "default";
|
|
2061
|
+
mcpAppsRequestQueue.enqueue(currentAgent, () => ɵrunMcpFollowUp({
|
|
2062
|
+
host: copilotkit,
|
|
2063
|
+
agent: currentAgent,
|
|
2064
|
+
capturedThreadId
|
|
2065
|
+
})).catch((err) => console.error("[MCPAppsRenderer] ui/message agent run failed:", err));
|
|
2066
|
+
}
|
|
2067
|
+
return { isError: false };
|
|
2068
|
+
} catch (err) {
|
|
2069
|
+
console.error("[MCPAppsRenderer] ui/message error:", err);
|
|
2070
|
+
return { isError: true };
|
|
2071
|
+
}
|
|
2072
|
+
});
|
|
2073
|
+
bridge.onopenlink = async ({ url }) => {
|
|
2074
|
+
let parsed;
|
|
2075
|
+
try {
|
|
2076
|
+
parsed = new URL(url);
|
|
2077
|
+
} catch {
|
|
2078
|
+
console.warn("[MCPAppsRenderer] ui/open-link rejected: unparseable url");
|
|
2079
|
+
return { isError: true };
|
|
2080
|
+
}
|
|
2081
|
+
if (MCP_OPEN_LINK_BLOCKED_SCHEMES.has(parsed.protocol)) {
|
|
2082
|
+
console.warn("[MCPAppsRenderer] ui/open-link rejected: blocked scheme", parsed.protocol);
|
|
2083
|
+
return { isError: true };
|
|
2084
|
+
}
|
|
2085
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
2086
|
+
return { isError: false };
|
|
2087
|
+
};
|
|
2088
|
+
bridge.oncalltool = async (params) => {
|
|
2089
|
+
const { serverHash, serverId } = contentRef.current;
|
|
2090
|
+
const currentAgent = agentRef.current;
|
|
2091
|
+
if (!serverHash) throw new Error("No server hash available for proxying");
|
|
2092
|
+
if (!currentAgent) throw new Error("No agent available for proxying");
|
|
2093
|
+
return (await mcpAppsRequestQueue.enqueue(currentAgent, () => currentAgent.runAgent({ forwardedProps: { __proxiedMCPRequest: {
|
|
2094
|
+
serverHash,
|
|
2095
|
+
serverId,
|
|
2096
|
+
method: "tools/call",
|
|
2097
|
+
params
|
|
2098
|
+
} } }))).result || { content: [] };
|
|
2099
|
+
};
|
|
2100
|
+
bridge.onsizechange = (p) => {
|
|
2101
|
+
if (!mounted) return;
|
|
2102
|
+
const { width, height } = p || {};
|
|
2103
|
+
setIframeSize({
|
|
2104
|
+
width: typeof width === "number" ? width : void 0,
|
|
2105
|
+
height: typeof height === "number" ? height : void 0
|
|
2106
|
+
});
|
|
2107
|
+
};
|
|
2108
|
+
bridge.oninitialized = () => {
|
|
2109
|
+
if (mounted) setIframeReady(true);
|
|
2110
|
+
};
|
|
2111
|
+
bridge.onloggingmessage = (p) => {
|
|
2112
|
+
console.log("[MCPAppsRenderer] App log:", p);
|
|
2113
|
+
};
|
|
2114
|
+
const transport = new PostMessageTransport(win, win);
|
|
2115
|
+
await bridge.connect(transport);
|
|
2116
|
+
if (!mounted) {
|
|
2117
|
+
await bridge.close();
|
|
2118
|
+
return;
|
|
2119
|
+
}
|
|
2120
|
+
bridgeRef.current = bridge;
|
|
2169
2121
|
} catch (err) {
|
|
2170
2122
|
console.error("[MCPAppsRenderer] Setup error:", err);
|
|
2171
2123
|
if (mounted) setError(err instanceof Error ? err : new Error(String(err)));
|
|
@@ -2174,11 +2126,8 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
2174
2126
|
setup();
|
|
2175
2127
|
return () => {
|
|
2176
2128
|
mounted = false;
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
initialListener = null;
|
|
2180
|
-
}
|
|
2181
|
-
if (messageHandler) window.removeEventListener("message", messageHandler);
|
|
2129
|
+
bridgeRef.current = null;
|
|
2130
|
+
bridge?.close();
|
|
2182
2131
|
if (createdIframe) {
|
|
2183
2132
|
createdIframe.remove();
|
|
2184
2133
|
createdIframe = null;
|
|
@@ -2188,9 +2137,7 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
2188
2137
|
}, [
|
|
2189
2138
|
isLoading,
|
|
2190
2139
|
fetchedResource,
|
|
2191
|
-
|
|
2192
|
-
sendResponse,
|
|
2193
|
-
sendErrorResponse
|
|
2140
|
+
copilotkit
|
|
2194
2141
|
]);
|
|
2195
2142
|
(0, react.useEffect)(() => {
|
|
2196
2143
|
if (iframeRef.current) {
|
|
@@ -2202,25 +2149,11 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
2202
2149
|
}
|
|
2203
2150
|
}, [iframeSize]);
|
|
2204
2151
|
(0, react.useEffect)(() => {
|
|
2205
|
-
if (iframeReady && content.toolInput) {
|
|
2206
|
-
|
|
2207
|
-
sendNotification("ui/notifications/tool-input", { arguments: content.toolInput });
|
|
2208
|
-
}
|
|
2209
|
-
}, [
|
|
2210
|
-
iframeReady,
|
|
2211
|
-
content.toolInput,
|
|
2212
|
-
sendNotification
|
|
2213
|
-
]);
|
|
2152
|
+
if (iframeReady && content.toolInput) bridgeRef.current?.sendToolInput({ arguments: content.toolInput });
|
|
2153
|
+
}, [iframeReady, content.toolInput]);
|
|
2214
2154
|
(0, react.useEffect)(() => {
|
|
2215
|
-
if (iframeReady && content.result)
|
|
2216
|
-
|
|
2217
|
-
sendNotification("ui/notifications/tool-result", content.result);
|
|
2218
|
-
}
|
|
2219
|
-
}, [
|
|
2220
|
-
iframeReady,
|
|
2221
|
-
content.result,
|
|
2222
|
-
sendNotification
|
|
2223
|
-
]);
|
|
2155
|
+
if (iframeReady && content.result) bridgeRef.current?.sendToolResult(content.result);
|
|
2156
|
+
}, [iframeReady, content.result]);
|
|
2224
2157
|
const borderStyle = fetchedResource?._meta?.ui?.prefersBorder === true ? {
|
|
2225
2158
|
borderRadius: "8px",
|
|
2226
2159
|
backgroundColor: "#f9f9f9",
|
|
@@ -4035,7 +3968,8 @@ function useFrontendTool(tool, deps) {
|
|
|
4035
3968
|
tool.name,
|
|
4036
3969
|
tool.available,
|
|
4037
3970
|
copilotkit,
|
|
4038
|
-
JSON.stringify(extraDeps)
|
|
3971
|
+
JSON.stringify(extraDeps),
|
|
3972
|
+
JSON.stringify(tool.webmcp ?? null)
|
|
4039
3973
|
]);
|
|
4040
3974
|
}
|
|
4041
3975
|
|
|
@@ -5829,9 +5763,9 @@ const DEFAULT_CONTAINERS = ["project"];
|
|
|
5829
5763
|
* }
|
|
5830
5764
|
* ```
|
|
5831
5765
|
*
|
|
5832
|
-
* @deprecated
|
|
5833
|
-
*
|
|
5834
|
-
*
|
|
5766
|
+
* @deprecated This hook supports only the legacy plural-container annotation.
|
|
5767
|
+
* Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
|
|
5768
|
+
* Intelligence runtimes.
|
|
5835
5769
|
*/
|
|
5836
5770
|
function useLearningContainers({ threadId, learningContainers }) {
|
|
5837
5771
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
@@ -5935,9 +5869,9 @@ function useLearningContainers({ threadId, learningContainers }) {
|
|
|
5935
5869
|
* }
|
|
5936
5870
|
* ```
|
|
5937
5871
|
*
|
|
5938
|
-
* @deprecated
|
|
5939
|
-
*
|
|
5940
|
-
*
|
|
5872
|
+
* @deprecated This hook supports only the legacy plural-container annotation.
|
|
5873
|
+
* Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
|
|
5874
|
+
* Intelligence runtimes.
|
|
5941
5875
|
*/
|
|
5942
5876
|
function useLearningContainersInCurrentThread({ learningContainers }) {
|
|
5943
5877
|
const threadId = useCopilotChatConfiguration()?.threadId;
|
|
@@ -10942,7 +10876,7 @@ const getErrorActions = (error) => {
|
|
|
10942
10876
|
switch (error.code) {
|
|
10943
10877
|
case _copilotkit_shared.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR: return { primary: {
|
|
10944
10878
|
label: "Show me how",
|
|
10945
|
-
onClick: () => window.open("https://docs.copilotkit.ai/
|
|
10879
|
+
onClick: () => window.open("https://docs.copilotkit.ai/intelligence/overview#plans-and-access", "_blank", "noopener,noreferrer")
|
|
10946
10880
|
} };
|
|
10947
10881
|
case _copilotkit_shared.CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR: return { primary: {
|
|
10948
10882
|
label: "Upgrade",
|
|
@@ -12689,4 +12623,4 @@ Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
|
|
|
12689
12623
|
return ɵrunMcpFollowUp;
|
|
12690
12624
|
}
|
|
12691
12625
|
});
|
|
12692
|
-
//# sourceMappingURL=copilotkit-
|
|
12626
|
+
//# sourceMappingURL=copilotkit-CxLT6zFx.cjs.map
|