@copilotkit/react-ui 1.3.16-pre.11 → 1.3.16-pre.13
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 +31 -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
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import "../../chunk-MRFF7GSQ.mjs";
|
|
2
2
|
import {
|
|
3
3
|
CopilotSidebar
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-5XQEL3WQ.mjs";
|
|
5
5
|
import "../../chunk-WB3YULQ4.mjs";
|
|
6
6
|
import {
|
|
7
7
|
CopilotPopup
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-DXMPY4SG.mjs";
|
|
9
|
+
import "../../chunk-OG2XHQQM.mjs";
|
|
10
10
|
import "../../chunk-YAGE7RCE.mjs";
|
|
11
11
|
import "../../chunk-VEC45H6Q.mjs";
|
|
12
12
|
import "../../chunk-RQNJNK2W.mjs";
|
|
13
13
|
import {
|
|
14
14
|
CopilotChat
|
|
15
|
-
} from "../../chunk-
|
|
15
|
+
} from "../../chunk-2BAND4IT.mjs";
|
|
16
16
|
import "../../chunk-V7W6IM2V.mjs";
|
|
17
17
|
import "../../chunk-OMTPWC7T.mjs";
|
|
18
18
|
import "../../chunk-ZABXREBH.mjs";
|
package/dist/components/index.js
CHANGED
|
@@ -2095,6 +2095,7 @@ function DebugMenuButton({
|
|
|
2095
2095
|
}
|
|
2096
2096
|
|
|
2097
2097
|
// src/components/chat/Chat.tsx
|
|
2098
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2098
2099
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2099
2100
|
function CopilotChat({
|
|
2100
2101
|
instructions,
|
|
@@ -2102,6 +2103,8 @@ function CopilotChat({
|
|
|
2102
2103
|
makeSystemMessage,
|
|
2103
2104
|
showResponseButton = true,
|
|
2104
2105
|
onInProgress,
|
|
2106
|
+
onStopGeneration,
|
|
2107
|
+
onReloadMessages,
|
|
2105
2108
|
Messages: Messages2 = Messages,
|
|
2106
2109
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2107
2110
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2124,7 +2127,13 @@ function CopilotChat({
|
|
|
2124
2127
|
sendMessage,
|
|
2125
2128
|
stopGeneration,
|
|
2126
2129
|
reloadMessages
|
|
2127
|
-
} = useCopilotChatLogic(
|
|
2130
|
+
} = useCopilotChatLogic(
|
|
2131
|
+
makeSystemMessage,
|
|
2132
|
+
onInProgress,
|
|
2133
|
+
onSubmitMessage,
|
|
2134
|
+
onStopGeneration,
|
|
2135
|
+
onReloadMessages
|
|
2136
|
+
);
|
|
2128
2137
|
const chatContext = import_react11.default.useContext(ChatContext);
|
|
2129
2138
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2130
2139
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2180,8 +2189,15 @@ function WrappedCopilotChat({
|
|
|
2180
2189
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2181
2190
|
}
|
|
2182
2191
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2183
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2184
|
-
|
|
2192
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2193
|
+
var _a;
|
|
2194
|
+
const {
|
|
2195
|
+
visibleMessages,
|
|
2196
|
+
appendMessage,
|
|
2197
|
+
reloadMessages: defaultReloadMessages,
|
|
2198
|
+
stopGeneration: defaultStopGeneration,
|
|
2199
|
+
isLoading
|
|
2200
|
+
} = (0, import_react_core8.useCopilotChat)({
|
|
2185
2201
|
id: (0, import_shared3.randomId)(),
|
|
2186
2202
|
makeSystemMessage
|
|
2187
2203
|
});
|
|
@@ -2189,8 +2205,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2189
2205
|
const suggestionsAbortControllerRef = (0, import_react11.useRef)(null);
|
|
2190
2206
|
const debounceTimerRef = (0, import_react11.useRef)();
|
|
2191
2207
|
const abortSuggestions = () => {
|
|
2192
|
-
var
|
|
2193
|
-
(
|
|
2208
|
+
var _a2;
|
|
2209
|
+
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
2194
2210
|
suggestionsAbortControllerRef.current = null;
|
|
2195
2211
|
};
|
|
2196
2212
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2216,7 +2232,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2216
2232
|
return () => {
|
|
2217
2233
|
clearTimeout(debounceTimerRef.current);
|
|
2218
2234
|
};
|
|
2219
|
-
}, [
|
|
2235
|
+
}, [
|
|
2236
|
+
isLoading,
|
|
2237
|
+
context.chatSuggestionConfiguration,
|
|
2238
|
+
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2239
|
+
// global context
|
|
2240
|
+
visibleMessages.length == 0
|
|
2241
|
+
]);
|
|
2220
2242
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2221
2243
|
abortSuggestions();
|
|
2222
2244
|
setCurrentSuggestions([]);
|
|
@@ -2234,6 +2256,79 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2234
2256
|
appendMessage(message);
|
|
2235
2257
|
return message;
|
|
2236
2258
|
});
|
|
2259
|
+
const messages = visibleMessages;
|
|
2260
|
+
const { setMessages } = messagesContext;
|
|
2261
|
+
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2262
|
+
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2263
|
+
if (generalContext.agentSession) {
|
|
2264
|
+
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2265
|
+
nodeName: void 0,
|
|
2266
|
+
threadId: void 0
|
|
2267
|
+
}));
|
|
2268
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2269
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2270
|
+
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2271
|
+
threadId: void 0,
|
|
2272
|
+
nodeName: void 0,
|
|
2273
|
+
runId: void 0
|
|
2274
|
+
})
|
|
2275
|
+
});
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
});
|
|
2279
|
+
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2280
|
+
if (generalContext.agentSession) {
|
|
2281
|
+
yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
|
|
2282
|
+
}
|
|
2283
|
+
});
|
|
2284
|
+
const stopCurrentAgent = () => {
|
|
2285
|
+
if (generalContext.agentSession) {
|
|
2286
|
+
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
2289
|
+
const setCurrentAgentState = (state) => {
|
|
2290
|
+
if (generalContext.agentSession) {
|
|
2291
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2292
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2293
|
+
[generalContext.agentSession.agentName]: {
|
|
2294
|
+
state
|
|
2295
|
+
}
|
|
2296
|
+
});
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
};
|
|
2300
|
+
function stopGeneration() {
|
|
2301
|
+
if (onStopGeneration) {
|
|
2302
|
+
onStopGeneration({
|
|
2303
|
+
messages,
|
|
2304
|
+
setMessages,
|
|
2305
|
+
stopGeneration: defaultStopGeneration,
|
|
2306
|
+
currentAgentName,
|
|
2307
|
+
restartCurrentAgent,
|
|
2308
|
+
stopCurrentAgent,
|
|
2309
|
+
runCurrentAgent,
|
|
2310
|
+
setCurrentAgentState
|
|
2311
|
+
});
|
|
2312
|
+
} else {
|
|
2313
|
+
defaultStopGeneration();
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
function reloadMessages() {
|
|
2317
|
+
if (onReloadMessages) {
|
|
2318
|
+
onReloadMessages({
|
|
2319
|
+
messages,
|
|
2320
|
+
setMessages,
|
|
2321
|
+
stopGeneration: defaultStopGeneration,
|
|
2322
|
+
currentAgentName,
|
|
2323
|
+
restartCurrentAgent,
|
|
2324
|
+
stopCurrentAgent,
|
|
2325
|
+
runCurrentAgent,
|
|
2326
|
+
setCurrentAgentState
|
|
2327
|
+
});
|
|
2328
|
+
} else {
|
|
2329
|
+
defaultReloadMessages();
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2237
2332
|
return {
|
|
2238
2333
|
visibleMessages,
|
|
2239
2334
|
isLoading,
|
|
@@ -2253,6 +2348,8 @@ var CopilotModal = ({
|
|
|
2253
2348
|
hitEscapeToClose = true,
|
|
2254
2349
|
onSetOpen,
|
|
2255
2350
|
onSubmitMessage,
|
|
2351
|
+
onStopGeneration,
|
|
2352
|
+
onReloadMessages,
|
|
2256
2353
|
shortcut = "/",
|
|
2257
2354
|
icons,
|
|
2258
2355
|
labels,
|
|
@@ -2290,6 +2387,8 @@ var CopilotModal = ({
|
|
|
2290
2387
|
{
|
|
2291
2388
|
instructions,
|
|
2292
2389
|
onSubmitMessage,
|
|
2390
|
+
onStopGeneration,
|
|
2391
|
+
onReloadMessages,
|
|
2293
2392
|
makeSystemMessage,
|
|
2294
2393
|
showResponseButton,
|
|
2295
2394
|
onInProgress,
|