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