@copilotkit/react-ui 1.9.3 → 1.10.0-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.
- package/CHANGELOG.md +30 -0
- package/dist/{chunk-KENCH7RN.mjs → chunk-B5IFB5YJ.mjs} +1 -1
- package/dist/chunk-B5IFB5YJ.mjs.map +1 -0
- package/dist/chunk-DBKRAOH7.mjs +34 -0
- package/dist/chunk-DBKRAOH7.mjs.map +1 -0
- package/dist/{chunk-4HUXYD3B.mjs → chunk-DTRPPNSA.mjs} +2 -2
- package/dist/{chunk-YTXEWDNC.mjs → chunk-E6MQUIZW.mjs} +15 -4
- package/dist/chunk-E6MQUIZW.mjs.map +1 -0
- package/dist/{chunk-L3GZ7TXC.mjs → chunk-GCKKSSBU.mjs} +21 -24
- package/dist/chunk-GCKKSSBU.mjs.map +1 -0
- package/dist/{chunk-KN2GCKBE.mjs → chunk-GJ3MFNBX.mjs} +6 -6
- package/dist/{chunk-32MUWKL3.mjs → chunk-JHUTTP5C.mjs} +21 -17
- package/dist/chunk-JHUTTP5C.mjs.map +1 -0
- package/dist/{chunk-HKTWKCPS.mjs → chunk-LXCD3K7B.mjs} +127 -92
- package/dist/chunk-LXCD3K7B.mjs.map +1 -0
- package/dist/{chunk-S5MBUNGN.mjs → chunk-O72ZB5V3.mjs} +4 -4
- package/dist/chunk-O72ZB5V3.mjs.map +1 -0
- package/dist/{chunk-QGSPTXOV.mjs → chunk-O7KTFUAN.mjs} +2 -2
- package/dist/chunk-O7KTFUAN.mjs.map +1 -0
- package/dist/chunk-Q2467VHZ.mjs +30 -0
- package/dist/chunk-Q2467VHZ.mjs.map +1 -0
- package/dist/{chunk-H3EM63WS.mjs → chunk-VLNT34X3.mjs} +2 -2
- package/dist/chunk-VVL6JFCJ.mjs +16 -0
- package/dist/chunk-VVL6JFCJ.mjs.map +1 -0
- package/dist/chunk-WHDNKXMP.mjs +135 -0
- package/dist/chunk-WHDNKXMP.mjs.map +1 -0
- package/dist/{chunk-ALIBUJML.mjs → chunk-WPVTPQ7X.mjs} +2 -2
- package/dist/components/chat/Button.d.ts +1 -1
- package/dist/components/chat/Chat.d.ts +119 -28
- package/dist/components/chat/Chat.js +298 -658
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +12 -15
- package/dist/components/chat/CodeBlock.js.map +1 -1
- package/dist/components/chat/CodeBlock.mjs +1 -1
- package/dist/components/chat/Header.d.ts +1 -1
- package/dist/components/chat/Input.d.ts +1 -1
- package/dist/components/chat/Input.js +3 -3
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +2 -2
- package/dist/components/chat/Markdown.js +13 -2
- package/dist/components/chat/Markdown.js.map +1 -1
- package/dist/components/chat/Markdown.mjs +2 -2
- package/dist/components/chat/Messages.d.ts +3 -3
- package/dist/components/chat/Messages.js +40 -116
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +1 -1
- package/dist/components/chat/Modal.d.ts +7 -2
- package/dist/components/chat/Modal.js +308 -668
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +13 -16
- package/dist/components/chat/Popup.d.ts +7 -2
- package/dist/components/chat/Popup.js +310 -670
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +14 -17
- package/dist/components/chat/Sidebar.d.ts +7 -2
- package/dist/components/chat/Sidebar.js +312 -672
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +14 -17
- package/dist/components/chat/Suggestion.d.ts +2 -9
- package/dist/components/chat/Suggestion.js +6 -96
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +3 -5
- package/dist/components/chat/Suggestions.d.ts +1 -1
- package/dist/components/chat/Suggestions.js +4 -3
- package/dist/components/chat/Suggestions.js.map +1 -1
- package/dist/components/chat/Suggestions.mjs +2 -2
- package/dist/components/chat/Window.d.ts +1 -1
- package/dist/components/chat/index.d.ts +8 -3
- package/dist/components/chat/index.js +316 -676
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +18 -21
- package/dist/components/chat/messages/AssistantMessage.d.ts +1 -1
- package/dist/components/chat/messages/AssistantMessage.js +32 -24
- package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
- package/dist/components/chat/messages/AssistantMessage.mjs +3 -3
- package/dist/components/chat/messages/ImageRenderer.d.ts +12 -0
- package/dist/components/chat/messages/ImageRenderer.js +58 -0
- package/dist/components/chat/messages/ImageRenderer.js.map +1 -0
- package/dist/components/chat/messages/ImageRenderer.mjs +8 -0
- package/dist/components/chat/messages/RenderMessage.d.ts +9 -0
- package/dist/components/chat/messages/{RenderTextMessage.js → RenderMessage.js} +92 -47
- package/dist/components/chat/messages/RenderMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderMessage.mjs +16 -0
- package/dist/components/chat/messages/UserMessage.d.ts +1 -1
- package/dist/components/chat/messages/UserMessage.js +7 -1
- package/dist/components/chat/messages/UserMessage.js.map +1 -1
- package/dist/components/chat/messages/UserMessage.mjs +1 -1
- package/dist/components/chat/props.d.ts +32 -27
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.d.ts +8 -3
- package/dist/components/index.js +316 -676
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +18 -21
- package/dist/hooks/use-push-to-talk.d.ts +1 -1
- package/dist/hooks/use-push-to-talk.js +3 -3
- package/dist/hooks/use-push-to-talk.js.map +1 -1
- package/dist/hooks/use-push-to-talk.mjs +1 -1
- package/dist/index.css +59 -3
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +322 -682
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -21
- package/dist/types/css.d.ts +3 -0
- package/dist/types/css.js.map +1 -1
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +193 -105
- package/src/components/chat/CodeBlock.tsx +1 -1
- package/src/components/chat/Markdown.tsx +12 -2
- package/src/components/chat/Messages.tsx +43 -122
- package/src/components/chat/Suggestion.tsx +5 -108
- package/src/components/chat/Suggestions.tsx +0 -1
- package/src/components/chat/index.tsx +1 -1
- package/src/components/chat/messages/AssistantMessage.tsx +15 -23
- package/src/components/chat/messages/ImageRenderer.tsx +37 -0
- package/src/components/chat/messages/{RenderTextMessage.tsx → RenderMessage.tsx} +10 -9
- package/src/components/chat/messages/UserMessage.tsx +16 -5
- package/src/components/chat/props.ts +36 -28
- package/src/css/colors.css +10 -0
- package/src/css/markdown.css +8 -0
- package/src/css/messages.css +54 -5
- package/src/css/suggestions.css +1 -1
- package/src/hooks/use-push-to-talk.tsx +6 -5
- package/src/styles.css +1 -1
- package/src/types/css.ts +3 -0
- package/dist/chunk-2II3Q27P.mjs +0 -112
- package/dist/chunk-2II3Q27P.mjs.map +0 -1
- package/dist/chunk-32MUWKL3.mjs.map +0 -1
- package/dist/chunk-53CVDVS5.mjs +0 -127
- package/dist/chunk-53CVDVS5.mjs.map +0 -1
- package/dist/chunk-B3D7U7TJ.mjs +0 -211
- package/dist/chunk-B3D7U7TJ.mjs.map +0 -1
- package/dist/chunk-C7OB63U5.mjs +0 -36
- package/dist/chunk-C7OB63U5.mjs.map +0 -1
- package/dist/chunk-HKTWKCPS.mjs.map +0 -1
- package/dist/chunk-HWMFMBJC.mjs +0 -10
- package/dist/chunk-HWMFMBJC.mjs.map +0 -1
- package/dist/chunk-IMBPSLL4.mjs +0 -104
- package/dist/chunk-IMBPSLL4.mjs.map +0 -1
- package/dist/chunk-KENCH7RN.mjs.map +0 -1
- package/dist/chunk-L3GZ7TXC.mjs.map +0 -1
- package/dist/chunk-QGSPTXOV.mjs.map +0 -1
- package/dist/chunk-S5MBUNGN.mjs.map +0 -1
- package/dist/chunk-ULDQXCED.mjs +0 -78
- package/dist/chunk-ULDQXCED.mjs.map +0 -1
- package/dist/chunk-YTXEWDNC.mjs.map +0 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.d.ts +0 -9
- package/dist/components/chat/messages/RenderActionExecutionMessage.js +0 -869
- package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +0 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +0 -14
- package/dist/components/chat/messages/RenderAgentStateMessage.d.ts +0 -9
- package/dist/components/chat/messages/RenderAgentStateMessage.js +0 -854
- package/dist/components/chat/messages/RenderAgentStateMessage.js.map +0 -1
- package/dist/components/chat/messages/RenderAgentStateMessage.mjs +0 -14
- package/dist/components/chat/messages/RenderImageMessage.d.ts +0 -9
- package/dist/components/chat/messages/RenderImageMessage.js +0 -823
- package/dist/components/chat/messages/RenderImageMessage.js.map +0 -1
- package/dist/components/chat/messages/RenderImageMessage.mjs +0 -15
- package/dist/components/chat/messages/RenderImageMessage.mjs.map +0 -1
- package/dist/components/chat/messages/RenderResultMessage.d.ts +0 -9
- package/dist/components/chat/messages/RenderResultMessage.js +0 -778
- package/dist/components/chat/messages/RenderResultMessage.js.map +0 -1
- package/dist/components/chat/messages/RenderResultMessage.mjs +0 -14
- package/dist/components/chat/messages/RenderResultMessage.mjs.map +0 -1
- package/dist/components/chat/messages/RenderTextMessage.d.ts +0 -9
- package/dist/components/chat/messages/RenderTextMessage.js.map +0 -1
- package/dist/components/chat/messages/RenderTextMessage.mjs +0 -15
- package/dist/components/chat/messages/RenderTextMessage.mjs.map +0 -1
- package/src/components/chat/messages/RenderActionExecutionMessage.tsx +0 -127
- package/src/components/chat/messages/RenderAgentStateMessage.tsx +0 -116
- package/src/components/chat/messages/RenderImageMessage.tsx +0 -64
- package/src/components/chat/messages/RenderResultMessage.tsx +0 -26
- /package/dist/{chunk-4HUXYD3B.mjs.map → chunk-DTRPPNSA.mjs.map} +0 -0
- /package/dist/{chunk-KN2GCKBE.mjs.map → chunk-GJ3MFNBX.mjs.map} +0 -0
- /package/dist/{chunk-H3EM63WS.mjs.map → chunk-VLNT34X3.mjs.map} +0 -0
- /package/dist/{chunk-ALIBUJML.mjs.map → chunk-WPVTPQ7X.mjs.map} +0 -0
- /package/dist/components/chat/messages/{RenderActionExecutionMessage.mjs.map → ImageRenderer.mjs.map} +0 -0
- /package/dist/components/chat/messages/{RenderAgentStateMessage.mjs.map → RenderMessage.mjs.map} +0 -0
|
@@ -1,869 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
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
|
-
};
|
|
37
|
-
var __export = (target, all) => {
|
|
38
|
-
for (var name in all)
|
|
39
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
-
};
|
|
41
|
-
var __copyProps = (to, from, except, desc) => {
|
|
42
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
-
for (let key of __getOwnPropNames(from))
|
|
44
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
-
}
|
|
47
|
-
return to;
|
|
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
|
-
));
|
|
57
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
-
|
|
59
|
-
// src/components/chat/messages/RenderActionExecutionMessage.tsx
|
|
60
|
-
var RenderActionExecutionMessage_exports = {};
|
|
61
|
-
__export(RenderActionExecutionMessage_exports, {
|
|
62
|
-
RenderActionExecutionMessage: () => RenderActionExecutionMessage
|
|
63
|
-
});
|
|
64
|
-
module.exports = __toCommonJS(RenderActionExecutionMessage_exports);
|
|
65
|
-
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
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
|
|
72
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
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_rehype_raw = __toESM(require("rehype-raw"));
|
|
549
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
550
|
-
var defaultComponents = {
|
|
551
|
-
a(_a) {
|
|
552
|
-
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
553
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { target: "_blank", rel: "noopener noreferrer", children }));
|
|
554
|
-
},
|
|
555
|
-
// @ts-expect-error -- inline
|
|
556
|
-
code(_c) {
|
|
557
|
-
var _d = _c, { children, className, inline } = _d, props = __objRest(_d, ["children", "className", "inline"]);
|
|
558
|
-
if (Array.isArray(children) && children.length) {
|
|
559
|
-
if (children[0] == "\u258D") {
|
|
560
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
561
|
-
"span",
|
|
562
|
-
{
|
|
563
|
-
style: {
|
|
564
|
-
animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
|
|
565
|
-
marginTop: "0.25rem"
|
|
566
|
-
},
|
|
567
|
-
children: "\u258D"
|
|
568
|
-
}
|
|
569
|
-
);
|
|
570
|
-
}
|
|
571
|
-
children[0] = (children == null ? void 0 : children[0]).replace("`\u258D`", "\u258D");
|
|
572
|
-
}
|
|
573
|
-
const match = /language-(\w+)/.exec(className || "");
|
|
574
|
-
if (inline) {
|
|
575
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("code", __spreadProps(__spreadValues({ className }, props), { children }));
|
|
576
|
-
}
|
|
577
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
578
|
-
CodeBlock,
|
|
579
|
-
__spreadValues({
|
|
580
|
-
language: match && match[1] || "",
|
|
581
|
-
value: String(children).replace(/\n$/, "")
|
|
582
|
-
}, props),
|
|
583
|
-
Math.random()
|
|
584
|
-
);
|
|
585
|
-
},
|
|
586
|
-
h1: (_e) => {
|
|
587
|
-
var _f = _e, { children } = _f, props = __objRest(_f, ["children"]);
|
|
588
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h1", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
589
|
-
},
|
|
590
|
-
h2: (_g) => {
|
|
591
|
-
var _h = _g, { children } = _h, props = __objRest(_h, ["children"]);
|
|
592
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
593
|
-
},
|
|
594
|
-
h3: (_i) => {
|
|
595
|
-
var _j = _i, { children } = _j, props = __objRest(_j, ["children"]);
|
|
596
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h3", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
597
|
-
},
|
|
598
|
-
h4: (_k) => {
|
|
599
|
-
var _l = _k, { children } = _l, props = __objRest(_l, ["children"]);
|
|
600
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h4", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
601
|
-
},
|
|
602
|
-
h5: (_m) => {
|
|
603
|
-
var _n = _m, { children } = _n, props = __objRest(_n, ["children"]);
|
|
604
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h5", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
605
|
-
},
|
|
606
|
-
h6: (_o) => {
|
|
607
|
-
var _p = _o, { children } = _p, props = __objRest(_p, ["children"]);
|
|
608
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h6", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
609
|
-
},
|
|
610
|
-
p: (_q) => {
|
|
611
|
-
var _r = _q, { children } = _r, props = __objRest(_r, ["children"]);
|
|
612
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
613
|
-
},
|
|
614
|
-
pre: (_s) => {
|
|
615
|
-
var _t = _s, { children } = _t, props = __objRest(_t, ["children"]);
|
|
616
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("pre", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
617
|
-
},
|
|
618
|
-
blockquote: (_u) => {
|
|
619
|
-
var _v = _u, { children } = _v, props = __objRest(_v, ["children"]);
|
|
620
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("blockquote", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
621
|
-
},
|
|
622
|
-
ul: (_w) => {
|
|
623
|
-
var _x = _w, { children } = _x, props = __objRest(_x, ["children"]);
|
|
624
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
625
|
-
},
|
|
626
|
-
li: (_y) => {
|
|
627
|
-
var _z = _y, { children } = _z, props = __objRest(_z, ["children"]);
|
|
628
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
|
|
629
|
-
}
|
|
630
|
-
};
|
|
631
|
-
var MemoizedReactMarkdown = (0, import_react3.memo)(
|
|
632
|
-
import_react_markdown.default,
|
|
633
|
-
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
|
|
634
|
-
);
|
|
635
|
-
var Markdown = ({ content, components }) => {
|
|
636
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
637
|
-
MemoizedReactMarkdown,
|
|
638
|
-
{
|
|
639
|
-
components: __spreadValues(__spreadValues({}, defaultComponents), components),
|
|
640
|
-
remarkPlugins: [import_remark_gfm.default, import_remark_math.default],
|
|
641
|
-
rehypePlugins: [import_rehype_raw.default],
|
|
642
|
-
children: content
|
|
643
|
-
}
|
|
644
|
-
) });
|
|
645
|
-
};
|
|
646
|
-
|
|
647
|
-
// src/components/chat/messages/AssistantMessage.tsx
|
|
648
|
-
var import_react4 = require("react");
|
|
649
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
650
|
-
var AssistantMessage = (props) => {
|
|
651
|
-
const { icons, labels } = useChatContext();
|
|
652
|
-
const {
|
|
653
|
-
message,
|
|
654
|
-
isLoading,
|
|
655
|
-
subComponent,
|
|
656
|
-
onRegenerate,
|
|
657
|
-
onCopy,
|
|
658
|
-
onThumbsUp,
|
|
659
|
-
onThumbsDown,
|
|
660
|
-
isCurrentMessage,
|
|
661
|
-
rawData,
|
|
662
|
-
markdownTagRenderers
|
|
663
|
-
} = props;
|
|
664
|
-
const [copied, setCopied] = (0, import_react4.useState)(false);
|
|
665
|
-
const handleCopy = () => {
|
|
666
|
-
if (message && onCopy) {
|
|
667
|
-
navigator.clipboard.writeText(message);
|
|
668
|
-
setCopied(true);
|
|
669
|
-
onCopy(message);
|
|
670
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
671
|
-
} else if (message) {
|
|
672
|
-
navigator.clipboard.writeText(message);
|
|
673
|
-
setCopied(true);
|
|
674
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
675
|
-
}
|
|
676
|
-
};
|
|
677
|
-
const handleRegenerate = () => {
|
|
678
|
-
if (onRegenerate) {
|
|
679
|
-
onRegenerate();
|
|
680
|
-
}
|
|
681
|
-
};
|
|
682
|
-
const handleThumbsUp = () => {
|
|
683
|
-
const fullMessage = rawData;
|
|
684
|
-
if (onThumbsUp && fullMessage) {
|
|
685
|
-
onThumbsUp(fullMessage);
|
|
686
|
-
}
|
|
687
|
-
};
|
|
688
|
-
const handleThumbsDown = () => {
|
|
689
|
-
const fullMessage = rawData;
|
|
690
|
-
if (onThumbsDown && fullMessage) {
|
|
691
|
-
onThumbsDown(fullMessage);
|
|
692
|
-
}
|
|
693
|
-
};
|
|
694
|
-
const LoadingIcon = () => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: icons.activityIcon });
|
|
695
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
696
|
-
(message || isLoading) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
|
|
697
|
-
message && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Markdown, { content: message || "", components: markdownTagRenderers }),
|
|
698
|
-
isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LoadingIcon, {}),
|
|
699
|
-
message && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
700
|
-
"div",
|
|
701
|
-
{
|
|
702
|
-
className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`,
|
|
703
|
-
children: [
|
|
704
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
705
|
-
"button",
|
|
706
|
-
{
|
|
707
|
-
className: "copilotKitMessageControlButton",
|
|
708
|
-
onClick: handleRegenerate,
|
|
709
|
-
"aria-label": labels.regenerateResponse,
|
|
710
|
-
title: labels.regenerateResponse,
|
|
711
|
-
children: icons.regenerateIcon
|
|
712
|
-
}
|
|
713
|
-
),
|
|
714
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
715
|
-
"button",
|
|
716
|
-
{
|
|
717
|
-
className: "copilotKitMessageControlButton",
|
|
718
|
-
onClick: handleCopy,
|
|
719
|
-
"aria-label": labels.copyToClipboard,
|
|
720
|
-
title: labels.copyToClipboard,
|
|
721
|
-
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
|
|
722
|
-
}
|
|
723
|
-
),
|
|
724
|
-
onThumbsUp && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
725
|
-
"button",
|
|
726
|
-
{
|
|
727
|
-
className: "copilotKitMessageControlButton",
|
|
728
|
-
onClick: handleThumbsUp,
|
|
729
|
-
"aria-label": labels.thumbsUp,
|
|
730
|
-
title: labels.thumbsUp,
|
|
731
|
-
children: icons.thumbsUpIcon
|
|
732
|
-
}
|
|
733
|
-
),
|
|
734
|
-
onThumbsDown && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
735
|
-
"button",
|
|
736
|
-
{
|
|
737
|
-
className: "copilotKitMessageControlButton",
|
|
738
|
-
onClick: handleThumbsDown,
|
|
739
|
-
"aria-label": labels.thumbsDown,
|
|
740
|
-
title: labels.thumbsDown,
|
|
741
|
-
children: icons.thumbsDownIcon
|
|
742
|
-
}
|
|
743
|
-
)
|
|
744
|
-
]
|
|
745
|
-
}
|
|
746
|
-
)
|
|
747
|
-
] }),
|
|
748
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { marginBottom: "0.5rem" }, children: subComponent })
|
|
749
|
-
] });
|
|
750
|
-
};
|
|
751
|
-
|
|
752
|
-
// src/components/chat/messages/RenderActionExecutionMessage.tsx
|
|
753
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
754
|
-
function RenderActionExecutionMessage(_a) {
|
|
755
|
-
var _b = _a, {
|
|
756
|
-
AssistantMessage: AssistantMessage2 = AssistantMessage
|
|
757
|
-
} = _b, props = __objRest(_b, [
|
|
758
|
-
"AssistantMessage"
|
|
759
|
-
]);
|
|
760
|
-
const { chatComponentsCache } = (0, import_react_core.useCopilotContext)();
|
|
761
|
-
const { message, inProgress, index, isCurrentMessage, actionResult } = props;
|
|
762
|
-
if (message.isActionExecutionMessage()) {
|
|
763
|
-
if (chatComponentsCache.current !== null && (chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"])) {
|
|
764
|
-
const render = chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"];
|
|
765
|
-
if (typeof render === "string") {
|
|
766
|
-
if (isCurrentMessage && inProgress) {
|
|
767
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
768
|
-
AssistantMessage2,
|
|
769
|
-
{
|
|
770
|
-
rawData: message,
|
|
771
|
-
"data-message-role": "assistant",
|
|
772
|
-
isLoading: false,
|
|
773
|
-
isGenerating: true,
|
|
774
|
-
message: render
|
|
775
|
-
},
|
|
776
|
-
index
|
|
777
|
-
);
|
|
778
|
-
} else {
|
|
779
|
-
return null;
|
|
780
|
-
}
|
|
781
|
-
} else {
|
|
782
|
-
const args = message.arguments;
|
|
783
|
-
let status = "inProgress";
|
|
784
|
-
if (actionResult !== void 0) {
|
|
785
|
-
status = "complete";
|
|
786
|
-
} else if (message.status.code !== import_runtime_client_gql.MessageStatusCode.Pending) {
|
|
787
|
-
status = "executing";
|
|
788
|
-
}
|
|
789
|
-
try {
|
|
790
|
-
const toRender = render({
|
|
791
|
-
status,
|
|
792
|
-
// Cast to any as RenderFunctionStatus is a union that can be complex to narrow here
|
|
793
|
-
args,
|
|
794
|
-
result: actionResult,
|
|
795
|
-
name: message.name,
|
|
796
|
-
messageId: message.id
|
|
797
|
-
// Pass messageId for HITL action correlation
|
|
798
|
-
});
|
|
799
|
-
if (!toRender && status === "complete") {
|
|
800
|
-
return null;
|
|
801
|
-
}
|
|
802
|
-
if (typeof toRender === "string") {
|
|
803
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
804
|
-
AssistantMessage2,
|
|
805
|
-
{
|
|
806
|
-
rawData: message,
|
|
807
|
-
"data-message-role": "assistant",
|
|
808
|
-
isLoading: false,
|
|
809
|
-
isGenerating: false,
|
|
810
|
-
message: toRender
|
|
811
|
-
},
|
|
812
|
-
index
|
|
813
|
-
);
|
|
814
|
-
} else {
|
|
815
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
816
|
-
AssistantMessage2,
|
|
817
|
-
{
|
|
818
|
-
rawData: message,
|
|
819
|
-
"data-message-role": "action-render",
|
|
820
|
-
isLoading: false,
|
|
821
|
-
isGenerating: false,
|
|
822
|
-
subComponent: toRender
|
|
823
|
-
},
|
|
824
|
-
index
|
|
825
|
-
);
|
|
826
|
-
}
|
|
827
|
-
} catch (e) {
|
|
828
|
-
console.error(`Error executing render function for action ${message.name}: ${e}`);
|
|
829
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
830
|
-
AssistantMessage2,
|
|
831
|
-
{
|
|
832
|
-
rawData: message,
|
|
833
|
-
"data-message-role": "assistant",
|
|
834
|
-
isLoading: false,
|
|
835
|
-
isGenerating: false,
|
|
836
|
-
subComponent: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
|
|
837
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("b", { children: [
|
|
838
|
-
"\u274C Error executing render function for action ",
|
|
839
|
-
message.name,
|
|
840
|
-
":"
|
|
841
|
-
] }),
|
|
842
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("pre", { children: e instanceof Error ? e.message : String(e) })
|
|
843
|
-
] })
|
|
844
|
-
},
|
|
845
|
-
index
|
|
846
|
-
);
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
} else if (!inProgress || !isCurrentMessage) {
|
|
850
|
-
return null;
|
|
851
|
-
} else {
|
|
852
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
853
|
-
AssistantMessage2,
|
|
854
|
-
{
|
|
855
|
-
rawData: message,
|
|
856
|
-
"data-message-role": "assistant",
|
|
857
|
-
isLoading: true,
|
|
858
|
-
isGenerating: true
|
|
859
|
-
},
|
|
860
|
-
index
|
|
861
|
-
);
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
866
|
-
0 && (module.exports = {
|
|
867
|
-
RenderActionExecutionMessage
|
|
868
|
-
});
|
|
869
|
-
//# sourceMappingURL=RenderActionExecutionMessage.js.map
|