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