@copilotkit/react-ui 1.3.2 → 1.3.3-pre.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 +10 -0
- package/dist/{chunk-PGJGIYRW.mjs → chunk-3YESXHJH.mjs} +3 -3
- package/dist/{chunk-I454U2HM.mjs → chunk-BTOVRBBW.mjs} +52 -25
- package/dist/chunk-BTOVRBBW.mjs.map +1 -0
- package/dist/chunk-GDNJRSD4.mjs +126 -0
- package/dist/chunk-GDNJRSD4.mjs.map +1 -0
- package/dist/{chunk-N6GQ4WV4.mjs → chunk-GHMYWL42.mjs} +2 -2
- package/dist/{chunk-N6GQ4WV4.mjs.map → chunk-GHMYWL42.mjs.map} +1 -1
- package/dist/chunk-GOTHQ665.mjs +19 -0
- package/dist/chunk-GOTHQ665.mjs.map +1 -0
- package/dist/chunk-MA5B5ELM.mjs +26 -0
- package/dist/chunk-MA5B5ELM.mjs.map +1 -0
- package/dist/chunk-U42OB2S3.mjs +61 -0
- package/dist/chunk-U42OB2S3.mjs.map +1 -0
- package/dist/{chunk-KJQVEUVB.mjs → chunk-UUHCZZZV.mjs} +2 -2
- package/dist/chunk-UUHCZZZV.mjs.map +1 -0
- package/dist/chunk-YH2STM73.mjs +76 -0
- package/dist/chunk-YH2STM73.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +18 -2
- package/dist/components/chat/Chat.js +664 -556
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +6 -2
- package/dist/components/chat/Messages.d.ts +1 -1
- package/dist/components/chat/Messages.js +61 -662
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +1 -4
- package/dist/components/chat/Modal.js +669 -561
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +7 -3
- package/dist/components/chat/Popup.js +669 -561
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +8 -4
- package/dist/components/chat/Sidebar.js +669 -561
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +8 -4
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/chat/index.js +669 -561
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +9 -5
- package/dist/components/chat/messages/RenderActionExecutionMessage.d.ts +7 -0
- package/dist/components/chat/messages/RenderActionExecutionMessage.js +122 -0
- package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +10 -0
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs.map +1 -0
- package/dist/components/chat/messages/RenderAgentStateMessage.d.ts +7 -0
- package/dist/components/chat/messages/RenderAgentStateMessage.js +107 -0
- package/dist/components/chat/messages/RenderAgentStateMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderAgentStateMessage.mjs +10 -0
- package/dist/components/chat/messages/RenderAgentStateMessage.mjs.map +1 -0
- package/dist/components/chat/messages/RenderResultMessage.d.ts +7 -0
- package/dist/components/chat/messages/RenderResultMessage.js +65 -0
- package/dist/components/chat/messages/RenderResultMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderResultMessage.mjs +10 -0
- package/dist/components/chat/messages/RenderResultMessage.mjs.map +1 -0
- package/dist/components/chat/messages/RenderTextMessage.d.ts +7 -0
- package/dist/components/chat/messages/RenderTextMessage.js +614 -0
- package/dist/components/chat/messages/RenderTextMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderTextMessage.mjs +13 -0
- package/dist/components/chat/messages/RenderTextMessage.mjs.map +1 -0
- package/dist/components/chat/props.d.ts +12 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +669 -561
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +9 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +677 -569
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -5
- package/package.json +7 -7
- package/src/components/chat/Chat.tsx +39 -4
- package/src/components/chat/Messages.tsx +45 -175
- package/src/components/chat/Popup.tsx +2 -2
- package/src/components/chat/Sidebar.tsx +2 -2
- package/src/components/chat/messages/RenderActionExecutionMessage.tsx +90 -0
- package/src/components/chat/messages/RenderAgentStateMessage.tsx +81 -0
- package/src/components/chat/messages/RenderResultMessage.tsx +15 -0
- package/src/components/chat/messages/RenderTextMessage.tsx +28 -0
- package/src/components/chat/props.ts +12 -0
- package/dist/chunk-4K36ATCD.mjs +0 -184
- package/dist/chunk-4K36ATCD.mjs.map +0 -1
- package/dist/chunk-I454U2HM.mjs.map +0 -1
- package/dist/chunk-KJQVEUVB.mjs.map +0 -1
- /package/dist/{chunk-PGJGIYRW.mjs.map → chunk-3YESXHJH.mjs.map} +0 -0
|
@@ -1,39 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
-
var __objRest = (source, exclude) => {
|
|
26
|
-
var target = {};
|
|
27
|
-
for (var prop in source)
|
|
28
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
if (source != null && __getOwnPropSymbols)
|
|
31
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
-
target[prop] = source[prop];
|
|
34
|
-
}
|
|
35
|
-
return target;
|
|
36
|
-
};
|
|
37
8
|
var __export = (target, all) => {
|
|
38
9
|
for (var name in all)
|
|
39
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -62,61 +33,11 @@ __export(Messages_exports, {
|
|
|
62
33
|
Messages: () => Messages
|
|
63
34
|
});
|
|
64
35
|
module.exports = __toCommonJS(Messages_exports);
|
|
65
|
-
var
|
|
36
|
+
var import_react2 = __toESM(require("react"));
|
|
66
37
|
|
|
67
38
|
// src/components/chat/ChatContext.tsx
|
|
68
39
|
var import_react = __toESM(require("react"));
|
|
69
|
-
|
|
70
|
-
// src/components/chat/Icons.tsx
|
|
71
40
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
72
|
-
function CheckIcon(_a) {
|
|
73
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
74
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
75
|
-
"svg",
|
|
76
|
-
__spreadProps(__spreadValues({
|
|
77
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
78
|
-
viewBox: "0 0 256 256",
|
|
79
|
-
fill: "currentColor",
|
|
80
|
-
style: { height: "1rem", width: "1rem" },
|
|
81
|
-
className
|
|
82
|
-
}, props), {
|
|
83
|
-
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" })
|
|
84
|
-
})
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
function DownloadIcon(_a) {
|
|
88
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
89
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
90
|
-
"svg",
|
|
91
|
-
__spreadProps(__spreadValues({
|
|
92
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
93
|
-
viewBox: "0 0 256 256",
|
|
94
|
-
fill: "currentColor",
|
|
95
|
-
style: { height: "1rem", width: "1rem" },
|
|
96
|
-
className
|
|
97
|
-
}, props), {
|
|
98
|
-
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" })
|
|
99
|
-
})
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
function CopyIcon(_a) {
|
|
103
|
-
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
104
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
105
|
-
"svg",
|
|
106
|
-
__spreadProps(__spreadValues({
|
|
107
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
108
|
-
viewBox: "0 0 256 256",
|
|
109
|
-
fill: "currentColor",
|
|
110
|
-
style: { height: "1rem", width: "1rem" },
|
|
111
|
-
className
|
|
112
|
-
}, props), {
|
|
113
|
-
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" })
|
|
114
|
-
})
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// src/components/chat/ChatContext.tsx
|
|
119
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
120
41
|
var ChatContext = import_react.default.createContext(void 0);
|
|
121
42
|
function useChatContext() {
|
|
122
43
|
const context = import_react.default.useContext(ChatContext);
|
|
@@ -128,487 +49,25 @@ function useChatContext() {
|
|
|
128
49
|
return context;
|
|
129
50
|
}
|
|
130
51
|
|
|
131
|
-
// src/components/chat/Markdown.tsx
|
|
132
|
-
var import_react3 = require("react");
|
|
133
|
-
var import_react_markdown = __toESM(require("react-markdown"));
|
|
134
|
-
|
|
135
|
-
// src/components/chat/CodeBlock.tsx
|
|
136
|
-
var import_react2 = require("react");
|
|
137
|
-
var import_react_syntax_highlighter = require("react-syntax-highlighter");
|
|
138
|
-
|
|
139
|
-
// src/hooks/use-copy-to-clipboard.tsx
|
|
140
|
-
var React2 = __toESM(require("react"));
|
|
141
|
-
function useCopyToClipboard({ timeout = 2e3 }) {
|
|
142
|
-
const [isCopied, setIsCopied] = React2.useState(false);
|
|
143
|
-
const copyToClipboard = (value) => {
|
|
144
|
-
var _a;
|
|
145
|
-
if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (!value) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
navigator.clipboard.writeText(value).then(() => {
|
|
152
|
-
setIsCopied(true);
|
|
153
|
-
setTimeout(() => {
|
|
154
|
-
setIsCopied(false);
|
|
155
|
-
}, timeout);
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
return { isCopied, copyToClipboard };
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// src/components/chat/CodeBlock.tsx
|
|
162
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
163
|
-
var programmingLanguages = {
|
|
164
|
-
javascript: ".js",
|
|
165
|
-
python: ".py",
|
|
166
|
-
java: ".java",
|
|
167
|
-
c: ".c",
|
|
168
|
-
cpp: ".cpp",
|
|
169
|
-
"c++": ".cpp",
|
|
170
|
-
"c#": ".cs",
|
|
171
|
-
ruby: ".rb",
|
|
172
|
-
php: ".php",
|
|
173
|
-
swift: ".swift",
|
|
174
|
-
"objective-c": ".m",
|
|
175
|
-
kotlin: ".kt",
|
|
176
|
-
typescript: ".ts",
|
|
177
|
-
go: ".go",
|
|
178
|
-
perl: ".pl",
|
|
179
|
-
rust: ".rs",
|
|
180
|
-
scala: ".scala",
|
|
181
|
-
haskell: ".hs",
|
|
182
|
-
lua: ".lua",
|
|
183
|
-
shell: ".sh",
|
|
184
|
-
sql: ".sql",
|
|
185
|
-
html: ".html",
|
|
186
|
-
css: ".css"
|
|
187
|
-
// add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
|
|
188
|
-
};
|
|
189
|
-
var generateRandomString = (length, lowercase = false) => {
|
|
190
|
-
const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
|
|
191
|
-
let result = "";
|
|
192
|
-
for (let i = 0; i < length; i++) {
|
|
193
|
-
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
194
|
-
}
|
|
195
|
-
return lowercase ? result.toLowerCase() : result;
|
|
196
|
-
};
|
|
197
|
-
var CodeBlock = (0, import_react2.memo)(({ language, value }) => {
|
|
198
|
-
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
199
|
-
const downloadAsFile = () => {
|
|
200
|
-
if (typeof window === "undefined") {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
const fileExtension = programmingLanguages[language] || ".file";
|
|
204
|
-
const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
|
|
205
|
-
const fileName = window.prompt("Enter file name", suggestedFileName);
|
|
206
|
-
if (!fileName) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const blob = new Blob([value], { type: "text/plain" });
|
|
210
|
-
const url = URL.createObjectURL(blob);
|
|
211
|
-
const link = document.createElement("a");
|
|
212
|
-
link.download = fileName;
|
|
213
|
-
link.href = url;
|
|
214
|
-
link.style.display = "none";
|
|
215
|
-
document.body.appendChild(link);
|
|
216
|
-
link.click();
|
|
217
|
-
document.body.removeChild(link);
|
|
218
|
-
URL.revokeObjectURL(url);
|
|
219
|
-
};
|
|
220
|
-
const onCopy = () => {
|
|
221
|
-
if (isCopied)
|
|
222
|
-
return;
|
|
223
|
-
copyToClipboard(value);
|
|
224
|
-
};
|
|
225
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "copilotKitCodeBlock", children: [
|
|
226
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
|
|
227
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
|
|
228
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
|
|
229
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
|
|
230
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DownloadIcon, {}),
|
|
231
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sr-only", children: "Download" })
|
|
232
|
-
] }),
|
|
233
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
|
|
234
|
-
isCopied ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CheckIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CopyIcon, {}),
|
|
235
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sr-only", children: "Copy code" })
|
|
236
|
-
] })
|
|
237
|
-
] })
|
|
238
|
-
] }),
|
|
239
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
240
|
-
import_react_syntax_highlighter.Prism,
|
|
241
|
-
{
|
|
242
|
-
language,
|
|
243
|
-
style: highlightStyle,
|
|
244
|
-
PreTag: "div",
|
|
245
|
-
customStyle: {
|
|
246
|
-
margin: 0,
|
|
247
|
-
borderBottomLeftRadius: "0.375rem",
|
|
248
|
-
borderBottomRightRadius: "0.375rem"
|
|
249
|
-
},
|
|
250
|
-
children: value
|
|
251
|
-
}
|
|
252
|
-
)
|
|
253
|
-
] });
|
|
254
|
-
});
|
|
255
|
-
CodeBlock.displayName = "CodeBlock";
|
|
256
|
-
var highlightStyle = {
|
|
257
|
-
'pre[class*="language-"]': {
|
|
258
|
-
color: "#d4d4d4",
|
|
259
|
-
fontSize: "13px",
|
|
260
|
-
textShadow: "none",
|
|
261
|
-
fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
|
|
262
|
-
direction: "ltr",
|
|
263
|
-
textAlign: "left",
|
|
264
|
-
whiteSpace: "pre",
|
|
265
|
-
wordSpacing: "normal",
|
|
266
|
-
wordBreak: "normal",
|
|
267
|
-
lineHeight: "1.5",
|
|
268
|
-
MozTabSize: "4",
|
|
269
|
-
OTabSize: "4",
|
|
270
|
-
tabSize: "4",
|
|
271
|
-
WebkitHyphens: "none",
|
|
272
|
-
MozHyphens: "none",
|
|
273
|
-
msHyphens: "none",
|
|
274
|
-
hyphens: "none",
|
|
275
|
-
padding: "1em",
|
|
276
|
-
margin: ".5em 0",
|
|
277
|
-
overflow: "auto",
|
|
278
|
-
background: "#1e1e1e"
|
|
279
|
-
},
|
|
280
|
-
'code[class*="language-"]': {
|
|
281
|
-
color: "#d4d4d4",
|
|
282
|
-
fontSize: "13px",
|
|
283
|
-
textShadow: "none",
|
|
284
|
-
fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
|
|
285
|
-
direction: "ltr",
|
|
286
|
-
textAlign: "left",
|
|
287
|
-
whiteSpace: "pre",
|
|
288
|
-
wordSpacing: "normal",
|
|
289
|
-
wordBreak: "normal",
|
|
290
|
-
lineHeight: "1.5",
|
|
291
|
-
MozTabSize: "4",
|
|
292
|
-
OTabSize: "4",
|
|
293
|
-
tabSize: "4",
|
|
294
|
-
WebkitHyphens: "none",
|
|
295
|
-
MozHyphens: "none",
|
|
296
|
-
msHyphens: "none",
|
|
297
|
-
hyphens: "none"
|
|
298
|
-
},
|
|
299
|
-
'pre[class*="language-"]::selection': {
|
|
300
|
-
textShadow: "none",
|
|
301
|
-
background: "#264F78"
|
|
302
|
-
},
|
|
303
|
-
'code[class*="language-"]::selection': {
|
|
304
|
-
textShadow: "none",
|
|
305
|
-
background: "#264F78"
|
|
306
|
-
},
|
|
307
|
-
'pre[class*="language-"] *::selection': {
|
|
308
|
-
textShadow: "none",
|
|
309
|
-
background: "#264F78"
|
|
310
|
-
},
|
|
311
|
-
'code[class*="language-"] *::selection': {
|
|
312
|
-
textShadow: "none",
|
|
313
|
-
background: "#264F78"
|
|
314
|
-
},
|
|
315
|
-
':not(pre) > code[class*="language-"]': {
|
|
316
|
-
padding: ".1em .3em",
|
|
317
|
-
borderRadius: ".3em",
|
|
318
|
-
color: "#db4c69",
|
|
319
|
-
background: "#1e1e1e"
|
|
320
|
-
},
|
|
321
|
-
".namespace": {
|
|
322
|
-
Opacity: ".7"
|
|
323
|
-
},
|
|
324
|
-
"doctype.doctype-tag": {
|
|
325
|
-
color: "#569CD6"
|
|
326
|
-
},
|
|
327
|
-
"doctype.name": {
|
|
328
|
-
color: "#9cdcfe"
|
|
329
|
-
},
|
|
330
|
-
comment: {
|
|
331
|
-
color: "#6a9955"
|
|
332
|
-
},
|
|
333
|
-
prolog: {
|
|
334
|
-
color: "#6a9955"
|
|
335
|
-
},
|
|
336
|
-
punctuation: {
|
|
337
|
-
color: "#d4d4d4"
|
|
338
|
-
},
|
|
339
|
-
".language-html .language-css .token.punctuation": {
|
|
340
|
-
color: "#d4d4d4"
|
|
341
|
-
},
|
|
342
|
-
".language-html .language-javascript .token.punctuation": {
|
|
343
|
-
color: "#d4d4d4"
|
|
344
|
-
},
|
|
345
|
-
property: {
|
|
346
|
-
color: "#9cdcfe"
|
|
347
|
-
},
|
|
348
|
-
tag: {
|
|
349
|
-
color: "#569cd6"
|
|
350
|
-
},
|
|
351
|
-
boolean: {
|
|
352
|
-
color: "#569cd6"
|
|
353
|
-
},
|
|
354
|
-
number: {
|
|
355
|
-
color: "#b5cea8"
|
|
356
|
-
},
|
|
357
|
-
constant: {
|
|
358
|
-
color: "#9cdcfe"
|
|
359
|
-
},
|
|
360
|
-
symbol: {
|
|
361
|
-
color: "#b5cea8"
|
|
362
|
-
},
|
|
363
|
-
inserted: {
|
|
364
|
-
color: "#b5cea8"
|
|
365
|
-
},
|
|
366
|
-
unit: {
|
|
367
|
-
color: "#b5cea8"
|
|
368
|
-
},
|
|
369
|
-
selector: {
|
|
370
|
-
color: "#d7ba7d"
|
|
371
|
-
},
|
|
372
|
-
"attr-name": {
|
|
373
|
-
color: "#9cdcfe"
|
|
374
|
-
},
|
|
375
|
-
string: {
|
|
376
|
-
color: "#ce9178"
|
|
377
|
-
},
|
|
378
|
-
char: {
|
|
379
|
-
color: "#ce9178"
|
|
380
|
-
},
|
|
381
|
-
builtin: {
|
|
382
|
-
color: "#ce9178"
|
|
383
|
-
},
|
|
384
|
-
deleted: {
|
|
385
|
-
color: "#ce9178"
|
|
386
|
-
},
|
|
387
|
-
".language-css .token.string.url": {
|
|
388
|
-
textDecoration: "underline"
|
|
389
|
-
},
|
|
390
|
-
operator: {
|
|
391
|
-
color: "#d4d4d4"
|
|
392
|
-
},
|
|
393
|
-
entity: {
|
|
394
|
-
color: "#569cd6"
|
|
395
|
-
},
|
|
396
|
-
"operator.arrow": {
|
|
397
|
-
color: "#569CD6"
|
|
398
|
-
},
|
|
399
|
-
atrule: {
|
|
400
|
-
color: "#ce9178"
|
|
401
|
-
},
|
|
402
|
-
"atrule.rule": {
|
|
403
|
-
color: "#c586c0"
|
|
404
|
-
},
|
|
405
|
-
"atrule.url": {
|
|
406
|
-
color: "#9cdcfe"
|
|
407
|
-
},
|
|
408
|
-
"atrule.url.function": {
|
|
409
|
-
color: "#dcdcaa"
|
|
410
|
-
},
|
|
411
|
-
"atrule.url.punctuation": {
|
|
412
|
-
color: "#d4d4d4"
|
|
413
|
-
},
|
|
414
|
-
keyword: {
|
|
415
|
-
color: "#569CD6"
|
|
416
|
-
},
|
|
417
|
-
"keyword.module": {
|
|
418
|
-
color: "#c586c0"
|
|
419
|
-
},
|
|
420
|
-
"keyword.control-flow": {
|
|
421
|
-
color: "#c586c0"
|
|
422
|
-
},
|
|
423
|
-
function: {
|
|
424
|
-
color: "#dcdcaa"
|
|
425
|
-
},
|
|
426
|
-
"function.maybe-class-name": {
|
|
427
|
-
color: "#dcdcaa"
|
|
428
|
-
},
|
|
429
|
-
regex: {
|
|
430
|
-
color: "#d16969"
|
|
431
|
-
},
|
|
432
|
-
important: {
|
|
433
|
-
color: "#569cd6"
|
|
434
|
-
},
|
|
435
|
-
italic: {
|
|
436
|
-
fontStyle: "italic"
|
|
437
|
-
},
|
|
438
|
-
"class-name": {
|
|
439
|
-
color: "#4ec9b0"
|
|
440
|
-
},
|
|
441
|
-
"maybe-class-name": {
|
|
442
|
-
color: "#4ec9b0"
|
|
443
|
-
},
|
|
444
|
-
console: {
|
|
445
|
-
color: "#9cdcfe"
|
|
446
|
-
},
|
|
447
|
-
parameter: {
|
|
448
|
-
color: "#9cdcfe"
|
|
449
|
-
},
|
|
450
|
-
interpolation: {
|
|
451
|
-
color: "#9cdcfe"
|
|
452
|
-
},
|
|
453
|
-
"punctuation.interpolation-punctuation": {
|
|
454
|
-
color: "#569cd6"
|
|
455
|
-
},
|
|
456
|
-
variable: {
|
|
457
|
-
color: "#9cdcfe"
|
|
458
|
-
},
|
|
459
|
-
"imports.maybe-class-name": {
|
|
460
|
-
color: "#9cdcfe"
|
|
461
|
-
},
|
|
462
|
-
"exports.maybe-class-name": {
|
|
463
|
-
color: "#9cdcfe"
|
|
464
|
-
},
|
|
465
|
-
escape: {
|
|
466
|
-
color: "#d7ba7d"
|
|
467
|
-
},
|
|
468
|
-
"tag.punctuation": {
|
|
469
|
-
color: "#808080"
|
|
470
|
-
},
|
|
471
|
-
cdata: {
|
|
472
|
-
color: "#808080"
|
|
473
|
-
},
|
|
474
|
-
"attr-value": {
|
|
475
|
-
color: "#ce9178"
|
|
476
|
-
},
|
|
477
|
-
"attr-value.punctuation": {
|
|
478
|
-
color: "#ce9178"
|
|
479
|
-
},
|
|
480
|
-
"attr-value.punctuation.attr-equals": {
|
|
481
|
-
color: "#d4d4d4"
|
|
482
|
-
},
|
|
483
|
-
namespace: {
|
|
484
|
-
color: "#4ec9b0"
|
|
485
|
-
},
|
|
486
|
-
'pre[class*="language-javascript"]': {
|
|
487
|
-
color: "#9cdcfe"
|
|
488
|
-
},
|
|
489
|
-
'code[class*="language-javascript"]': {
|
|
490
|
-
color: "#9cdcfe"
|
|
491
|
-
},
|
|
492
|
-
'pre[class*="language-jsx"]': {
|
|
493
|
-
color: "#9cdcfe"
|
|
494
|
-
},
|
|
495
|
-
'code[class*="language-jsx"]': {
|
|
496
|
-
color: "#9cdcfe"
|
|
497
|
-
},
|
|
498
|
-
'pre[class*="language-typescript"]': {
|
|
499
|
-
color: "#9cdcfe"
|
|
500
|
-
},
|
|
501
|
-
'code[class*="language-typescript"]': {
|
|
502
|
-
color: "#9cdcfe"
|
|
503
|
-
},
|
|
504
|
-
'pre[class*="language-tsx"]': {
|
|
505
|
-
color: "#9cdcfe"
|
|
506
|
-
},
|
|
507
|
-
'code[class*="language-tsx"]': {
|
|
508
|
-
color: "#9cdcfe"
|
|
509
|
-
},
|
|
510
|
-
'pre[class*="language-css"]': {
|
|
511
|
-
color: "#ce9178"
|
|
512
|
-
},
|
|
513
|
-
'code[class*="language-css"]': {
|
|
514
|
-
color: "#ce9178"
|
|
515
|
-
},
|
|
516
|
-
'pre[class*="language-html"]': {
|
|
517
|
-
color: "#d4d4d4"
|
|
518
|
-
},
|
|
519
|
-
'code[class*="language-html"]': {
|
|
520
|
-
color: "#d4d4d4"
|
|
521
|
-
},
|
|
522
|
-
".language-regex .token.anchor": {
|
|
523
|
-
color: "#dcdcaa"
|
|
524
|
-
},
|
|
525
|
-
".language-html .token.punctuation": {
|
|
526
|
-
color: "#808080"
|
|
527
|
-
},
|
|
528
|
-
'pre[class*="language-"] > code[class*="language-"]': {
|
|
529
|
-
position: "relative",
|
|
530
|
-
zIndex: "1"
|
|
531
|
-
},
|
|
532
|
-
".line-highlight.line-highlight": {
|
|
533
|
-
background: "#f7ebc6",
|
|
534
|
-
boxShadow: "inset 5px 0 0 #f7d87c",
|
|
535
|
-
zIndex: "0"
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
// src/components/chat/Markdown.tsx
|
|
540
|
-
var import_remark_gfm = __toESM(require("remark-gfm"));
|
|
541
|
-
var import_remark_math = __toESM(require("remark-math"));
|
|
542
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
543
|
-
var MemoizedReactMarkdown = (0, import_react3.memo)(
|
|
544
|
-
import_react_markdown.default,
|
|
545
|
-
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
|
|
546
|
-
);
|
|
547
|
-
var Markdown = ({ content }) => {
|
|
548
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MemoizedReactMarkdown, { components, remarkPlugins: [import_remark_gfm.default, import_remark_math.default], children: content }) });
|
|
549
|
-
};
|
|
550
|
-
var components = {
|
|
551
|
-
p({ children }) {
|
|
552
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children });
|
|
553
|
-
},
|
|
554
|
-
a(_a) {
|
|
555
|
-
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
556
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
557
|
-
"a",
|
|
558
|
-
__spreadProps(__spreadValues({
|
|
559
|
-
style: { color: "blue", textDecoration: "underline" }
|
|
560
|
-
}, props), {
|
|
561
|
-
target: "_blank",
|
|
562
|
-
rel: "noopener noreferrer",
|
|
563
|
-
children
|
|
564
|
-
})
|
|
565
|
-
);
|
|
566
|
-
},
|
|
567
|
-
code(_c) {
|
|
568
|
-
var _d = _c, { children, className, inline } = _d, props = __objRest(_d, ["children", "className", "inline"]);
|
|
569
|
-
if (children.length) {
|
|
570
|
-
if (children[0] == "\u258D") {
|
|
571
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
572
|
-
"span",
|
|
573
|
-
{
|
|
574
|
-
style: {
|
|
575
|
-
animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
|
|
576
|
-
marginTop: "0.25rem"
|
|
577
|
-
},
|
|
578
|
-
children: "\u258D"
|
|
579
|
-
}
|
|
580
|
-
);
|
|
581
|
-
}
|
|
582
|
-
children[0] = children[0].replace("`\u258D`", "\u258D");
|
|
583
|
-
}
|
|
584
|
-
const match = /language-(\w+)/.exec(className || "");
|
|
585
|
-
if (inline) {
|
|
586
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", __spreadProps(__spreadValues({ className }, props), { children }));
|
|
587
|
-
}
|
|
588
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
589
|
-
CodeBlock,
|
|
590
|
-
__spreadValues({
|
|
591
|
-
language: match && match[1] || "",
|
|
592
|
-
value: String(children).replace(/\n$/, "")
|
|
593
|
-
}, props),
|
|
594
|
-
Math.random()
|
|
595
|
-
);
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
|
|
599
52
|
// src/components/chat/Messages.tsx
|
|
600
|
-
var import_react_core = require("@copilotkit/react-core");
|
|
601
53
|
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
602
|
-
var
|
|
603
|
-
var Messages = ({
|
|
604
|
-
|
|
54
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
55
|
+
var Messages = ({
|
|
56
|
+
messages,
|
|
57
|
+
inProgress,
|
|
58
|
+
children,
|
|
59
|
+
RenderTextMessage,
|
|
60
|
+
RenderActionExecutionMessage,
|
|
61
|
+
RenderAgentStateMessage,
|
|
62
|
+
RenderResultMessage
|
|
63
|
+
}) => {
|
|
605
64
|
const context = useChatContext();
|
|
606
|
-
const initialMessages = (0,
|
|
65
|
+
const initialMessages = (0, import_react2.useMemo)(
|
|
607
66
|
() => makeInitialMessages(context.labels.initial),
|
|
608
67
|
[context.labels.initial]
|
|
609
68
|
);
|
|
610
69
|
messages = [...initialMessages, ...messages];
|
|
611
|
-
const
|
|
70
|
+
const actionResults = {};
|
|
612
71
|
for (let i = 0; i < messages.length; i++) {
|
|
613
72
|
if (messages[i] instanceof import_runtime_client_gql.ActionExecutionMessage) {
|
|
614
73
|
const id = messages[i].id;
|
|
@@ -616,11 +75,11 @@ var Messages = ({ messages, inProgress, children }) => {
|
|
|
616
75
|
(message) => message instanceof import_runtime_client_gql.ResultMessage && message.actionExecutionId === id
|
|
617
76
|
);
|
|
618
77
|
if (resultMessage) {
|
|
619
|
-
|
|
78
|
+
actionResults[id] = import_runtime_client_gql.ResultMessage.decodeResult(resultMessage.result || "");
|
|
620
79
|
}
|
|
621
80
|
}
|
|
622
81
|
}
|
|
623
|
-
const messagesEndRef =
|
|
82
|
+
const messagesEndRef = import_react2.default.useRef(null);
|
|
624
83
|
const scrollToBottom = () => {
|
|
625
84
|
if (messagesEndRef.current) {
|
|
626
85
|
messagesEndRef.current.scrollIntoView({
|
|
@@ -628,120 +87,60 @@ var Messages = ({ messages, inProgress, children }) => {
|
|
|
628
87
|
});
|
|
629
88
|
}
|
|
630
89
|
};
|
|
631
|
-
(0,
|
|
90
|
+
(0, import_react2.useEffect)(() => {
|
|
632
91
|
scrollToBottom();
|
|
633
92
|
}, [messages]);
|
|
634
|
-
return /* @__PURE__ */ (0,
|
|
93
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "copilotKitMessages", children: [
|
|
635
94
|
messages.map((message, index) => {
|
|
636
95
|
const isCurrentMessage = index === messages.length - 1;
|
|
637
|
-
if (message instanceof import_runtime_client_gql.TextMessage
|
|
638
|
-
return /* @__PURE__ */ (0,
|
|
639
|
-
|
|
640
|
-
|
|
96
|
+
if (message instanceof import_runtime_client_gql.TextMessage) {
|
|
97
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
98
|
+
RenderTextMessage,
|
|
99
|
+
{
|
|
100
|
+
message,
|
|
101
|
+
inProgress,
|
|
102
|
+
index,
|
|
103
|
+
isCurrentMessage
|
|
104
|
+
},
|
|
105
|
+
index
|
|
106
|
+
);
|
|
641
107
|
} else if (message instanceof import_runtime_client_gql.ActionExecutionMessage) {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
}
|
|
654
|
-
} else {
|
|
655
|
-
const args = message.arguments;
|
|
656
|
-
let status = "inProgress";
|
|
657
|
-
if (functionResults[message.id] !== void 0) {
|
|
658
|
-
status = "complete";
|
|
659
|
-
} else if (message.status.code !== import_runtime_client_gql.MessageStatusCode.Pending) {
|
|
660
|
-
status = "executing";
|
|
661
|
-
}
|
|
662
|
-
try {
|
|
663
|
-
const toRender = render({
|
|
664
|
-
status,
|
|
665
|
-
args,
|
|
666
|
-
result: functionResults[message.id]
|
|
667
|
-
});
|
|
668
|
-
if (!toRender && status === "complete") {
|
|
669
|
-
return null;
|
|
670
|
-
}
|
|
671
|
-
if (typeof toRender === "string") {
|
|
672
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: [
|
|
673
|
-
isCurrentMessage && inProgress && context.icons.spinnerIcon,
|
|
674
|
-
" ",
|
|
675
|
-
toRender
|
|
676
|
-
] }, index);
|
|
677
|
-
} else {
|
|
678
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "copilotKitCustomAssistantMessage", children: toRender }, index);
|
|
679
|
-
}
|
|
680
|
-
} catch (e) {
|
|
681
|
-
console.error(`Error executing render function for action ${message.name}: ${e}`);
|
|
682
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: [
|
|
683
|
-
isCurrentMessage && inProgress && context.icons.spinnerIcon,
|
|
684
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("b", { children: [
|
|
685
|
-
"\u274C Error executing render: ",
|
|
686
|
-
message.name
|
|
687
|
-
] }),
|
|
688
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("br", {}),
|
|
689
|
-
e instanceof Error ? e.message : String(e)
|
|
690
|
-
] }, index);
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
} else if (!inProgress || !isCurrentMessage) {
|
|
694
|
-
return null;
|
|
695
|
-
} else {
|
|
696
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
|
|
697
|
-
}
|
|
108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
109
|
+
RenderActionExecutionMessage,
|
|
110
|
+
{
|
|
111
|
+
message,
|
|
112
|
+
inProgress,
|
|
113
|
+
index,
|
|
114
|
+
isCurrentMessage,
|
|
115
|
+
actionResult: actionResults[message.id]
|
|
116
|
+
},
|
|
117
|
+
index
|
|
118
|
+
);
|
|
698
119
|
} else if (message instanceof import_runtime_client_gql.AgentStateMessage) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
nodeName: message.nodeName
|
|
721
|
-
});
|
|
722
|
-
if (!toRender && status === "complete") {
|
|
723
|
-
return null;
|
|
724
|
-
}
|
|
725
|
-
if (typeof toRender === "string") {
|
|
726
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: [
|
|
727
|
-
isCurrentMessage && inProgress && context.icons.spinnerIcon,
|
|
728
|
-
" ",
|
|
729
|
-
toRender
|
|
730
|
-
] }, index);
|
|
731
|
-
} else {
|
|
732
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "copilotKitCustomAssistantMessage", children: toRender }, index);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
} else if (!inProgress || !isCurrentMessage) {
|
|
736
|
-
return null;
|
|
737
|
-
} else {
|
|
738
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
|
|
739
|
-
}
|
|
740
|
-
} else if (message instanceof import_runtime_client_gql.ResultMessage && inProgress && isCurrentMessage) {
|
|
741
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
|
|
120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
121
|
+
RenderAgentStateMessage,
|
|
122
|
+
{
|
|
123
|
+
message,
|
|
124
|
+
inProgress,
|
|
125
|
+
index,
|
|
126
|
+
isCurrentMessage
|
|
127
|
+
},
|
|
128
|
+
index
|
|
129
|
+
);
|
|
130
|
+
} else if (message instanceof import_runtime_client_gql.ResultMessage) {
|
|
131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
132
|
+
RenderResultMessage,
|
|
133
|
+
{
|
|
134
|
+
message,
|
|
135
|
+
inProgress,
|
|
136
|
+
index,
|
|
137
|
+
isCurrentMessage
|
|
138
|
+
},
|
|
139
|
+
index
|
|
140
|
+
);
|
|
742
141
|
}
|
|
743
142
|
}),
|
|
744
|
-
/* @__PURE__ */ (0,
|
|
143
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("footer", { ref: messagesEndRef, children })
|
|
745
144
|
] });
|
|
746
145
|
};
|
|
747
146
|
function makeInitialMessages(initial) {
|