@copilotkitnext/react 0.0.33 → 0.0.34-pr.fix-express-endpoint

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/index.mjs CHANGED
@@ -1378,12 +1378,12 @@ import "katex/dist/katex.min.css";
1378
1378
  import { Streamdown } from "streamdown";
1379
1379
 
1380
1380
  // src/hooks/use-render-tool-call.tsx
1381
- import React6, { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo4, useState as useState5, useSyncExternalStore } from "react";
1381
+ import React7, { useCallback as useCallback3, useMemo as useMemo4, useSyncExternalStore } from "react";
1382
1382
  import { ToolCallStatus } from "@copilotkitnext/core";
1383
1383
 
1384
1384
  // src/providers/CopilotKitProvider.tsx
1385
- import { createContext as createContext2, useContext as useContext2, useMemo as useMemo3, useEffect as useEffect4, useReducer, useRef as useRef3, useState as useState4 } from "react";
1386
- import { z } from "zod";
1385
+ import { createContext as createContext2, useContext as useContext2, useMemo as useMemo3, useEffect as useEffect5, useReducer, useRef as useRef4, useState as useState5 } from "react";
1386
+ import { z as z2 } from "zod";
1387
1387
 
1388
1388
  // src/lib/react-core.ts
1389
1389
  import { CopilotKitCore } from "@copilotkitnext/core";
@@ -1455,18 +1455,289 @@ var CopilotKitInspector = ({ core, ...rest }) => {
1455
1455
  };
1456
1456
  CopilotKitInspector.displayName = "CopilotKitInspector";
1457
1457
 
1458
- // src/providers/CopilotKitProvider.tsx
1458
+ // src/components/MCPAppsActivityRenderer.tsx
1459
+ import { useEffect as useEffect4, useRef as useRef3, useState as useState4, useCallback as useCallback2 } from "react";
1460
+ import { z } from "zod";
1459
1461
  import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1462
+ var PROTOCOL_VERSION = "2025-06-18";
1463
+ var MCPAppsActivityType = "mcp-apps";
1464
+ var MCPAppsActivityContentSchema = z.object({
1465
+ result: z.object({
1466
+ content: z.array(z.any()).optional(),
1467
+ structuredContent: z.any().optional(),
1468
+ isError: z.boolean().optional()
1469
+ }),
1470
+ resource: z.object({
1471
+ uri: z.string(),
1472
+ mimeType: z.string().optional(),
1473
+ text: z.string().optional(),
1474
+ blob: z.string().optional()
1475
+ }),
1476
+ // Server ID for proxying requests (MD5 hash of server config)
1477
+ serverId: z.string().optional(),
1478
+ // Original tool input arguments
1479
+ toolInput: z.record(z.unknown()).optional()
1480
+ });
1481
+ function isRequest(msg) {
1482
+ return "id" in msg && "method" in msg;
1483
+ }
1484
+ function isNotification(msg) {
1485
+ return !("id" in msg) && "method" in msg;
1486
+ }
1487
+ function extractHtmlFromResource(resource) {
1488
+ if (resource.text) {
1489
+ return resource.text;
1490
+ }
1491
+ if (resource.blob) {
1492
+ return atob(resource.blob);
1493
+ }
1494
+ throw new Error("Resource has no text or blob content");
1495
+ }
1496
+ var MCPAppsActivityRenderer = ({ content, agent }) => {
1497
+ const containerRef = useRef3(null);
1498
+ const iframeRef = useRef3(null);
1499
+ const [iframeReady, setIframeReady] = useState4(false);
1500
+ const [error, setError] = useState4(null);
1501
+ const [iframeSize, setIframeSize] = useState4({});
1502
+ const contentRef = useRef3(content);
1503
+ contentRef.current = content;
1504
+ const agentRef = useRef3(agent);
1505
+ agentRef.current = agent;
1506
+ const sendToIframe = useCallback2((msg) => {
1507
+ if (iframeRef.current?.contentWindow) {
1508
+ console.log("[MCPAppsRenderer] Sending to iframe:", msg);
1509
+ iframeRef.current.contentWindow.postMessage(msg, "*");
1510
+ }
1511
+ }, []);
1512
+ const sendResponse = useCallback2((id, result) => {
1513
+ sendToIframe({
1514
+ jsonrpc: "2.0",
1515
+ id,
1516
+ result
1517
+ });
1518
+ }, [sendToIframe]);
1519
+ const sendErrorResponse = useCallback2((id, code, message) => {
1520
+ sendToIframe({
1521
+ jsonrpc: "2.0",
1522
+ id,
1523
+ error: { code, message }
1524
+ });
1525
+ }, [sendToIframe]);
1526
+ const sendNotification = useCallback2((method, params) => {
1527
+ sendToIframe({
1528
+ jsonrpc: "2.0",
1529
+ method,
1530
+ params: params || {}
1531
+ });
1532
+ }, [sendToIframe]);
1533
+ useEffect4(() => {
1534
+ if (!containerRef.current) return;
1535
+ let mounted = true;
1536
+ let messageHandler = null;
1537
+ const setup = async () => {
1538
+ try {
1539
+ const iframe = document.createElement("iframe");
1540
+ iframe.style.width = "100%";
1541
+ iframe.style.height = "300px";
1542
+ iframe.style.border = "none";
1543
+ iframe.style.backgroundColor = "transparent";
1544
+ iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
1545
+ const sandboxReady = new Promise((resolve) => {
1546
+ const initialListener = (event) => {
1547
+ if (event.source === iframe.contentWindow) {
1548
+ if (event.data?.method === "ui/notifications/sandbox-proxy-ready") {
1549
+ window.removeEventListener("message", initialListener);
1550
+ resolve();
1551
+ }
1552
+ }
1553
+ };
1554
+ window.addEventListener("message", initialListener);
1555
+ });
1556
+ iframe.src = "/sandbox.html";
1557
+ iframeRef.current = iframe;
1558
+ containerRef.current?.appendChild(iframe);
1559
+ await sandboxReady;
1560
+ if (!mounted) return;
1561
+ console.log("[MCPAppsRenderer] Sandbox proxy ready");
1562
+ messageHandler = async (event) => {
1563
+ if (event.source !== iframe.contentWindow) return;
1564
+ const msg = event.data;
1565
+ if (!msg || typeof msg !== "object" || msg.jsonrpc !== "2.0") return;
1566
+ console.log("[MCPAppsRenderer] Received from iframe:", msg);
1567
+ if (isRequest(msg)) {
1568
+ switch (msg.method) {
1569
+ case "ui/initialize": {
1570
+ sendResponse(msg.id, {
1571
+ protocolVersion: PROTOCOL_VERSION,
1572
+ hostInfo: {
1573
+ name: "CopilotKit MCP Apps Host",
1574
+ version: "1.0.0"
1575
+ },
1576
+ hostCapabilities: {
1577
+ openLinks: {},
1578
+ logging: {}
1579
+ },
1580
+ hostContext: {
1581
+ theme: "light",
1582
+ platform: "web"
1583
+ }
1584
+ });
1585
+ break;
1586
+ }
1587
+ case "ui/message": {
1588
+ console.log("[MCPAppsRenderer] ui/message request:", msg.params);
1589
+ sendResponse(msg.id, { isError: false });
1590
+ break;
1591
+ }
1592
+ case "ui/open-link": {
1593
+ const url = msg.params?.url;
1594
+ if (url) {
1595
+ window.open(url, "_blank", "noopener,noreferrer");
1596
+ sendResponse(msg.id, { isError: false });
1597
+ } else {
1598
+ sendErrorResponse(msg.id, -32602, "Missing url parameter");
1599
+ }
1600
+ break;
1601
+ }
1602
+ case "tools/call": {
1603
+ const { serverId } = contentRef.current;
1604
+ const currentAgent = agentRef.current;
1605
+ if (!serverId) {
1606
+ sendErrorResponse(msg.id, -32603, "No server ID available for proxying");
1607
+ break;
1608
+ }
1609
+ if (!currentAgent) {
1610
+ sendErrorResponse(msg.id, -32603, "No agent available for proxying");
1611
+ break;
1612
+ }
1613
+ try {
1614
+ const runResult = await currentAgent.runAgent({
1615
+ forwardedProps: {
1616
+ __proxiedMCPRequest: {
1617
+ serverId,
1618
+ method: "tools/call",
1619
+ params: msg.params
1620
+ }
1621
+ }
1622
+ });
1623
+ sendResponse(msg.id, runResult.result || {});
1624
+ } catch (err) {
1625
+ console.error("[MCPAppsRenderer] tools/call error:", err);
1626
+ sendErrorResponse(msg.id, -32603, String(err));
1627
+ }
1628
+ break;
1629
+ }
1630
+ default:
1631
+ sendErrorResponse(msg.id, -32601, `Method not found: ${msg.method}`);
1632
+ }
1633
+ }
1634
+ if (isNotification(msg)) {
1635
+ switch (msg.method) {
1636
+ case "ui/notifications/initialized": {
1637
+ console.log("[MCPAppsRenderer] Inner iframe initialized");
1638
+ if (mounted) {
1639
+ setIframeReady(true);
1640
+ }
1641
+ break;
1642
+ }
1643
+ case "ui/notifications/size-change": {
1644
+ const { width, height } = msg.params || {};
1645
+ console.log("[MCPAppsRenderer] Size change:", { width, height });
1646
+ if (mounted) {
1647
+ setIframeSize({
1648
+ width: typeof width === "number" ? width : void 0,
1649
+ height: typeof height === "number" ? height : void 0
1650
+ });
1651
+ }
1652
+ break;
1653
+ }
1654
+ case "notifications/message": {
1655
+ console.log("[MCPAppsRenderer] App log:", msg.params);
1656
+ break;
1657
+ }
1658
+ }
1659
+ }
1660
+ };
1661
+ window.addEventListener("message", messageHandler);
1662
+ const html = extractHtmlFromResource(content.resource);
1663
+ sendNotification("ui/notifications/sandbox-resource-ready", { html });
1664
+ } catch (err) {
1665
+ console.error("[MCPAppsRenderer] Setup error:", err);
1666
+ if (mounted) {
1667
+ setError(err instanceof Error ? err : new Error(String(err)));
1668
+ }
1669
+ }
1670
+ };
1671
+ setup();
1672
+ return () => {
1673
+ mounted = false;
1674
+ if (messageHandler) {
1675
+ window.removeEventListener("message", messageHandler);
1676
+ }
1677
+ if (iframeRef.current && containerRef.current?.contains(iframeRef.current)) {
1678
+ containerRef.current.removeChild(iframeRef.current);
1679
+ }
1680
+ iframeRef.current = null;
1681
+ };
1682
+ }, [content.resource, sendNotification, sendResponse, sendErrorResponse]);
1683
+ useEffect4(() => {
1684
+ if (iframeRef.current) {
1685
+ if (iframeSize.width !== void 0) {
1686
+ iframeRef.current.style.width = `${iframeSize.width}px`;
1687
+ }
1688
+ if (iframeSize.height !== void 0) {
1689
+ iframeRef.current.style.height = `${iframeSize.height}px`;
1690
+ }
1691
+ }
1692
+ }, [iframeSize]);
1693
+ useEffect4(() => {
1694
+ if (iframeReady && content.toolInput) {
1695
+ console.log("[MCPAppsRenderer] Sending tool input:", content.toolInput);
1696
+ sendNotification("ui/notifications/tool-input", {
1697
+ arguments: content.toolInput
1698
+ });
1699
+ }
1700
+ }, [iframeReady, content.toolInput, sendNotification]);
1701
+ useEffect4(() => {
1702
+ if (iframeReady && content.result) {
1703
+ console.log("[MCPAppsRenderer] Sending tool result:", content.result);
1704
+ sendNotification("ui/notifications/tool-result", content.result);
1705
+ }
1706
+ }, [iframeReady, content.result, sendNotification]);
1707
+ return /* @__PURE__ */ jsx8(
1708
+ "div",
1709
+ {
1710
+ ref: containerRef,
1711
+ style: {
1712
+ width: "100%",
1713
+ minHeight: "100px",
1714
+ borderRadius: "8px",
1715
+ overflow: "hidden",
1716
+ backgroundColor: "#f9f9f9",
1717
+ border: "1px solid #e0e0e0"
1718
+ },
1719
+ children: error && /* @__PURE__ */ jsxs4("div", { style: { color: "red", padding: "1rem" }, children: [
1720
+ "Error: ",
1721
+ error.message
1722
+ ] })
1723
+ }
1724
+ );
1725
+ };
1726
+
1727
+ // src/providers/CopilotKitProvider.tsx
1728
+ import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
1460
1729
  var HEADER_NAME = "X-CopilotCloud-Public-Api-Key";
1461
1730
  var COPILOT_CLOUD_CHAT_URL = "https://api.cloud.copilotkit.ai/copilotkit/v1";
1731
+ var EMPTY_SET = /* @__PURE__ */ new Set();
1462
1732
  var CopilotKitContext = createContext2({
1463
- copilotkit: null
1733
+ copilotkit: null,
1734
+ executingToolCallIds: EMPTY_SET
1464
1735
  });
1465
1736
  function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
1466
1737
  const empty = useMemo3(() => [], []);
1467
1738
  const value = prop ?? empty;
1468
- const initial = useRef3(value);
1469
- useEffect4(() => {
1739
+ const initial = useRef4(value);
1740
+ useEffect5(() => {
1470
1741
  if (warningMessage && value !== initial.current && (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)) {
1471
1742
  console.error(warningMessage);
1472
1743
  }
@@ -1489,8 +1760,8 @@ var CopilotKitProvider = ({
1489
1760
  showDevConsole = false,
1490
1761
  useSingleEndpoint = false
1491
1762
  }) => {
1492
- const [shouldRenderInspector, setShouldRenderInspector] = useState4(false);
1493
- useEffect4(() => {
1763
+ const [shouldRenderInspector, setShouldRenderInspector] = useState5(false);
1764
+ useEffect5(() => {
1494
1765
  if (typeof window === "undefined") {
1495
1766
  return;
1496
1767
  }
@@ -1528,6 +1799,16 @@ var CopilotKitProvider = ({
1528
1799
  renderActivityMessages,
1529
1800
  "renderActivityMessages must be a stable array."
1530
1801
  );
1802
+ const builtInActivityRenderers = useMemo3(() => [
1803
+ {
1804
+ activityType: MCPAppsActivityType,
1805
+ content: MCPAppsActivityContentSchema,
1806
+ render: MCPAppsActivityRenderer
1807
+ }
1808
+ ], []);
1809
+ const allActivityRenderers = useMemo3(() => {
1810
+ return [...renderActivityMessagesList, ...builtInActivityRenderers];
1811
+ }, [renderActivityMessagesList, builtInActivityRenderers]);
1531
1812
  const resolvedPublicKey = publicApiKey ?? publicLicenseKey;
1532
1813
  const hasLocalAgents = agents && Object.keys(agents).length > 0;
1533
1814
  const mergedHeaders = useMemo3(() => {
@@ -1594,7 +1875,7 @@ var CopilotKitProvider = ({
1594
1875
  const combined = [...renderToolCallsList];
1595
1876
  frontendToolsList.forEach((tool) => {
1596
1877
  if (tool.render) {
1597
- const args = tool.parameters || (tool.name === "*" ? z.any() : void 0);
1878
+ const args = tool.parameters || (tool.name === "*" ? z2.any() : void 0);
1598
1879
  if (args) {
1599
1880
  combined.push({
1600
1881
  name: tool.name,
@@ -1616,13 +1897,13 @@ var CopilotKitProvider = ({
1616
1897
  agents__unsafe_dev_only: agents,
1617
1898
  tools: allTools,
1618
1899
  renderToolCalls: allRenderToolCalls,
1619
- renderActivityMessages: renderActivityMessagesList,
1900
+ renderActivityMessages: allActivityRenderers,
1620
1901
  renderCustomMessages: renderCustomMessagesList
1621
1902
  });
1622
1903
  return copilotkit2;
1623
- }, [allTools, allRenderToolCalls, renderActivityMessagesList, renderCustomMessagesList, useSingleEndpoint]);
1904
+ }, [allTools, allRenderToolCalls, allActivityRenderers, renderCustomMessagesList, useSingleEndpoint]);
1624
1905
  const [, forceUpdate] = useReducer((x) => x + 1, 0);
1625
- useEffect4(() => {
1906
+ useEffect5(() => {
1626
1907
  const subscription = copilotkit.subscribe({
1627
1908
  onRenderToolCallsChanged: () => {
1628
1909
  forceUpdate();
@@ -1632,22 +1913,47 @@ var CopilotKitProvider = ({
1632
1913
  subscription.unsubscribe();
1633
1914
  };
1634
1915
  }, [copilotkit]);
1635
- useEffect4(() => {
1916
+ const [executingToolCallIds, setExecutingToolCallIds] = useState5(() => /* @__PURE__ */ new Set());
1917
+ useEffect5(() => {
1918
+ const subscription = copilotkit.subscribe({
1919
+ onToolExecutionStart: ({ toolCallId }) => {
1920
+ setExecutingToolCallIds((prev) => {
1921
+ if (prev.has(toolCallId)) return prev;
1922
+ const next = new Set(prev);
1923
+ next.add(toolCallId);
1924
+ return next;
1925
+ });
1926
+ },
1927
+ onToolExecutionEnd: ({ toolCallId }) => {
1928
+ setExecutingToolCallIds((prev) => {
1929
+ if (!prev.has(toolCallId)) return prev;
1930
+ const next = new Set(prev);
1931
+ next.delete(toolCallId);
1932
+ return next;
1933
+ });
1934
+ }
1935
+ });
1936
+ return () => {
1937
+ subscription.unsubscribe();
1938
+ };
1939
+ }, [copilotkit]);
1940
+ useEffect5(() => {
1636
1941
  copilotkit.setRuntimeUrl(chatApiEndpoint);
1637
1942
  copilotkit.setRuntimeTransport(useSingleEndpoint ? "single" : "rest");
1638
1943
  copilotkit.setHeaders(mergedHeaders);
1639
1944
  copilotkit.setProperties(properties);
1640
1945
  copilotkit.setAgents__unsafe_dev_only(agents);
1641
1946
  }, [chatApiEndpoint, mergedHeaders, properties, agents, useSingleEndpoint]);
1642
- return /* @__PURE__ */ jsxs4(
1947
+ return /* @__PURE__ */ jsxs5(
1643
1948
  CopilotKitContext.Provider,
1644
1949
  {
1645
1950
  value: {
1646
- copilotkit
1951
+ copilotkit,
1952
+ executingToolCallIds
1647
1953
  },
1648
1954
  children: [
1649
1955
  children,
1650
- shouldRenderInspector ? /* @__PURE__ */ jsx8(CopilotKitInspector, { core: copilotkit }) : null
1956
+ shouldRenderInspector ? /* @__PURE__ */ jsx9(CopilotKitInspector, { core: copilotkit }) : null
1651
1957
  ]
1652
1958
  }
1653
1959
  );
@@ -1658,7 +1964,7 @@ var useCopilotKit = () => {
1658
1964
  if (!context) {
1659
1965
  throw new Error("useCopilotKit must be used within CopilotKitProvider");
1660
1966
  }
1661
- useEffect4(() => {
1967
+ useEffect5(() => {
1662
1968
  const subscription = context.copilotkit.subscribe({
1663
1969
  onRuntimeConnectionStatusChanged: () => {
1664
1970
  forceUpdate();
@@ -1674,8 +1980,8 @@ var useCopilotKit = () => {
1674
1980
  // src/hooks/use-render-tool-call.tsx
1675
1981
  import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID2 } from "@copilotkitnext/shared";
1676
1982
  import { partialJSONParse } from "@copilotkitnext/shared";
1677
- import { jsx as jsx9 } from "react/jsx-runtime";
1678
- var ToolCallRenderer = React6.memo(
1983
+ import { jsx as jsx10 } from "react/jsx-runtime";
1984
+ var ToolCallRenderer = React7.memo(
1679
1985
  function ToolCallRenderer2({
1680
1986
  toolCall,
1681
1987
  toolMessage,
@@ -1688,7 +1994,7 @@ var ToolCallRenderer = React6.memo(
1688
1994
  );
1689
1995
  const toolName = toolCall.function.name;
1690
1996
  if (toolMessage) {
1691
- return /* @__PURE__ */ jsx9(
1997
+ return /* @__PURE__ */ jsx10(
1692
1998
  RenderComponent,
1693
1999
  {
1694
2000
  name: toolName,
@@ -1698,7 +2004,7 @@ var ToolCallRenderer = React6.memo(
1698
2004
  }
1699
2005
  );
1700
2006
  } else if (isExecuting) {
1701
- return /* @__PURE__ */ jsx9(
2007
+ return /* @__PURE__ */ jsx10(
1702
2008
  RenderComponent,
1703
2009
  {
1704
2010
  name: toolName,
@@ -1708,7 +2014,7 @@ var ToolCallRenderer = React6.memo(
1708
2014
  }
1709
2015
  );
1710
2016
  } else {
1711
- return /* @__PURE__ */ jsx9(
2017
+ return /* @__PURE__ */ jsx10(
1712
2018
  RenderComponent,
1713
2019
  {
1714
2020
  name: toolName,
@@ -1733,10 +2039,9 @@ var ToolCallRenderer = React6.memo(
1733
2039
  }
1734
2040
  );
1735
2041
  function useRenderToolCall() {
1736
- const { copilotkit } = useCopilotKit();
2042
+ const { copilotkit, executingToolCallIds } = useCopilotKit();
1737
2043
  const config = useCopilotChatConfiguration();
1738
2044
  const agentId = config?.agentId ?? DEFAULT_AGENT_ID2;
1739
- const [executingToolCallIds, setExecutingToolCallIds] = useState5(() => /* @__PURE__ */ new Set());
1740
2045
  const renderToolCalls = useSyncExternalStore(
1741
2046
  (callback) => {
1742
2047
  return copilotkit.subscribe({
@@ -1746,28 +2051,7 @@ function useRenderToolCall() {
1746
2051
  () => copilotkit.renderToolCalls,
1747
2052
  () => copilotkit.renderToolCalls
1748
2053
  );
1749
- useEffect5(() => {
1750
- const subscription = copilotkit.subscribe({
1751
- onToolExecutionStart: ({ toolCallId }) => {
1752
- setExecutingToolCallIds((prev) => {
1753
- if (prev.has(toolCallId)) return prev;
1754
- const next = new Set(prev);
1755
- next.add(toolCallId);
1756
- return next;
1757
- });
1758
- },
1759
- onToolExecutionEnd: ({ toolCallId }) => {
1760
- setExecutingToolCallIds((prev) => {
1761
- if (!prev.has(toolCallId)) return prev;
1762
- const next = new Set(prev);
1763
- next.delete(toolCallId);
1764
- return next;
1765
- });
1766
- }
1767
- });
1768
- return () => subscription.unsubscribe();
1769
- }, [copilotkit]);
1770
- const renderToolCall = useCallback2(
2054
+ const renderToolCall = useCallback3(
1771
2055
  ({
1772
2056
  toolCall,
1773
2057
  toolMessage
@@ -1781,7 +2065,7 @@ function useRenderToolCall() {
1781
2065
  }
1782
2066
  const RenderComponent = renderConfig.render;
1783
2067
  const isExecuting = executingToolCallIds.has(toolCall.id);
1784
- return /* @__PURE__ */ jsx9(
2068
+ return /* @__PURE__ */ jsx10(
1785
2069
  ToolCallRenderer,
1786
2070
  {
1787
2071
  toolCall,
@@ -1798,7 +2082,7 @@ function useRenderToolCall() {
1798
2082
  }
1799
2083
 
1800
2084
  // src/hooks/use-render-custom-messages.tsx
1801
- import { jsx as jsx10 } from "react/jsx-runtime";
2085
+ import { jsx as jsx11 } from "react/jsx-runtime";
1802
2086
  function useRenderCustomMessages() {
1803
2087
  const { copilotkit } = useCopilotKit();
1804
2088
  const config = useCopilotChatConfiguration();
@@ -1833,7 +2117,7 @@ function useRenderCustomMessages() {
1833
2117
  continue;
1834
2118
  }
1835
2119
  const Component = renderer.render;
1836
- result = /* @__PURE__ */ jsx10(
2120
+ result = /* @__PURE__ */ jsx11(
1837
2121
  Component,
1838
2122
  {
1839
2123
  message,
@@ -1857,14 +2141,14 @@ function useRenderCustomMessages() {
1857
2141
 
1858
2142
  // src/hooks/use-render-activity-message.tsx
1859
2143
  import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID3 } from "@copilotkitnext/shared";
1860
- import { useCallback as useCallback3 } from "react";
1861
- import { jsx as jsx11 } from "react/jsx-runtime";
2144
+ import { useCallback as useCallback4 } from "react";
2145
+ import { jsx as jsx12 } from "react/jsx-runtime";
1862
2146
  function useRenderActivityMessage() {
1863
2147
  const { copilotkit } = useCopilotKit();
1864
2148
  const config = useCopilotChatConfiguration();
1865
2149
  const agentId = config?.agentId ?? DEFAULT_AGENT_ID3;
1866
2150
  const renderers = copilotkit.renderActivityMessages;
1867
- return useCallback3(
2151
+ return useCallback4(
1868
2152
  (message) => {
1869
2153
  if (!renderers.length) {
1870
2154
  return null;
@@ -1886,7 +2170,7 @@ function useRenderActivityMessage() {
1886
2170
  }
1887
2171
  const Component = renderer.render;
1888
2172
  const agent = copilotkit.getAgent(agentId);
1889
- return /* @__PURE__ */ jsx11(
2173
+ return /* @__PURE__ */ jsx12(
1890
2174
  Component,
1891
2175
  {
1892
2176
  activityType: message.activityType,
@@ -1939,23 +2223,23 @@ function useFrontendTool(tool, deps) {
1939
2223
  }
1940
2224
 
1941
2225
  // src/hooks/use-human-in-the-loop.tsx
1942
- import { useCallback as useCallback4, useRef as useRef4, useEffect as useEffect7 } from "react";
1943
- import React7 from "react";
2226
+ import { useCallback as useCallback5, useRef as useRef5, useEffect as useEffect7 } from "react";
2227
+ import React8 from "react";
1944
2228
  function useHumanInTheLoop(tool, deps) {
1945
2229
  const { copilotkit } = useCopilotKit();
1946
- const resolvePromiseRef = useRef4(null);
1947
- const respond = useCallback4(async (result) => {
2230
+ const resolvePromiseRef = useRef5(null);
2231
+ const respond = useCallback5(async (result) => {
1948
2232
  if (resolvePromiseRef.current) {
1949
2233
  resolvePromiseRef.current(result);
1950
2234
  resolvePromiseRef.current = null;
1951
2235
  }
1952
2236
  }, []);
1953
- const handler = useCallback4(async () => {
2237
+ const handler = useCallback5(async () => {
1954
2238
  return new Promise((resolve) => {
1955
2239
  resolvePromiseRef.current = resolve;
1956
2240
  });
1957
2241
  }, []);
1958
- const RenderComponent = useCallback4(
2242
+ const RenderComponent = useCallback5(
1959
2243
  (props) => {
1960
2244
  const ToolComponent = tool.render;
1961
2245
  if (props.status === "inProgress") {
@@ -1965,7 +2249,7 @@ function useHumanInTheLoop(tool, deps) {
1965
2249
  description: tool.description || "",
1966
2250
  respond: void 0
1967
2251
  };
1968
- return React7.createElement(ToolComponent, enhancedProps);
2252
+ return React8.createElement(ToolComponent, enhancedProps);
1969
2253
  } else if (props.status === "executing") {
1970
2254
  const enhancedProps = {
1971
2255
  ...props,
@@ -1973,7 +2257,7 @@ function useHumanInTheLoop(tool, deps) {
1973
2257
  description: tool.description || "",
1974
2258
  respond
1975
2259
  };
1976
- return React7.createElement(ToolComponent, enhancedProps);
2260
+ return React8.createElement(ToolComponent, enhancedProps);
1977
2261
  } else if (props.status === "complete") {
1978
2262
  const enhancedProps = {
1979
2263
  ...props,
@@ -1981,9 +2265,9 @@ function useHumanInTheLoop(tool, deps) {
1981
2265
  description: tool.description || "",
1982
2266
  respond: void 0
1983
2267
  };
1984
- return React7.createElement(ToolComponent, enhancedProps);
2268
+ return React8.createElement(ToolComponent, enhancedProps);
1985
2269
  }
1986
- return React7.createElement(ToolComponent, props);
2270
+ return React8.createElement(ToolComponent, props);
1987
2271
  },
1988
2272
  [tool.render, tool.name, tool.description, respond]
1989
2273
  );
@@ -2009,6 +2293,12 @@ function useHumanInTheLoop(tool, deps) {
2009
2293
  import { useMemo as useMemo5, useEffect as useEffect8, useReducer as useReducer2 } from "react";
2010
2294
  import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID4 } from "@copilotkitnext/shared";
2011
2295
  import { ProxiedCopilotRuntimeAgent, CopilotKitCoreRuntimeConnectionStatus } from "@copilotkitnext/core";
2296
+ var UseAgentUpdate = /* @__PURE__ */ ((UseAgentUpdate2) => {
2297
+ UseAgentUpdate2["OnMessagesChanged"] = "OnMessagesChanged";
2298
+ UseAgentUpdate2["OnStateChanged"] = "OnStateChanged";
2299
+ UseAgentUpdate2["OnRunStatusChanged"] = "OnRunStatusChanged";
2300
+ return UseAgentUpdate2;
2301
+ })(UseAgentUpdate || {});
2012
2302
  var ALL_UPDATES = [
2013
2303
  "OnMessagesChanged" /* OnMessagesChanged */,
2014
2304
  "OnStateChanged" /* OnStateChanged */,
@@ -2107,7 +2397,7 @@ function useAgentContext(context) {
2107
2397
  }
2108
2398
 
2109
2399
  // src/hooks/use-suggestions.tsx
2110
- import { useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo7, useState as useState6 } from "react";
2400
+ import { useCallback as useCallback6, useEffect as useEffect10, useMemo as useMemo7, useState as useState6 } from "react";
2111
2401
  import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID5 } from "@copilotkitnext/shared";
2112
2402
  function useSuggestions({ agentId } = {}) {
2113
2403
  const { copilotkit } = useCopilotKit();
@@ -2156,10 +2446,10 @@ function useSuggestions({ agentId } = {}) {
2156
2446
  subscription.unsubscribe();
2157
2447
  };
2158
2448
  }, [copilotkit, resolvedAgentId]);
2159
- const reloadSuggestions = useCallback5(() => {
2449
+ const reloadSuggestions = useCallback6(() => {
2160
2450
  copilotkit.reloadSuggestions(resolvedAgentId);
2161
2451
  }, [copilotkit, resolvedAgentId]);
2162
- const clearSuggestions = useCallback5(() => {
2452
+ const clearSuggestions = useCallback6(() => {
2163
2453
  copilotkit.clearSuggestions(resolvedAgentId);
2164
2454
  }, [copilotkit, resolvedAgentId]);
2165
2455
  return {
@@ -2171,7 +2461,7 @@ function useSuggestions({ agentId } = {}) {
2171
2461
  }
2172
2462
 
2173
2463
  // src/hooks/use-configure-suggestions.tsx
2174
- import { useCallback as useCallback6, useEffect as useEffect11, useMemo as useMemo8, useRef as useRef5 } from "react";
2464
+ import { useCallback as useCallback7, useEffect as useEffect11, useMemo as useMemo8, useRef as useRef6 } from "react";
2175
2465
  import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID6 } from "@copilotkitnext/shared";
2176
2466
  function useConfigureSuggestions(config, deps) {
2177
2467
  const { copilotkit } = useCopilotKit();
@@ -2179,7 +2469,7 @@ function useConfigureSuggestions(config, deps) {
2179
2469
  const extraDeps = deps ?? [];
2180
2470
  const resolvedConsumerAgentId = useMemo8(() => chatConfig?.agentId ?? DEFAULT_AGENT_ID6, [chatConfig?.agentId]);
2181
2471
  const rawConsumerAgentId = useMemo8(() => config ? config.consumerAgentId : void 0, [config]);
2182
- const normalizationCacheRef = useRef5({
2472
+ const normalizationCacheRef = useRef6({
2183
2473
  serialized: null,
2184
2474
  config: null
2185
2475
  });
@@ -2213,9 +2503,9 @@ function useConfigureSuggestions(config, deps) {
2213
2503
  normalizationCacheRef.current = { serialized, config: built };
2214
2504
  return { normalizedConfig: built, serializedConfig: serialized };
2215
2505
  }, [config, resolvedConsumerAgentId, ...extraDeps]);
2216
- const latestConfigRef = useRef5(null);
2506
+ const latestConfigRef = useRef6(null);
2217
2507
  latestConfigRef.current = normalizedConfig;
2218
- const previousSerializedConfigRef = useRef5(null);
2508
+ const previousSerializedConfigRef = useRef6(null);
2219
2509
  const targetAgentId = useMemo8(() => {
2220
2510
  if (!normalizedConfig) {
2221
2511
  return resolvedConsumerAgentId;
@@ -2227,7 +2517,7 @@ function useConfigureSuggestions(config, deps) {
2227
2517
  return consumer;
2228
2518
  }, [normalizedConfig, resolvedConsumerAgentId]);
2229
2519
  const isGlobalConfig = rawConsumerAgentId === void 0 || rawConsumerAgentId === "*";
2230
- const requestReload = useCallback6(() => {
2520
+ const requestReload = useCallback7(() => {
2231
2521
  if (!normalizedConfig) {
2232
2522
  return;
2233
2523
  }
@@ -2290,8 +2580,8 @@ function normalizeStaticSuggestions(suggestions) {
2290
2580
  }
2291
2581
 
2292
2582
  // src/components/chat/CopilotChatToolCallsView.tsx
2293
- import React8 from "react";
2294
- import { Fragment as Fragment2, jsx as jsx12 } from "react/jsx-runtime";
2583
+ import React9 from "react";
2584
+ import { Fragment as Fragment2, jsx as jsx13 } from "react/jsx-runtime";
2295
2585
  function CopilotChatToolCallsView({
2296
2586
  message,
2297
2587
  messages = []
@@ -2300,11 +2590,11 @@ function CopilotChatToolCallsView({
2300
2590
  if (!message.toolCalls || message.toolCalls.length === 0) {
2301
2591
  return null;
2302
2592
  }
2303
- return /* @__PURE__ */ jsx12(Fragment2, { children: message.toolCalls.map((toolCall) => {
2593
+ return /* @__PURE__ */ jsx13(Fragment2, { children: message.toolCalls.map((toolCall) => {
2304
2594
  const toolMessage = messages.find(
2305
2595
  (m) => m.role === "tool" && m.toolCallId === toolCall.id
2306
2596
  );
2307
- return /* @__PURE__ */ jsx12(React8.Fragment, { children: renderToolCall({
2597
+ return /* @__PURE__ */ jsx13(React9.Fragment, { children: renderToolCall({
2308
2598
  toolCall,
2309
2599
  toolMessage
2310
2600
  }) }, toolCall.id);
@@ -2313,7 +2603,7 @@ function CopilotChatToolCallsView({
2313
2603
  var CopilotChatToolCallsView_default = CopilotChatToolCallsView;
2314
2604
 
2315
2605
  // src/components/chat/CopilotChatAssistantMessage.tsx
2316
- import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
2606
+ import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
2317
2607
  function CopilotChatAssistantMessage({
2318
2608
  message,
2319
2609
  messages,
@@ -2390,7 +2680,7 @@ function CopilotChatAssistantMessage({
2390
2680
  toolbar,
2391
2681
  CopilotChatAssistantMessage.Toolbar,
2392
2682
  {
2393
- children: /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1", children: [
2683
+ children: /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1", children: [
2394
2684
  boundCopyButton,
2395
2685
  (onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
2396
2686
  (onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
@@ -2412,7 +2702,7 @@ function CopilotChatAssistantMessage({
2412
2702
  const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
2413
2703
  const shouldShowToolbar = toolbarVisible && hasContent && !(isRunning && isLatestAssistantMessage);
2414
2704
  if (children) {
2415
- return /* @__PURE__ */ jsx13(Fragment3, { children: children({
2705
+ return /* @__PURE__ */ jsx14(Fragment3, { children: children({
2416
2706
  markdownRenderer: boundMarkdownRenderer,
2417
2707
  toolbar: boundToolbar,
2418
2708
  toolCallsView: boundToolCallsView,
@@ -2432,7 +2722,7 @@ function CopilotChatAssistantMessage({
2432
2722
  toolbarVisible: shouldShowToolbar
2433
2723
  }) });
2434
2724
  }
2435
- return /* @__PURE__ */ jsxs5(
2725
+ return /* @__PURE__ */ jsxs6(
2436
2726
  "div",
2437
2727
  {
2438
2728
  className: twMerge4(
@@ -2450,11 +2740,11 @@ function CopilotChatAssistantMessage({
2450
2740
  );
2451
2741
  }
2452
2742
  ((CopilotChatAssistantMessage2) => {
2453
- CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ jsx13(Streamdown, { className, ...props, children: content ?? "" });
2743
+ CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ jsx14(Streamdown, { className, ...props, children: content ?? "" });
2454
2744
  CopilotChatAssistantMessage2.Toolbar = ({
2455
2745
  className,
2456
2746
  ...props
2457
- }) => /* @__PURE__ */ jsx13(
2747
+ }) => /* @__PURE__ */ jsx14(
2458
2748
  "div",
2459
2749
  {
2460
2750
  className: twMerge4(
@@ -2465,8 +2755,8 @@ function CopilotChatAssistantMessage({
2465
2755
  }
2466
2756
  );
2467
2757
  CopilotChatAssistantMessage2.ToolbarButton = ({ title, children, ...props }) => {
2468
- return /* @__PURE__ */ jsxs5(Tooltip, { children: [
2469
- /* @__PURE__ */ jsx13(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx13(
2758
+ return /* @__PURE__ */ jsxs6(Tooltip, { children: [
2759
+ /* @__PURE__ */ jsx14(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx14(
2470
2760
  Button,
2471
2761
  {
2472
2762
  type: "button",
@@ -2476,7 +2766,7 @@ function CopilotChatAssistantMessage({
2476
2766
  children
2477
2767
  }
2478
2768
  ) }),
2479
- /* @__PURE__ */ jsx13(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx13("p", { children: title }) })
2769
+ /* @__PURE__ */ jsx14(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx14("p", { children: title }) })
2480
2770
  ] });
2481
2771
  };
2482
2772
  CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
@@ -2490,62 +2780,62 @@ function CopilotChatAssistantMessage({
2490
2780
  onClick(event);
2491
2781
  }
2492
2782
  };
2493
- return /* @__PURE__ */ jsx13(
2783
+ return /* @__PURE__ */ jsx14(
2494
2784
  CopilotChatAssistantMessage2.ToolbarButton,
2495
2785
  {
2496
2786
  title: title || labels.assistantMessageToolbarCopyMessageLabel,
2497
2787
  onClick: handleClick,
2498
2788
  className,
2499
2789
  ...props,
2500
- children: copied ? /* @__PURE__ */ jsx13(Check2, { className: "size-[18px]" }) : /* @__PURE__ */ jsx13(Copy, { className: "size-[18px]" })
2790
+ children: copied ? /* @__PURE__ */ jsx14(Check2, { className: "size-[18px]" }) : /* @__PURE__ */ jsx14(Copy, { className: "size-[18px]" })
2501
2791
  }
2502
2792
  );
2503
2793
  };
2504
2794
  CopilotChatAssistantMessage2.ThumbsUpButton = ({ title, ...props }) => {
2505
2795
  const config = useCopilotChatConfiguration();
2506
2796
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2507
- return /* @__PURE__ */ jsx13(
2797
+ return /* @__PURE__ */ jsx14(
2508
2798
  CopilotChatAssistantMessage2.ToolbarButton,
2509
2799
  {
2510
2800
  title: title || labels.assistantMessageToolbarThumbsUpLabel,
2511
2801
  ...props,
2512
- children: /* @__PURE__ */ jsx13(ThumbsUp, { className: "size-[18px]" })
2802
+ children: /* @__PURE__ */ jsx14(ThumbsUp, { className: "size-[18px]" })
2513
2803
  }
2514
2804
  );
2515
2805
  };
2516
2806
  CopilotChatAssistantMessage2.ThumbsDownButton = ({ title, ...props }) => {
2517
2807
  const config = useCopilotChatConfiguration();
2518
2808
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2519
- return /* @__PURE__ */ jsx13(
2809
+ return /* @__PURE__ */ jsx14(
2520
2810
  CopilotChatAssistantMessage2.ToolbarButton,
2521
2811
  {
2522
2812
  title: title || labels.assistantMessageToolbarThumbsDownLabel,
2523
2813
  ...props,
2524
- children: /* @__PURE__ */ jsx13(ThumbsDown, { className: "size-[18px]" })
2814
+ children: /* @__PURE__ */ jsx14(ThumbsDown, { className: "size-[18px]" })
2525
2815
  }
2526
2816
  );
2527
2817
  };
2528
2818
  CopilotChatAssistantMessage2.ReadAloudButton = ({ title, ...props }) => {
2529
2819
  const config = useCopilotChatConfiguration();
2530
2820
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2531
- return /* @__PURE__ */ jsx13(
2821
+ return /* @__PURE__ */ jsx14(
2532
2822
  CopilotChatAssistantMessage2.ToolbarButton,
2533
2823
  {
2534
2824
  title: title || labels.assistantMessageToolbarReadAloudLabel,
2535
2825
  ...props,
2536
- children: /* @__PURE__ */ jsx13(Volume2, { className: "size-[20px]" })
2826
+ children: /* @__PURE__ */ jsx14(Volume2, { className: "size-[20px]" })
2537
2827
  }
2538
2828
  );
2539
2829
  };
2540
2830
  CopilotChatAssistantMessage2.RegenerateButton = ({ title, ...props }) => {
2541
2831
  const config = useCopilotChatConfiguration();
2542
2832
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2543
- return /* @__PURE__ */ jsx13(
2833
+ return /* @__PURE__ */ jsx14(
2544
2834
  CopilotChatAssistantMessage2.ToolbarButton,
2545
2835
  {
2546
2836
  title: title || labels.assistantMessageToolbarRegenerateLabel,
2547
2837
  ...props,
2548
- children: /* @__PURE__ */ jsx13(RefreshCw, { className: "size-[18px]" })
2838
+ children: /* @__PURE__ */ jsx14(RefreshCw, { className: "size-[18px]" })
2549
2839
  }
2550
2840
  );
2551
2841
  };
@@ -2563,7 +2853,7 @@ var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
2563
2853
  import { useMemo as useMemo9, useState as useState8 } from "react";
2564
2854
  import { Copy as Copy2, Check as Check3, Edit, ChevronLeft, ChevronRight } from "lucide-react";
2565
2855
  import { twMerge as twMerge5 } from "tailwind-merge";
2566
- import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
2856
+ import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
2567
2857
  function flattenUserMessageContent(content) {
2568
2858
  if (!content) {
2569
2859
  return "";
@@ -2639,7 +2929,7 @@ function CopilotChatUserMessage({
2639
2929
  );
2640
2930
  const showBranchNavigation = numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;
2641
2931
  const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, {
2642
- children: /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1 justify-end", children: [
2932
+ children: /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-1 justify-end", children: [
2643
2933
  additionalToolbarItems,
2644
2934
  BoundCopyButton,
2645
2935
  onEditMessage && BoundEditButton,
@@ -2647,7 +2937,7 @@ function CopilotChatUserMessage({
2647
2937
  ] })
2648
2938
  });
2649
2939
  if (children) {
2650
- return /* @__PURE__ */ jsx14(Fragment4, { children: children({
2940
+ return /* @__PURE__ */ jsx15(Fragment4, { children: children({
2651
2941
  messageRenderer: BoundMessageRenderer,
2652
2942
  toolbar: BoundToolbar,
2653
2943
  copyButton: BoundCopyButton,
@@ -2659,7 +2949,7 @@ function CopilotChatUserMessage({
2659
2949
  additionalToolbarItems
2660
2950
  }) });
2661
2951
  }
2662
- return /* @__PURE__ */ jsxs6(
2952
+ return /* @__PURE__ */ jsxs7(
2663
2953
  "div",
2664
2954
  {
2665
2955
  className: twMerge5("flex flex-col items-end group pt-10", className),
@@ -2673,7 +2963,7 @@ function CopilotChatUserMessage({
2673
2963
  );
2674
2964
  }
2675
2965
  ((CopilotChatUserMessage2) => {
2676
- CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ jsx14(
2966
+ CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ jsx15(
2677
2967
  "div",
2678
2968
  {
2679
2969
  className: twMerge5("flex flex-col items-end group", className),
@@ -2681,7 +2971,7 @@ function CopilotChatUserMessage({
2681
2971
  children
2682
2972
  }
2683
2973
  );
2684
- CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ jsx14(
2974
+ CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ jsx15(
2685
2975
  "div",
2686
2976
  {
2687
2977
  className: twMerge5(
@@ -2694,7 +2984,7 @@ function CopilotChatUserMessage({
2694
2984
  CopilotChatUserMessage2.Toolbar = ({
2695
2985
  className,
2696
2986
  ...props
2697
- }) => /* @__PURE__ */ jsx14(
2987
+ }) => /* @__PURE__ */ jsx15(
2698
2988
  "div",
2699
2989
  {
2700
2990
  className: twMerge5(
@@ -2705,8 +2995,8 @@ function CopilotChatUserMessage({
2705
2995
  }
2706
2996
  );
2707
2997
  CopilotChatUserMessage2.ToolbarButton = ({ title, children, className, ...props }) => {
2708
- return /* @__PURE__ */ jsxs6(Tooltip, { children: [
2709
- /* @__PURE__ */ jsx14(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx14(
2998
+ return /* @__PURE__ */ jsxs7(Tooltip, { children: [
2999
+ /* @__PURE__ */ jsx15(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx15(
2710
3000
  Button,
2711
3001
  {
2712
3002
  type: "button",
@@ -2717,7 +3007,7 @@ function CopilotChatUserMessage({
2717
3007
  children
2718
3008
  }
2719
3009
  ) }),
2720
- /* @__PURE__ */ jsx14(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx14("p", { children: title }) })
3010
+ /* @__PURE__ */ jsx15(TooltipContent, { side: "bottom", children: /* @__PURE__ */ jsx15("p", { children: title }) })
2721
3011
  ] });
2722
3012
  };
2723
3013
  CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
@@ -2731,27 +3021,27 @@ function CopilotChatUserMessage({
2731
3021
  onClick(event);
2732
3022
  }
2733
3023
  };
2734
- return /* @__PURE__ */ jsx14(
3024
+ return /* @__PURE__ */ jsx15(
2735
3025
  CopilotChatUserMessage2.ToolbarButton,
2736
3026
  {
2737
3027
  title: title || labels.userMessageToolbarCopyMessageLabel,
2738
3028
  onClick: handleClick,
2739
3029
  className,
2740
3030
  ...props,
2741
- children: copied ? /* @__PURE__ */ jsx14(Check3, { className: "size-[18px]" }) : /* @__PURE__ */ jsx14(Copy2, { className: "size-[18px]" })
3031
+ children: copied ? /* @__PURE__ */ jsx15(Check3, { className: "size-[18px]" }) : /* @__PURE__ */ jsx15(Copy2, { className: "size-[18px]" })
2742
3032
  }
2743
3033
  );
2744
3034
  };
2745
3035
  CopilotChatUserMessage2.EditButton = ({ className, title, ...props }) => {
2746
3036
  const config = useCopilotChatConfiguration();
2747
3037
  const labels = config?.labels ?? CopilotChatDefaultLabels;
2748
- return /* @__PURE__ */ jsx14(
3038
+ return /* @__PURE__ */ jsx15(
2749
3039
  CopilotChatUserMessage2.ToolbarButton,
2750
3040
  {
2751
3041
  title: title || labels.userMessageToolbarEditMessageLabel,
2752
3042
  className,
2753
3043
  ...props,
2754
- children: /* @__PURE__ */ jsx14(Edit, { className: "size-[18px]" })
3044
+ children: /* @__PURE__ */ jsx15(Edit, { className: "size-[18px]" })
2755
3045
  }
2756
3046
  );
2757
3047
  };
@@ -2768,8 +3058,8 @@ function CopilotChatUserMessage({
2768
3058
  }
2769
3059
  const canGoPrev = currentBranch > 0;
2770
3060
  const canGoNext = currentBranch < numberOfBranches - 1;
2771
- return /* @__PURE__ */ jsxs6("div", { className: twMerge5("flex items-center gap-1", className), ...props, children: [
2772
- /* @__PURE__ */ jsx14(
3061
+ return /* @__PURE__ */ jsxs7("div", { className: twMerge5("flex items-center gap-1", className), ...props, children: [
3062
+ /* @__PURE__ */ jsx15(
2773
3063
  Button,
2774
3064
  {
2775
3065
  type: "button",
@@ -2781,15 +3071,15 @@ function CopilotChatUserMessage({
2781
3071
  }),
2782
3072
  disabled: !canGoPrev,
2783
3073
  className: "h-6 w-6 p-0",
2784
- children: /* @__PURE__ */ jsx14(ChevronLeft, { className: "size-[20px]" })
3074
+ children: /* @__PURE__ */ jsx15(ChevronLeft, { className: "size-[20px]" })
2785
3075
  }
2786
3076
  ),
2787
- /* @__PURE__ */ jsxs6("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
3077
+ /* @__PURE__ */ jsxs7("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
2788
3078
  currentBranch + 1,
2789
3079
  "/",
2790
3080
  numberOfBranches
2791
3081
  ] }),
2792
- /* @__PURE__ */ jsx14(
3082
+ /* @__PURE__ */ jsx15(
2793
3083
  Button,
2794
3084
  {
2795
3085
  type: "button",
@@ -2801,7 +3091,7 @@ function CopilotChatUserMessage({
2801
3091
  }),
2802
3092
  disabled: !canGoNext,
2803
3093
  className: "h-6 w-6 p-0",
2804
- children: /* @__PURE__ */ jsx14(ChevronRight, { className: "size-[20px]" })
3094
+ children: /* @__PURE__ */ jsx15(ChevronRight, { className: "size-[20px]" })
2805
3095
  }
2806
3096
  )
2807
3097
  ] });
@@ -2817,14 +3107,14 @@ CopilotChatUserMessage.BranchNavigation.displayName = "CopilotChatUserMessage.Br
2817
3107
  var CopilotChatUserMessage_default = CopilotChatUserMessage;
2818
3108
 
2819
3109
  // src/components/chat/CopilotChatSuggestionPill.tsx
2820
- import React9 from "react";
3110
+ import React10 from "react";
2821
3111
  import { Loader2 } from "lucide-react";
2822
- import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
3112
+ import { jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
2823
3113
  var baseClasses = "group inline-flex h-7 sm:h-8 items-center gap-1 sm:gap-1.5 rounded-full border border-border/60 bg-background px-2.5 sm:px-3 text-[11px] sm:text-xs leading-none text-foreground transition-colors cursor-pointer hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:text-muted-foreground disabled:hover:bg-background disabled:hover:text-muted-foreground pointer-events-auto";
2824
3114
  var labelClasses = "whitespace-nowrap font-medium leading-none";
2825
- var CopilotChatSuggestionPill = React9.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
3115
+ var CopilotChatSuggestionPill = React10.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
2826
3116
  const showIcon = !isLoading && icon;
2827
- return /* @__PURE__ */ jsxs7(
3117
+ return /* @__PURE__ */ jsxs8(
2828
3118
  "button",
2829
3119
  {
2830
3120
  ref,
@@ -2835,8 +3125,8 @@ var CopilotChatSuggestionPill = React9.forwardRef(function CopilotChatSuggestion
2835
3125
  disabled: isLoading || props.disabled,
2836
3126
  ...props,
2837
3127
  children: [
2838
- isLoading ? /* @__PURE__ */ jsx15("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsx15(Loader2, { className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ jsx15("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: icon }),
2839
- /* @__PURE__ */ jsx15("span", { className: labelClasses, children })
3128
+ isLoading ? /* @__PURE__ */ jsx16("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsx16(Loader2, { className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ jsx16("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: icon }),
3129
+ /* @__PURE__ */ jsx16("span", { className: labelClasses, children })
2840
3130
  ]
2841
3131
  }
2842
3132
  );
@@ -2845,10 +3135,10 @@ CopilotChatSuggestionPill.displayName = "CopilotChatSuggestionPill";
2845
3135
  var CopilotChatSuggestionPill_default = CopilotChatSuggestionPill;
2846
3136
 
2847
3137
  // src/components/chat/CopilotChatSuggestionView.tsx
2848
- import React10 from "react";
2849
- import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs8 } from "react/jsx-runtime";
2850
- var DefaultContainer = React10.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
2851
- return /* @__PURE__ */ jsx16(
3138
+ import React11 from "react";
3139
+ import { Fragment as Fragment5, jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
3140
+ var DefaultContainer = React11.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
3141
+ return /* @__PURE__ */ jsx17(
2852
3142
  "div",
2853
3143
  {
2854
3144
  ref,
@@ -2860,7 +3150,7 @@ var DefaultContainer = React10.forwardRef(function DefaultContainer2({ className
2860
3150
  }
2861
3151
  );
2862
3152
  });
2863
- var CopilotChatSuggestionView = React10.forwardRef(function CopilotChatSuggestionView2({
3153
+ var CopilotChatSuggestionView = React11.forwardRef(function CopilotChatSuggestionView2({
2864
3154
  suggestions,
2865
3155
  onSelectSuggestion,
2866
3156
  loadingIndexes,
@@ -2870,7 +3160,7 @@ var CopilotChatSuggestionView = React10.forwardRef(function CopilotChatSuggestio
2870
3160
  children,
2871
3161
  ...restProps
2872
3162
  }, ref) {
2873
- const loadingSet = React10.useMemo(() => {
3163
+ const loadingSet = React11.useMemo(() => {
2874
3164
  if (!loadingIndexes || loadingIndexes.length === 0) {
2875
3165
  return /* @__PURE__ */ new Set();
2876
3166
  }
@@ -2889,11 +3179,11 @@ var CopilotChatSuggestionView = React10.forwardRef(function CopilotChatSuggestio
2889
3179
  type: "button",
2890
3180
  onClick: () => onSelectSuggestion?.(suggestion, index)
2891
3181
  });
2892
- return React10.cloneElement(pill, {
3182
+ return React11.cloneElement(pill, {
2893
3183
  key: `${suggestion.title}-${index}`
2894
3184
  });
2895
3185
  });
2896
- const boundContainer = React10.cloneElement(
3186
+ const boundContainer = React11.cloneElement(
2897
3187
  ContainerElement,
2898
3188
  void 0,
2899
3189
  suggestionElements
@@ -2904,7 +3194,7 @@ var CopilotChatSuggestionView = React10.forwardRef(function CopilotChatSuggestio
2904
3194
  isLoading: suggestions.length > 0 ? loadingSet.has(0) || suggestions[0]?.isLoading === true : false,
2905
3195
  type: "button"
2906
3196
  });
2907
- return /* @__PURE__ */ jsx16(Fragment5, { children: children({
3197
+ return /* @__PURE__ */ jsx17(Fragment5, { children: children({
2908
3198
  container: boundContainer,
2909
3199
  suggestion: sampleSuggestion,
2910
3200
  suggestions,
@@ -2915,7 +3205,7 @@ var CopilotChatSuggestionView = React10.forwardRef(function CopilotChatSuggestio
2915
3205
  }) });
2916
3206
  }
2917
3207
  if (children) {
2918
- return /* @__PURE__ */ jsxs8(Fragment5, { children: [
3208
+ return /* @__PURE__ */ jsxs9(Fragment5, { children: [
2919
3209
  boundContainer,
2920
3210
  children
2921
3211
  ] });
@@ -2926,17 +3216,17 @@ CopilotChatSuggestionView.displayName = "CopilotChatSuggestionView";
2926
3216
  var CopilotChatSuggestionView_default = CopilotChatSuggestionView;
2927
3217
 
2928
3218
  // src/components/chat/CopilotChatMessageView.tsx
2929
- import React11 from "react";
3219
+ import React12, { useEffect as useEffect12, useReducer as useReducer3 } from "react";
2930
3220
  import { twMerge as twMerge6 } from "tailwind-merge";
2931
- import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
2932
- var MemoizedAssistantMessage = React11.memo(
3221
+ import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
3222
+ var MemoizedAssistantMessage = React12.memo(
2933
3223
  function MemoizedAssistantMessage2({
2934
3224
  message,
2935
3225
  messages,
2936
3226
  isRunning,
2937
3227
  AssistantMessageComponent
2938
3228
  }) {
2939
- return /* @__PURE__ */ jsx17(
3229
+ return /* @__PURE__ */ jsx18(
2940
3230
  AssistantMessageComponent,
2941
3231
  {
2942
3232
  message,
@@ -2979,12 +3269,12 @@ var MemoizedAssistantMessage = React11.memo(
2979
3269
  return true;
2980
3270
  }
2981
3271
  );
2982
- var MemoizedUserMessage = React11.memo(
3272
+ var MemoizedUserMessage = React12.memo(
2983
3273
  function MemoizedUserMessage2({
2984
3274
  message,
2985
3275
  UserMessageComponent
2986
3276
  }) {
2987
- return /* @__PURE__ */ jsx17(UserMessageComponent, { message });
3277
+ return /* @__PURE__ */ jsx18(UserMessageComponent, { message });
2988
3278
  },
2989
3279
  (prevProps, nextProps) => {
2990
3280
  if (prevProps.message.id !== nextProps.message.id) return false;
@@ -2993,7 +3283,7 @@ var MemoizedUserMessage = React11.memo(
2993
3283
  return true;
2994
3284
  }
2995
3285
  );
2996
- var MemoizedActivityMessage = React11.memo(
3286
+ var MemoizedActivityMessage = React12.memo(
2997
3287
  function MemoizedActivityMessage2({
2998
3288
  message,
2999
3289
  renderActivityMessage
@@ -3007,7 +3297,7 @@ var MemoizedActivityMessage = React11.memo(
3007
3297
  return true;
3008
3298
  }
3009
3299
  );
3010
- var MemoizedCustomMessage = React11.memo(
3300
+ var MemoizedCustomMessage = React12.memo(
3011
3301
  function MemoizedCustomMessage2({
3012
3302
  message,
3013
3303
  position,
@@ -3020,6 +3310,7 @@ var MemoizedCustomMessage = React11.memo(
3020
3310
  if (prevProps.position !== nextProps.position) return false;
3021
3311
  if (prevProps.message.content !== nextProps.message.content) return false;
3022
3312
  if (prevProps.message.role !== nextProps.message.role) return false;
3313
+ if (JSON.stringify(prevProps.stateSnapshot) !== JSON.stringify(nextProps.stateSnapshot)) return false;
3023
3314
  return true;
3024
3315
  }
3025
3316
  );
@@ -3035,16 +3326,36 @@ function CopilotChatMessageView({
3035
3326
  }) {
3036
3327
  const renderCustomMessage = useRenderCustomMessages();
3037
3328
  const renderActivityMessage = useRenderActivityMessage();
3329
+ const { copilotkit } = useCopilotKit();
3330
+ const config = useCopilotChatConfiguration();
3331
+ const [, forceUpdate] = useReducer3((x) => x + 1, 0);
3332
+ useEffect12(() => {
3333
+ if (!config?.agentId) return;
3334
+ const agent = copilotkit.getAgent(config.agentId);
3335
+ if (!agent) return;
3336
+ const subscription = agent.subscribe({
3337
+ onStateChanged: () => forceUpdate()
3338
+ });
3339
+ return () => subscription.unsubscribe();
3340
+ }, [config?.agentId, copilotkit]);
3341
+ const getStateSnapshotForMessage = (messageId) => {
3342
+ if (!config) return void 0;
3343
+ const runId = copilotkit.getRunIdForMessage(config.agentId, config.threadId, messageId);
3344
+ if (!runId) return void 0;
3345
+ return copilotkit.getStateByRun(config.agentId, config.threadId, runId);
3346
+ };
3038
3347
  const messageElements = messages.flatMap((message) => {
3039
3348
  const elements = [];
3349
+ const stateSnapshot = getStateSnapshotForMessage(message.id);
3040
3350
  if (renderCustomMessage) {
3041
3351
  elements.push(
3042
- /* @__PURE__ */ jsx17(
3352
+ /* @__PURE__ */ jsx18(
3043
3353
  MemoizedCustomMessage,
3044
3354
  {
3045
3355
  message,
3046
3356
  position: "before",
3047
- renderCustomMessage
3357
+ renderCustomMessage,
3358
+ stateSnapshot
3048
3359
  },
3049
3360
  `${message.id}-custom-before`
3050
3361
  )
@@ -3053,7 +3364,7 @@ function CopilotChatMessageView({
3053
3364
  if (message.role === "assistant") {
3054
3365
  const AssistantComponent = typeof assistantMessage === "function" ? assistantMessage : CopilotChatAssistantMessage_default;
3055
3366
  elements.push(
3056
- /* @__PURE__ */ jsx17(
3367
+ /* @__PURE__ */ jsx18(
3057
3368
  MemoizedAssistantMessage,
3058
3369
  {
3059
3370
  message,
@@ -3067,7 +3378,7 @@ function CopilotChatMessageView({
3067
3378
  } else if (message.role === "user") {
3068
3379
  const UserComponent = typeof userMessage === "function" ? userMessage : CopilotChatUserMessage_default;
3069
3380
  elements.push(
3070
- /* @__PURE__ */ jsx17(
3381
+ /* @__PURE__ */ jsx18(
3071
3382
  MemoizedUserMessage,
3072
3383
  {
3073
3384
  message,
@@ -3078,7 +3389,7 @@ function CopilotChatMessageView({
3078
3389
  );
3079
3390
  } else if (message.role === "activity") {
3080
3391
  elements.push(
3081
- /* @__PURE__ */ jsx17(
3392
+ /* @__PURE__ */ jsx18(
3082
3393
  MemoizedActivityMessage,
3083
3394
  {
3084
3395
  message,
@@ -3090,12 +3401,13 @@ function CopilotChatMessageView({
3090
3401
  }
3091
3402
  if (renderCustomMessage) {
3092
3403
  elements.push(
3093
- /* @__PURE__ */ jsx17(
3404
+ /* @__PURE__ */ jsx18(
3094
3405
  MemoizedCustomMessage,
3095
3406
  {
3096
3407
  message,
3097
3408
  position: "after",
3098
- renderCustomMessage
3409
+ renderCustomMessage,
3410
+ stateSnapshot
3099
3411
  },
3100
3412
  `${message.id}-custom-after`
3101
3413
  )
@@ -3106,13 +3418,13 @@ function CopilotChatMessageView({
3106
3418
  if (children) {
3107
3419
  return children({ messageElements, messages, isRunning });
3108
3420
  }
3109
- return /* @__PURE__ */ jsxs9("div", { className: twMerge6("flex flex-col", className), ...props, children: [
3421
+ return /* @__PURE__ */ jsxs10("div", { className: twMerge6("flex flex-col", className), ...props, children: [
3110
3422
  messageElements,
3111
3423
  isRunning && renderSlot(cursor, CopilotChatMessageView.Cursor, {})
3112
3424
  ] });
3113
3425
  }
3114
3426
  CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
3115
- return /* @__PURE__ */ jsx17(
3427
+ return /* @__PURE__ */ jsx18(
3116
3428
  "div",
3117
3429
  {
3118
3430
  className: twMerge6("w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1", className),
@@ -3123,13 +3435,13 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
3123
3435
  var CopilotChatMessageView_default = CopilotChatMessageView;
3124
3436
 
3125
3437
  // src/components/chat/CopilotChatView.tsx
3126
- import React12, { useRef as useRef6, useState as useState10, useEffect as useEffect13 } from "react";
3438
+ import React13, { useRef as useRef7, useState as useState10, useEffect as useEffect14 } from "react";
3127
3439
  import { twMerge as twMerge7 } from "tailwind-merge";
3128
3440
  import { StickToBottom, useStickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
3129
3441
  import { ChevronDown } from "lucide-react";
3130
3442
 
3131
3443
  // src/hooks/use-keyboard-height.tsx
3132
- import { useState as useState9, useEffect as useEffect12 } from "react";
3444
+ import { useState as useState9, useEffect as useEffect13 } from "react";
3133
3445
  function useKeyboardHeight() {
3134
3446
  const [keyboardState, setKeyboardState] = useState9({
3135
3447
  isKeyboardOpen: false,
@@ -3137,7 +3449,7 @@ function useKeyboardHeight() {
3137
3449
  availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
3138
3450
  viewportHeight: typeof window !== "undefined" ? window.innerHeight : 0
3139
3451
  });
3140
- useEffect12(() => {
3452
+ useEffect13(() => {
3141
3453
  if (typeof window === "undefined") {
3142
3454
  return;
3143
3455
  }
@@ -3169,7 +3481,7 @@ function useKeyboardHeight() {
3169
3481
  }
3170
3482
 
3171
3483
  // src/components/chat/CopilotChatView.tsx
3172
- import { Fragment as Fragment6, jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
3484
+ import { Fragment as Fragment6, jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
3173
3485
  function CopilotChatView({
3174
3486
  messageView,
3175
3487
  input,
@@ -3190,12 +3502,12 @@ function CopilotChatView({
3190
3502
  className,
3191
3503
  ...props
3192
3504
  }) {
3193
- const inputContainerRef = useRef6(null);
3505
+ const inputContainerRef = useRef7(null);
3194
3506
  const [inputContainerHeight, setInputContainerHeight] = useState10(0);
3195
3507
  const [isResizing, setIsResizing] = useState10(false);
3196
- const resizeTimeoutRef = useRef6(null);
3508
+ const resizeTimeoutRef = useRef7(null);
3197
3509
  const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
3198
- useEffect13(() => {
3510
+ useEffect14(() => {
3199
3511
  const element = inputContainerRef.current;
3200
3512
  if (!element) return;
3201
3513
  const resizeObserver = new ResizeObserver((entries) => {
@@ -3243,9 +3555,9 @@ function CopilotChatView({
3243
3555
  scrollToBottomButton,
3244
3556
  inputContainerHeight,
3245
3557
  isResizing,
3246
- children: /* @__PURE__ */ jsx18("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ jsxs10("div", { className: "max-w-3xl mx-auto", children: [
3558
+ children: /* @__PURE__ */ jsx19("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ jsxs11("div", { className: "max-w-3xl mx-auto", children: [
3247
3559
  BoundMessageView,
3248
- hasSuggestions ? /* @__PURE__ */ jsx18("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
3560
+ hasSuggestions ? /* @__PURE__ */ jsx19("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
3249
3561
  ] }) })
3250
3562
  });
3251
3563
  const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});
@@ -3253,8 +3565,8 @@ function CopilotChatView({
3253
3565
  const BoundInputContainer = renderSlot(inputContainer, CopilotChatView.InputContainer, {
3254
3566
  ref: inputContainerRef,
3255
3567
  keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
3256
- children: /* @__PURE__ */ jsxs10(Fragment6, { children: [
3257
- /* @__PURE__ */ jsx18("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6 pointer-events-auto", children: BoundInput }),
3568
+ children: /* @__PURE__ */ jsxs11(Fragment6, { children: [
3569
+ /* @__PURE__ */ jsx19("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6 pointer-events-auto", children: BoundInput }),
3258
3570
  BoundDisclaimer
3259
3571
  ] })
3260
3572
  });
@@ -3267,10 +3579,10 @@ function CopilotChatView({
3267
3579
  feather: BoundFeather,
3268
3580
  inputContainer: BoundInputContainer,
3269
3581
  disclaimer: BoundDisclaimer,
3270
- suggestionView: BoundSuggestionView ?? /* @__PURE__ */ jsx18(Fragment6, {})
3582
+ suggestionView: BoundSuggestionView ?? /* @__PURE__ */ jsx19(Fragment6, {})
3271
3583
  });
3272
3584
  }
3273
- return /* @__PURE__ */ jsxs10("div", { className: twMerge7("relative h-full", className), ...props, children: [
3585
+ return /* @__PURE__ */ jsxs11("div", { className: twMerge7("relative h-full", className), ...props, children: [
3274
3586
  BoundScrollView,
3275
3587
  BoundFeather,
3276
3588
  BoundInputContainer
@@ -3279,9 +3591,9 @@ function CopilotChatView({
3279
3591
  ((CopilotChatView2) => {
3280
3592
  const ScrollContent = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {
3281
3593
  const { isAtBottom, scrollToBottom } = useStickToBottomContext();
3282
- return /* @__PURE__ */ jsxs10(Fragment6, { children: [
3283
- /* @__PURE__ */ jsx18(StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx18("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
3284
- !isAtBottom && !isResizing && /* @__PURE__ */ jsx18(
3594
+ return /* @__PURE__ */ jsxs11(Fragment6, { children: [
3595
+ /* @__PURE__ */ jsx19(StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx19("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
3596
+ !isAtBottom && !isResizing && /* @__PURE__ */ jsx19(
3285
3597
  "div",
3286
3598
  {
3287
3599
  className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
@@ -3307,10 +3619,10 @@ function CopilotChatView({
3307
3619
  const [hasMounted, setHasMounted] = useState10(false);
3308
3620
  const { scrollRef, contentRef, scrollToBottom } = useStickToBottom();
3309
3621
  const [showScrollButton, setShowScrollButton] = useState10(false);
3310
- useEffect13(() => {
3622
+ useEffect14(() => {
3311
3623
  setHasMounted(true);
3312
3624
  }, []);
3313
- useEffect13(() => {
3625
+ useEffect14(() => {
3314
3626
  if (autoScroll) return;
3315
3627
  const scrollElement = scrollRef.current;
3316
3628
  if (!scrollElement) return;
@@ -3328,10 +3640,10 @@ function CopilotChatView({
3328
3640
  };
3329
3641
  }, [scrollRef, autoScroll]);
3330
3642
  if (!hasMounted) {
3331
- return /* @__PURE__ */ jsx18("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx18("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
3643
+ return /* @__PURE__ */ jsx19("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx19("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
3332
3644
  }
3333
3645
  if (!autoScroll) {
3334
- return /* @__PURE__ */ jsxs10(
3646
+ return /* @__PURE__ */ jsxs11(
3335
3647
  "div",
3336
3648
  {
3337
3649
  ref: scrollRef,
@@ -3341,8 +3653,8 @@ function CopilotChatView({
3341
3653
  ),
3342
3654
  ...props,
3343
3655
  children: [
3344
- /* @__PURE__ */ jsx18("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
3345
- showScrollButton && !isResizing && /* @__PURE__ */ jsx18(
3656
+ /* @__PURE__ */ jsx19("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
3657
+ showScrollButton && !isResizing && /* @__PURE__ */ jsx19(
3346
3658
  "div",
3347
3659
  {
3348
3660
  className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
@@ -3358,14 +3670,14 @@ function CopilotChatView({
3358
3670
  }
3359
3671
  );
3360
3672
  }
3361
- return /* @__PURE__ */ jsx18(
3673
+ return /* @__PURE__ */ jsx19(
3362
3674
  StickToBottom,
3363
3675
  {
3364
3676
  className: cn("h-full max-h-full flex flex-col min-h-0 relative", className),
3365
3677
  resize: "smooth",
3366
3678
  initial: "smooth",
3367
3679
  ...props,
3368
- children: /* @__PURE__ */ jsx18(
3680
+ children: /* @__PURE__ */ jsx19(
3369
3681
  ScrollContent,
3370
3682
  {
3371
3683
  scrollToBottomButton,
@@ -3380,7 +3692,7 @@ function CopilotChatView({
3380
3692
  CopilotChatView2.ScrollToBottomButton = ({
3381
3693
  className,
3382
3694
  ...props
3383
- }) => /* @__PURE__ */ jsx18(
3695
+ }) => /* @__PURE__ */ jsx19(
3384
3696
  Button,
3385
3697
  {
3386
3698
  variant: "outline",
@@ -3394,10 +3706,10 @@ function CopilotChatView({
3394
3706
  className
3395
3707
  ),
3396
3708
  ...props,
3397
- children: /* @__PURE__ */ jsx18(ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
3709
+ children: /* @__PURE__ */ jsx19(ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
3398
3710
  }
3399
3711
  );
3400
- CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ jsx18(
3712
+ CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ jsx19(
3401
3713
  "div",
3402
3714
  {
3403
3715
  className: cn(
@@ -3410,7 +3722,7 @@ function CopilotChatView({
3410
3722
  ...props
3411
3723
  }
3412
3724
  );
3413
- CopilotChatView2.InputContainer = React12.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ jsx18(
3725
+ CopilotChatView2.InputContainer = React13.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ jsx19(
3414
3726
  "div",
3415
3727
  {
3416
3728
  ref,
@@ -3428,7 +3740,7 @@ function CopilotChatView({
3428
3740
  CopilotChatView2.Disclaimer = ({ className, ...props }) => {
3429
3741
  const config = useCopilotChatConfiguration();
3430
3742
  const labels = config?.labels ?? CopilotChatDefaultLabels;
3431
- return /* @__PURE__ */ jsx18(
3743
+ return /* @__PURE__ */ jsx19(
3432
3744
  "div",
3433
3745
  {
3434
3746
  className: cn("text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto", className),
@@ -3442,10 +3754,10 @@ var CopilotChatView_default = CopilotChatView;
3442
3754
 
3443
3755
  // src/components/chat/CopilotChat.tsx
3444
3756
  import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID7, randomUUID as randomUUID2 } from "@copilotkitnext/shared";
3445
- import { useCallback as useCallback7, useEffect as useEffect14, useMemo as useMemo10 } from "react";
3757
+ import { useCallback as useCallback8, useEffect as useEffect15, useMemo as useMemo10 } from "react";
3446
3758
  import { merge } from "ts-deepmerge";
3447
3759
  import { AGUIConnectNotImplementedError } from "@ag-ui/client";
3448
- import { jsx as jsx19 } from "react/jsx-runtime";
3760
+ import { jsx as jsx20 } from "react/jsx-runtime";
3449
3761
  function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, ...props }) {
3450
3762
  const existingConfig = useCopilotChatConfiguration();
3451
3763
  const resolvedAgentId = agentId ?? existingConfig?.agentId ?? DEFAULT_AGENT_ID7;
@@ -3462,7 +3774,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3462
3774
  suggestionView: providedSuggestionView,
3463
3775
  ...restProps
3464
3776
  } = props;
3465
- useEffect14(() => {
3777
+ useEffect15(() => {
3466
3778
  const connect = async (agent2) => {
3467
3779
  try {
3468
3780
  await copilotkit.connectAgent({ agent: agent2 });
@@ -3478,7 +3790,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3478
3790
  return () => {
3479
3791
  };
3480
3792
  }, [resolvedThreadId, agent, copilotkit, resolvedAgentId]);
3481
- const onSubmitInput = useCallback7(
3793
+ const onSubmitInput = useCallback8(
3482
3794
  async (value) => {
3483
3795
  agent.addMessage({
3484
3796
  id: randomUUID2(),
@@ -3493,7 +3805,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3493
3805
  },
3494
3806
  [agent, copilotkit]
3495
3807
  );
3496
- const handleSelectSuggestion = useCallback7(
3808
+ const handleSelectSuggestion = useCallback8(
3497
3809
  async (suggestion) => {
3498
3810
  agent.addMessage({
3499
3811
  id: randomUUID2(),
@@ -3508,7 +3820,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3508
3820
  },
3509
3821
  [agent, copilotkit]
3510
3822
  );
3511
- const stopCurrentRun = useCallback7(() => {
3823
+ const stopCurrentRun = useCallback8(() => {
3512
3824
  try {
3513
3825
  copilotkit.stopAgent({ agent });
3514
3826
  } catch (error) {
@@ -3548,7 +3860,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3548
3860
  inputProps: finalInputProps
3549
3861
  });
3550
3862
  const RenderedChatView = renderSlot(chatView, CopilotChatView, finalProps);
3551
- return /* @__PURE__ */ jsx19(
3863
+ return /* @__PURE__ */ jsx20(
3552
3864
  CopilotChatConfigurationProvider,
3553
3865
  {
3554
3866
  agentId: resolvedAgentId,
@@ -3564,17 +3876,17 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3564
3876
  })(CopilotChat || (CopilotChat = {}));
3565
3877
 
3566
3878
  // src/components/chat/CopilotChatToggleButton.tsx
3567
- import React13, { useState as useState11 } from "react";
3879
+ import React14, { useState as useState11 } from "react";
3568
3880
  import { MessageCircle, X as X2 } from "lucide-react";
3569
- import { jsx as jsx20, jsxs as jsxs11 } from "react/jsx-runtime";
3881
+ import { jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
3570
3882
  var DefaultOpenIcon = ({
3571
3883
  className,
3572
3884
  ...props
3573
- }) => /* @__PURE__ */ jsx20(MessageCircle, { className: cn("h-6 w-6", className), strokeWidth: 1.75, fill: "currentColor", ...props });
3885
+ }) => /* @__PURE__ */ jsx21(MessageCircle, { className: cn("h-6 w-6", className), strokeWidth: 1.75, fill: "currentColor", ...props });
3574
3886
  var DefaultCloseIcon = ({
3575
3887
  className,
3576
3888
  ...props
3577
- }) => /* @__PURE__ */ jsx20(X2, { className: cn("h-6 w-6", className), strokeWidth: 1.75, ...props });
3889
+ }) => /* @__PURE__ */ jsx21(X2, { className: cn("h-6 w-6", className), strokeWidth: 1.75, ...props });
3578
3890
  DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
3579
3891
  DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
3580
3892
  var ICON_TRANSITION_STYLE = Object.freeze({
@@ -3591,7 +3903,7 @@ var BUTTON_BASE_CLASSES = cn(
3591
3903
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background",
3592
3904
  "disabled:pointer-events-none disabled:opacity-60"
3593
3905
  );
3594
- var CopilotChatToggleButton = React13.forwardRef(function CopilotChatToggleButton2({ openIcon, closeIcon, className, ...buttonProps }, ref) {
3906
+ var CopilotChatToggleButton = React14.forwardRef(function CopilotChatToggleButton2({ openIcon, closeIcon, className, ...buttonProps }, ref) {
3595
3907
  const { onClick, type, disabled, ...restProps } = buttonProps;
3596
3908
  const configuration = useCopilotChatConfiguration();
3597
3909
  const labels = configuration?.labels ?? CopilotChatDefaultLabels;
@@ -3629,7 +3941,7 @@ var CopilotChatToggleButton = React13.forwardRef(function CopilotChatToggleButto
3629
3941
  focusable: false
3630
3942
  }
3631
3943
  );
3632
- const openIconElement = /* @__PURE__ */ jsx20(
3944
+ const openIconElement = /* @__PURE__ */ jsx21(
3633
3945
  "span",
3634
3946
  {
3635
3947
  "aria-hidden": "true",
@@ -3643,7 +3955,7 @@ var CopilotChatToggleButton = React13.forwardRef(function CopilotChatToggleButto
3643
3955
  children: renderedOpenIcon
3644
3956
  }
3645
3957
  );
3646
- const closeIconElement = /* @__PURE__ */ jsx20(
3958
+ const closeIconElement = /* @__PURE__ */ jsx21(
3647
3959
  "span",
3648
3960
  {
3649
3961
  "aria-hidden": "true",
@@ -3657,7 +3969,7 @@ var CopilotChatToggleButton = React13.forwardRef(function CopilotChatToggleButto
3657
3969
  children: renderedCloseIcon
3658
3970
  }
3659
3971
  );
3660
- return /* @__PURE__ */ jsxs11(
3972
+ return /* @__PURE__ */ jsxs12(
3661
3973
  "button",
3662
3974
  {
3663
3975
  ref,
@@ -3681,12 +3993,12 @@ CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
3681
3993
  var CopilotChatToggleButton_default = CopilotChatToggleButton;
3682
3994
 
3683
3995
  // src/components/chat/CopilotSidebarView.tsx
3684
- import { useEffect as useEffect15, useRef as useRef7, useState as useState12 } from "react";
3996
+ import { useEffect as useEffect16, useRef as useRef8, useState as useState12 } from "react";
3685
3997
 
3686
3998
  // src/components/chat/CopilotModalHeader.tsx
3687
- import { useCallback as useCallback8 } from "react";
3999
+ import { useCallback as useCallback9 } from "react";
3688
4000
  import { X as X3 } from "lucide-react";
3689
- import { jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
4001
+ import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
3690
4002
  function CopilotModalHeader({
3691
4003
  title,
3692
4004
  titleContent,
@@ -3698,7 +4010,7 @@ function CopilotModalHeader({
3698
4010
  const configuration = useCopilotChatConfiguration();
3699
4011
  const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
3700
4012
  const resolvedTitle = title ?? fallbackTitle;
3701
- const handleClose = useCallback8(() => {
4013
+ const handleClose = useCallback9(() => {
3702
4014
  configuration?.setModalOpen(false);
3703
4015
  }, [configuration]);
3704
4016
  const BoundTitle = renderSlot(titleContent, CopilotModalHeader.Title, {
@@ -3715,7 +4027,7 @@ function CopilotModalHeader({
3715
4027
  ...rest
3716
4028
  });
3717
4029
  }
3718
- return /* @__PURE__ */ jsx21(
4030
+ return /* @__PURE__ */ jsx22(
3719
4031
  "header",
3720
4032
  {
3721
4033
  "data-slot": "copilot-modal-header",
@@ -3725,17 +4037,17 @@ function CopilotModalHeader({
3725
4037
  className
3726
4038
  ),
3727
4039
  ...rest,
3728
- children: /* @__PURE__ */ jsxs12("div", { className: "flex w-full items-center gap-2", children: [
3729
- /* @__PURE__ */ jsx21("div", { className: "flex-1", "aria-hidden": "true" }),
3730
- /* @__PURE__ */ jsx21("div", { className: "flex flex-1 justify-center text-center", children: BoundTitle }),
3731
- /* @__PURE__ */ jsx21("div", { className: "flex flex-1 justify-end", children: BoundCloseButton })
4040
+ children: /* @__PURE__ */ jsxs13("div", { className: "flex w-full items-center gap-2", children: [
4041
+ /* @__PURE__ */ jsx22("div", { className: "flex-1", "aria-hidden": "true" }),
4042
+ /* @__PURE__ */ jsx22("div", { className: "flex flex-1 justify-center text-center", children: BoundTitle }),
4043
+ /* @__PURE__ */ jsx22("div", { className: "flex flex-1 justify-end", children: BoundCloseButton })
3732
4044
  ] })
3733
4045
  }
3734
4046
  );
3735
4047
  }
3736
4048
  CopilotModalHeader.displayName = "CopilotModalHeader";
3737
4049
  ((CopilotModalHeader2) => {
3738
- CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ jsx21(
4050
+ CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ jsx22(
3739
4051
  "div",
3740
4052
  {
3741
4053
  className: cn(
@@ -3749,7 +4061,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
3749
4061
  CopilotModalHeader2.CloseButton = ({
3750
4062
  className,
3751
4063
  ...props
3752
- }) => /* @__PURE__ */ jsx21(
4064
+ }) => /* @__PURE__ */ jsx22(
3753
4065
  "button",
3754
4066
  {
3755
4067
  type: "button",
@@ -3760,7 +4072,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
3760
4072
  ),
3761
4073
  "aria-label": "Close",
3762
4074
  ...props,
3763
- children: /* @__PURE__ */ jsx21(X3, { className: "h-4 w-4", "aria-hidden": "true" })
4075
+ children: /* @__PURE__ */ jsx22(X3, { className: "h-4 w-4", "aria-hidden": "true" })
3764
4076
  }
3765
4077
  );
3766
4078
  })(CopilotModalHeader || (CopilotModalHeader = {}));
@@ -3768,13 +4080,13 @@ CopilotModalHeader.Title.displayName = "CopilotModalHeader.Title";
3768
4080
  CopilotModalHeader.CloseButton.displayName = "CopilotModalHeader.CloseButton";
3769
4081
 
3770
4082
  // src/components/chat/CopilotSidebarView.tsx
3771
- import { Fragment as Fragment7, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
4083
+ import { Fragment as Fragment7, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
3772
4084
  var DEFAULT_SIDEBAR_WIDTH = 480;
3773
4085
  var SIDEBAR_TRANSITION_MS = 260;
3774
4086
  function CopilotSidebarView({ header, width, ...props }) {
3775
4087
  const configuration = useCopilotChatConfiguration();
3776
4088
  const isSidebarOpen = configuration?.isModalOpen ?? false;
3777
- const sidebarRef = useRef7(null);
4089
+ const sidebarRef = useRef8(null);
3778
4090
  const [sidebarWidth, setSidebarWidth] = useState12(width ?? DEFAULT_SIDEBAR_WIDTH);
3779
4091
  const widthToCss = (w) => {
3780
4092
  return typeof w === "number" ? `${w}px` : w;
@@ -3785,7 +4097,7 @@ function CopilotSidebarView({ header, width, ...props }) {
3785
4097
  }
3786
4098
  return w;
3787
4099
  };
3788
- useEffect15(() => {
4100
+ useEffect16(() => {
3789
4101
  if (width !== void 0) {
3790
4102
  return;
3791
4103
  }
@@ -3812,8 +4124,8 @@ function CopilotSidebarView({ header, width, ...props }) {
3812
4124
  return () => window.removeEventListener("resize", updateWidth);
3813
4125
  }, [width]);
3814
4126
  const headerElement = renderSlot(header, CopilotModalHeader, {});
3815
- return /* @__PURE__ */ jsxs13(Fragment7, { children: [
3816
- isSidebarOpen && /* @__PURE__ */ jsx22(
4127
+ return /* @__PURE__ */ jsxs14(Fragment7, { children: [
4128
+ isSidebarOpen && /* @__PURE__ */ jsx23(
3817
4129
  "style",
3818
4130
  {
3819
4131
  dangerouslySetInnerHTML: {
@@ -3827,8 +4139,8 @@ function CopilotSidebarView({ header, width, ...props }) {
3827
4139
  }
3828
4140
  }
3829
4141
  ),
3830
- /* @__PURE__ */ jsx22(CopilotChatToggleButton_default, {}),
3831
- /* @__PURE__ */ jsx22(
4142
+ /* @__PURE__ */ jsx23(CopilotChatToggleButton_default, {}),
4143
+ /* @__PURE__ */ jsx23(
3832
4144
  "aside",
3833
4145
  {
3834
4146
  ref: sidebarRef,
@@ -3853,9 +4165,9 @@ function CopilotSidebarView({ header, width, ...props }) {
3853
4165
  "aria-hidden": !isSidebarOpen,
3854
4166
  "aria-label": "Copilot chat sidebar",
3855
4167
  role: "complementary",
3856
- children: /* @__PURE__ */ jsxs13("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
4168
+ children: /* @__PURE__ */ jsxs14("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
3857
4169
  headerElement,
3858
- /* @__PURE__ */ jsx22("div", { className: "flex-1 overflow-hidden", "data-sidebar-chat": true, children: /* @__PURE__ */ jsx22(CopilotChatView_default, { ...props }) })
4170
+ /* @__PURE__ */ jsx23("div", { className: "flex-1 overflow-hidden", "data-sidebar-chat": true, children: /* @__PURE__ */ jsx23(CopilotChatView_default, { ...props }) })
3859
4171
  ] })
3860
4172
  }
3861
4173
  )
@@ -3864,8 +4176,8 @@ function CopilotSidebarView({ header, width, ...props }) {
3864
4176
  CopilotSidebarView.displayName = "CopilotSidebarView";
3865
4177
 
3866
4178
  // src/components/chat/CopilotPopupView.tsx
3867
- import { useEffect as useEffect16, useMemo as useMemo11, useRef as useRef8, useState as useState13 } from "react";
3868
- import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
4179
+ import { useEffect as useEffect17, useMemo as useMemo11, useRef as useRef9, useState as useState13 } from "react";
4180
+ import { Fragment as Fragment8, jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
3869
4181
  var DEFAULT_POPUP_WIDTH = 420;
3870
4182
  var DEFAULT_POPUP_HEIGHT = 560;
3871
4183
  var dimensionToCss = (value, fallback) => {
@@ -3889,10 +4201,10 @@ function CopilotPopupView({
3889
4201
  const isPopupOpen = configuration?.isModalOpen ?? false;
3890
4202
  const setModalOpen = configuration?.setModalOpen;
3891
4203
  const labels = configuration?.labels ?? CopilotChatDefaultLabels;
3892
- const containerRef = useRef8(null);
4204
+ const containerRef = useRef9(null);
3893
4205
  const [isRendered, setIsRendered] = useState13(isPopupOpen);
3894
4206
  const [isAnimatingOut, setIsAnimatingOut] = useState13(false);
3895
- useEffect16(() => {
4207
+ useEffect17(() => {
3896
4208
  if (isPopupOpen) {
3897
4209
  setIsRendered(true);
3898
4210
  setIsAnimatingOut(false);
@@ -3908,7 +4220,7 @@ function CopilotPopupView({
3908
4220
  }, 200);
3909
4221
  return () => clearTimeout(timeout);
3910
4222
  }, [isPopupOpen, isRendered]);
3911
- useEffect16(() => {
4223
+ useEffect17(() => {
3912
4224
  if (!isPopupOpen) {
3913
4225
  return;
3914
4226
  }
@@ -3924,7 +4236,7 @@ function CopilotPopupView({
3924
4236
  window.addEventListener("keydown", handleKeyDown);
3925
4237
  return () => window.removeEventListener("keydown", handleKeyDown);
3926
4238
  }, [isPopupOpen, setModalOpen]);
3927
- useEffect16(() => {
4239
+ useEffect17(() => {
3928
4240
  if (!isPopupOpen) {
3929
4241
  return;
3930
4242
  }
@@ -3933,7 +4245,7 @@ function CopilotPopupView({
3933
4245
  }, 200);
3934
4246
  return () => clearTimeout(focusTimer);
3935
4247
  }, [isPopupOpen]);
3936
- useEffect16(() => {
4248
+ useEffect17(() => {
3937
4249
  if (!isPopupOpen || !clickOutsideToClose) {
3938
4250
  return;
3939
4251
  }
@@ -3975,14 +4287,14 @@ function CopilotPopupView({
3975
4287
  [resolvedHeight, resolvedWidth]
3976
4288
  );
3977
4289
  const popupAnimationClass = isPopupOpen && !isAnimatingOut ? "pointer-events-auto translate-y-0 opacity-100 md:scale-100" : "pointer-events-none translate-y-4 opacity-0 md:translate-y-5 md:scale-[0.95]";
3978
- const popupContent = isRendered ? /* @__PURE__ */ jsx23(
4290
+ const popupContent = isRendered ? /* @__PURE__ */ jsx24(
3979
4291
  "div",
3980
4292
  {
3981
4293
  className: cn(
3982
4294
  "fixed inset-0 z-[1200] flex max-w-full flex-col items-stretch",
3983
4295
  "md:inset-auto md:bottom-24 md:right-6 md:items-end md:gap-4"
3984
4296
  ),
3985
- children: /* @__PURE__ */ jsxs14(
4297
+ children: /* @__PURE__ */ jsxs15(
3986
4298
  "div",
3987
4299
  {
3988
4300
  ref: containerRef,
@@ -4003,7 +4315,7 @@ function CopilotPopupView({
4003
4315
  style: popupStyle,
4004
4316
  children: [
4005
4317
  headerElement,
4006
- /* @__PURE__ */ jsx23("div", { className: "flex-1 overflow-hidden", "data-popup-chat": true, children: /* @__PURE__ */ jsx23(
4318
+ /* @__PURE__ */ jsx24("div", { className: "flex-1 overflow-hidden", "data-popup-chat": true, children: /* @__PURE__ */ jsx24(
4007
4319
  CopilotChatView_default,
4008
4320
  {
4009
4321
  ...restProps,
@@ -4015,8 +4327,8 @@ function CopilotPopupView({
4015
4327
  )
4016
4328
  }
4017
4329
  ) : null;
4018
- return /* @__PURE__ */ jsxs14(Fragment8, { children: [
4019
- /* @__PURE__ */ jsx23(CopilotChatToggleButton_default, {}),
4330
+ return /* @__PURE__ */ jsxs15(Fragment8, { children: [
4331
+ /* @__PURE__ */ jsx24(CopilotChatToggleButton_default, {}),
4020
4332
  popupContent
4021
4333
  ] });
4022
4334
  }
@@ -4024,12 +4336,12 @@ CopilotPopupView.displayName = "CopilotPopupView";
4024
4336
 
4025
4337
  // src/components/chat/CopilotSidebar.tsx
4026
4338
  import { useMemo as useMemo12 } from "react";
4027
- import { jsx as jsx24 } from "react/jsx-runtime";
4339
+ import { jsx as jsx25 } from "react/jsx-runtime";
4028
4340
  function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
4029
4341
  const SidebarViewOverride = useMemo12(() => {
4030
4342
  const Component = (viewProps) => {
4031
4343
  const { header: viewHeader, width: viewWidth, ...restProps } = viewProps;
4032
- return /* @__PURE__ */ jsx24(
4344
+ return /* @__PURE__ */ jsx25(
4033
4345
  CopilotSidebarView,
4034
4346
  {
4035
4347
  ...restProps,
@@ -4040,7 +4352,7 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
4040
4352
  };
4041
4353
  return Object.assign(Component, CopilotChatView_default);
4042
4354
  }, [header, width]);
4043
- return /* @__PURE__ */ jsx24(
4355
+ return /* @__PURE__ */ jsx25(
4044
4356
  CopilotChat,
4045
4357
  {
4046
4358
  ...chatProps,
@@ -4053,7 +4365,7 @@ CopilotSidebar.displayName = "CopilotSidebar";
4053
4365
 
4054
4366
  // src/components/chat/CopilotPopup.tsx
4055
4367
  import { useMemo as useMemo13 } from "react";
4056
- import { jsx as jsx25 } from "react/jsx-runtime";
4368
+ import { jsx as jsx26 } from "react/jsx-runtime";
4057
4369
  function CopilotPopup({
4058
4370
  header,
4059
4371
  defaultOpen,
@@ -4071,7 +4383,7 @@ function CopilotPopup({
4071
4383
  clickOutsideToClose: viewClickOutsideToClose,
4072
4384
  ...restProps
4073
4385
  } = viewProps;
4074
- return /* @__PURE__ */ jsx25(
4386
+ return /* @__PURE__ */ jsx26(
4075
4387
  CopilotPopupView,
4076
4388
  {
4077
4389
  ...restProps,
@@ -4084,7 +4396,7 @@ function CopilotPopup({
4084
4396
  };
4085
4397
  return Object.assign(Component, CopilotChatView_default);
4086
4398
  }, [clickOutsideToClose, header, height, width]);
4087
- return /* @__PURE__ */ jsx25(
4399
+ return /* @__PURE__ */ jsx26(
4088
4400
  CopilotChat,
4089
4401
  {
4090
4402
  ...chatProps,
@@ -4096,9 +4408,9 @@ function CopilotPopup({
4096
4408
  CopilotPopup.displayName = "CopilotPopup";
4097
4409
 
4098
4410
  // src/types/defineToolCallRenderer.ts
4099
- import { z as z2 } from "zod";
4411
+ import { z as z3 } from "zod";
4100
4412
  function defineToolCallRenderer(def) {
4101
- const argsSchema = def.name === "*" && !def.args ? z2.any() : def.args;
4413
+ const argsSchema = def.name === "*" && !def.args ? z3.any() : def.args;
4102
4414
  return {
4103
4415
  name: def.name,
4104
4416
  args: argsSchema,
@@ -4109,7 +4421,7 @@ function defineToolCallRenderer(def) {
4109
4421
 
4110
4422
  // src/components/WildcardToolCallRender.tsx
4111
4423
  import { useState as useState14 } from "react";
4112
- import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
4424
+ import { jsx as jsx27, jsxs as jsxs16 } from "react/jsx-runtime";
4113
4425
  var WildcardToolCallRender = defineToolCallRenderer({
4114
4426
  name: "*",
4115
4427
  render: ({ args, result, name, status }) => {
@@ -4118,15 +4430,15 @@ var WildcardToolCallRender = defineToolCallRenderer({
4118
4430
  const isActive = statusString === "inProgress" || statusString === "executing";
4119
4431
  const isComplete = statusString === "complete";
4120
4432
  const statusStyles = isActive ? "bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-400" : isComplete ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-400" : "bg-zinc-100 text-zinc-800 dark:bg-zinc-700/40 dark:text-zinc-300";
4121
- return /* @__PURE__ */ jsx26("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ jsxs15("div", { className: "rounded-xl border border-zinc-200/60 dark:border-zinc-800/60 bg-white/70 dark:bg-zinc-900/50 shadow-sm backdrop-blur p-4", children: [
4122
- /* @__PURE__ */ jsxs15(
4433
+ return /* @__PURE__ */ jsx27("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ jsxs16("div", { className: "rounded-xl border border-zinc-200/60 dark:border-zinc-800/60 bg-white/70 dark:bg-zinc-900/50 shadow-sm backdrop-blur p-4", children: [
4434
+ /* @__PURE__ */ jsxs16(
4123
4435
  "div",
4124
4436
  {
4125
4437
  className: "flex items-center justify-between gap-3 cursor-pointer",
4126
4438
  onClick: () => setIsExpanded(!isExpanded),
4127
4439
  children: [
4128
- /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2 min-w-0", children: [
4129
- /* @__PURE__ */ jsx26(
4440
+ /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-2 min-w-0", children: [
4441
+ /* @__PURE__ */ jsx27(
4130
4442
  "svg",
4131
4443
  {
4132
4444
  className: `h-4 w-4 text-zinc-500 dark:text-zinc-400 transition-transform ${isExpanded ? "rotate-90" : ""}`,
@@ -4134,7 +4446,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
4134
4446
  viewBox: "0 0 24 24",
4135
4447
  strokeWidth: 2,
4136
4448
  stroke: "currentColor",
4137
- children: /* @__PURE__ */ jsx26(
4449
+ children: /* @__PURE__ */ jsx27(
4138
4450
  "path",
4139
4451
  {
4140
4452
  strokeLinecap: "round",
@@ -4144,10 +4456,10 @@ var WildcardToolCallRender = defineToolCallRenderer({
4144
4456
  )
4145
4457
  }
4146
4458
  ),
4147
- /* @__PURE__ */ jsx26("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
4148
- /* @__PURE__ */ jsx26("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
4459
+ /* @__PURE__ */ jsx27("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
4460
+ /* @__PURE__ */ jsx27("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
4149
4461
  ] }),
4150
- /* @__PURE__ */ jsx26(
4462
+ /* @__PURE__ */ jsx27(
4151
4463
  "span",
4152
4464
  {
4153
4465
  className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${statusStyles}`,
@@ -4157,14 +4469,14 @@ var WildcardToolCallRender = defineToolCallRenderer({
4157
4469
  ]
4158
4470
  }
4159
4471
  ),
4160
- isExpanded && /* @__PURE__ */ jsxs15("div", { className: "mt-3 grid gap-4", children: [
4161
- /* @__PURE__ */ jsxs15("div", { children: [
4162
- /* @__PURE__ */ jsx26("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
4163
- /* @__PURE__ */ jsx26("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: JSON.stringify(args ?? {}, null, 2) })
4472
+ isExpanded && /* @__PURE__ */ jsxs16("div", { className: "mt-3 grid gap-4", children: [
4473
+ /* @__PURE__ */ jsxs16("div", { children: [
4474
+ /* @__PURE__ */ jsx27("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
4475
+ /* @__PURE__ */ jsx27("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: JSON.stringify(args ?? {}, null, 2) })
4164
4476
  ] }),
4165
- result !== void 0 && /* @__PURE__ */ jsxs15("div", { children: [
4166
- /* @__PURE__ */ jsx26("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
4167
- /* @__PURE__ */ jsx26("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: typeof result === "string" ? result : JSON.stringify(result, null, 2) })
4477
+ result !== void 0 && /* @__PURE__ */ jsxs16("div", { children: [
4478
+ /* @__PURE__ */ jsx27("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
4479
+ /* @__PURE__ */ jsx27("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: typeof result === "string" ? result : JSON.stringify(result, null, 2) })
4168
4480
  ] })
4169
4481
  ] })
4170
4482
  ] }) });
@@ -4194,6 +4506,10 @@ export {
4194
4506
  CopilotPopupView,
4195
4507
  CopilotSidebar,
4196
4508
  CopilotSidebarView,
4509
+ MCPAppsActivityContentSchema,
4510
+ MCPAppsActivityRenderer,
4511
+ MCPAppsActivityType,
4512
+ UseAgentUpdate,
4197
4513
  WildcardToolCallRender,
4198
4514
  defineToolCallRenderer,
4199
4515
  useAgent,