@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
@@ -1352,7 +1352,7 @@ function CopilotChatInput({ mode = "input", onSubmitMessage, onStop, isRunning =
1352
1352
  side: "bottom",
1353
1353
  children: /* @__PURE__ */ jsxs("p", {
1354
1354
  className: "cpk:flex cpk:items-center cpk:gap-1 cpk:text-xs cpk:font-medium",
1355
- children: [/* @__PURE__ */ jsx("span", { children: "Add attachments" }), /* @__PURE__ */ jsx("code", {
1355
+ children: [/* @__PURE__ */ jsx("span", { children: labels.chatInputToolbarAddButtonLabel }), /* @__PURE__ */ jsx("code", {
1356
1356
  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",
1357
1357
  children: "/"
1358
1358
  })]
@@ -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 messageHandler = null;
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
- await sandboxReady;
2020
- if (!mounted) return;
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
- sendNotification("ui/notifications/sandbox-resource-ready", { html });
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
- if (initialListener) {
2148
- window.removeEventListener("message", initialListener);
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
- sendNotification,
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
- console.log("[MCPAppsRenderer] Sending tool input:", content.toolInput);
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
- console.log("[MCPAppsRenderer] Sending tool result:", content.result);
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",
@@ -3506,6 +3439,8 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3506
3439
  const a2uiCatalogProvided = !!a2ui?.catalog;
3507
3440
  const a2uiActive = runtimeA2UIEnabled || a2uiCatalogProvided;
3508
3441
  const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState(void 0);
3442
+ const [runtimeEntitlements, setRuntimeEntitlements] = useState(void 0);
3443
+ const [runtimeEntitlementRetryPending, setRuntimeEntitlementRetryPending] = useState(false);
3509
3444
  const requestInspectorOpen = useCallback((request) => {
3510
3445
  setInspectorOpenRequest({ ...request });
3511
3446
  }, []);
@@ -3696,6 +3631,8 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3696
3631
  setRuntimeA2UIEnabled(copilotkit.a2uiEnabled);
3697
3632
  setRuntimeOpenGenUIEnabled(copilotkit.openGenerativeUIEnabled);
3698
3633
  setRuntimeLicenseStatus(copilotkit.licenseStatus);
3634
+ setRuntimeEntitlements(copilotkit.runtimeEntitlements);
3635
+ setRuntimeEntitlementRetryPending(copilotkit.runtimeEntitlementRetryPending);
3699
3636
  };
3700
3637
  const subscription = copilotkit.subscribe({ onRuntimeConnectionStatusChanged: syncRuntimeInfo });
3701
3638
  syncRuntimeInfo();
@@ -3836,7 +3773,26 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3836
3773
  copilotkit,
3837
3774
  executingToolCallIds
3838
3775
  }), [copilotkit, executingToolCallIds]);
3839
- const licenseContextValue = useMemo(() => createLicenseContextValue(runtimeLicenseStatus), [runtimeLicenseStatus]);
3776
+ const retryableRuntimeEntitlementFailure = runtimeEntitlements?.status !== "ready" && runtimeEntitlements?.error.retryable === true;
3777
+ const hasNonReadyRuntimeEntitlement = runtimeEntitlements !== void 0 && runtimeEntitlements.status !== "ready";
3778
+ const hasLegacyRuntimeEntitlementFallback = runtimeLicenseStatus === "valid" || runtimeLicenseStatus === "expiring";
3779
+ const runtimeEntitlementRetryInProgress = retryableRuntimeEntitlementFailure && runtimeEntitlementRetryPending && !hasLegacyRuntimeEntitlementFallback;
3780
+ const runtimeEntitlementFailureSettled = hasNonReadyRuntimeEntitlement && !runtimeEntitlementRetryInProgress && !hasLegacyRuntimeEntitlementFallback;
3781
+ const licenseContextValue = useMemo(() => {
3782
+ const runtimeLicenseContext = createLicenseContextValue(runtimeEntitlementRetryInProgress ? void 0 : runtimeLicenseStatus, runtimeEntitlements);
3783
+ if (!runtimeEntitlementFailureSettled) return runtimeLicenseContext;
3784
+ return {
3785
+ ...runtimeLicenseContext,
3786
+ checkFeature: () => false,
3787
+ getLimit: () => null
3788
+ };
3789
+ }, [
3790
+ runtimeEntitlementFailureSettled,
3791
+ runtimeEntitlementRetryInProgress,
3792
+ runtimeEntitlements,
3793
+ runtimeLicenseStatus
3794
+ ]);
3795
+ const runtimeLicenseWarningStatus = runtimeEntitlementRetryInProgress ? void 0 : licenseContextValue.status ?? void 0;
3840
3796
  return /* @__PURE__ */ jsx(SandboxFunctionsContext.Provider, {
3841
3797
  value: sandboxFunctionsList,
3842
3798
  children: /* @__PURE__ */ jsx(CopilotKitContext.Provider, {
@@ -3856,10 +3812,10 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
3856
3812
  openRequest: inspectorOpenRequest
3857
3813
  }) : null]
3858
3814
  }),
3859
- runtimeLicenseStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "no_license" }),
3860
- runtimeLicenseStatus === "expired" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "expired" }),
3861
- runtimeLicenseStatus === "invalid" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "invalid" }),
3862
- runtimeLicenseStatus === "expiring" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "expiring" })
3815
+ runtimeLicenseWarningStatus === "none" && !resolvedPublicKey && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "no_license" }),
3816
+ runtimeLicenseWarningStatus === "expired" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "expired" }),
3817
+ runtimeLicenseWarningStatus === "invalid" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "invalid" }),
3818
+ runtimeLicenseWarningStatus === "expiring" && /* @__PURE__ */ jsx(LicenseWarningBanner, { type: "expiring" })
3863
3819
  ]
3864
3820
  })
3865
3821
  })
@@ -3959,7 +3915,7 @@ const EMPTY_DEPS$1 = [];
3959
3915
  function useFrontendTool(tool, deps) {
3960
3916
  const { copilotkit } = useCopilotKit();
3961
3917
  const extraDeps = deps ?? EMPTY_DEPS$1;
3962
- useEffect(() => {
3918
+ useLayoutEffect(() => {
3963
3919
  const name = tool.name;
3964
3920
  if (copilotkit.getTool({
3965
3921
  toolName: name,
@@ -3982,7 +3938,8 @@ function useFrontendTool(tool, deps) {
3982
3938
  tool.name,
3983
3939
  tool.available,
3984
3940
  copilotkit,
3985
- JSON.stringify(extraDeps)
3941
+ JSON.stringify(extraDeps),
3942
+ JSON.stringify(tool.webmcp ?? null)
3986
3943
  ]);
3987
3944
  }
3988
3945
 
@@ -4326,6 +4283,8 @@ function safeStringifyForAttr(value) {
4326
4283
 
4327
4284
  //#endregion
4328
4285
  //#region src/v2/hooks/use-human-in-the-loop.tsx
4286
+ /** Registration name of a catch-all tool: handles any otherwise-unhandled call. */
4287
+ const WILDCARD_TOOL_NAME = "*";
4329
4288
  function useHumanInTheLoop(tool, deps) {
4330
4289
  const { copilotkit } = useCopilotKit();
4331
4290
  const resolvePromiseRef = useRef(null);
@@ -4361,10 +4320,11 @@ function useHumanInTheLoop(tool, deps) {
4361
4320
  }, []);
4362
4321
  const RenderComponent = useCallback((props) => {
4363
4322
  const ToolComponent = tool.render;
4323
+ const name = tool.name === WILDCARD_TOOL_NAME ? props.name : tool.name;
4364
4324
  if (props.status === ToolCallStatus.InProgress) {
4365
4325
  const enhancedProps = {
4366
4326
  ...props,
4367
- name: tool.name,
4327
+ name,
4368
4328
  description: tool.description || "",
4369
4329
  agentId: tool.agentId,
4370
4330
  respond: void 0
@@ -4373,7 +4333,7 @@ function useHumanInTheLoop(tool, deps) {
4373
4333
  } else if (props.status === ToolCallStatus.Executing) {
4374
4334
  const enhancedProps = {
4375
4335
  ...props,
4376
- name: tool.name,
4336
+ name,
4377
4337
  description: tool.description || "",
4378
4338
  agentId: tool.agentId,
4379
4339
  respond
@@ -4382,7 +4342,7 @@ function useHumanInTheLoop(tool, deps) {
4382
4342
  } else if (props.status === ToolCallStatus.Complete) {
4383
4343
  const enhancedProps = {
4384
4344
  ...props,
4385
- name: tool.name,
4345
+ name,
4386
4346
  description: tool.description || "",
4387
4347
  agentId: tool.agentId,
4388
4348
  respond: void 0
@@ -4402,7 +4362,7 @@ function useHumanInTheLoop(tool, deps) {
4402
4362
  handler,
4403
4363
  render: RenderComponent
4404
4364
  }, deps);
4405
- useEffect(() => {
4365
+ useLayoutEffect(() => {
4406
4366
  return () => {
4407
4367
  copilotkit.removeHookRenderToolCall(tool.name, tool.agentId);
4408
4368
  };
@@ -4867,8 +4827,12 @@ function normalizeStaticSuggestions(suggestions) {
4867
4827
  }
4868
4828
 
4869
4829
  //#endregion
4870
- //#region src/v2/hooks/use-interrupt.tsx
4830
+ //#region src/v2/types/interrupt.ts
4831
+ /** Name of the legacy custom event agents emit to signal an interrupt. */
4871
4832
  const INTERRUPT_EVENT_NAME = "on_interrupt";
4833
+
4834
+ //#endregion
4835
+ //#region src/v2/hooks/use-interrupt.tsx
4872
4836
  function isPromiseLike(value) {
4873
4837
  return (typeof value === "object" || typeof value === "function") && value !== null && typeof Reflect.get(value, "then") === "function";
4874
4838
  }
@@ -5205,7 +5169,7 @@ function useThreadStoreSelector(store, selector) {
5205
5169
  */
5206
5170
  function useThreads$1({ agentId, includeArchived, limit, enabled = true }) {
5207
5171
  const { copilotkit } = useCopilotKit();
5208
- const [store] = useState(() => ɵcreateThreadStore({ fetch: globalThis.fetch }));
5172
+ const [store] = useState(() => ɵcreateThreadStore({ fetch: copilotkit.ɵruntimeFetch }));
5209
5173
  const coreThreads = useThreadStoreSelector(store, ɵselectThreads);
5210
5174
  const threads = useMemo(() => coreThreads.map(({ id, agentId, name, archived, createdAt, updatedAt, lastRunAt }) => ({
5211
5175
  id,
@@ -5769,9 +5733,9 @@ const DEFAULT_CONTAINERS = ["project"];
5769
5733
  * }
5770
5734
  * ```
5771
5735
  *
5772
- * @deprecated Legacy plural-container annotation compatibility only. New
5773
- * Intelligence runtimes assign one container with `ɵlearning.containerId` on
5774
- * `CopilotRuntime`.
5736
+ * @deprecated This hook supports only the legacy plural-container annotation.
5737
+ * Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
5738
+ * Intelligence runtimes.
5775
5739
  */
5776
5740
  function useLearningContainers({ threadId, learningContainers }) {
5777
5741
  const { copilotkit } = useCopilotKit();
@@ -5875,9 +5839,9 @@ function useLearningContainers({ threadId, learningContainers }) {
5875
5839
  * }
5876
5840
  * ```
5877
5841
  *
5878
- * @deprecated Legacy plural-container annotation compatibility only. New
5879
- * Intelligence runtimes assign one container with `ɵlearning.containerId` on
5880
- * `CopilotRuntime`.
5842
+ * @deprecated This hook supports only the legacy plural-container annotation.
5843
+ * Configure `getLearningContainerId` on `CopilotKitIntelligence` for new
5844
+ * Intelligence runtimes.
5881
5845
  */
5882
5846
  function useLearningContainersInCurrentThread({ learningContainers }) {
5883
5847
  const threadId = useCopilotChatConfiguration()?.threadId;
@@ -5904,21 +5868,35 @@ function CopilotChatToolCallsView({ message, messages = [] }) {
5904
5868
 
5905
5869
  //#endregion
5906
5870
  //#region src/v2/components/chat/CopilotChatAssistantMessage.tsx
5871
+ /**
5872
+ * Binds the Inspector action to the active chat without making the full
5873
+ * assistant message subscribe to chat configuration changes.
5874
+ */
5875
+ function BoundInspectorButton({ inspectorButton, messageId, openInspector, ...props }) {
5876
+ const chatConfiguration = useCopilotChatConfiguration();
5877
+ return renderSlot(inspectorButton, CopilotChatAssistantMessage.InspectorButton, {
5878
+ ...props,
5879
+ onClick: () => openInspector({
5880
+ messageId,
5881
+ threadId: chatConfiguration?.threadId,
5882
+ agentId: chatConfiguration?.agentId
5883
+ })
5884
+ });
5885
+ }
5907
5886
  function CopilotChatAssistantMessage({ message, messages, isRunning, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible = true, markdownRenderer, toolbar, copyButton, inspectorButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }) {
5908
5887
  useKatexStyles();
5909
5888
  const { isInspectorEnabled, openInspector } = useCopilotKitInspector();
5910
- const chatConfiguration = useCopilotChatConfiguration();
5911
5889
  const boundMarkdownRenderer = renderSlot(markdownRenderer, CopilotChatAssistantMessage.MarkdownRenderer, { content: message.content || "" });
5912
5890
  const boundCopyButton = renderSlot(copyButton, CopilotChatAssistantMessage.CopyButton, { onClick: async () => {
5913
5891
  if (message.content) return await copyToClipboard(message.content);
5914
5892
  return false;
5915
5893
  } });
5916
5894
  const boundThumbsUpButton = renderSlot(thumbsUpButton, CopilotChatAssistantMessage.ThumbsUpButton, { onClick: onThumbsUp ? () => onThumbsUp(message) : void 0 });
5917
- const boundInspectorButton = renderSlot(inspectorButton, CopilotChatAssistantMessage.InspectorButton, { onClick: () => openInspector({
5895
+ const boundInspectorButton = /* @__PURE__ */ jsx(BoundInspectorButton, {
5896
+ inspectorButton,
5918
5897
  messageId: message.id,
5919
- threadId: chatConfiguration?.threadId,
5920
- agentId: chatConfiguration?.agentId
5921
- }) });
5898
+ openInspector
5899
+ });
5922
5900
  const boundThumbsDownButton = renderSlot(thumbsDownButton, CopilotChatAssistantMessage.ThumbsDownButton, { onClick: onThumbsDown ? () => onThumbsDown(message) : void 0 });
5923
5901
  const boundReadAloudButton = renderSlot(readAloudButton, CopilotChatAssistantMessage.ReadAloudButton, { onClick: onReadAloud ? () => onReadAloud(message) : void 0 });
5924
5902
  const boundRegenerateButton = renderSlot(regenerateButton, CopilotChatAssistantMessage.RegenerateButton, { onClick: onRegenerate ? () => onRegenerate(message) : void 0 });
@@ -8498,7 +8476,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
8498
8476
  const startRunActivityReconnectRef = useRef(null);
8499
8477
  const runtimeStatus = copilotkit.runtimeConnectionStatus === CopilotKitCoreRuntimeConnectionStatus.Connected ? "Connected" : copilotkit.runtimeConnectionStatus;
8500
8478
  const hasNativeIntelligenceRunActivity = hasExplicitThreadId && runtimeStatus === "Connected" && !!copilotkit.intelligence?.wsUrl && copilotkit.threadEndpoints?.realtimeMetadata === true;
8501
- const [standaloneRunActivityStore] = useState(() => ɵcreateThreadStore({ fetch: globalThis.fetch }));
8479
+ const [standaloneRunActivityStore] = useState(() => ɵcreateThreadStore({ fetch: copilotkit.ɵruntimeFetch }));
8502
8480
  const previousThreadRef = useRef(null);
8503
8481
  const hasExplicitThreadIdRef = useRef(hasExplicitThreadId);
8504
8482
  hasExplicitThreadIdRef.current = hasExplicitThreadId;
@@ -10868,7 +10846,7 @@ const getErrorActions = (error) => {
10868
10846
  switch (error.code) {
10869
10847
  case CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR: return { primary: {
10870
10848
  label: "Show me how",
10871
- onClick: () => window.open("https://docs.copilotkit.ai/premium/overview#getting-access", "_blank", "noopener,noreferrer")
10849
+ onClick: () => window.open("https://docs.copilotkit.ai/intelligence/overview#plans-and-access", "_blank", "noopener,noreferrer")
10872
10850
  } };
10873
10851
  case CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR: return { primary: {
10874
10852
  label: "Upgrade",
@@ -12099,5 +12077,5 @@ function validateProps(props) {
12099
12077
  }
12100
12078
 
12101
12079
  //#endregion
12102
- export { useCapabilities as $, CopilotChatMessageView as A, CopilotChatAudioRecorder as At, CopilotChatAssistantMessage_default as B, CopilotModalHeader as C, MCPAppsActivityRenderer as Ct, CopilotChat as D, useRenderToolCall as Dt, DefaultOpenIcon as E, CopilotKitInspector 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, useCopilotChatConfiguration as Mt, getIntelligenceTurnAnchors as N, CopilotChatView_default as O, CopilotChatInput_default as Ot, IntelligenceIndicatorView as P, useAgentContext as Q, CopilotChatUserMessage_default as R, CopilotSidebarView as S, MCPAppsActivityContentSchema as St, DefaultCloseIcon as T, ɵrunMcpFollowUp as Tt, useLearningContainers as U, CopilotChatToolCallsView as V, useAttachments as W, useConfigureSuggestions as X, useInterrupt as Y, useSuggestions as Z, WildcardToolCallRender as _, OpenGenerativeUIActivityType as _t, ThreadsProvider as a, useComponent as at, CopilotSidebar as b, SandboxFunctionsContext as bt, CoAgentStateRendersProvider as c, useRenderCustomMessages as ct, shouldShowDevConsole as d, useLicenseContext$1 as dt, UseAgentUpdate as et, useToast as f, CopilotKitCoreReact as ft, useCopilotContext as g, OpenGenerativeUIActivityRenderer as gt, CopilotContext as h, GenerateSandboxedUiArgsSchema as ht, ThreadsContext as i, useRenderTool as it, INTELLIGENCE_TURN_HEAD as j, CopilotChatConfigurationProvider as jt, CopilotChatAttachmentQueue as k, AudioRecorderError as kt, useCoAgentStateRenders as l, CopilotKitProvider as lt, useCopilotMessagesContext as m, createA2UIMessageRenderer as mt, defaultCopilotContextCategories as n, useHumanInTheLoop as nt, useThreads as o, useFrontendTool as ot, CopilotMessagesContext as p, defineToolCallRenderer as pt, useMemories as q, CoAgentStateRenderBridge as r, useDefaultRenderTool as rt, CoAgentStateRendersContext as s, useRenderActivityMessage as st, CopilotKit as t, useAgent as tt, useAsyncCallback as u, useCopilotKit$1 as ut, CopilotThreadsDrawer as v, OpenGenerativeUIContentSchema as vt, CopilotChatToggleButton as w, MCPAppsActivityType as wt, CopilotPopupView as x, useSandboxFunctions as xt, CopilotPopup as y, OpenGenerativeUIToolRenderer as yt, CopilotChatAttachmentRenderer as z };
12103
- //# sourceMappingURL=copilotkit-JdHy0xdu.mjs.map
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 };
12081
+ //# sourceMappingURL=copilotkit-DiUK2Bhq.mjs.map