@copilotkit/react-ui 1.51.3-next.5 → 1.51.3-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 +8 -0
  2. package/dist/{chunk-PKSW6ZMQ.mjs → chunk-7OURDQZJ.mjs} +2 -2
  3. package/dist/{chunk-HKZL4P3F.mjs → chunk-BVKKSSB2.mjs} +4 -4
  4. package/dist/{chunk-4S4ZEKE6.mjs → chunk-DI7DDMRS.mjs} +2 -2
  5. package/dist/{chunk-UH5GQ7QF.mjs → chunk-HIW7RXCD.mjs} +2 -2
  6. package/dist/{chunk-SLM2AOHF.mjs → chunk-IHFR6PYG.mjs} +2 -2
  7. package/dist/{chunk-XOBQLKUU.mjs → chunk-JZ3RFQQ6.mjs} +13 -3
  8. package/dist/chunk-JZ3RFQQ6.mjs.map +1 -0
  9. package/dist/{chunk-XEZ5ODJS.mjs → chunk-NCIAFFQ2.mjs} +2 -2
  10. package/dist/{chunk-YQOESY4Y.mjs → chunk-NSJWSIPR.mjs} +4 -4
  11. package/dist/{chunk-O4PPO3K3.mjs → chunk-VVCCMYGT.mjs} +2 -2
  12. package/dist/components/chat/Chat.js +67 -57
  13. package/dist/components/chat/Chat.js.map +1 -1
  14. package/dist/components/chat/Chat.mjs +6 -6
  15. package/dist/components/chat/Markdown.d.ts +2 -4
  16. package/dist/components/chat/Markdown.js +12 -2
  17. package/dist/components/chat/Markdown.js.map +1 -1
  18. package/dist/components/chat/Markdown.mjs +1 -1
  19. package/dist/components/chat/Messages.js +27 -17
  20. package/dist/components/chat/Messages.js.map +1 -1
  21. package/dist/components/chat/Messages.mjs +5 -5
  22. package/dist/components/chat/Modal.js +74 -64
  23. package/dist/components/chat/Modal.js.map +1 -1
  24. package/dist/components/chat/Modal.mjs +7 -7
  25. package/dist/components/chat/Popup.js +74 -64
  26. package/dist/components/chat/Popup.js.map +1 -1
  27. package/dist/components/chat/Popup.mjs +8 -8
  28. package/dist/components/chat/Sidebar.js +76 -66
  29. package/dist/components/chat/Sidebar.js.map +1 -1
  30. package/dist/components/chat/Sidebar.mjs +8 -8
  31. package/dist/components/chat/index.d.ts +1 -1
  32. package/dist/components/chat/index.js +76 -66
  33. package/dist/components/chat/index.js.map +1 -1
  34. package/dist/components/chat/index.mjs +9 -9
  35. package/dist/components/chat/messages/AssistantMessage.js +14 -4
  36. package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
  37. package/dist/components/chat/messages/AssistantMessage.mjs +2 -2
  38. package/dist/components/chat/messages/ErrorMessage.js +14 -4
  39. package/dist/components/chat/messages/ErrorMessage.js.map +1 -1
  40. package/dist/components/chat/messages/ErrorMessage.mjs +1 -1
  41. package/dist/components/chat/messages/LegacyRenderMessage.js +16 -6
  42. package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
  43. package/dist/components/chat/messages/LegacyRenderMessage.mjs +4 -4
  44. package/dist/components/chat/messages/RenderMessage.js +16 -6
  45. package/dist/components/chat/messages/RenderMessage.js.map +1 -1
  46. package/dist/components/chat/messages/RenderMessage.mjs +3 -3
  47. package/dist/components/index.d.ts +1 -1
  48. package/dist/components/index.js +76 -66
  49. package/dist/components/index.js.map +1 -1
  50. package/dist/components/index.mjs +9 -9
  51. package/dist/index.d.ts +1 -1
  52. package/dist/index.js +76 -66
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +9 -9
  55. package/package.json +8 -5
  56. package/src/components/chat/Markdown.tsx +17 -8
  57. package/dist/chunk-XOBQLKUU.mjs.map +0 -1
  58. /package/dist/{chunk-PKSW6ZMQ.mjs.map → chunk-7OURDQZJ.mjs.map} +0 -0
  59. /package/dist/{chunk-HKZL4P3F.mjs.map → chunk-BVKKSSB2.mjs.map} +0 -0
  60. /package/dist/{chunk-4S4ZEKE6.mjs.map → chunk-DI7DDMRS.mjs.map} +0 -0
  61. /package/dist/{chunk-UH5GQ7QF.mjs.map → chunk-HIW7RXCD.mjs.map} +0 -0
  62. /package/dist/{chunk-SLM2AOHF.mjs.map → chunk-IHFR6PYG.mjs.map} +0 -0
  63. /package/dist/{chunk-XEZ5ODJS.mjs.map → chunk-NCIAFFQ2.mjs.map} +0 -0
  64. /package/dist/{chunk-YQOESY4Y.mjs.map → chunk-NSJWSIPR.mjs.map} +0 -0
  65. /package/dist/{chunk-O4PPO3K3.mjs.map → chunk-VVCCMYGT.mjs.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # ui
2
2
 
3
+ ## 1.51.3-next.6
4
+
5
+ ### Patch Changes
6
+
7
+ - @copilotkit/runtime-client-gql@1.51.3-next.6
8
+ - @copilotkit/react-core@1.51.3-next.6
9
+ - @copilotkit/shared@1.51.3-next.6
10
+
3
11
  ## 1.51.3-next.5
4
12
 
5
13
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RenderMessage
3
- } from "./chunk-XEZ5ODJS.mjs";
3
+ } from "./chunk-NCIAFFQ2.mjs";
4
4
 
5
5
  // src/components/chat/messages/LegacyRenderMessage.tsx
6
6
  import { aguiToGQL } from "@copilotkit/runtime-client-gql";
@@ -130,4 +130,4 @@ var LegacyRenderMessage = ({
130
130
  export {
131
131
  LegacyRenderMessage
132
132
  };
133
- //# sourceMappingURL=chunk-PKSW6ZMQ.mjs.map
133
+ //# sourceMappingURL=chunk-7OURDQZJ.mjs.map
@@ -9,16 +9,16 @@ import {
9
9
  } from "./chunk-UFN2VWSR.mjs";
10
10
  import {
11
11
  CopilotChat
12
- } from "./chunk-YQOESY4Y.mjs";
12
+ } from "./chunk-NSJWSIPR.mjs";
13
13
  import {
14
14
  Input
15
15
  } from "./chunk-3W6J75HS.mjs";
16
16
  import {
17
17
  Messages
18
- } from "./chunk-UH5GQ7QF.mjs";
18
+ } from "./chunk-HIW7RXCD.mjs";
19
19
  import {
20
20
  AssistantMessage
21
- } from "./chunk-SLM2AOHF.mjs";
21
+ } from "./chunk-IHFR6PYG.mjs";
22
22
  import {
23
23
  UserMessage
24
24
  } from "./chunk-RYUCX3ZK.mjs";
@@ -219,4 +219,4 @@ var CopilotModal = (_a) => {
219
219
  export {
220
220
  CopilotModal
221
221
  };
222
- //# sourceMappingURL=chunk-HKZL4P3F.mjs.map
222
+ //# sourceMappingURL=chunk-BVKKSSB2.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-HKZL4P3F.mjs";
3
+ } from "./chunk-BVKKSSB2.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -27,4 +27,4 @@ function CopilotSidebar(props) {
27
27
  export {
28
28
  CopilotSidebar
29
29
  };
30
- //# sourceMappingURL=chunk-4S4ZEKE6.mjs.map
30
+ //# sourceMappingURL=chunk-DI7DDMRS.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LegacyRenderMessage
3
- } from "./chunk-PKSW6ZMQ.mjs";
3
+ } from "./chunk-7OURDQZJ.mjs";
4
4
  import {
5
5
  useChatContext
6
6
  } from "./chunk-IEMQ2SQW.mjs";
@@ -181,4 +181,4 @@ export {
181
181
  Messages,
182
182
  useScrollToBottom
183
183
  };
184
- //# sourceMappingURL=chunk-UH5GQ7QF.mjs.map
184
+ //# sourceMappingURL=chunk-HIW7RXCD.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Markdown
3
- } from "./chunk-XOBQLKUU.mjs";
3
+ } from "./chunk-JZ3RFQQ6.mjs";
4
4
  import {
5
5
  useChatContext
6
6
  } from "./chunk-IEMQ2SQW.mjs";
@@ -113,4 +113,4 @@ var AssistantMessage = (props) => {
113
113
  export {
114
114
  AssistantMessage
115
115
  };
116
- //# sourceMappingURL=chunk-SLM2AOHF.mjs.map
116
+ //# sourceMappingURL=chunk-IHFR6PYG.mjs.map
@@ -8,7 +8,11 @@ import {
8
8
  } from "./chunk-MRXNTQOX.mjs";
9
9
 
10
10
  // src/components/chat/Markdown.tsx
11
- import { Streamdown } from "streamdown";
11
+ import { memo } from "react";
12
+ import ReactMarkdown from "react-markdown";
13
+ import remarkGfm from "remark-gfm";
14
+ import remarkMath from "remark-math";
15
+ import rehypeRaw from "rehype-raw";
12
16
  import { jsx } from "react/jsx-runtime";
13
17
  var defaultComponents = {
14
18
  a(_a) {
@@ -102,11 +106,17 @@ var defaultComponents = {
102
106
  return /* @__PURE__ */ jsx("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
103
107
  }
104
108
  };
109
+ var MemoizedReactMarkdown = memo(
110
+ ReactMarkdown,
111
+ (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
112
+ );
105
113
  var Markdown = ({ content, components }) => {
106
114
  return /* @__PURE__ */ jsx("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ jsx(
107
- Streamdown,
115
+ MemoizedReactMarkdown,
108
116
  {
109
117
  components: __spreadValues(__spreadValues({}, defaultComponents), components),
118
+ remarkPlugins: [remarkGfm, [remarkMath, { singleDollarTextMath: false }]],
119
+ rehypePlugins: [rehypeRaw],
110
120
  children: content
111
121
  }
112
122
  ) });
@@ -115,4 +125,4 @@ var Markdown = ({ content, components }) => {
115
125
  export {
116
126
  Markdown
117
127
  };
118
- //# sourceMappingURL=chunk-XOBQLKUU.mjs.map
128
+ //# sourceMappingURL=chunk-JZ3RFQQ6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Markdown.tsx"],"sourcesContent":["import { FC, memo } from \"react\";\nimport ReactMarkdown, { Options, Components } from \"react-markdown\";\nimport { CodeBlock } from \"./CodeBlock\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkMath from \"remark-math\";\nimport rehypeRaw from \"rehype-raw\";\n\nconst defaultComponents: Components = {\n a({ children, ...props }) {\n return (\n <a className=\"copilotKitMarkdownElement\" {...props} target=\"_blank\" rel=\"noopener noreferrer\">\n {children}\n </a>\n );\n },\n // @ts-expect-error -- inline\n code({ children, className, inline, ...props }) {\n if (Array.isArray(children) && children.length) {\n if (children[0] == \"▍\") {\n return (\n <span\n style={{\n animation: \"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite\",\n marginTop: \"0.25rem\",\n }}\n >\n ▍\n </span>\n );\n }\n\n children[0] = (children?.[0] as string).replace(\"`▍`\", \"▍\");\n }\n\n const match = /language-(\\w+)/.exec(className || \"\");\n\n // Detect inline code: if it has a language class or contains newlines, it's likely a code block\n // Otherwise, treat it as inline code\n const hasLanguage = match && match[1];\n const content = String(children);\n const hasNewlines = content.includes(\"\\n\");\n const isInline = !hasLanguage && !hasNewlines;\n\n if (isInline) {\n return (\n <code\n className={`copilotKitMarkdownElement copilotKitInlineCode ${className || \"\"}`}\n {...props}\n >\n {children}\n </code>\n );\n }\n\n return (\n <CodeBlock\n key={Math.random()}\n language={(match && match[1]) || \"\"}\n value={String(children).replace(/\\n$/, \"\")}\n {...props}\n />\n );\n },\n h1: ({ children, ...props }) => (\n <h1 className=\"copilotKitMarkdownElement\" {...props}>\n {children}\n </h1>\n ),\n h2: ({ children, ...props }) => (\n <h2 className=\"copilotKitMarkdownElement\" {...props}>\n {children}\n </h2>\n ),\n h3: ({ children, ...props }) => (\n <h3 className=\"copilotKitMarkdownElement\" {...props}>\n {children}\n </h3>\n ),\n h4: ({ children, ...props }) => (\n <h4 className=\"copilotKitMarkdownElement\" {...props}>\n {children}\n </h4>\n ),\n h5: ({ children, ...props }) => (\n <h5 className=\"copilotKitMarkdownElement\" {...props}>\n {children}\n </h5>\n ),\n h6: ({ children, ...props }) => (\n <h6 className=\"copilotKitMarkdownElement\" {...props}>\n {children}\n </h6>\n ),\n p: ({ children, ...props }) => (\n <p className=\"copilotKitMarkdownElement\" {...props}>\n {children}\n </p>\n ),\n pre: ({ children, ...props }) => (\n <pre className=\"copilotKitMarkdownElement\" {...props}>\n {children}\n </pre>\n ),\n blockquote: ({ children, ...props }) => (\n <blockquote className=\"copilotKitMarkdownElement\" {...props}>\n {children}\n </blockquote>\n ),\n ul: ({ children, ...props }) => (\n <ul className=\"copilotKitMarkdownElement\" {...props}>\n {children}\n </ul>\n ),\n li: ({ children, ...props }) => (\n <li className=\"copilotKitMarkdownElement\" {...props}>\n {children}\n </li>\n ),\n};\n\nconst MemoizedReactMarkdown: FC<Options> = memo(\n ReactMarkdown,\n (prevProps, nextProps) =>\n prevProps.children === nextProps.children && prevProps.components === nextProps.components,\n);\n\ntype MarkdownProps = {\n content: string;\n components?: Components;\n};\n\nexport const Markdown = ({ content, components }: MarkdownProps) => {\n return (\n <div className=\"copilotKitMarkdown\">\n <MemoizedReactMarkdown\n components={{ ...defaultComponents, ...components }}\n remarkPlugins={[remarkGfm, [remarkMath, { singleDollarTextMath: false }]]}\n rehypePlugins={[rehypeRaw]}\n >\n {content}\n </MemoizedReactMarkdown>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;AAAA,SAAa,YAAY;AACzB,OAAO,mBAA4C;AAEnD,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,eAAe;AAKhB;AAHN,IAAM,oBAAgC;AAAA,EACpC,EAAE,IAAwB;AAAxB,iBAAE,WARN,IAQI,IAAe,kBAAf,IAAe,CAAb;AACF,WACE,oBAAC,oCAAE,WAAU,+BAAgC,QAA5C,EAAmD,QAAO,UAAS,KAAI,uBACrE,WACH;AAAA,EAEJ;AAAA;AAAA,EAEA,KAAK,IAA2C;AAA3C,iBAAE,YAAU,WAAW,OAhB9B,IAgBO,IAAkC,kBAAlC,IAAkC,CAAhC,YAAU,aAAW;AAC1B,QAAI,MAAM,QAAQ,QAAQ,KAAK,SAAS,QAAQ;AAC9C,UAAI,SAAS,CAAC,KAAK,UAAK;AACtB,eACE;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,WAAW;AAAA,cACX,WAAW;AAAA,YACb;AAAA,YACD;AAAA;AAAA,QAED;AAAA,MAEJ;AAEA,eAAS,CAAC,KAAK,qCAAW,IAAc,QAAQ,YAAO,QAAG;AAAA,IAC5D;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AAEJ;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AssistantMessage
3
- } from "./chunk-SLM2AOHF.mjs";
3
+ } from "./chunk-IHFR6PYG.mjs";
4
4
  import {
5
5
  ImageRenderer
6
6
  } from "./chunk-DBKRAOH7.mjs";
@@ -79,4 +79,4 @@ function RenderMessage(_a) {
79
79
  export {
80
80
  RenderMessage
81
81
  };
82
- //# sourceMappingURL=chunk-XEZ5ODJS.mjs.map
82
+ //# sourceMappingURL=chunk-NCIAFFQ2.mjs.map
@@ -9,13 +9,13 @@ import {
9
9
  } from "./chunk-3W6J75HS.mjs";
10
10
  import {
11
11
  Messages
12
- } from "./chunk-UH5GQ7QF.mjs";
12
+ } from "./chunk-HIW7RXCD.mjs";
13
13
  import {
14
14
  RenderMessage
15
- } from "./chunk-XEZ5ODJS.mjs";
15
+ } from "./chunk-NCIAFFQ2.mjs";
16
16
  import {
17
17
  AssistantMessage
18
- } from "./chunk-SLM2AOHF.mjs";
18
+ } from "./chunk-IHFR6PYG.mjs";
19
19
  import {
20
20
  ImageRenderer
21
21
  } from "./chunk-DBKRAOH7.mjs";
@@ -432,4 +432,4 @@ export {
432
432
  CopilotChat,
433
433
  WrappedCopilotChat
434
434
  };
435
- //# sourceMappingURL=chunk-YQOESY4Y.mjs.map
435
+ //# sourceMappingURL=chunk-NSJWSIPR.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-HKZL4P3F.mjs";
3
+ } from "./chunk-BVKKSSB2.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
@@ -18,4 +18,4 @@ function CopilotPopup(props) {
18
18
  export {
19
19
  CopilotPopup
20
20
  };
21
- //# sourceMappingURL=chunk-O4PPO3K3.mjs.map
21
+ //# sourceMappingURL=chunk-VVCCMYGT.mjs.map
@@ -394,7 +394,7 @@ var ChatContextProvider = ({
394
394
  };
395
395
 
396
396
  // src/components/chat/Messages.tsx
397
- var import_react5 = require("react");
397
+ var import_react6 = require("react");
398
398
  var import_react_core = require("@copilotkit/react-core");
399
399
 
400
400
  // src/components/chat/messages/UserMessage.tsx
@@ -426,7 +426,8 @@ var UserMessage = (props) => {
426
426
  };
427
427
 
428
428
  // src/components/chat/Markdown.tsx
429
- var import_streamdown = require("streamdown");
429
+ var import_react3 = require("react");
430
+ var import_react_markdown = __toESM(require("react-markdown"));
430
431
 
431
432
  // src/components/chat/CodeBlock.tsx
432
433
  var import_react2 = require("react");
@@ -838,6 +839,9 @@ var highlightStyle = {
838
839
  };
839
840
 
840
841
  // src/components/chat/Markdown.tsx
842
+ var import_remark_gfm = __toESM(require("remark-gfm"));
843
+ var import_remark_math = __toESM(require("remark-math"));
844
+ var import_rehype_raw = __toESM(require("rehype-raw"));
841
845
  var import_jsx_runtime5 = require("react/jsx-runtime");
842
846
  var defaultComponents = {
843
847
  a(_a) {
@@ -931,18 +935,24 @@ var defaultComponents = {
931
935
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
932
936
  }
933
937
  };
938
+ var MemoizedReactMarkdown = (0, import_react3.memo)(
939
+ import_react_markdown.default,
940
+ (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
941
+ );
934
942
  var Markdown = ({ content, components }) => {
935
943
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
936
- import_streamdown.Streamdown,
944
+ MemoizedReactMarkdown,
937
945
  {
938
946
  components: __spreadValues(__spreadValues({}, defaultComponents), components),
947
+ remarkPlugins: [import_remark_gfm.default, [import_remark_math.default, { singleDollarTextMath: false }]],
948
+ rehypePlugins: [import_rehype_raw.default],
939
949
  children: content
940
950
  }
941
951
  ) });
942
952
  };
943
953
 
944
954
  // src/components/chat/messages/AssistantMessage.tsx
945
- var import_react3 = require("react");
955
+ var import_react4 = require("react");
946
956
  var import_jsx_runtime6 = require("react/jsx-runtime");
947
957
  var AssistantMessage = (props) => {
948
958
  var _a;
@@ -958,7 +968,7 @@ var AssistantMessage = (props) => {
958
968
  feedback,
959
969
  markdownTagRenderers
960
970
  } = props;
961
- const [copied, setCopied] = (0, import_react3.useState)(false);
971
+ const [copied, setCopied] = (0, import_react4.useState)(false);
962
972
  const handleCopy = () => {
963
973
  const content2 = (message == null ? void 0 : message.content) || "";
964
974
  if (content2 && onCopy) {
@@ -1047,10 +1057,10 @@ var AssistantMessage = (props) => {
1047
1057
  };
1048
1058
 
1049
1059
  // src/components/chat/messages/ImageRenderer.tsx
1050
- var import_react4 = require("react");
1060
+ var import_react5 = require("react");
1051
1061
  var import_jsx_runtime7 = require("react/jsx-runtime");
1052
1062
  var ImageRenderer = ({ image, content, className = "" }) => {
1053
- const [imageError, setImageError] = (0, import_react4.useState)(false);
1063
+ const [imageError, setImageError] = (0, import_react5.useState)(false);
1054
1064
  const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
1055
1065
  const altText = content || "User uploaded image";
1056
1066
  const handleImageError = () => {
@@ -1293,18 +1303,18 @@ var Messages = ({
1293
1303
  var _a;
1294
1304
  const { labels, icons } = useChatContext();
1295
1305
  const { messages: visibleMessages, interrupt } = (0, import_react_core.useCopilotChatInternal)();
1296
- const initialMessages = (0, import_react5.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1306
+ const initialMessages = (0, import_react6.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1297
1307
  const messages = [...initialMessages, ...visibleMessages];
1298
1308
  const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
1299
1309
  const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
1300
- (0, import_react5.useEffect)(() => {
1310
+ (0, import_react6.useEffect)(() => {
1301
1311
  if (hasLegacyProps) {
1302
1312
  console.warn(
1303
1313
  "[CopilotKit] Legacy message render props (RenderTextMessage, RenderActionExecutionMessage, etc.) are deprecated. Please use the unified 'RenderMessage' prop instead. See migration guide: https://docs.copilotkit.ai/migration/render-message"
1304
1314
  );
1305
1315
  }
1306
1316
  }, [hasLegacyProps]);
1307
- const legacyProps = (0, import_react5.useMemo)(
1317
+ const legacyProps = (0, import_react6.useMemo)(
1308
1318
  () => ({
1309
1319
  RenderTextMessage,
1310
1320
  RenderActionExecutionMessage,
@@ -1375,10 +1385,10 @@ function makeInitialMessages(initial) {
1375
1385
  ];
1376
1386
  }
1377
1387
  function useScrollToBottom(messages) {
1378
- const messagesEndRef = (0, import_react5.useRef)(null);
1379
- const messagesContainerRef = (0, import_react5.useRef)(null);
1380
- const isProgrammaticScrollRef = (0, import_react5.useRef)(false);
1381
- const isUserScrollUpRef = (0, import_react5.useRef)(false);
1388
+ const messagesEndRef = (0, import_react6.useRef)(null);
1389
+ const messagesContainerRef = (0, import_react6.useRef)(null);
1390
+ const isProgrammaticScrollRef = (0, import_react6.useRef)(false);
1391
+ const isUserScrollUpRef = (0, import_react6.useRef)(false);
1382
1392
  const scrollToBottom = () => {
1383
1393
  if (messagesContainerRef.current && messagesEndRef.current) {
1384
1394
  isProgrammaticScrollRef.current = true;
@@ -1395,7 +1405,7 @@ function useScrollToBottom(messages) {
1395
1405
  isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
1396
1406
  }
1397
1407
  };
1398
- (0, import_react5.useEffect)(() => {
1408
+ (0, import_react6.useEffect)(() => {
1399
1409
  const container = messagesContainerRef.current;
1400
1410
  if (container) {
1401
1411
  container.addEventListener("scroll", handleScroll);
@@ -1406,7 +1416,7 @@ function useScrollToBottom(messages) {
1406
1416
  }
1407
1417
  };
1408
1418
  }, []);
1409
- (0, import_react5.useEffect)(() => {
1419
+ (0, import_react6.useEffect)(() => {
1410
1420
  const container = messagesContainerRef.current;
1411
1421
  if (!container) {
1412
1422
  return;
@@ -1425,7 +1435,7 @@ function useScrollToBottom(messages) {
1425
1435
  mutationObserver.disconnect();
1426
1436
  };
1427
1437
  }, []);
1428
- (0, import_react5.useEffect)(() => {
1438
+ (0, import_react6.useEffect)(() => {
1429
1439
  isUserScrollUpRef.current = false;
1430
1440
  scrollToBottom();
1431
1441
  }, [messages.filter((m) => m.role === "user").length]);
@@ -1433,12 +1443,12 @@ function useScrollToBottom(messages) {
1433
1443
  }
1434
1444
 
1435
1445
  // src/components/chat/Input.tsx
1436
- var import_react9 = require("react");
1446
+ var import_react10 = require("react");
1437
1447
 
1438
1448
  // src/components/chat/Textarea.tsx
1439
- var import_react6 = require("react");
1449
+ var import_react7 = require("react");
1440
1450
  var import_jsx_runtime11 = require("react/jsx-runtime");
1441
- var AutoResizingTextarea = (0, import_react6.forwardRef)(
1451
+ var AutoResizingTextarea = (0, import_react7.forwardRef)(
1442
1452
  ({
1443
1453
  maxRows = 1,
1444
1454
  placeholder,
@@ -1449,10 +1459,10 @@ var AutoResizingTextarea = (0, import_react6.forwardRef)(
1449
1459
  onCompositionEnd,
1450
1460
  autoFocus
1451
1461
  }, ref) => {
1452
- const internalTextareaRef = (0, import_react6.useRef)(null);
1453
- const [maxHeight, setMaxHeight] = (0, import_react6.useState)(0);
1454
- (0, import_react6.useImperativeHandle)(ref, () => internalTextareaRef.current);
1455
- (0, import_react6.useEffect)(() => {
1462
+ const internalTextareaRef = (0, import_react7.useRef)(null);
1463
+ const [maxHeight, setMaxHeight] = (0, import_react7.useState)(0);
1464
+ (0, import_react7.useImperativeHandle)(ref, () => internalTextareaRef.current);
1465
+ (0, import_react7.useEffect)(() => {
1456
1466
  const calculateMaxHeight = () => {
1457
1467
  const textarea = internalTextareaRef.current;
1458
1468
  if (textarea) {
@@ -1466,7 +1476,7 @@ var AutoResizingTextarea = (0, import_react6.forwardRef)(
1466
1476
  };
1467
1477
  calculateMaxHeight();
1468
1478
  }, [maxRows]);
1469
- (0, import_react6.useEffect)(() => {
1479
+ (0, import_react7.useEffect)(() => {
1470
1480
  const textarea = internalTextareaRef.current;
1471
1481
  if (textarea) {
1472
1482
  textarea.style.height = "auto";
@@ -1498,7 +1508,7 @@ var Textarea_default = AutoResizingTextarea;
1498
1508
  // src/hooks/use-push-to-talk.tsx
1499
1509
  var import_react_core2 = require("@copilotkit/react-core");
1500
1510
  var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
1501
- var import_react7 = require("react");
1511
+ var import_react8 = require("react");
1502
1512
  var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
1503
1513
  if (!mediaStreamRef.current || !audioContextRef.current) {
1504
1514
  mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
@@ -1547,16 +1557,16 @@ var usePushToTalk = ({
1547
1557
  sendFunction,
1548
1558
  inProgress
1549
1559
  }) => {
1550
- const [pushToTalkState, setPushToTalkState] = (0, import_react7.useState)("idle");
1551
- const mediaStreamRef = (0, import_react7.useRef)(null);
1552
- const audioContextRef = (0, import_react7.useRef)(null);
1553
- const mediaRecorderRef = (0, import_react7.useRef)(null);
1554
- const recordedChunks = (0, import_react7.useRef)([]);
1560
+ const [pushToTalkState, setPushToTalkState] = (0, import_react8.useState)("idle");
1561
+ const mediaStreamRef = (0, import_react8.useRef)(null);
1562
+ const audioContextRef = (0, import_react8.useRef)(null);
1563
+ const mediaRecorderRef = (0, import_react8.useRef)(null);
1564
+ const recordedChunks = (0, import_react8.useRef)([]);
1555
1565
  const generalContext = (0, import_react_core2.useCopilotContext)();
1556
1566
  const messagesContext = (0, import_react_core2.useCopilotMessagesContext)();
1557
1567
  const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
1558
- const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react7.useState)(null);
1559
- (0, import_react7.useEffect)(() => {
1568
+ const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react8.useState)(null);
1569
+ (0, import_react8.useEffect)(() => {
1560
1570
  if (pushToTalkState === "recording") {
1561
1571
  startRecording(
1562
1572
  mediaStreamRef,
@@ -1584,7 +1594,7 @@ var usePushToTalk = ({
1584
1594
  stopRecording(mediaRecorderRef);
1585
1595
  };
1586
1596
  }, [pushToTalkState]);
1587
- (0, import_react7.useEffect)(() => {
1597
+ (0, import_react8.useEffect)(() => {
1588
1598
  if (inProgress === false && startReadingFromMessageId) {
1589
1599
  const lastMessageIndex = context.messages.findIndex(
1590
1600
  (message) => message.id === startReadingFromMessageId
@@ -1603,7 +1613,7 @@ var usePushToTalk = ({
1603
1613
  var import_react_core3 = require("@copilotkit/react-core");
1604
1614
 
1605
1615
  // src/components/chat/PoweredByTag.tsx
1606
- var import_react8 = require("react");
1616
+ var import_react9 = require("react");
1607
1617
 
1608
1618
  // src/hooks/use-dark-mode.ts
1609
1619
  var useDarkMode = () => {
@@ -1615,9 +1625,9 @@ var useDarkMode = () => {
1615
1625
  // src/components/chat/PoweredByTag.tsx
1616
1626
  var import_jsx_runtime12 = require("react/jsx-runtime");
1617
1627
  function PoweredByTag({ showPoweredBy = true }) {
1618
- const [mounted, setMounted] = (0, import_react8.useState)(false);
1628
+ const [mounted, setMounted] = (0, import_react9.useState)(false);
1619
1629
  const isDark = useDarkMode();
1620
- (0, import_react8.useEffect)(() => {
1630
+ (0, import_react9.useEffect)(() => {
1621
1631
  setMounted(true);
1622
1632
  }, []);
1623
1633
  if (!showPoweredBy) {
@@ -1651,8 +1661,8 @@ var Input = ({
1651
1661
  const copilotContext = (0, import_react_core3.useCopilotContext)();
1652
1662
  const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
1653
1663
  const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
1654
- const textareaRef = (0, import_react9.useRef)(null);
1655
- const [isComposing, setIsComposing] = (0, import_react9.useState)(false);
1664
+ const textareaRef = (0, import_react10.useRef)(null);
1665
+ const [isComposing, setIsComposing] = (0, import_react10.useState)(false);
1656
1666
  const handleDivClick = (event) => {
1657
1667
  var _a2;
1658
1668
  const target = event.target;
@@ -1662,7 +1672,7 @@ var Input = ({
1662
1672
  return;
1663
1673
  (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
1664
1674
  };
1665
- const [text, setText] = (0, import_react9.useState)("");
1675
+ const [text, setText] = (0, import_react10.useState)("");
1666
1676
  const send = () => {
1667
1677
  var _a2;
1668
1678
  if (inProgress)
@@ -1676,17 +1686,17 @@ var Input = ({
1676
1686
  inProgress
1677
1687
  });
1678
1688
  const isInProgress = inProgress || pushToTalkState === "transcribing";
1679
- const { buttonIcon, buttonAlt } = (0, import_react9.useMemo)(() => {
1689
+ const { buttonIcon, buttonAlt } = (0, import_react10.useMemo)(() => {
1680
1690
  if (!chatReady)
1681
1691
  return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
1682
1692
  return isInProgress && !hideStopButton && chatReady ? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" } : { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
1683
1693
  }, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
1684
1694
  const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
1685
1695
  const { interrupt } = (0, import_react_core3.useCopilotChatInternal)();
1686
- const canSend = (0, import_react9.useMemo)(() => {
1696
+ const canSend = (0, import_react10.useMemo)(() => {
1687
1697
  return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
1688
1698
  }, [interrupt, isInProgress, text, pushToTalkState]);
1689
- const canStop = (0, import_react9.useMemo)(() => {
1699
+ const canStop = (0, import_react10.useMemo)(() => {
1690
1700
  return isInProgress && !hideStopButton;
1691
1701
  }, [isInProgress, hideStopButton]);
1692
1702
  const sendDisabled = !canSend && !canStop;
@@ -1743,7 +1753,7 @@ var Input = ({
1743
1753
  };
1744
1754
 
1745
1755
  // src/components/chat/Chat.tsx
1746
- var import_react10 = __toESM(require("react"));
1756
+ var import_react11 = __toESM(require("react"));
1747
1757
  var import_react_core5 = require("@copilotkit/react-core");
1748
1758
  var import_shared = require("@copilotkit/shared");
1749
1759
 
@@ -1920,13 +1930,13 @@ function CopilotChat({
1920
1930
  removeInternalErrorHandler
1921
1931
  } = (0, import_react_core5.useCopilotContext)();
1922
1932
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
1923
- const [selectedImages, setSelectedImages] = (0, import_react10.useState)([]);
1924
- const [chatError, setChatError] = (0, import_react10.useState)(null);
1925
- const [messageFeedback, setMessageFeedback] = (0, import_react10.useState)(
1933
+ const [selectedImages, setSelectedImages] = (0, import_react11.useState)([]);
1934
+ const [chatError, setChatError] = (0, import_react11.useState)(null);
1935
+ const [messageFeedback, setMessageFeedback] = (0, import_react11.useState)(
1926
1936
  {}
1927
1937
  );
1928
- const fileInputRef = (0, import_react10.useRef)(null);
1929
- const triggerObservabilityHook = (0, import_react10.useCallback)(
1938
+ const fileInputRef = (0, import_react11.useRef)(null);
1939
+ const triggerObservabilityHook = (0, import_react11.useCallback)(
1930
1940
  (hookName, ...args) => {
1931
1941
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
1932
1942
  observabilityHooks[hookName](...args);
@@ -1945,7 +1955,7 @@ function CopilotChat({
1945
1955
  },
1946
1956
  [publicApiKey, observabilityHooks, setBannerError]
1947
1957
  );
1948
- const triggerChatError = (0, import_react10.useCallback)(
1958
+ const triggerChatError = (0, import_react11.useCallback)(
1949
1959
  (error, operation, originalError) => {
1950
1960
  const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
1951
1961
  setChatError({
@@ -1991,7 +2001,7 @@ function CopilotChat({
1991
2001
  },
1992
2002
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
1993
2003
  );
1994
- (0, import_react10.useEffect)(() => {
2004
+ (0, import_react11.useEffect)(() => {
1995
2005
  const id = "chat-component";
1996
2006
  setInternalErrorHandler({
1997
2007
  [id]: (error) => {
@@ -2004,7 +2014,7 @@ function CopilotChat({
2004
2014
  removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2005
2015
  };
2006
2016
  }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2007
- (0, import_react10.useEffect)(() => {
2017
+ (0, import_react11.useEffect)(() => {
2008
2018
  if (!imageUploadsEnabled)
2009
2019
  return;
2010
2020
  const handlePaste = (e) => __async(this, null, function* () {
@@ -2050,7 +2060,7 @@ function CopilotChat({
2050
2060
  document.addEventListener("paste", handlePaste);
2051
2061
  return () => document.removeEventListener("paste", handlePaste);
2052
2062
  }, [imageUploadsEnabled, triggerChatError]);
2053
- (0, import_react10.useEffect)(() => {
2063
+ (0, import_react11.useEffect)(() => {
2054
2064
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2055
2065
  setChatInstructions(instructions || "");
2056
2066
  return;
@@ -2078,8 +2088,8 @@ function CopilotChat({
2078
2088
  onStopGeneration,
2079
2089
  onReloadMessages
2080
2090
  });
2081
- const prevIsLoading = (0, import_react10.useRef)(isLoading);
2082
- (0, import_react10.useEffect)(() => {
2091
+ const prevIsLoading = (0, import_react11.useRef)(isLoading);
2092
+ (0, import_react11.useEffect)(() => {
2083
2093
  if (prevIsLoading.current !== isLoading) {
2084
2094
  if (isLoading) {
2085
2095
  triggerObservabilityHook("onChatStarted");
@@ -2102,7 +2112,7 @@ function CopilotChat({
2102
2112
  role: "user"
2103
2113
  });
2104
2114
  };
2105
- const chatContext = import_react10.default.useContext(ChatContext);
2115
+ const chatContext = import_react11.default.useContext(ChatContext);
2106
2116
  const isVisible = chatContext ? chatContext.open : true;
2107
2117
  const handleRegenerate = (messageId) => {
2108
2118
  if (onRegenerate) {
@@ -2246,7 +2256,7 @@ function WrappedCopilotChat({
2246
2256
  labels,
2247
2257
  className
2248
2258
  }) {
2249
- const chatContext = import_react10.default.useContext(ChatContext);
2259
+ const chatContext = import_react11.default.useContext(ChatContext);
2250
2260
  if (!chatContext) {
2251
2261
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2252
2262
  }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });