@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
  CopilotSidebar
3
- } from "../../chunk-ZQFKJLQ6.mjs";
4
- import "../../chunk-E5SSVET3.mjs";
3
+ } from "../../chunk-WSMMTZCM.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";
@@ -946,9 +946,9 @@ var import_react7 = require("react");
946
946
  var import_react_syntax_highlighter = require("react-syntax-highlighter");
947
947
 
948
948
  // src/hooks/use-copy-to-clipboard.tsx
949
- var React6 = __toESM(require("react"));
949
+ var React5 = __toESM(require("react"));
950
950
  function useCopyToClipboard({ timeout = 2e3 }) {
951
- const [isCopied, setIsCopied] = React6.useState(false);
951
+ const [isCopied, setIsCopied] = React5.useState(false);
952
952
  const copyToClipboard = (value) => {
953
953
  var _a;
954
954
  if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
@@ -1444,8 +1444,8 @@ function RenderActionExecutionMessage(props) {
1444
1444
  const { chatComponentsCache } = (0, import_react_core3.useCopilotContext)();
1445
1445
  const { icons } = useChatContext();
1446
1446
  if (message.isActionExecutionMessage()) {
1447
- if (chatComponentsCache.current !== null && chatComponentsCache.current.actions[message.name]) {
1448
- const render = chatComponentsCache.current.actions[message.name];
1447
+ if (chatComponentsCache.current !== null && (chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"])) {
1448
+ const render = chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"];
1449
1449
  if (typeof render === "string") {
1450
1450
  if (isCurrentMessage && inProgress) {
1451
1451
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: [
@@ -1468,7 +1468,8 @@ function RenderActionExecutionMessage(props) {
1468
1468
  const toRender = render({
1469
1469
  status,
1470
1470
  args,
1471
- result: actionResult
1471
+ result: actionResult,
1472
+ name: message.name
1472
1473
  });
1473
1474
  if (!toRender && status === "complete") {
1474
1475
  return null;
@@ -1782,7 +1783,7 @@ function logMessages(context) {
1782
1783
  type: "ActionExecutionMessage",
1783
1784
  role: void 0,
1784
1785
  name: message.name,
1785
- scope: message.scope,
1786
+ scope: message.parentMessageId,
1786
1787
  content: message.arguments
1787
1788
  };
1788
1789
  } else if (message.isResultMessage()) {
@@ -1905,30 +1906,6 @@ var import_react9 = require("react");
1905
1906
 
1906
1907
  // src/components/help-modal/icons.tsx
1907
1908
  var import_jsx_runtime18 = require("react/jsx-runtime");
1908
- var LifeBuoyIcon = () => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1909
- "svg",
1910
- {
1911
- xmlns: "http://www.w3.org/2000/svg",
1912
- width: "24",
1913
- height: "24",
1914
- viewBox: "0 0 24 24",
1915
- fill: "none",
1916
- stroke: "currentColor",
1917
- strokeWidth: "2",
1918
- strokeLinecap: "round",
1919
- strokeLinejoin: "round",
1920
- className: "icon icon-tabler icons-tabler-outline icon-tabler-lifebuoy",
1921
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("g", { transform: "translate(0, -1)", children: [
1922
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
1923
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M12 12m-4 0a4 4 0 1 0 8 0a4 4 0 1 0 -8 0" }),
1924
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" }),
1925
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M15 15l3.35 3.35" }),
1926
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M9 15l-3.35 3.35" }),
1927
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M5.65 5.65l3.35 3.35" }),
1928
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M18.35 5.65l-3.35 3.35" })
1929
- ] })
1930
- }
1931
- );
1932
1909
  var CloseIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1933
1910
  "svg",
1934
1911
  {
@@ -2019,9 +1996,10 @@ function CopilotKitHelpModal() {
2019
1996
  "button",
2020
1997
  {
2021
1998
  onClick: () => setShowHelpModal(true),
2022
- 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",
1999
+ style: { width: "50px", height: "30px", marginRight: "0.25rem" },
2000
+ className: "text-sm p-0 bg-transparent rounded border border-blue-500",
2023
2001
  "aria-label": "Open Help",
2024
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LifeBuoyIcon, {})
2002
+ children: "Help"
2025
2003
  }
2026
2004
  );
2027
2005
  const submitButtonDisabled = (0, import_react9.useMemo)(
@@ -2048,6 +2026,15 @@ function CopilotKitHelpModal() {
2048
2026
  ),
2049
2027
  /* @__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" }) }),
2050
2028
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "space-y-4 mb-4", children: [
2029
+ /* @__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)(
2030
+ "a",
2031
+ {
2032
+ href: "https://docs.copilotkit.ai/coagents/troubleshooting/common-issues",
2033
+ target: "_blank",
2034
+ rel: "noopener noreferrer",
2035
+ children: "Visit the Troubleshooting and FAQ section in the docs"
2036
+ }
2037
+ ) }),
2051
2038
  /* @__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)(
2052
2039
  "a",
2053
2040
  {
@@ -2322,6 +2309,7 @@ function DebugMenuButton({
2322
2309
  }
2323
2310
 
2324
2311
  // src/components/chat/Chat.tsx
2312
+ var import_react_core9 = require("@copilotkit/react-core");
2325
2313
  var import_jsx_runtime21 = require("react/jsx-runtime");
2326
2314
  function CopilotChat({
2327
2315
  instructions,
@@ -2329,6 +2317,8 @@ function CopilotChat({
2329
2317
  makeSystemMessage,
2330
2318
  showResponseButton = true,
2331
2319
  onInProgress,
2320
+ onStopGeneration,
2321
+ onReloadMessages,
2332
2322
  Messages: Messages2 = Messages,
2333
2323
  RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
2334
2324
  RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
@@ -2351,7 +2341,13 @@ function CopilotChat({
2351
2341
  sendMessage,
2352
2342
  stopGeneration,
2353
2343
  reloadMessages
2354
- } = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);
2344
+ } = useCopilotChatLogic(
2345
+ makeSystemMessage,
2346
+ onInProgress,
2347
+ onSubmitMessage,
2348
+ onStopGeneration,
2349
+ onReloadMessages
2350
+ );
2355
2351
  const chatContext = import_react12.default.useContext(ChatContext);
2356
2352
  const isVisible = chatContext ? chatContext.open : true;
2357
2353
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
@@ -2407,8 +2403,16 @@ function WrappedCopilotChat({
2407
2403
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children });
2408
2404
  }
2409
2405
  var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
2410
- var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
2411
- const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = (0, import_react_core8.useCopilotChat)({
2406
+ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
2407
+ var _a;
2408
+ const {
2409
+ visibleMessages,
2410
+ appendMessage,
2411
+ reloadMessages: defaultReloadMessages,
2412
+ stopGeneration: defaultStopGeneration,
2413
+ runChatCompletion,
2414
+ isLoading
2415
+ } = (0, import_react_core8.useCopilotChat)({
2412
2416
  id: (0, import_shared3.randomId)(),
2413
2417
  makeSystemMessage
2414
2418
  });
@@ -2416,8 +2420,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
2416
2420
  const suggestionsAbortControllerRef = (0, import_react12.useRef)(null);
2417
2421
  const debounceTimerRef = (0, import_react12.useRef)();
2418
2422
  const abortSuggestions = () => {
2419
- var _a;
2420
- (_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
2423
+ var _a2;
2424
+ (_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
2421
2425
  suggestionsAbortControllerRef.current = null;
2422
2426
  };
2423
2427
  const generalContext = (0, import_react_core8.useCopilotContext)();
@@ -2443,7 +2447,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
2443
2447
  return () => {
2444
2448
  clearTimeout(debounceTimerRef.current);
2445
2449
  };
2446
- }, [isLoading, context.chatSuggestionConfiguration]);
2450
+ }, [
2451
+ isLoading,
2452
+ context.chatSuggestionConfiguration,
2453
+ // hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
2454
+ // global context
2455
+ visibleMessages.length == 0
2456
+ ]);
2447
2457
  const sendMessage = (messageContent) => __async(void 0, null, function* () {
2448
2458
  abortSuggestions();
2449
2459
  setCurrentSuggestions([]);
@@ -2461,6 +2471,85 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
2461
2471
  appendMessage(message);
2462
2472
  return message;
2463
2473
  });
2474
+ const messages = visibleMessages;
2475
+ const { setMessages } = messagesContext;
2476
+ const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
2477
+ const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
2478
+ if (generalContext.agentSession) {
2479
+ generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
2480
+ nodeName: void 0,
2481
+ threadId: void 0
2482
+ }));
2483
+ generalContext.setCoagentStates((prevAgentStates) => {
2484
+ return __spreadProps(__spreadValues({}, prevAgentStates), {
2485
+ [generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
2486
+ threadId: void 0,
2487
+ nodeName: void 0,
2488
+ runId: void 0
2489
+ })
2490
+ });
2491
+ });
2492
+ }
2493
+ });
2494
+ const runCurrentAgent = (hint) => __async(void 0, null, function* () {
2495
+ if (generalContext.agentSession) {
2496
+ yield (0, import_react_core9.runAgent)(
2497
+ generalContext.agentSession.agentName,
2498
+ context,
2499
+ appendMessage,
2500
+ runChatCompletion,
2501
+ hint
2502
+ );
2503
+ }
2504
+ });
2505
+ const stopCurrentAgent = () => {
2506
+ if (generalContext.agentSession) {
2507
+ (0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
2508
+ }
2509
+ };
2510
+ const setCurrentAgentState = (state) => {
2511
+ if (generalContext.agentSession) {
2512
+ generalContext.setCoagentStates((prevAgentStates) => {
2513
+ return __spreadProps(__spreadValues({}, prevAgentStates), {
2514
+ [generalContext.agentSession.agentName]: {
2515
+ state
2516
+ }
2517
+ });
2518
+ });
2519
+ }
2520
+ };
2521
+ function stopGeneration() {
2522
+ if (onStopGeneration) {
2523
+ onStopGeneration({
2524
+ messages,
2525
+ setMessages,
2526
+ stopGeneration: defaultStopGeneration,
2527
+ currentAgentName,
2528
+ restartCurrentAgent,
2529
+ stopCurrentAgent,
2530
+ runCurrentAgent,
2531
+ setCurrentAgentState
2532
+ });
2533
+ } else {
2534
+ defaultStopGeneration();
2535
+ }
2536
+ }
2537
+ function reloadMessages() {
2538
+ if (onReloadMessages) {
2539
+ onReloadMessages({
2540
+ messages,
2541
+ setMessages,
2542
+ stopGeneration: defaultStopGeneration,
2543
+ currentAgentName,
2544
+ restartCurrentAgent,
2545
+ stopCurrentAgent,
2546
+ runCurrentAgent,
2547
+ setCurrentAgentState
2548
+ });
2549
+ } else {
2550
+ defaultReloadMessages();
2551
+ }
2552
+ }
2464
2553
  return {
2465
2554
  visibleMessages,
2466
2555
  isLoading,
@@ -2480,6 +2569,8 @@ var CopilotModal = ({
2480
2569
  hitEscapeToClose = true,
2481
2570
  onSetOpen,
2482
2571
  onSubmitMessage,
2572
+ onStopGeneration,
2573
+ onReloadMessages,
2483
2574
  shortcut = "/",
2484
2575
  icons,
2485
2576
  labels,
@@ -2517,6 +2608,8 @@ var CopilotModal = ({
2517
2608
  {
2518
2609
  instructions,
2519
2610
  onSubmitMessage,
2611
+ onStopGeneration,
2612
+ onReloadMessages,
2520
2613
  makeSystemMessage,
2521
2614
  showResponseButton,
2522
2615
  onInProgress,