@copilotkit/react-ui 1.8.12-next.4 → 1.8.12-next.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 (65) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/chunk-CGEAG65D.mjs +27 -0
  3. package/dist/chunk-CGEAG65D.mjs.map +1 -0
  4. package/dist/{chunk-SJWVHGKD.mjs → chunk-ECCHEFQV.mjs} +2 -2
  5. package/dist/chunk-EMIYIMQ6.mjs +110 -0
  6. package/dist/chunk-EMIYIMQ6.mjs.map +1 -0
  7. package/dist/{chunk-QXWJ7HYU.mjs → chunk-JZAMNIUD.mjs} +8 -8
  8. package/dist/{chunk-QXWJ7HYU.mjs.map → chunk-JZAMNIUD.mjs.map} +1 -1
  9. package/dist/{chunk-T5637OOY.mjs → chunk-KCV67665.mjs} +2 -2
  10. package/dist/{chunk-SLTG4L62.mjs → chunk-LUPGADWY.mjs} +4 -4
  11. package/dist/{chunk-POWCBXRY.mjs → chunk-RVLCPPEL.mjs} +4 -4
  12. package/dist/{chunk-Q2NFQTCQ.mjs → chunk-TIDV74OE.mjs} +7 -33
  13. package/dist/chunk-TIDV74OE.mjs.map +1 -0
  14. package/dist/{chunk-W2OWARTP.mjs → chunk-WN46UIN3.mjs} +7 -7
  15. package/dist/components/chat/Chat.js +151 -118
  16. package/dist/components/chat/Chat.js.map +1 -1
  17. package/dist/components/chat/Chat.mjs +7 -5
  18. package/dist/components/chat/Input.js +79 -46
  19. package/dist/components/chat/Input.js.map +1 -1
  20. package/dist/components/chat/Input.mjs +3 -1
  21. package/dist/components/chat/Modal.js +163 -162
  22. package/dist/components/chat/Modal.js.map +1 -1
  23. package/dist/components/chat/Modal.mjs +8 -7
  24. package/dist/components/chat/Popup.js +165 -164
  25. package/dist/components/chat/Popup.js.map +1 -1
  26. package/dist/components/chat/Popup.mjs +9 -8
  27. package/dist/components/chat/PoweredByTag.d.ts +7 -0
  28. package/dist/components/chat/PoweredByTag.js +56 -0
  29. package/dist/components/chat/PoweredByTag.js.map +1 -0
  30. package/dist/components/chat/PoweredByTag.mjs +9 -0
  31. package/dist/components/chat/PoweredByTag.mjs.map +1 -0
  32. package/dist/components/chat/Sidebar.js +165 -164
  33. package/dist/components/chat/Sidebar.js.map +1 -1
  34. package/dist/components/chat/Sidebar.mjs +9 -8
  35. package/dist/components/chat/Window.js +5 -37
  36. package/dist/components/chat/Window.js.map +1 -1
  37. package/dist/components/chat/Window.mjs +1 -2
  38. package/dist/components/chat/index.js +167 -166
  39. package/dist/components/chat/index.js.map +1 -1
  40. package/dist/components/chat/index.mjs +12 -11
  41. package/dist/components/chat/messages/RenderImageMessage.mjs +2 -2
  42. package/dist/components/chat/messages/RenderTextMessage.mjs +2 -2
  43. package/dist/components/index.js +167 -166
  44. package/dist/components/index.js.map +1 -1
  45. package/dist/components/index.mjs +12 -11
  46. package/dist/index.css +23 -26
  47. package/dist/index.css.map +1 -1
  48. package/dist/index.js +167 -166
  49. package/dist/index.js.map +1 -1
  50. package/dist/index.mjs +12 -11
  51. package/package.json +4 -4
  52. package/src/components/chat/Chat.tsx +1 -1
  53. package/src/components/chat/Input.tsx +6 -2
  54. package/src/components/chat/PoweredByTag.tsx +29 -0
  55. package/src/components/chat/Window.tsx +1 -24
  56. package/src/css/input.css +27 -0
  57. package/src/css/window.css +0 -29
  58. package/dist/chunk-IWBARPUZ.mjs +0 -102
  59. package/dist/chunk-IWBARPUZ.mjs.map +0 -1
  60. package/dist/chunk-Q2NFQTCQ.mjs.map +0 -1
  61. /package/dist/{chunk-SJWVHGKD.mjs.map → chunk-ECCHEFQV.mjs.map} +0 -0
  62. /package/dist/{chunk-T5637OOY.mjs.map → chunk-KCV67665.mjs.map} +0 -0
  63. /package/dist/{chunk-SLTG4L62.mjs.map → chunk-LUPGADWY.mjs.map} +0 -0
  64. /package/dist/{chunk-POWCBXRY.mjs.map → chunk-RVLCPPEL.mjs.map} +0 -0
  65. /package/dist/{chunk-W2OWARTP.mjs.map → chunk-WN46UIN3.mjs.map} +0 -0
@@ -752,30 +752,60 @@ var usePushToTalk = ({
752
752
 
753
753
  // src/components/chat/Input.tsx
754
754
  var import_react_core3 = require("@copilotkit/react-core");
755
+
756
+ // src/hooks/use-dark-mode.ts
757
+ var useDarkMode = () => {
758
+ if (typeof window === "undefined")
759
+ return false;
760
+ return document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") || document.documentElement.getAttribute("data-theme") === "dark" || document.body.getAttribute("data-theme") === "dark" || window.matchMedia("(prefers-color-scheme: dark)").matches;
761
+ };
762
+
763
+ // src/components/chat/PoweredByTag.tsx
755
764
  var import_jsx_runtime5 = require("react/jsx-runtime");
765
+ function PoweredByTag({ showPoweredBy = true }) {
766
+ const isDark = useDarkMode();
767
+ if (!showPoweredBy) {
768
+ return null;
769
+ }
770
+ const poweredByStyle = {
771
+ visibility: "visible",
772
+ display: "block",
773
+ position: "static",
774
+ textAlign: "center",
775
+ fontSize: "12px",
776
+ padding: "3px 0",
777
+ color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
778
+ };
779
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" }) });
780
+ }
781
+
782
+ // src/components/chat/Input.tsx
783
+ var import_jsx_runtime6 = require("react/jsx-runtime");
756
784
  var MAX_NEWLINES = 6;
757
785
  var Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload }) => {
786
+ var _a;
758
787
  const context = useChatContext();
759
788
  const copilotContext = (0, import_react_core3.useCopilotContext)();
789
+ const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
760
790
  const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
761
791
  const textareaRef = (0, import_react5.useRef)(null);
762
792
  const handleDivClick = (event) => {
763
- var _a;
793
+ var _a2;
764
794
  const target = event.target;
765
795
  if (target.closest("button"))
766
796
  return;
767
797
  if (target.tagName === "TEXTAREA")
768
798
  return;
769
- (_a = textareaRef.current) == null ? void 0 : _a.focus();
799
+ (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
770
800
  };
771
801
  const [text, setText] = (0, import_react5.useState)("");
772
802
  const send = () => {
773
- var _a;
803
+ var _a2;
774
804
  if (inProgress)
775
805
  return;
776
806
  onSend(text);
777
807
  setText("");
778
- (_a = textareaRef.current) == null ? void 0 : _a.focus();
808
+ (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
779
809
  };
780
810
  const { pushToTalkState, setPushToTalkState } = usePushToTalk({
781
811
  sendFunction: onSend,
@@ -785,62 +815,65 @@ var Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload }) => {
785
815
  const buttonIcon = isInProgress ? context.icons.stopIcon : context.icons.sendIcon;
786
816
  const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
787
817
  const canSend = () => {
788
- var _a;
789
- const interruptEvent = (_a = copilotContext.langGraphInterruptAction) == null ? void 0 : _a.event;
818
+ var _a2;
819
+ const interruptEvent = (_a2 = copilotContext.langGraphInterruptAction) == null ? void 0 : _a2.event;
790
820
  const interruptInProgress = (interruptEvent == null ? void 0 : interruptEvent.name) === "LangGraphInterruptEvent" && !(interruptEvent == null ? void 0 : interruptEvent.response);
791
821
  return (isInProgress || !isInProgress && text.trim().length > 0) && pushToTalkState === "idle" && !interruptInProgress;
792
822
  };
793
823
  const sendDisabled = !canSend();
794
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "copilotKitInputContainer", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
795
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
796
- Textarea_default,
797
- {
798
- ref: textareaRef,
799
- placeholder: context.labels.placeholder,
800
- autoFocus: false,
801
- maxRows: MAX_NEWLINES,
802
- value: text,
803
- onChange: (event) => setText(event.target.value),
804
- onKeyDown: (event) => {
805
- if (event.key === "Enter" && !event.shiftKey) {
806
- event.preventDefault();
807
- if (canSend()) {
808
- send();
824
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: `copilotKitInputContainer ${showPoweredBy ? "poweredByContainer" : ""}`, children: [
825
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
826
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
827
+ Textarea_default,
828
+ {
829
+ ref: textareaRef,
830
+ placeholder: context.labels.placeholder,
831
+ autoFocus: false,
832
+ maxRows: MAX_NEWLINES,
833
+ value: text,
834
+ onChange: (event) => setText(event.target.value),
835
+ onKeyDown: (event) => {
836
+ if (event.key === "Enter" && !event.shiftKey) {
837
+ event.preventDefault();
838
+ if (canSend()) {
839
+ send();
840
+ }
809
841
  }
810
842
  }
811
843
  }
812
- }
813
- ),
814
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "copilotKitInputControls", children: [
815
- onUpload && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { onClick: onUpload, className: "copilotKitInputControlButton", children: context.icons.uploadIcon }),
816
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flexGrow: 1 } }),
817
- showPushToTalk && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
818
- "button",
819
- {
820
- onClick: () => setPushToTalkState(pushToTalkState === "idle" ? "recording" : "transcribing"),
821
- className: pushToTalkState === "recording" ? "copilotKitInputControlButton copilotKitPushToTalkRecording" : "copilotKitInputControlButton",
822
- children: context.icons.pushToTalkIcon
823
- }
824
844
  ),
825
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
826
- "button",
827
- {
828
- disabled: sendDisabled,
829
- onClick: isInProgress ? onStop : send,
830
- "data-copilotkit-in-progress": inProgress,
831
- "data-test-id": inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready",
832
- className: "copilotKitInputControlButton",
833
- children: buttonIcon
834
- }
835
- )
836
- ] })
837
- ] }) });
845
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitInputControls", children: [
846
+ onUpload && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { onClick: onUpload, className: "copilotKitInputControlButton", children: context.icons.uploadIcon }),
847
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flexGrow: 1 } }),
848
+ showPushToTalk && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
849
+ "button",
850
+ {
851
+ onClick: () => setPushToTalkState(pushToTalkState === "idle" ? "recording" : "transcribing"),
852
+ className: pushToTalkState === "recording" ? "copilotKitInputControlButton copilotKitPushToTalkRecording" : "copilotKitInputControlButton",
853
+ children: context.icons.pushToTalkIcon
854
+ }
855
+ ),
856
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
857
+ "button",
858
+ {
859
+ disabled: sendDisabled,
860
+ onClick: isInProgress ? onStop : send,
861
+ "data-copilotkit-in-progress": inProgress,
862
+ "data-test-id": inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready",
863
+ className: "copilotKitInputControlButton",
864
+ children: buttonIcon
865
+ }
866
+ )
867
+ ] })
868
+ ] }),
869
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PoweredByTag, { showPoweredBy })
870
+ ] });
838
871
  };
839
872
 
840
873
  // src/components/chat/messages/UserMessage.tsx
841
- var import_jsx_runtime6 = require("react/jsx-runtime");
874
+ var import_jsx_runtime7 = require("react/jsx-runtime");
842
875
  var UserMessage = (props) => {
843
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: props.subComponent || props.message });
876
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: props.subComponent || props.message });
844
877
  };
845
878
 
846
879
  // src/components/chat/Markdown.tsx
@@ -874,7 +907,7 @@ function useCopyToClipboard({ timeout = 2e3 }) {
874
907
  }
875
908
 
876
909
  // src/components/chat/CodeBlock.tsx
877
- var import_jsx_runtime7 = require("react/jsx-runtime");
910
+ var import_jsx_runtime8 = require("react/jsx-runtime");
878
911
  var programmingLanguages = {
879
912
  javascript: ".js",
880
913
  python: ".py",
@@ -937,15 +970,15 @@ var CodeBlock = (0, import_react6.memo)(({ language, value }) => {
937
970
  return;
938
971
  copyToClipboard(value);
939
972
  };
940
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "copilotKitCodeBlock", children: [
941
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
942
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
943
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
944
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: DownloadIcon }),
945
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: isCopied ? CheckIcon : CopyIcon })
973
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "copilotKitCodeBlock", children: [
974
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
975
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
976
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
977
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: DownloadIcon }),
978
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: isCopied ? CheckIcon : CopyIcon })
946
979
  ] })
947
980
  ] }),
948
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
981
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
949
982
  import_react_syntax_highlighter.Prism,
950
983
  {
951
984
  language,
@@ -1248,18 +1281,18 @@ var highlightStyle = {
1248
1281
  // src/components/chat/Markdown.tsx
1249
1282
  var import_remark_gfm = __toESM(require("remark-gfm"));
1250
1283
  var import_remark_math = __toESM(require("remark-math"));
1251
- var import_jsx_runtime8 = require("react/jsx-runtime");
1284
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1252
1285
  var MemoizedReactMarkdown = (0, import_react7.memo)(
1253
1286
  import_react_markdown.default,
1254
1287
  (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
1255
1288
  );
1256
1289
  var Markdown = ({ content }) => {
1257
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MemoizedReactMarkdown, { components, remarkPlugins: [import_remark_gfm.default, import_remark_math.default], children: content }) });
1290
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MemoizedReactMarkdown, { components, remarkPlugins: [import_remark_gfm.default, import_remark_math.default], children: content }) });
1258
1291
  };
1259
1292
  var components = {
1260
1293
  a(_a) {
1261
1294
  var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
1262
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1295
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1263
1296
  "a",
1264
1297
  __spreadProps(__spreadValues({
1265
1298
  style: { color: "blue", textDecoration: "underline" }
@@ -1274,7 +1307,7 @@ var components = {
1274
1307
  var _d = _c, { children, className, inline } = _d, props = __objRest(_d, ["children", "className", "inline"]);
1275
1308
  if (children.length) {
1276
1309
  if (children[0] == "\u258D") {
1277
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1310
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1278
1311
  "span",
1279
1312
  {
1280
1313
  style: {
@@ -1289,9 +1322,9 @@ var components = {
1289
1322
  }
1290
1323
  const match = /language-(\w+)/.exec(className || "");
1291
1324
  if (inline) {
1292
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("code", __spreadProps(__spreadValues({ className }, props), { children }));
1325
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", __spreadProps(__spreadValues({ className }, props), { children }));
1293
1326
  }
1294
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1327
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1295
1328
  CodeBlock,
1296
1329
  __spreadValues({
1297
1330
  language: match && match[1] || "",
@@ -1304,7 +1337,7 @@ var components = {
1304
1337
 
1305
1338
  // src/components/chat/messages/AssistantMessage.tsx
1306
1339
  var import_react8 = require("react");
1307
- var import_jsx_runtime9 = require("react/jsx-runtime");
1340
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1308
1341
  var AssistantMessage = (props) => {
1309
1342
  const { icons, labels } = useChatContext();
1310
1343
  const {
@@ -1345,17 +1378,17 @@ var AssistantMessage = (props) => {
1345
1378
  onThumbsDown(message);
1346
1379
  }
1347
1380
  };
1348
- const LoadingIcon = () => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: icons.activityIcon });
1349
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1350
- (message || isLoading) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
1351
- message && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Markdown, { content: message || "" }),
1352
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(LoadingIcon, {}),
1353
- message && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1381
+ const LoadingIcon = () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: icons.activityIcon });
1382
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1383
+ (message || isLoading) && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
1384
+ message && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Markdown, { content: message || "" }),
1385
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LoadingIcon, {}),
1386
+ message && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1354
1387
  "div",
1355
1388
  {
1356
1389
  className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`,
1357
1390
  children: [
1358
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1391
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1359
1392
  "button",
1360
1393
  {
1361
1394
  className: "copilotKitMessageControlButton",
@@ -1365,17 +1398,17 @@ var AssistantMessage = (props) => {
1365
1398
  children: icons.regenerateIcon
1366
1399
  }
1367
1400
  ),
1368
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1401
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1369
1402
  "button",
1370
1403
  {
1371
1404
  className: "copilotKitMessageControlButton",
1372
1405
  onClick: handleCopy,
1373
1406
  "aria-label": labels.copyToClipboard,
1374
1407
  title: labels.copyToClipboard,
1375
- children: copied ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
1408
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
1376
1409
  }
1377
1410
  ),
1378
- onThumbsUp && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1411
+ onThumbsUp && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1379
1412
  "button",
1380
1413
  {
1381
1414
  className: "copilotKitMessageControlButton",
@@ -1385,7 +1418,7 @@ var AssistantMessage = (props) => {
1385
1418
  children: icons.thumbsUpIcon
1386
1419
  }
1387
1420
  ),
1388
- onThumbsDown && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1421
+ onThumbsDown && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1389
1422
  "button",
1390
1423
  {
1391
1424
  className: "copilotKitMessageControlButton",
@@ -1399,12 +1432,12 @@ var AssistantMessage = (props) => {
1399
1432
  }
1400
1433
  )
1401
1434
  ] }),
1402
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { marginBottom: "0.5rem" }, children: subComponent })
1435
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: { marginBottom: "0.5rem" }, children: subComponent })
1403
1436
  ] });
1404
1437
  };
1405
1438
 
1406
1439
  // src/components/chat/messages/RenderTextMessage.tsx
1407
- var import_jsx_runtime10 = require("react/jsx-runtime");
1440
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1408
1441
  function RenderTextMessage(_a) {
1409
1442
  var _b = _a, {
1410
1443
  UserMessage: UserMessage2 = UserMessage,
@@ -1425,7 +1458,7 @@ function RenderTextMessage(_a) {
1425
1458
  } = props;
1426
1459
  if (message.isTextMessage()) {
1427
1460
  if (message.role === "user") {
1428
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1461
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1429
1462
  UserMessage2,
1430
1463
  {
1431
1464
  "data-message-role": "user",
@@ -1435,7 +1468,7 @@ function RenderTextMessage(_a) {
1435
1468
  index
1436
1469
  );
1437
1470
  } else if (message.role == "assistant") {
1438
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1471
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1439
1472
  AssistantMessage2,
1440
1473
  {
1441
1474
  "data-message-role": "assistant",
@@ -1458,7 +1491,7 @@ function RenderTextMessage(_a) {
1458
1491
  // src/components/chat/messages/RenderActionExecutionMessage.tsx
1459
1492
  var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
1460
1493
  var import_react_core4 = require("@copilotkit/react-core");
1461
- var import_jsx_runtime11 = require("react/jsx-runtime");
1494
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1462
1495
  function RenderActionExecutionMessage(_a) {
1463
1496
  var _b = _a, {
1464
1497
  AssistantMessage: AssistantMessage2 = AssistantMessage
@@ -1472,7 +1505,7 @@ function RenderActionExecutionMessage(_a) {
1472
1505
  const render = chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"];
1473
1506
  if (typeof render === "string") {
1474
1507
  if (isCurrentMessage && inProgress) {
1475
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1508
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1476
1509
  AssistantMessage2,
1477
1510
  {
1478
1511
  rawData: message,
@@ -1505,7 +1538,7 @@ function RenderActionExecutionMessage(_a) {
1505
1538
  return null;
1506
1539
  }
1507
1540
  if (typeof toRender === "string") {
1508
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1541
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1509
1542
  AssistantMessage2,
1510
1543
  {
1511
1544
  rawData: message,
@@ -1517,7 +1550,7 @@ function RenderActionExecutionMessage(_a) {
1517
1550
  index
1518
1551
  );
1519
1552
  } else {
1520
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1553
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1521
1554
  AssistantMessage2,
1522
1555
  {
1523
1556
  rawData: message,
@@ -1531,20 +1564,20 @@ function RenderActionExecutionMessage(_a) {
1531
1564
  }
1532
1565
  } catch (e) {
1533
1566
  console.error(`Error executing render function for action ${message.name}: ${e}`);
1534
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1567
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1535
1568
  AssistantMessage2,
1536
1569
  {
1537
1570
  rawData: message,
1538
1571
  "data-message-role": "assistant",
1539
1572
  isLoading: false,
1540
1573
  isGenerating: false,
1541
- subComponent: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
1542
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("b", { children: [
1574
+ subComponent: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
1575
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("b", { children: [
1543
1576
  "\u274C Error executing render function for action ",
1544
1577
  message.name,
1545
1578
  ":"
1546
1579
  ] }),
1547
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("pre", { children: e instanceof Error ? e.message : String(e) })
1580
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("pre", { children: e instanceof Error ? e.message : String(e) })
1548
1581
  ] })
1549
1582
  },
1550
1583
  index
@@ -1554,7 +1587,7 @@ function RenderActionExecutionMessage(_a) {
1554
1587
  } else if (!inProgress || !isCurrentMessage) {
1555
1588
  return null;
1556
1589
  } else {
1557
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1590
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1558
1591
  AssistantMessage2,
1559
1592
  {
1560
1593
  rawData: message,
@@ -1569,7 +1602,7 @@ function RenderActionExecutionMessage(_a) {
1569
1602
  }
1570
1603
 
1571
1604
  // src/components/chat/messages/RenderResultMessage.tsx
1572
- var import_jsx_runtime12 = require("react/jsx-runtime");
1605
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1573
1606
  function RenderResultMessage(_a) {
1574
1607
  var _b = _a, {
1575
1608
  AssistantMessage: AssistantMessage2 = AssistantMessage
@@ -1578,7 +1611,7 @@ function RenderResultMessage(_a) {
1578
1611
  ]);
1579
1612
  const { message, inProgress, index, isCurrentMessage } = props;
1580
1613
  if (message.isResultMessage() && inProgress && isCurrentMessage) {
1581
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1614
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1582
1615
  AssistantMessage2,
1583
1616
  {
1584
1617
  "data-message-role": "assistant",
@@ -1595,7 +1628,7 @@ function RenderResultMessage(_a) {
1595
1628
 
1596
1629
  // src/components/chat/messages/RenderAgentStateMessage.tsx
1597
1630
  var import_react_core5 = require("@copilotkit/react-core");
1598
- var import_jsx_runtime13 = require("react/jsx-runtime");
1631
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1599
1632
  function RenderAgentStateMessage(_a) {
1600
1633
  var _b = _a, {
1601
1634
  AssistantMessage: AssistantMessage2 = AssistantMessage
@@ -1612,7 +1645,7 @@ function RenderAgentStateMessage(_a) {
1612
1645
  if (render) {
1613
1646
  if (typeof render === "string") {
1614
1647
  if (isCurrentMessage && inProgress) {
1615
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1648
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1616
1649
  AssistantMessage2,
1617
1650
  {
1618
1651
  rawData: message,
@@ -1638,7 +1671,7 @@ function RenderAgentStateMessage(_a) {
1638
1671
  return null;
1639
1672
  }
1640
1673
  if (!toRender && isCurrentMessage && inProgress) {
1641
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1674
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1642
1675
  AssistantMessage2,
1643
1676
  {
1644
1677
  "data-message-role": "assistant",
@@ -1652,7 +1685,7 @@ function RenderAgentStateMessage(_a) {
1652
1685
  return null;
1653
1686
  }
1654
1687
  if (typeof toRender === "string") {
1655
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1688
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1656
1689
  AssistantMessage2,
1657
1690
  {
1658
1691
  rawData: message,
@@ -1664,7 +1697,7 @@ function RenderAgentStateMessage(_a) {
1664
1697
  index
1665
1698
  );
1666
1699
  } else {
1667
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1700
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1668
1701
  AssistantMessage2,
1669
1702
  {
1670
1703
  rawData: message,
@@ -1680,7 +1713,7 @@ function RenderAgentStateMessage(_a) {
1680
1713
  } else if (!inProgress || !isCurrentMessage) {
1681
1714
  return null;
1682
1715
  } else {
1683
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1716
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1684
1717
  AssistantMessage2,
1685
1718
  {
1686
1719
  rawData: message,
@@ -1695,7 +1728,7 @@ function RenderAgentStateMessage(_a) {
1695
1728
  }
1696
1729
 
1697
1730
  // src/components/chat/messages/RenderImageMessage.tsx
1698
- var import_jsx_runtime14 = require("react/jsx-runtime");
1731
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1699
1732
  function RenderImageMessage(_a) {
1700
1733
  var _b = _a, {
1701
1734
  UserMessage: UserMessage2 = UserMessage,
@@ -1716,7 +1749,7 @@ function RenderImageMessage(_a) {
1716
1749
  } = props;
1717
1750
  if (message.isImageMessage()) {
1718
1751
  const imageData = `data:${message.format};base64,${message.bytes}`;
1719
- const imageComponent = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "copilotKitImage", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1752
+ const imageComponent = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "copilotKitImage", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1720
1753
  "img",
1721
1754
  {
1722
1755
  src: imageData,
@@ -1725,7 +1758,7 @@ function RenderImageMessage(_a) {
1725
1758
  }
1726
1759
  ) });
1727
1760
  if (message.role === "user") {
1728
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1761
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1729
1762
  UserMessage2,
1730
1763
  {
1731
1764
  "data-message-role": "user",
@@ -1736,7 +1769,7 @@ function RenderImageMessage(_a) {
1736
1769
  index
1737
1770
  );
1738
1771
  } else if (message.role === "assistant") {
1739
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1772
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1740
1773
  AssistantMessage2,
1741
1774
  {
1742
1775
  "data-message-role": "assistant",
@@ -1762,9 +1795,9 @@ function RenderImageMessage(_a) {
1762
1795
  var import_react_core6 = require("@copilotkit/react-core");
1763
1796
  var import_shared = require("@copilotkit/shared");
1764
1797
  var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
1765
- var import_jsx_runtime15 = require("react/jsx-runtime");
1798
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1766
1799
  function Suggestion({ title, message, onClick, partial, className }) {
1767
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1800
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1768
1801
  "button",
1769
1802
  {
1770
1803
  disabled: partial,
@@ -1774,7 +1807,7 @@ function Suggestion({ title, message, onClick, partial, className }) {
1774
1807
  },
1775
1808
  className: className || (partial ? "suggestion loading" : "suggestion"),
1776
1809
  "data-test-id": "suggestion",
1777
- children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: title })
1810
+ children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: title })
1778
1811
  }
1779
1812
  );
1780
1813
  }
@@ -1856,7 +1889,7 @@ var import_shared2 = require("@copilotkit/shared");
1856
1889
  var import_react_core8 = require("@copilotkit/react-core");
1857
1890
 
1858
1891
  // src/components/chat/ImageUploadQueue.tsx
1859
- var import_jsx_runtime16 = require("react/jsx-runtime");
1892
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1860
1893
  var ImageUploadQueue = ({
1861
1894
  images,
1862
1895
  onRemoveImage,
@@ -1864,7 +1897,7 @@ var ImageUploadQueue = ({
1864
1897
  }) => {
1865
1898
  if (images.length === 0)
1866
1899
  return null;
1867
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1900
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1868
1901
  "div",
1869
1902
  {
1870
1903
  className: `copilotKitImageUploadQueue ${className}`,
@@ -1875,7 +1908,7 @@ var ImageUploadQueue = ({
1875
1908
  margin: "8px",
1876
1909
  padding: "8px"
1877
1910
  },
1878
- children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1911
+ children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1879
1912
  "div",
1880
1913
  {
1881
1914
  className: "copilotKitImageUploadQueueItem",
@@ -1888,7 +1921,7 @@ var ImageUploadQueue = ({
1888
1921
  overflow: "hidden"
1889
1922
  },
1890
1923
  children: [
1891
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1924
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1892
1925
  "img",
1893
1926
  {
1894
1927
  src: `data:${image.contentType};base64,${image.bytes}`,
@@ -1900,7 +1933,7 @@ var ImageUploadQueue = ({
1900
1933
  }
1901
1934
  }
1902
1935
  ),
1903
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1936
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1904
1937
  "button",
1905
1938
  {
1906
1939
  onClick: () => onRemoveImage(index),
@@ -1934,7 +1967,7 @@ var ImageUploadQueue = ({
1934
1967
  };
1935
1968
 
1936
1969
  // src/components/chat/Chat.tsx
1937
- var import_jsx_runtime17 = require("react/jsx-runtime");
1970
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1938
1971
  function CopilotChat({
1939
1972
  instructions,
1940
1973
  onSubmitMessage,
@@ -2091,8 +2124,8 @@ function CopilotChat({
2091
2124
  const removeSelectedImage = (index) => {
2092
2125
  setSelectedImages((prev) => prev.filter((_, i) => i !== index));
2093
2126
  };
2094
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2095
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2127
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2128
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2096
2129
  Messages2,
2097
2130
  {
2098
2131
  AssistantMessage: AssistantMessage2,
@@ -2108,7 +2141,7 @@ function CopilotChat({
2108
2141
  onCopy: handleCopy,
2109
2142
  onThumbsUp,
2110
2143
  onThumbsDown,
2111
- children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2144
+ children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2112
2145
  Suggestion,
2113
2146
  {
2114
2147
  title: suggestion.title,
@@ -2121,9 +2154,9 @@ function CopilotChat({
2121
2154
  )) })
2122
2155
  }
2123
2156
  ),
2124
- imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
2125
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2126
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2157
+ imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
2158
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2159
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2127
2160
  "input",
2128
2161
  {
2129
2162
  type: "file",
@@ -2135,7 +2168,7 @@ function CopilotChat({
2135
2168
  }
2136
2169
  )
2137
2170
  ] }),
2138
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2171
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2139
2172
  Input2,
2140
2173
  {
2141
2174
  inProgress: isLoading,
@@ -2158,10 +2191,10 @@ function WrappedCopilotChat({
2158
2191
  }) {
2159
2192
  const chatContext = import_react9.default.useContext(ChatContext);
2160
2193
  if (!chatContext) {
2161
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2162
- }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: `copilotKitChat ${className}`, children }) });
2194
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2195
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2163
2196
  }
2164
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children });
2197
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
2165
2198
  }
2166
2199
  var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
2167
2200
  var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {