@copilotkit/react-ui 1.3.16-pre.11 → 1.3.16-pre.12
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 +21 -5
- package/dist/{chunk-ORHE7FYT.mjs → chunk-2BAND4IT.mjs} +103 -7
- package/dist/chunk-2BAND4IT.mjs.map +1 -0
- package/dist/{chunk-M2NVAJQA.mjs → chunk-5XQEL3WQ.mjs} +2 -2
- package/dist/{chunk-PY7YBFPA.mjs → chunk-DXMPY4SG.mjs} +2 -2
- package/dist/{chunk-H5CXJBR5.mjs → chunk-OG2XHQQM.mjs} +6 -2
- package/dist/chunk-OG2XHQQM.mjs.map +1 -0
- 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-H5CXJBR5.mjs.map +0 -1
- package/dist/chunk-ORHE7FYT.mjs.map +0 -1
- /package/dist/{chunk-M2NVAJQA.mjs.map → chunk-5XQEL3WQ.mjs.map} +0 -0
- /package/dist/{chunk-PY7YBFPA.mjs.map → chunk-DXMPY4SG.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 };
|
|
@@ -2090,6 +2090,7 @@ function DebugMenuButton({
|
|
|
2090
2090
|
}
|
|
2091
2091
|
|
|
2092
2092
|
// src/components/chat/Chat.tsx
|
|
2093
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2093
2094
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2094
2095
|
function CopilotChat({
|
|
2095
2096
|
instructions,
|
|
@@ -2097,6 +2098,8 @@ function CopilotChat({
|
|
|
2097
2098
|
makeSystemMessage,
|
|
2098
2099
|
showResponseButton = true,
|
|
2099
2100
|
onInProgress,
|
|
2101
|
+
onStopGeneration,
|
|
2102
|
+
onReloadMessages,
|
|
2100
2103
|
Messages: Messages2 = Messages,
|
|
2101
2104
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2102
2105
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2119,7 +2122,13 @@ function CopilotChat({
|
|
|
2119
2122
|
sendMessage,
|
|
2120
2123
|
stopGeneration,
|
|
2121
2124
|
reloadMessages
|
|
2122
|
-
} = useCopilotChatLogic(
|
|
2125
|
+
} = useCopilotChatLogic(
|
|
2126
|
+
makeSystemMessage,
|
|
2127
|
+
onInProgress,
|
|
2128
|
+
onSubmitMessage,
|
|
2129
|
+
onStopGeneration,
|
|
2130
|
+
onReloadMessages
|
|
2131
|
+
);
|
|
2123
2132
|
const chatContext = import_react11.default.useContext(ChatContext);
|
|
2124
2133
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2125
2134
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2175,8 +2184,15 @@ function WrappedCopilotChat({
|
|
|
2175
2184
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2176
2185
|
}
|
|
2177
2186
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2178
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2179
|
-
|
|
2187
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2188
|
+
var _a;
|
|
2189
|
+
const {
|
|
2190
|
+
visibleMessages,
|
|
2191
|
+
appendMessage,
|
|
2192
|
+
reloadMessages: defaultReloadMessages,
|
|
2193
|
+
stopGeneration: defaultStopGeneration,
|
|
2194
|
+
isLoading
|
|
2195
|
+
} = (0, import_react_core8.useCopilotChat)({
|
|
2180
2196
|
id: (0, import_shared3.randomId)(),
|
|
2181
2197
|
makeSystemMessage
|
|
2182
2198
|
});
|
|
@@ -2184,8 +2200,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2184
2200
|
const suggestionsAbortControllerRef = (0, import_react11.useRef)(null);
|
|
2185
2201
|
const debounceTimerRef = (0, import_react11.useRef)();
|
|
2186
2202
|
const abortSuggestions = () => {
|
|
2187
|
-
var
|
|
2188
|
-
(
|
|
2203
|
+
var _a2;
|
|
2204
|
+
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
2189
2205
|
suggestionsAbortControllerRef.current = null;
|
|
2190
2206
|
};
|
|
2191
2207
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2211,7 +2227,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2211
2227
|
return () => {
|
|
2212
2228
|
clearTimeout(debounceTimerRef.current);
|
|
2213
2229
|
};
|
|
2214
|
-
}, [
|
|
2230
|
+
}, [
|
|
2231
|
+
isLoading,
|
|
2232
|
+
context.chatSuggestionConfiguration,
|
|
2233
|
+
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2234
|
+
// global context
|
|
2235
|
+
visibleMessages.length == 0
|
|
2236
|
+
]);
|
|
2215
2237
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2216
2238
|
abortSuggestions();
|
|
2217
2239
|
setCurrentSuggestions([]);
|
|
@@ -2229,6 +2251,79 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2229
2251
|
appendMessage(message);
|
|
2230
2252
|
return message;
|
|
2231
2253
|
});
|
|
2254
|
+
const messages = visibleMessages;
|
|
2255
|
+
const { setMessages } = messagesContext;
|
|
2256
|
+
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2257
|
+
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2258
|
+
if (generalContext.agentSession) {
|
|
2259
|
+
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2260
|
+
nodeName: void 0,
|
|
2261
|
+
threadId: void 0
|
|
2262
|
+
}));
|
|
2263
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2264
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2265
|
+
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2266
|
+
threadId: void 0,
|
|
2267
|
+
nodeName: void 0,
|
|
2268
|
+
runId: void 0
|
|
2269
|
+
})
|
|
2270
|
+
});
|
|
2271
|
+
});
|
|
2272
|
+
}
|
|
2273
|
+
});
|
|
2274
|
+
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2275
|
+
if (generalContext.agentSession) {
|
|
2276
|
+
yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
|
|
2277
|
+
}
|
|
2278
|
+
});
|
|
2279
|
+
const stopCurrentAgent = () => {
|
|
2280
|
+
if (generalContext.agentSession) {
|
|
2281
|
+
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2282
|
+
}
|
|
2283
|
+
};
|
|
2284
|
+
const setCurrentAgentState = (state) => {
|
|
2285
|
+
if (generalContext.agentSession) {
|
|
2286
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2287
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2288
|
+
[generalContext.agentSession.agentName]: {
|
|
2289
|
+
state
|
|
2290
|
+
}
|
|
2291
|
+
});
|
|
2292
|
+
});
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2295
|
+
function stopGeneration() {
|
|
2296
|
+
if (onStopGeneration) {
|
|
2297
|
+
onStopGeneration({
|
|
2298
|
+
messages,
|
|
2299
|
+
setMessages,
|
|
2300
|
+
stopGeneration: defaultStopGeneration,
|
|
2301
|
+
currentAgentName,
|
|
2302
|
+
restartCurrentAgent,
|
|
2303
|
+
stopCurrentAgent,
|
|
2304
|
+
runCurrentAgent,
|
|
2305
|
+
setCurrentAgentState
|
|
2306
|
+
});
|
|
2307
|
+
} else {
|
|
2308
|
+
defaultStopGeneration();
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
function reloadMessages() {
|
|
2312
|
+
if (onReloadMessages) {
|
|
2313
|
+
onReloadMessages({
|
|
2314
|
+
messages,
|
|
2315
|
+
setMessages,
|
|
2316
|
+
stopGeneration: defaultStopGeneration,
|
|
2317
|
+
currentAgentName,
|
|
2318
|
+
restartCurrentAgent,
|
|
2319
|
+
stopCurrentAgent,
|
|
2320
|
+
runCurrentAgent,
|
|
2321
|
+
setCurrentAgentState
|
|
2322
|
+
});
|
|
2323
|
+
} else {
|
|
2324
|
+
defaultReloadMessages();
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2232
2327
|
return {
|
|
2233
2328
|
visibleMessages,
|
|
2234
2329
|
isLoading,
|
|
@@ -2248,6 +2343,8 @@ var CopilotModal = ({
|
|
|
2248
2343
|
hitEscapeToClose = true,
|
|
2249
2344
|
onSetOpen,
|
|
2250
2345
|
onSubmitMessage,
|
|
2346
|
+
onStopGeneration,
|
|
2347
|
+
onReloadMessages,
|
|
2251
2348
|
shortcut = "/",
|
|
2252
2349
|
icons,
|
|
2253
2350
|
labels,
|
|
@@ -2285,6 +2382,8 @@ var CopilotModal = ({
|
|
|
2285
2382
|
{
|
|
2286
2383
|
instructions,
|
|
2287
2384
|
onSubmitMessage,
|
|
2385
|
+
onStopGeneration,
|
|
2386
|
+
onReloadMessages,
|
|
2288
2387
|
makeSystemMessage,
|
|
2289
2388
|
showResponseButton,
|
|
2290
2389
|
onInProgress,
|