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