@copilotkit/react-ui 1.8.5-next.1 → 1.8.5-next.3

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 (79) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{chunk-Q2YY2NX3.mjs → chunk-COZFHP6Y.mjs} +2 -2
  3. package/dist/{chunk-MYUOPOIL.mjs → chunk-DRAM4KIH.mjs} +13 -13
  4. package/dist/{chunk-PCTCOQK2.mjs → chunk-DYUT4CVD.mjs} +4 -4
  5. package/dist/{chunk-4TWPMWD4.mjs → chunk-GULJZORG.mjs} +8 -8
  6. package/dist/chunk-JGMFJZMG.mjs +11 -0
  7. package/dist/chunk-JGMFJZMG.mjs.map +1 -0
  8. package/dist/{chunk-XNQO5AZZ.mjs → chunk-KSW7FVYG.mjs} +2 -2
  9. package/dist/{chunk-5M7ODWKH.mjs → chunk-N7ZQXCKF.mjs} +2 -2
  10. package/dist/{chunk-6QV7AIIG.mjs → chunk-P53JYD5X.mjs} +2 -2
  11. package/dist/{chunk-D5XIJNXQ.mjs → chunk-Q6XB5B2M.mjs} +7 -7
  12. package/dist/{chunk-2OTVZXDX.mjs → chunk-QDC2Q7XX.mjs} +2 -2
  13. package/dist/{chunk-NMNC4ROZ.mjs → chunk-QMW2LYI3.mjs} +2 -2
  14. package/dist/{chunk-P7S3E5UW.mjs → chunk-QSUC3MKT.mjs} +35 -7
  15. package/dist/chunk-QSUC3MKT.mjs.map +1 -0
  16. package/dist/{chunk-QJKMOGWN.mjs → chunk-RXBEZZ5I.mjs} +4 -4
  17. package/dist/{chunk-U6ISBBRF.mjs → chunk-TYAYVE3X.mjs} +2 -2
  18. package/dist/{chunk-62QMTKMJ.mjs → chunk-USR5CBYD.mjs} +4 -4
  19. package/dist/{chunk-WNC6OCIB.mjs → chunk-YIQTTJAT.mjs} +2 -2
  20. package/dist/components/chat/Chat.mjs +11 -11
  21. package/dist/components/chat/CodeBlock.mjs +2 -2
  22. package/dist/components/chat/Header.mjs +3 -3
  23. package/dist/components/chat/Input.mjs +2 -2
  24. package/dist/components/chat/Markdown.mjs +3 -3
  25. package/dist/components/chat/Modal.js +66 -32
  26. package/dist/components/chat/Modal.js.map +1 -1
  27. package/dist/components/chat/Modal.mjs +17 -16
  28. package/dist/components/chat/Popup.js +66 -32
  29. package/dist/components/chat/Popup.js.map +1 -1
  30. package/dist/components/chat/Popup.mjs +18 -17
  31. package/dist/components/chat/Sidebar.js +66 -32
  32. package/dist/components/chat/Sidebar.js.map +1 -1
  33. package/dist/components/chat/Sidebar.mjs +18 -17
  34. package/dist/components/chat/Window.js +39 -5
  35. package/dist/components/chat/Window.js.map +1 -1
  36. package/dist/components/chat/Window.mjs +2 -1
  37. package/dist/components/chat/index.js +66 -32
  38. package/dist/components/chat/index.js.map +1 -1
  39. package/dist/components/chat/index.mjs +22 -21
  40. package/dist/components/chat/messages/AssistantMessage.mjs +4 -4
  41. package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +5 -5
  42. package/dist/components/chat/messages/RenderAgentStateMessage.mjs +5 -5
  43. package/dist/components/chat/messages/RenderResultMessage.mjs +5 -5
  44. package/dist/components/chat/messages/RenderTextMessage.mjs +5 -5
  45. package/dist/components/dev-console/console.mjs +2 -2
  46. package/dist/components/dev-console/index.mjs +2 -2
  47. package/dist/components/index.js +66 -32
  48. package/dist/components/index.js.map +1 -1
  49. package/dist/components/index.mjs +22 -21
  50. package/dist/hooks/use-dark-mode.d.ts +3 -0
  51. package/dist/hooks/use-dark-mode.js +35 -0
  52. package/dist/hooks/use-dark-mode.js.map +1 -0
  53. package/dist/hooks/use-dark-mode.mjs +8 -0
  54. package/dist/hooks/use-dark-mode.mjs.map +1 -0
  55. package/dist/index.css +25 -1
  56. package/dist/index.css.map +1 -1
  57. package/dist/index.js +68 -34
  58. package/dist/index.js.map +1 -1
  59. package/dist/index.mjs +28 -27
  60. package/package.json +4 -4
  61. package/src/components/chat/Window.tsx +26 -1
  62. package/src/css/input.css +1 -1
  63. package/src/css/window.css +27 -0
  64. package/src/hooks/use-dark-mode.ts +10 -0
  65. package/dist/chunk-P7S3E5UW.mjs.map +0 -1
  66. /package/dist/{chunk-Q2YY2NX3.mjs.map → chunk-COZFHP6Y.mjs.map} +0 -0
  67. /package/dist/{chunk-MYUOPOIL.mjs.map → chunk-DRAM4KIH.mjs.map} +0 -0
  68. /package/dist/{chunk-PCTCOQK2.mjs.map → chunk-DYUT4CVD.mjs.map} +0 -0
  69. /package/dist/{chunk-4TWPMWD4.mjs.map → chunk-GULJZORG.mjs.map} +0 -0
  70. /package/dist/{chunk-XNQO5AZZ.mjs.map → chunk-KSW7FVYG.mjs.map} +0 -0
  71. /package/dist/{chunk-5M7ODWKH.mjs.map → chunk-N7ZQXCKF.mjs.map} +0 -0
  72. /package/dist/{chunk-6QV7AIIG.mjs.map → chunk-P53JYD5X.mjs.map} +0 -0
  73. /package/dist/{chunk-D5XIJNXQ.mjs.map → chunk-Q6XB5B2M.mjs.map} +0 -0
  74. /package/dist/{chunk-2OTVZXDX.mjs.map → chunk-QDC2Q7XX.mjs.map} +0 -0
  75. /package/dist/{chunk-NMNC4ROZ.mjs.map → chunk-QMW2LYI3.mjs.map} +0 -0
  76. /package/dist/{chunk-QJKMOGWN.mjs.map → chunk-RXBEZZ5I.mjs.map} +0 -0
  77. /package/dist/{chunk-U6ISBBRF.mjs.map → chunk-TYAYVE3X.mjs.map} +0 -0
  78. /package/dist/{chunk-62QMTKMJ.mjs.map → chunk-USR5CBYD.mjs.map} +0 -0
  79. /package/dist/{chunk-WNC6OCIB.mjs.map → chunk-YIQTTJAT.mjs.map} +0 -0
@@ -1,34 +1,35 @@
1
1
  import {
2
2
  CopilotSidebar
3
- } from "../../chunk-U6ISBBRF.mjs";
4
- import "../../chunk-4TWPMWD4.mjs";
5
- import "../../chunk-P7S3E5UW.mjs";
6
- import "../../chunk-2OTVZXDX.mjs";
3
+ } from "../../chunk-TYAYVE3X.mjs";
4
+ import "../../chunk-GULJZORG.mjs";
5
+ import "../../chunk-QSUC3MKT.mjs";
6
+ import "../../chunk-JGMFJZMG.mjs";
7
+ import "../../chunk-QDC2Q7XX.mjs";
7
8
  import "../../chunk-V7W6IM2V.mjs";
8
- import "../../chunk-D5XIJNXQ.mjs";
9
+ import "../../chunk-Q6XB5B2M.mjs";
10
+ import "../../chunk-Q5V6S67N.mjs";
9
11
  import "../../chunk-6TCUJ3B7.mjs";
10
12
  import "../../chunk-KXE2JCUH.mjs";
11
13
  import "../../chunk-NRA3CFEE.mjs";
12
14
  import "../../chunk-BH6PCAAL.mjs";
13
- import "../../chunk-Q5V6S67N.mjs";
14
15
  import "../../chunk-YOEL33HG.mjs";
15
- import "../../chunk-MYUOPOIL.mjs";
16
- import "../../chunk-WNC6OCIB.mjs";
17
- import "../../chunk-62QMTKMJ.mjs";
16
+ import "../../chunk-DRAM4KIH.mjs";
17
+ import "../../chunk-QMW2LYI3.mjs";
18
+ import "../../chunk-COZFHP6Y.mjs";
19
+ import "../../chunk-YIQTTJAT.mjs";
20
+ import "../../chunk-USR5CBYD.mjs";
21
+ import "../../chunk-N7ZQXCKF.mjs";
18
22
  import "../../chunk-HEIDCT7I.mjs";
19
- import "../../chunk-NMNC4ROZ.mjs";
20
- import "../../chunk-Q2YY2NX3.mjs";
21
- import "../../chunk-5M7ODWKH.mjs";
22
23
  import "../../chunk-TOQ7P4DO.mjs";
23
- import "../../chunk-QJKMOGWN.mjs";
24
+ import "../../chunk-RXBEZZ5I.mjs";
25
+ import "../../chunk-S5MBUNGN.mjs";
24
26
  import "../../chunk-YQFVRDNC.mjs";
25
- import "../../chunk-XNQO5AZZ.mjs";
27
+ import "../../chunk-KSW7FVYG.mjs";
28
+ import "../../chunk-DYUT4CVD.mjs";
29
+ import "../../chunk-54JAUBUJ.mjs";
26
30
  import "../../chunk-ZY25LVYR.mjs";
27
31
  import "../../chunk-UN2E3HCK.mjs";
28
- import "../../chunk-PCTCOQK2.mjs";
29
32
  import "../../chunk-ORSMX3SE.mjs";
30
- import "../../chunk-54JAUBUJ.mjs";
31
- import "../../chunk-S5MBUNGN.mjs";
32
33
  import "../../chunk-MRXNTQOX.mjs";
33
34
  export {
34
35
  CopilotSidebar
@@ -49,6 +49,16 @@ function useChatContext() {
49
49
  return context;
50
50
  }
51
51
 
52
+ // src/components/chat/Window.tsx
53
+ var import_react_core = require("@copilotkit/react-core");
54
+
55
+ // src/hooks/use-dark-mode.ts
56
+ var useDarkMode = () => {
57
+ if (typeof window === "undefined")
58
+ return false;
59
+ return document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") || document.documentElement.getAttribute("data-theme") === "dark" || document.body.getAttribute("data-theme") === "dark" || window.matchMedia("(prefers-color-scheme: dark)").matches;
60
+ };
61
+
52
62
  // src/components/chat/Window.tsx
53
63
  var import_jsx_runtime2 = require("react/jsx-runtime");
54
64
  var Window = ({
@@ -57,15 +67,17 @@ var Window = ({
57
67
  shortcut,
58
68
  hitEscapeToClose
59
69
  }) => {
70
+ var _a;
60
71
  const windowRef = import_react2.default.useRef(null);
72
+ const context = (0, import_react_core.useCopilotContext)();
61
73
  const { open, setOpen } = useChatContext();
62
74
  const handleClickOutside = (0, import_react2.useCallback)(
63
75
  (event) => {
64
- var _a;
76
+ var _a2;
65
77
  if (!clickOutsideToClose) {
66
78
  return;
67
79
  }
68
- const parentElement = (_a = windowRef.current) == null ? void 0 : _a.parentElement;
80
+ const parentElement = (_a2 = windowRef.current) == null ? void 0 : _a2.parentElement;
69
81
  let className = "";
70
82
  if (event.target instanceof HTMLElement) {
71
83
  className = event.target.className;
@@ -79,10 +91,10 @@ var Window = ({
79
91
  );
80
92
  const handleKeyDown = (0, import_react2.useCallback)(
81
93
  (event) => {
82
- var _a;
94
+ var _a2;
83
95
  const target = event.target;
84
96
  const isInput = target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.isContentEditable;
85
- const isDescendantOfWrapper = (_a = windowRef.current) == null ? void 0 : _a.contains(target);
97
+ const isDescendantOfWrapper = (_a2 = windowRef.current) == null ? void 0 : _a2.contains(target);
86
98
  if (open && event.key === "Escape" && (!isInput || isDescendantOfWrapper) && hitEscapeToClose) {
87
99
  setOpen(false);
88
100
  } else if (event.key === shortcut && (isMacOS() && event.metaKey || !isMacOS() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
@@ -137,7 +149,29 @@ var Window = ({
137
149
  }
138
150
  };
139
151
  }, [adjustForMobile, handleClickOutside, handleKeyDown]);
140
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: `copilotKitWindow${open ? " open" : ""}`, ref: windowRef, children });
152
+ const isDark = useDarkMode();
153
+ const showPoweredBy = !((_a = context.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
154
+ const poweredByStyle = {
155
+ visibility: "visible",
156
+ display: "block",
157
+ position: "static",
158
+ textAlign: "center",
159
+ fontSize: "12px",
160
+ padding: "3px 0",
161
+ color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
162
+ };
163
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
164
+ "div",
165
+ {
166
+ className: `copilotKitWindow ${showPoweredBy ? " poweredByContainer" : ""} ${open ? " open" : ""}`,
167
+ ref: windowRef,
168
+ children: [
169
+ children,
170
+ showPoweredBy && // @ts-expect-error -- expecting position not to be a string, but it can be.
171
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" })
172
+ ]
173
+ }
174
+ );
141
175
  };
142
176
  var preventScroll = (event) => {
143
177
  let targetElement = event.target;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/chat/Window.tsx","../../../src/components/chat/ChatContext.tsx"],"sourcesContent":["import React, { useCallback, useEffect } from \"react\";\nimport { WindowProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\n\nexport const Window = ({\n children,\n clickOutsideToClose,\n shortcut,\n hitEscapeToClose,\n}: WindowProps) => {\n const windowRef = React.useRef<HTMLDivElement>(null);\n\n const { open, setOpen } = useChatContext();\n\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (!clickOutsideToClose) {\n return;\n }\n\n const parentElement = windowRef.current?.parentElement;\n\n let className = \"\";\n if (event.target instanceof HTMLElement) {\n className = event.target.className;\n }\n\n if (\n open &&\n parentElement &&\n !parentElement.contains(event.target as any) &&\n // prevent closing the window when clicking on the debug menu\n !className.includes(\"copilotKitDebugMenu\")\n ) {\n setOpen(false);\n }\n },\n [clickOutsideToClose, open, setOpen],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const isInput =\n target.tagName === \"INPUT\" ||\n target.tagName === \"SELECT\" ||\n target.tagName === \"TEXTAREA\" ||\n target.isContentEditable;\n\n const isDescendantOfWrapper = windowRef.current?.contains(target);\n\n if (\n open &&\n event.key === \"Escape\" &&\n (!isInput || isDescendantOfWrapper) &&\n hitEscapeToClose\n ) {\n setOpen(false);\n } else if (\n event.key === shortcut &&\n ((isMacOS() && event.metaKey) || (!isMacOS() && event.ctrlKey)) &&\n (!isInput || isDescendantOfWrapper)\n ) {\n setOpen(!open);\n }\n },\n [hitEscapeToClose, shortcut, open, setOpen],\n );\n\n const adjustForMobile = useCallback(() => {\n const copilotKitWindow = windowRef.current;\n const vv = window.visualViewport;\n if (!copilotKitWindow || !vv) {\n return;\n }\n\n if (window.innerWidth < 640 && open) {\n copilotKitWindow.style.height = `${vv.height}px`;\n copilotKitWindow.style.left = `${vv.offsetLeft}px`;\n copilotKitWindow.style.top = `${vv.offsetTop}px`;\n\n document.body.style.position = \"fixed\";\n document.body.style.width = \"100%\";\n document.body.style.height = `${window.innerHeight}px`;\n document.body.style.overflow = \"hidden\";\n document.body.style.touchAction = \"none\";\n\n // Prevent scrolling on iOS\n document.body.addEventListener(\"touchmove\", preventScroll, {\n passive: false,\n });\n } else {\n copilotKitWindow.style.height = \"\";\n copilotKitWindow.style.left = \"\";\n copilotKitWindow.style.top = \"\";\n document.body.style.position = \"\";\n document.body.style.height = \"\";\n document.body.style.width = \"\";\n document.body.style.overflow = \"\";\n document.body.style.top = \"\";\n document.body.style.touchAction = \"\";\n\n document.body.removeEventListener(\"touchmove\", preventScroll);\n }\n }, [open]);\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n document.addEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.addEventListener(\"resize\", adjustForMobile);\n adjustForMobile();\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n document.removeEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.removeEventListener(\"resize\", adjustForMobile);\n }\n };\n }, [adjustForMobile, handleClickOutside, handleKeyDown]);\n\n return (\n <div className={`copilotKitWindow${open ? \" open\" : \"\"}`} ref={windowRef}>\n {children}\n </div>\n );\n};\n\nconst preventScroll = (event: TouchEvent): void => {\n let targetElement = event.target as Element;\n\n // Function to check if the target has the parent with a given class\n const hasParentWithClass = (element: Element, className: string): boolean => {\n while (element && element !== document.body) {\n if (element.classList.contains(className)) {\n return true;\n }\n element = element.parentElement!;\n }\n return false;\n };\n\n // Check if the target of the touch event is inside an element with the 'copilotKitMessages' class\n if (!hasParentWithClass(targetElement, \"copilotKitMessages\")) {\n event.preventDefault();\n }\n};\n\nfunction isMacOS() {\n return /Mac|iMac|Macintosh/i.test(navigator.userAgent);\n}\n","import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\nimport { ThumbsDownIcon, ThumbsUpIcon } from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n\n /**\n * The icons to use for copy assistant response\n * @default <CopyIcon />\n */\n\n copyIcon?: React.ReactNode;\n\n /**\n * The icon to use for thumbs up/response approval.\n * @default <ThumbsUpIcon />\n */\n\n thumbsUpIcon?: React.ReactNode;\n\n /**\n * The icon to use for thumbs down/response rejection.\n * @default <ThumbsDownIcon />\n */\n\n thumbsDownIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n\n /**\n * The label for the copy button.\n * @default \"Copy to clipboard\"\n */\n copyToClipboard?: string;\n\n /**\n * The label for the thumbs up button.\n * @default \"Thumbs up\"\n */\n thumbsUp?: string;\n\n /**\n * The label for the thumbs down button.\n * @default \"Thumbs down\"\n */\n thumbsDown?: string;\n\n /**\n * The text to display when content is copied.\n * @default \"Copied!\"\n */\n copied?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const memoizedLabels = useMemo(\n () => ({\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n copyToClipboard: \"Copy to clipboard\",\n thumbsUp: \"Thumbs up\",\n thumbsDown: \"Thumbs down\",\n copied: \"Copied!\",\n },\n ...labels,\n }),\n [labels],\n );\n\n const memoizedIcons = useMemo(\n () => ({\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n pushToTalkIcon: DefaultIcons.MicrophoneIcon,\n copyIcon: DefaultIcons.CopyIcon,\n thumbsUpIcon: DefaultIcons.ThumbsUpIcon,\n thumbsDownIcon: DefaultIcons.ThumbsDownIcon,\n },\n ...icons,\n }),\n [icons],\n );\n\n const context = useMemo(\n () => ({\n labels: memoizedLabels,\n icons: memoizedIcons,\n open,\n setOpen,\n }),\n [memoizedLabels, memoizedIcons, open, setOpen],\n );\n\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA8C;;;ACA9C,mBAAyC;AA+OhC;AAnFF,IAAM,cAAc,aAAAC,QAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,aAAAA,QAAM,WAAW,WAAW;AAC5C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;AD1CI,IAAAC,sBAAA;AAxHG,IAAM,SAAS,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAmB;AACjB,QAAM,YAAY,cAAAC,QAAM,OAAuB,IAAI;AAEnD,QAAM,EAAE,MAAM,QAAQ,IAAI,eAAe;AAEzC,QAAM,yBAAqB;AAAA,IACzB,CAAC,UAAsB;AAf3B;AAgBM,UAAI,CAAC,qBAAqB;AACxB;AAAA,MACF;AAEA,YAAM,iBAAgB,eAAU,YAAV,mBAAmB;AAEzC,UAAI,YAAY;AAChB,UAAI,MAAM,kBAAkB,aAAa;AACvC,oBAAY,MAAM,OAAO;AAAA,MAC3B;AAEA,UACE,QACA,iBACA,CAAC,cAAc,SAAS,MAAM,MAAa;AAAA,MAE3C,CAAC,UAAU,SAAS,qBAAqB,GACzC;AACA,gBAAQ,KAAK;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,qBAAqB,MAAM,OAAO;AAAA,EACrC;AAEA,QAAM,oBAAgB;AAAA,IACpB,CAAC,UAAyB;AAzC9B;AA0CM,YAAM,SAAS,MAAM;AACrB,YAAM,UACJ,OAAO,YAAY,WACnB,OAAO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;AAAA,IAC9D;AAAA,EACF,GAAG,CAAC,IAAI,CAAC;AAET,+BAAU,MAAM;AACd,aAAS,iBAAiB,aAAa,kBAAkB;AACzD,aAAS,iBAAiB,WAAW,aAAa;AAClD,QAAI,OAAO,gBAAgB;AACzB,aAAO,eAAe,iBAAiB,UAAU,eAAe;AAChE,sBAAgB;AAAA,IAClB;AAEA,WAAO,MAAM;AACX,eAAS,oBAAoB,aAAa,kBAAkB;AAC5D,eAAS,oBAAoB,WAAW,aAAa;AACrD,UAAI,OAAO,gBAAgB;AACzB,eAAO,eAAe,oBAAoB,UAAU,eAAe;AAAA,MACrE;AAAA,IACF;AAAA,EACF,GAAG,CAAC,iBAAiB,oBAAoB,aAAa,CAAC;AAEvD,SACE,6CAAC,SAAI,WAAW,mBAAmB,OAAO,UAAU,MAAM,KAAK,WAC5D,UACH;AAEJ;AAEA,IAAM,gBAAgB,CAAC,UAA4B;AACjD,MAAI,gBAAgB,MAAM;AAG1B,QAAM,qBAAqB,CAAC,SAAkB,cAA+B;AAC3E,WAAO,WAAW,YAAY,SAAS,MAAM;AAC3C,UAAI,QAAQ,UAAU,SAAS,SAAS,GAAG;AACzC,eAAO;AAAA,MACT;AACA,gBAAU,QAAQ;AAAA,IACpB;AACA,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,mBAAmB,eAAe,oBAAoB,GAAG;AAC5D,UAAM,eAAe;AAAA,EACvB;AACF;AAEA,SAAS,UAAU;AACjB,SAAO,sBAAsB,KAAK,UAAU,SAAS;AACvD;","names":["import_react","React","import_jsx_runtime","React"]}
1
+ {"version":3,"sources":["../../../src/components/chat/Window.tsx","../../../src/components/chat/ChatContext.tsx","../../../src/hooks/use-dark-mode.ts"],"sourcesContent":["import React, { useCallback, useEffect } from \"react\";\nimport { WindowProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { useDarkMode } from \"../../hooks/use-dark-mode\";\n\nexport const Window = ({\n children,\n clickOutsideToClose,\n shortcut,\n hitEscapeToClose,\n}: WindowProps) => {\n const windowRef = React.useRef<HTMLDivElement>(null);\n const context = useCopilotContext();\n\n const { open, setOpen } = useChatContext();\n\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (!clickOutsideToClose) {\n return;\n }\n\n const parentElement = windowRef.current?.parentElement;\n\n let className = \"\";\n if (event.target instanceof HTMLElement) {\n className = event.target.className;\n }\n\n if (\n open &&\n parentElement &&\n !parentElement.contains(event.target as any) &&\n // prevent closing the window when clicking on the debug menu\n !className.includes(\"copilotKitDebugMenu\")\n ) {\n setOpen(false);\n }\n },\n [clickOutsideToClose, open, setOpen],\n );\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n const isInput =\n target.tagName === \"INPUT\" ||\n target.tagName === \"SELECT\" ||\n target.tagName === \"TEXTAREA\" ||\n target.isContentEditable;\n\n const isDescendantOfWrapper = windowRef.current?.contains(target);\n\n if (\n open &&\n event.key === \"Escape\" &&\n (!isInput || isDescendantOfWrapper) &&\n hitEscapeToClose\n ) {\n setOpen(false);\n } else if (\n event.key === shortcut &&\n ((isMacOS() && event.metaKey) || (!isMacOS() && event.ctrlKey)) &&\n (!isInput || isDescendantOfWrapper)\n ) {\n setOpen(!open);\n }\n },\n [hitEscapeToClose, shortcut, open, setOpen],\n );\n\n const adjustForMobile = useCallback(() => {\n const copilotKitWindow = windowRef.current;\n const vv = window.visualViewport;\n if (!copilotKitWindow || !vv) {\n return;\n }\n\n if (window.innerWidth < 640 && open) {\n copilotKitWindow.style.height = `${vv.height}px`;\n copilotKitWindow.style.left = `${vv.offsetLeft}px`;\n copilotKitWindow.style.top = `${vv.offsetTop}px`;\n\n document.body.style.position = \"fixed\";\n document.body.style.width = \"100%\";\n document.body.style.height = `${window.innerHeight}px`;\n document.body.style.overflow = \"hidden\";\n document.body.style.touchAction = \"none\";\n\n // Prevent scrolling on iOS\n document.body.addEventListener(\"touchmove\", preventScroll, {\n passive: false,\n });\n } else {\n copilotKitWindow.style.height = \"\";\n copilotKitWindow.style.left = \"\";\n copilotKitWindow.style.top = \"\";\n document.body.style.position = \"\";\n document.body.style.height = \"\";\n document.body.style.width = \"\";\n document.body.style.overflow = \"\";\n document.body.style.top = \"\";\n document.body.style.touchAction = \"\";\n\n document.body.removeEventListener(\"touchmove\", preventScroll);\n }\n }, [open]);\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n document.addEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.addEventListener(\"resize\", adjustForMobile);\n adjustForMobile();\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n document.removeEventListener(\"keydown\", handleKeyDown);\n if (window.visualViewport) {\n window.visualViewport.removeEventListener(\"resize\", adjustForMobile);\n }\n };\n }, [adjustForMobile, handleClickOutside, handleKeyDown]);\n\n const isDark = useDarkMode();\n\n const showPoweredBy = !context.copilotApiConfig?.publicApiKey;\n const poweredByStyle = {\n visibility: \"visible\",\n display: \"block\",\n position: \"static\",\n textAlign: \"center\",\n fontSize: \"12px\",\n padding: \"3px 0\",\n color: isDark ? \"rgb(69, 69, 69)\" : \"rgb(214, 214, 214)\",\n };\n\n return (\n <div\n className={`copilotKitWindow ${showPoweredBy ? \" poweredByContainer\" : \"\"} ${open ? \" open\" : \"\"}`}\n ref={windowRef}\n >\n {children}\n {showPoweredBy && (\n // @ts-expect-error -- expecting position not to be a string, but it can be.\n <p className=\"poweredBy\" style={poweredByStyle}>\n Powered by CopilotKit\n </p>\n )}\n </div>\n );\n};\n\nconst preventScroll = (event: TouchEvent): void => {\n let targetElement = event.target as Element;\n\n // Function to check if the target has the parent with a given class\n const hasParentWithClass = (element: Element, className: string): boolean => {\n while (element && element !== document.body) {\n if (element.classList.contains(className)) {\n return true;\n }\n element = element.parentElement!;\n }\n return false;\n };\n\n // Check if the target of the touch event is inside an element with the 'copilotKitMessages' class\n if (!hasParentWithClass(targetElement, \"copilotKitMessages\")) {\n event.preventDefault();\n }\n};\n\nfunction isMacOS() {\n return /Mac|iMac|Macintosh/i.test(navigator.userAgent);\n}\n","import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\nimport { ThumbsDownIcon, ThumbsUpIcon } from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n\n /**\n * The icons to use for copy assistant response\n * @default <CopyIcon />\n */\n\n copyIcon?: React.ReactNode;\n\n /**\n * The icon to use for thumbs up/response approval.\n * @default <ThumbsUpIcon />\n */\n\n thumbsUpIcon?: React.ReactNode;\n\n /**\n * The icon to use for thumbs down/response rejection.\n * @default <ThumbsDownIcon />\n */\n\n thumbsDownIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n\n /**\n * The label for the copy button.\n * @default \"Copy to clipboard\"\n */\n copyToClipboard?: string;\n\n /**\n * The label for the thumbs up button.\n * @default \"Thumbs up\"\n */\n thumbsUp?: string;\n\n /**\n * The label for the thumbs down button.\n * @default \"Thumbs down\"\n */\n thumbsDown?: string;\n\n /**\n * The text to display when content is copied.\n * @default \"Copied!\"\n */\n copied?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const memoizedLabels = useMemo(\n () => ({\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n copyToClipboard: \"Copy to clipboard\",\n thumbsUp: \"Thumbs up\",\n thumbsDown: \"Thumbs down\",\n copied: \"Copied!\",\n },\n ...labels,\n }),\n [labels],\n );\n\n const memoizedIcons = useMemo(\n () => ({\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n pushToTalkIcon: DefaultIcons.MicrophoneIcon,\n copyIcon: DefaultIcons.CopyIcon,\n thumbsUpIcon: DefaultIcons.ThumbsUpIcon,\n thumbsDownIcon: DefaultIcons.ThumbsDownIcon,\n },\n ...icons,\n }),\n [icons],\n );\n\n const context = useMemo(\n () => ({\n labels: memoizedLabels,\n icons: memoizedIcons,\n open,\n setOpen,\n }),\n [memoizedLabels, memoizedIcons, open, setOpen],\n );\n\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n","export const useDarkMode = () => {\n if (typeof window === \"undefined\") return false;\n return (\n document.documentElement.classList.contains(\"dark\") ||\n document.body.classList.contains(\"dark\") ||\n document.documentElement.getAttribute(\"data-theme\") === \"dark\" ||\n document.body.getAttribute(\"data-theme\") === \"dark\" ||\n window.matchMedia(\"(prefers-color-scheme: dark)\").matches\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA8C;;;ACA9C,mBAAyC;AA+OhC;AAnFF,IAAM,cAAc,aAAAC,QAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,aAAAA,QAAM,WAAW,WAAW;AAC5C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;ADnKA,wBAAkC;;;AEH3B,IAAM,cAAc,MAAM;AAC/B,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,SACE,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AM;AACX,eAAS,oBAAoB,aAAa,kBAAkB;AAC5D,eAAS,oBAAoB,WAAW,aAAa;AACrD,UAAI,OAAO,gBAAgB;AACzB,eAAO,eAAe,oBAAoB,UAAU,eAAe;AAAA,MACrE;AAAA,IACF;AAAA,EACF,GAAG,CAAC,iBAAiB,oBAAoB,aAAa,CAAC;AAEvD,QAAM,SAAS,YAAY;AAE3B,QAAM,gBAAgB,GAAC,aAAQ,qBAAR,mBAA0B;AACjD,QAAM,iBAAiB;AAAA,IACrB,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,SAAS;AAAA,IACT,OAAO,SAAS,oBAAoB;AAAA,EACtC;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,oBAAoB,gBAAgB,wBAAwB,MAAM,OAAO,UAAU;AAAA,MAC9F,KAAK;AAAA,MAEJ;AAAA;AAAA,QACA;AAAA,QAEC,6CAAC,OAAE,WAAU,aAAY,OAAO,gBAAgB,mCAEhD;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAM,gBAAgB,CAAC,UAA4B;AACjD,MAAI,gBAAgB,MAAM;AAG1B,QAAM,qBAAqB,CAAC,SAAkB,cAA+B;AAC3E,WAAO,WAAW,YAAY,SAAS,MAAM;AAC3C,UAAI,QAAQ,UAAU,SAAS,SAAS,GAAG;AACzC,eAAO;AAAA,MACT;AACA,gBAAU,QAAQ;AAAA,IACpB;AACA,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,mBAAmB,eAAe,oBAAoB,GAAG;AAC5D,UAAM,eAAe;AAAA,EACvB;AACF;AAEA,SAAS,UAAU;AACjB,SAAO,sBAAsB,KAAK,UAAU,SAAS;AACvD;","names":["import_react","React","import_jsx_runtime","React","_a"]}
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  Window
3
- } from "../../chunk-P7S3E5UW.mjs";
3
+ } from "../../chunk-QSUC3MKT.mjs";
4
+ import "../../chunk-JGMFJZMG.mjs";
4
5
  import "../../chunk-UN2E3HCK.mjs";
5
6
  import "../../chunk-ORSMX3SE.mjs";
6
7
  import "../../chunk-MRXNTQOX.mjs";
@@ -389,6 +389,16 @@ var ChatContextProvider = ({
389
389
 
390
390
  // src/components/chat/Window.tsx
391
391
  var import_react2 = __toESM(require("react"));
392
+ var import_react_core = require("@copilotkit/react-core");
393
+
394
+ // src/hooks/use-dark-mode.ts
395
+ var useDarkMode = () => {
396
+ if (typeof window === "undefined")
397
+ return false;
398
+ return document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") || document.documentElement.getAttribute("data-theme") === "dark" || document.body.getAttribute("data-theme") === "dark" || window.matchMedia("(prefers-color-scheme: dark)").matches;
399
+ };
400
+
401
+ // src/components/chat/Window.tsx
392
402
  var import_jsx_runtime3 = require("react/jsx-runtime");
393
403
  var Window = ({
394
404
  children,
@@ -396,15 +406,17 @@ var Window = ({
396
406
  shortcut,
397
407
  hitEscapeToClose
398
408
  }) => {
409
+ var _a;
399
410
  const windowRef = import_react2.default.useRef(null);
411
+ const context = (0, import_react_core.useCopilotContext)();
400
412
  const { open, setOpen } = useChatContext();
401
413
  const handleClickOutside = (0, import_react2.useCallback)(
402
414
  (event) => {
403
- var _a;
415
+ var _a2;
404
416
  if (!clickOutsideToClose) {
405
417
  return;
406
418
  }
407
- const parentElement = (_a = windowRef.current) == null ? void 0 : _a.parentElement;
419
+ const parentElement = (_a2 = windowRef.current) == null ? void 0 : _a2.parentElement;
408
420
  let className = "";
409
421
  if (event.target instanceof HTMLElement) {
410
422
  className = event.target.className;
@@ -418,10 +430,10 @@ var Window = ({
418
430
  );
419
431
  const handleKeyDown = (0, import_react2.useCallback)(
420
432
  (event) => {
421
- var _a;
433
+ var _a2;
422
434
  const target = event.target;
423
435
  const isInput = target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.isContentEditable;
424
- const isDescendantOfWrapper = (_a = windowRef.current) == null ? void 0 : _a.contains(target);
436
+ const isDescendantOfWrapper = (_a2 = windowRef.current) == null ? void 0 : _a2.contains(target);
425
437
  if (open && event.key === "Escape" && (!isInput || isDescendantOfWrapper) && hitEscapeToClose) {
426
438
  setOpen(false);
427
439
  } else if (event.key === shortcut && (isMacOS() && event.metaKey || !isMacOS() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
@@ -476,7 +488,29 @@ var Window = ({
476
488
  }
477
489
  };
478
490
  }, [adjustForMobile, handleClickOutside, handleKeyDown]);
479
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `copilotKitWindow${open ? " open" : ""}`, ref: windowRef, children });
491
+ const isDark = useDarkMode();
492
+ const showPoweredBy = !((_a = context.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
493
+ const poweredByStyle = {
494
+ visibility: "visible",
495
+ display: "block",
496
+ position: "static",
497
+ textAlign: "center",
498
+ fontSize: "12px",
499
+ padding: "3px 0",
500
+ color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
501
+ };
502
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
503
+ "div",
504
+ {
505
+ className: `copilotKitWindow ${showPoweredBy ? " poweredByContainer" : ""} ${open ? " open" : ""}`,
506
+ ref: windowRef,
507
+ children: [
508
+ children,
509
+ showPoweredBy && // @ts-expect-error -- expecting position not to be a string, but it can be.
510
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" })
511
+ ]
512
+ }
513
+ );
480
514
  };
481
515
  var preventScroll = (event) => {
482
516
  let targetElement = event.target;
@@ -515,7 +549,7 @@ var Button = ({}) => {
515
549
  };
516
550
 
517
551
  // src/components/dev-console/utils.ts
518
- var import_react_core = require("@copilotkit/react-core");
552
+ var import_react_core2 = require("@copilotkit/react-core");
519
553
  function shouldShowDevConsole(showDevConsole) {
520
554
  if (typeof showDevConsole === "boolean") {
521
555
  return showDevConsole;
@@ -577,7 +611,7 @@ function getPublishedCopilotKitVersion(current, forceCheck = false) {
577
611
  }
578
612
  function logReadables(context) {
579
613
  console.log("%cCurrent Readables:", "font-size: 16px; font-weight: bold;");
580
- const readables = context.getContextString([], import_react_core.defaultCopilotContextCategories).trim();
614
+ const readables = context.getContextString([], import_react_core2.defaultCopilotContextCategories).trim();
581
615
  if (readables.length === 0) {
582
616
  console.log("No readables found");
583
617
  return;
@@ -647,7 +681,7 @@ function logMessages(context) {
647
681
  }
648
682
 
649
683
  // src/components/dev-console/console.tsx
650
- var import_react_core2 = require("@copilotkit/react-core");
684
+ var import_react_core3 = require("@copilotkit/react-core");
651
685
  var import_react4 = require("react");
652
686
 
653
687
  // src/components/dev-console/icons.tsx
@@ -837,7 +871,7 @@ function CopilotKitHelpModal() {
837
871
  var import_jsx_runtime8 = require("react/jsx-runtime");
838
872
  function CopilotDevConsole() {
839
873
  const currentVersion = import_shared.COPILOTKIT_VERSION;
840
- const context = (0, import_react_core2.useCopilotContext)();
874
+ const context = (0, import_react_core3.useCopilotContext)();
841
875
  const [showDevConsole, setShowDevConsole] = (0, import_react4.useState)(false);
842
876
  (0, import_react4.useEffect)(() => {
843
877
  setShowDevConsole(shouldShowDevConsole(context.showDevConsole));
@@ -968,8 +1002,8 @@ function DebugMenuButton({
968
1002
  checkForUpdates,
969
1003
  mode
970
1004
  }) {
971
- const context = (0, import_react_core2.useCopilotContext)();
972
- const messagesContext = (0, import_react_core2.useCopilotMessagesContext)();
1005
+ const context = (0, import_react_core3.useCopilotContext)();
1006
+ const messagesContext = (0, import_react_core3.useCopilotMessagesContext)();
973
1007
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react5.Menu, { children: [
974
1008
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
975
1009
  import_react5.MenuButton,
@@ -1032,7 +1066,7 @@ var Header = ({}) => {
1032
1066
  // src/components/chat/Messages.tsx
1033
1067
  var import_react6 = require("react");
1034
1068
  var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
1035
- var import_react_core3 = require("@copilotkit/react-core");
1069
+ var import_react_core4 = require("@copilotkit/react-core");
1036
1070
  var import_jsx_runtime10 = require("react/jsx-runtime");
1037
1071
  var Messages = ({
1038
1072
  messages,
@@ -1068,7 +1102,7 @@ var Messages = ({
1068
1102
  }
1069
1103
  }
1070
1104
  const { messagesEndRef, messagesContainerRef } = useScrollToBottom(messages);
1071
- const interrupt = (0, import_react_core3.useLangGraphInterruptRender)();
1105
+ const interrupt = (0, import_react_core4.useLangGraphInterruptRender)();
1072
1106
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
1073
1107
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitMessagesContainer", children: [
1074
1108
  messages.map((message, index) => {
@@ -1266,7 +1300,7 @@ var AutoResizingTextarea = (0, import_react7.forwardRef)(
1266
1300
  var Textarea_default = AutoResizingTextarea;
1267
1301
 
1268
1302
  // src/hooks/use-push-to-talk.tsx
1269
- var import_react_core4 = require("@copilotkit/react-core");
1303
+ var import_react_core5 = require("@copilotkit/react-core");
1270
1304
  var import_react8 = require("react");
1271
1305
  var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
1272
1306
  if (!mediaStreamRef.current || !audioContextRef.current) {
@@ -1321,8 +1355,8 @@ var usePushToTalk = ({
1321
1355
  const audioContextRef = (0, import_react8.useRef)(null);
1322
1356
  const mediaRecorderRef = (0, import_react8.useRef)(null);
1323
1357
  const recordedChunks = (0, import_react8.useRef)([]);
1324
- const generalContext = (0, import_react_core4.useCopilotContext)();
1325
- const messagesContext = (0, import_react_core4.useCopilotMessagesContext)();
1358
+ const generalContext = (0, import_react_core5.useCopilotContext)();
1359
+ const messagesContext = (0, import_react_core5.useCopilotMessagesContext)();
1326
1360
  const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
1327
1361
  const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react8.useState)(null);
1328
1362
  (0, import_react8.useEffect)(() => {
@@ -1370,11 +1404,11 @@ var usePushToTalk = ({
1370
1404
  };
1371
1405
 
1372
1406
  // src/components/chat/Input.tsx
1373
- var import_react_core5 = require("@copilotkit/react-core");
1407
+ var import_react_core6 = require("@copilotkit/react-core");
1374
1408
  var import_jsx_runtime12 = require("react/jsx-runtime");
1375
1409
  var Input = ({ inProgress, onSend, isVisible = false, onStop }) => {
1376
1410
  const context = useChatContext();
1377
- const copilotContext = (0, import_react_core5.useCopilotContext)();
1411
+ const copilotContext = (0, import_react_core6.useCopilotContext)();
1378
1412
  const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
1379
1413
  const textareaRef = (0, import_react9.useRef)(null);
1380
1414
  const handleDivClick = (event) => {
@@ -2080,7 +2114,7 @@ function RenderTextMessage(_a) {
2080
2114
 
2081
2115
  // src/components/chat/messages/RenderActionExecutionMessage.tsx
2082
2116
  var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
2083
- var import_react_core6 = require("@copilotkit/react-core");
2117
+ var import_react_core7 = require("@copilotkit/react-core");
2084
2118
  var import_jsx_runtime18 = require("react/jsx-runtime");
2085
2119
  function RenderActionExecutionMessage(_a) {
2086
2120
  var _b = _a, {
@@ -2088,7 +2122,7 @@ function RenderActionExecutionMessage(_a) {
2088
2122
  } = _b, props = __objRest(_b, [
2089
2123
  "AssistantMessage"
2090
2124
  ]);
2091
- const { chatComponentsCache } = (0, import_react_core6.useCopilotContext)();
2125
+ const { chatComponentsCache } = (0, import_react_core7.useCopilotContext)();
2092
2126
  const { message, inProgress, index, isCurrentMessage, actionResult } = props;
2093
2127
  if (message.isActionExecutionMessage()) {
2094
2128
  if (chatComponentsCache.current !== null && (chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"])) {
@@ -2217,7 +2251,7 @@ function RenderResultMessage(_a) {
2217
2251
  }
2218
2252
 
2219
2253
  // src/components/chat/messages/RenderAgentStateMessage.tsx
2220
- var import_react_core7 = require("@copilotkit/react-core");
2254
+ var import_react_core8 = require("@copilotkit/react-core");
2221
2255
  var import_jsx_runtime20 = require("react/jsx-runtime");
2222
2256
  function RenderAgentStateMessage(_a) {
2223
2257
  var _b = _a, {
@@ -2225,7 +2259,7 @@ function RenderAgentStateMessage(_a) {
2225
2259
  } = _b, props = __objRest(_b, [
2226
2260
  "AssistantMessage"
2227
2261
  ]);
2228
- const { chatComponentsCache } = (0, import_react_core7.useCopilotContext)();
2262
+ const { chatComponentsCache } = (0, import_react_core8.useCopilotContext)();
2229
2263
  const { message, inProgress, index, isCurrentMessage } = props;
2230
2264
  if (message.isAgentStateMessage()) {
2231
2265
  let render;
@@ -2318,7 +2352,7 @@ function RenderAgentStateMessage(_a) {
2318
2352
  }
2319
2353
 
2320
2354
  // src/components/chat/Suggestion.tsx
2321
- var import_react_core8 = require("@copilotkit/react-core");
2355
+ var import_react_core9 = require("@copilotkit/react-core");
2322
2356
  var import_shared2 = require("@copilotkit/shared");
2323
2357
  var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
2324
2358
  var import_jsx_runtime21 = require("react/jsx-runtime");
@@ -2350,7 +2384,7 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
2350
2384
  for (const config of Object.values(chatSuggestionConfiguration)) {
2351
2385
  try {
2352
2386
  const numOfSuggestionsInstructions = config.minSuggestions === 0 ? `Produce up to ${config.maxSuggestions} suggestions. If there are no highly relevant suggestions you can think of, provide an empty array.` : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;
2353
- const result = yield (0, import_react_core8.extract)({
2387
+ const result = yield (0, import_react_core9.extract)({
2354
2388
  context,
2355
2389
  instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. ",
2356
2390
  data: config.instructions + "\n\n" + numOfSuggestionsInstructions + "\n\nAvailable tools: " + tools + "\n\n",
@@ -2409,10 +2443,10 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
2409
2443
 
2410
2444
  // src/components/chat/Chat.tsx
2411
2445
  var import_react13 = __toESM(require("react"));
2412
- var import_react_core9 = require("@copilotkit/react-core");
2446
+ var import_react_core10 = require("@copilotkit/react-core");
2413
2447
  var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
2414
2448
  var import_shared3 = require("@copilotkit/shared");
2415
- var import_react_core10 = require("@copilotkit/react-core");
2449
+ var import_react_core11 = require("@copilotkit/react-core");
2416
2450
  var import_jsx_runtime22 = require("react/jsx-runtime");
2417
2451
  function CopilotChat({
2418
2452
  instructions,
@@ -2437,7 +2471,7 @@ function CopilotChat({
2437
2471
  AssistantMessage: AssistantMessage2 = AssistantMessage,
2438
2472
  UserMessage: UserMessage2 = UserMessage
2439
2473
  }) {
2440
- const { additionalInstructions, setChatInstructions } = (0, import_react_core9.useCopilotContext)();
2474
+ const { additionalInstructions, setChatInstructions } = (0, import_react_core10.useCopilotContext)();
2441
2475
  (0, import_react13.useEffect)(() => {
2442
2476
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2443
2477
  setChatInstructions(instructions || "");
@@ -2541,7 +2575,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
2541
2575
  stopGeneration: defaultStopGeneration,
2542
2576
  runChatCompletion,
2543
2577
  isLoading
2544
- } = (0, import_react_core9.useCopilotChat)({
2578
+ } = (0, import_react_core10.useCopilotChat)({
2545
2579
  id: (0, import_shared3.randomId)(),
2546
2580
  makeSystemMessage
2547
2581
  });
@@ -2553,8 +2587,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
2553
2587
  (_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
2554
2588
  suggestionsAbortControllerRef.current = null;
2555
2589
  };
2556
- const generalContext = (0, import_react_core9.useCopilotContext)();
2557
- const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
2590
+ const generalContext = (0, import_react_core10.useCopilotContext)();
2591
+ const messagesContext = (0, import_react_core10.useCopilotMessagesContext)();
2558
2592
  const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
2559
2593
  (0, import_react13.useEffect)(() => {
2560
2594
  onInProgress == null ? void 0 : onInProgress(isLoading);
@@ -2622,7 +2656,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
2622
2656
  });
2623
2657
  const runCurrentAgent = (hint) => __async(void 0, null, function* () {
2624
2658
  if (generalContext.agentSession) {
2625
- yield (0, import_react_core10.runAgent)(
2659
+ yield (0, import_react_core11.runAgent)(
2626
2660
  generalContext.agentSession.agentName,
2627
2661
  context,
2628
2662
  appendMessage,
@@ -2633,7 +2667,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
2633
2667
  });
2634
2668
  const stopCurrentAgent = () => {
2635
2669
  if (generalContext.agentSession) {
2636
- (0, import_react_core10.stopAgent)(generalContext.agentSession.agentName, context);
2670
+ (0, import_react_core11.stopAgent)(generalContext.agentSession.agentName, context);
2637
2671
  }
2638
2672
  };
2639
2673
  const setCurrentAgentState = (state) => {