@copilotkit/react-ui 1.4.8 → 1.5.0-coagents-v0-3.0
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 +15 -0
- package/dist/{chunk-CVHT5XCA.mjs → chunk-375NVWZM.mjs} +2 -2
- package/dist/{chunk-OMTPWC7T.mjs → chunk-3E7HY2UN.mjs} +5 -4
- package/dist/chunk-3E7HY2UN.mjs.map +1 -0
- package/dist/{chunk-RKPANT3F.mjs → chunk-7II4YL7R.mjs} +2 -6
- package/dist/chunk-7II4YL7R.mjs.map +1 -0
- package/dist/{chunk-46UJJGXP.mjs → chunk-DCNCY2PL.mjs} +113 -10
- package/dist/chunk-DCNCY2PL.mjs.map +1 -0
- package/dist/{chunk-DVMTTXGZ.mjs → chunk-F2W5FD7L.mjs} +2 -2
- package/dist/{chunk-4FIGRRFS.mjs → chunk-PNQVKBPN.mjs} +2 -2
- package/dist/{chunk-4FIGRRFS.mjs.map → chunk-PNQVKBPN.mjs.map} +1 -1
- package/dist/{chunk-752NGHCE.mjs → chunk-UWVGLGFQ.mjs} +7 -3
- package/dist/chunk-UWVGLGFQ.mjs.map +1 -0
- package/dist/{chunk-PNKBFDUI.mjs → chunk-WSMMTZCM.mjs} +2 -2
- package/dist/components/chat/Chat.d.ts +50 -5
- package/dist/components/chat/Chat.js +115 -12
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +5 -5
- package/dist/components/chat/Messages.d.ts +3 -3
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +1 -1
- package/dist/components/chat/Modal.d.ts +1 -1
- package/dist/components/chat/Modal.js +119 -12
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +6 -6
- package/dist/components/chat/Popup.js +119 -12
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +7 -7
- package/dist/components/chat/Sidebar.js +119 -12
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +7 -7
- package/dist/components/chat/index.js +119 -12
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +8 -8
- package/dist/components/chat/messages/RenderActionExecutionMessage.js +4 -3
- package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +1 -1
- package/dist/components/dev-console/console.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +1 -1
- package/dist/components/index.js +119 -12
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +8 -8
- package/dist/index.js +121 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +173 -7
- package/src/components/chat/Messages.tsx +2 -9
- package/src/components/chat/Modal.tsx +4 -0
- package/src/components/chat/messages/RenderActionExecutionMessage.tsx +10 -3
- package/src/components/dev-console/utils.ts +1 -1
- package/dist/chunk-46UJJGXP.mjs.map +0 -1
- package/dist/chunk-752NGHCE.mjs.map +0 -1
- package/dist/chunk-OMTPWC7T.mjs.map +0 -1
- package/dist/chunk-RKPANT3F.mjs.map +0 -1
- /package/dist/{chunk-CVHT5XCA.mjs.map → chunk-375NVWZM.mjs.map} +0 -0
- /package/dist/{chunk-DVMTTXGZ.mjs.map → chunk-F2W5FD7L.mjs.map} +0 -0
- /package/dist/{chunk-PNKBFDUI.mjs.map → chunk-WSMMTZCM.mjs.map} +0 -0
|
@@ -2,30 +2,30 @@ import "../chunk-MMVDU6DF.mjs";
|
|
|
2
2
|
import "../chunk-MRFF7GSQ.mjs";
|
|
3
3
|
import {
|
|
4
4
|
CopilotSidebar
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-WSMMTZCM.mjs";
|
|
6
6
|
import "../chunk-WB3YULQ4.mjs";
|
|
7
7
|
import {
|
|
8
8
|
CopilotPopup
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-375NVWZM.mjs";
|
|
10
|
+
import "../chunk-UWVGLGFQ.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-DCNCY2PL.mjs";
|
|
17
17
|
import "../chunk-6INMITFA.mjs";
|
|
18
18
|
import "../chunk-RU73BEZM.mjs";
|
|
19
19
|
import "../chunk-V7W6IM2V.mjs";
|
|
20
|
-
import "../chunk-
|
|
20
|
+
import "../chunk-3E7HY2UN.mjs";
|
|
21
21
|
import "../chunk-ZABXREBH.mjs";
|
|
22
22
|
import "../chunk-RJCZRKTV.mjs";
|
|
23
23
|
import {
|
|
24
24
|
CopilotDevConsole
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-F2W5FD7L.mjs";
|
|
26
26
|
import {
|
|
27
27
|
shouldShowDevConsole
|
|
28
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-PNQVKBPN.mjs";
|
|
29
29
|
import "../chunk-KXE2JCUH.mjs";
|
|
30
30
|
import "../chunk-TI7SY2RI.mjs";
|
|
31
31
|
import "../chunk-BH6PCAAL.mjs";
|
|
@@ -33,7 +33,7 @@ import "../chunk-OTPAZXVR.mjs";
|
|
|
33
33
|
import "../chunk-EMQEEXUB.mjs";
|
|
34
34
|
import "../chunk-YQFVRDNC.mjs";
|
|
35
35
|
import "../chunk-YQ3D5IQV.mjs";
|
|
36
|
-
import "../chunk-
|
|
36
|
+
import "../chunk-7II4YL7R.mjs";
|
|
37
37
|
import "../chunk-3XAXY2Z3.mjs";
|
|
38
38
|
import {
|
|
39
39
|
useChatContext
|
package/dist/index.js
CHANGED
|
@@ -950,9 +950,9 @@ var import_react7 = require("react");
|
|
|
950
950
|
var import_react_syntax_highlighter = require("react-syntax-highlighter");
|
|
951
951
|
|
|
952
952
|
// src/hooks/use-copy-to-clipboard.tsx
|
|
953
|
-
var
|
|
953
|
+
var React5 = __toESM(require("react"));
|
|
954
954
|
function useCopyToClipboard({ timeout = 2e3 }) {
|
|
955
|
-
const [isCopied, setIsCopied] =
|
|
955
|
+
const [isCopied, setIsCopied] = React5.useState(false);
|
|
956
956
|
const copyToClipboard = (value) => {
|
|
957
957
|
var _a;
|
|
958
958
|
if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
|
|
@@ -1448,8 +1448,8 @@ function RenderActionExecutionMessage(props) {
|
|
|
1448
1448
|
const { chatComponentsCache } = (0, import_react_core3.useCopilotContext)();
|
|
1449
1449
|
const { icons } = useChatContext();
|
|
1450
1450
|
if (message.isActionExecutionMessage()) {
|
|
1451
|
-
if (chatComponentsCache.current !== null && chatComponentsCache.current.actions[message.name]) {
|
|
1452
|
-
const render = chatComponentsCache.current.actions[message.name];
|
|
1451
|
+
if (chatComponentsCache.current !== null && (chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"])) {
|
|
1452
|
+
const render = chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"];
|
|
1453
1453
|
if (typeof render === "string") {
|
|
1454
1454
|
if (isCurrentMessage && inProgress) {
|
|
1455
1455
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: [
|
|
@@ -1472,7 +1472,8 @@ function RenderActionExecutionMessage(props) {
|
|
|
1472
1472
|
const toRender = render({
|
|
1473
1473
|
status,
|
|
1474
1474
|
args,
|
|
1475
|
-
result: actionResult
|
|
1475
|
+
result: actionResult,
|
|
1476
|
+
name: message.name
|
|
1476
1477
|
});
|
|
1477
1478
|
if (!toRender && status === "complete") {
|
|
1478
1479
|
return null;
|
|
@@ -1786,7 +1787,7 @@ function logMessages(context) {
|
|
|
1786
1787
|
type: "ActionExecutionMessage",
|
|
1787
1788
|
role: void 0,
|
|
1788
1789
|
name: message.name,
|
|
1789
|
-
scope: message.
|
|
1790
|
+
scope: message.parentMessageId,
|
|
1790
1791
|
content: message.arguments
|
|
1791
1792
|
};
|
|
1792
1793
|
} else if (message.isResultMessage()) {
|
|
@@ -2312,6 +2313,7 @@ function DebugMenuButton({
|
|
|
2312
2313
|
}
|
|
2313
2314
|
|
|
2314
2315
|
// src/components/chat/Chat.tsx
|
|
2316
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2315
2317
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2316
2318
|
function CopilotChat({
|
|
2317
2319
|
instructions,
|
|
@@ -2319,6 +2321,8 @@ function CopilotChat({
|
|
|
2319
2321
|
makeSystemMessage,
|
|
2320
2322
|
showResponseButton = true,
|
|
2321
2323
|
onInProgress,
|
|
2324
|
+
onStopGeneration,
|
|
2325
|
+
onReloadMessages,
|
|
2322
2326
|
Messages: Messages2 = Messages,
|
|
2323
2327
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2324
2328
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2341,7 +2345,13 @@ function CopilotChat({
|
|
|
2341
2345
|
sendMessage,
|
|
2342
2346
|
stopGeneration,
|
|
2343
2347
|
reloadMessages
|
|
2344
|
-
} = useCopilotChatLogic(
|
|
2348
|
+
} = useCopilotChatLogic(
|
|
2349
|
+
makeSystemMessage,
|
|
2350
|
+
onInProgress,
|
|
2351
|
+
onSubmitMessage,
|
|
2352
|
+
onStopGeneration,
|
|
2353
|
+
onReloadMessages
|
|
2354
|
+
);
|
|
2345
2355
|
const chatContext = import_react12.default.useContext(ChatContext);
|
|
2346
2356
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2347
2357
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2397,8 +2407,16 @@ function WrappedCopilotChat({
|
|
|
2397
2407
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children });
|
|
2398
2408
|
}
|
|
2399
2409
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2400
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2401
|
-
|
|
2410
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2411
|
+
var _a;
|
|
2412
|
+
const {
|
|
2413
|
+
visibleMessages,
|
|
2414
|
+
appendMessage,
|
|
2415
|
+
reloadMessages: defaultReloadMessages,
|
|
2416
|
+
stopGeneration: defaultStopGeneration,
|
|
2417
|
+
runChatCompletion,
|
|
2418
|
+
isLoading
|
|
2419
|
+
} = (0, import_react_core8.useCopilotChat)({
|
|
2402
2420
|
id: (0, import_shared3.randomId)(),
|
|
2403
2421
|
makeSystemMessage
|
|
2404
2422
|
});
|
|
@@ -2406,8 +2424,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2406
2424
|
const suggestionsAbortControllerRef = (0, import_react12.useRef)(null);
|
|
2407
2425
|
const debounceTimerRef = (0, import_react12.useRef)();
|
|
2408
2426
|
const abortSuggestions = () => {
|
|
2409
|
-
var
|
|
2410
|
-
(
|
|
2427
|
+
var _a2;
|
|
2428
|
+
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
2411
2429
|
suggestionsAbortControllerRef.current = null;
|
|
2412
2430
|
};
|
|
2413
2431
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2433,7 +2451,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2433
2451
|
return () => {
|
|
2434
2452
|
clearTimeout(debounceTimerRef.current);
|
|
2435
2453
|
};
|
|
2436
|
-
}, [
|
|
2454
|
+
}, [
|
|
2455
|
+
isLoading,
|
|
2456
|
+
context.chatSuggestionConfiguration,
|
|
2457
|
+
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2458
|
+
// global context
|
|
2459
|
+
visibleMessages.length == 0
|
|
2460
|
+
]);
|
|
2437
2461
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2438
2462
|
abortSuggestions();
|
|
2439
2463
|
setCurrentSuggestions([]);
|
|
@@ -2451,6 +2475,85 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2451
2475
|
appendMessage(message);
|
|
2452
2476
|
return message;
|
|
2453
2477
|
});
|
|
2478
|
+
const messages = visibleMessages;
|
|
2479
|
+
const { setMessages } = messagesContext;
|
|
2480
|
+
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2481
|
+
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2482
|
+
if (generalContext.agentSession) {
|
|
2483
|
+
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2484
|
+
nodeName: void 0,
|
|
2485
|
+
threadId: void 0
|
|
2486
|
+
}));
|
|
2487
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2488
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2489
|
+
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2490
|
+
threadId: void 0,
|
|
2491
|
+
nodeName: void 0,
|
|
2492
|
+
runId: void 0
|
|
2493
|
+
})
|
|
2494
|
+
});
|
|
2495
|
+
});
|
|
2496
|
+
}
|
|
2497
|
+
});
|
|
2498
|
+
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2499
|
+
if (generalContext.agentSession) {
|
|
2500
|
+
yield (0, import_react_core9.runAgent)(
|
|
2501
|
+
generalContext.agentSession.agentName,
|
|
2502
|
+
context,
|
|
2503
|
+
appendMessage,
|
|
2504
|
+
runChatCompletion,
|
|
2505
|
+
hint
|
|
2506
|
+
);
|
|
2507
|
+
}
|
|
2508
|
+
});
|
|
2509
|
+
const stopCurrentAgent = () => {
|
|
2510
|
+
if (generalContext.agentSession) {
|
|
2511
|
+
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2512
|
+
}
|
|
2513
|
+
};
|
|
2514
|
+
const setCurrentAgentState = (state) => {
|
|
2515
|
+
if (generalContext.agentSession) {
|
|
2516
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2517
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2518
|
+
[generalContext.agentSession.agentName]: {
|
|
2519
|
+
state
|
|
2520
|
+
}
|
|
2521
|
+
});
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
};
|
|
2525
|
+
function stopGeneration() {
|
|
2526
|
+
if (onStopGeneration) {
|
|
2527
|
+
onStopGeneration({
|
|
2528
|
+
messages,
|
|
2529
|
+
setMessages,
|
|
2530
|
+
stopGeneration: defaultStopGeneration,
|
|
2531
|
+
currentAgentName,
|
|
2532
|
+
restartCurrentAgent,
|
|
2533
|
+
stopCurrentAgent,
|
|
2534
|
+
runCurrentAgent,
|
|
2535
|
+
setCurrentAgentState
|
|
2536
|
+
});
|
|
2537
|
+
} else {
|
|
2538
|
+
defaultStopGeneration();
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
function reloadMessages() {
|
|
2542
|
+
if (onReloadMessages) {
|
|
2543
|
+
onReloadMessages({
|
|
2544
|
+
messages,
|
|
2545
|
+
setMessages,
|
|
2546
|
+
stopGeneration: defaultStopGeneration,
|
|
2547
|
+
currentAgentName,
|
|
2548
|
+
restartCurrentAgent,
|
|
2549
|
+
stopCurrentAgent,
|
|
2550
|
+
runCurrentAgent,
|
|
2551
|
+
setCurrentAgentState
|
|
2552
|
+
});
|
|
2553
|
+
} else {
|
|
2554
|
+
defaultReloadMessages();
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2454
2557
|
return {
|
|
2455
2558
|
visibleMessages,
|
|
2456
2559
|
isLoading,
|
|
@@ -2470,6 +2573,8 @@ var CopilotModal = ({
|
|
|
2470
2573
|
hitEscapeToClose = true,
|
|
2471
2574
|
onSetOpen,
|
|
2472
2575
|
onSubmitMessage,
|
|
2576
|
+
onStopGeneration,
|
|
2577
|
+
onReloadMessages,
|
|
2473
2578
|
shortcut = "/",
|
|
2474
2579
|
icons,
|
|
2475
2580
|
labels,
|
|
@@ -2507,6 +2612,8 @@ var CopilotModal = ({
|
|
|
2507
2612
|
{
|
|
2508
2613
|
instructions,
|
|
2509
2614
|
onSubmitMessage,
|
|
2615
|
+
onStopGeneration,
|
|
2616
|
+
onReloadMessages,
|
|
2510
2617
|
makeSystemMessage,
|
|
2511
2618
|
showResponseButton,
|
|
2512
2619
|
onInProgress,
|
|
@@ -2551,7 +2658,7 @@ function CopilotSidebar(props) {
|
|
|
2551
2658
|
|
|
2552
2659
|
// src/hooks/use-copilot-chat-suggestions.tsx
|
|
2553
2660
|
var import_react15 = require("react");
|
|
2554
|
-
var
|
|
2661
|
+
var import_react_core10 = require("@copilotkit/react-core");
|
|
2555
2662
|
var import_shared4 = require("@copilotkit/shared");
|
|
2556
2663
|
function useCopilotChatSuggestions({
|
|
2557
2664
|
instructions,
|
|
@@ -2559,7 +2666,7 @@ function useCopilotChatSuggestions({
|
|
|
2559
2666
|
minSuggestions = 1,
|
|
2560
2667
|
maxSuggestions = 3
|
|
2561
2668
|
}, dependencies = []) {
|
|
2562
|
-
const context = (0,
|
|
2669
|
+
const context = (0, import_react_core10.useCopilotContext)();
|
|
2563
2670
|
(0, import_react15.useEffect)(() => {
|
|
2564
2671
|
const id = (0, import_shared4.randomId)();
|
|
2565
2672
|
context.addChatSuggestionConfiguration(id, {
|