@copilotkit/react-core 1.69.3 → 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.
Files changed (37) hide show
  1. package/dist/{copilotkit-CrNUgJiq.d.cts → copilotkit-CtF2clxZ.d.cts} +50 -23
  2. package/dist/copilotkit-CtF2clxZ.d.cts.map +1 -0
  3. package/dist/{copilotkit-BPeh62mW.cjs → copilotkit-CxLT6zFx.cjs} +214 -230
  4. package/dist/copilotkit-CxLT6zFx.cjs.map +1 -0
  5. package/dist/{copilotkit-JdHy0xdu.mjs → copilotkit-DiUK2Bhq.mjs} +209 -231
  6. package/dist/copilotkit-DiUK2Bhq.mjs.map +1 -0
  7. package/dist/{copilotkit-DgO31tBq.d.mts → copilotkit-DsWuxPUQ.d.mts} +50 -23
  8. package/dist/copilotkit-DsWuxPUQ.d.mts.map +1 -0
  9. package/dist/index.cjs +97 -24
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +18 -3
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts +18 -3
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs +97 -24
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/index.umd.js +275 -239
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/v2/headless.cjs +16 -8
  20. package/dist/v2/headless.cjs.map +1 -1
  21. package/dist/v2/headless.d.cts.map +1 -1
  22. package/dist/v2/headless.d.mts.map +1 -1
  23. package/dist/v2/headless.mjs +16 -8
  24. package/dist/v2/headless.mjs.map +1 -1
  25. package/dist/v2/index.cjs +2 -1
  26. package/dist/v2/index.d.cts +2 -2
  27. package/dist/v2/index.d.mts +2 -2
  28. package/dist/v2/index.mjs +2 -2
  29. package/dist/v2/index.umd.js +208 -229
  30. package/dist/v2/index.umd.js.map +1 -1
  31. package/package.json +13 -10
  32. package/skills/react-core/SKILL.md +1 -1
  33. package/skills/react-core/references/threads.md +1 -1
  34. package/dist/copilotkit-BPeh62mW.cjs.map +0 -1
  35. package/dist/copilotkit-CrNUgJiq.d.cts.map +0 -1
  36. package/dist/copilotkit-DgO31tBq.d.mts.map +0 -1
  37. package/dist/copilotkit-JdHy0xdu.mjs.map +0 -1
@@ -1382,7 +1382,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
1382
1382
  side: "bottom",
1383
1383
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
1384
1384
  className: "cpk:flex cpk:items-center cpk:gap-1 cpk:text-xs cpk:font-medium",
1385
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Add attachments" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
1385
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: labels.chatInputToolbarAddButtonLabel }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
1386
1386
  className: "cpk:rounded cpk:bg-[#4a4a4a] cpk:px-1 cpk:py-[1px] cpk:font-mono cpk:text-[11px] cpk:text-white cpk:dark:bg-[#e0e0e0] cpk:dark:text-black",
1387
1387
  children: "/"
1388
1388
  })]
@@ -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 messageHandler = null;
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
- await sandboxReady;
2050
- if (!mounted) return;
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
- sendNotification("ui/notifications/sandbox-resource-ready", { html });
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
- if (initialListener) {
2178
- window.removeEventListener("message", initialListener);
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
- sendNotification,
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
- console.log("[MCPAppsRenderer] Sending tool input:", content.toolInput);
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
- console.log("[MCPAppsRenderer] Sending tool result:", content.result);
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",
@@ -3536,6 +3469,8 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3536
3469
  const a2uiCatalogProvided = !!a2ui?.catalog;
3537
3470
  const a2uiActive = runtimeA2UIEnabled || a2uiCatalogProvided;
3538
3471
  const [runtimeLicenseStatus, setRuntimeLicenseStatus] = (0, react.useState)(void 0);
3472
+ const [runtimeEntitlements, setRuntimeEntitlements] = (0, react.useState)(void 0);
3473
+ const [runtimeEntitlementRetryPending, setRuntimeEntitlementRetryPending] = (0, react.useState)(false);
3539
3474
  const requestInspectorOpen = (0, react.useCallback)((request) => {
3540
3475
  setInspectorOpenRequest({ ...request });
3541
3476
  }, []);
@@ -3726,6 +3661,8 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3726
3661
  setRuntimeA2UIEnabled(copilotkit.a2uiEnabled);
3727
3662
  setRuntimeOpenGenUIEnabled(copilotkit.openGenerativeUIEnabled);
3728
3663
  setRuntimeLicenseStatus(copilotkit.licenseStatus);
3664
+ setRuntimeEntitlements(copilotkit.runtimeEntitlements);
3665
+ setRuntimeEntitlementRetryPending(copilotkit.runtimeEntitlementRetryPending);
3729
3666
  };
3730
3667
  const subscription = copilotkit.subscribe({ onRuntimeConnectionStatusChanged: syncRuntimeInfo });
3731
3668
  syncRuntimeInfo();
@@ -3866,7 +3803,26 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3866
3803
  copilotkit,
3867
3804
  executingToolCallIds
3868
3805
  }), [copilotkit, executingToolCallIds]);
3869
- const licenseContextValue = (0, react.useMemo)(() => (0, _copilotkit_shared.createLicenseContextValue)(runtimeLicenseStatus), [runtimeLicenseStatus]);
3806
+ const retryableRuntimeEntitlementFailure = runtimeEntitlements?.status !== "ready" && runtimeEntitlements?.error.retryable === true;
3807
+ const hasNonReadyRuntimeEntitlement = runtimeEntitlements !== void 0 && runtimeEntitlements.status !== "ready";
3808
+ const hasLegacyRuntimeEntitlementFallback = runtimeLicenseStatus === "valid" || runtimeLicenseStatus === "expiring";
3809
+ const runtimeEntitlementRetryInProgress = retryableRuntimeEntitlementFailure && runtimeEntitlementRetryPending && !hasLegacyRuntimeEntitlementFallback;
3810
+ const runtimeEntitlementFailureSettled = hasNonReadyRuntimeEntitlement && !runtimeEntitlementRetryInProgress && !hasLegacyRuntimeEntitlementFallback;
3811
+ const licenseContextValue = (0, react.useMemo)(() => {
3812
+ const runtimeLicenseContext = (0, _copilotkit_shared.createLicenseContextValue)(runtimeEntitlementRetryInProgress ? void 0 : runtimeLicenseStatus, runtimeEntitlements);
3813
+ if (!runtimeEntitlementFailureSettled) return runtimeLicenseContext;
3814
+ return {
3815
+ ...runtimeLicenseContext,
3816
+ checkFeature: () => false,
3817
+ getLimit: () => null
3818
+ };
3819
+ }, [
3820
+ runtimeEntitlementFailureSettled,
3821
+ runtimeEntitlementRetryInProgress,
3822
+ runtimeEntitlements,
3823
+ runtimeLicenseStatus
3824
+ ]);
3825
+ const runtimeLicenseWarningStatus = runtimeEntitlementRetryInProgress ? void 0 : licenseContextValue.status ?? void 0;
3870
3826
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SandboxFunctionsContext.Provider, {
3871
3827
  value: sandboxFunctionsList,
3872
3828
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_context.CopilotKitContext.Provider, {
@@ -3886,10 +3842,10 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3886
3842
  openRequest: inspectorOpenRequest
3887
3843
  }) : null]
3888
3844
  }),
3889
- runtimeLicenseStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "no_license" }),
3890
- runtimeLicenseStatus === "expired" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "expired" }),
3891
- runtimeLicenseStatus === "invalid" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "invalid" }),
3892
- runtimeLicenseStatus === "expiring" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "expiring" })
3845
+ runtimeLicenseWarningStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "no_license" }),
3846
+ runtimeLicenseWarningStatus === "expired" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "expired" }),
3847
+ runtimeLicenseWarningStatus === "invalid" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "invalid" }),
3848
+ runtimeLicenseWarningStatus === "expiring" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LicenseWarningBanner, { type: "expiring" })
3893
3849
  ]
3894
3850
  })
3895
3851
  })
@@ -3989,7 +3945,7 @@ const EMPTY_DEPS$1 = [];
3989
3945
  function useFrontendTool(tool, deps) {
3990
3946
  const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
3991
3947
  const extraDeps = deps ?? EMPTY_DEPS$1;
3992
- (0, react.useEffect)(() => {
3948
+ (0, react.useLayoutEffect)(() => {
3993
3949
  const name = tool.name;
3994
3950
  if (copilotkit.getTool({
3995
3951
  toolName: name,
@@ -4012,7 +3968,8 @@ function useFrontendTool(tool, deps) {
4012
3968
  tool.name,
4013
3969
  tool.available,
4014
3970
  copilotkit,
4015
- JSON.stringify(extraDeps)
3971
+ JSON.stringify(extraDeps),
3972
+ JSON.stringify(tool.webmcp ?? null)
4016
3973
  ]);
4017
3974
  }
4018
3975
 
@@ -4356,6 +4313,8 @@ function safeStringifyForAttr(value) {
4356
4313
 
4357
4314
  //#endregion
4358
4315
  //#region src/v2/hooks/use-human-in-the-loop.tsx
4316
+ /** Registration name of a catch-all tool: handles any otherwise-unhandled call. */
4317
+ const WILDCARD_TOOL_NAME = "*";
4359
4318
  function useHumanInTheLoop(tool, deps) {
4360
4319
  const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
4361
4320
  const resolvePromiseRef = (0, react.useRef)(null);
@@ -4391,10 +4350,11 @@ function useHumanInTheLoop(tool, deps) {
4391
4350
  }, []);
4392
4351
  const RenderComponent = (0, react.useCallback)((props) => {
4393
4352
  const ToolComponent = tool.render;
4353
+ const name = tool.name === WILDCARD_TOOL_NAME ? props.name : tool.name;
4394
4354
  if (props.status === _copilotkit_core.ToolCallStatus.InProgress) {
4395
4355
  const enhancedProps = {
4396
4356
  ...props,
4397
- name: tool.name,
4357
+ name,
4398
4358
  description: tool.description || "",
4399
4359
  agentId: tool.agentId,
4400
4360
  respond: void 0
@@ -4403,7 +4363,7 @@ function useHumanInTheLoop(tool, deps) {
4403
4363
  } else if (props.status === _copilotkit_core.ToolCallStatus.Executing) {
4404
4364
  const enhancedProps = {
4405
4365
  ...props,
4406
- name: tool.name,
4366
+ name,
4407
4367
  description: tool.description || "",
4408
4368
  agentId: tool.agentId,
4409
4369
  respond
@@ -4412,7 +4372,7 @@ function useHumanInTheLoop(tool, deps) {
4412
4372
  } else if (props.status === _copilotkit_core.ToolCallStatus.Complete) {
4413
4373
  const enhancedProps = {
4414
4374
  ...props,
4415
- name: tool.name,
4375
+ name,
4416
4376
  description: tool.description || "",
4417
4377
  agentId: tool.agentId,
4418
4378
  respond: void 0
@@ -4432,7 +4392,7 @@ function useHumanInTheLoop(tool, deps) {
4432
4392
  handler,
4433
4393
  render: RenderComponent
4434
4394
  }, deps);
4435
- (0, react.useEffect)(() => {
4395
+ (0, react.useLayoutEffect)(() => {
4436
4396
  return () => {
4437
4397
  copilotkit.removeHookRenderToolCall(tool.name, tool.agentId);
4438
4398
  };
@@ -4897,8 +4857,12 @@ function normalizeStaticSuggestions(suggestions) {
4897
4857
  }
4898
4858
 
4899
4859
  //#endregion
4900
- //#region src/v2/hooks/use-interrupt.tsx
4860
+ //#region src/v2/types/interrupt.ts
4861
+ /** Name of the legacy custom event agents emit to signal an interrupt. */
4901
4862
  const INTERRUPT_EVENT_NAME = "on_interrupt";
4863
+
4864
+ //#endregion
4865
+ //#region src/v2/hooks/use-interrupt.tsx
4902
4866
  function isPromiseLike(value) {
4903
4867
  return (typeof value === "object" || typeof value === "function") && value !== null && typeof Reflect.get(value, "then") === "function";
4904
4868
  }
@@ -5235,7 +5199,7 @@ function useThreadStoreSelector(store, selector) {
5235
5199
  */
5236
5200
  function useThreads$1({ agentId, includeArchived, limit, enabled = true }) {
5237
5201
  const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
5238
- const [store] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: globalThis.fetch }));
5202
+ const [store] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: copilotkit.ɵruntimeFetch }));
5239
5203
  const coreThreads = useThreadStoreSelector(store, _copilotkit_core.ɵselectThreads);
5240
5204
  const threads = (0, react.useMemo)(() => coreThreads.map(({ id, agentId, name, archived, createdAt, updatedAt, lastRunAt }) => ({
5241
5205
  id,
@@ -5799,9 +5763,9 @@ const DEFAULT_CONTAINERS = ["project"];
5799
5763
  * }
5800
5764
  * ```
5801
5765
  *
5802
- * @deprecated Legacy plural-container annotation compatibility only. New
5803
- * Intelligence runtimes assign one container with `ɵlearning.containerId` on
5804
- * `CopilotRuntime`.
5766
+ * @deprecated This hook supports only the legacy plural-container annotation.
5767
+ * Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
5768
+ * Intelligence runtimes.
5805
5769
  */
5806
5770
  function useLearningContainers({ threadId, learningContainers }) {
5807
5771
  const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
@@ -5905,9 +5869,9 @@ function useLearningContainers({ threadId, learningContainers }) {
5905
5869
  * }
5906
5870
  * ```
5907
5871
  *
5908
- * @deprecated Legacy plural-container annotation compatibility only. New
5909
- * Intelligence runtimes assign one container with `ɵlearning.containerId` on
5910
- * `CopilotRuntime`.
5872
+ * @deprecated This hook supports only the legacy plural-container annotation.
5873
+ * Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
5874
+ * Intelligence runtimes.
5911
5875
  */
5912
5876
  function useLearningContainersInCurrentThread({ learningContainers }) {
5913
5877
  const threadId = useCopilotChatConfiguration()?.threadId;
@@ -5934,21 +5898,35 @@ function CopilotChatToolCallsView({ message, messages = [] }) {
5934
5898
 
5935
5899
  //#endregion
5936
5900
  //#region src/v2/components/chat/CopilotChatAssistantMessage.tsx
5901
+ /**
5902
+ * Binds the Inspector action to the active chat without making the full
5903
+ * assistant message subscribe to chat configuration changes.
5904
+ */
5905
+ function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...props }) {
5906
+ const chatConfiguration = useCopilotChatConfiguration();
5907
+ return renderSlot(inspectorButton, CopilotChatAssistantMessage.InspectorButton, {
5908
+ ...props,
5909
+ onClick: () => openInspector({
5910
+ messageId,
5911
+ threadId: chatConfiguration?.threadId,
5912
+ agentId: chatConfiguration?.agentId
5913
+ })
5914
+ });
5915
+ }
5937
5916
  function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
5938
5917
  useKatexStyles();
5939
5918
  const { isInspectorEnabled, openInspector } = useCopilotKitInspector();
5940
- const chatConfiguration = useCopilotChatConfiguration();
5941
5919
  const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
5942
5920
  const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
5943
5921
  if (message.content) return await (0, _copilotkit_shared.copyToClipboard)(message.content);
5944
5922
  return false;
5945
5923
  } });
5946
5924
  const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp ? () => onThumbsUp(message) : void 0 });
5947
- const boundInspectorButton = renderSlot(inspectorButton, CopilotChatAssistantMessage.InspectorButton, { onClick: () => openInspector({
5925
+ const boundInspectorButton = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BoundInspectorButton, {
5926
+ inspectorButton,
5948
5927
  messageId: message.id,
5949
- threadId: chatConfiguration?.threadId,
5950
- agentId: chatConfiguration?.agentId
5951
- }) });
5928
+ openInspector
5929
+ });
5952
5930
  const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
5953
5931
  const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
5954
5932
  const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
@@ -8528,7 +8506,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
8528
8506
  const startRunActivityReconnectRef = (0, react.useRef)(null);
8529
8507
  const runtimeStatus = copilotkit.runtimeConnectionStatus === _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus.Connected ? "Connected" : copilotkit.runtimeConnectionStatus;
8530
8508
  const hasNativeIntelligenceRunActivity = hasExplicitThreadId && runtimeStatus === "Connected" && !!copilotkit.intelligence?.wsUrl && copilotkit.threadEndpoints?.realtimeMetadata === true;
8531
- const [standaloneRunActivityStore] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: globalThis.fetch }));
8509
+ const [standaloneRunActivityStore] = (0, react.useState)(() => (0, _copilotkit_core.ɵcreateThreadStore)({ fetch: copilotkit.ɵruntimeFetch }));
8532
8510
  const previousThreadRef = (0, react.useRef)(null);
8533
8511
  const hasExplicitThreadIdRef = (0, react.useRef)(hasExplicitThreadId);
8534
8512
  hasExplicitThreadIdRef.current = hasExplicitThreadId;
@@ -10898,7 +10876,7 @@ const getErrorActions = (error) => {
10898
10876
  switch (error.code) {
10899
10877
  case _copilotkit_shared.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR: return { primary: {
10900
10878
  label: "Show me how",
10901
- onClick: () => window.open("https://docs.copilotkit.ai/premium/overview#getting-access", "_blank", "noopener,noreferrer")
10879
+ onClick: () => window.open("https://docs.copilotkit.ai/intelligence/overview#plans-and-access", "_blank", "noopener,noreferrer")
10902
10880
  } };
10903
10881
  case _copilotkit_shared.CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR: return { primary: {
10904
10882
  label: "Upgrade",
@@ -12339,6 +12317,12 @@ Object.defineProperty(exports, 'INTELLIGENCE_TURN_HEAD', {
12339
12317
  return INTELLIGENCE_TURN_HEAD;
12340
12318
  }
12341
12319
  });
12320
+ Object.defineProperty(exports, 'INTERRUPT_EVENT_NAME', {
12321
+ enumerable: true,
12322
+ get: function () {
12323
+ return INTERRUPT_EVENT_NAME;
12324
+ }
12325
+ });
12342
12326
  Object.defineProperty(exports, 'IntelligenceIndicator', {
12343
12327
  enumerable: true,
12344
12328
  get: function () {
@@ -12639,4 +12623,4 @@ Object.defineProperty(exports, 'ɵrunMcpFollowUp', {
12639
12623
  return ɵrunMcpFollowUp;
12640
12624
  }
12641
12625
  });
12642
- //# sourceMappingURL=copilotkit-BPeh62mW.cjs.map
12626
+ //# sourceMappingURL=copilotkit-CxLT6zFx.cjs.map