@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
|
@@ -1735,7 +1735,6 @@ async function ɵrunMcpFollowUp({ host, agent, capturedThreadId }) {
|
|
|
1735
1735
|
newMessages: []
|
|
1736
1736
|
};
|
|
1737
1737
|
}
|
|
1738
|
-
const PROTOCOL_VERSION = "2025-06-18";
|
|
1739
1738
|
function buildSandboxHTML(extraCspDomains) {
|
|
1740
1739
|
const baseScriptSrc = "'self' 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data: http://localhost:* https://localhost:*";
|
|
1741
1740
|
const baseFrameSrc = "* blob: data: http://localhost:* https://localhost:*";
|
|
@@ -1847,6 +1846,13 @@ var MCPAppsRequestQueue = class {
|
|
|
1847
1846
|
}
|
|
1848
1847
|
};
|
|
1849
1848
|
const mcpAppsRequestQueue = new MCPAppsRequestQueue();
|
|
1849
|
+
const MCP_OPEN_LINK_BLOCKED_SCHEMES = new Set([
|
|
1850
|
+
"javascript:",
|
|
1851
|
+
"data:",
|
|
1852
|
+
"vbscript:",
|
|
1853
|
+
"blob:",
|
|
1854
|
+
"file:"
|
|
1855
|
+
]);
|
|
1850
1856
|
/**
|
|
1851
1857
|
* Activity type for MCP Apps events - must match the middleware's MCPAppsActivityType
|
|
1852
1858
|
*/
|
|
@@ -1862,18 +1868,32 @@ const MCPAppsActivityContentSchema = z.object({
|
|
|
1862
1868
|
serverId: z.string().optional(),
|
|
1863
1869
|
toolInput: z.record(z.string(), z.unknown()).optional()
|
|
1864
1870
|
});
|
|
1865
|
-
function isRequest(msg) {
|
|
1866
|
-
return "id" in msg && "method" in msg;
|
|
1867
|
-
}
|
|
1868
|
-
function isNotification(msg) {
|
|
1869
|
-
return !("id" in msg) && "method" in msg;
|
|
1870
|
-
}
|
|
1871
1871
|
/**
|
|
1872
1872
|
* MCP Apps Extension Activity Renderer
|
|
1873
1873
|
*
|
|
1874
1874
|
* Renders MCP Apps UI in a sandboxed iframe with full protocol support.
|
|
1875
1875
|
* Fetches resource content on-demand via proxied MCP requests.
|
|
1876
1876
|
*/
|
|
1877
|
+
/**
|
|
1878
|
+
* Permissive `ui/message` schema. ext-apps restricts the request to
|
|
1879
|
+
* `role: "user"` with no `followUp`, but CopilotKit intentionally extends
|
|
1880
|
+
* `ui/message` with `role` ("user" | "assistant") and `followUp` (documented
|
|
1881
|
+
* behavior with dedicated tests). We register our own handler (instead of the
|
|
1882
|
+
* bridge's strict `onmessage`) so those extensions survive the migration.
|
|
1883
|
+
*
|
|
1884
|
+
* Going forward, widgets SHOULD pass the extensions under
|
|
1885
|
+
* `params._meta.copilotkit`; the top-level `role`/`followUp` fields are the
|
|
1886
|
+
* legacy channel, kept for backward compatibility and slated for deprecation.
|
|
1887
|
+
*/
|
|
1888
|
+
const CopilotKitUiMessageSchema = z.object({
|
|
1889
|
+
method: z.literal("ui/message"),
|
|
1890
|
+
params: z.object({
|
|
1891
|
+
role: z.string().optional(),
|
|
1892
|
+
content: z.array(z.any()).optional(),
|
|
1893
|
+
followUp: z.boolean().optional(),
|
|
1894
|
+
_meta: z.record(z.string(), z.any()).optional()
|
|
1895
|
+
}).passthrough()
|
|
1896
|
+
});
|
|
1877
1897
|
const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agent }) {
|
|
1878
1898
|
const { copilotkit } = useCopilotKit$1();
|
|
1879
1899
|
const containerRef = useRef(null);
|
|
@@ -1887,41 +1907,12 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
1887
1907
|
contentRef.current = content;
|
|
1888
1908
|
const agentRef = useRef(agent);
|
|
1889
1909
|
agentRef.current = agent;
|
|
1910
|
+
const bridgeRef = useRef(null);
|
|
1890
1911
|
const fetchStateRef = useRef({
|
|
1891
1912
|
inProgress: false,
|
|
1892
1913
|
promise: null,
|
|
1893
1914
|
resourceUri: null
|
|
1894
1915
|
});
|
|
1895
|
-
const sendToIframe = useCallback((msg) => {
|
|
1896
|
-
if (iframeRef.current?.contentWindow) {
|
|
1897
|
-
console.log("[MCPAppsRenderer] Sending to iframe:", msg);
|
|
1898
|
-
iframeRef.current.contentWindow.postMessage(msg, "*");
|
|
1899
|
-
}
|
|
1900
|
-
}, []);
|
|
1901
|
-
const sendResponse = useCallback((id, result) => {
|
|
1902
|
-
sendToIframe({
|
|
1903
|
-
jsonrpc: "2.0",
|
|
1904
|
-
id,
|
|
1905
|
-
result
|
|
1906
|
-
});
|
|
1907
|
-
}, [sendToIframe]);
|
|
1908
|
-
const sendErrorResponse = useCallback((id, code, message) => {
|
|
1909
|
-
sendToIframe({
|
|
1910
|
-
jsonrpc: "2.0",
|
|
1911
|
-
id,
|
|
1912
|
-
error: {
|
|
1913
|
-
code,
|
|
1914
|
-
message
|
|
1915
|
-
}
|
|
1916
|
-
});
|
|
1917
|
-
}, [sendToIframe]);
|
|
1918
|
-
const sendNotification = useCallback((method, params) => {
|
|
1919
|
-
sendToIframe({
|
|
1920
|
-
jsonrpc: "2.0",
|
|
1921
|
-
method,
|
|
1922
|
-
params: params || {}
|
|
1923
|
-
});
|
|
1924
|
-
}, [sendToIframe]);
|
|
1925
1916
|
useEffect(() => {
|
|
1926
1917
|
const { resourceUri, serverHash, serverId } = content;
|
|
1927
1918
|
if (fetchStateRef.current.inProgress && fetchStateRef.current.resourceUri === resourceUri) {
|
|
@@ -1976,11 +1967,15 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
1976
1967
|
const container = containerRef.current;
|
|
1977
1968
|
if (!container) return;
|
|
1978
1969
|
let mounted = true;
|
|
1979
|
-
let
|
|
1980
|
-
let initialListener = null;
|
|
1970
|
+
let bridge = null;
|
|
1981
1971
|
let createdIframe = null;
|
|
1982
1972
|
const setup = async () => {
|
|
1983
1973
|
try {
|
|
1974
|
+
const bridgeModule = await import("@modelcontextprotocol/ext-apps/app-bridge").catch((importErr) => {
|
|
1975
|
+
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 });
|
|
1976
|
+
});
|
|
1977
|
+
if (!mounted) return;
|
|
1978
|
+
const { AppBridge, PostMessageTransport } = bridgeModule;
|
|
1984
1979
|
const iframe = document.createElement("iframe");
|
|
1985
1980
|
createdIframe = iframe;
|
|
1986
1981
|
iframe.style.width = "100%";
|
|
@@ -1991,151 +1986,108 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
1991
1986
|
iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
|
|
1992
1987
|
iframe.setAttribute("data-testid", "mcp-app-iframe");
|
|
1993
1988
|
iframe.setAttribute("title", "Interactive MCP application");
|
|
1994
|
-
const sandboxReady = new Promise((resolve) => {
|
|
1995
|
-
initialListener = (event) => {
|
|
1996
|
-
if (event.source === iframe.contentWindow) {
|
|
1997
|
-
if (event.data?.method === "ui/notifications/sandbox-proxy-ready") {
|
|
1998
|
-
if (initialListener) {
|
|
1999
|
-
window.removeEventListener("message", initialListener);
|
|
2000
|
-
initialListener = null;
|
|
2001
|
-
}
|
|
2002
|
-
resolve();
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
};
|
|
2006
|
-
window.addEventListener("message", initialListener);
|
|
2007
|
-
});
|
|
2008
|
-
if (!mounted) {
|
|
2009
|
-
if (initialListener) {
|
|
2010
|
-
window.removeEventListener("message", initialListener);
|
|
2011
|
-
initialListener = null;
|
|
2012
|
-
}
|
|
2013
|
-
return;
|
|
2014
|
-
}
|
|
2015
1989
|
const cspDomains = fetchedResource._meta?.ui?.csp?.resourceDomains;
|
|
2016
1990
|
iframe.srcdoc = buildSandboxHTML(cspDomains);
|
|
2017
1991
|
iframeRef.current = iframe;
|
|
2018
1992
|
container.appendChild(iframe);
|
|
2019
|
-
|
|
2020
|
-
if (!
|
|
2021
|
-
console.log("[MCPAppsRenderer] Sandbox proxy ready");
|
|
2022
|
-
messageHandler = async (event) => {
|
|
2023
|
-
if (event.source !== iframe.contentWindow) return;
|
|
2024
|
-
const msg = event.data;
|
|
2025
|
-
if (!msg || typeof msg !== "object" || msg.jsonrpc !== "2.0") return;
|
|
2026
|
-
console.log("[MCPAppsRenderer] Received from iframe:", msg);
|
|
2027
|
-
if (isRequest(msg)) switch (msg.method) {
|
|
2028
|
-
case "ui/initialize":
|
|
2029
|
-
sendResponse(msg.id, {
|
|
2030
|
-
protocolVersion: PROTOCOL_VERSION,
|
|
2031
|
-
hostInfo: {
|
|
2032
|
-
name: "CopilotKit MCP Apps Host",
|
|
2033
|
-
version: "1.0.0"
|
|
2034
|
-
},
|
|
2035
|
-
hostCapabilities: {
|
|
2036
|
-
openLinks: {},
|
|
2037
|
-
logging: {}
|
|
2038
|
-
},
|
|
2039
|
-
hostContext: {
|
|
2040
|
-
theme: "light",
|
|
2041
|
-
platform: "web"
|
|
2042
|
-
}
|
|
2043
|
-
});
|
|
2044
|
-
break;
|
|
2045
|
-
case "ui/message": {
|
|
2046
|
-
const currentAgent = agentRef.current;
|
|
2047
|
-
if (!currentAgent) {
|
|
2048
|
-
console.warn("[MCPAppsRenderer] ui/message: No agent available");
|
|
2049
|
-
sendResponse(msg.id, { isError: false });
|
|
2050
|
-
break;
|
|
2051
|
-
}
|
|
2052
|
-
try {
|
|
2053
|
-
const params = msg.params;
|
|
2054
|
-
const role = params.role || "user";
|
|
2055
|
-
const textContent = params.content?.filter((c) => c.type === "text" && c.text).map((c) => c.text).join("\n") || "";
|
|
2056
|
-
if (textContent) currentAgent.addMessage({
|
|
2057
|
-
id: crypto.randomUUID(),
|
|
2058
|
-
role,
|
|
2059
|
-
content: textContent
|
|
2060
|
-
});
|
|
2061
|
-
sendResponse(msg.id, { isError: false });
|
|
2062
|
-
if ((params.followUp ?? role === "user") && textContent) {
|
|
2063
|
-
const capturedThreadId = currentAgent.threadId || "default";
|
|
2064
|
-
mcpAppsRequestQueue.enqueue(currentAgent, () => ɵrunMcpFollowUp({
|
|
2065
|
-
host: copilotkit,
|
|
2066
|
-
agent: currentAgent,
|
|
2067
|
-
capturedThreadId
|
|
2068
|
-
})).catch((err) => console.error("[MCPAppsRenderer] ui/message agent run failed:", err));
|
|
2069
|
-
}
|
|
2070
|
-
} catch (err) {
|
|
2071
|
-
console.error("[MCPAppsRenderer] ui/message error:", err);
|
|
2072
|
-
sendResponse(msg.id, { isError: true });
|
|
2073
|
-
}
|
|
2074
|
-
break;
|
|
2075
|
-
}
|
|
2076
|
-
case "ui/open-link": {
|
|
2077
|
-
const url = msg.params?.url;
|
|
2078
|
-
if (url) {
|
|
2079
|
-
window.open(url, "_blank", "noopener,noreferrer");
|
|
2080
|
-
sendResponse(msg.id, { isError: false });
|
|
2081
|
-
} else sendErrorResponse(msg.id, -32602, "Missing url parameter");
|
|
2082
|
-
break;
|
|
2083
|
-
}
|
|
2084
|
-
case "tools/call": {
|
|
2085
|
-
const { serverHash, serverId } = contentRef.current;
|
|
2086
|
-
const currentAgent = agentRef.current;
|
|
2087
|
-
if (!serverHash) {
|
|
2088
|
-
sendErrorResponse(msg.id, -32603, "No server hash available for proxying");
|
|
2089
|
-
break;
|
|
2090
|
-
}
|
|
2091
|
-
if (!currentAgent) {
|
|
2092
|
-
sendErrorResponse(msg.id, -32603, "No agent available for proxying");
|
|
2093
|
-
break;
|
|
2094
|
-
}
|
|
2095
|
-
try {
|
|
2096
|
-
const runResult = await mcpAppsRequestQueue.enqueue(currentAgent, () => currentAgent.runAgent({ forwardedProps: { __proxiedMCPRequest: {
|
|
2097
|
-
serverHash,
|
|
2098
|
-
serverId,
|
|
2099
|
-
method: "tools/call",
|
|
2100
|
-
params: msg.params
|
|
2101
|
-
} } }));
|
|
2102
|
-
sendResponse(msg.id, runResult.result || {});
|
|
2103
|
-
} catch (err) {
|
|
2104
|
-
console.error("[MCPAppsRenderer] tools/call error:", err);
|
|
2105
|
-
sendErrorResponse(msg.id, -32603, String(err));
|
|
2106
|
-
}
|
|
2107
|
-
break;
|
|
2108
|
-
}
|
|
2109
|
-
default: sendErrorResponse(msg.id, -32601, `Method not found: ${msg.method}`);
|
|
2110
|
-
}
|
|
2111
|
-
if (isNotification(msg)) switch (msg.method) {
|
|
2112
|
-
case "ui/notifications/initialized":
|
|
2113
|
-
console.log("[MCPAppsRenderer] Inner iframe initialized");
|
|
2114
|
-
if (mounted) setIframeReady(true);
|
|
2115
|
-
break;
|
|
2116
|
-
case "ui/notifications/size-changed": {
|
|
2117
|
-
const { width, height } = msg.params || {};
|
|
2118
|
-
console.log("[MCPAppsRenderer] Size change:", {
|
|
2119
|
-
width,
|
|
2120
|
-
height
|
|
2121
|
-
});
|
|
2122
|
-
if (mounted) setIframeSize({
|
|
2123
|
-
width: typeof width === "number" ? width : void 0,
|
|
2124
|
-
height: typeof height === "number" ? height : void 0
|
|
2125
|
-
});
|
|
2126
|
-
break;
|
|
2127
|
-
}
|
|
2128
|
-
case "notifications/message":
|
|
2129
|
-
console.log("[MCPAppsRenderer] App log:", msg.params);
|
|
2130
|
-
break;
|
|
2131
|
-
}
|
|
2132
|
-
};
|
|
2133
|
-
window.addEventListener("message", messageHandler);
|
|
1993
|
+
const win = iframe.contentWindow;
|
|
1994
|
+
if (!win) throw new Error("Sandbox iframe has no contentWindow");
|
|
2134
1995
|
let html;
|
|
2135
1996
|
if (fetchedResource.text) html = fetchedResource.text;
|
|
2136
1997
|
else if (fetchedResource.blob) html = atob(fetchedResource.blob);
|
|
2137
1998
|
else throw new Error("Resource has no text or blob content");
|
|
2138
|
-
|
|
1999
|
+
bridge = new AppBridge(null, {
|
|
2000
|
+
name: "CopilotKit MCP Apps Host",
|
|
2001
|
+
version: "1.0.0"
|
|
2002
|
+
}, {
|
|
2003
|
+
openLinks: {},
|
|
2004
|
+
logging: {},
|
|
2005
|
+
message: { text: {} }
|
|
2006
|
+
}, { hostContext: {
|
|
2007
|
+
theme: "light",
|
|
2008
|
+
platform: "web"
|
|
2009
|
+
} });
|
|
2010
|
+
bridge.onsandboxready = () => {
|
|
2011
|
+
bridge?.sendSandboxResourceReady({ html });
|
|
2012
|
+
};
|
|
2013
|
+
bridge.setRequestHandler(CopilotKitUiMessageSchema, async (req) => {
|
|
2014
|
+
const currentAgent = agentRef.current;
|
|
2015
|
+
if (!currentAgent) {
|
|
2016
|
+
console.warn("[MCPAppsRenderer] ui/message: No agent available");
|
|
2017
|
+
return { isError: false };
|
|
2018
|
+
}
|
|
2019
|
+
try {
|
|
2020
|
+
const params = req.params;
|
|
2021
|
+
const ck = params._meta?.copilotkit ?? {};
|
|
2022
|
+
const role = ck.role || params.role || "user";
|
|
2023
|
+
const textContent = params.content?.filter((c) => c.type === "text" && c.text).map((c) => c.text).join("\n") || "";
|
|
2024
|
+
if (textContent) currentAgent.addMessage({
|
|
2025
|
+
id: crypto.randomUUID(),
|
|
2026
|
+
role,
|
|
2027
|
+
content: textContent
|
|
2028
|
+
});
|
|
2029
|
+
if ((ck.followUp ?? params.followUp ?? role === "user") && textContent) {
|
|
2030
|
+
const capturedThreadId = currentAgent.threadId || "default";
|
|
2031
|
+
mcpAppsRequestQueue.enqueue(currentAgent, () => ɵrunMcpFollowUp({
|
|
2032
|
+
host: copilotkit,
|
|
2033
|
+
agent: currentAgent,
|
|
2034
|
+
capturedThreadId
|
|
2035
|
+
})).catch((err) => console.error("[MCPAppsRenderer] ui/message agent run failed:", err));
|
|
2036
|
+
}
|
|
2037
|
+
return { isError: false };
|
|
2038
|
+
} catch (err) {
|
|
2039
|
+
console.error("[MCPAppsRenderer] ui/message error:", err);
|
|
2040
|
+
return { isError: true };
|
|
2041
|
+
}
|
|
2042
|
+
});
|
|
2043
|
+
bridge.onopenlink = async ({ url }) => {
|
|
2044
|
+
let parsed;
|
|
2045
|
+
try {
|
|
2046
|
+
parsed = new URL(url);
|
|
2047
|
+
} catch {
|
|
2048
|
+
console.warn("[MCPAppsRenderer] ui/open-link rejected: unparseable url");
|
|
2049
|
+
return { isError: true };
|
|
2050
|
+
}
|
|
2051
|
+
if (MCP_OPEN_LINK_BLOCKED_SCHEMES.has(parsed.protocol)) {
|
|
2052
|
+
console.warn("[MCPAppsRenderer] ui/open-link rejected: blocked scheme", parsed.protocol);
|
|
2053
|
+
return { isError: true };
|
|
2054
|
+
}
|
|
2055
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
2056
|
+
return { isError: false };
|
|
2057
|
+
};
|
|
2058
|
+
bridge.oncalltool = async (params) => {
|
|
2059
|
+
const { serverHash, serverId } = contentRef.current;
|
|
2060
|
+
const currentAgent = agentRef.current;
|
|
2061
|
+
if (!serverHash) throw new Error("No server hash available for proxying");
|
|
2062
|
+
if (!currentAgent) throw new Error("No agent available for proxying");
|
|
2063
|
+
return (await mcpAppsRequestQueue.enqueue(currentAgent, () => currentAgent.runAgent({ forwardedProps: { __proxiedMCPRequest: {
|
|
2064
|
+
serverHash,
|
|
2065
|
+
serverId,
|
|
2066
|
+
method: "tools/call",
|
|
2067
|
+
params
|
|
2068
|
+
} } }))).result || { content: [] };
|
|
2069
|
+
};
|
|
2070
|
+
bridge.onsizechange = (p) => {
|
|
2071
|
+
if (!mounted) return;
|
|
2072
|
+
const { width, height } = p || {};
|
|
2073
|
+
setIframeSize({
|
|
2074
|
+
width: typeof width === "number" ? width : void 0,
|
|
2075
|
+
height: typeof height === "number" ? height : void 0
|
|
2076
|
+
});
|
|
2077
|
+
};
|
|
2078
|
+
bridge.oninitialized = () => {
|
|
2079
|
+
if (mounted) setIframeReady(true);
|
|
2080
|
+
};
|
|
2081
|
+
bridge.onloggingmessage = (p) => {
|
|
2082
|
+
console.log("[MCPAppsRenderer] App log:", p);
|
|
2083
|
+
};
|
|
2084
|
+
const transport = new PostMessageTransport(win, win);
|
|
2085
|
+
await bridge.connect(transport);
|
|
2086
|
+
if (!mounted) {
|
|
2087
|
+
await bridge.close();
|
|
2088
|
+
return;
|
|
2089
|
+
}
|
|
2090
|
+
bridgeRef.current = bridge;
|
|
2139
2091
|
} catch (err) {
|
|
2140
2092
|
console.error("[MCPAppsRenderer] Setup error:", err);
|
|
2141
2093
|
if (mounted) setError(err instanceof Error ? err : new Error(String(err)));
|
|
@@ -2144,11 +2096,8 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
2144
2096
|
setup();
|
|
2145
2097
|
return () => {
|
|
2146
2098
|
mounted = false;
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
initialListener = null;
|
|
2150
|
-
}
|
|
2151
|
-
if (messageHandler) window.removeEventListener("message", messageHandler);
|
|
2099
|
+
bridgeRef.current = null;
|
|
2100
|
+
bridge?.close();
|
|
2152
2101
|
if (createdIframe) {
|
|
2153
2102
|
createdIframe.remove();
|
|
2154
2103
|
createdIframe = null;
|
|
@@ -2158,9 +2107,7 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
2158
2107
|
}, [
|
|
2159
2108
|
isLoading,
|
|
2160
2109
|
fetchedResource,
|
|
2161
|
-
|
|
2162
|
-
sendResponse,
|
|
2163
|
-
sendErrorResponse
|
|
2110
|
+
copilotkit
|
|
2164
2111
|
]);
|
|
2165
2112
|
useEffect(() => {
|
|
2166
2113
|
if (iframeRef.current) {
|
|
@@ -2172,25 +2119,11 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
2172
2119
|
}
|
|
2173
2120
|
}, [iframeSize]);
|
|
2174
2121
|
useEffect(() => {
|
|
2175
|
-
if (iframeReady && content.toolInput) {
|
|
2176
|
-
|
|
2177
|
-
sendNotification("ui/notifications/tool-input", { arguments: content.toolInput });
|
|
2178
|
-
}
|
|
2179
|
-
}, [
|
|
2180
|
-
iframeReady,
|
|
2181
|
-
content.toolInput,
|
|
2182
|
-
sendNotification
|
|
2183
|
-
]);
|
|
2122
|
+
if (iframeReady && content.toolInput) bridgeRef.current?.sendToolInput({ arguments: content.toolInput });
|
|
2123
|
+
}, [iframeReady, content.toolInput]);
|
|
2184
2124
|
useEffect(() => {
|
|
2185
|
-
if (iframeReady && content.result)
|
|
2186
|
-
|
|
2187
|
-
sendNotification("ui/notifications/tool-result", content.result);
|
|
2188
|
-
}
|
|
2189
|
-
}, [
|
|
2190
|
-
iframeReady,
|
|
2191
|
-
content.result,
|
|
2192
|
-
sendNotification
|
|
2193
|
-
]);
|
|
2125
|
+
if (iframeReady && content.result) bridgeRef.current?.sendToolResult(content.result);
|
|
2126
|
+
}, [iframeReady, content.result]);
|
|
2194
2127
|
const borderStyle = fetchedResource?._meta?.ui?.prefersBorder === true ? {
|
|
2195
2128
|
borderRadius: "8px",
|
|
2196
2129
|
backgroundColor: "#f9f9f9",
|
|
@@ -4005,7 +3938,8 @@ function useFrontendTool(tool, deps) {
|
|
|
4005
3938
|
tool.name,
|
|
4006
3939
|
tool.available,
|
|
4007
3940
|
copilotkit,
|
|
4008
|
-
JSON.stringify(extraDeps)
|
|
3941
|
+
JSON.stringify(extraDeps),
|
|
3942
|
+
JSON.stringify(tool.webmcp ?? null)
|
|
4009
3943
|
]);
|
|
4010
3944
|
}
|
|
4011
3945
|
|
|
@@ -5799,9 +5733,9 @@ const DEFAULT_CONTAINERS = ["project"];
|
|
|
5799
5733
|
* }
|
|
5800
5734
|
* ```
|
|
5801
5735
|
*
|
|
5802
|
-
* @deprecated
|
|
5803
|
-
*
|
|
5804
|
-
*
|
|
5736
|
+
* @deprecated This hook supports only the legacy plural-container annotation.
|
|
5737
|
+
* Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
|
|
5738
|
+
* Intelligence runtimes.
|
|
5805
5739
|
*/
|
|
5806
5740
|
function useLearningContainers({ threadId, learningContainers }) {
|
|
5807
5741
|
const { copilotkit } = useCopilotKit();
|
|
@@ -5905,9 +5839,9 @@ function useLearningContainers({ threadId, learningContainers }) {
|
|
|
5905
5839
|
* }
|
|
5906
5840
|
* ```
|
|
5907
5841
|
*
|
|
5908
|
-
* @deprecated
|
|
5909
|
-
*
|
|
5910
|
-
*
|
|
5842
|
+
* @deprecated This hook supports only the legacy plural-container annotation.
|
|
5843
|
+
* Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
|
|
5844
|
+
* Intelligence runtimes.
|
|
5911
5845
|
*/
|
|
5912
5846
|
function useLearningContainersInCurrentThread({ learningContainers }) {
|
|
5913
5847
|
const threadId = useCopilotChatConfiguration()?.threadId;
|
|
@@ -10912,7 +10846,7 @@ const getErrorActions = (error) => {
|
|
|
10912
10846
|
switch (error.code) {
|
|
10913
10847
|
case CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR: return { primary: {
|
|
10914
10848
|
label: "Show me how",
|
|
10915
|
-
onClick: () => window.open("https://docs.copilotkit.ai/
|
|
10849
|
+
onClick: () => window.open("https://docs.copilotkit.ai/intelligence/overview#plans-and-access", "_blank", "noopener,noreferrer")
|
|
10916
10850
|
} };
|
|
10917
10851
|
case CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR: return { primary: {
|
|
10918
10852
|
label: "Upgrade",
|
|
@@ -12144,4 +12078,4 @@ function validateProps(props) {
|
|
|
12144
12078
|
|
|
12145
12079
|
//#endregion
|
|
12146
12080
|
export { useAgentContext as $, CopilotChatMessageView as A, AudioRecorderError as At, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, MCPAppsActivityContentSchema as Ct, CopilotChat as D, CopilotKitInspector as Dt, DefaultOpenIcon as E, ɵrunMcpFollowUp as Et, CopilotChatSuggestionView as F, useLearnFromUserActionInCurrentThread as G, useLearningContainersInCurrentThread as H, CopilotChatSuggestionPill as I, useThreads$1 as J, useLearnFromUserAction as K, CopilotChatReasoningMessage_default as L, IntelligenceIndicator as M, CopilotChatConfigurationProvider as Mt, getIntelligenceTurnAnchors as N, useCopilotChatConfiguration as Nt, CopilotChatView_default as O, useRenderToolCall as Ot, IntelligenceIndicatorView as P, useSuggestions as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, useSandboxFunctions as St, DefaultCloseIcon as T, MCPAppsActivityType as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, INTERRUPT_EVENT_NAME as X, useInterrupt as Y, useConfigureSuggestions as Z, WildcardToolCallRender as _, OpenGenerativeUIActivityRenderer as _t, ThreadsProvider as a, useRenderTool as at, CopilotSidebar as b, OpenGenerativeUIToolRenderer as bt, CoAgentStateRendersProvider as c, useRenderActivityMessage as ct, shouldShowDevConsole as d, useCopilotKit$1 as dt, useCapabilities as et, useToast as f, useLicenseContext$1 as ft, useCopilotContext as g, GenerateSandboxedUiArgsSchema as gt, CopilotContext as h, createA2UIMessageRenderer as ht, ThreadsContext as i, useDefaultRenderTool as it, INTELLIGENCE_TURN_HEAD as j, CopilotChatAudioRecorder as jt, CopilotChatAttachmentQueue as k, CopilotChatInput_default as kt, useCoAgentStateRenders as l, useRenderCustomMessages as lt, useCopilotMessagesContext as m, defineToolCallRenderer as mt, defaultCopilotContextCategories as n, useAgent as nt, useThreads as o, useComponent as ot, CopilotMessagesContext as p, CopilotKitCoreReact as pt, useMemories as q, CoAgentStateRenderBridge as r, useHumanInTheLoop as rt, CoAgentStateRendersContext as s, useFrontendTool as st, CopilotKit as t, UseAgentUpdate as tt, useAsyncCallback as u, CopilotKitProvider as ut, CopilotThreadsDrawer as v, OpenGenerativeUIActivityType as vt, CopilotChatToggleButton as w, MCPAppsActivityRenderer as wt, CopilotPopupView as x, SandboxFunctionsContext as xt, CopilotPopup as y, OpenGenerativeUIContentSchema as yt, CopilotChatAttachmentRenderer as z };
|
|
12147
|
-
//# sourceMappingURL=copilotkit-
|
|
12081
|
+
//# sourceMappingURL=copilotkit-DiUK2Bhq.mjs.map
|