@copilotkit/react-ui 1.51.2-next.1 → 1.51.3-next.0
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.
- package/CHANGELOG.md +20 -0
- package/dist/{chunk-DI7DDMRS.mjs → chunk-4S4ZEKE6.mjs} +2 -2
- package/dist/{chunk-BVKKSSB2.mjs → chunk-HKZL4P3F.mjs} +4 -4
- package/dist/{chunk-VVCCMYGT.mjs → chunk-O4PPO3K3.mjs} +2 -2
- package/dist/{chunk-7OURDQZJ.mjs → chunk-PKSW6ZMQ.mjs} +2 -2
- package/dist/{chunk-IHFR6PYG.mjs → chunk-SLM2AOHF.mjs} +2 -2
- package/dist/{chunk-HIW7RXCD.mjs → chunk-UH5GQ7QF.mjs} +2 -2
- package/dist/{chunk-NCIAFFQ2.mjs → chunk-XEZ5ODJS.mjs} +2 -2
- package/dist/{chunk-JZ3RFQQ6.mjs → chunk-XOBQLKUU.mjs} +3 -13
- package/dist/chunk-XOBQLKUU.mjs.map +1 -0
- package/dist/{chunk-NSJWSIPR.mjs → chunk-YQOESY4Y.mjs} +4 -4
- package/dist/components/chat/Chat.js +57 -67
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +6 -6
- package/dist/components/chat/Markdown.d.ts +4 -2
- package/dist/components/chat/Markdown.js +2 -12
- package/dist/components/chat/Markdown.js.map +1 -1
- package/dist/components/chat/Markdown.mjs +1 -1
- package/dist/components/chat/Messages.js +17 -27
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +5 -5
- package/dist/components/chat/Modal.js +64 -74
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +7 -7
- package/dist/components/chat/Popup.js +64 -74
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +8 -8
- package/dist/components/chat/Sidebar.js +66 -76
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +8 -8
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/chat/index.js +66 -76
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +9 -9
- package/dist/components/chat/messages/AssistantMessage.js +4 -14
- package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
- package/dist/components/chat/messages/AssistantMessage.mjs +2 -2
- package/dist/components/chat/messages/ErrorMessage.js +4 -14
- package/dist/components/chat/messages/ErrorMessage.js.map +1 -1
- package/dist/components/chat/messages/ErrorMessage.mjs +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.js +6 -16
- package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.mjs +4 -4
- package/dist/components/chat/messages/RenderMessage.js +6 -16
- package/dist/components/chat/messages/RenderMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderMessage.mjs +3 -3
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +66 -76
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +9 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +66 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -9
- package/package.json +5 -8
- package/src/components/chat/Markdown.tsx +8 -17
- package/dist/chunk-JZ3RFQQ6.mjs.map +0 -1
- /package/dist/{chunk-DI7DDMRS.mjs.map → chunk-4S4ZEKE6.mjs.map} +0 -0
- /package/dist/{chunk-BVKKSSB2.mjs.map → chunk-HKZL4P3F.mjs.map} +0 -0
- /package/dist/{chunk-VVCCMYGT.mjs.map → chunk-O4PPO3K3.mjs.map} +0 -0
- /package/dist/{chunk-7OURDQZJ.mjs.map → chunk-PKSW6ZMQ.mjs.map} +0 -0
- /package/dist/{chunk-IHFR6PYG.mjs.map → chunk-SLM2AOHF.mjs.map} +0 -0
- /package/dist/{chunk-HIW7RXCD.mjs.map → chunk-UH5GQ7QF.mjs.map} +0 -0
- /package/dist/{chunk-NCIAFFQ2.mjs.map → chunk-XEZ5ODJS.mjs.map} +0 -0
- /package/dist/{chunk-NSJWSIPR.mjs.map → chunk-YQOESY4Y.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 1.51.3-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @copilotkit/runtime-client-gql@1.51.3-next.0
|
|
8
|
+
- @copilotkit/react-core@1.51.3-next.0
|
|
9
|
+
- @copilotkit/shared@1.51.3-next.0
|
|
10
|
+
|
|
11
|
+
## 1.51.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- e59d23f: Use deps instead of peerdeps
|
|
16
|
+
- e59d23f: Move in-repo deps from peerdeps to actual deps
|
|
17
|
+
- Updated dependencies [e59d23f]
|
|
18
|
+
- Updated dependencies [e59d23f]
|
|
19
|
+
- @copilotkit/runtime-client-gql@1.51.2
|
|
20
|
+
- @copilotkit/react-core@1.51.2
|
|
21
|
+
- @copilotkit/shared@1.51.2
|
|
22
|
+
|
|
3
23
|
## 1.51.2-next.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HKZL4P3F.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-
|
|
30
|
+
//# sourceMappingURL=chunk-4S4ZEKE6.mjs.map
|
|
@@ -9,16 +9,16 @@ import {
|
|
|
9
9
|
} from "./chunk-UFN2VWSR.mjs";
|
|
10
10
|
import {
|
|
11
11
|
CopilotChat
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-YQOESY4Y.mjs";
|
|
13
13
|
import {
|
|
14
14
|
Input
|
|
15
15
|
} from "./chunk-3W6J75HS.mjs";
|
|
16
16
|
import {
|
|
17
17
|
Messages
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-UH5GQ7QF.mjs";
|
|
19
19
|
import {
|
|
20
20
|
AssistantMessage
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-SLM2AOHF.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-
|
|
222
|
+
//# sourceMappingURL=chunk-HKZL4P3F.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HKZL4P3F.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-
|
|
21
|
+
//# sourceMappingURL=chunk-O4PPO3K3.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RenderMessage
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XEZ5ODJS.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-
|
|
133
|
+
//# sourceMappingURL=chunk-PKSW6ZMQ.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Markdown
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XOBQLKUU.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-
|
|
116
|
+
//# sourceMappingURL=chunk-SLM2AOHF.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LegacyRenderMessage
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PKSW6ZMQ.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-
|
|
184
|
+
//# sourceMappingURL=chunk-UH5GQ7QF.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AssistantMessage
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SLM2AOHF.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-
|
|
82
|
+
//# sourceMappingURL=chunk-XEZ5ODJS.mjs.map
|
|
@@ -8,11 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-MRXNTQOX.mjs";
|
|
9
9
|
|
|
10
10
|
// src/components/chat/Markdown.tsx
|
|
11
|
-
import {
|
|
12
|
-
import ReactMarkdown from "react-markdown";
|
|
13
|
-
import remarkGfm from "remark-gfm";
|
|
14
|
-
import remarkMath from "remark-math";
|
|
15
|
-
import rehypeRaw from "rehype-raw";
|
|
11
|
+
import { Streamdown } from "streamdown";
|
|
16
12
|
import { jsx } from "react/jsx-runtime";
|
|
17
13
|
var defaultComponents = {
|
|
18
14
|
a(_a) {
|
|
@@ -106,17 +102,11 @@ var defaultComponents = {
|
|
|
106
102
|
return /* @__PURE__ */ jsx("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
107
103
|
}
|
|
108
104
|
};
|
|
109
|
-
var MemoizedReactMarkdown = memo(
|
|
110
|
-
ReactMarkdown,
|
|
111
|
-
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
|
|
112
|
-
);
|
|
113
105
|
var Markdown = ({ content, components }) => {
|
|
114
106
|
return /* @__PURE__ */ jsx("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ jsx(
|
|
115
|
-
|
|
107
|
+
Streamdown,
|
|
116
108
|
{
|
|
117
109
|
components: __spreadValues(__spreadValues({}, defaultComponents), components),
|
|
118
|
-
remarkPlugins: [remarkGfm, [remarkMath, { singleDollarTextMath: false }]],
|
|
119
|
-
rehypePlugins: [rehypeRaw],
|
|
120
110
|
children: content
|
|
121
111
|
}
|
|
122
112
|
) });
|
|
@@ -125,4 +115,4 @@ var Markdown = ({ content, components }) => {
|
|
|
125
115
|
export {
|
|
126
116
|
Markdown
|
|
127
117
|
};
|
|
128
|
-
//# sourceMappingURL=chunk-
|
|
118
|
+
//# sourceMappingURL=chunk-XOBQLKUU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Markdown.tsx"],"sourcesContent":["import { ComponentProps, FC, memo } from \"react\";\nimport { Streamdown } from \"streamdown\";\nimport { CodeBlock } from \"./CodeBlock\";\n\ntype Options = ComponentProps<typeof Streamdown>;\n\nconst defaultComponents: Options[\"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\ntype MarkdownProps = {\n content: string;\n components?: Options[\"components\"];\n};\n\nexport const Markdown = ({ content, components }: MarkdownProps) => {\n return (\n <div className=\"copilotKitMarkdown\">\n <Streamdown\n components={{ ...defaultComponents, ...components }}\n >\n {content}\n </Streamdown>\n </div>\n );\n};\n"],"mappings":"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","names":[]}
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
} from "./chunk-3W6J75HS.mjs";
|
|
10
10
|
import {
|
|
11
11
|
Messages
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-UH5GQ7QF.mjs";
|
|
13
13
|
import {
|
|
14
14
|
RenderMessage
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-XEZ5ODJS.mjs";
|
|
16
16
|
import {
|
|
17
17
|
AssistantMessage
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-SLM2AOHF.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-
|
|
435
|
+
//# sourceMappingURL=chunk-YQOESY4Y.mjs.map
|
|
@@ -394,7 +394,7 @@ var ChatContextProvider = ({
|
|
|
394
394
|
};
|
|
395
395
|
|
|
396
396
|
// src/components/chat/Messages.tsx
|
|
397
|
-
var
|
|
397
|
+
var import_react5 = require("react");
|
|
398
398
|
var import_react_core = require("@copilotkit/react-core");
|
|
399
399
|
|
|
400
400
|
// src/components/chat/messages/UserMessage.tsx
|
|
@@ -426,8 +426,7 @@ var UserMessage = (props) => {
|
|
|
426
426
|
};
|
|
427
427
|
|
|
428
428
|
// src/components/chat/Markdown.tsx
|
|
429
|
-
var
|
|
430
|
-
var import_react_markdown = __toESM(require("react-markdown"));
|
|
429
|
+
var import_streamdown = require("streamdown");
|
|
431
430
|
|
|
432
431
|
// src/components/chat/CodeBlock.tsx
|
|
433
432
|
var import_react2 = require("react");
|
|
@@ -839,9 +838,6 @@ var highlightStyle = {
|
|
|
839
838
|
};
|
|
840
839
|
|
|
841
840
|
// 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"));
|
|
845
841
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
846
842
|
var defaultComponents = {
|
|
847
843
|
a(_a) {
|
|
@@ -935,24 +931,18 @@ var defaultComponents = {
|
|
|
935
931
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
936
932
|
}
|
|
937
933
|
};
|
|
938
|
-
var MemoizedReactMarkdown = (0, import_react3.memo)(
|
|
939
|
-
import_react_markdown.default,
|
|
940
|
-
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
|
|
941
|
-
);
|
|
942
934
|
var Markdown = ({ content, components }) => {
|
|
943
935
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
944
|
-
|
|
936
|
+
import_streamdown.Streamdown,
|
|
945
937
|
{
|
|
946
938
|
components: __spreadValues(__spreadValues({}, defaultComponents), components),
|
|
947
|
-
remarkPlugins: [import_remark_gfm.default, [import_remark_math.default, { singleDollarTextMath: false }]],
|
|
948
|
-
rehypePlugins: [import_rehype_raw.default],
|
|
949
939
|
children: content
|
|
950
940
|
}
|
|
951
941
|
) });
|
|
952
942
|
};
|
|
953
943
|
|
|
954
944
|
// src/components/chat/messages/AssistantMessage.tsx
|
|
955
|
-
var
|
|
945
|
+
var import_react3 = require("react");
|
|
956
946
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
957
947
|
var AssistantMessage = (props) => {
|
|
958
948
|
var _a;
|
|
@@ -968,7 +958,7 @@ var AssistantMessage = (props) => {
|
|
|
968
958
|
feedback,
|
|
969
959
|
markdownTagRenderers
|
|
970
960
|
} = props;
|
|
971
|
-
const [copied, setCopied] = (0,
|
|
961
|
+
const [copied, setCopied] = (0, import_react3.useState)(false);
|
|
972
962
|
const handleCopy = () => {
|
|
973
963
|
const content2 = (message == null ? void 0 : message.content) || "";
|
|
974
964
|
if (content2 && onCopy) {
|
|
@@ -1057,10 +1047,10 @@ var AssistantMessage = (props) => {
|
|
|
1057
1047
|
};
|
|
1058
1048
|
|
|
1059
1049
|
// src/components/chat/messages/ImageRenderer.tsx
|
|
1060
|
-
var
|
|
1050
|
+
var import_react4 = require("react");
|
|
1061
1051
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1062
1052
|
var ImageRenderer = ({ image, content, className = "" }) => {
|
|
1063
|
-
const [imageError, setImageError] = (0,
|
|
1053
|
+
const [imageError, setImageError] = (0, import_react4.useState)(false);
|
|
1064
1054
|
const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
|
|
1065
1055
|
const altText = content || "User uploaded image";
|
|
1066
1056
|
const handleImageError = () => {
|
|
@@ -1303,18 +1293,18 @@ var Messages = ({
|
|
|
1303
1293
|
var _a;
|
|
1304
1294
|
const { labels, icons } = useChatContext();
|
|
1305
1295
|
const { messages: visibleMessages, interrupt } = (0, import_react_core.useCopilotChatInternal)();
|
|
1306
|
-
const initialMessages = (0,
|
|
1296
|
+
const initialMessages = (0, import_react5.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
|
|
1307
1297
|
const messages = [...initialMessages, ...visibleMessages];
|
|
1308
1298
|
const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
|
|
1309
1299
|
const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
|
|
1310
|
-
(0,
|
|
1300
|
+
(0, import_react5.useEffect)(() => {
|
|
1311
1301
|
if (hasLegacyProps) {
|
|
1312
1302
|
console.warn(
|
|
1313
1303
|
"[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"
|
|
1314
1304
|
);
|
|
1315
1305
|
}
|
|
1316
1306
|
}, [hasLegacyProps]);
|
|
1317
|
-
const legacyProps = (0,
|
|
1307
|
+
const legacyProps = (0, import_react5.useMemo)(
|
|
1318
1308
|
() => ({
|
|
1319
1309
|
RenderTextMessage,
|
|
1320
1310
|
RenderActionExecutionMessage,
|
|
@@ -1385,10 +1375,10 @@ function makeInitialMessages(initial) {
|
|
|
1385
1375
|
];
|
|
1386
1376
|
}
|
|
1387
1377
|
function useScrollToBottom(messages) {
|
|
1388
|
-
const messagesEndRef = (0,
|
|
1389
|
-
const messagesContainerRef = (0,
|
|
1390
|
-
const isProgrammaticScrollRef = (0,
|
|
1391
|
-
const isUserScrollUpRef = (0,
|
|
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);
|
|
1392
1382
|
const scrollToBottom = () => {
|
|
1393
1383
|
if (messagesContainerRef.current && messagesEndRef.current) {
|
|
1394
1384
|
isProgrammaticScrollRef.current = true;
|
|
@@ -1405,7 +1395,7 @@ function useScrollToBottom(messages) {
|
|
|
1405
1395
|
isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
|
|
1406
1396
|
}
|
|
1407
1397
|
};
|
|
1408
|
-
(0,
|
|
1398
|
+
(0, import_react5.useEffect)(() => {
|
|
1409
1399
|
const container = messagesContainerRef.current;
|
|
1410
1400
|
if (container) {
|
|
1411
1401
|
container.addEventListener("scroll", handleScroll);
|
|
@@ -1416,7 +1406,7 @@ function useScrollToBottom(messages) {
|
|
|
1416
1406
|
}
|
|
1417
1407
|
};
|
|
1418
1408
|
}, []);
|
|
1419
|
-
(0,
|
|
1409
|
+
(0, import_react5.useEffect)(() => {
|
|
1420
1410
|
const container = messagesContainerRef.current;
|
|
1421
1411
|
if (!container) {
|
|
1422
1412
|
return;
|
|
@@ -1435,7 +1425,7 @@ function useScrollToBottom(messages) {
|
|
|
1435
1425
|
mutationObserver.disconnect();
|
|
1436
1426
|
};
|
|
1437
1427
|
}, []);
|
|
1438
|
-
(0,
|
|
1428
|
+
(0, import_react5.useEffect)(() => {
|
|
1439
1429
|
isUserScrollUpRef.current = false;
|
|
1440
1430
|
scrollToBottom();
|
|
1441
1431
|
}, [messages.filter((m) => m.role === "user").length]);
|
|
@@ -1443,12 +1433,12 @@ function useScrollToBottom(messages) {
|
|
|
1443
1433
|
}
|
|
1444
1434
|
|
|
1445
1435
|
// src/components/chat/Input.tsx
|
|
1446
|
-
var
|
|
1436
|
+
var import_react9 = require("react");
|
|
1447
1437
|
|
|
1448
1438
|
// src/components/chat/Textarea.tsx
|
|
1449
|
-
var
|
|
1439
|
+
var import_react6 = require("react");
|
|
1450
1440
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1451
|
-
var AutoResizingTextarea = (0,
|
|
1441
|
+
var AutoResizingTextarea = (0, import_react6.forwardRef)(
|
|
1452
1442
|
({
|
|
1453
1443
|
maxRows = 1,
|
|
1454
1444
|
placeholder,
|
|
@@ -1459,10 +1449,10 @@ var AutoResizingTextarea = (0, import_react7.forwardRef)(
|
|
|
1459
1449
|
onCompositionEnd,
|
|
1460
1450
|
autoFocus
|
|
1461
1451
|
}, ref) => {
|
|
1462
|
-
const internalTextareaRef = (0,
|
|
1463
|
-
const [maxHeight, setMaxHeight] = (0,
|
|
1464
|
-
(0,
|
|
1465
|
-
(0,
|
|
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)(() => {
|
|
1466
1456
|
const calculateMaxHeight = () => {
|
|
1467
1457
|
const textarea = internalTextareaRef.current;
|
|
1468
1458
|
if (textarea) {
|
|
@@ -1476,7 +1466,7 @@ var AutoResizingTextarea = (0, import_react7.forwardRef)(
|
|
|
1476
1466
|
};
|
|
1477
1467
|
calculateMaxHeight();
|
|
1478
1468
|
}, [maxRows]);
|
|
1479
|
-
(0,
|
|
1469
|
+
(0, import_react6.useEffect)(() => {
|
|
1480
1470
|
const textarea = internalTextareaRef.current;
|
|
1481
1471
|
if (textarea) {
|
|
1482
1472
|
textarea.style.height = "auto";
|
|
@@ -1508,7 +1498,7 @@ var Textarea_default = AutoResizingTextarea;
|
|
|
1508
1498
|
// src/hooks/use-push-to-talk.tsx
|
|
1509
1499
|
var import_react_core2 = require("@copilotkit/react-core");
|
|
1510
1500
|
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
1511
|
-
var
|
|
1501
|
+
var import_react7 = require("react");
|
|
1512
1502
|
var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
|
|
1513
1503
|
if (!mediaStreamRef.current || !audioContextRef.current) {
|
|
1514
1504
|
mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
|
|
@@ -1557,16 +1547,16 @@ var usePushToTalk = ({
|
|
|
1557
1547
|
sendFunction,
|
|
1558
1548
|
inProgress
|
|
1559
1549
|
}) => {
|
|
1560
|
-
const [pushToTalkState, setPushToTalkState] = (0,
|
|
1561
|
-
const mediaStreamRef = (0,
|
|
1562
|
-
const audioContextRef = (0,
|
|
1563
|
-
const mediaRecorderRef = (0,
|
|
1564
|
-
const recordedChunks = (0,
|
|
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)([]);
|
|
1565
1555
|
const generalContext = (0, import_react_core2.useCopilotContext)();
|
|
1566
1556
|
const messagesContext = (0, import_react_core2.useCopilotMessagesContext)();
|
|
1567
1557
|
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
1568
|
-
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0,
|
|
1569
|
-
(0,
|
|
1558
|
+
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react7.useState)(null);
|
|
1559
|
+
(0, import_react7.useEffect)(() => {
|
|
1570
1560
|
if (pushToTalkState === "recording") {
|
|
1571
1561
|
startRecording(
|
|
1572
1562
|
mediaStreamRef,
|
|
@@ -1594,7 +1584,7 @@ var usePushToTalk = ({
|
|
|
1594
1584
|
stopRecording(mediaRecorderRef);
|
|
1595
1585
|
};
|
|
1596
1586
|
}, [pushToTalkState]);
|
|
1597
|
-
(0,
|
|
1587
|
+
(0, import_react7.useEffect)(() => {
|
|
1598
1588
|
if (inProgress === false && startReadingFromMessageId) {
|
|
1599
1589
|
const lastMessageIndex = context.messages.findIndex(
|
|
1600
1590
|
(message) => message.id === startReadingFromMessageId
|
|
@@ -1613,7 +1603,7 @@ var usePushToTalk = ({
|
|
|
1613
1603
|
var import_react_core3 = require("@copilotkit/react-core");
|
|
1614
1604
|
|
|
1615
1605
|
// src/components/chat/PoweredByTag.tsx
|
|
1616
|
-
var
|
|
1606
|
+
var import_react8 = require("react");
|
|
1617
1607
|
|
|
1618
1608
|
// src/hooks/use-dark-mode.ts
|
|
1619
1609
|
var useDarkMode = () => {
|
|
@@ -1625,9 +1615,9 @@ var useDarkMode = () => {
|
|
|
1625
1615
|
// src/components/chat/PoweredByTag.tsx
|
|
1626
1616
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1627
1617
|
function PoweredByTag({ showPoweredBy = true }) {
|
|
1628
|
-
const [mounted, setMounted] = (0,
|
|
1618
|
+
const [mounted, setMounted] = (0, import_react8.useState)(false);
|
|
1629
1619
|
const isDark = useDarkMode();
|
|
1630
|
-
(0,
|
|
1620
|
+
(0, import_react8.useEffect)(() => {
|
|
1631
1621
|
setMounted(true);
|
|
1632
1622
|
}, []);
|
|
1633
1623
|
if (!showPoweredBy) {
|
|
@@ -1661,8 +1651,8 @@ var Input = ({
|
|
|
1661
1651
|
const copilotContext = (0, import_react_core3.useCopilotContext)();
|
|
1662
1652
|
const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
|
|
1663
1653
|
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
1664
|
-
const textareaRef = (0,
|
|
1665
|
-
const [isComposing, setIsComposing] = (0,
|
|
1654
|
+
const textareaRef = (0, import_react9.useRef)(null);
|
|
1655
|
+
const [isComposing, setIsComposing] = (0, import_react9.useState)(false);
|
|
1666
1656
|
const handleDivClick = (event) => {
|
|
1667
1657
|
var _a2;
|
|
1668
1658
|
const target = event.target;
|
|
@@ -1672,7 +1662,7 @@ var Input = ({
|
|
|
1672
1662
|
return;
|
|
1673
1663
|
(_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
|
|
1674
1664
|
};
|
|
1675
|
-
const [text, setText] = (0,
|
|
1665
|
+
const [text, setText] = (0, import_react9.useState)("");
|
|
1676
1666
|
const send = () => {
|
|
1677
1667
|
var _a2;
|
|
1678
1668
|
if (inProgress)
|
|
@@ -1686,17 +1676,17 @@ var Input = ({
|
|
|
1686
1676
|
inProgress
|
|
1687
1677
|
});
|
|
1688
1678
|
const isInProgress = inProgress || pushToTalkState === "transcribing";
|
|
1689
|
-
const { buttonIcon, buttonAlt } = (0,
|
|
1679
|
+
const { buttonIcon, buttonAlt } = (0, import_react9.useMemo)(() => {
|
|
1690
1680
|
if (!chatReady)
|
|
1691
1681
|
return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
|
|
1692
1682
|
return isInProgress && !hideStopButton && chatReady ? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" } : { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
|
|
1693
1683
|
}, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
|
|
1694
1684
|
const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
|
|
1695
1685
|
const { interrupt } = (0, import_react_core3.useCopilotChatInternal)();
|
|
1696
|
-
const canSend = (0,
|
|
1686
|
+
const canSend = (0, import_react9.useMemo)(() => {
|
|
1697
1687
|
return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
|
|
1698
1688
|
}, [interrupt, isInProgress, text, pushToTalkState]);
|
|
1699
|
-
const canStop = (0,
|
|
1689
|
+
const canStop = (0, import_react9.useMemo)(() => {
|
|
1700
1690
|
return isInProgress && !hideStopButton;
|
|
1701
1691
|
}, [isInProgress, hideStopButton]);
|
|
1702
1692
|
const sendDisabled = !canSend && !canStop;
|
|
@@ -1753,7 +1743,7 @@ var Input = ({
|
|
|
1753
1743
|
};
|
|
1754
1744
|
|
|
1755
1745
|
// src/components/chat/Chat.tsx
|
|
1756
|
-
var
|
|
1746
|
+
var import_react10 = __toESM(require("react"));
|
|
1757
1747
|
var import_react_core5 = require("@copilotkit/react-core");
|
|
1758
1748
|
var import_shared = require("@copilotkit/shared");
|
|
1759
1749
|
|
|
@@ -1930,13 +1920,13 @@ function CopilotChat({
|
|
|
1930
1920
|
removeInternalErrorHandler
|
|
1931
1921
|
} = (0, import_react_core5.useCopilotContext)();
|
|
1932
1922
|
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
1933
|
-
const [selectedImages, setSelectedImages] = (0,
|
|
1934
|
-
const [chatError, setChatError] = (0,
|
|
1935
|
-
const [messageFeedback, setMessageFeedback] = (0,
|
|
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)(
|
|
1936
1926
|
{}
|
|
1937
1927
|
);
|
|
1938
|
-
const fileInputRef = (0,
|
|
1939
|
-
const triggerObservabilityHook = (0,
|
|
1928
|
+
const fileInputRef = (0, import_react10.useRef)(null);
|
|
1929
|
+
const triggerObservabilityHook = (0, import_react10.useCallback)(
|
|
1940
1930
|
(hookName, ...args) => {
|
|
1941
1931
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
1942
1932
|
observabilityHooks[hookName](...args);
|
|
@@ -1955,7 +1945,7 @@ function CopilotChat({
|
|
|
1955
1945
|
},
|
|
1956
1946
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
1957
1947
|
);
|
|
1958
|
-
const triggerChatError = (0,
|
|
1948
|
+
const triggerChatError = (0, import_react10.useCallback)(
|
|
1959
1949
|
(error, operation, originalError) => {
|
|
1960
1950
|
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
1961
1951
|
setChatError({
|
|
@@ -2001,7 +1991,7 @@ function CopilotChat({
|
|
|
2001
1991
|
},
|
|
2002
1992
|
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2003
1993
|
);
|
|
2004
|
-
(0,
|
|
1994
|
+
(0, import_react10.useEffect)(() => {
|
|
2005
1995
|
const id = "chat-component";
|
|
2006
1996
|
setInternalErrorHandler({
|
|
2007
1997
|
[id]: (error) => {
|
|
@@ -2014,7 +2004,7 @@ function CopilotChat({
|
|
|
2014
2004
|
removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
|
|
2015
2005
|
};
|
|
2016
2006
|
}, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
|
|
2017
|
-
(0,
|
|
2007
|
+
(0, import_react10.useEffect)(() => {
|
|
2018
2008
|
if (!imageUploadsEnabled)
|
|
2019
2009
|
return;
|
|
2020
2010
|
const handlePaste = (e) => __async(this, null, function* () {
|
|
@@ -2060,7 +2050,7 @@ function CopilotChat({
|
|
|
2060
2050
|
document.addEventListener("paste", handlePaste);
|
|
2061
2051
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2062
2052
|
}, [imageUploadsEnabled, triggerChatError]);
|
|
2063
|
-
(0,
|
|
2053
|
+
(0, import_react10.useEffect)(() => {
|
|
2064
2054
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2065
2055
|
setChatInstructions(instructions || "");
|
|
2066
2056
|
return;
|
|
@@ -2088,8 +2078,8 @@ function CopilotChat({
|
|
|
2088
2078
|
onStopGeneration,
|
|
2089
2079
|
onReloadMessages
|
|
2090
2080
|
});
|
|
2091
|
-
const prevIsLoading = (0,
|
|
2092
|
-
(0,
|
|
2081
|
+
const prevIsLoading = (0, import_react10.useRef)(isLoading);
|
|
2082
|
+
(0, import_react10.useEffect)(() => {
|
|
2093
2083
|
if (prevIsLoading.current !== isLoading) {
|
|
2094
2084
|
if (isLoading) {
|
|
2095
2085
|
triggerObservabilityHook("onChatStarted");
|
|
@@ -2112,7 +2102,7 @@ function CopilotChat({
|
|
|
2112
2102
|
role: "user"
|
|
2113
2103
|
});
|
|
2114
2104
|
};
|
|
2115
|
-
const chatContext =
|
|
2105
|
+
const chatContext = import_react10.default.useContext(ChatContext);
|
|
2116
2106
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2117
2107
|
const handleRegenerate = (messageId) => {
|
|
2118
2108
|
if (onRegenerate) {
|
|
@@ -2256,7 +2246,7 @@ function WrappedCopilotChat({
|
|
|
2256
2246
|
labels,
|
|
2257
2247
|
className
|
|
2258
2248
|
}) {
|
|
2259
|
-
const chatContext =
|
|
2249
|
+
const chatContext = import_react10.default.useContext(ChatContext);
|
|
2260
2250
|
if (!chatContext) {
|
|
2261
2251
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2262
2252
|
}, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
|