@copilotkit/react-ui 0.15.0-alpha.8 → 0.15.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/.turbo/turbo-build.log +187 -207
- package/CHANGELOG.md +46 -0
- package/dist/chunk-3M4HWSE7.mjs +13 -7
- package/dist/chunk-3M4HWSE7.mjs.map +1 -1
- package/dist/chunk-47SYBLI2.mjs +5 -5
- package/dist/chunk-47SYBLI2.mjs.map +1 -1
- package/dist/chunk-5O2MCJZ2.mjs +8 -4
- package/dist/chunk-5O2MCJZ2.mjs.map +1 -1
- package/dist/chunk-7NSRDJ5C.mjs +0 -2
- package/dist/chunk-7NSRDJ5C.mjs.map +1 -1
- package/dist/chunk-7YXG7D47.mjs +20 -4
- package/dist/chunk-7YXG7D47.mjs.map +1 -1
- package/dist/chunk-CKJXXQ2W.mjs +13 -6
- package/dist/chunk-CKJXXQ2W.mjs.map +1 -1
- package/dist/chunk-DPRH4HX3.mjs +20 -10
- package/dist/chunk-DPRH4HX3.mjs.map +1 -1
- package/dist/chunk-GWGHQNRI.mjs +17 -9
- package/dist/chunk-GWGHQNRI.mjs.map +1 -1
- package/dist/chunk-H4VKQGVU.mjs +0 -2
- package/dist/chunk-H4VKQGVU.mjs.map +1 -1
- package/dist/chunk-IU3WTXLQ.mjs +0 -2
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -1
- package/dist/chunk-JD7BAH7U.mjs +0 -2
- package/dist/chunk-JD7BAH7U.mjs.map +1 -1
- package/dist/chunk-KBGIPFXA.mjs +12 -5
- package/dist/chunk-KBGIPFXA.mjs.map +1 -1
- package/dist/chunk-MRXNTQOX.mjs +6 -2
- package/dist/chunk-MRXNTQOX.mjs.map +1 -1
- package/dist/chunk-NNVWLSYK.mjs +32 -14
- package/dist/chunk-NNVWLSYK.mjs.map +1 -1
- package/dist/chunk-NYLOXKYT.mjs +12 -6
- package/dist/chunk-NYLOXKYT.mjs.map +1 -1
- package/dist/chunk-OF66AL5Z.mjs +22 -6
- package/dist/chunk-OF66AL5Z.mjs.map +1 -1
- package/dist/chunk-P4GBO6MW.mjs +0 -2
- package/dist/chunk-P4GBO6MW.mjs.map +1 -1
- package/dist/chunk-POVINPXX.mjs +4 -4
- package/dist/chunk-POVINPXX.mjs.map +1 -1
- package/dist/chunk-UWPFPWAW.mjs +8 -4
- package/dist/chunk-UWPFPWAW.mjs.map +1 -1
- package/dist/chunk-WB3YULQ4.mjs +0 -2
- package/dist/chunk-WB3YULQ4.mjs.map +1 -1
- package/dist/chunk-WM6BS77F.mjs +5 -5
- package/dist/chunk-WM6BS77F.mjs.map +1 -1
- package/dist/chunk-Z34F3WLK.mjs +8 -4
- package/dist/chunk-Z34F3WLK.mjs.map +1 -1
- package/dist/components/chat/Button.js +48 -15
- package/dist/components/chat/Button.js.map +1 -1
- package/dist/components/chat/Button.mjs +9 -5
- package/dist/components/chat/Button.mjs.map +1 -1
- package/dist/components/chat/Chat.js +204 -138
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +19 -15
- package/dist/components/chat/Chat.mjs.map +1 -1
- package/dist/components/chat/ChatContext.js +71 -37
- package/dist/components/chat/ChatContext.js.map +1 -1
- package/dist/components/chat/ChatContext.mjs +12 -4
- package/dist/components/chat/ChatContext.mjs.map +1 -1
- package/dist/components/chat/CodeBlock.js +75 -53
- package/dist/components/chat/CodeBlock.js.map +1 -1
- package/dist/components/chat/CodeBlock.mjs +14 -5
- package/dist/components/chat/CodeBlock.mjs.map +1 -1
- package/dist/components/chat/Header.js +48 -15
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +9 -5
- package/dist/components/chat/Header.mjs.map +1 -1
- package/dist/components/chat/Icons.js +73 -42
- package/dist/components/chat/Icons.js.map +1 -1
- package/dist/components/chat/Icons.mjs +27 -3
- package/dist/components/chat/Icons.mjs.map +1 -1
- package/dist/components/chat/Input.js +64 -26
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +10 -6
- package/dist/components/chat/Input.mjs.map +1 -1
- package/dist/components/chat/Markdown.js +86 -66
- package/dist/components/chat/Markdown.js.map +1 -1
- package/dist/components/chat/Markdown.mjs +10 -6
- package/dist/components/chat/Markdown.mjs.map +1 -1
- package/dist/components/chat/Messages.js +113 -79
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +12 -8
- package/dist/components/chat/Messages.mjs.map +1 -1
- package/dist/components/chat/Popup.js +210 -139
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +20 -16
- package/dist/components/chat/Popup.mjs.map +1 -1
- package/dist/components/chat/Response.js +47 -14
- package/dist/components/chat/Response.js.map +1 -1
- package/dist/components/chat/Response.mjs +9 -5
- package/dist/components/chat/Response.mjs.map +1 -1
- package/dist/components/chat/Sidebar.js +213 -141
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +20 -16
- package/dist/components/chat/Sidebar.mjs.map +1 -1
- package/dist/components/chat/Textarea.js +32 -14
- package/dist/components/chat/Textarea.js.map +1 -1
- package/dist/components/chat/Textarea.mjs +7 -3
- package/dist/components/chat/Textarea.mjs.map +1 -1
- package/dist/components/chat/Window.js +45 -17
- package/dist/components/chat/Window.js.map +1 -1
- package/dist/components/chat/Window.mjs +7 -3
- package/dist/components/chat/Window.mjs.map +1 -1
- package/dist/components/chat/index.js +219 -143
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +26 -19
- package/dist/components/chat/index.mjs.map +1 -1
- package/dist/components/chat/props.js +17 -2
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/chat/props.mjs +1 -2
- package/dist/components/chat/props.mjs.map +1 -1
- package/dist/components/index.js +219 -143
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +27 -20
- package/dist/components/index.mjs.map +1 -1
- package/dist/context/index.js +17 -2
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -2
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/index.js +17 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -2
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +40 -26
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.mjs +8 -3
- package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -1
- package/dist/index.js +219 -143
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -23
- package/dist/index.mjs.map +1 -1
- package/dist/lib/utils.js +40 -14
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/utils.mjs +13 -7
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.js +1 -2
- package/dist/lib/utils.test.js.map +1 -1
- package/dist/lib/utils.test.mjs +0 -1
- package/dist/lib/utils.test.mjs.map +1 -1
- package/dist/types/index.js +17 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +1 -2
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/types.js +17 -2
- package/dist/types/types.js.map +1 -1
- package/dist/types/types.mjs +0 -2
- package/dist/types/types.mjs.map +1 -1
- package/package.json +8 -8
|
@@ -1,44 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
var reactCore = require('@copilotkit/react-core');
|
|
6
|
-
var nanoid = require('nanoid');
|
|
7
|
-
var ReactMarkdown = require('react-markdown');
|
|
8
|
-
var reactSyntaxHighlighter = require('react-syntax-highlighter');
|
|
9
|
-
var prism = require('react-syntax-highlighter/dist/esm/styles/prism');
|
|
10
|
-
var remarkGfm = require('remark-gfm');
|
|
11
|
-
var remarkMath = require('remark-math');
|
|
12
|
-
|
|
13
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
-
|
|
15
|
-
function _interopNamespace(e) {
|
|
16
|
-
if (e && e.__esModule) return e;
|
|
17
|
-
var n = Object.create(null);
|
|
18
|
-
if (e) {
|
|
19
|
-
Object.keys(e).forEach(function (k) {
|
|
20
|
-
if (k !== 'default') {
|
|
21
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () { return e[k]; }
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
n.default = e;
|
|
30
|
-
return Object.freeze(n);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
|
-
var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
|
|
35
|
-
var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
|
|
36
|
-
var remarkMath__default = /*#__PURE__*/_interopDefault(remarkMath);
|
|
37
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
38
3
|
var __defProp = Object.defineProperty;
|
|
39
4
|
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
40
6
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
41
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
42
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
43
11
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
44
12
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -66,6 +34,27 @@ var __objRest = (source, exclude) => {
|
|
|
66
34
|
}
|
|
67
35
|
return target;
|
|
68
36
|
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
69
58
|
var __async = (__this, __arguments, generator) => {
|
|
70
59
|
return new Promise((resolve, reject) => {
|
|
71
60
|
var fulfilled = (value) => {
|
|
@@ -86,7 +75,21 @@ var __async = (__this, __arguments, generator) => {
|
|
|
86
75
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
87
76
|
});
|
|
88
77
|
};
|
|
89
|
-
|
|
78
|
+
|
|
79
|
+
// src/components/chat/Chat.tsx
|
|
80
|
+
var Chat_exports = {};
|
|
81
|
+
__export(Chat_exports, {
|
|
82
|
+
CopilotChat: () => CopilotChat
|
|
83
|
+
});
|
|
84
|
+
module.exports = __toCommonJS(Chat_exports);
|
|
85
|
+
var import_react8 = __toESM(require("react"));
|
|
86
|
+
|
|
87
|
+
// src/components/chat/ChatContext.tsx
|
|
88
|
+
var import_react = __toESM(require("react"));
|
|
89
|
+
|
|
90
|
+
// src/components/chat/Icons.tsx
|
|
91
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
92
|
+
var OpenIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
90
93
|
"svg",
|
|
91
94
|
{
|
|
92
95
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -94,7 +97,7 @@ var OpenIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
94
97
|
fill: "currentColor",
|
|
95
98
|
width: "24",
|
|
96
99
|
height: "24",
|
|
97
|
-
children: /* @__PURE__ */
|
|
100
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
101
|
"path",
|
|
99
102
|
{
|
|
100
103
|
fillRule: "evenodd",
|
|
@@ -104,7 +107,7 @@ var OpenIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
104
107
|
) })
|
|
105
108
|
}
|
|
106
109
|
);
|
|
107
|
-
var CloseIcon = /* @__PURE__ */
|
|
110
|
+
var CloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
108
111
|
"svg",
|
|
109
112
|
{
|
|
110
113
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -114,10 +117,10 @@ var CloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
114
117
|
stroke: "currentColor",
|
|
115
118
|
width: "24",
|
|
116
119
|
height: "24",
|
|
117
|
-
children: /* @__PURE__ */
|
|
120
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" })
|
|
118
121
|
}
|
|
119
122
|
);
|
|
120
|
-
var HeaderCloseIcon = /* @__PURE__ */
|
|
123
|
+
var HeaderCloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
121
124
|
"svg",
|
|
122
125
|
{
|
|
123
126
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -127,10 +130,10 @@ var HeaderCloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
127
130
|
stroke: "currentColor",
|
|
128
131
|
width: "24",
|
|
129
132
|
height: "24",
|
|
130
|
-
children: /* @__PURE__ */
|
|
133
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
|
131
134
|
}
|
|
132
135
|
);
|
|
133
|
-
var SendIcon = /* @__PURE__ */
|
|
136
|
+
var SendIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
134
137
|
"svg",
|
|
135
138
|
{
|
|
136
139
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -140,7 +143,7 @@ var SendIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
140
143
|
stroke: "currentColor",
|
|
141
144
|
width: "24",
|
|
142
145
|
height: "24",
|
|
143
|
-
children: /* @__PURE__ */
|
|
146
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
147
|
"path",
|
|
145
148
|
{
|
|
146
149
|
strokeLinecap: "round",
|
|
@@ -150,7 +153,7 @@ var SendIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
150
153
|
)
|
|
151
154
|
}
|
|
152
155
|
);
|
|
153
|
-
var SpinnerIcon = /* @__PURE__ */
|
|
156
|
+
var SpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
154
157
|
"svg",
|
|
155
158
|
{
|
|
156
159
|
style: {
|
|
@@ -163,7 +166,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
163
166
|
fill: "none",
|
|
164
167
|
viewBox: "0 0 24 24",
|
|
165
168
|
children: [
|
|
166
|
-
/* @__PURE__ */
|
|
169
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
167
170
|
"circle",
|
|
168
171
|
{
|
|
169
172
|
style: { opacity: 0.25 },
|
|
@@ -174,7 +177,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
174
177
|
strokeWidth: "4"
|
|
175
178
|
}
|
|
176
179
|
),
|
|
177
|
-
/* @__PURE__ */
|
|
180
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
178
181
|
"path",
|
|
179
182
|
{
|
|
180
183
|
style: { opacity: 0.75 },
|
|
@@ -185,7 +188,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
185
188
|
]
|
|
186
189
|
}
|
|
187
190
|
);
|
|
188
|
-
var ActivityIcon = /* @__PURE__ */
|
|
191
|
+
var ActivityIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
189
192
|
"svg",
|
|
190
193
|
{
|
|
191
194
|
style: {
|
|
@@ -199,15 +202,15 @@ var ActivityIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
199
202
|
xmlns: "http://www.w3.org/2000/svg",
|
|
200
203
|
fill: "currentColor",
|
|
201
204
|
children: [
|
|
202
|
-
/* @__PURE__ */
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1", cx: "4", cy: "12", r: "3" }),
|
|
206
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot2", cx: "12", cy: "12", r: "3" }),
|
|
207
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot3", cx: "20", cy: "12", r: "3" })
|
|
205
208
|
]
|
|
206
209
|
}
|
|
207
210
|
);
|
|
208
211
|
function CheckIcon(_a) {
|
|
209
212
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
210
|
-
return /* @__PURE__ */
|
|
213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
211
214
|
"svg",
|
|
212
215
|
__spreadProps(__spreadValues({
|
|
213
216
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -216,13 +219,13 @@ function CheckIcon(_a) {
|
|
|
216
219
|
style: { height: "1rem", width: "1rem" },
|
|
217
220
|
className
|
|
218
221
|
}, props), {
|
|
219
|
-
children: /* @__PURE__ */
|
|
222
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z" })
|
|
220
223
|
})
|
|
221
224
|
);
|
|
222
225
|
}
|
|
223
226
|
function DownloadIcon(_a) {
|
|
224
227
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
225
|
-
return /* @__PURE__ */
|
|
228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
226
229
|
"svg",
|
|
227
230
|
__spreadProps(__spreadValues({
|
|
228
231
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -231,13 +234,13 @@ function DownloadIcon(_a) {
|
|
|
231
234
|
style: { height: "1rem", width: "1rem" },
|
|
232
235
|
className
|
|
233
236
|
}, props), {
|
|
234
|
-
children: /* @__PURE__ */
|
|
237
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z" })
|
|
235
238
|
})
|
|
236
239
|
);
|
|
237
240
|
}
|
|
238
241
|
function CopyIcon(_a) {
|
|
239
242
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
240
|
-
return /* @__PURE__ */
|
|
243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
241
244
|
"svg",
|
|
242
245
|
__spreadProps(__spreadValues({
|
|
243
246
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -246,33 +249,36 @@ function CopyIcon(_a) {
|
|
|
246
249
|
style: { height: "1rem", width: "1rem" },
|
|
247
250
|
className
|
|
248
251
|
}, props), {
|
|
249
|
-
children: /* @__PURE__ */
|
|
252
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z" })
|
|
250
253
|
})
|
|
251
254
|
);
|
|
252
255
|
}
|
|
253
|
-
var StopIcon = /* @__PURE__ */
|
|
256
|
+
var StopIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
254
257
|
"svg",
|
|
255
258
|
{
|
|
256
259
|
xmlns: "http://www.w3.org/2000/svg",
|
|
257
260
|
viewBox: "0 0 256 256",
|
|
258
261
|
fill: "currentColor",
|
|
259
262
|
style: { height: "1rem", width: "1rem" },
|
|
260
|
-
children: /* @__PURE__ */
|
|
263
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z" })
|
|
261
264
|
}
|
|
262
265
|
);
|
|
263
|
-
var RegenerateIcon = /* @__PURE__ */
|
|
266
|
+
var RegenerateIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
264
267
|
"svg",
|
|
265
268
|
{
|
|
266
269
|
xmlns: "http://www.w3.org/2000/svg",
|
|
267
270
|
viewBox: "0 0 256 256",
|
|
268
271
|
fill: "currentColor",
|
|
269
272
|
style: { height: "1rem", width: "1rem" },
|
|
270
|
-
children: /* @__PURE__ */
|
|
273
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z" })
|
|
271
274
|
}
|
|
272
275
|
);
|
|
273
|
-
|
|
276
|
+
|
|
277
|
+
// src/components/chat/ChatContext.tsx
|
|
278
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
279
|
+
var ChatContext = import_react.default.createContext(void 0);
|
|
274
280
|
function useChatContext() {
|
|
275
|
-
const context =
|
|
281
|
+
const context = import_react.default.useContext(ChatContext);
|
|
276
282
|
if (context === void 0) {
|
|
277
283
|
throw new Error(
|
|
278
284
|
"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
|
|
@@ -288,7 +294,7 @@ var ChatContextProvider = ({
|
|
|
288
294
|
icons,
|
|
289
295
|
children
|
|
290
296
|
}) => {
|
|
291
|
-
const context =
|
|
297
|
+
const context = (0, import_react.useMemo)(
|
|
292
298
|
() => ({
|
|
293
299
|
labels: __spreadValues(__spreadValues({}, {
|
|
294
300
|
initial: "",
|
|
@@ -315,8 +321,15 @@ var ChatContextProvider = ({
|
|
|
315
321
|
}),
|
|
316
322
|
[labels, icons]
|
|
317
323
|
);
|
|
318
|
-
return /* @__PURE__ */
|
|
324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChatContext.Provider, { value: context, children });
|
|
319
325
|
};
|
|
326
|
+
|
|
327
|
+
// src/components/chat/Chat.tsx
|
|
328
|
+
var import_react_core = require("@copilotkit/react-core");
|
|
329
|
+
|
|
330
|
+
// src/components/chat/Window.tsx
|
|
331
|
+
var import_react2 = __toESM(require("react"));
|
|
332
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
320
333
|
var Window = ({
|
|
321
334
|
open,
|
|
322
335
|
setOpen,
|
|
@@ -325,8 +338,8 @@ var Window = ({
|
|
|
325
338
|
hotkey,
|
|
326
339
|
hitEscapeToClose
|
|
327
340
|
}) => {
|
|
328
|
-
const windowRef =
|
|
329
|
-
const handleClickOutside =
|
|
341
|
+
const windowRef = import_react2.default.useRef(null);
|
|
342
|
+
const handleClickOutside = (0, import_react2.useCallback)(
|
|
330
343
|
(event) => {
|
|
331
344
|
var _a;
|
|
332
345
|
if (!clickOutsideToClose) {
|
|
@@ -339,7 +352,7 @@ var Window = ({
|
|
|
339
352
|
},
|
|
340
353
|
[clickOutsideToClose, open, setOpen]
|
|
341
354
|
);
|
|
342
|
-
const handleKeyDown =
|
|
355
|
+
const handleKeyDown = (0, import_react2.useCallback)(
|
|
343
356
|
(event) => {
|
|
344
357
|
var _a;
|
|
345
358
|
const target = event.target;
|
|
@@ -353,7 +366,7 @@ var Window = ({
|
|
|
353
366
|
},
|
|
354
367
|
[hitEscapeToClose, hotkey, open, setOpen]
|
|
355
368
|
);
|
|
356
|
-
const adjustForMobile =
|
|
369
|
+
const adjustForMobile = (0, import_react2.useCallback)(() => {
|
|
357
370
|
const copilotKitWindow = windowRef.current;
|
|
358
371
|
const vv = window.visualViewport;
|
|
359
372
|
if (!copilotKitWindow || !vv) {
|
|
@@ -384,7 +397,7 @@ var Window = ({
|
|
|
384
397
|
document.body.removeEventListener("touchmove", preventScroll);
|
|
385
398
|
}
|
|
386
399
|
}, [open]);
|
|
387
|
-
|
|
400
|
+
(0, import_react2.useEffect)(() => {
|
|
388
401
|
document.addEventListener("mousedown", handleClickOutside);
|
|
389
402
|
document.addEventListener("keydown", handleKeyDown);
|
|
390
403
|
if (window.visualViewport) {
|
|
@@ -399,7 +412,7 @@ var Window = ({
|
|
|
399
412
|
}
|
|
400
413
|
};
|
|
401
414
|
}, [adjustForMobile, handleClickOutside, handleKeyDown]);
|
|
402
|
-
return /* @__PURE__ */
|
|
415
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `copilotKitWindow${open ? " open" : ""}`, ref: windowRef, children });
|
|
403
416
|
};
|
|
404
417
|
var preventScroll = (event) => {
|
|
405
418
|
let targetElement = event.target;
|
|
@@ -419,29 +432,51 @@ var preventScroll = (event) => {
|
|
|
419
432
|
function isMacOS() {
|
|
420
433
|
return /Mac|iMac|Macintosh/i.test(navigator.userAgent);
|
|
421
434
|
}
|
|
435
|
+
|
|
436
|
+
// src/components/chat/Button.tsx
|
|
437
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
422
438
|
var Button = ({ open, setOpen }) => {
|
|
423
439
|
const context = useChatContext();
|
|
424
|
-
return /* @__PURE__ */
|
|
440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
425
441
|
"button",
|
|
426
442
|
{
|
|
427
443
|
className: `copilotKitButton ${open ? "open" : ""}`,
|
|
428
444
|
"aria-label": open ? "Close Chat" : "Open Chat",
|
|
429
445
|
children: [
|
|
430
|
-
/* @__PURE__ */
|
|
431
|
-
/* @__PURE__ */
|
|
446
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconOpen", children: context.icons.openIcon }),
|
|
447
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconClose", children: context.icons.closeIcon })
|
|
432
448
|
]
|
|
433
449
|
}
|
|
434
450
|
) });
|
|
435
451
|
};
|
|
452
|
+
|
|
453
|
+
// src/components/chat/Header.tsx
|
|
454
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
436
455
|
var Header = ({ setOpen }) => {
|
|
437
456
|
const context = useChatContext();
|
|
438
|
-
return /* @__PURE__ */
|
|
439
|
-
/* @__PURE__ */
|
|
440
|
-
/* @__PURE__ */
|
|
457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "copilotKitHeader", children: [
|
|
458
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: context.labels.title }),
|
|
459
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { onClick: () => setOpen(false), "aria-label": "Close", children: context.icons.headerCloseIcon })
|
|
441
460
|
] });
|
|
442
461
|
};
|
|
462
|
+
|
|
463
|
+
// src/components/chat/Messages.tsx
|
|
464
|
+
var import_react5 = __toESM(require("react"));
|
|
465
|
+
var import_nanoid = require("nanoid");
|
|
466
|
+
|
|
467
|
+
// src/components/chat/Markdown.tsx
|
|
468
|
+
var import_react4 = require("react");
|
|
469
|
+
var import_react_markdown = __toESM(require("react-markdown"));
|
|
470
|
+
|
|
471
|
+
// src/components/chat/CodeBlock.tsx
|
|
472
|
+
var import_react3 = require("react");
|
|
473
|
+
var import_react_syntax_highlighter = require("react-syntax-highlighter");
|
|
474
|
+
var import_prism = require("react-syntax-highlighter/dist/esm/styles/prism");
|
|
475
|
+
|
|
476
|
+
// src/hooks/use-copy-to-clipboard.tsx
|
|
477
|
+
var React3 = __toESM(require("react"));
|
|
443
478
|
function useCopyToClipboard({ timeout = 2e3 }) {
|
|
444
|
-
const [isCopied, setIsCopied] =
|
|
479
|
+
const [isCopied, setIsCopied] = React3.useState(false);
|
|
445
480
|
const copyToClipboard = (value) => {
|
|
446
481
|
var _a;
|
|
447
482
|
if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
|
|
@@ -459,6 +494,9 @@ function useCopyToClipboard({ timeout = 2e3 }) {
|
|
|
459
494
|
};
|
|
460
495
|
return { isCopied, copyToClipboard };
|
|
461
496
|
}
|
|
497
|
+
|
|
498
|
+
// src/components/chat/CodeBlock.tsx
|
|
499
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
462
500
|
var programmingLanguages = {
|
|
463
501
|
javascript: ".js",
|
|
464
502
|
python: ".py",
|
|
@@ -493,7 +531,7 @@ var generateRandomString = (length, lowercase = false) => {
|
|
|
493
531
|
}
|
|
494
532
|
return lowercase ? result.toLowerCase() : result;
|
|
495
533
|
};
|
|
496
|
-
var CodeBlock =
|
|
534
|
+
var CodeBlock = (0, import_react3.memo)(({ language, value }) => {
|
|
497
535
|
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
498
536
|
const downloadAsFile = () => {
|
|
499
537
|
if (typeof window === "undefined") {
|
|
@@ -521,25 +559,25 @@ var CodeBlock = React.memo(({ language, value }) => {
|
|
|
521
559
|
return;
|
|
522
560
|
copyToClipboard(value);
|
|
523
561
|
};
|
|
524
|
-
return /* @__PURE__ */
|
|
525
|
-
/* @__PURE__ */
|
|
526
|
-
/* @__PURE__ */
|
|
527
|
-
/* @__PURE__ */
|
|
528
|
-
/* @__PURE__ */
|
|
529
|
-
/* @__PURE__ */
|
|
530
|
-
/* @__PURE__ */
|
|
562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlock", children: [
|
|
563
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
|
|
564
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
|
|
565
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
|
|
566
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
|
|
567
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DownloadIcon, {}),
|
|
568
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Download" })
|
|
531
569
|
] }),
|
|
532
|
-
/* @__PURE__ */
|
|
533
|
-
isCopied ? /* @__PURE__ */
|
|
534
|
-
/* @__PURE__ */
|
|
570
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
|
|
571
|
+
isCopied ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopyIcon, {}),
|
|
572
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Copy code" })
|
|
535
573
|
] })
|
|
536
574
|
] })
|
|
537
575
|
] }),
|
|
538
|
-
/* @__PURE__ */
|
|
539
|
-
|
|
576
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
577
|
+
import_react_syntax_highlighter.Prism,
|
|
540
578
|
{
|
|
541
579
|
language,
|
|
542
|
-
style:
|
|
580
|
+
style: import_prism.vscDarkPlus,
|
|
543
581
|
PreTag: "div",
|
|
544
582
|
customStyle: {
|
|
545
583
|
margin: 0,
|
|
@@ -552,22 +590,27 @@ var CodeBlock = React.memo(({ language, value }) => {
|
|
|
552
590
|
] });
|
|
553
591
|
});
|
|
554
592
|
CodeBlock.displayName = "CodeBlock";
|
|
555
|
-
|
|
556
|
-
|
|
593
|
+
|
|
594
|
+
// src/components/chat/Markdown.tsx
|
|
595
|
+
var import_remark_gfm = __toESM(require("remark-gfm"));
|
|
596
|
+
var import_remark_math = __toESM(require("remark-math"));
|
|
597
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
598
|
+
var MemoizedReactMarkdown = (0, import_react4.memo)(
|
|
599
|
+
import_react_markdown.default,
|
|
557
600
|
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
|
|
558
601
|
);
|
|
559
602
|
var Markdown = ({ content }) => {
|
|
560
|
-
return /* @__PURE__ */
|
|
603
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MemoizedReactMarkdown, { components, remarkPlugins: [import_remark_gfm.default, import_remark_math.default], children: content }) });
|
|
561
604
|
};
|
|
562
605
|
var components = {
|
|
563
606
|
p({ children }) {
|
|
564
|
-
return /* @__PURE__ */
|
|
607
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children });
|
|
565
608
|
},
|
|
566
609
|
code(_a) {
|
|
567
610
|
var _b = _a, { children, className, inline } = _b, props = __objRest(_b, ["children", "className", "inline"]);
|
|
568
611
|
if (children.length) {
|
|
569
612
|
if (children[0] == "\u258D") {
|
|
570
|
-
return /* @__PURE__ */
|
|
613
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
571
614
|
"span",
|
|
572
615
|
{
|
|
573
616
|
style: {
|
|
@@ -582,9 +625,9 @@ var components = {
|
|
|
582
625
|
}
|
|
583
626
|
const match = /language-(\w+)/.exec(className || "");
|
|
584
627
|
if (inline) {
|
|
585
|
-
return /* @__PURE__ */
|
|
628
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", __spreadProps(__spreadValues({ className }, props), { children }));
|
|
586
629
|
}
|
|
587
|
-
return /* @__PURE__ */
|
|
630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
588
631
|
CodeBlock,
|
|
589
632
|
__spreadValues({
|
|
590
633
|
language: match && match[1] || "",
|
|
@@ -594,14 +637,17 @@ var components = {
|
|
|
594
637
|
);
|
|
595
638
|
}
|
|
596
639
|
};
|
|
640
|
+
|
|
641
|
+
// src/components/chat/Messages.tsx
|
|
642
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
597
643
|
var Messages = ({ messages, inProgress }) => {
|
|
598
644
|
const context = useChatContext();
|
|
599
|
-
const initialMessages =
|
|
645
|
+
const initialMessages = (0, import_react5.useMemo)(
|
|
600
646
|
() => makeInitialMessages(context.labels.initial),
|
|
601
647
|
[context.labels.initial]
|
|
602
648
|
);
|
|
603
649
|
messages = [...initialMessages, ...messages];
|
|
604
|
-
const messagesEndRef =
|
|
650
|
+
const messagesEndRef = import_react5.default.useRef(null);
|
|
605
651
|
const scrollToBottom = () => {
|
|
606
652
|
if (messagesEndRef.current) {
|
|
607
653
|
messagesEndRef.current.scrollIntoView({
|
|
@@ -609,25 +655,25 @@ var Messages = ({ messages, inProgress }) => {
|
|
|
609
655
|
});
|
|
610
656
|
}
|
|
611
657
|
};
|
|
612
|
-
|
|
658
|
+
(0, import_react5.useEffect)(() => {
|
|
613
659
|
scrollToBottom();
|
|
614
660
|
}, [messages]);
|
|
615
|
-
return /* @__PURE__ */
|
|
661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "copilotKitMessages", children: [
|
|
616
662
|
messages.map((message, index) => {
|
|
617
663
|
const isCurrentMessage = index === messages.length - 1;
|
|
618
664
|
if (message.role === "user") {
|
|
619
|
-
return /* @__PURE__ */
|
|
665
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
|
|
620
666
|
} else if (message.role == "assistant") {
|
|
621
667
|
if (isCurrentMessage && inProgress && !message.content) {
|
|
622
|
-
return /* @__PURE__ */
|
|
668
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
|
|
623
669
|
} else if ((!inProgress || index != messages.length - 1) && !message.content && message.function_call) {
|
|
624
|
-
return /* @__PURE__ */
|
|
670
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.labels.done }, index);
|
|
625
671
|
} else {
|
|
626
|
-
return /* @__PURE__ */
|
|
672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Markdown, { content: message.content }) }, index);
|
|
627
673
|
}
|
|
628
674
|
}
|
|
629
675
|
}),
|
|
630
|
-
/* @__PURE__ */
|
|
676
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: messagesEndRef })
|
|
631
677
|
] });
|
|
632
678
|
};
|
|
633
679
|
function makeInitialMessages(initial) {
|
|
@@ -640,17 +686,24 @@ function makeInitialMessages(initial) {
|
|
|
640
686
|
}
|
|
641
687
|
}
|
|
642
688
|
return initialArray.map((message) => ({
|
|
643
|
-
id:
|
|
689
|
+
id: (0, import_nanoid.nanoid)(),
|
|
644
690
|
role: "assistant",
|
|
645
691
|
content: message
|
|
646
692
|
}));
|
|
647
693
|
}
|
|
648
|
-
|
|
694
|
+
|
|
695
|
+
// src/components/chat/Input.tsx
|
|
696
|
+
var import_react7 = require("react");
|
|
697
|
+
|
|
698
|
+
// src/components/chat/Textarea.tsx
|
|
699
|
+
var import_react6 = require("react");
|
|
700
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
701
|
+
var AutoResizingTextarea = (0, import_react6.forwardRef)(
|
|
649
702
|
({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {
|
|
650
|
-
const internalTextareaRef =
|
|
651
|
-
const [maxHeight, setMaxHeight] =
|
|
652
|
-
|
|
653
|
-
|
|
703
|
+
const internalTextareaRef = (0, import_react6.useRef)(null);
|
|
704
|
+
const [maxHeight, setMaxHeight] = (0, import_react6.useState)(0);
|
|
705
|
+
(0, import_react6.useImperativeHandle)(ref, () => internalTextareaRef.current);
|
|
706
|
+
(0, import_react6.useEffect)(() => {
|
|
654
707
|
const calculateMaxHeight = () => {
|
|
655
708
|
const textarea = internalTextareaRef.current;
|
|
656
709
|
if (textarea) {
|
|
@@ -664,14 +717,14 @@ var AutoResizingTextarea = React.forwardRef(
|
|
|
664
717
|
};
|
|
665
718
|
calculateMaxHeight();
|
|
666
719
|
}, [maxRows]);
|
|
667
|
-
|
|
720
|
+
(0, import_react6.useEffect)(() => {
|
|
668
721
|
const textarea = internalTextareaRef.current;
|
|
669
722
|
if (textarea) {
|
|
670
723
|
textarea.style.height = "auto";
|
|
671
724
|
textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
|
|
672
725
|
}
|
|
673
726
|
}, [value, maxHeight]);
|
|
674
|
-
return /* @__PURE__ */
|
|
727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
675
728
|
"textarea",
|
|
676
729
|
{
|
|
677
730
|
ref: internalTextareaRef,
|
|
@@ -690,16 +743,19 @@ var AutoResizingTextarea = React.forwardRef(
|
|
|
690
743
|
}
|
|
691
744
|
);
|
|
692
745
|
var Textarea_default = AutoResizingTextarea;
|
|
746
|
+
|
|
747
|
+
// src/components/chat/Input.tsx
|
|
748
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
693
749
|
var Input = ({ inProgress, onSend, children }) => {
|
|
694
750
|
const context = useChatContext();
|
|
695
|
-
const textareaRef =
|
|
751
|
+
const textareaRef = (0, import_react7.useRef)(null);
|
|
696
752
|
const handleDivClick = (event) => {
|
|
697
753
|
var _a;
|
|
698
754
|
if (event.target !== event.currentTarget)
|
|
699
755
|
return;
|
|
700
756
|
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
701
757
|
};
|
|
702
|
-
const [text, setText] =
|
|
758
|
+
const [text, setText] = (0, import_react7.useState)("");
|
|
703
759
|
const send = () => {
|
|
704
760
|
var _a;
|
|
705
761
|
if (inProgress)
|
|
@@ -710,10 +766,10 @@ var Input = ({ inProgress, onSend, children }) => {
|
|
|
710
766
|
};
|
|
711
767
|
const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;
|
|
712
768
|
const disabled = inProgress || text.length === 0;
|
|
713
|
-
return /* @__PURE__ */
|
|
714
|
-
/* @__PURE__ */
|
|
715
|
-
/* @__PURE__ */
|
|
716
|
-
/* @__PURE__ */
|
|
769
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
|
|
770
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children }),
|
|
771
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
|
|
772
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
717
773
|
Textarea_default,
|
|
718
774
|
{
|
|
719
775
|
ref: textareaRef,
|
|
@@ -732,13 +788,22 @@ var Input = ({ inProgress, onSend, children }) => {
|
|
|
732
788
|
)
|
|
733
789
|
] });
|
|
734
790
|
};
|
|
791
|
+
|
|
792
|
+
// src/components/chat/Chat.tsx
|
|
793
|
+
var import_nanoid2 = require("nanoid");
|
|
794
|
+
|
|
795
|
+
// src/components/chat/Response.tsx
|
|
796
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
735
797
|
var ResponseButton = ({ onClick, inProgress }) => {
|
|
736
798
|
const context = useChatContext();
|
|
737
|
-
return /* @__PURE__ */
|
|
738
|
-
/* @__PURE__ */
|
|
799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("button", { onClick, className: "copilotKitResponseButton", children: [
|
|
800
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: inProgress ? context.icons.stopIcon : context.icons.regenerateIcon }),
|
|
739
801
|
inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse
|
|
740
802
|
] });
|
|
741
803
|
};
|
|
804
|
+
|
|
805
|
+
// src/components/chat/Chat.tsx
|
|
806
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
742
807
|
var CopilotChat = ({
|
|
743
808
|
instructions,
|
|
744
809
|
defaultOpen = false,
|
|
@@ -758,26 +823,26 @@ var CopilotChat = ({
|
|
|
758
823
|
ResponseButton: ResponseButton2 = ResponseButton,
|
|
759
824
|
className
|
|
760
825
|
}) => {
|
|
761
|
-
const { visibleMessages, append, reload, stop, isLoading, input, setInput } =
|
|
762
|
-
id:
|
|
826
|
+
const { visibleMessages, append, reload, stop, isLoading, input, setInput } = (0, import_react_core.useCopilotChat)({
|
|
827
|
+
id: (0, import_nanoid2.nanoid)(),
|
|
763
828
|
makeSystemMessage,
|
|
764
829
|
additionalInstructions: instructions
|
|
765
830
|
});
|
|
766
|
-
const [openState, setOpenState] =
|
|
831
|
+
const [openState, setOpenState] = import_react8.default.useState(defaultOpen);
|
|
767
832
|
const setOpen = (open) => {
|
|
768
833
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
769
834
|
setOpenState(open);
|
|
770
835
|
};
|
|
771
836
|
const sendMessage = (message) => __async(void 0, null, function* () {
|
|
772
837
|
append({
|
|
773
|
-
id:
|
|
838
|
+
id: (0, import_nanoid2.nanoid)(),
|
|
774
839
|
content: message,
|
|
775
840
|
role: "user"
|
|
776
841
|
});
|
|
777
842
|
});
|
|
778
|
-
return /* @__PURE__ */
|
|
779
|
-
/* @__PURE__ */
|
|
780
|
-
/* @__PURE__ */
|
|
843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChatContextProvider, { icons, labels, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className, children: [
|
|
844
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button2, { open: openState, setOpen }),
|
|
845
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
781
846
|
Window2,
|
|
782
847
|
{
|
|
783
848
|
open: openState,
|
|
@@ -786,15 +851,16 @@ var CopilotChat = ({
|
|
|
786
851
|
hotkey,
|
|
787
852
|
hitEscapeToClose,
|
|
788
853
|
children: [
|
|
789
|
-
/* @__PURE__ */
|
|
790
|
-
/* @__PURE__ */
|
|
791
|
-
/* @__PURE__ */
|
|
854
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Header2, { open: openState, setOpen }),
|
|
855
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Messages2, { messages: visibleMessages, inProgress: isLoading }),
|
|
856
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input2, { inProgress: isLoading, onSend: sendMessage, children: showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading }) })
|
|
792
857
|
]
|
|
793
858
|
}
|
|
794
859
|
)
|
|
795
860
|
] }) });
|
|
796
861
|
};
|
|
797
|
-
|
|
798
|
-
exports
|
|
799
|
-
|
|
862
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
863
|
+
0 && (module.exports = {
|
|
864
|
+
CopilotChat
|
|
865
|
+
});
|
|
800
866
|
//# sourceMappingURL=Chat.js.map
|