@copilotkitnext/react 0.0.22-alpha.4 → 0.0.22-alpha.6

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 (397) hide show
  1. package/dist/index.d.mts +635 -46
  2. package/dist/index.d.ts +635 -46
  3. package/dist/index.js +325 -22
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +4286 -109
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +6 -6
  8. package/dist/chunk-32YJ5VJ4.mjs +0 -157
  9. package/dist/chunk-32YJ5VJ4.mjs.map +0 -1
  10. package/dist/chunk-36HFWACS.mjs +0 -1
  11. package/dist/chunk-36HFWACS.mjs.map +0 -1
  12. package/dist/chunk-46BZRXWT.mjs +0 -16
  13. package/dist/chunk-46BZRXWT.mjs.map +0 -1
  14. package/dist/chunk-4UDBR75C.mjs +0 -106
  15. package/dist/chunk-4UDBR75C.mjs.map +0 -1
  16. package/dist/chunk-4XJK5IVQ.mjs +0 -83
  17. package/dist/chunk-4XJK5IVQ.mjs.map +0 -1
  18. package/dist/chunk-5JNWVLQI.mjs +0 -72
  19. package/dist/chunk-5JNWVLQI.mjs.map +0 -1
  20. package/dist/chunk-5SC3CO5Q.mjs +0 -69
  21. package/dist/chunk-5SC3CO5Q.mjs.map +0 -1
  22. package/dist/chunk-6VUKDHOD.mjs +0 -1
  23. package/dist/chunk-6VUKDHOD.mjs.map +0 -1
  24. package/dist/chunk-7HM7CU5A.mjs +0 -122
  25. package/dist/chunk-7HM7CU5A.mjs.map +0 -1
  26. package/dist/chunk-AEFM73CL.mjs +0 -32
  27. package/dist/chunk-AEFM73CL.mjs.map +0 -1
  28. package/dist/chunk-AI3Z3CHN.mjs +0 -97
  29. package/dist/chunk-AI3Z3CHN.mjs.map +0 -1
  30. package/dist/chunk-AXFRCGH6.mjs +0 -107
  31. package/dist/chunk-AXFRCGH6.mjs.map +0 -1
  32. package/dist/chunk-BNT754Z2.mjs +0 -185
  33. package/dist/chunk-BNT754Z2.mjs.map +0 -1
  34. package/dist/chunk-BT6C5OPU.mjs +0 -278
  35. package/dist/chunk-BT6C5OPU.mjs.map +0 -1
  36. package/dist/chunk-CDSO65ZY.mjs +0 -157
  37. package/dist/chunk-CDSO65ZY.mjs.map +0 -1
  38. package/dist/chunk-CGLGXQAU.mjs +0 -78
  39. package/dist/chunk-CGLGXQAU.mjs.map +0 -1
  40. package/dist/chunk-DVUQO72Z.mjs +0 -1
  41. package/dist/chunk-DVUQO72Z.mjs.map +0 -1
  42. package/dist/chunk-E56GYBP3.mjs +0 -101
  43. package/dist/chunk-E56GYBP3.mjs.map +0 -1
  44. package/dist/chunk-ETWJDCGE.mjs +0 -1
  45. package/dist/chunk-ETWJDCGE.mjs.map +0 -1
  46. package/dist/chunk-FIBK3DYE.mjs +0 -26
  47. package/dist/chunk-FIBK3DYE.mjs.map +0 -1
  48. package/dist/chunk-FVURPXQK.mjs +0 -45
  49. package/dist/chunk-FVURPXQK.mjs.map +0 -1
  50. package/dist/chunk-FZR2XQKR.mjs +0 -44
  51. package/dist/chunk-FZR2XQKR.mjs.map +0 -1
  52. package/dist/chunk-GK4NXPLC.mjs +0 -60
  53. package/dist/chunk-GK4NXPLC.mjs.map +0 -1
  54. package/dist/chunk-IA4CLXDM.mjs +0 -76
  55. package/dist/chunk-IA4CLXDM.mjs.map +0 -1
  56. package/dist/chunk-IICUCI5S.mjs +0 -43
  57. package/dist/chunk-IICUCI5S.mjs.map +0 -1
  58. package/dist/chunk-JLVGSNAO.mjs +0 -311
  59. package/dist/chunk-JLVGSNAO.mjs.map +0 -1
  60. package/dist/chunk-JWOIINVV.mjs +0 -237
  61. package/dist/chunk-JWOIINVV.mjs.map +0 -1
  62. package/dist/chunk-KCVDFZJX.mjs +0 -873
  63. package/dist/chunk-KCVDFZJX.mjs.map +0 -1
  64. package/dist/chunk-KPRUSQ3K.mjs +0 -1
  65. package/dist/chunk-KPRUSQ3K.mjs.map +0 -1
  66. package/dist/chunk-MWC5OV7Z.mjs +0 -1
  67. package/dist/chunk-MWC5OV7Z.mjs.map +0 -1
  68. package/dist/chunk-N5EP5OD5.mjs +0 -1
  69. package/dist/chunk-N5EP5OD5.mjs.map +0 -1
  70. package/dist/chunk-N5HC66HU.mjs +0 -311
  71. package/dist/chunk-N5HC66HU.mjs.map +0 -1
  72. package/dist/chunk-NB2GZAKG.mjs +0 -131
  73. package/dist/chunk-NB2GZAKG.mjs.map +0 -1
  74. package/dist/chunk-NB4DFAZH.mjs +0 -185
  75. package/dist/chunk-NB4DFAZH.mjs.map +0 -1
  76. package/dist/chunk-NNAYEAP2.mjs +0 -49
  77. package/dist/chunk-NNAYEAP2.mjs.map +0 -1
  78. package/dist/chunk-NNPKBGD6.mjs +0 -37
  79. package/dist/chunk-NNPKBGD6.mjs.map +0 -1
  80. package/dist/chunk-OMPVTGXH.mjs +0 -122
  81. package/dist/chunk-OMPVTGXH.mjs.map +0 -1
  82. package/dist/chunk-R5OLAA3L.mjs +0 -135
  83. package/dist/chunk-R5OLAA3L.mjs.map +0 -1
  84. package/dist/chunk-RF2CGPHQ.mjs +0 -215
  85. package/dist/chunk-RF2CGPHQ.mjs.map +0 -1
  86. package/dist/chunk-RGD2L3Z4.mjs +0 -96
  87. package/dist/chunk-RGD2L3Z4.mjs.map +0 -1
  88. package/dist/chunk-RK5P2LG6.mjs +0 -57
  89. package/dist/chunk-RK5P2LG6.mjs.map +0 -1
  90. package/dist/chunk-RRXDJCXI.mjs +0 -60
  91. package/dist/chunk-RRXDJCXI.mjs.map +0 -1
  92. package/dist/chunk-SPDE34WC.mjs +0 -283
  93. package/dist/chunk-SPDE34WC.mjs.map +0 -1
  94. package/dist/chunk-TAUOEJH2.mjs +0 -120
  95. package/dist/chunk-TAUOEJH2.mjs.map +0 -1
  96. package/dist/chunk-TBE7ZI5G.mjs +0 -45
  97. package/dist/chunk-TBE7ZI5G.mjs.map +0 -1
  98. package/dist/chunk-UOX5D73C.mjs +0 -22
  99. package/dist/chunk-UOX5D73C.mjs.map +0 -1
  100. package/dist/chunk-US4KNAAV.mjs +0 -1
  101. package/dist/chunk-US4KNAAV.mjs.map +0 -1
  102. package/dist/chunk-UZB3CTOY.mjs +0 -873
  103. package/dist/chunk-UZB3CTOY.mjs.map +0 -1
  104. package/dist/chunk-VBI6JXPC.mjs +0 -1
  105. package/dist/chunk-VBI6JXPC.mjs.map +0 -1
  106. package/dist/chunk-VVAXSF3M.mjs +0 -61
  107. package/dist/chunk-VVAXSF3M.mjs.map +0 -1
  108. package/dist/chunk-XO4IRKSC.mjs +0 -11
  109. package/dist/chunk-XO4IRKSC.mjs.map +0 -1
  110. package/dist/chunk-XU5CEPYQ.mjs +0 -75
  111. package/dist/chunk-XU5CEPYQ.mjs.map +0 -1
  112. package/dist/chunk-YPH4BHOY.mjs +0 -39
  113. package/dist/chunk-YPH4BHOY.mjs.map +0 -1
  114. package/dist/chunk-YZUPVMHC.mjs +0 -1
  115. package/dist/chunk-YZUPVMHC.mjs.map +0 -1
  116. package/dist/components/CopilotKitInspector.d.mts +0 -13
  117. package/dist/components/CopilotKitInspector.d.ts +0 -13
  118. package/dist/components/CopilotKitInspector.js +0 -69
  119. package/dist/components/CopilotKitInspector.js.map +0 -1
  120. package/dist/components/CopilotKitInspector.mjs +0 -7
  121. package/dist/components/CopilotKitInspector.mjs.map +0 -1
  122. package/dist/components/WildcardToolCallRender.d.mts +0 -7
  123. package/dist/components/WildcardToolCallRender.d.ts +0 -7
  124. package/dist/components/WildcardToolCallRender.js +0 -106
  125. package/dist/components/WildcardToolCallRender.js.map +0 -1
  126. package/dist/components/WildcardToolCallRender.mjs +0 -8
  127. package/dist/components/WildcardToolCallRender.mjs.map +0 -1
  128. package/dist/components/chat/CopilotChat.d.mts +0 -30
  129. package/dist/components/chat/CopilotChat.d.ts +0 -30
  130. package/dist/components/chat/CopilotChat.js +0 -2934
  131. package/dist/components/chat/CopilotChat.js.map +0 -1
  132. package/dist/components/chat/CopilotChat.mjs +0 -37
  133. package/dist/components/chat/CopilotChat.mjs.map +0 -1
  134. package/dist/components/chat/CopilotChatAssistantMessage.d.mts +0 -45
  135. package/dist/components/chat/CopilotChatAssistantMessage.d.ts +0 -45
  136. package/dist/components/chat/CopilotChatAssistantMessage.js +0 -735
  137. package/dist/components/chat/CopilotChatAssistantMessage.js.map +0 -1
  138. package/dist/components/chat/CopilotChatAssistantMessage.mjs +0 -29
  139. package/dist/components/chat/CopilotChatAssistantMessage.mjs.map +0 -1
  140. package/dist/components/chat/CopilotChatAudioRecorder.d.mts +0 -11
  141. package/dist/components/chat/CopilotChatAudioRecorder.d.ts +0 -11
  142. package/dist/components/chat/CopilotChatAudioRecorder.js +0 -131
  143. package/dist/components/chat/CopilotChatAudioRecorder.js.map +0 -1
  144. package/dist/components/chat/CopilotChatAudioRecorder.mjs +0 -9
  145. package/dist/components/chat/CopilotChatAudioRecorder.mjs.map +0 -1
  146. package/dist/components/chat/CopilotChatInput.d.mts +0 -67
  147. package/dist/components/chat/CopilotChatInput.d.ts +0 -67
  148. package/dist/components/chat/CopilotChatInput.js +0 -1305
  149. package/dist/components/chat/CopilotChatInput.js.map +0 -1
  150. package/dist/components/chat/CopilotChatInput.mjs +0 -16
  151. package/dist/components/chat/CopilotChatInput.mjs.map +0 -1
  152. package/dist/components/chat/CopilotChatMessageView.d.mts +0 -29
  153. package/dist/components/chat/CopilotChatMessageView.d.ts +0 -29
  154. package/dist/components/chat/CopilotChatMessageView.js +0 -1164
  155. package/dist/components/chat/CopilotChatMessageView.js.map +0 -1
  156. package/dist/components/chat/CopilotChatMessageView.mjs +0 -31
  157. package/dist/components/chat/CopilotChatMessageView.mjs.map +0 -1
  158. package/dist/components/chat/CopilotChatSuggestionPill.d.mts +0 -11
  159. package/dist/components/chat/CopilotChatSuggestionPill.d.ts +0 -11
  160. package/dist/components/chat/CopilotChatSuggestionPill.js +0 -76
  161. package/dist/components/chat/CopilotChatSuggestionPill.js.map +0 -1
  162. package/dist/components/chat/CopilotChatSuggestionPill.mjs +0 -10
  163. package/dist/components/chat/CopilotChatSuggestionPill.mjs.map +0 -1
  164. package/dist/components/chat/CopilotChatSuggestionView.d.mts +0 -33
  165. package/dist/components/chat/CopilotChatSuggestionView.d.ts +0 -33
  166. package/dist/components/chat/CopilotChatSuggestionView.js +0 -179
  167. package/dist/components/chat/CopilotChatSuggestionView.js.map +0 -1
  168. package/dist/components/chat/CopilotChatSuggestionView.mjs +0 -12
  169. package/dist/components/chat/CopilotChatSuggestionView.mjs.map +0 -1
  170. package/dist/components/chat/CopilotChatToggleButton.d.mts +0 -14
  171. package/dist/components/chat/CopilotChatToggleButton.d.ts +0 -14
  172. package/dist/components/chat/CopilotChatToggleButton.js +0 -222
  173. package/dist/components/chat/CopilotChatToggleButton.js.map +0 -1
  174. package/dist/components/chat/CopilotChatToggleButton.mjs +0 -16
  175. package/dist/components/chat/CopilotChatToggleButton.mjs.map +0 -1
  176. package/dist/components/chat/CopilotChatToolCallsView.d.mts +0 -10
  177. package/dist/components/chat/CopilotChatToolCallsView.d.ts +0 -10
  178. package/dist/components/chat/CopilotChatToolCallsView.js +0 -264
  179. package/dist/components/chat/CopilotChatToolCallsView.js.map +0 -1
  180. package/dist/components/chat/CopilotChatToolCallsView.mjs +0 -24
  181. package/dist/components/chat/CopilotChatToolCallsView.mjs.map +0 -1
  182. package/dist/components/chat/CopilotChatUserMessage.d.mts +0 -52
  183. package/dist/components/chat/CopilotChatUserMessage.d.ts +0 -52
  184. package/dist/components/chat/CopilotChatUserMessage.js +0 -523
  185. package/dist/components/chat/CopilotChatUserMessage.js.map +0 -1
  186. package/dist/components/chat/CopilotChatUserMessage.mjs +0 -14
  187. package/dist/components/chat/CopilotChatUserMessage.mjs.map +0 -1
  188. package/dist/components/chat/CopilotChatView.d.mts +0 -54
  189. package/dist/components/chat/CopilotChatView.d.ts +0 -54
  190. package/dist/components/chat/CopilotChatView.js +0 -2640
  191. package/dist/components/chat/CopilotChatView.js.map +0 -1
  192. package/dist/components/chat/CopilotChatView.mjs +0 -38
  193. package/dist/components/chat/CopilotChatView.mjs.map +0 -1
  194. package/dist/components/chat/CopilotModalHeader.d.mts +0 -22
  195. package/dist/components/chat/CopilotModalHeader.d.ts +0 -22
  196. package/dist/components/chat/CopilotModalHeader.js +0 -186
  197. package/dist/components/chat/CopilotModalHeader.js.map +0 -1
  198. package/dist/components/chat/CopilotModalHeader.mjs +0 -12
  199. package/dist/components/chat/CopilotModalHeader.mjs.map +0 -1
  200. package/dist/components/chat/CopilotPopup.d.mts +0 -33
  201. package/dist/components/chat/CopilotPopup.d.ts +0 -33
  202. package/dist/components/chat/CopilotPopup.js +0 -3343
  203. package/dist/components/chat/CopilotPopup.js.map +0 -1
  204. package/dist/components/chat/CopilotPopup.mjs +0 -43
  205. package/dist/components/chat/CopilotPopup.mjs.map +0 -1
  206. package/dist/components/chat/CopilotPopupView.d.mts +0 -30
  207. package/dist/components/chat/CopilotPopupView.d.ts +0 -30
  208. package/dist/components/chat/CopilotPopupView.js +0 -3003
  209. package/dist/components/chat/CopilotPopupView.js.map +0 -1
  210. package/dist/components/chat/CopilotPopupView.mjs +0 -41
  211. package/dist/components/chat/CopilotPopupView.mjs.map +0 -1
  212. package/dist/components/chat/CopilotSidebar.d.mts +0 -31
  213. package/dist/components/chat/CopilotSidebar.d.ts +0 -31
  214. package/dist/components/chat/CopilotSidebar.js +0 -3266
  215. package/dist/components/chat/CopilotSidebar.js.map +0 -1
  216. package/dist/components/chat/CopilotSidebar.mjs +0 -43
  217. package/dist/components/chat/CopilotSidebar.mjs.map +0 -1
  218. package/dist/components/chat/CopilotSidebarView.d.mts +0 -28
  219. package/dist/components/chat/CopilotSidebarView.d.ts +0 -28
  220. package/dist/components/chat/CopilotSidebarView.js +0 -2941
  221. package/dist/components/chat/CopilotSidebarView.js.map +0 -1
  222. package/dist/components/chat/CopilotSidebarView.mjs +0 -41
  223. package/dist/components/chat/CopilotSidebarView.mjs.map +0 -1
  224. package/dist/components/chat/index.d.mts +0 -23
  225. package/dist/components/chat/index.d.ts +0 -23
  226. package/dist/components/chat/index.js +0 -3503
  227. package/dist/components/chat/index.js.map +0 -1
  228. package/dist/components/chat/index.mjs +0 -95
  229. package/dist/components/chat/index.mjs.map +0 -1
  230. package/dist/components/index.d.mts +0 -29
  231. package/dist/components/index.d.ts +0 -29
  232. package/dist/components/index.js +0 -3583
  233. package/dist/components/index.js.map +0 -1
  234. package/dist/components/index.mjs +0 -104
  235. package/dist/components/index.mjs.map +0 -1
  236. package/dist/components/ui/button.d.mts +0 -14
  237. package/dist/components/ui/button.d.ts +0 -14
  238. package/dist/components/ui/button.js +0 -150
  239. package/dist/components/ui/button.js.map +0 -1
  240. package/dist/components/ui/button.mjs +0 -10
  241. package/dist/components/ui/button.mjs.map +0 -1
  242. package/dist/components/ui/dropdown-menu.d.mts +0 -28
  243. package/dist/components/ui/dropdown-menu.d.ts +0 -28
  244. package/dist/components/ui/dropdown-menu.js +0 -291
  245. package/dist/components/ui/dropdown-menu.js.map +0 -1
  246. package/dist/components/ui/dropdown-menu.mjs +0 -37
  247. package/dist/components/ui/dropdown-menu.mjs.map +0 -1
  248. package/dist/components/ui/tooltip.d.mts +0 -10
  249. package/dist/components/ui/tooltip.d.ts +0 -10
  250. package/dist/components/ui/tooltip.js +0 -103
  251. package/dist/components/ui/tooltip.js.map +0 -1
  252. package/dist/components/ui/tooltip.mjs +0 -14
  253. package/dist/components/ui/tooltip.mjs.map +0 -1
  254. package/dist/hooks/index.d.mts +0 -19
  255. package/dist/hooks/index.d.ts +0 -19
  256. package/dist/hooks/index.js +0 -691
  257. package/dist/hooks/index.js.map +0 -1
  258. package/dist/hooks/index.mjs +0 -45
  259. package/dist/hooks/index.mjs.map +0 -1
  260. package/dist/hooks/use-agent-context.d.mts +0 -5
  261. package/dist/hooks/use-agent-context.d.ts +0 -5
  262. package/dist/hooks/use-agent-context.js +0 -116
  263. package/dist/hooks/use-agent-context.js.map +0 -1
  264. package/dist/hooks/use-agent-context.mjs +0 -10
  265. package/dist/hooks/use-agent-context.mjs.map +0 -1
  266. package/dist/hooks/use-agent.d.mts +0 -16
  267. package/dist/hooks/use-agent.d.ts +0 -16
  268. package/dist/hooks/use-agent.js +0 -171
  269. package/dist/hooks/use-agent.js.map +0 -1
  270. package/dist/hooks/use-agent.mjs +0 -12
  271. package/dist/hooks/use-agent.mjs.map +0 -1
  272. package/dist/hooks/use-configure-suggestions.d.mts +0 -13
  273. package/dist/hooks/use-configure-suggestions.d.ts +0 -13
  274. package/dist/hooks/use-configure-suggestions.js +0 -232
  275. package/dist/hooks/use-configure-suggestions.js.map +0 -1
  276. package/dist/hooks/use-configure-suggestions.mjs +0 -11
  277. package/dist/hooks/use-configure-suggestions.mjs.map +0 -1
  278. package/dist/hooks/use-frontend-tool.d.mts +0 -8
  279. package/dist/hooks/use-frontend-tool.d.ts +0 -8
  280. package/dist/hooks/use-frontend-tool.js +0 -137
  281. package/dist/hooks/use-frontend-tool.js.map +0 -1
  282. package/dist/hooks/use-frontend-tool.mjs +0 -10
  283. package/dist/hooks/use-frontend-tool.mjs.map +0 -1
  284. package/dist/hooks/use-human-in-the-loop.d.mts +0 -7
  285. package/dist/hooks/use-human-in-the-loop.d.ts +0 -7
  286. package/dist/hooks/use-human-in-the-loop.js +0 -206
  287. package/dist/hooks/use-human-in-the-loop.js.map +0 -1
  288. package/dist/hooks/use-human-in-the-loop.mjs +0 -11
  289. package/dist/hooks/use-human-in-the-loop.mjs.map +0 -1
  290. package/dist/hooks/use-keyboard-height.d.mts +0 -15
  291. package/dist/hooks/use-keyboard-height.d.ts +0 -15
  292. package/dist/hooks/use-keyboard-height.js +0 -68
  293. package/dist/hooks/use-keyboard-height.js.map +0 -1
  294. package/dist/hooks/use-keyboard-height.mjs +0 -7
  295. package/dist/hooks/use-keyboard-height.mjs.map +0 -1
  296. package/dist/hooks/use-render-activity-message.d.mts +0 -5
  297. package/dist/hooks/use-render-activity-message.d.ts +0 -5
  298. package/dist/hooks/use-render-activity-message.js +0 -158
  299. package/dist/hooks/use-render-activity-message.js.map +0 -1
  300. package/dist/hooks/use-render-activity-message.mjs +0 -12
  301. package/dist/hooks/use-render-activity-message.mjs.map +0 -1
  302. package/dist/hooks/use-render-custom-messages.d.mts +0 -11
  303. package/dist/hooks/use-render-custom-messages.d.ts +0 -11
  304. package/dist/hooks/use-render-custom-messages.js +0 -170
  305. package/dist/hooks/use-render-custom-messages.js.map +0 -1
  306. package/dist/hooks/use-render-custom-messages.mjs +0 -12
  307. package/dist/hooks/use-render-custom-messages.mjs.map +0 -1
  308. package/dist/hooks/use-render-tool-call.d.mts +0 -16
  309. package/dist/hooks/use-render-tool-call.d.ts +0 -16
  310. package/dist/hooks/use-render-tool-call.js +0 -208
  311. package/dist/hooks/use-render-tool-call.js.map +0 -1
  312. package/dist/hooks/use-render-tool-call.mjs +0 -11
  313. package/dist/hooks/use-render-tool-call.mjs.map +0 -1
  314. package/dist/hooks/use-suggestions.d.mts +0 -14
  315. package/dist/hooks/use-suggestions.d.ts +0 -14
  316. package/dist/hooks/use-suggestions.js +0 -176
  317. package/dist/hooks/use-suggestions.js.map +0 -1
  318. package/dist/hooks/use-suggestions.mjs +0 -11
  319. package/dist/hooks/use-suggestions.mjs.map +0 -1
  320. package/dist/lib/react-core.d.mts +0 -33
  321. package/dist/lib/react-core.d.ts +0 -33
  322. package/dist/lib/react-core.js +0 -73
  323. package/dist/lib/react-core.js.map +0 -1
  324. package/dist/lib/react-core.mjs +0 -7
  325. package/dist/lib/react-core.mjs.map +0 -1
  326. package/dist/lib/slots.d.mts +0 -16
  327. package/dist/lib/slots.d.ts +0 -16
  328. package/dist/lib/slots.js +0 -60
  329. package/dist/lib/slots.js.map +0 -1
  330. package/dist/lib/slots.mjs +0 -7
  331. package/dist/lib/slots.mjs.map +0 -1
  332. package/dist/lib/utils.d.mts +0 -5
  333. package/dist/lib/utils.d.ts +0 -5
  334. package/dist/lib/utils.js +0 -35
  335. package/dist/lib/utils.js.map +0 -1
  336. package/dist/lib/utils.mjs +0 -7
  337. package/dist/lib/utils.mjs.map +0 -1
  338. package/dist/providers/CopilotChatConfigurationProvider.d.mts +0 -43
  339. package/dist/providers/CopilotChatConfigurationProvider.d.ts +0 -43
  340. package/dist/providers/CopilotChatConfigurationProvider.js +0 -109
  341. package/dist/providers/CopilotChatConfigurationProvider.js.map +0 -1
  342. package/dist/providers/CopilotChatConfigurationProvider.mjs +0 -11
  343. package/dist/providers/CopilotChatConfigurationProvider.mjs.map +0 -1
  344. package/dist/providers/CopilotKitProvider.d.mts +0 -33
  345. package/dist/providers/CopilotKitProvider.d.ts +0 -33
  346. package/dist/providers/CopilotKitProvider.js +0 -314
  347. package/dist/providers/CopilotKitProvider.js.map +0 -1
  348. package/dist/providers/CopilotKitProvider.mjs +0 -12
  349. package/dist/providers/CopilotKitProvider.mjs.map +0 -1
  350. package/dist/providers/index.d.mts +0 -13
  351. package/dist/providers/index.d.ts +0 -13
  352. package/dist/providers/index.js +0 -396
  353. package/dist/providers/index.js.map +0 -1
  354. package/dist/providers/index.mjs +0 -18
  355. package/dist/providers/index.mjs.map +0 -1
  356. package/dist/types/defineToolCallRenderer.d.mts +0 -41
  357. package/dist/types/defineToolCallRenderer.d.ts +0 -41
  358. package/dist/types/defineToolCallRenderer.js +0 -40
  359. package/dist/types/defineToolCallRenderer.js.map +0 -1
  360. package/dist/types/defineToolCallRenderer.mjs +0 -7
  361. package/dist/types/defineToolCallRenderer.mjs.map +0 -1
  362. package/dist/types/frontend-tool.d.mts +0 -9
  363. package/dist/types/frontend-tool.d.ts +0 -9
  364. package/dist/types/frontend-tool.js +0 -19
  365. package/dist/types/frontend-tool.js.map +0 -1
  366. package/dist/types/frontend-tool.mjs +0 -2
  367. package/dist/types/frontend-tool.mjs.map +0 -1
  368. package/dist/types/human-in-the-loop.d.mts +0 -29
  369. package/dist/types/human-in-the-loop.d.ts +0 -29
  370. package/dist/types/human-in-the-loop.js +0 -19
  371. package/dist/types/human-in-the-loop.js.map +0 -1
  372. package/dist/types/human-in-the-loop.mjs +0 -2
  373. package/dist/types/human-in-the-loop.mjs.map +0 -1
  374. package/dist/types/index.d.mts +0 -11
  375. package/dist/types/index.d.ts +0 -11
  376. package/dist/types/index.js +0 -42
  377. package/dist/types/index.js.map +0 -1
  378. package/dist/types/index.mjs +0 -13
  379. package/dist/types/index.mjs.map +0 -1
  380. package/dist/types/react-activity-message-renderer.d.mts +0 -29
  381. package/dist/types/react-activity-message-renderer.d.ts +0 -29
  382. package/dist/types/react-activity-message-renderer.js +0 -19
  383. package/dist/types/react-activity-message-renderer.js.map +0 -1
  384. package/dist/types/react-activity-message-renderer.mjs +0 -2
  385. package/dist/types/react-activity-message-renderer.mjs.map +0 -1
  386. package/dist/types/react-custom-message-renderer.d.mts +0 -18
  387. package/dist/types/react-custom-message-renderer.d.ts +0 -18
  388. package/dist/types/react-custom-message-renderer.js +0 -19
  389. package/dist/types/react-custom-message-renderer.js.map +0 -1
  390. package/dist/types/react-custom-message-renderer.mjs +0 -2
  391. package/dist/types/react-custom-message-renderer.mjs.map +0 -1
  392. package/dist/types/react-tool-call-renderer.d.mts +0 -30
  393. package/dist/types/react-tool-call-renderer.d.ts +0 -30
  394. package/dist/types/react-tool-call-renderer.js +0 -19
  395. package/dist/types/react-tool-call-renderer.js.map +0 -1
  396. package/dist/types/react-tool-call-renderer.mjs +0 -2
  397. package/dist/types/react-tool-call-renderer.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/chat/CopilotChatInput.tsx"],"sourcesContent":["import React, {\n useState,\n useRef,\n KeyboardEvent,\n ChangeEvent,\n useEffect,\n useLayoutEffect,\n forwardRef,\n useImperativeHandle,\n useCallback,\n useMemo,\n} from \"react\";\nimport { twMerge } from \"tailwind-merge\";\nimport { Plus, Mic, ArrowUp, X, Check, Square } from \"lucide-react\";\n\nimport {\n CopilotChatLabels,\n useCopilotChatConfiguration,\n CopilotChatDefaultLabels,\n} from \"@/providers/CopilotChatConfigurationProvider\";\nimport { Button } from \"@/components/ui/button\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@/components/ui/tooltip\";\nimport {\n DropdownMenu,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSub,\n DropdownMenuSubTrigger,\n DropdownMenuSubContent,\n DropdownMenuSeparator,\n} from \"@/components/ui/dropdown-menu\";\n\nimport { CopilotChatAudioRecorder } from \"./CopilotChatAudioRecorder\";\nimport { renderSlot, WithSlots } from \"@/lib/slots\";\n\nexport type CopilotChatInputMode = \"input\" | \"transcribe\" | \"processing\";\n\nexport type ToolsMenuItem = {\n label: string;\n} & (\n | {\n action: () => void;\n items?: never;\n }\n | {\n action?: never;\n items: (ToolsMenuItem | \"-\")[];\n }\n);\n\ntype CopilotChatInputSlots = {\n textArea: typeof CopilotChatInput.TextArea;\n sendButton: typeof CopilotChatInput.SendButton;\n startTranscribeButton: typeof CopilotChatInput.StartTranscribeButton;\n cancelTranscribeButton: typeof CopilotChatInput.CancelTranscribeButton;\n finishTranscribeButton: typeof CopilotChatInput.FinishTranscribeButton;\n addMenuButton: typeof CopilotChatInput.AddMenuButton;\n audioRecorder: typeof CopilotChatAudioRecorder;\n};\n\ntype CopilotChatInputRestProps = {\n mode?: CopilotChatInputMode;\n toolsMenu?: (ToolsMenuItem | \"-\")[];\n autoFocus?: boolean;\n onSubmitMessage?: (value: string) => void;\n onStop?: () => void;\n isRunning?: boolean;\n onStartTranscribe?: () => void;\n onCancelTranscribe?: () => void;\n onFinishTranscribe?: () => void;\n onAddFile?: () => void;\n value?: string;\n onChange?: (value: string) => void;\n} & Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\">;\n\ntype CopilotChatInputBaseProps = WithSlots<CopilotChatInputSlots, CopilotChatInputRestProps>;\n\ntype CopilotChatInputChildrenArgs = CopilotChatInputBaseProps extends { children?: infer C }\n ? C extends (props: infer P) => React.ReactNode\n ? P\n : never\n : never;\n\nexport type CopilotChatInputProps = Omit<CopilotChatInputBaseProps, \"children\"> & {\n children?: (props: CopilotChatInputChildrenArgs) => React.ReactNode;\n};\n\nconst SLASH_MENU_MAX_VISIBLE_ITEMS = 5;\nconst SLASH_MENU_ITEM_HEIGHT_PX = 40;\n\nexport function CopilotChatInput({\n mode = \"input\",\n onSubmitMessage,\n onStop,\n isRunning = false,\n onStartTranscribe,\n onCancelTranscribe,\n onFinishTranscribe,\n onAddFile,\n onChange,\n value,\n toolsMenu,\n autoFocus = true,\n textArea,\n sendButton,\n startTranscribeButton,\n cancelTranscribeButton,\n finishTranscribeButton,\n addMenuButton,\n audioRecorder,\n children,\n className,\n ...props\n}: CopilotChatInputProps) {\n const isControlled = value !== undefined;\n const [internalValue, setInternalValue] = useState<string>(() => value ?? \"\");\n\n useEffect(() => {\n if (!isControlled && value !== undefined) {\n setInternalValue(value);\n }\n }, [isControlled, value]);\n\n const resolvedValue = isControlled ? (value ?? \"\") : internalValue;\n\n const [layout, setLayout] = useState<\"compact\" | \"expanded\">(\"compact\");\n const ignoreResizeRef = useRef(false);\n const resizeEvaluationRafRef = useRef<number | null>(null);\n const isExpanded = mode === \"input\" && layout === \"expanded\";\n const [commandQuery, setCommandQuery] = useState<string | null>(null);\n const [slashHighlightIndex, setSlashHighlightIndex] = useState(0);\n\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const gridRef = useRef<HTMLDivElement>(null);\n const addButtonContainerRef = useRef<HTMLDivElement>(null);\n const actionsContainerRef = useRef<HTMLDivElement>(null);\n const audioRecorderRef = useRef<React.ElementRef<typeof CopilotChatAudioRecorder>>(null);\n const slashMenuRef = useRef<HTMLDivElement>(null);\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n\n const previousModalStateRef = useRef<boolean | undefined>(undefined);\n const measurementCanvasRef = useRef<HTMLCanvasElement | null>(null);\n const measurementsRef = useRef({\n singleLineHeight: 0,\n maxHeight: 0,\n paddingLeft: 0,\n paddingRight: 0,\n });\n\n const commandItems = useMemo(() => {\n const entries: ToolsMenuItem[] = [];\n const seen = new Set<string>();\n\n const pushItem = (item: ToolsMenuItem | \"-\") => {\n if (item === \"-\") {\n return;\n }\n\n if (item.items && item.items.length > 0) {\n for (const nested of item.items) {\n pushItem(nested);\n }\n return;\n }\n\n if (!seen.has(item.label)) {\n seen.add(item.label);\n entries.push(item);\n }\n };\n\n if (onAddFile) {\n pushItem({\n label: labels.chatInputToolbarAddButtonLabel,\n action: onAddFile,\n });\n }\n\n if (toolsMenu && toolsMenu.length > 0) {\n for (const item of toolsMenu) {\n pushItem(item);\n }\n }\n\n return entries;\n }, [labels.chatInputToolbarAddButtonLabel, onAddFile, toolsMenu]);\n\n const filteredCommands = useMemo(() => {\n if (commandQuery === null) {\n return [] as ToolsMenuItem[];\n }\n\n if (commandItems.length === 0) {\n return [] as ToolsMenuItem[];\n }\n\n const query = commandQuery.trim().toLowerCase();\n if (query.length === 0) {\n return commandItems;\n }\n\n const startsWith: ToolsMenuItem[] = [];\n const contains: ToolsMenuItem[] = [];\n for (const item of commandItems) {\n const label = item.label.toLowerCase();\n if (label.startsWith(query)) {\n startsWith.push(item);\n } else if (label.includes(query)) {\n contains.push(item);\n }\n }\n\n return [...startsWith, ...contains];\n }, [commandItems, commandQuery]);\n\n useEffect(() => {\n if (!autoFocus) {\n previousModalStateRef.current = config?.isModalOpen;\n return;\n }\n\n if (config?.isModalOpen && !previousModalStateRef.current) {\n inputRef.current?.focus();\n }\n\n previousModalStateRef.current = config?.isModalOpen;\n }, [config?.isModalOpen, autoFocus]);\n\n useEffect(() => {\n if (commandItems.length === 0 && commandQuery !== null) {\n setCommandQuery(null);\n }\n }, [commandItems.length, commandQuery]);\n\n const previousCommandQueryRef = useRef<string | null>(null);\n\n useEffect(() => {\n if (\n commandQuery !== null &&\n commandQuery !== previousCommandQueryRef.current &&\n filteredCommands.length > 0\n ) {\n setSlashHighlightIndex(0);\n }\n\n previousCommandQueryRef.current = commandQuery;\n }, [commandQuery, filteredCommands.length]);\n\n useEffect(() => {\n if (commandQuery === null) {\n setSlashHighlightIndex(0);\n return;\n }\n\n if (filteredCommands.length === 0) {\n setSlashHighlightIndex(-1);\n } else if (slashHighlightIndex < 0 || slashHighlightIndex >= filteredCommands.length) {\n setSlashHighlightIndex(0);\n }\n }, [commandQuery, filteredCommands, slashHighlightIndex]);\n\n // Handle recording based on mode changes\n useEffect(() => {\n const recorder = audioRecorderRef.current;\n if (!recorder) {\n return;\n }\n\n if (mode === \"transcribe\") {\n // Start recording when entering transcribe mode\n recorder.start().catch(console.error);\n } else {\n // Stop recording when leaving transcribe mode\n if (recorder.state === \"recording\") {\n recorder.stop().catch(console.error);\n }\n }\n }, [mode]);\n\n useEffect(() => {\n if (mode !== \"input\") {\n setLayout(\"compact\");\n setCommandQuery(null);\n }\n }, [mode]);\n\n const updateSlashState = useCallback(\n (value: string) => {\n if (commandItems.length === 0) {\n setCommandQuery((prev) => (prev === null ? prev : null));\n return;\n }\n\n if (value.startsWith(\"/\")) {\n const firstLine = value.split(/\\r?\\n/, 1)[0] ?? \"\";\n const query = firstLine.slice(1);\n setCommandQuery((prev) => (prev === query ? prev : query));\n } else {\n setCommandQuery((prev) => (prev === null ? prev : null));\n }\n },\n [commandItems.length],\n );\n\n useEffect(() => {\n updateSlashState(resolvedValue);\n }, [resolvedValue, updateSlashState]);\n\n // Handlers\n const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {\n const nextValue = e.target.value;\n if (!isControlled) {\n setInternalValue(nextValue);\n }\n onChange?.(nextValue);\n updateSlashState(nextValue);\n };\n\n const clearInputValue = useCallback(() => {\n if (!isControlled) {\n setInternalValue(\"\");\n }\n\n if (onChange) {\n onChange(\"\");\n }\n }, [isControlled, onChange]);\n\n const runCommand = useCallback(\n (item: ToolsMenuItem) => {\n clearInputValue();\n\n item.action?.();\n\n setCommandQuery(null);\n setSlashHighlightIndex(0);\n\n requestAnimationFrame(() => {\n inputRef.current?.focus();\n });\n },\n [clearInputValue],\n );\n\n const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (commandQuery !== null && mode === \"input\") {\n if (e.key === \"ArrowDown\") {\n if (filteredCommands.length > 0) {\n e.preventDefault();\n setSlashHighlightIndex((prev) => {\n if (filteredCommands.length === 0) {\n return prev;\n }\n const next = prev === -1 ? 0 : (prev + 1) % filteredCommands.length;\n return next;\n });\n }\n return;\n }\n\n if (e.key === \"ArrowUp\") {\n if (filteredCommands.length > 0) {\n e.preventDefault();\n setSlashHighlightIndex((prev) => {\n if (filteredCommands.length === 0) {\n return prev;\n }\n if (prev === -1) {\n return filteredCommands.length - 1;\n }\n return prev <= 0 ? filteredCommands.length - 1 : prev - 1;\n });\n }\n return;\n }\n\n if (e.key === \"Enter\") {\n const selected = slashHighlightIndex >= 0 ? filteredCommands[slashHighlightIndex] : undefined;\n if (selected) {\n e.preventDefault();\n runCommand(selected);\n return;\n }\n }\n\n if (e.key === \"Escape\") {\n e.preventDefault();\n setCommandQuery(null);\n return;\n }\n }\n\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n if (isProcessing) {\n onStop?.();\n } else {\n send();\n }\n }\n };\n\n const send = () => {\n if (!onSubmitMessage) {\n return;\n }\n const trimmed = resolvedValue.trim();\n if (!trimmed) {\n return;\n }\n\n onSubmitMessage(trimmed);\n\n if (!isControlled) {\n setInternalValue(\"\");\n onChange?.(\"\");\n }\n\n if (inputRef.current) {\n inputRef.current.focus();\n }\n };\n\n const BoundTextArea = renderSlot(textArea, CopilotChatInput.TextArea, {\n ref: inputRef,\n value: resolvedValue,\n onChange: handleChange,\n onKeyDown: handleKeyDown,\n autoFocus: autoFocus,\n className: twMerge(\n \"w-full py-3\",\n isExpanded ? \"px-5\" : \"pr-5\",\n ),\n });\n\n const isProcessing = mode !== \"transcribe\" && isRunning;\n const canSend = resolvedValue.trim().length > 0 && !!onSubmitMessage;\n const canStop = !!onStop;\n\n const handleSendButtonClick = () => {\n if (isProcessing) {\n onStop?.();\n return;\n }\n send();\n };\n\n const BoundAudioRecorder = renderSlot(audioRecorder, CopilotChatAudioRecorder, {\n ref: audioRecorderRef,\n });\n\n const BoundSendButton = renderSlot(sendButton, CopilotChatInput.SendButton, {\n onClick: handleSendButtonClick,\n disabled: isProcessing ? !canStop : !canSend,\n children: isProcessing && canStop ? <Square className=\"size-[18px] fill-current\" /> : undefined,\n });\n\n const BoundStartTranscribeButton = renderSlot(startTranscribeButton, CopilotChatInput.StartTranscribeButton, {\n onClick: onStartTranscribe,\n });\n\n const BoundCancelTranscribeButton = renderSlot(cancelTranscribeButton, CopilotChatInput.CancelTranscribeButton, {\n onClick: onCancelTranscribe,\n });\n\n const BoundFinishTranscribeButton = renderSlot(finishTranscribeButton, CopilotChatInput.FinishTranscribeButton, {\n onClick: onFinishTranscribe,\n });\n\n const BoundAddMenuButton = renderSlot(addMenuButton, CopilotChatInput.AddMenuButton, {\n disabled: mode === \"transcribe\",\n onAddFile,\n toolsMenu,\n });\n\n if (children) {\n const childProps = {\n textArea: BoundTextArea,\n audioRecorder: BoundAudioRecorder,\n sendButton: BoundSendButton,\n startTranscribeButton: BoundStartTranscribeButton,\n cancelTranscribeButton: BoundCancelTranscribeButton,\n finishTranscribeButton: BoundFinishTranscribeButton,\n addMenuButton: BoundAddMenuButton,\n onSubmitMessage,\n onStop,\n isRunning,\n onStartTranscribe,\n onCancelTranscribe,\n onFinishTranscribe,\n onAddFile,\n mode,\n toolsMenu,\n autoFocus,\n } as CopilotChatInputChildrenArgs;\n\n return <>{children(childProps)}</>;\n }\n\n const handleContainerClick = (e: React.MouseEvent<HTMLDivElement>) => {\n // Don't focus if clicking on buttons or other interactive elements\n const target = e.target as HTMLElement;\n if (target.tagName !== \"BUTTON\" && !target.closest(\"button\") && inputRef.current && mode === \"input\") {\n inputRef.current.focus();\n }\n };\n\n const ensureMeasurements = useCallback(() => {\n const textarea = inputRef.current;\n if (!textarea) {\n return;\n }\n\n const previousValue = textarea.value;\n const previousHeight = textarea.style.height;\n\n textarea.style.height = \"auto\";\n\n const computedStyle = window.getComputedStyle(textarea);\n const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;\n const paddingRight = parseFloat(computedStyle.paddingRight) || 0;\n const paddingTop = parseFloat(computedStyle.paddingTop) || 0;\n const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;\n\n textarea.value = \"\";\n const singleLineHeight = textarea.scrollHeight;\n textarea.value = previousValue;\n\n const contentHeight = singleLineHeight - paddingTop - paddingBottom;\n const maxHeight = contentHeight * 5 + paddingTop + paddingBottom;\n\n measurementsRef.current = {\n singleLineHeight,\n maxHeight,\n paddingLeft,\n paddingRight,\n };\n\n textarea.style.height = previousHeight;\n textarea.style.maxHeight = `${maxHeight}px`;\n }, []);\n\n const adjustTextareaHeight = useCallback(() => {\n const textarea = inputRef.current;\n if (!textarea) {\n return 0;\n }\n\n if (measurementsRef.current.singleLineHeight === 0) {\n ensureMeasurements();\n }\n\n const { maxHeight } = measurementsRef.current;\n if (maxHeight) {\n textarea.style.maxHeight = `${maxHeight}px`;\n }\n\n textarea.style.height = \"auto\";\n const scrollHeight = textarea.scrollHeight;\n if (maxHeight) {\n textarea.style.height = `${Math.min(scrollHeight, maxHeight)}px`;\n } else {\n textarea.style.height = `${scrollHeight}px`;\n }\n\n return scrollHeight;\n }, [ensureMeasurements]);\n\n const updateLayout = useCallback((nextLayout: \"compact\" | \"expanded\") => {\n setLayout((prev) => {\n if (prev === nextLayout) {\n return prev;\n }\n ignoreResizeRef.current = true;\n return nextLayout;\n });\n }, []);\n\n const evaluateLayout = useCallback(() => {\n if (mode !== \"input\") {\n updateLayout(\"compact\");\n return;\n }\n\n if (typeof window !== \"undefined\" && typeof window.matchMedia === \"function\") {\n const isMobileViewport = window.matchMedia(\"(max-width: 767px)\").matches;\n if (isMobileViewport) {\n ensureMeasurements();\n adjustTextareaHeight();\n updateLayout(\"expanded\");\n return;\n }\n }\n\n const textarea = inputRef.current;\n const grid = gridRef.current;\n const addContainer = addButtonContainerRef.current;\n const actionsContainer = actionsContainerRef.current;\n\n if (!textarea || !grid || !addContainer || !actionsContainer) {\n return;\n }\n\n if (measurementsRef.current.singleLineHeight === 0) {\n ensureMeasurements();\n }\n\n const scrollHeight = adjustTextareaHeight();\n const baseline = measurementsRef.current.singleLineHeight;\n const hasExplicitBreak = resolvedValue.includes(\"\\n\");\n const renderedMultiline = baseline > 0 ? scrollHeight > baseline + 1 : false;\n let shouldExpand = hasExplicitBreak || renderedMultiline;\n\n if (!shouldExpand) {\n const gridStyles = window.getComputedStyle(grid);\n const paddingLeft = parseFloat(gridStyles.paddingLeft) || 0;\n const paddingRight = parseFloat(gridStyles.paddingRight) || 0;\n const columnGap = parseFloat(gridStyles.columnGap) || 0;\n const gridAvailableWidth = grid.clientWidth - paddingLeft - paddingRight;\n\n if (gridAvailableWidth > 0) {\n const addWidth = addContainer.getBoundingClientRect().width;\n const actionsWidth = actionsContainer.getBoundingClientRect().width;\n const compactWidth = Math.max(gridAvailableWidth - addWidth - actionsWidth - columnGap * 2, 0);\n\n const canvas = measurementCanvasRef.current ?? document.createElement(\"canvas\");\n if (!measurementCanvasRef.current) {\n measurementCanvasRef.current = canvas;\n }\n\n const context = canvas.getContext(\"2d\");\n if (context) {\n const textareaStyles = window.getComputedStyle(textarea);\n const font =\n textareaStyles.font ||\n `${textareaStyles.fontStyle} ${textareaStyles.fontVariant} ${textareaStyles.fontWeight} ${textareaStyles.fontSize}/${textareaStyles.lineHeight} ${textareaStyles.fontFamily}`;\n context.font = font;\n\n const compactInnerWidth = Math.max(\n compactWidth - (measurementsRef.current.paddingLeft || 0) - (measurementsRef.current.paddingRight || 0),\n 0,\n );\n\n if (compactInnerWidth > 0) {\n const lines = resolvedValue.length > 0 ? resolvedValue.split(\"\\n\") : [\"\"];\n let longestWidth = 0;\n for (const line of lines) {\n const metrics = context.measureText(line || \" \");\n if (metrics.width > longestWidth) {\n longestWidth = metrics.width;\n }\n }\n\n if (longestWidth > compactInnerWidth) {\n shouldExpand = true;\n }\n }\n }\n }\n }\n\n const nextLayout = shouldExpand ? \"expanded\" : \"compact\";\n updateLayout(nextLayout);\n }, [adjustTextareaHeight, ensureMeasurements, mode, resolvedValue, updateLayout]);\n\n useLayoutEffect(() => {\n evaluateLayout();\n }, [evaluateLayout]);\n\n useEffect(() => {\n if (typeof ResizeObserver === \"undefined\") {\n return;\n }\n\n const textarea = inputRef.current;\n const grid = gridRef.current;\n const addContainer = addButtonContainerRef.current;\n const actionsContainer = actionsContainerRef.current;\n\n if (!textarea || !grid || !addContainer || !actionsContainer) {\n return;\n }\n\n const scheduleEvaluation = () => {\n if (ignoreResizeRef.current) {\n ignoreResizeRef.current = false;\n return;\n }\n\n if (typeof window === \"undefined\") {\n evaluateLayout();\n return;\n }\n\n if (resizeEvaluationRafRef.current !== null) {\n cancelAnimationFrame(resizeEvaluationRafRef.current);\n }\n\n resizeEvaluationRafRef.current = window.requestAnimationFrame(() => {\n resizeEvaluationRafRef.current = null;\n evaluateLayout();\n });\n };\n\n const observer = new ResizeObserver(() => {\n scheduleEvaluation();\n });\n\n observer.observe(grid);\n observer.observe(addContainer);\n observer.observe(actionsContainer);\n observer.observe(textarea);\n\n return () => {\n observer.disconnect();\n if (typeof window !== \"undefined\" && resizeEvaluationRafRef.current !== null) {\n cancelAnimationFrame(resizeEvaluationRafRef.current);\n resizeEvaluationRafRef.current = null;\n }\n };\n }, [evaluateLayout]);\n\n const slashMenuVisible = commandQuery !== null && commandItems.length > 0;\n\n useEffect(() => {\n if (!slashMenuVisible || slashHighlightIndex < 0) {\n return;\n }\n\n const active = slashMenuRef.current?.querySelector<HTMLElement>(\n `[data-slash-index=\"${slashHighlightIndex}\"]`,\n );\n active?.scrollIntoView({ block: \"nearest\" });\n }, [slashMenuVisible, slashHighlightIndex]);\n\n const slashMenu = slashMenuVisible ? (\n <div\n data-testid=\"copilot-slash-menu\"\n role=\"listbox\"\n aria-label=\"Slash commands\"\n ref={slashMenuRef}\n className=\"absolute bottom-full left-0 right-0 z-30 mb-2 max-h-64 overflow-y-auto rounded-lg border border-border bg-white shadow-lg dark:border-[#3a3a3a] dark:bg-[#1f1f1f]\"\n style={{ maxHeight: `${SLASH_MENU_MAX_VISIBLE_ITEMS * SLASH_MENU_ITEM_HEIGHT_PX}px` }}\n >\n {filteredCommands.length === 0 ? (\n <div className=\"px-3 py-2 text-sm text-muted-foreground\">No commands found</div>\n ) : (\n filteredCommands.map((item, index) => {\n const isActive = index === slashHighlightIndex;\n return (\n <button\n key={`${item.label}-${index}`}\n type=\"button\"\n role=\"option\"\n aria-selected={isActive}\n data-active={isActive ? \"true\" : undefined}\n data-slash-index={index}\n className={twMerge(\n \"w-full px-3 py-2 text-left text-sm transition-colors\",\n \"hover:bg-muted dark:hover:bg-[#2f2f2f]\",\n isActive ? \"bg-muted dark:bg-[#2f2f2f]\" : \"bg-transparent\",\n )}\n onMouseEnter={() => setSlashHighlightIndex(index)}\n onMouseDown={(event) => {\n event.preventDefault();\n runCommand(item);\n }}\n >\n {item.label}\n </button>\n );\n })\n )}\n </div>\n ) : null;\n\n return (\n <div\n className={twMerge(\n // Layout\n \"flex w-full flex-col items-center justify-center\",\n // Interaction\n \"cursor-text\",\n // Overflow and clipping\n \"overflow-visible bg-clip-padding contain-inline-size\",\n // Background\n \"bg-white dark:bg-[#303030]\",\n // Visual effects\n \"shadow-[0_4px_4px_0_#0000000a,0_0_1px_0_#0000009e] rounded-[28px]\",\n className,\n )}\n onClick={handleContainerClick}\n {...props}\n data-layout={isExpanded ? \"expanded\" : \"compact\"}\n >\n <div\n ref={gridRef}\n className={twMerge(\n \"grid w-full gap-x-3 gap-y-3 px-3 py-2\",\n isExpanded\n ? \"grid-cols-[auto_minmax(0,1fr)_auto] grid-rows-[auto_auto]\"\n : \"grid-cols-[auto_minmax(0,1fr)_auto] items-center\",\n )}\n data-layout={isExpanded ? \"expanded\" : \"compact\"}\n >\n <div\n ref={addButtonContainerRef}\n className={twMerge(\n \"flex items-center\",\n isExpanded ? \"row-start-2\" : \"row-start-1\",\n \"col-start-1\",\n )}\n >\n {BoundAddMenuButton}\n </div>\n <div\n className={twMerge(\n \"relative flex min-w-0 flex-col\",\n isExpanded ? \"col-span-3 row-start-1\" : \"col-start-2 row-start-1\",\n )}\n >\n {mode === \"transcribe\" ? (\n BoundAudioRecorder\n ) : (\n <>\n {BoundTextArea}\n {slashMenu}\n </>\n )}\n </div>\n <div\n ref={actionsContainerRef}\n className={twMerge(\n \"flex items-center justify-end gap-2\",\n isExpanded ? \"col-start-3 row-start-2\" : \"col-start-3 row-start-1\",\n )}\n >\n {mode === \"transcribe\" ? (\n <>\n {onCancelTranscribe && BoundCancelTranscribeButton}\n {onFinishTranscribe && BoundFinishTranscribeButton}\n </>\n ) : (\n <>\n {onStartTranscribe && BoundStartTranscribeButton}\n {BoundSendButton}\n </>\n )}\n </div>\n </div>\n </div>\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace CopilotChatInput {\n export const SendButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>> = ({ className, children, ...props }) => (\n <div className=\"mr-[10px]\">\n <Button\n type=\"button\"\n variant=\"chatInputToolbarPrimary\"\n size=\"chatInputToolbarIcon\"\n className={className}\n {...props}\n >\n {children ?? <ArrowUp className=\"size-[18px]\" />}\n </Button>\n </div>\n );\n\n export const ToolbarButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement> & {\n icon: React.ReactNode;\n labelKey: keyof CopilotChatLabels;\n defaultClassName?: string;\n }\n > = ({ icon, labelKey, defaultClassName, className, ...props }) => {\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n type=\"button\"\n variant=\"chatInputToolbarSecondary\"\n size=\"chatInputToolbarIcon\"\n className={twMerge(defaultClassName, className)}\n {...props}\n >\n {icon}\n </Button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">\n <p>{labels[labelKey]}</p>\n </TooltipContent>\n </Tooltip>\n );\n };\n\n export const StartTranscribeButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>> = (props) => (\n <ToolbarButton\n icon={<Mic className=\"size-[18px]\" />}\n labelKey=\"chatInputToolbarStartTranscribeButtonLabel\"\n defaultClassName=\"mr-2\"\n {...props}\n />\n );\n\n export const CancelTranscribeButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>> = (props) => (\n <ToolbarButton\n icon={<X className=\"size-[18px]\" />}\n labelKey=\"chatInputToolbarCancelTranscribeButtonLabel\"\n defaultClassName=\"mr-2\"\n {...props}\n />\n );\n\n export const FinishTranscribeButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>> = (props) => (\n <ToolbarButton\n icon={<Check className=\"size-[18px]\" />}\n labelKey=\"chatInputToolbarFinishTranscribeButtonLabel\"\n defaultClassName=\"mr-[10px]\"\n {...props}\n />\n );\n\n export const AddMenuButton: React.FC<\n React.ButtonHTMLAttributes<HTMLButtonElement> & {\n toolsMenu?: (ToolsMenuItem | \"-\")[];\n onAddFile?: () => void;\n }\n > = ({ className, toolsMenu, onAddFile, disabled, ...props }) => {\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n\n const menuItems = useMemo<(ToolsMenuItem | \"-\")[]>(() => {\n const items: (ToolsMenuItem | \"-\")[] = [];\n\n if (onAddFile) {\n items.push({\n label: labels.chatInputToolbarAddButtonLabel,\n action: onAddFile,\n });\n }\n\n if (toolsMenu && toolsMenu.length > 0) {\n if (items.length > 0) {\n items.push(\"-\");\n }\n\n for (const item of toolsMenu) {\n if (item === \"-\") {\n if (items.length === 0 || items[items.length - 1] === \"-\") {\n continue;\n }\n items.push(item);\n } else {\n items.push(item);\n }\n }\n\n while (items.length > 0 && items[items.length - 1] === \"-\") {\n items.pop();\n }\n }\n\n return items;\n }, [onAddFile, toolsMenu, labels.chatInputToolbarAddButtonLabel]);\n\n const renderMenuItems = useCallback(\n (items: (ToolsMenuItem | \"-\")[]): React.ReactNode =>\n items.map((item, index) => {\n if (item === \"-\") {\n return <DropdownMenuSeparator key={`separator-${index}`} />;\n }\n\n if (item.items && item.items.length > 0) {\n return (\n <DropdownMenuSub key={`group-${index}`}>\n <DropdownMenuSubTrigger>{item.label}</DropdownMenuSubTrigger>\n <DropdownMenuSubContent>{renderMenuItems(item.items)}</DropdownMenuSubContent>\n </DropdownMenuSub>\n );\n }\n\n return (\n <DropdownMenuItem key={`item-${index}`} onClick={item.action}>\n {item.label}\n </DropdownMenuItem>\n );\n }),\n [],\n );\n\n const hasMenuItems = menuItems.length > 0;\n const isDisabled = disabled || !hasMenuItems;\n\n return (\n <DropdownMenu>\n <Tooltip>\n <TooltipTrigger asChild>\n <DropdownMenuTrigger asChild>\n <Button\n type=\"button\"\n variant=\"chatInputToolbarSecondary\"\n size=\"chatInputToolbarIcon\"\n className={twMerge(\"ml-1\", className)}\n disabled={isDisabled}\n {...props}\n >\n <Plus className=\"size-[20px]\" />\n </Button>\n </DropdownMenuTrigger>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">\n <p className=\"flex items-center gap-1 text-xs font-medium\">\n <span>Add files and more</span>\n <code className=\"rounded bg-[#4a4a4a] px-1 py-[1px] font-mono text-[11px] text-white dark:bg-[#e0e0e0] dark:text-black\">/</code>\n </p>\n </TooltipContent>\n </Tooltip>\n {hasMenuItems && (\n <DropdownMenuContent side=\"top\" align=\"start\">\n {renderMenuItems(menuItems)}\n </DropdownMenuContent>\n )}\n </DropdownMenu>\n );\n };\n\n export type TextAreaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;\n\n export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextArea(\n { style, className, autoFocus, ...props },\n ref,\n ) {\n const internalTextareaRef = useRef<HTMLTextAreaElement>(null);\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n\n useImperativeHandle(ref, () => internalTextareaRef.current as HTMLTextAreaElement);\n\n // Auto-scroll input into view on mobile when focused\n useEffect(() => {\n const textarea = internalTextareaRef.current;\n if (!textarea) return;\n\n const handleFocus = () => {\n // Small delay to let the keyboard start appearing\n setTimeout(() => {\n textarea.scrollIntoView({ behavior: \"smooth\", block: \"nearest\" });\n }, 300);\n };\n\n textarea.addEventListener(\"focus\", handleFocus);\n return () => textarea.removeEventListener(\"focus\", handleFocus);\n }, []);\n\n useEffect(() => {\n if (autoFocus) {\n internalTextareaRef.current?.focus();\n }\n }, [autoFocus]);\n\n return (\n <textarea\n ref={internalTextareaRef}\n {...props}\n style={{\n overflow: \"auto\",\n resize: \"none\",\n ...style,\n }}\n placeholder={labels.chatInputPlaceholder}\n className={twMerge(\n \"bg-transparent outline-none antialiased font-regular leading-relaxed text-[16px] placeholder:text-[#00000077] dark:placeholder:text-[#fffc]\",\n className,\n )}\n rows={1}\n />\n );\n });\n\n export const AudioRecorder = CopilotChatAudioRecorder;\n}\n\nCopilotChatInput.TextArea.displayName = \"CopilotChatInput.TextArea\";\nCopilotChatInput.SendButton.displayName = \"CopilotChatInput.SendButton\";\nCopilotChatInput.ToolbarButton.displayName = \"CopilotChatInput.ToolbarButton\";\nCopilotChatInput.StartTranscribeButton.displayName = \"CopilotChatInput.StartTranscribeButton\";\nCopilotChatInput.CancelTranscribeButton.displayName = \"CopilotChatInput.CancelTranscribeButton\";\nCopilotChatInput.FinishTranscribeButton.displayName = \"CopilotChatInput.FinishTranscribeButton\";\nCopilotChatInput.AddMenuButton.displayName = \"CopilotChatInput.AddMenuButton\";\n\nexport default CopilotChatInput;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,MAAM,KAAK,SAAS,GAAG,OAAO,cAAc;AA2bb,SA0C7B,UA1C6B,KAkX5B,YAlX4B;AAhXxC,IAAM,+BAA+B;AACrC,IAAM,4BAA4B;AAE3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,MAAM;AAAA,MACrC;AAAA,IACF,GAAG,CAAC,SAAS,CAAC;AAEd,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACJ,GAAG;AAAA,QACJ,OAAO;AAAA,UACL,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,GAAG;AAAA,QACL;AAAA,QACA,aAAa,OAAO;AAAA,QACpB,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QACF;AAAA,QACA,MAAM;AAAA;AAAA,IACR;AAAA,EAEJ,CAAC;AAEM,EAAMD,kBAAA,gBAAgB;AAAA,GApOd;AAuOjB,iBAAiB,SAAS,cAAc;AACxC,iBAAiB,WAAW,cAAc;AAC1C,iBAAiB,cAAc,cAAc;AAC7C,iBAAiB,sBAAsB,cAAc;AACrD,iBAAiB,uBAAuB,cAAc;AACtD,iBAAiB,uBAAuB,cAAc;AACtD,iBAAiB,cAAc,cAAc;AAE7C,IAAO,2BAAQ;","names":["value","CopilotChatInput","TextArea"]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-KPRUSQ3K.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-MWC5OV7Z.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-N5EP5OD5.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,311 +0,0 @@
1
- import {
2
- CopilotChatInput_default
3
- } from "./chunk-KCVDFZJX.mjs";
4
- import {
5
- CopilotChatMessageView_default
6
- } from "./chunk-AI3Z3CHN.mjs";
7
- import {
8
- CopilotChatSuggestionView_default
9
- } from "./chunk-RGD2L3Z4.mjs";
10
- import {
11
- Button
12
- } from "./chunk-TAUOEJH2.mjs";
13
- import {
14
- renderSlot
15
- } from "./chunk-FIBK3DYE.mjs";
16
- import {
17
- cn
18
- } from "./chunk-XO4IRKSC.mjs";
19
- import {
20
- useKeyboardHeight
21
- } from "./chunk-FZR2XQKR.mjs";
22
- import {
23
- CopilotChatDefaultLabels,
24
- useCopilotChatConfiguration
25
- } from "./chunk-4XJK5IVQ.mjs";
26
-
27
- // src/components/chat/CopilotChatView.tsx
28
- import React, { useRef, useState, useEffect } from "react";
29
- import { twMerge } from "tailwind-merge";
30
- import { StickToBottom, useStickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
31
- import { ChevronDown } from "lucide-react";
32
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
33
- function CopilotChatView({
34
- messageView,
35
- input,
36
- scrollView,
37
- scrollToBottomButton,
38
- feather,
39
- inputContainer,
40
- disclaimer,
41
- suggestionView,
42
- messages = [],
43
- autoScroll = true,
44
- inputProps,
45
- isRunning = false,
46
- suggestions,
47
- suggestionLoadingIndexes,
48
- onSelectSuggestion,
49
- children,
50
- className,
51
- ...props
52
- }) {
53
- const inputContainerRef = useRef(null);
54
- const [inputContainerHeight, setInputContainerHeight] = useState(0);
55
- const [isResizing, setIsResizing] = useState(false);
56
- const resizeTimeoutRef = useRef(null);
57
- const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
58
- useEffect(() => {
59
- const element = inputContainerRef.current;
60
- if (!element) return;
61
- const resizeObserver = new ResizeObserver((entries) => {
62
- for (const entry of entries) {
63
- const newHeight = entry.contentRect.height;
64
- setInputContainerHeight((prevHeight) => {
65
- if (newHeight !== prevHeight) {
66
- setIsResizing(true);
67
- if (resizeTimeoutRef.current) {
68
- clearTimeout(resizeTimeoutRef.current);
69
- }
70
- resizeTimeoutRef.current = setTimeout(() => {
71
- setIsResizing(false);
72
- }, 250);
73
- return newHeight;
74
- }
75
- return prevHeight;
76
- });
77
- }
78
- });
79
- resizeObserver.observe(element);
80
- setInputContainerHeight(element.offsetHeight);
81
- return () => {
82
- resizeObserver.disconnect();
83
- if (resizeTimeoutRef.current) {
84
- clearTimeout(resizeTimeoutRef.current);
85
- }
86
- };
87
- }, []);
88
- const BoundMessageView = renderSlot(messageView, CopilotChatMessageView_default, {
89
- messages,
90
- isRunning
91
- });
92
- const BoundInput = renderSlot(input, CopilotChatInput_default, inputProps ?? {});
93
- const hasSuggestions = Array.isArray(suggestions) && suggestions.length > 0;
94
- const BoundSuggestionView = hasSuggestions ? renderSlot(
95
- suggestionView,
96
- CopilotChatSuggestionView_default,
97
- {
98
- suggestions,
99
- loadingIndexes: suggestionLoadingIndexes,
100
- onSelectSuggestion,
101
- className: "mb-3 lg:ml-4 lg:mr-4 ml-0 mr-0"
102
- }
103
- ) : null;
104
- const BoundFeather = renderSlot(feather, CopilotChatView.Feather, {});
105
- const BoundScrollView = renderSlot(scrollView, CopilotChatView.ScrollView, {
106
- autoScroll,
107
- scrollToBottomButton,
108
- inputContainerHeight,
109
- isResizing,
110
- children: /* @__PURE__ */ jsx("div", { style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }, children: /* @__PURE__ */ jsxs("div", { className: "max-w-3xl mx-auto", children: [
111
- BoundMessageView,
112
- hasSuggestions ? /* @__PURE__ */ jsx("div", { className: "pl-0 pr-4 sm:px-0 mt-4", children: BoundSuggestionView }) : null
113
- ] }) })
114
- });
115
- const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});
116
- const BoundDisclaimer = renderSlot(disclaimer, CopilotChatView.Disclaimer, {});
117
- const BoundInputContainer = renderSlot(inputContainer, CopilotChatView.InputContainer, {
118
- ref: inputContainerRef,
119
- keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,
120
- children: /* @__PURE__ */ jsxs(Fragment, { children: [
121
- /* @__PURE__ */ jsx("div", { className: "max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6 pointer-events-auto", children: BoundInput }),
122
- BoundDisclaimer
123
- ] })
124
- });
125
- if (children) {
126
- return children({
127
- messageView: BoundMessageView,
128
- input: BoundInput,
129
- scrollView: BoundScrollView,
130
- scrollToBottomButton: BoundScrollToBottomButton,
131
- feather: BoundFeather,
132
- inputContainer: BoundInputContainer,
133
- disclaimer: BoundDisclaimer,
134
- suggestionView: BoundSuggestionView ?? /* @__PURE__ */ jsx(Fragment, {})
135
- });
136
- }
137
- return /* @__PURE__ */ jsxs("div", { className: twMerge("relative h-full", className), ...props, children: [
138
- BoundScrollView,
139
- BoundFeather,
140
- BoundInputContainer
141
- ] });
142
- }
143
- ((CopilotChatView2) => {
144
- const ScrollContent = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {
145
- const { isAtBottom, scrollToBottom } = useStickToBottomContext();
146
- return /* @__PURE__ */ jsxs(Fragment, { children: [
147
- /* @__PURE__ */ jsx(StickToBottom.Content, { className: "overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) }),
148
- !isAtBottom && !isResizing && /* @__PURE__ */ jsx(
149
- "div",
150
- {
151
- className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
152
- style: {
153
- bottom: `${inputContainerHeight + 16}px`
154
- },
155
- children: renderSlot(scrollToBottomButton, CopilotChatView2.ScrollToBottomButton, {
156
- onClick: () => scrollToBottom()
157
- })
158
- }
159
- )
160
- ] });
161
- };
162
- CopilotChatView2.ScrollView = ({
163
- children,
164
- autoScroll = true,
165
- scrollToBottomButton,
166
- inputContainerHeight = 0,
167
- isResizing = false,
168
- className,
169
- ...props
170
- }) => {
171
- const [hasMounted, setHasMounted] = useState(false);
172
- const { scrollRef, contentRef, scrollToBottom } = useStickToBottom();
173
- const [showScrollButton, setShowScrollButton] = useState(false);
174
- useEffect(() => {
175
- setHasMounted(true);
176
- }, []);
177
- useEffect(() => {
178
- if (autoScroll) return;
179
- const scrollElement = scrollRef.current;
180
- if (!scrollElement) return;
181
- const checkScroll = () => {
182
- const atBottom = scrollElement.scrollHeight - scrollElement.scrollTop - scrollElement.clientHeight < 10;
183
- setShowScrollButton(!atBottom);
184
- };
185
- checkScroll();
186
- scrollElement.addEventListener("scroll", checkScroll);
187
- const resizeObserver = new ResizeObserver(checkScroll);
188
- resizeObserver.observe(scrollElement);
189
- return () => {
190
- scrollElement.removeEventListener("scroll", checkScroll);
191
- resizeObserver.disconnect();
192
- };
193
- }, [scrollRef, autoScroll]);
194
- if (!hasMounted) {
195
- return /* @__PURE__ */ jsx("div", { className: "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden", children: /* @__PURE__ */ jsx("div", { className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }) });
196
- }
197
- if (!autoScroll) {
198
- return /* @__PURE__ */ jsxs(
199
- "div",
200
- {
201
- ref: scrollRef,
202
- className: cn(
203
- "h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden relative",
204
- className
205
- ),
206
- ...props,
207
- children: [
208
- /* @__PURE__ */ jsx("div", { ref: contentRef, className: "px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6", children }),
209
- showScrollButton && !isResizing && /* @__PURE__ */ jsx(
210
- "div",
211
- {
212
- className: "absolute inset-x-0 flex justify-center z-10 pointer-events-none",
213
- style: {
214
- bottom: `${inputContainerHeight + 16}px`
215
- },
216
- children: renderSlot(scrollToBottomButton, CopilotChatView2.ScrollToBottomButton, {
217
- onClick: () => scrollToBottom()
218
- })
219
- }
220
- )
221
- ]
222
- }
223
- );
224
- }
225
- return /* @__PURE__ */ jsx(
226
- StickToBottom,
227
- {
228
- className: cn("h-full max-h-full flex flex-col min-h-0 relative", className),
229
- resize: "smooth",
230
- initial: "smooth",
231
- ...props,
232
- children: /* @__PURE__ */ jsx(
233
- ScrollContent,
234
- {
235
- scrollToBottomButton,
236
- inputContainerHeight,
237
- isResizing,
238
- children
239
- }
240
- )
241
- }
242
- );
243
- };
244
- CopilotChatView2.ScrollToBottomButton = ({
245
- className,
246
- ...props
247
- }) => /* @__PURE__ */ jsx(
248
- Button,
249
- {
250
- variant: "outline",
251
- size: "sm",
252
- className: twMerge(
253
- "rounded-full w-10 h-10 p-0 pointer-events-auto",
254
- "bg-white dark:bg-gray-900",
255
- "shadow-lg border border-gray-200 dark:border-gray-700",
256
- "hover:bg-gray-50 dark:hover:bg-gray-800",
257
- "flex items-center justify-center cursor-pointer",
258
- className
259
- ),
260
- ...props,
261
- children: /* @__PURE__ */ jsx(ChevronDown, { className: "w-4 h-4 text-gray-600 dark:text-white" })
262
- }
263
- );
264
- CopilotChatView2.Feather = ({ className, style, ...props }) => /* @__PURE__ */ jsx(
265
- "div",
266
- {
267
- className: cn(
268
- "absolute bottom-0 left-0 right-4 h-24 pointer-events-none z-10 bg-gradient-to-t",
269
- "from-white via-white to-transparent",
270
- "dark:from-[rgb(33,33,33)] dark:via-[rgb(33,33,33)]",
271
- className
272
- ),
273
- style,
274
- ...props
275
- }
276
- );
277
- CopilotChatView2.InputContainer = React.forwardRef(({ children, className, keyboardHeight = 0, ...props }, ref) => /* @__PURE__ */ jsx(
278
- "div",
279
- {
280
- ref,
281
- className: cn("absolute bottom-0 left-0 right-0 z-20 pointer-events-none", className),
282
- style: {
283
- // Adjust position when keyboard is open to keep input visible
284
- transform: keyboardHeight > 0 ? `translateY(-${keyboardHeight}px)` : void 0,
285
- transition: "transform 0.2s ease-out"
286
- },
287
- ...props,
288
- children
289
- }
290
- ));
291
- CopilotChatView2.InputContainer.displayName = "CopilotChatView.InputContainer";
292
- CopilotChatView2.Disclaimer = ({ className, ...props }) => {
293
- const config = useCopilotChatConfiguration();
294
- const labels = config?.labels ?? CopilotChatDefaultLabels;
295
- return /* @__PURE__ */ jsx(
296
- "div",
297
- {
298
- className: cn("text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto", className),
299
- ...props,
300
- children: labels.chatDisclaimerText
301
- }
302
- );
303
- };
304
- })(CopilotChatView || (CopilotChatView = {}));
305
- var CopilotChatView_default = CopilotChatView;
306
-
307
- export {
308
- CopilotChatView,
309
- CopilotChatView_default
310
- };
311
- //# sourceMappingURL=chunk-N5HC66HU.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/chat/CopilotChatView.tsx"],"sourcesContent":["import React, { useRef, useState, useEffect } from \"react\";\nimport { WithSlots, renderSlot } from \"@/lib/slots\";\nimport CopilotChatMessageView from \"./CopilotChatMessageView\";\nimport CopilotChatInput, { CopilotChatInputProps } from \"./CopilotChatInput\";\nimport CopilotChatSuggestionView, { CopilotChatSuggestionViewProps } from \"./CopilotChatSuggestionView\";\nimport { Suggestion } from \"@copilotkitnext/core\";\nimport { Message } from \"@ag-ui/core\";\nimport { twMerge } from \"tailwind-merge\";\nimport { StickToBottom, useStickToBottom, useStickToBottomContext } from \"use-stick-to-bottom\";\nimport { ChevronDown } from \"lucide-react\";\nimport { Button } from \"@/components/ui/button\";\nimport { cn } from \"@/lib/utils\";\nimport { useCopilotChatConfiguration, CopilotChatDefaultLabels } from \"@/providers/CopilotChatConfigurationProvider\";\nimport { useKeyboardHeight } from \"@/hooks/use-keyboard-height\";\n\nexport type CopilotChatViewProps = WithSlots<\n {\n messageView: typeof CopilotChatMessageView;\n scrollView: React.FC<React.HTMLAttributes<HTMLDivElement>>;\n scrollToBottomButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;\n input: typeof CopilotChatInput;\n inputContainer: React.FC<React.HTMLAttributes<HTMLDivElement> & { children: React.ReactNode }>;\n feather: React.FC<React.HTMLAttributes<HTMLDivElement>>;\n disclaimer: React.FC<React.HTMLAttributes<HTMLDivElement>>;\n suggestionView: typeof CopilotChatSuggestionView;\n },\n {\n messages?: Message[];\n autoScroll?: boolean;\n inputProps?: Partial<Omit<CopilotChatInputProps, \"children\">>;\n isRunning?: boolean;\n suggestions?: Suggestion[];\n suggestionLoadingIndexes?: ReadonlyArray<number>;\n onSelectSuggestion?: (suggestion: Suggestion, index: number) => void;\n } & React.HTMLAttributes<HTMLDivElement>\n>;\n\nexport function CopilotChatView({\n messageView,\n input,\n scrollView,\n scrollToBottomButton,\n feather,\n inputContainer,\n disclaimer,\n suggestionView,\n messages = [],\n autoScroll = true,\n inputProps,\n isRunning = false,\n suggestions,\n suggestionLoadingIndexes,\n onSelectSuggestion,\n children,\n className,\n ...props\n}: CopilotChatViewProps) {\n const inputContainerRef = useRef<HTMLDivElement>(null);\n const [inputContainerHeight, setInputContainerHeight] = useState(0);\n const [isResizing, setIsResizing] = useState(false);\n const resizeTimeoutRef = useRef<NodeJS.Timeout | null>(null);\n\n // Track keyboard state for mobile\n const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();\n\n // Track input container height changes\n useEffect(() => {\n const element = inputContainerRef.current;\n if (!element) return;\n\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const newHeight = entry.contentRect.height;\n\n // Update height and set resizing state\n setInputContainerHeight((prevHeight) => {\n if (newHeight !== prevHeight) {\n setIsResizing(true);\n\n // Clear existing timeout\n if (resizeTimeoutRef.current) {\n clearTimeout(resizeTimeoutRef.current);\n }\n\n // Set isResizing to false after a short delay\n resizeTimeoutRef.current = setTimeout(() => {\n setIsResizing(false);\n }, 250);\n\n return newHeight;\n }\n return prevHeight;\n });\n }\n });\n\n resizeObserver.observe(element);\n\n // Set initial height\n setInputContainerHeight(element.offsetHeight);\n\n return () => {\n resizeObserver.disconnect();\n if (resizeTimeoutRef.current) {\n clearTimeout(resizeTimeoutRef.current);\n }\n };\n }, []);\n\n const BoundMessageView = renderSlot(messageView, CopilotChatMessageView, {\n messages,\n isRunning,\n });\n\n const BoundInput = renderSlot(input, CopilotChatInput, (inputProps ?? {}) as CopilotChatInputProps);\n const hasSuggestions = Array.isArray(suggestions) && suggestions.length > 0;\n const BoundSuggestionView = hasSuggestions\n ? renderSlot<typeof CopilotChatSuggestionView, CopilotChatSuggestionViewProps>(\n suggestionView,\n CopilotChatSuggestionView,\n {\n suggestions,\n loadingIndexes: suggestionLoadingIndexes,\n onSelectSuggestion,\n className: \"mb-3 lg:ml-4 lg:mr-4 ml-0 mr-0\",\n },\n )\n : null;\n const BoundFeather = renderSlot(feather, CopilotChatView.Feather, {});\n const BoundScrollView = renderSlot(scrollView, CopilotChatView.ScrollView, {\n autoScroll,\n scrollToBottomButton,\n inputContainerHeight,\n isResizing,\n children: (\n <div style={{ paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` }}>\n <div className=\"max-w-3xl mx-auto\">\n {BoundMessageView}\n {hasSuggestions ? <div className=\"pl-0 pr-4 sm:px-0 mt-4\">{BoundSuggestionView}</div> : null}\n </div>\n </div>\n ),\n });\n\n const BoundScrollToBottomButton = renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {});\n\n const BoundDisclaimer = renderSlot(disclaimer, CopilotChatView.Disclaimer, {});\n\n const BoundInputContainer = renderSlot(inputContainer, CopilotChatView.InputContainer, {\n ref: inputContainerRef,\n keyboardHeight: isKeyboardOpen ? keyboardHeight : 0,\n children: (\n <>\n <div className=\"max-w-3xl mx-auto py-0 px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6 pointer-events-auto\">\n {BoundInput}\n </div>\n {BoundDisclaimer}\n </>\n ),\n });\n\n if (children) {\n return children({\n messageView: BoundMessageView,\n input: BoundInput,\n scrollView: BoundScrollView,\n scrollToBottomButton: BoundScrollToBottomButton,\n feather: BoundFeather,\n inputContainer: BoundInputContainer,\n disclaimer: BoundDisclaimer,\n suggestionView: BoundSuggestionView ?? <></>,\n });\n }\n\n return (\n <div className={twMerge(\"relative h-full\", className)} {...props}>\n {BoundScrollView}\n\n {BoundFeather}\n\n {BoundInputContainer}\n </div>\n );\n}\n\nexport namespace CopilotChatView {\n // Inner component that has access to StickToBottom context\n const ScrollContent: React.FC<{\n children: React.ReactNode;\n scrollToBottomButton?: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;\n inputContainerHeight: number;\n isResizing: boolean;\n }> = ({ children, scrollToBottomButton, inputContainerHeight, isResizing }) => {\n const { isAtBottom, scrollToBottom } = useStickToBottomContext();\n\n return (\n <>\n <StickToBottom.Content className=\"overflow-y-scroll overflow-x-hidden\">\n <div className=\"px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6\">{children}</div>\n </StickToBottom.Content>\n\n {/* Scroll to bottom button - hidden during resize */}\n {!isAtBottom && !isResizing && (\n <div\n className=\"absolute inset-x-0 flex justify-center z-10 pointer-events-none\"\n style={{\n bottom: `${inputContainerHeight + 16}px`,\n }}\n >\n {renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {\n onClick: () => scrollToBottom(),\n })}\n </div>\n )}\n </>\n );\n };\n\n export const ScrollView: React.FC<\n React.HTMLAttributes<HTMLDivElement> & {\n autoScroll?: boolean;\n scrollToBottomButton?: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;\n inputContainerHeight?: number;\n isResizing?: boolean;\n }\n > = ({\n children,\n autoScroll = true,\n scrollToBottomButton,\n inputContainerHeight = 0,\n isResizing = false,\n className,\n ...props\n }) => {\n const [hasMounted, setHasMounted] = useState(false);\n const { scrollRef, contentRef, scrollToBottom } = useStickToBottom();\n const [showScrollButton, setShowScrollButton] = useState(false);\n\n useEffect(() => {\n setHasMounted(true);\n }, []);\n\n // Monitor scroll position for non-autoscroll mode\n useEffect(() => {\n if (autoScroll) return; // Skip for autoscroll mode\n\n const scrollElement = scrollRef.current;\n if (!scrollElement) return;\n\n const checkScroll = () => {\n const atBottom = scrollElement.scrollHeight - scrollElement.scrollTop - scrollElement.clientHeight < 10;\n setShowScrollButton(!atBottom);\n };\n\n checkScroll();\n scrollElement.addEventListener(\"scroll\", checkScroll);\n\n // Also check on resize\n const resizeObserver = new ResizeObserver(checkScroll);\n resizeObserver.observe(scrollElement);\n\n return () => {\n scrollElement.removeEventListener(\"scroll\", checkScroll);\n resizeObserver.disconnect();\n };\n }, [scrollRef, autoScroll]);\n\n if (!hasMounted) {\n return (\n <div className=\"h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden\">\n <div className=\"px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6\">{children}</div>\n </div>\n );\n }\n\n // When autoScroll is false, we don't use StickToBottom\n if (!autoScroll) {\n return (\n <div\n ref={scrollRef}\n className={cn(\n \"h-full max-h-full flex flex-col min-h-0 overflow-y-scroll overflow-x-hidden relative\",\n className,\n )}\n {...props}\n >\n <div ref={contentRef} className=\"px-4 sm:px-0 [div[data-sidebar-chat]_&]:px-8 [div[data-popup-chat]_&]:px-6\">\n {children}\n </div>\n\n {/* Scroll to bottom button for manual mode */}\n {showScrollButton && !isResizing && (\n <div\n className=\"absolute inset-x-0 flex justify-center z-10 pointer-events-none\"\n style={{\n bottom: `${inputContainerHeight + 16}px`,\n }}\n >\n {renderSlot(scrollToBottomButton, CopilotChatView.ScrollToBottomButton, {\n onClick: () => scrollToBottom(),\n })}\n </div>\n )}\n </div>\n );\n }\n\n return (\n <StickToBottom\n className={cn(\"h-full max-h-full flex flex-col min-h-0 relative\", className)}\n resize=\"smooth\"\n initial=\"smooth\"\n {...props}\n >\n <ScrollContent\n scrollToBottomButton={scrollToBottomButton}\n inputContainerHeight={inputContainerHeight}\n isResizing={isResizing}\n >\n {children}\n </ScrollContent>\n </StickToBottom>\n );\n };\n\n export const ScrollToBottomButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>> = ({\n className,\n ...props\n }) => (\n <Button\n variant=\"outline\"\n size=\"sm\"\n className={twMerge(\n \"rounded-full w-10 h-10 p-0 pointer-events-auto\",\n \"bg-white dark:bg-gray-900\",\n \"shadow-lg border border-gray-200 dark:border-gray-700\",\n \"hover:bg-gray-50 dark:hover:bg-gray-800\",\n \"flex items-center justify-center cursor-pointer\",\n className,\n )}\n {...props}\n >\n <ChevronDown className=\"w-4 h-4 text-gray-600 dark:text-white\" />\n </Button>\n );\n\n export const Feather: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({ className, style, ...props }) => (\n <div\n className={cn(\n \"absolute bottom-0 left-0 right-4 h-24 pointer-events-none z-10 bg-gradient-to-t\",\n \"from-white via-white to-transparent\",\n \"dark:from-[rgb(33,33,33)] dark:via-[rgb(33,33,33)]\",\n className,\n )}\n style={style}\n {...props}\n />\n );\n\n export const InputContainer = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement> & { children: React.ReactNode; keyboardHeight?: number }\n >(({ children, className, keyboardHeight = 0, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\"absolute bottom-0 left-0 right-0 z-20 pointer-events-none\", className)}\n style={{\n // Adjust position when keyboard is open to keep input visible\n transform: keyboardHeight > 0 ? `translateY(-${keyboardHeight}px)` : undefined,\n transition: \"transform 0.2s ease-out\",\n }}\n {...props}\n >\n {children}\n </div>\n ));\n\n InputContainer.displayName = \"CopilotChatView.InputContainer\";\n\n export const Disclaimer: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({ className, ...props }) => {\n const config = useCopilotChatConfiguration();\n const labels = config?.labels ?? CopilotChatDefaultLabels;\n\n return (\n <div\n className={cn(\"text-center text-xs text-muted-foreground py-3 px-4 max-w-3xl mx-auto\", className)}\n {...props}\n >\n {labels.chatDisclaimerText}\n </div>\n );\n };\n}\n\nexport default CopilotChatView;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,SAAS,QAAQ,UAAU,iBAAiB;AAOnD,SAAS,eAAe;AACxB,SAAS,eAAe,kBAAkB,+BAA+B;AACzE,SAAS,mBAAmB;AA+HpB,SAgBF,UAdsB,KAFpB;AAnGD,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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EACjE;AAGK,EAAMA,iBAAA,UAA0D,CAAC,EAAE,WAAW,OAAO,GAAG,MAAM,MACnG;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAGK,EAAMA,iBAAA,iBAAiB,MAAM,WAGlC,CAAC,EAAE,UAAU,WAAW,iBAAiB,GAAG,GAAG,MAAM,GAAG,QACxD;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,WAAW,GAAG,6DAA6D,SAAS;AAAA,MACpF,OAAO;AAAA;AAAA,QAEL,WAAW,iBAAiB,IAAI,eAAe,cAAc,QAAQ;AAAA,QACrE,YAAY;AAAA,MACd;AAAA,MACC,GAAG;AAAA,MAEH;AAAA;AAAA,EACH,CACD;AAED,EAAAA,iBAAA,eAAe,cAAc;AAEtB,EAAMA,iBAAA,aAA6D,CAAC,EAAE,WAAW,GAAG,MAAM,MAAM;AACrG,UAAM,SAAS,4BAA4B;AAC3C,UAAM,SAAS,QAAQ,UAAU;AAEjC,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,GAAG,yEAAyE,SAAS;AAAA,QAC/F,GAAG;AAAA,QAEH,iBAAO;AAAA;AAAA,IACV;AAAA,EAEJ;AAAA,GA9Me;AAiNjB,IAAO,0BAAQ;","names":["CopilotChatView"]}
@@ -1,131 +0,0 @@
1
- import {
2
- useCopilotChatConfiguration
3
- } from "./chunk-4XJK5IVQ.mjs";
4
- import {
5
- useCopilotKit
6
- } from "./chunk-RF2CGPHQ.mjs";
7
-
8
- // src/hooks/use-configure-suggestions.tsx
9
- import { useCallback, useEffect, useMemo, useRef } from "react";
10
- import { DEFAULT_AGENT_ID } from "@copilotkitnext/shared";
11
- var EMPTY_DEPS = [];
12
- function useConfigureSuggestions(config, options) {
13
- const { copilotkit } = useCopilotKit();
14
- const chatConfig = useCopilotChatConfiguration();
15
- const extraDeps = options?.deps ?? EMPTY_DEPS;
16
- const resolvedConsumerAgentId = useMemo(() => chatConfig?.agentId ?? DEFAULT_AGENT_ID, [chatConfig?.agentId]);
17
- const rawConsumerAgentId = useMemo(() => config ? config.consumerAgentId : void 0, [config]);
18
- const normalizationCacheRef = useRef({
19
- serialized: null,
20
- config: null
21
- });
22
- const { normalizedConfig, serializedConfig } = useMemo(() => {
23
- if (!config) {
24
- normalizationCacheRef.current = { serialized: null, config: null };
25
- return { normalizedConfig: null, serializedConfig: null };
26
- }
27
- if (config.available === "disabled") {
28
- normalizationCacheRef.current = { serialized: null, config: null };
29
- return { normalizedConfig: null, serializedConfig: null };
30
- }
31
- let built;
32
- if (isDynamicConfig(config)) {
33
- built = {
34
- ...config
35
- };
36
- } else {
37
- const normalizedSuggestions = normalizeStaticSuggestions(config.suggestions);
38
- const baseConfig = {
39
- ...config,
40
- suggestions: normalizedSuggestions
41
- };
42
- built = baseConfig;
43
- }
44
- const serialized = JSON.stringify(built);
45
- const cache = normalizationCacheRef.current;
46
- if (cache.serialized === serialized && cache.config) {
47
- return { normalizedConfig: cache.config, serializedConfig: serialized };
48
- }
49
- normalizationCacheRef.current = { serialized, config: built };
50
- return { normalizedConfig: built, serializedConfig: serialized };
51
- }, [config, resolvedConsumerAgentId, ...extraDeps]);
52
- const latestConfigRef = useRef(null);
53
- latestConfigRef.current = normalizedConfig;
54
- const previousSerializedConfigRef = useRef(null);
55
- const targetAgentId = useMemo(() => {
56
- if (!normalizedConfig) {
57
- return resolvedConsumerAgentId;
58
- }
59
- const consumer = normalizedConfig.consumerAgentId;
60
- if (!consumer || consumer === "*") {
61
- return resolvedConsumerAgentId;
62
- }
63
- return consumer;
64
- }, [normalizedConfig, resolvedConsumerAgentId]);
65
- const isGlobalConfig = rawConsumerAgentId === void 0 || rawConsumerAgentId === "*";
66
- const requestReload = useCallback(() => {
67
- if (!normalizedConfig) {
68
- return;
69
- }
70
- if (isGlobalConfig) {
71
- const agents = Object.values(copilotkit.agents ?? {});
72
- for (const entry of agents) {
73
- const agentId = entry.agentId;
74
- if (!agentId) {
75
- continue;
76
- }
77
- if (!entry.isRunning) {
78
- copilotkit.reloadSuggestions(agentId);
79
- }
80
- }
81
- return;
82
- }
83
- if (!targetAgentId) {
84
- return;
85
- }
86
- copilotkit.reloadSuggestions(targetAgentId);
87
- }, [copilotkit, isGlobalConfig, normalizedConfig, targetAgentId]);
88
- useEffect(() => {
89
- if (!serializedConfig || !latestConfigRef.current) {
90
- return;
91
- }
92
- const id = copilotkit.addSuggestionsConfig(latestConfigRef.current);
93
- requestReload();
94
- return () => {
95
- copilotkit.removeSuggestionsConfig(id);
96
- };
97
- }, [copilotkit, serializedConfig, requestReload]);
98
- useEffect(() => {
99
- if (!normalizedConfig) {
100
- previousSerializedConfigRef.current = null;
101
- return;
102
- }
103
- if (serializedConfig && previousSerializedConfigRef.current === serializedConfig) {
104
- return;
105
- }
106
- if (serializedConfig) {
107
- previousSerializedConfigRef.current = serializedConfig;
108
- }
109
- requestReload();
110
- }, [normalizedConfig, requestReload, serializedConfig]);
111
- useEffect(() => {
112
- if (!normalizedConfig || extraDeps.length === 0) {
113
- return;
114
- }
115
- requestReload();
116
- }, [extraDeps.length, normalizedConfig, requestReload, ...extraDeps]);
117
- }
118
- function isDynamicConfig(config) {
119
- return "instructions" in config;
120
- }
121
- function normalizeStaticSuggestions(suggestions) {
122
- return suggestions.map((suggestion) => ({
123
- ...suggestion,
124
- isLoading: suggestion.isLoading ?? false
125
- }));
126
- }
127
-
128
- export {
129
- useConfigureSuggestions
130
- };
131
- //# sourceMappingURL=chunk-NB2GZAKG.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/use-configure-suggestions.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { useCopilotKit } from \"@/providers/CopilotKitProvider\";\nimport { useCopilotChatConfiguration } from \"@/providers/CopilotChatConfigurationProvider\";\nimport { DEFAULT_AGENT_ID } from \"@copilotkitnext/shared\";\nimport {\n DynamicSuggestionsConfig,\n StaticSuggestionsConfig,\n SuggestionsConfig,\n Suggestion,\n} from \"@copilotkitnext/core\";\n\ntype StaticSuggestionInput = Omit<Suggestion, \"isLoading\"> & Partial<Pick<Suggestion, \"isLoading\">>;\n\ntype StaticSuggestionsConfigInput = Omit<StaticSuggestionsConfig, \"suggestions\"> & {\n suggestions: StaticSuggestionInput[];\n};\n\ntype SuggestionsConfigInput = DynamicSuggestionsConfig | StaticSuggestionsConfigInput;\n\nconst EMPTY_DEPS: ReadonlyArray<unknown> = [];\n\nexport interface UseConfigureSuggestionsOptions {\n deps?: ReadonlyArray<unknown>;\n}\n\nexport function useConfigureSuggestions(\n config: SuggestionsConfigInput | null | undefined,\n options?: UseConfigureSuggestionsOptions,\n): void {\n const { copilotkit } = useCopilotKit();\n const chatConfig = useCopilotChatConfiguration();\n const extraDeps = options?.deps ?? EMPTY_DEPS;\n\n const resolvedConsumerAgentId = useMemo(() => chatConfig?.agentId ?? DEFAULT_AGENT_ID, [chatConfig?.agentId]);\n\n const rawConsumerAgentId = useMemo(() => (config ? (config as SuggestionsConfigInput).consumerAgentId : undefined), [config]);\n\n const normalizationCacheRef = useRef<{ serialized: string | null; config: SuggestionsConfig | null }>({\n serialized: null,\n config: null,\n });\n\n const { normalizedConfig, serializedConfig } = useMemo(() => {\n if (!config) {\n normalizationCacheRef.current = { serialized: null, config: null };\n return { normalizedConfig: null, serializedConfig: null };\n }\n\n if (config.available === \"disabled\") {\n normalizationCacheRef.current = { serialized: null, config: null };\n return { normalizedConfig: null, serializedConfig: null };\n }\n\n let built: SuggestionsConfig;\n if (isDynamicConfig(config)) {\n built = {\n ...config,\n } satisfies DynamicSuggestionsConfig;\n } else {\n const normalizedSuggestions = normalizeStaticSuggestions(config.suggestions);\n const baseConfig: StaticSuggestionsConfig = {\n ...config,\n suggestions: normalizedSuggestions,\n };\n built = baseConfig;\n }\n\n const serialized = JSON.stringify(built);\n const cache = normalizationCacheRef.current;\n if (cache.serialized === serialized && cache.config) {\n return { normalizedConfig: cache.config, serializedConfig: serialized };\n }\n\n normalizationCacheRef.current = { serialized, config: built };\n return { normalizedConfig: built, serializedConfig: serialized };\n }, [config, resolvedConsumerAgentId, ...extraDeps]);\n const latestConfigRef = useRef<SuggestionsConfig | null>(null);\n latestConfigRef.current = normalizedConfig;\n const previousSerializedConfigRef = useRef<string | null>(null);\n\n const targetAgentId = useMemo(() => {\n if (!normalizedConfig) {\n return resolvedConsumerAgentId;\n }\n const consumer = (normalizedConfig as StaticSuggestionsConfig | DynamicSuggestionsConfig).consumerAgentId;\n if (!consumer || consumer === \"*\") {\n return resolvedConsumerAgentId;\n }\n return consumer;\n }, [normalizedConfig, resolvedConsumerAgentId]);\n\n const isGlobalConfig = rawConsumerAgentId === undefined || rawConsumerAgentId === \"*\";\n\n const requestReload = useCallback(() => {\n if (!normalizedConfig) {\n return;\n }\n\n if (isGlobalConfig) {\n const agents = Object.values(copilotkit.agents ?? {});\n for (const entry of agents) {\n const agentId = entry.agentId;\n if (!agentId) {\n continue;\n }\n if (!entry.isRunning) {\n copilotkit.reloadSuggestions(agentId);\n }\n }\n return;\n }\n\n if (!targetAgentId) {\n return;\n }\n\n copilotkit.reloadSuggestions(targetAgentId);\n }, [copilotkit, isGlobalConfig, normalizedConfig, targetAgentId]);\n\n useEffect(() => {\n if (!serializedConfig || !latestConfigRef.current) {\n return;\n }\n\n const id = copilotkit.addSuggestionsConfig(latestConfigRef.current);\n\n requestReload();\n\n return () => {\n copilotkit.removeSuggestionsConfig(id);\n };\n }, [copilotkit, serializedConfig, requestReload]);\n\n useEffect(() => {\n if (!normalizedConfig) {\n previousSerializedConfigRef.current = null;\n return;\n }\n if (serializedConfig && previousSerializedConfigRef.current === serializedConfig) {\n return;\n }\n if (serializedConfig) {\n previousSerializedConfigRef.current = serializedConfig;\n }\n requestReload();\n }, [normalizedConfig, requestReload, serializedConfig]);\n\n useEffect(() => {\n if (!normalizedConfig || extraDeps.length === 0) {\n return;\n }\n requestReload();\n }, [extraDeps.length, normalizedConfig, requestReload, ...extraDeps]);\n\n}\n\nfunction isDynamicConfig(config: SuggestionsConfigInput): config is DynamicSuggestionsConfig {\n return \"instructions\" in config;\n}\n\nfunction normalizeStaticSuggestions(suggestions: StaticSuggestionInput[]): Suggestion[] {\n return suggestions.map((suggestion) => ({\n ...suggestion,\n isLoading: suggestion.isLoading ?? false,\n }));\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,aAAa,WAAW,SAAS,cAAc;AAGxD,SAAS,wBAAwB;AAgBjC,IAAM,aAAqC,CAAC;AAMrC,SAAS,wBACd,QACA,SACM;AACN,QAAM,EAAE,WAAW,IAAI,cAAc;AACrC,QAAM,aAAa,4BAA4B;AAC/C,QAAM,YAAY,SAAS,QAAQ;AAEnC,QAAM,0BAA0B,QAAQ,MAAM,YAAY,WAAW,kBAAkB,CAAC,YAAY,OAAO,CAAC;AAE5G,QAAM,qBAAqB,QAAQ,MAAO,SAAU,OAAkC,kBAAkB,QAAY,CAAC,MAAM,CAAC;AAE5H,QAAM,wBAAwB,OAAwE;AAAA,IACpG,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV,CAAC;AAED,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,QAAQ,MAAM;AAC3D,QAAI,CAAC,QAAQ;AACX,4BAAsB,UAAU,EAAE,YAAY,MAAM,QAAQ,KAAK;AACjE,aAAO,EAAE,kBAAkB,MAAM,kBAAkB,KAAK;AAAA,IAC1D;AAEA,QAAI,OAAO,cAAc,YAAY;AACnC,4BAAsB,UAAU,EAAE,YAAY,MAAM,QAAQ,KAAK;AACjE,aAAO,EAAE,kBAAkB,MAAM,kBAAkB,KAAK;AAAA,IAC1D;AAEA,QAAI;AACJ,QAAI,gBAAgB,MAAM,GAAG;AAC3B,cAAQ;AAAA,QACN,GAAG;AAAA,MACL;AAAA,IACF,OAAO;AACL,YAAM,wBAAwB,2BAA2B,OAAO,WAAW;AAC3E,YAAM,aAAsC;AAAA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