@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,19 +1,22 @@
1
1
  import {
2
2
  CopilotSidebar
3
- } from "../../chunk-ECPBML4L.mjs";
4
- import "../../chunk-H5CXJBR5.mjs";
3
+ } from "../../chunk-RQRK6DEW.mjs";
4
+ import "../../chunk-B6A6OMIG.mjs";
5
5
  import "../../chunk-YAGE7RCE.mjs";
6
6
  import "../../chunk-VEC45H6Q.mjs";
7
7
  import "../../chunk-RQNJNK2W.mjs";
8
- import "../../chunk-ORHE7FYT.mjs";
8
+ import "../../chunk-OI5EKZPO.mjs";
9
+ import "../../chunk-6INMITFA.mjs";
10
+ import "../../chunk-RU73BEZM.mjs";
9
11
  import "../../chunk-V7W6IM2V.mjs";
10
12
  import "../../chunk-OMTPWC7T.mjs";
11
13
  import "../../chunk-ZABXREBH.mjs";
12
- import "../../chunk-6INMITFA.mjs";
13
- import "../../chunk-RU73BEZM.mjs";
14
14
  import "../../chunk-RJCZRKTV.mjs";
15
- import "../../chunk-RS6UPR5N.mjs";
15
+ import "../../chunk-2B57NCBA.mjs";
16
16
  import "../../chunk-4FIGRRFS.mjs";
17
+ import "../../chunk-KXE2JCUH.mjs";
18
+ import "../../chunk-WOUWNTAV.mjs";
19
+ import "../../chunk-4T3TMQNJ.mjs";
17
20
  import "../../chunk-OTPAZXVR.mjs";
18
21
  import "../../chunk-4LUMV4YO.mjs";
19
22
  import "../../chunk-YQFVRDNC.mjs";
@@ -87,7 +87,7 @@ __export(chat_exports, {
87
87
  module.exports = __toCommonJS(chat_exports);
88
88
 
89
89
  // src/components/chat/Modal.tsx
90
- var import_react12 = __toESM(require("react"));
90
+ var import_react13 = __toESM(require("react"));
91
91
 
92
92
  // src/components/chat/ChatContext.tsx
93
93
  var import_react = __toESM(require("react"));
@@ -1666,7 +1666,7 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
1666
1666
  });
1667
1667
 
1668
1668
  // src/components/chat/Chat.tsx
1669
- var import_react11 = __toESM(require("react"));
1669
+ var import_react12 = __toESM(require("react"));
1670
1670
  var import_react_core8 = require("@copilotkit/react-core");
1671
1671
  var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
1672
1672
  var import_shared3 = require("@copilotkit/shared");
@@ -1805,7 +1805,7 @@ function logMessages(context) {
1805
1805
 
1806
1806
  // src/components/dev-console/console.tsx
1807
1807
  var import_react_core7 = require("@copilotkit/react-core");
1808
- var import_react9 = require("react");
1808
+ var import_react10 = require("react");
1809
1809
 
1810
1810
  // src/components/dev-console/icons.tsx
1811
1811
  var import_jsx_runtime17 = require("react/jsx-runtime");
@@ -1892,21 +1892,128 @@ var CopilotKitIcon = /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1892
1892
  );
1893
1893
 
1894
1894
  // src/components/dev-console/console.tsx
1895
- var import_react10 = require("@headlessui/react");
1895
+ var import_react11 = require("@headlessui/react");
1896
1896
  var import_shared2 = require("@copilotkit/shared");
1897
+
1898
+ // src/components/help-modal/modal.tsx
1899
+ var import_react9 = require("react");
1900
+
1901
+ // src/components/help-modal/icons.tsx
1897
1902
  var import_jsx_runtime18 = require("react/jsx-runtime");
1903
+ var LifeBuoyIcon = () => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1904
+ "svg",
1905
+ {
1906
+ xmlns: "http://www.w3.org/2000/svg",
1907
+ width: "24",
1908
+ height: "24",
1909
+ viewBox: "0 0 24 24",
1910
+ fill: "none",
1911
+ stroke: "currentColor",
1912
+ strokeWidth: "2",
1913
+ strokeLinecap: "round",
1914
+ strokeLinejoin: "round",
1915
+ className: "icon icon-tabler icons-tabler-outline icon-tabler-lifebuoy",
1916
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("g", { transform: "translate(0, -1)", children: [
1917
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
1918
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0" }),
1919
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" }),
1920
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M15 15l3.35 3.35" }),
1921
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M9 15l-3.35 3.35" }),
1922
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M5.65 5.65l3.35 3.35" }),
1923
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M18.35 5.65l-3.35 3.35" })
1924
+ ] })
1925
+ }
1926
+ );
1927
+ var CloseIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1928
+ "svg",
1929
+ {
1930
+ xmlns: "http://www.w3.org/2000/svg",
1931
+ fill: "none",
1932
+ viewBox: "0 0 24 24",
1933
+ strokeWidth: "1.5",
1934
+ stroke: "currentColor",
1935
+ width: "20",
1936
+ height: "20",
1937
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
1938
+ }
1939
+ );
1940
+
1941
+ // src/components/help-modal/modal.tsx
1942
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1943
+ function CopilotKitHelpModal() {
1944
+ const [showHelpModal, setShowHelpModal] = (0, import_react9.useState)(false);
1945
+ const [issueDescription, setIssueDescription] = (0, import_react9.useState)("");
1946
+ const handleSubmit = () => {
1947
+ setShowHelpModal(false);
1948
+ };
1949
+ const HelpButton = () => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1950
+ "button",
1951
+ {
1952
+ onClick: () => setShowHelpModal(true),
1953
+ 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",
1954
+ "aria-label": "Open Help",
1955
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LifeBuoyIcon, {})
1956
+ }
1957
+ );
1958
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
1959
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(HelpButton, {}),
1960
+ showHelpModal && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1961
+ "div",
1962
+ {
1963
+ className: "fixed inset-0 flex items-center justify-center p-4",
1964
+ style: { backgroundColor: "rgba(11, 15, 26, 0.5)", zIndex: 99 },
1965
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "bg-white rounded-lg shadow-xl max-w-md w-full p-4 flex-col relative", children: [
1966
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1967
+ "button",
1968
+ {
1969
+ className: "absolute text-gray-400 hover:text-gray-600 focus:outline-none",
1970
+ style: { top: "10px", right: "10px" },
1971
+ onClick: () => setShowHelpModal(false),
1972
+ "aria-label": "Close",
1973
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CloseIcon2, {})
1974
+ }
1975
+ ),
1976
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w-full flex mb-6 justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h2", { className: "text-2xl font-bold", children: "Help Options" }) }),
1977
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-4 mb-4", children: [
1978
+ /* @__PURE__ */ (0, import_jsx_runtime19.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_runtime19.jsx)(
1979
+ "a",
1980
+ {
1981
+ href: "https://go.copilotkit.ai/dev-console-support-discord",
1982
+ target: "_blank",
1983
+ rel: "noopener noreferrer",
1984
+ children: "Go to Discord Support Channel (Community Support)"
1985
+ }
1986
+ ) }),
1987
+ /* @__PURE__ */ (0, import_jsx_runtime19.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_runtime19.jsx)(
1988
+ "a",
1989
+ {
1990
+ href: "https://go.copilotkit.ai/dev-console-support-slack",
1991
+ target: "_blank",
1992
+ rel: "noopener noreferrer",
1993
+ children: "Apply for Priority Direct Slack Support"
1994
+ }
1995
+ ) })
1996
+ ] })
1997
+ ] })
1998
+ }
1999
+ )
2000
+ ] });
2001
+ }
2002
+
2003
+ // src/components/dev-console/console.tsx
2004
+ var import_jsx_runtime20 = require("react/jsx-runtime");
1898
2005
  function CopilotDevConsole() {
1899
2006
  const currentVersion = import_shared2.COPILOTKIT_VERSION;
1900
2007
  const context = (0, import_react_core7.useCopilotContext)();
1901
- const [showDevConsole, setShowDevConsole] = (0, import_react9.useState)(false);
1902
- (0, import_react9.useEffect)(() => {
2008
+ const [showDevConsole, setShowDevConsole] = (0, import_react10.useState)(false);
2009
+ (0, import_react10.useEffect)(() => {
1903
2010
  setShowDevConsole(shouldShowDevConsole(context.showDevConsole));
1904
2011
  }, [context.showDevConsole]);
1905
- const dontRunTwiceInDevMode = (0, import_react9.useRef)(false);
1906
- const [versionStatus, setVersionStatus] = (0, import_react9.useState)("unknown");
1907
- const [latestVersion, setLatestVersion] = (0, import_react9.useState)("");
1908
- const consoleRef = (0, import_react9.useRef)(null);
1909
- const [debugButtonMode, setDebugButtonMode] = (0, import_react9.useState)("full");
2012
+ const dontRunTwiceInDevMode = (0, import_react10.useRef)(false);
2013
+ const [versionStatus, setVersionStatus] = (0, import_react10.useState)("unknown");
2014
+ const [latestVersion, setLatestVersion] = (0, import_react10.useState)("");
2015
+ const consoleRef = (0, import_react10.useRef)(null);
2016
+ const [debugButtonMode, setDebugButtonMode] = (0, import_react10.useState)("full");
1910
2017
  const checkForUpdates = (force = false) => {
1911
2018
  setVersionStatus("checking");
1912
2019
  getPublishedCopilotKitVersion(currentVersion, force).then((v) => {
@@ -1929,14 +2036,14 @@ function CopilotDevConsole() {
1929
2036
  setVersionStatus("unknown");
1930
2037
  });
1931
2038
  };
1932
- (0, import_react9.useEffect)(() => {
2039
+ (0, import_react10.useEffect)(() => {
1933
2040
  if (dontRunTwiceInDevMode.current === true) {
1934
2041
  return;
1935
2042
  }
1936
2043
  dontRunTwiceInDevMode.current = true;
1937
2044
  checkForUpdates();
1938
2045
  }, []);
1939
- (0, import_react9.useEffect)(() => {
2046
+ (0, import_react10.useEffect)(() => {
1940
2047
  const handleResize = (entries) => {
1941
2048
  for (let entry of entries) {
1942
2049
  if (entry.target === consoleRef.current) {
@@ -1968,14 +2075,14 @@ function CopilotDevConsole() {
1968
2075
  if (!showDevConsole) {
1969
2076
  return null;
1970
2077
  }
1971
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2078
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
1972
2079
  "div",
1973
2080
  {
1974
2081
  ref: consoleRef,
1975
2082
  className: "copilotKitDevConsole " + (versionStatus === "update-available" ? "copilotKitDevConsoleUpgrade" : "") + (versionStatus === "outdated" ? "copilotKitDevConsoleWarnOutdated" : ""),
1976
2083
  children: [
1977
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "copilotKitDevConsoleLogo", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("a", { href: "https://copilotkit.ai", target: "_blank", children: CopilotKitIcon }) }),
1978
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2084
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "copilotKitDevConsoleLogo", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("a", { href: "https://copilotkit.ai", target: "_blank", children: CopilotKitIcon }) }),
2085
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1979
2086
  VersionInfo,
1980
2087
  {
1981
2088
  showDevConsole: context.showDevConsole,
@@ -1984,7 +2091,8 @@ function CopilotDevConsole() {
1984
2091
  latestVersion
1985
2092
  }
1986
2093
  ),
1987
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2094
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CopilotKitHelpModal, {}),
2095
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1988
2096
  DebugMenuButton,
1989
2097
  {
1990
2098
  setShowDevConsole,
@@ -2002,7 +2110,7 @@ function VersionInfo({
2002
2110
  currentVersion,
2003
2111
  latestVersion
2004
2112
  }) {
2005
- const [copyStatus, setCopyStatus] = (0, import_react9.useState)("");
2113
+ const [copyStatus, setCopyStatus] = (0, import_react10.useState)("");
2006
2114
  let versionLabel = "";
2007
2115
  let versionIcon = "";
2008
2116
  let currentVersionLabel = currentVersion;
@@ -2039,12 +2147,12 @@ function VersionInfo({
2039
2147
  setTimeout(() => setCopyStatus(""), 1e3);
2040
2148
  });
2041
2149
  };
2042
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "copilotKitVersionInfo", children: [
2043
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("header", { children: [
2150
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "copilotKitVersionInfo", children: [
2151
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("header", { children: [
2044
2152
  "COPILOTKIT DEV CONSOLE",
2045
- showDevConsole === "auto" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("aside", { children: asideLabel })
2153
+ showDevConsole === "auto" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("aside", { children: asideLabel })
2046
2154
  ] }),
2047
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("section", { children: [
2155
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("section", { children: [
2048
2156
  "Version: ",
2049
2157
  versionLabel,
2050
2158
  " (",
@@ -2052,7 +2160,7 @@ function VersionInfo({
2052
2160
  ") ",
2053
2161
  versionIcon
2054
2162
  ] }),
2055
- (versionStatus === "update-available" || versionStatus === "outdated") && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("footer", { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { onClick: handleCopyClick, children: copyStatus || installCommand }) })
2163
+ (versionStatus === "update-available" || versionStatus === "outdated") && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("footer", { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { onClick: handleCopyClick, children: copyStatus || installCommand }) })
2056
2164
  ] });
2057
2165
  }
2058
2166
  function DebugMenuButton({
@@ -2062,22 +2170,22 @@ function DebugMenuButton({
2062
2170
  }) {
2063
2171
  const context = (0, import_react_core7.useCopilotContext)();
2064
2172
  const messagesContext = (0, import_react_core7.useCopilotMessagesContext)();
2065
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "bg-black top-24 w-52 text-right", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react10.Menu, { children: [
2066
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuButton, { className: `copilotKitDebugMenuButton ${mode === "compact" ? "compact" : ""}`, children: mode == "compact" ? "Debug" : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
2173
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "bg-black top-24 w-52 text-right", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_react11.Menu, { children: [
2174
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react11.MenuButton, { className: `copilotKitDebugMenuButton ${mode === "compact" ? "compact" : ""}`, children: mode == "compact" ? "Debug" : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
2067
2175
  "Debug ",
2068
2176
  ChevronDownIcon
2069
2177
  ] }) }),
2070
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2071
- import_react10.MenuItems,
2178
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2179
+ import_react11.MenuItems,
2072
2180
  {
2073
2181
  transition: true,
2074
2182
  anchor: "bottom end",
2075
2183
  className: "copilotKitDebugMenu",
2076
2184
  style: { zIndex: 40 },
2077
2185
  children: [
2078
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logReadables(context), children: "Log Readables" }) }),
2079
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logActions(context), children: "Log Actions" }) }),
2080
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2186
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react11.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logReadables(context), children: "Log Readables" }) }),
2187
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react11.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logActions(context), children: "Log Actions" }) }),
2188
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react11.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2081
2189
  "button",
2082
2190
  {
2083
2191
  className: "copilotKitDebugMenuItem",
@@ -2085,9 +2193,9 @@ function DebugMenuButton({
2085
2193
  children: "Log Messages"
2086
2194
  }
2087
2195
  ) }),
2088
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => checkForUpdates(true), children: "Check for Updates" }) }),
2089
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("hr", {}),
2090
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react10.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => setShowDevConsole(false), children: "Hide Dev Console" }) })
2196
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react11.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => checkForUpdates(true), children: "Check for Updates" }) }),
2197
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("hr", {}),
2198
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react11.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => setShowDevConsole(false), children: "Hide Dev Console" }) })
2091
2199
  ]
2092
2200
  }
2093
2201
  )
@@ -2095,13 +2203,16 @@ function DebugMenuButton({
2095
2203
  }
2096
2204
 
2097
2205
  // src/components/chat/Chat.tsx
2098
- var import_jsx_runtime19 = require("react/jsx-runtime");
2206
+ var import_react_core9 = require("@copilotkit/react-core");
2207
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2099
2208
  function CopilotChat({
2100
2209
  instructions,
2101
2210
  onSubmitMessage,
2102
2211
  makeSystemMessage,
2103
2212
  showResponseButton = true,
2104
2213
  onInProgress,
2214
+ onStopGeneration,
2215
+ onReloadMessages,
2105
2216
  Messages: Messages2 = Messages,
2106
2217
  RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
2107
2218
  RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
@@ -2114,7 +2225,7 @@ function CopilotChat({
2114
2225
  labels
2115
2226
  }) {
2116
2227
  const context = (0, import_react_core8.useCopilotContext)();
2117
- (0, import_react11.useEffect)(() => {
2228
+ (0, import_react12.useEffect)(() => {
2118
2229
  context.setChatInstructions(instructions || "");
2119
2230
  }, [instructions]);
2120
2231
  const {
@@ -2124,12 +2235,18 @@ function CopilotChat({
2124
2235
  sendMessage,
2125
2236
  stopGeneration,
2126
2237
  reloadMessages
2127
- } = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);
2128
- const chatContext = import_react11.default.useContext(ChatContext);
2238
+ } = useCopilotChatLogic(
2239
+ makeSystemMessage,
2240
+ onInProgress,
2241
+ onSubmitMessage,
2242
+ onStopGeneration,
2243
+ onReloadMessages
2244
+ );
2245
+ const chatContext = import_react12.default.useContext(ChatContext);
2129
2246
  const isVisible = chatContext ? chatContext.open : true;
2130
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2131
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CopilotDevConsole, {}),
2132
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
2247
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2248
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CopilotDevConsole, {}),
2249
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2133
2250
  Messages2,
2134
2251
  {
2135
2252
  RenderTextMessage: RenderTextMessage2,
@@ -2139,9 +2256,9 @@ function CopilotChat({
2139
2256
  messages: visibleMessages,
2140
2257
  inProgress: isLoading,
2141
2258
  children: [
2142
- currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { children: [
2143
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h6", { children: "Suggested:" }),
2144
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2259
+ currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { children: [
2260
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h6", { children: "Suggested:" }),
2261
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2145
2262
  Suggestion,
2146
2263
  {
2147
2264
  title: suggestion.title,
@@ -2153,7 +2270,7 @@ function CopilotChat({
2153
2270
  index
2154
2271
  )) })
2155
2272
  ] }),
2156
- showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2273
+ showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2157
2274
  ResponseButton2,
2158
2275
  {
2159
2276
  onClick: isLoading ? stopGeneration : reloadMessages,
@@ -2163,7 +2280,7 @@ function CopilotChat({
2163
2280
  ]
2164
2281
  }
2165
2282
  ),
2166
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Input2, { inProgress: isLoading, onSend: sendMessage, isVisible })
2283
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Input2, { inProgress: isLoading, onSend: sendMessage, isVisible })
2167
2284
  ] });
2168
2285
  }
2169
2286
  function WrappedCopilotChat({
@@ -2172,31 +2289,38 @@ function WrappedCopilotChat({
2172
2289
  labels,
2173
2290
  className
2174
2291
  }) {
2175
- const chatContext = import_react11.default.useContext(ChatContext);
2292
+ const chatContext = import_react12.default.useContext(ChatContext);
2176
2293
  if (!chatContext) {
2177
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2178
- }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: `copilotKitChat ${className}`, children }) });
2294
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2295
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: `copilotKitChat ${className}`, children }) });
2179
2296
  }
2180
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
2297
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children });
2181
2298
  }
2182
2299
  var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
2183
- var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
2184
- const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = (0, import_react_core8.useCopilotChat)({
2300
+ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
2301
+ var _a;
2302
+ const {
2303
+ visibleMessages,
2304
+ appendMessage,
2305
+ reloadMessages: defaultReloadMessages,
2306
+ stopGeneration: defaultStopGeneration,
2307
+ isLoading
2308
+ } = (0, import_react_core8.useCopilotChat)({
2185
2309
  id: (0, import_shared3.randomId)(),
2186
2310
  makeSystemMessage
2187
2311
  });
2188
- const [currentSuggestions, setCurrentSuggestions] = (0, import_react11.useState)([]);
2189
- const suggestionsAbortControllerRef = (0, import_react11.useRef)(null);
2190
- const debounceTimerRef = (0, import_react11.useRef)();
2312
+ const [currentSuggestions, setCurrentSuggestions] = (0, import_react12.useState)([]);
2313
+ const suggestionsAbortControllerRef = (0, import_react12.useRef)(null);
2314
+ const debounceTimerRef = (0, import_react12.useRef)();
2191
2315
  const abortSuggestions = () => {
2192
- var _a;
2193
- (_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
2316
+ var _a2;
2317
+ (_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
2194
2318
  suggestionsAbortControllerRef.current = null;
2195
2319
  };
2196
2320
  const generalContext = (0, import_react_core8.useCopilotContext)();
2197
2321
  const messagesContext = (0, import_react_core8.useCopilotMessagesContext)();
2198
2322
  const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
2199
- (0, import_react11.useEffect)(() => {
2323
+ (0, import_react12.useEffect)(() => {
2200
2324
  onInProgress == null ? void 0 : onInProgress(isLoading);
2201
2325
  abortSuggestions();
2202
2326
  debounceTimerRef.current = setTimeout(
@@ -2216,7 +2340,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
2216
2340
  return () => {
2217
2341
  clearTimeout(debounceTimerRef.current);
2218
2342
  };
2219
- }, [isLoading, context.chatSuggestionConfiguration]);
2343
+ }, [
2344
+ isLoading,
2345
+ context.chatSuggestionConfiguration,
2346
+ // hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
2347
+ // global context
2348
+ visibleMessages.length == 0
2349
+ ]);
2220
2350
  const sendMessage = (messageContent) => __async(void 0, null, function* () {
2221
2351
  abortSuggestions();
2222
2352
  setCurrentSuggestions([]);
@@ -2234,6 +2364,79 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
2234
2364
  appendMessage(message);
2235
2365
  return message;
2236
2366
  });
2367
+ const messages = visibleMessages;
2368
+ const { setMessages } = messagesContext;
2369
+ const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
2370
+ const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
2371
+ if (generalContext.agentSession) {
2372
+ generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
2373
+ nodeName: void 0,
2374
+ threadId: void 0
2375
+ }));
2376
+ generalContext.setCoagentStates((prevAgentStates) => {
2377
+ return __spreadProps(__spreadValues({}, prevAgentStates), {
2378
+ [generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
2379
+ threadId: void 0,
2380
+ nodeName: void 0,
2381
+ runId: void 0
2382
+ })
2383
+ });
2384
+ });
2385
+ }
2386
+ });
2387
+ const runCurrentAgent = (hint) => __async(void 0, null, function* () {
2388
+ if (generalContext.agentSession) {
2389
+ yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
2390
+ }
2391
+ });
2392
+ const stopCurrentAgent = () => {
2393
+ if (generalContext.agentSession) {
2394
+ (0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
2395
+ }
2396
+ };
2397
+ const setCurrentAgentState = (state) => {
2398
+ if (generalContext.agentSession) {
2399
+ generalContext.setCoagentStates((prevAgentStates) => {
2400
+ return __spreadProps(__spreadValues({}, prevAgentStates), {
2401
+ [generalContext.agentSession.agentName]: {
2402
+ state
2403
+ }
2404
+ });
2405
+ });
2406
+ }
2407
+ };
2408
+ function stopGeneration() {
2409
+ if (onStopGeneration) {
2410
+ onStopGeneration({
2411
+ messages,
2412
+ setMessages,
2413
+ stopGeneration: defaultStopGeneration,
2414
+ currentAgentName,
2415
+ restartCurrentAgent,
2416
+ stopCurrentAgent,
2417
+ runCurrentAgent,
2418
+ setCurrentAgentState
2419
+ });
2420
+ } else {
2421
+ defaultStopGeneration();
2422
+ }
2423
+ }
2424
+ function reloadMessages() {
2425
+ if (onReloadMessages) {
2426
+ onReloadMessages({
2427
+ messages,
2428
+ setMessages,
2429
+ stopGeneration: defaultStopGeneration,
2430
+ currentAgentName,
2431
+ restartCurrentAgent,
2432
+ stopCurrentAgent,
2433
+ runCurrentAgent,
2434
+ setCurrentAgentState
2435
+ });
2436
+ } else {
2437
+ defaultReloadMessages();
2438
+ }
2439
+ }
2237
2440
  return {
2238
2441
  visibleMessages,
2239
2442
  isLoading,
@@ -2245,7 +2448,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
2245
2448
  };
2246
2449
 
2247
2450
  // src/components/chat/Modal.tsx
2248
- var import_jsx_runtime20 = require("react/jsx-runtime");
2451
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2249
2452
  var CopilotModal = ({
2250
2453
  instructions,
2251
2454
  defaultOpen = false,
@@ -2253,6 +2456,8 @@ var CopilotModal = ({
2253
2456
  hitEscapeToClose = true,
2254
2457
  onSetOpen,
2255
2458
  onSubmitMessage,
2459
+ onStopGeneration,
2460
+ onReloadMessages,
2256
2461
  shortcut = "/",
2257
2462
  icons,
2258
2463
  labels,
@@ -2268,28 +2473,30 @@ var CopilotModal = ({
2268
2473
  className,
2269
2474
  children
2270
2475
  }) => {
2271
- const [openState, setOpenState] = import_react12.default.useState(defaultOpen);
2476
+ const [openState, setOpenState] = import_react13.default.useState(defaultOpen);
2272
2477
  const setOpen = (open) => {
2273
2478
  onSetOpen == null ? void 0 : onSetOpen(open);
2274
2479
  setOpenState(open);
2275
2480
  };
2276
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ChatContextProvider, { icons, labels, open: openState, setOpen, children: [
2481
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(ChatContextProvider, { icons, labels, open: openState, setOpen, children: [
2277
2482
  children,
2278
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className, children: [
2279
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Button2, {}),
2280
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2483
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className, children: [
2484
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Button2, {}),
2485
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
2281
2486
  Window2,
2282
2487
  {
2283
2488
  clickOutsideToClose,
2284
2489
  shortcut,
2285
2490
  hitEscapeToClose,
2286
2491
  children: [
2287
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Header2, {}),
2288
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2492
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Header2, {}),
2493
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2289
2494
  CopilotChat,
2290
2495
  {
2291
2496
  instructions,
2292
2497
  onSubmitMessage,
2498
+ onStopGeneration,
2499
+ onReloadMessages,
2293
2500
  makeSystemMessage,
2294
2501
  showResponseButton,
2295
2502
  onInProgress,
@@ -2306,22 +2513,22 @@ var CopilotModal = ({
2306
2513
  };
2307
2514
 
2308
2515
  // src/components/chat/Popup.tsx
2309
- var import_jsx_runtime21 = require("react/jsx-runtime");
2516
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2310
2517
  function CopilotPopup(props) {
2311
2518
  props = __spreadProps(__spreadValues({}, props), {
2312
2519
  className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
2313
2520
  });
2314
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
2521
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
2315
2522
  }
2316
2523
 
2317
2524
  // src/components/chat/Sidebar.tsx
2318
- var import_react13 = require("react");
2319
- var import_jsx_runtime22 = require("react/jsx-runtime");
2525
+ var import_react14 = require("react");
2526
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2320
2527
  function CopilotSidebar(props) {
2321
2528
  props = __spreadProps(__spreadValues({}, props), {
2322
2529
  className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
2323
2530
  });
2324
- const [expandedClassName, setExpandedClassName] = (0, import_react13.useState)(
2531
+ const [expandedClassName, setExpandedClassName] = (0, import_react14.useState)(
2325
2532
  props.defaultOpen ? "sidebarExpanded" : ""
2326
2533
  );
2327
2534
  const onSetOpen = (open) => {
@@ -2329,7 +2536,7 @@ function CopilotSidebar(props) {
2329
2536
  (_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
2330
2537
  setExpandedClassName(open ? "sidebarExpanded" : "");
2331
2538
  };
2332
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
2539
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
2333
2540
  }
2334
2541
  // Annotate the CommonJS export names for ESM import in node:
2335
2542
  0 && (module.exports = {