@copilotkit/react-ui 1.4.8-no-pino-redact.1 → 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.
Files changed (75) hide show
  1. package/CHANGELOG.md +37 -4
  2. package/dist/{chunk-FUDBUYBG.mjs → chunk-375NVWZM.mjs} +2 -2
  3. package/dist/{chunk-OMTPWC7T.mjs → chunk-3E7HY2UN.mjs} +5 -4
  4. package/dist/chunk-3E7HY2UN.mjs.map +1 -0
  5. package/dist/{chunk-RKPANT3F.mjs → chunk-7II4YL7R.mjs} +2 -6
  6. package/dist/chunk-7II4YL7R.mjs.map +1 -0
  7. package/dist/{chunk-T35X2SFE.mjs → chunk-DCNCY2PL.mjs} +113 -10
  8. package/dist/chunk-DCNCY2PL.mjs.map +1 -0
  9. package/dist/{chunk-TTYR7XPN.mjs → chunk-F2W5FD7L.mjs} +3 -3
  10. package/dist/{chunk-4FIGRRFS.mjs → chunk-PNQVKBPN.mjs} +2 -2
  11. package/dist/{chunk-4FIGRRFS.mjs.map → chunk-PNQVKBPN.mjs.map} +1 -1
  12. package/dist/{chunk-ICGZEGHQ.mjs → chunk-TI7SY2RI.mjs} +13 -4
  13. package/dist/chunk-TI7SY2RI.mjs.map +1 -0
  14. package/dist/{chunk-E5SSVET3.mjs → chunk-UWVGLGFQ.mjs} +7 -3
  15. package/dist/chunk-UWVGLGFQ.mjs.map +1 -0
  16. package/dist/{chunk-ZQFKJLQ6.mjs → chunk-WSMMTZCM.mjs} +2 -2
  17. package/dist/components/chat/Chat.d.ts +50 -5
  18. package/dist/components/chat/Chat.js +127 -38
  19. package/dist/components/chat/Chat.js.map +1 -1
  20. package/dist/components/chat/Chat.mjs +6 -6
  21. package/dist/components/chat/Messages.d.ts +3 -3
  22. package/dist/components/chat/Messages.js.map +1 -1
  23. package/dist/components/chat/Messages.mjs +1 -1
  24. package/dist/components/chat/Modal.d.ts +1 -1
  25. package/dist/components/chat/Modal.js +131 -38
  26. package/dist/components/chat/Modal.js.map +1 -1
  27. package/dist/components/chat/Modal.mjs +7 -7
  28. package/dist/components/chat/Popup.js +131 -38
  29. package/dist/components/chat/Popup.js.map +1 -1
  30. package/dist/components/chat/Popup.mjs +8 -8
  31. package/dist/components/chat/Sidebar.js +131 -38
  32. package/dist/components/chat/Sidebar.js.map +1 -1
  33. package/dist/components/chat/Sidebar.mjs +8 -8
  34. package/dist/components/chat/index.js +131 -38
  35. package/dist/components/chat/index.js.map +1 -1
  36. package/dist/components/chat/index.mjs +9 -9
  37. package/dist/components/chat/messages/RenderActionExecutionMessage.js +4 -3
  38. package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -1
  39. package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +1 -1
  40. package/dist/components/dev-console/console.js +13 -27
  41. package/dist/components/dev-console/console.js.map +1 -1
  42. package/dist/components/dev-console/console.mjs +3 -3
  43. package/dist/components/dev-console/index.js +13 -27
  44. package/dist/components/dev-console/index.js.map +1 -1
  45. package/dist/components/dev-console/index.mjs +3 -3
  46. package/dist/components/dev-console/utils.js +1 -1
  47. package/dist/components/dev-console/utils.js.map +1 -1
  48. package/dist/components/dev-console/utils.mjs +1 -1
  49. package/dist/components/help-modal/index.js +12 -26
  50. package/dist/components/help-modal/index.js.map +1 -1
  51. package/dist/components/help-modal/index.mjs +1 -1
  52. package/dist/components/help-modal/modal.js +12 -26
  53. package/dist/components/help-modal/modal.js.map +1 -1
  54. package/dist/components/help-modal/modal.mjs +1 -1
  55. package/dist/components/index.js +131 -38
  56. package/dist/components/index.js.map +1 -1
  57. package/dist/components/index.mjs +9 -9
  58. package/dist/index.js +133 -40
  59. package/dist/index.js.map +1 -1
  60. package/dist/index.mjs +9 -9
  61. package/package.json +4 -4
  62. package/src/components/chat/Chat.tsx +173 -7
  63. package/src/components/chat/Messages.tsx +2 -9
  64. package/src/components/chat/Modal.tsx +4 -0
  65. package/src/components/chat/messages/RenderActionExecutionMessage.tsx +10 -3
  66. package/src/components/dev-console/utils.ts +1 -1
  67. package/src/components/help-modal/modal.tsx +12 -2
  68. package/dist/chunk-E5SSVET3.mjs.map +0 -1
  69. package/dist/chunk-ICGZEGHQ.mjs.map +0 -1
  70. package/dist/chunk-OMTPWC7T.mjs.map +0 -1
  71. package/dist/chunk-RKPANT3F.mjs.map +0 -1
  72. package/dist/chunk-T35X2SFE.mjs.map +0 -1
  73. /package/dist/{chunk-FUDBUYBG.mjs.map → chunk-375NVWZM.mjs.map} +0 -0
  74. /package/dist/{chunk-TTYR7XPN.mjs.map → chunk-F2W5FD7L.mjs.map} +0 -0
  75. /package/dist/{chunk-ZQFKJLQ6.mjs.map → chunk-WSMMTZCM.mjs.map} +0 -0
@@ -1,27 +1,27 @@
1
1
  import {
2
2
  CopilotPopup
3
- } from "../../chunk-FUDBUYBG.mjs";
4
- import "../../chunk-E5SSVET3.mjs";
3
+ } from "../../chunk-375NVWZM.mjs";
4
+ import "../../chunk-UWVGLGFQ.mjs";
5
5
  import "../../chunk-YAGE7RCE.mjs";
6
6
  import "../../chunk-VEC45H6Q.mjs";
7
7
  import "../../chunk-RQNJNK2W.mjs";
8
- import "../../chunk-T35X2SFE.mjs";
8
+ import "../../chunk-DCNCY2PL.mjs";
9
9
  import "../../chunk-6INMITFA.mjs";
10
10
  import "../../chunk-RU73BEZM.mjs";
11
11
  import "../../chunk-V7W6IM2V.mjs";
12
- import "../../chunk-OMTPWC7T.mjs";
12
+ import "../../chunk-3E7HY2UN.mjs";
13
13
  import "../../chunk-ZABXREBH.mjs";
14
14
  import "../../chunk-RJCZRKTV.mjs";
15
- import "../../chunk-TTYR7XPN.mjs";
16
- import "../../chunk-4FIGRRFS.mjs";
15
+ import "../../chunk-F2W5FD7L.mjs";
16
+ import "../../chunk-PNQVKBPN.mjs";
17
17
  import "../../chunk-KXE2JCUH.mjs";
18
- import "../../chunk-ICGZEGHQ.mjs";
18
+ import "../../chunk-TI7SY2RI.mjs";
19
19
  import "../../chunk-BH6PCAAL.mjs";
20
20
  import "../../chunk-OTPAZXVR.mjs";
21
21
  import "../../chunk-EMQEEXUB.mjs";
22
22
  import "../../chunk-YQFVRDNC.mjs";
23
23
  import "../../chunk-YQ3D5IQV.mjs";
24
- import "../../chunk-RKPANT3F.mjs";
24
+ import "../../chunk-7II4YL7R.mjs";
25
25
  import "../../chunk-3XAXY2Z3.mjs";
26
26
  import "../../chunk-CBBFRI3Q.mjs";
27
27
  import "../../chunk-UPTB2MVO.mjs";
@@ -944,9 +944,9 @@ var import_react7 = require("react");
944
944
  var import_react_syntax_highlighter = require("react-syntax-highlighter");
945
945
 
946
946
  // src/hooks/use-copy-to-clipboard.tsx
947
- var React6 = __toESM(require("react"));
947
+ var React5 = __toESM(require("react"));
948
948
  function useCopyToClipboard({ timeout = 2e3 }) {
949
- const [isCopied, setIsCopied] = React6.useState(false);
949
+ const [isCopied, setIsCopied] = React5.useState(false);
950
950
  const copyToClipboard = (value) => {
951
951
  var _a;
952
952
  if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
@@ -1442,8 +1442,8 @@ function RenderActionExecutionMessage(props) {
1442
1442
  const { chatComponentsCache } = (0, import_react_core3.useCopilotContext)();
1443
1443
  const { icons } = useChatContext();
1444
1444
  if (message.isActionExecutionMessage()) {
1445
- if (chatComponentsCache.current !== null && chatComponentsCache.current.actions[message.name]) {
1446
- const render = chatComponentsCache.current.actions[message.name];
1445
+ if (chatComponentsCache.current !== null && (chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"])) {
1446
+ const render = chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"];
1447
1447
  if (typeof render === "string") {
1448
1448
  if (isCurrentMessage && inProgress) {
1449
1449
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: [
@@ -1466,7 +1466,8 @@ function RenderActionExecutionMessage(props) {
1466
1466
  const toRender = render({
1467
1467
  status,
1468
1468
  args,
1469
- result: actionResult
1469
+ result: actionResult,
1470
+ name: message.name
1470
1471
  });
1471
1472
  if (!toRender && status === "complete") {
1472
1473
  return null;
@@ -1780,7 +1781,7 @@ function logMessages(context) {
1780
1781
  type: "ActionExecutionMessage",
1781
1782
  role: void 0,
1782
1783
  name: message.name,
1783
- scope: message.scope,
1784
+ scope: message.parentMessageId,
1784
1785
  content: message.arguments
1785
1786
  };
1786
1787
  } else if (message.isResultMessage()) {
@@ -1903,30 +1904,6 @@ var import_react9 = require("react");
1903
1904
 
1904
1905
  // src/components/help-modal/icons.tsx
1905
1906
  var import_jsx_runtime18 = require("react/jsx-runtime");
1906
- var LifeBuoyIcon = () => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1907
- "svg",
1908
- {
1909
- xmlns: "http://www.w3.org/2000/svg",
1910
- width: "24",
1911
- height: "24",
1912
- viewBox: "0 0 24 24",
1913
- fill: "none",
1914
- stroke: "currentColor",
1915
- strokeWidth: "2",
1916
- strokeLinecap: "round",
1917
- strokeLinejoin: "round",
1918
- className: "icon icon-tabler icons-tabler-outline icon-tabler-lifebuoy",
1919
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("g", { transform: "translate(0, -1)", children: [
1920
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
1921
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0" }),
1922
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" }),
1923
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M15 15l3.35 3.35" }),
1924
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M9 15l-3.35 3.35" }),
1925
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M5.65 5.65l3.35 3.35" }),
1926
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M18.35 5.65l-3.35 3.35" })
1927
- ] })
1928
- }
1929
- );
1930
1907
  var CloseIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1931
1908
  "svg",
1932
1909
  {
@@ -2017,9 +1994,10 @@ function CopilotKitHelpModal() {
2017
1994
  "button",
2018
1995
  {
2019
1996
  onClick: () => setShowHelpModal(true),
2020
- className: "p-2 bg-transparent rounded-full shadow-lg hover:shadow-xl transition-shadow duration-300 focus:outline-none focus:ring-2 focus:ring-blue-500",
1997
+ style: { width: "50px", height: "30px", marginRight: "0.25rem" },
1998
+ className: "text-sm p-0 bg-transparent rounded border border-blue-500",
2021
1999
  "aria-label": "Open Help",
2022
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LifeBuoyIcon, {})
2000
+ children: "Help"
2023
2001
  }
2024
2002
  );
2025
2003
  const submitButtonDisabled = (0, import_react9.useMemo)(
@@ -2046,6 +2024,15 @@ function CopilotKitHelpModal() {
2046
2024
  ),
2047
2025
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w-full flex mb-6 justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h2", { className: "text-2xl font-bold", children: "Help Options" }) }),
2048
2026
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-4 mb-4", children: [
2027
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "block w-full text-center py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-150 text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2028
+ "a",
2029
+ {
2030
+ href: "https://docs.copilotkit.ai/coagents/troubleshooting/common-issues",
2031
+ target: "_blank",
2032
+ rel: "noopener noreferrer",
2033
+ children: "Visit the Troubleshooting and FAQ section in the docs"
2034
+ }
2035
+ ) }),
2049
2036
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "block w-full text-center py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600 transition duration-150 text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2050
2037
  "a",
2051
2038
  {
@@ -2320,6 +2307,7 @@ function DebugMenuButton({
2320
2307
  }
2321
2308
 
2322
2309
  // src/components/chat/Chat.tsx
2310
+ var import_react_core9 = require("@copilotkit/react-core");
2323
2311
  var import_jsx_runtime21 = require("react/jsx-runtime");
2324
2312
  function CopilotChat({
2325
2313
  instructions,
@@ -2327,6 +2315,8 @@ function CopilotChat({
2327
2315
  makeSystemMessage,
2328
2316
  showResponseButton = true,
2329
2317
  onInProgress,
2318
+ onStopGeneration,
2319
+ onReloadMessages,
2330
2320
  Messages: Messages2 = Messages,
2331
2321
  RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
2332
2322
  RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
@@ -2349,7 +2339,13 @@ function CopilotChat({
2349
2339
  sendMessage,
2350
2340
  stopGeneration,
2351
2341
  reloadMessages
2352
- } = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);
2342
+ } = useCopilotChatLogic(
2343
+ makeSystemMessage,
2344
+ onInProgress,
2345
+ onSubmitMessage,
2346
+ onStopGeneration,
2347
+ onReloadMessages
2348
+ );
2353
2349
  const chatContext = import_react12.default.useContext(ChatContext);
2354
2350
  const isVisible = chatContext ? chatContext.open : true;
2355
2351
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
@@ -2405,8 +2401,16 @@ function WrappedCopilotChat({
2405
2401
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children });
2406
2402
  }
2407
2403
  var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
2408
- var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
2409
- const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = (0, import_react_core8.useCopilotChat)({
2404
+ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
2405
+ var _a;
2406
+ const {
2407
+ visibleMessages,
2408
+ appendMessage,
2409
+ reloadMessages: defaultReloadMessages,
2410
+ stopGeneration: defaultStopGeneration,
2411
+ runChatCompletion,
2412
+ isLoading
2413
+ } = (0, import_react_core8.useCopilotChat)({
2410
2414
  id: (0, import_shared3.randomId)(),
2411
2415
  makeSystemMessage
2412
2416
  });
@@ -2414,8 +2418,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
2414
2418
  const suggestionsAbortControllerRef = (0, import_react12.useRef)(null);
2415
2419
  const debounceTimerRef = (0, import_react12.useRef)();
2416
2420
  const abortSuggestions = () => {
2417
- var _a;
2418
- (_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
2421
+ var _a2;
2422
+ (_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
2419
2423
  suggestionsAbortControllerRef.current = null;
2420
2424
  };
2421
2425
  const generalContext = (0, import_react_core8.useCopilotContext)();
@@ -2441,7 +2445,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
2441
2445
  return () => {
2442
2446
  clearTimeout(debounceTimerRef.current);
2443
2447
  };
2444
- }, [isLoading, context.chatSuggestionConfiguration]);
2448
+ }, [
2449
+ isLoading,
2450
+ context.chatSuggestionConfiguration,
2451
+ // hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
2452
+ // global context
2453
+ visibleMessages.length == 0
2454
+ ]);
2445
2455
  const sendMessage = (messageContent) => __async(void 0, null, function* () {
2446
2456
  abortSuggestions();
2447
2457
  setCurrentSuggestions([]);
@@ -2459,6 +2469,85 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
2459
2469
  appendMessage(message);
2460
2470
  return message;
2461
2471
  });
2472
+ const messages = visibleMessages;
2473
+ const { setMessages } = messagesContext;
2474
+ const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
2475
+ const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
2476
+ if (generalContext.agentSession) {
2477
+ generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
2478
+ nodeName: void 0,
2479
+ threadId: void 0
2480
+ }));
2481
+ generalContext.setCoagentStates((prevAgentStates) => {
2482
+ return __spreadProps(__spreadValues({}, prevAgentStates), {
2483
+ [generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
2484
+ threadId: void 0,
2485
+ nodeName: void 0,
2486
+ runId: void 0
2487
+ })
2488
+ });
2489
+ });
2490
+ }
2491
+ });
2492
+ const runCurrentAgent = (hint) => __async(void 0, null, function* () {
2493
+ if (generalContext.agentSession) {
2494
+ yield (0, import_react_core9.runAgent)(
2495
+ generalContext.agentSession.agentName,
2496
+ context,
2497
+ appendMessage,
2498
+ runChatCompletion,
2499
+ hint
2500
+ );
2501
+ }
2502
+ });
2503
+ const stopCurrentAgent = () => {
2504
+ if (generalContext.agentSession) {
2505
+ (0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
2506
+ }
2507
+ };
2508
+ const setCurrentAgentState = (state) => {
2509
+ if (generalContext.agentSession) {
2510
+ generalContext.setCoagentStates((prevAgentStates) => {
2511
+ return __spreadProps(__spreadValues({}, prevAgentStates), {
2512
+ [generalContext.agentSession.agentName]: {
2513
+ state
2514
+ }
2515
+ });
2516
+ });
2517
+ }
2518
+ };
2519
+ function stopGeneration() {
2520
+ if (onStopGeneration) {
2521
+ onStopGeneration({
2522
+ messages,
2523
+ setMessages,
2524
+ stopGeneration: defaultStopGeneration,
2525
+ currentAgentName,
2526
+ restartCurrentAgent,
2527
+ stopCurrentAgent,
2528
+ runCurrentAgent,
2529
+ setCurrentAgentState
2530
+ });
2531
+ } else {
2532
+ defaultStopGeneration();
2533
+ }
2534
+ }
2535
+ function reloadMessages() {
2536
+ if (onReloadMessages) {
2537
+ onReloadMessages({
2538
+ messages,
2539
+ setMessages,
2540
+ stopGeneration: defaultStopGeneration,
2541
+ currentAgentName,
2542
+ restartCurrentAgent,
2543
+ stopCurrentAgent,
2544
+ runCurrentAgent,
2545
+ setCurrentAgentState
2546
+ });
2547
+ } else {
2548
+ defaultReloadMessages();
2549
+ }
2550
+ }
2462
2551
  return {
2463
2552
  visibleMessages,
2464
2553
  isLoading,
@@ -2478,6 +2567,8 @@ var CopilotModal = ({
2478
2567
  hitEscapeToClose = true,
2479
2568
  onSetOpen,
2480
2569
  onSubmitMessage,
2570
+ onStopGeneration,
2571
+ onReloadMessages,
2481
2572
  shortcut = "/",
2482
2573
  icons,
2483
2574
  labels,
@@ -2515,6 +2606,8 @@ var CopilotModal = ({
2515
2606
  {
2516
2607
  instructions,
2517
2608
  onSubmitMessage,
2609
+ onStopGeneration,
2610
+ onReloadMessages,
2518
2611
  makeSystemMessage,
2519
2612
  showResponseButton,
2520
2613
  onInProgress,