@copilotkit/react-ui 1.5.11 → 1.5.12-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 (102) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{chunk-7II4YL7R.mjs → chunk-34FREWVK.mjs} +16 -6
  3. package/dist/chunk-34FREWVK.mjs.map +1 -0
  4. package/dist/chunk-3VNMQWGT.mjs +25 -0
  5. package/dist/chunk-3VNMQWGT.mjs.map +1 -0
  6. package/dist/{chunk-WSMMTZCM.mjs → chunk-B23XDGH4.mjs} +2 -2
  7. package/dist/chunk-F7VWGY77.mjs +22 -0
  8. package/dist/chunk-F7VWGY77.mjs.map +1 -0
  9. package/dist/chunk-HEIDCT7I.mjs +10 -0
  10. package/dist/chunk-HEIDCT7I.mjs.map +1 -0
  11. package/dist/{chunk-DCNCY2PL.mjs → chunk-I7MG52I5.mjs} +19 -9
  12. package/dist/chunk-I7MG52I5.mjs.map +1 -0
  13. package/dist/{chunk-375NVWZM.mjs → chunk-O6JFOQQA.mjs} +2 -2
  14. package/dist/chunk-OFYI4UU4.mjs +35 -0
  15. package/dist/chunk-OFYI4UU4.mjs.map +1 -0
  16. package/dist/{chunk-3E7HY2UN.mjs → chunk-P5A3A5FO.mjs} +58 -31
  17. package/dist/chunk-P5A3A5FO.mjs.map +1 -0
  18. package/dist/chunk-SQMEPWVT.mjs +1 -0
  19. package/dist/chunk-UWWMAJ7R.mjs +100 -0
  20. package/dist/chunk-UWWMAJ7R.mjs.map +1 -0
  21. package/dist/{chunk-UWVGLGFQ.mjs → chunk-VKVNMHM5.mjs} +14 -4
  22. package/dist/chunk-VKVNMHM5.mjs.map +1 -0
  23. package/dist/components/chat/Chat.d.ts +10 -2
  24. package/dist/components/chat/Chat.js +384 -271
  25. package/dist/components/chat/Chat.js.map +1 -1
  26. package/dist/components/chat/Chat.mjs +8 -6
  27. package/dist/components/chat/Messages.d.ts +1 -1
  28. package/dist/components/chat/Messages.js +15 -5
  29. package/dist/components/chat/Messages.js.map +1 -1
  30. package/dist/components/chat/Messages.mjs +1 -1
  31. package/dist/components/chat/Modal.d.ts +1 -1
  32. package/dist/components/chat/Modal.js +396 -279
  33. package/dist/components/chat/Modal.js.map +1 -1
  34. package/dist/components/chat/Modal.mjs +9 -7
  35. package/dist/components/chat/Popup.js +398 -281
  36. package/dist/components/chat/Popup.js.map +1 -1
  37. package/dist/components/chat/Popup.mjs +10 -8
  38. package/dist/components/chat/Sidebar.js +398 -281
  39. package/dist/components/chat/Sidebar.js.map +1 -1
  40. package/dist/components/chat/Sidebar.mjs +10 -8
  41. package/dist/components/chat/index.d.ts +4 -1
  42. package/dist/components/chat/index.js +406 -283
  43. package/dist/components/chat/index.js.map +1 -1
  44. package/dist/components/chat/index.mjs +22 -11
  45. package/dist/components/chat/messages/AssistantMessage.d.ts +7 -0
  46. package/dist/components/chat/messages/AssistantMessage.js +615 -0
  47. package/dist/components/chat/messages/AssistantMessage.js.map +1 -0
  48. package/dist/components/chat/messages/AssistantMessage.mjs +13 -0
  49. package/dist/components/chat/messages/AssistantMessage.mjs.map +1 -0
  50. package/dist/components/chat/messages/RenderActionExecutionMessage.js +59 -54
  51. package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -1
  52. package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +1 -3
  53. package/dist/components/chat/messages/RenderAgentStateMessage.js +55 -42
  54. package/dist/components/chat/messages/RenderAgentStateMessage.js.map +1 -1
  55. package/dist/components/chat/messages/RenderAgentStateMessage.mjs +1 -3
  56. package/dist/components/chat/messages/RenderResultMessage.js +11 -29
  57. package/dist/components/chat/messages/RenderResultMessage.js.map +1 -1
  58. package/dist/components/chat/messages/RenderResultMessage.mjs +1 -3
  59. package/dist/components/chat/messages/RenderTextMessage.js +11 -581
  60. package/dist/components/chat/messages/RenderTextMessage.js.map +1 -1
  61. package/dist/components/chat/messages/RenderTextMessage.mjs +1 -6
  62. package/dist/components/chat/messages/UserMessage.d.ts +7 -0
  63. package/dist/components/chat/messages/UserMessage.js +34 -0
  64. package/dist/components/chat/messages/UserMessage.js.map +1 -0
  65. package/dist/components/chat/messages/UserMessage.mjs +8 -0
  66. package/dist/components/chat/messages/UserMessage.mjs.map +1 -0
  67. package/dist/components/chat/props.d.ts +36 -1
  68. package/dist/components/chat/props.js.map +1 -1
  69. package/dist/components/index.d.ts +4 -1
  70. package/dist/components/index.js +406 -283
  71. package/dist/components/index.js.map +1 -1
  72. package/dist/components/index.mjs +22 -11
  73. package/dist/index.d.ts +4 -1
  74. package/dist/index.js +406 -283
  75. package/dist/index.js.map +1 -1
  76. package/dist/index.mjs +22 -11
  77. package/package.json +4 -4
  78. package/src/components/chat/Chat.tsx +25 -1
  79. package/src/components/chat/Messages.tsx +10 -0
  80. package/src/components/chat/Modal.tsx +7 -0
  81. package/src/components/chat/index.tsx +3 -0
  82. package/src/components/chat/messages/AssistantMessage.tsx +20 -0
  83. package/src/components/chat/messages/RenderActionExecutionMessage.tsx +45 -24
  84. package/src/components/chat/messages/RenderAgentStateMessage.tsx +39 -19
  85. package/src/components/chat/messages/RenderResultMessage.tsx +9 -7
  86. package/src/components/chat/messages/RenderTextMessage.tsx +12 -19
  87. package/src/components/chat/messages/UserMessage.tsx +5 -0
  88. package/src/components/chat/props.ts +43 -0
  89. package/dist/chunk-3E7HY2UN.mjs.map +0 -1
  90. package/dist/chunk-6INMITFA.mjs +0 -18
  91. package/dist/chunk-6INMITFA.mjs.map +0 -1
  92. package/dist/chunk-7II4YL7R.mjs.map +0 -1
  93. package/dist/chunk-DCNCY2PL.mjs.map +0 -1
  94. package/dist/chunk-MRFF7GSQ.mjs +0 -1
  95. package/dist/chunk-RU73BEZM.mjs +0 -41
  96. package/dist/chunk-RU73BEZM.mjs.map +0 -1
  97. package/dist/chunk-UWVGLGFQ.mjs.map +0 -1
  98. package/dist/chunk-ZABXREBH.mjs +0 -65
  99. package/dist/chunk-ZABXREBH.mjs.map +0 -1
  100. /package/dist/{chunk-WSMMTZCM.mjs.map → chunk-B23XDGH4.mjs.map} +0 -0
  101. /package/dist/{chunk-375NVWZM.mjs.map → chunk-O6JFOQQA.mjs.map} +0 -0
  102. /package/dist/{chunk-MRFF7GSQ.mjs.map → chunk-SQMEPWVT.mjs.map} +0 -0
@@ -1,39 +1,8 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __getProtoOf = Object.getPrototypeOf;
10
5
  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
6
  var __export = (target, all) => {
38
7
  for (var name in all)
39
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -46,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
46
15
  }
47
16
  return to;
48
17
  };
49
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
- // If the importer is in node compatibility mode or this is not an ESM
51
- // file that has been converted to a CommonJS file using a Babel-
52
- // compatible transform (i.e. "__esModule" has not been set), then set
53
- // "default" to the CommonJS "module.exports" for node compatibility.
54
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
- mod
56
- ));
57
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
19
 
59
20
  // src/components/chat/messages/RenderTextMessage.tsx
@@ -62,560 +23,29 @@ __export(RenderTextMessage_exports, {
62
23
  RenderTextMessage: () => RenderTextMessage
63
24
  });
64
25
  module.exports = __toCommonJS(RenderTextMessage_exports);
65
-
66
- // src/components/chat/Markdown.tsx
67
- var import_react2 = require("react");
68
- var import_react_markdown = __toESM(require("react-markdown"));
69
-
70
- // src/components/chat/CodeBlock.tsx
71
- var import_react = require("react");
72
- var import_react_syntax_highlighter = require("react-syntax-highlighter");
73
-
74
- // src/hooks/use-copy-to-clipboard.tsx
75
- var React = __toESM(require("react"));
76
- function useCopyToClipboard({ timeout = 2e3 }) {
77
- const [isCopied, setIsCopied] = React.useState(false);
78
- const copyToClipboard = (value) => {
79
- var _a;
80
- if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
81
- return;
82
- }
83
- if (!value) {
84
- return;
85
- }
86
- navigator.clipboard.writeText(value).then(() => {
87
- setIsCopied(true);
88
- setTimeout(() => {
89
- setIsCopied(false);
90
- }, timeout);
91
- });
92
- };
93
- return { isCopied, copyToClipboard };
94
- }
95
-
96
- // src/components/chat/Icons.tsx
97
26
  var import_jsx_runtime = require("react/jsx-runtime");
98
- function CheckIcon(_a) {
99
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
100
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
101
- "svg",
102
- __spreadProps(__spreadValues({
103
- xmlns: "http://www.w3.org/2000/svg",
104
- viewBox: "0 0 256 256",
105
- fill: "currentColor",
106
- style: { height: "1rem", width: "1rem" },
107
- className
108
- }, props), {
109
- 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" })
110
- })
111
- );
112
- }
113
- function DownloadIcon(_a) {
114
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
115
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
116
- "svg",
117
- __spreadProps(__spreadValues({
118
- xmlns: "http://www.w3.org/2000/svg",
119
- viewBox: "0 0 256 256",
120
- fill: "currentColor",
121
- style: { height: "1rem", width: "1rem" },
122
- className
123
- }, props), {
124
- 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" })
125
- })
126
- );
127
- }
128
- function CopyIcon(_a) {
129
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
130
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
131
- "svg",
132
- __spreadProps(__spreadValues({
133
- xmlns: "http://www.w3.org/2000/svg",
134
- viewBox: "0 0 256 256",
135
- fill: "currentColor",
136
- style: { height: "1rem", width: "1rem" },
137
- className
138
- }, props), {
139
- 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" })
140
- })
141
- );
142
- }
143
-
144
- // src/components/chat/CodeBlock.tsx
145
- var import_jsx_runtime2 = require("react/jsx-runtime");
146
- var programmingLanguages = {
147
- javascript: ".js",
148
- python: ".py",
149
- java: ".java",
150
- c: ".c",
151
- cpp: ".cpp",
152
- "c++": ".cpp",
153
- "c#": ".cs",
154
- ruby: ".rb",
155
- php: ".php",
156
- swift: ".swift",
157
- "objective-c": ".m",
158
- kotlin: ".kt",
159
- typescript: ".ts",
160
- go: ".go",
161
- perl: ".pl",
162
- rust: ".rs",
163
- scala: ".scala",
164
- haskell: ".hs",
165
- lua: ".lua",
166
- shell: ".sh",
167
- sql: ".sql",
168
- html: ".html",
169
- css: ".css"
170
- // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
171
- };
172
- var generateRandomString = (length, lowercase = false) => {
173
- const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
174
- let result = "";
175
- for (let i = 0; i < length; i++) {
176
- result += chars.charAt(Math.floor(Math.random() * chars.length));
177
- }
178
- return lowercase ? result.toLowerCase() : result;
179
- };
180
- var CodeBlock = (0, import_react.memo)(({ language, value }) => {
181
- const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
182
- const downloadAsFile = () => {
183
- if (typeof window === "undefined") {
184
- return;
185
- }
186
- const fileExtension = programmingLanguages[language] || ".file";
187
- const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
188
- const fileName = window.prompt("Enter file name", suggestedFileName);
189
- if (!fileName) {
190
- return;
191
- }
192
- const blob = new Blob([value], { type: "text/plain" });
193
- const url = URL.createObjectURL(blob);
194
- const link = document.createElement("a");
195
- link.download = fileName;
196
- link.href = url;
197
- link.style.display = "none";
198
- document.body.appendChild(link);
199
- link.click();
200
- document.body.removeChild(link);
201
- URL.revokeObjectURL(url);
202
- };
203
- const onCopy = () => {
204
- if (isCopied)
205
- return;
206
- copyToClipboard(value);
207
- };
208
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "copilotKitCodeBlock", children: [
209
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
210
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
211
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
212
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
213
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DownloadIcon, {}),
214
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sr-only", children: "Download" })
215
- ] }),
216
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
217
- isCopied ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CheckIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CopyIcon, {}),
218
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sr-only", children: "Copy code" })
219
- ] })
220
- ] })
221
- ] }),
222
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
223
- import_react_syntax_highlighter.Prism,
224
- {
225
- language,
226
- style: highlightStyle,
227
- PreTag: "div",
228
- customStyle: {
229
- margin: 0,
230
- borderBottomLeftRadius: "0.375rem",
231
- borderBottomRightRadius: "0.375rem"
232
- },
233
- children: value
234
- }
235
- )
236
- ] });
237
- });
238
- CodeBlock.displayName = "CodeBlock";
239
- var highlightStyle = {
240
- 'pre[class*="language-"]': {
241
- color: "#d4d4d4",
242
- fontSize: "13px",
243
- textShadow: "none",
244
- fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
245
- direction: "ltr",
246
- textAlign: "left",
247
- whiteSpace: "pre",
248
- wordSpacing: "normal",
249
- wordBreak: "normal",
250
- lineHeight: "1.5",
251
- MozTabSize: "4",
252
- OTabSize: "4",
253
- tabSize: "4",
254
- WebkitHyphens: "none",
255
- MozHyphens: "none",
256
- msHyphens: "none",
257
- hyphens: "none",
258
- padding: "1em",
259
- margin: ".5em 0",
260
- overflow: "auto",
261
- background: "#1e1e1e"
262
- },
263
- 'code[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
- },
282
- 'pre[class*="language-"]::selection': {
283
- textShadow: "none",
284
- background: "#264F78"
285
- },
286
- 'code[class*="language-"]::selection': {
287
- textShadow: "none",
288
- background: "#264F78"
289
- },
290
- 'pre[class*="language-"] *::selection': {
291
- textShadow: "none",
292
- background: "#264F78"
293
- },
294
- 'code[class*="language-"] *::selection': {
295
- textShadow: "none",
296
- background: "#264F78"
297
- },
298
- ':not(pre) > code[class*="language-"]': {
299
- padding: ".1em .3em",
300
- borderRadius: ".3em",
301
- color: "#db4c69",
302
- background: "#1e1e1e"
303
- },
304
- ".namespace": {
305
- Opacity: ".7"
306
- },
307
- "doctype.doctype-tag": {
308
- color: "#569CD6"
309
- },
310
- "doctype.name": {
311
- color: "#9cdcfe"
312
- },
313
- comment: {
314
- color: "#6a9955"
315
- },
316
- prolog: {
317
- color: "#6a9955"
318
- },
319
- punctuation: {
320
- color: "#d4d4d4"
321
- },
322
- ".language-html .language-css .token.punctuation": {
323
- color: "#d4d4d4"
324
- },
325
- ".language-html .language-javascript .token.punctuation": {
326
- color: "#d4d4d4"
327
- },
328
- property: {
329
- color: "#9cdcfe"
330
- },
331
- tag: {
332
- color: "#569cd6"
333
- },
334
- boolean: {
335
- color: "#569cd6"
336
- },
337
- number: {
338
- color: "#b5cea8"
339
- },
340
- constant: {
341
- color: "#9cdcfe"
342
- },
343
- symbol: {
344
- color: "#b5cea8"
345
- },
346
- inserted: {
347
- color: "#b5cea8"
348
- },
349
- unit: {
350
- color: "#b5cea8"
351
- },
352
- selector: {
353
- color: "#d7ba7d"
354
- },
355
- "attr-name": {
356
- color: "#9cdcfe"
357
- },
358
- string: {
359
- color: "#ce9178"
360
- },
361
- char: {
362
- color: "#ce9178"
363
- },
364
- builtin: {
365
- color: "#ce9178"
366
- },
367
- deleted: {
368
- color: "#ce9178"
369
- },
370
- ".language-css .token.string.url": {
371
- textDecoration: "underline"
372
- },
373
- operator: {
374
- color: "#d4d4d4"
375
- },
376
- entity: {
377
- color: "#569cd6"
378
- },
379
- "operator.arrow": {
380
- color: "#569CD6"
381
- },
382
- atrule: {
383
- color: "#ce9178"
384
- },
385
- "atrule.rule": {
386
- color: "#c586c0"
387
- },
388
- "atrule.url": {
389
- color: "#9cdcfe"
390
- },
391
- "atrule.url.function": {
392
- color: "#dcdcaa"
393
- },
394
- "atrule.url.punctuation": {
395
- color: "#d4d4d4"
396
- },
397
- keyword: {
398
- color: "#569CD6"
399
- },
400
- "keyword.module": {
401
- color: "#c586c0"
402
- },
403
- "keyword.control-flow": {
404
- color: "#c586c0"
405
- },
406
- function: {
407
- color: "#dcdcaa"
408
- },
409
- "function.maybe-class-name": {
410
- color: "#dcdcaa"
411
- },
412
- regex: {
413
- color: "#d16969"
414
- },
415
- important: {
416
- color: "#569cd6"
417
- },
418
- italic: {
419
- fontStyle: "italic"
420
- },
421
- "class-name": {
422
- color: "#4ec9b0"
423
- },
424
- "maybe-class-name": {
425
- color: "#4ec9b0"
426
- },
427
- console: {
428
- color: "#9cdcfe"
429
- },
430
- parameter: {
431
- color: "#9cdcfe"
432
- },
433
- interpolation: {
434
- color: "#9cdcfe"
435
- },
436
- "punctuation.interpolation-punctuation": {
437
- color: "#569cd6"
438
- },
439
- variable: {
440
- color: "#9cdcfe"
441
- },
442
- "imports.maybe-class-name": {
443
- color: "#9cdcfe"
444
- },
445
- "exports.maybe-class-name": {
446
- color: "#9cdcfe"
447
- },
448
- escape: {
449
- color: "#d7ba7d"
450
- },
451
- "tag.punctuation": {
452
- color: "#808080"
453
- },
454
- cdata: {
455
- color: "#808080"
456
- },
457
- "attr-value": {
458
- color: "#ce9178"
459
- },
460
- "attr-value.punctuation": {
461
- color: "#ce9178"
462
- },
463
- "attr-value.punctuation.attr-equals": {
464
- color: "#d4d4d4"
465
- },
466
- namespace: {
467
- color: "#4ec9b0"
468
- },
469
- 'pre[class*="language-javascript"]': {
470
- color: "#9cdcfe"
471
- },
472
- 'code[class*="language-javascript"]': {
473
- color: "#9cdcfe"
474
- },
475
- 'pre[class*="language-jsx"]': {
476
- color: "#9cdcfe"
477
- },
478
- 'code[class*="language-jsx"]': {
479
- color: "#9cdcfe"
480
- },
481
- 'pre[class*="language-typescript"]': {
482
- color: "#9cdcfe"
483
- },
484
- 'code[class*="language-typescript"]': {
485
- color: "#9cdcfe"
486
- },
487
- 'pre[class*="language-tsx"]': {
488
- color: "#9cdcfe"
489
- },
490
- 'code[class*="language-tsx"]': {
491
- color: "#9cdcfe"
492
- },
493
- 'pre[class*="language-css"]': {
494
- color: "#ce9178"
495
- },
496
- 'code[class*="language-css"]': {
497
- color: "#ce9178"
498
- },
499
- 'pre[class*="language-html"]': {
500
- color: "#d4d4d4"
501
- },
502
- 'code[class*="language-html"]': {
503
- color: "#d4d4d4"
504
- },
505
- ".language-regex .token.anchor": {
506
- color: "#dcdcaa"
507
- },
508
- ".language-html .token.punctuation": {
509
- color: "#808080"
510
- },
511
- 'pre[class*="language-"] > code[class*="language-"]': {
512
- position: "relative",
513
- zIndex: "1"
514
- },
515
- ".line-highlight.line-highlight": {
516
- background: "#f7ebc6",
517
- boxShadow: "inset 5px 0 0 #f7d87c",
518
- zIndex: "0"
519
- }
520
- };
521
-
522
- // src/components/chat/Markdown.tsx
523
- var import_remark_gfm = __toESM(require("remark-gfm"));
524
- var import_remark_math = __toESM(require("remark-math"));
525
- var import_jsx_runtime3 = require("react/jsx-runtime");
526
- var MemoizedReactMarkdown = (0, import_react2.memo)(
527
- import_react_markdown.default,
528
- (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
529
- );
530
- var Markdown = ({ content }) => {
531
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MemoizedReactMarkdown, { components, remarkPlugins: [import_remark_gfm.default, import_remark_math.default], children: content }) });
532
- };
533
- var components = {
534
- p({ children }) {
535
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children });
536
- },
537
- a(_a) {
538
- var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
539
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
540
- "a",
541
- __spreadProps(__spreadValues({
542
- style: { color: "blue", textDecoration: "underline" }
543
- }, props), {
544
- target: "_blank",
545
- rel: "noopener noreferrer",
546
- children
547
- })
548
- );
549
- },
550
- code(_c) {
551
- var _d = _c, { children, className, inline } = _d, props = __objRest(_d, ["children", "className", "inline"]);
552
- if (children.length) {
553
- if (children[0] == "\u258D") {
554
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
555
- "span",
556
- {
557
- style: {
558
- animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
559
- marginTop: "0.25rem"
560
- },
561
- children: "\u258D"
562
- }
563
- );
564
- }
565
- children[0] = children[0].replace("`\u258D`", "\u258D");
566
- }
567
- const match = /language-(\w+)/.exec(className || "");
568
- if (inline) {
569
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("code", __spreadProps(__spreadValues({ className }, props), { children }));
570
- }
571
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
572
- CodeBlock,
573
- __spreadValues({
574
- language: match && match[1] || "",
575
- value: String(children).replace(/\n$/, "")
576
- }, props),
577
- Math.random()
578
- );
579
- }
580
- };
581
-
582
- // src/components/chat/ChatContext.tsx
583
- var import_react3 = __toESM(require("react"));
584
- var import_jsx_runtime4 = require("react/jsx-runtime");
585
- var ChatContext = import_react3.default.createContext(void 0);
586
- function useChatContext() {
587
- const context = import_react3.default.useContext(ChatContext);
588
- if (context === void 0) {
589
- throw new Error(
590
- "Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
591
- );
592
- }
593
- return context;
594
- }
595
-
596
- // src/components/chat/messages/RenderTextMessage.tsx
597
- var import_jsx_runtime5 = require("react/jsx-runtime");
598
27
  function RenderTextMessage(props) {
599
- const { message, inProgress, index, isCurrentMessage } = props;
600
- const { icons } = useChatContext();
28
+ const { message, inProgress, index, isCurrentMessage, UserMessage, AssistantMessage } = props;
601
29
  if (message.isTextMessage()) {
602
30
  if (message.role === "user") {
603
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
604
- "div",
31
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
32
+ UserMessage,
605
33
  {
606
34
  "data-message-role": "user",
607
- className: "copilotKitMessage copilotKitUserMessage",
608
- children: message.content
35
+ message: message.content,
36
+ rawData: message
609
37
  },
610
38
  index
611
39
  );
612
40
  } else if (message.role == "assistant") {
613
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
614
- "div",
41
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
42
+ AssistantMessage,
615
43
  {
616
44
  "data-message-role": "assistant",
617
- className: `copilotKitMessage copilotKitAssistantMessage`,
618
- children: isCurrentMessage && inProgress && !message.content ? icons.spinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Markdown, { content: message.content })
45
+ message: message.content,
46
+ rawData: message,
47
+ isLoading: inProgress && isCurrentMessage && !message.content,
48
+ isGenerating: inProgress && isCurrentMessage && !!message.content
619
49
  },
620
50
  index
621
51
  );