@copilotkit/react-core 1.9.2-next.10 → 1.9.2-next.3

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 (168) hide show
  1. package/CHANGELOG.md +0 -56
  2. package/dist/{chunk-3YHYWAHK.mjs → chunk-2FW7HH6W.mjs} +3 -3
  3. package/dist/{chunk-OF4SZTLL.mjs → chunk-2XSUXRGG.mjs} +4 -4
  4. package/dist/{chunk-WOGURSAL.mjs → chunk-3XXVDQ7Z.mjs} +8 -10
  5. package/dist/chunk-3XXVDQ7Z.mjs.map +1 -0
  6. package/dist/{chunk-XFOTNHYA.mjs → chunk-6KGEF242.mjs} +2 -3
  7. package/dist/chunk-6KGEF242.mjs.map +1 -0
  8. package/dist/{chunk-EXU7GWLC.mjs → chunk-C3SYYVMR.mjs} +5 -5
  9. package/dist/{chunk-JPMIAGI6.mjs → chunk-C6F6EQNA.mjs} +2 -2
  10. package/dist/{chunk-3OQM3NEK.mjs → chunk-CCESTGAM.mjs} +2 -2
  11. package/dist/chunk-HD2GE3DK.mjs +359 -0
  12. package/dist/chunk-HD2GE3DK.mjs.map +1 -0
  13. package/dist/{chunk-G7LYGERN.mjs → chunk-HJP2RX5R.mjs} +14 -81
  14. package/dist/chunk-HJP2RX5R.mjs.map +1 -0
  15. package/dist/{chunk-ADIITPD2.mjs → chunk-IVXB3GYK.mjs} +6 -9
  16. package/dist/{chunk-ADIITPD2.mjs.map → chunk-IVXB3GYK.mjs.map} +1 -1
  17. package/dist/{chunk-EF5BNM34.mjs → chunk-LDACFA2B.mjs} +3 -3
  18. package/dist/{chunk-UBNRUXEK.mjs → chunk-LZDDYZEY.mjs} +2 -2
  19. package/dist/{chunk-FXK6RQIN.mjs → chunk-PUNALT2S.mjs} +2 -2
  20. package/dist/{chunk-CMQV4XNY.mjs → chunk-Q5D5XQFA.mjs} +2 -2
  21. package/dist/{chunk-SJJNFYGQ.mjs → chunk-QQZLIEXK.mjs} +3 -3
  22. package/dist/{chunk-JDEWNLNP.mjs → chunk-QRGDQSGZ.mjs} +5 -38
  23. package/dist/chunk-QRGDQSGZ.mjs.map +1 -0
  24. package/dist/{chunk-55QZ2SVJ.mjs → chunk-RUY6MLHA.mjs} +6 -36
  25. package/dist/chunk-RUY6MLHA.mjs.map +1 -0
  26. package/dist/{chunk-NQVCZQ5T.mjs → chunk-T42PN5VN.mjs} +4 -4
  27. package/dist/{chunk-ERXWDCY6.mjs → chunk-UHQMV2CE.mjs} +2 -2
  28. package/dist/chunk-VRXANACV.mjs +277 -0
  29. package/dist/chunk-VRXANACV.mjs.map +1 -0
  30. package/dist/components/copilot-provider/copilot-messages.js +3 -37
  31. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  32. package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
  33. package/dist/components/copilot-provider/copilotkit-props.d.ts +2 -21
  34. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  35. package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
  36. package/dist/components/copilot-provider/copilotkit.js +238 -326
  37. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  38. package/dist/components/copilot-provider/copilotkit.mjs +8 -8
  39. package/dist/components/copilot-provider/index.d.ts +1 -1
  40. package/dist/components/copilot-provider/index.js +238 -326
  41. package/dist/components/copilot-provider/index.js.map +1 -1
  42. package/dist/components/copilot-provider/index.mjs +8 -8
  43. package/dist/components/error-boundary/error-boundary.js +146 -135
  44. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  45. package/dist/components/error-boundary/error-boundary.mjs +4 -4
  46. package/dist/components/error-boundary/error-utils.js.map +1 -1
  47. package/dist/components/error-boundary/error-utils.mjs +2 -2
  48. package/dist/components/index.d.ts +1 -1
  49. package/dist/components/index.js +238 -326
  50. package/dist/components/index.js.map +1 -1
  51. package/dist/components/index.mjs +8 -8
  52. package/dist/components/toast/toast-provider.js +85 -118
  53. package/dist/components/toast/toast-provider.js.map +1 -1
  54. package/dist/components/toast/toast-provider.mjs +1 -1
  55. package/dist/components/usage-banner.js +146 -135
  56. package/dist/components/usage-banner.js.map +1 -1
  57. package/dist/components/usage-banner.mjs +1 -1
  58. package/dist/context/copilot-context.d.ts +1 -1
  59. package/dist/context/copilot-context.js +1 -2
  60. package/dist/context/copilot-context.js.map +1 -1
  61. package/dist/context/copilot-context.mjs +1 -1
  62. package/dist/context/index.d.ts +1 -1
  63. package/dist/context/index.js +1 -2
  64. package/dist/context/index.js.map +1 -1
  65. package/dist/context/index.mjs +1 -1
  66. package/dist/{copilot-context-3da805ab.d.ts → copilot-context-f9b2b4c3.d.ts} +1 -5
  67. package/dist/hooks/index.d.ts +1 -1
  68. package/dist/hooks/index.js +12 -108
  69. package/dist/hooks/index.js.map +1 -1
  70. package/dist/hooks/index.mjs +19 -19
  71. package/dist/hooks/use-chat.d.ts +1 -1
  72. package/dist/hooks/use-chat.js +12 -105
  73. package/dist/hooks/use-chat.js.map +1 -1
  74. package/dist/hooks/use-chat.mjs +5 -5
  75. package/dist/hooks/use-coagent-state-render.js +1 -2
  76. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  77. package/dist/hooks/use-coagent-state-render.mjs +3 -3
  78. package/dist/hooks/use-coagent.d.ts +1 -1
  79. package/dist/hooks/use-coagent.js +12 -108
  80. package/dist/hooks/use-coagent.js.map +1 -1
  81. package/dist/hooks/use-coagent.mjs +11 -11
  82. package/dist/hooks/use-copilot-action.js +1 -2
  83. package/dist/hooks/use-copilot-action.js.map +1 -1
  84. package/dist/hooks/use-copilot-action.mjs +4 -4
  85. package/dist/hooks/use-copilot-additional-instructions.js +1 -2
  86. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  87. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  88. package/dist/hooks/use-copilot-authenticated-action.js +1 -2
  89. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  90. package/dist/hooks/use-copilot-authenticated-action.mjs +5 -5
  91. package/dist/hooks/use-copilot-chat.d.ts +1 -1
  92. package/dist/hooks/use-copilot-chat.js +12 -105
  93. package/dist/hooks/use-copilot-chat.js.map +1 -1
  94. package/dist/hooks/use-copilot-chat.mjs +10 -10
  95. package/dist/hooks/use-copilot-readable.js +1 -2
  96. package/dist/hooks/use-copilot-readable.js.map +1 -1
  97. package/dist/hooks/use-copilot-readable.mjs +2 -2
  98. package/dist/hooks/use-copilot-runtime-client.d.ts +0 -2
  99. package/dist/hooks/use-copilot-runtime-client.js +2 -52
  100. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  101. package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
  102. package/dist/hooks/use-langgraph-interrupt-render.js +1 -2
  103. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  104. package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
  105. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  106. package/dist/hooks/use-langgraph-interrupt.js +12 -105
  107. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  108. package/dist/hooks/use-langgraph-interrupt.mjs +11 -11
  109. package/dist/hooks/use-make-copilot-document-readable.js +1 -2
  110. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  111. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  112. package/dist/index.d.ts +1 -1
  113. package/dist/index.js +247 -400
  114. package/dist/index.js.map +1 -1
  115. package/dist/index.mjs +20 -20
  116. package/dist/lib/copilot-task.d.ts +1 -1
  117. package/dist/lib/copilot-task.js.map +1 -1
  118. package/dist/lib/copilot-task.mjs +9 -9
  119. package/dist/lib/index.d.ts +1 -1
  120. package/dist/lib/index.js.map +1 -1
  121. package/dist/lib/index.mjs +9 -9
  122. package/dist/types/interrupt-action.d.ts +1 -1
  123. package/dist/utils/extract.d.ts +1 -1
  124. package/dist/utils/extract.js.map +1 -1
  125. package/dist/utils/extract.mjs +8 -8
  126. package/dist/utils/index.d.ts +1 -1
  127. package/dist/utils/index.js.map +1 -1
  128. package/dist/utils/index.mjs +8 -8
  129. package/dist/utils/utils.test.d.ts +2 -0
  130. package/dist/utils/utils.test.js +9 -0
  131. package/dist/utils/utils.test.js.map +1 -0
  132. package/dist/utils/utils.test.mjs +7 -0
  133. package/dist/utils/utils.test.mjs.map +1 -0
  134. package/jest.config.js +3 -7
  135. package/package.json +3 -4
  136. package/src/components/copilot-provider/copilot-messages.tsx +3 -42
  137. package/src/components/copilot-provider/copilotkit-props.tsx +0 -21
  138. package/src/components/copilot-provider/copilotkit.tsx +0 -2
  139. package/src/components/toast/toast-provider.tsx +24 -49
  140. package/src/components/usage-banner.tsx +147 -144
  141. package/src/context/copilot-context.tsx +1 -7
  142. package/src/hooks/use-chat.ts +6 -106
  143. package/src/hooks/use-coagent.ts +0 -5
  144. package/src/hooks/use-copilot-runtime-client.ts +39 -41
  145. package/tsconfig.json +8 -1
  146. package/tsup.config.ts +6 -6
  147. package/dist/chunk-55QZ2SVJ.mjs.map +0 -1
  148. package/dist/chunk-57K2ZJ5F.mjs +0 -348
  149. package/dist/chunk-57K2ZJ5F.mjs.map +0 -1
  150. package/dist/chunk-G7LYGERN.mjs.map +0 -1
  151. package/dist/chunk-JDEWNLNP.mjs.map +0 -1
  152. package/dist/chunk-WOGURSAL.mjs.map +0 -1
  153. package/dist/chunk-XFOTNHYA.mjs.map +0 -1
  154. package/dist/chunk-YAF2LATQ.mjs +0 -310
  155. package/dist/chunk-YAF2LATQ.mjs.map +0 -1
  156. package/src/components/copilot-provider/__tests__/copilotkit-trace.test.tsx +0 -75
  157. /package/dist/{chunk-3YHYWAHK.mjs.map → chunk-2FW7HH6W.mjs.map} +0 -0
  158. /package/dist/{chunk-OF4SZTLL.mjs.map → chunk-2XSUXRGG.mjs.map} +0 -0
  159. /package/dist/{chunk-EXU7GWLC.mjs.map → chunk-C3SYYVMR.mjs.map} +0 -0
  160. /package/dist/{chunk-JPMIAGI6.mjs.map → chunk-C6F6EQNA.mjs.map} +0 -0
  161. /package/dist/{chunk-3OQM3NEK.mjs.map → chunk-CCESTGAM.mjs.map} +0 -0
  162. /package/dist/{chunk-EF5BNM34.mjs.map → chunk-LDACFA2B.mjs.map} +0 -0
  163. /package/dist/{chunk-UBNRUXEK.mjs.map → chunk-LZDDYZEY.mjs.map} +0 -0
  164. /package/dist/{chunk-FXK6RQIN.mjs.map → chunk-PUNALT2S.mjs.map} +0 -0
  165. /package/dist/{chunk-CMQV4XNY.mjs.map → chunk-Q5D5XQFA.mjs.map} +0 -0
  166. /package/dist/{chunk-SJJNFYGQ.mjs.map → chunk-QQZLIEXK.mjs.map} +0 -0
  167. /package/dist/{chunk-NQVCZQ5T.mjs.map → chunk-T42PN5VN.mjs.map} +0 -0
  168. /package/dist/{chunk-ERXWDCY6.mjs.map → chunk-UHQMV2CE.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -183,8 +183,7 @@ var emptyCopilotContext = {
183
183
  },
184
184
  langGraphInterruptAction: null,
185
185
  setLangGraphInterruptAction: () => null,
186
- removeLangGraphInterruptAction: () => null,
187
- onTrace: void 0
186
+ removeLangGraphInterruptAction: () => null
188
187
  };
189
188
  var CopilotContext = import_react.default.createContext(emptyCopilotContext);
190
189
  function useCopilotContext() {
@@ -548,14 +547,12 @@ function ToastProvider({
548
547
  border: `1px solid ${colors.border}`,
549
548
  borderLeft: `4px solid ${colors.border}`,
550
549
  borderRadius: "8px",
551
- padding: "12px 16px",
550
+ padding: "10px 14px",
552
551
  fontSize: "13px",
553
552
  boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
554
553
  backdropFilter: "blur(8px)",
555
- maxWidth: "min(90vw, 700px)",
556
- width: "100%",
557
- boxSizing: "border-box",
558
- overflow: "hidden"
554
+ maxWidth: "500px",
555
+ minWidth: "350px"
559
556
  },
560
557
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
561
558
  "div",
@@ -567,125 +564,94 @@ function ToastProvider({
567
564
  gap: "10px"
568
565
  },
569
566
  children: [
570
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
571
- "div",
572
- {
573
- style: {
574
- display: "flex",
575
- alignItems: "center",
576
- gap: "8px",
577
- flex: 1,
578
- minWidth: 0
579
- },
580
- children: [
581
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
582
- "div",
583
- {
584
- style: {
585
- width: "12px",
586
- height: "12px",
587
- borderRadius: "50%",
588
- backgroundColor: colors.border,
589
- flexShrink: 0
567
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", flex: 1 }, children: [
568
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
569
+ "div",
570
+ {
571
+ style: {
572
+ width: "12px",
573
+ height: "12px",
574
+ borderRadius: "50%",
575
+ backgroundColor: colors.border,
576
+ flexShrink: 0
577
+ }
578
+ }
579
+ ),
580
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px", flex: 1 }, children: [
581
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
582
+ "div",
583
+ {
584
+ style: {
585
+ color: colors.text,
586
+ lineHeight: "1.4",
587
+ fontWeight: "400",
588
+ fontSize: "13px",
589
+ flex: 1,
590
+ wordWrap: "break-word",
591
+ overflowWrap: "break-word",
592
+ hyphens: "auto"
593
+ },
594
+ children: (() => {
595
+ const message = bannerError.message;
596
+ const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
597
+ const plainUrlRegex = /(https?:\/\/[^\s)]+)/g;
598
+ let cleanMessage = message.replace(markdownLinkRegex, "").replace(plainUrlRegex, "").replace(/See more:\s*/g, "").replace(/\s+/g, " ").trim();
599
+ if (cleanMessage.length > 120) {
600
+ cleanMessage = cleanMessage.substring(0, 117) + "...";
590
601
  }
602
+ return cleanMessage;
603
+ })()
604
+ }
605
+ ),
606
+ (() => {
607
+ const message = bannerError.message;
608
+ const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
609
+ const plainUrlRegex = /(https?:\/\/[^\s)]+)/g;
610
+ let url = null;
611
+ let buttonText = "See More";
612
+ const markdownMatch = markdownLinkRegex.exec(message);
613
+ if (markdownMatch) {
614
+ url = markdownMatch[2];
615
+ buttonText = "See More";
616
+ } else {
617
+ const urlMatch = plainUrlRegex.exec(message);
618
+ if (urlMatch) {
619
+ url = urlMatch[0];
620
+ buttonText = "See More";
591
621
  }
592
- ),
593
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
594
- "div",
622
+ }
623
+ if (!url)
624
+ return null;
625
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
626
+ "button",
595
627
  {
628
+ onClick: () => window.open(url, "_blank", "noopener,noreferrer"),
596
629
  style: {
597
- display: "flex",
598
- alignItems: "center",
599
- gap: "10px",
600
- flex: 1,
601
- minWidth: 0
630
+ background: colors.border,
631
+ color: "white",
632
+ border: "none",
633
+ borderRadius: "5px",
634
+ padding: "4px 10px",
635
+ fontSize: "11px",
636
+ fontWeight: "500",
637
+ cursor: "pointer",
638
+ transition: "all 0.2s ease",
639
+ flexShrink: 0
640
+ },
641
+ onMouseEnter: (e) => {
642
+ e.currentTarget.style.opacity = "0.9";
643
+ e.currentTarget.style.transform = "translateY(-1px)";
602
644
  },
603
- children: [
604
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
605
- "div",
606
- {
607
- style: {
608
- color: colors.text,
609
- lineHeight: "1.4",
610
- fontWeight: "400",
611
- fontSize: "13px",
612
- flex: 1,
613
- wordBreak: "break-all",
614
- overflowWrap: "break-word",
615
- maxWidth: "550px",
616
- overflow: "hidden",
617
- display: "-webkit-box",
618
- WebkitLineClamp: 10,
619
- WebkitBoxOrient: "vertical"
620
- },
621
- children: (() => {
622
- let message = bannerError.message;
623
- const jsonMatch = message.match(/'message':\s*'([^']+)'/);
624
- if (jsonMatch) {
625
- return jsonMatch[1];
626
- }
627
- message = message.split(" - ")[0];
628
- message = message.split(": Error code")[0];
629
- message = message.replace(/:\s*\d{3}$/, "");
630
- message = message.replace(/See more:.*$/g, "");
631
- message = message.trim();
632
- return message || "Configuration error occurred.";
633
- })()
634
- }
635
- ),
636
- (() => {
637
- const message = bannerError.message;
638
- const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
639
- const plainUrlRegex = /(https?:\/\/[^\s)]+)/g;
640
- let url = null;
641
- let buttonText = "See More";
642
- const markdownMatch = markdownLinkRegex.exec(message);
643
- if (markdownMatch) {
644
- url = markdownMatch[2];
645
- buttonText = "See More";
646
- } else {
647
- const urlMatch = plainUrlRegex.exec(message);
648
- if (urlMatch) {
649
- url = urlMatch[0].replace(/[.,;:'"]*$/, "");
650
- buttonText = "See More";
651
- }
652
- }
653
- if (!url)
654
- return null;
655
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
656
- "button",
657
- {
658
- onClick: () => window.open(url, "_blank", "noopener,noreferrer"),
659
- style: {
660
- background: colors.border,
661
- color: "white",
662
- border: "none",
663
- borderRadius: "5px",
664
- padding: "4px 10px",
665
- fontSize: "11px",
666
- fontWeight: "500",
667
- cursor: "pointer",
668
- transition: "all 0.2s ease",
669
- flexShrink: 0
670
- },
671
- onMouseEnter: (e) => {
672
- e.currentTarget.style.opacity = "0.9";
673
- e.currentTarget.style.transform = "translateY(-1px)";
674
- },
675
- onMouseLeave: (e) => {
676
- e.currentTarget.style.opacity = "1";
677
- e.currentTarget.style.transform = "translateY(0)";
678
- },
679
- children: buttonText
680
- }
681
- );
682
- })()
683
- ]
645
+ onMouseLeave: (e) => {
646
+ e.currentTarget.style.opacity = "1";
647
+ e.currentTarget.style.transform = "translateY(0)";
648
+ },
649
+ children: buttonText
684
650
  }
685
- )
686
- ]
687
- }
688
- ),
651
+ );
652
+ })()
653
+ ] })
654
+ ] }),
689
655
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
690
656
  "button",
691
657
  {
@@ -738,38 +704,8 @@ function CopilotMessages({ children }) {
738
704
  const lastLoadedThreadId = (0, import_react6.useRef)();
739
705
  const lastLoadedAgentName = (0, import_react6.useRef)();
740
706
  const lastLoadedMessages = (0, import_react6.useRef)();
741
- const { threadId, agentSession, runtimeClient, showDevConsole, onTrace, copilotApiConfig } = useCopilotContext();
707
+ const { threadId, agentSession, runtimeClient, showDevConsole } = useCopilotContext();
742
708
  const { setBannerError } = useToast();
743
- const traceUIError = (0, import_react6.useCallback)(
744
- (error, originalError) => __async(this, null, function* () {
745
- if (!onTrace || !copilotApiConfig.publicApiKey)
746
- return;
747
- try {
748
- const traceEvent = {
749
- type: "error",
750
- timestamp: Date.now(),
751
- context: {
752
- source: "ui",
753
- request: {
754
- operation: "loadAgentState",
755
- url: copilotApiConfig.chatApiEndpoint,
756
- startTime: Date.now()
757
- },
758
- technical: {
759
- environment: "browser",
760
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
761
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
762
- }
763
- },
764
- error
765
- };
766
- yield onTrace(traceEvent);
767
- } catch (traceError) {
768
- console.error("Error in CopilotMessages onTrace handler:", traceError);
769
- }
770
- }),
771
- [onTrace, copilotApiConfig.publicApiKey, copilotApiConfig.chatApiEndpoint]
772
- );
773
709
  const createStructuredError2 = (gqlError) => {
774
710
  const extensions = gqlError.extensions;
775
711
  const originalError = extensions == null ? void 0 : extensions.originalError;
@@ -814,14 +750,12 @@ function CopilotMessages({ children }) {
814
750
  const ckError = createStructuredError2(gqlError);
815
751
  if (ckError) {
816
752
  setBannerError(ckError);
817
- traceUIError(ckError, gqlError);
818
753
  } else {
819
754
  const fallbackError = new import_shared4.CopilotKitError({
820
755
  message: gqlError.message,
821
756
  code: import_shared4.CopilotKitErrorCode.UNKNOWN
822
757
  });
823
758
  setBannerError(fallbackError);
824
- traceUIError(fallbackError, gqlError);
825
759
  }
826
760
  };
827
761
  graphQLErrors.forEach(routeError);
@@ -835,11 +769,10 @@ function CopilotMessages({ children }) {
835
769
  code: import_shared4.CopilotKitErrorCode.UNKNOWN
836
770
  });
837
771
  setBannerError(fallbackError);
838
- traceUIError(fallbackError, error);
839
772
  }
840
773
  }
841
774
  },
842
- [setBannerError, showDevConsole, traceUIError]
775
+ [setBannerError, showDevConsole]
843
776
  );
844
777
  (0, import_react6.useEffect)(() => {
845
778
  if (!threadId || threadId === lastLoadedThreadId.current)
@@ -893,35 +826,8 @@ var import_react7 = require("react");
893
826
  var import_shared5 = require("@copilotkit/shared");
894
827
  var useCopilotRuntimeClient = (options) => {
895
828
  const { setBannerError } = useToast();
896
- const _a = options, { showDevConsole, onTrace } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onTrace"]);
829
+ const _a = options, { showDevConsole } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
897
830
  const lastStructuredErrorRef = (0, import_react7.useRef)(null);
898
- const traceUIError = (error, originalError) => __async(void 0, null, function* () {
899
- if (!onTrace || !runtimeOptions.publicApiKey)
900
- return;
901
- try {
902
- const traceEvent = {
903
- type: "error",
904
- timestamp: Date.now(),
905
- context: {
906
- source: "ui",
907
- request: {
908
- operation: "runtimeClient",
909
- url: runtimeOptions.url,
910
- startTime: Date.now()
911
- },
912
- technical: {
913
- environment: "browser",
914
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
915
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
916
- }
917
- },
918
- error
919
- };
920
- yield onTrace(traceEvent);
921
- } catch (traceError) {
922
- console.error("Error in onTrace handler:", traceError);
923
- }
924
- });
925
831
  const runtimeClient = (0, import_react7.useMemo)(() => {
926
832
  return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
927
833
  handleGQLErrors: (error) => {
@@ -949,14 +855,12 @@ var useCopilotRuntimeClient = (options) => {
949
855
  const ckError = createStructuredError(gqlError);
950
856
  if (ckError) {
951
857
  setBannerError(ckError);
952
- traceUIError(ckError, gqlError);
953
858
  } else {
954
859
  const fallbackError = new import_shared5.CopilotKitError({
955
860
  message: gqlError.message,
956
861
  code: import_shared5.CopilotKitErrorCode.UNKNOWN
957
862
  });
958
863
  setBannerError(fallbackError);
959
- traceUIError(fallbackError, gqlError);
960
864
  }
961
865
  };
962
866
  graphQLErrors.forEach(routeError);
@@ -970,7 +874,6 @@ var useCopilotRuntimeClient = (options) => {
970
874
  code: import_shared5.CopilotKitErrorCode.UNKNOWN
971
875
  });
972
876
  setBannerError(fallbackError);
973
- traceUIError(fallbackError, error);
974
877
  }
975
878
  }
976
879
  },
@@ -983,7 +886,7 @@ var useCopilotRuntimeClient = (options) => {
983
886
  setBannerError(warningError);
984
887
  }
985
888
  }));
986
- }, [runtimeOptions, setBannerError, showDevConsole, onTrace]);
889
+ }, [runtimeOptions, setBannerError, showDevConsole]);
987
890
  return runtimeClient;
988
891
  };
989
892
  function createStructuredError(gqlError) {
@@ -1210,8 +1113,8 @@ var defaultIcons = {
1210
1113
  "svg",
1211
1114
  {
1212
1115
  viewBox: "0 0 24 24",
1213
- width: "16",
1214
- height: "16",
1116
+ width: "18",
1117
+ height: "18",
1215
1118
  stroke: "currentColor",
1216
1119
  strokeWidth: "2.5",
1217
1120
  fill: "none",
@@ -1228,8 +1131,8 @@ var defaultIcons = {
1228
1131
  "svg",
1229
1132
  {
1230
1133
  viewBox: "0 0 24 24",
1231
- width: "16",
1232
- height: "16",
1134
+ width: "18",
1135
+ height: "18",
1233
1136
  stroke: "currentColor",
1234
1137
  strokeWidth: "2.5",
1235
1138
  fill: "none",
@@ -1246,8 +1149,8 @@ var defaultIcons = {
1246
1149
  "svg",
1247
1150
  {
1248
1151
  viewBox: "0 0 24 24",
1249
- width: "16",
1250
- height: "16",
1152
+ width: "18",
1153
+ height: "18",
1251
1154
  stroke: "currentColor",
1252
1155
  strokeWidth: "2.5",
1253
1156
  fill: "none",
@@ -1272,33 +1175,19 @@ function UsageBanner({
1272
1175
  return null;
1273
1176
  }
1274
1177
  const parseMessage = (rawMessage) => {
1275
- if (rawMessage.toLowerCase().includes("authentication") || rawMessage.toLowerCase().includes("api key")) {
1276
- return "Authentication failed. Please check your API key.";
1277
- }
1278
- if (rawMessage.toLowerCase().includes("rate limit")) {
1279
- return "Rate limit exceeded. Please try again later.";
1280
- }
1281
- if (rawMessage.toLowerCase().includes("checkpointer")) {
1282
- return "Agent configuration error. Please check your setup.";
1283
- }
1284
- let cleanMessage2 = rawMessage;
1285
- cleanMessage2 = cleanMessage2.split(" - ")[0];
1286
- cleanMessage2 = cleanMessage2.split(": Error code")[0];
1287
- cleanMessage2 = cleanMessage2.split(": 401")[0];
1288
- cleanMessage2 = cleanMessage2.split(": 403")[0];
1289
- cleanMessage2 = cleanMessage2.split(": 404")[0];
1290
- cleanMessage2 = cleanMessage2.split(": 500")[0];
1291
- cleanMessage2 = cleanMessage2.replace(/See more:.*$/g, "").trim();
1292
- if (cleanMessage2.includes("{") || cleanMessage2.includes("'") || cleanMessage2.length > 60) {
1293
- return "Configuration error. Please check your setup.";
1178
+ const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
1179
+ const matches = Array.from(rawMessage.matchAll(linkRegex));
1180
+ if (matches.length > 0) {
1181
+ let cleanMessage2 = rawMessage.replace(/\.\s*See more:\s*\[([^\]]+)\]\(([^)]+)\)/g, ".").replace(/See more:\s*\[([^\]]+)\]\(([^)]+)\)/g, "").trim();
1182
+ return cleanMessage2;
1294
1183
  }
1295
- return cleanMessage2 || "An error occurred. Please check your configuration.";
1184
+ return rawMessage;
1296
1185
  };
1297
1186
  const cleanMessage = parseMessage(message);
1298
1187
  const Icon = icon || defaultIcons[severity];
1299
1188
  const themeConfigs = {
1300
1189
  [import_shared8.Severity.INFO]: {
1301
- bg: "rgba(239, 246, 255, 0.95)",
1190
+ bg: "linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%)",
1302
1191
  border: "#93c5fd",
1303
1192
  text: "#1e40af",
1304
1193
  icon: "#3b82f6",
@@ -1306,7 +1195,7 @@ function UsageBanner({
1306
1195
  primaryBtnHover: "#2563eb"
1307
1196
  },
1308
1197
  [import_shared8.Severity.WARNING]: {
1309
- bg: "rgba(255, 251, 235, 0.95)",
1198
+ bg: "linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%)",
1310
1199
  border: "#fbbf24",
1311
1200
  text: "#92400e",
1312
1201
  icon: "#f59e0b",
@@ -1314,7 +1203,7 @@ function UsageBanner({
1314
1203
  primaryBtnHover: "#d97706"
1315
1204
  },
1316
1205
  [import_shared8.Severity.CRITICAL]: {
1317
- bg: "rgba(254, 242, 242, 0.95)",
1206
+ bg: "linear-gradient(135deg, #fef2f2 0%, #fecaca 100%)",
1318
1207
  border: "#f87171",
1319
1208
  text: "#991b1b",
1320
1209
  icon: "#ef4444",
@@ -1328,26 +1217,24 @@ function UsageBanner({
1328
1217
  {
1329
1218
  style: {
1330
1219
  position: "fixed",
1331
- bottom: "24px",
1220
+ bottom: "20px",
1332
1221
  left: "50%",
1333
1222
  transform: "translateX(-50%)",
1334
- width: "400px",
1335
- maxWidth: "90vw",
1223
+ maxWidth: "min(95vw, 680px)",
1224
+ width: "100%",
1336
1225
  zIndex: 1e4,
1337
- animation: "bannerSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1)"
1226
+ animation: "bannerSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1)"
1338
1227
  },
1339
1228
  children: [
1340
1229
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
1341
1230
  @keyframes bannerSlideIn {
1342
1231
  from {
1343
1232
  opacity: 0;
1344
- transform: translateX(-50%) translateY(20px);
1345
- scale: 0.95;
1233
+ transform: translateX(-50%) translateY(10px);
1346
1234
  }
1347
1235
  to {
1348
1236
  opacity: 1;
1349
1237
  transform: translateX(-50%) translateY(0);
1350
- scale: 1;
1351
1238
  }
1352
1239
  }
1353
1240
  ` }),
@@ -1355,16 +1242,17 @@ function UsageBanner({
1355
1242
  "div",
1356
1243
  {
1357
1244
  style: {
1358
- borderRadius: "12px",
1245
+ display: "flex",
1246
+ alignItems: "flex-start",
1247
+ gap: "14px",
1248
+ borderRadius: "16px",
1359
1249
  border: `1px solid ${themeConfig.border}`,
1360
1250
  background: themeConfig.bg,
1361
- padding: "14px",
1362
- boxShadow: "0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08)",
1251
+ padding: "18px 20px",
1252
+ boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",
1363
1253
  position: "relative",
1364
- backdropFilter: "blur(12px)",
1365
- WebkitBackdropFilter: "blur(12px)",
1366
- boxSizing: "border-box",
1367
- overflow: "hidden"
1254
+ backdropFilter: "blur(10px)",
1255
+ WebkitBackdropFilter: "blur(10px)"
1368
1256
  },
1369
1257
  children: [
1370
1258
  onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -1373,23 +1261,35 @@ function UsageBanner({
1373
1261
  onClick: onClose,
1374
1262
  style: {
1375
1263
  position: "absolute",
1376
- top: "8px",
1377
- right: "8px",
1378
- background: "rgba(255, 255, 255, 0.9)",
1264
+ top: "12px",
1265
+ right: "12px",
1266
+ background: "rgba(255, 255, 255, 0.8)",
1379
1267
  border: "none",
1380
1268
  color: themeConfig.text,
1381
1269
  cursor: "pointer",
1382
- fontSize: "16px",
1270
+ fontSize: "18px",
1383
1271
  lineHeight: "1",
1384
- padding: "4px",
1385
- borderRadius: "4px",
1386
- width: "20px",
1387
- height: "20px",
1272
+ padding: "6px",
1273
+ borderRadius: "8px",
1274
+ opacity: 0.7,
1275
+ transition: "all 0.2s ease",
1388
1276
  display: "flex",
1389
1277
  alignItems: "center",
1390
- justifyContent: "center"
1278
+ justifyContent: "center",
1279
+ width: "28px",
1280
+ height: "28px"
1391
1281
  },
1392
1282
  title: "Close",
1283
+ onMouseOver: (e) => {
1284
+ e.currentTarget.style.opacity = "1";
1285
+ e.currentTarget.style.background = "rgba(255, 255, 255, 1)";
1286
+ e.currentTarget.style.transform = "scale(1.05)";
1287
+ },
1288
+ onMouseOut: (e) => {
1289
+ e.currentTarget.style.opacity = "0.7";
1290
+ e.currentTarget.style.background = "rgba(255, 255, 255, 0.8)";
1291
+ e.currentTarget.style.transform = "scale(1)";
1292
+ },
1393
1293
  children: "\xD7"
1394
1294
  }
1395
1295
  ),
@@ -1397,92 +1297,106 @@ function UsageBanner({
1397
1297
  "div",
1398
1298
  {
1399
1299
  style: {
1400
- fontSize: "14px",
1401
- fontWeight: 500,
1402
- color: themeConfig.text,
1403
- lineHeight: "1.4",
1404
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
1405
- paddingRight: onClose ? "30px" : "0",
1406
- marginBottom: actions ? "12px" : "0",
1407
- wordBreak: "break-word",
1408
- overflow: "hidden",
1409
- textOverflow: "ellipsis",
1410
- display: "-webkit-box",
1411
- WebkitLineClamp: 2,
1412
- WebkitBoxOrient: "vertical"
1413
- },
1414
- children: cleanMessage
1415
- }
1416
- ),
1417
- actions && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1418
- "div",
1419
- {
1420
- style: {
1300
+ color: themeConfig.icon,
1301
+ flexShrink: 0,
1302
+ marginTop: "1px",
1303
+ padding: "6px",
1304
+ borderRadius: "10px",
1305
+ background: "rgba(255, 255, 255, 0.7)",
1421
1306
  display: "flex",
1422
- gap: "8px",
1423
- flexWrap: "wrap"
1307
+ alignItems: "center",
1308
+ justifyContent: "center"
1424
1309
  },
1425
- children: [
1426
- actions.secondary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1427
- "button",
1428
- {
1429
- onClick: actions.secondary.onClick,
1430
- style: {
1431
- borderRadius: "8px",
1432
- padding: "6px 12px",
1433
- fontSize: "13px",
1434
- fontWeight: 500,
1435
- color: themeConfig.text,
1436
- backgroundColor: "rgba(255, 255, 255, 0.9)",
1437
- border: `1px solid ${themeConfig.border}`,
1438
- cursor: "pointer",
1439
- transition: "all 0.2s ease",
1440
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1441
- },
1442
- onMouseOver: (e) => {
1443
- e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 1)";
1444
- e.currentTarget.style.transform = "translateY(-1px)";
1445
- },
1446
- onMouseOut: (e) => {
1447
- e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.9)";
1448
- e.currentTarget.style.transform = "translateY(0)";
1449
- },
1450
- children: actions.secondary.label
1451
- }
1452
- ),
1453
- actions.primary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1454
- "button",
1455
- {
1456
- onClick: actions.primary.onClick,
1457
- style: {
1458
- borderRadius: "8px",
1459
- padding: "6px 12px",
1460
- fontSize: "13px",
1461
- fontWeight: 600,
1462
- color: "#fff",
1463
- backgroundColor: themeConfig.primaryBtn,
1464
- border: "none",
1465
- cursor: "pointer",
1466
- transition: "all 0.2s ease",
1467
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
1468
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1469
- },
1470
- onMouseOver: (e) => {
1471
- e.currentTarget.style.backgroundColor = themeConfig.primaryBtnHover;
1472
- e.currentTarget.style.transform = "translateY(-1px)";
1473
- e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.2)";
1474
- },
1475
- onMouseOut: (e) => {
1476
- e.currentTarget.style.backgroundColor = themeConfig.primaryBtn;
1477
- e.currentTarget.style.transform = "translateY(0)";
1478
- e.currentTarget.style.boxShadow = "0 2px 8px rgba(0, 0, 0, 0.15)";
1479
- },
1480
- children: actions.primary.label
1481
- }
1482
- )
1483
- ]
1310
+ children: Icon
1484
1311
  }
1485
- )
1312
+ ),
1313
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { flex: 1, paddingRight: onClose ? "40px" : "0" }, children: [
1314
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1315
+ "div",
1316
+ {
1317
+ style: {
1318
+ fontSize: "15px",
1319
+ fontWeight: 600,
1320
+ color: themeConfig.text,
1321
+ lineHeight: "1.5",
1322
+ marginBottom: actions ? "12px" : "0",
1323
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1324
+ },
1325
+ children: cleanMessage
1326
+ }
1327
+ ),
1328
+ actions && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1329
+ "div",
1330
+ {
1331
+ style: {
1332
+ display: "flex",
1333
+ gap: "10px",
1334
+ flexWrap: "wrap"
1335
+ },
1336
+ children: [
1337
+ actions.secondary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1338
+ "button",
1339
+ {
1340
+ onClick: actions.secondary.onClick,
1341
+ style: {
1342
+ borderRadius: "10px",
1343
+ padding: "8px 16px",
1344
+ fontSize: "14px",
1345
+ fontWeight: 500,
1346
+ color: themeConfig.text,
1347
+ backgroundColor: "rgba(255, 255, 255, 0.8)",
1348
+ border: `1.5px solid ${themeConfig.border}`,
1349
+ cursor: "pointer",
1350
+ transition: "all 0.2s ease",
1351
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1352
+ },
1353
+ onMouseOver: (e) => {
1354
+ e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 1)";
1355
+ e.currentTarget.style.transform = "translateY(-1px)";
1356
+ e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)";
1357
+ },
1358
+ onMouseOut: (e) => {
1359
+ e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.8)";
1360
+ e.currentTarget.style.transform = "translateY(0)";
1361
+ e.currentTarget.style.boxShadow = "none";
1362
+ },
1363
+ children: actions.secondary.label
1364
+ }
1365
+ ),
1366
+ actions.primary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1367
+ "button",
1368
+ {
1369
+ onClick: actions.primary.onClick,
1370
+ style: {
1371
+ borderRadius: "10px",
1372
+ padding: "8px 16px",
1373
+ fontSize: "14px",
1374
+ fontWeight: 600,
1375
+ color: "#fff",
1376
+ backgroundColor: themeConfig.primaryBtn,
1377
+ border: "none",
1378
+ cursor: "pointer",
1379
+ transition: "all 0.2s ease",
1380
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
1381
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1382
+ },
1383
+ onMouseOver: (e) => {
1384
+ e.currentTarget.style.backgroundColor = themeConfig.primaryBtnHover;
1385
+ e.currentTarget.style.transform = "translateY(-1px)";
1386
+ e.currentTarget.style.boxShadow = "0 6px 16px rgba(0, 0, 0, 0.2)";
1387
+ },
1388
+ onMouseOut: (e) => {
1389
+ e.currentTarget.style.backgroundColor = themeConfig.primaryBtn;
1390
+ e.currentTarget.style.transform = "translateY(0)";
1391
+ e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)";
1392
+ },
1393
+ children: actions.primary.label
1394
+ }
1395
+ )
1396
+ ]
1397
+ }
1398
+ )
1399
+ ] })
1486
1400
  ]
1487
1401
  }
1488
1402
  )
@@ -1898,8 +1812,7 @@ ${nonDocumentStrings}`;
1898
1812
  publicApiKey: copilotApiConfig.publicApiKey,
1899
1813
  headers,
1900
1814
  credentials: copilotApiConfig.credentials,
1901
- showDevConsole: (_b = props.showDevConsole) != null ? _b : false,
1902
- onTrace: props.onTrace
1815
+ showDevConsole: (_b = props.showDevConsole) != null ? _b : false
1903
1816
  });
1904
1817
  const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
1905
1818
  const addChatSuggestionConfiguration = (id, suggestion) => {
@@ -2042,8 +1955,7 @@ ${nonDocumentStrings}`;
2042
1955
  setExtensions,
2043
1956
  langGraphInterruptAction,
2044
1957
  setLangGraphInterruptAction,
2045
- removeLangGraphInterruptAction,
2046
- onTrace: props.onTrace
1958
+ removeLangGraphInterruptAction
2047
1959
  },
2048
1960
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children: memoizedChildren })
2049
1961
  }
@@ -2154,35 +2066,6 @@ function useChat(options) {
2154
2066
  } = options;
2155
2067
  const runChatCompletionRef = (0, import_react11.useRef)();
2156
2068
  const addErrorToast = useErrorToast();
2157
- const { setBannerError } = useToast();
2158
- const { onTrace } = useCopilotContext();
2159
- const traceUIError = (error, originalError) => __async(this, null, function* () {
2160
- if (!onTrace || !(copilotConfig == null ? void 0 : copilotConfig.publicApiKey))
2161
- return;
2162
- try {
2163
- const traceEvent = {
2164
- type: "error",
2165
- timestamp: Date.now(),
2166
- context: {
2167
- source: "ui",
2168
- request: {
2169
- operation: "useChatCompletion",
2170
- url: copilotConfig.chatApiEndpoint,
2171
- startTime: Date.now()
2172
- },
2173
- technical: {
2174
- environment: "browser",
2175
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2176
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
2177
- }
2178
- },
2179
- error
2180
- };
2181
- yield onTrace(traceEvent);
2182
- } catch (traceError) {
2183
- console.error("Error in use-chat onTrace handler:", traceError);
2184
- }
2185
- });
2186
2069
  const agentSessionRef = (0, import_react11.useRef)(agentSession);
2187
2070
  agentSessionRef.current = agentSession;
2188
2071
  const runIdRef = (0, import_react11.useRef)(runId);
@@ -2202,7 +2085,7 @@ function useChat(options) {
2202
2085
  const pendingAppendsRef = (0, import_react11.useRef)([]);
2203
2086
  const runChatCompletion = useAsyncCallback(
2204
2087
  (previousMessages) => __async(this, null, function* () {
2205
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
2088
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
2206
2089
  setIsLoading(true);
2207
2090
  const interruptEvent = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event;
2208
2091
  if ((interruptEvent == null ? void 0 : interruptEvent.name) === import_runtime_client_gql6.MetaEventName.LangGraphInterruptEvent && (interruptEvent == null ? void 0 : interruptEvent.value) && !(interruptEvent == null ? void 0 : interruptEvent.response) && agentSessionRef.current) {
@@ -2334,53 +2217,20 @@ function useChat(options) {
2334
2217
  messages2 = (0, import_runtime_client_gql6.convertGqlOutputToMessages)(
2335
2218
  (0, import_runtime_client_gql6.filterAdjacentAgentStateMessages)(rawMessagesResponse)
2336
2219
  );
2220
+ if (messages2.length === 0) {
2221
+ continue;
2222
+ }
2337
2223
  newMessages = [];
2338
2224
  if (((_k = value.generateCopilotResponse.status) == null ? void 0 : _k.__typename) === "FailedResponseStatus" && value.generateCopilotResponse.status.reason === "GUARDRAILS_VALIDATION_FAILED") {
2339
- const guardrailsReason = ((_l = value.generateCopilotResponse.status.details) == null ? void 0 : _l.guardrailsReason) || "";
2340
2225
  newMessages = [
2341
2226
  new import_runtime_client_gql6.TextMessage({
2342
2227
  role: import_runtime_client_gql6.MessageRole.Assistant,
2343
- content: guardrailsReason
2228
+ content: ((_l = value.generateCopilotResponse.status.details) == null ? void 0 : _l.guardrailsReason) || ""
2344
2229
  })
2345
2230
  ];
2346
- const guardrailsError = new import_shared12.CopilotKitError({
2347
- message: `Guardrails validation failed: ${guardrailsReason}`,
2348
- code: import_shared12.CopilotKitErrorCode.MISUSE
2349
- });
2350
- yield traceUIError(guardrailsError, {
2351
- statusReason: value.generateCopilotResponse.status.reason,
2352
- statusDetails: value.generateCopilotResponse.status.details
2353
- });
2354
2231
  setMessages([...previousMessages, ...newMessages]);
2355
2232
  break;
2356
- }
2357
- if (((_m = value.generateCopilotResponse.status) == null ? void 0 : _m.__typename) === "FailedResponseStatus" && value.generateCopilotResponse.status.reason === "UNKNOWN_ERROR") {
2358
- const errorMessage = ((_n = value.generateCopilotResponse.status.details) == null ? void 0 : _n.description) || "An unknown error occurred";
2359
- const statusDetails = value.generateCopilotResponse.status.details;
2360
- const originalError = (statusDetails == null ? void 0 : statusDetails.originalError) || (statusDetails == null ? void 0 : statusDetails.error);
2361
- const originalCode = (originalError == null ? void 0 : originalError.code) || ((_o = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _o.code);
2362
- const originalSeverity = (originalError == null ? void 0 : originalError.severity) || ((_p = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _p.severity);
2363
- const originalVisibility = (originalError == null ? void 0 : originalError.visibility) || ((_q = originalError == null ? void 0 : originalError.extensions) == null ? void 0 : _q.visibility);
2364
- let errorCode = import_shared12.CopilotKitErrorCode.NETWORK_ERROR;
2365
- if (originalCode && Object.values(import_shared12.CopilotKitErrorCode).includes(originalCode)) {
2366
- errorCode = originalCode;
2367
- }
2368
- const structuredError = new import_shared12.CopilotKitError({
2369
- message: errorMessage,
2370
- code: errorCode,
2371
- severity: originalSeverity,
2372
- visibility: originalVisibility
2373
- });
2374
- setBannerError(structuredError);
2375
- yield traceUIError(structuredError, {
2376
- statusReason: value.generateCopilotResponse.status.reason,
2377
- statusDetails: value.generateCopilotResponse.status.details,
2378
- originalErrorCode: originalCode,
2379
- preservedStructure: !!originalCode
2380
- });
2381
- setIsLoading(false);
2382
- break;
2383
- } else if (messages2.length > 0) {
2233
+ } else {
2384
2234
  newMessages = [...messages2];
2385
2235
  for (const message of messages2) {
2386
2236
  if (message.isAgentStateMessage() && !message.active && !executedCoAgentStateRenders.includes(message.id) && onCoAgentStateRender) {
@@ -2511,11 +2361,11 @@ function useChat(options) {
2511
2361
  followUp !== false && // and we executed an action
2512
2362
  (didExecuteAction || // the last message is a server side result
2513
2363
  !isAgentRun && finalMessages.length && finalMessages[finalMessages.length - 1].isResultMessage()) && // the user did not stop generation
2514
- !((_r = chatAbortControllerRef.current) == null ? void 0 : _r.signal.aborted)
2364
+ !((_m = chatAbortControllerRef.current) == null ? void 0 : _m.signal.aborted)
2515
2365
  ) {
2516
2366
  yield new Promise((resolve) => setTimeout(resolve, 10));
2517
2367
  return yield runChatCompletionRef.current(finalMessages);
2518
- } else if ((_s = chatAbortControllerRef.current) == null ? void 0 : _s.signal.aborted) {
2368
+ } else if ((_n = chatAbortControllerRef.current) == null ? void 0 : _n.signal.aborted) {
2519
2369
  const repairedMessages = finalMessages.filter((message, actionExecutionIndex) => {
2520
2370
  if (message.isActionExecutionMessage()) {
2521
2371
  return finalMessages.find(
@@ -2526,7 +2376,7 @@ function useChat(options) {
2526
2376
  });
2527
2377
  const repairedMessageIds = repairedMessages.map((message) => message.id);
2528
2378
  setMessages(repairedMessages);
2529
- if ((_t = agentSessionRef.current) == null ? void 0 : _t.nodeName) {
2379
+ if ((_o = agentSessionRef.current) == null ? void 0 : _o.nodeName) {
2530
2380
  setAgentSession({
2531
2381
  threadId: agentSessionRef.current.threadId,
2532
2382
  agentName: agentSessionRef.current.agentName,
@@ -3222,9 +3072,6 @@ function useCoAgent(options) {
3222
3072
  threadId,
3223
3073
  agentName: name
3224
3074
  });
3225
- if (result.error) {
3226
- return;
3227
- }
3228
3075
  const newState = (_b = (_a = result.data) == null ? void 0 : _a.loadAgentState) == null ? void 0 : _b.state;
3229
3076
  if (newState === lastLoadedState.current)
3230
3077
  return;