@copilotkit/react-ui 1.3.16-mme-lgc-langgraph-package.11 → 1.3.16-mme-reset-chat.10
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 +55 -95
- package/dist/{chunk-C5KOJ3IH.mjs → chunk-3QOICFXX.mjs} +103 -7
- package/dist/chunk-3QOICFXX.mjs.map +1 -0
- package/dist/{chunk-QK6XA3PL.mjs → chunk-H7LLXN6X.mjs} +6 -2
- package/dist/chunk-H7LLXN6X.mjs.map +1 -0
- package/dist/{chunk-TEZWY2BL.mjs → chunk-P54DK2TL.mjs} +2 -2
- package/dist/{chunk-OJ5NVSTU.mjs → chunk-SEY3XSCD.mjs} +2 -2
- package/dist/components/chat/Chat.d.ts +50 -5
- package/dist/components/chat/Chat.js +101 -6
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +1 -1
- package/dist/components/chat/Modal.d.ts +1 -1
- package/dist/components/chat/Modal.js +105 -6
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +2 -2
- package/dist/components/chat/Popup.js +105 -6
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +3 -3
- package/dist/components/chat/Sidebar.js +105 -6
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +3 -3
- package/dist/components/chat/index.js +105 -6
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +4 -4
- package/dist/components/index.js +105 -6
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -4
- package/dist/index.js +107 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/package.json +7 -7
- package/src/components/chat/Chat.tsx +166 -7
- package/src/components/chat/Modal.tsx +4 -0
- package/dist/chunk-C5KOJ3IH.mjs.map +0 -1
- package/dist/chunk-QK6XA3PL.mjs.map +0 -1
- /package/dist/{chunk-TEZWY2BL.mjs.map → chunk-P54DK2TL.mjs.map} +0 -0
- /package/dist/{chunk-OJ5NVSTU.mjs.map → chunk-SEY3XSCD.mjs.map} +0 -0
|
@@ -46,6 +46,6 @@ interface CopilotModalProps extends CopilotChatProps {
|
|
|
46
46
|
*/
|
|
47
47
|
Header?: React__default.ComponentType<HeaderProps>;
|
|
48
48
|
}
|
|
49
|
-
declare const CopilotModal: ({ instructions, defaultOpen, clickOutsideToClose, hitEscapeToClose, onSetOpen, onSubmitMessage, shortcut, icons, labels, makeSystemMessage, showResponseButton, onInProgress, Window, Button, Header, Messages, Input, ResponseButton, className, children, }: CopilotModalProps) => react_jsx_runtime.JSX.Element;
|
|
49
|
+
declare const CopilotModal: ({ instructions, defaultOpen, clickOutsideToClose, hitEscapeToClose, onSetOpen, onSubmitMessage, onStopGeneration, onReloadMessages, shortcut, icons, labels, makeSystemMessage, showResponseButton, onInProgress, Window, Button, Header, Messages, Input, ResponseButton, className, children, }: CopilotModalProps) => react_jsx_runtime.JSX.Element;
|
|
50
50
|
|
|
51
51
|
export { CopilotModal, CopilotModalProps };
|
|
@@ -2041,6 +2041,7 @@ function DebugMenuButton({
|
|
|
2041
2041
|
}
|
|
2042
2042
|
|
|
2043
2043
|
// src/components/chat/Chat.tsx
|
|
2044
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2044
2045
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2045
2046
|
function CopilotChat({
|
|
2046
2047
|
instructions,
|
|
@@ -2048,6 +2049,8 @@ function CopilotChat({
|
|
|
2048
2049
|
makeSystemMessage,
|
|
2049
2050
|
showResponseButton = true,
|
|
2050
2051
|
onInProgress,
|
|
2052
|
+
onStopGeneration,
|
|
2053
|
+
onReloadMessages,
|
|
2051
2054
|
Messages: Messages2 = Messages,
|
|
2052
2055
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2053
2056
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2070,7 +2073,13 @@ function CopilotChat({
|
|
|
2070
2073
|
sendMessage,
|
|
2071
2074
|
stopGeneration,
|
|
2072
2075
|
reloadMessages
|
|
2073
|
-
} = useCopilotChatLogic(
|
|
2076
|
+
} = useCopilotChatLogic(
|
|
2077
|
+
makeSystemMessage,
|
|
2078
|
+
onInProgress,
|
|
2079
|
+
onSubmitMessage,
|
|
2080
|
+
onStopGeneration,
|
|
2081
|
+
onReloadMessages
|
|
2082
|
+
);
|
|
2074
2083
|
const chatContext = import_react11.default.useContext(ChatContext);
|
|
2075
2084
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2076
2085
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2126,8 +2135,15 @@ function WrappedCopilotChat({
|
|
|
2126
2135
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2127
2136
|
}
|
|
2128
2137
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2129
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2130
|
-
|
|
2138
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2139
|
+
var _a;
|
|
2140
|
+
const {
|
|
2141
|
+
visibleMessages,
|
|
2142
|
+
appendMessage,
|
|
2143
|
+
reloadMessages: defaultReloadMessages,
|
|
2144
|
+
stopGeneration: defaultStopGeneration,
|
|
2145
|
+
isLoading
|
|
2146
|
+
} = (0, import_react_core8.useCopilotChat)({
|
|
2131
2147
|
id: (0, import_shared3.randomId)(),
|
|
2132
2148
|
makeSystemMessage
|
|
2133
2149
|
});
|
|
@@ -2135,8 +2151,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2135
2151
|
const suggestionsAbortControllerRef = (0, import_react11.useRef)(null);
|
|
2136
2152
|
const debounceTimerRef = (0, import_react11.useRef)();
|
|
2137
2153
|
const abortSuggestions = () => {
|
|
2138
|
-
var
|
|
2139
|
-
(
|
|
2154
|
+
var _a2;
|
|
2155
|
+
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
2140
2156
|
suggestionsAbortControllerRef.current = null;
|
|
2141
2157
|
};
|
|
2142
2158
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2162,7 +2178,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2162
2178
|
return () => {
|
|
2163
2179
|
clearTimeout(debounceTimerRef.current);
|
|
2164
2180
|
};
|
|
2165
|
-
}, [
|
|
2181
|
+
}, [
|
|
2182
|
+
isLoading,
|
|
2183
|
+
context.chatSuggestionConfiguration,
|
|
2184
|
+
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2185
|
+
// global context
|
|
2186
|
+
visibleMessages.length == 0
|
|
2187
|
+
]);
|
|
2166
2188
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2167
2189
|
abortSuggestions();
|
|
2168
2190
|
setCurrentSuggestions([]);
|
|
@@ -2180,6 +2202,79 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2180
2202
|
appendMessage(message);
|
|
2181
2203
|
return message;
|
|
2182
2204
|
});
|
|
2205
|
+
const messages = visibleMessages;
|
|
2206
|
+
const { setMessages } = messagesContext;
|
|
2207
|
+
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2208
|
+
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2209
|
+
if (generalContext.agentSession) {
|
|
2210
|
+
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2211
|
+
nodeName: void 0,
|
|
2212
|
+
threadId: void 0
|
|
2213
|
+
}));
|
|
2214
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2215
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2216
|
+
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2217
|
+
threadId: void 0,
|
|
2218
|
+
nodeName: void 0,
|
|
2219
|
+
runId: void 0
|
|
2220
|
+
})
|
|
2221
|
+
});
|
|
2222
|
+
});
|
|
2223
|
+
}
|
|
2224
|
+
});
|
|
2225
|
+
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2226
|
+
if (generalContext.agentSession) {
|
|
2227
|
+
yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
|
|
2228
|
+
}
|
|
2229
|
+
});
|
|
2230
|
+
const stopCurrentAgent = () => {
|
|
2231
|
+
if (generalContext.agentSession) {
|
|
2232
|
+
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2233
|
+
}
|
|
2234
|
+
};
|
|
2235
|
+
const setCurrentAgentState = (state) => {
|
|
2236
|
+
if (generalContext.agentSession) {
|
|
2237
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2238
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2239
|
+
[generalContext.agentSession.agentName]: {
|
|
2240
|
+
state
|
|
2241
|
+
}
|
|
2242
|
+
});
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
};
|
|
2246
|
+
function stopGeneration() {
|
|
2247
|
+
if (onStopGeneration) {
|
|
2248
|
+
onStopGeneration({
|
|
2249
|
+
messages,
|
|
2250
|
+
setMessages,
|
|
2251
|
+
stopGeneration: defaultStopGeneration,
|
|
2252
|
+
currentAgentName,
|
|
2253
|
+
restartCurrentAgent,
|
|
2254
|
+
stopCurrentAgent,
|
|
2255
|
+
runCurrentAgent,
|
|
2256
|
+
setCurrentAgentState
|
|
2257
|
+
});
|
|
2258
|
+
} else {
|
|
2259
|
+
defaultStopGeneration();
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
function reloadMessages() {
|
|
2263
|
+
if (onReloadMessages) {
|
|
2264
|
+
onReloadMessages({
|
|
2265
|
+
messages,
|
|
2266
|
+
setMessages,
|
|
2267
|
+
stopGeneration: defaultStopGeneration,
|
|
2268
|
+
currentAgentName,
|
|
2269
|
+
restartCurrentAgent,
|
|
2270
|
+
stopCurrentAgent,
|
|
2271
|
+
runCurrentAgent,
|
|
2272
|
+
setCurrentAgentState
|
|
2273
|
+
});
|
|
2274
|
+
} else {
|
|
2275
|
+
defaultReloadMessages();
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2183
2278
|
return {
|
|
2184
2279
|
visibleMessages,
|
|
2185
2280
|
isLoading,
|
|
@@ -2199,6 +2294,8 @@ var CopilotModal = ({
|
|
|
2199
2294
|
hitEscapeToClose = true,
|
|
2200
2295
|
onSetOpen,
|
|
2201
2296
|
onSubmitMessage,
|
|
2297
|
+
onStopGeneration,
|
|
2298
|
+
onReloadMessages,
|
|
2202
2299
|
shortcut = "/",
|
|
2203
2300
|
icons,
|
|
2204
2301
|
labels,
|
|
@@ -2236,6 +2333,8 @@ var CopilotModal = ({
|
|
|
2236
2333
|
{
|
|
2237
2334
|
instructions,
|
|
2238
2335
|
onSubmitMessage,
|
|
2336
|
+
onStopGeneration,
|
|
2337
|
+
onReloadMessages,
|
|
2239
2338
|
makeSystemMessage,
|
|
2240
2339
|
showResponseButton,
|
|
2241
2340
|
onInProgress,
|