@copilotkit/react-ui 1.4.1-pre.6 → 1.4.2-tyler-reset-chat.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/{chunk-RS6UPR5N.mjs → chunk-2B57NCBA.mjs} +5 -1
  3. package/dist/chunk-2B57NCBA.mjs.map +1 -0
  4. package/dist/chunk-4T3TMQNJ.mjs +45 -0
  5. package/dist/chunk-4T3TMQNJ.mjs.map +1 -0
  6. package/dist/{chunk-H5CXJBR5.mjs → chunk-B6A6OMIG.mjs} +6 -2
  7. package/dist/chunk-B6A6OMIG.mjs.map +1 -0
  8. package/dist/chunk-KXE2JCUH.mjs +1 -0
  9. package/dist/chunk-KXE2JCUH.mjs.map +1 -0
  10. package/dist/{chunk-ORHE7FYT.mjs → chunk-OI5EKZPO.mjs} +110 -14
  11. package/dist/chunk-OI5EKZPO.mjs.map +1 -0
  12. package/dist/{chunk-ECPBML4L.mjs → chunk-RQRK6DEW.mjs} +2 -2
  13. package/dist/chunk-WOUWNTAV.mjs +72 -0
  14. package/dist/chunk-WOUWNTAV.mjs.map +1 -0
  15. package/dist/{chunk-TSIFZ5N5.mjs → chunk-Z2RXDT7O.mjs} +2 -2
  16. package/dist/components/chat/Chat.d.ts +50 -5
  17. package/dist/components/chat/Chat.js +260 -57
  18. package/dist/components/chat/Chat.js.map +1 -1
  19. package/dist/components/chat/Chat.mjs +7 -4
  20. package/dist/components/chat/Modal.d.ts +1 -1
  21. package/dist/components/chat/Modal.js +273 -66
  22. package/dist/components/chat/Modal.js.map +1 -1
  23. package/dist/components/chat/Modal.mjs +8 -5
  24. package/dist/components/chat/Popup.js +275 -68
  25. package/dist/components/chat/Popup.js.map +1 -1
  26. package/dist/components/chat/Popup.mjs +9 -6
  27. package/dist/components/chat/Sidebar.js +277 -70
  28. package/dist/components/chat/Sidebar.js.map +1 -1
  29. package/dist/components/chat/Sidebar.mjs +9 -6
  30. package/dist/components/chat/index.js +279 -72
  31. package/dist/components/chat/index.js.map +1 -1
  32. package/dist/components/chat/index.mjs +10 -7
  33. package/dist/components/dev-console/console.js +138 -32
  34. package/dist/components/dev-console/console.js.map +1 -1
  35. package/dist/components/dev-console/console.mjs +4 -1
  36. package/dist/components/dev-console/index.js +138 -32
  37. package/dist/components/dev-console/index.js.map +1 -1
  38. package/dist/components/dev-console/index.mjs +4 -1
  39. package/dist/components/help-modal/icons.d.ts +6 -0
  40. package/dist/components/help-modal/icons.js +70 -0
  41. package/dist/components/help-modal/icons.js.map +1 -0
  42. package/dist/components/help-modal/icons.mjs +10 -0
  43. package/dist/components/help-modal/icons.mjs.map +1 -0
  44. package/dist/components/help-modal/index.d.ts +2 -0
  45. package/dist/components/help-modal/index.js +135 -0
  46. package/dist/components/help-modal/index.js.map +1 -0
  47. package/dist/components/help-modal/index.mjs +10 -0
  48. package/dist/components/help-modal/index.mjs.map +1 -0
  49. package/dist/components/help-modal/modal.d.ts +5 -0
  50. package/dist/components/help-modal/modal.js +133 -0
  51. package/dist/components/help-modal/modal.js.map +1 -0
  52. package/dist/components/help-modal/modal.mjs +9 -0
  53. package/dist/components/help-modal/modal.mjs.map +1 -0
  54. package/dist/components/index.js +279 -72
  55. package/dist/components/index.js.map +1 -1
  56. package/dist/components/index.mjs +10 -7
  57. package/dist/index.js +283 -76
  58. package/dist/index.js.map +1 -1
  59. package/dist/index.mjs +10 -7
  60. package/package.json +7 -7
  61. package/src/components/chat/Chat.tsx +167 -8
  62. package/src/components/chat/Modal.tsx +4 -0
  63. package/src/components/dev-console/console.tsx +4 -1
  64. package/src/components/help-modal/icons.tsx +40 -0
  65. package/src/components/help-modal/index.tsx +1 -0
  66. package/src/components/help-modal/modal.tsx +91 -0
  67. package/dist/chunk-H5CXJBR5.mjs.map +0 -1
  68. package/dist/chunk-ORHE7FYT.mjs.map +0 -1
  69. package/dist/chunk-RS6UPR5N.mjs.map +0 -1
  70. /package/dist/{chunk-ECPBML4L.mjs.map → chunk-RQRK6DEW.mjs.map} +0 -0
  71. /package/dist/{chunk-TSIFZ5N5.mjs.map → chunk-Z2RXDT7O.mjs.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { CopilotChatIcons, CopilotChatLabels } from './ChatContext.js';
3
3
  import React__default from 'react';
4
- import { SystemMessageFunction } from '@copilotkit/react-core';
4
+ import { SystemMessageFunction, HintFunction } from '@copilotkit/react-core';
5
5
  import { CopilotChatSuggestion } from '../../types/suggestions.js';
6
6
  import { Message } from '@copilotkit/runtime-client-gql';
7
7
  import { MessagesProps, RenderMessageProps, InputProps, ResponseButtonProps } from './props.js';
@@ -27,6 +27,14 @@ interface CopilotChatProps {
27
27
  * A callback that gets called when a new message it submitted.
28
28
  */
29
29
  onSubmitMessage?: (message: string) => void | Promise<void>;
30
+ /**
31
+ * A custom stop generation function.
32
+ */
33
+ onStopGeneration?: OnStopGeneration;
34
+ /**
35
+ * A custom reload messages function.
36
+ */
37
+ onReloadMessages?: OnReloadMessages;
30
38
  /**
31
39
  * Icons can be used to set custom icons for the chat window.
32
40
  */
@@ -84,20 +92,57 @@ interface CopilotChatProps {
84
92
  */
85
93
  children?: React__default.ReactNode;
86
94
  }
87
- declare function CopilotChat({ instructions, onSubmitMessage, makeSystemMessage, showResponseButton, onInProgress, Messages, RenderTextMessage, RenderActionExecutionMessage, RenderAgentStateMessage, RenderResultMessage, Input, ResponseButton, className, icons, labels, }: CopilotChatProps): react_jsx_runtime.JSX.Element;
95
+ interface OnStopGenerationArguments {
96
+ /**
97
+ * The name of the currently executing agent.
98
+ */
99
+ currentAgentName: string | undefined;
100
+ /**
101
+ * The messages in the chat.
102
+ */
103
+ messages: Message[];
104
+ /**
105
+ * Set the messages in the chat.
106
+ */
107
+ setMessages: (messages: Message[]) => void;
108
+ /**
109
+ * Stop chat generation.
110
+ */
111
+ stopGeneration: () => void;
112
+ /**
113
+ * Restart the currently executing agent.
114
+ */
115
+ restartCurrentAgent: () => void;
116
+ /**
117
+ * Stop the currently executing agent.
118
+ */
119
+ stopCurrentAgent: () => void;
120
+ /**
121
+ * Run the currently executing agent.
122
+ */
123
+ runCurrentAgent: (hint?: HintFunction) => Promise<void>;
124
+ /**
125
+ * Set the state of the currently executing agent.
126
+ */
127
+ setCurrentAgentState: (state: any) => void;
128
+ }
129
+ type OnReloadMessagesArguments = OnStopGenerationArguments;
130
+ type OnStopGeneration = (args: OnStopGenerationArguments) => void;
131
+ type OnReloadMessages = (args: OnReloadMessagesArguments) => void;
132
+ declare function CopilotChat({ instructions, onSubmitMessage, makeSystemMessage, showResponseButton, onInProgress, onStopGeneration, onReloadMessages, Messages, RenderTextMessage, RenderActionExecutionMessage, RenderAgentStateMessage, RenderResultMessage, Input, ResponseButton, className, icons, labels, }: CopilotChatProps): react_jsx_runtime.JSX.Element;
88
133
  declare function WrappedCopilotChat({ children, icons, labels, className, }: {
89
134
  children: React__default.ReactNode;
90
135
  icons?: CopilotChatIcons;
91
136
  labels?: CopilotChatLabels;
92
137
  className?: string;
93
138
  }): react_jsx_runtime.JSX.Element;
94
- declare const useCopilotChatLogic: (makeSystemMessage?: SystemMessageFunction, onInProgress?: (isLoading: boolean) => void, onSubmitMessage?: (messageContent: string) => Promise<void> | void) => {
139
+ declare const useCopilotChatLogic: (makeSystemMessage?: SystemMessageFunction, onInProgress?: (isLoading: boolean) => void, onSubmitMessage?: (messageContent: string) => Promise<void> | void, onStopGeneration?: OnStopGeneration, onReloadMessages?: OnReloadMessages) => {
95
140
  visibleMessages: Message[];
96
141
  isLoading: boolean;
97
142
  currentSuggestions: CopilotChatSuggestion[];
98
143
  sendMessage: (messageContent: string) => Promise<Message>;
99
144
  stopGeneration: () => void;
100
- reloadMessages: () => Promise<void>;
145
+ reloadMessages: () => void;
101
146
  };
102
147
 
103
- export { CopilotChat, CopilotChatProps, WrappedCopilotChat, useCopilotChatLogic };
148
+ export { CopilotChat, CopilotChatProps, OnReloadMessages, OnReloadMessagesArguments, OnStopGeneration, WrappedCopilotChat, useCopilotChatLogic };
@@ -1525,7 +1525,7 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
1525
1525
  });
1526
1526
 
1527
1527
  // src/components/chat/Chat.tsx
1528
- var import_react10 = __toESM(require("react"));
1528
+ var import_react11 = __toESM(require("react"));
1529
1529
  var import_react_core8 = require("@copilotkit/react-core");
1530
1530
  var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
1531
1531
  var import_shared3 = require("@copilotkit/shared");
@@ -1664,7 +1664,7 @@ function logMessages(context) {
1664
1664
 
1665
1665
  // src/components/dev-console/console.tsx
1666
1666
  var import_react_core7 = require("@copilotkit/react-core");
1667
- var import_react8 = require("react");
1667
+ var import_react9 = require("react");
1668
1668
 
1669
1669
  // src/components/dev-console/icons.tsx
1670
1670
  var import_jsx_runtime14 = require("react/jsx-runtime");
@@ -1751,21 +1751,128 @@ var CopilotKitIcon = /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1751
1751
  );
1752
1752
 
1753
1753
  // src/components/dev-console/console.tsx
1754
- var import_react9 = require("@headlessui/react");
1754
+ var import_react10 = require("@headlessui/react");
1755
1755
  var import_shared2 = require("@copilotkit/shared");
1756
+
1757
+ // src/components/help-modal/modal.tsx
1758
+ var import_react8 = require("react");
1759
+
1760
+ // src/components/help-modal/icons.tsx
1756
1761
  var import_jsx_runtime15 = require("react/jsx-runtime");
1762
+ var LifeBuoyIcon = () => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1763
+ "svg",
1764
+ {
1765
+ xmlns: "http://www.w3.org/2000/svg",
1766
+ width: "24",
1767
+ height: "24",
1768
+ viewBox: "0 0 24 24",
1769
+ fill: "none",
1770
+ stroke: "currentColor",
1771
+ strokeWidth: "2",
1772
+ strokeLinecap: "round",
1773
+ strokeLinejoin: "round",
1774
+ className: "icon icon-tabler icons-tabler-outline icon-tabler-lifebuoy",
1775
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { transform: "translate(0, -1)", children: [
1776
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
1777
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0" }),
1778
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" }),
1779
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M15 15l3.35 3.35" }),
1780
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M9 15l-3.35 3.35" }),
1781
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M5.65 5.65l3.35 3.35" }),
1782
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M18.35 5.65l-3.35 3.35" })
1783
+ ] })
1784
+ }
1785
+ );
1786
+ var CloseIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1787
+ "svg",
1788
+ {
1789
+ xmlns: "http://www.w3.org/2000/svg",
1790
+ fill: "none",
1791
+ viewBox: "0 0 24 24",
1792
+ strokeWidth: "1.5",
1793
+ stroke: "currentColor",
1794
+ width: "20",
1795
+ height: "20",
1796
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
1797
+ }
1798
+ );
1799
+
1800
+ // src/components/help-modal/modal.tsx
1801
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1802
+ function CopilotKitHelpModal() {
1803
+ const [showHelpModal, setShowHelpModal] = (0, import_react8.useState)(false);
1804
+ const [issueDescription, setIssueDescription] = (0, import_react8.useState)("");
1805
+ const handleSubmit = () => {
1806
+ setShowHelpModal(false);
1807
+ };
1808
+ const HelpButton = () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1809
+ "button",
1810
+ {
1811
+ onClick: () => setShowHelpModal(true),
1812
+ className: "p-2 bg-transparent rounded-full shadow-lg hover:shadow-xl transition-shadow duration-300 focus:outline-none focus:ring-2 focus:ring-blue-500",
1813
+ "aria-label": "Open Help",
1814
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(LifeBuoyIcon, {})
1815
+ }
1816
+ );
1817
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
1818
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(HelpButton, {}),
1819
+ showHelpModal && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1820
+ "div",
1821
+ {
1822
+ className: "fixed inset-0 flex items-center justify-center p-4",
1823
+ style: { backgroundColor: "rgba(11, 15, 26, 0.5)", zIndex: 99 },
1824
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "bg-white rounded-lg shadow-xl max-w-md w-full p-4 flex-col relative", children: [
1825
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1826
+ "button",
1827
+ {
1828
+ className: "absolute text-gray-400 hover:text-gray-600 focus:outline-none",
1829
+ style: { top: "10px", right: "10px" },
1830
+ onClick: () => setShowHelpModal(false),
1831
+ "aria-label": "Close",
1832
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CloseIcon2, {})
1833
+ }
1834
+ ),
1835
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "w-full flex mb-6 justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h2", { className: "text-2xl font-bold", children: "Help Options" }) }),
1836
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-4 mb-4", children: [
1837
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "block w-full text-center py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-150 text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1838
+ "a",
1839
+ {
1840
+ href: "https://go.copilotkit.ai/dev-console-support-discord",
1841
+ target: "_blank",
1842
+ rel: "noopener noreferrer",
1843
+ children: "Go to Discord Support Channel (Community Support)"
1844
+ }
1845
+ ) }),
1846
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "block w-full text-center py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-150 text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1847
+ "a",
1848
+ {
1849
+ href: "https://go.copilotkit.ai/dev-console-support-slack",
1850
+ target: "_blank",
1851
+ rel: "noopener noreferrer",
1852
+ children: "Apply for Priority Direct Slack Support"
1853
+ }
1854
+ ) })
1855
+ ] })
1856
+ ] })
1857
+ }
1858
+ )
1859
+ ] });
1860
+ }
1861
+
1862
+ // src/components/dev-console/console.tsx
1863
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1757
1864
  function CopilotDevConsole() {
1758
1865
  const currentVersion = import_shared2.COPILOTKIT_VERSION;
1759
1866
  const context = (0, import_react_core7.useCopilotContext)();
1760
- const [showDevConsole, setShowDevConsole] = (0, import_react8.useState)(false);
1761
- (0, import_react8.useEffect)(() => {
1867
+ const [showDevConsole, setShowDevConsole] = (0, import_react9.useState)(false);
1868
+ (0, import_react9.useEffect)(() => {
1762
1869
  setShowDevConsole(shouldShowDevConsole(context.showDevConsole));
1763
1870
  }, [context.showDevConsole]);
1764
- const dontRunTwiceInDevMode = (0, import_react8.useRef)(false);
1765
- const [versionStatus, setVersionStatus] = (0, import_react8.useState)("unknown");
1766
- const [latestVersion, setLatestVersion] = (0, import_react8.useState)("");
1767
- const consoleRef = (0, import_react8.useRef)(null);
1768
- const [debugButtonMode, setDebugButtonMode] = (0, import_react8.useState)("full");
1871
+ const dontRunTwiceInDevMode = (0, import_react9.useRef)(false);
1872
+ const [versionStatus, setVersionStatus] = (0, import_react9.useState)("unknown");
1873
+ const [latestVersion, setLatestVersion] = (0, import_react9.useState)("");
1874
+ const consoleRef = (0, import_react9.useRef)(null);
1875
+ const [debugButtonMode, setDebugButtonMode] = (0, import_react9.useState)("full");
1769
1876
  const checkForUpdates = (force = false) => {
1770
1877
  setVersionStatus("checking");
1771
1878
  getPublishedCopilotKitVersion(currentVersion, force).then((v) => {
@@ -1788,14 +1895,14 @@ function CopilotDevConsole() {
1788
1895
  setVersionStatus("unknown");
1789
1896
  });
1790
1897
  };
1791
- (0, import_react8.useEffect)(() => {
1898
+ (0, import_react9.useEffect)(() => {
1792
1899
  if (dontRunTwiceInDevMode.current === true) {
1793
1900
  return;
1794
1901
  }
1795
1902
  dontRunTwiceInDevMode.current = true;
1796
1903
  checkForUpdates();
1797
1904
  }, []);
1798
- (0, import_react8.useEffect)(() => {
1905
+ (0, import_react9.useEffect)(() => {
1799
1906
  const handleResize = (entries) => {
1800
1907
  for (let entry of entries) {
1801
1908
  if (entry.target === consoleRef.current) {
@@ -1827,14 +1934,14 @@ function CopilotDevConsole() {
1827
1934
  if (!showDevConsole) {
1828
1935
  return null;
1829
1936
  }
1830
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1937
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1831
1938
  "div",
1832
1939
  {
1833
1940
  ref: consoleRef,
1834
1941
  className: "copilotKitDevConsole " + (versionStatus === "update-available" ? "copilotKitDevConsoleUpgrade" : "") + (versionStatus === "outdated" ? "copilotKitDevConsoleWarnOutdated" : ""),
1835
1942
  children: [
1836
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "copilotKitDevConsoleLogo", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("a", { href: "https://copilotkit.ai", target: "_blank", children: CopilotKitIcon }) }),
1837
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1943
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "copilotKitDevConsoleLogo", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("a", { href: "https://copilotkit.ai", target: "_blank", children: CopilotKitIcon }) }),
1944
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1838
1945
  VersionInfo,
1839
1946
  {
1840
1947
  showDevConsole: context.showDevConsole,
@@ -1843,7 +1950,8 @@ function CopilotDevConsole() {
1843
1950
  latestVersion
1844
1951
  }
1845
1952
  ),
1846
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1953
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CopilotKitHelpModal, {}),
1954
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1847
1955
  DebugMenuButton,
1848
1956
  {
1849
1957
  setShowDevConsole,
@@ -1861,7 +1969,7 @@ function VersionInfo({
1861
1969
  currentVersion,
1862
1970
  latestVersion
1863
1971
  }) {
1864
- const [copyStatus, setCopyStatus] = (0, import_react8.useState)("");
1972
+ const [copyStatus, setCopyStatus] = (0, import_react9.useState)("");
1865
1973
  let versionLabel = "";
1866
1974
  let versionIcon = "";
1867
1975
  let currentVersionLabel = currentVersion;
@@ -1898,12 +2006,12 @@ function VersionInfo({
1898
2006
  setTimeout(() => setCopyStatus(""), 1e3);
1899
2007
  });
1900
2008
  };
1901
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "copilotKitVersionInfo", children: [
1902
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("header", { children: [
2009
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "copilotKitVersionInfo", children: [
2010
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("header", { children: [
1903
2011
  "COPILOTKIT DEV CONSOLE",
1904
- showDevConsole === "auto" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("aside", { children: asideLabel })
2012
+ showDevConsole === "auto" && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("aside", { children: asideLabel })
1905
2013
  ] }),
1906
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("section", { children: [
2014
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("section", { children: [
1907
2015
  "Version: ",
1908
2016
  versionLabel,
1909
2017
  " (",
@@ -1911,7 +2019,7 @@ function VersionInfo({
1911
2019
  ") ",
1912
2020
  versionIcon
1913
2021
  ] }),
1914
- (versionStatus === "update-available" || versionStatus === "outdated") && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("footer", { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { onClick: handleCopyClick, children: copyStatus || installCommand }) })
2022
+ (versionStatus === "update-available" || versionStatus === "outdated") && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { onClick: handleCopyClick, children: copyStatus || installCommand }) })
1915
2023
  ] });
1916
2024
  }
1917
2025
  function DebugMenuButton({
@@ -1921,22 +2029,22 @@ function DebugMenuButton({
1921
2029
  }) {
1922
2030
  const context = (0, import_react_core7.useCopilotContext)();
1923
2031
  const messagesContext = (0, import_react_core7.useCopilotMessagesContext)();
1924
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "bg-black top-24 w-52 text-right", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react9.Menu, { children: [
1925
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react9.MenuButton, { className: `copilotKitDebugMenuButton ${mode === "compact" ? "compact" : ""}`, children: mode == "compact" ? "Debug" : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
2032
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "bg-black top-24 w-52 text-right", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react10.Menu, { children: [
2033
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react10.MenuButton, { className: `copilotKitDebugMenuButton ${mode === "compact" ? "compact" : ""}`, children: mode == "compact" ? "Debug" : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
1926
2034
  "Debug ",
1927
2035
  ChevronDownIcon
1928
2036
  ] }) }),
1929
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1930
- import_react9.MenuItems,
2037
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2038
+ import_react10.MenuItems,
1931
2039
  {
1932
2040
  transition: true,
1933
2041
  anchor: "bottom end",
1934
2042
  className: "copilotKitDebugMenu",
1935
2043
  style: { zIndex: 40 },
1936
2044
  children: [
1937
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react9.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logReadables(context), children: "Log Readables" }) }),
1938
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react9.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logActions(context), children: "Log Actions" }) }),
1939
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react9.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2045
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logReadables(context), children: "Log Readables" }) }),
2046
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logActions(context), children: "Log Actions" }) }),
2047
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1940
2048
  "button",
1941
2049
  {
1942
2050
  className: "copilotKitDebugMenuItem",
@@ -1944,9 +2052,9 @@ function DebugMenuButton({
1944
2052
  children: "Log Messages"
1945
2053
  }
1946
2054
  ) }),
1947
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react9.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => checkForUpdates(true), children: "Check for Updates" }) }),
1948
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("hr", {}),
1949
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react9.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => setShowDevConsole(false), children: "Hide Dev Console" }) })
2055
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => checkForUpdates(true), children: "Check for Updates" }) }),
2056
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("hr", {}),
2057
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => setShowDevConsole(false), children: "Hide Dev Console" }) })
1950
2058
  ]
1951
2059
  }
1952
2060
  )
@@ -1954,13 +2062,16 @@ function DebugMenuButton({
1954
2062
  }
1955
2063
 
1956
2064
  // src/components/chat/Chat.tsx
1957
- var import_jsx_runtime16 = require("react/jsx-runtime");
2065
+ var import_react_core9 = require("@copilotkit/react-core");
2066
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1958
2067
  function CopilotChat({
1959
2068
  instructions,
1960
2069
  onSubmitMessage,
1961
2070
  makeSystemMessage,
1962
2071
  showResponseButton = true,
1963
2072
  onInProgress,
2073
+ onStopGeneration,
2074
+ onReloadMessages,
1964
2075
  Messages: Messages2 = Messages,
1965
2076
  RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
1966
2077
  RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
@@ -1973,7 +2084,7 @@ function CopilotChat({
1973
2084
  labels
1974
2085
  }) {
1975
2086
  const context = (0, import_react_core8.useCopilotContext)();
1976
- (0, import_react10.useEffect)(() => {
2087
+ (0, import_react11.useEffect)(() => {
1977
2088
  context.setChatInstructions(instructions || "");
1978
2089
  }, [instructions]);
1979
2090
  const {
@@ -1983,12 +2094,18 @@ function CopilotChat({
1983
2094
  sendMessage,
1984
2095
  stopGeneration,
1985
2096
  reloadMessages
1986
- } = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);
1987
- const chatContext = import_react10.default.useContext(ChatContext);
2097
+ } = useCopilotChatLogic(
2098
+ makeSystemMessage,
2099
+ onInProgress,
2100
+ onSubmitMessage,
2101
+ onStopGeneration,
2102
+ onReloadMessages
2103
+ );
2104
+ const chatContext = import_react11.default.useContext(ChatContext);
1988
2105
  const isVisible = chatContext ? chatContext.open : true;
1989
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
1990
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CopilotDevConsole, {}),
1991
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2106
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2107
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CopilotDevConsole, {}),
2108
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1992
2109
  Messages2,
1993
2110
  {
1994
2111
  RenderTextMessage: RenderTextMessage2,
@@ -1998,9 +2115,9 @@ function CopilotChat({
1998
2115
  messages: visibleMessages,
1999
2116
  inProgress: isLoading,
2000
2117
  children: [
2001
- currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { children: [
2002
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h6", { children: "Suggested:" }),
2003
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2118
+ currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { children: [
2119
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h6", { children: "Suggested:" }),
2120
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2004
2121
  Suggestion,
2005
2122
  {
2006
2123
  title: suggestion.title,
@@ -2012,7 +2129,7 @@ function CopilotChat({
2012
2129
  index
2013
2130
  )) })
2014
2131
  ] }),
2015
- showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2132
+ showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2016
2133
  ResponseButton2,
2017
2134
  {
2018
2135
  onClick: isLoading ? stopGeneration : reloadMessages,
@@ -2022,7 +2139,7 @@ function CopilotChat({
2022
2139
  ]
2023
2140
  }
2024
2141
  ),
2025
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Input2, { inProgress: isLoading, onSend: sendMessage, isVisible })
2142
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Input2, { inProgress: isLoading, onSend: sendMessage, isVisible })
2026
2143
  ] });
2027
2144
  }
2028
2145
  function WrappedCopilotChat({
@@ -2031,31 +2148,38 @@ function WrappedCopilotChat({
2031
2148
  labels,
2032
2149
  className
2033
2150
  }) {
2034
- const chatContext = import_react10.default.useContext(ChatContext);
2151
+ const chatContext = import_react11.default.useContext(ChatContext);
2035
2152
  if (!chatContext) {
2036
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2037
- }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: `copilotKitChat ${className}`, children }) });
2153
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2154
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: `copilotKitChat ${className}`, children }) });
2038
2155
  }
2039
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children });
2156
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
2040
2157
  }
2041
2158
  var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
2042
- var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
2043
- const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = (0, import_react_core8.useCopilotChat)({
2159
+ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
2160
+ var _a;
2161
+ const {
2162
+ visibleMessages,
2163
+ appendMessage,
2164
+ reloadMessages: defaultReloadMessages,
2165
+ stopGeneration: defaultStopGeneration,
2166
+ isLoading
2167
+ } = (0, import_react_core8.useCopilotChat)({
2044
2168
  id: (0, import_shared3.randomId)(),
2045
2169
  makeSystemMessage
2046
2170
  });
2047
- const [currentSuggestions, setCurrentSuggestions] = (0, import_react10.useState)([]);
2048
- const suggestionsAbortControllerRef = (0, import_react10.useRef)(null);
2049
- const debounceTimerRef = (0, import_react10.useRef)();
2171
+ const [currentSuggestions, setCurrentSuggestions] = (0, import_react11.useState)([]);
2172
+ const suggestionsAbortControllerRef = (0, import_react11.useRef)(null);
2173
+ const debounceTimerRef = (0, import_react11.useRef)();
2050
2174
  const abortSuggestions = () => {
2051
- var _a;
2052
- (_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
2175
+ var _a2;
2176
+ (_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
2053
2177
  suggestionsAbortControllerRef.current = null;
2054
2178
  };
2055
2179
  const generalContext = (0, import_react_core8.useCopilotContext)();
2056
2180
  const messagesContext = (0, import_react_core8.useCopilotMessagesContext)();
2057
2181
  const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
2058
- (0, import_react10.useEffect)(() => {
2182
+ (0, import_react11.useEffect)(() => {
2059
2183
  onInProgress == null ? void 0 : onInProgress(isLoading);
2060
2184
  abortSuggestions();
2061
2185
  debounceTimerRef.current = setTimeout(
@@ -2075,7 +2199,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
2075
2199
  return () => {
2076
2200
  clearTimeout(debounceTimerRef.current);
2077
2201
  };
2078
- }, [isLoading, context.chatSuggestionConfiguration]);
2202
+ }, [
2203
+ isLoading,
2204
+ context.chatSuggestionConfiguration,
2205
+ // hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
2206
+ // global context
2207
+ visibleMessages.length == 0
2208
+ ]);
2079
2209
  const sendMessage = (messageContent) => __async(void 0, null, function* () {
2080
2210
  abortSuggestions();
2081
2211
  setCurrentSuggestions([]);
@@ -2093,6 +2223,79 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
2093
2223
  appendMessage(message);
2094
2224
  return message;
2095
2225
  });
2226
+ const messages = visibleMessages;
2227
+ const { setMessages } = messagesContext;
2228
+ const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
2229
+ const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
2230
+ if (generalContext.agentSession) {
2231
+ generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
2232
+ nodeName: void 0,
2233
+ threadId: void 0
2234
+ }));
2235
+ generalContext.setCoagentStates((prevAgentStates) => {
2236
+ return __spreadProps(__spreadValues({}, prevAgentStates), {
2237
+ [generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
2238
+ threadId: void 0,
2239
+ nodeName: void 0,
2240
+ runId: void 0
2241
+ })
2242
+ });
2243
+ });
2244
+ }
2245
+ });
2246
+ const runCurrentAgent = (hint) => __async(void 0, null, function* () {
2247
+ if (generalContext.agentSession) {
2248
+ yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
2249
+ }
2250
+ });
2251
+ const stopCurrentAgent = () => {
2252
+ if (generalContext.agentSession) {
2253
+ (0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
2254
+ }
2255
+ };
2256
+ const setCurrentAgentState = (state) => {
2257
+ if (generalContext.agentSession) {
2258
+ generalContext.setCoagentStates((prevAgentStates) => {
2259
+ return __spreadProps(__spreadValues({}, prevAgentStates), {
2260
+ [generalContext.agentSession.agentName]: {
2261
+ state
2262
+ }
2263
+ });
2264
+ });
2265
+ }
2266
+ };
2267
+ function stopGeneration() {
2268
+ if (onStopGeneration) {
2269
+ onStopGeneration({
2270
+ messages,
2271
+ setMessages,
2272
+ stopGeneration: defaultStopGeneration,
2273
+ currentAgentName,
2274
+ restartCurrentAgent,
2275
+ stopCurrentAgent,
2276
+ runCurrentAgent,
2277
+ setCurrentAgentState
2278
+ });
2279
+ } else {
2280
+ defaultStopGeneration();
2281
+ }
2282
+ }
2283
+ function reloadMessages() {
2284
+ if (onReloadMessages) {
2285
+ onReloadMessages({
2286
+ messages,
2287
+ setMessages,
2288
+ stopGeneration: defaultStopGeneration,
2289
+ currentAgentName,
2290
+ restartCurrentAgent,
2291
+ stopCurrentAgent,
2292
+ runCurrentAgent,
2293
+ setCurrentAgentState
2294
+ });
2295
+ } else {
2296
+ defaultReloadMessages();
2297
+ }
2298
+ }
2096
2299
  return {
2097
2300
  visibleMessages,
2098
2301
  isLoading,