@copilotkit/react-core 1.9.2-next.8 → 1.9.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 (171) hide show
  1. package/CHANGELOG.md +193 -0
  2. package/dist/{chunk-ERXWDCY6.mjs → chunk-36MGCCPZ.mjs} +2 -2
  3. package/dist/{chunk-CCESTGAM.mjs → chunk-3OQM3NEK.mjs} +2 -2
  4. package/dist/{chunk-7G6RR4HE.mjs → chunk-3Q4F7RF2.mjs} +2 -2
  5. package/dist/chunk-57K2ZJ5F.mjs +348 -0
  6. package/dist/chunk-57K2ZJ5F.mjs.map +1 -0
  7. package/dist/{chunk-UBNRUXEK.mjs → chunk-5BSUSFHM.mjs} +2 -2
  8. package/dist/{chunk-RN3ZRHI7.mjs → chunk-AD7DWJNW.mjs} +66 -25
  9. package/dist/chunk-AD7DWJNW.mjs.map +1 -0
  10. package/dist/{chunk-JPMIAGI6.mjs → chunk-BVK7PLK6.mjs} +2 -2
  11. package/dist/{chunk-VJCHRQ7Q.mjs → chunk-DGON3GZX.mjs} +39 -6
  12. package/dist/chunk-DGON3GZX.mjs.map +1 -0
  13. package/dist/{chunk-XFOTNHYA.mjs → chunk-DKZTPL66.mjs} +2 -2
  14. package/dist/{chunk-XFOTNHYA.mjs.map → chunk-DKZTPL66.mjs.map} +1 -1
  15. package/dist/{chunk-S4BOATBG.mjs → chunk-FN3UA2ZE.mjs} +3 -3
  16. package/dist/{chunk-ISYBUDL4.mjs → chunk-JWAXDYOW.mjs} +11 -12
  17. package/dist/chunk-JWAXDYOW.mjs.map +1 -0
  18. package/dist/{chunk-T4ZKC4X4.mjs → chunk-KIXKBJUV.mjs} +3 -3
  19. package/dist/{chunk-I4JPQECN.mjs → chunk-LFAZTKBK.mjs} +5 -5
  20. package/dist/{chunk-JHIZ5HAI.mjs → chunk-NJA5ZLAZ.mjs} +29 -10
  21. package/dist/chunk-NJA5ZLAZ.mjs.map +1 -0
  22. package/dist/{chunk-ZHEEHGLS.mjs → chunk-QGT4JO7R.mjs} +35 -6
  23. package/dist/chunk-QGT4JO7R.mjs.map +1 -0
  24. package/dist/{chunk-JXF732XG.mjs → chunk-S5QUEHJC.mjs} +195 -77
  25. package/dist/chunk-S5QUEHJC.mjs.map +1 -0
  26. package/dist/{chunk-QQZLIEXK.mjs → chunk-SJJNFYGQ.mjs} +3 -3
  27. package/dist/{chunk-CMQV4XNY.mjs → chunk-VDADWRS3.mjs} +2 -2
  28. package/dist/chunk-YAF2LATQ.mjs +310 -0
  29. package/dist/chunk-YAF2LATQ.mjs.map +1 -0
  30. package/dist/{chunk-VF6UPRKM.mjs → chunk-ZGMZ5WJI.mjs} +4 -4
  31. package/dist/components/copilot-provider/copilot-messages.js +37 -4
  32. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  33. package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
  34. package/dist/components/copilot-provider/copilotkit-props.d.ts +14 -9
  35. package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
  36. package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
  37. package/dist/components/copilot-provider/copilotkit.js +354 -258
  38. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  39. package/dist/components/copilot-provider/copilotkit.mjs +10 -10
  40. package/dist/components/copilot-provider/index.d.ts +1 -1
  41. package/dist/components/copilot-provider/index.js +354 -258
  42. package/dist/components/copilot-provider/index.js.map +1 -1
  43. package/dist/components/copilot-provider/index.mjs +10 -10
  44. package/dist/components/error-boundary/error-boundary.js +135 -146
  45. package/dist/components/error-boundary/error-boundary.js.map +1 -1
  46. package/dist/components/error-boundary/error-boundary.mjs +4 -4
  47. package/dist/components/error-boundary/error-utils.js.map +1 -1
  48. package/dist/components/error-boundary/error-utils.mjs +2 -2
  49. package/dist/components/index.d.ts +1 -1
  50. package/dist/components/index.js +354 -258
  51. package/dist/components/index.js.map +1 -1
  52. package/dist/components/index.mjs +10 -10
  53. package/dist/components/toast/toast-provider.js +118 -85
  54. package/dist/components/toast/toast-provider.js.map +1 -1
  55. package/dist/components/toast/toast-provider.mjs +1 -1
  56. package/dist/components/usage-banner.js +135 -146
  57. package/dist/components/usage-banner.js.map +1 -1
  58. package/dist/components/usage-banner.mjs +1 -1
  59. package/dist/context/copilot-context.d.ts +1 -1
  60. package/dist/context/copilot-context.js +1 -1
  61. package/dist/context/copilot-context.js.map +1 -1
  62. package/dist/context/copilot-context.mjs +1 -1
  63. package/dist/context/index.d.ts +1 -1
  64. package/dist/context/index.js +1 -1
  65. package/dist/context/index.js.map +1 -1
  66. package/dist/context/index.mjs +1 -1
  67. package/dist/{copilot-context-3da805ab.d.ts → copilot-context-3ab4fdf5.d.ts} +3 -3
  68. package/dist/hooks/index.d.ts +1 -1
  69. package/dist/hooks/index.js +249 -88
  70. package/dist/hooks/index.js.map +1 -1
  71. package/dist/hooks/index.mjs +32 -32
  72. package/dist/hooks/use-chat.d.ts +1 -1
  73. package/dist/hooks/use-chat.js +287 -174
  74. package/dist/hooks/use-chat.js.map +1 -1
  75. package/dist/hooks/use-chat.mjs +5 -5
  76. package/dist/hooks/use-coagent-state-render.js +1 -1
  77. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  78. package/dist/hooks/use-coagent-state-render.mjs +3 -3
  79. package/dist/hooks/use-coagent.d.ts +1 -1
  80. package/dist/hooks/use-coagent.js +224 -82
  81. package/dist/hooks/use-coagent.js.map +1 -1
  82. package/dist/hooks/use-coagent.mjs +14 -14
  83. package/dist/hooks/use-copilot-action.js +26 -7
  84. package/dist/hooks/use-copilot-action.js.map +1 -1
  85. package/dist/hooks/use-copilot-action.mjs +4 -4
  86. package/dist/hooks/use-copilot-additional-instructions.js +1 -1
  87. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  88. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  89. package/dist/hooks/use-copilot-authenticated-action.js +26 -7
  90. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  91. package/dist/hooks/use-copilot-authenticated-action.mjs +5 -5
  92. package/dist/hooks/use-copilot-chat.d.ts +1 -1
  93. package/dist/hooks/use-copilot-chat.js +195 -82
  94. package/dist/hooks/use-copilot-chat.js.map +1 -1
  95. package/dist/hooks/use-copilot-chat.mjs +13 -13
  96. package/dist/hooks/use-copilot-readable.js +1 -1
  97. package/dist/hooks/use-copilot-readable.js.map +1 -1
  98. package/dist/hooks/use-copilot-readable.mjs +2 -2
  99. package/dist/hooks/use-copilot-runtime-client.d.ts +2 -2
  100. package/dist/hooks/use-copilot-runtime-client.js +8 -8
  101. package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
  102. package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
  103. package/dist/hooks/use-langgraph-interrupt-render.js +1 -1
  104. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  105. package/dist/hooks/use-langgraph-interrupt-render.mjs +2 -2
  106. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  107. package/dist/hooks/use-langgraph-interrupt.js +195 -82
  108. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  109. package/dist/hooks/use-langgraph-interrupt.mjs +14 -14
  110. package/dist/hooks/use-make-copilot-document-readable.js +1 -1
  111. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  112. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  113. package/dist/index.d.ts +1 -1
  114. package/dist/index.js +593 -336
  115. package/dist/index.js.map +1 -1
  116. package/dist/index.mjs +33 -33
  117. package/dist/lib/copilot-task.d.ts +1 -1
  118. package/dist/lib/copilot-task.js.map +1 -1
  119. package/dist/lib/copilot-task.mjs +11 -11
  120. package/dist/lib/index.d.ts +1 -1
  121. package/dist/lib/index.js.map +1 -1
  122. package/dist/lib/index.mjs +11 -11
  123. package/dist/setupTests.d.ts +2 -0
  124. package/dist/setupTests.js +26 -0
  125. package/dist/setupTests.js.map +1 -0
  126. package/dist/setupTests.mjs +24 -0
  127. package/dist/setupTests.mjs.map +1 -0
  128. package/dist/types/interrupt-action.d.ts +1 -1
  129. package/dist/utils/extract.d.ts +1 -1
  130. package/dist/utils/extract.js.map +1 -1
  131. package/dist/utils/extract.mjs +10 -10
  132. package/dist/utils/index.d.ts +1 -1
  133. package/dist/utils/index.js.map +1 -1
  134. package/dist/utils/index.mjs +10 -10
  135. package/jest.config.js +4 -0
  136. package/package.json +6 -3
  137. package/src/components/copilot-provider/__tests__/{copilotkit-trace.test.tsx → copilotkit-error.test.tsx} +17 -17
  138. package/src/components/copilot-provider/copilot-messages.tsx +43 -4
  139. package/src/components/copilot-provider/copilotkit-props.tsx +13 -8
  140. package/src/components/copilot-provider/copilotkit.tsx +61 -19
  141. package/src/components/toast/toast-provider.tsx +49 -24
  142. package/src/components/usage-banner.tsx +144 -147
  143. package/src/context/copilot-context.tsx +4 -4
  144. package/src/hooks/__tests__/use-coagent-config.test.ts +284 -0
  145. package/src/hooks/use-chat.ts +249 -61
  146. package/src/hooks/use-coagent.ts +41 -0
  147. package/src/hooks/use-copilot-action.ts +51 -9
  148. package/src/hooks/use-copilot-runtime-client.ts +12 -50
  149. package/src/setupTests.ts +26 -0
  150. package/tsconfig.json +5 -2
  151. package/dist/chunk-HD2GE3DK.mjs +0 -359
  152. package/dist/chunk-HD2GE3DK.mjs.map +0 -1
  153. package/dist/chunk-ISYBUDL4.mjs.map +0 -1
  154. package/dist/chunk-JHIZ5HAI.mjs.map +0 -1
  155. package/dist/chunk-JXF732XG.mjs.map +0 -1
  156. package/dist/chunk-RN3ZRHI7.mjs.map +0 -1
  157. package/dist/chunk-VJCHRQ7Q.mjs.map +0 -1
  158. package/dist/chunk-VRXANACV.mjs +0 -277
  159. package/dist/chunk-VRXANACV.mjs.map +0 -1
  160. package/dist/chunk-ZHEEHGLS.mjs.map +0 -1
  161. /package/dist/{chunk-ERXWDCY6.mjs.map → chunk-36MGCCPZ.mjs.map} +0 -0
  162. /package/dist/{chunk-CCESTGAM.mjs.map → chunk-3OQM3NEK.mjs.map} +0 -0
  163. /package/dist/{chunk-7G6RR4HE.mjs.map → chunk-3Q4F7RF2.mjs.map} +0 -0
  164. /package/dist/{chunk-UBNRUXEK.mjs.map → chunk-5BSUSFHM.mjs.map} +0 -0
  165. /package/dist/{chunk-JPMIAGI6.mjs.map → chunk-BVK7PLK6.mjs.map} +0 -0
  166. /package/dist/{chunk-S4BOATBG.mjs.map → chunk-FN3UA2ZE.mjs.map} +0 -0
  167. /package/dist/{chunk-T4ZKC4X4.mjs.map → chunk-KIXKBJUV.mjs.map} +0 -0
  168. /package/dist/{chunk-I4JPQECN.mjs.map → chunk-LFAZTKBK.mjs.map} +0 -0
  169. /package/dist/{chunk-QQZLIEXK.mjs.map → chunk-SJJNFYGQ.mjs.map} +0 -0
  170. /package/dist/{chunk-CMQV4XNY.mjs.map → chunk-VDADWRS3.mjs.map} +0 -0
  171. /package/dist/{chunk-VF6UPRKM.mjs.map → chunk-ZGMZ5WJI.mjs.map} +0 -0
@@ -162,7 +162,7 @@ var emptyCopilotContext = {
162
162
  langGraphInterruptAction: null,
163
163
  setLangGraphInterruptAction: () => null,
164
164
  removeLangGraphInterruptAction: () => null,
165
- onTrace: void 0
165
+ onError: void 0
166
166
  };
167
167
  var CopilotContext = import_react.default.createContext(emptyCopilotContext);
168
168
  function useCopilotContext() {
@@ -517,12 +517,14 @@ function ToastProvider({
517
517
  border: `1px solid ${colors.border}`,
518
518
  borderLeft: `4px solid ${colors.border}`,
519
519
  borderRadius: "8px",
520
- padding: "10px 14px",
520
+ padding: "12px 16px",
521
521
  fontSize: "13px",
522
522
  boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
523
523
  backdropFilter: "blur(8px)",
524
- maxWidth: "500px",
525
- minWidth: "350px"
524
+ maxWidth: "min(90vw, 700px)",
525
+ width: "100%",
526
+ boxSizing: "border-box",
527
+ overflow: "hidden"
526
528
  },
527
529
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
528
530
  "div",
@@ -534,94 +536,125 @@ function ToastProvider({
534
536
  gap: "10px"
535
537
  },
536
538
  children: [
537
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", flex: 1 }, children: [
538
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
539
- "div",
540
- {
541
- style: {
542
- width: "12px",
543
- height: "12px",
544
- borderRadius: "50%",
545
- backgroundColor: colors.border,
546
- flexShrink: 0
547
- }
548
- }
549
- ),
550
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "10px", flex: 1 }, children: [
551
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
552
- "div",
553
- {
554
- style: {
555
- color: colors.text,
556
- lineHeight: "1.4",
557
- fontWeight: "400",
558
- fontSize: "13px",
559
- flex: 1,
560
- wordWrap: "break-word",
561
- overflowWrap: "break-word",
562
- hyphens: "auto"
563
- },
564
- children: (() => {
565
- const message = bannerError.message;
566
- const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
567
- const plainUrlRegex = /(https?:\/\/[^\s)]+)/g;
568
- let cleanMessage = message.replace(markdownLinkRegex, "").replace(plainUrlRegex, "").replace(/See more:\s*/g, "").replace(/\s+/g, " ").trim();
569
- if (cleanMessage.length > 120) {
570
- cleanMessage = cleanMessage.substring(0, 117) + "...";
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
571
559
  }
572
- return cleanMessage;
573
- })()
574
- }
575
- ),
576
- (() => {
577
- const message = bannerError.message;
578
- const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
579
- const plainUrlRegex = /(https?:\/\/[^\s)]+)/g;
580
- let url = null;
581
- let buttonText = "See More";
582
- const markdownMatch = markdownLinkRegex.exec(message);
583
- if (markdownMatch) {
584
- url = markdownMatch[2];
585
- buttonText = "See More";
586
- } else {
587
- const urlMatch = plainUrlRegex.exec(message);
588
- if (urlMatch) {
589
- url = urlMatch[0];
590
- buttonText = "See More";
591
560
  }
592
- }
593
- if (!url)
594
- return null;
595
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
596
- "button",
561
+ ),
562
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
563
+ "div",
597
564
  {
598
- onClick: () => window.open(url, "_blank", "noopener,noreferrer"),
599
565
  style: {
600
- background: colors.border,
601
- color: "white",
602
- border: "none",
603
- borderRadius: "5px",
604
- padding: "4px 10px",
605
- fontSize: "11px",
606
- fontWeight: "500",
607
- cursor: "pointer",
608
- transition: "all 0.2s ease",
609
- flexShrink: 0
566
+ display: "flex",
567
+ alignItems: "center",
568
+ gap: "10px",
569
+ flex: 1,
570
+ minWidth: 0
610
571
  },
611
- onMouseEnter: (e) => {
612
- e.currentTarget.style.opacity = "0.9";
613
- e.currentTarget.style.transform = "translateY(-1px)";
614
- },
615
- onMouseLeave: (e) => {
616
- e.currentTarget.style.opacity = "1";
617
- e.currentTarget.style.transform = "translateY(0)";
618
- },
619
- children: buttonText
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
+ ]
620
653
  }
621
- );
622
- })()
623
- ] })
624
- ] }),
654
+ )
655
+ ]
656
+ }
657
+ ),
625
658
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
626
659
  "button",
627
660
  {
@@ -674,8 +707,38 @@ function CopilotMessages({ children }) {
674
707
  const lastLoadedThreadId = (0, import_react6.useRef)();
675
708
  const lastLoadedAgentName = (0, import_react6.useRef)();
676
709
  const lastLoadedMessages = (0, import_react6.useRef)();
677
- const { threadId, agentSession, runtimeClient, showDevConsole } = useCopilotContext();
710
+ const { threadId, agentSession, runtimeClient, showDevConsole, onError, copilotApiConfig } = useCopilotContext();
678
711
  const { setBannerError } = useToast();
712
+ const traceUIError = (0, import_react6.useCallback)(
713
+ (error, originalError) => __async(this, null, function* () {
714
+ if (!onError || !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 onError(traceEvent);
736
+ } catch (traceError) {
737
+ console.error("Error in CopilotMessages onError handler:", traceError);
738
+ }
739
+ }),
740
+ [onError, copilotApiConfig.publicApiKey, copilotApiConfig.chatApiEndpoint]
741
+ );
679
742
  const createStructuredError2 = (gqlError) => {
680
743
  const extensions = gqlError.extensions;
681
744
  const originalError = extensions == null ? void 0 : extensions.originalError;
@@ -720,12 +783,14 @@ function CopilotMessages({ children }) {
720
783
  const ckError = createStructuredError2(gqlError);
721
784
  if (ckError) {
722
785
  setBannerError(ckError);
786
+ traceUIError(ckError, gqlError);
723
787
  } else {
724
788
  const fallbackError = new import_shared4.CopilotKitError({
725
789
  message: gqlError.message,
726
790
  code: import_shared4.CopilotKitErrorCode.UNKNOWN
727
791
  });
728
792
  setBannerError(fallbackError);
793
+ traceUIError(fallbackError, gqlError);
729
794
  }
730
795
  };
731
796
  graphQLErrors.forEach(routeError);
@@ -739,10 +804,11 @@ function CopilotMessages({ children }) {
739
804
  code: import_shared4.CopilotKitErrorCode.UNKNOWN
740
805
  });
741
806
  setBannerError(fallbackError);
807
+ traceUIError(fallbackError, error);
742
808
  }
743
809
  }
744
810
  },
745
- [setBannerError, showDevConsole]
811
+ [setBannerError, showDevConsole, traceUIError]
746
812
  );
747
813
  (0, import_react6.useEffect)(() => {
748
814
  if (!threadId || threadId === lastLoadedThreadId.current)
@@ -776,7 +842,7 @@ function CopilotMessages({ children }) {
776
842
  }
777
843
  });
778
844
  void fetchMessages();
779
- }, [threadId, agentSession == null ? void 0 : agentSession.agentName, runtimeClient]);
845
+ }, [threadId, agentSession == null ? void 0 : agentSession.agentName]);
780
846
  const memoizedChildren = (0, import_react6.useMemo)(() => children, [children]);
781
847
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
782
848
  CopilotMessagesContext.Provider,
@@ -796,13 +862,13 @@ var import_react7 = require("react");
796
862
  var import_shared5 = require("@copilotkit/shared");
797
863
  var useCopilotRuntimeClient = (options) => {
798
864
  const { setBannerError } = useToast();
799
- const _a = options, { showDevConsole, onTrace } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onTrace"]);
865
+ const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
800
866
  const lastStructuredErrorRef = (0, import_react7.useRef)(null);
801
867
  const traceUIError = (error, originalError) => __async(void 0, null, function* () {
802
- if (!onTrace || !runtimeOptions.publicApiKey)
868
+ if (!onError || !runtimeOptions.publicApiKey)
803
869
  return;
804
870
  try {
805
- const traceEvent = {
871
+ const errorEvent = {
806
872
  type: "error",
807
873
  timestamp: Date.now(),
808
874
  context: {
@@ -813,16 +879,16 @@ var useCopilotRuntimeClient = (options) => {
813
879
  startTime: Date.now()
814
880
  },
815
881
  technical: {
816
- environment: process.env.NODE_ENV,
882
+ environment: "browser",
817
883
  userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
818
884
  stackTrace: originalError instanceof Error ? originalError.stack : void 0
819
885
  }
820
886
  },
821
887
  error
822
888
  };
823
- yield onTrace(traceEvent);
824
- } catch (traceError) {
825
- console.error("Error in onTrace handler:", traceError);
889
+ yield onError(errorEvent);
890
+ } catch (error2) {
891
+ console.error("Error in onError handler:", error2);
826
892
  }
827
893
  });
828
894
  const runtimeClient = (0, import_react7.useMemo)(() => {
@@ -886,7 +952,7 @@ var useCopilotRuntimeClient = (options) => {
886
952
  setBannerError(warningError);
887
953
  }
888
954
  }));
889
- }, [runtimeOptions, setBannerError, showDevConsole, onTrace]);
955
+ }, [runtimeOptions, setBannerError, showDevConsole, onError]);
890
956
  return runtimeClient;
891
957
  };
892
958
  function createStructuredError(gqlError) {
@@ -979,8 +1045,8 @@ var defaultIcons = {
979
1045
  "svg",
980
1046
  {
981
1047
  viewBox: "0 0 24 24",
982
- width: "18",
983
- height: "18",
1048
+ width: "16",
1049
+ height: "16",
984
1050
  stroke: "currentColor",
985
1051
  strokeWidth: "2.5",
986
1052
  fill: "none",
@@ -997,8 +1063,8 @@ var defaultIcons = {
997
1063
  "svg",
998
1064
  {
999
1065
  viewBox: "0 0 24 24",
1000
- width: "18",
1001
- height: "18",
1066
+ width: "16",
1067
+ height: "16",
1002
1068
  stroke: "currentColor",
1003
1069
  strokeWidth: "2.5",
1004
1070
  fill: "none",
@@ -1015,8 +1081,8 @@ var defaultIcons = {
1015
1081
  "svg",
1016
1082
  {
1017
1083
  viewBox: "0 0 24 24",
1018
- width: "18",
1019
- height: "18",
1084
+ width: "16",
1085
+ height: "16",
1020
1086
  stroke: "currentColor",
1021
1087
  strokeWidth: "2.5",
1022
1088
  fill: "none",
@@ -1041,19 +1107,33 @@ function UsageBanner({
1041
1107
  return null;
1042
1108
  }
1043
1109
  const parseMessage = (rawMessage) => {
1044
- const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
1045
- const matches = Array.from(rawMessage.matchAll(linkRegex));
1046
- if (matches.length > 0) {
1047
- let cleanMessage2 = rawMessage.replace(/\.\s*See more:\s*\[([^\]]+)\]\(([^)]+)\)/g, ".").replace(/See more:\s*\[([^\]]+)\]\(([^)]+)\)/g, "").trim();
1048
- return cleanMessage2;
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.";
1049
1118
  }
1050
- return rawMessage;
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.";
1129
+ }
1130
+ return cleanMessage2 || "An error occurred. Please check your configuration.";
1051
1131
  };
1052
1132
  const cleanMessage = parseMessage(message);
1053
1133
  const Icon = icon || defaultIcons[severity];
1054
1134
  const themeConfigs = {
1055
1135
  [import_shared7.Severity.INFO]: {
1056
- bg: "linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%)",
1136
+ bg: "rgba(239, 246, 255, 0.95)",
1057
1137
  border: "#93c5fd",
1058
1138
  text: "#1e40af",
1059
1139
  icon: "#3b82f6",
@@ -1061,7 +1141,7 @@ function UsageBanner({
1061
1141
  primaryBtnHover: "#2563eb"
1062
1142
  },
1063
1143
  [import_shared7.Severity.WARNING]: {
1064
- bg: "linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%)",
1144
+ bg: "rgba(255, 251, 235, 0.95)",
1065
1145
  border: "#fbbf24",
1066
1146
  text: "#92400e",
1067
1147
  icon: "#f59e0b",
@@ -1069,7 +1149,7 @@ function UsageBanner({
1069
1149
  primaryBtnHover: "#d97706"
1070
1150
  },
1071
1151
  [import_shared7.Severity.CRITICAL]: {
1072
- bg: "linear-gradient(135deg, #fef2f2 0%, #fecaca 100%)",
1152
+ bg: "rgba(254, 242, 242, 0.95)",
1073
1153
  border: "#f87171",
1074
1154
  text: "#991b1b",
1075
1155
  icon: "#ef4444",
@@ -1083,24 +1163,26 @@ function UsageBanner({
1083
1163
  {
1084
1164
  style: {
1085
1165
  position: "fixed",
1086
- bottom: "20px",
1166
+ bottom: "24px",
1087
1167
  left: "50%",
1088
1168
  transform: "translateX(-50%)",
1089
- maxWidth: "min(95vw, 680px)",
1090
- width: "100%",
1169
+ width: "400px",
1170
+ maxWidth: "90vw",
1091
1171
  zIndex: 1e4,
1092
- animation: "bannerSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1)"
1172
+ animation: "bannerSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1)"
1093
1173
  },
1094
1174
  children: [
1095
1175
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
1096
1176
  @keyframes bannerSlideIn {
1097
1177
  from {
1098
1178
  opacity: 0;
1099
- transform: translateX(-50%) translateY(10px);
1179
+ transform: translateX(-50%) translateY(20px);
1180
+ scale: 0.95;
1100
1181
  }
1101
1182
  to {
1102
1183
  opacity: 1;
1103
1184
  transform: translateX(-50%) translateY(0);
1185
+ scale: 1;
1104
1186
  }
1105
1187
  }
1106
1188
  ` }),
@@ -1108,17 +1190,16 @@ function UsageBanner({
1108
1190
  "div",
1109
1191
  {
1110
1192
  style: {
1111
- display: "flex",
1112
- alignItems: "flex-start",
1113
- gap: "14px",
1114
- borderRadius: "16px",
1193
+ borderRadius: "12px",
1115
1194
  border: `1px solid ${themeConfig.border}`,
1116
1195
  background: themeConfig.bg,
1117
- padding: "18px 20px",
1118
- boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",
1196
+ padding: "14px",
1197
+ boxShadow: "0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08)",
1119
1198
  position: "relative",
1120
- backdropFilter: "blur(10px)",
1121
- WebkitBackdropFilter: "blur(10px)"
1199
+ backdropFilter: "blur(12px)",
1200
+ WebkitBackdropFilter: "blur(12px)",
1201
+ boxSizing: "border-box",
1202
+ overflow: "hidden"
1122
1203
  },
1123
1204
  children: [
1124
1205
  onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -1127,35 +1208,23 @@ function UsageBanner({
1127
1208
  onClick: onClose,
1128
1209
  style: {
1129
1210
  position: "absolute",
1130
- top: "12px",
1131
- right: "12px",
1132
- background: "rgba(255, 255, 255, 0.8)",
1211
+ top: "8px",
1212
+ right: "8px",
1213
+ background: "rgba(255, 255, 255, 0.9)",
1133
1214
  border: "none",
1134
1215
  color: themeConfig.text,
1135
1216
  cursor: "pointer",
1136
- fontSize: "18px",
1217
+ fontSize: "16px",
1137
1218
  lineHeight: "1",
1138
- padding: "6px",
1139
- borderRadius: "8px",
1140
- opacity: 0.7,
1141
- transition: "all 0.2s ease",
1219
+ padding: "4px",
1220
+ borderRadius: "4px",
1221
+ width: "20px",
1222
+ height: "20px",
1142
1223
  display: "flex",
1143
1224
  alignItems: "center",
1144
- justifyContent: "center",
1145
- width: "28px",
1146
- height: "28px"
1225
+ justifyContent: "center"
1147
1226
  },
1148
1227
  title: "Close",
1149
- onMouseOver: (e) => {
1150
- e.currentTarget.style.opacity = "1";
1151
- e.currentTarget.style.background = "rgba(255, 255, 255, 1)";
1152
- e.currentTarget.style.transform = "scale(1.05)";
1153
- },
1154
- onMouseOut: (e) => {
1155
- e.currentTarget.style.opacity = "0.7";
1156
- e.currentTarget.style.background = "rgba(255, 255, 255, 0.8)";
1157
- e.currentTarget.style.transform = "scale(1)";
1158
- },
1159
1228
  children: "\xD7"
1160
1229
  }
1161
1230
  ),
@@ -1163,106 +1232,92 @@ function UsageBanner({
1163
1232
  "div",
1164
1233
  {
1165
1234
  style: {
1166
- color: themeConfig.icon,
1167
- flexShrink: 0,
1168
- marginTop: "1px",
1169
- padding: "6px",
1170
- borderRadius: "10px",
1171
- background: "rgba(255, 255, 255, 0.7)",
1172
- display: "flex",
1173
- alignItems: "center",
1174
- justifyContent: "center"
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"
1175
1248
  },
1176
- children: Icon
1249
+ children: cleanMessage
1177
1250
  }
1178
1251
  ),
1179
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { flex: 1, paddingRight: onClose ? "40px" : "0" }, children: [
1180
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1181
- "div",
1182
- {
1183
- style: {
1184
- fontSize: "15px",
1185
- fontWeight: 600,
1186
- color: themeConfig.text,
1187
- lineHeight: "1.5",
1188
- marginBottom: actions ? "12px" : "0",
1189
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1190
- },
1191
- children: cleanMessage
1192
- }
1193
- ),
1194
- actions && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1195
- "div",
1196
- {
1197
- style: {
1198
- display: "flex",
1199
- gap: "10px",
1200
- flexWrap: "wrap"
1201
- },
1202
- children: [
1203
- actions.secondary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1204
- "button",
1205
- {
1206
- onClick: actions.secondary.onClick,
1207
- style: {
1208
- borderRadius: "10px",
1209
- padding: "8px 16px",
1210
- fontSize: "14px",
1211
- fontWeight: 500,
1212
- color: themeConfig.text,
1213
- backgroundColor: "rgba(255, 255, 255, 0.8)",
1214
- border: `1.5px solid ${themeConfig.border}`,
1215
- cursor: "pointer",
1216
- transition: "all 0.2s ease",
1217
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1218
- },
1219
- onMouseOver: (e) => {
1220
- e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 1)";
1221
- e.currentTarget.style.transform = "translateY(-1px)";
1222
- e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)";
1223
- },
1224
- onMouseOut: (e) => {
1225
- e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.8)";
1226
- e.currentTarget.style.transform = "translateY(0)";
1227
- e.currentTarget.style.boxShadow = "none";
1228
- },
1229
- children: actions.secondary.label
1230
- }
1231
- ),
1232
- actions.primary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1233
- "button",
1234
- {
1235
- onClick: actions.primary.onClick,
1236
- style: {
1237
- borderRadius: "10px",
1238
- padding: "8px 16px",
1239
- fontSize: "14px",
1240
- fontWeight: 600,
1241
- color: "#fff",
1242
- backgroundColor: themeConfig.primaryBtn,
1243
- border: "none",
1244
- cursor: "pointer",
1245
- transition: "all 0.2s ease",
1246
- boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
1247
- fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
1248
- },
1249
- onMouseOver: (e) => {
1250
- e.currentTarget.style.backgroundColor = themeConfig.primaryBtnHover;
1251
- e.currentTarget.style.transform = "translateY(-1px)";
1252
- e.currentTarget.style.boxShadow = "0 6px 16px rgba(0, 0, 0, 0.2)";
1253
- },
1254
- onMouseOut: (e) => {
1255
- e.currentTarget.style.backgroundColor = themeConfig.primaryBtn;
1256
- e.currentTarget.style.transform = "translateY(0)";
1257
- e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.15)";
1258
- },
1259
- children: actions.primary.label
1260
- }
1261
- )
1262
- ]
1263
- }
1264
- )
1265
- ] })
1252
+ actions && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1253
+ "div",
1254
+ {
1255
+ style: {
1256
+ display: "flex",
1257
+ gap: "8px",
1258
+ flexWrap: "wrap"
1259
+ },
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
+ ]
1319
+ }
1320
+ )
1266
1321
  ]
1267
1322
  }
1268
1323
  )
@@ -1667,18 +1722,24 @@ ${nonDocumentStrings}`;
1667
1722
  headers,
1668
1723
  credentials: copilotApiConfig.credentials,
1669
1724
  showDevConsole: (_b = props.showDevConsole) != null ? _b : false,
1670
- onTrace: props.onTrace
1725
+ onError: props.onError
1671
1726
  });
1672
1727
  const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
1673
- const addChatSuggestionConfiguration = (id, suggestion) => {
1674
- setChatSuggestionConfiguration((prev) => __spreadProps(__spreadValues({}, prev), { [id]: suggestion }));
1675
- };
1676
- const removeChatSuggestionConfiguration = (id) => {
1677
- setChatSuggestionConfiguration((prev) => {
1678
- const _a2 = prev, { [id]: _ } = _a2, rest = __objRest(_a2, [__restKey(id)]);
1679
- return rest;
1680
- });
1681
- };
1728
+ const addChatSuggestionConfiguration = (0, import_react10.useCallback)(
1729
+ (id, suggestion) => {
1730
+ setChatSuggestionConfiguration((prev) => __spreadProps(__spreadValues({}, prev), { [id]: suggestion }));
1731
+ },
1732
+ [setChatSuggestionConfiguration]
1733
+ );
1734
+ const removeChatSuggestionConfiguration = (0, import_react10.useCallback)(
1735
+ (id) => {
1736
+ setChatSuggestionConfiguration((prev) => {
1737
+ const _a2 = prev, { [id]: _ } = _a2, rest = __objRest(_a2, [__restKey(id)]);
1738
+ return rest;
1739
+ });
1740
+ },
1741
+ [setChatSuggestionConfiguration]
1742
+ );
1682
1743
  const [availableAgents, setAvailableAgents] = (0, import_react10.useState)([]);
1683
1744
  const [coagentStates, setCoagentStates] = (0, import_react10.useState)({});
1684
1745
  const coagentStatesRef = (0, import_react10.useRef)({});
@@ -1758,6 +1819,41 @@ ${nonDocumentStrings}`;
1758
1819
  setLangGraphInterruptAction(null);
1759
1820
  }, []);
1760
1821
  const memoizedChildren = (0, import_react10.useMemo)(() => children, [children]);
1822
+ const agentLock = (0, import_react10.useMemo)(() => {
1823
+ var _a2;
1824
+ return (_a2 = props.agent) != null ? _a2 : null;
1825
+ }, [props.agent]);
1826
+ const forwardedParameters = (0, import_react10.useMemo)(
1827
+ () => {
1828
+ var _a2;
1829
+ return (_a2 = props.forwardedParameters) != null ? _a2 : {};
1830
+ },
1831
+ [props.forwardedParameters]
1832
+ );
1833
+ const updateExtensions = (0, import_react10.useCallback)(
1834
+ (newExtensions) => {
1835
+ setExtensions((prev) => {
1836
+ const resolved = typeof newExtensions === "function" ? newExtensions(prev) : newExtensions;
1837
+ const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;
1838
+ const isEqual = isSameLength && // @ts-ignore
1839
+ Object.entries(resolved).every(([key, value]) => prev[key] === value);
1840
+ return isEqual ? prev : resolved;
1841
+ });
1842
+ },
1843
+ [setExtensions]
1844
+ );
1845
+ const updateAuthStates = (0, import_react10.useCallback)(
1846
+ (newAuthStates) => {
1847
+ setAuthStates((prev) => {
1848
+ const resolved = typeof newAuthStates === "function" ? newAuthStates(prev) : newAuthStates;
1849
+ const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;
1850
+ const isEqual = isSameLength && // @ts-ignore
1851
+ Object.entries(resolved).every(([key, value]) => prev[key] === value);
1852
+ return isEqual ? prev : resolved;
1853
+ });
1854
+ },
1855
+ [setAuthStates]
1856
+ );
1761
1857
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1762
1858
  CopilotContext.Provider,
1763
1859
  {
@@ -1795,8 +1891,8 @@ ${nonDocumentStrings}`;
1795
1891
  agentSession,
1796
1892
  setAgentSession,
1797
1893
  runtimeClient,
1798
- forwardedParameters: props.forwardedParameters || {},
1799
- agentLock: props.agent || null,
1894
+ forwardedParameters,
1895
+ agentLock,
1800
1896
  threadId: internalThreadId,
1801
1897
  setThreadId,
1802
1898
  runId,
@@ -1805,13 +1901,13 @@ ${nonDocumentStrings}`;
1805
1901
  availableAgents,
1806
1902
  authConfig_c: props.authConfig_c,
1807
1903
  authStates_c: authStates,
1808
- setAuthStates_c: setAuthStates,
1904
+ setAuthStates_c: updateAuthStates,
1809
1905
  extensions,
1810
- setExtensions,
1906
+ setExtensions: updateExtensions,
1811
1907
  langGraphInterruptAction,
1812
1908
  setLangGraphInterruptAction,
1813
1909
  removeLangGraphInterruptAction,
1814
- onTrace: props.onTrace
1910
+ onError: props.onError
1815
1911
  },
1816
1912
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children: memoizedChildren })
1817
1913
  }