@copilotkit/react-ui 1.10.0-next.3 → 1.10.0-next.5
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 +20 -0
- package/dist/{chunk-O7KTFUAN.mjs → chunk-226ZMOE3.mjs} +2 -2
- package/dist/{chunk-PF3QW6U5.mjs → chunk-BXX6RM44.mjs} +2 -2
- package/dist/chunk-BXX6RM44.mjs.map +1 -0
- package/dist/chunk-BY42E5VF.mjs +203 -0
- package/dist/chunk-BY42E5VF.mjs.map +1 -0
- package/dist/{chunk-SGFUVPDB.mjs → chunk-FFJHOZX6.mjs} +2 -2
- package/dist/{chunk-GVKA7RQQ.mjs → chunk-GDSZGYCE.mjs} +2 -2
- package/dist/{chunk-QN7T3GWI.mjs → chunk-JY2CSDKN.mjs} +4 -6
- package/dist/chunk-JY2CSDKN.mjs.map +1 -0
- package/dist/{chunk-7L34XQRL.mjs → chunk-K344MVUT.mjs} +61 -8
- package/dist/chunk-K344MVUT.mjs.map +1 -0
- package/dist/{chunk-QNG5G23E.mjs → chunk-MYWIJSW6.mjs} +2 -2
- package/dist/chunk-MYWIJSW6.mjs.map +1 -0
- package/dist/{chunk-WHDNKXMP.mjs → chunk-U5ATIGWH.mjs} +2 -2
- package/dist/chunk-U5ATIGWH.mjs.map +1 -0
- package/dist/{chunk-Q2467VHZ.mjs → chunk-W26XFBEG.mjs} +2 -2
- package/dist/chunk-W26XFBEG.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +19 -12
- package/dist/components/chat/Chat.js +57 -10
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +4 -4
- package/dist/components/chat/Header.js +6 -8
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +3 -3
- package/dist/components/chat/Messages.js +1 -1
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +1 -1
- package/dist/components/chat/Modal.d.ts +2 -2
- package/dist/components/chat/Modal.js +179 -76
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +8 -8
- package/dist/components/chat/Popup.d.ts +1 -1
- package/dist/components/chat/Popup.js +179 -76
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +9 -9
- package/dist/components/chat/Sidebar.d.ts +1 -1
- package/dist/components/chat/Sidebar.js +179 -76
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +9 -9
- package/dist/components/chat/Suggestion.js +1 -1
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +1 -1
- package/dist/components/chat/Suggestions.js +1 -1
- package/dist/components/chat/Suggestions.js.map +1 -1
- package/dist/components/chat/Suggestions.mjs +2 -2
- package/dist/components/chat/index.d.ts +2 -2
- package/dist/components/chat/index.js +179 -76
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +10 -10
- package/dist/components/chat/props.d.ts +39 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/dev-console/console.d.ts +1 -0
- package/dist/components/dev-console/console.js +6 -8
- package/dist/components/dev-console/console.js.map +1 -1
- package/dist/components/dev-console/console.mjs +2 -2
- package/dist/components/dev-console/index.d.ts +1 -3
- package/dist/components/dev-console/index.js +7 -9
- package/dist/components/dev-console/index.js.map +1 -1
- package/dist/components/dev-console/index.mjs +2 -2
- package/dist/components/dev-console/utils.d.ts +2 -2
- package/dist/components/dev-console/utils.js +2 -4
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +1 -1
- package/dist/components/index.d.ts +3 -5
- package/dist/components/index.js +180 -77
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +10 -10
- package/dist/index.d.ts +3 -5
- package/dist/index.js +184 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/package.json +5 -5
- package/src/components/chat/Chat.tsx +99 -5
- package/src/components/chat/Messages.tsx +2 -2
- package/src/components/chat/Modal.tsx +107 -41
- package/src/components/chat/Popup.tsx +20 -0
- package/src/components/chat/Sidebar.tsx +22 -0
- package/src/components/chat/Suggestion.tsx +1 -1
- package/src/components/chat/props.ts +46 -0
- package/src/components/dev-console/utils.ts +1 -6
- package/dist/chunk-7L34XQRL.mjs.map +0 -1
- package/dist/chunk-DNSSBMAS.mjs +0 -144
- package/dist/chunk-DNSSBMAS.mjs.map +0 -1
- package/dist/chunk-PF3QW6U5.mjs.map +0 -1
- package/dist/chunk-Q2467VHZ.mjs.map +0 -1
- package/dist/chunk-QN7T3GWI.mjs.map +0 -1
- package/dist/chunk-QNG5G23E.mjs.map +0 -1
- package/dist/chunk-WHDNKXMP.mjs.map +0 -1
- /package/dist/{chunk-O7KTFUAN.mjs.map → chunk-226ZMOE3.mjs.map} +0 -0
- /package/dist/{chunk-SGFUVPDB.mjs.map → chunk-FFJHOZX6.mjs.map} +0 -0
- /package/dist/{chunk-GVKA7RQQ.mjs.map → chunk-GDSZGYCE.mjs.map} +0 -0
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotPopup
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-BXX6RM44.mjs";
|
|
4
|
+
import "../../chunk-BY42E5VF.mjs";
|
|
5
5
|
import "../../chunk-C3GSYRC3.mjs";
|
|
6
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-GDSZGYCE.mjs";
|
|
7
7
|
import "../../chunk-V7W6IM2V.mjs";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-FFJHOZX6.mjs";
|
|
9
9
|
import "../../chunk-Q5V6S67N.mjs";
|
|
10
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-JY2CSDKN.mjs";
|
|
11
11
|
import "../../chunk-KXE2JCUH.mjs";
|
|
12
12
|
import "../../chunk-NRA3CFEE.mjs";
|
|
13
13
|
import "../../chunk-BH6PCAAL.mjs";
|
|
14
14
|
import "../../chunk-UFN2VWSR.mjs";
|
|
15
|
-
import "../../chunk-
|
|
15
|
+
import "../../chunk-K344MVUT.mjs";
|
|
16
16
|
import "../../chunk-JHUTTP5C.mjs";
|
|
17
17
|
import "../../chunk-GCKKSSBU.mjs";
|
|
18
18
|
import "../../chunk-DBKRAOH7.mjs";
|
|
19
19
|
import "../../chunk-VVL6JFCJ.mjs";
|
|
20
|
-
import "../../chunk-
|
|
21
|
-
import "../../chunk-
|
|
20
|
+
import "../../chunk-226ZMOE3.mjs";
|
|
21
|
+
import "../../chunk-W26XFBEG.mjs";
|
|
22
22
|
import "../../chunk-PLHTVHUW.mjs";
|
|
23
23
|
import "../../chunk-DTRPPNSA.mjs";
|
|
24
24
|
import "../../chunk-CGEAG65D.mjs";
|
|
25
25
|
import "../../chunk-QIOJXTIQ.mjs";
|
|
26
26
|
import "../../chunk-E6MQUIZW.mjs";
|
|
27
|
-
import "../../chunk-
|
|
27
|
+
import "../../chunk-U5ATIGWH.mjs";
|
|
28
28
|
import "../../chunk-IEMQ2SQW.mjs";
|
|
29
29
|
import "../../chunk-B5IFB5YJ.mjs";
|
|
30
30
|
import "../../chunk-XWG3L6QC.mjs";
|
|
@@ -7,7 +7,7 @@ import '../../types/suggestions.js';
|
|
|
7
7
|
import './Chat.js';
|
|
8
8
|
import '@copilotkit/react-core/dist/types/coagent-state';
|
|
9
9
|
import '@copilotkit/react-core/dist/hooks/use-tree';
|
|
10
|
-
import '@copilotkit/react-core/dist/copilot-context-
|
|
10
|
+
import '@copilotkit/react-core/dist/copilot-context-78fc727c';
|
|
11
11
|
import '@copilotkit/react-core/dist/types/coagent-action';
|
|
12
12
|
import '@copilotkit/react-core';
|
|
13
13
|
import '@copilotkit/runtime-client-gql';
|
|
@@ -525,9 +525,7 @@ var Button = ({}) => {
|
|
|
525
525
|
|
|
526
526
|
// src/components/dev-console/utils.ts
|
|
527
527
|
var import_react_core2 = require("@copilotkit/react-core");
|
|
528
|
-
|
|
529
|
-
return showDevConsole;
|
|
530
|
-
}
|
|
528
|
+
var import_react_core3 = require("@copilotkit/react-core");
|
|
531
529
|
function getPublishedCopilotKitVersion(current, forceCheck = false) {
|
|
532
530
|
return __async(this, null, function* () {
|
|
533
531
|
const LOCAL_STORAGE_KEY = "__copilotkit_version_check__";
|
|
@@ -647,7 +645,7 @@ function logMessages(context) {
|
|
|
647
645
|
}
|
|
648
646
|
|
|
649
647
|
// src/components/dev-console/console.tsx
|
|
650
|
-
var
|
|
648
|
+
var import_react_core4 = require("@copilotkit/react-core");
|
|
651
649
|
var import_react4 = require("react");
|
|
652
650
|
|
|
653
651
|
// src/components/dev-console/icons.tsx
|
|
@@ -837,10 +835,10 @@ function CopilotKitHelpModal() {
|
|
|
837
835
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
838
836
|
function CopilotDevConsole() {
|
|
839
837
|
const currentVersion = import_shared2.COPILOTKIT_VERSION;
|
|
840
|
-
const context = (0,
|
|
838
|
+
const context = (0, import_react_core4.useCopilotContext)();
|
|
841
839
|
const [showDevConsole, setShowDevConsole] = (0, import_react4.useState)(false);
|
|
842
840
|
(0, import_react4.useEffect)(() => {
|
|
843
|
-
setShowDevConsole(shouldShowDevConsole(context.showDevConsole));
|
|
841
|
+
setShowDevConsole((0, import_react_core3.shouldShowDevConsole)(context.showDevConsole));
|
|
844
842
|
}, [context.showDevConsole]);
|
|
845
843
|
const dontRunTwiceInDevMode = (0, import_react4.useRef)(false);
|
|
846
844
|
const [versionStatus, setVersionStatus] = (0, import_react4.useState)("unknown");
|
|
@@ -966,8 +964,8 @@ function DebugMenuButton({
|
|
|
966
964
|
checkForUpdates,
|
|
967
965
|
mode
|
|
968
966
|
}) {
|
|
969
|
-
const context = (0,
|
|
970
|
-
const messagesContext = (0,
|
|
967
|
+
const context = (0, import_react_core4.useCopilotContext)();
|
|
968
|
+
const messagesContext = (0, import_react_core4.useCopilotMessagesContext)();
|
|
971
969
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react5.Menu, { children: [
|
|
972
970
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
973
971
|
import_react5.MenuButton,
|
|
@@ -1029,7 +1027,7 @@ var Header = ({}) => {
|
|
|
1029
1027
|
|
|
1030
1028
|
// src/components/chat/Messages.tsx
|
|
1031
1029
|
var import_react6 = require("react");
|
|
1032
|
-
var
|
|
1030
|
+
var import_react_core5 = require("@copilotkit/react-core");
|
|
1033
1031
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1034
1032
|
var Messages = ({
|
|
1035
1033
|
inProgress,
|
|
@@ -1044,7 +1042,7 @@ var Messages = ({
|
|
|
1044
1042
|
markdownTagRenderers
|
|
1045
1043
|
}) => {
|
|
1046
1044
|
const { labels } = useChatContext();
|
|
1047
|
-
const { visibleMessages, interrupt } = (0,
|
|
1045
|
+
const { visibleMessages, interrupt } = (0, import_react_core5.useCopilotChatInternal)();
|
|
1048
1046
|
const initialMessages = (0, import_react6.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
|
|
1049
1047
|
const messages = [...initialMessages, ...visibleMessages];
|
|
1050
1048
|
const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
|
|
@@ -1217,7 +1215,7 @@ var AutoResizingTextarea = (0, import_react7.forwardRef)(
|
|
|
1217
1215
|
var Textarea_default = AutoResizingTextarea;
|
|
1218
1216
|
|
|
1219
1217
|
// src/hooks/use-push-to-talk.tsx
|
|
1220
|
-
var
|
|
1218
|
+
var import_react_core6 = require("@copilotkit/react-core");
|
|
1221
1219
|
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
1222
1220
|
var import_react8 = require("react");
|
|
1223
1221
|
var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
|
|
@@ -1273,8 +1271,8 @@ var usePushToTalk = ({
|
|
|
1273
1271
|
const audioContextRef = (0, import_react8.useRef)(null);
|
|
1274
1272
|
const mediaRecorderRef = (0, import_react8.useRef)(null);
|
|
1275
1273
|
const recordedChunks = (0, import_react8.useRef)([]);
|
|
1276
|
-
const generalContext = (0,
|
|
1277
|
-
const messagesContext = (0,
|
|
1274
|
+
const generalContext = (0, import_react_core6.useCopilotContext)();
|
|
1275
|
+
const messagesContext = (0, import_react_core6.useCopilotMessagesContext)();
|
|
1278
1276
|
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
1279
1277
|
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react8.useState)(null);
|
|
1280
1278
|
(0, import_react8.useEffect)(() => {
|
|
@@ -1321,7 +1319,7 @@ var usePushToTalk = ({
|
|
|
1321
1319
|
};
|
|
1322
1320
|
|
|
1323
1321
|
// src/components/chat/Input.tsx
|
|
1324
|
-
var
|
|
1322
|
+
var import_react_core7 = require("@copilotkit/react-core");
|
|
1325
1323
|
|
|
1326
1324
|
// src/hooks/use-dark-mode.ts
|
|
1327
1325
|
var useDarkMode = () => {
|
|
@@ -1362,7 +1360,7 @@ var Input = ({
|
|
|
1362
1360
|
}) => {
|
|
1363
1361
|
var _a, _b;
|
|
1364
1362
|
const context = useChatContext();
|
|
1365
|
-
const copilotContext = (0,
|
|
1363
|
+
const copilotContext = (0, import_react_core7.useCopilotContext)();
|
|
1366
1364
|
const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
|
|
1367
1365
|
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
1368
1366
|
const textareaRef = (0, import_react9.useRef)(null);
|
|
@@ -2169,9 +2167,10 @@ function RenderMessage(_a) {
|
|
|
2169
2167
|
|
|
2170
2168
|
// src/components/chat/Chat.tsx
|
|
2171
2169
|
var import_react14 = __toESM(require("react"));
|
|
2172
|
-
var import_react_core8 = require("@copilotkit/react-core");
|
|
2173
|
-
var import_shared3 = require("@copilotkit/shared");
|
|
2174
2170
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2171
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
2172
|
+
var import_shared4 = require("@copilotkit/shared");
|
|
2173
|
+
var import_react_core10 = require("@copilotkit/react-core");
|
|
2175
2174
|
|
|
2176
2175
|
// src/components/chat/ImageUploadQueue.tsx
|
|
2177
2176
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
@@ -2252,12 +2251,12 @@ var ImageUploadQueue = ({
|
|
|
2252
2251
|
};
|
|
2253
2252
|
|
|
2254
2253
|
// src/components/chat/Suggestion.tsx
|
|
2255
|
-
var
|
|
2254
|
+
var import_react_core8 = require("@copilotkit/react-core");
|
|
2256
2255
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2257
2256
|
function Suggestion({ title, onClick, partial, className }) {
|
|
2258
2257
|
if (!title)
|
|
2259
2258
|
return null;
|
|
2260
|
-
const { isLoading } = (0,
|
|
2259
|
+
const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
|
|
2261
2260
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2262
2261
|
"button",
|
|
2263
2262
|
{
|
|
@@ -2316,11 +2315,31 @@ function CopilotChat({
|
|
|
2316
2315
|
ImageRenderer: ImageRenderer2 = ImageRenderer,
|
|
2317
2316
|
imageUploadsEnabled,
|
|
2318
2317
|
inputFileAccept = "image/*",
|
|
2319
|
-
hideStopButton
|
|
2318
|
+
hideStopButton,
|
|
2319
|
+
observabilityHooks
|
|
2320
2320
|
}) {
|
|
2321
|
-
const { additionalInstructions, setChatInstructions } = (0,
|
|
2321
|
+
const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
|
|
2322
2322
|
const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
|
|
2323
2323
|
const fileInputRef = (0, import_react14.useRef)(null);
|
|
2324
|
+
const triggerObservabilityHook = (0, import_react14.useCallback)(
|
|
2325
|
+
(hookName, ...args) => {
|
|
2326
|
+
if (copilotApiConfig.publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2327
|
+
observabilityHooks[hookName](...args);
|
|
2328
|
+
}
|
|
2329
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !copilotApiConfig.publicApiKey) {
|
|
2330
|
+
setBannerError(
|
|
2331
|
+
new import_shared3.CopilotKitError({
|
|
2332
|
+
message: "observabilityHooks requires a publicApiKey to function.",
|
|
2333
|
+
code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2334
|
+
severity: import_shared3.Severity.CRITICAL,
|
|
2335
|
+
visibility: import_shared3.ErrorVisibility.BANNER
|
|
2336
|
+
})
|
|
2337
|
+
);
|
|
2338
|
+
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2339
|
+
}
|
|
2340
|
+
},
|
|
2341
|
+
[copilotApiConfig.publicApiKey, observabilityHooks]
|
|
2342
|
+
);
|
|
2324
2343
|
(0, import_react14.useEffect)(() => {
|
|
2325
2344
|
if (!imageUploadsEnabled)
|
|
2326
2345
|
return;
|
|
@@ -2393,12 +2412,24 @@ function CopilotChat({
|
|
|
2393
2412
|
onStopGeneration,
|
|
2394
2413
|
onReloadMessages
|
|
2395
2414
|
);
|
|
2415
|
+
const prevIsLoading = (0, import_react14.useRef)(isLoading);
|
|
2416
|
+
(0, import_react14.useEffect)(() => {
|
|
2417
|
+
if (prevIsLoading.current !== isLoading) {
|
|
2418
|
+
if (isLoading) {
|
|
2419
|
+
triggerObservabilityHook("onChatStarted");
|
|
2420
|
+
} else {
|
|
2421
|
+
triggerObservabilityHook("onChatStopped");
|
|
2422
|
+
}
|
|
2423
|
+
prevIsLoading.current = isLoading;
|
|
2424
|
+
}
|
|
2425
|
+
}, [isLoading, triggerObservabilityHook]);
|
|
2396
2426
|
const handleSendMessage = (text) => {
|
|
2397
2427
|
const images = selectedImages;
|
|
2398
2428
|
setSelectedImages([]);
|
|
2399
2429
|
if (fileInputRef.current) {
|
|
2400
2430
|
fileInputRef.current.value = "";
|
|
2401
2431
|
}
|
|
2432
|
+
triggerObservabilityHook("onMessageSent", text);
|
|
2402
2433
|
return sendMessage(text, images);
|
|
2403
2434
|
};
|
|
2404
2435
|
const chatContext = import_react14.default.useContext(ChatContext);
|
|
@@ -2407,12 +2438,14 @@ function CopilotChat({
|
|
|
2407
2438
|
if (onRegenerate) {
|
|
2408
2439
|
onRegenerate(messageId);
|
|
2409
2440
|
}
|
|
2441
|
+
triggerObservabilityHook("onMessageRegenerated", messageId);
|
|
2410
2442
|
reloadMessages(messageId);
|
|
2411
2443
|
};
|
|
2412
2444
|
const handleCopy = (message) => {
|
|
2413
2445
|
if (onCopy) {
|
|
2414
2446
|
onCopy(message);
|
|
2415
2447
|
}
|
|
2448
|
+
triggerObservabilityHook("onMessageCopied", message);
|
|
2416
2449
|
};
|
|
2417
2450
|
const handleImageUpload = (event) => __async(this, null, function* () {
|
|
2418
2451
|
if (!event.target.files || event.target.files.length === 0) {
|
|
@@ -2448,6 +2481,18 @@ function CopilotChat({
|
|
|
2448
2481
|
const removeSelectedImage = (index) => {
|
|
2449
2482
|
setSelectedImages((prev) => prev.filter((_, i) => i !== index));
|
|
2450
2483
|
};
|
|
2484
|
+
const handleThumbsUp = (message) => {
|
|
2485
|
+
if (onThumbsUp) {
|
|
2486
|
+
onThumbsUp(message);
|
|
2487
|
+
}
|
|
2488
|
+
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsUp");
|
|
2489
|
+
};
|
|
2490
|
+
const handleThumbsDown = (message) => {
|
|
2491
|
+
if (onThumbsDown) {
|
|
2492
|
+
onThumbsDown(message);
|
|
2493
|
+
}
|
|
2494
|
+
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2495
|
+
};
|
|
2451
2496
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2452
2497
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2453
2498
|
Messages2,
|
|
@@ -2459,8 +2504,8 @@ function CopilotChat({
|
|
|
2459
2504
|
inProgress: isLoading,
|
|
2460
2505
|
onRegenerate: handleRegenerate,
|
|
2461
2506
|
onCopy: handleCopy,
|
|
2462
|
-
onThumbsUp,
|
|
2463
|
-
onThumbsDown,
|
|
2507
|
+
onThumbsUp: handleThumbsUp,
|
|
2508
|
+
onThumbsDown: handleThumbsDown,
|
|
2464
2509
|
markdownTagRenderers,
|
|
2465
2510
|
ImageRenderer: ImageRenderer2,
|
|
2466
2511
|
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
@@ -2530,11 +2575,11 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2530
2575
|
generateSuggestions,
|
|
2531
2576
|
resetSuggestions: resetSuggestionsFromHook,
|
|
2532
2577
|
isLoadingSuggestions
|
|
2533
|
-
} = (0,
|
|
2578
|
+
} = (0, import_react_core9.useCopilotChatInternal)({
|
|
2534
2579
|
makeSystemMessage
|
|
2535
2580
|
});
|
|
2536
|
-
const generalContext = (0,
|
|
2537
|
-
const messagesContext = (0,
|
|
2581
|
+
const generalContext = (0, import_react_core9.useCopilotContext)();
|
|
2582
|
+
const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
|
|
2538
2583
|
const { actions } = generalContext;
|
|
2539
2584
|
const [suggestionsFailed, setSuggestionsFailed] = (0, import_react14.useState)(false);
|
|
2540
2585
|
const hasGeneratedInitialSuggestions = (0, import_react14.useRef)(false);
|
|
@@ -2616,7 +2661,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2616
2661
|
let firstMessage = null;
|
|
2617
2662
|
if (messageContent.trim().length > 0) {
|
|
2618
2663
|
const textMessage = {
|
|
2619
|
-
id: (0,
|
|
2664
|
+
id: (0, import_shared4.randomId)(),
|
|
2620
2665
|
role: "user",
|
|
2621
2666
|
content: messageContent
|
|
2622
2667
|
};
|
|
@@ -2638,7 +2683,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2638
2683
|
if (images.length > 0) {
|
|
2639
2684
|
for (let i = 0; i < images.length; i++) {
|
|
2640
2685
|
const imageMessage = {
|
|
2641
|
-
id: (0,
|
|
2686
|
+
id: (0, import_shared4.randomId)(),
|
|
2642
2687
|
role: "user",
|
|
2643
2688
|
image: {
|
|
2644
2689
|
format: images[i].contentType.replace("image/", ""),
|
|
@@ -2652,7 +2697,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2652
2697
|
}
|
|
2653
2698
|
}
|
|
2654
2699
|
if (!firstMessage) {
|
|
2655
|
-
return { role: "user", content: "", id: (0,
|
|
2700
|
+
return { role: "user", content: "", id: (0, import_shared4.randomId)() };
|
|
2656
2701
|
}
|
|
2657
2702
|
return firstMessage;
|
|
2658
2703
|
});
|
|
@@ -2677,7 +2722,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2677
2722
|
});
|
|
2678
2723
|
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2679
2724
|
if (generalContext.agentSession) {
|
|
2680
|
-
yield (0,
|
|
2725
|
+
yield (0, import_react_core10.runAgent)(
|
|
2681
2726
|
generalContext.agentSession.agentName,
|
|
2682
2727
|
stableContext,
|
|
2683
2728
|
appendMessage,
|
|
@@ -2688,7 +2733,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2688
2733
|
});
|
|
2689
2734
|
const stopCurrentAgent = () => {
|
|
2690
2735
|
if (generalContext.agentSession) {
|
|
2691
|
-
(0,
|
|
2736
|
+
(0, import_react_core10.stopAgent)(generalContext.agentSession.agentName, stableContext);
|
|
2692
2737
|
}
|
|
2693
2738
|
};
|
|
2694
2739
|
const setCurrentAgentState = (state) => {
|
|
@@ -2751,7 +2796,75 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2751
2796
|
};
|
|
2752
2797
|
|
|
2753
2798
|
// src/components/chat/Modal.tsx
|
|
2799
|
+
var import_react_core11 = require("@copilotkit/react-core");
|
|
2754
2800
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2801
|
+
var CopilotModalInner = (_a) => {
|
|
2802
|
+
var _b = _a, {
|
|
2803
|
+
observabilityHooks,
|
|
2804
|
+
onSetOpen,
|
|
2805
|
+
clickOutsideToClose,
|
|
2806
|
+
hitEscapeToClose,
|
|
2807
|
+
shortcut,
|
|
2808
|
+
className,
|
|
2809
|
+
children,
|
|
2810
|
+
Window: Window2,
|
|
2811
|
+
Button: Button2,
|
|
2812
|
+
Header: Header2
|
|
2813
|
+
} = _b, chatProps = __objRest(_b, [
|
|
2814
|
+
"observabilityHooks",
|
|
2815
|
+
"onSetOpen",
|
|
2816
|
+
"clickOutsideToClose",
|
|
2817
|
+
"hitEscapeToClose",
|
|
2818
|
+
"shortcut",
|
|
2819
|
+
"className",
|
|
2820
|
+
"children",
|
|
2821
|
+
"Window",
|
|
2822
|
+
"Button",
|
|
2823
|
+
"Header"
|
|
2824
|
+
]);
|
|
2825
|
+
const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
|
|
2826
|
+
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2827
|
+
(hookName, ...args) => {
|
|
2828
|
+
if (copilotApiConfig.publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2829
|
+
observabilityHooks[hookName](...args);
|
|
2830
|
+
}
|
|
2831
|
+
},
|
|
2832
|
+
[copilotApiConfig.publicApiKey, observabilityHooks]
|
|
2833
|
+
);
|
|
2834
|
+
const { open } = useChatContext();
|
|
2835
|
+
const prevOpen = (0, import_react15.useRef)(open);
|
|
2836
|
+
(0, import_react15.useEffect)(() => {
|
|
2837
|
+
if (prevOpen.current !== open) {
|
|
2838
|
+
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
2839
|
+
if (open) {
|
|
2840
|
+
triggerObservabilityHook("onChatExpanded");
|
|
2841
|
+
} else {
|
|
2842
|
+
triggerObservabilityHook("onChatMinimized");
|
|
2843
|
+
}
|
|
2844
|
+
prevOpen.current = open;
|
|
2845
|
+
}
|
|
2846
|
+
}, [open, onSetOpen, triggerObservabilityHook]);
|
|
2847
|
+
const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Header2, {}), [Header2]);
|
|
2848
|
+
const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
|
|
2849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
2850
|
+
memoizedChildren,
|
|
2851
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className, children: [
|
|
2852
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Button2, {}),
|
|
2853
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2854
|
+
Window2,
|
|
2855
|
+
{
|
|
2856
|
+
clickOutsideToClose,
|
|
2857
|
+
shortcut,
|
|
2858
|
+
hitEscapeToClose,
|
|
2859
|
+
children: [
|
|
2860
|
+
memoizedHeader,
|
|
2861
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
|
|
2862
|
+
]
|
|
2863
|
+
}
|
|
2864
|
+
)
|
|
2865
|
+
] })
|
|
2866
|
+
] });
|
|
2867
|
+
};
|
|
2755
2868
|
var CopilotModal = (_a) => {
|
|
2756
2869
|
var _b = _a, {
|
|
2757
2870
|
instructions,
|
|
@@ -2780,7 +2893,8 @@ var CopilotModal = (_a) => {
|
|
|
2780
2893
|
onRegenerate,
|
|
2781
2894
|
markdownTagRenderers,
|
|
2782
2895
|
className,
|
|
2783
|
-
children
|
|
2896
|
+
children,
|
|
2897
|
+
observabilityHooks
|
|
2784
2898
|
} = _b, props = __objRest(_b, [
|
|
2785
2899
|
"instructions",
|
|
2786
2900
|
"defaultOpen",
|
|
@@ -2808,52 +2922,41 @@ var CopilotModal = (_a) => {
|
|
|
2808
2922
|
"onRegenerate",
|
|
2809
2923
|
"markdownTagRenderers",
|
|
2810
2924
|
"className",
|
|
2811
|
-
"children"
|
|
2925
|
+
"children",
|
|
2926
|
+
"observabilityHooks"
|
|
2812
2927
|
]);
|
|
2813
2928
|
const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
onThumbsUp,
|
|
2846
|
-
onThumbsDown,
|
|
2847
|
-
onCopy,
|
|
2848
|
-
onRegenerate,
|
|
2849
|
-
markdownTagRenderers
|
|
2850
|
-
})
|
|
2851
|
-
)
|
|
2852
|
-
]
|
|
2853
|
-
}
|
|
2854
|
-
)
|
|
2855
|
-
] })
|
|
2856
|
-
] });
|
|
2929
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2930
|
+
CopilotModalInner,
|
|
2931
|
+
__spreadProps(__spreadValues({
|
|
2932
|
+
observabilityHooks,
|
|
2933
|
+
onSetOpen,
|
|
2934
|
+
clickOutsideToClose: clickOutsideToClose != null ? clickOutsideToClose : true,
|
|
2935
|
+
hitEscapeToClose: hitEscapeToClose != null ? hitEscapeToClose : true,
|
|
2936
|
+
shortcut: shortcut != null ? shortcut : "/",
|
|
2937
|
+
className,
|
|
2938
|
+
Window: Window2,
|
|
2939
|
+
Button: Button2,
|
|
2940
|
+
Header: Header2,
|
|
2941
|
+
instructions,
|
|
2942
|
+
onSubmitMessage,
|
|
2943
|
+
onStopGeneration,
|
|
2944
|
+
onReloadMessages,
|
|
2945
|
+
makeSystemMessage,
|
|
2946
|
+
onInProgress,
|
|
2947
|
+
Messages: Messages2,
|
|
2948
|
+
Input: Input2,
|
|
2949
|
+
AssistantMessage: AssistantMessage2,
|
|
2950
|
+
UserMessage: UserMessage2,
|
|
2951
|
+
onThumbsUp,
|
|
2952
|
+
onThumbsDown,
|
|
2953
|
+
onCopy,
|
|
2954
|
+
onRegenerate,
|
|
2955
|
+
markdownTagRenderers
|
|
2956
|
+
}, props), {
|
|
2957
|
+
children
|
|
2958
|
+
})
|
|
2959
|
+
) });
|
|
2857
2960
|
};
|
|
2858
2961
|
|
|
2859
2962
|
// src/components/chat/Sidebar.tsx
|