@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
@@ -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)
@@ -843,7 +776,6 @@ function CopilotMessages({ children }) {
843
776
  });
844
777
  void fetchMessages();
845
778
  }, [threadId, agentSession == null ? void 0 : agentSession.agentName, runtimeClient]);
846
- const memoizedChildren = (0, import_react6.useMemo)(() => children, [children]);
847
779
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
848
780
  CopilotMessagesContext.Provider,
849
781
  {
@@ -851,7 +783,7 @@ function CopilotMessages({ children }) {
851
783
  messages,
852
784
  setMessages
853
785
  },
854
- children: memoizedChildren
786
+ children
855
787
  }
856
788
  );
857
789
  }
@@ -862,35 +794,8 @@ var import_react7 = require("react");
862
794
  var import_shared5 = require("@copilotkit/shared");
863
795
  var useCopilotRuntimeClient = (options) => {
864
796
  const { setBannerError } = useToast();
865
- const _a = options, { showDevConsole, onTrace } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onTrace"]);
797
+ const _a = options, { showDevConsole } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
866
798
  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
799
  const runtimeClient = (0, import_react7.useMemo)(() => {
895
800
  return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
896
801
  handleGQLErrors: (error) => {
@@ -918,14 +823,12 @@ var useCopilotRuntimeClient = (options) => {
918
823
  const ckError = createStructuredError(gqlError);
919
824
  if (ckError) {
920
825
  setBannerError(ckError);
921
- traceUIError(ckError, gqlError);
922
826
  } else {
923
827
  const fallbackError = new import_shared5.CopilotKitError({
924
828
  message: gqlError.message,
925
829
  code: import_shared5.CopilotKitErrorCode.UNKNOWN
926
830
  });
927
831
  setBannerError(fallbackError);
928
- traceUIError(fallbackError, gqlError);
929
832
  }
930
833
  };
931
834
  graphQLErrors.forEach(routeError);
@@ -939,7 +842,6 @@ var useCopilotRuntimeClient = (options) => {
939
842
  code: import_shared5.CopilotKitErrorCode.UNKNOWN
940
843
  });
941
844
  setBannerError(fallbackError);
942
- traceUIError(fallbackError, error);
943
845
  }
944
846
  }
945
847
  },
@@ -952,7 +854,7 @@ var useCopilotRuntimeClient = (options) => {
952
854
  setBannerError(warningError);
953
855
  }
954
856
  }));
955
- }, [runtimeOptions, setBannerError, showDevConsole, onTrace]);
857
+ }, [runtimeOptions, setBannerError, showDevConsole]);
956
858
  return runtimeClient;
957
859
  };
958
860
  function createStructuredError(gqlError) {
@@ -1045,8 +947,8 @@ var defaultIcons = {
1045
947
  "svg",
1046
948
  {
1047
949
  viewBox: "0 0 24 24",
1048
- width: "16",
1049
- height: "16",
950
+ width: "18",
951
+ height: "18",
1050
952
  stroke: "currentColor",
1051
953
  strokeWidth: "2.5",
1052
954
  fill: "none",
@@ -1063,8 +965,8 @@ var defaultIcons = {
1063
965
  "svg",
1064
966
  {
1065
967
  viewBox: "0 0 24 24",
1066
- width: "16",
1067
- height: "16",
968
+ width: "18",
969
+ height: "18",
1068
970
  stroke: "currentColor",
1069
971
  strokeWidth: "2.5",
1070
972
  fill: "none",
@@ -1081,8 +983,8 @@ var defaultIcons = {
1081
983
  "svg",
1082
984
  {
1083
985
  viewBox: "0 0 24 24",
1084
- width: "16",
1085
- height: "16",
986
+ width: "18",
987
+ height: "18",
1086
988
  stroke: "currentColor",
1087
989
  strokeWidth: "2.5",
1088
990
  fill: "none",
@@ -1107,33 +1009,19 @@ function UsageBanner({
1107
1009
  return null;
1108
1010
  }
1109
1011
  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.";
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;
1129
1017
  }
1130
- return cleanMessage2 || "An error occurred. Please check your configuration.";
1018
+ return rawMessage;
1131
1019
  };
1132
1020
  const cleanMessage = parseMessage(message);
1133
1021
  const Icon = icon || defaultIcons[severity];
1134
1022
  const themeConfigs = {
1135
1023
  [import_shared7.Severity.INFO]: {
1136
- bg: "rgba(239, 246, 255, 0.95)",
1024
+ bg: "linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%)",
1137
1025
  border: "#93c5fd",
1138
1026
  text: "#1e40af",
1139
1027
  icon: "#3b82f6",
@@ -1141,7 +1029,7 @@ function UsageBanner({
1141
1029
  primaryBtnHover: "#2563eb"
1142
1030
  },
1143
1031
  [import_shared7.Severity.WARNING]: {
1144
- bg: "rgba(255, 251, 235, 0.95)",
1032
+ bg: "linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%)",
1145
1033
  border: "#fbbf24",
1146
1034
  text: "#92400e",
1147
1035
  icon: "#f59e0b",
@@ -1149,7 +1037,7 @@ function UsageBanner({
1149
1037
  primaryBtnHover: "#d97706"
1150
1038
  },
1151
1039
  [import_shared7.Severity.CRITICAL]: {
1152
- bg: "rgba(254, 242, 242, 0.95)",
1040
+ bg: "linear-gradient(135deg, #fef2f2 0%, #fecaca 100%)",
1153
1041
  border: "#f87171",
1154
1042
  text: "#991b1b",
1155
1043
  icon: "#ef4444",
@@ -1163,26 +1051,24 @@ function UsageBanner({
1163
1051
  {
1164
1052
  style: {
1165
1053
  position: "fixed",
1166
- bottom: "24px",
1054
+ bottom: "20px",
1167
1055
  left: "50%",
1168
1056
  transform: "translateX(-50%)",
1169
- width: "400px",
1170
- maxWidth: "90vw",
1057
+ maxWidth: "min(95vw, 680px)",
1058
+ width: "100%",
1171
1059
  zIndex: 1e4,
1172
- 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)"
1173
1061
  },
1174
1062
  children: [
1175
1063
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
1176
1064
  @keyframes bannerSlideIn {
1177
1065
  from {
1178
1066
  opacity: 0;
1179
- transform: translateX(-50%) translateY(20px);
1180
- scale: 0.95;
1067
+ transform: translateX(-50%) translateY(10px);
1181
1068
  }
1182
1069
  to {
1183
1070
  opacity: 1;
1184
1071
  transform: translateX(-50%) translateY(0);
1185
- scale: 1;
1186
1072
  }
1187
1073
  }
1188
1074
  ` }),
@@ -1190,16 +1076,17 @@ function UsageBanner({
1190
1076
  "div",
1191
1077
  {
1192
1078
  style: {
1193
- borderRadius: "12px",
1079
+ display: "flex",
1080
+ alignItems: "flex-start",
1081
+ gap: "14px",
1082
+ borderRadius: "16px",
1194
1083
  border: `1px solid ${themeConfig.border}`,
1195
1084
  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)",
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)",
1198
1087
  position: "relative",
1199
- backdropFilter: "blur(12px)",
1200
- WebkitBackdropFilter: "blur(12px)",
1201
- boxSizing: "border-box",
1202
- overflow: "hidden"
1088
+ backdropFilter: "blur(10px)",
1089
+ WebkitBackdropFilter: "blur(10px)"
1203
1090
  },
1204
1091
  children: [
1205
1092
  onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -1208,23 +1095,35 @@ function UsageBanner({
1208
1095
  onClick: onClose,
1209
1096
  style: {
1210
1097
  position: "absolute",
1211
- top: "8px",
1212
- right: "8px",
1213
- background: "rgba(255, 255, 255, 0.9)",
1098
+ top: "12px",
1099
+ right: "12px",
1100
+ background: "rgba(255, 255, 255, 0.8)",
1214
1101
  border: "none",
1215
1102
  color: themeConfig.text,
1216
1103
  cursor: "pointer",
1217
- fontSize: "16px",
1104
+ fontSize: "18px",
1218
1105
  lineHeight: "1",
1219
- padding: "4px",
1220
- borderRadius: "4px",
1221
- width: "20px",
1222
- height: "20px",
1106
+ padding: "6px",
1107
+ borderRadius: "8px",
1108
+ opacity: 0.7,
1109
+ transition: "all 0.2s ease",
1223
1110
  display: "flex",
1224
1111
  alignItems: "center",
1225
- justifyContent: "center"
1112
+ justifyContent: "center",
1113
+ width: "28px",
1114
+ height: "28px"
1226
1115
  },
1227
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
+ },
1228
1127
  children: "\xD7"
1229
1128
  }
1230
1129
  ),
@@ -1232,92 +1131,106 @@ function UsageBanner({
1232
1131
  "div",
1233
1132
  {
1234
1133
  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: {
1134
+ color: themeConfig.icon,
1135
+ flexShrink: 0,
1136
+ marginTop: "1px",
1137
+ padding: "6px",
1138
+ borderRadius: "10px",
1139
+ background: "rgba(255, 255, 255, 0.7)",
1256
1140
  display: "flex",
1257
- gap: "8px",
1258
- flexWrap: "wrap"
1141
+ alignItems: "center",
1142
+ justifyContent: "center"
1259
1143
  },
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
- ]
1144
+ children: Icon
1319
1145
  }
1320
- )
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
+ ] })
1321
1234
  ]
1322
1235
  }
1323
1236
  )
@@ -1721,8 +1634,7 @@ ${nonDocumentStrings}`;
1721
1634
  publicApiKey: copilotApiConfig.publicApiKey,
1722
1635
  headers,
1723
1636
  credentials: copilotApiConfig.credentials,
1724
- showDevConsole: (_b = props.showDevConsole) != null ? _b : false,
1725
- onTrace: props.onTrace
1637
+ showDevConsole: (_b = props.showDevConsole) != null ? _b : false
1726
1638
  });
1727
1639
  const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
1728
1640
  const addChatSuggestionConfiguration = (id, suggestion) => {
@@ -1812,7 +1724,6 @@ ${nonDocumentStrings}`;
1812
1724
  const removeLangGraphInterruptAction = (0, import_react10.useCallback)(() => {
1813
1725
  setLangGraphInterruptAction(null);
1814
1726
  }, []);
1815
- const memoizedChildren = (0, import_react10.useMemo)(() => children, [children]);
1816
1727
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1817
1728
  CopilotContext.Provider,
1818
1729
  {
@@ -1865,10 +1776,9 @@ ${nonDocumentStrings}`;
1865
1776
  setExtensions,
1866
1777
  langGraphInterruptAction,
1867
1778
  setLangGraphInterruptAction,
1868
- removeLangGraphInterruptAction,
1869
- onTrace: props.onTrace
1779
+ removeLangGraphInterruptAction
1870
1780
  },
1871
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children: memoizedChildren })
1781
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children })
1872
1782
  }
1873
1783
  );
1874
1784
  }