@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
|
@@ -2,29 +2,29 @@ import "../chunk-MMVDU6DF.mjs";
|
|
|
2
2
|
import "../chunk-SC6JRFAJ.mjs";
|
|
3
3
|
import {
|
|
4
4
|
CopilotSidebar
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-MYWIJSW6.mjs";
|
|
6
6
|
import "../chunk-WB3YULQ4.mjs";
|
|
7
7
|
import {
|
|
8
8
|
CopilotPopup
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-BXX6RM44.mjs";
|
|
10
|
+
import "../chunk-BY42E5VF.mjs";
|
|
11
11
|
import "../chunk-C3GSYRC3.mjs";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-GDSZGYCE.mjs";
|
|
13
13
|
import "../chunk-V7W6IM2V.mjs";
|
|
14
14
|
import {
|
|
15
15
|
CopilotDevConsole
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-FFJHOZX6.mjs";
|
|
17
17
|
import "../chunk-Q5V6S67N.mjs";
|
|
18
18
|
import {
|
|
19
19
|
shouldShowDevConsole
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-JY2CSDKN.mjs";
|
|
21
21
|
import "../chunk-KXE2JCUH.mjs";
|
|
22
22
|
import "../chunk-NRA3CFEE.mjs";
|
|
23
23
|
import "../chunk-BH6PCAAL.mjs";
|
|
24
24
|
import "../chunk-UFN2VWSR.mjs";
|
|
25
25
|
import {
|
|
26
26
|
CopilotChat
|
|
27
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-K344MVUT.mjs";
|
|
28
28
|
import "../chunk-JHUTTP5C.mjs";
|
|
29
29
|
import {
|
|
30
30
|
AssistantMessage
|
|
@@ -37,10 +37,10 @@ import {
|
|
|
37
37
|
} from "../chunk-VVL6JFCJ.mjs";
|
|
38
38
|
import {
|
|
39
39
|
Suggestions
|
|
40
|
-
} from "../chunk-
|
|
40
|
+
} from "../chunk-226ZMOE3.mjs";
|
|
41
41
|
import {
|
|
42
42
|
Suggestion
|
|
43
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-W26XFBEG.mjs";
|
|
44
44
|
import "../chunk-PLHTVHUW.mjs";
|
|
45
45
|
import "../chunk-DTRPPNSA.mjs";
|
|
46
46
|
import "../chunk-CGEAG65D.mjs";
|
|
@@ -48,7 +48,7 @@ import "../chunk-QIOJXTIQ.mjs";
|
|
|
48
48
|
import {
|
|
49
49
|
Markdown
|
|
50
50
|
} from "../chunk-E6MQUIZW.mjs";
|
|
51
|
-
import "../chunk-
|
|
51
|
+
import "../chunk-U5ATIGWH.mjs";
|
|
52
52
|
import {
|
|
53
53
|
useChatContext
|
|
54
54
|
} from "../chunk-IEMQ2SQW.mjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AssistantMessageProps, ButtonProps, ComponentsMap, HeaderProps, ImageRendererProps, InputProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './components/chat/props.js';
|
|
1
|
+
export { AssistantMessageProps, ButtonProps, ComponentsMap, CopilotObservabilityHooks, HeaderProps, ImageRendererProps, InputProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, Renderer, SuggestionsProps, UserMessageProps, WindowProps } from './components/chat/props.js';
|
|
2
2
|
export { CopilotPopup } from './components/chat/Popup.js';
|
|
3
3
|
export { CopilotSidebar } from './components/chat/Sidebar.js';
|
|
4
4
|
export { CopilotChat } from './components/chat/Chat.js';
|
|
@@ -9,7 +9,7 @@ export { ImageRenderer } from './components/chat/messages/ImageRenderer.js';
|
|
|
9
9
|
export { useChatContext } from './components/chat/ChatContext.js';
|
|
10
10
|
export { Suggestions as RenderSuggestionsList } from './components/chat/Suggestions.js';
|
|
11
11
|
export { Suggestion as RenderSuggestion } from './components/chat/Suggestion.js';
|
|
12
|
-
export { shouldShowDevConsole } from '
|
|
12
|
+
export { shouldShowDevConsole } from '@copilotkit/react-core';
|
|
13
13
|
export { CopilotDevConsole } from './components/dev-console/console.js';
|
|
14
14
|
export { useCopilotChatSuggestions } from './hooks/use-copilot-chat-suggestions.js';
|
|
15
15
|
export { CopilotKitCSSProperties } from './types/css.js';
|
|
@@ -20,9 +20,7 @@ import 'react/jsx-runtime';
|
|
|
20
20
|
import './components/chat/Modal.js';
|
|
21
21
|
import '@copilotkit/react-core/dist/types/coagent-state';
|
|
22
22
|
import '@copilotkit/react-core/dist/hooks/use-tree';
|
|
23
|
-
import '@copilotkit/react-core/dist/copilot-context-
|
|
23
|
+
import '@copilotkit/react-core/dist/copilot-context-78fc727c';
|
|
24
24
|
import '@copilotkit/react-core/dist/types/coagent-action';
|
|
25
|
-
import '@copilotkit/react-core';
|
|
26
25
|
import '@copilotkit/runtime-client-gql';
|
|
27
26
|
import 'react-markdown';
|
|
28
|
-
import './components/dev-console/types.js';
|
package/dist/index.js
CHANGED
|
@@ -90,7 +90,7 @@ __export(src_exports, {
|
|
|
90
90
|
RenderSuggestion: () => Suggestion,
|
|
91
91
|
RenderSuggestionsList: () => Suggestions,
|
|
92
92
|
UserMessage: () => UserMessage,
|
|
93
|
-
shouldShowDevConsole: () => shouldShowDevConsole,
|
|
93
|
+
shouldShowDevConsole: () => import_react_core3.shouldShowDevConsole,
|
|
94
94
|
useChatContext: () => useChatContext,
|
|
95
95
|
useCopilotChatSuggestions: () => useCopilotChatSuggestions
|
|
96
96
|
});
|
|
@@ -537,9 +537,7 @@ var Button = ({}) => {
|
|
|
537
537
|
|
|
538
538
|
// src/components/dev-console/utils.ts
|
|
539
539
|
var import_react_core2 = require("@copilotkit/react-core");
|
|
540
|
-
|
|
541
|
-
return showDevConsole;
|
|
542
|
-
}
|
|
540
|
+
var import_react_core3 = require("@copilotkit/react-core");
|
|
543
541
|
function getPublishedCopilotKitVersion(current, forceCheck = false) {
|
|
544
542
|
return __async(this, null, function* () {
|
|
545
543
|
const LOCAL_STORAGE_KEY = "__copilotkit_version_check__";
|
|
@@ -659,7 +657,7 @@ function logMessages(context) {
|
|
|
659
657
|
}
|
|
660
658
|
|
|
661
659
|
// src/components/dev-console/console.tsx
|
|
662
|
-
var
|
|
660
|
+
var import_react_core4 = require("@copilotkit/react-core");
|
|
663
661
|
var import_react4 = require("react");
|
|
664
662
|
|
|
665
663
|
// src/components/dev-console/icons.tsx
|
|
@@ -849,10 +847,10 @@ function CopilotKitHelpModal() {
|
|
|
849
847
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
850
848
|
function CopilotDevConsole() {
|
|
851
849
|
const currentVersion = import_shared2.COPILOTKIT_VERSION;
|
|
852
|
-
const context = (0,
|
|
850
|
+
const context = (0, import_react_core4.useCopilotContext)();
|
|
853
851
|
const [showDevConsole, setShowDevConsole] = (0, import_react4.useState)(false);
|
|
854
852
|
(0, import_react4.useEffect)(() => {
|
|
855
|
-
setShowDevConsole(shouldShowDevConsole(context.showDevConsole));
|
|
853
|
+
setShowDevConsole((0, import_react_core3.shouldShowDevConsole)(context.showDevConsole));
|
|
856
854
|
}, [context.showDevConsole]);
|
|
857
855
|
const dontRunTwiceInDevMode = (0, import_react4.useRef)(false);
|
|
858
856
|
const [versionStatus, setVersionStatus] = (0, import_react4.useState)("unknown");
|
|
@@ -978,8 +976,8 @@ function DebugMenuButton({
|
|
|
978
976
|
checkForUpdates,
|
|
979
977
|
mode
|
|
980
978
|
}) {
|
|
981
|
-
const context = (0,
|
|
982
|
-
const messagesContext = (0,
|
|
979
|
+
const context = (0, import_react_core4.useCopilotContext)();
|
|
980
|
+
const messagesContext = (0, import_react_core4.useCopilotMessagesContext)();
|
|
983
981
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react5.Menu, { children: [
|
|
984
982
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
985
983
|
import_react5.MenuButton,
|
|
@@ -1041,7 +1039,7 @@ var Header = ({}) => {
|
|
|
1041
1039
|
|
|
1042
1040
|
// src/components/chat/Messages.tsx
|
|
1043
1041
|
var import_react6 = require("react");
|
|
1044
|
-
var
|
|
1042
|
+
var import_react_core5 = require("@copilotkit/react-core");
|
|
1045
1043
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1046
1044
|
var Messages = ({
|
|
1047
1045
|
inProgress,
|
|
@@ -1056,7 +1054,7 @@ var Messages = ({
|
|
|
1056
1054
|
markdownTagRenderers
|
|
1057
1055
|
}) => {
|
|
1058
1056
|
const { labels } = useChatContext();
|
|
1059
|
-
const { visibleMessages, interrupt } = (0,
|
|
1057
|
+
const { visibleMessages, interrupt } = (0, import_react_core5.useCopilotChatInternal)();
|
|
1060
1058
|
const initialMessages = (0, import_react6.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
|
|
1061
1059
|
const messages = [...initialMessages, ...visibleMessages];
|
|
1062
1060
|
const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
|
|
@@ -1229,7 +1227,7 @@ var AutoResizingTextarea = (0, import_react7.forwardRef)(
|
|
|
1229
1227
|
var Textarea_default = AutoResizingTextarea;
|
|
1230
1228
|
|
|
1231
1229
|
// src/hooks/use-push-to-talk.tsx
|
|
1232
|
-
var
|
|
1230
|
+
var import_react_core6 = require("@copilotkit/react-core");
|
|
1233
1231
|
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
1234
1232
|
var import_react8 = require("react");
|
|
1235
1233
|
var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
|
|
@@ -1285,8 +1283,8 @@ var usePushToTalk = ({
|
|
|
1285
1283
|
const audioContextRef = (0, import_react8.useRef)(null);
|
|
1286
1284
|
const mediaRecorderRef = (0, import_react8.useRef)(null);
|
|
1287
1285
|
const recordedChunks = (0, import_react8.useRef)([]);
|
|
1288
|
-
const generalContext = (0,
|
|
1289
|
-
const messagesContext = (0,
|
|
1286
|
+
const generalContext = (0, import_react_core6.useCopilotContext)();
|
|
1287
|
+
const messagesContext = (0, import_react_core6.useCopilotMessagesContext)();
|
|
1290
1288
|
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
1291
1289
|
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react8.useState)(null);
|
|
1292
1290
|
(0, import_react8.useEffect)(() => {
|
|
@@ -1333,7 +1331,7 @@ var usePushToTalk = ({
|
|
|
1333
1331
|
};
|
|
1334
1332
|
|
|
1335
1333
|
// src/components/chat/Input.tsx
|
|
1336
|
-
var
|
|
1334
|
+
var import_react_core7 = require("@copilotkit/react-core");
|
|
1337
1335
|
|
|
1338
1336
|
// src/hooks/use-dark-mode.ts
|
|
1339
1337
|
var useDarkMode = () => {
|
|
@@ -1374,7 +1372,7 @@ var Input = ({
|
|
|
1374
1372
|
}) => {
|
|
1375
1373
|
var _a, _b;
|
|
1376
1374
|
const context = useChatContext();
|
|
1377
|
-
const copilotContext = (0,
|
|
1375
|
+
const copilotContext = (0, import_react_core7.useCopilotContext)();
|
|
1378
1376
|
const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
|
|
1379
1377
|
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
1380
1378
|
const textareaRef = (0, import_react9.useRef)(null);
|
|
@@ -2181,9 +2179,10 @@ function RenderMessage(_a) {
|
|
|
2181
2179
|
|
|
2182
2180
|
// src/components/chat/Chat.tsx
|
|
2183
2181
|
var import_react14 = __toESM(require("react"));
|
|
2184
|
-
var import_react_core8 = require("@copilotkit/react-core");
|
|
2185
|
-
var import_shared3 = require("@copilotkit/shared");
|
|
2186
2182
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2183
|
+
var import_shared3 = require("@copilotkit/shared");
|
|
2184
|
+
var import_shared4 = require("@copilotkit/shared");
|
|
2185
|
+
var import_react_core10 = require("@copilotkit/react-core");
|
|
2187
2186
|
|
|
2188
2187
|
// src/components/chat/ImageUploadQueue.tsx
|
|
2189
2188
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
@@ -2264,12 +2263,12 @@ var ImageUploadQueue = ({
|
|
|
2264
2263
|
};
|
|
2265
2264
|
|
|
2266
2265
|
// src/components/chat/Suggestion.tsx
|
|
2267
|
-
var
|
|
2266
|
+
var import_react_core8 = require("@copilotkit/react-core");
|
|
2268
2267
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2269
2268
|
function Suggestion({ title, onClick, partial, className }) {
|
|
2270
2269
|
if (!title)
|
|
2271
2270
|
return null;
|
|
2272
|
-
const { isLoading } = (0,
|
|
2271
|
+
const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
|
|
2273
2272
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2274
2273
|
"button",
|
|
2275
2274
|
{
|
|
@@ -2328,11 +2327,31 @@ function CopilotChat({
|
|
|
2328
2327
|
ImageRenderer: ImageRenderer2 = ImageRenderer,
|
|
2329
2328
|
imageUploadsEnabled,
|
|
2330
2329
|
inputFileAccept = "image/*",
|
|
2331
|
-
hideStopButton
|
|
2330
|
+
hideStopButton,
|
|
2331
|
+
observabilityHooks
|
|
2332
2332
|
}) {
|
|
2333
|
-
const { additionalInstructions, setChatInstructions } = (0,
|
|
2333
|
+
const { additionalInstructions, setChatInstructions, copilotApiConfig, setBannerError } = (0, import_react_core9.useCopilotContext)();
|
|
2334
2334
|
const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
|
|
2335
2335
|
const fileInputRef = (0, import_react14.useRef)(null);
|
|
2336
|
+
const triggerObservabilityHook = (0, import_react14.useCallback)(
|
|
2337
|
+
(hookName, ...args) => {
|
|
2338
|
+
if (copilotApiConfig.publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2339
|
+
observabilityHooks[hookName](...args);
|
|
2340
|
+
}
|
|
2341
|
+
if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !copilotApiConfig.publicApiKey) {
|
|
2342
|
+
setBannerError(
|
|
2343
|
+
new import_shared3.CopilotKitError({
|
|
2344
|
+
message: "observabilityHooks requires a publicApiKey to function.",
|
|
2345
|
+
code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
2346
|
+
severity: import_shared3.Severity.CRITICAL,
|
|
2347
|
+
visibility: import_shared3.ErrorVisibility.BANNER
|
|
2348
|
+
})
|
|
2349
|
+
);
|
|
2350
|
+
import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks");
|
|
2351
|
+
}
|
|
2352
|
+
},
|
|
2353
|
+
[copilotApiConfig.publicApiKey, observabilityHooks]
|
|
2354
|
+
);
|
|
2336
2355
|
(0, import_react14.useEffect)(() => {
|
|
2337
2356
|
if (!imageUploadsEnabled)
|
|
2338
2357
|
return;
|
|
@@ -2405,12 +2424,24 @@ function CopilotChat({
|
|
|
2405
2424
|
onStopGeneration,
|
|
2406
2425
|
onReloadMessages
|
|
2407
2426
|
);
|
|
2427
|
+
const prevIsLoading = (0, import_react14.useRef)(isLoading);
|
|
2428
|
+
(0, import_react14.useEffect)(() => {
|
|
2429
|
+
if (prevIsLoading.current !== isLoading) {
|
|
2430
|
+
if (isLoading) {
|
|
2431
|
+
triggerObservabilityHook("onChatStarted");
|
|
2432
|
+
} else {
|
|
2433
|
+
triggerObservabilityHook("onChatStopped");
|
|
2434
|
+
}
|
|
2435
|
+
prevIsLoading.current = isLoading;
|
|
2436
|
+
}
|
|
2437
|
+
}, [isLoading, triggerObservabilityHook]);
|
|
2408
2438
|
const handleSendMessage = (text) => {
|
|
2409
2439
|
const images = selectedImages;
|
|
2410
2440
|
setSelectedImages([]);
|
|
2411
2441
|
if (fileInputRef.current) {
|
|
2412
2442
|
fileInputRef.current.value = "";
|
|
2413
2443
|
}
|
|
2444
|
+
triggerObservabilityHook("onMessageSent", text);
|
|
2414
2445
|
return sendMessage(text, images);
|
|
2415
2446
|
};
|
|
2416
2447
|
const chatContext = import_react14.default.useContext(ChatContext);
|
|
@@ -2419,12 +2450,14 @@ function CopilotChat({
|
|
|
2419
2450
|
if (onRegenerate) {
|
|
2420
2451
|
onRegenerate(messageId);
|
|
2421
2452
|
}
|
|
2453
|
+
triggerObservabilityHook("onMessageRegenerated", messageId);
|
|
2422
2454
|
reloadMessages(messageId);
|
|
2423
2455
|
};
|
|
2424
2456
|
const handleCopy = (message) => {
|
|
2425
2457
|
if (onCopy) {
|
|
2426
2458
|
onCopy(message);
|
|
2427
2459
|
}
|
|
2460
|
+
triggerObservabilityHook("onMessageCopied", message);
|
|
2428
2461
|
};
|
|
2429
2462
|
const handleImageUpload = (event) => __async(this, null, function* () {
|
|
2430
2463
|
if (!event.target.files || event.target.files.length === 0) {
|
|
@@ -2460,6 +2493,18 @@ function CopilotChat({
|
|
|
2460
2493
|
const removeSelectedImage = (index) => {
|
|
2461
2494
|
setSelectedImages((prev) => prev.filter((_, i) => i !== index));
|
|
2462
2495
|
};
|
|
2496
|
+
const handleThumbsUp = (message) => {
|
|
2497
|
+
if (onThumbsUp) {
|
|
2498
|
+
onThumbsUp(message);
|
|
2499
|
+
}
|
|
2500
|
+
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsUp");
|
|
2501
|
+
};
|
|
2502
|
+
const handleThumbsDown = (message) => {
|
|
2503
|
+
if (onThumbsDown) {
|
|
2504
|
+
onThumbsDown(message);
|
|
2505
|
+
}
|
|
2506
|
+
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2507
|
+
};
|
|
2463
2508
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2464
2509
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2465
2510
|
Messages2,
|
|
@@ -2471,8 +2516,8 @@ function CopilotChat({
|
|
|
2471
2516
|
inProgress: isLoading,
|
|
2472
2517
|
onRegenerate: handleRegenerate,
|
|
2473
2518
|
onCopy: handleCopy,
|
|
2474
|
-
onThumbsUp,
|
|
2475
|
-
onThumbsDown,
|
|
2519
|
+
onThumbsUp: handleThumbsUp,
|
|
2520
|
+
onThumbsDown: handleThumbsDown,
|
|
2476
2521
|
markdownTagRenderers,
|
|
2477
2522
|
ImageRenderer: ImageRenderer2,
|
|
2478
2523
|
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
@@ -2542,11 +2587,11 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2542
2587
|
generateSuggestions,
|
|
2543
2588
|
resetSuggestions: resetSuggestionsFromHook,
|
|
2544
2589
|
isLoadingSuggestions
|
|
2545
|
-
} = (0,
|
|
2590
|
+
} = (0, import_react_core9.useCopilotChatInternal)({
|
|
2546
2591
|
makeSystemMessage
|
|
2547
2592
|
});
|
|
2548
|
-
const generalContext = (0,
|
|
2549
|
-
const messagesContext = (0,
|
|
2593
|
+
const generalContext = (0, import_react_core9.useCopilotContext)();
|
|
2594
|
+
const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
|
|
2550
2595
|
const { actions } = generalContext;
|
|
2551
2596
|
const [suggestionsFailed, setSuggestionsFailed] = (0, import_react14.useState)(false);
|
|
2552
2597
|
const hasGeneratedInitialSuggestions = (0, import_react14.useRef)(false);
|
|
@@ -2628,7 +2673,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2628
2673
|
let firstMessage = null;
|
|
2629
2674
|
if (messageContent.trim().length > 0) {
|
|
2630
2675
|
const textMessage = {
|
|
2631
|
-
id: (0,
|
|
2676
|
+
id: (0, import_shared4.randomId)(),
|
|
2632
2677
|
role: "user",
|
|
2633
2678
|
content: messageContent
|
|
2634
2679
|
};
|
|
@@ -2650,7 +2695,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2650
2695
|
if (images.length > 0) {
|
|
2651
2696
|
for (let i = 0; i < images.length; i++) {
|
|
2652
2697
|
const imageMessage = {
|
|
2653
|
-
id: (0,
|
|
2698
|
+
id: (0, import_shared4.randomId)(),
|
|
2654
2699
|
role: "user",
|
|
2655
2700
|
image: {
|
|
2656
2701
|
format: images[i].contentType.replace("image/", ""),
|
|
@@ -2664,7 +2709,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2664
2709
|
}
|
|
2665
2710
|
}
|
|
2666
2711
|
if (!firstMessage) {
|
|
2667
|
-
return { role: "user", content: "", id: (0,
|
|
2712
|
+
return { role: "user", content: "", id: (0, import_shared4.randomId)() };
|
|
2668
2713
|
}
|
|
2669
2714
|
return firstMessage;
|
|
2670
2715
|
});
|
|
@@ -2689,7 +2734,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2689
2734
|
});
|
|
2690
2735
|
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2691
2736
|
if (generalContext.agentSession) {
|
|
2692
|
-
yield (0,
|
|
2737
|
+
yield (0, import_react_core10.runAgent)(
|
|
2693
2738
|
generalContext.agentSession.agentName,
|
|
2694
2739
|
stableContext,
|
|
2695
2740
|
appendMessage,
|
|
@@ -2700,7 +2745,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2700
2745
|
});
|
|
2701
2746
|
const stopCurrentAgent = () => {
|
|
2702
2747
|
if (generalContext.agentSession) {
|
|
2703
|
-
(0,
|
|
2748
|
+
(0, import_react_core10.stopAgent)(generalContext.agentSession.agentName, stableContext);
|
|
2704
2749
|
}
|
|
2705
2750
|
};
|
|
2706
2751
|
const setCurrentAgentState = (state) => {
|
|
@@ -2763,7 +2808,75 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, onInProgress, onS
|
|
|
2763
2808
|
};
|
|
2764
2809
|
|
|
2765
2810
|
// src/components/chat/Modal.tsx
|
|
2811
|
+
var import_react_core11 = require("@copilotkit/react-core");
|
|
2766
2812
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2813
|
+
var CopilotModalInner = (_a) => {
|
|
2814
|
+
var _b = _a, {
|
|
2815
|
+
observabilityHooks,
|
|
2816
|
+
onSetOpen,
|
|
2817
|
+
clickOutsideToClose,
|
|
2818
|
+
hitEscapeToClose,
|
|
2819
|
+
shortcut,
|
|
2820
|
+
className,
|
|
2821
|
+
children,
|
|
2822
|
+
Window: Window2,
|
|
2823
|
+
Button: Button2,
|
|
2824
|
+
Header: Header2
|
|
2825
|
+
} = _b, chatProps = __objRest(_b, [
|
|
2826
|
+
"observabilityHooks",
|
|
2827
|
+
"onSetOpen",
|
|
2828
|
+
"clickOutsideToClose",
|
|
2829
|
+
"hitEscapeToClose",
|
|
2830
|
+
"shortcut",
|
|
2831
|
+
"className",
|
|
2832
|
+
"children",
|
|
2833
|
+
"Window",
|
|
2834
|
+
"Button",
|
|
2835
|
+
"Header"
|
|
2836
|
+
]);
|
|
2837
|
+
const { copilotApiConfig } = (0, import_react_core11.useCopilotContext)();
|
|
2838
|
+
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
2839
|
+
(hookName, ...args) => {
|
|
2840
|
+
if (copilotApiConfig.publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2841
|
+
observabilityHooks[hookName](...args);
|
|
2842
|
+
}
|
|
2843
|
+
},
|
|
2844
|
+
[copilotApiConfig.publicApiKey, observabilityHooks]
|
|
2845
|
+
);
|
|
2846
|
+
const { open } = useChatContext();
|
|
2847
|
+
const prevOpen = (0, import_react15.useRef)(open);
|
|
2848
|
+
(0, import_react15.useEffect)(() => {
|
|
2849
|
+
if (prevOpen.current !== open) {
|
|
2850
|
+
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
2851
|
+
if (open) {
|
|
2852
|
+
triggerObservabilityHook("onChatExpanded");
|
|
2853
|
+
} else {
|
|
2854
|
+
triggerObservabilityHook("onChatMinimized");
|
|
2855
|
+
}
|
|
2856
|
+
prevOpen.current = open;
|
|
2857
|
+
}
|
|
2858
|
+
}, [open, onSetOpen, triggerObservabilityHook]);
|
|
2859
|
+
const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Header2, {}), [Header2]);
|
|
2860
|
+
const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
|
|
2861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
2862
|
+
memoizedChildren,
|
|
2863
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className, children: [
|
|
2864
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Button2, {}),
|
|
2865
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2866
|
+
Window2,
|
|
2867
|
+
{
|
|
2868
|
+
clickOutsideToClose,
|
|
2869
|
+
shortcut,
|
|
2870
|
+
hitEscapeToClose,
|
|
2871
|
+
children: [
|
|
2872
|
+
memoizedHeader,
|
|
2873
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
|
|
2874
|
+
]
|
|
2875
|
+
}
|
|
2876
|
+
)
|
|
2877
|
+
] })
|
|
2878
|
+
] });
|
|
2879
|
+
};
|
|
2767
2880
|
var CopilotModal = (_a) => {
|
|
2768
2881
|
var _b = _a, {
|
|
2769
2882
|
instructions,
|
|
@@ -2792,7 +2905,8 @@ var CopilotModal = (_a) => {
|
|
|
2792
2905
|
onRegenerate,
|
|
2793
2906
|
markdownTagRenderers,
|
|
2794
2907
|
className,
|
|
2795
|
-
children
|
|
2908
|
+
children,
|
|
2909
|
+
observabilityHooks
|
|
2796
2910
|
} = _b, props = __objRest(_b, [
|
|
2797
2911
|
"instructions",
|
|
2798
2912
|
"defaultOpen",
|
|
@@ -2820,52 +2934,41 @@ var CopilotModal = (_a) => {
|
|
|
2820
2934
|
"onRegenerate",
|
|
2821
2935
|
"markdownTagRenderers",
|
|
2822
2936
|
"className",
|
|
2823
|
-
"children"
|
|
2937
|
+
"children",
|
|
2938
|
+
"observabilityHooks"
|
|
2824
2939
|
]);
|
|
2825
2940
|
const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
|
|
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
|
-
|
|
2856
|
-
|
|
2857
|
-
onThumbsUp,
|
|
2858
|
-
onThumbsDown,
|
|
2859
|
-
onCopy,
|
|
2860
|
-
onRegenerate,
|
|
2861
|
-
markdownTagRenderers
|
|
2862
|
-
})
|
|
2863
|
-
)
|
|
2864
|
-
]
|
|
2865
|
-
}
|
|
2866
|
-
)
|
|
2867
|
-
] })
|
|
2868
|
-
] });
|
|
2941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2942
|
+
CopilotModalInner,
|
|
2943
|
+
__spreadProps(__spreadValues({
|
|
2944
|
+
observabilityHooks,
|
|
2945
|
+
onSetOpen,
|
|
2946
|
+
clickOutsideToClose: clickOutsideToClose != null ? clickOutsideToClose : true,
|
|
2947
|
+
hitEscapeToClose: hitEscapeToClose != null ? hitEscapeToClose : true,
|
|
2948
|
+
shortcut: shortcut != null ? shortcut : "/",
|
|
2949
|
+
className,
|
|
2950
|
+
Window: Window2,
|
|
2951
|
+
Button: Button2,
|
|
2952
|
+
Header: Header2,
|
|
2953
|
+
instructions,
|
|
2954
|
+
onSubmitMessage,
|
|
2955
|
+
onStopGeneration,
|
|
2956
|
+
onReloadMessages,
|
|
2957
|
+
makeSystemMessage,
|
|
2958
|
+
onInProgress,
|
|
2959
|
+
Messages: Messages2,
|
|
2960
|
+
Input: Input2,
|
|
2961
|
+
AssistantMessage: AssistantMessage2,
|
|
2962
|
+
UserMessage: UserMessage2,
|
|
2963
|
+
onThumbsUp,
|
|
2964
|
+
onThumbsDown,
|
|
2965
|
+
onCopy,
|
|
2966
|
+
onRegenerate,
|
|
2967
|
+
markdownTagRenderers
|
|
2968
|
+
}, props), {
|
|
2969
|
+
children
|
|
2970
|
+
})
|
|
2971
|
+
) });
|
|
2869
2972
|
};
|
|
2870
2973
|
|
|
2871
2974
|
// src/components/chat/Popup.tsx
|
|
@@ -2897,8 +3000,8 @@ function CopilotSidebar(props) {
|
|
|
2897
3000
|
|
|
2898
3001
|
// src/hooks/use-copilot-chat-suggestions.tsx
|
|
2899
3002
|
var import_react17 = require("react");
|
|
2900
|
-
var
|
|
2901
|
-
var
|
|
3003
|
+
var import_react_core12 = require("@copilotkit/react-core");
|
|
3004
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
2902
3005
|
function useCopilotChatSuggestions({
|
|
2903
3006
|
available = "enabled",
|
|
2904
3007
|
instructions,
|
|
@@ -2906,11 +3009,11 @@ function useCopilotChatSuggestions({
|
|
|
2906
3009
|
minSuggestions = 1,
|
|
2907
3010
|
maxSuggestions = 3
|
|
2908
3011
|
}, dependencies = []) {
|
|
2909
|
-
const context = (0,
|
|
3012
|
+
const context = (0, import_react_core12.useCopilotContext)();
|
|
2910
3013
|
(0, import_react17.useEffect)(() => {
|
|
2911
3014
|
if (available === "disabled")
|
|
2912
3015
|
return;
|
|
2913
|
-
const id = (0,
|
|
3016
|
+
const id = (0, import_shared5.randomId)();
|
|
2914
3017
|
context.addChatSuggestionConfiguration(id, {
|
|
2915
3018
|
instructions,
|
|
2916
3019
|
minSuggestions,
|