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