@copilotkit/react-core 1.9.2-next.2 → 1.9.2-next.21
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 +162 -0
- package/dist/{chunk-UHQMV2CE.mjs → chunk-36MGCCPZ.mjs} +2 -2
- package/dist/{chunk-CCESTGAM.mjs → chunk-3OQM3NEK.mjs} +2 -2
- package/dist/{chunk-OUSWPVDT.mjs → chunk-4URMLOBR.mjs} +4 -4
- package/dist/chunk-57K2ZJ5F.mjs +348 -0
- package/dist/chunk-57K2ZJ5F.mjs.map +1 -0
- package/dist/{chunk-LZDDYZEY.mjs → chunk-5BSUSFHM.mjs} +2 -2
- package/dist/{chunk-C6F6EQNA.mjs → chunk-BVK7PLK6.mjs} +2 -2
- package/dist/{chunk-CMKIDDQL.mjs → chunk-DDIBJUWK.mjs} +11 -8
- package/dist/{chunk-CMKIDDQL.mjs.map → chunk-DDIBJUWK.mjs.map} +1 -1
- package/dist/{chunk-NNSXCFQO.mjs → chunk-DGON3GZX.mjs} +42 -8
- package/dist/chunk-DGON3GZX.mjs.map +1 -0
- package/dist/{chunk-6KGEF242.mjs → chunk-DKZTPL66.mjs} +3 -2
- package/dist/chunk-DKZTPL66.mjs.map +1 -0
- package/dist/{chunk-LDACFA2B.mjs → chunk-FN3UA2ZE.mjs} +3 -3
- package/dist/{chunk-RUY6MLHA.mjs → chunk-JWAXDYOW.mjs} +36 -6
- package/dist/chunk-JWAXDYOW.mjs.map +1 -0
- package/dist/{chunk-2FW7HH6W.mjs → chunk-KIXKBJUV.mjs} +3 -3
- package/dist/{chunk-MGIXEJWG.mjs → chunk-MTAJI7HV.mjs} +181 -68
- package/dist/chunk-MTAJI7HV.mjs.map +1 -0
- package/dist/{chunk-L6QAOAE4.mjs → chunk-N2M65NJ2.mjs} +69 -25
- package/dist/chunk-N2M65NJ2.mjs.map +1 -0
- package/dist/{chunk-T42PN5VN.mjs → chunk-NJA5ZLAZ.mjs} +29 -10
- package/dist/chunk-NJA5ZLAZ.mjs.map +1 -0
- package/dist/{chunk-4I7PLQF7.mjs → chunk-QKEH3O4S.mjs} +5 -5
- package/dist/{chunk-FRZZPPIV.mjs → chunk-RAQK4M64.mjs} +2 -2
- package/dist/{chunk-QQZLIEXK.mjs → chunk-SJJNFYGQ.mjs} +3 -3
- package/dist/{chunk-Q5D5XQFA.mjs → chunk-VDADWRS3.mjs} +2 -2
- package/dist/chunk-YAF2LATQ.mjs +310 -0
- package/dist/chunk-YAF2LATQ.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.js +40 -5
- 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 +27 -3
- 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 +385 -254
- 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 +385 -254
- 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 +385 -254
- 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 +2 -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 +2 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +1 -1
- package/dist/{copilot-context-f9b2b4c3.d.ts → copilot-context-3ab4fdf5.d.ts} +6 -2
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +232 -71
- 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 +295 -156
- package/dist/hooks/use-chat.js.map +1 -1
- package/dist/hooks/use-chat.mjs +6 -6
- package/dist/hooks/use-coagent-state-render.js +2 -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 +207 -65
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +14 -14
- package/dist/hooks/use-copilot-action.js +27 -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 +2 -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 +27 -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 +204 -65
- 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 +2 -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 -0
- package/dist/hooks/use-copilot-runtime-client.js +52 -2
- 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 +2 -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 +204 -65
- 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 +2 -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 +582 -321
- 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/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 +7 -3
- package/package.json +4 -3
- package/src/components/copilot-provider/__tests__/copilotkit-error.test.tsx +75 -0
- package/src/components/copilot-provider/copilot-messages.tsx +47 -6
- package/src/components/copilot-provider/copilotkit-props.tsx +27 -1
- package/src/components/copilot-provider/copilotkit.tsx +64 -18
- package/src/components/toast/toast-provider.tsx +49 -24
- package/src/components/usage-banner.tsx +144 -147
- package/src/context/copilot-context.tsx +8 -2
- package/src/hooks/use-chat.ts +247 -61
- package/src/hooks/use-coagent.ts +5 -0
- package/src/hooks/use-copilot-action.ts +51 -9
- package/src/hooks/use-copilot-runtime-client.ts +41 -40
- package/tsconfig.json +4 -8
- package/tsup.config.ts +6 -6
- package/dist/chunk-6KGEF242.mjs.map +0 -1
- package/dist/chunk-HD2GE3DK.mjs +0 -359
- package/dist/chunk-HD2GE3DK.mjs.map +0 -1
- package/dist/chunk-L6QAOAE4.mjs.map +0 -1
- package/dist/chunk-MGIXEJWG.mjs.map +0 -1
- package/dist/chunk-NNSXCFQO.mjs.map +0 -1
- package/dist/chunk-RUY6MLHA.mjs.map +0 -1
- package/dist/chunk-T42PN5VN.mjs.map +0 -1
- package/dist/chunk-VRXANACV.mjs +0 -277
- package/dist/chunk-VRXANACV.mjs.map +0 -1
- package/dist/utils/utils.test.d.ts +0 -2
- package/dist/utils/utils.test.js +0 -9
- package/dist/utils/utils.test.js.map +0 -1
- package/dist/utils/utils.test.mjs +0 -7
- package/dist/utils/utils.test.mjs.map +0 -1
- /package/dist/{chunk-UHQMV2CE.mjs.map → chunk-36MGCCPZ.mjs.map} +0 -0
- /package/dist/{chunk-CCESTGAM.mjs.map → chunk-3OQM3NEK.mjs.map} +0 -0
- /package/dist/{chunk-OUSWPVDT.mjs.map → chunk-4URMLOBR.mjs.map} +0 -0
- /package/dist/{chunk-LZDDYZEY.mjs.map → chunk-5BSUSFHM.mjs.map} +0 -0
- /package/dist/{chunk-C6F6EQNA.mjs.map → chunk-BVK7PLK6.mjs.map} +0 -0
- /package/dist/{chunk-LDACFA2B.mjs.map → chunk-FN3UA2ZE.mjs.map} +0 -0
- /package/dist/{chunk-2FW7HH6W.mjs.map → chunk-KIXKBJUV.mjs.map} +0 -0
- /package/dist/{chunk-4I7PLQF7.mjs.map → chunk-QKEH3O4S.mjs.map} +0 -0
- /package/dist/{chunk-FRZZPPIV.mjs.map → chunk-RAQK4M64.mjs.map} +0 -0
- /package/dist/{chunk-QQZLIEXK.mjs.map → chunk-SJJNFYGQ.mjs.map} +0 -0
- /package/dist/{chunk-Q5D5XQFA.mjs.map → chunk-VDADWRS3.mjs.map} +0 -0
package/dist/components/index.js
CHANGED
|
@@ -161,7 +161,8 @@ var emptyCopilotContext = {
|
|
|
161
161
|
},
|
|
162
162
|
langGraphInterruptAction: null,
|
|
163
163
|
setLangGraphInterruptAction: () => null,
|
|
164
|
-
removeLangGraphInterruptAction: () => null
|
|
164
|
+
removeLangGraphInterruptAction: () => null,
|
|
165
|
+
onError: void 0
|
|
165
166
|
};
|
|
166
167
|
var CopilotContext = import_react.default.createContext(emptyCopilotContext);
|
|
167
168
|
function useCopilotContext() {
|
|
@@ -516,12 +517,14 @@ function ToastProvider({
|
|
|
516
517
|
border: `1px solid ${colors.border}`,
|
|
517
518
|
borderLeft: `4px solid ${colors.border}`,
|
|
518
519
|
borderRadius: "8px",
|
|
519
|
-
padding: "
|
|
520
|
+
padding: "12px 16px",
|
|
520
521
|
fontSize: "13px",
|
|
521
522
|
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
522
523
|
backdropFilter: "blur(8px)",
|
|
523
|
-
maxWidth: "
|
|
524
|
-
|
|
524
|
+
maxWidth: "min(90vw, 700px)",
|
|
525
|
+
width: "100%",
|
|
526
|
+
boxSizing: "border-box",
|
|
527
|
+
overflow: "hidden"
|
|
525
528
|
},
|
|
526
529
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
527
530
|
"div",
|
|
@@ -533,94 +536,125 @@ function ToastProvider({
|
|
|
533
536
|
gap: "10px"
|
|
534
537
|
},
|
|
535
538
|
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) + "...";
|
|
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
|
|
570
559
|
}
|
|
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
560
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
595
|
-
"button",
|
|
561
|
+
),
|
|
562
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
563
|
+
"div",
|
|
596
564
|
{
|
|
597
|
-
onClick: () => window.open(url, "_blank", "noopener,noreferrer"),
|
|
598
565
|
style: {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
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)";
|
|
566
|
+
display: "flex",
|
|
567
|
+
alignItems: "center",
|
|
568
|
+
gap: "10px",
|
|
569
|
+
flex: 1,
|
|
570
|
+
minWidth: 0
|
|
613
571
|
},
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
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
|
+
]
|
|
619
653
|
}
|
|
620
|
-
)
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
654
|
+
)
|
|
655
|
+
]
|
|
656
|
+
}
|
|
657
|
+
),
|
|
624
658
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
625
659
|
"button",
|
|
626
660
|
{
|
|
@@ -673,8 +707,38 @@ function CopilotMessages({ children }) {
|
|
|
673
707
|
const lastLoadedThreadId = (0, import_react6.useRef)();
|
|
674
708
|
const lastLoadedAgentName = (0, import_react6.useRef)();
|
|
675
709
|
const lastLoadedMessages = (0, import_react6.useRef)();
|
|
676
|
-
const { threadId, agentSession, runtimeClient, showDevConsole } = useCopilotContext();
|
|
710
|
+
const { threadId, agentSession, runtimeClient, showDevConsole, onError, copilotApiConfig } = useCopilotContext();
|
|
677
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
|
+
);
|
|
678
742
|
const createStructuredError2 = (gqlError) => {
|
|
679
743
|
const extensions = gqlError.extensions;
|
|
680
744
|
const originalError = extensions == null ? void 0 : extensions.originalError;
|
|
@@ -719,12 +783,14 @@ function CopilotMessages({ children }) {
|
|
|
719
783
|
const ckError = createStructuredError2(gqlError);
|
|
720
784
|
if (ckError) {
|
|
721
785
|
setBannerError(ckError);
|
|
786
|
+
traceUIError(ckError, gqlError);
|
|
722
787
|
} else {
|
|
723
788
|
const fallbackError = new import_shared4.CopilotKitError({
|
|
724
789
|
message: gqlError.message,
|
|
725
790
|
code: import_shared4.CopilotKitErrorCode.UNKNOWN
|
|
726
791
|
});
|
|
727
792
|
setBannerError(fallbackError);
|
|
793
|
+
traceUIError(fallbackError, gqlError);
|
|
728
794
|
}
|
|
729
795
|
};
|
|
730
796
|
graphQLErrors.forEach(routeError);
|
|
@@ -738,10 +804,11 @@ function CopilotMessages({ children }) {
|
|
|
738
804
|
code: import_shared4.CopilotKitErrorCode.UNKNOWN
|
|
739
805
|
});
|
|
740
806
|
setBannerError(fallbackError);
|
|
807
|
+
traceUIError(fallbackError, error);
|
|
741
808
|
}
|
|
742
809
|
}
|
|
743
810
|
},
|
|
744
|
-
[setBannerError, showDevConsole]
|
|
811
|
+
[setBannerError, showDevConsole, traceUIError]
|
|
745
812
|
);
|
|
746
813
|
(0, import_react6.useEffect)(() => {
|
|
747
814
|
if (!threadId || threadId === lastLoadedThreadId.current)
|
|
@@ -775,7 +842,8 @@ function CopilotMessages({ children }) {
|
|
|
775
842
|
}
|
|
776
843
|
});
|
|
777
844
|
void fetchMessages();
|
|
778
|
-
}, [threadId, agentSession == null ? void 0 : agentSession.agentName
|
|
845
|
+
}, [threadId, agentSession == null ? void 0 : agentSession.agentName]);
|
|
846
|
+
const memoizedChildren = (0, import_react6.useMemo)(() => children, [children]);
|
|
779
847
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
780
848
|
CopilotMessagesContext.Provider,
|
|
781
849
|
{
|
|
@@ -783,7 +851,7 @@ function CopilotMessages({ children }) {
|
|
|
783
851
|
messages,
|
|
784
852
|
setMessages
|
|
785
853
|
},
|
|
786
|
-
children
|
|
854
|
+
children: memoizedChildren
|
|
787
855
|
}
|
|
788
856
|
);
|
|
789
857
|
}
|
|
@@ -794,8 +862,35 @@ var import_react7 = require("react");
|
|
|
794
862
|
var import_shared5 = require("@copilotkit/shared");
|
|
795
863
|
var useCopilotRuntimeClient = (options) => {
|
|
796
864
|
const { setBannerError } = useToast();
|
|
797
|
-
const _a = options, { showDevConsole } = _a, runtimeOptions = __objRest(_a, ["showDevConsole"]);
|
|
865
|
+
const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
|
|
798
866
|
const lastStructuredErrorRef = (0, import_react7.useRef)(null);
|
|
867
|
+
const traceUIError = (error, originalError) => __async(void 0, null, function* () {
|
|
868
|
+
if (!onError || !runtimeOptions.publicApiKey)
|
|
869
|
+
return;
|
|
870
|
+
try {
|
|
871
|
+
const errorEvent = {
|
|
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 onError(errorEvent);
|
|
890
|
+
} catch (error2) {
|
|
891
|
+
console.error("Error in onError handler:", error2);
|
|
892
|
+
}
|
|
893
|
+
});
|
|
799
894
|
const runtimeClient = (0, import_react7.useMemo)(() => {
|
|
800
895
|
return new import_runtime_client_gql2.CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
|
|
801
896
|
handleGQLErrors: (error) => {
|
|
@@ -823,12 +918,14 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
823
918
|
const ckError = createStructuredError(gqlError);
|
|
824
919
|
if (ckError) {
|
|
825
920
|
setBannerError(ckError);
|
|
921
|
+
traceUIError(ckError, gqlError);
|
|
826
922
|
} else {
|
|
827
923
|
const fallbackError = new import_shared5.CopilotKitError({
|
|
828
924
|
message: gqlError.message,
|
|
829
925
|
code: import_shared5.CopilotKitErrorCode.UNKNOWN
|
|
830
926
|
});
|
|
831
927
|
setBannerError(fallbackError);
|
|
928
|
+
traceUIError(fallbackError, gqlError);
|
|
832
929
|
}
|
|
833
930
|
};
|
|
834
931
|
graphQLErrors.forEach(routeError);
|
|
@@ -842,6 +939,7 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
842
939
|
code: import_shared5.CopilotKitErrorCode.UNKNOWN
|
|
843
940
|
});
|
|
844
941
|
setBannerError(fallbackError);
|
|
942
|
+
traceUIError(fallbackError, error);
|
|
845
943
|
}
|
|
846
944
|
}
|
|
847
945
|
},
|
|
@@ -854,7 +952,7 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
854
952
|
setBannerError(warningError);
|
|
855
953
|
}
|
|
856
954
|
}));
|
|
857
|
-
}, [runtimeOptions, setBannerError, showDevConsole]);
|
|
955
|
+
}, [runtimeOptions, setBannerError, showDevConsole, onError]);
|
|
858
956
|
return runtimeClient;
|
|
859
957
|
};
|
|
860
958
|
function createStructuredError(gqlError) {
|
|
@@ -947,8 +1045,8 @@ var defaultIcons = {
|
|
|
947
1045
|
"svg",
|
|
948
1046
|
{
|
|
949
1047
|
viewBox: "0 0 24 24",
|
|
950
|
-
width: "
|
|
951
|
-
height: "
|
|
1048
|
+
width: "16",
|
|
1049
|
+
height: "16",
|
|
952
1050
|
stroke: "currentColor",
|
|
953
1051
|
strokeWidth: "2.5",
|
|
954
1052
|
fill: "none",
|
|
@@ -965,8 +1063,8 @@ var defaultIcons = {
|
|
|
965
1063
|
"svg",
|
|
966
1064
|
{
|
|
967
1065
|
viewBox: "0 0 24 24",
|
|
968
|
-
width: "
|
|
969
|
-
height: "
|
|
1066
|
+
width: "16",
|
|
1067
|
+
height: "16",
|
|
970
1068
|
stroke: "currentColor",
|
|
971
1069
|
strokeWidth: "2.5",
|
|
972
1070
|
fill: "none",
|
|
@@ -983,8 +1081,8 @@ var defaultIcons = {
|
|
|
983
1081
|
"svg",
|
|
984
1082
|
{
|
|
985
1083
|
viewBox: "0 0 24 24",
|
|
986
|
-
width: "
|
|
987
|
-
height: "
|
|
1084
|
+
width: "16",
|
|
1085
|
+
height: "16",
|
|
988
1086
|
stroke: "currentColor",
|
|
989
1087
|
strokeWidth: "2.5",
|
|
990
1088
|
fill: "none",
|
|
@@ -1009,19 +1107,33 @@ function UsageBanner({
|
|
|
1009
1107
|
return null;
|
|
1010
1108
|
}
|
|
1011
1109
|
const parseMessage = (rawMessage) => {
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
return
|
|
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.";
|
|
1017
1115
|
}
|
|
1018
|
-
|
|
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.";
|
|
1129
|
+
}
|
|
1130
|
+
return cleanMessage2 || "An error occurred. Please check your configuration.";
|
|
1019
1131
|
};
|
|
1020
1132
|
const cleanMessage = parseMessage(message);
|
|
1021
1133
|
const Icon = icon || defaultIcons[severity];
|
|
1022
1134
|
const themeConfigs = {
|
|
1023
1135
|
[import_shared7.Severity.INFO]: {
|
|
1024
|
-
bg: "
|
|
1136
|
+
bg: "rgba(239, 246, 255, 0.95)",
|
|
1025
1137
|
border: "#93c5fd",
|
|
1026
1138
|
text: "#1e40af",
|
|
1027
1139
|
icon: "#3b82f6",
|
|
@@ -1029,7 +1141,7 @@ function UsageBanner({
|
|
|
1029
1141
|
primaryBtnHover: "#2563eb"
|
|
1030
1142
|
},
|
|
1031
1143
|
[import_shared7.Severity.WARNING]: {
|
|
1032
|
-
bg: "
|
|
1144
|
+
bg: "rgba(255, 251, 235, 0.95)",
|
|
1033
1145
|
border: "#fbbf24",
|
|
1034
1146
|
text: "#92400e",
|
|
1035
1147
|
icon: "#f59e0b",
|
|
@@ -1037,7 +1149,7 @@ function UsageBanner({
|
|
|
1037
1149
|
primaryBtnHover: "#d97706"
|
|
1038
1150
|
},
|
|
1039
1151
|
[import_shared7.Severity.CRITICAL]: {
|
|
1040
|
-
bg: "
|
|
1152
|
+
bg: "rgba(254, 242, 242, 0.95)",
|
|
1041
1153
|
border: "#f87171",
|
|
1042
1154
|
text: "#991b1b",
|
|
1043
1155
|
icon: "#ef4444",
|
|
@@ -1051,24 +1163,26 @@ function UsageBanner({
|
|
|
1051
1163
|
{
|
|
1052
1164
|
style: {
|
|
1053
1165
|
position: "fixed",
|
|
1054
|
-
bottom: "
|
|
1166
|
+
bottom: "24px",
|
|
1055
1167
|
left: "50%",
|
|
1056
1168
|
transform: "translateX(-50%)",
|
|
1057
|
-
|
|
1058
|
-
|
|
1169
|
+
width: "400px",
|
|
1170
|
+
maxWidth: "90vw",
|
|
1059
1171
|
zIndex: 1e4,
|
|
1060
|
-
animation: "bannerSlideIn 0.
|
|
1172
|
+
animation: "bannerSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1)"
|
|
1061
1173
|
},
|
|
1062
1174
|
children: [
|
|
1063
1175
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
|
|
1064
1176
|
@keyframes bannerSlideIn {
|
|
1065
1177
|
from {
|
|
1066
1178
|
opacity: 0;
|
|
1067
|
-
transform: translateX(-50%) translateY(
|
|
1179
|
+
transform: translateX(-50%) translateY(20px);
|
|
1180
|
+
scale: 0.95;
|
|
1068
1181
|
}
|
|
1069
1182
|
to {
|
|
1070
1183
|
opacity: 1;
|
|
1071
1184
|
transform: translateX(-50%) translateY(0);
|
|
1185
|
+
scale: 1;
|
|
1072
1186
|
}
|
|
1073
1187
|
}
|
|
1074
1188
|
` }),
|
|
@@ -1076,17 +1190,16 @@ function UsageBanner({
|
|
|
1076
1190
|
"div",
|
|
1077
1191
|
{
|
|
1078
1192
|
style: {
|
|
1079
|
-
|
|
1080
|
-
alignItems: "flex-start",
|
|
1081
|
-
gap: "14px",
|
|
1082
|
-
borderRadius: "16px",
|
|
1193
|
+
borderRadius: "12px",
|
|
1083
1194
|
border: `1px solid ${themeConfig.border}`,
|
|
1084
1195
|
background: themeConfig.bg,
|
|
1085
|
-
padding: "
|
|
1086
|
-
boxShadow: "0
|
|
1196
|
+
padding: "14px",
|
|
1197
|
+
boxShadow: "0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08)",
|
|
1087
1198
|
position: "relative",
|
|
1088
|
-
backdropFilter: "blur(
|
|
1089
|
-
WebkitBackdropFilter: "blur(
|
|
1199
|
+
backdropFilter: "blur(12px)",
|
|
1200
|
+
WebkitBackdropFilter: "blur(12px)",
|
|
1201
|
+
boxSizing: "border-box",
|
|
1202
|
+
overflow: "hidden"
|
|
1090
1203
|
},
|
|
1091
1204
|
children: [
|
|
1092
1205
|
onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
@@ -1095,35 +1208,23 @@ function UsageBanner({
|
|
|
1095
1208
|
onClick: onClose,
|
|
1096
1209
|
style: {
|
|
1097
1210
|
position: "absolute",
|
|
1098
|
-
top: "
|
|
1099
|
-
right: "
|
|
1100
|
-
background: "rgba(255, 255, 255, 0.
|
|
1211
|
+
top: "8px",
|
|
1212
|
+
right: "8px",
|
|
1213
|
+
background: "rgba(255, 255, 255, 0.9)",
|
|
1101
1214
|
border: "none",
|
|
1102
1215
|
color: themeConfig.text,
|
|
1103
1216
|
cursor: "pointer",
|
|
1104
|
-
fontSize: "
|
|
1217
|
+
fontSize: "16px",
|
|
1105
1218
|
lineHeight: "1",
|
|
1106
|
-
padding: "
|
|
1107
|
-
borderRadius: "
|
|
1108
|
-
|
|
1109
|
-
|
|
1219
|
+
padding: "4px",
|
|
1220
|
+
borderRadius: "4px",
|
|
1221
|
+
width: "20px",
|
|
1222
|
+
height: "20px",
|
|
1110
1223
|
display: "flex",
|
|
1111
1224
|
alignItems: "center",
|
|
1112
|
-
justifyContent: "center"
|
|
1113
|
-
width: "28px",
|
|
1114
|
-
height: "28px"
|
|
1225
|
+
justifyContent: "center"
|
|
1115
1226
|
},
|
|
1116
1227
|
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
|
-
},
|
|
1127
1228
|
children: "\xD7"
|
|
1128
1229
|
}
|
|
1129
1230
|
),
|
|
@@ -1131,106 +1232,92 @@ function UsageBanner({
|
|
|
1131
1232
|
"div",
|
|
1132
1233
|
{
|
|
1133
1234
|
style: {
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
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"
|
|
1143
1248
|
},
|
|
1144
|
-
children:
|
|
1249
|
+
children: cleanMessage
|
|
1145
1250
|
}
|
|
1146
1251
|
),
|
|
1147
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
{
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
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
|
-
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
|
-
] })
|
|
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
|
+
)
|
|
1234
1321
|
]
|
|
1235
1322
|
}
|
|
1236
1323
|
)
|
|
@@ -1634,18 +1721,25 @@ ${nonDocumentStrings}`;
|
|
|
1634
1721
|
publicApiKey: copilotApiConfig.publicApiKey,
|
|
1635
1722
|
headers,
|
|
1636
1723
|
credentials: copilotApiConfig.credentials,
|
|
1637
|
-
showDevConsole: (_b = props.showDevConsole) != null ? _b : false
|
|
1724
|
+
showDevConsole: (_b = props.showDevConsole) != null ? _b : false,
|
|
1725
|
+
onError: props.onError
|
|
1638
1726
|
});
|
|
1639
1727
|
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
|
|
1640
|
-
const addChatSuggestionConfiguration = (
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
setChatSuggestionConfiguration
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
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
|
+
);
|
|
1649
1743
|
const [availableAgents, setAvailableAgents] = (0, import_react10.useState)([]);
|
|
1650
1744
|
const [coagentStates, setCoagentStates] = (0, import_react10.useState)({});
|
|
1651
1745
|
const coagentStatesRef = (0, import_react10.useRef)({});
|
|
@@ -1724,6 +1818,42 @@ ${nonDocumentStrings}`;
|
|
|
1724
1818
|
const removeLangGraphInterruptAction = (0, import_react10.useCallback)(() => {
|
|
1725
1819
|
setLangGraphInterruptAction(null);
|
|
1726
1820
|
}, []);
|
|
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
|
+
);
|
|
1727
1857
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1728
1858
|
CopilotContext.Provider,
|
|
1729
1859
|
{
|
|
@@ -1761,8 +1891,8 @@ ${nonDocumentStrings}`;
|
|
|
1761
1891
|
agentSession,
|
|
1762
1892
|
setAgentSession,
|
|
1763
1893
|
runtimeClient,
|
|
1764
|
-
forwardedParameters
|
|
1765
|
-
agentLock
|
|
1894
|
+
forwardedParameters,
|
|
1895
|
+
agentLock,
|
|
1766
1896
|
threadId: internalThreadId,
|
|
1767
1897
|
setThreadId,
|
|
1768
1898
|
runId,
|
|
@@ -1771,14 +1901,15 @@ ${nonDocumentStrings}`;
|
|
|
1771
1901
|
availableAgents,
|
|
1772
1902
|
authConfig_c: props.authConfig_c,
|
|
1773
1903
|
authStates_c: authStates,
|
|
1774
|
-
setAuthStates_c:
|
|
1904
|
+
setAuthStates_c: updateAuthStates,
|
|
1775
1905
|
extensions,
|
|
1776
|
-
setExtensions,
|
|
1906
|
+
setExtensions: updateExtensions,
|
|
1777
1907
|
langGraphInterruptAction,
|
|
1778
1908
|
setLangGraphInterruptAction,
|
|
1779
|
-
removeLangGraphInterruptAction
|
|
1909
|
+
removeLangGraphInterruptAction,
|
|
1910
|
+
onError: props.onError
|
|
1780
1911
|
},
|
|
1781
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children })
|
|
1912
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children: memoizedChildren })
|
|
1782
1913
|
}
|
|
1783
1914
|
);
|
|
1784
1915
|
}
|