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