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

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 -64
  2. package/dist/{chunk-3YHYWAHK.mjs → chunk-2FW7HH6W.mjs} +3 -3
  3. package/dist/{chunk-EXU7GWLC.mjs → chunk-4I7PLQF7.mjs} +5 -5
  4. package/dist/{chunk-XFOTNHYA.mjs → chunk-6KGEF242.mjs} +2 -3
  5. package/dist/chunk-6KGEF242.mjs.map +1 -0
  6. package/dist/{chunk-JPMIAGI6.mjs → chunk-C6F6EQNA.mjs} +2 -2
  7. package/dist/{chunk-3OQM3NEK.mjs → chunk-CCESTGAM.mjs} +2 -2
  8. package/dist/{chunk-ADIITPD2.mjs → chunk-CMKIDDQL.mjs} +8 -11
  9. package/dist/{chunk-ADIITPD2.mjs.map → chunk-CMKIDDQL.mjs.map} +1 -1
  10. package/dist/{chunk-FXK6RQIN.mjs → chunk-FRZZPPIV.mjs} +2 -2
  11. package/dist/chunk-HD2GE3DK.mjs +359 -0
  12. package/dist/chunk-HD2GE3DK.mjs.map +1 -0
  13. package/dist/{chunk-WOGURSAL.mjs → chunk-L6QAOAE4.mjs} +12 -15
  14. package/dist/chunk-L6QAOAE4.mjs.map +1 -0
  15. package/dist/{chunk-EF5BNM34.mjs → chunk-LDACFA2B.mjs} +3 -3
  16. package/dist/{chunk-UBNRUXEK.mjs → chunk-LZDDYZEY.mjs} +2 -2
  17. package/dist/{chunk-G7LYGERN.mjs → chunk-MGIXEJWG.mjs} +16 -83
  18. package/dist/chunk-MGIXEJWG.mjs.map +1 -0
  19. package/dist/{chunk-JDEWNLNP.mjs → chunk-NNSXCFQO.mjs} +7 -41
  20. package/dist/chunk-NNSXCFQO.mjs.map +1 -0
  21. package/dist/{chunk-OF4SZTLL.mjs → chunk-OUSWPVDT.mjs} +4 -4
  22. package/dist/{chunk-CMQV4XNY.mjs → chunk-Q5D5XQFA.mjs} +2 -2
  23. package/dist/{chunk-SJJNFYGQ.mjs → chunk-QQZLIEXK.mjs} +3 -3
  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 +4 -39
  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 +240 -330
  37. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  38. package/dist/components/copilot-provider/copilotkit.mjs +10 -10
  39. package/dist/components/copilot-provider/index.d.ts +1 -1
  40. package/dist/components/copilot-provider/index.js +240 -330
  41. package/dist/components/copilot-provider/index.js.map +1 -1
  42. package/dist/components/copilot-provider/index.mjs +10 -10
  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 +240 -330
  50. package/dist/components/index.js.map +1 -1
  51. package/dist/components/index.mjs +10 -10
  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 +32 -32
  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 +6 -6
  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 +14 -14
  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 +13 -13
  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 +14 -14
  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 +249 -404
  114. package/dist/index.js.map +1 -1
  115. package/dist/index.mjs +33 -33
  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 +11 -11
  119. package/dist/lib/index.d.ts +1 -1
  120. package/dist/lib/index.js.map +1 -1
  121. package/dist/lib/index.mjs +11 -11
  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 +10 -10
  126. package/dist/utils/index.d.ts +1 -1
  127. package/dist/utils/index.js.map +1 -1
  128. package/dist/utils/index.mjs +10 -10
  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 +5 -46
  137. package/src/components/copilot-provider/copilotkit-props.tsx +0 -21
  138. package/src/components/copilot-provider/copilotkit.tsx +1 -5
  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-EXU7GWLC.mjs.map → chunk-4I7PLQF7.mjs.map} +0 -0
  159. /package/dist/{chunk-JPMIAGI6.mjs.map → chunk-C6F6EQNA.mjs.map} +0 -0
  160. /package/dist/{chunk-3OQM3NEK.mjs.map → chunk-CCESTGAM.mjs.map} +0 -0
  161. /package/dist/{chunk-FXK6RQIN.mjs.map → chunk-FRZZPPIV.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-OF4SZTLL.mjs.map → chunk-OUSWPVDT.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)
@@ -842,7 +775,6 @@ function CopilotMessages({ children }) {
842
775
  });
843
776
  void fetchMessages();
844
777
  }, [threadId, agentSession == null ? void 0 : agentSession.agentName, runtimeClient]);
845
- const memoizedChildren = (0, import_react6.useMemo)(() => children, [children]);
846
778
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
847
779
  CopilotMessagesContext.Provider,
848
780
  {
@@ -850,7 +782,7 @@ function CopilotMessages({ children }) {
850
782
  messages,
851
783
  setMessages
852
784
  },
853
- children: memoizedChildren
785
+ children
854
786
  }
855
787
  );
856
788
  }
@@ -861,35 +793,8 @@ var import_react7 = require("react");
861
793
  var import_shared5 = require("@copilotkit/shared");
862
794
  var useCopilotRuntimeClient = (options) => {
863
795
  const { setBannerError } = useToast();
864
- const _a = options, { showDevConsole, onTrace } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onTrace"]);
796
+ const _a = options, { showDevConsole } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
865
797
  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
798
  const runtimeClient = (0, import_react7.useMemo)(() => {
894
799
  return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
895
800
  handleGQLErrors: (error) => {
@@ -917,14 +822,12 @@ var useCopilotRuntimeClient = (options) => {
917
822
  const ckError = createStructuredError(gqlError);
918
823
  if (ckError) {
919
824
  setBannerError(ckError);
920
- traceUIError(ckError, gqlError);
921
825
  } else {
922
826
  const fallbackError = new import_shared5.CopilotKitError({
923
827
  message: gqlError.message,
924
828
  code: import_shared5.CopilotKitErrorCode.UNKNOWN
925
829
  });
926
830
  setBannerError(fallbackError);
927
- traceUIError(fallbackError, gqlError);
928
831
  }
929
832
  };
930
833
  graphQLErrors.forEach(routeError);
@@ -938,7 +841,6 @@ var useCopilotRuntimeClient = (options) => {
938
841
  code: import_shared5.CopilotKitErrorCode.UNKNOWN
939
842
  });
940
843
  setBannerError(fallbackError);
941
- traceUIError(fallbackError, error);
942
844
  }
943
845
  }
944
846
  },
@@ -951,7 +853,7 @@ var useCopilotRuntimeClient = (options) => {
951
853
  setBannerError(warningError);
952
854
  }
953
855
  }));
954
- }, [runtimeOptions, setBannerError, showDevConsole, onTrace]);
856
+ }, [runtimeOptions, setBannerError, showDevConsole]);
955
857
  return runtimeClient;
956
858
  };
957
859
  function createStructuredError(gqlError) {
@@ -1044,8 +946,8 @@ var defaultIcons = {
1044
946
  "svg",
1045
947
  {
1046
948
  viewBox: "0 0 24 24",
1047
- width: "16",
1048
- height: "16",
949
+ width: "18",
950
+ height: "18",
1049
951
  stroke: "currentColor",
1050
952
  strokeWidth: "2.5",
1051
953
  fill: "none",
@@ -1062,8 +964,8 @@ var defaultIcons = {
1062
964
  "svg",
1063
965
  {
1064
966
  viewBox: "0 0 24 24",
1065
- width: "16",
1066
- height: "16",
967
+ width: "18",
968
+ height: "18",
1067
969
  stroke: "currentColor",
1068
970
  strokeWidth: "2.5",
1069
971
  fill: "none",
@@ -1080,8 +982,8 @@ var defaultIcons = {
1080
982
  "svg",
1081
983
  {
1082
984
  viewBox: "0 0 24 24",
1083
- width: "16",
1084
- height: "16",
985
+ width: "18",
986
+ height: "18",
1085
987
  stroke: "currentColor",
1086
988
  strokeWidth: "2.5",
1087
989
  fill: "none",
@@ -1106,33 +1008,19 @@ function UsageBanner({
1106
1008
  return null;
1107
1009
  }
1108
1010
  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.";
1011
+ const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
1012
+ const matches = Array.from(rawMessage.matchAll(linkRegex));
1013
+ if (matches.length > 0) {
1014
+ let cleanMessage2 = rawMessage.replace(/\.\s*See more:\s*\[([^\]]+)\]\(([^)]+)\)/g, ".").replace(/See more:\s*\[([^\]]+)\]\(([^)]+)\)/g, "").trim();
1015
+ return cleanMessage2;
1128
1016
  }
1129
- return cleanMessage2 || "An error occurred. Please check your configuration.";
1017
+ return rawMessage;
1130
1018
  };
1131
1019
  const cleanMessage = parseMessage(message);
1132
1020
  const Icon = icon || defaultIcons[severity];
1133
1021
  const themeConfigs = {
1134
1022
  [import_shared7.Severity.INFO]: {
1135
- bg: "rgba(239, 246, 255, 0.95)",
1023
+ bg: "linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%)",
1136
1024
  border: "#93c5fd",
1137
1025
  text: "#1e40af",
1138
1026
  icon: "#3b82f6",
@@ -1140,7 +1028,7 @@ function UsageBanner({
1140
1028
  primaryBtnHover: "#2563eb"
1141
1029
  },
1142
1030
  [import_shared7.Severity.WARNING]: {
1143
- bg: "rgba(255, 251, 235, 0.95)",
1031
+ bg: "linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%)",
1144
1032
  border: "#fbbf24",
1145
1033
  text: "#92400e",
1146
1034
  icon: "#f59e0b",
@@ -1148,7 +1036,7 @@ function UsageBanner({
1148
1036
  primaryBtnHover: "#d97706"
1149
1037
  },
1150
1038
  [import_shared7.Severity.CRITICAL]: {
1151
- bg: "rgba(254, 242, 242, 0.95)",
1039
+ bg: "linear-gradient(135deg, #fef2f2 0%, #fecaca 100%)",
1152
1040
  border: "#f87171",
1153
1041
  text: "#991b1b",
1154
1042
  icon: "#ef4444",
@@ -1162,26 +1050,24 @@ function UsageBanner({
1162
1050
  {
1163
1051
  style: {
1164
1052
  position: "fixed",
1165
- bottom: "24px",
1053
+ bottom: "20px",
1166
1054
  left: "50%",
1167
1055
  transform: "translateX(-50%)",
1168
- width: "400px",
1169
- maxWidth: "90vw",
1056
+ maxWidth: "min(95vw, 680px)",
1057
+ width: "100%",
1170
1058
  zIndex: 1e4,
1171
- animation: "bannerSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1)"
1059
+ animation: "bannerSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1)"
1172
1060
  },
1173
1061
  children: [
1174
1062
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
1175
1063
  @keyframes bannerSlideIn {
1176
1064
  from {
1177
1065
  opacity: 0;
1178
- transform: translateX(-50%) translateY(20px);
1179
- scale: 0.95;
1066
+ transform: translateX(-50%) translateY(10px);
1180
1067
  }
1181
1068
  to {
1182
1069
  opacity: 1;
1183
1070
  transform: translateX(-50%) translateY(0);
1184
- scale: 1;
1185
1071
  }
1186
1072
  }
1187
1073
  ` }),
@@ -1189,16 +1075,17 @@ function UsageBanner({
1189
1075
  "div",
1190
1076
  {
1191
1077
  style: {
1192
- borderRadius: "12px",
1078
+ display: "flex",
1079
+ alignItems: "flex-start",
1080
+ gap: "14px",
1081
+ borderRadius: "16px",
1193
1082
  border: `1px solid ${themeConfig.border}`,
1194
1083
  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)",
1084
+ padding: "18px 20px",
1085
+ boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",
1197
1086
  position: "relative",
1198
- backdropFilter: "blur(12px)",
1199
- WebkitBackdropFilter: "blur(12px)",
1200
- boxSizing: "border-box",
1201
- overflow: "hidden"
1087
+ backdropFilter: "blur(10px)",
1088
+ WebkitBackdropFilter: "blur(10px)"
1202
1089
  },
1203
1090
  children: [
1204
1091
  onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -1207,23 +1094,35 @@ function UsageBanner({
1207
1094
  onClick: onClose,
1208
1095
  style: {
1209
1096
  position: "absolute",
1210
- top: "8px",
1211
- right: "8px",
1212
- background: "rgba(255, 255, 255, 0.9)",
1097
+ top: "12px",
1098
+ right: "12px",
1099
+ background: "rgba(255, 255, 255, 0.8)",
1213
1100
  border: "none",
1214
1101
  color: themeConfig.text,
1215
1102
  cursor: "pointer",
1216
- fontSize: "16px",
1103
+ fontSize: "18px",
1217
1104
  lineHeight: "1",
1218
- padding: "4px",
1219
- borderRadius: "4px",
1220
- width: "20px",
1221
- height: "20px",
1105
+ padding: "6px",
1106
+ borderRadius: "8px",
1107
+ opacity: 0.7,
1108
+ transition: "all 0.2s ease",
1222
1109
  display: "flex",
1223
1110
  alignItems: "center",
1224
- justifyContent: "center"
1111
+ justifyContent: "center",
1112
+ width: "28px",
1113
+ height: "28px"
1225
1114
  },
1226
1115
  title: "Close",
1116
+ onMouseOver: (e) => {
1117
+ e.currentTarget.style.opacity = "1";
1118
+ e.currentTarget.style.background = "rgba(255, 255, 255, 1)";
1119
+ e.currentTarget.style.transform = "scale(1.05)";
1120
+ },
1121
+ onMouseOut: (e) => {
1122
+ e.currentTarget.style.opacity = "0.7";
1123
+ e.currentTarget.style.background = "rgba(255, 255, 255, 0.8)";
1124
+ e.currentTarget.style.transform = "scale(1)";
1125
+ },
1227
1126
  children: "\xD7"
1228
1127
  }
1229
1128
  ),
@@ -1231,92 +1130,106 @@ function UsageBanner({
1231
1130
  "div",
1232
1131
  {
1233
1132
  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: {
1133
+ color: themeConfig.icon,
1134
+ flexShrink: 0,
1135
+ marginTop: "1px",
1136
+ padding: "6px",
1137
+ borderRadius: "10px",
1138
+ background: "rgba(255, 255, 255, 0.7)",
1255
1139
  display: "flex",
1256
- gap: "8px",
1257
- flexWrap: "wrap"
1140
+ alignItems: "center",
1141
+ justifyContent: "center"
1258
1142
  },
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
- ]
1143
+ children: Icon
1318
1144
  }
1319
- )
1145
+ ),
1146
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { flex: 1, paddingRight: onClose ? "40px" : "0" }, children: [
1147
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1148
+ "div",
1149
+ {
1150
+ style: {
1151
+ fontSize: "15px",
1152
+ fontWeight: 600,
1153
+ color: themeConfig.text,
1154
+ lineHeight: "1.5",
1155
+ marginBottom: actions ? "12px" : "0",
1156
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1157
+ },
1158
+ children: cleanMessage
1159
+ }
1160
+ ),
1161
+ actions && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1162
+ "div",
1163
+ {
1164
+ style: {
1165
+ display: "flex",
1166
+ gap: "10px",
1167
+ flexWrap: "wrap"
1168
+ },
1169
+ children: [
1170
+ actions.secondary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1171
+ "button",
1172
+ {
1173
+ onClick: actions.secondary.onClick,
1174
+ style: {
1175
+ borderRadius: "10px",
1176
+ padding: "8px 16px",
1177
+ fontSize: "14px",
1178
+ fontWeight: 500,
1179
+ color: themeConfig.text,
1180
+ backgroundColor: "rgba(255, 255, 255, 0.8)",
1181
+ border: `1.5px solid ${themeConfig.border}`,
1182
+ cursor: "pointer",
1183
+ transition: "all 0.2s ease",
1184
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1185
+ },
1186
+ onMouseOver: (e) => {
1187
+ e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 1)";
1188
+ e.currentTarget.style.transform = "translateY(-1px)";
1189
+ e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)";
1190
+ },
1191
+ onMouseOut: (e) => {
1192
+ e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.8)";
1193
+ e.currentTarget.style.transform = "translateY(0)";
1194
+ e.currentTarget.style.boxShadow = "none";
1195
+ },
1196
+ children: actions.secondary.label
1197
+ }
1198
+ ),
1199
+ actions.primary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1200
+ "button",
1201
+ {
1202
+ onClick: actions.primary.onClick,
1203
+ style: {
1204
+ borderRadius: "10px",
1205
+ padding: "8px 16px",
1206
+ fontSize: "14px",
1207
+ fontWeight: 600,
1208
+ color: "#fff",
1209
+ backgroundColor: themeConfig.primaryBtn,
1210
+ border: "none",
1211
+ cursor: "pointer",
1212
+ transition: "all 0.2s ease",
1213
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
1214
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1215
+ },
1216
+ onMouseOver: (e) => {
1217
+ e.currentTarget.style.backgroundColor = themeConfig.primaryBtnHover;
1218
+ e.currentTarget.style.transform = "translateY(-1px)";
1219
+ e.currentTarget.style.boxShadow = "0 6px 16px rgba(0, 0, 0, 0.2)";
1220
+ },
1221
+ onMouseOut: (e) => {
1222
+ e.currentTarget.style.backgroundColor = themeConfig.primaryBtn;
1223
+ e.currentTarget.style.transform = "translateY(0)";
1224
+ e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)";
1225
+ },
1226
+ children: actions.primary.label
1227
+ }
1228
+ )
1229
+ ]
1230
+ }
1231
+ )
1232
+ ] })
1320
1233
  ]
1321
1234
  }
1322
1235
  )
@@ -1720,8 +1633,7 @@ ${nonDocumentStrings}`;
1720
1633
  publicApiKey: copilotApiConfig.publicApiKey,
1721
1634
  headers,
1722
1635
  credentials: copilotApiConfig.credentials,
1723
- showDevConsole: (_b = props.showDevConsole) != null ? _b : false,
1724
- onTrace: props.onTrace
1636
+ showDevConsole: (_b = props.showDevConsole) != null ? _b : false
1725
1637
  });
1726
1638
  const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
1727
1639
  const addChatSuggestionConfiguration = (id, suggestion) => {
@@ -1811,7 +1723,6 @@ ${nonDocumentStrings}`;
1811
1723
  const removeLangGraphInterruptAction = (0, import_react10.useCallback)(() => {
1812
1724
  setLangGraphInterruptAction(null);
1813
1725
  }, []);
1814
- const memoizedChildren = (0, import_react10.useMemo)(() => children, [children]);
1815
1726
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1816
1727
  CopilotContext.Provider,
1817
1728
  {
@@ -1864,10 +1775,9 @@ ${nonDocumentStrings}`;
1864
1775
  setExtensions,
1865
1776
  langGraphInterruptAction,
1866
1777
  setLangGraphInterruptAction,
1867
- removeLangGraphInterruptAction,
1868
- onTrace: props.onTrace
1778
+ removeLangGraphInterruptAction
1869
1779
  },
1870
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children: memoizedChildren })
1780
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children })
1871
1781
  }
1872
1782
  );
1873
1783
  }