@copilotkit/react-ui 1.8.4 → 1.8.5-next.1

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