@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
package/dist/components/index.js
CHANGED
|
@@ -89,7 +89,7 @@ __export(components_exports, {
|
|
|
89
89
|
RenderSuggestion: () => Suggestion,
|
|
90
90
|
RenderSuggestionsList: () => Suggestions,
|
|
91
91
|
UserMessage: () => UserMessage,
|
|
92
|
-
shouldShowDevConsole: () => shouldShowDevConsole,
|
|
92
|
+
shouldShowDevConsole: () => import_react_core3.shouldShowDevConsole,
|
|
93
93
|
useChatContext: () => useChatContext
|
|
94
94
|
});
|
|
95
95
|
module.exports = __toCommonJS(components_exports);
|
|
@@ -535,9 +535,7 @@ var Button = ({}) => {
|
|
|
535
535
|
|
|
536
536
|
// src/components/dev-console/utils.ts
|
|
537
537
|
var import_react_core2 = require("@copilotkit/react-core");
|
|
538
|
-
|
|
539
|
-
return showDevConsole;
|
|
540
|
-
}
|
|
538
|
+
var import_react_core3 = require("@copilotkit/react-core");
|
|
541
539
|
function getPublishedCopilotKitVersion(current, forceCheck = false) {
|
|
542
540
|
return __async(this, null, function* () {
|
|
543
541
|
const LOCAL_STORAGE_KEY = "__copilotkit_version_check__";
|
|
@@ -657,7 +655,7 @@ function logMessages(context) {
|
|
|
657
655
|
}
|
|
658
656
|
|
|
659
657
|
// src/components/dev-console/console.tsx
|
|
660
|
-
var
|
|
658
|
+
var import_react_core4 = require("@copilotkit/react-core");
|
|
661
659
|
var import_react4 = require("react");
|
|
662
660
|
|
|
663
661
|
// src/components/dev-console/icons.tsx
|
|
@@ -847,10 +845,10 @@ function CopilotKitHelpModal() {
|
|
|
847
845
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
848
846
|
function CopilotDevConsole() {
|
|
849
847
|
const currentVersion = import_shared2.COPILOTKIT_VERSION;
|
|
850
|
-
const context = (0,
|
|
848
|
+
const context = (0, import_react_core4.useCopilotContext)();
|
|
851
849
|
const [showDevConsole, setShowDevConsole] = (0, import_react4.useState)(false);
|
|
852
850
|
(0, import_react4.useEffect)(() => {
|
|
853
|
-
setShowDevConsole(shouldShowDevConsole(context.showDevConsole));
|
|
851
|
+
setShowDevConsole((0, import_react_core3.shouldShowDevConsole)(context.showDevConsole));
|
|
854
852
|
}, [context.showDevConsole]);
|
|
855
853
|
const dontRunTwiceInDevMode = (0, import_react4.useRef)(false);
|
|
856
854
|
const [versionStatus, setVersionStatus] = (0, import_react4.useState)("unknown");
|
|
@@ -976,8 +974,8 @@ function DebugMenuButton({
|
|
|
976
974
|
checkForUpdates,
|
|
977
975
|
mode
|
|
978
976
|
}) {
|
|
979
|
-
const context = (0,
|
|
980
|
-
const messagesContext = (0,
|
|
977
|
+
const context = (0, import_react_core4.useCopilotContext)();
|
|
978
|
+
const messagesContext = (0, import_react_core4.useCopilotMessagesContext)();
|
|
981
979
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react5.Menu, { children: [
|
|
982
980
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
983
981
|
import_react5.MenuButton,
|
|
@@ -1039,7 +1037,7 @@ var Header = ({}) => {
|
|
|
1039
1037
|
|
|
1040
1038
|
// src/components/chat/Messages.tsx
|
|
1041
1039
|
var import_react6 = require("react");
|
|
1042
|
-
var
|
|
1040
|
+
var import_react_core5 = require("@copilotkit/react-core");
|
|
1043
1041
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1044
1042
|
var Messages = ({
|
|
1045
1043
|
inProgress,
|
|
@@ -1054,7 +1052,7 @@ var Messages = ({
|
|
|
1054
1052
|
markdownTagRenderers
|
|
1055
1053
|
}) => {
|
|
1056
1054
|
const { labels } = useChatContext();
|
|
1057
|
-
const { visibleMessages, interrupt } = (0,
|
|
1055
|
+
const { visibleMessages, interrupt } = (0, import_react_core5.useCopilotChatInternal)();
|
|
1058
1056
|
const initialMessages = (0, import_react6.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
|
|
1059
1057
|
const messages = [...initialMessages, ...visibleMessages];
|
|
1060
1058
|
const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
|
|
@@ -1227,7 +1225,7 @@ var AutoResizingTextarea = (0, import_react7.forwardRef)(
|
|
|
1227
1225
|
var Textarea_default = AutoResizingTextarea;
|
|
1228
1226
|
|
|
1229
1227
|
// src/hooks/use-push-to-talk.tsx
|
|
1230
|
-
var
|
|
1228
|
+
var import_react_core6 = require("@copilotkit/react-core");
|
|
1231
1229
|
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
1232
1230
|
var import_react8 = require("react");
|
|
1233
1231
|
var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
|
|
@@ -1283,8 +1281,8 @@ var usePushToTalk = ({
|
|
|
1283
1281
|
const audioContextRef = (0, import_react8.useRef)(null);
|
|
1284
1282
|
const mediaRecorderRef = (0, import_react8.useRef)(null);
|
|
1285
1283
|
const recordedChunks = (0, import_react8.useRef)([]);
|
|
1286
|
-
const generalContext = (0,
|
|
1287
|
-
const messagesContext = (0,
|
|
1284
|
+
const generalContext = (0, import_react_core6.useCopilotContext)();
|
|
1285
|
+
const messagesContext = (0, import_react_core6.useCopilotMessagesContext)();
|
|
1288
1286
|
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
1289
1287
|
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react8.useState)(null);
|
|
1290
1288
|
(0, import_react8.useEffect)(() => {
|
|
@@ -1331,7 +1329,7 @@ var usePushToTalk = ({
|
|
|
1331
1329
|
};
|
|
1332
1330
|
|
|
1333
1331
|
// src/components/chat/Input.tsx
|
|
1334
|
-
var
|
|
1332
|
+
var import_react_core7 = require("@copilotkit/react-core");
|
|
1335
1333
|
|
|
1336
1334
|
// src/hooks/use-dark-mode.ts
|
|
1337
1335
|
var useDarkMode = () => {
|
|
@@ -1372,7 +1370,7 @@ var Input = ({
|
|
|
1372
1370
|
}) => {
|
|
1373
1371
|
var _a, _b;
|
|
1374
1372
|
const context = useChatContext();
|
|
1375
|
-
const copilotContext = (0,
|
|
1373
|
+
const copilotContext = (0, import_react_core7.useCopilotContext)();
|
|
1376
1374
|
const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
|
|
1377
1375
|
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
1378
1376
|
const textareaRef = (0, import_react9.useRef)(null);
|
|
@@ -2179,9 +2177,10 @@ function RenderMessage(_a) {
|
|
|
2179
2177
|
|
|
2180
2178
|
// src/components/chat/Chat.tsx
|
|
2181
2179
|
var import_react14 = __toESM(require("react"));
|
|
2182
|
-
var import_react_core8 = require("@copilotkit/react-core");
|
|
2183
|
-
var import_shared3 = require("@copilotkit/shared");
|
|
2184
2180
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2181
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
2182
|
+
var import_shared4 = require("@copilotkit/shared");
|
|
2183
|
+
var import_react_core10 = require("@copilotkit/react-core");
|
|
2185
2184
|
|
|
2186
2185
|
// src/components/chat/ImageUploadQueue.tsx
|
|
2187
2186
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
@@ -2262,12 +2261,12 @@ var ImageUploadQueue = ({
|
|
|
2262
2261
|
};
|
|
2263
2262
|
|
|
2264
2263
|
// src/components/chat/Suggestion.tsx
|
|
2265
|
-
var
|
|
2264
|
+
var import_react_core8 = require("@copilotkit/react-core");
|
|
2266
2265
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2267
2266
|
function Suggestion({ title, onClick, partial, className }) {
|
|
2268
2267
|
if (!title)
|
|
2269
2268
|
return null;
|
|
2270
|
-
const { isLoading } = (0,
|
|
2269
|
+
const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
|
|
2271
2270
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2272
2271
|
"button",
|
|
2273
2272
|
{
|
|
@@ -2326,11 +2325,31 @@ function CopilotChat({
|
|
|
2326
2325
|
ImageRenderer: ImageRenderer2 = ImageRenderer,
|
|
2327
2326
|
imageUploadsEnabled,
|
|
2328
2327
|
inputFileAccept = "image/*",
|
|
2329
|
-
hideStopButton
|
|
2328
|
+
hideStopButton,
|
|
2329
|
+
observabilityHooks
|
|
2330
2330
|
}) {
|
|
2331
|
-
const { additionalInstructions, setChatInstructions } = (0,
|
|
2331
|
+
const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
|
|
2332
2332
|
const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
|
|
2333
2333
|
const fileInputRef = (0, import_react14.useRef)(null);
|
|
2334
|
+
const triggerObservabilityHook = (0, import_react14.useCallback)(
|
|
2335
|
+
(hookName, ...args) => {
|
|
2336
|
+
if (copilotApiConfig.publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2337
|
+
observabilityHooks[hookName](...args);
|
|
2338
|
+
}
|
|
2339
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !copilotApiConfig.publicApiKey) {
|
|
2340
|
+
setBannerError(
|
|
2341
|
+
new import_shared3.CopilotKitError({
|
|
2342
|
+
message: "observabilityHooks requires a publicApiKey to function.",
|
|
2343
|
+
code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2344
|
+
severity: import_shared3.Severity.CRITICAL,
|
|
2345
|
+
visibility: import_shared3.ErrorVisibility.BANNER
|
|
2346
|
+
})
|
|
2347
|
+
);
|
|
2348
|
+
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2349
|
+
}
|
|
2350
|
+
},
|
|
2351
|
+
[copilotApiConfig.publicApiKey, observabilityHooks]
|
|
2352
|
+
);
|
|
2334
2353
|
(0, import_react14.useEffect)(() => {
|
|
2335
2354
|
if (!imageUploadsEnabled)
|
|
2336
2355
|
return;
|
|
@@ -2403,12 +2422,24 @@ function CopilotChat({
|
|
|
2403
2422
|
onStopGeneration,
|
|
2404
2423
|
onReloadMessages
|
|
2405
2424
|
);
|
|
2425
|
+
const prevIsLoading = (0, import_react14.useRef)(isLoading);
|
|
2426
|
+
(0, import_react14.useEffect)(() => {
|
|
2427
|
+
if (prevIsLoading.current !== isLoading) {
|
|
2428
|
+
if (isLoading) {
|
|
2429
|
+
triggerObservabilityHook("onChatStarted");
|
|
2430
|
+
} else {
|
|
2431
|
+
triggerObservabilityHook("onChatStopped");
|
|
2432
|
+
}
|
|
2433
|
+
prevIsLoading.current = isLoading;
|
|
2434
|
+
}
|
|
2435
|
+
}, [isLoading, triggerObservabilityHook]);
|
|
2406
2436
|
const handleSendMessage = (text) => {
|
|
2407
2437
|
const images = selectedImages;
|
|
2408
2438
|
setSelectedImages([]);
|
|
2409
2439
|
if (fileInputRef.current) {
|
|
2410
2440
|
fileInputRef.current.value = "";
|
|
2411
2441
|
}
|
|
2442
|
+
triggerObservabilityHook("onMessageSent", text);
|
|
2412
2443
|
return sendMessage(text, images);
|
|
2413
2444
|
};
|
|
2414
2445
|
const chatContext = import_react14.default.useContext(ChatContext);
|
|
@@ -2417,12 +2448,14 @@ function CopilotChat({
|
|
|
2417
2448
|
if (onRegenerate) {
|
|
2418
2449
|
onRegenerate(messageId);
|
|
2419
2450
|
}
|
|
2451
|
+
triggerObservabilityHook("onMessageRegenerated", messageId);
|
|
2420
2452
|
reloadMessages(messageId);
|
|
2421
2453
|
};
|
|
2422
2454
|
const handleCopy = (message) => {
|
|
2423
2455
|
if (onCopy) {
|
|
2424
2456
|
onCopy(message);
|
|
2425
2457
|
}
|
|
2458
|
+
triggerObservabilityHook("onMessageCopied", message);
|
|
2426
2459
|
};
|
|
2427
2460
|
const handleImageUpload = (event) => __async(this, null, function* () {
|
|
2428
2461
|
if (!event.target.files || event.target.files.length === 0) {
|
|
@@ -2458,6 +2491,18 @@ function CopilotChat({
|
|
|
2458
2491
|
const removeSelectedImage = (index) => {
|
|
2459
2492
|
setSelectedImages((prev) => prev.filter((_, i) => i !== index));
|
|
2460
2493
|
};
|
|
2494
|
+
const handleThumbsUp = (message) => {
|
|
2495
|
+
if (onThumbsUp) {
|
|
2496
|
+
onThumbsUp(message);
|
|
2497
|
+
}
|
|
2498
|
+
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsUp");
|
|
2499
|
+
};
|
|
2500
|
+
const handleThumbsDown = (message) => {
|
|
2501
|
+
if (onThumbsDown) {
|
|
2502
|
+
onThumbsDown(message);
|
|
2503
|
+
}
|
|
2504
|
+
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2505
|
+
};
|
|
2461
2506
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2462
2507
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2463
2508
|
Messages2,
|
|
@@ -2469,8 +2514,8 @@ function CopilotChat({
|
|
|
2469
2514
|
inProgress: isLoading,
|
|
2470
2515
|
onRegenerate: handleRegenerate,
|
|
2471
2516
|
onCopy: handleCopy,
|
|
2472
|
-
onThumbsUp,
|
|
2473
|
-
onThumbsDown,
|
|
2517
|
+
onThumbsUp: handleThumbsUp,
|
|
2518
|
+
onThumbsDown: handleThumbsDown,
|
|
2474
2519
|
markdownTagRenderers,
|
|
2475
2520
|
ImageRenderer: ImageRenderer2,
|
|
2476
2521
|
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
@@ -2540,11 +2585,11 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2540
2585
|
generateSuggestions,
|
|
2541
2586
|
resetSuggestions: resetSuggestionsFromHook,
|
|
2542
2587
|
isLoadingSuggestions
|
|
2543
|
-
} = (0,
|
|
2588
|
+
} = (0, import_react_core9.useCopilotChatInternal)({
|
|
2544
2589
|
makeSystemMessage
|
|
2545
2590
|
});
|
|
2546
|
-
const generalContext = (0,
|
|
2547
|
-
const messagesContext = (0,
|
|
2591
|
+
const generalContext = (0, import_react_core9.useCopilotContext)();
|
|
2592
|
+
const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
|
|
2548
2593
|
const { actions } = generalContext;
|
|
2549
2594
|
const [suggestionsFailed, setSuggestionsFailed] = (0, import_react14.useState)(false);
|
|
2550
2595
|
const hasGeneratedInitialSuggestions = (0, import_react14.useRef)(false);
|
|
@@ -2626,7 +2671,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2626
2671
|
let firstMessage = null;
|
|
2627
2672
|
if (messageContent.trim().length > 0) {
|
|
2628
2673
|
const textMessage = {
|
|
2629
|
-
id: (0,
|
|
2674
|
+
id: (0, import_shared4.randomId)(),
|
|
2630
2675
|
role: "user",
|
|
2631
2676
|
content: messageContent
|
|
2632
2677
|
};
|
|
@@ -2648,7 +2693,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2648
2693
|
if (images.length > 0) {
|
|
2649
2694
|
for (let i = 0; i < images.length; i++) {
|
|
2650
2695
|
const imageMessage = {
|
|
2651
|
-
id: (0,
|
|
2696
|
+
id: (0, import_shared4.randomId)(),
|
|
2652
2697
|
role: "user",
|
|
2653
2698
|
image: {
|
|
2654
2699
|
format: images[i].contentType.replace("image/", ""),
|
|
@@ -2662,7 +2707,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2662
2707
|
}
|
|
2663
2708
|
}
|
|
2664
2709
|
if (!firstMessage) {
|
|
2665
|
-
return { role: "user", content: "", id: (0,
|
|
2710
|
+
return { role: "user", content: "", id: (0, import_shared4.randomId)() };
|
|
2666
2711
|
}
|
|
2667
2712
|
return firstMessage;
|
|
2668
2713
|
});
|
|
@@ -2687,7 +2732,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2687
2732
|
});
|
|
2688
2733
|
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2689
2734
|
if (generalContext.agentSession) {
|
|
2690
|
-
yield (0,
|
|
2735
|
+
yield (0, import_react_core10.runAgent)(
|
|
2691
2736
|
generalContext.agentSession.agentName,
|
|
2692
2737
|
stableContext,
|
|
2693
2738
|
appendMessage,
|
|
@@ -2698,7 +2743,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2698
2743
|
});
|
|
2699
2744
|
const stopCurrentAgent = () => {
|
|
2700
2745
|
if (generalContext.agentSession) {
|
|
2701
|
-
(0,
|
|
2746
|
+
(0, import_react_core10.stopAgent)(generalContext.agentSession.agentName, stableContext);
|
|
2702
2747
|
}
|
|
2703
2748
|
};
|
|
2704
2749
|
const setCurrentAgentState = (state) => {
|
|
@@ -2761,7 +2806,75 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2761
2806
|
};
|
|
2762
2807
|
|
|
2763
2808
|
// src/components/chat/Modal.tsx
|
|
2809
|
+
var import_react_core11 = require("@copilotkit/react-core");
|
|
2764
2810
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2811
|
+
var CopilotModalInner = (_a) => {
|
|
2812
|
+
var _b = _a, {
|
|
2813
|
+
observabilityHooks,
|
|
2814
|
+
onSetOpen,
|
|
2815
|
+
clickOutsideToClose,
|
|
2816
|
+
hitEscapeToClose,
|
|
2817
|
+
shortcut,
|
|
2818
|
+
className,
|
|
2819
|
+
children,
|
|
2820
|
+
Window: Window2,
|
|
2821
|
+
Button: Button2,
|
|
2822
|
+
Header: Header2
|
|
2823
|
+
} = _b, chatProps = __objRest(_b, [
|
|
2824
|
+
"observabilityHooks",
|
|
2825
|
+
"onSetOpen",
|
|
2826
|
+
"clickOutsideToClose",
|
|
2827
|
+
"hitEscapeToClose",
|
|
2828
|
+
"shortcut",
|
|
2829
|
+
"className",
|
|
2830
|
+
"children",
|
|
2831
|
+
"Window",
|
|
2832
|
+
"Button",
|
|
2833
|
+
"Header"
|
|
2834
|
+
]);
|
|
2835
|
+
const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
|
|
2836
|
+
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2837
|
+
(hookName, ...args) => {
|
|
2838
|
+
if (copilotApiConfig.publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2839
|
+
observabilityHooks[hookName](...args);
|
|
2840
|
+
}
|
|
2841
|
+
},
|
|
2842
|
+
[copilotApiConfig.publicApiKey, observabilityHooks]
|
|
2843
|
+
);
|
|
2844
|
+
const { open } = useChatContext();
|
|
2845
|
+
const prevOpen = (0, import_react15.useRef)(open);
|
|
2846
|
+
(0, import_react15.useEffect)(() => {
|
|
2847
|
+
if (prevOpen.current !== open) {
|
|
2848
|
+
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
2849
|
+
if (open) {
|
|
2850
|
+
triggerObservabilityHook("onChatExpanded");
|
|
2851
|
+
} else {
|
|
2852
|
+
triggerObservabilityHook("onChatMinimized");
|
|
2853
|
+
}
|
|
2854
|
+
prevOpen.current = open;
|
|
2855
|
+
}
|
|
2856
|
+
}, [open, onSetOpen, triggerObservabilityHook]);
|
|
2857
|
+
const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Header2, {}), [Header2]);
|
|
2858
|
+
const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
|
|
2859
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
2860
|
+
memoizedChildren,
|
|
2861
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className, children: [
|
|
2862
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Button2, {}),
|
|
2863
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2864
|
+
Window2,
|
|
2865
|
+
{
|
|
2866
|
+
clickOutsideToClose,
|
|
2867
|
+
shortcut,
|
|
2868
|
+
hitEscapeToClose,
|
|
2869
|
+
children: [
|
|
2870
|
+
memoizedHeader,
|
|
2871
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
|
|
2872
|
+
]
|
|
2873
|
+
}
|
|
2874
|
+
)
|
|
2875
|
+
] })
|
|
2876
|
+
] });
|
|
2877
|
+
};
|
|
2765
2878
|
var CopilotModal = (_a) => {
|
|
2766
2879
|
var _b = _a, {
|
|
2767
2880
|
instructions,
|
|
@@ -2790,7 +2903,8 @@ var CopilotModal = (_a) => {
|
|
|
2790
2903
|
onRegenerate,
|
|
2791
2904
|
markdownTagRenderers,
|
|
2792
2905
|
className,
|
|
2793
|
-
children
|
|
2906
|
+
children,
|
|
2907
|
+
observabilityHooks
|
|
2794
2908
|
} = _b, props = __objRest(_b, [
|
|
2795
2909
|
"instructions",
|
|
2796
2910
|
"defaultOpen",
|
|
@@ -2818,52 +2932,41 @@ var CopilotModal = (_a) => {
|
|
|
2818
2932
|
"onRegenerate",
|
|
2819
2933
|
"markdownTagRenderers",
|
|
2820
2934
|
"className",
|
|
2821
|
-
"children"
|
|
2935
|
+
"children",
|
|
2936
|
+
"observabilityHooks"
|
|
2822
2937
|
]);
|
|
2823
2938
|
const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
onThumbsUp,
|
|
2856
|
-
onThumbsDown,
|
|
2857
|
-
onCopy,
|
|
2858
|
-
onRegenerate,
|
|
2859
|
-
markdownTagRenderers
|
|
2860
|
-
})
|
|
2861
|
-
)
|
|
2862
|
-
]
|
|
2863
|
-
}
|
|
2864
|
-
)
|
|
2865
|
-
] })
|
|
2866
|
-
] });
|
|
2939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2940
|
+
CopilotModalInner,
|
|
2941
|
+
__spreadProps(__spreadValues({
|
|
2942
|
+
observabilityHooks,
|
|
2943
|
+
onSetOpen,
|
|
2944
|
+
clickOutsideToClose: clickOutsideToClose != null ? clickOutsideToClose : true,
|
|
2945
|
+
hitEscapeToClose: hitEscapeToClose != null ? hitEscapeToClose : true,
|
|
2946
|
+
shortcut: shortcut != null ? shortcut : "/",
|
|
2947
|
+
className,
|
|
2948
|
+
Window: Window2,
|
|
2949
|
+
Button: Button2,
|
|
2950
|
+
Header: Header2,
|
|
2951
|
+
instructions,
|
|
2952
|
+
onSubmitMessage,
|
|
2953
|
+
onStopGeneration,
|
|
2954
|
+
onReloadMessages,
|
|
2955
|
+
makeSystemMessage,
|
|
2956
|
+
onInProgress,
|
|
2957
|
+
Messages: Messages2,
|
|
2958
|
+
Input: Input2,
|
|
2959
|
+
AssistantMessage: AssistantMessage2,
|
|
2960
|
+
UserMessage: UserMessage2,
|
|
2961
|
+
onThumbsUp,
|
|
2962
|
+
onThumbsDown,
|
|
2963
|
+
onCopy,
|
|
2964
|
+
onRegenerate,
|
|
2965
|
+
markdownTagRenderers
|
|
2966
|
+
}, props), {
|
|
2967
|
+
children
|
|
2968
|
+
})
|
|
2969
|
+
) });
|
|
2867
2970
|
};
|
|
2868
2971
|
|
|
2869
2972
|
// src/components/chat/Popup.tsx
|