@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
@@ -161,8 +161,7 @@ var emptyCopilotContext = {
161
161
  },
162
162
  langGraphInterruptAction: null,
163
163
  setLangGraphInterruptAction: () => null,
164
- removeLangGraphInterruptAction: () => null,
165
- onTrace: void 0
164
+ removeLangGraphInterruptAction: () => null
166
165
  };
167
166
  var CopilotContext = import_react.default.createContext(emptyCopilotContext);
168
167
  function useCopilotContext() {
@@ -517,14 +516,12 @@ function ToastProvider({
517
516
  border: `1px solid ${colors.border}`,
518
517
  borderLeft: `4px solid ${colors.border}`,
519
518
  borderRadius: "8px",
520
- padding: "12px 16px",
519
+ padding: "10px 14px",
521
520
  fontSize: "13px",
522
521
  boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
523
522
  backdropFilter: "blur(8px)",
524
- maxWidth: "min(90vw, 700px)",
525
- width: "100%",
526
- boxSizing: "border-box",
527
- overflow: "hidden"
523
+ maxWidth: "500px",
524
+ minWidth: "350px"
528
525
  },
529
526
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
530
527
  "div",
@@ -536,125 +533,94 @@ function ToastProvider({
536
533
  gap: "10px"
537
534
  },
538
535
  children: [
539
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
540
- "div",
541
- {
542
- style: {
543
- display: "flex",
544
- alignItems: "center",
545
- gap: "8px",
546
- flex: 1,
547
- minWidth: 0
548
- },
549
- children: [
550
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
551
- "div",
552
- {
553
- style: {
554
- width: "12px",
555
- height: "12px",
556
- borderRadius: "50%",
557
- backgroundColor: colors.border,
558
- flexShrink: 0
536
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", flex: 1 }, children: [
537
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
538
+ "div",
539
+ {
540
+ style: {
541
+ width: "12px",
542
+ height: "12px",
543
+ borderRadius: "50%",
544
+ backgroundColor: colors.border,
545
+ flexShrink: 0
546
+ }
547
+ }
548
+ ),
549
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px", flex: 1 }, children: [
550
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
551
+ "div",
552
+ {
553
+ style: {
554
+ color: colors.text,
555
+ lineHeight: "1.4",
556
+ fontWeight: "400",
557
+ fontSize: "13px",
558
+ flex: 1,
559
+ wordWrap: "break-word",
560
+ overflowWrap: "break-word",
561
+ hyphens: "auto"
562
+ },
563
+ children: (() => {
564
+ const message = bannerError.message;
565
+ const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
566
+ const plainUrlRegex = /(https?:\/\/[^\s)]+)/g;
567
+ let cleanMessage = message.replace(markdownLinkRegex, "").replace(plainUrlRegex, "").replace(/See more:\s*/g, "").replace(/\s+/g, " ").trim();
568
+ if (cleanMessage.length > 120) {
569
+ cleanMessage = cleanMessage.substring(0, 117) + "...";
559
570
  }
571
+ return cleanMessage;
572
+ })()
573
+ }
574
+ ),
575
+ (() => {
576
+ const message = bannerError.message;
577
+ const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
578
+ const plainUrlRegex = /(https?:\/\/[^\s)]+)/g;
579
+ let url = null;
580
+ let buttonText = "See More";
581
+ const markdownMatch = markdownLinkRegex.exec(message);
582
+ if (markdownMatch) {
583
+ url = markdownMatch[2];
584
+ buttonText = "See More";
585
+ } else {
586
+ const urlMatch = plainUrlRegex.exec(message);
587
+ if (urlMatch) {
588
+ url = urlMatch[0];
589
+ buttonText = "See More";
560
590
  }
561
- ),
562
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
563
- "div",
591
+ }
592
+ if (!url)
593
+ return null;
594
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
595
+ "button",
564
596
  {
597
+ onClick: () => window.open(url, "_blank", "noopener,noreferrer"),
565
598
  style: {
566
- display: "flex",
567
- alignItems: "center",
568
- gap: "10px",
569
- flex: 1,
570
- minWidth: 0
599
+ background: colors.border,
600
+ color: "white",
601
+ border: "none",
602
+ borderRadius: "5px",
603
+ padding: "4px 10px",
604
+ fontSize: "11px",
605
+ fontWeight: "500",
606
+ cursor: "pointer",
607
+ transition: "all 0.2s ease",
608
+ flexShrink: 0
609
+ },
610
+ onMouseEnter: (e) => {
611
+ e.currentTarget.style.opacity = "0.9";
612
+ e.currentTarget.style.transform = "translateY(-1px)";
571
613
  },
572
- children: [
573
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
574
- "div",
575
- {
576
- style: {
577
- color: colors.text,
578
- lineHeight: "1.4",
579
- fontWeight: "400",
580
- fontSize: "13px",
581
- flex: 1,
582
- wordBreak: "break-all",
583
- overflowWrap: "break-word",
584
- maxWidth: "550px",
585
- overflow: "hidden",
586
- display: "-webkit-box",
587
- WebkitLineClamp: 10,
588
- WebkitBoxOrient: "vertical"
589
- },
590
- children: (() => {
591
- let message = bannerError.message;
592
- const jsonMatch = message.match(/'message':\s*'([^']+)'/);
593
- if (jsonMatch) {
594
- return jsonMatch[1];
595
- }
596
- message = message.split(" - ")[0];
597
- message = message.split(": Error code")[0];
598
- message = message.replace(/:\s*\d{3}$/, "");
599
- message = message.replace(/See more:.*$/g, "");
600
- message = message.trim();
601
- return message || "Configuration error occurred.";
602
- })()
603
- }
604
- ),
605
- (() => {
606
- const message = bannerError.message;
607
- const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
608
- const plainUrlRegex = /(https?:\/\/[^\s)]+)/g;
609
- let url = null;
610
- let buttonText = "See More";
611
- const markdownMatch = markdownLinkRegex.exec(message);
612
- if (markdownMatch) {
613
- url = markdownMatch[2];
614
- buttonText = "See More";
615
- } else {
616
- const urlMatch = plainUrlRegex.exec(message);
617
- if (urlMatch) {
618
- url = urlMatch[0].replace(/[.,;:'"]*$/, "");
619
- buttonText = "See More";
620
- }
621
- }
622
- if (!url)
623
- return null;
624
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
625
- "button",
626
- {
627
- onClick: () => window.open(url, "_blank", "noopener,noreferrer"),
628
- style: {
629
- background: colors.border,
630
- color: "white",
631
- border: "none",
632
- borderRadius: "5px",
633
- padding: "4px 10px",
634
- fontSize: "11px",
635
- fontWeight: "500",
636
- cursor: "pointer",
637
- transition: "all 0.2s ease",
638
- flexShrink: 0
639
- },
640
- onMouseEnter: (e) => {
641
- e.currentTarget.style.opacity = "0.9";
642
- e.currentTarget.style.transform = "translateY(-1px)";
643
- },
644
- onMouseLeave: (e) => {
645
- e.currentTarget.style.opacity = "1";
646
- e.currentTarget.style.transform = "translateY(0)";
647
- },
648
- children: buttonText
649
- }
650
- );
651
- })()
652
- ]
614
+ onMouseLeave: (e) => {
615
+ e.currentTarget.style.opacity = "1";
616
+ e.currentTarget.style.transform = "translateY(0)";
617
+ },
618
+ children: buttonText
653
619
  }
654
- )
655
- ]
656
- }
657
- ),
620
+ );
621
+ })()
622
+ ] })
623
+ ] }),
658
624
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
659
625
  "button",
660
626
  {
@@ -707,38 +673,8 @@ function CopilotMessages({ children }) {
707
673
  const lastLoadedThreadId = (0, import_react6.useRef)();
708
674
  const lastLoadedAgentName = (0, import_react6.useRef)();
709
675
  const lastLoadedMessages = (0, import_react6.useRef)();
710
- const { threadId, agentSession, runtimeClient, showDevConsole, onTrace, copilotApiConfig } = useCopilotContext();
676
+ const { threadId, agentSession, runtimeClient, showDevConsole } = useCopilotContext();
711
677
  const { setBannerError } = useToast();
712
- const traceUIError = (0, import_react6.useCallback)(
713
- (error, originalError) => __async(this, null, function* () {
714
- if (!onTrace || !copilotApiConfig.publicApiKey)
715
- return;
716
- try {
717
- const traceEvent = {
718
- type: "error",
719
- timestamp: Date.now(),
720
- context: {
721
- source: "ui",
722
- request: {
723
- operation: "loadAgentState",
724
- url: copilotApiConfig.chatApiEndpoint,
725
- startTime: Date.now()
726
- },
727
- technical: {
728
- environment: "browser",
729
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
730
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
731
- }
732
- },
733
- error
734
- };
735
- yield onTrace(traceEvent);
736
- } catch (traceError) {
737
- console.error("Error in CopilotMessages onTrace handler:", traceError);
738
- }
739
- }),
740
- [onTrace, copilotApiConfig.publicApiKey, copilotApiConfig.chatApiEndpoint]
741
- );
742
678
  const createStructuredError2 = (gqlError) => {
743
679
  const extensions = gqlError.extensions;
744
680
  const originalError = extensions == null ? void 0 : extensions.originalError;
@@ -783,14 +719,12 @@ function CopilotMessages({ children }) {
783
719
  const ckError = createStructuredError2(gqlError);
784
720
  if (ckError) {
785
721
  setBannerError(ckError);
786
- traceUIError(ckError, gqlError);
787
722
  } else {
788
723
  const fallbackError = new import_shared4.CopilotKitError({
789
724
  message: gqlError.message,
790
725
  code: import_shared4.CopilotKitErrorCode.UNKNOWN
791
726
  });
792
727
  setBannerError(fallbackError);
793
- traceUIError(fallbackError, gqlError);
794
728
  }
795
729
  };
796
730
  graphQLErrors.forEach(routeError);
@@ -804,11 +738,10 @@ function CopilotMessages({ children }) {
804
738
  code: import_shared4.CopilotKitErrorCode.UNKNOWN
805
739
  });
806
740
  setBannerError(fallbackError);
807
- traceUIError(fallbackError, error);
808
741
  }
809
742
  }
810
743
  },
811
- [setBannerError, showDevConsole, traceUIError]
744
+ [setBannerError, showDevConsole]
812
745
  );
813
746
  (0, import_react6.useEffect)(() => {
814
747
  if (!threadId || threadId === lastLoadedThreadId.current)
@@ -862,35 +795,8 @@ var import_react7 = require("react");
862
795
  var import_shared5 = require("@copilotkit/shared");
863
796
  var useCopilotRuntimeClient = (options) => {
864
797
  const { setBannerError } = useToast();
865
- const _a = options, { showDevConsole, onTrace } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onTrace"]);
798
+ const _a = options, { showDevConsole } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
866
799
  const lastStructuredErrorRef = (0, import_react7.useRef)(null);
867
- const traceUIError = (error, originalError) => __async(void 0, null, function* () {
868
- if (!onTrace || !runtimeOptions.publicApiKey)
869
- return;
870
- try {
871
- const traceEvent = {
872
- type: "error",
873
- timestamp: Date.now(),
874
- context: {
875
- source: "ui",
876
- request: {
877
- operation: "runtimeClient",
878
- url: runtimeOptions.url,
879
- startTime: Date.now()
880
- },
881
- technical: {
882
- environment: "browser",
883
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
884
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
885
- }
886
- },
887
- error
888
- };
889
- yield onTrace(traceEvent);
890
- } catch (traceError) {
891
- console.error("Error in onTrace handler:", traceError);
892
- }
893
- });
894
800
  const runtimeClient = (0, import_react7.useMemo)(() => {
895
801
  return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
896
802
  handleGQLErrors: (error) => {
@@ -918,14 +824,12 @@ var useCopilotRuntimeClient = (options) => {
918
824
  const ckError = createStructuredError(gqlError);
919
825
  if (ckError) {
920
826
  setBannerError(ckError);
921
- traceUIError(ckError, gqlError);
922
827
  } else {
923
828
  const fallbackError = new import_shared5.CopilotKitError({
924
829
  message: gqlError.message,
925
830
  code: import_shared5.CopilotKitErrorCode.UNKNOWN
926
831
  });
927
832
  setBannerError(fallbackError);
928
- traceUIError(fallbackError, gqlError);
929
833
  }
930
834
  };
931
835
  graphQLErrors.forEach(routeError);
@@ -939,7 +843,6 @@ var useCopilotRuntimeClient = (options) => {
939
843
  code: import_shared5.CopilotKitErrorCode.UNKNOWN
940
844
  });
941
845
  setBannerError(fallbackError);
942
- traceUIError(fallbackError, error);
943
846
  }
944
847
  }
945
848
  },
@@ -952,7 +855,7 @@ var useCopilotRuntimeClient = (options) => {
952
855
  setBannerError(warningError);
953
856
  }
954
857
  }));
955
- }, [runtimeOptions, setBannerError, showDevConsole, onTrace]);
858
+ }, [runtimeOptions, setBannerError, showDevConsole]);
956
859
  return runtimeClient;
957
860
  };
958
861
  function createStructuredError(gqlError) {
@@ -1045,8 +948,8 @@ var defaultIcons = {
1045
948
  "svg",
1046
949
  {
1047
950
  viewBox: "0 0 24 24",
1048
- width: "16",
1049
- height: "16",
951
+ width: "18",
952
+ height: "18",
1050
953
  stroke: "currentColor",
1051
954
  strokeWidth: "2.5",
1052
955
  fill: "none",
@@ -1063,8 +966,8 @@ var defaultIcons = {
1063
966
  "svg",
1064
967
  {
1065
968
  viewBox: "0 0 24 24",
1066
- width: "16",
1067
- height: "16",
969
+ width: "18",
970
+ height: "18",
1068
971
  stroke: "currentColor",
1069
972
  strokeWidth: "2.5",
1070
973
  fill: "none",
@@ -1081,8 +984,8 @@ var defaultIcons = {
1081
984
  "svg",
1082
985
  {
1083
986
  viewBox: "0 0 24 24",
1084
- width: "16",
1085
- height: "16",
987
+ width: "18",
988
+ height: "18",
1086
989
  stroke: "currentColor",
1087
990
  strokeWidth: "2.5",
1088
991
  fill: "none",
@@ -1107,33 +1010,19 @@ function UsageBanner({
1107
1010
  return null;
1108
1011
  }
1109
1012
  const parseMessage = (rawMessage) => {
1110
- if (rawMessage.toLowerCase().includes("authentication") || rawMessage.toLowerCase().includes("api key")) {
1111
- return "Authentication failed. Please check your API key.";
1112
- }
1113
- if (rawMessage.toLowerCase().includes("rate limit")) {
1114
- return "Rate limit exceeded. Please try again later.";
1115
- }
1116
- if (rawMessage.toLowerCase().includes("checkpointer")) {
1117
- return "Agent configuration error. Please check your setup.";
1118
- }
1119
- let cleanMessage2 = rawMessage;
1120
- cleanMessage2 = cleanMessage2.split(" - ")[0];
1121
- cleanMessage2 = cleanMessage2.split(": Error code")[0];
1122
- cleanMessage2 = cleanMessage2.split(": 401")[0];
1123
- cleanMessage2 = cleanMessage2.split(": 403")[0];
1124
- cleanMessage2 = cleanMessage2.split(": 404")[0];
1125
- cleanMessage2 = cleanMessage2.split(": 500")[0];
1126
- cleanMessage2 = cleanMessage2.replace(/See more:.*$/g, "").trim();
1127
- if (cleanMessage2.includes("{") || cleanMessage2.includes("'") || cleanMessage2.length > 60) {
1128
- return "Configuration error. Please check your setup.";
1013
+ const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
1014
+ const matches = Array.from(rawMessage.matchAll(linkRegex));
1015
+ if (matches.length > 0) {
1016
+ let cleanMessage2 = rawMessage.replace(/\.\s*See more:\s*\[([^\]]+)\]\(([^)]+)\)/g, ".").replace(/See more:\s*\[([^\]]+)\]\(([^)]+)\)/g, "").trim();
1017
+ return cleanMessage2;
1129
1018
  }
1130
- return cleanMessage2 || "An error occurred. Please check your configuration.";
1019
+ return rawMessage;
1131
1020
  };
1132
1021
  const cleanMessage = parseMessage(message);
1133
1022
  const Icon = icon || defaultIcons[severity];
1134
1023
  const themeConfigs = {
1135
1024
  [import_shared7.Severity.INFO]: {
1136
- bg: "rgba(239, 246, 255, 0.95)",
1025
+ bg: "linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%)",
1137
1026
  border: "#93c5fd",
1138
1027
  text: "#1e40af",
1139
1028
  icon: "#3b82f6",
@@ -1141,7 +1030,7 @@ function UsageBanner({
1141
1030
  primaryBtnHover: "#2563eb"
1142
1031
  },
1143
1032
  [import_shared7.Severity.WARNING]: {
1144
- bg: "rgba(255, 251, 235, 0.95)",
1033
+ bg: "linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%)",
1145
1034
  border: "#fbbf24",
1146
1035
  text: "#92400e",
1147
1036
  icon: "#f59e0b",
@@ -1149,7 +1038,7 @@ function UsageBanner({
1149
1038
  primaryBtnHover: "#d97706"
1150
1039
  },
1151
1040
  [import_shared7.Severity.CRITICAL]: {
1152
- bg: "rgba(254, 242, 242, 0.95)",
1041
+ bg: "linear-gradient(135deg, #fef2f2 0%, #fecaca 100%)",
1153
1042
  border: "#f87171",
1154
1043
  text: "#991b1b",
1155
1044
  icon: "#ef4444",
@@ -1163,26 +1052,24 @@ function UsageBanner({
1163
1052
  {
1164
1053
  style: {
1165
1054
  position: "fixed",
1166
- bottom: "24px",
1055
+ bottom: "20px",
1167
1056
  left: "50%",
1168
1057
  transform: "translateX(-50%)",
1169
- width: "400px",
1170
- maxWidth: "90vw",
1058
+ maxWidth: "min(95vw, 680px)",
1059
+ width: "100%",
1171
1060
  zIndex: 1e4,
1172
- animation: "bannerSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1)"
1061
+ animation: "bannerSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1)"
1173
1062
  },
1174
1063
  children: [
1175
1064
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
1176
1065
  @keyframes bannerSlideIn {
1177
1066
  from {
1178
1067
  opacity: 0;
1179
- transform: translateX(-50%) translateY(20px);
1180
- scale: 0.95;
1068
+ transform: translateX(-50%) translateY(10px);
1181
1069
  }
1182
1070
  to {
1183
1071
  opacity: 1;
1184
1072
  transform: translateX(-50%) translateY(0);
1185
- scale: 1;
1186
1073
  }
1187
1074
  }
1188
1075
  ` }),
@@ -1190,16 +1077,17 @@ function UsageBanner({
1190
1077
  "div",
1191
1078
  {
1192
1079
  style: {
1193
- borderRadius: "12px",
1080
+ display: "flex",
1081
+ alignItems: "flex-start",
1082
+ gap: "14px",
1083
+ borderRadius: "16px",
1194
1084
  border: `1px solid ${themeConfig.border}`,
1195
1085
  background: themeConfig.bg,
1196
- padding: "14px",
1197
- boxShadow: "0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08)",
1086
+ padding: "18px 20px",
1087
+ boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",
1198
1088
  position: "relative",
1199
- backdropFilter: "blur(12px)",
1200
- WebkitBackdropFilter: "blur(12px)",
1201
- boxSizing: "border-box",
1202
- overflow: "hidden"
1089
+ backdropFilter: "blur(10px)",
1090
+ WebkitBackdropFilter: "blur(10px)"
1203
1091
  },
1204
1092
  children: [
1205
1093
  onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -1208,23 +1096,35 @@ function UsageBanner({
1208
1096
  onClick: onClose,
1209
1097
  style: {
1210
1098
  position: "absolute",
1211
- top: "8px",
1212
- right: "8px",
1213
- background: "rgba(255, 255, 255, 0.9)",
1099
+ top: "12px",
1100
+ right: "12px",
1101
+ background: "rgba(255, 255, 255, 0.8)",
1214
1102
  border: "none",
1215
1103
  color: themeConfig.text,
1216
1104
  cursor: "pointer",
1217
- fontSize: "16px",
1105
+ fontSize: "18px",
1218
1106
  lineHeight: "1",
1219
- padding: "4px",
1220
- borderRadius: "4px",
1221
- width: "20px",
1222
- height: "20px",
1107
+ padding: "6px",
1108
+ borderRadius: "8px",
1109
+ opacity: 0.7,
1110
+ transition: "all 0.2s ease",
1223
1111
  display: "flex",
1224
1112
  alignItems: "center",
1225
- justifyContent: "center"
1113
+ justifyContent: "center",
1114
+ width: "28px",
1115
+ height: "28px"
1226
1116
  },
1227
1117
  title: "Close",
1118
+ onMouseOver: (e) => {
1119
+ e.currentTarget.style.opacity = "1";
1120
+ e.currentTarget.style.background = "rgba(255, 255, 255, 1)";
1121
+ e.currentTarget.style.transform = "scale(1.05)";
1122
+ },
1123
+ onMouseOut: (e) => {
1124
+ e.currentTarget.style.opacity = "0.7";
1125
+ e.currentTarget.style.background = "rgba(255, 255, 255, 0.8)";
1126
+ e.currentTarget.style.transform = "scale(1)";
1127
+ },
1228
1128
  children: "\xD7"
1229
1129
  }
1230
1130
  ),
@@ -1232,92 +1132,106 @@ function UsageBanner({
1232
1132
  "div",
1233
1133
  {
1234
1134
  style: {
1235
- fontSize: "14px",
1236
- fontWeight: 500,
1237
- color: themeConfig.text,
1238
- lineHeight: "1.4",
1239
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
1240
- paddingRight: onClose ? "30px" : "0",
1241
- marginBottom: actions ? "12px" : "0",
1242
- wordBreak: "break-word",
1243
- overflow: "hidden",
1244
- textOverflow: "ellipsis",
1245
- display: "-webkit-box",
1246
- WebkitLineClamp: 2,
1247
- WebkitBoxOrient: "vertical"
1248
- },
1249
- children: cleanMessage
1250
- }
1251
- ),
1252
- actions && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1253
- "div",
1254
- {
1255
- style: {
1135
+ color: themeConfig.icon,
1136
+ flexShrink: 0,
1137
+ marginTop: "1px",
1138
+ padding: "6px",
1139
+ borderRadius: "10px",
1140
+ background: "rgba(255, 255, 255, 0.7)",
1256
1141
  display: "flex",
1257
- gap: "8px",
1258
- flexWrap: "wrap"
1142
+ alignItems: "center",
1143
+ justifyContent: "center"
1259
1144
  },
1260
- children: [
1261
- actions.secondary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1262
- "button",
1263
- {
1264
- onClick: actions.secondary.onClick,
1265
- style: {
1266
- borderRadius: "8px",
1267
- padding: "6px 12px",
1268
- fontSize: "13px",
1269
- fontWeight: 500,
1270
- color: themeConfig.text,
1271
- backgroundColor: "rgba(255, 255, 255, 0.9)",
1272
- border: `1px solid ${themeConfig.border}`,
1273
- cursor: "pointer",
1274
- transition: "all 0.2s ease",
1275
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1276
- },
1277
- onMouseOver: (e) => {
1278
- e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 1)";
1279
- e.currentTarget.style.transform = "translateY(-1px)";
1280
- },
1281
- onMouseOut: (e) => {
1282
- e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.9)";
1283
- e.currentTarget.style.transform = "translateY(0)";
1284
- },
1285
- children: actions.secondary.label
1286
- }
1287
- ),
1288
- actions.primary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1289
- "button",
1290
- {
1291
- onClick: actions.primary.onClick,
1292
- style: {
1293
- borderRadius: "8px",
1294
- padding: "6px 12px",
1295
- fontSize: "13px",
1296
- fontWeight: 600,
1297
- color: "#fff",
1298
- backgroundColor: themeConfig.primaryBtn,
1299
- border: "none",
1300
- cursor: "pointer",
1301
- transition: "all 0.2s ease",
1302
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
1303
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1304
- },
1305
- onMouseOver: (e) => {
1306
- e.currentTarget.style.backgroundColor = themeConfig.primaryBtnHover;
1307
- e.currentTarget.style.transform = "translateY(-1px)";
1308
- e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.2)";
1309
- },
1310
- onMouseOut: (e) => {
1311
- e.currentTarget.style.backgroundColor = themeConfig.primaryBtn;
1312
- e.currentTarget.style.transform = "translateY(0)";
1313
- e.currentTarget.style.boxShadow = "0 2px 8px rgba(0, 0, 0, 0.15)";
1314
- },
1315
- children: actions.primary.label
1316
- }
1317
- )
1318
- ]
1145
+ children: Icon
1319
1146
  }
1320
- )
1147
+ ),
1148
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { flex: 1, paddingRight: onClose ? "40px" : "0" }, children: [
1149
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1150
+ "div",
1151
+ {
1152
+ style: {
1153
+ fontSize: "15px",
1154
+ fontWeight: 600,
1155
+ color: themeConfig.text,
1156
+ lineHeight: "1.5",
1157
+ marginBottom: actions ? "12px" : "0",
1158
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1159
+ },
1160
+ children: cleanMessage
1161
+ }
1162
+ ),
1163
+ actions && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1164
+ "div",
1165
+ {
1166
+ style: {
1167
+ display: "flex",
1168
+ gap: "10px",
1169
+ flexWrap: "wrap"
1170
+ },
1171
+ children: [
1172
+ actions.secondary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1173
+ "button",
1174
+ {
1175
+ onClick: actions.secondary.onClick,
1176
+ style: {
1177
+ borderRadius: "10px",
1178
+ padding: "8px 16px",
1179
+ fontSize: "14px",
1180
+ fontWeight: 500,
1181
+ color: themeConfig.text,
1182
+ backgroundColor: "rgba(255, 255, 255, 0.8)",
1183
+ border: `1.5px solid ${themeConfig.border}`,
1184
+ cursor: "pointer",
1185
+ transition: "all 0.2s ease",
1186
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1187
+ },
1188
+ onMouseOver: (e) => {
1189
+ e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 1)";
1190
+ e.currentTarget.style.transform = "translateY(-1px)";
1191
+ e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)";
1192
+ },
1193
+ onMouseOut: (e) => {
1194
+ e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.8)";
1195
+ e.currentTarget.style.transform = "translateY(0)";
1196
+ e.currentTarget.style.boxShadow = "none";
1197
+ },
1198
+ children: actions.secondary.label
1199
+ }
1200
+ ),
1201
+ actions.primary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1202
+ "button",
1203
+ {
1204
+ onClick: actions.primary.onClick,
1205
+ style: {
1206
+ borderRadius: "10px",
1207
+ padding: "8px 16px",
1208
+ fontSize: "14px",
1209
+ fontWeight: 600,
1210
+ color: "#fff",
1211
+ backgroundColor: themeConfig.primaryBtn,
1212
+ border: "none",
1213
+ cursor: "pointer",
1214
+ transition: "all 0.2s ease",
1215
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
1216
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1217
+ },
1218
+ onMouseOver: (e) => {
1219
+ e.currentTarget.style.backgroundColor = themeConfig.primaryBtnHover;
1220
+ e.currentTarget.style.transform = "translateY(-1px)";
1221
+ e.currentTarget.style.boxShadow = "0 6px 16px rgba(0, 0, 0, 0.2)";
1222
+ },
1223
+ onMouseOut: (e) => {
1224
+ e.currentTarget.style.backgroundColor = themeConfig.primaryBtn;
1225
+ e.currentTarget.style.transform = "translateY(0)";
1226
+ e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)";
1227
+ },
1228
+ children: actions.primary.label
1229
+ }
1230
+ )
1231
+ ]
1232
+ }
1233
+ )
1234
+ ] })
1321
1235
  ]
1322
1236
  }
1323
1237
  )
@@ -1721,8 +1635,7 @@ ${nonDocumentStrings}`;
1721
1635
  publicApiKey: copilotApiConfig.publicApiKey,
1722
1636
  headers,
1723
1637
  credentials: copilotApiConfig.credentials,
1724
- showDevConsole: (_b = props.showDevConsole) != null ? _b : false,
1725
- onTrace: props.onTrace
1638
+ showDevConsole: (_b = props.showDevConsole) != null ? _b : false
1726
1639
  });
1727
1640
  const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
1728
1641
  const addChatSuggestionConfiguration = (id, suggestion) => {
@@ -1865,8 +1778,7 @@ ${nonDocumentStrings}`;
1865
1778
  setExtensions,
1866
1779
  langGraphInterruptAction,
1867
1780
  setLangGraphInterruptAction,
1868
- removeLangGraphInterruptAction,
1869
- onTrace: props.onTrace
1781
+ removeLangGraphInterruptAction
1870
1782
  },
1871
1783
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children: memoizedChildren })
1872
1784
  }