@copilotkit/react-ui 1.51.4-next.7 → 1.51.4-next.8

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 (226) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +18 -12
  3. package/dist/{chunk-O72ZB5V3.mjs → chunk-2QEDCM6H.mjs} +22 -12
  4. package/dist/chunk-2QEDCM6H.mjs.map +1 -0
  5. package/dist/{chunk-54JAUBUJ.mjs → chunk-6SMTHXVA.mjs} +4 -2
  6. package/dist/chunk-6SMTHXVA.mjs.map +1 -0
  7. package/dist/{chunk-IEMQ2SQW.mjs → chunk-6TLDRWAD.mjs} +5 -3
  8. package/dist/{chunk-IEMQ2SQW.mjs.map → chunk-6TLDRWAD.mjs.map} +1 -1
  9. package/dist/{chunk-UFN2VWSR.mjs → chunk-72FQQMQ2.mjs} +2 -2
  10. package/dist/chunk-72FQQMQ2.mjs.map +1 -0
  11. package/dist/{chunk-ELGRNEAO.mjs → chunk-AOUHT4JR.mjs} +4 -2
  12. package/dist/chunk-AOUHT4JR.mjs.map +1 -0
  13. package/dist/{chunk-C3GSYRC3.mjs → chunk-BNJX66OH.mjs} +2 -2
  14. package/dist/{chunk-NRA3CFEE.mjs → chunk-C27LZFA5.mjs} +2 -2
  15. package/dist/{chunk-FFJHOZX6.mjs → chunk-C7WM7GM3.mjs} +44 -11
  16. package/dist/chunk-C7WM7GM3.mjs.map +1 -0
  17. package/dist/{chunk-6TWQUA2Q.mjs → chunk-CNIC5HO5.mjs} +8 -3
  18. package/dist/chunk-CNIC5HO5.mjs.map +1 -0
  19. package/dist/chunk-CQCXH5LY.mjs +143 -0
  20. package/dist/chunk-CQCXH5LY.mjs.map +1 -0
  21. package/dist/{chunk-RYUCX3ZK.mjs → chunk-DM2V5WTG.mjs} +4 -2
  22. package/dist/chunk-DM2V5WTG.mjs.map +1 -0
  23. package/dist/{chunk-JZ3RFQQ6.mjs → chunk-DSHTRV2R.mjs} +16 -4
  24. package/dist/chunk-DSHTRV2R.mjs.map +1 -0
  25. package/dist/{chunk-GDSZGYCE.mjs → chunk-EACIYBQH.mjs} +3 -3
  26. package/dist/{chunk-XWG3L6QC.mjs → chunk-GBAPANZE.mjs} +76 -11
  27. package/dist/chunk-GBAPANZE.mjs.map +1 -0
  28. package/dist/{chunk-Q5V6S67N.mjs → chunk-GFE5ZSPV.mjs} +15 -6
  29. package/dist/chunk-GFE5ZSPV.mjs.map +1 -0
  30. package/dist/{chunk-VHKHX7GV.mjs → chunk-HHLX4MQN.mjs} +2 -2
  31. package/dist/{chunk-WNX755OE.mjs → chunk-ICA2EXIX.mjs} +7 -4
  32. package/dist/chunk-ICA2EXIX.mjs.map +1 -0
  33. package/dist/{chunk-QIOJXTIQ.mjs → chunk-IWOCQACI.mjs} +12 -3
  34. package/dist/chunk-IWOCQACI.mjs.map +1 -0
  35. package/dist/{chunk-BH6PCAAL.mjs → chunk-JYHRHKV5.mjs} +12 -3
  36. package/dist/chunk-JYHRHKV5.mjs.map +1 -0
  37. package/dist/{chunk-IK2BPURM.mjs → chunk-LIXN3OVQ.mjs} +12 -7
  38. package/dist/chunk-LIXN3OVQ.mjs.map +1 -0
  39. package/dist/{chunk-PD36EMOZ.mjs → chunk-MC6PY7XH.mjs} +75 -54
  40. package/dist/chunk-MC6PY7XH.mjs.map +1 -0
  41. package/dist/{chunk-LYYDXL2G.mjs → chunk-OQWEOBRX.mjs} +3 -3
  42. package/dist/chunk-OQWEOBRX.mjs.map +1 -0
  43. package/dist/{chunk-LBR23XXF.mjs → chunk-P34CL4LC.mjs} +4 -4
  44. package/dist/{chunk-F2CDEOFX.mjs → chunk-PF3QBO7V.mjs} +2 -2
  45. package/dist/chunk-PF3QBO7V.mjs.map +1 -0
  46. package/dist/{chunk-7CMZ7YPQ.mjs → chunk-PP2A5RP6.mjs} +2 -2
  47. package/dist/{chunk-7CMZ7YPQ.mjs.map → chunk-PP2A5RP6.mjs.map} +1 -1
  48. package/dist/{chunk-RKQM2AE5.mjs → chunk-Q64GLWPQ.mjs} +2 -2
  49. package/dist/{chunk-RKQM2AE5.mjs.map → chunk-Q64GLWPQ.mjs.map} +1 -1
  50. package/dist/{chunk-OHGUQZJT.mjs → chunk-T4NNQG6T.mjs} +50 -41
  51. package/dist/chunk-T4NNQG6T.mjs.map +1 -0
  52. package/dist/{chunk-DBKRAOH7.mjs → chunk-TGM5PKBF.mjs} +16 -6
  53. package/dist/chunk-TGM5PKBF.mjs.map +1 -0
  54. package/dist/{chunk-JY2CSDKN.mjs → chunk-YDJ4YUUF.mjs} +22 -16
  55. package/dist/chunk-YDJ4YUUF.mjs.map +1 -0
  56. package/dist/components/chat/Button.js +3 -1
  57. package/dist/components/chat/Button.js.map +1 -1
  58. package/dist/components/chat/Button.mjs +3 -3
  59. package/dist/components/chat/Chat.js +285 -132
  60. package/dist/components/chat/Chat.js.map +1 -1
  61. package/dist/components/chat/Chat.mjs +18 -18
  62. package/dist/components/chat/ChatContext.js +63 -9
  63. package/dist/components/chat/ChatContext.js.map +1 -1
  64. package/dist/components/chat/ChatContext.mjs +2 -2
  65. package/dist/components/chat/CodeBlock.js +20 -6
  66. package/dist/components/chat/CodeBlock.js.map +1 -1
  67. package/dist/components/chat/CodeBlock.mjs +3 -3
  68. package/dist/components/chat/Header.js +88 -28
  69. package/dist/components/chat/Header.js.map +1 -1
  70. package/dist/components/chat/Header.mjs +8 -8
  71. package/dist/components/chat/Icons.js +75 -10
  72. package/dist/components/chat/Icons.js.map +1 -1
  73. package/dist/components/chat/Icons.mjs +1 -1
  74. package/dist/components/chat/Input.js +90 -62
  75. package/dist/components/chat/Input.js.map +1 -1
  76. package/dist/components/chat/Input.mjs +6 -6
  77. package/dist/components/chat/Markdown.js +34 -8
  78. package/dist/components/chat/Markdown.js.map +1 -1
  79. package/dist/components/chat/Markdown.mjs +4 -4
  80. package/dist/components/chat/Messages.js +59 -16
  81. package/dist/components/chat/Messages.js.map +1 -1
  82. package/dist/components/chat/Messages.mjs +11 -11
  83. package/dist/components/chat/Modal.js +403 -189
  84. package/dist/components/chat/Modal.js.map +1 -1
  85. package/dist/components/chat/Modal.mjs +27 -27
  86. package/dist/components/chat/Popup.js +403 -189
  87. package/dist/components/chat/Popup.js.map +1 -1
  88. package/dist/components/chat/Popup.mjs +28 -28
  89. package/dist/components/chat/PoweredByTag.d.ts +1 -1
  90. package/dist/components/chat/PoweredByTag.js +3 -1
  91. package/dist/components/chat/PoweredByTag.js.map +1 -1
  92. package/dist/components/chat/PoweredByTag.mjs +1 -1
  93. package/dist/components/chat/Sidebar.js +403 -189
  94. package/dist/components/chat/Sidebar.js.map +1 -1
  95. package/dist/components/chat/Sidebar.mjs +28 -28
  96. package/dist/components/chat/Suggestion.d.ts +1 -1
  97. package/dist/components/chat/Suggestion.js +13 -2
  98. package/dist/components/chat/Suggestion.js.map +1 -1
  99. package/dist/components/chat/Suggestion.mjs +2 -2
  100. package/dist/components/chat/Suggestions.js +13 -2
  101. package/dist/components/chat/Suggestions.js.map +1 -1
  102. package/dist/components/chat/Suggestions.mjs +3 -3
  103. package/dist/components/chat/Textarea.js +4 -1
  104. package/dist/components/chat/Textarea.js.map +1 -1
  105. package/dist/components/chat/Textarea.mjs +1 -1
  106. package/dist/components/chat/Window.js +3 -1
  107. package/dist/components/chat/Window.js.map +1 -1
  108. package/dist/components/chat/Window.mjs +3 -3
  109. package/dist/components/chat/index.js +403 -189
  110. package/dist/components/chat/index.js.map +1 -1
  111. package/dist/components/chat/index.mjs +29 -29
  112. package/dist/components/chat/messages/AssistantMessage.js +37 -9
  113. package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
  114. package/dist/components/chat/messages/AssistantMessage.mjs +6 -6
  115. package/dist/components/chat/messages/ErrorMessage.js +65 -31
  116. package/dist/components/chat/messages/ErrorMessage.js.map +1 -1
  117. package/dist/components/chat/messages/ErrorMessage.mjs +33 -27
  118. package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -1
  119. package/dist/components/chat/messages/ImageRenderer.js +15 -5
  120. package/dist/components/chat/messages/ImageRenderer.js.map +1 -1
  121. package/dist/components/chat/messages/ImageRenderer.mjs +1 -1
  122. package/dist/components/chat/messages/LegacyRenderMessage.js +55 -15
  123. package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
  124. package/dist/components/chat/messages/LegacyRenderMessage.mjs +10 -10
  125. package/dist/components/chat/messages/RenderMessage.js +55 -15
  126. package/dist/components/chat/messages/RenderMessage.js.map +1 -1
  127. package/dist/components/chat/messages/RenderMessage.mjs +9 -9
  128. package/dist/components/chat/messages/UserMessage.js +3 -1
  129. package/dist/components/chat/messages/UserMessage.js.map +1 -1
  130. package/dist/components/chat/messages/UserMessage.mjs +1 -1
  131. package/dist/components/chat/props.js.map +1 -1
  132. package/dist/components/dev-console/console.js +85 -27
  133. package/dist/components/dev-console/console.js.map +1 -1
  134. package/dist/components/dev-console/console.mjs +6 -6
  135. package/dist/components/dev-console/icons.js +14 -5
  136. package/dist/components/dev-console/icons.js.map +1 -1
  137. package/dist/components/dev-console/icons.mjs +1 -1
  138. package/dist/components/dev-console/index.js +85 -27
  139. package/dist/components/dev-console/index.js.map +1 -1
  140. package/dist/components/dev-console/index.mjs +6 -6
  141. package/dist/components/dev-console/utils.js +21 -15
  142. package/dist/components/dev-console/utils.js.map +1 -1
  143. package/dist/components/dev-console/utils.mjs +1 -1
  144. package/dist/components/help-modal/icons.d.ts +1 -1
  145. package/dist/components/help-modal/icons.js +11 -2
  146. package/dist/components/help-modal/icons.js.map +1 -1
  147. package/dist/components/help-modal/icons.mjs +1 -1
  148. package/dist/components/help-modal/index.js +8 -1
  149. package/dist/components/help-modal/index.js.map +1 -1
  150. package/dist/components/help-modal/index.mjs +2 -2
  151. package/dist/components/help-modal/modal.js +8 -1
  152. package/dist/components/help-modal/modal.js.map +1 -1
  153. package/dist/components/help-modal/modal.mjs +2 -2
  154. package/dist/components/index.js +403 -189
  155. package/dist/components/index.js.map +1 -1
  156. package/dist/components/index.mjs +29 -29
  157. package/dist/hooks/use-copy-to-clipboard.d.ts +1 -1
  158. package/dist/hooks/use-copy-to-clipboard.js +3 -1
  159. package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
  160. package/dist/hooks/use-copy-to-clipboard.mjs +1 -1
  161. package/dist/hooks/use-push-to-talk.js +17 -10
  162. package/dist/hooks/use-push-to-talk.js.map +1 -1
  163. package/dist/hooks/use-push-to-talk.mjs +1 -1
  164. package/dist/index.js +403 -189
  165. package/dist/index.js.map +1 -1
  166. package/dist/index.mjs +34 -34
  167. package/dist/index.umd.js.map +1 -1
  168. package/dist/lib/utils.js.map +1 -1
  169. package/dist/lib/utils.mjs.map +1 -1
  170. package/package.json +4 -5
  171. package/src/components/chat/Button.tsx +6 -2
  172. package/src/components/chat/Chat.tsx +75 -48
  173. package/src/components/chat/ChatContext.tsx +6 -2
  174. package/src/components/chat/CodeBlock.tsx +11 -6
  175. package/src/components/chat/Icons.tsx +45 -10
  176. package/src/components/chat/Input.tsx +30 -7
  177. package/src/components/chat/Markdown.tsx +12 -3
  178. package/src/components/chat/Messages.tsx +24 -8
  179. package/src/components/chat/Modal.tsx +12 -2
  180. package/src/components/chat/Popup.tsx +3 -1
  181. package/src/components/chat/PoweredByTag.tsx +5 -1
  182. package/src/components/chat/Sidebar.tsx +3 -1
  183. package/src/components/chat/Suggestion.tsx +6 -1
  184. package/src/components/chat/Textarea.tsx +15 -3
  185. package/src/components/chat/messages/AssistantMessage.tsx +12 -4
  186. package/src/components/chat/messages/ErrorMessage.tsx +3 -1
  187. package/src/components/chat/messages/ImageRenderer.tsx +17 -5
  188. package/src/components/chat/messages/LegacyRenderMessage.tsx +4 -1
  189. package/src/components/chat/messages/UserMessage.tsx +12 -4
  190. package/src/components/chat/props.ts +13 -3
  191. package/src/components/dev-console/console.tsx +35 -9
  192. package/src/components/dev-console/icons.tsx +6 -1
  193. package/src/components/dev-console/utils.ts +23 -15
  194. package/src/components/help-modal/icons.tsx +10 -2
  195. package/src/hooks/use-copy-to-clipboard.tsx +3 -1
  196. package/src/hooks/use-push-to-talk.tsx +45 -18
  197. package/src/lib/utils.ts +4 -1
  198. package/tsconfig.json +1 -1
  199. package/tsup.config.ts +5 -1
  200. package/dist/chunk-3W6J75HS.mjs +0 -126
  201. package/dist/chunk-3W6J75HS.mjs.map +0 -1
  202. package/dist/chunk-54JAUBUJ.mjs.map +0 -1
  203. package/dist/chunk-6TWQUA2Q.mjs.map +0 -1
  204. package/dist/chunk-BH6PCAAL.mjs.map +0 -1
  205. package/dist/chunk-DBKRAOH7.mjs.map +0 -1
  206. package/dist/chunk-ELGRNEAO.mjs.map +0 -1
  207. package/dist/chunk-F2CDEOFX.mjs.map +0 -1
  208. package/dist/chunk-FFJHOZX6.mjs.map +0 -1
  209. package/dist/chunk-IK2BPURM.mjs.map +0 -1
  210. package/dist/chunk-JY2CSDKN.mjs.map +0 -1
  211. package/dist/chunk-JZ3RFQQ6.mjs.map +0 -1
  212. package/dist/chunk-LYYDXL2G.mjs.map +0 -1
  213. package/dist/chunk-O72ZB5V3.mjs.map +0 -1
  214. package/dist/chunk-OHGUQZJT.mjs.map +0 -1
  215. package/dist/chunk-PD36EMOZ.mjs.map +0 -1
  216. package/dist/chunk-Q5V6S67N.mjs.map +0 -1
  217. package/dist/chunk-QIOJXTIQ.mjs.map +0 -1
  218. package/dist/chunk-RYUCX3ZK.mjs.map +0 -1
  219. package/dist/chunk-UFN2VWSR.mjs.map +0 -1
  220. package/dist/chunk-WNX755OE.mjs.map +0 -1
  221. package/dist/chunk-XWG3L6QC.mjs.map +0 -1
  222. /package/dist/{chunk-C3GSYRC3.mjs.map → chunk-BNJX66OH.mjs.map} +0 -0
  223. /package/dist/{chunk-NRA3CFEE.mjs.map → chunk-C27LZFA5.mjs.map} +0 -0
  224. /package/dist/{chunk-GDSZGYCE.mjs.map → chunk-EACIYBQH.mjs.map} +0 -0
  225. /package/dist/{chunk-VHKHX7GV.mjs.map → chunk-HHLX4MQN.mjs.map} +0 -0
  226. /package/dist/{chunk-LBR23XXF.mjs.map → chunk-P34CL4LC.mjs.map} +0 -0
@@ -1,7 +1,11 @@
1
1
  import React, { useState, useEffect } from "react";
2
2
  import { useDarkMode } from "../../hooks/use-dark-mode";
3
3
 
4
- export function PoweredByTag({ showPoweredBy = true }: { showPoweredBy?: boolean }) {
4
+ export function PoweredByTag({
5
+ showPoweredBy = true,
6
+ }: {
7
+ showPoweredBy?: boolean;
8
+ }) {
5
9
  const [mounted, setMounted] = useState(false);
6
10
  const isDark = useDarkMode();
7
11
 
@@ -75,7 +75,9 @@ import { CopilotModal, CopilotModalProps } from "./Modal";
75
75
  export function CopilotSidebar(props: CopilotModalProps) {
76
76
  props = {
77
77
  ...props,
78
- className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar",
78
+ className: props.className
79
+ ? props.className + " copilotKitSidebar"
80
+ : "copilotKitSidebar",
79
81
  };
80
82
  const [expandedClassName, setExpandedClassName] = useState(
81
83
  props.defaultOpen ? "sidebarExpanded" : "",
@@ -9,7 +9,12 @@ interface SuggestionsProps {
9
9
  onClick: () => void;
10
10
  }
11
11
 
12
- export function Suggestion({ title, onClick, partial, className }: SuggestionsProps) {
12
+ export function Suggestion({
13
+ title,
14
+ onClick,
15
+ partial,
16
+ className,
17
+ }: SuggestionsProps) {
13
18
  const { isLoading } = useCopilotChatInternal();
14
19
  if (!title) return null;
15
20
 
@@ -1,4 +1,10 @@
1
- import React, { useState, useRef, useEffect, forwardRef, useImperativeHandle } from "react";
1
+ import React, {
2
+ useState,
3
+ useRef,
4
+ useEffect,
5
+ forwardRef,
6
+ useImperativeHandle,
7
+ } from "react";
2
8
 
3
9
  interface AutoResizingTextareaProps {
4
10
  maxRows?: number;
@@ -11,7 +17,10 @@ interface AutoResizingTextareaProps {
11
17
  autoFocus?: boolean;
12
18
  }
13
19
 
14
- const AutoResizingTextarea = forwardRef<HTMLTextAreaElement, AutoResizingTextareaProps>(
20
+ const AutoResizingTextarea = forwardRef<
21
+ HTMLTextAreaElement,
22
+ AutoResizingTextareaProps
23
+ >(
15
24
  (
16
25
  {
17
26
  maxRows = 1,
@@ -28,7 +37,10 @@ const AutoResizingTextarea = forwardRef<HTMLTextAreaElement, AutoResizingTextare
28
37
  const internalTextareaRef = useRef<HTMLTextAreaElement>(null);
29
38
  const [maxHeight, setMaxHeight] = useState<number>(0);
30
39
 
31
- useImperativeHandle(ref, () => internalTextareaRef.current as HTMLTextAreaElement);
40
+ useImperativeHandle(
41
+ ref,
42
+ () => internalTextareaRef.current as HTMLTextAreaElement,
43
+ );
32
44
 
33
45
  useEffect(() => {
34
46
  const calculateMaxHeight = () => {
@@ -58,10 +58,14 @@ export const AssistantMessage = (props: AssistantMessageProps) => {
58
58
 
59
59
  return (
60
60
  <>
61
- {renderBefore ? <div style={{ marginBottom: "0.5rem" }}>{subComponent}</div> : null}
61
+ {renderBefore ? (
62
+ <div style={{ marginBottom: "0.5rem" }}>{subComponent}</div>
63
+ ) : null}
62
64
  {content && (
63
65
  <div className="copilotKitMessage copilotKitAssistantMessage">
64
- {content && <Markdown content={content} components={markdownTagRenderers} />}
66
+ {content && (
67
+ <Markdown content={content} components={markdownTagRenderers} />
68
+ )}
65
69
 
66
70
  {content && !isLoading && (
67
71
  <div
@@ -82,7 +86,9 @@ export const AssistantMessage = (props: AssistantMessageProps) => {
82
86
  title={labels.copyToClipboard}
83
87
  >
84
88
  {copied ? (
85
- <span style={{ fontSize: "10px", fontWeight: "bold" }}>✓</span>
89
+ <span style={{ fontSize: "10px", fontWeight: "bold" }}>
90
+
91
+ </span>
86
92
  ) : (
87
93
  icons.copyIcon
88
94
  )}
@@ -115,7 +121,9 @@ export const AssistantMessage = (props: AssistantMessageProps) => {
115
121
  )}
116
122
  </div>
117
123
  )}
118
- {renderAfter ? <div style={{ marginBottom: "0.5rem" }}>{subComponent}</div> : null}
124
+ {renderAfter ? (
125
+ <div style={{ marginBottom: "0.5rem" }}>{subComponent}</div>
126
+ ) : null}
119
127
  {isLoading && <LoadingIcon />}
120
128
  </>
121
129
  );
@@ -32,7 +32,9 @@ export const ErrorMessage = (props: ErrorMessageProps) => {
32
32
  <div className="copilotKitMessage copilotKitAssistantMessage">
33
33
  <Markdown content={error.message} />
34
34
 
35
- <div className={`copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`}>
35
+ <div
36
+ className={`copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`}
37
+ >
36
38
  <button
37
39
  className="copilotKitMessageControlButton"
38
40
  onClick={handleRegenerate}
@@ -5,7 +5,11 @@ import { ImageRendererProps } from "../props";
5
5
  * Default image rendering component that can be customized by users.
6
6
  * Uses CSS classes for styling so users can override styles.
7
7
  */
8
- export const ImageRenderer: React.FC<ImageRendererProps> = ({ image, content, className = "" }) => {
8
+ export const ImageRenderer: React.FC<ImageRendererProps> = ({
9
+ image,
10
+ content,
11
+ className = "",
12
+ }) => {
9
13
  const [imageError, setImageError] = useState(false);
10
14
  const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
11
15
  const altText = content || "User uploaded image";
@@ -16,9 +20,15 @@ export const ImageRenderer: React.FC<ImageRendererProps> = ({ image, content, cl
16
20
 
17
21
  if (imageError) {
18
22
  return (
19
- <div className={`copilotKitImageRendering copilotKitImageRenderingError ${className}`}>
20
- <div className="copilotKitImageRenderingErrorMessage">Failed to load image</div>
21
- {content && <div className="copilotKitImageRenderingContent">{content}</div>}
23
+ <div
24
+ className={`copilotKitImageRendering copilotKitImageRenderingError ${className}`}
25
+ >
26
+ <div className="copilotKitImageRenderingErrorMessage">
27
+ Failed to load image
28
+ </div>
29
+ {content && (
30
+ <div className="copilotKitImageRenderingContent">{content}</div>
31
+ )}
22
32
  </div>
23
33
  );
24
34
  }
@@ -31,7 +41,9 @@ export const ImageRenderer: React.FC<ImageRendererProps> = ({ image, content, cl
31
41
  className="copilotKitImageRenderingImage"
32
42
  onError={handleImageError}
33
43
  />
34
- {content && <div className="copilotKitImageRenderingContent">{content}</div>}
44
+ {content && (
45
+ <div className="copilotKitImageRenderingContent">{content}</div>
46
+ )}
35
47
  </div>
36
48
  );
37
49
  };
@@ -72,7 +72,10 @@ export const LegacyRenderMessage: React.FC<LegacyRenderMessageProps> = ({
72
72
  );
73
73
  }
74
74
 
75
- if (deprecatedMessage.isActionExecutionMessage() && RenderActionExecutionMessage) {
75
+ if (
76
+ deprecatedMessage.isActionExecutionMessage() &&
77
+ RenderActionExecutionMessage
78
+ ) {
76
79
  return (
77
80
  <RenderActionExecutionMessage
78
81
  messages={messages}
@@ -2,7 +2,9 @@ import { UserMessageProps } from "../props";
2
2
 
3
3
  type UserMessageContent = NonNullable<UserMessageProps["message"]>["content"];
4
4
 
5
- const getTextContent = (content: UserMessageContent | undefined): string | undefined => {
5
+ const getTextContent = (
6
+ content: UserMessageContent | undefined,
7
+ ): string | undefined => {
6
8
  if (typeof content === "undefined") {
7
9
  return undefined;
8
10
  }
@@ -19,7 +21,10 @@ const getTextContent = (content: UserMessageContent | undefined): string | undef
19
21
  }
20
22
  return undefined;
21
23
  })
22
- .filter((value): value is string => typeof value === "string" && value.length > 0)
24
+ .filter(
25
+ (value): value is string =>
26
+ typeof value === "string" && value.length > 0,
27
+ )
23
28
  .join(" ")
24
29
  .trim() || undefined
25
30
  );
@@ -27,7 +32,8 @@ const getTextContent = (content: UserMessageContent | undefined): string | undef
27
32
 
28
33
  export const UserMessage = (props: UserMessageProps) => {
29
34
  const { message, ImageRenderer } = props;
30
- const isImageMessage = message && "image" in message && Boolean(message.image);
35
+ const isImageMessage =
36
+ message && "image" in message && Boolean(message.image);
31
37
 
32
38
  if (isImageMessage) {
33
39
  const imageMessage = message!;
@@ -42,5 +48,7 @@ export const UserMessage = (props: UserMessageProps) => {
42
48
 
43
49
  const content = getTextContent(message?.content);
44
50
 
45
- return <div className="copilotKitMessage copilotKitUserMessage">{content}</div>;
51
+ return (
52
+ <div className="copilotKitMessage copilotKitUserMessage">{content}</div>
53
+ );
46
54
  };
@@ -1,4 +1,9 @@
1
- import { AIMessage, Message, UserMessage, CopilotErrorEvent } from "@copilotkit/shared";
1
+ import {
2
+ AIMessage,
3
+ Message,
4
+ UserMessage,
5
+ CopilotErrorEvent,
6
+ } from "@copilotkit/shared";
2
7
  import { CopilotChatSuggestion } from "../../types/suggestions";
3
8
  import { ReactNode } from "react";
4
9
  import { ImageData } from "@copilotkit/shared";
@@ -36,7 +41,10 @@ export interface CopilotObservabilityHooks {
36
41
  /**
37
42
  * Called when feedback is given (thumbs up/down)
38
43
  */
39
- onFeedbackGiven?: (messageId: string, type: "thumbsUp" | "thumbsDown") => void;
44
+ onFeedbackGiven?: (
45
+ messageId: string,
46
+ type: "thumbsUp" | "thumbsDown",
47
+ ) => void;
40
48
 
41
49
  /**
42
50
  * Called when chat generation starts
@@ -74,7 +82,9 @@ export interface SuggestionsProps {
74
82
  onClick: (message: string) => void;
75
83
  }
76
84
 
77
- export type ComponentsMap<T extends Record<string, object> = Record<string, object>> = {
85
+ export type ComponentsMap<
86
+ T extends Record<string, object> = Record<string, object>,
87
+ > = {
78
88
  [K in keyof T]: React.FC<{ children?: ReactNode } & T[K]>;
79
89
  };
80
90
 
@@ -1,6 +1,9 @@
1
1
  "use client";
2
2
 
3
- import { useCopilotContext, useCopilotMessagesContext } from "@copilotkit/react-core";
3
+ import {
4
+ useCopilotContext,
5
+ useCopilotMessagesContext,
6
+ } from "@copilotkit/react-core";
4
7
  import {
5
8
  getPublishedCopilotKitVersion,
6
9
  logActions,
@@ -21,7 +24,12 @@ import { COPILOTKIT_VERSION } from "@copilotkit/shared";
21
24
  import { SmallSpinnerIcon } from "../chat/Icons";
22
25
  import { CopilotKitHelpModal } from "../help-modal";
23
26
 
24
- type VersionStatus = "unknown" | "checking" | "latest" | "update-available" | "outdated";
27
+ type VersionStatus =
28
+ | "unknown"
29
+ | "checking"
30
+ | "latest"
31
+ | "update-available"
32
+ | "outdated";
25
33
 
26
34
  export function CopilotDevConsole() {
27
35
  const currentVersion = COPILOTKIT_VERSION;
@@ -42,7 +50,9 @@ export function CopilotDevConsole() {
42
50
  const [versionStatus, setVersionStatus] = useState<VersionStatus>("unknown");
43
51
  const [latestVersion, setLatestVersion] = useState<string>("");
44
52
  const consoleRef = useRef<HTMLDivElement>(null);
45
- const [debugButtonMode, setDebugButtonMode] = useState<"full" | "compact">("full");
53
+ const [debugButtonMode, setDebugButtonMode] = useState<"full" | "compact">(
54
+ "full",
55
+ );
46
56
 
47
57
  const checkForUpdates = (force: boolean = false) => {
48
58
  setVersionStatus("checking");
@@ -90,7 +100,9 @@ export function CopilotDevConsole() {
90
100
  ref={consoleRef}
91
101
  className={
92
102
  "copilotKitDevConsole " +
93
- (versionStatus === "update-available" ? "copilotKitDevConsoleUpgrade" : "") +
103
+ (versionStatus === "update-available"
104
+ ? "copilotKitDevConsoleUpgrade"
105
+ : "") +
94
106
  (versionStatus === "outdated" ? "copilotKitDevConsoleWarnOutdated" : "")
95
107
  }
96
108
  >
@@ -171,7 +183,9 @@ function VersionInfo({
171
183
  <p>
172
184
  {currentVersionLabel} {versionIcon}
173
185
  </p>
174
- <button onClick={handleCopyClick}>{copyStatus || installCommand}</button>
186
+ <button onClick={handleCopyClick}>
187
+ {copyStatus || installCommand}
188
+ </button>
175
189
  </div>
176
190
  );
177
191
  }
@@ -207,12 +221,18 @@ export default function DebugMenuButton({
207
221
  style={{ zIndex: 40 }}
208
222
  >
209
223
  <MenuItem>
210
- <button className="copilotKitDebugMenuItem" onClick={() => logReadables(context)}>
224
+ <button
225
+ className="copilotKitDebugMenuItem"
226
+ onClick={() => logReadables(context)}
227
+ >
211
228
  Log Readables
212
229
  </button>
213
230
  </MenuItem>
214
231
  <MenuItem>
215
- <button className="copilotKitDebugMenuItem" onClick={() => logActions(context)}>
232
+ <button
233
+ className="copilotKitDebugMenuItem"
234
+ onClick={() => logActions(context)}
235
+ >
216
236
  Log Actions
217
237
  </button>
218
238
  </MenuItem>
@@ -225,13 +245,19 @@ export default function DebugMenuButton({
225
245
  </button>
226
246
  </MenuItem>
227
247
  <MenuItem>
228
- <button className="copilotKitDebugMenuItem" onClick={() => checkForUpdates(true)}>
248
+ <button
249
+ className="copilotKitDebugMenuItem"
250
+ onClick={() => checkForUpdates(true)}
251
+ >
229
252
  Check for Updates
230
253
  </button>
231
254
  </MenuItem>
232
255
  <hr />
233
256
  <MenuItem>
234
- <button className="copilotKitDebugMenuItem" onClick={() => setShowDevConsole(false)}>
257
+ <button
258
+ className="copilotKitDebugMenuItem"
259
+ onClick={() => setShowDevConsole(false)}
260
+ >
235
261
  Hide Dev Console
236
262
  </button>
237
263
  </MenuItem>
@@ -65,7 +65,12 @@ export const CheckIcon = (
65
65
  xmlns="http://www.w3.org/2000/svg"
66
66
  >
67
67
  <g id="Page-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
68
- <g id="Group-2" transform="translate(-118, 0)" fill="#1BC030" fillRule="nonzero">
68
+ <g
69
+ id="Group-2"
70
+ transform="translate(-118, 0)"
71
+ fill="#1BC030"
72
+ fillRule="nonzero"
73
+ >
69
74
  <g id="Group" transform="translate(118, 0)">
70
75
  <path
71
76
  d="M0,7 C0,3.13384615 3.13384615,0 7,0 C10.8661538,0 14,3.13384615 14,7 C14,10.8661538 10.8661538,14 7,14 C3.13384615,14 0,10.8661538 0,7 Z M9.59179487,5.69764103 C9.70905818,5.54139023 9.73249341,5.33388318 9.65303227,5.15541491 C9.57357113,4.97694665 9.40367989,4.85551619 9.20909814,4.83811118 C9.01451638,4.82070616 8.82577109,4.91005717 8.71589744,5.07158974 L6.39261538,8.32389744 L5.22666667,7.15794872 C5.01450582,6.96025518 4.68389046,6.9660885 4.47883563,7.17114332 C4.27378081,7.37619815 4.26794748,7.70681351 4.46564103,7.91897436 L6.08102564,9.53435897 C6.19289944,9.64614839 6.3482622,9.70310251 6.50588106,9.69010587 C6.66349993,9.67710922 6.80743532,9.59547613 6.89948718,9.46687179 L9.59179487,5.69764103 L9.59179487,5.69764103 Z"
@@ -25,25 +25,31 @@ export async function getPublishedCopilotKitVersion(
25
25
  return parsedVersion;
26
26
  }
27
27
  } catch (error) {
28
- console.error("Failed to parse CopilotKitVersion from localStorage", error);
28
+ console.error(
29
+ "Failed to parse CopilotKitVersion from localStorage",
30
+ error,
31
+ );
29
32
  }
30
33
  }
31
34
 
32
35
  try {
33
- const response = await fetch("https://api.cloud.copilotkit.ai/check-for-updates", {
34
- method: "POST",
35
- headers: {
36
- "Content-Type": "application/json",
36
+ const response = await fetch(
37
+ "https://api.cloud.copilotkit.ai/check-for-updates",
38
+ {
39
+ method: "POST",
40
+ headers: {
41
+ "Content-Type": "application/json",
42
+ },
43
+ body: JSON.stringify({
44
+ packages: [
45
+ {
46
+ packageName: "@copilotkit/shared",
47
+ packageVersion: current,
48
+ },
49
+ ],
50
+ }),
37
51
  },
38
- body: JSON.stringify({
39
- packages: [
40
- {
41
- packageName: "@copilotkit/shared",
42
- packageVersion: current,
43
- },
44
- ],
45
- }),
46
- });
52
+ );
47
53
 
48
54
  const data = await response.json();
49
55
 
@@ -66,7 +72,9 @@ export async function getPublishedCopilotKitVersion(
66
72
  export function logReadables(context: CopilotContextParams) {
67
73
  console.log("%cCurrent Readables:", "font-size: 16px; font-weight: bold;");
68
74
 
69
- const readables = context.getContextString([], defaultCopilotContextCategories).trim();
75
+ const readables = context
76
+ .getContextString([], defaultCopilotContextCategories)
77
+ .trim();
70
78
  if (readables.length === 0) {
71
79
  console.log("No readables found");
72
80
  return;
@@ -35,11 +35,19 @@ export const CloseIcon = () => (
35
35
  width="20"
36
36
  height="20"
37
37
  >
38
- <path strokeLinecap="round" strokeLinejoin="round" d="M6 18L18 6M6 6l12 12" />
38
+ <path
39
+ strokeLinecap="round"
40
+ strokeLinejoin="round"
41
+ d="M6 18L18 6M6 6l12 12"
42
+ />
39
43
  </svg>
40
44
  );
41
45
 
42
- export const LoadingSpinnerIcon = ({ color = "rgb(107 114 128)" }: { color?: string }) => (
46
+ export const LoadingSpinnerIcon = ({
47
+ color = "rgb(107 114 128)",
48
+ }: {
49
+ color?: string;
50
+ }) => (
43
51
  <svg
44
52
  style={{
45
53
  animation: "copilotKitSpinAnimation 1s linear infinite",
@@ -4,7 +4,9 @@ export interface useCopyToClipboardProps {
4
4
  timeout?: number;
5
5
  }
6
6
 
7
- export function useCopyToClipboard({ timeout = 2000 }: useCopyToClipboardProps) {
7
+ export function useCopyToClipboard({
8
+ timeout = 2000,
9
+ }: useCopyToClipboardProps) {
8
10
  const [isCopied, setIsCopied] = React.useState<Boolean>(false);
9
11
 
10
12
  const copyToClipboard = (value: string) => {
@@ -1,4 +1,7 @@
1
- import { useCopilotContext, useCopilotMessagesContext } from "@copilotkit/react-core";
1
+ import {
2
+ useCopilotContext,
3
+ useCopilotMessagesContext,
4
+ } from "@copilotkit/react-core";
2
5
  import { gqlToAGUI } from "@copilotkit/runtime-client-gql";
3
6
  import { Message } from "@copilotkit/shared";
4
7
  import { MutableRefObject, useEffect, useRef, useState } from "react";
@@ -38,7 +41,9 @@ const startRecording = async (
38
41
  onStop: () => void,
39
42
  ) => {
40
43
  if (!mediaStreamRef.current || !audioContextRef.current) {
41
- mediaStreamRef.current = await navigator.mediaDevices.getUserMedia({ audio: true });
44
+ mediaStreamRef.current = await navigator.mediaDevices.getUserMedia({
45
+ audio: true,
46
+ });
42
47
  audioContextRef.current = new window.AudioContext();
43
48
  await audioContextRef.current.resume();
44
49
  }
@@ -51,13 +56,21 @@ const startRecording = async (
51
56
  mediaRecorderRef.current.onstop = onStop;
52
57
  };
53
58
 
54
- const stopRecording = (mediaRecorderRef: MutableRefObject<MediaRecorder | null>) => {
55
- if (mediaRecorderRef.current && mediaRecorderRef.current.state !== "inactive") {
59
+ const stopRecording = (
60
+ mediaRecorderRef: MutableRefObject<MediaRecorder | null>,
61
+ ) => {
62
+ if (
63
+ mediaRecorderRef.current &&
64
+ mediaRecorderRef.current.state !== "inactive"
65
+ ) {
56
66
  mediaRecorderRef.current.stop();
57
67
  }
58
68
  };
59
69
 
60
- const transcribeAudio = async (recordedChunks: Blob[], transcribeAudioUrl: string) => {
70
+ const transcribeAudio = async (
71
+ recordedChunks: Blob[],
72
+ transcribeAudioUrl: string,
73
+ ) => {
61
74
  const completeBlob = new Blob(recordedChunks, { type: "audio/mp4" });
62
75
  const formData = new FormData();
63
76
  formData.append("file", completeBlob, "recording.mp4");
@@ -75,7 +88,11 @@ const transcribeAudio = async (recordedChunks: Blob[], transcribeAudioUrl: strin
75
88
  return transcription.text;
76
89
  };
77
90
 
78
- const playAudioResponse = (text: string, textToSpeechUrl: string, audioContext: AudioContext) => {
91
+ const playAudioResponse = (
92
+ text: string,
93
+ textToSpeechUrl: string,
94
+ audioContext: AudioContext,
95
+ ) => {
79
96
  const encodedText = encodeURIComponent(text);
80
97
  const url = `${textToSpeechUrl}?text=${encodedText}`;
81
98
 
@@ -104,7 +121,8 @@ export const usePushToTalk = ({
104
121
  sendFunction: SendFunction;
105
122
  inProgress: boolean;
106
123
  }) => {
107
- const [pushToTalkState, setPushToTalkState] = useState<PushToTalkState>("idle");
124
+ const [pushToTalkState, setPushToTalkState] =
125
+ useState<PushToTalkState>("idle");
108
126
  const mediaStreamRef = useRef<MediaStream | null>(null);
109
127
  const audioContextRef = useRef<AudioContext | null>(null);
110
128
  const mediaRecorderRef = useRef<MediaRecorder | null>(null);
@@ -112,7 +130,9 @@ export const usePushToTalk = ({
112
130
  const generalContext = useCopilotContext();
113
131
  const messagesContext = useCopilotMessagesContext();
114
132
  const context = { ...generalContext, ...messagesContext };
115
- const [startReadingFromMessageId, setStartReadingFromMessageId] = useState<string | null>(null);
133
+ const [startReadingFromMessageId, setStartReadingFromMessageId] = useState<
134
+ string | null
135
+ >(null);
116
136
 
117
137
  useEffect(() => {
118
138
  if (pushToTalkState === "recording") {
@@ -128,14 +148,15 @@ export const usePushToTalk = ({
128
148
  } else {
129
149
  stopRecording(mediaRecorderRef);
130
150
  if (pushToTalkState === "transcribing") {
131
- transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl!).then(
132
- async (transcription) => {
133
- recordedChunks.current = [];
134
- setPushToTalkState("idle");
135
- const message = await sendFunction(transcription);
136
- setStartReadingFromMessageId(message.id);
137
- },
138
- );
151
+ transcribeAudio(
152
+ recordedChunks.current,
153
+ context.copilotApiConfig.transcribeAudioUrl!,
154
+ ).then(async (transcription) => {
155
+ recordedChunks.current = [];
156
+ setPushToTalkState("idle");
157
+ const message = await sendFunction(transcription);
158
+ setStartReadingFromMessageId(message.id);
159
+ });
139
160
  }
140
161
  }
141
162
 
@@ -156,8 +177,14 @@ export const usePushToTalk = ({
156
177
  .slice(lastMessageIndex + 1)
157
178
  .filter((message) => message.role === "assistant");
158
179
 
159
- const text = messagesAfterLast.map((message) => message.content).join("\n");
160
- playAudioResponse(text, context.copilotApiConfig.textToSpeechUrl!, audioContextRef.current!);
180
+ const text = messagesAfterLast
181
+ .map((message) => message.content)
182
+ .join("\n");
183
+ playAudioResponse(
184
+ text,
185
+ context.copilotApiConfig.textToSpeechUrl!,
186
+ audioContextRef.current!,
187
+ );
161
188
 
162
189
  setStartReadingFromMessageId(null);
163
190
  }
package/src/lib/utils.ts CHANGED
@@ -1,4 +1,7 @@
1
- export async function fetcher<JSON = any>(input: RequestInfo, init?: RequestInit): Promise<JSON> {
1
+ export async function fetcher<JSON = any>(
2
+ input: RequestInfo,
3
+ init?: RequestInit,
4
+ ): Promise<JSON> {
2
5
  const res = await fetch(input, init);
3
6
 
4
7
  if (!res.ok) {
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "../../utilities/tsconfig/react-library.json",
2
+ "extends": "../tsconfig/react-library.json",
3
3
  "include": ["."],
4
4
  "exclude": [
5
5
  "dist",
package/tsup.config.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  import { defineConfig, Options } from "tsup";
2
2
 
3
3
  export default defineConfig((options: Options) => ({
4
- entry: ["src/**/*.{ts,tsx}", "!src/**/*.test.{ts,tsx}", "!src/**/__tests__/**/*"],
4
+ entry: [
5
+ "src/**/*.{ts,tsx}",
6
+ "!src/**/*.test.{ts,tsx}",
7
+ "!src/**/__tests__/**/*",
8
+ ],
5
9
  format: ["esm", "cjs"],
6
10
  dts: true,
7
11
  minify: false,