@copilotkit/react-ui 0.0.0-feat-dynamic-copilotcloud-qa-20250117190454

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 (368) hide show
  1. package/CHANGELOG.md +2436 -0
  2. package/README.md +46 -0
  3. package/dist/chunk-34FREWVK.mjs +180 -0
  4. package/dist/chunk-34FREWVK.mjs.map +1 -0
  5. package/dist/chunk-3VNMQWGT.mjs +25 -0
  6. package/dist/chunk-3VNMQWGT.mjs.map +1 -0
  7. package/dist/chunk-3XAXY2Z3.mjs +18 -0
  8. package/dist/chunk-3XAXY2Z3.mjs.map +1 -0
  9. package/dist/chunk-54JAUBUJ.mjs +26 -0
  10. package/dist/chunk-54JAUBUJ.mjs.map +1 -0
  11. package/dist/chunk-B23XDGH4.mjs +30 -0
  12. package/dist/chunk-B23XDGH4.mjs.map +1 -0
  13. package/dist/chunk-BH6PCAAL.mjs +81 -0
  14. package/dist/chunk-BH6PCAAL.mjs.map +1 -0
  15. package/dist/chunk-CBBFRI3Q.mjs +81 -0
  16. package/dist/chunk-CBBFRI3Q.mjs.map +1 -0
  17. package/dist/chunk-EFZPSZWO.mjs +1 -0
  18. package/dist/chunk-EFZPSZWO.mjs.map +1 -0
  19. package/dist/chunk-EMQEEXUB.mjs +97 -0
  20. package/dist/chunk-EMQEEXUB.mjs.map +1 -0
  21. package/dist/chunk-F2W5FD7L.mjs +232 -0
  22. package/dist/chunk-F2W5FD7L.mjs.map +1 -0
  23. package/dist/chunk-F7VWGY77.mjs +22 -0
  24. package/dist/chunk-F7VWGY77.mjs.map +1 -0
  25. package/dist/chunk-FZC7X5PK.mjs +262 -0
  26. package/dist/chunk-FZC7X5PK.mjs.map +1 -0
  27. package/dist/chunk-HEIDCT7I.mjs +10 -0
  28. package/dist/chunk-HEIDCT7I.mjs.map +1 -0
  29. package/dist/chunk-I7MG52I5.mjs +314 -0
  30. package/dist/chunk-I7MG52I5.mjs.map +1 -0
  31. package/dist/chunk-IU3WTXLQ.mjs +1 -0
  32. package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
  33. package/dist/chunk-KXE2JCUH.mjs +1 -0
  34. package/dist/chunk-KXE2JCUH.mjs.map +1 -0
  35. package/dist/chunk-MMVDU6DF.mjs +1 -0
  36. package/dist/chunk-MMVDU6DF.mjs.map +1 -0
  37. package/dist/chunk-MRXNTQOX.mjs +59 -0
  38. package/dist/chunk-MRXNTQOX.mjs.map +1 -0
  39. package/dist/chunk-O6JFOQQA.mjs +21 -0
  40. package/dist/chunk-O6JFOQQA.mjs.map +1 -0
  41. package/dist/chunk-OFYI4UU4.mjs +35 -0
  42. package/dist/chunk-OFYI4UU4.mjs.map +1 -0
  43. package/dist/chunk-OTPAZXVR.mjs +92 -0
  44. package/dist/chunk-OTPAZXVR.mjs.map +1 -0
  45. package/dist/chunk-P5A3A5FO.mjs +112 -0
  46. package/dist/chunk-P5A3A5FO.mjs.map +1 -0
  47. package/dist/chunk-PNQVKBPN.mjs +146 -0
  48. package/dist/chunk-PNQVKBPN.mjs.map +1 -0
  49. package/dist/chunk-RJCZRKTV.mjs +106 -0
  50. package/dist/chunk-RJCZRKTV.mjs.map +1 -0
  51. package/dist/chunk-RQNJNK2W.mjs +25 -0
  52. package/dist/chunk-RQNJNK2W.mjs.map +1 -0
  53. package/dist/chunk-S5MBUNGN.mjs +140 -0
  54. package/dist/chunk-S5MBUNGN.mjs.map +1 -0
  55. package/dist/chunk-SQMEPWVT.mjs +1 -0
  56. package/dist/chunk-SQMEPWVT.mjs.map +1 -0
  57. package/dist/chunk-T26KLXLH.mjs +1 -0
  58. package/dist/chunk-T26KLXLH.mjs.map +1 -0
  59. package/dist/chunk-TI7SY2RI.mjs +164 -0
  60. package/dist/chunk-TI7SY2RI.mjs.map +1 -0
  61. package/dist/chunk-UPTB2MVO.mjs +395 -0
  62. package/dist/chunk-UPTB2MVO.mjs.map +1 -0
  63. package/dist/chunk-UWWMAJ7R.mjs +100 -0
  64. package/dist/chunk-UWWMAJ7R.mjs.map +1 -0
  65. package/dist/chunk-V7W6IM2V.mjs +1 -0
  66. package/dist/chunk-V7W6IM2V.mjs.map +1 -0
  67. package/dist/chunk-VEC45H6Q.mjs +18 -0
  68. package/dist/chunk-VEC45H6Q.mjs.map +1 -0
  69. package/dist/chunk-VKVNMHM5.mjs +105 -0
  70. package/dist/chunk-VKVNMHM5.mjs.map +1 -0
  71. package/dist/chunk-WB3YULQ4.mjs +1 -0
  72. package/dist/chunk-WB3YULQ4.mjs.map +1 -0
  73. package/dist/chunk-YAGE7RCE.mjs +118 -0
  74. package/dist/chunk-YAGE7RCE.mjs.map +1 -0
  75. package/dist/chunk-YQ3D5IQV.mjs +75 -0
  76. package/dist/chunk-YQ3D5IQV.mjs.map +1 -0
  77. package/dist/chunk-YQFVRDNC.mjs +53 -0
  78. package/dist/chunk-YQFVRDNC.mjs.map +1 -0
  79. package/dist/chunk-Z2UZSN3K.mjs +29 -0
  80. package/dist/chunk-Z2UZSN3K.mjs.map +1 -0
  81. package/dist/components/chat/Button.d.ts +7 -0
  82. package/dist/components/chat/Button.js +71 -0
  83. package/dist/components/chat/Button.js.map +1 -0
  84. package/dist/components/chat/Button.mjs +10 -0
  85. package/dist/components/chat/Button.mjs.map +1 -0
  86. package/dist/components/chat/Chat.d.ts +156 -0
  87. package/dist/components/chat/Chat.js +2540 -0
  88. package/dist/components/chat/Chat.js.map +1 -0
  89. package/dist/components/chat/Chat.mjs +36 -0
  90. package/dist/components/chat/Chat.mjs.map +1 -0
  91. package/dist/components/chat/ChatContext.d.ts +105 -0
  92. package/dist/components/chat/ChatContext.js +279 -0
  93. package/dist/components/chat/ChatContext.js.map +1 -0
  94. package/dist/components/chat/ChatContext.mjs +13 -0
  95. package/dist/components/chat/ChatContext.mjs.map +1 -0
  96. package/dist/components/chat/CodeBlock.d.ts +14 -0
  97. package/dist/components/chat/CodeBlock.js +523 -0
  98. package/dist/components/chat/CodeBlock.js.map +1 -0
  99. package/dist/components/chat/CodeBlock.mjs +14 -0
  100. package/dist/components/chat/CodeBlock.mjs.map +1 -0
  101. package/dist/components/chat/Header.d.ts +7 -0
  102. package/dist/components/chat/Header.js +64 -0
  103. package/dist/components/chat/Header.js.map +1 -0
  104. package/dist/components/chat/Header.mjs +10 -0
  105. package/dist/components/chat/Header.mjs.map +1 -0
  106. package/dist/components/chat/Icons.d.ts +18 -0
  107. package/dist/components/chat/Icons.js +321 -0
  108. package/dist/components/chat/Icons.js.map +1 -0
  109. package/dist/components/chat/Icons.mjs +32 -0
  110. package/dist/components/chat/Icons.mjs.map +1 -0
  111. package/dist/components/chat/Input.d.ts +7 -0
  112. package/dist/components/chat/Input.js +324 -0
  113. package/dist/components/chat/Input.js.map +1 -0
  114. package/dist/components/chat/Input.mjs +12 -0
  115. package/dist/components/chat/Input.mjs.map +1 -0
  116. package/dist/components/chat/Markdown.d.ts +8 -0
  117. package/dist/components/chat/Markdown.js +583 -0
  118. package/dist/components/chat/Markdown.js.map +1 -0
  119. package/dist/components/chat/Markdown.mjs +11 -0
  120. package/dist/components/chat/Markdown.mjs.map +1 -0
  121. package/dist/components/chat/Messages.d.ts +12 -0
  122. package/dist/components/chat/Messages.js +227 -0
  123. package/dist/components/chat/Messages.js.map +1 -0
  124. package/dist/components/chat/Messages.mjs +12 -0
  125. package/dist/components/chat/Messages.mjs.map +1 -0
  126. package/dist/components/chat/Modal.d.ts +51 -0
  127. package/dist/components/chat/Modal.js +2743 -0
  128. package/dist/components/chat/Modal.js.map +1 -0
  129. package/dist/components/chat/Modal.mjs +36 -0
  130. package/dist/components/chat/Modal.mjs.map +1 -0
  131. package/dist/components/chat/Popup.d.ts +13 -0
  132. package/dist/components/chat/Popup.js +2754 -0
  133. package/dist/components/chat/Popup.js.map +1 -0
  134. package/dist/components/chat/Popup.mjs +37 -0
  135. package/dist/components/chat/Popup.mjs.map +1 -0
  136. package/dist/components/chat/Response.d.ts +7 -0
  137. package/dist/components/chat/Response.js +64 -0
  138. package/dist/components/chat/Response.js.map +1 -0
  139. package/dist/components/chat/Response.mjs +10 -0
  140. package/dist/components/chat/Response.mjs.map +1 -0
  141. package/dist/components/chat/Sidebar.d.ts +13 -0
  142. package/dist/components/chat/Sidebar.js +2763 -0
  143. package/dist/components/chat/Sidebar.js.map +1 -0
  144. package/dist/components/chat/Sidebar.mjs +37 -0
  145. package/dist/components/chat/Sidebar.mjs.map +1 -0
  146. package/dist/components/chat/Suggestion.d.ts +14 -0
  147. package/dist/components/chat/Suggestion.js +181 -0
  148. package/dist/components/chat/Suggestion.js.map +1 -0
  149. package/dist/components/chat/Suggestion.mjs +11 -0
  150. package/dist/components/chat/Suggestion.mjs.map +1 -0
  151. package/dist/components/chat/Textarea.d.ts +13 -0
  152. package/dist/components/chat/Textarea.js +73 -0
  153. package/dist/components/chat/Textarea.js.map +1 -0
  154. package/dist/components/chat/Textarea.mjs +8 -0
  155. package/dist/components/chat/Textarea.mjs.map +1 -0
  156. package/dist/components/chat/Window.d.ts +7 -0
  157. package/dist/components/chat/Window.js +164 -0
  158. package/dist/components/chat/Window.js.map +1 -0
  159. package/dist/components/chat/Window.mjs +10 -0
  160. package/dist/components/chat/Window.mjs.map +1 -0
  161. package/dist/components/chat/index.d.ts +14 -0
  162. package/dist/components/chat/index.js +2784 -0
  163. package/dist/components/chat/index.js.map +1 -0
  164. package/dist/components/chat/index.mjs +58 -0
  165. package/dist/components/chat/index.mjs.map +1 -0
  166. package/dist/components/chat/messages/AssistantMessage.d.ts +7 -0
  167. package/dist/components/chat/messages/AssistantMessage.js +615 -0
  168. package/dist/components/chat/messages/AssistantMessage.js.map +1 -0
  169. package/dist/components/chat/messages/AssistantMessage.mjs +13 -0
  170. package/dist/components/chat/messages/AssistantMessage.mjs.map +1 -0
  171. package/dist/components/chat/messages/RenderActionExecutionMessage.d.ts +7 -0
  172. package/dist/components/chat/messages/RenderActionExecutionMessage.js +136 -0
  173. package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -0
  174. package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +8 -0
  175. package/dist/components/chat/messages/RenderActionExecutionMessage.mjs.map +1 -0
  176. package/dist/components/chat/messages/RenderAgentStateMessage.d.ts +7 -0
  177. package/dist/components/chat/messages/RenderAgentStateMessage.js +124 -0
  178. package/dist/components/chat/messages/RenderAgentStateMessage.js.map +1 -0
  179. package/dist/components/chat/messages/RenderAgentStateMessage.mjs +8 -0
  180. package/dist/components/chat/messages/RenderAgentStateMessage.mjs.map +1 -0
  181. package/dist/components/chat/messages/RenderResultMessage.d.ts +7 -0
  182. package/dist/components/chat/messages/RenderResultMessage.js +46 -0
  183. package/dist/components/chat/messages/RenderResultMessage.js.map +1 -0
  184. package/dist/components/chat/messages/RenderResultMessage.mjs +8 -0
  185. package/dist/components/chat/messages/RenderResultMessage.mjs.map +1 -0
  186. package/dist/components/chat/messages/RenderTextMessage.d.ts +7 -0
  187. package/dist/components/chat/messages/RenderTextMessage.js +59 -0
  188. package/dist/components/chat/messages/RenderTextMessage.js.map +1 -0
  189. package/dist/components/chat/messages/RenderTextMessage.mjs +8 -0
  190. package/dist/components/chat/messages/RenderTextMessage.mjs.map +1 -0
  191. package/dist/components/chat/messages/UserMessage.d.ts +7 -0
  192. package/dist/components/chat/messages/UserMessage.js +34 -0
  193. package/dist/components/chat/messages/UserMessage.js.map +1 -0
  194. package/dist/components/chat/messages/UserMessage.mjs +8 -0
  195. package/dist/components/chat/messages/UserMessage.mjs.map +1 -0
  196. package/dist/components/chat/props.d.ts +81 -0
  197. package/dist/components/chat/props.js +19 -0
  198. package/dist/components/chat/props.js.map +1 -0
  199. package/dist/components/chat/props.mjs +2 -0
  200. package/dist/components/chat/props.mjs.map +1 -0
  201. package/dist/components/dev-console/console.d.ts +10 -0
  202. package/dist/components/dev-console/console.js +720 -0
  203. package/dist/components/dev-console/console.js.map +1 -0
  204. package/dist/components/dev-console/console.mjs +17 -0
  205. package/dist/components/dev-console/console.mjs.map +1 -0
  206. package/dist/components/dev-console/icons.d.ts +9 -0
  207. package/dist/components/dev-console/icons.js +120 -0
  208. package/dist/components/dev-console/icons.js.map +1 -0
  209. package/dist/components/dev-console/icons.mjs +16 -0
  210. package/dist/components/dev-console/icons.mjs.map +1 -0
  211. package/dist/components/dev-console/index.d.ts +5 -0
  212. package/dist/components/dev-console/index.js +720 -0
  213. package/dist/components/dev-console/index.js.map +1 -0
  214. package/dist/components/dev-console/index.mjs +18 -0
  215. package/dist/components/dev-console/index.mjs.map +1 -0
  216. package/dist/components/dev-console/types.d.ts +9 -0
  217. package/dist/components/dev-console/types.js +19 -0
  218. package/dist/components/dev-console/types.js.map +1 -0
  219. package/dist/components/dev-console/types.mjs +1 -0
  220. package/dist/components/dev-console/types.mjs.map +1 -0
  221. package/dist/components/dev-console/utils.d.ts +10 -0
  222. package/dist/components/dev-console/utils.js +188 -0
  223. package/dist/components/dev-console/utils.js.map +1 -0
  224. package/dist/components/dev-console/utils.mjs +16 -0
  225. package/dist/components/dev-console/utils.mjs.map +1 -0
  226. package/dist/components/help-modal/icons.d.ts +9 -0
  227. package/dist/components/help-modal/icons.js +107 -0
  228. package/dist/components/help-modal/icons.js.map +1 -0
  229. package/dist/components/help-modal/icons.mjs +12 -0
  230. package/dist/components/help-modal/icons.mjs.map +1 -0
  231. package/dist/components/help-modal/index.d.ts +2 -0
  232. package/dist/components/help-modal/index.js +255 -0
  233. package/dist/components/help-modal/index.js.map +1 -0
  234. package/dist/components/help-modal/index.mjs +10 -0
  235. package/dist/components/help-modal/index.mjs.map +1 -0
  236. package/dist/components/help-modal/modal.d.ts +5 -0
  237. package/dist/components/help-modal/modal.js +253 -0
  238. package/dist/components/help-modal/modal.js.map +1 -0
  239. package/dist/components/help-modal/modal.mjs +9 -0
  240. package/dist/components/help-modal/modal.mjs.map +1 -0
  241. package/dist/components/index.d.ts +17 -0
  242. package/dist/components/index.js +2788 -0
  243. package/dist/components/index.js.map +1 -0
  244. package/dist/components/index.mjs +65 -0
  245. package/dist/components/index.mjs.map +1 -0
  246. package/dist/context/index.d.ts +2 -0
  247. package/dist/context/index.js +19 -0
  248. package/dist/context/index.js.map +1 -0
  249. package/dist/context/index.mjs +2 -0
  250. package/dist/context/index.mjs.map +1 -0
  251. package/dist/hooks/index.d.ts +1 -0
  252. package/dist/hooks/index.js +55 -0
  253. package/dist/hooks/index.js.map +1 -0
  254. package/dist/hooks/index.mjs +9 -0
  255. package/dist/hooks/index.mjs.map +1 -0
  256. package/dist/hooks/use-copilot-chat-suggestions.d.ts +83 -0
  257. package/dist/hooks/use-copilot-chat-suggestions.js +53 -0
  258. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
  259. package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
  260. package/dist/hooks/use-copilot-chat-suggestions.mjs.map +1 -0
  261. package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
  262. package/dist/hooks/use-copy-to-clipboard.js +60 -0
  263. package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
  264. package/dist/hooks/use-copy-to-clipboard.mjs +8 -0
  265. package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
  266. package/dist/hooks/use-push-to-talk.d.ts +19 -0
  267. package/dist/hooks/use-push-to-talk.js +195 -0
  268. package/dist/hooks/use-push-to-talk.js.map +1 -0
  269. package/dist/hooks/use-push-to-talk.mjs +12 -0
  270. package/dist/hooks/use-push-to-talk.mjs.map +1 -0
  271. package/dist/index.css +751 -0
  272. package/dist/index.css.map +1 -0
  273. package/dist/index.d.ts +19 -0
  274. package/dist/index.js +2816 -0
  275. package/dist/index.js.map +1 -0
  276. package/dist/index.mjs +73 -0
  277. package/dist/index.mjs.map +1 -0
  278. package/dist/lib/utils.d.ts +4 -0
  279. package/dist/lib/utils.js +76 -0
  280. package/dist/lib/utils.js.map +1 -0
  281. package/dist/lib/utils.mjs +34 -0
  282. package/dist/lib/utils.mjs.map +1 -0
  283. package/dist/lib/utils.test.d.ts +2 -0
  284. package/dist/lib/utils.test.js +9 -0
  285. package/dist/lib/utils.test.js.map +1 -0
  286. package/dist/lib/utils.test.mjs +7 -0
  287. package/dist/lib/utils.test.mjs.map +1 -0
  288. package/dist/types/css.d.ts +16 -0
  289. package/dist/types/css.js +19 -0
  290. package/dist/types/css.js.map +1 -0
  291. package/dist/types/css.mjs +1 -0
  292. package/dist/types/css.mjs.map +1 -0
  293. package/dist/types/index.d.ts +2 -0
  294. package/dist/types/index.js +19 -0
  295. package/dist/types/index.js.map +1 -0
  296. package/dist/types/index.mjs +2 -0
  297. package/dist/types/index.mjs.map +1 -0
  298. package/dist/types/suggestions.d.ts +8 -0
  299. package/dist/types/suggestions.js +19 -0
  300. package/dist/types/suggestions.js.map +1 -0
  301. package/dist/types/suggestions.mjs +1 -0
  302. package/dist/types/suggestions.mjs.map +1 -0
  303. package/jest.config.js +5 -0
  304. package/package.json +78 -0
  305. package/postcss.config.js +60 -0
  306. package/src/components/chat/Button.tsx +18 -0
  307. package/src/components/chat/Chat.tsx +541 -0
  308. package/src/components/chat/ChatContext.tsx +188 -0
  309. package/src/components/chat/CodeBlock.tsx +408 -0
  310. package/src/components/chat/Header.tsx +15 -0
  311. package/src/components/chat/Icons.tsx +223 -0
  312. package/src/components/chat/Input.tsx +100 -0
  313. package/src/components/chat/Markdown.tsx +80 -0
  314. package/src/components/chat/Messages.tsx +188 -0
  315. package/src/components/chat/Modal.tsx +124 -0
  316. package/src/components/chat/Popup.tsx +57 -0
  317. package/src/components/chat/Response.tsx +12 -0
  318. package/src/components/chat/Sidebar.tsx +74 -0
  319. package/src/components/chat/Suggestion.tsx +125 -0
  320. package/src/components/chat/Textarea.tsx +61 -0
  321. package/src/components/chat/Window.tsx +153 -0
  322. package/src/components/chat/index.tsx +8 -0
  323. package/src/components/chat/messages/AssistantMessage.tsx +20 -0
  324. package/src/components/chat/messages/RenderActionExecutionMessage.tsx +122 -0
  325. package/src/components/chat/messages/RenderAgentStateMessage.tsx +112 -0
  326. package/src/components/chat/messages/RenderResultMessage.tsx +17 -0
  327. package/src/components/chat/messages/RenderTextMessage.tsx +29 -0
  328. package/src/components/chat/messages/UserMessage.tsx +5 -0
  329. package/src/components/chat/props.ts +92 -0
  330. package/src/components/dev-console/console.tsx +281 -0
  331. package/src/components/dev-console/icons.tsx +92 -0
  332. package/src/components/dev-console/index.tsx +2 -0
  333. package/src/components/dev-console/types.ts +7 -0
  334. package/src/components/dev-console/utils.ts +162 -0
  335. package/src/components/help-modal/icons.tsx +68 -0
  336. package/src/components/help-modal/index.tsx +1 -0
  337. package/src/components/help-modal/modal.tsx +164 -0
  338. package/src/components/index.ts +2 -0
  339. package/src/context/index.ts +1 -0
  340. package/src/css/animations.css +35 -0
  341. package/src/css/button.css +56 -0
  342. package/src/css/colors.css +12 -0
  343. package/src/css/console.css +134 -0
  344. package/src/css/header.css +43 -0
  345. package/src/css/input.css +89 -0
  346. package/src/css/markdown.css +136 -0
  347. package/src/css/messages.css +73 -0
  348. package/src/css/panel.css +38 -0
  349. package/src/css/popup.css +22 -0
  350. package/src/css/response.css +26 -0
  351. package/src/css/sidebar.css +34 -0
  352. package/src/css/suggestions.css +35 -0
  353. package/src/css/window.css +60 -0
  354. package/src/hooks/index.ts +1 -0
  355. package/src/hooks/use-copilot-chat-suggestions.tsx +112 -0
  356. package/src/hooks/use-copy-to-clipboard.tsx +29 -0
  357. package/src/hooks/use-push-to-talk.tsx +166 -0
  358. package/src/index.tsx +7 -0
  359. package/src/lib/utils.test.ts +7 -0
  360. package/src/lib/utils.ts +27 -0
  361. package/src/styles.css +14 -0
  362. package/src/types/css.ts +15 -0
  363. package/src/types/index.ts +1 -0
  364. package/src/types/suggestions.ts +6 -0
  365. package/tailwind.config.js +7 -0
  366. package/tsconfig.json +12 -0
  367. package/tsup.config.ts +16 -0
  368. package/typedoc.json +4 -0
@@ -0,0 +1,124 @@
1
+ import React from "react";
2
+ import { ChatContextProvider } from "./ChatContext";
3
+ import { ButtonProps, HeaderProps, WindowProps } from "./props";
4
+ import { Window as DefaultWindow } from "./Window";
5
+ import { Button as DefaultButton } from "./Button";
6
+ import { Header as DefaultHeader } from "./Header";
7
+ import { Messages as DefaultMessages } from "./Messages";
8
+ import { Input as DefaultInput } from "./Input";
9
+ import { ResponseButton as DefaultResponseButton } from "./Response";
10
+ import { CopilotChat, CopilotChatProps } from "./Chat";
11
+ import { Markdown as DefaultRenderer } from "./Markdown";
12
+ import { AssistantMessage as DefaultAssistantMessage } from "./messages/AssistantMessage";
13
+ import { UserMessage as DefaultUserMessage } from "./messages/UserMessage";
14
+
15
+ export interface CopilotModalProps extends CopilotChatProps {
16
+ /**
17
+ * Whether the chat window should be open by default.
18
+ * @default false
19
+ */
20
+ defaultOpen?: boolean;
21
+
22
+ /**
23
+ * If the chat window should close when the user clicks outside of it.
24
+ * @default true
25
+ */
26
+ clickOutsideToClose?: boolean;
27
+
28
+ /**
29
+ * If the chat window should close when the user hits the Escape key.
30
+ * @default true
31
+ */
32
+ hitEscapeToClose?: boolean;
33
+
34
+ /**
35
+ * The shortcut key to open the chat window.
36
+ * Uses Command-[shortcut] on a Mac and Ctrl-[shortcut] on Windows.
37
+ * @default '/'
38
+ */
39
+ shortcut?: string;
40
+
41
+ /**
42
+ * A callback that gets called when the chat window opens or closes.
43
+ */
44
+ onSetOpen?: (open: boolean) => void;
45
+
46
+ /**
47
+ * A custom Window component to use instead of the default.
48
+ */
49
+ Window?: React.ComponentType<WindowProps>;
50
+
51
+ /**
52
+ * A custom Button component to use instead of the default.
53
+ */
54
+ Button?: React.ComponentType<ButtonProps>;
55
+
56
+ /**
57
+ * A custom Header component to use instead of the default.
58
+ */
59
+ Header?: React.ComponentType<HeaderProps>;
60
+ }
61
+
62
+ export const CopilotModal = ({
63
+ instructions,
64
+ defaultOpen = false,
65
+ clickOutsideToClose = true,
66
+ hitEscapeToClose = true,
67
+ onSetOpen,
68
+ onSubmitMessage,
69
+ onStopGeneration,
70
+ onReloadMessages,
71
+ shortcut = "/",
72
+ icons,
73
+ labels,
74
+ makeSystemMessage,
75
+ showResponseButton = true,
76
+ onInProgress,
77
+ Window = DefaultWindow,
78
+ Button = DefaultButton,
79
+ Header = DefaultHeader,
80
+ Messages = DefaultMessages,
81
+ Input = DefaultInput,
82
+ ResponseButton = DefaultResponseButton,
83
+ AssistantMessage = DefaultAssistantMessage,
84
+ UserMessage = DefaultUserMessage,
85
+ className,
86
+ children,
87
+ }: CopilotModalProps) => {
88
+ const [openState, setOpenState] = React.useState(defaultOpen);
89
+
90
+ const setOpen = (open: boolean) => {
91
+ onSetOpen?.(open);
92
+ setOpenState(open);
93
+ };
94
+
95
+ return (
96
+ <ChatContextProvider icons={icons} labels={labels} open={openState} setOpen={setOpen}>
97
+ {children}
98
+ <div className={className}>
99
+ <Button></Button>
100
+ <Window
101
+ clickOutsideToClose={clickOutsideToClose}
102
+ shortcut={shortcut}
103
+ hitEscapeToClose={hitEscapeToClose}
104
+ >
105
+ <Header />
106
+ <CopilotChat
107
+ instructions={instructions}
108
+ onSubmitMessage={onSubmitMessage}
109
+ onStopGeneration={onStopGeneration}
110
+ onReloadMessages={onReloadMessages}
111
+ makeSystemMessage={makeSystemMessage}
112
+ showResponseButton={showResponseButton}
113
+ onInProgress={onInProgress}
114
+ Messages={Messages}
115
+ Input={Input}
116
+ ResponseButton={ResponseButton}
117
+ AssistantMessage={AssistantMessage}
118
+ UserMessage={UserMessage}
119
+ />
120
+ </Window>
121
+ </div>
122
+ </ChatContextProvider>
123
+ );
124
+ };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * <br/>
3
+ * <img src="/images/CopilotPopup.gif" width="500" />
4
+ *
5
+ * A chatbot popup component for the CopilotKit framework. The component allows for a high degree
6
+ * of customization through various props and custom CSS.
7
+ *
8
+ * See [CopilotSidebar](/reference/components/chat/CopilotSidebar) for a sidebar version of this component.
9
+ *
10
+ * ## Install Dependencies
11
+ *
12
+ * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
13
+ *
14
+ * ```shell npm2yarn \"@copilotkit/react-ui"\
15
+ * npm install @copilotkit/react-core @copilotkit/react-ui
16
+ * ```
17
+ * ## Usage
18
+ *
19
+ * ```tsx
20
+ * import { CopilotPopup } from "@copilotkit/react-ui";
21
+ * import "@copilotkit/react-ui/styles.css";
22
+ *
23
+ * <CopilotPopup
24
+ * labels={{
25
+ * title: "Your Assistant",
26
+ * initial: "Hi! 👋 How can I assist you today?",
27
+ * }}
28
+ * />
29
+ * ```
30
+ *
31
+ * ### Look & Feel
32
+ *
33
+ * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
34
+ * ```tsx title="YourRootComponent.tsx"
35
+ * ...
36
+ * import "@copilotkit/react-ui/styles.css"; // [!code highlight]
37
+ *
38
+ * export function YourRootComponent() {
39
+ * return (
40
+ * <CopilotKit>
41
+ * ...
42
+ * </CopilotKit>
43
+ * );
44
+ * }
45
+ * ```
46
+ * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.
47
+ */
48
+
49
+ import { CopilotModal, CopilotModalProps } from "./Modal";
50
+
51
+ export function CopilotPopup(props: CopilotModalProps) {
52
+ props = {
53
+ ...props,
54
+ className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup",
55
+ };
56
+ return <CopilotModal {...props}>{props.children}</CopilotModal>;
57
+ }
@@ -0,0 +1,12 @@
1
+ import { useChatContext } from "./ChatContext";
2
+ import { ResponseButtonProps } from "./props";
3
+
4
+ export const ResponseButton = ({ onClick, inProgress }: ResponseButtonProps) => {
5
+ const context = useChatContext();
6
+ return (
7
+ <button onClick={onClick} className="copilotKitResponseButton">
8
+ <span>{inProgress ? context.icons.stopIcon : context.icons.regenerateIcon}</span>
9
+ {inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse}
10
+ </button>
11
+ );
12
+ };
@@ -0,0 +1,74 @@
1
+ /**
2
+ * <br/>
3
+ * <img src="/images/CopilotSidebar.gif" width="500" />
4
+ *
5
+ * A chatbot sidebar component for the CopilotKit framework. Highly customizable through various props and custom CSS.
6
+ *
7
+ * See [CopilotPopup](/reference/components/chat/CopilotPopup) for a popup version of this component.
8
+ *
9
+ * ## Install Dependencies
10
+ *
11
+ * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
12
+ *
13
+ * ```shell npm2yarn \"@copilotkit/react-ui"\
14
+ * npm install @copilotkit/react-core @copilotkit/react-ui
15
+ * ```
16
+ *
17
+ * ## Usage
18
+ *
19
+ * ```tsx
20
+ * import { CopilotSidebar } from "@copilotkit/react-ui";
21
+ * import "@copilotkit/react-ui/styles.css";
22
+ *
23
+ * <CopilotSidebar
24
+ * labels={{
25
+ * title: "Your Assistant",
26
+ * initial: "Hi! 👋 How can I assist you today?",
27
+ * }}
28
+ * >
29
+ * <YourApp/>
30
+ * </CopilotSidebar>
31
+ * ```
32
+ *
33
+ * ### Look & Feel
34
+ *
35
+ * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
36
+ * ```tsx title="YourRootComponent.tsx"
37
+ * ...
38
+ * import "@copilotkit/react-ui/styles.css"; // [!code highlight]
39
+ *
40
+ * export function YourRootComponent() {
41
+ * return (
42
+ * <CopilotKit>
43
+ * ...
44
+ * </CopilotKit>
45
+ * );
46
+ * }
47
+ * ```
48
+ * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.
49
+ */
50
+ import React, { useState } from "react";
51
+ import { CopilotModal, CopilotModalProps } from "./Modal";
52
+
53
+ export function CopilotSidebar(props: CopilotModalProps) {
54
+ props = {
55
+ ...props,
56
+ className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar",
57
+ };
58
+ const [expandedClassName, setExpandedClassName] = useState(
59
+ props.defaultOpen ? "sidebarExpanded" : "",
60
+ );
61
+
62
+ const onSetOpen = (open: boolean) => {
63
+ props.onSetOpen?.(open);
64
+ setExpandedClassName(open ? "sidebarExpanded" : "");
65
+ };
66
+
67
+ return (
68
+ <div className={`copilotKitSidebarContentWrapper ${expandedClassName}`}>
69
+ <CopilotModal {...props} {...{ onSetOpen }}>
70
+ {props.children}
71
+ </CopilotModal>
72
+ </div>
73
+ );
74
+ }
@@ -0,0 +1,125 @@
1
+ import {
2
+ CopilotContextParams,
3
+ extract,
4
+ CopilotChatSuggestionConfiguration,
5
+ CopilotMessagesContextParams,
6
+ } from "@copilotkit/react-core";
7
+ import { SuggestionsProps } from "./props";
8
+ import { SmallSpinnerIcon } from "./Icons";
9
+ import { CopilotChatSuggestion } from "../../types/suggestions";
10
+ import { actionParametersToJsonSchema } from "@copilotkit/shared";
11
+ import { CopilotRequestType } from "@copilotkit/runtime-client-gql";
12
+
13
+ export function Suggestion({ title, message, onClick, partial, className }: SuggestionsProps) {
14
+ return (
15
+ <button
16
+ disabled={partial}
17
+ onClick={(e) => {
18
+ e.preventDefault();
19
+ onClick(message);
20
+ }}
21
+ className={className || "suggestion"}
22
+ >
23
+ {partial && SmallSpinnerIcon}
24
+ <span>{title}</span>
25
+ </button>
26
+ );
27
+ }
28
+
29
+ export const reloadSuggestions = async (
30
+ context: CopilotContextParams & CopilotMessagesContextParams,
31
+ chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration },
32
+ setCurrentSuggestions: (suggestions: { title: string; message: string }[]) => void,
33
+ abortControllerRef: React.MutableRefObject<AbortController | null>,
34
+ ) => {
35
+ const abortController = abortControllerRef.current;
36
+
37
+ const tools = JSON.stringify(
38
+ Object.values(context.actions).map((action) => ({
39
+ name: action.name,
40
+ description: action.description,
41
+ jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters)),
42
+ })),
43
+ );
44
+
45
+ const allSuggestions: CopilotChatSuggestion[] = [];
46
+
47
+ for (const config of Object.values(chatSuggestionConfiguration)) {
48
+ try {
49
+ const numOfSuggestionsInstructions =
50
+ config.minSuggestions === 0
51
+ ? `Produce up to ${config.maxSuggestions} suggestions. ` +
52
+ `If there are no highly relevant suggestions you can think of, provide an empty array.`
53
+ : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;
54
+
55
+ const result = await extract({
56
+ context,
57
+ instructions:
58
+ "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. ",
59
+ data:
60
+ config.instructions +
61
+ "\n\n" +
62
+ numOfSuggestionsInstructions +
63
+ "\n\n" +
64
+ "Available tools: " +
65
+ tools +
66
+ "\n\n",
67
+ requestType: CopilotRequestType.Task,
68
+ parameters: [
69
+ {
70
+ name: "suggestions",
71
+ type: "object[]",
72
+ attributes: [
73
+ {
74
+ name: "title",
75
+ description:
76
+ "The title of the suggestion. This is shown as a button and should be short.",
77
+ type: "string",
78
+ },
79
+ {
80
+ name: "message",
81
+ description:
82
+ "The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.",
83
+ type: "string",
84
+ },
85
+ ],
86
+ },
87
+ ],
88
+ include: {
89
+ messages: true,
90
+ readable: true,
91
+ },
92
+ abortSignal: abortController?.signal,
93
+ stream: ({ status, args }) => {
94
+ const suggestions = args.suggestions || [];
95
+ const newSuggestions: CopilotChatSuggestion[] = [];
96
+ for (let i = 0; i < suggestions.length; i++) {
97
+ // if GPT provides too many suggestions, limit the number of suggestions
98
+ if (config.maxSuggestions !== undefined && i >= config.maxSuggestions) {
99
+ break;
100
+ }
101
+ const { title, message } = suggestions[i];
102
+
103
+ // If this is the last suggestion and the status is not complete, mark it as partial
104
+ const partial = i == suggestions.length - 1 && status !== "complete";
105
+
106
+ newSuggestions.push({
107
+ title,
108
+ message,
109
+ partial,
110
+ className: config.className,
111
+ });
112
+ }
113
+ setCurrentSuggestions([...allSuggestions, ...newSuggestions]);
114
+ },
115
+ });
116
+ allSuggestions.push(...result.suggestions);
117
+ } catch (error) {
118
+ console.error("Error loading suggestions", error);
119
+ }
120
+ }
121
+
122
+ if (abortControllerRef.current === abortController) {
123
+ abortControllerRef.current = null;
124
+ }
125
+ };
@@ -0,0 +1,61 @@
1
+ import React, { useState, useRef, useEffect, forwardRef, useImperativeHandle } from "react";
2
+
3
+ interface AutoResizingTextareaProps {
4
+ maxRows?: number;
5
+ placeholder?: string;
6
+ value: string;
7
+ onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
8
+ onKeyDown?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
9
+ autoFocus?: boolean;
10
+ }
11
+
12
+ const AutoResizingTextarea = forwardRef<HTMLTextAreaElement, AutoResizingTextareaProps>(
13
+ ({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {
14
+ const internalTextareaRef = useRef<HTMLTextAreaElement>(null);
15
+ const [maxHeight, setMaxHeight] = useState<number>(0);
16
+
17
+ useImperativeHandle(ref, () => internalTextareaRef.current as HTMLTextAreaElement);
18
+
19
+ useEffect(() => {
20
+ const calculateMaxHeight = () => {
21
+ const textarea = internalTextareaRef.current;
22
+ if (textarea) {
23
+ textarea.style.height = "auto";
24
+ const singleRowHeight = textarea.scrollHeight;
25
+ setMaxHeight(singleRowHeight * maxRows);
26
+ if (autoFocus) {
27
+ textarea.focus();
28
+ }
29
+ }
30
+ };
31
+
32
+ calculateMaxHeight();
33
+ }, [maxRows]);
34
+
35
+ useEffect(() => {
36
+ const textarea = internalTextareaRef.current;
37
+ if (textarea) {
38
+ textarea.style.height = "auto";
39
+ textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
40
+ }
41
+ }, [value, maxHeight]);
42
+
43
+ return (
44
+ <textarea
45
+ ref={internalTextareaRef}
46
+ value={value}
47
+ onChange={onChange}
48
+ onKeyDown={onKeyDown}
49
+ placeholder={placeholder}
50
+ style={{
51
+ overflow: "auto",
52
+ resize: "none",
53
+ maxHeight: `${maxHeight}px`,
54
+ }}
55
+ rows={1}
56
+ />
57
+ );
58
+ },
59
+ );
60
+
61
+ export default AutoResizingTextarea;
@@ -0,0 +1,153 @@
1
+ import React, { useCallback, useEffect } from "react";
2
+ import { WindowProps } from "./props";
3
+ import { useChatContext } from "./ChatContext";
4
+
5
+ export const Window = ({
6
+ children,
7
+ clickOutsideToClose,
8
+ shortcut,
9
+ hitEscapeToClose,
10
+ }: WindowProps) => {
11
+ const windowRef = React.useRef<HTMLDivElement>(null);
12
+
13
+ const { open, setOpen } = useChatContext();
14
+
15
+ const handleClickOutside = useCallback(
16
+ (event: MouseEvent) => {
17
+ if (!clickOutsideToClose) {
18
+ return;
19
+ }
20
+
21
+ const parentElement = windowRef.current?.parentElement;
22
+
23
+ let className = "";
24
+ if (event.target instanceof HTMLElement) {
25
+ className = event.target.className;
26
+ }
27
+
28
+ if (
29
+ open &&
30
+ parentElement &&
31
+ !parentElement.contains(event.target as any) &&
32
+ // prevent closing the window when clicking on the debug menu
33
+ !className.includes("copilotKitDebugMenu")
34
+ ) {
35
+ setOpen(false);
36
+ }
37
+ },
38
+ [clickOutsideToClose, open, setOpen],
39
+ );
40
+
41
+ const handleKeyDown = useCallback(
42
+ (event: KeyboardEvent) => {
43
+ const target = event.target as HTMLElement;
44
+ const isInput =
45
+ target.tagName === "INPUT" ||
46
+ target.tagName === "SELECT" ||
47
+ target.tagName === "TEXTAREA" ||
48
+ target.isContentEditable;
49
+
50
+ const isDescendantOfWrapper = windowRef.current?.contains(target);
51
+
52
+ if (
53
+ open &&
54
+ event.key === "Escape" &&
55
+ (!isInput || isDescendantOfWrapper) &&
56
+ hitEscapeToClose
57
+ ) {
58
+ setOpen(false);
59
+ } else if (
60
+ event.key === shortcut &&
61
+ ((isMacOS() && event.metaKey) || (!isMacOS() && event.ctrlKey)) &&
62
+ (!isInput || isDescendantOfWrapper)
63
+ ) {
64
+ setOpen(!open);
65
+ }
66
+ },
67
+ [hitEscapeToClose, shortcut, open, setOpen],
68
+ );
69
+
70
+ const adjustForMobile = useCallback(() => {
71
+ const copilotKitWindow = windowRef.current;
72
+ const vv = window.visualViewport;
73
+ if (!copilotKitWindow || !vv) {
74
+ return;
75
+ }
76
+
77
+ if (window.innerWidth < 640 && open) {
78
+ copilotKitWindow.style.height = `${vv.height}px`;
79
+ copilotKitWindow.style.left = `${vv.offsetLeft}px`;
80
+ copilotKitWindow.style.top = `${vv.offsetTop}px`;
81
+
82
+ document.body.style.position = "fixed";
83
+ document.body.style.width = "100%";
84
+ document.body.style.height = `${window.innerHeight}px`;
85
+ document.body.style.overflow = "hidden";
86
+ document.body.style.touchAction = "none";
87
+
88
+ // Prevent scrolling on iOS
89
+ document.body.addEventListener("touchmove", preventScroll, {
90
+ passive: false,
91
+ });
92
+ } else {
93
+ copilotKitWindow.style.height = "";
94
+ copilotKitWindow.style.left = "";
95
+ copilotKitWindow.style.top = "";
96
+ document.body.style.position = "";
97
+ document.body.style.height = "";
98
+ document.body.style.width = "";
99
+ document.body.style.overflow = "";
100
+ document.body.style.top = "";
101
+ document.body.style.touchAction = "";
102
+
103
+ document.body.removeEventListener("touchmove", preventScroll);
104
+ }
105
+ }, [open]);
106
+
107
+ useEffect(() => {
108
+ document.addEventListener("mousedown", handleClickOutside);
109
+ document.addEventListener("keydown", handleKeyDown);
110
+ if (window.visualViewport) {
111
+ window.visualViewport.addEventListener("resize", adjustForMobile);
112
+ adjustForMobile();
113
+ }
114
+
115
+ return () => {
116
+ document.removeEventListener("mousedown", handleClickOutside);
117
+ document.removeEventListener("keydown", handleKeyDown);
118
+ if (window.visualViewport) {
119
+ window.visualViewport.removeEventListener("resize", adjustForMobile);
120
+ }
121
+ };
122
+ }, [adjustForMobile, handleClickOutside, handleKeyDown]);
123
+
124
+ return (
125
+ <div className={`copilotKitWindow${open ? " open" : ""}`} ref={windowRef}>
126
+ {children}
127
+ </div>
128
+ );
129
+ };
130
+
131
+ const preventScroll = (event: TouchEvent): void => {
132
+ let targetElement = event.target as Element;
133
+
134
+ // Function to check if the target has the parent with a given class
135
+ const hasParentWithClass = (element: Element, className: string): boolean => {
136
+ while (element && element !== document.body) {
137
+ if (element.classList.contains(className)) {
138
+ return true;
139
+ }
140
+ element = element.parentElement!;
141
+ }
142
+ return false;
143
+ };
144
+
145
+ // Check if the target of the touch event is inside an element with the 'copilotKitMessages' class
146
+ if (!hasParentWithClass(targetElement, "copilotKitMessages")) {
147
+ event.preventDefault();
148
+ }
149
+ };
150
+
151
+ function isMacOS() {
152
+ return /Mac|iMac|Macintosh/i.test(navigator.userAgent);
153
+ }
@@ -0,0 +1,8 @@
1
+ export * from "./props";
2
+ export { CopilotPopup } from "./Popup";
3
+ export { CopilotSidebar } from "./Sidebar";
4
+ export { CopilotChat } from "./Chat";
5
+ export { Markdown } from "./Markdown";
6
+ export { AssistantMessage } from "./messages/AssistantMessage";
7
+ export { UserMessage } from "./messages/UserMessage";
8
+ export { useChatContext } from "./ChatContext";
@@ -0,0 +1,20 @@
1
+ import { AssistantMessageProps } from "../props";
2
+ import { useChatContext } from "../ChatContext";
3
+ import { Markdown } from "../Markdown";
4
+
5
+ export const AssistantMessage = (props: AssistantMessageProps) => {
6
+ const { icons } = useChatContext();
7
+ const { message, isLoading, subComponent } = props;
8
+
9
+ return (
10
+ <>
11
+ {(message || isLoading) && (
12
+ <div className="copilotKitMessage copilotKitAssistantMessage">
13
+ {message && <Markdown content={message || ""} />}
14
+ {isLoading && icons.spinnerIcon}
15
+ </div>
16
+ )}
17
+ <div style={{ marginBottom: "0.5rem" }}>{subComponent}</div>
18
+ </>
19
+ );
20
+ };