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