@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.d.mts +89 -1
- package/dist/index.d.ts +89 -1
- package/dist/index.js +627 -307
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +565 -249
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -55,6 +55,10 @@ __export(index_exports, {
|
|
|
55
55
|
CopilotPopupView: () => CopilotPopupView,
|
|
56
56
|
CopilotSidebar: () => CopilotSidebar,
|
|
57
57
|
CopilotSidebarView: () => CopilotSidebarView,
|
|
58
|
+
MCPAppsActivityContentSchema: () => MCPAppsActivityContentSchema,
|
|
59
|
+
MCPAppsActivityRenderer: () => MCPAppsActivityRenderer,
|
|
60
|
+
MCPAppsActivityType: () => MCPAppsActivityType,
|
|
61
|
+
UseAgentUpdate: () => UseAgentUpdate,
|
|
58
62
|
WildcardToolCallRender: () => WildcardToolCallRender,
|
|
59
63
|
defineToolCallRenderer: () => defineToolCallRenderer,
|
|
60
64
|
useAgent: () => useAgent,
|
|
@@ -1424,19 +1428,19 @@ CopilotChatInput.AddMenuButton.displayName = "CopilotChatInput.AddMenuButton";
|
|
|
1424
1428
|
var CopilotChatInput_default = CopilotChatInput;
|
|
1425
1429
|
|
|
1426
1430
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
1427
|
-
var
|
|
1431
|
+
var import_react18 = require("react");
|
|
1428
1432
|
var import_lucide_react3 = require("lucide-react");
|
|
1429
1433
|
var import_tailwind_merge4 = require("tailwind-merge");
|
|
1430
1434
|
var import_katex_min = require("katex/dist/katex.min.css");
|
|
1431
1435
|
var import_streamdown = require("streamdown");
|
|
1432
1436
|
|
|
1433
1437
|
// src/hooks/use-render-tool-call.tsx
|
|
1434
|
-
var
|
|
1438
|
+
var import_react8 = __toESM(require("react"));
|
|
1435
1439
|
var import_core2 = require("@copilotkitnext/core");
|
|
1436
1440
|
|
|
1437
1441
|
// src/providers/CopilotKitProvider.tsx
|
|
1438
|
-
var
|
|
1439
|
-
var
|
|
1442
|
+
var import_react7 = require("react");
|
|
1443
|
+
var import_zod2 = require("zod");
|
|
1440
1444
|
|
|
1441
1445
|
// src/lib/react-core.ts
|
|
1442
1446
|
var import_core = require("@copilotkitnext/core");
|
|
@@ -1508,18 +1512,289 @@ var CopilotKitInspector = ({ core, ...rest }) => {
|
|
|
1508
1512
|
};
|
|
1509
1513
|
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
1510
1514
|
|
|
1511
|
-
// src/
|
|
1515
|
+
// src/components/MCPAppsActivityRenderer.tsx
|
|
1516
|
+
var import_react6 = require("react");
|
|
1517
|
+
var import_zod = require("zod");
|
|
1512
1518
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1519
|
+
var PROTOCOL_VERSION = "2025-06-18";
|
|
1520
|
+
var MCPAppsActivityType = "mcp-apps";
|
|
1521
|
+
var MCPAppsActivityContentSchema = import_zod.z.object({
|
|
1522
|
+
result: import_zod.z.object({
|
|
1523
|
+
content: import_zod.z.array(import_zod.z.any()).optional(),
|
|
1524
|
+
structuredContent: import_zod.z.any().optional(),
|
|
1525
|
+
isError: import_zod.z.boolean().optional()
|
|
1526
|
+
}),
|
|
1527
|
+
resource: import_zod.z.object({
|
|
1528
|
+
uri: import_zod.z.string(),
|
|
1529
|
+
mimeType: import_zod.z.string().optional(),
|
|
1530
|
+
text: import_zod.z.string().optional(),
|
|
1531
|
+
blob: import_zod.z.string().optional()
|
|
1532
|
+
}),
|
|
1533
|
+
// Server ID for proxying requests (MD5 hash of server config)
|
|
1534
|
+
serverId: import_zod.z.string().optional(),
|
|
1535
|
+
// Original tool input arguments
|
|
1536
|
+
toolInput: import_zod.z.record(import_zod.z.unknown()).optional()
|
|
1537
|
+
});
|
|
1538
|
+
function isRequest(msg) {
|
|
1539
|
+
return "id" in msg && "method" in msg;
|
|
1540
|
+
}
|
|
1541
|
+
function isNotification(msg) {
|
|
1542
|
+
return !("id" in msg) && "method" in msg;
|
|
1543
|
+
}
|
|
1544
|
+
function extractHtmlFromResource(resource) {
|
|
1545
|
+
if (resource.text) {
|
|
1546
|
+
return resource.text;
|
|
1547
|
+
}
|
|
1548
|
+
if (resource.blob) {
|
|
1549
|
+
return atob(resource.blob);
|
|
1550
|
+
}
|
|
1551
|
+
throw new Error("Resource has no text or blob content");
|
|
1552
|
+
}
|
|
1553
|
+
var MCPAppsActivityRenderer = ({ content, agent }) => {
|
|
1554
|
+
const containerRef = (0, import_react6.useRef)(null);
|
|
1555
|
+
const iframeRef = (0, import_react6.useRef)(null);
|
|
1556
|
+
const [iframeReady, setIframeReady] = (0, import_react6.useState)(false);
|
|
1557
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
1558
|
+
const [iframeSize, setIframeSize] = (0, import_react6.useState)({});
|
|
1559
|
+
const contentRef = (0, import_react6.useRef)(content);
|
|
1560
|
+
contentRef.current = content;
|
|
1561
|
+
const agentRef = (0, import_react6.useRef)(agent);
|
|
1562
|
+
agentRef.current = agent;
|
|
1563
|
+
const sendToIframe = (0, import_react6.useCallback)((msg) => {
|
|
1564
|
+
if (iframeRef.current?.contentWindow) {
|
|
1565
|
+
console.log("[MCPAppsRenderer] Sending to iframe:", msg);
|
|
1566
|
+
iframeRef.current.contentWindow.postMessage(msg, "*");
|
|
1567
|
+
}
|
|
1568
|
+
}, []);
|
|
1569
|
+
const sendResponse = (0, import_react6.useCallback)((id, result) => {
|
|
1570
|
+
sendToIframe({
|
|
1571
|
+
jsonrpc: "2.0",
|
|
1572
|
+
id,
|
|
1573
|
+
result
|
|
1574
|
+
});
|
|
1575
|
+
}, [sendToIframe]);
|
|
1576
|
+
const sendErrorResponse = (0, import_react6.useCallback)((id, code, message) => {
|
|
1577
|
+
sendToIframe({
|
|
1578
|
+
jsonrpc: "2.0",
|
|
1579
|
+
id,
|
|
1580
|
+
error: { code, message }
|
|
1581
|
+
});
|
|
1582
|
+
}, [sendToIframe]);
|
|
1583
|
+
const sendNotification = (0, import_react6.useCallback)((method, params) => {
|
|
1584
|
+
sendToIframe({
|
|
1585
|
+
jsonrpc: "2.0",
|
|
1586
|
+
method,
|
|
1587
|
+
params: params || {}
|
|
1588
|
+
});
|
|
1589
|
+
}, [sendToIframe]);
|
|
1590
|
+
(0, import_react6.useEffect)(() => {
|
|
1591
|
+
if (!containerRef.current) return;
|
|
1592
|
+
let mounted = true;
|
|
1593
|
+
let messageHandler = null;
|
|
1594
|
+
const setup = async () => {
|
|
1595
|
+
try {
|
|
1596
|
+
const iframe = document.createElement("iframe");
|
|
1597
|
+
iframe.style.width = "100%";
|
|
1598
|
+
iframe.style.height = "300px";
|
|
1599
|
+
iframe.style.border = "none";
|
|
1600
|
+
iframe.style.backgroundColor = "transparent";
|
|
1601
|
+
iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
|
|
1602
|
+
const sandboxReady = new Promise((resolve) => {
|
|
1603
|
+
const initialListener = (event) => {
|
|
1604
|
+
if (event.source === iframe.contentWindow) {
|
|
1605
|
+
if (event.data?.method === "ui/notifications/sandbox-proxy-ready") {
|
|
1606
|
+
window.removeEventListener("message", initialListener);
|
|
1607
|
+
resolve();
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
window.addEventListener("message", initialListener);
|
|
1612
|
+
});
|
|
1613
|
+
iframe.src = "/sandbox.html";
|
|
1614
|
+
iframeRef.current = iframe;
|
|
1615
|
+
containerRef.current?.appendChild(iframe);
|
|
1616
|
+
await sandboxReady;
|
|
1617
|
+
if (!mounted) return;
|
|
1618
|
+
console.log("[MCPAppsRenderer] Sandbox proxy ready");
|
|
1619
|
+
messageHandler = async (event) => {
|
|
1620
|
+
if (event.source !== iframe.contentWindow) return;
|
|
1621
|
+
const msg = event.data;
|
|
1622
|
+
if (!msg || typeof msg !== "object" || msg.jsonrpc !== "2.0") return;
|
|
1623
|
+
console.log("[MCPAppsRenderer] Received from iframe:", msg);
|
|
1624
|
+
if (isRequest(msg)) {
|
|
1625
|
+
switch (msg.method) {
|
|
1626
|
+
case "ui/initialize": {
|
|
1627
|
+
sendResponse(msg.id, {
|
|
1628
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
1629
|
+
hostInfo: {
|
|
1630
|
+
name: "CopilotKit MCP Apps Host",
|
|
1631
|
+
version: "1.0.0"
|
|
1632
|
+
},
|
|
1633
|
+
hostCapabilities: {
|
|
1634
|
+
openLinks: {},
|
|
1635
|
+
logging: {}
|
|
1636
|
+
},
|
|
1637
|
+
hostContext: {
|
|
1638
|
+
theme: "light",
|
|
1639
|
+
platform: "web"
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1642
|
+
break;
|
|
1643
|
+
}
|
|
1644
|
+
case "ui/message": {
|
|
1645
|
+
console.log("[MCPAppsRenderer] ui/message request:", msg.params);
|
|
1646
|
+
sendResponse(msg.id, { isError: false });
|
|
1647
|
+
break;
|
|
1648
|
+
}
|
|
1649
|
+
case "ui/open-link": {
|
|
1650
|
+
const url = msg.params?.url;
|
|
1651
|
+
if (url) {
|
|
1652
|
+
window.open(url, "_blank", "noopener,noreferrer");
|
|
1653
|
+
sendResponse(msg.id, { isError: false });
|
|
1654
|
+
} else {
|
|
1655
|
+
sendErrorResponse(msg.id, -32602, "Missing url parameter");
|
|
1656
|
+
}
|
|
1657
|
+
break;
|
|
1658
|
+
}
|
|
1659
|
+
case "tools/call": {
|
|
1660
|
+
const { serverId } = contentRef.current;
|
|
1661
|
+
const currentAgent = agentRef.current;
|
|
1662
|
+
if (!serverId) {
|
|
1663
|
+
sendErrorResponse(msg.id, -32603, "No server ID available for proxying");
|
|
1664
|
+
break;
|
|
1665
|
+
}
|
|
1666
|
+
if (!currentAgent) {
|
|
1667
|
+
sendErrorResponse(msg.id, -32603, "No agent available for proxying");
|
|
1668
|
+
break;
|
|
1669
|
+
}
|
|
1670
|
+
try {
|
|
1671
|
+
const runResult = await currentAgent.runAgent({
|
|
1672
|
+
forwardedProps: {
|
|
1673
|
+
__proxiedMCPRequest: {
|
|
1674
|
+
serverId,
|
|
1675
|
+
method: "tools/call",
|
|
1676
|
+
params: msg.params
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
});
|
|
1680
|
+
sendResponse(msg.id, runResult.result || {});
|
|
1681
|
+
} catch (err) {
|
|
1682
|
+
console.error("[MCPAppsRenderer] tools/call error:", err);
|
|
1683
|
+
sendErrorResponse(msg.id, -32603, String(err));
|
|
1684
|
+
}
|
|
1685
|
+
break;
|
|
1686
|
+
}
|
|
1687
|
+
default:
|
|
1688
|
+
sendErrorResponse(msg.id, -32601, `Method not found: ${msg.method}`);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
if (isNotification(msg)) {
|
|
1692
|
+
switch (msg.method) {
|
|
1693
|
+
case "ui/notifications/initialized": {
|
|
1694
|
+
console.log("[MCPAppsRenderer] Inner iframe initialized");
|
|
1695
|
+
if (mounted) {
|
|
1696
|
+
setIframeReady(true);
|
|
1697
|
+
}
|
|
1698
|
+
break;
|
|
1699
|
+
}
|
|
1700
|
+
case "ui/notifications/size-change": {
|
|
1701
|
+
const { width, height } = msg.params || {};
|
|
1702
|
+
console.log("[MCPAppsRenderer] Size change:", { width, height });
|
|
1703
|
+
if (mounted) {
|
|
1704
|
+
setIframeSize({
|
|
1705
|
+
width: typeof width === "number" ? width : void 0,
|
|
1706
|
+
height: typeof height === "number" ? height : void 0
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
break;
|
|
1710
|
+
}
|
|
1711
|
+
case "notifications/message": {
|
|
1712
|
+
console.log("[MCPAppsRenderer] App log:", msg.params);
|
|
1713
|
+
break;
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
};
|
|
1718
|
+
window.addEventListener("message", messageHandler);
|
|
1719
|
+
const html = extractHtmlFromResource(content.resource);
|
|
1720
|
+
sendNotification("ui/notifications/sandbox-resource-ready", { html });
|
|
1721
|
+
} catch (err) {
|
|
1722
|
+
console.error("[MCPAppsRenderer] Setup error:", err);
|
|
1723
|
+
if (mounted) {
|
|
1724
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
};
|
|
1728
|
+
setup();
|
|
1729
|
+
return () => {
|
|
1730
|
+
mounted = false;
|
|
1731
|
+
if (messageHandler) {
|
|
1732
|
+
window.removeEventListener("message", messageHandler);
|
|
1733
|
+
}
|
|
1734
|
+
if (iframeRef.current && containerRef.current?.contains(iframeRef.current)) {
|
|
1735
|
+
containerRef.current.removeChild(iframeRef.current);
|
|
1736
|
+
}
|
|
1737
|
+
iframeRef.current = null;
|
|
1738
|
+
};
|
|
1739
|
+
}, [content.resource, sendNotification, sendResponse, sendErrorResponse]);
|
|
1740
|
+
(0, import_react6.useEffect)(() => {
|
|
1741
|
+
if (iframeRef.current) {
|
|
1742
|
+
if (iframeSize.width !== void 0) {
|
|
1743
|
+
iframeRef.current.style.width = `${iframeSize.width}px`;
|
|
1744
|
+
}
|
|
1745
|
+
if (iframeSize.height !== void 0) {
|
|
1746
|
+
iframeRef.current.style.height = `${iframeSize.height}px`;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
}, [iframeSize]);
|
|
1750
|
+
(0, import_react6.useEffect)(() => {
|
|
1751
|
+
if (iframeReady && content.toolInput) {
|
|
1752
|
+
console.log("[MCPAppsRenderer] Sending tool input:", content.toolInput);
|
|
1753
|
+
sendNotification("ui/notifications/tool-input", {
|
|
1754
|
+
arguments: content.toolInput
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
}, [iframeReady, content.toolInput, sendNotification]);
|
|
1758
|
+
(0, import_react6.useEffect)(() => {
|
|
1759
|
+
if (iframeReady && content.result) {
|
|
1760
|
+
console.log("[MCPAppsRenderer] Sending tool result:", content.result);
|
|
1761
|
+
sendNotification("ui/notifications/tool-result", content.result);
|
|
1762
|
+
}
|
|
1763
|
+
}, [iframeReady, content.result, sendNotification]);
|
|
1764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1765
|
+
"div",
|
|
1766
|
+
{
|
|
1767
|
+
ref: containerRef,
|
|
1768
|
+
style: {
|
|
1769
|
+
width: "100%",
|
|
1770
|
+
minHeight: "100px",
|
|
1771
|
+
borderRadius: "8px",
|
|
1772
|
+
overflow: "hidden",
|
|
1773
|
+
backgroundColor: "#f9f9f9",
|
|
1774
|
+
border: "1px solid #e0e0e0"
|
|
1775
|
+
},
|
|
1776
|
+
children: error && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { color: "red", padding: "1rem" }, children: [
|
|
1777
|
+
"Error: ",
|
|
1778
|
+
error.message
|
|
1779
|
+
] })
|
|
1780
|
+
}
|
|
1781
|
+
);
|
|
1782
|
+
};
|
|
1783
|
+
|
|
1784
|
+
// src/providers/CopilotKitProvider.tsx
|
|
1785
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1513
1786
|
var HEADER_NAME = "X-CopilotCloud-Public-Api-Key";
|
|
1514
1787
|
var COPILOT_CLOUD_CHAT_URL = "https://api.cloud.copilotkit.ai/copilotkit/v1";
|
|
1515
|
-
var
|
|
1516
|
-
|
|
1788
|
+
var EMPTY_SET = /* @__PURE__ */ new Set();
|
|
1789
|
+
var CopilotKitContext = (0, import_react7.createContext)({
|
|
1790
|
+
copilotkit: null,
|
|
1791
|
+
executingToolCallIds: EMPTY_SET
|
|
1517
1792
|
});
|
|
1518
1793
|
function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
|
|
1519
|
-
const empty = (0,
|
|
1794
|
+
const empty = (0, import_react7.useMemo)(() => [], []);
|
|
1520
1795
|
const value = prop ?? empty;
|
|
1521
|
-
const initial = (0,
|
|
1522
|
-
(0,
|
|
1796
|
+
const initial = (0, import_react7.useRef)(value);
|
|
1797
|
+
(0, import_react7.useEffect)(() => {
|
|
1523
1798
|
if (warningMessage && value !== initial.current && (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)) {
|
|
1524
1799
|
console.error(warningMessage);
|
|
1525
1800
|
}
|
|
@@ -1542,8 +1817,8 @@ var CopilotKitProvider = ({
|
|
|
1542
1817
|
showDevConsole = false,
|
|
1543
1818
|
useSingleEndpoint = false
|
|
1544
1819
|
}) => {
|
|
1545
|
-
const [shouldRenderInspector, setShouldRenderInspector] = (0,
|
|
1546
|
-
(0,
|
|
1820
|
+
const [shouldRenderInspector, setShouldRenderInspector] = (0, import_react7.useState)(false);
|
|
1821
|
+
(0, import_react7.useEffect)(() => {
|
|
1547
1822
|
if (typeof window === "undefined") {
|
|
1548
1823
|
return;
|
|
1549
1824
|
}
|
|
@@ -1581,9 +1856,19 @@ var CopilotKitProvider = ({
|
|
|
1581
1856
|
renderActivityMessages,
|
|
1582
1857
|
"renderActivityMessages must be a stable array."
|
|
1583
1858
|
);
|
|
1859
|
+
const builtInActivityRenderers = (0, import_react7.useMemo)(() => [
|
|
1860
|
+
{
|
|
1861
|
+
activityType: MCPAppsActivityType,
|
|
1862
|
+
content: MCPAppsActivityContentSchema,
|
|
1863
|
+
render: MCPAppsActivityRenderer
|
|
1864
|
+
}
|
|
1865
|
+
], []);
|
|
1866
|
+
const allActivityRenderers = (0, import_react7.useMemo)(() => {
|
|
1867
|
+
return [...renderActivityMessagesList, ...builtInActivityRenderers];
|
|
1868
|
+
}, [renderActivityMessagesList, builtInActivityRenderers]);
|
|
1584
1869
|
const resolvedPublicKey = publicApiKey ?? publicLicenseKey;
|
|
1585
1870
|
const hasLocalAgents = agents && Object.keys(agents).length > 0;
|
|
1586
|
-
const mergedHeaders = (0,
|
|
1871
|
+
const mergedHeaders = (0, import_react7.useMemo)(() => {
|
|
1587
1872
|
if (!resolvedPublicKey) return headers;
|
|
1588
1873
|
if (headers[HEADER_NAME]) return headers;
|
|
1589
1874
|
return {
|
|
@@ -1608,7 +1893,7 @@ var CopilotKitProvider = ({
|
|
|
1608
1893
|
humanInTheLoop,
|
|
1609
1894
|
"humanInTheLoop must be a stable array. If you want to dynamically add or remove human-in-the-loop tools, use `useHumanInTheLoop` instead."
|
|
1610
1895
|
);
|
|
1611
|
-
const processedHumanInTheLoopTools = (0,
|
|
1896
|
+
const processedHumanInTheLoopTools = (0, import_react7.useMemo)(() => {
|
|
1612
1897
|
const processedTools = [];
|
|
1613
1898
|
const processedRenderToolCalls = [];
|
|
1614
1899
|
humanInTheLoopList.forEach((tool) => {
|
|
@@ -1637,17 +1922,17 @@ var CopilotKitProvider = ({
|
|
|
1637
1922
|
});
|
|
1638
1923
|
return { tools: processedTools, renderToolCalls: processedRenderToolCalls };
|
|
1639
1924
|
}, [humanInTheLoopList]);
|
|
1640
|
-
const allTools = (0,
|
|
1925
|
+
const allTools = (0, import_react7.useMemo)(() => {
|
|
1641
1926
|
const tools = [];
|
|
1642
1927
|
tools.push(...frontendToolsList);
|
|
1643
1928
|
tools.push(...processedHumanInTheLoopTools.tools);
|
|
1644
1929
|
return tools;
|
|
1645
1930
|
}, [frontendToolsList, processedHumanInTheLoopTools]);
|
|
1646
|
-
const allRenderToolCalls = (0,
|
|
1931
|
+
const allRenderToolCalls = (0, import_react7.useMemo)(() => {
|
|
1647
1932
|
const combined = [...renderToolCallsList];
|
|
1648
1933
|
frontendToolsList.forEach((tool) => {
|
|
1649
1934
|
if (tool.render) {
|
|
1650
|
-
const args = tool.parameters || (tool.name === "*" ?
|
|
1935
|
+
const args = tool.parameters || (tool.name === "*" ? import_zod2.z.any() : void 0);
|
|
1651
1936
|
if (args) {
|
|
1652
1937
|
combined.push({
|
|
1653
1938
|
name: tool.name,
|
|
@@ -1660,7 +1945,7 @@ var CopilotKitProvider = ({
|
|
|
1660
1945
|
combined.push(...processedHumanInTheLoopTools.renderToolCalls);
|
|
1661
1946
|
return combined;
|
|
1662
1947
|
}, [renderToolCallsList, frontendToolsList, processedHumanInTheLoopTools]);
|
|
1663
|
-
const copilotkit = (0,
|
|
1948
|
+
const copilotkit = (0, import_react7.useMemo)(() => {
|
|
1664
1949
|
const copilotkit2 = new CopilotKitCoreReact({
|
|
1665
1950
|
runtimeUrl: chatApiEndpoint,
|
|
1666
1951
|
runtimeTransport: useSingleEndpoint ? "single" : "rest",
|
|
@@ -1669,13 +1954,13 @@ var CopilotKitProvider = ({
|
|
|
1669
1954
|
agents__unsafe_dev_only: agents,
|
|
1670
1955
|
tools: allTools,
|
|
1671
1956
|
renderToolCalls: allRenderToolCalls,
|
|
1672
|
-
renderActivityMessages:
|
|
1957
|
+
renderActivityMessages: allActivityRenderers,
|
|
1673
1958
|
renderCustomMessages: renderCustomMessagesList
|
|
1674
1959
|
});
|
|
1675
1960
|
return copilotkit2;
|
|
1676
|
-
}, [allTools, allRenderToolCalls,
|
|
1677
|
-
const [, forceUpdate] = (0,
|
|
1678
|
-
(0,
|
|
1961
|
+
}, [allTools, allRenderToolCalls, allActivityRenderers, renderCustomMessagesList, useSingleEndpoint]);
|
|
1962
|
+
const [, forceUpdate] = (0, import_react7.useReducer)((x) => x + 1, 0);
|
|
1963
|
+
(0, import_react7.useEffect)(() => {
|
|
1679
1964
|
const subscription = copilotkit.subscribe({
|
|
1680
1965
|
onRenderToolCallsChanged: () => {
|
|
1681
1966
|
forceUpdate();
|
|
@@ -1685,33 +1970,58 @@ var CopilotKitProvider = ({
|
|
|
1685
1970
|
subscription.unsubscribe();
|
|
1686
1971
|
};
|
|
1687
1972
|
}, [copilotkit]);
|
|
1688
|
-
(0,
|
|
1973
|
+
const [executingToolCallIds, setExecutingToolCallIds] = (0, import_react7.useState)(() => /* @__PURE__ */ new Set());
|
|
1974
|
+
(0, import_react7.useEffect)(() => {
|
|
1975
|
+
const subscription = copilotkit.subscribe({
|
|
1976
|
+
onToolExecutionStart: ({ toolCallId }) => {
|
|
1977
|
+
setExecutingToolCallIds((prev) => {
|
|
1978
|
+
if (prev.has(toolCallId)) return prev;
|
|
1979
|
+
const next = new Set(prev);
|
|
1980
|
+
next.add(toolCallId);
|
|
1981
|
+
return next;
|
|
1982
|
+
});
|
|
1983
|
+
},
|
|
1984
|
+
onToolExecutionEnd: ({ toolCallId }) => {
|
|
1985
|
+
setExecutingToolCallIds((prev) => {
|
|
1986
|
+
if (!prev.has(toolCallId)) return prev;
|
|
1987
|
+
const next = new Set(prev);
|
|
1988
|
+
next.delete(toolCallId);
|
|
1989
|
+
return next;
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
});
|
|
1993
|
+
return () => {
|
|
1994
|
+
subscription.unsubscribe();
|
|
1995
|
+
};
|
|
1996
|
+
}, [copilotkit]);
|
|
1997
|
+
(0, import_react7.useEffect)(() => {
|
|
1689
1998
|
copilotkit.setRuntimeUrl(chatApiEndpoint);
|
|
1690
1999
|
copilotkit.setRuntimeTransport(useSingleEndpoint ? "single" : "rest");
|
|
1691
2000
|
copilotkit.setHeaders(mergedHeaders);
|
|
1692
2001
|
copilotkit.setProperties(properties);
|
|
1693
2002
|
copilotkit.setAgents__unsafe_dev_only(agents);
|
|
1694
2003
|
}, [chatApiEndpoint, mergedHeaders, properties, agents, useSingleEndpoint]);
|
|
1695
|
-
return /* @__PURE__ */ (0,
|
|
2004
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1696
2005
|
CopilotKitContext.Provider,
|
|
1697
2006
|
{
|
|
1698
2007
|
value: {
|
|
1699
|
-
copilotkit
|
|
2008
|
+
copilotkit,
|
|
2009
|
+
executingToolCallIds
|
|
1700
2010
|
},
|
|
1701
2011
|
children: [
|
|
1702
2012
|
children,
|
|
1703
|
-
shouldRenderInspector ? /* @__PURE__ */ (0,
|
|
2013
|
+
shouldRenderInspector ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CopilotKitInspector, { core: copilotkit }) : null
|
|
1704
2014
|
]
|
|
1705
2015
|
}
|
|
1706
2016
|
);
|
|
1707
2017
|
};
|
|
1708
2018
|
var useCopilotKit = () => {
|
|
1709
|
-
const context = (0,
|
|
1710
|
-
const [, forceUpdate] = (0,
|
|
2019
|
+
const context = (0, import_react7.useContext)(CopilotKitContext);
|
|
2020
|
+
const [, forceUpdate] = (0, import_react7.useReducer)((x) => x + 1, 0);
|
|
1711
2021
|
if (!context) {
|
|
1712
2022
|
throw new Error("useCopilotKit must be used within CopilotKitProvider");
|
|
1713
2023
|
}
|
|
1714
|
-
(0,
|
|
2024
|
+
(0, import_react7.useEffect)(() => {
|
|
1715
2025
|
const subscription = context.copilotkit.subscribe({
|
|
1716
2026
|
onRuntimeConnectionStatusChanged: () => {
|
|
1717
2027
|
forceUpdate();
|
|
@@ -1727,21 +2037,21 @@ var useCopilotKit = () => {
|
|
|
1727
2037
|
// src/hooks/use-render-tool-call.tsx
|
|
1728
2038
|
var import_shared2 = require("@copilotkitnext/shared");
|
|
1729
2039
|
var import_shared3 = require("@copilotkitnext/shared");
|
|
1730
|
-
var
|
|
1731
|
-
var ToolCallRenderer =
|
|
2040
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2041
|
+
var ToolCallRenderer = import_react8.default.memo(
|
|
1732
2042
|
function ToolCallRenderer2({
|
|
1733
2043
|
toolCall,
|
|
1734
2044
|
toolMessage,
|
|
1735
2045
|
RenderComponent,
|
|
1736
2046
|
isExecuting
|
|
1737
2047
|
}) {
|
|
1738
|
-
const args = (0,
|
|
2048
|
+
const args = (0, import_react8.useMemo)(
|
|
1739
2049
|
() => (0, import_shared3.partialJSONParse)(toolCall.function.arguments),
|
|
1740
2050
|
[toolCall.function.arguments]
|
|
1741
2051
|
);
|
|
1742
2052
|
const toolName = toolCall.function.name;
|
|
1743
2053
|
if (toolMessage) {
|
|
1744
|
-
return /* @__PURE__ */ (0,
|
|
2054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1745
2055
|
RenderComponent,
|
|
1746
2056
|
{
|
|
1747
2057
|
name: toolName,
|
|
@@ -1751,7 +2061,7 @@ var ToolCallRenderer = import_react7.default.memo(
|
|
|
1751
2061
|
}
|
|
1752
2062
|
);
|
|
1753
2063
|
} else if (isExecuting) {
|
|
1754
|
-
return /* @__PURE__ */ (0,
|
|
2064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1755
2065
|
RenderComponent,
|
|
1756
2066
|
{
|
|
1757
2067
|
name: toolName,
|
|
@@ -1761,7 +2071,7 @@ var ToolCallRenderer = import_react7.default.memo(
|
|
|
1761
2071
|
}
|
|
1762
2072
|
);
|
|
1763
2073
|
} else {
|
|
1764
|
-
return /* @__PURE__ */ (0,
|
|
2074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1765
2075
|
RenderComponent,
|
|
1766
2076
|
{
|
|
1767
2077
|
name: toolName,
|
|
@@ -1786,11 +2096,10 @@ var ToolCallRenderer = import_react7.default.memo(
|
|
|
1786
2096
|
}
|
|
1787
2097
|
);
|
|
1788
2098
|
function useRenderToolCall() {
|
|
1789
|
-
const { copilotkit } = useCopilotKit();
|
|
2099
|
+
const { copilotkit, executingToolCallIds } = useCopilotKit();
|
|
1790
2100
|
const config = useCopilotChatConfiguration();
|
|
1791
2101
|
const agentId = config?.agentId ?? import_shared2.DEFAULT_AGENT_ID;
|
|
1792
|
-
const
|
|
1793
|
-
const renderToolCalls = (0, import_react7.useSyncExternalStore)(
|
|
2102
|
+
const renderToolCalls = (0, import_react8.useSyncExternalStore)(
|
|
1794
2103
|
(callback) => {
|
|
1795
2104
|
return copilotkit.subscribe({
|
|
1796
2105
|
onRenderToolCallsChanged: callback
|
|
@@ -1799,28 +2108,7 @@ function useRenderToolCall() {
|
|
|
1799
2108
|
() => copilotkit.renderToolCalls,
|
|
1800
2109
|
() => copilotkit.renderToolCalls
|
|
1801
2110
|
);
|
|
1802
|
-
(0,
|
|
1803
|
-
const subscription = copilotkit.subscribe({
|
|
1804
|
-
onToolExecutionStart: ({ toolCallId }) => {
|
|
1805
|
-
setExecutingToolCallIds((prev) => {
|
|
1806
|
-
if (prev.has(toolCallId)) return prev;
|
|
1807
|
-
const next = new Set(prev);
|
|
1808
|
-
next.add(toolCallId);
|
|
1809
|
-
return next;
|
|
1810
|
-
});
|
|
1811
|
-
},
|
|
1812
|
-
onToolExecutionEnd: ({ toolCallId }) => {
|
|
1813
|
-
setExecutingToolCallIds((prev) => {
|
|
1814
|
-
if (!prev.has(toolCallId)) return prev;
|
|
1815
|
-
const next = new Set(prev);
|
|
1816
|
-
next.delete(toolCallId);
|
|
1817
|
-
return next;
|
|
1818
|
-
});
|
|
1819
|
-
}
|
|
1820
|
-
});
|
|
1821
|
-
return () => subscription.unsubscribe();
|
|
1822
|
-
}, [copilotkit]);
|
|
1823
|
-
const renderToolCall = (0, import_react7.useCallback)(
|
|
2111
|
+
const renderToolCall = (0, import_react8.useCallback)(
|
|
1824
2112
|
({
|
|
1825
2113
|
toolCall,
|
|
1826
2114
|
toolMessage
|
|
@@ -1834,7 +2122,7 @@ function useRenderToolCall() {
|
|
|
1834
2122
|
}
|
|
1835
2123
|
const RenderComponent = renderConfig.render;
|
|
1836
2124
|
const isExecuting = executingToolCallIds.has(toolCall.id);
|
|
1837
|
-
return /* @__PURE__ */ (0,
|
|
2125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1838
2126
|
ToolCallRenderer,
|
|
1839
2127
|
{
|
|
1840
2128
|
toolCall,
|
|
@@ -1851,7 +2139,7 @@ function useRenderToolCall() {
|
|
|
1851
2139
|
}
|
|
1852
2140
|
|
|
1853
2141
|
// src/hooks/use-render-custom-messages.tsx
|
|
1854
|
-
var
|
|
2142
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1855
2143
|
function useRenderCustomMessages() {
|
|
1856
2144
|
const { copilotkit } = useCopilotKit();
|
|
1857
2145
|
const config = useCopilotChatConfiguration();
|
|
@@ -1886,7 +2174,7 @@ function useRenderCustomMessages() {
|
|
|
1886
2174
|
continue;
|
|
1887
2175
|
}
|
|
1888
2176
|
const Component = renderer.render;
|
|
1889
|
-
result = /* @__PURE__ */ (0,
|
|
2177
|
+
result = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1890
2178
|
Component,
|
|
1891
2179
|
{
|
|
1892
2180
|
message,
|
|
@@ -1910,14 +2198,14 @@ function useRenderCustomMessages() {
|
|
|
1910
2198
|
|
|
1911
2199
|
// src/hooks/use-render-activity-message.tsx
|
|
1912
2200
|
var import_shared4 = require("@copilotkitnext/shared");
|
|
1913
|
-
var
|
|
1914
|
-
var
|
|
2201
|
+
var import_react9 = require("react");
|
|
2202
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1915
2203
|
function useRenderActivityMessage() {
|
|
1916
2204
|
const { copilotkit } = useCopilotKit();
|
|
1917
2205
|
const config = useCopilotChatConfiguration();
|
|
1918
2206
|
const agentId = config?.agentId ?? import_shared4.DEFAULT_AGENT_ID;
|
|
1919
2207
|
const renderers = copilotkit.renderActivityMessages;
|
|
1920
|
-
return (0,
|
|
2208
|
+
return (0, import_react9.useCallback)(
|
|
1921
2209
|
(message) => {
|
|
1922
2210
|
if (!renderers.length) {
|
|
1923
2211
|
return null;
|
|
@@ -1939,7 +2227,7 @@ function useRenderActivityMessage() {
|
|
|
1939
2227
|
}
|
|
1940
2228
|
const Component = renderer.render;
|
|
1941
2229
|
const agent = copilotkit.getAgent(agentId);
|
|
1942
|
-
return /* @__PURE__ */ (0,
|
|
2230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1943
2231
|
Component,
|
|
1944
2232
|
{
|
|
1945
2233
|
activityType: message.activityType,
|
|
@@ -1955,12 +2243,12 @@ function useRenderActivityMessage() {
|
|
|
1955
2243
|
}
|
|
1956
2244
|
|
|
1957
2245
|
// src/hooks/use-frontend-tool.tsx
|
|
1958
|
-
var
|
|
2246
|
+
var import_react10 = require("react");
|
|
1959
2247
|
var EMPTY_DEPS = [];
|
|
1960
2248
|
function useFrontendTool(tool, deps) {
|
|
1961
2249
|
const { copilotkit } = useCopilotKit();
|
|
1962
2250
|
const extraDeps = deps ?? EMPTY_DEPS;
|
|
1963
|
-
(0,
|
|
2251
|
+
(0, import_react10.useEffect)(() => {
|
|
1964
2252
|
const name = tool.name;
|
|
1965
2253
|
if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {
|
|
1966
2254
|
console.warn(
|
|
@@ -1992,23 +2280,23 @@ function useFrontendTool(tool, deps) {
|
|
|
1992
2280
|
}
|
|
1993
2281
|
|
|
1994
2282
|
// src/hooks/use-human-in-the-loop.tsx
|
|
1995
|
-
var
|
|
1996
|
-
var
|
|
2283
|
+
var import_react11 = require("react");
|
|
2284
|
+
var import_react12 = __toESM(require("react"));
|
|
1997
2285
|
function useHumanInTheLoop(tool, deps) {
|
|
1998
2286
|
const { copilotkit } = useCopilotKit();
|
|
1999
|
-
const resolvePromiseRef = (0,
|
|
2000
|
-
const respond = (0,
|
|
2287
|
+
const resolvePromiseRef = (0, import_react11.useRef)(null);
|
|
2288
|
+
const respond = (0, import_react11.useCallback)(async (result) => {
|
|
2001
2289
|
if (resolvePromiseRef.current) {
|
|
2002
2290
|
resolvePromiseRef.current(result);
|
|
2003
2291
|
resolvePromiseRef.current = null;
|
|
2004
2292
|
}
|
|
2005
2293
|
}, []);
|
|
2006
|
-
const handler = (0,
|
|
2294
|
+
const handler = (0, import_react11.useCallback)(async () => {
|
|
2007
2295
|
return new Promise((resolve) => {
|
|
2008
2296
|
resolvePromiseRef.current = resolve;
|
|
2009
2297
|
});
|
|
2010
2298
|
}, []);
|
|
2011
|
-
const RenderComponent = (0,
|
|
2299
|
+
const RenderComponent = (0, import_react11.useCallback)(
|
|
2012
2300
|
(props) => {
|
|
2013
2301
|
const ToolComponent = tool.render;
|
|
2014
2302
|
if (props.status === "inProgress") {
|
|
@@ -2018,7 +2306,7 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
2018
2306
|
description: tool.description || "",
|
|
2019
2307
|
respond: void 0
|
|
2020
2308
|
};
|
|
2021
|
-
return
|
|
2309
|
+
return import_react12.default.createElement(ToolComponent, enhancedProps);
|
|
2022
2310
|
} else if (props.status === "executing") {
|
|
2023
2311
|
const enhancedProps = {
|
|
2024
2312
|
...props,
|
|
@@ -2026,7 +2314,7 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
2026
2314
|
description: tool.description || "",
|
|
2027
2315
|
respond
|
|
2028
2316
|
};
|
|
2029
|
-
return
|
|
2317
|
+
return import_react12.default.createElement(ToolComponent, enhancedProps);
|
|
2030
2318
|
} else if (props.status === "complete") {
|
|
2031
2319
|
const enhancedProps = {
|
|
2032
2320
|
...props,
|
|
@@ -2034,9 +2322,9 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
2034
2322
|
description: tool.description || "",
|
|
2035
2323
|
respond: void 0
|
|
2036
2324
|
};
|
|
2037
|
-
return
|
|
2325
|
+
return import_react12.default.createElement(ToolComponent, enhancedProps);
|
|
2038
2326
|
}
|
|
2039
|
-
return
|
|
2327
|
+
return import_react12.default.createElement(ToolComponent, props);
|
|
2040
2328
|
},
|
|
2041
2329
|
[tool.render, tool.name, tool.description, respond]
|
|
2042
2330
|
);
|
|
@@ -2046,7 +2334,7 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
2046
2334
|
render: RenderComponent
|
|
2047
2335
|
};
|
|
2048
2336
|
useFrontendTool(frontendTool, deps);
|
|
2049
|
-
(0,
|
|
2337
|
+
(0, import_react11.useEffect)(() => {
|
|
2050
2338
|
return () => {
|
|
2051
2339
|
const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
|
|
2052
2340
|
const currentRenderToolCalls = copilotkit.renderToolCalls;
|
|
@@ -2059,9 +2347,15 @@ function useHumanInTheLoop(tool, deps) {
|
|
|
2059
2347
|
}
|
|
2060
2348
|
|
|
2061
2349
|
// src/hooks/use-agent.tsx
|
|
2062
|
-
var
|
|
2350
|
+
var import_react13 = require("react");
|
|
2063
2351
|
var import_shared5 = require("@copilotkitnext/shared");
|
|
2064
2352
|
var import_core3 = require("@copilotkitnext/core");
|
|
2353
|
+
var UseAgentUpdate = /* @__PURE__ */ ((UseAgentUpdate2) => {
|
|
2354
|
+
UseAgentUpdate2["OnMessagesChanged"] = "OnMessagesChanged";
|
|
2355
|
+
UseAgentUpdate2["OnStateChanged"] = "OnStateChanged";
|
|
2356
|
+
UseAgentUpdate2["OnRunStatusChanged"] = "OnRunStatusChanged";
|
|
2357
|
+
return UseAgentUpdate2;
|
|
2358
|
+
})(UseAgentUpdate || {});
|
|
2065
2359
|
var ALL_UPDATES = [
|
|
2066
2360
|
"OnMessagesChanged" /* OnMessagesChanged */,
|
|
2067
2361
|
"OnStateChanged" /* OnStateChanged */,
|
|
@@ -2070,12 +2364,12 @@ var ALL_UPDATES = [
|
|
|
2070
2364
|
function useAgent({ agentId, updates } = {}) {
|
|
2071
2365
|
agentId ??= import_shared5.DEFAULT_AGENT_ID;
|
|
2072
2366
|
const { copilotkit } = useCopilotKit();
|
|
2073
|
-
const [, forceUpdate] = (0,
|
|
2074
|
-
const updateFlags = (0,
|
|
2367
|
+
const [, forceUpdate] = (0, import_react13.useReducer)((x) => x + 1, 0);
|
|
2368
|
+
const updateFlags = (0, import_react13.useMemo)(
|
|
2075
2369
|
() => updates ?? ALL_UPDATES,
|
|
2076
2370
|
[JSON.stringify(updates)]
|
|
2077
2371
|
);
|
|
2078
|
-
const agent = (0,
|
|
2372
|
+
const agent = (0, import_react13.useMemo)(() => {
|
|
2079
2373
|
const existing = copilotkit.getAgent(agentId);
|
|
2080
2374
|
if (existing) {
|
|
2081
2375
|
return existing;
|
|
@@ -2105,7 +2399,7 @@ function useAgent({ agentId, updates } = {}) {
|
|
|
2105
2399
|
JSON.stringify(copilotkit.headers),
|
|
2106
2400
|
copilotkit
|
|
2107
2401
|
]);
|
|
2108
|
-
(0,
|
|
2402
|
+
(0, import_react13.useEffect)(() => {
|
|
2109
2403
|
if (updateFlags.length === 0) {
|
|
2110
2404
|
return;
|
|
2111
2405
|
}
|
|
@@ -2140,17 +2434,17 @@ function useAgent({ agentId, updates } = {}) {
|
|
|
2140
2434
|
}
|
|
2141
2435
|
|
|
2142
2436
|
// src/hooks/use-agent-context.tsx
|
|
2143
|
-
var
|
|
2437
|
+
var import_react14 = require("react");
|
|
2144
2438
|
function useAgentContext(context) {
|
|
2145
2439
|
const { description, value } = context;
|
|
2146
2440
|
const { copilotkit } = useCopilotKit();
|
|
2147
|
-
const stringValue = (0,
|
|
2441
|
+
const stringValue = (0, import_react14.useMemo)(() => {
|
|
2148
2442
|
if (typeof value === "string") {
|
|
2149
2443
|
return value;
|
|
2150
2444
|
}
|
|
2151
2445
|
return JSON.stringify(value);
|
|
2152
2446
|
}, [value]);
|
|
2153
|
-
(0,
|
|
2447
|
+
(0, import_react14.useEffect)(() => {
|
|
2154
2448
|
if (!copilotkit) return;
|
|
2155
2449
|
const id = copilotkit.addContext({ description, value: stringValue });
|
|
2156
2450
|
return () => {
|
|
@@ -2160,26 +2454,26 @@ function useAgentContext(context) {
|
|
|
2160
2454
|
}
|
|
2161
2455
|
|
|
2162
2456
|
// src/hooks/use-suggestions.tsx
|
|
2163
|
-
var
|
|
2457
|
+
var import_react15 = require("react");
|
|
2164
2458
|
var import_shared6 = require("@copilotkitnext/shared");
|
|
2165
2459
|
function useSuggestions({ agentId } = {}) {
|
|
2166
2460
|
const { copilotkit } = useCopilotKit();
|
|
2167
2461
|
const config = useCopilotChatConfiguration();
|
|
2168
|
-
const resolvedAgentId = (0,
|
|
2169
|
-
const [suggestions, setSuggestions] = (0,
|
|
2462
|
+
const resolvedAgentId = (0, import_react15.useMemo)(() => agentId ?? config?.agentId ?? import_shared6.DEFAULT_AGENT_ID, [agentId, config?.agentId]);
|
|
2463
|
+
const [suggestions, setSuggestions] = (0, import_react15.useState)(() => {
|
|
2170
2464
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
2171
2465
|
return result.suggestions;
|
|
2172
2466
|
});
|
|
2173
|
-
const [isLoading, setIsLoading] = (0,
|
|
2467
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(() => {
|
|
2174
2468
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
2175
2469
|
return result.isLoading;
|
|
2176
2470
|
});
|
|
2177
|
-
(0,
|
|
2471
|
+
(0, import_react15.useEffect)(() => {
|
|
2178
2472
|
const result = copilotkit.getSuggestions(resolvedAgentId);
|
|
2179
2473
|
setSuggestions(result.suggestions);
|
|
2180
2474
|
setIsLoading(result.isLoading);
|
|
2181
2475
|
}, [copilotkit, resolvedAgentId]);
|
|
2182
|
-
(0,
|
|
2476
|
+
(0, import_react15.useEffect)(() => {
|
|
2183
2477
|
const subscription = copilotkit.subscribe({
|
|
2184
2478
|
onSuggestionsChanged: ({ agentId: changedAgentId, suggestions: suggestions2 }) => {
|
|
2185
2479
|
if (changedAgentId !== resolvedAgentId) {
|
|
@@ -2209,10 +2503,10 @@ function useSuggestions({ agentId } = {}) {
|
|
|
2209
2503
|
subscription.unsubscribe();
|
|
2210
2504
|
};
|
|
2211
2505
|
}, [copilotkit, resolvedAgentId]);
|
|
2212
|
-
const reloadSuggestions = (0,
|
|
2506
|
+
const reloadSuggestions = (0, import_react15.useCallback)(() => {
|
|
2213
2507
|
copilotkit.reloadSuggestions(resolvedAgentId);
|
|
2214
2508
|
}, [copilotkit, resolvedAgentId]);
|
|
2215
|
-
const clearSuggestions = (0,
|
|
2509
|
+
const clearSuggestions = (0, import_react15.useCallback)(() => {
|
|
2216
2510
|
copilotkit.clearSuggestions(resolvedAgentId);
|
|
2217
2511
|
}, [copilotkit, resolvedAgentId]);
|
|
2218
2512
|
return {
|
|
@@ -2224,19 +2518,19 @@ function useSuggestions({ agentId } = {}) {
|
|
|
2224
2518
|
}
|
|
2225
2519
|
|
|
2226
2520
|
// src/hooks/use-configure-suggestions.tsx
|
|
2227
|
-
var
|
|
2521
|
+
var import_react16 = require("react");
|
|
2228
2522
|
var import_shared7 = require("@copilotkitnext/shared");
|
|
2229
2523
|
function useConfigureSuggestions(config, deps) {
|
|
2230
2524
|
const { copilotkit } = useCopilotKit();
|
|
2231
2525
|
const chatConfig = useCopilotChatConfiguration();
|
|
2232
2526
|
const extraDeps = deps ?? [];
|
|
2233
|
-
const resolvedConsumerAgentId = (0,
|
|
2234
|
-
const rawConsumerAgentId = (0,
|
|
2235
|
-
const normalizationCacheRef = (0,
|
|
2527
|
+
const resolvedConsumerAgentId = (0, import_react16.useMemo)(() => chatConfig?.agentId ?? import_shared7.DEFAULT_AGENT_ID, [chatConfig?.agentId]);
|
|
2528
|
+
const rawConsumerAgentId = (0, import_react16.useMemo)(() => config ? config.consumerAgentId : void 0, [config]);
|
|
2529
|
+
const normalizationCacheRef = (0, import_react16.useRef)({
|
|
2236
2530
|
serialized: null,
|
|
2237
2531
|
config: null
|
|
2238
2532
|
});
|
|
2239
|
-
const { normalizedConfig, serializedConfig } = (0,
|
|
2533
|
+
const { normalizedConfig, serializedConfig } = (0, import_react16.useMemo)(() => {
|
|
2240
2534
|
if (!config) {
|
|
2241
2535
|
normalizationCacheRef.current = { serialized: null, config: null };
|
|
2242
2536
|
return { normalizedConfig: null, serializedConfig: null };
|
|
@@ -2266,10 +2560,10 @@ function useConfigureSuggestions(config, deps) {
|
|
|
2266
2560
|
normalizationCacheRef.current = { serialized, config: built };
|
|
2267
2561
|
return { normalizedConfig: built, serializedConfig: serialized };
|
|
2268
2562
|
}, [config, resolvedConsumerAgentId, ...extraDeps]);
|
|
2269
|
-
const latestConfigRef = (0,
|
|
2563
|
+
const latestConfigRef = (0, import_react16.useRef)(null);
|
|
2270
2564
|
latestConfigRef.current = normalizedConfig;
|
|
2271
|
-
const previousSerializedConfigRef = (0,
|
|
2272
|
-
const targetAgentId = (0,
|
|
2565
|
+
const previousSerializedConfigRef = (0, import_react16.useRef)(null);
|
|
2566
|
+
const targetAgentId = (0, import_react16.useMemo)(() => {
|
|
2273
2567
|
if (!normalizedConfig) {
|
|
2274
2568
|
return resolvedConsumerAgentId;
|
|
2275
2569
|
}
|
|
@@ -2280,7 +2574,7 @@ function useConfigureSuggestions(config, deps) {
|
|
|
2280
2574
|
return consumer;
|
|
2281
2575
|
}, [normalizedConfig, resolvedConsumerAgentId]);
|
|
2282
2576
|
const isGlobalConfig = rawConsumerAgentId === void 0 || rawConsumerAgentId === "*";
|
|
2283
|
-
const requestReload = (0,
|
|
2577
|
+
const requestReload = (0, import_react16.useCallback)(() => {
|
|
2284
2578
|
if (!normalizedConfig) {
|
|
2285
2579
|
return;
|
|
2286
2580
|
}
|
|
@@ -2302,7 +2596,7 @@ function useConfigureSuggestions(config, deps) {
|
|
|
2302
2596
|
}
|
|
2303
2597
|
copilotkit.reloadSuggestions(targetAgentId);
|
|
2304
2598
|
}, [copilotkit, isGlobalConfig, normalizedConfig, targetAgentId]);
|
|
2305
|
-
(0,
|
|
2599
|
+
(0, import_react16.useEffect)(() => {
|
|
2306
2600
|
if (!serializedConfig || !latestConfigRef.current) {
|
|
2307
2601
|
return;
|
|
2308
2602
|
}
|
|
@@ -2312,7 +2606,7 @@ function useConfigureSuggestions(config, deps) {
|
|
|
2312
2606
|
copilotkit.removeSuggestionsConfig(id);
|
|
2313
2607
|
};
|
|
2314
2608
|
}, [copilotkit, serializedConfig, requestReload]);
|
|
2315
|
-
(0,
|
|
2609
|
+
(0, import_react16.useEffect)(() => {
|
|
2316
2610
|
if (!normalizedConfig) {
|
|
2317
2611
|
previousSerializedConfigRef.current = null;
|
|
2318
2612
|
return;
|
|
@@ -2325,7 +2619,7 @@ function useConfigureSuggestions(config, deps) {
|
|
|
2325
2619
|
}
|
|
2326
2620
|
requestReload();
|
|
2327
2621
|
}, [normalizedConfig, requestReload, serializedConfig]);
|
|
2328
|
-
(0,
|
|
2622
|
+
(0, import_react16.useEffect)(() => {
|
|
2329
2623
|
if (!normalizedConfig || extraDeps.length === 0) {
|
|
2330
2624
|
return;
|
|
2331
2625
|
}
|
|
@@ -2343,8 +2637,8 @@ function normalizeStaticSuggestions(suggestions) {
|
|
|
2343
2637
|
}
|
|
2344
2638
|
|
|
2345
2639
|
// src/components/chat/CopilotChatToolCallsView.tsx
|
|
2346
|
-
var
|
|
2347
|
-
var
|
|
2640
|
+
var import_react17 = __toESM(require("react"));
|
|
2641
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2348
2642
|
function CopilotChatToolCallsView({
|
|
2349
2643
|
message,
|
|
2350
2644
|
messages = []
|
|
@@ -2353,11 +2647,11 @@ function CopilotChatToolCallsView({
|
|
|
2353
2647
|
if (!message.toolCalls || message.toolCalls.length === 0) {
|
|
2354
2648
|
return null;
|
|
2355
2649
|
}
|
|
2356
|
-
return /* @__PURE__ */ (0,
|
|
2650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: message.toolCalls.map((toolCall) => {
|
|
2357
2651
|
const toolMessage = messages.find(
|
|
2358
2652
|
(m) => m.role === "tool" && m.toolCallId === toolCall.id
|
|
2359
2653
|
);
|
|
2360
|
-
return /* @__PURE__ */ (0,
|
|
2654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react17.default.Fragment, { children: renderToolCall({
|
|
2361
2655
|
toolCall,
|
|
2362
2656
|
toolMessage
|
|
2363
2657
|
}) }, toolCall.id);
|
|
@@ -2366,7 +2660,7 @@ function CopilotChatToolCallsView({
|
|
|
2366
2660
|
var CopilotChatToolCallsView_default = CopilotChatToolCallsView;
|
|
2367
2661
|
|
|
2368
2662
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
2369
|
-
var
|
|
2663
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2370
2664
|
function CopilotChatAssistantMessage({
|
|
2371
2665
|
message,
|
|
2372
2666
|
messages,
|
|
@@ -2443,7 +2737,7 @@ function CopilotChatAssistantMessage({
|
|
|
2443
2737
|
toolbar,
|
|
2444
2738
|
CopilotChatAssistantMessage.Toolbar,
|
|
2445
2739
|
{
|
|
2446
|
-
children: /* @__PURE__ */ (0,
|
|
2740
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2447
2741
|
boundCopyButton,
|
|
2448
2742
|
(onThumbsUp || thumbsUpButton) && boundThumbsUpButton,
|
|
2449
2743
|
(onThumbsDown || thumbsDownButton) && boundThumbsDownButton,
|
|
@@ -2465,7 +2759,7 @@ function CopilotChatAssistantMessage({
|
|
|
2465
2759
|
const isLatestAssistantMessage = message.role === "assistant" && messages?.[messages.length - 1]?.id === message.id;
|
|
2466
2760
|
const shouldShowToolbar = toolbarVisible && hasContent && !(isRunning && isLatestAssistantMessage);
|
|
2467
2761
|
if (children) {
|
|
2468
|
-
return /* @__PURE__ */ (0,
|
|
2762
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: children({
|
|
2469
2763
|
markdownRenderer: boundMarkdownRenderer,
|
|
2470
2764
|
toolbar: boundToolbar,
|
|
2471
2765
|
toolCallsView: boundToolCallsView,
|
|
@@ -2485,7 +2779,7 @@ function CopilotChatAssistantMessage({
|
|
|
2485
2779
|
toolbarVisible: shouldShowToolbar
|
|
2486
2780
|
}) });
|
|
2487
2781
|
}
|
|
2488
|
-
return /* @__PURE__ */ (0,
|
|
2782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2489
2783
|
"div",
|
|
2490
2784
|
{
|
|
2491
2785
|
className: (0, import_tailwind_merge4.twMerge)(
|
|
@@ -2503,11 +2797,11 @@ function CopilotChatAssistantMessage({
|
|
|
2503
2797
|
);
|
|
2504
2798
|
}
|
|
2505
2799
|
((CopilotChatAssistantMessage2) => {
|
|
2506
|
-
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ (0,
|
|
2800
|
+
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_streamdown.Streamdown, { className, ...props, children: content ?? "" });
|
|
2507
2801
|
CopilotChatAssistantMessage2.Toolbar = ({
|
|
2508
2802
|
className,
|
|
2509
2803
|
...props
|
|
2510
|
-
}) => /* @__PURE__ */ (0,
|
|
2804
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2511
2805
|
"div",
|
|
2512
2806
|
{
|
|
2513
2807
|
className: (0, import_tailwind_merge4.twMerge)(
|
|
@@ -2518,8 +2812,8 @@ function CopilotChatAssistantMessage({
|
|
|
2518
2812
|
}
|
|
2519
2813
|
);
|
|
2520
2814
|
CopilotChatAssistantMessage2.ToolbarButton = ({ title, children, ...props }) => {
|
|
2521
|
-
return /* @__PURE__ */ (0,
|
|
2522
|
-
/* @__PURE__ */ (0,
|
|
2815
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Tooltip, { children: [
|
|
2816
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2523
2817
|
Button,
|
|
2524
2818
|
{
|
|
2525
2819
|
type: "button",
|
|
@@ -2529,13 +2823,13 @@ function CopilotChatAssistantMessage({
|
|
|
2529
2823
|
children
|
|
2530
2824
|
}
|
|
2531
2825
|
) }),
|
|
2532
|
-
/* @__PURE__ */ (0,
|
|
2826
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { children: title }) })
|
|
2533
2827
|
] });
|
|
2534
2828
|
};
|
|
2535
2829
|
CopilotChatAssistantMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
2536
2830
|
const config = useCopilotChatConfiguration();
|
|
2537
2831
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2538
|
-
const [copied, setCopied] = (0,
|
|
2832
|
+
const [copied, setCopied] = (0, import_react18.useState)(false);
|
|
2539
2833
|
const handleClick = (event) => {
|
|
2540
2834
|
setCopied(true);
|
|
2541
2835
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -2543,62 +2837,62 @@ function CopilotChatAssistantMessage({
|
|
|
2543
2837
|
onClick(event);
|
|
2544
2838
|
}
|
|
2545
2839
|
};
|
|
2546
|
-
return /* @__PURE__ */ (0,
|
|
2840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2547
2841
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2548
2842
|
{
|
|
2549
2843
|
title: title || labels.assistantMessageToolbarCopyMessageLabel,
|
|
2550
2844
|
onClick: handleClick,
|
|
2551
2845
|
className,
|
|
2552
2846
|
...props,
|
|
2553
|
-
children: copied ? /* @__PURE__ */ (0,
|
|
2847
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.Check, { className: "size-[18px]" }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.Copy, { className: "size-[18px]" })
|
|
2554
2848
|
}
|
|
2555
2849
|
);
|
|
2556
2850
|
};
|
|
2557
2851
|
CopilotChatAssistantMessage2.ThumbsUpButton = ({ title, ...props }) => {
|
|
2558
2852
|
const config = useCopilotChatConfiguration();
|
|
2559
2853
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2560
|
-
return /* @__PURE__ */ (0,
|
|
2854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2561
2855
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2562
2856
|
{
|
|
2563
2857
|
title: title || labels.assistantMessageToolbarThumbsUpLabel,
|
|
2564
2858
|
...props,
|
|
2565
|
-
children: /* @__PURE__ */ (0,
|
|
2859
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.ThumbsUp, { className: "size-[18px]" })
|
|
2566
2860
|
}
|
|
2567
2861
|
);
|
|
2568
2862
|
};
|
|
2569
2863
|
CopilotChatAssistantMessage2.ThumbsDownButton = ({ title, ...props }) => {
|
|
2570
2864
|
const config = useCopilotChatConfiguration();
|
|
2571
2865
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2572
|
-
return /* @__PURE__ */ (0,
|
|
2866
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2573
2867
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2574
2868
|
{
|
|
2575
2869
|
title: title || labels.assistantMessageToolbarThumbsDownLabel,
|
|
2576
2870
|
...props,
|
|
2577
|
-
children: /* @__PURE__ */ (0,
|
|
2871
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.ThumbsDown, { className: "size-[18px]" })
|
|
2578
2872
|
}
|
|
2579
2873
|
);
|
|
2580
2874
|
};
|
|
2581
2875
|
CopilotChatAssistantMessage2.ReadAloudButton = ({ title, ...props }) => {
|
|
2582
2876
|
const config = useCopilotChatConfiguration();
|
|
2583
2877
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2584
|
-
return /* @__PURE__ */ (0,
|
|
2878
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2585
2879
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2586
2880
|
{
|
|
2587
2881
|
title: title || labels.assistantMessageToolbarReadAloudLabel,
|
|
2588
2882
|
...props,
|
|
2589
|
-
children: /* @__PURE__ */ (0,
|
|
2883
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.Volume2, { className: "size-[20px]" })
|
|
2590
2884
|
}
|
|
2591
2885
|
);
|
|
2592
2886
|
};
|
|
2593
2887
|
CopilotChatAssistantMessage2.RegenerateButton = ({ title, ...props }) => {
|
|
2594
2888
|
const config = useCopilotChatConfiguration();
|
|
2595
2889
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2596
|
-
return /* @__PURE__ */ (0,
|
|
2890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2597
2891
|
CopilotChatAssistantMessage2.ToolbarButton,
|
|
2598
2892
|
{
|
|
2599
2893
|
title: title || labels.assistantMessageToolbarRegenerateLabel,
|
|
2600
2894
|
...props,
|
|
2601
|
-
children: /* @__PURE__ */ (0,
|
|
2895
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react3.RefreshCw, { className: "size-[18px]" })
|
|
2602
2896
|
}
|
|
2603
2897
|
);
|
|
2604
2898
|
};
|
|
@@ -2613,10 +2907,10 @@ CopilotChatAssistantMessage.RegenerateButton.displayName = "CopilotChatAssistant
|
|
|
2613
2907
|
var CopilotChatAssistantMessage_default = CopilotChatAssistantMessage;
|
|
2614
2908
|
|
|
2615
2909
|
// src/components/chat/CopilotChatUserMessage.tsx
|
|
2616
|
-
var
|
|
2910
|
+
var import_react19 = require("react");
|
|
2617
2911
|
var import_lucide_react4 = require("lucide-react");
|
|
2618
2912
|
var import_tailwind_merge5 = require("tailwind-merge");
|
|
2619
|
-
var
|
|
2913
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2620
2914
|
function flattenUserMessageContent(content) {
|
|
2621
2915
|
if (!content) {
|
|
2622
2916
|
return "";
|
|
@@ -2647,7 +2941,7 @@ function CopilotChatUserMessage({
|
|
|
2647
2941
|
className,
|
|
2648
2942
|
...props
|
|
2649
2943
|
}) {
|
|
2650
|
-
const flattenedContent = (0,
|
|
2944
|
+
const flattenedContent = (0, import_react19.useMemo)(
|
|
2651
2945
|
() => flattenUserMessageContent(message.content),
|
|
2652
2946
|
[message.content]
|
|
2653
2947
|
);
|
|
@@ -2692,7 +2986,7 @@ function CopilotChatUserMessage({
|
|
|
2692
2986
|
);
|
|
2693
2987
|
const showBranchNavigation = numberOfBranches && numberOfBranches > 1 && onSwitchToBranch;
|
|
2694
2988
|
const BoundToolbar = renderSlot(toolbar, CopilotChatUserMessage.Toolbar, {
|
|
2695
|
-
children: /* @__PURE__ */ (0,
|
|
2989
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1 justify-end", children: [
|
|
2696
2990
|
additionalToolbarItems,
|
|
2697
2991
|
BoundCopyButton,
|
|
2698
2992
|
onEditMessage && BoundEditButton,
|
|
@@ -2700,7 +2994,7 @@ function CopilotChatUserMessage({
|
|
|
2700
2994
|
] })
|
|
2701
2995
|
});
|
|
2702
2996
|
if (children) {
|
|
2703
|
-
return /* @__PURE__ */ (0,
|
|
2997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: children({
|
|
2704
2998
|
messageRenderer: BoundMessageRenderer,
|
|
2705
2999
|
toolbar: BoundToolbar,
|
|
2706
3000
|
copyButton: BoundCopyButton,
|
|
@@ -2712,7 +3006,7 @@ function CopilotChatUserMessage({
|
|
|
2712
3006
|
additionalToolbarItems
|
|
2713
3007
|
}) });
|
|
2714
3008
|
}
|
|
2715
|
-
return /* @__PURE__ */ (0,
|
|
3009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2716
3010
|
"div",
|
|
2717
3011
|
{
|
|
2718
3012
|
className: (0, import_tailwind_merge5.twMerge)("flex flex-col items-end group pt-10", className),
|
|
@@ -2726,7 +3020,7 @@ function CopilotChatUserMessage({
|
|
|
2726
3020
|
);
|
|
2727
3021
|
}
|
|
2728
3022
|
((CopilotChatUserMessage2) => {
|
|
2729
|
-
CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ (0,
|
|
3023
|
+
CopilotChatUserMessage2.Container = ({ children, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2730
3024
|
"div",
|
|
2731
3025
|
{
|
|
2732
3026
|
className: (0, import_tailwind_merge5.twMerge)("flex flex-col items-end group", className),
|
|
@@ -2734,7 +3028,7 @@ function CopilotChatUserMessage({
|
|
|
2734
3028
|
children
|
|
2735
3029
|
}
|
|
2736
3030
|
);
|
|
2737
|
-
CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ (0,
|
|
3031
|
+
CopilotChatUserMessage2.MessageRenderer = ({ content, className }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2738
3032
|
"div",
|
|
2739
3033
|
{
|
|
2740
3034
|
className: (0, import_tailwind_merge5.twMerge)(
|
|
@@ -2747,7 +3041,7 @@ function CopilotChatUserMessage({
|
|
|
2747
3041
|
CopilotChatUserMessage2.Toolbar = ({
|
|
2748
3042
|
className,
|
|
2749
3043
|
...props
|
|
2750
|
-
}) => /* @__PURE__ */ (0,
|
|
3044
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2751
3045
|
"div",
|
|
2752
3046
|
{
|
|
2753
3047
|
className: (0, import_tailwind_merge5.twMerge)(
|
|
@@ -2758,8 +3052,8 @@ function CopilotChatUserMessage({
|
|
|
2758
3052
|
}
|
|
2759
3053
|
);
|
|
2760
3054
|
CopilotChatUserMessage2.ToolbarButton = ({ title, children, className, ...props }) => {
|
|
2761
|
-
return /* @__PURE__ */ (0,
|
|
2762
|
-
/* @__PURE__ */ (0,
|
|
3055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Tooltip, { children: [
|
|
3056
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2763
3057
|
Button,
|
|
2764
3058
|
{
|
|
2765
3059
|
type: "button",
|
|
@@ -2770,13 +3064,13 @@ function CopilotChatUserMessage({
|
|
|
2770
3064
|
children
|
|
2771
3065
|
}
|
|
2772
3066
|
) }),
|
|
2773
|
-
/* @__PURE__ */ (0,
|
|
3067
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(TooltipContent, { side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { children: title }) })
|
|
2774
3068
|
] });
|
|
2775
3069
|
};
|
|
2776
3070
|
CopilotChatUserMessage2.CopyButton = ({ className, title, onClick, ...props }) => {
|
|
2777
3071
|
const config = useCopilotChatConfiguration();
|
|
2778
3072
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2779
|
-
const [copied, setCopied] = (0,
|
|
3073
|
+
const [copied, setCopied] = (0, import_react19.useState)(false);
|
|
2780
3074
|
const handleClick = (event) => {
|
|
2781
3075
|
setCopied(true);
|
|
2782
3076
|
setTimeout(() => setCopied(false), 2e3);
|
|
@@ -2784,27 +3078,27 @@ function CopilotChatUserMessage({
|
|
|
2784
3078
|
onClick(event);
|
|
2785
3079
|
}
|
|
2786
3080
|
};
|
|
2787
|
-
return /* @__PURE__ */ (0,
|
|
3081
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2788
3082
|
CopilotChatUserMessage2.ToolbarButton,
|
|
2789
3083
|
{
|
|
2790
3084
|
title: title || labels.userMessageToolbarCopyMessageLabel,
|
|
2791
3085
|
onClick: handleClick,
|
|
2792
3086
|
className,
|
|
2793
3087
|
...props,
|
|
2794
|
-
children: copied ? /* @__PURE__ */ (0,
|
|
3088
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Check, { className: "size-[18px]" }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Copy, { className: "size-[18px]" })
|
|
2795
3089
|
}
|
|
2796
3090
|
);
|
|
2797
3091
|
};
|
|
2798
3092
|
CopilotChatUserMessage2.EditButton = ({ className, title, ...props }) => {
|
|
2799
3093
|
const config = useCopilotChatConfiguration();
|
|
2800
3094
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
2801
|
-
return /* @__PURE__ */ (0,
|
|
3095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2802
3096
|
CopilotChatUserMessage2.ToolbarButton,
|
|
2803
3097
|
{
|
|
2804
3098
|
title: title || labels.userMessageToolbarEditMessageLabel,
|
|
2805
3099
|
className,
|
|
2806
3100
|
...props,
|
|
2807
|
-
children: /* @__PURE__ */ (0,
|
|
3101
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Edit, { className: "size-[18px]" })
|
|
2808
3102
|
}
|
|
2809
3103
|
);
|
|
2810
3104
|
};
|
|
@@ -2821,8 +3115,8 @@ function CopilotChatUserMessage({
|
|
|
2821
3115
|
}
|
|
2822
3116
|
const canGoPrev = currentBranch > 0;
|
|
2823
3117
|
const canGoNext = currentBranch < numberOfBranches - 1;
|
|
2824
|
-
return /* @__PURE__ */ (0,
|
|
2825
|
-
/* @__PURE__ */ (0,
|
|
3118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: (0, import_tailwind_merge5.twMerge)("flex items-center gap-1", className), ...props, children: [
|
|
3119
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2826
3120
|
Button,
|
|
2827
3121
|
{
|
|
2828
3122
|
type: "button",
|
|
@@ -2834,15 +3128,15 @@ function CopilotChatUserMessage({
|
|
|
2834
3128
|
}),
|
|
2835
3129
|
disabled: !canGoPrev,
|
|
2836
3130
|
className: "h-6 w-6 p-0",
|
|
2837
|
-
children: /* @__PURE__ */ (0,
|
|
3131
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.ChevronLeft, { className: "size-[20px]" })
|
|
2838
3132
|
}
|
|
2839
3133
|
),
|
|
2840
|
-
/* @__PURE__ */ (0,
|
|
3134
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "text-sm text-muted-foreground px-0 font-medium", children: [
|
|
2841
3135
|
currentBranch + 1,
|
|
2842
3136
|
"/",
|
|
2843
3137
|
numberOfBranches
|
|
2844
3138
|
] }),
|
|
2845
|
-
/* @__PURE__ */ (0,
|
|
3139
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2846
3140
|
Button,
|
|
2847
3141
|
{
|
|
2848
3142
|
type: "button",
|
|
@@ -2854,7 +3148,7 @@ function CopilotChatUserMessage({
|
|
|
2854
3148
|
}),
|
|
2855
3149
|
disabled: !canGoNext,
|
|
2856
3150
|
className: "h-6 w-6 p-0",
|
|
2857
|
-
children: /* @__PURE__ */ (0,
|
|
3151
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.ChevronRight, { className: "size-[20px]" })
|
|
2858
3152
|
}
|
|
2859
3153
|
)
|
|
2860
3154
|
] });
|
|
@@ -2870,14 +3164,14 @@ CopilotChatUserMessage.BranchNavigation.displayName = "CopilotChatUserMessage.Br
|
|
|
2870
3164
|
var CopilotChatUserMessage_default = CopilotChatUserMessage;
|
|
2871
3165
|
|
|
2872
3166
|
// src/components/chat/CopilotChatSuggestionPill.tsx
|
|
2873
|
-
var
|
|
3167
|
+
var import_react20 = __toESM(require("react"));
|
|
2874
3168
|
var import_lucide_react5 = require("lucide-react");
|
|
2875
|
-
var
|
|
3169
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2876
3170
|
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";
|
|
2877
3171
|
var labelClasses = "whitespace-nowrap font-medium leading-none";
|
|
2878
|
-
var CopilotChatSuggestionPill =
|
|
3172
|
+
var CopilotChatSuggestionPill = import_react20.default.forwardRef(function CopilotChatSuggestionPill2({ className, children, icon, isLoading, type, ...props }, ref) {
|
|
2879
3173
|
const showIcon = !isLoading && icon;
|
|
2880
|
-
return /* @__PURE__ */ (0,
|
|
3174
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
2881
3175
|
"button",
|
|
2882
3176
|
{
|
|
2883
3177
|
ref,
|
|
@@ -2888,8 +3182,8 @@ var CopilotChatSuggestionPill = import_react19.default.forwardRef(function Copil
|
|
|
2888
3182
|
disabled: isLoading || props.disabled,
|
|
2889
3183
|
...props,
|
|
2890
3184
|
children: [
|
|
2891
|
-
isLoading ? /* @__PURE__ */ (0,
|
|
2892
|
-
/* @__PURE__ */ (0,
|
|
3185
|
+
isLoading ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_lucide_react5.Loader2, { className: "h-3.5 sm:h-4 w-3.5 sm:w-4 animate-spin", "aria-hidden": "true" }) }) : showIcon && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "flex h-3.5 sm:h-4 w-3.5 sm:w-4 items-center justify-center text-muted-foreground", children: icon }),
|
|
3186
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: labelClasses, children })
|
|
2893
3187
|
]
|
|
2894
3188
|
}
|
|
2895
3189
|
);
|
|
@@ -2898,10 +3192,10 @@ CopilotChatSuggestionPill.displayName = "CopilotChatSuggestionPill";
|
|
|
2898
3192
|
var CopilotChatSuggestionPill_default = CopilotChatSuggestionPill;
|
|
2899
3193
|
|
|
2900
3194
|
// src/components/chat/CopilotChatSuggestionView.tsx
|
|
2901
|
-
var
|
|
2902
|
-
var
|
|
2903
|
-
var DefaultContainer =
|
|
2904
|
-
return /* @__PURE__ */ (0,
|
|
3195
|
+
var import_react21 = __toESM(require("react"));
|
|
3196
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3197
|
+
var DefaultContainer = import_react21.default.forwardRef(function DefaultContainer2({ className, ...props }, ref) {
|
|
3198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2905
3199
|
"div",
|
|
2906
3200
|
{
|
|
2907
3201
|
ref,
|
|
@@ -2913,7 +3207,7 @@ var DefaultContainer = import_react20.default.forwardRef(function DefaultContain
|
|
|
2913
3207
|
}
|
|
2914
3208
|
);
|
|
2915
3209
|
});
|
|
2916
|
-
var CopilotChatSuggestionView =
|
|
3210
|
+
var CopilotChatSuggestionView = import_react21.default.forwardRef(function CopilotChatSuggestionView2({
|
|
2917
3211
|
suggestions,
|
|
2918
3212
|
onSelectSuggestion,
|
|
2919
3213
|
loadingIndexes,
|
|
@@ -2923,7 +3217,7 @@ var CopilotChatSuggestionView = import_react20.default.forwardRef(function Copil
|
|
|
2923
3217
|
children,
|
|
2924
3218
|
...restProps
|
|
2925
3219
|
}, ref) {
|
|
2926
|
-
const loadingSet =
|
|
3220
|
+
const loadingSet = import_react21.default.useMemo(() => {
|
|
2927
3221
|
if (!loadingIndexes || loadingIndexes.length === 0) {
|
|
2928
3222
|
return /* @__PURE__ */ new Set();
|
|
2929
3223
|
}
|
|
@@ -2942,11 +3236,11 @@ var CopilotChatSuggestionView = import_react20.default.forwardRef(function Copil
|
|
|
2942
3236
|
type: "button",
|
|
2943
3237
|
onClick: () => onSelectSuggestion?.(suggestion, index)
|
|
2944
3238
|
});
|
|
2945
|
-
return
|
|
3239
|
+
return import_react21.default.cloneElement(pill, {
|
|
2946
3240
|
key: `${suggestion.title}-${index}`
|
|
2947
3241
|
});
|
|
2948
3242
|
});
|
|
2949
|
-
const boundContainer =
|
|
3243
|
+
const boundContainer = import_react21.default.cloneElement(
|
|
2950
3244
|
ContainerElement,
|
|
2951
3245
|
void 0,
|
|
2952
3246
|
suggestionElements
|
|
@@ -2957,7 +3251,7 @@ var CopilotChatSuggestionView = import_react20.default.forwardRef(function Copil
|
|
|
2957
3251
|
isLoading: suggestions.length > 0 ? loadingSet.has(0) || suggestions[0]?.isLoading === true : false,
|
|
2958
3252
|
type: "button"
|
|
2959
3253
|
});
|
|
2960
|
-
return /* @__PURE__ */ (0,
|
|
3254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: children({
|
|
2961
3255
|
container: boundContainer,
|
|
2962
3256
|
suggestion: sampleSuggestion,
|
|
2963
3257
|
suggestions,
|
|
@@ -2968,7 +3262,7 @@ var CopilotChatSuggestionView = import_react20.default.forwardRef(function Copil
|
|
|
2968
3262
|
}) });
|
|
2969
3263
|
}
|
|
2970
3264
|
if (children) {
|
|
2971
|
-
return /* @__PURE__ */ (0,
|
|
3265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
2972
3266
|
boundContainer,
|
|
2973
3267
|
children
|
|
2974
3268
|
] });
|
|
@@ -2979,17 +3273,17 @@ CopilotChatSuggestionView.displayName = "CopilotChatSuggestionView";
|
|
|
2979
3273
|
var CopilotChatSuggestionView_default = CopilotChatSuggestionView;
|
|
2980
3274
|
|
|
2981
3275
|
// src/components/chat/CopilotChatMessageView.tsx
|
|
2982
|
-
var
|
|
3276
|
+
var import_react22 = __toESM(require("react"));
|
|
2983
3277
|
var import_tailwind_merge6 = require("tailwind-merge");
|
|
2984
|
-
var
|
|
2985
|
-
var MemoizedAssistantMessage =
|
|
3278
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3279
|
+
var MemoizedAssistantMessage = import_react22.default.memo(
|
|
2986
3280
|
function MemoizedAssistantMessage2({
|
|
2987
3281
|
message,
|
|
2988
3282
|
messages,
|
|
2989
3283
|
isRunning,
|
|
2990
3284
|
AssistantMessageComponent
|
|
2991
3285
|
}) {
|
|
2992
|
-
return /* @__PURE__ */ (0,
|
|
3286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2993
3287
|
AssistantMessageComponent,
|
|
2994
3288
|
{
|
|
2995
3289
|
message,
|
|
@@ -3032,12 +3326,12 @@ var MemoizedAssistantMessage = import_react21.default.memo(
|
|
|
3032
3326
|
return true;
|
|
3033
3327
|
}
|
|
3034
3328
|
);
|
|
3035
|
-
var MemoizedUserMessage =
|
|
3329
|
+
var MemoizedUserMessage = import_react22.default.memo(
|
|
3036
3330
|
function MemoizedUserMessage2({
|
|
3037
3331
|
message,
|
|
3038
3332
|
UserMessageComponent
|
|
3039
3333
|
}) {
|
|
3040
|
-
return /* @__PURE__ */ (0,
|
|
3334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UserMessageComponent, { message });
|
|
3041
3335
|
},
|
|
3042
3336
|
(prevProps, nextProps) => {
|
|
3043
3337
|
if (prevProps.message.id !== nextProps.message.id) return false;
|
|
@@ -3046,7 +3340,7 @@ var MemoizedUserMessage = import_react21.default.memo(
|
|
|
3046
3340
|
return true;
|
|
3047
3341
|
}
|
|
3048
3342
|
);
|
|
3049
|
-
var MemoizedActivityMessage =
|
|
3343
|
+
var MemoizedActivityMessage = import_react22.default.memo(
|
|
3050
3344
|
function MemoizedActivityMessage2({
|
|
3051
3345
|
message,
|
|
3052
3346
|
renderActivityMessage
|
|
@@ -3060,7 +3354,7 @@ var MemoizedActivityMessage = import_react21.default.memo(
|
|
|
3060
3354
|
return true;
|
|
3061
3355
|
}
|
|
3062
3356
|
);
|
|
3063
|
-
var MemoizedCustomMessage =
|
|
3357
|
+
var MemoizedCustomMessage = import_react22.default.memo(
|
|
3064
3358
|
function MemoizedCustomMessage2({
|
|
3065
3359
|
message,
|
|
3066
3360
|
position,
|
|
@@ -3073,6 +3367,7 @@ var MemoizedCustomMessage = import_react21.default.memo(
|
|
|
3073
3367
|
if (prevProps.position !== nextProps.position) return false;
|
|
3074
3368
|
if (prevProps.message.content !== nextProps.message.content) return false;
|
|
3075
3369
|
if (prevProps.message.role !== nextProps.message.role) return false;
|
|
3370
|
+
if (JSON.stringify(prevProps.stateSnapshot) !== JSON.stringify(nextProps.stateSnapshot)) return false;
|
|
3076
3371
|
return true;
|
|
3077
3372
|
}
|
|
3078
3373
|
);
|
|
@@ -3088,16 +3383,36 @@ function CopilotChatMessageView({
|
|
|
3088
3383
|
}) {
|
|
3089
3384
|
const renderCustomMessage = useRenderCustomMessages();
|
|
3090
3385
|
const renderActivityMessage = useRenderActivityMessage();
|
|
3386
|
+
const { copilotkit } = useCopilotKit();
|
|
3387
|
+
const config = useCopilotChatConfiguration();
|
|
3388
|
+
const [, forceUpdate] = (0, import_react22.useReducer)((x) => x + 1, 0);
|
|
3389
|
+
(0, import_react22.useEffect)(() => {
|
|
3390
|
+
if (!config?.agentId) return;
|
|
3391
|
+
const agent = copilotkit.getAgent(config.agentId);
|
|
3392
|
+
if (!agent) return;
|
|
3393
|
+
const subscription = agent.subscribe({
|
|
3394
|
+
onStateChanged: () => forceUpdate()
|
|
3395
|
+
});
|
|
3396
|
+
return () => subscription.unsubscribe();
|
|
3397
|
+
}, [config?.agentId, copilotkit]);
|
|
3398
|
+
const getStateSnapshotForMessage = (messageId) => {
|
|
3399
|
+
if (!config) return void 0;
|
|
3400
|
+
const runId = copilotkit.getRunIdForMessage(config.agentId, config.threadId, messageId);
|
|
3401
|
+
if (!runId) return void 0;
|
|
3402
|
+
return copilotkit.getStateByRun(config.agentId, config.threadId, runId);
|
|
3403
|
+
};
|
|
3091
3404
|
const messageElements = messages.flatMap((message) => {
|
|
3092
3405
|
const elements = [];
|
|
3406
|
+
const stateSnapshot = getStateSnapshotForMessage(message.id);
|
|
3093
3407
|
if (renderCustomMessage) {
|
|
3094
3408
|
elements.push(
|
|
3095
|
-
/* @__PURE__ */ (0,
|
|
3409
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3096
3410
|
MemoizedCustomMessage,
|
|
3097
3411
|
{
|
|
3098
3412
|
message,
|
|
3099
3413
|
position: "before",
|
|
3100
|
-
renderCustomMessage
|
|
3414
|
+
renderCustomMessage,
|
|
3415
|
+
stateSnapshot
|
|
3101
3416
|
},
|
|
3102
3417
|
`${message.id}-custom-before`
|
|
3103
3418
|
)
|
|
@@ -3106,7 +3421,7 @@ function CopilotChatMessageView({
|
|
|
3106
3421
|
if (message.role === "assistant") {
|
|
3107
3422
|
const AssistantComponent = typeof assistantMessage === "function" ? assistantMessage : CopilotChatAssistantMessage_default;
|
|
3108
3423
|
elements.push(
|
|
3109
|
-
/* @__PURE__ */ (0,
|
|
3424
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3110
3425
|
MemoizedAssistantMessage,
|
|
3111
3426
|
{
|
|
3112
3427
|
message,
|
|
@@ -3120,7 +3435,7 @@ function CopilotChatMessageView({
|
|
|
3120
3435
|
} else if (message.role === "user") {
|
|
3121
3436
|
const UserComponent = typeof userMessage === "function" ? userMessage : CopilotChatUserMessage_default;
|
|
3122
3437
|
elements.push(
|
|
3123
|
-
/* @__PURE__ */ (0,
|
|
3438
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3124
3439
|
MemoizedUserMessage,
|
|
3125
3440
|
{
|
|
3126
3441
|
message,
|
|
@@ -3131,7 +3446,7 @@ function CopilotChatMessageView({
|
|
|
3131
3446
|
);
|
|
3132
3447
|
} else if (message.role === "activity") {
|
|
3133
3448
|
elements.push(
|
|
3134
|
-
/* @__PURE__ */ (0,
|
|
3449
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3135
3450
|
MemoizedActivityMessage,
|
|
3136
3451
|
{
|
|
3137
3452
|
message,
|
|
@@ -3143,12 +3458,13 @@ function CopilotChatMessageView({
|
|
|
3143
3458
|
}
|
|
3144
3459
|
if (renderCustomMessage) {
|
|
3145
3460
|
elements.push(
|
|
3146
|
-
/* @__PURE__ */ (0,
|
|
3461
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3147
3462
|
MemoizedCustomMessage,
|
|
3148
3463
|
{
|
|
3149
3464
|
message,
|
|
3150
3465
|
position: "after",
|
|
3151
|
-
renderCustomMessage
|
|
3466
|
+
renderCustomMessage,
|
|
3467
|
+
stateSnapshot
|
|
3152
3468
|
},
|
|
3153
3469
|
`${message.id}-custom-after`
|
|
3154
3470
|
)
|
|
@@ -3159,13 +3475,13 @@ function CopilotChatMessageView({
|
|
|
3159
3475
|
if (children) {
|
|
3160
3476
|
return children({ messageElements, messages, isRunning });
|
|
3161
3477
|
}
|
|
3162
|
-
return /* @__PURE__ */ (0,
|
|
3478
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: (0, import_tailwind_merge6.twMerge)("flex flex-col", className), ...props, children: [
|
|
3163
3479
|
messageElements,
|
|
3164
3480
|
isRunning && renderSlot(cursor, CopilotChatMessageView.Cursor, {})
|
|
3165
3481
|
] });
|
|
3166
3482
|
}
|
|
3167
3483
|
CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
3168
|
-
return /* @__PURE__ */ (0,
|
|
3484
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3169
3485
|
"div",
|
|
3170
3486
|
{
|
|
3171
3487
|
className: (0, import_tailwind_merge6.twMerge)("w-[11px] h-[11px] rounded-full bg-foreground animate-pulse-cursor ml-1", className),
|
|
@@ -3176,21 +3492,21 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
|
|
|
3176
3492
|
var CopilotChatMessageView_default = CopilotChatMessageView;
|
|
3177
3493
|
|
|
3178
3494
|
// src/components/chat/CopilotChatView.tsx
|
|
3179
|
-
var
|
|
3495
|
+
var import_react24 = __toESM(require("react"));
|
|
3180
3496
|
var import_tailwind_merge7 = require("tailwind-merge");
|
|
3181
3497
|
var import_use_stick_to_bottom = require("use-stick-to-bottom");
|
|
3182
3498
|
var import_lucide_react6 = require("lucide-react");
|
|
3183
3499
|
|
|
3184
3500
|
// src/hooks/use-keyboard-height.tsx
|
|
3185
|
-
var
|
|
3501
|
+
var import_react23 = require("react");
|
|
3186
3502
|
function useKeyboardHeight() {
|
|
3187
|
-
const [keyboardState, setKeyboardState] = (0,
|
|
3503
|
+
const [keyboardState, setKeyboardState] = (0, import_react23.useState)({
|
|
3188
3504
|
isKeyboardOpen: false,
|
|
3189
3505
|
keyboardHeight: 0,
|
|
3190
3506
|
availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
|
|
3191
3507
|
viewportHeight: typeof window !== "undefined" ? window.innerHeight : 0
|
|
3192
3508
|
});
|
|
3193
|
-
(0,
|
|
3509
|
+
(0, import_react23.useEffect)(() => {
|
|
3194
3510
|
if (typeof window === "undefined") {
|
|
3195
3511
|
return;
|
|
3196
3512
|
}
|
|
@@ -3222,7 +3538,7 @@ function useKeyboardHeight() {
|
|
|
3222
3538
|
}
|
|
3223
3539
|
|
|
3224
3540
|
// src/components/chat/CopilotChatView.tsx
|
|
3225
|
-
var
|
|
3541
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3226
3542
|
function CopilotChatView({
|
|
3227
3543
|
messageView,
|
|
3228
3544
|
input,
|
|
@@ -3243,12 +3559,12 @@ function CopilotChatView({
|
|
|
3243
3559
|
className,
|
|
3244
3560
|
...props
|
|
3245
3561
|
}) {
|
|
3246
|
-
const inputContainerRef = (0,
|
|
3247
|
-
const [inputContainerHeight, setInputContainerHeight] = (0,
|
|
3248
|
-
const [isResizing, setIsResizing] = (0,
|
|
3249
|
-
const resizeTimeoutRef = (0,
|
|
3562
|
+
const inputContainerRef = (0, import_react24.useRef)(null);
|
|
3563
|
+
const [inputContainerHeight, setInputContainerHeight] = (0, import_react24.useState)(0);
|
|
3564
|
+
const [isResizing, setIsResizing] = (0, import_react24.useState)(false);
|
|
3565
|
+
const resizeTimeoutRef = (0, import_react24.useRef)(null);
|
|
3250
3566
|
const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
|
|
3251
|
-
(0,
|
|
3567
|
+
(0, import_react24.useEffect)(() => {
|
|
3252
3568
|
const element = inputContainerRef.current;
|
|
3253
3569
|
if (!element) return;
|
|
3254
3570
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
@@ -3296,9 +3612,9 @@ function CopilotChatView({
|
|
|
3296
3612
|
scrollToBottomButton,
|
|
3297
3613
|
inputContainerHeight,
|
|
3298
3614
|
isResizing,
|
|
3299
|
-
children: /* @__PURE__ */ (0,
|
|
3615
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "max-w-3xl mx-auto", children: [
|
|
3300
3616
|
BoundMessageView,
|
|
3301
|
-
hasSuggestions ? /* @__PURE__ */ (0,
|
|
3617
|
+
hasSuggestions ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
|
|
3302
3618
|
] }) })
|
|
3303
3619
|
});
|
|
3304
3620
|
const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});
|
|
@@ -3306,8 +3622,8 @@ function CopilotChatView({
|
|
|
3306
3622
|
const BoundInputContainer = renderSlot(inputContainer, CopilotChatView.InputContainer, {
|
|
3307
3623
|
ref: inputContainerRef,
|
|
3308
3624
|
keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
|
|
3309
|
-
children: /* @__PURE__ */ (0,
|
|
3310
|
-
/* @__PURE__ */ (0,
|
|
3625
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
3626
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("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 }),
|
|
3311
3627
|
BoundDisclaimer
|
|
3312
3628
|
] })
|
|
3313
3629
|
});
|
|
@@ -3320,10 +3636,10 @@ function CopilotChatView({
|
|
|
3320
3636
|
feather: BoundFeather,
|
|
3321
3637
|
inputContainer: BoundInputContainer,
|
|
3322
3638
|
disclaimer: BoundDisclaimer,
|
|
3323
|
-
suggestionView: BoundSuggestionView ?? /* @__PURE__ */ (0,
|
|
3639
|
+
suggestionView: BoundSuggestionView ?? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, {})
|
|
3324
3640
|
});
|
|
3325
3641
|
}
|
|
3326
|
-
return /* @__PURE__ */ (0,
|
|
3642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: (0, import_tailwind_merge7.twMerge)("relative h-full", className), ...props, children: [
|
|
3327
3643
|
BoundScrollView,
|
|
3328
3644
|
BoundFeather,
|
|
3329
3645
|
BoundInputContainer
|
|
@@ -3332,9 +3648,9 @@ function CopilotChatView({
|
|
|
3332
3648
|
((CopilotChatView2) => {
|
|
3333
3649
|
const ScrollContent = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {
|
|
3334
3650
|
const { isAtBottom, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottomContext)();
|
|
3335
|
-
return /* @__PURE__ */ (0,
|
|
3336
|
-
/* @__PURE__ */ (0,
|
|
3337
|
-
!isAtBottom && !isResizing && /* @__PURE__ */ (0,
|
|
3651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
3652
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_use_stick_to_bottom.StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
|
|
3653
|
+
!isAtBottom && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3338
3654
|
"div",
|
|
3339
3655
|
{
|
|
3340
3656
|
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
@@ -3357,13 +3673,13 @@ function CopilotChatView({
|
|
|
3357
3673
|
className,
|
|
3358
3674
|
...props
|
|
3359
3675
|
}) => {
|
|
3360
|
-
const [hasMounted, setHasMounted] = (0,
|
|
3676
|
+
const [hasMounted, setHasMounted] = (0, import_react24.useState)(false);
|
|
3361
3677
|
const { scrollRef, contentRef, scrollToBottom } = (0, import_use_stick_to_bottom.useStickToBottom)();
|
|
3362
|
-
const [showScrollButton, setShowScrollButton] = (0,
|
|
3363
|
-
(0,
|
|
3678
|
+
const [showScrollButton, setShowScrollButton] = (0, import_react24.useState)(false);
|
|
3679
|
+
(0, import_react24.useEffect)(() => {
|
|
3364
3680
|
setHasMounted(true);
|
|
3365
3681
|
}, []);
|
|
3366
|
-
(0,
|
|
3682
|
+
(0, import_react24.useEffect)(() => {
|
|
3367
3683
|
if (autoScroll) return;
|
|
3368
3684
|
const scrollElement = scrollRef.current;
|
|
3369
3685
|
if (!scrollElement) return;
|
|
@@ -3381,10 +3697,10 @@ function CopilotChatView({
|
|
|
3381
3697
|
};
|
|
3382
3698
|
}, [scrollRef, autoScroll]);
|
|
3383
3699
|
if (!hasMounted) {
|
|
3384
|
-
return /* @__PURE__ */ (0,
|
|
3700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
|
|
3385
3701
|
}
|
|
3386
3702
|
if (!autoScroll) {
|
|
3387
|
-
return /* @__PURE__ */ (0,
|
|
3703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
3388
3704
|
"div",
|
|
3389
3705
|
{
|
|
3390
3706
|
ref: scrollRef,
|
|
@@ -3394,8 +3710,8 @@ function CopilotChatView({
|
|
|
3394
3710
|
),
|
|
3395
3711
|
...props,
|
|
3396
3712
|
children: [
|
|
3397
|
-
/* @__PURE__ */ (0,
|
|
3398
|
-
showScrollButton && !isResizing && /* @__PURE__ */ (0,
|
|
3713
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
|
|
3714
|
+
showScrollButton && !isResizing && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3399
3715
|
"div",
|
|
3400
3716
|
{
|
|
3401
3717
|
className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
|
|
@@ -3411,14 +3727,14 @@ function CopilotChatView({
|
|
|
3411
3727
|
}
|
|
3412
3728
|
);
|
|
3413
3729
|
}
|
|
3414
|
-
return /* @__PURE__ */ (0,
|
|
3730
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3415
3731
|
import_use_stick_to_bottom.StickToBottom,
|
|
3416
3732
|
{
|
|
3417
3733
|
className: cn("h-full max-h-full flex flex-col min-h-0 relative", className),
|
|
3418
3734
|
resize: "smooth",
|
|
3419
3735
|
initial: "smooth",
|
|
3420
3736
|
...props,
|
|
3421
|
-
children: /* @__PURE__ */ (0,
|
|
3737
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3422
3738
|
ScrollContent,
|
|
3423
3739
|
{
|
|
3424
3740
|
scrollToBottomButton,
|
|
@@ -3433,7 +3749,7 @@ function CopilotChatView({
|
|
|
3433
3749
|
CopilotChatView2.ScrollToBottomButton = ({
|
|
3434
3750
|
className,
|
|
3435
3751
|
...props
|
|
3436
|
-
}) => /* @__PURE__ */ (0,
|
|
3752
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3437
3753
|
Button,
|
|
3438
3754
|
{
|
|
3439
3755
|
variant: "outline",
|
|
@@ -3447,10 +3763,10 @@ function CopilotChatView({
|
|
|
3447
3763
|
className
|
|
3448
3764
|
),
|
|
3449
3765
|
...props,
|
|
3450
|
-
children: /* @__PURE__ */ (0,
|
|
3766
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react6.ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
|
|
3451
3767
|
}
|
|
3452
3768
|
);
|
|
3453
|
-
CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ (0,
|
|
3769
|
+
CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3454
3770
|
"div",
|
|
3455
3771
|
{
|
|
3456
3772
|
className: cn(
|
|
@@ -3463,7 +3779,7 @@ function CopilotChatView({
|
|
|
3463
3779
|
...props
|
|
3464
3780
|
}
|
|
3465
3781
|
);
|
|
3466
|
-
CopilotChatView2.InputContainer =
|
|
3782
|
+
CopilotChatView2.InputContainer = import_react24.default.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3467
3783
|
"div",
|
|
3468
3784
|
{
|
|
3469
3785
|
ref,
|
|
@@ -3481,7 +3797,7 @@ function CopilotChatView({
|
|
|
3481
3797
|
CopilotChatView2.Disclaimer = ({ className, ...props }) => {
|
|
3482
3798
|
const config = useCopilotChatConfiguration();
|
|
3483
3799
|
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
3484
|
-
return /* @__PURE__ */ (0,
|
|
3800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
3485
3801
|
"div",
|
|
3486
3802
|
{
|
|
3487
3803
|
className: cn("text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto", className),
|
|
@@ -3495,14 +3811,14 @@ var CopilotChatView_default = CopilotChatView;
|
|
|
3495
3811
|
|
|
3496
3812
|
// src/components/chat/CopilotChat.tsx
|
|
3497
3813
|
var import_shared8 = require("@copilotkitnext/shared");
|
|
3498
|
-
var
|
|
3814
|
+
var import_react25 = require("react");
|
|
3499
3815
|
var import_ts_deepmerge = require("ts-deepmerge");
|
|
3500
3816
|
var import_client = require("@ag-ui/client");
|
|
3501
|
-
var
|
|
3817
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3502
3818
|
function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen, ...props }) {
|
|
3503
3819
|
const existingConfig = useCopilotChatConfiguration();
|
|
3504
3820
|
const resolvedAgentId = agentId ?? existingConfig?.agentId ?? import_shared8.DEFAULT_AGENT_ID;
|
|
3505
|
-
const resolvedThreadId = (0,
|
|
3821
|
+
const resolvedThreadId = (0, import_react25.useMemo)(
|
|
3506
3822
|
() => threadId ?? existingConfig?.threadId ?? (0, import_shared8.randomUUID)(),
|
|
3507
3823
|
[threadId, existingConfig?.threadId]
|
|
3508
3824
|
);
|
|
@@ -3515,7 +3831,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3515
3831
|
suggestionView: providedSuggestionView,
|
|
3516
3832
|
...restProps
|
|
3517
3833
|
} = props;
|
|
3518
|
-
(0,
|
|
3834
|
+
(0, import_react25.useEffect)(() => {
|
|
3519
3835
|
const connect = async (agent2) => {
|
|
3520
3836
|
try {
|
|
3521
3837
|
await copilotkit.connectAgent({ agent: agent2 });
|
|
@@ -3531,7 +3847,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3531
3847
|
return () => {
|
|
3532
3848
|
};
|
|
3533
3849
|
}, [resolvedThreadId, agent, copilotkit, resolvedAgentId]);
|
|
3534
|
-
const onSubmitInput = (0,
|
|
3850
|
+
const onSubmitInput = (0, import_react25.useCallback)(
|
|
3535
3851
|
async (value) => {
|
|
3536
3852
|
agent.addMessage({
|
|
3537
3853
|
id: (0, import_shared8.randomUUID)(),
|
|
@@ -3546,7 +3862,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3546
3862
|
},
|
|
3547
3863
|
[agent, copilotkit]
|
|
3548
3864
|
);
|
|
3549
|
-
const handleSelectSuggestion = (0,
|
|
3865
|
+
const handleSelectSuggestion = (0, import_react25.useCallback)(
|
|
3550
3866
|
async (suggestion) => {
|
|
3551
3867
|
agent.addMessage({
|
|
3552
3868
|
id: (0, import_shared8.randomUUID)(),
|
|
@@ -3561,7 +3877,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3561
3877
|
},
|
|
3562
3878
|
[agent, copilotkit]
|
|
3563
3879
|
);
|
|
3564
|
-
const stopCurrentRun = (0,
|
|
3880
|
+
const stopCurrentRun = (0, import_react25.useCallback)(() => {
|
|
3565
3881
|
try {
|
|
3566
3882
|
copilotkit.stopAgent({ agent });
|
|
3567
3883
|
} catch (error) {
|
|
@@ -3601,7 +3917,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3601
3917
|
inputProps: finalInputProps
|
|
3602
3918
|
});
|
|
3603
3919
|
const RenderedChatView = renderSlot(chatView, CopilotChatView, finalProps);
|
|
3604
|
-
return /* @__PURE__ */ (0,
|
|
3920
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3605
3921
|
CopilotChatConfigurationProvider,
|
|
3606
3922
|
{
|
|
3607
3923
|
agentId: resolvedAgentId,
|
|
@@ -3617,17 +3933,17 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
|
|
|
3617
3933
|
})(CopilotChat || (CopilotChat = {}));
|
|
3618
3934
|
|
|
3619
3935
|
// src/components/chat/CopilotChatToggleButton.tsx
|
|
3620
|
-
var
|
|
3936
|
+
var import_react26 = __toESM(require("react"));
|
|
3621
3937
|
var import_lucide_react7 = require("lucide-react");
|
|
3622
|
-
var
|
|
3938
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3623
3939
|
var DefaultOpenIcon = ({
|
|
3624
3940
|
className,
|
|
3625
3941
|
...props
|
|
3626
|
-
}) => /* @__PURE__ */ (0,
|
|
3942
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react7.MessageCircle, { className: cn("h-6 w-6", className), strokeWidth: 1.75, fill: "currentColor", ...props });
|
|
3627
3943
|
var DefaultCloseIcon = ({
|
|
3628
3944
|
className,
|
|
3629
3945
|
...props
|
|
3630
|
-
}) => /* @__PURE__ */ (0,
|
|
3946
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react7.X, { className: cn("h-6 w-6", className), strokeWidth: 1.75, ...props });
|
|
3631
3947
|
DefaultOpenIcon.displayName = "CopilotChatToggleButton.OpenIcon";
|
|
3632
3948
|
DefaultCloseIcon.displayName = "CopilotChatToggleButton.CloseIcon";
|
|
3633
3949
|
var ICON_TRANSITION_STYLE = Object.freeze({
|
|
@@ -3644,11 +3960,11 @@ var BUTTON_BASE_CLASSES = cn(
|
|
|
3644
3960
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
3645
3961
|
"disabled:pointer-events-none disabled:opacity-60"
|
|
3646
3962
|
);
|
|
3647
|
-
var CopilotChatToggleButton =
|
|
3963
|
+
var CopilotChatToggleButton = import_react26.default.forwardRef(function CopilotChatToggleButton2({ openIcon, closeIcon, className, ...buttonProps }, ref) {
|
|
3648
3964
|
const { onClick, type, disabled, ...restProps } = buttonProps;
|
|
3649
3965
|
const configuration = useCopilotChatConfiguration();
|
|
3650
3966
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
3651
|
-
const [fallbackOpen, setFallbackOpen] = (0,
|
|
3967
|
+
const [fallbackOpen, setFallbackOpen] = (0, import_react26.useState)(false);
|
|
3652
3968
|
const isOpen = configuration?.isModalOpen ?? fallbackOpen;
|
|
3653
3969
|
const setModalOpen = configuration?.setModalOpen ?? setFallbackOpen;
|
|
3654
3970
|
const handleClick = (event) => {
|
|
@@ -3682,7 +3998,7 @@ var CopilotChatToggleButton = import_react25.default.forwardRef(function Copilot
|
|
|
3682
3998
|
focusable: false
|
|
3683
3999
|
}
|
|
3684
4000
|
);
|
|
3685
|
-
const openIconElement = /* @__PURE__ */ (0,
|
|
4001
|
+
const openIconElement = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3686
4002
|
"span",
|
|
3687
4003
|
{
|
|
3688
4004
|
"aria-hidden": "true",
|
|
@@ -3696,7 +4012,7 @@ var CopilotChatToggleButton = import_react25.default.forwardRef(function Copilot
|
|
|
3696
4012
|
children: renderedOpenIcon
|
|
3697
4013
|
}
|
|
3698
4014
|
);
|
|
3699
|
-
const closeIconElement = /* @__PURE__ */ (0,
|
|
4015
|
+
const closeIconElement = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3700
4016
|
"span",
|
|
3701
4017
|
{
|
|
3702
4018
|
"aria-hidden": "true",
|
|
@@ -3710,7 +4026,7 @@ var CopilotChatToggleButton = import_react25.default.forwardRef(function Copilot
|
|
|
3710
4026
|
children: renderedCloseIcon
|
|
3711
4027
|
}
|
|
3712
4028
|
);
|
|
3713
|
-
return /* @__PURE__ */ (0,
|
|
4029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
3714
4030
|
"button",
|
|
3715
4031
|
{
|
|
3716
4032
|
ref,
|
|
@@ -3734,12 +4050,12 @@ CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
|
|
|
3734
4050
|
var CopilotChatToggleButton_default = CopilotChatToggleButton;
|
|
3735
4051
|
|
|
3736
4052
|
// src/components/chat/CopilotSidebarView.tsx
|
|
3737
|
-
var
|
|
4053
|
+
var import_react28 = require("react");
|
|
3738
4054
|
|
|
3739
4055
|
// src/components/chat/CopilotModalHeader.tsx
|
|
3740
|
-
var
|
|
4056
|
+
var import_react27 = require("react");
|
|
3741
4057
|
var import_lucide_react8 = require("lucide-react");
|
|
3742
|
-
var
|
|
4058
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3743
4059
|
function CopilotModalHeader({
|
|
3744
4060
|
title,
|
|
3745
4061
|
titleContent,
|
|
@@ -3751,7 +4067,7 @@ function CopilotModalHeader({
|
|
|
3751
4067
|
const configuration = useCopilotChatConfiguration();
|
|
3752
4068
|
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? CopilotChatDefaultLabels.modalHeaderTitle;
|
|
3753
4069
|
const resolvedTitle = title ?? fallbackTitle;
|
|
3754
|
-
const handleClose = (0,
|
|
4070
|
+
const handleClose = (0, import_react27.useCallback)(() => {
|
|
3755
4071
|
configuration?.setModalOpen(false);
|
|
3756
4072
|
}, [configuration]);
|
|
3757
4073
|
const BoundTitle = renderSlot(titleContent, CopilotModalHeader.Title, {
|
|
@@ -3768,7 +4084,7 @@ function CopilotModalHeader({
|
|
|
3768
4084
|
...rest
|
|
3769
4085
|
});
|
|
3770
4086
|
}
|
|
3771
|
-
return /* @__PURE__ */ (0,
|
|
4087
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3772
4088
|
"header",
|
|
3773
4089
|
{
|
|
3774
4090
|
"data-slot": "copilot-modal-header",
|
|
@@ -3778,17 +4094,17 @@ function CopilotModalHeader({
|
|
|
3778
4094
|
className
|
|
3779
4095
|
),
|
|
3780
4096
|
...rest,
|
|
3781
|
-
children: /* @__PURE__ */ (0,
|
|
3782
|
-
/* @__PURE__ */ (0,
|
|
3783
|
-
/* @__PURE__ */ (0,
|
|
3784
|
-
/* @__PURE__ */ (0,
|
|
4097
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex w-full items-center gap-2", children: [
|
|
4098
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex-1", "aria-hidden": "true" }),
|
|
4099
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex flex-1 justify-center text-center", children: BoundTitle }),
|
|
4100
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex flex-1 justify-end", children: BoundCloseButton })
|
|
3785
4101
|
] })
|
|
3786
4102
|
}
|
|
3787
4103
|
);
|
|
3788
4104
|
}
|
|
3789
4105
|
CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
3790
4106
|
((CopilotModalHeader2) => {
|
|
3791
|
-
CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ (0,
|
|
4107
|
+
CopilotModalHeader2.Title = ({ children, className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3792
4108
|
"div",
|
|
3793
4109
|
{
|
|
3794
4110
|
className: cn(
|
|
@@ -3802,7 +4118,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
3802
4118
|
CopilotModalHeader2.CloseButton = ({
|
|
3803
4119
|
className,
|
|
3804
4120
|
...props
|
|
3805
|
-
}) => /* @__PURE__ */ (0,
|
|
4121
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3806
4122
|
"button",
|
|
3807
4123
|
{
|
|
3808
4124
|
type: "button",
|
|
@@ -3813,7 +4129,7 @@ CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
|
3813
4129
|
),
|
|
3814
4130
|
"aria-label": "Close",
|
|
3815
4131
|
...props,
|
|
3816
|
-
children: /* @__PURE__ */ (0,
|
|
4132
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react8.X, { className: "h-4 w-4", "aria-hidden": "true" })
|
|
3817
4133
|
}
|
|
3818
4134
|
);
|
|
3819
4135
|
})(CopilotModalHeader || (CopilotModalHeader = {}));
|
|
@@ -3821,14 +4137,14 @@ CopilotModalHeader.Title.displayName = "CopilotModalHeader.Title";
|
|
|
3821
4137
|
CopilotModalHeader.CloseButton.displayName = "CopilotModalHeader.CloseButton";
|
|
3822
4138
|
|
|
3823
4139
|
// src/components/chat/CopilotSidebarView.tsx
|
|
3824
|
-
var
|
|
4140
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3825
4141
|
var DEFAULT_SIDEBAR_WIDTH = 480;
|
|
3826
4142
|
var SIDEBAR_TRANSITION_MS = 260;
|
|
3827
4143
|
function CopilotSidebarView({ header, width, ...props }) {
|
|
3828
4144
|
const configuration = useCopilotChatConfiguration();
|
|
3829
4145
|
const isSidebarOpen = configuration?.isModalOpen ?? false;
|
|
3830
|
-
const sidebarRef = (0,
|
|
3831
|
-
const [sidebarWidth, setSidebarWidth] = (0,
|
|
4146
|
+
const sidebarRef = (0, import_react28.useRef)(null);
|
|
4147
|
+
const [sidebarWidth, setSidebarWidth] = (0, import_react28.useState)(width ?? DEFAULT_SIDEBAR_WIDTH);
|
|
3832
4148
|
const widthToCss = (w) => {
|
|
3833
4149
|
return typeof w === "number" ? `${w}px` : w;
|
|
3834
4150
|
};
|
|
@@ -3838,7 +4154,7 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3838
4154
|
}
|
|
3839
4155
|
return w;
|
|
3840
4156
|
};
|
|
3841
|
-
(0,
|
|
4157
|
+
(0, import_react28.useEffect)(() => {
|
|
3842
4158
|
if (width !== void 0) {
|
|
3843
4159
|
return;
|
|
3844
4160
|
}
|
|
@@ -3865,8 +4181,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3865
4181
|
return () => window.removeEventListener("resize", updateWidth);
|
|
3866
4182
|
}, [width]);
|
|
3867
4183
|
const headerElement = renderSlot(header, CopilotModalHeader, {});
|
|
3868
|
-
return /* @__PURE__ */ (0,
|
|
3869
|
-
isSidebarOpen && /* @__PURE__ */ (0,
|
|
4184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
4185
|
+
isSidebarOpen && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3870
4186
|
"style",
|
|
3871
4187
|
{
|
|
3872
4188
|
dangerouslySetInnerHTML: {
|
|
@@ -3880,8 +4196,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3880
4196
|
}
|
|
3881
4197
|
}
|
|
3882
4198
|
),
|
|
3883
|
-
/* @__PURE__ */ (0,
|
|
3884
|
-
/* @__PURE__ */ (0,
|
|
4199
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CopilotChatToggleButton_default, {}),
|
|
4200
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3885
4201
|
"aside",
|
|
3886
4202
|
{
|
|
3887
4203
|
ref: sidebarRef,
|
|
@@ -3906,9 +4222,9 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3906
4222
|
"aria-hidden": !isSidebarOpen,
|
|
3907
4223
|
"aria-label": "Copilot chat sidebar",
|
|
3908
4224
|
role: "complementary",
|
|
3909
|
-
children: /* @__PURE__ */ (0,
|
|
4225
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [
|
|
3910
4226
|
headerElement,
|
|
3911
|
-
/* @__PURE__ */ (0,
|
|
4227
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "flex-1 overflow-hidden", "data-sidebar-chat": true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CopilotChatView_default, { ...props }) })
|
|
3912
4228
|
] })
|
|
3913
4229
|
}
|
|
3914
4230
|
)
|
|
@@ -3917,8 +4233,8 @@ function CopilotSidebarView({ header, width, ...props }) {
|
|
|
3917
4233
|
CopilotSidebarView.displayName = "CopilotSidebarView";
|
|
3918
4234
|
|
|
3919
4235
|
// src/components/chat/CopilotPopupView.tsx
|
|
3920
|
-
var
|
|
3921
|
-
var
|
|
4236
|
+
var import_react29 = require("react");
|
|
4237
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3922
4238
|
var DEFAULT_POPUP_WIDTH = 420;
|
|
3923
4239
|
var DEFAULT_POPUP_HEIGHT = 560;
|
|
3924
4240
|
var dimensionToCss = (value, fallback) => {
|
|
@@ -3942,10 +4258,10 @@ function CopilotPopupView({
|
|
|
3942
4258
|
const isPopupOpen = configuration?.isModalOpen ?? false;
|
|
3943
4259
|
const setModalOpen = configuration?.setModalOpen;
|
|
3944
4260
|
const labels = configuration?.labels ?? CopilotChatDefaultLabels;
|
|
3945
|
-
const containerRef = (0,
|
|
3946
|
-
const [isRendered, setIsRendered] = (0,
|
|
3947
|
-
const [isAnimatingOut, setIsAnimatingOut] = (0,
|
|
3948
|
-
(0,
|
|
4261
|
+
const containerRef = (0, import_react29.useRef)(null);
|
|
4262
|
+
const [isRendered, setIsRendered] = (0, import_react29.useState)(isPopupOpen);
|
|
4263
|
+
const [isAnimatingOut, setIsAnimatingOut] = (0, import_react29.useState)(false);
|
|
4264
|
+
(0, import_react29.useEffect)(() => {
|
|
3949
4265
|
if (isPopupOpen) {
|
|
3950
4266
|
setIsRendered(true);
|
|
3951
4267
|
setIsAnimatingOut(false);
|
|
@@ -3961,7 +4277,7 @@ function CopilotPopupView({
|
|
|
3961
4277
|
}, 200);
|
|
3962
4278
|
return () => clearTimeout(timeout);
|
|
3963
4279
|
}, [isPopupOpen, isRendered]);
|
|
3964
|
-
(0,
|
|
4280
|
+
(0, import_react29.useEffect)(() => {
|
|
3965
4281
|
if (!isPopupOpen) {
|
|
3966
4282
|
return;
|
|
3967
4283
|
}
|
|
@@ -3977,7 +4293,7 @@ function CopilotPopupView({
|
|
|
3977
4293
|
window.addEventListener("keydown", handleKeyDown);
|
|
3978
4294
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
3979
4295
|
}, [isPopupOpen, setModalOpen]);
|
|
3980
|
-
(0,
|
|
4296
|
+
(0, import_react29.useEffect)(() => {
|
|
3981
4297
|
if (!isPopupOpen) {
|
|
3982
4298
|
return;
|
|
3983
4299
|
}
|
|
@@ -3986,7 +4302,7 @@ function CopilotPopupView({
|
|
|
3986
4302
|
}, 200);
|
|
3987
4303
|
return () => clearTimeout(focusTimer);
|
|
3988
4304
|
}, [isPopupOpen]);
|
|
3989
|
-
(0,
|
|
4305
|
+
(0, import_react29.useEffect)(() => {
|
|
3990
4306
|
if (!isPopupOpen || !clickOutsideToClose) {
|
|
3991
4307
|
return;
|
|
3992
4308
|
}
|
|
@@ -4011,10 +4327,10 @@ function CopilotPopupView({
|
|
|
4011
4327
|
document.addEventListener("pointerdown", handlePointerDown);
|
|
4012
4328
|
return () => document.removeEventListener("pointerdown", handlePointerDown);
|
|
4013
4329
|
}, [isPopupOpen, clickOutsideToClose, setModalOpen]);
|
|
4014
|
-
const headerElement = (0,
|
|
4330
|
+
const headerElement = (0, import_react29.useMemo)(() => renderSlot(header, CopilotModalHeader, {}), [header]);
|
|
4015
4331
|
const resolvedWidth = dimensionToCss(width, DEFAULT_POPUP_WIDTH);
|
|
4016
4332
|
const resolvedHeight = dimensionToCss(height, DEFAULT_POPUP_HEIGHT);
|
|
4017
|
-
const popupStyle = (0,
|
|
4333
|
+
const popupStyle = (0, import_react29.useMemo)(
|
|
4018
4334
|
() => ({
|
|
4019
4335
|
"--copilot-popup-width": resolvedWidth,
|
|
4020
4336
|
"--copilot-popup-height": resolvedHeight,
|
|
@@ -4028,14 +4344,14 @@ function CopilotPopupView({
|
|
|
4028
4344
|
[resolvedHeight, resolvedWidth]
|
|
4029
4345
|
);
|
|
4030
4346
|
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]";
|
|
4031
|
-
const popupContent = isRendered ? /* @__PURE__ */ (0,
|
|
4347
|
+
const popupContent = isRendered ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4032
4348
|
"div",
|
|
4033
4349
|
{
|
|
4034
4350
|
className: cn(
|
|
4035
4351
|
"fixed inset-0 z-[1200] flex max-w-full flex-col items-stretch",
|
|
4036
4352
|
"md:inset-auto md:bottom-24 md:right-6 md:items-end md:gap-4"
|
|
4037
4353
|
),
|
|
4038
|
-
children: /* @__PURE__ */ (0,
|
|
4354
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4039
4355
|
"div",
|
|
4040
4356
|
{
|
|
4041
4357
|
ref: containerRef,
|
|
@@ -4056,7 +4372,7 @@ function CopilotPopupView({
|
|
|
4056
4372
|
style: popupStyle,
|
|
4057
4373
|
children: [
|
|
4058
4374
|
headerElement,
|
|
4059
|
-
/* @__PURE__ */ (0,
|
|
4375
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "flex-1 overflow-hidden", "data-popup-chat": true, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4060
4376
|
CopilotChatView_default,
|
|
4061
4377
|
{
|
|
4062
4378
|
...restProps,
|
|
@@ -4068,21 +4384,21 @@ function CopilotPopupView({
|
|
|
4068
4384
|
)
|
|
4069
4385
|
}
|
|
4070
4386
|
) : null;
|
|
4071
|
-
return /* @__PURE__ */ (0,
|
|
4072
|
-
/* @__PURE__ */ (0,
|
|
4387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
4388
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CopilotChatToggleButton_default, {}),
|
|
4073
4389
|
popupContent
|
|
4074
4390
|
] });
|
|
4075
4391
|
}
|
|
4076
4392
|
CopilotPopupView.displayName = "CopilotPopupView";
|
|
4077
4393
|
|
|
4078
4394
|
// src/components/chat/CopilotSidebar.tsx
|
|
4079
|
-
var
|
|
4080
|
-
var
|
|
4395
|
+
var import_react30 = require("react");
|
|
4396
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4081
4397
|
function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
4082
|
-
const SidebarViewOverride = (0,
|
|
4398
|
+
const SidebarViewOverride = (0, import_react30.useMemo)(() => {
|
|
4083
4399
|
const Component = (viewProps) => {
|
|
4084
4400
|
const { header: viewHeader, width: viewWidth, ...restProps } = viewProps;
|
|
4085
|
-
return /* @__PURE__ */ (0,
|
|
4401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4086
4402
|
CopilotSidebarView,
|
|
4087
4403
|
{
|
|
4088
4404
|
...restProps,
|
|
@@ -4093,7 +4409,7 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
4093
4409
|
};
|
|
4094
4410
|
return Object.assign(Component, CopilotChatView_default);
|
|
4095
4411
|
}, [header, width]);
|
|
4096
|
-
return /* @__PURE__ */ (0,
|
|
4412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4097
4413
|
CopilotChat,
|
|
4098
4414
|
{
|
|
4099
4415
|
...chatProps,
|
|
@@ -4105,8 +4421,8 @@ function CopilotSidebar({ header, defaultOpen, width, ...chatProps }) {
|
|
|
4105
4421
|
CopilotSidebar.displayName = "CopilotSidebar";
|
|
4106
4422
|
|
|
4107
4423
|
// src/components/chat/CopilotPopup.tsx
|
|
4108
|
-
var
|
|
4109
|
-
var
|
|
4424
|
+
var import_react31 = require("react");
|
|
4425
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
4110
4426
|
function CopilotPopup({
|
|
4111
4427
|
header,
|
|
4112
4428
|
defaultOpen,
|
|
@@ -4115,7 +4431,7 @@ function CopilotPopup({
|
|
|
4115
4431
|
clickOutsideToClose,
|
|
4116
4432
|
...chatProps
|
|
4117
4433
|
}) {
|
|
4118
|
-
const PopupViewOverride = (0,
|
|
4434
|
+
const PopupViewOverride = (0, import_react31.useMemo)(() => {
|
|
4119
4435
|
const Component = (viewProps) => {
|
|
4120
4436
|
const {
|
|
4121
4437
|
header: viewHeader,
|
|
@@ -4124,7 +4440,7 @@ function CopilotPopup({
|
|
|
4124
4440
|
clickOutsideToClose: viewClickOutsideToClose,
|
|
4125
4441
|
...restProps
|
|
4126
4442
|
} = viewProps;
|
|
4127
|
-
return /* @__PURE__ */ (0,
|
|
4443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4128
4444
|
CopilotPopupView,
|
|
4129
4445
|
{
|
|
4130
4446
|
...restProps,
|
|
@@ -4137,7 +4453,7 @@ function CopilotPopup({
|
|
|
4137
4453
|
};
|
|
4138
4454
|
return Object.assign(Component, CopilotChatView_default);
|
|
4139
4455
|
}, [clickOutsideToClose, header, height, width]);
|
|
4140
|
-
return /* @__PURE__ */ (0,
|
|
4456
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4141
4457
|
CopilotChat,
|
|
4142
4458
|
{
|
|
4143
4459
|
...chatProps,
|
|
@@ -4149,9 +4465,9 @@ function CopilotPopup({
|
|
|
4149
4465
|
CopilotPopup.displayName = "CopilotPopup";
|
|
4150
4466
|
|
|
4151
4467
|
// src/types/defineToolCallRenderer.ts
|
|
4152
|
-
var
|
|
4468
|
+
var import_zod3 = require("zod");
|
|
4153
4469
|
function defineToolCallRenderer(def) {
|
|
4154
|
-
const argsSchema = def.name === "*" && !def.args ?
|
|
4470
|
+
const argsSchema = def.name === "*" && !def.args ? import_zod3.z.any() : def.args;
|
|
4155
4471
|
return {
|
|
4156
4472
|
name: def.name,
|
|
4157
4473
|
args: argsSchema,
|
|
@@ -4161,25 +4477,25 @@ function defineToolCallRenderer(def) {
|
|
|
4161
4477
|
}
|
|
4162
4478
|
|
|
4163
4479
|
// src/components/WildcardToolCallRender.tsx
|
|
4164
|
-
var
|
|
4165
|
-
var
|
|
4480
|
+
var import_react32 = require("react");
|
|
4481
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
4166
4482
|
var WildcardToolCallRender = defineToolCallRenderer({
|
|
4167
4483
|
name: "*",
|
|
4168
4484
|
render: ({ args, result, name, status }) => {
|
|
4169
|
-
const [isExpanded, setIsExpanded] = (0,
|
|
4485
|
+
const [isExpanded, setIsExpanded] = (0, import_react32.useState)(false);
|
|
4170
4486
|
const statusString = String(status);
|
|
4171
4487
|
const isActive = statusString === "inProgress" || statusString === "executing";
|
|
4172
4488
|
const isComplete = statusString === "complete";
|
|
4173
4489
|
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";
|
|
4174
|
-
return /* @__PURE__ */ (0,
|
|
4175
|
-
/* @__PURE__ */ (0,
|
|
4490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("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: [
|
|
4491
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
4176
4492
|
"div",
|
|
4177
4493
|
{
|
|
4178
4494
|
className: "flex items-center justify-between gap-3 cursor-pointer",
|
|
4179
4495
|
onClick: () => setIsExpanded(!isExpanded),
|
|
4180
4496
|
children: [
|
|
4181
|
-
/* @__PURE__ */ (0,
|
|
4182
|
-
/* @__PURE__ */ (0,
|
|
4497
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
4498
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4183
4499
|
"svg",
|
|
4184
4500
|
{
|
|
4185
4501
|
className: `h-4 w-4 text-zinc-500 dark:text-zinc-400 transition-transform ${isExpanded ? "rotate-90" : ""}`,
|
|
@@ -4187,7 +4503,7 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
4187
4503
|
viewBox: "0 0 24 24",
|
|
4188
4504
|
strokeWidth: 2,
|
|
4189
4505
|
stroke: "currentColor",
|
|
4190
|
-
children: /* @__PURE__ */ (0,
|
|
4506
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4191
4507
|
"path",
|
|
4192
4508
|
{
|
|
4193
4509
|
strokeLinecap: "round",
|
|
@@ -4197,10 +4513,10 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
4197
4513
|
)
|
|
4198
4514
|
}
|
|
4199
4515
|
),
|
|
4200
|
-
/* @__PURE__ */ (0,
|
|
4201
|
-
/* @__PURE__ */ (0,
|
|
4516
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
|
|
4517
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
|
|
4202
4518
|
] }),
|
|
4203
|
-
/* @__PURE__ */ (0,
|
|
4519
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4204
4520
|
"span",
|
|
4205
4521
|
{
|
|
4206
4522
|
className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${statusStyles}`,
|
|
@@ -4210,14 +4526,14 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
4210
4526
|
]
|
|
4211
4527
|
}
|
|
4212
4528
|
),
|
|
4213
|
-
isExpanded && /* @__PURE__ */ (0,
|
|
4214
|
-
/* @__PURE__ */ (0,
|
|
4215
|
-
/* @__PURE__ */ (0,
|
|
4216
|
-
/* @__PURE__ */ (0,
|
|
4529
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "mt-3 grid gap-4", children: [
|
|
4530
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { children: [
|
|
4531
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
|
|
4532
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("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) })
|
|
4217
4533
|
] }),
|
|
4218
|
-
result !== void 0 && /* @__PURE__ */ (0,
|
|
4219
|
-
/* @__PURE__ */ (0,
|
|
4220
|
-
/* @__PURE__ */ (0,
|
|
4534
|
+
result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { children: [
|
|
4535
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
|
|
4536
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("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) })
|
|
4221
4537
|
] })
|
|
4222
4538
|
] })
|
|
4223
4539
|
] }) });
|
|
@@ -4248,6 +4564,10 @@ var WildcardToolCallRender = defineToolCallRenderer({
|
|
|
4248
4564
|
CopilotPopupView,
|
|
4249
4565
|
CopilotSidebar,
|
|
4250
4566
|
CopilotSidebarView,
|
|
4567
|
+
MCPAppsActivityContentSchema,
|
|
4568
|
+
MCPAppsActivityRenderer,
|
|
4569
|
+
MCPAppsActivityType,
|
|
4570
|
+
UseAgentUpdate,
|
|
4251
4571
|
WildcardToolCallRender,
|
|
4252
4572
|
defineToolCallRenderer,
|
|
4253
4573
|
useAgent,
|