@copilotkit/react-ui 0.15.0-alpha.7 → 0.15.0-alpha.9
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 +148 -168
- package/CHANGELOG.md +24 -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,24 @@ var __async = (__this, __arguments, generator) => {
|
|
|
86
75
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
87
76
|
});
|
|
88
77
|
};
|
|
89
|
-
|
|
78
|
+
|
|
79
|
+
// src/components/chat/Sidebar.tsx
|
|
80
|
+
var Sidebar_exports = {};
|
|
81
|
+
__export(Sidebar_exports, {
|
|
82
|
+
CopilotSidebar: () => CopilotSidebar
|
|
83
|
+
});
|
|
84
|
+
module.exports = __toCommonJS(Sidebar_exports);
|
|
85
|
+
var import_react9 = require("react");
|
|
86
|
+
|
|
87
|
+
// src/components/chat/Chat.tsx
|
|
88
|
+
var import_react8 = __toESM(require("react"));
|
|
89
|
+
|
|
90
|
+
// src/components/chat/ChatContext.tsx
|
|
91
|
+
var import_react = __toESM(require("react"));
|
|
92
|
+
|
|
93
|
+
// src/components/chat/Icons.tsx
|
|
94
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
95
|
+
var OpenIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
90
96
|
"svg",
|
|
91
97
|
{
|
|
92
98
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -94,7 +100,7 @@ var OpenIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
94
100
|
fill: "currentColor",
|
|
95
101
|
width: "24",
|
|
96
102
|
height: "24",
|
|
97
|
-
children: /* @__PURE__ */
|
|
103
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
104
|
"path",
|
|
99
105
|
{
|
|
100
106
|
fillRule: "evenodd",
|
|
@@ -104,7 +110,7 @@ var OpenIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
104
110
|
) })
|
|
105
111
|
}
|
|
106
112
|
);
|
|
107
|
-
var CloseIcon = /* @__PURE__ */
|
|
113
|
+
var CloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
108
114
|
"svg",
|
|
109
115
|
{
|
|
110
116
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -114,10 +120,10 @@ var CloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
114
120
|
stroke: "currentColor",
|
|
115
121
|
width: "24",
|
|
116
122
|
height: "24",
|
|
117
|
-
children: /* @__PURE__ */
|
|
123
|
+
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
124
|
}
|
|
119
125
|
);
|
|
120
|
-
var HeaderCloseIcon = /* @__PURE__ */
|
|
126
|
+
var HeaderCloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
121
127
|
"svg",
|
|
122
128
|
{
|
|
123
129
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -127,10 +133,10 @@ var HeaderCloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
127
133
|
stroke: "currentColor",
|
|
128
134
|
width: "24",
|
|
129
135
|
height: "24",
|
|
130
|
-
children: /* @__PURE__ */
|
|
136
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
|
131
137
|
}
|
|
132
138
|
);
|
|
133
|
-
var SendIcon = /* @__PURE__ */
|
|
139
|
+
var SendIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
134
140
|
"svg",
|
|
135
141
|
{
|
|
136
142
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -140,7 +146,7 @@ var SendIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
140
146
|
stroke: "currentColor",
|
|
141
147
|
width: "24",
|
|
142
148
|
height: "24",
|
|
143
|
-
children: /* @__PURE__ */
|
|
149
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
150
|
"path",
|
|
145
151
|
{
|
|
146
152
|
strokeLinecap: "round",
|
|
@@ -150,7 +156,7 @@ var SendIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
|
150
156
|
)
|
|
151
157
|
}
|
|
152
158
|
);
|
|
153
|
-
var SpinnerIcon = /* @__PURE__ */
|
|
159
|
+
var SpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
154
160
|
"svg",
|
|
155
161
|
{
|
|
156
162
|
style: {
|
|
@@ -163,7 +169,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
163
169
|
fill: "none",
|
|
164
170
|
viewBox: "0 0 24 24",
|
|
165
171
|
children: [
|
|
166
|
-
/* @__PURE__ */
|
|
172
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
167
173
|
"circle",
|
|
168
174
|
{
|
|
169
175
|
style: { opacity: 0.25 },
|
|
@@ -174,7 +180,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
174
180
|
strokeWidth: "4"
|
|
175
181
|
}
|
|
176
182
|
),
|
|
177
|
-
/* @__PURE__ */
|
|
183
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
178
184
|
"path",
|
|
179
185
|
{
|
|
180
186
|
style: { opacity: 0.75 },
|
|
@@ -185,7 +191,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
185
191
|
]
|
|
186
192
|
}
|
|
187
193
|
);
|
|
188
|
-
var ActivityIcon = /* @__PURE__ */
|
|
194
|
+
var ActivityIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
189
195
|
"svg",
|
|
190
196
|
{
|
|
191
197
|
style: {
|
|
@@ -199,15 +205,15 @@ var ActivityIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
|
199
205
|
xmlns: "http://www.w3.org/2000/svg",
|
|
200
206
|
fill: "currentColor",
|
|
201
207
|
children: [
|
|
202
|
-
/* @__PURE__ */
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
/* @__PURE__ */
|
|
208
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1", cx: "4", cy: "12", r: "3" }),
|
|
209
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot2", cx: "12", cy: "12", r: "3" }),
|
|
210
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot3", cx: "20", cy: "12", r: "3" })
|
|
205
211
|
]
|
|
206
212
|
}
|
|
207
213
|
);
|
|
208
214
|
function CheckIcon(_a) {
|
|
209
215
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
210
|
-
return /* @__PURE__ */
|
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
211
217
|
"svg",
|
|
212
218
|
__spreadProps(__spreadValues({
|
|
213
219
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -216,13 +222,13 @@ function CheckIcon(_a) {
|
|
|
216
222
|
style: { height: "1rem", width: "1rem" },
|
|
217
223
|
className
|
|
218
224
|
}, props), {
|
|
219
|
-
children: /* @__PURE__ */
|
|
225
|
+
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
226
|
})
|
|
221
227
|
);
|
|
222
228
|
}
|
|
223
229
|
function DownloadIcon(_a) {
|
|
224
230
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
225
|
-
return /* @__PURE__ */
|
|
231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
226
232
|
"svg",
|
|
227
233
|
__spreadProps(__spreadValues({
|
|
228
234
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -231,13 +237,13 @@ function DownloadIcon(_a) {
|
|
|
231
237
|
style: { height: "1rem", width: "1rem" },
|
|
232
238
|
className
|
|
233
239
|
}, props), {
|
|
234
|
-
children: /* @__PURE__ */
|
|
240
|
+
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
241
|
})
|
|
236
242
|
);
|
|
237
243
|
}
|
|
238
244
|
function CopyIcon(_a) {
|
|
239
245
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
240
|
-
return /* @__PURE__ */
|
|
246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
241
247
|
"svg",
|
|
242
248
|
__spreadProps(__spreadValues({
|
|
243
249
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -246,33 +252,36 @@ function CopyIcon(_a) {
|
|
|
246
252
|
style: { height: "1rem", width: "1rem" },
|
|
247
253
|
className
|
|
248
254
|
}, props), {
|
|
249
|
-
children: /* @__PURE__ */
|
|
255
|
+
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
256
|
})
|
|
251
257
|
);
|
|
252
258
|
}
|
|
253
|
-
var StopIcon = /* @__PURE__ */
|
|
259
|
+
var StopIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
254
260
|
"svg",
|
|
255
261
|
{
|
|
256
262
|
xmlns: "http://www.w3.org/2000/svg",
|
|
257
263
|
viewBox: "0 0 256 256",
|
|
258
264
|
fill: "currentColor",
|
|
259
265
|
style: { height: "1rem", width: "1rem" },
|
|
260
|
-
children: /* @__PURE__ */
|
|
266
|
+
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
267
|
}
|
|
262
268
|
);
|
|
263
|
-
var RegenerateIcon = /* @__PURE__ */
|
|
269
|
+
var RegenerateIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
264
270
|
"svg",
|
|
265
271
|
{
|
|
266
272
|
xmlns: "http://www.w3.org/2000/svg",
|
|
267
273
|
viewBox: "0 0 256 256",
|
|
268
274
|
fill: "currentColor",
|
|
269
275
|
style: { height: "1rem", width: "1rem" },
|
|
270
|
-
children: /* @__PURE__ */
|
|
276
|
+
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
277
|
}
|
|
272
278
|
);
|
|
273
|
-
|
|
279
|
+
|
|
280
|
+
// src/components/chat/ChatContext.tsx
|
|
281
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
282
|
+
var ChatContext = import_react.default.createContext(void 0);
|
|
274
283
|
function useChatContext() {
|
|
275
|
-
const context =
|
|
284
|
+
const context = import_react.default.useContext(ChatContext);
|
|
276
285
|
if (context === void 0) {
|
|
277
286
|
throw new Error(
|
|
278
287
|
"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
|
|
@@ -288,7 +297,7 @@ var ChatContextProvider = ({
|
|
|
288
297
|
icons,
|
|
289
298
|
children
|
|
290
299
|
}) => {
|
|
291
|
-
const context =
|
|
300
|
+
const context = (0, import_react.useMemo)(
|
|
292
301
|
() => ({
|
|
293
302
|
labels: __spreadValues(__spreadValues({}, {
|
|
294
303
|
initial: "",
|
|
@@ -315,8 +324,15 @@ var ChatContextProvider = ({
|
|
|
315
324
|
}),
|
|
316
325
|
[labels, icons]
|
|
317
326
|
);
|
|
318
|
-
return /* @__PURE__ */
|
|
327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChatContext.Provider, { value: context, children });
|
|
319
328
|
};
|
|
329
|
+
|
|
330
|
+
// src/components/chat/Chat.tsx
|
|
331
|
+
var import_react_core = require("@copilotkit/react-core");
|
|
332
|
+
|
|
333
|
+
// src/components/chat/Window.tsx
|
|
334
|
+
var import_react2 = __toESM(require("react"));
|
|
335
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
320
336
|
var Window = ({
|
|
321
337
|
open,
|
|
322
338
|
setOpen,
|
|
@@ -325,8 +341,8 @@ var Window = ({
|
|
|
325
341
|
hotkey,
|
|
326
342
|
hitEscapeToClose
|
|
327
343
|
}) => {
|
|
328
|
-
const windowRef =
|
|
329
|
-
const handleClickOutside =
|
|
344
|
+
const windowRef = import_react2.default.useRef(null);
|
|
345
|
+
const handleClickOutside = (0, import_react2.useCallback)(
|
|
330
346
|
(event) => {
|
|
331
347
|
var _a;
|
|
332
348
|
if (!clickOutsideToClose) {
|
|
@@ -339,7 +355,7 @@ var Window = ({
|
|
|
339
355
|
},
|
|
340
356
|
[clickOutsideToClose, open, setOpen]
|
|
341
357
|
);
|
|
342
|
-
const handleKeyDown =
|
|
358
|
+
const handleKeyDown = (0, import_react2.useCallback)(
|
|
343
359
|
(event) => {
|
|
344
360
|
var _a;
|
|
345
361
|
const target = event.target;
|
|
@@ -353,7 +369,7 @@ var Window = ({
|
|
|
353
369
|
},
|
|
354
370
|
[hitEscapeToClose, hotkey, open, setOpen]
|
|
355
371
|
);
|
|
356
|
-
const adjustForMobile =
|
|
372
|
+
const adjustForMobile = (0, import_react2.useCallback)(() => {
|
|
357
373
|
const copilotKitWindow = windowRef.current;
|
|
358
374
|
const vv = window.visualViewport;
|
|
359
375
|
if (!copilotKitWindow || !vv) {
|
|
@@ -384,7 +400,7 @@ var Window = ({
|
|
|
384
400
|
document.body.removeEventListener("touchmove", preventScroll);
|
|
385
401
|
}
|
|
386
402
|
}, [open]);
|
|
387
|
-
|
|
403
|
+
(0, import_react2.useEffect)(() => {
|
|
388
404
|
document.addEventListener("mousedown", handleClickOutside);
|
|
389
405
|
document.addEventListener("keydown", handleKeyDown);
|
|
390
406
|
if (window.visualViewport) {
|
|
@@ -399,7 +415,7 @@ var Window = ({
|
|
|
399
415
|
}
|
|
400
416
|
};
|
|
401
417
|
}, [adjustForMobile, handleClickOutside, handleKeyDown]);
|
|
402
|
-
return /* @__PURE__ */
|
|
418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `copilotKitWindow${open ? " open" : ""}`, ref: windowRef, children });
|
|
403
419
|
};
|
|
404
420
|
var preventScroll = (event) => {
|
|
405
421
|
let targetElement = event.target;
|
|
@@ -419,29 +435,51 @@ var preventScroll = (event) => {
|
|
|
419
435
|
function isMacOS() {
|
|
420
436
|
return /Mac|iMac|Macintosh/i.test(navigator.userAgent);
|
|
421
437
|
}
|
|
438
|
+
|
|
439
|
+
// src/components/chat/Button.tsx
|
|
440
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
422
441
|
var Button = ({ open, setOpen }) => {
|
|
423
442
|
const context = useChatContext();
|
|
424
|
-
return /* @__PURE__ */
|
|
443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
425
444
|
"button",
|
|
426
445
|
{
|
|
427
446
|
className: `copilotKitButton ${open ? "open" : ""}`,
|
|
428
447
|
"aria-label": open ? "Close Chat" : "Open Chat",
|
|
429
448
|
children: [
|
|
430
|
-
/* @__PURE__ */
|
|
431
|
-
/* @__PURE__ */
|
|
449
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconOpen", children: context.icons.openIcon }),
|
|
450
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconClose", children: context.icons.closeIcon })
|
|
432
451
|
]
|
|
433
452
|
}
|
|
434
453
|
) });
|
|
435
454
|
};
|
|
455
|
+
|
|
456
|
+
// src/components/chat/Header.tsx
|
|
457
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
436
458
|
var Header = ({ setOpen }) => {
|
|
437
459
|
const context = useChatContext();
|
|
438
|
-
return /* @__PURE__ */
|
|
439
|
-
/* @__PURE__ */
|
|
440
|
-
/* @__PURE__ */
|
|
460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "copilotKitHeader", children: [
|
|
461
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: context.labels.title }),
|
|
462
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { onClick: () => setOpen(false), "aria-label": "Close", children: context.icons.headerCloseIcon })
|
|
441
463
|
] });
|
|
442
464
|
};
|
|
465
|
+
|
|
466
|
+
// src/components/chat/Messages.tsx
|
|
467
|
+
var import_react5 = __toESM(require("react"));
|
|
468
|
+
var import_nanoid = require("nanoid");
|
|
469
|
+
|
|
470
|
+
// src/components/chat/Markdown.tsx
|
|
471
|
+
var import_react4 = require("react");
|
|
472
|
+
var import_react_markdown = __toESM(require("react-markdown"));
|
|
473
|
+
|
|
474
|
+
// src/components/chat/CodeBlock.tsx
|
|
475
|
+
var import_react3 = require("react");
|
|
476
|
+
var import_react_syntax_highlighter = require("react-syntax-highlighter");
|
|
477
|
+
var import_prism = require("react-syntax-highlighter/dist/esm/styles/prism");
|
|
478
|
+
|
|
479
|
+
// src/hooks/use-copy-to-clipboard.tsx
|
|
480
|
+
var React3 = __toESM(require("react"));
|
|
443
481
|
function useCopyToClipboard({ timeout = 2e3 }) {
|
|
444
|
-
const [isCopied, setIsCopied] =
|
|
482
|
+
const [isCopied, setIsCopied] = React3.useState(false);
|
|
445
483
|
const copyToClipboard = (value) => {
|
|
446
484
|
var _a;
|
|
447
485
|
if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
|
|
@@ -459,6 +497,9 @@ function useCopyToClipboard({ timeout = 2e3 }) {
|
|
|
459
497
|
};
|
|
460
498
|
return { isCopied, copyToClipboard };
|
|
461
499
|
}
|
|
500
|
+
|
|
501
|
+
// src/components/chat/CodeBlock.tsx
|
|
502
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
462
503
|
var programmingLanguages = {
|
|
463
504
|
javascript: ".js",
|
|
464
505
|
python: ".py",
|
|
@@ -493,7 +534,7 @@ var generateRandomString = (length, lowercase = false) => {
|
|
|
493
534
|
}
|
|
494
535
|
return lowercase ? result.toLowerCase() : result;
|
|
495
536
|
};
|
|
496
|
-
var CodeBlock =
|
|
537
|
+
var CodeBlock = (0, import_react3.memo)(({ language, value }) => {
|
|
497
538
|
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
498
539
|
const downloadAsFile = () => {
|
|
499
540
|
if (typeof window === "undefined") {
|
|
@@ -521,25 +562,25 @@ var CodeBlock = React.memo(({ language, value }) => {
|
|
|
521
562
|
return;
|
|
522
563
|
copyToClipboard(value);
|
|
523
564
|
};
|
|
524
|
-
return /* @__PURE__ */
|
|
525
|
-
/* @__PURE__ */
|
|
526
|
-
/* @__PURE__ */
|
|
527
|
-
/* @__PURE__ */
|
|
528
|
-
/* @__PURE__ */
|
|
529
|
-
/* @__PURE__ */
|
|
530
|
-
/* @__PURE__ */
|
|
565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlock", children: [
|
|
566
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
|
|
567
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
|
|
568
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
|
|
569
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
|
|
570
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DownloadIcon, {}),
|
|
571
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Download" })
|
|
531
572
|
] }),
|
|
532
|
-
/* @__PURE__ */
|
|
533
|
-
isCopied ? /* @__PURE__ */
|
|
534
|
-
/* @__PURE__ */
|
|
573
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
|
|
574
|
+
isCopied ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopyIcon, {}),
|
|
575
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Copy code" })
|
|
535
576
|
] })
|
|
536
577
|
] })
|
|
537
578
|
] }),
|
|
538
|
-
/* @__PURE__ */
|
|
539
|
-
|
|
579
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
580
|
+
import_react_syntax_highlighter.Prism,
|
|
540
581
|
{
|
|
541
582
|
language,
|
|
542
|
-
style:
|
|
583
|
+
style: import_prism.vscDarkPlus,
|
|
543
584
|
PreTag: "div",
|
|
544
585
|
customStyle: {
|
|
545
586
|
margin: 0,
|
|
@@ -552,22 +593,27 @@ var CodeBlock = React.memo(({ language, value }) => {
|
|
|
552
593
|
] });
|
|
553
594
|
});
|
|
554
595
|
CodeBlock.displayName = "CodeBlock";
|
|
555
|
-
|
|
556
|
-
|
|
596
|
+
|
|
597
|
+
// src/components/chat/Markdown.tsx
|
|
598
|
+
var import_remark_gfm = __toESM(require("remark-gfm"));
|
|
599
|
+
var import_remark_math = __toESM(require("remark-math"));
|
|
600
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
601
|
+
var MemoizedReactMarkdown = (0, import_react4.memo)(
|
|
602
|
+
import_react_markdown.default,
|
|
557
603
|
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
|
|
558
604
|
);
|
|
559
605
|
var Markdown = ({ content }) => {
|
|
560
|
-
return /* @__PURE__ */
|
|
606
|
+
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
607
|
};
|
|
562
608
|
var components = {
|
|
563
609
|
p({ children }) {
|
|
564
|
-
return /* @__PURE__ */
|
|
610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children });
|
|
565
611
|
},
|
|
566
612
|
code(_a) {
|
|
567
613
|
var _b = _a, { children, className, inline } = _b, props = __objRest(_b, ["children", "className", "inline"]);
|
|
568
614
|
if (children.length) {
|
|
569
615
|
if (children[0] == "\u258D") {
|
|
570
|
-
return /* @__PURE__ */
|
|
616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
571
617
|
"span",
|
|
572
618
|
{
|
|
573
619
|
style: {
|
|
@@ -582,9 +628,9 @@ var components = {
|
|
|
582
628
|
}
|
|
583
629
|
const match = /language-(\w+)/.exec(className || "");
|
|
584
630
|
if (inline) {
|
|
585
|
-
return /* @__PURE__ */
|
|
631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", __spreadProps(__spreadValues({ className }, props), { children }));
|
|
586
632
|
}
|
|
587
|
-
return /* @__PURE__ */
|
|
633
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
588
634
|
CodeBlock,
|
|
589
635
|
__spreadValues({
|
|
590
636
|
language: match && match[1] || "",
|
|
@@ -594,14 +640,17 @@ var components = {
|
|
|
594
640
|
);
|
|
595
641
|
}
|
|
596
642
|
};
|
|
643
|
+
|
|
644
|
+
// src/components/chat/Messages.tsx
|
|
645
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
597
646
|
var Messages = ({ messages, inProgress }) => {
|
|
598
647
|
const context = useChatContext();
|
|
599
|
-
const initialMessages =
|
|
648
|
+
const initialMessages = (0, import_react5.useMemo)(
|
|
600
649
|
() => makeInitialMessages(context.labels.initial),
|
|
601
650
|
[context.labels.initial]
|
|
602
651
|
);
|
|
603
652
|
messages = [...initialMessages, ...messages];
|
|
604
|
-
const messagesEndRef =
|
|
653
|
+
const messagesEndRef = import_react5.default.useRef(null);
|
|
605
654
|
const scrollToBottom = () => {
|
|
606
655
|
if (messagesEndRef.current) {
|
|
607
656
|
messagesEndRef.current.scrollIntoView({
|
|
@@ -609,25 +658,25 @@ var Messages = ({ messages, inProgress }) => {
|
|
|
609
658
|
});
|
|
610
659
|
}
|
|
611
660
|
};
|
|
612
|
-
|
|
661
|
+
(0, import_react5.useEffect)(() => {
|
|
613
662
|
scrollToBottom();
|
|
614
663
|
}, [messages]);
|
|
615
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "copilotKitMessages", children: [
|
|
616
665
|
messages.map((message, index) => {
|
|
617
666
|
const isCurrentMessage = index === messages.length - 1;
|
|
618
667
|
if (message.role === "user") {
|
|
619
|
-
return /* @__PURE__ */
|
|
668
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
|
|
620
669
|
} else if (message.role == "assistant") {
|
|
621
670
|
if (isCurrentMessage && inProgress && !message.content) {
|
|
622
|
-
return /* @__PURE__ */
|
|
671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
|
|
623
672
|
} else if ((!inProgress || index != messages.length - 1) && !message.content && message.function_call) {
|
|
624
|
-
return /* @__PURE__ */
|
|
673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.labels.done }, index);
|
|
625
674
|
} else {
|
|
626
|
-
return /* @__PURE__ */
|
|
675
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Markdown, { content: message.content }) }, index);
|
|
627
676
|
}
|
|
628
677
|
}
|
|
629
678
|
}),
|
|
630
|
-
/* @__PURE__ */
|
|
679
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: messagesEndRef })
|
|
631
680
|
] });
|
|
632
681
|
};
|
|
633
682
|
function makeInitialMessages(initial) {
|
|
@@ -640,17 +689,24 @@ function makeInitialMessages(initial) {
|
|
|
640
689
|
}
|
|
641
690
|
}
|
|
642
691
|
return initialArray.map((message) => ({
|
|
643
|
-
id:
|
|
692
|
+
id: (0, import_nanoid.nanoid)(),
|
|
644
693
|
role: "assistant",
|
|
645
694
|
content: message
|
|
646
695
|
}));
|
|
647
696
|
}
|
|
648
|
-
|
|
697
|
+
|
|
698
|
+
// src/components/chat/Input.tsx
|
|
699
|
+
var import_react7 = require("react");
|
|
700
|
+
|
|
701
|
+
// src/components/chat/Textarea.tsx
|
|
702
|
+
var import_react6 = require("react");
|
|
703
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
704
|
+
var AutoResizingTextarea = (0, import_react6.forwardRef)(
|
|
649
705
|
({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {
|
|
650
|
-
const internalTextareaRef =
|
|
651
|
-
const [maxHeight, setMaxHeight] =
|
|
652
|
-
|
|
653
|
-
|
|
706
|
+
const internalTextareaRef = (0, import_react6.useRef)(null);
|
|
707
|
+
const [maxHeight, setMaxHeight] = (0, import_react6.useState)(0);
|
|
708
|
+
(0, import_react6.useImperativeHandle)(ref, () => internalTextareaRef.current);
|
|
709
|
+
(0, import_react6.useEffect)(() => {
|
|
654
710
|
const calculateMaxHeight = () => {
|
|
655
711
|
const textarea = internalTextareaRef.current;
|
|
656
712
|
if (textarea) {
|
|
@@ -664,14 +720,14 @@ var AutoResizingTextarea = React.forwardRef(
|
|
|
664
720
|
};
|
|
665
721
|
calculateMaxHeight();
|
|
666
722
|
}, [maxRows]);
|
|
667
|
-
|
|
723
|
+
(0, import_react6.useEffect)(() => {
|
|
668
724
|
const textarea = internalTextareaRef.current;
|
|
669
725
|
if (textarea) {
|
|
670
726
|
textarea.style.height = "auto";
|
|
671
727
|
textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
|
|
672
728
|
}
|
|
673
729
|
}, [value, maxHeight]);
|
|
674
|
-
return /* @__PURE__ */
|
|
730
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
675
731
|
"textarea",
|
|
676
732
|
{
|
|
677
733
|
ref: internalTextareaRef,
|
|
@@ -690,16 +746,19 @@ var AutoResizingTextarea = React.forwardRef(
|
|
|
690
746
|
}
|
|
691
747
|
);
|
|
692
748
|
var Textarea_default = AutoResizingTextarea;
|
|
749
|
+
|
|
750
|
+
// src/components/chat/Input.tsx
|
|
751
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
693
752
|
var Input = ({ inProgress, onSend, children }) => {
|
|
694
753
|
const context = useChatContext();
|
|
695
|
-
const textareaRef =
|
|
754
|
+
const textareaRef = (0, import_react7.useRef)(null);
|
|
696
755
|
const handleDivClick = (event) => {
|
|
697
756
|
var _a;
|
|
698
757
|
if (event.target !== event.currentTarget)
|
|
699
758
|
return;
|
|
700
759
|
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
701
760
|
};
|
|
702
|
-
const [text, setText] =
|
|
761
|
+
const [text, setText] = (0, import_react7.useState)("");
|
|
703
762
|
const send = () => {
|
|
704
763
|
var _a;
|
|
705
764
|
if (inProgress)
|
|
@@ -710,10 +769,10 @@ var Input = ({ inProgress, onSend, children }) => {
|
|
|
710
769
|
};
|
|
711
770
|
const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;
|
|
712
771
|
const disabled = inProgress || text.length === 0;
|
|
713
|
-
return /* @__PURE__ */
|
|
714
|
-
/* @__PURE__ */
|
|
715
|
-
/* @__PURE__ */
|
|
716
|
-
/* @__PURE__ */
|
|
772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
|
|
773
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children }),
|
|
774
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
|
|
775
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
717
776
|
Textarea_default,
|
|
718
777
|
{
|
|
719
778
|
ref: textareaRef,
|
|
@@ -732,13 +791,22 @@ var Input = ({ inProgress, onSend, children }) => {
|
|
|
732
791
|
)
|
|
733
792
|
] });
|
|
734
793
|
};
|
|
794
|
+
|
|
795
|
+
// src/components/chat/Chat.tsx
|
|
796
|
+
var import_nanoid2 = require("nanoid");
|
|
797
|
+
|
|
798
|
+
// src/components/chat/Response.tsx
|
|
799
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
735
800
|
var ResponseButton = ({ onClick, inProgress }) => {
|
|
736
801
|
const context = useChatContext();
|
|
737
|
-
return /* @__PURE__ */
|
|
738
|
-
/* @__PURE__ */
|
|
802
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("button", { onClick, className: "copilotKitResponseButton", children: [
|
|
803
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: inProgress ? context.icons.stopIcon : context.icons.regenerateIcon }),
|
|
739
804
|
inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse
|
|
740
805
|
] });
|
|
741
806
|
};
|
|
807
|
+
|
|
808
|
+
// src/components/chat/Chat.tsx
|
|
809
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
742
810
|
var CopilotChat = ({
|
|
743
811
|
instructions,
|
|
744
812
|
defaultOpen = false,
|
|
@@ -758,26 +826,26 @@ var CopilotChat = ({
|
|
|
758
826
|
ResponseButton: ResponseButton2 = ResponseButton,
|
|
759
827
|
className
|
|
760
828
|
}) => {
|
|
761
|
-
const { visibleMessages, append, reload, stop, isLoading, input, setInput } =
|
|
762
|
-
id:
|
|
829
|
+
const { visibleMessages, append, reload, stop, isLoading, input, setInput } = (0, import_react_core.useCopilotChat)({
|
|
830
|
+
id: (0, import_nanoid2.nanoid)(),
|
|
763
831
|
makeSystemMessage,
|
|
764
832
|
additionalInstructions: instructions
|
|
765
833
|
});
|
|
766
|
-
const [openState, setOpenState] =
|
|
834
|
+
const [openState, setOpenState] = import_react8.default.useState(defaultOpen);
|
|
767
835
|
const setOpen = (open) => {
|
|
768
836
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
769
837
|
setOpenState(open);
|
|
770
838
|
};
|
|
771
839
|
const sendMessage = (message) => __async(void 0, null, function* () {
|
|
772
840
|
append({
|
|
773
|
-
id:
|
|
841
|
+
id: (0, import_nanoid2.nanoid)(),
|
|
774
842
|
content: message,
|
|
775
843
|
role: "user"
|
|
776
844
|
});
|
|
777
845
|
});
|
|
778
|
-
return /* @__PURE__ */
|
|
779
|
-
/* @__PURE__ */
|
|
780
|
-
/* @__PURE__ */
|
|
846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChatContextProvider, { icons, labels, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className, children: [
|
|
847
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button2, { open: openState, setOpen }),
|
|
848
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
781
849
|
Window2,
|
|
782
850
|
{
|
|
783
851
|
open: openState,
|
|
@@ -786,19 +854,22 @@ var CopilotChat = ({
|
|
|
786
854
|
hotkey,
|
|
787
855
|
hitEscapeToClose,
|
|
788
856
|
children: [
|
|
789
|
-
/* @__PURE__ */
|
|
790
|
-
/* @__PURE__ */
|
|
791
|
-
/* @__PURE__ */
|
|
857
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Header2, { open: openState, setOpen }),
|
|
858
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Messages2, { messages: visibleMessages, inProgress: isLoading }),
|
|
859
|
+
/* @__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
860
|
]
|
|
793
861
|
}
|
|
794
862
|
)
|
|
795
863
|
] }) });
|
|
796
864
|
};
|
|
865
|
+
|
|
866
|
+
// src/components/chat/Sidebar.tsx
|
|
867
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
797
868
|
var CopilotSidebar = (props) => {
|
|
798
869
|
props = __spreadProps(__spreadValues({}, props), {
|
|
799
870
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
800
871
|
});
|
|
801
|
-
const [expandedClassName, setExpandedClassName] =
|
|
872
|
+
const [expandedClassName, setExpandedClassName] = (0, import_react9.useState)(
|
|
802
873
|
props.defaultOpen ? "sidebarExpanded" : ""
|
|
803
874
|
);
|
|
804
875
|
const onSetOpen = (open) => {
|
|
@@ -806,12 +877,13 @@ var CopilotSidebar = (props) => {
|
|
|
806
877
|
(_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
|
|
807
878
|
setExpandedClassName(open ? "sidebarExpanded" : "");
|
|
808
879
|
};
|
|
809
|
-
return /* @__PURE__ */
|
|
880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: [
|
|
810
881
|
props.children,
|
|
811
|
-
/* @__PURE__ */
|
|
882
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CopilotChat, __spreadValues(__spreadValues({}, props), { onSetOpen }))
|
|
812
883
|
] });
|
|
813
884
|
};
|
|
814
|
-
|
|
815
|
-
exports
|
|
816
|
-
|
|
885
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
886
|
+
0 && (module.exports = {
|
|
887
|
+
CopilotSidebar
|
|
888
|
+
});
|
|
817
889
|
//# sourceMappingURL=Sidebar.js.map
|