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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +18 -12
  3. package/dist/{chunk-O72ZB5V3.mjs → chunk-2QEDCM6H.mjs} +22 -12
  4. package/dist/chunk-2QEDCM6H.mjs.map +1 -0
  5. package/dist/{chunk-54JAUBUJ.mjs → chunk-6SMTHXVA.mjs} +4 -2
  6. package/dist/chunk-6SMTHXVA.mjs.map +1 -0
  7. package/dist/{chunk-IEMQ2SQW.mjs → chunk-6TLDRWAD.mjs} +5 -3
  8. package/dist/{chunk-IEMQ2SQW.mjs.map → chunk-6TLDRWAD.mjs.map} +1 -1
  9. package/dist/{chunk-UFN2VWSR.mjs → chunk-72FQQMQ2.mjs} +2 -2
  10. package/dist/chunk-72FQQMQ2.mjs.map +1 -0
  11. package/dist/{chunk-ELGRNEAO.mjs → chunk-AOUHT4JR.mjs} +4 -2
  12. package/dist/chunk-AOUHT4JR.mjs.map +1 -0
  13. package/dist/{chunk-C3GSYRC3.mjs → chunk-BNJX66OH.mjs} +2 -2
  14. package/dist/{chunk-NRA3CFEE.mjs → chunk-C27LZFA5.mjs} +2 -2
  15. package/dist/{chunk-FFJHOZX6.mjs → chunk-C7WM7GM3.mjs} +44 -11
  16. package/dist/chunk-C7WM7GM3.mjs.map +1 -0
  17. package/dist/{chunk-6TWQUA2Q.mjs → chunk-CNIC5HO5.mjs} +8 -3
  18. package/dist/chunk-CNIC5HO5.mjs.map +1 -0
  19. package/dist/chunk-CQCXH5LY.mjs +143 -0
  20. package/dist/chunk-CQCXH5LY.mjs.map +1 -0
  21. package/dist/{chunk-RYUCX3ZK.mjs → chunk-DM2V5WTG.mjs} +4 -2
  22. package/dist/chunk-DM2V5WTG.mjs.map +1 -0
  23. package/dist/{chunk-JZ3RFQQ6.mjs → chunk-DSHTRV2R.mjs} +16 -4
  24. package/dist/chunk-DSHTRV2R.mjs.map +1 -0
  25. package/dist/{chunk-GDSZGYCE.mjs → chunk-EACIYBQH.mjs} +3 -3
  26. package/dist/{chunk-XWG3L6QC.mjs → chunk-GBAPANZE.mjs} +76 -11
  27. package/dist/chunk-GBAPANZE.mjs.map +1 -0
  28. package/dist/{chunk-Q5V6S67N.mjs → chunk-GFE5ZSPV.mjs} +15 -6
  29. package/dist/chunk-GFE5ZSPV.mjs.map +1 -0
  30. package/dist/{chunk-VHKHX7GV.mjs → chunk-HHLX4MQN.mjs} +2 -2
  31. package/dist/{chunk-WNX755OE.mjs → chunk-ICA2EXIX.mjs} +7 -4
  32. package/dist/chunk-ICA2EXIX.mjs.map +1 -0
  33. package/dist/{chunk-QIOJXTIQ.mjs → chunk-IWOCQACI.mjs} +12 -3
  34. package/dist/chunk-IWOCQACI.mjs.map +1 -0
  35. package/dist/{chunk-BH6PCAAL.mjs → chunk-JYHRHKV5.mjs} +12 -3
  36. package/dist/chunk-JYHRHKV5.mjs.map +1 -0
  37. package/dist/{chunk-IK2BPURM.mjs → chunk-LIXN3OVQ.mjs} +12 -7
  38. package/dist/chunk-LIXN3OVQ.mjs.map +1 -0
  39. package/dist/{chunk-PD36EMOZ.mjs → chunk-MC6PY7XH.mjs} +75 -54
  40. package/dist/chunk-MC6PY7XH.mjs.map +1 -0
  41. package/dist/{chunk-LYYDXL2G.mjs → chunk-OQWEOBRX.mjs} +3 -3
  42. package/dist/chunk-OQWEOBRX.mjs.map +1 -0
  43. package/dist/{chunk-LBR23XXF.mjs → chunk-P34CL4LC.mjs} +4 -4
  44. package/dist/{chunk-F2CDEOFX.mjs → chunk-PF3QBO7V.mjs} +2 -2
  45. package/dist/chunk-PF3QBO7V.mjs.map +1 -0
  46. package/dist/{chunk-7CMZ7YPQ.mjs → chunk-PP2A5RP6.mjs} +2 -2
  47. package/dist/{chunk-7CMZ7YPQ.mjs.map → chunk-PP2A5RP6.mjs.map} +1 -1
  48. package/dist/{chunk-RKQM2AE5.mjs → chunk-Q64GLWPQ.mjs} +2 -2
  49. package/dist/{chunk-RKQM2AE5.mjs.map → chunk-Q64GLWPQ.mjs.map} +1 -1
  50. package/dist/{chunk-OHGUQZJT.mjs → chunk-T4NNQG6T.mjs} +50 -41
  51. package/dist/chunk-T4NNQG6T.mjs.map +1 -0
  52. package/dist/{chunk-DBKRAOH7.mjs → chunk-TGM5PKBF.mjs} +16 -6
  53. package/dist/chunk-TGM5PKBF.mjs.map +1 -0
  54. package/dist/{chunk-JY2CSDKN.mjs → chunk-YDJ4YUUF.mjs} +22 -16
  55. package/dist/chunk-YDJ4YUUF.mjs.map +1 -0
  56. package/dist/components/chat/Button.js +3 -1
  57. package/dist/components/chat/Button.js.map +1 -1
  58. package/dist/components/chat/Button.mjs +3 -3
  59. package/dist/components/chat/Chat.js +285 -132
  60. package/dist/components/chat/Chat.js.map +1 -1
  61. package/dist/components/chat/Chat.mjs +18 -18
  62. package/dist/components/chat/ChatContext.js +63 -9
  63. package/dist/components/chat/ChatContext.js.map +1 -1
  64. package/dist/components/chat/ChatContext.mjs +2 -2
  65. package/dist/components/chat/CodeBlock.js +20 -6
  66. package/dist/components/chat/CodeBlock.js.map +1 -1
  67. package/dist/components/chat/CodeBlock.mjs +3 -3
  68. package/dist/components/chat/Header.js +88 -28
  69. package/dist/components/chat/Header.js.map +1 -1
  70. package/dist/components/chat/Header.mjs +8 -8
  71. package/dist/components/chat/Icons.js +75 -10
  72. package/dist/components/chat/Icons.js.map +1 -1
  73. package/dist/components/chat/Icons.mjs +1 -1
  74. package/dist/components/chat/Input.js +90 -62
  75. package/dist/components/chat/Input.js.map +1 -1
  76. package/dist/components/chat/Input.mjs +6 -6
  77. package/dist/components/chat/Markdown.js +34 -8
  78. package/dist/components/chat/Markdown.js.map +1 -1
  79. package/dist/components/chat/Markdown.mjs +4 -4
  80. package/dist/components/chat/Messages.js +59 -16
  81. package/dist/components/chat/Messages.js.map +1 -1
  82. package/dist/components/chat/Messages.mjs +11 -11
  83. package/dist/components/chat/Modal.js +403 -189
  84. package/dist/components/chat/Modal.js.map +1 -1
  85. package/dist/components/chat/Modal.mjs +27 -27
  86. package/dist/components/chat/Popup.js +403 -189
  87. package/dist/components/chat/Popup.js.map +1 -1
  88. package/dist/components/chat/Popup.mjs +28 -28
  89. package/dist/components/chat/PoweredByTag.d.ts +1 -1
  90. package/dist/components/chat/PoweredByTag.js +3 -1
  91. package/dist/components/chat/PoweredByTag.js.map +1 -1
  92. package/dist/components/chat/PoweredByTag.mjs +1 -1
  93. package/dist/components/chat/Sidebar.js +403 -189
  94. package/dist/components/chat/Sidebar.js.map +1 -1
  95. package/dist/components/chat/Sidebar.mjs +28 -28
  96. package/dist/components/chat/Suggestion.d.ts +1 -1
  97. package/dist/components/chat/Suggestion.js +13 -2
  98. package/dist/components/chat/Suggestion.js.map +1 -1
  99. package/dist/components/chat/Suggestion.mjs +2 -2
  100. package/dist/components/chat/Suggestions.js +13 -2
  101. package/dist/components/chat/Suggestions.js.map +1 -1
  102. package/dist/components/chat/Suggestions.mjs +3 -3
  103. package/dist/components/chat/Textarea.js +4 -1
  104. package/dist/components/chat/Textarea.js.map +1 -1
  105. package/dist/components/chat/Textarea.mjs +1 -1
  106. package/dist/components/chat/Window.js +3 -1
  107. package/dist/components/chat/Window.js.map +1 -1
  108. package/dist/components/chat/Window.mjs +3 -3
  109. package/dist/components/chat/index.js +403 -189
  110. package/dist/components/chat/index.js.map +1 -1
  111. package/dist/components/chat/index.mjs +29 -29
  112. package/dist/components/chat/messages/AssistantMessage.js +37 -9
  113. package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
  114. package/dist/components/chat/messages/AssistantMessage.mjs +6 -6
  115. package/dist/components/chat/messages/ErrorMessage.js +65 -31
  116. package/dist/components/chat/messages/ErrorMessage.js.map +1 -1
  117. package/dist/components/chat/messages/ErrorMessage.mjs +33 -27
  118. package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -1
  119. package/dist/components/chat/messages/ImageRenderer.js +15 -5
  120. package/dist/components/chat/messages/ImageRenderer.js.map +1 -1
  121. package/dist/components/chat/messages/ImageRenderer.mjs +1 -1
  122. package/dist/components/chat/messages/LegacyRenderMessage.js +55 -15
  123. package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
  124. package/dist/components/chat/messages/LegacyRenderMessage.mjs +10 -10
  125. package/dist/components/chat/messages/RenderMessage.js +55 -15
  126. package/dist/components/chat/messages/RenderMessage.js.map +1 -1
  127. package/dist/components/chat/messages/RenderMessage.mjs +9 -9
  128. package/dist/components/chat/messages/UserMessage.js +3 -1
  129. package/dist/components/chat/messages/UserMessage.js.map +1 -1
  130. package/dist/components/chat/messages/UserMessage.mjs +1 -1
  131. package/dist/components/chat/props.js.map +1 -1
  132. package/dist/components/dev-console/console.js +85 -27
  133. package/dist/components/dev-console/console.js.map +1 -1
  134. package/dist/components/dev-console/console.mjs +6 -6
  135. package/dist/components/dev-console/icons.js +14 -5
  136. package/dist/components/dev-console/icons.js.map +1 -1
  137. package/dist/components/dev-console/icons.mjs +1 -1
  138. package/dist/components/dev-console/index.js +85 -27
  139. package/dist/components/dev-console/index.js.map +1 -1
  140. package/dist/components/dev-console/index.mjs +6 -6
  141. package/dist/components/dev-console/utils.js +21 -15
  142. package/dist/components/dev-console/utils.js.map +1 -1
  143. package/dist/components/dev-console/utils.mjs +1 -1
  144. package/dist/components/help-modal/icons.d.ts +1 -1
  145. package/dist/components/help-modal/icons.js +11 -2
  146. package/dist/components/help-modal/icons.js.map +1 -1
  147. package/dist/components/help-modal/icons.mjs +1 -1
  148. package/dist/components/help-modal/index.js +8 -1
  149. package/dist/components/help-modal/index.js.map +1 -1
  150. package/dist/components/help-modal/index.mjs +2 -2
  151. package/dist/components/help-modal/modal.js +8 -1
  152. package/dist/components/help-modal/modal.js.map +1 -1
  153. package/dist/components/help-modal/modal.mjs +2 -2
  154. package/dist/components/index.js +403 -189
  155. package/dist/components/index.js.map +1 -1
  156. package/dist/components/index.mjs +29 -29
  157. package/dist/hooks/use-copy-to-clipboard.d.ts +1 -1
  158. package/dist/hooks/use-copy-to-clipboard.js +3 -1
  159. package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
  160. package/dist/hooks/use-copy-to-clipboard.mjs +1 -1
  161. package/dist/hooks/use-push-to-talk.js +17 -10
  162. package/dist/hooks/use-push-to-talk.js.map +1 -1
  163. package/dist/hooks/use-push-to-talk.mjs +1 -1
  164. package/dist/index.js +403 -189
  165. package/dist/index.js.map +1 -1
  166. package/dist/index.mjs +34 -34
  167. package/dist/index.umd.js.map +1 -1
  168. package/dist/lib/utils.js.map +1 -1
  169. package/dist/lib/utils.mjs.map +1 -1
  170. package/package.json +4 -5
  171. package/src/components/chat/Button.tsx +6 -2
  172. package/src/components/chat/Chat.tsx +75 -48
  173. package/src/components/chat/ChatContext.tsx +6 -2
  174. package/src/components/chat/CodeBlock.tsx +11 -6
  175. package/src/components/chat/Icons.tsx +45 -10
  176. package/src/components/chat/Input.tsx +30 -7
  177. package/src/components/chat/Markdown.tsx +12 -3
  178. package/src/components/chat/Messages.tsx +24 -8
  179. package/src/components/chat/Modal.tsx +12 -2
  180. package/src/components/chat/Popup.tsx +3 -1
  181. package/src/components/chat/PoweredByTag.tsx +5 -1
  182. package/src/components/chat/Sidebar.tsx +3 -1
  183. package/src/components/chat/Suggestion.tsx +6 -1
  184. package/src/components/chat/Textarea.tsx +15 -3
  185. package/src/components/chat/messages/AssistantMessage.tsx +12 -4
  186. package/src/components/chat/messages/ErrorMessage.tsx +3 -1
  187. package/src/components/chat/messages/ImageRenderer.tsx +17 -5
  188. package/src/components/chat/messages/LegacyRenderMessage.tsx +4 -1
  189. package/src/components/chat/messages/UserMessage.tsx +12 -4
  190. package/src/components/chat/props.ts +13 -3
  191. package/src/components/dev-console/console.tsx +35 -9
  192. package/src/components/dev-console/icons.tsx +6 -1
  193. package/src/components/dev-console/utils.ts +23 -15
  194. package/src/components/help-modal/icons.tsx +10 -2
  195. package/src/hooks/use-copy-to-clipboard.tsx +3 -1
  196. package/src/hooks/use-push-to-talk.tsx +45 -18
  197. package/src/lib/utils.ts +4 -1
  198. package/tsconfig.json +1 -1
  199. package/tsup.config.ts +5 -1
  200. package/dist/chunk-3W6J75HS.mjs +0 -126
  201. package/dist/chunk-3W6J75HS.mjs.map +0 -1
  202. package/dist/chunk-54JAUBUJ.mjs.map +0 -1
  203. package/dist/chunk-6TWQUA2Q.mjs.map +0 -1
  204. package/dist/chunk-BH6PCAAL.mjs.map +0 -1
  205. package/dist/chunk-DBKRAOH7.mjs.map +0 -1
  206. package/dist/chunk-ELGRNEAO.mjs.map +0 -1
  207. package/dist/chunk-F2CDEOFX.mjs.map +0 -1
  208. package/dist/chunk-FFJHOZX6.mjs.map +0 -1
  209. package/dist/chunk-IK2BPURM.mjs.map +0 -1
  210. package/dist/chunk-JY2CSDKN.mjs.map +0 -1
  211. package/dist/chunk-JZ3RFQQ6.mjs.map +0 -1
  212. package/dist/chunk-LYYDXL2G.mjs.map +0 -1
  213. package/dist/chunk-O72ZB5V3.mjs.map +0 -1
  214. package/dist/chunk-OHGUQZJT.mjs.map +0 -1
  215. package/dist/chunk-PD36EMOZ.mjs.map +0 -1
  216. package/dist/chunk-Q5V6S67N.mjs.map +0 -1
  217. package/dist/chunk-QIOJXTIQ.mjs.map +0 -1
  218. package/dist/chunk-RYUCX3ZK.mjs.map +0 -1
  219. package/dist/chunk-UFN2VWSR.mjs.map +0 -1
  220. package/dist/chunk-WNX755OE.mjs.map +0 -1
  221. package/dist/chunk-XWG3L6QC.mjs.map +0 -1
  222. /package/dist/{chunk-C3GSYRC3.mjs.map → chunk-BNJX66OH.mjs.map} +0 -0
  223. /package/dist/{chunk-NRA3CFEE.mjs.map → chunk-C27LZFA5.mjs.map} +0 -0
  224. /package/dist/{chunk-GDSZGYCE.mjs.map → chunk-EACIYBQH.mjs.map} +0 -0
  225. /package/dist/{chunk-VHKHX7GV.mjs.map → chunk-HHLX4MQN.mjs.map} +0 -0
  226. /package/dist/{chunk-LBR23XXF.mjs.map → chunk-P34CL4LC.mjs.map} +0 -0
@@ -130,7 +130,14 @@ var CloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
130
130
  stroke: "currentColor",
131
131
  width: "24",
132
132
  height: "24",
133
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" })
133
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
134
+ "path",
135
+ {
136
+ strokeLinecap: "round",
137
+ strokeLinejoin: "round",
138
+ d: "M19.5 8.25l-7.5 7.5-7.5-7.5"
139
+ }
140
+ )
134
141
  }
135
142
  );
136
143
  var HeaderCloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -143,7 +150,14 @@ var HeaderCloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
143
150
  stroke: "currentColor",
144
151
  width: "24",
145
152
  height: "24",
146
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
153
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
154
+ "path",
155
+ {
156
+ strokeLinecap: "round",
157
+ strokeLinejoin: "round",
158
+ d: "M6 18L18 6M6 6l12 12"
159
+ }
160
+ )
147
161
  }
148
162
  );
149
163
  var SendIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -156,7 +170,14 @@ var SendIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
156
170
  stroke: "currentColor",
157
171
  width: "24",
158
172
  height: "24",
159
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 19V5m0 0l-7 7m7-7l7 7" })
173
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
174
+ "path",
175
+ {
176
+ strokeLinecap: "round",
177
+ strokeLinejoin: "round",
178
+ d: "M12 19V5m0 0l-7 7m7-7l7 7"
179
+ }
180
+ )
160
181
  }
161
182
  );
162
183
  var MicrophoneIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -241,12 +262,42 @@ var CopyIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
241
262
  )
242
263
  }
243
264
  );
244
- var SmallSpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitSpinner", style: { width: "13px", height: "13px" } });
245
- var SpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitSpinner", style: { width: "24px", height: "24px" } });
265
+ var SmallSpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
266
+ "span",
267
+ {
268
+ className: "copilotKitSpinner",
269
+ style: { width: "13px", height: "13px" }
270
+ }
271
+ );
272
+ var SpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
273
+ "span",
274
+ {
275
+ className: "copilotKitSpinner",
276
+ style: { width: "24px", height: "24px" }
277
+ }
278
+ );
246
279
  var ActivityIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
247
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitActivityDot", style: { animationDelay: "0s" } }),
248
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitActivityDot", style: { animationDelay: "0.2s" } }),
249
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitActivityDot", style: { animationDelay: "0.4s" } })
280
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
281
+ "span",
282
+ {
283
+ className: "copilotKitActivityDot",
284
+ style: { animationDelay: "0s" }
285
+ }
286
+ ),
287
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
288
+ "span",
289
+ {
290
+ className: "copilotKitActivityDot",
291
+ style: { animationDelay: "0.2s" }
292
+ }
293
+ ),
294
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
295
+ "span",
296
+ {
297
+ className: "copilotKitActivityDot",
298
+ style: { animationDelay: "0.4s" }
299
+ }
300
+ )
250
301
  ] });
251
302
  var ThumbsUpIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
252
303
  "svg",
@@ -321,7 +372,14 @@ var UploadIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
321
372
  stroke: "currentColor",
322
373
  width: "24",
323
374
  height: "24",
324
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 4.5v15m7.5-7.5h-15" })
375
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
376
+ "path",
377
+ {
378
+ strokeLinecap: "round",
379
+ strokeLinejoin: "round",
380
+ d: "M12 4.5v15m7.5-7.5h-15"
381
+ }
382
+ )
325
383
  }
326
384
  );
327
385
  var CheckIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -335,13 +393,22 @@ var CheckIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
335
393
  width: "16",
336
394
  height: "16",
337
395
  style: { minWidth: "16px", minHeight: "16px" },
338
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 12.75l6 6 9-13.5" })
396
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
397
+ "path",
398
+ {
399
+ strokeLinecap: "round",
400
+ strokeLinejoin: "round",
401
+ d: "M4.5 12.75l6 6 9-13.5"
402
+ }
403
+ )
339
404
  }
340
405
  );
341
406
 
342
407
  // src/components/chat/ChatContext.tsx
343
408
  var import_jsx_runtime2 = require("react/jsx-runtime");
344
- var ChatContext = import_react.default.createContext(void 0);
409
+ var ChatContext = import_react.default.createContext(
410
+ void 0
411
+ );
345
412
  function useChatContext() {
346
413
  const context = import_react.default.useContext(ChatContext);
347
414
  if (context === void 0) {
@@ -549,24 +616,30 @@ function getPublishedCopilotKitVersion(current, forceCheck = false) {
549
616
  return parsedVersion;
550
617
  }
551
618
  } catch (error) {
552
- console.error("Failed to parse CopilotKitVersion from localStorage", error);
619
+ console.error(
620
+ "Failed to parse CopilotKitVersion from localStorage",
621
+ error
622
+ );
553
623
  }
554
624
  }
555
625
  try {
556
- const response = yield fetch("https://api.cloud.copilotkit.ai/check-for-updates", {
557
- method: "POST",
558
- headers: {
559
- "Content-Type": "application/json"
560
- },
561
- body: JSON.stringify({
562
- packages: [
563
- {
564
- packageName: "@copilotkit/shared",
565
- packageVersion: current
566
- }
567
- ]
568
- })
569
- });
626
+ const response = yield fetch(
627
+ "https://api.cloud.copilotkit.ai/check-for-updates",
628
+ {
629
+ method: "POST",
630
+ headers: {
631
+ "Content-Type": "application/json"
632
+ },
633
+ body: JSON.stringify({
634
+ packages: [
635
+ {
636
+ packageName: "@copilotkit/shared",
637
+ packageVersion: current
638
+ }
639
+ ]
640
+ })
641
+ }
642
+ );
570
643
  const data = yield response.json();
571
644
  const version = {
572
645
  current,
@@ -720,13 +793,22 @@ var CheckIcon2 = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
720
793
  viewBox: "0 0 14 14",
721
794
  version: "1.1",
722
795
  xmlns: "http://www.w3.org/2000/svg",
723
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Group-2", transform: "translate(-118, 0)", fill: "#1BC030", fillRule: "nonzero", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Group", transform: "translate(118, 0)", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
724
- "path",
796
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
797
+ "g",
725
798
  {
726
- d: "M0,7 C0,3.13384615 3.13384615,0 7,0 C10.8661538,0 14,3.13384615 14,7 C14,10.8661538 10.8661538,14 7,14 C3.13384615,14 0,10.8661538 0,7 Z M9.59179487,5.69764103 C9.70905818,5.54139023 9.73249341,5.33388318 9.65303227,5.15541491 C9.57357113,4.97694665 9.40367989,4.85551619 9.20909814,4.83811118 C9.01451638,4.82070616 8.82577109,4.91005717 8.71589744,5.07158974 L6.39261538,8.32389744 L5.22666667,7.15794872 C5.01450582,6.96025518 4.68389046,6.9660885 4.47883563,7.17114332 C4.27378081,7.37619815 4.26794748,7.70681351 4.46564103,7.91897436 L6.08102564,9.53435897 C6.19289944,9.64614839 6.3482622,9.70310251 6.50588106,9.69010587 C6.66349993,9.67710922 6.80743532,9.59547613 6.89948718,9.46687179 L9.59179487,5.69764103 L9.59179487,5.69764103 Z",
727
- id: "Shape"
799
+ id: "Group-2",
800
+ transform: "translate(-118, 0)",
801
+ fill: "#1BC030",
802
+ fillRule: "nonzero",
803
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Group", transform: "translate(118, 0)", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
804
+ "path",
805
+ {
806
+ d: "M0,7 C0,3.13384615 3.13384615,0 7,0 C10.8661538,0 14,3.13384615 14,7 C14,10.8661538 10.8661538,14 7,14 C3.13384615,14 0,10.8661538 0,7 Z M9.59179487,5.69764103 C9.70905818,5.54139023 9.73249341,5.33388318 9.65303227,5.15541491 C9.57357113,4.97694665 9.40367989,4.85551619 9.20909814,4.83811118 C9.01451638,4.82070616 8.82577109,4.91005717 8.71589744,5.07158974 L6.39261538,8.32389744 L5.22666667,7.15794872 C5.01450582,6.96025518 4.68389046,6.9660885 4.47883563,7.17114332 C4.27378081,7.37619815 4.26794748,7.70681351 4.46564103,7.91897436 L6.08102564,9.53435897 C6.19289944,9.64614839 6.3482622,9.70310251 6.50588106,9.69010587 C6.66349993,9.67710922 6.80743532,9.59547613 6.89948718,9.46687179 L9.59179487,5.69764103 L9.59179487,5.69764103 Z",
807
+ id: "Shape"
808
+ }
809
+ ) })
728
810
  }
729
- ) }) }) })
811
+ ) })
730
812
  }
731
813
  );
732
814
 
@@ -749,7 +831,14 @@ var CloseIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
749
831
  stroke: "currentColor",
750
832
  width: "20",
751
833
  height: "20",
752
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
834
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
835
+ "path",
836
+ {
837
+ strokeLinecap: "round",
838
+ strokeLinejoin: "round",
839
+ d: "M6 18L18 6M6 6l12 12"
840
+ }
841
+ )
753
842
  }
754
843
  );
755
844
 
@@ -854,7 +943,9 @@ function CopilotDevConsole() {
854
943
  const [versionStatus, setVersionStatus] = (0, import_react4.useState)("unknown");
855
944
  const [latestVersion, setLatestVersion] = (0, import_react4.useState)("");
856
945
  const consoleRef = (0, import_react4.useRef)(null);
857
- const [debugButtonMode, setDebugButtonMode] = (0, import_react4.useState)("full");
946
+ const [debugButtonMode, setDebugButtonMode] = (0, import_react4.useState)(
947
+ "full"
948
+ );
858
949
  const checkForUpdates = (force = false) => {
859
950
  setVersionStatus("checking");
860
951
  getPublishedCopilotKitVersion(currentVersion, force).then((v) => {
@@ -995,8 +1086,22 @@ function DebugMenuButton({
995
1086
  className: "copilotKitDebugMenu",
996
1087
  style: { zIndex: 40 },
997
1088
  children: [
998
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logReadables(context), children: "Log Readables" }) }),
999
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logActions(context), children: "Log Actions" }) }),
1089
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1090
+ "button",
1091
+ {
1092
+ className: "copilotKitDebugMenuItem",
1093
+ onClick: () => logReadables(context),
1094
+ children: "Log Readables"
1095
+ }
1096
+ ) }),
1097
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1098
+ "button",
1099
+ {
1100
+ className: "copilotKitDebugMenuItem",
1101
+ onClick: () => logActions(context),
1102
+ children: "Log Actions"
1103
+ }
1104
+ ) }),
1000
1105
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1001
1106
  "button",
1002
1107
  {
@@ -1005,9 +1110,23 @@ function DebugMenuButton({
1005
1110
  children: "Log Messages"
1006
1111
  }
1007
1112
  ) }),
1008
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => checkForUpdates(true), children: "Check for Updates" }) }),
1113
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1114
+ "button",
1115
+ {
1116
+ className: "copilotKitDebugMenuItem",
1117
+ onClick: () => checkForUpdates(true),
1118
+ children: "Check for Updates"
1119
+ }
1120
+ ) }),
1009
1121
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("hr", {}),
1010
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => setShowDevConsole(false), children: "Hide Dev Console" }) })
1122
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1123
+ "button",
1124
+ {
1125
+ className: "copilotKitDebugMenuItem",
1126
+ onClick: () => setShowDevConsole(false),
1127
+ children: "Hide Dev Console"
1128
+ }
1129
+ ) })
1011
1130
  ]
1012
1131
  }
1013
1132
  )
@@ -1053,7 +1172,9 @@ var getTextContent = (content) => {
1053
1172
  return part.text;
1054
1173
  }
1055
1174
  return void 0;
1056
- }).filter((value) => typeof value === "string" && value.length > 0).join(" ").trim() || void 0;
1175
+ }).filter(
1176
+ (value) => typeof value === "string" && value.length > 0
1177
+ ).join(" ").trim() || void 0;
1057
1178
  };
1058
1179
  var UserMessage = (props) => {
1059
1180
  const { message, ImageRenderer: ImageRenderer2 } = props;
@@ -1077,7 +1198,9 @@ var import_react_syntax_highlighter = require("react-syntax-highlighter");
1077
1198
 
1078
1199
  // src/hooks/use-copy-to-clipboard.tsx
1079
1200
  var React5 = __toESM(require("react"));
1080
- function useCopyToClipboard({ timeout = 2e3 }) {
1201
+ function useCopyToClipboard({
1202
+ timeout = 2e3
1203
+ }) {
1081
1204
  const [isCopied, setIsCopied] = React5.useState(false);
1082
1205
  const copyToClipboard = (value) => {
1083
1206
  var _a;
@@ -1135,9 +1258,7 @@ var generateRandomString = (length, lowercase = false) => {
1135
1258
  };
1136
1259
  var CodeBlock = (0, import_react6.memo)(({ language, value }) => {
1137
1260
  const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
1138
- const [SyntaxHighlighter, setSyntaxHighlighter] = (0, import_react6.useState)(
1139
- () => import_react_syntax_highlighter.Light
1140
- );
1261
+ const [SyntaxHighlighter, setSyntaxHighlighter] = (0, import_react6.useState)(() => import_react_syntax_highlighter.Light);
1141
1262
  (0, import_react6.useEffect)(() => {
1142
1263
  try {
1143
1264
  new RegExp("(?<=#)\\w+");
@@ -1176,7 +1297,14 @@ var CodeBlock = (0, import_react6.memo)(({ language, value }) => {
1176
1297
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
1177
1298
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
1178
1299
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
1179
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: DownloadIcon }),
1300
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1301
+ "button",
1302
+ {
1303
+ className: "copilotKitCodeBlockToolbarButton",
1304
+ onClick: downloadAsFile,
1305
+ children: DownloadIcon
1306
+ }
1307
+ ),
1180
1308
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: isCopied ? CheckIcon : CopyIcon })
1181
1309
  ] })
1182
1310
  ] }),
@@ -1488,7 +1616,16 @@ var import_jsx_runtime12 = require("react/jsx-runtime");
1488
1616
  var defaultComponents = {
1489
1617
  a(_a) {
1490
1618
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
1491
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("a", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { target: "_blank", rel: "noopener noreferrer", children }));
1619
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1620
+ "a",
1621
+ __spreadProps(__spreadValues({
1622
+ className: "copilotKitMarkdownElement"
1623
+ }, props), {
1624
+ target: "_blank",
1625
+ rel: "noopener noreferrer",
1626
+ children
1627
+ })
1628
+ );
1492
1629
  },
1493
1630
  // @ts-expect-error -- inline
1494
1631
  code(_c) {
@@ -1586,7 +1723,10 @@ var Markdown = ({ content, components }) => {
1586
1723
  MemoizedReactMarkdown,
1587
1724
  {
1588
1725
  components: __spreadValues(__spreadValues({}, defaultComponents), components),
1589
- remarkPlugins: [import_remark_gfm.default, [import_remark_math.default, { singleDollarTextMath: false }]],
1726
+ remarkPlugins: [
1727
+ import_remark_gfm.default,
1728
+ [import_remark_math.default, { singleDollarTextMath: false }]
1729
+ ],
1590
1730
  rehypePlugins: [import_rehype_raw.default],
1591
1731
  children: content
1592
1732
  }
@@ -1705,7 +1845,11 @@ var AssistantMessage = (props) => {
1705
1845
  // src/components/chat/messages/ImageRenderer.tsx
1706
1846
  var import_react9 = require("react");
1707
1847
  var import_jsx_runtime14 = require("react/jsx-runtime");
1708
- var ImageRenderer = ({ image, content, className = "" }) => {
1848
+ var ImageRenderer = ({
1849
+ image,
1850
+ content,
1851
+ className = ""
1852
+ }) => {
1709
1853
  const [imageError, setImageError] = (0, import_react9.useState)(false);
1710
1854
  const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
1711
1855
  const altText = content || "User uploaded image";
@@ -1713,10 +1857,16 @@ var ImageRenderer = ({ image, content, className = "" }) => {
1713
1857
  setImageError(true);
1714
1858
  };
1715
1859
  if (imageError) {
1716
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `copilotKitImageRendering copilotKitImageRenderingError ${className}`, children: [
1717
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "copilotKitImageRenderingErrorMessage", children: "Failed to load image" }),
1718
- content && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "copilotKitImageRenderingContent", children: content })
1719
- ] });
1860
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1861
+ "div",
1862
+ {
1863
+ className: `copilotKitImageRendering copilotKitImageRenderingError ${className}`,
1864
+ children: [
1865
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "copilotKitImageRenderingErrorMessage", children: "Failed to load image" }),
1866
+ content && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "copilotKitImageRenderingContent", children: content })
1867
+ ]
1868
+ }
1869
+ );
1720
1870
  }
1721
1871
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `copilotKitImageRendering ${className}`, children: [
1722
1872
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
@@ -1949,7 +2099,10 @@ var Messages = ({
1949
2099
  var _a;
1950
2100
  const { labels, icons } = useChatContext();
1951
2101
  const { messages: visibleMessages, interrupt } = (0, import_react_core5.useCopilotChatInternal)();
1952
- const initialMessages = (0, import_react10.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
2102
+ const initialMessages = (0, import_react10.useMemo)(
2103
+ () => makeInitialMessages(labels.initial),
2104
+ [labels.initial]
2105
+ );
1953
2106
  const messages = [...initialMessages, ...visibleMessages];
1954
2107
  const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
1955
2108
  const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
@@ -2107,7 +2260,10 @@ var AutoResizingTextarea = (0, import_react11.forwardRef)(
2107
2260
  }, ref) => {
2108
2261
  const internalTextareaRef = (0, import_react11.useRef)(null);
2109
2262
  const [maxHeight, setMaxHeight] = (0, import_react11.useState)(0);
2110
- (0, import_react11.useImperativeHandle)(ref, () => internalTextareaRef.current);
2263
+ (0, import_react11.useImperativeHandle)(
2264
+ ref,
2265
+ () => internalTextareaRef.current
2266
+ );
2111
2267
  (0, import_react11.useEffect)(() => {
2112
2268
  const calculateMaxHeight = () => {
2113
2269
  const textarea = internalTextareaRef.current;
@@ -2157,7 +2313,9 @@ var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
2157
2313
  var import_react12 = require("react");
2158
2314
  var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
2159
2315
  if (!mediaStreamRef.current || !audioContextRef.current) {
2160
- mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
2316
+ mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({
2317
+ audio: true
2318
+ });
2161
2319
  audioContextRef.current = new window.AudioContext();
2162
2320
  yield audioContextRef.current.resume();
2163
2321
  }
@@ -2226,14 +2384,15 @@ var usePushToTalk = ({
2226
2384
  } else {
2227
2385
  stopRecording(mediaRecorderRef);
2228
2386
  if (pushToTalkState === "transcribing") {
2229
- transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl).then(
2230
- (transcription) => __async(void 0, null, function* () {
2231
- recordedChunks.current = [];
2232
- setPushToTalkState("idle");
2233
- const message = yield sendFunction(transcription);
2234
- setStartReadingFromMessageId(message.id);
2235
- })
2236
- );
2387
+ transcribeAudio(
2388
+ recordedChunks.current,
2389
+ context.copilotApiConfig.transcribeAudioUrl
2390
+ ).then((transcription) => __async(void 0, null, function* () {
2391
+ recordedChunks.current = [];
2392
+ setPushToTalkState("idle");
2393
+ const message = yield sendFunction(transcription);
2394
+ setStartReadingFromMessageId(message.id);
2395
+ }));
2237
2396
  }
2238
2397
  }
2239
2398
  return () => {
@@ -2248,7 +2407,11 @@ var usePushToTalk = ({
2248
2407
  const aguiMessages = (0, import_runtime_client_gql2.gqlToAGUI)(context.messages);
2249
2408
  const messagesAfterLast = aguiMessages.slice(lastMessageIndex + 1).filter((message) => message.role === "assistant");
2250
2409
  const text = messagesAfterLast.map((message) => message.content).join("\n");
2251
- playAudioResponse(text, context.copilotApiConfig.textToSpeechUrl, audioContextRef.current);
2410
+ playAudioResponse(
2411
+ text,
2412
+ context.copilotApiConfig.textToSpeechUrl,
2413
+ audioContextRef.current
2414
+ );
2252
2415
  setStartReadingFromMessageId(null);
2253
2416
  }
2254
2417
  }, [startReadingFromMessageId, inProgress]);
@@ -2270,7 +2433,9 @@ var useDarkMode = () => {
2270
2433
 
2271
2434
  // src/components/chat/PoweredByTag.tsx
2272
2435
  var import_jsx_runtime19 = require("react/jsx-runtime");
2273
- function PoweredByTag({ showPoweredBy = true }) {
2436
+ function PoweredByTag({
2437
+ showPoweredBy = true
2438
+ }) {
2274
2439
  const [mounted, setMounted] = (0, import_react13.useState)(false);
2275
2440
  const isDark = useDarkMode();
2276
2441
  (0, import_react13.useEffect)(() => {
@@ -2336,7 +2501,13 @@ var Input = ({
2336
2501
  if (!chatReady)
2337
2502
  return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
2338
2503
  return isInProgress && !hideStopButton && chatReady ? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" } : { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
2339
- }, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
2504
+ }, [
2505
+ isInProgress,
2506
+ chatReady,
2507
+ hideStopButton,
2508
+ context.icons.stopIcon,
2509
+ context.icons.sendIcon
2510
+ ]);
2340
2511
  const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
2341
2512
  const { interrupt } = (0, import_react_core7.useCopilotChatInternal)();
2342
2513
  const canSend = (0, import_react14.useMemo)(() => {
@@ -2346,56 +2517,64 @@ var Input = ({
2346
2517
  return isInProgress && !hideStopButton;
2347
2518
  }, [isInProgress, hideStopButton]);
2348
2519
  const sendDisabled = !canSend && !canStop;
2349
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `copilotKitInputContainer ${showPoweredBy ? "poweredByContainer" : ""}`, children: [
2350
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
2351
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2352
- Textarea_default,
2353
- {
2354
- ref: textareaRef,
2355
- placeholder: context.labels.placeholder,
2356
- autoFocus: false,
2357
- maxRows: MAX_NEWLINES,
2358
- value: text,
2359
- onChange: (event) => setText(event.target.value),
2360
- onCompositionStart: () => setIsComposing(true),
2361
- onCompositionEnd: () => setIsComposing(false),
2362
- onKeyDown: (event) => {
2363
- if (event.key === "Enter" && !event.shiftKey && !isComposing) {
2364
- event.preventDefault();
2365
- if (canSend) {
2366
- send();
2520
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2521
+ "div",
2522
+ {
2523
+ className: `copilotKitInputContainer ${showPoweredBy ? "poweredByContainer" : ""}`,
2524
+ children: [
2525
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
2526
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2527
+ Textarea_default,
2528
+ {
2529
+ ref: textareaRef,
2530
+ placeholder: context.labels.placeholder,
2531
+ autoFocus: false,
2532
+ maxRows: MAX_NEWLINES,
2533
+ value: text,
2534
+ onChange: (event) => setText(event.target.value),
2535
+ onCompositionStart: () => setIsComposing(true),
2536
+ onCompositionEnd: () => setIsComposing(false),
2537
+ onKeyDown: (event) => {
2538
+ if (event.key === "Enter" && !event.shiftKey && !isComposing) {
2539
+ event.preventDefault();
2540
+ if (canSend) {
2541
+ send();
2542
+ }
2543
+ }
2367
2544
  }
2368
2545
  }
2369
- }
2370
- }
2371
- ),
2372
- /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "copilotKitInputControls", children: [
2373
- onUpload && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { onClick: onUpload, className: "copilotKitInputControlButton", children: context.icons.uploadIcon }),
2374
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: { flexGrow: 1 } }),
2375
- showPushToTalk && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2376
- "button",
2377
- {
2378
- onClick: () => setPushToTalkState(pushToTalkState === "idle" ? "recording" : "transcribing"),
2379
- className: pushToTalkState === "recording" ? "copilotKitInputControlButton copilotKitPushToTalkRecording" : "copilotKitInputControlButton",
2380
- children: context.icons.pushToTalkIcon
2381
- }
2382
- ),
2383
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2384
- "button",
2385
- {
2386
- disabled: sendDisabled,
2387
- onClick: isInProgress && !hideStopButton ? onStop : send,
2388
- "data-copilotkit-in-progress": inProgress,
2389
- "data-test-id": inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready",
2390
- className: "copilotKitInputControlButton",
2391
- "aria-label": buttonAlt,
2392
- children: buttonIcon
2393
- }
2394
- )
2395
- ] })
2396
- ] }),
2397
- /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(PoweredByTag, { showPoweredBy })
2398
- ] });
2546
+ ),
2547
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "copilotKitInputControls", children: [
2548
+ onUpload && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { onClick: onUpload, className: "copilotKitInputControlButton", children: context.icons.uploadIcon }),
2549
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: { flexGrow: 1 } }),
2550
+ showPushToTalk && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2551
+ "button",
2552
+ {
2553
+ onClick: () => setPushToTalkState(
2554
+ pushToTalkState === "idle" ? "recording" : "transcribing"
2555
+ ),
2556
+ className: pushToTalkState === "recording" ? "copilotKitInputControlButton copilotKitPushToTalkRecording" : "copilotKitInputControlButton",
2557
+ children: context.icons.pushToTalkIcon
2558
+ }
2559
+ ),
2560
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2561
+ "button",
2562
+ {
2563
+ disabled: sendDisabled,
2564
+ onClick: isInProgress && !hideStopButton ? onStop : send,
2565
+ "data-copilotkit-in-progress": inProgress,
2566
+ "data-test-id": inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready",
2567
+ className: "copilotKitInputControlButton",
2568
+ "aria-label": buttonAlt,
2569
+ children: buttonIcon
2570
+ }
2571
+ )
2572
+ ] })
2573
+ ] }),
2574
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(PoweredByTag, { showPoweredBy })
2575
+ ]
2576
+ }
2577
+ );
2399
2578
  };
2400
2579
 
2401
2580
  // src/components/chat/Chat.tsx
@@ -2484,7 +2663,12 @@ var ImageUploadQueue = ({
2484
2663
  // src/components/chat/Suggestion.tsx
2485
2664
  var import_react_core8 = require("@copilotkit/react-core");
2486
2665
  var import_jsx_runtime22 = require("react/jsx-runtime");
2487
- function Suggestion({ title, onClick, partial, className }) {
2666
+ function Suggestion({
2667
+ title,
2668
+ onClick,
2669
+ partial,
2670
+ className
2671
+ }) {
2488
2672
  const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
2489
2673
  if (!title)
2490
2674
  return null;
@@ -2578,9 +2762,7 @@ function CopilotChat({
2578
2762
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2579
2763
  const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
2580
2764
  const [chatError, setChatError] = (0, import_react15.useState)(null);
2581
- const [messageFeedback, setMessageFeedback] = (0, import_react15.useState)(
2582
- {}
2583
- );
2765
+ const [messageFeedback, setMessageFeedback] = (0, import_react15.useState)({});
2584
2766
  const fileInputRef = (0, import_react15.useRef)(null);
2585
2767
  const triggerObservabilityHook = (0, import_react15.useCallback)(
2586
2768
  (hookName, ...args) => {
@@ -2673,30 +2855,34 @@ function CopilotChat({
2673
2855
  if (imageItems.length === 0)
2674
2856
  return;
2675
2857
  e.preventDefault();
2676
- const imagePromises = imageItems.map((item) => {
2677
- const file = item.getAsFile();
2678
- if (!file)
2679
- return Promise.resolve(null);
2680
- return new Promise((resolve, reject) => {
2681
- const reader = new FileReader();
2682
- reader.onload = (e2) => {
2683
- var _a2, _b2;
2684
- const base64String = (_b2 = (_a2 = e2.target) == null ? void 0 : _a2.result) == null ? void 0 : _b2.split(",")[1];
2685
- if (base64String) {
2686
- resolve({
2687
- contentType: file.type,
2688
- bytes: base64String
2689
- });
2690
- } else {
2691
- resolve(null);
2692
- }
2693
- };
2694
- reader.onerror = reject;
2695
- reader.readAsDataURL(file);
2696
- });
2697
- });
2858
+ const imagePromises = imageItems.map(
2859
+ (item) => {
2860
+ const file = item.getAsFile();
2861
+ if (!file)
2862
+ return Promise.resolve(null);
2863
+ return new Promise((resolve, reject) => {
2864
+ const reader = new FileReader();
2865
+ reader.onload = (e2) => {
2866
+ var _a2, _b2;
2867
+ const base64String = (_b2 = (_a2 = e2.target) == null ? void 0 : _a2.result) == null ? void 0 : _b2.split(",")[1];
2868
+ if (base64String) {
2869
+ resolve({
2870
+ contentType: file.type,
2871
+ bytes: base64String
2872
+ });
2873
+ } else {
2874
+ resolve(null);
2875
+ }
2876
+ };
2877
+ reader.onerror = reject;
2878
+ reader.readAsDataURL(file);
2879
+ });
2880
+ }
2881
+ );
2698
2882
  try {
2699
- const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
2883
+ const loadedImages = (yield Promise.all(imagePromises)).filter(
2884
+ (img) => img !== null
2885
+ );
2700
2886
  setSelectedImages((prev) => [...prev, ...loadedImages]);
2701
2887
  } catch (error) {
2702
2888
  triggerChatError(error, "processClipboardImages", error);
@@ -2777,25 +2963,29 @@ function CopilotChat({
2777
2963
  if (!event.target.files || event.target.files.length === 0) {
2778
2964
  return;
2779
2965
  }
2780
- const files = Array.from(event.target.files).filter((file) => file.type.startsWith("image/"));
2966
+ const files = Array.from(event.target.files).filter(
2967
+ (file) => file.type.startsWith("image/")
2968
+ );
2781
2969
  if (files.length === 0)
2782
2970
  return;
2783
2971
  const fileReadPromises = files.map((file) => {
2784
- return new Promise((resolve, reject) => {
2785
- const reader = new FileReader();
2786
- reader.onload = (e) => {
2787
- var _a, _b;
2788
- const base64String = ((_b = (_a = e.target) == null ? void 0 : _a.result) == null ? void 0 : _b.split(",")[1]) || "";
2789
- if (base64String) {
2790
- resolve({
2791
- contentType: file.type,
2792
- bytes: base64String
2793
- });
2794
- }
2795
- };
2796
- reader.onerror = reject;
2797
- reader.readAsDataURL(file);
2798
- });
2972
+ return new Promise(
2973
+ (resolve, reject) => {
2974
+ const reader = new FileReader();
2975
+ reader.onload = (e) => {
2976
+ var _a, _b;
2977
+ const base64String = ((_b = (_a = e.target) == null ? void 0 : _a.result) == null ? void 0 : _b.split(",")[1]) || "";
2978
+ if (base64String) {
2979
+ resolve({
2980
+ contentType: file.type,
2981
+ bytes: base64String
2982
+ });
2983
+ }
2984
+ };
2985
+ reader.onerror = reject;
2986
+ reader.readAsDataURL(file);
2987
+ }
2988
+ );
2799
2989
  });
2800
2990
  try {
2801
2991
  const loadedImages = yield Promise.all(fileReadPromises);
@@ -2866,7 +3056,13 @@ function CopilotChat({
2866
3056
  }
2867
3057
  ),
2868
3058
  imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
2869
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
3059
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
3060
+ ImageUploadQueue,
3061
+ {
3062
+ images: selectedImages,
3063
+ onRemoveImage: removeSelectedImage
3064
+ }
3065
+ ),
2870
3066
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2871
3067
  "input",
2872
3068
  {
@@ -2904,8 +3100,17 @@ function WrappedCopilotChat({
2904
3100
  }) {
2905
3101
  const chatContext = import_react15.default.useContext(ChatContext);
2906
3102
  if (!chatContext) {
2907
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2908
- }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
3103
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
3104
+ ChatContextProvider,
3105
+ {
3106
+ icons,
3107
+ labels,
3108
+ open: true,
3109
+ setOpen: () => {
3110
+ },
3111
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children })
3112
+ }
3113
+ );
2909
3114
  }
2910
3115
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children });
2911
3116
  }
@@ -3054,37 +3259,46 @@ var CopilotModal = (_a) => {
3054
3259
  "observabilityHooks"
3055
3260
  ]);
3056
3261
  const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
3057
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3058
- CopilotModalInner,
3059
- __spreadProps(__spreadValues({
3060
- observabilityHooks,
3061
- onSetOpen,
3062
- clickOutsideToClose: clickOutsideToClose != null ? clickOutsideToClose : true,
3063
- hitEscapeToClose: hitEscapeToClose != null ? hitEscapeToClose : true,
3064
- shortcut: shortcut != null ? shortcut : "/",
3065
- className,
3066
- Window: Window2,
3067
- Button: Button2,
3068
- Header: Header2,
3069
- instructions,
3070
- onSubmitMessage,
3071
- onStopGeneration,
3072
- onReloadMessages,
3073
- makeSystemMessage,
3074
- onInProgress,
3075
- Messages: Messages2,
3076
- Input: Input2,
3077
- AssistantMessage: AssistantMessage2,
3078
- UserMessage: UserMessage2,
3079
- onThumbsUp,
3080
- onThumbsDown,
3081
- onCopy,
3082
- onRegenerate,
3083
- markdownTagRenderers
3084
- }, props), {
3085
- children
3086
- })
3087
- ) });
3262
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3263
+ ChatContextProvider,
3264
+ {
3265
+ icons,
3266
+ labels,
3267
+ open: openState,
3268
+ setOpen: setOpenState,
3269
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3270
+ CopilotModalInner,
3271
+ __spreadProps(__spreadValues({
3272
+ observabilityHooks,
3273
+ onSetOpen,
3274
+ clickOutsideToClose: clickOutsideToClose != null ? clickOutsideToClose : true,
3275
+ hitEscapeToClose: hitEscapeToClose != null ? hitEscapeToClose : true,
3276
+ shortcut: shortcut != null ? shortcut : "/",
3277
+ className,
3278
+ Window: Window2,
3279
+ Button: Button2,
3280
+ Header: Header2,
3281
+ instructions,
3282
+ onSubmitMessage,
3283
+ onStopGeneration,
3284
+ onReloadMessages,
3285
+ makeSystemMessage,
3286
+ onInProgress,
3287
+ Messages: Messages2,
3288
+ Input: Input2,
3289
+ AssistantMessage: AssistantMessage2,
3290
+ UserMessage: UserMessage2,
3291
+ onThumbsUp,
3292
+ onThumbsDown,
3293
+ onCopy,
3294
+ onRegenerate,
3295
+ markdownTagRenderers
3296
+ }, props), {
3297
+ children
3298
+ })
3299
+ )
3300
+ }
3301
+ );
3088
3302
  };
3089
3303
 
3090
3304
  // src/components/chat/Popup.tsx