@copilotkit/react-core 1.10.0-next.3 → 1.10.0-next.5
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 +16 -0
- package/dist/{chunk-VM7CVIET.mjs → chunk-32JPCD6C.mjs} +10 -10
- package/dist/chunk-32JPCD6C.mjs.map +1 -0
- package/dist/{chunk-XGRBCWK6.mjs → chunk-47GMU44Z.mjs} +4 -1
- package/dist/chunk-47GMU44Z.mjs.map +1 -0
- package/dist/{chunk-PYULBXCD.mjs → chunk-4NR26FFD.mjs} +8 -8
- package/dist/{chunk-DF4YG4PF.mjs → chunk-57MBVQPX.mjs} +2 -2
- package/dist/chunk-5RPZ4T2V.mjs +18 -0
- package/dist/chunk-5RPZ4T2V.mjs.map +1 -0
- package/dist/{chunk-JZQOCH4A.mjs → chunk-A3QJUCBZ.mjs} +4 -4
- package/dist/{chunk-LNAQ7JG3.mjs → chunk-AC2GVFW6.mjs} +2 -2
- package/dist/chunk-AWFAFFO5.mjs +221 -0
- package/dist/chunk-AWFAFFO5.mjs.map +1 -0
- package/dist/chunk-BJ7N5YF5.mjs +79 -0
- package/dist/chunk-BJ7N5YF5.mjs.map +1 -0
- package/dist/{chunk-KV25ZRMH.mjs → chunk-CZWJ4VJG.mjs} +6 -6
- package/dist/chunk-CZWJ4VJG.mjs.map +1 -0
- package/dist/{chunk-YAF2LATQ.mjs → chunk-EFL5OBKN.mjs} +1 -1
- package/dist/chunk-EFL5OBKN.mjs.map +1 -0
- package/dist/{chunk-4CFY3CON.mjs → chunk-EQQSE6KM.mjs} +2 -2
- package/dist/{chunk-JWAXDYOW.mjs → chunk-FAUNHSQU.mjs} +3 -3
- package/dist/chunk-ICIK2BSB.mjs +17 -0
- package/dist/chunk-ICIK2BSB.mjs.map +1 -0
- package/dist/chunk-KDAZGZ24.mjs +1 -0
- package/dist/{chunk-NXCJELW7.mjs → chunk-KTD5U4PK.mjs} +3 -3
- package/dist/{chunk-3OQM3NEK.mjs → chunk-N4WEHORG.mjs} +2 -2
- package/dist/{chunk-Q6FZZJ5A.mjs → chunk-OL3VRQKU.mjs} +2 -2
- package/dist/{chunk-WUORFPJ7.mjs → chunk-PH6RVMFU.mjs} +6 -6
- package/dist/{chunk-RGKZCCPA.mjs → chunk-SMLWBM4N.mjs} +5 -5
- package/dist/{chunk-OMVNJ7S3.mjs → chunk-TUPJR242.mjs} +36 -21
- package/dist/chunk-TUPJR242.mjs.map +1 -0
- package/dist/{chunk-SGF6C7I6.mjs → chunk-U6JSCZCE.mjs} +11 -16
- package/dist/chunk-U6JSCZCE.mjs.map +1 -0
- package/dist/{chunk-4XVBXDCX.mjs → chunk-X7ETNW3P.mjs} +8 -8
- package/dist/{chunk-VOMGRGWT.mjs → chunk-XGRBVNW2.mjs} +12 -12
- package/dist/chunk-XGRBVNW2.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.js +12 -1
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +4 -4
- package/dist/components/copilot-provider/copilotkit-props.d.ts +1 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
- package/dist/components/copilot-provider/copilotkit.js +307 -550
- 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 +307 -550
- 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 +172 -323
- 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 +307 -550
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +10 -10
- package/dist/components/toast/toast-provider.js.map +1 -1
- package/dist/components/toast/toast-provider.mjs +1 -1
- package/dist/components/usage-banner.d.ts +8 -3
- package/dist/components/usage-banner.js +172 -302
- package/dist/components/usage-banner.js.map +1 -1
- package/dist/components/usage-banner.mjs +3 -1
- package/dist/context/copilot-context.d.ts +1 -1
- package/dist/context/copilot-context.js +3 -0
- 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 +3 -0
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +4 -4
- package/dist/{copilot-context-bd88d30d.d.ts → copilot-context-78fc727c.d.ts} +3 -1
- package/dist/hooks/index.d.ts +5 -3
- package/dist/hooks/index.js +143 -57
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +42 -34
- package/dist/hooks/use-chat.d.ts +1 -1
- package/dist/hooks/use-chat.js +12 -1
- 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 +3 -0
- 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 +15 -4
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +16 -16
- package/dist/hooks/use-copilot-action.js +3 -0
- 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 +3 -0
- 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 +3 -0
- 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-light.d.ts +211 -0
- package/dist/hooks/use-copilot-chat-light.js +1770 -0
- package/dist/hooks/use-copilot-chat-light.js.map +1 -0
- package/dist/hooks/use-copilot-chat-light.mjs +28 -0
- package/dist/hooks/use-copilot-chat-light.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat.d.ts +9 -81
- package/dist/hooks/use-copilot-chat.js +77 -5
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +18 -16
- package/dist/hooks/use-copilot-chat_internal.d.ts +91 -0
- package/dist/hooks/use-copilot-chat_internal.js +1760 -0
- package/dist/hooks/use-copilot-chat_internal.js.map +1 -0
- package/dist/hooks/use-copilot-chat_internal.mjs +29 -0
- package/dist/hooks/use-copilot-chat_internal.mjs.map +1 -0
- package/dist/hooks/use-copilot-readable.js +3 -0
- 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.js +9 -1
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
- package/dist/hooks/use-copilot-runtime-client.mjs +3 -3
- package/dist/hooks/use-langgraph-interrupt-render.js +3 -0
- 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 +15 -4
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +16 -16
- package/dist/hooks/use-make-copilot-document-readable.js +3 -0
- 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 +4 -2
- package/dist/index.js +384 -449
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -39
- package/dist/lib/copilot-task.d.ts +1 -1
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +12 -12
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +12 -12
- package/dist/types/interrupt-action.d.ts +1 -1
- package/dist/utils/dev-console.d.ts +1 -1
- package/dist/utils/dev-console.js +9 -1
- package/dist/utils/dev-console.js.map +1 -1
- package/dist/utils/dev-console.mjs +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 +9 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +11 -11
- package/dist/utils/suggestions.d.ts +1 -1
- package/dist/utils/suggestions.js.map +1 -1
- package/dist/utils/suggestions.mjs +10 -10
- package/package.json +3 -3
- package/src/components/copilot-provider/copilotkit.tsx +16 -5
- package/src/components/error-boundary/error-boundary.tsx +5 -15
- package/src/components/toast/toast-provider.tsx +1 -3
- package/src/components/usage-banner.tsx +187 -315
- package/src/context/copilot-context.tsx +12 -1
- package/src/hooks/__tests__/use-coagent-config.test.ts +1 -1
- package/src/hooks/index.ts +6 -0
- package/src/hooks/use-coagent.ts +1 -1
- package/src/hooks/use-copilot-chat-light.ts +219 -0
- package/src/hooks/use-copilot-chat.ts +89 -430
- package/src/hooks/use-copilot-chat_internal.ts +437 -0
- package/src/hooks/use-langgraph-interrupt.ts +1 -1
- package/src/utils/dev-console.ts +18 -2
- package/dist/chunk-57K2ZJ5F.mjs +0 -348
- package/dist/chunk-57K2ZJ5F.mjs.map +0 -1
- package/dist/chunk-CQPYJIBH.mjs +0 -1
- package/dist/chunk-GFJW4RIM.mjs +0 -9
- package/dist/chunk-GFJW4RIM.mjs.map +0 -1
- package/dist/chunk-KV25ZRMH.mjs.map +0 -1
- package/dist/chunk-OMVNJ7S3.mjs.map +0 -1
- package/dist/chunk-SGF6C7I6.mjs.map +0 -1
- package/dist/chunk-VM7CVIET.mjs.map +0 -1
- package/dist/chunk-VOMGRGWT.mjs.map +0 -1
- package/dist/chunk-XGRBCWK6.mjs.map +0 -1
- package/dist/chunk-YAF2LATQ.mjs.map +0 -1
- /package/dist/{chunk-PYULBXCD.mjs.map → chunk-4NR26FFD.mjs.map} +0 -0
- /package/dist/{chunk-DF4YG4PF.mjs.map → chunk-57MBVQPX.mjs.map} +0 -0
- /package/dist/{chunk-JZQOCH4A.mjs.map → chunk-A3QJUCBZ.mjs.map} +0 -0
- /package/dist/{chunk-LNAQ7JG3.mjs.map → chunk-AC2GVFW6.mjs.map} +0 -0
- /package/dist/{chunk-4CFY3CON.mjs.map → chunk-EQQSE6KM.mjs.map} +0 -0
- /package/dist/{chunk-JWAXDYOW.mjs.map → chunk-FAUNHSQU.mjs.map} +0 -0
- /package/dist/{chunk-CQPYJIBH.mjs.map → chunk-KDAZGZ24.mjs.map} +0 -0
- /package/dist/{chunk-NXCJELW7.mjs.map → chunk-KTD5U4PK.mjs.map} +0 -0
- /package/dist/{chunk-3OQM3NEK.mjs.map → chunk-N4WEHORG.mjs.map} +0 -0
- /package/dist/{chunk-Q6FZZJ5A.mjs.map → chunk-OL3VRQKU.mjs.map} +0 -0
- /package/dist/{chunk-WUORFPJ7.mjs.map → chunk-PH6RVMFU.mjs.map} +0 -0
- /package/dist/{chunk-RGKZCCPA.mjs.map → chunk-SMLWBM4N.mjs.map} +0 -0
- /package/dist/{chunk-4XVBXDCX.mjs.map → chunk-X7ETNW3P.mjs.map} +0 -0
|
@@ -85,7 +85,7 @@ __export(copilotkit_exports, {
|
|
|
85
85
|
defaultCopilotContextCategories: () => defaultCopilotContextCategories
|
|
86
86
|
});
|
|
87
87
|
module.exports = __toCommonJS(copilotkit_exports);
|
|
88
|
-
var
|
|
88
|
+
var import_react9 = require("react");
|
|
89
89
|
|
|
90
90
|
// src/context/copilot-context.tsx
|
|
91
91
|
var import_react = __toESM(require("react"));
|
|
@@ -163,6 +163,9 @@ var emptyCopilotContext = {
|
|
|
163
163
|
removeLangGraphInterruptAction: () => null,
|
|
164
164
|
onError: void 0,
|
|
165
165
|
suggestions: [],
|
|
166
|
+
bannerError: null,
|
|
167
|
+
setBannerError: () => {
|
|
168
|
+
},
|
|
166
169
|
setSuggestions: () => {
|
|
167
170
|
}
|
|
168
171
|
};
|
|
@@ -697,8 +700,16 @@ function ToastProvider({
|
|
|
697
700
|
}
|
|
698
701
|
|
|
699
702
|
// src/utils/dev-console.ts
|
|
703
|
+
function isLocalhost() {
|
|
704
|
+
if (typeof window === "undefined")
|
|
705
|
+
return false;
|
|
706
|
+
return window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "0.0.0.0";
|
|
707
|
+
}
|
|
700
708
|
function shouldShowDevConsole(showDevConsole) {
|
|
701
|
-
|
|
709
|
+
if (showDevConsole !== void 0) {
|
|
710
|
+
return showDevConsole;
|
|
711
|
+
}
|
|
712
|
+
return isLocalhost();
|
|
702
713
|
}
|
|
703
714
|
|
|
704
715
|
// src/components/copilot-provider/copilot-messages.tsx
|
|
@@ -858,10 +869,207 @@ function CopilotMessages({ children }) {
|
|
|
858
869
|
);
|
|
859
870
|
}
|
|
860
871
|
|
|
872
|
+
// src/components/usage-banner.tsx
|
|
873
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
874
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
875
|
+
function UsageBanner({
|
|
876
|
+
severity = import_shared5.Severity.CRITICAL,
|
|
877
|
+
message = "",
|
|
878
|
+
onClose,
|
|
879
|
+
actions
|
|
880
|
+
}) {
|
|
881
|
+
if (!message || !severity) {
|
|
882
|
+
return null;
|
|
883
|
+
}
|
|
884
|
+
const themes = {
|
|
885
|
+
[import_shared5.Severity.INFO]: {
|
|
886
|
+
bg: "#f8fafc",
|
|
887
|
+
border: "#e2e8f0",
|
|
888
|
+
text: "#475569",
|
|
889
|
+
accent: "#3b82f6"
|
|
890
|
+
},
|
|
891
|
+
[import_shared5.Severity.WARNING]: {
|
|
892
|
+
bg: "#fffbeb",
|
|
893
|
+
border: "#fbbf24",
|
|
894
|
+
text: "#92400e",
|
|
895
|
+
accent: "#f59e0b"
|
|
896
|
+
},
|
|
897
|
+
[import_shared5.Severity.CRITICAL]: {
|
|
898
|
+
bg: "#fef2f2",
|
|
899
|
+
border: "#fecaca",
|
|
900
|
+
text: "#dc2626",
|
|
901
|
+
accent: "#ef4444"
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
const theme = themes[severity];
|
|
905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
906
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
|
|
907
|
+
@keyframes slideUp {
|
|
908
|
+
from { opacity: 0; transform: translateX(-50%) translateY(8px); }
|
|
909
|
+
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
.usage-banner {
|
|
913
|
+
position: fixed;
|
|
914
|
+
bottom: 24px;
|
|
915
|
+
left: 50%;
|
|
916
|
+
transform: translateX(-50%);
|
|
917
|
+
width: min(600px, calc(100vw - 32px));
|
|
918
|
+
z-index: 10000;
|
|
919
|
+
animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
.banner-content {
|
|
923
|
+
background: linear-gradient(135deg, ${theme.bg} 0%, ${theme.bg}f5 100%);
|
|
924
|
+
border: 1px solid ${theme.border};
|
|
925
|
+
border-radius: 12px;
|
|
926
|
+
padding: 18px 20px;
|
|
927
|
+
box-shadow:
|
|
928
|
+
0 4px 24px rgba(0, 0, 0, 0.08),
|
|
929
|
+
0 2px 8px rgba(0, 0, 0, 0.04),
|
|
930
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.7);
|
|
931
|
+
display: flex;
|
|
932
|
+
align-items: center;
|
|
933
|
+
gap: 16px;
|
|
934
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
|
|
935
|
+
backdrop-filter: blur(12px);
|
|
936
|
+
position: relative;
|
|
937
|
+
overflow: hidden;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
.banner-content::before {
|
|
941
|
+
content: '';
|
|
942
|
+
position: absolute;
|
|
943
|
+
top: 0;
|
|
944
|
+
left: 0;
|
|
945
|
+
right: 0;
|
|
946
|
+
height: 1px;
|
|
947
|
+
background: linear-gradient(90deg, transparent, ${theme.accent}40, transparent);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
.banner-message {
|
|
951
|
+
color: ${theme.text};
|
|
952
|
+
font-size: 14px;
|
|
953
|
+
line-height: 1.5;
|
|
954
|
+
font-weight: 500;
|
|
955
|
+
flex: 1;
|
|
956
|
+
letter-spacing: -0.01em;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
.close-btn {
|
|
960
|
+
background: rgba(0, 0, 0, 0.05);
|
|
961
|
+
border: none;
|
|
962
|
+
color: ${theme.text};
|
|
963
|
+
cursor: pointer;
|
|
964
|
+
padding: 0;
|
|
965
|
+
border-radius: 6px;
|
|
966
|
+
opacity: 0.6;
|
|
967
|
+
transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
|
|
968
|
+
font-size: 14px;
|
|
969
|
+
line-height: 1;
|
|
970
|
+
flex-shrink: 0;
|
|
971
|
+
width: 24px;
|
|
972
|
+
height: 24px;
|
|
973
|
+
display: flex;
|
|
974
|
+
align-items: center;
|
|
975
|
+
justify-content: center;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
.close-btn:hover {
|
|
979
|
+
opacity: 1;
|
|
980
|
+
background: rgba(0, 0, 0, 0.08);
|
|
981
|
+
transform: scale(1.05);
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
.btn-primary {
|
|
985
|
+
background: linear-gradient(135deg, ${theme.accent} 0%, ${theme.accent}e6 100%);
|
|
986
|
+
color: white;
|
|
987
|
+
border: none;
|
|
988
|
+
border-radius: 8px;
|
|
989
|
+
padding: 10px 18px;
|
|
990
|
+
font-size: 13px;
|
|
991
|
+
font-weight: 600;
|
|
992
|
+
cursor: pointer;
|
|
993
|
+
transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
|
|
994
|
+
font-family: inherit;
|
|
995
|
+
flex-shrink: 0;
|
|
996
|
+
box-shadow:
|
|
997
|
+
0 2px 8px ${theme.accent}30,
|
|
998
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.2);
|
|
999
|
+
letter-spacing: -0.01em;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
.btn-primary:hover {
|
|
1003
|
+
transform: translateY(-1px) scale(1.02);
|
|
1004
|
+
box-shadow:
|
|
1005
|
+
0 4px 12px ${theme.accent}40,
|
|
1006
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.25);
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
.btn-primary:active {
|
|
1010
|
+
transform: translateY(0) scale(0.98);
|
|
1011
|
+
transition: all 0.08s cubic-bezier(0.16, 1, 0.3, 1);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
@media (max-width: 640px) {
|
|
1015
|
+
.usage-banner {
|
|
1016
|
+
width: calc(100vw - 24px);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
.banner-content {
|
|
1020
|
+
padding: 16px;
|
|
1021
|
+
gap: 12px;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
.banner-message {
|
|
1025
|
+
font-size: 13px;
|
|
1026
|
+
line-height: 1.45;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
.btn-primary {
|
|
1030
|
+
padding: 8px 14px;
|
|
1031
|
+
font-size: 12px;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
.close-btn {
|
|
1035
|
+
width: 22px;
|
|
1036
|
+
height: 22px;
|
|
1037
|
+
font-size: 12px;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
` }),
|
|
1041
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "usage-banner", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "banner-content", children: [
|
|
1042
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "banner-message", children: message }),
|
|
1043
|
+
(actions == null ? void 0 : actions.primary) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "btn-primary", onClick: actions.primary.onClick, children: actions.primary.label }),
|
|
1044
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "close-btn", onClick: onClose, title: "Close", children: "\xD7" })
|
|
1045
|
+
] }) })
|
|
1046
|
+
] });
|
|
1047
|
+
}
|
|
1048
|
+
var getErrorActions = (error) => {
|
|
1049
|
+
switch (error.code) {
|
|
1050
|
+
case import_shared5.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR:
|
|
1051
|
+
return {
|
|
1052
|
+
primary: {
|
|
1053
|
+
label: "Get Free API Key",
|
|
1054
|
+
onClick: () => window.open("https://cloud.copilotkit.ai", "_blank", "noopener,noreferrer")
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
case import_shared5.CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR:
|
|
1058
|
+
return {
|
|
1059
|
+
primary: {
|
|
1060
|
+
label: "Upgrade",
|
|
1061
|
+
onClick: () => window.open("https://cloud.copilotkit.ai", "_blank", "noopener,noreferrer")
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
default:
|
|
1065
|
+
return void 0;
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
|
|
861
1069
|
// src/hooks/use-copilot-runtime-client.ts
|
|
862
1070
|
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
863
1071
|
var import_react7 = require("react");
|
|
864
|
-
var
|
|
1072
|
+
var import_shared6 = require("@copilotkit/shared");
|
|
865
1073
|
var useCopilotRuntimeClient = (options) => {
|
|
866
1074
|
const { setBannerError } = useToast();
|
|
867
1075
|
const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
|
|
@@ -903,7 +1111,7 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
903
1111
|
const extensions = gqlError.extensions;
|
|
904
1112
|
const visibility = extensions == null ? void 0 : extensions.visibility;
|
|
905
1113
|
const isDev = shouldShowDevConsole(showDevConsole != null ? showDevConsole : false);
|
|
906
|
-
if (visibility ===
|
|
1114
|
+
if (visibility === import_shared6.ErrorVisibility.SILENT) {
|
|
907
1115
|
console.error("CopilotKit Silent Error:", gqlError.message);
|
|
908
1116
|
return;
|
|
909
1117
|
}
|
|
@@ -922,9 +1130,9 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
922
1130
|
setBannerError(ckError);
|
|
923
1131
|
traceUIError(ckError, gqlError);
|
|
924
1132
|
} else {
|
|
925
|
-
const fallbackError = new
|
|
1133
|
+
const fallbackError = new import_shared6.CopilotKitError({
|
|
926
1134
|
message: gqlError.message,
|
|
927
|
-
code:
|
|
1135
|
+
code: import_shared6.CopilotKitErrorCode.UNKNOWN
|
|
928
1136
|
});
|
|
929
1137
|
setBannerError(fallbackError);
|
|
930
1138
|
traceUIError(fallbackError, gqlError);
|
|
@@ -936,9 +1144,9 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
936
1144
|
if (!isDev) {
|
|
937
1145
|
console.error("CopilotKit Error (hidden in production):", error);
|
|
938
1146
|
} else {
|
|
939
|
-
const fallbackError = new
|
|
1147
|
+
const fallbackError = new import_shared6.CopilotKitError({
|
|
940
1148
|
message: (error == null ? void 0 : error.message) || String(error),
|
|
941
|
-
code:
|
|
1149
|
+
code: import_shared6.CopilotKitErrorCode.UNKNOWN
|
|
942
1150
|
});
|
|
943
1151
|
setBannerError(fallbackError);
|
|
944
1152
|
traceUIError(fallbackError, error);
|
|
@@ -947,9 +1155,9 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
947
1155
|
},
|
|
948
1156
|
handleGQLWarning: (message) => {
|
|
949
1157
|
console.warn(message);
|
|
950
|
-
const warningError = new
|
|
1158
|
+
const warningError = new import_shared6.CopilotKitError({
|
|
951
1159
|
message,
|
|
952
|
-
code:
|
|
1160
|
+
code: import_shared6.CopilotKitErrorCode.UNKNOWN
|
|
953
1161
|
});
|
|
954
1162
|
setBannerError(warningError);
|
|
955
1163
|
}
|
|
@@ -964,16 +1172,16 @@ function createStructuredError(gqlError) {
|
|
|
964
1172
|
const message = (originalError == null ? void 0 : originalError.message) || gqlError.message;
|
|
965
1173
|
const code = extensions == null ? void 0 : extensions.code;
|
|
966
1174
|
if (code) {
|
|
967
|
-
return new
|
|
1175
|
+
return new import_shared6.CopilotKitError({ message, code });
|
|
968
1176
|
}
|
|
969
1177
|
if ((_a = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _a.includes("CopilotApiDiscoveryError")) {
|
|
970
|
-
return new
|
|
1178
|
+
return new import_shared6.CopilotKitApiDiscoveryError({ message });
|
|
971
1179
|
}
|
|
972
1180
|
if ((_b = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _b.includes("CopilotKitRemoteEndpointDiscoveryError")) {
|
|
973
|
-
return new
|
|
1181
|
+
return new import_shared6.CopilotKitRemoteEndpointDiscoveryError({ message });
|
|
974
1182
|
}
|
|
975
1183
|
if ((_c = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _c.includes("CopilotKitAgentDiscoveryError")) {
|
|
976
|
-
return new
|
|
1184
|
+
return new import_shared6.CopilotKitAgentDiscoveryError({
|
|
977
1185
|
agentName: "",
|
|
978
1186
|
availableAgents: []
|
|
979
1187
|
});
|
|
@@ -982,11 +1190,11 @@ function createStructuredError(gqlError) {
|
|
|
982
1190
|
}
|
|
983
1191
|
|
|
984
1192
|
// src/components/error-boundary/error-boundary.tsx
|
|
985
|
-
var
|
|
1193
|
+
var import_react8 = __toESM(require("react"));
|
|
986
1194
|
var import_shared8 = require("@copilotkit/shared");
|
|
987
1195
|
|
|
988
1196
|
// src/lib/status-checker.ts
|
|
989
|
-
var
|
|
1197
|
+
var import_shared7 = require("@copilotkit/shared");
|
|
990
1198
|
var STATUS_CHECK_INTERVAL = 1e3 * 60 * 5;
|
|
991
1199
|
var StatusChecker = class {
|
|
992
1200
|
constructor() {
|
|
@@ -1004,10 +1212,10 @@ var StatusChecker = class {
|
|
|
1004
1212
|
clearInterval(this.intervalId);
|
|
1005
1213
|
const checkStatus = () => __async(this, null, function* () {
|
|
1006
1214
|
try {
|
|
1007
|
-
const response = yield fetch(`${
|
|
1215
|
+
const response = yield fetch(`${import_shared7.COPILOT_CLOUD_API_URL}/ciu`, {
|
|
1008
1216
|
method: "GET",
|
|
1009
1217
|
headers: {
|
|
1010
|
-
[
|
|
1218
|
+
[import_shared7.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey
|
|
1011
1219
|
}
|
|
1012
1220
|
}).then((response2) => response2.json());
|
|
1013
1221
|
this.lastResponse = response;
|
|
@@ -1039,456 +1247,10 @@ var StatusChecker = class {
|
|
|
1039
1247
|
}
|
|
1040
1248
|
};
|
|
1041
1249
|
|
|
1042
|
-
// src/components/usage-banner.tsx
|
|
1043
|
-
var import_shared7 = require("@copilotkit/shared");
|
|
1044
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1045
|
-
var defaultIcons = {
|
|
1046
|
-
[import_shared7.Severity.CRITICAL]: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1047
|
-
"svg",
|
|
1048
|
-
{
|
|
1049
|
-
viewBox: "0 0 24 24",
|
|
1050
|
-
width: "16",
|
|
1051
|
-
height: "16",
|
|
1052
|
-
stroke: "currentColor",
|
|
1053
|
-
strokeWidth: "2.5",
|
|
1054
|
-
fill: "none",
|
|
1055
|
-
strokeLinecap: "round",
|
|
1056
|
-
strokeLinejoin: "round",
|
|
1057
|
-
children: [
|
|
1058
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
1059
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
|
|
1060
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
1061
|
-
]
|
|
1062
|
-
}
|
|
1063
|
-
),
|
|
1064
|
-
[import_shared7.Severity.WARNING]: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1065
|
-
"svg",
|
|
1066
|
-
{
|
|
1067
|
-
viewBox: "0 0 24 24",
|
|
1068
|
-
width: "16",
|
|
1069
|
-
height: "16",
|
|
1070
|
-
stroke: "currentColor",
|
|
1071
|
-
strokeWidth: "2.5",
|
|
1072
|
-
fill: "none",
|
|
1073
|
-
strokeLinecap: "round",
|
|
1074
|
-
strokeLinejoin: "round",
|
|
1075
|
-
children: [
|
|
1076
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
|
|
1077
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "9", x2: "12", y2: "13" }),
|
|
1078
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })
|
|
1079
|
-
]
|
|
1080
|
-
}
|
|
1081
|
-
),
|
|
1082
|
-
[import_shared7.Severity.INFO]: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1083
|
-
"svg",
|
|
1084
|
-
{
|
|
1085
|
-
viewBox: "0 0 24 24",
|
|
1086
|
-
width: "16",
|
|
1087
|
-
height: "16",
|
|
1088
|
-
stroke: "currentColor",
|
|
1089
|
-
strokeWidth: "2.5",
|
|
1090
|
-
fill: "none",
|
|
1091
|
-
strokeLinecap: "round",
|
|
1092
|
-
strokeLinejoin: "round",
|
|
1093
|
-
children: [
|
|
1094
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
1095
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "16", x2: "12", y2: "12" }),
|
|
1096
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "8", x2: "12.01", y2: "8" })
|
|
1097
|
-
]
|
|
1098
|
-
}
|
|
1099
|
-
)
|
|
1100
|
-
};
|
|
1101
|
-
function UsageBanner({
|
|
1102
|
-
severity = import_shared7.Severity.CRITICAL,
|
|
1103
|
-
message = "",
|
|
1104
|
-
icon,
|
|
1105
|
-
onClose,
|
|
1106
|
-
actions
|
|
1107
|
-
}) {
|
|
1108
|
-
if (!message || !severity) {
|
|
1109
|
-
return null;
|
|
1110
|
-
}
|
|
1111
|
-
const parseMessage = (rawMessage) => {
|
|
1112
|
-
if (rawMessage.toLowerCase().includes("authentication") || rawMessage.toLowerCase().includes("api key")) {
|
|
1113
|
-
return "Authentication failed. Please check your API key.";
|
|
1114
|
-
}
|
|
1115
|
-
if (rawMessage.toLowerCase().includes("rate limit")) {
|
|
1116
|
-
return "Rate limit exceeded. Please try again later.";
|
|
1117
|
-
}
|
|
1118
|
-
if (rawMessage.toLowerCase().includes("checkpointer")) {
|
|
1119
|
-
return "Agent configuration error. Please check your setup.";
|
|
1120
|
-
}
|
|
1121
|
-
let cleanMessage2 = rawMessage;
|
|
1122
|
-
cleanMessage2 = cleanMessage2.split(" - ")[0];
|
|
1123
|
-
cleanMessage2 = cleanMessage2.split(": Error code")[0];
|
|
1124
|
-
cleanMessage2 = cleanMessage2.split(": 401")[0];
|
|
1125
|
-
cleanMessage2 = cleanMessage2.split(": 403")[0];
|
|
1126
|
-
cleanMessage2 = cleanMessage2.split(": 404")[0];
|
|
1127
|
-
cleanMessage2 = cleanMessage2.split(": 500")[0];
|
|
1128
|
-
cleanMessage2 = cleanMessage2.replace(/See more:.*$/g, "").trim();
|
|
1129
|
-
if (cleanMessage2.includes("{") || cleanMessage2.includes("'") || cleanMessage2.length > 60) {
|
|
1130
|
-
return "Configuration error. Please check your setup.";
|
|
1131
|
-
}
|
|
1132
|
-
return cleanMessage2 || "An error occurred. Please check your configuration.";
|
|
1133
|
-
};
|
|
1134
|
-
const cleanMessage = parseMessage(message);
|
|
1135
|
-
const Icon = icon || defaultIcons[severity];
|
|
1136
|
-
const themeConfigs = {
|
|
1137
|
-
[import_shared7.Severity.INFO]: {
|
|
1138
|
-
bg: "rgba(239, 246, 255, 0.95)",
|
|
1139
|
-
border: "#93c5fd",
|
|
1140
|
-
text: "#1e40af",
|
|
1141
|
-
icon: "#3b82f6",
|
|
1142
|
-
primaryBtn: "#3b82f6",
|
|
1143
|
-
primaryBtnHover: "#2563eb"
|
|
1144
|
-
},
|
|
1145
|
-
[import_shared7.Severity.WARNING]: {
|
|
1146
|
-
bg: "rgba(255, 251, 235, 0.95)",
|
|
1147
|
-
border: "#fbbf24",
|
|
1148
|
-
text: "#92400e",
|
|
1149
|
-
icon: "#f59e0b",
|
|
1150
|
-
primaryBtn: "#f59e0b",
|
|
1151
|
-
primaryBtnHover: "#d97706"
|
|
1152
|
-
},
|
|
1153
|
-
[import_shared7.Severity.CRITICAL]: {
|
|
1154
|
-
bg: "rgba(254, 242, 242, 0.95)",
|
|
1155
|
-
border: "#f87171",
|
|
1156
|
-
text: "#991b1b",
|
|
1157
|
-
icon: "#ef4444",
|
|
1158
|
-
primaryBtn: "#ef4444",
|
|
1159
|
-
primaryBtnHover: "#dc2626"
|
|
1160
|
-
}
|
|
1161
|
-
};
|
|
1162
|
-
const themeConfig = themeConfigs[severity] || themeConfigs[import_shared7.Severity.CRITICAL];
|
|
1163
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1164
|
-
"div",
|
|
1165
|
-
{
|
|
1166
|
-
style: {
|
|
1167
|
-
position: "fixed",
|
|
1168
|
-
bottom: "24px",
|
|
1169
|
-
left: "50%",
|
|
1170
|
-
transform: "translateX(-50%)",
|
|
1171
|
-
width: "400px",
|
|
1172
|
-
maxWidth: "90vw",
|
|
1173
|
-
zIndex: 1e4,
|
|
1174
|
-
animation: "bannerSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1)"
|
|
1175
|
-
},
|
|
1176
|
-
children: [
|
|
1177
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
|
|
1178
|
-
@keyframes bannerSlideIn {
|
|
1179
|
-
from {
|
|
1180
|
-
opacity: 0;
|
|
1181
|
-
transform: translateX(-50%) translateY(20px);
|
|
1182
|
-
scale: 0.95;
|
|
1183
|
-
}
|
|
1184
|
-
to {
|
|
1185
|
-
opacity: 1;
|
|
1186
|
-
transform: translateX(-50%) translateY(0);
|
|
1187
|
-
scale: 1;
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
` }),
|
|
1191
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1192
|
-
"div",
|
|
1193
|
-
{
|
|
1194
|
-
style: {
|
|
1195
|
-
borderRadius: "12px",
|
|
1196
|
-
border: `1px solid ${themeConfig.border}`,
|
|
1197
|
-
background: themeConfig.bg,
|
|
1198
|
-
padding: "14px",
|
|
1199
|
-
boxShadow: "0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08)",
|
|
1200
|
-
position: "relative",
|
|
1201
|
-
backdropFilter: "blur(12px)",
|
|
1202
|
-
WebkitBackdropFilter: "blur(12px)",
|
|
1203
|
-
boxSizing: "border-box",
|
|
1204
|
-
overflow: "hidden"
|
|
1205
|
-
},
|
|
1206
|
-
children: [
|
|
1207
|
-
onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1208
|
-
"button",
|
|
1209
|
-
{
|
|
1210
|
-
onClick: onClose,
|
|
1211
|
-
style: {
|
|
1212
|
-
position: "absolute",
|
|
1213
|
-
top: "8px",
|
|
1214
|
-
right: "8px",
|
|
1215
|
-
background: "rgba(255, 255, 255, 0.9)",
|
|
1216
|
-
border: "none",
|
|
1217
|
-
color: themeConfig.text,
|
|
1218
|
-
cursor: "pointer",
|
|
1219
|
-
fontSize: "16px",
|
|
1220
|
-
lineHeight: "1",
|
|
1221
|
-
padding: "4px",
|
|
1222
|
-
borderRadius: "4px",
|
|
1223
|
-
width: "20px",
|
|
1224
|
-
height: "20px",
|
|
1225
|
-
display: "flex",
|
|
1226
|
-
alignItems: "center",
|
|
1227
|
-
justifyContent: "center"
|
|
1228
|
-
},
|
|
1229
|
-
title: "Close",
|
|
1230
|
-
children: "\xD7"
|
|
1231
|
-
}
|
|
1232
|
-
),
|
|
1233
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1234
|
-
"div",
|
|
1235
|
-
{
|
|
1236
|
-
style: {
|
|
1237
|
-
fontSize: "14px",
|
|
1238
|
-
fontWeight: 500,
|
|
1239
|
-
color: themeConfig.text,
|
|
1240
|
-
lineHeight: "1.4",
|
|
1241
|
-
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
1242
|
-
paddingRight: onClose ? "30px" : "0",
|
|
1243
|
-
marginBottom: actions ? "12px" : "0",
|
|
1244
|
-
wordBreak: "break-word",
|
|
1245
|
-
overflow: "hidden",
|
|
1246
|
-
textOverflow: "ellipsis",
|
|
1247
|
-
display: "-webkit-box",
|
|
1248
|
-
WebkitLineClamp: 2,
|
|
1249
|
-
WebkitBoxOrient: "vertical"
|
|
1250
|
-
},
|
|
1251
|
-
children: cleanMessage
|
|
1252
|
-
}
|
|
1253
|
-
),
|
|
1254
|
-
actions && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1255
|
-
"div",
|
|
1256
|
-
{
|
|
1257
|
-
style: {
|
|
1258
|
-
display: "flex",
|
|
1259
|
-
gap: "8px",
|
|
1260
|
-
flexWrap: "wrap"
|
|
1261
|
-
},
|
|
1262
|
-
children: [
|
|
1263
|
-
actions.secondary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1264
|
-
"button",
|
|
1265
|
-
{
|
|
1266
|
-
onClick: actions.secondary.onClick,
|
|
1267
|
-
style: {
|
|
1268
|
-
borderRadius: "8px",
|
|
1269
|
-
padding: "6px 12px",
|
|
1270
|
-
fontSize: "13px",
|
|
1271
|
-
fontWeight: 500,
|
|
1272
|
-
color: themeConfig.text,
|
|
1273
|
-
backgroundColor: "rgba(255, 255, 255, 0.9)",
|
|
1274
|
-
border: `1px solid ${themeConfig.border}`,
|
|
1275
|
-
cursor: "pointer",
|
|
1276
|
-
transition: "all 0.2s ease",
|
|
1277
|
-
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
1278
|
-
},
|
|
1279
|
-
onMouseOver: (e) => {
|
|
1280
|
-
e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 1)";
|
|
1281
|
-
e.currentTarget.style.transform = "translateY(-1px)";
|
|
1282
|
-
},
|
|
1283
|
-
onMouseOut: (e) => {
|
|
1284
|
-
e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.9)";
|
|
1285
|
-
e.currentTarget.style.transform = "translateY(0)";
|
|
1286
|
-
},
|
|
1287
|
-
children: actions.secondary.label
|
|
1288
|
-
}
|
|
1289
|
-
),
|
|
1290
|
-
actions.primary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1291
|
-
"button",
|
|
1292
|
-
{
|
|
1293
|
-
onClick: actions.primary.onClick,
|
|
1294
|
-
style: {
|
|
1295
|
-
borderRadius: "8px",
|
|
1296
|
-
padding: "6px 12px",
|
|
1297
|
-
fontSize: "13px",
|
|
1298
|
-
fontWeight: 600,
|
|
1299
|
-
color: "#fff",
|
|
1300
|
-
backgroundColor: themeConfig.primaryBtn,
|
|
1301
|
-
border: "none",
|
|
1302
|
-
cursor: "pointer",
|
|
1303
|
-
transition: "all 0.2s ease",
|
|
1304
|
-
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
|
|
1305
|
-
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
1306
|
-
},
|
|
1307
|
-
onMouseOver: (e) => {
|
|
1308
|
-
e.currentTarget.style.backgroundColor = themeConfig.primaryBtnHover;
|
|
1309
|
-
e.currentTarget.style.transform = "translateY(-1px)";
|
|
1310
|
-
e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.2)";
|
|
1311
|
-
},
|
|
1312
|
-
onMouseOut: (e) => {
|
|
1313
|
-
e.currentTarget.style.backgroundColor = themeConfig.primaryBtn;
|
|
1314
|
-
e.currentTarget.style.transform = "translateY(0)";
|
|
1315
|
-
e.currentTarget.style.boxShadow = "0 2px 8px rgba(0, 0, 0, 0.15)";
|
|
1316
|
-
},
|
|
1317
|
-
children: actions.primary.label
|
|
1318
|
-
}
|
|
1319
|
-
)
|
|
1320
|
-
]
|
|
1321
|
-
}
|
|
1322
|
-
)
|
|
1323
|
-
]
|
|
1324
|
-
}
|
|
1325
|
-
)
|
|
1326
|
-
]
|
|
1327
|
-
}
|
|
1328
|
-
);
|
|
1329
|
-
}
|
|
1330
|
-
function renderCopilotKitUsage(error, onClose) {
|
|
1331
|
-
if (error.visibility !== import_shared7.ErrorVisibility.BANNER) {
|
|
1332
|
-
return null;
|
|
1333
|
-
}
|
|
1334
|
-
const extractUrlFromMessage = (message) => {
|
|
1335
|
-
const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
1336
|
-
const match = linkRegex.exec(message);
|
|
1337
|
-
return match ? match[2] : null;
|
|
1338
|
-
};
|
|
1339
|
-
const getErrorActions = (error2) => {
|
|
1340
|
-
switch (error2.name) {
|
|
1341
|
-
case import_shared7.ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR:
|
|
1342
|
-
return {
|
|
1343
|
-
primary: {
|
|
1344
|
-
label: "Sign In",
|
|
1345
|
-
onClick: () => window.location.href = "https://cloud.copilotkit.ai"
|
|
1346
|
-
}
|
|
1347
|
-
};
|
|
1348
|
-
case import_shared7.ERROR_NAMES.UPGRADE_REQUIRED_ERROR:
|
|
1349
|
-
return {
|
|
1350
|
-
primary: {
|
|
1351
|
-
label: "Upgrade",
|
|
1352
|
-
onClick: () => window.location.href = "https://copilotkit.ai/"
|
|
1353
|
-
}
|
|
1354
|
-
};
|
|
1355
|
-
case import_shared7.ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR:
|
|
1356
|
-
case import_shared7.ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR:
|
|
1357
|
-
case import_shared7.ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR:
|
|
1358
|
-
return {
|
|
1359
|
-
primary: {
|
|
1360
|
-
label: "View Docs",
|
|
1361
|
-
onClick: () => {
|
|
1362
|
-
var _a;
|
|
1363
|
-
const urlFromMessage = extractUrlFromMessage(error2.message);
|
|
1364
|
-
const urlFromExtensions = (_a = error2.extensions) == null ? void 0 : _a.troubleshootingUrl;
|
|
1365
|
-
const url = urlFromMessage || urlFromExtensions || "https://docs.copilotkit.ai/troubleshooting/common-issues";
|
|
1366
|
-
window.open(url, "_blank");
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
};
|
|
1370
|
-
default:
|
|
1371
|
-
return void 0;
|
|
1372
|
-
}
|
|
1373
|
-
};
|
|
1374
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1375
|
-
UsageBanner,
|
|
1376
|
-
{
|
|
1377
|
-
severity: error.severity || import_shared7.Severity.CRITICAL,
|
|
1378
|
-
message: error.message,
|
|
1379
|
-
onClose,
|
|
1380
|
-
actions: getErrorActions(error)
|
|
1381
|
-
}
|
|
1382
|
-
);
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
// src/components/error-boundary/error-utils.tsx
|
|
1386
|
-
var import_react8 = require("react");
|
|
1387
|
-
|
|
1388
|
-
// src/components/toast/exclamation-mark-icon.tsx
|
|
1389
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1390
|
-
var ExclamationMarkIcon = ({
|
|
1391
|
-
className,
|
|
1392
|
-
style
|
|
1393
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1394
|
-
"svg",
|
|
1395
|
-
{
|
|
1396
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1397
|
-
width: "24",
|
|
1398
|
-
height: "24",
|
|
1399
|
-
viewBox: "0 0 24 24",
|
|
1400
|
-
fill: "none",
|
|
1401
|
-
stroke: "currentColor",
|
|
1402
|
-
strokeWidth: "2",
|
|
1403
|
-
strokeLinecap: "round",
|
|
1404
|
-
strokeLinejoin: "round",
|
|
1405
|
-
className: `lucide lucide-circle-alert ${className ? className : ""}`,
|
|
1406
|
-
style,
|
|
1407
|
-
children: [
|
|
1408
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
1409
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "12" }),
|
|
1410
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "12", x2: "12.01", y1: "16", y2: "16" })
|
|
1411
|
-
]
|
|
1412
|
-
}
|
|
1413
|
-
);
|
|
1414
|
-
|
|
1415
|
-
// src/components/error-boundary/error-utils.tsx
|
|
1416
|
-
var import_react_markdown = __toESM(require("react-markdown"));
|
|
1417
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1418
|
-
function ErrorToast({ errors }) {
|
|
1419
|
-
const errorsToRender = errors.map((error, idx) => {
|
|
1420
|
-
var _a, _b, _c;
|
|
1421
|
-
const originalError = "extensions" in error ? (_a = error.extensions) == null ? void 0 : _a.originalError : {};
|
|
1422
|
-
const message = (_b = originalError == null ? void 0 : originalError.message) != null ? _b : error.message;
|
|
1423
|
-
const code = "extensions" in error ? (_c = error.extensions) == null ? void 0 : _c.code : null;
|
|
1424
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1425
|
-
"div",
|
|
1426
|
-
{
|
|
1427
|
-
style: {
|
|
1428
|
-
marginTop: idx === 0 ? 0 : 10,
|
|
1429
|
-
marginBottom: 14
|
|
1430
|
-
},
|
|
1431
|
-
children: [
|
|
1432
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ExclamationMarkIcon, { style: { marginBottom: 4 } }),
|
|
1433
|
-
code && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1434
|
-
"div",
|
|
1435
|
-
{
|
|
1436
|
-
style: {
|
|
1437
|
-
fontWeight: "600",
|
|
1438
|
-
marginBottom: 4
|
|
1439
|
-
},
|
|
1440
|
-
children: [
|
|
1441
|
-
"Copilot Runtime Error:",
|
|
1442
|
-
" ",
|
|
1443
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { fontFamily: "monospace", fontWeight: "normal" }, children: code })
|
|
1444
|
-
]
|
|
1445
|
-
}
|
|
1446
|
-
),
|
|
1447
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_markdown.default, { children: message })
|
|
1448
|
-
]
|
|
1449
|
-
},
|
|
1450
|
-
idx
|
|
1451
|
-
);
|
|
1452
|
-
});
|
|
1453
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1454
|
-
"div",
|
|
1455
|
-
{
|
|
1456
|
-
style: {
|
|
1457
|
-
fontSize: "13px",
|
|
1458
|
-
maxWidth: "600px"
|
|
1459
|
-
},
|
|
1460
|
-
children: [
|
|
1461
|
-
errorsToRender,
|
|
1462
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { fontSize: "11px", opacity: 0.75 }, children: "NOTE: This error only displays during local development." })
|
|
1463
|
-
]
|
|
1464
|
-
}
|
|
1465
|
-
);
|
|
1466
|
-
}
|
|
1467
|
-
function useErrorToast() {
|
|
1468
|
-
const { addToast } = useToast();
|
|
1469
|
-
return (0, import_react8.useCallback)(
|
|
1470
|
-
(error) => {
|
|
1471
|
-
const errorId = error.map((err) => {
|
|
1472
|
-
var _a, _b;
|
|
1473
|
-
const message = "extensions" in err ? ((_b = (_a = err.extensions) == null ? void 0 : _a.originalError) == null ? void 0 : _b.message) || err.message : err.message;
|
|
1474
|
-
const stack = err.stack || "";
|
|
1475
|
-
return btoa(message + stack).slice(0, 32);
|
|
1476
|
-
}).join("|");
|
|
1477
|
-
addToast({
|
|
1478
|
-
type: "error",
|
|
1479
|
-
id: errorId,
|
|
1480
|
-
// Toast libraries typically dedupe by id
|
|
1481
|
-
message: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ErrorToast, { errors: error })
|
|
1482
|
-
});
|
|
1483
|
-
},
|
|
1484
|
-
[addToast]
|
|
1485
|
-
);
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
1250
|
// src/components/error-boundary/error-boundary.tsx
|
|
1489
|
-
var
|
|
1251
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1490
1252
|
var statusChecker = new StatusChecker();
|
|
1491
|
-
var CopilotErrorBoundary = class extends
|
|
1253
|
+
var CopilotErrorBoundary = class extends import_react8.default.Component {
|
|
1492
1254
|
constructor(props) {
|
|
1493
1255
|
super(props);
|
|
1494
1256
|
this.state = {
|
|
@@ -1518,22 +1280,17 @@ var CopilotErrorBoundary = class extends import_react9.default.Component {
|
|
|
1518
1280
|
console.error("CopilotKit Error:", error, errorInfo);
|
|
1519
1281
|
}
|
|
1520
1282
|
render() {
|
|
1521
|
-
var _a, _b;
|
|
1283
|
+
var _a, _b, _c, _d;
|
|
1522
1284
|
if (this.state.hasError) {
|
|
1523
1285
|
if (this.state.error instanceof import_shared8.CopilotKitError) {
|
|
1524
|
-
|
|
1525
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ErrorToast2, { error: this.state.error, children: renderCopilotKitUsage(
|
|
1526
|
-
this.state.error,
|
|
1527
|
-
() => this.setState({ hasError: false, error: void 0 })
|
|
1528
|
-
) });
|
|
1529
|
-
}
|
|
1530
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1531
1287
|
this.props.children,
|
|
1532
|
-
this.props.showUsageBanner && /* @__PURE__ */ (0,
|
|
1288
|
+
this.props.showUsageBanner && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1533
1289
|
UsageBanner,
|
|
1534
1290
|
{
|
|
1535
|
-
severity: (_a = this.state.status) == null ? void 0 : _a.severity,
|
|
1536
|
-
message: (
|
|
1291
|
+
severity: (_b = (_a = this.state.status) == null ? void 0 : _a.severity) != null ? _b : this.state.error.severity,
|
|
1292
|
+
message: (_d = (_c = this.state.status) == null ? void 0 : _c.message) != null ? _d : this.state.error.message,
|
|
1293
|
+
actions: getErrorActions(this.state.error)
|
|
1537
1294
|
}
|
|
1538
1295
|
)
|
|
1539
1296
|
] });
|
|
@@ -1543,80 +1300,66 @@ var CopilotErrorBoundary = class extends import_react9.default.Component {
|
|
|
1543
1300
|
return this.props.children;
|
|
1544
1301
|
}
|
|
1545
1302
|
};
|
|
1546
|
-
function ErrorToast2({ error, children }) {
|
|
1547
|
-
const addErrorToast = useErrorToast();
|
|
1548
|
-
(0, import_react9.useEffect)(() => {
|
|
1549
|
-
if (error) {
|
|
1550
|
-
addErrorToast([error]);
|
|
1551
|
-
}
|
|
1552
|
-
}, [error, addErrorToast]);
|
|
1553
|
-
if (!error)
|
|
1554
|
-
throw error;
|
|
1555
|
-
return children;
|
|
1556
|
-
}
|
|
1557
1303
|
|
|
1558
1304
|
// src/components/copilot-provider/copilotkit.tsx
|
|
1559
|
-
var
|
|
1305
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1560
1306
|
function CopilotKit(_a) {
|
|
1561
1307
|
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
const enabled = shouldShowDevConsole(showDevConsole);
|
|
1565
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotErrorBoundary, { publicApiKey: props.publicApiKey, showUsageBanner: enabled, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) }) });
|
|
1308
|
+
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
1309
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CopilotErrorBoundary, { publicApiKey: props.publicApiKey, showUsageBanner: enabled, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) }) });
|
|
1566
1310
|
}
|
|
1567
1311
|
function CopilotKitInternal(cpkProps) {
|
|
1568
|
-
var _b, _c;
|
|
1569
1312
|
const _a = cpkProps, { children } = _a, props = __objRest(_a, ["children"]);
|
|
1570
1313
|
validateProps(cpkProps);
|
|
1571
1314
|
const chatApiEndpoint = props.runtimeUrl || import_shared9.COPILOT_CLOUD_CHAT_URL;
|
|
1572
|
-
const [actions, setActions] = (0,
|
|
1573
|
-
const [coAgentStateRenders, setCoAgentStateRenders] = (0,
|
|
1574
|
-
const chatComponentsCache = (0,
|
|
1315
|
+
const [actions, setActions] = (0, import_react9.useState)({});
|
|
1316
|
+
const [coAgentStateRenders, setCoAgentStateRenders] = (0, import_react9.useState)({});
|
|
1317
|
+
const chatComponentsCache = (0, import_react9.useRef)({
|
|
1575
1318
|
actions: {},
|
|
1576
1319
|
coAgentStateRenders: {}
|
|
1577
1320
|
});
|
|
1578
1321
|
const { addElement, removeElement, printTree, getAllElements } = use_tree_default();
|
|
1579
|
-
const [isLoading, setIsLoading] = (0,
|
|
1580
|
-
const [chatInstructions, setChatInstructions] = (0,
|
|
1581
|
-
const [authStates, setAuthStates] = (0,
|
|
1582
|
-
const [extensions, setExtensions] = (0,
|
|
1583
|
-
const [additionalInstructions, setAdditionalInstructions] = (0,
|
|
1322
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
|
|
1323
|
+
const [chatInstructions, setChatInstructions] = (0, import_react9.useState)("");
|
|
1324
|
+
const [authStates, setAuthStates] = (0, import_react9.useState)({});
|
|
1325
|
+
const [extensions, setExtensions] = (0, import_react9.useState)({});
|
|
1326
|
+
const [additionalInstructions, setAdditionalInstructions] = (0, import_react9.useState)([]);
|
|
1584
1327
|
const {
|
|
1585
1328
|
addElement: addDocument,
|
|
1586
1329
|
removeElement: removeDocument,
|
|
1587
1330
|
allElements: allDocuments
|
|
1588
1331
|
} = use_flat_category_store_default();
|
|
1589
|
-
const statusChecker2 = (0,
|
|
1590
|
-
const [usageBannerStatus, setUsageBannerStatus] = (0,
|
|
1591
|
-
const setAction = (0,
|
|
1332
|
+
const statusChecker2 = (0, import_react9.useMemo)(() => new StatusChecker(), []);
|
|
1333
|
+
const [usageBannerStatus, setUsageBannerStatus] = (0, import_react9.useState)(null);
|
|
1334
|
+
const setAction = (0, import_react9.useCallback)((id, action) => {
|
|
1592
1335
|
setActions((prevPoints) => {
|
|
1593
1336
|
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
1594
1337
|
[id]: action
|
|
1595
1338
|
});
|
|
1596
1339
|
});
|
|
1597
1340
|
}, []);
|
|
1598
|
-
const removeAction = (0,
|
|
1341
|
+
const removeAction = (0, import_react9.useCallback)((id) => {
|
|
1599
1342
|
setActions((prevPoints) => {
|
|
1600
1343
|
const newPoints = __spreadValues({}, prevPoints);
|
|
1601
1344
|
delete newPoints[id];
|
|
1602
1345
|
return newPoints;
|
|
1603
1346
|
});
|
|
1604
1347
|
}, []);
|
|
1605
|
-
const setCoAgentStateRender = (0,
|
|
1348
|
+
const setCoAgentStateRender = (0, import_react9.useCallback)((id, stateRender) => {
|
|
1606
1349
|
setCoAgentStateRenders((prevPoints) => {
|
|
1607
1350
|
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
1608
1351
|
[id]: stateRender
|
|
1609
1352
|
});
|
|
1610
1353
|
});
|
|
1611
1354
|
}, []);
|
|
1612
|
-
const removeCoAgentStateRender = (0,
|
|
1355
|
+
const removeCoAgentStateRender = (0, import_react9.useCallback)((id) => {
|
|
1613
1356
|
setCoAgentStateRenders((prevPoints) => {
|
|
1614
1357
|
const newPoints = __spreadValues({}, prevPoints);
|
|
1615
1358
|
delete newPoints[id];
|
|
1616
1359
|
return newPoints;
|
|
1617
1360
|
});
|
|
1618
1361
|
}, []);
|
|
1619
|
-
const getContextString = (0,
|
|
1362
|
+
const getContextString = (0, import_react9.useCallback)(
|
|
1620
1363
|
(documents, categories) => {
|
|
1621
1364
|
const documentsString = documents.map((document) => {
|
|
1622
1365
|
return `${document.name} (${document.sourceApplication}):
|
|
@@ -1629,47 +1372,47 @@ ${nonDocumentStrings}`;
|
|
|
1629
1372
|
},
|
|
1630
1373
|
[printTree]
|
|
1631
1374
|
);
|
|
1632
|
-
const addContext = (0,
|
|
1375
|
+
const addContext = (0, import_react9.useCallback)(
|
|
1633
1376
|
(context, parentId, categories = defaultCopilotContextCategories) => {
|
|
1634
1377
|
return addElement(context, categories, parentId);
|
|
1635
1378
|
},
|
|
1636
1379
|
[addElement]
|
|
1637
1380
|
);
|
|
1638
|
-
const removeContext = (0,
|
|
1381
|
+
const removeContext = (0, import_react9.useCallback)(
|
|
1639
1382
|
(id) => {
|
|
1640
1383
|
removeElement(id);
|
|
1641
1384
|
},
|
|
1642
1385
|
[removeElement]
|
|
1643
1386
|
);
|
|
1644
|
-
const getAllContext = (0,
|
|
1387
|
+
const getAllContext = (0, import_react9.useCallback)(() => {
|
|
1645
1388
|
return getAllElements();
|
|
1646
1389
|
}, [getAllElements]);
|
|
1647
|
-
const getFunctionCallHandler = (0,
|
|
1390
|
+
const getFunctionCallHandler = (0, import_react9.useCallback)(
|
|
1648
1391
|
(customEntryPoints) => {
|
|
1649
1392
|
return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));
|
|
1650
1393
|
},
|
|
1651
1394
|
[actions]
|
|
1652
1395
|
);
|
|
1653
|
-
const getDocumentsContext = (0,
|
|
1396
|
+
const getDocumentsContext = (0, import_react9.useCallback)(
|
|
1654
1397
|
(categories) => {
|
|
1655
1398
|
return allDocuments(categories);
|
|
1656
1399
|
},
|
|
1657
1400
|
[allDocuments]
|
|
1658
1401
|
);
|
|
1659
|
-
const addDocumentContext = (0,
|
|
1402
|
+
const addDocumentContext = (0, import_react9.useCallback)(
|
|
1660
1403
|
(documentPointer, categories = defaultCopilotContextCategories) => {
|
|
1661
1404
|
return addDocument(documentPointer, categories);
|
|
1662
1405
|
},
|
|
1663
1406
|
[addDocument]
|
|
1664
1407
|
);
|
|
1665
|
-
const removeDocumentContext = (0,
|
|
1408
|
+
const removeDocumentContext = (0, import_react9.useCallback)(
|
|
1666
1409
|
(documentId) => {
|
|
1667
1410
|
removeDocument(documentId);
|
|
1668
1411
|
},
|
|
1669
1412
|
[removeDocument]
|
|
1670
1413
|
);
|
|
1671
|
-
const copilotApiConfig = (0,
|
|
1672
|
-
var _a2,
|
|
1414
|
+
const copilotApiConfig = (0, import_react9.useMemo)(() => {
|
|
1415
|
+
var _a2, _b;
|
|
1673
1416
|
let cloud = void 0;
|
|
1674
1417
|
if (props.publicApiKey) {
|
|
1675
1418
|
cloud = {
|
|
@@ -1678,7 +1421,7 @@ ${nonDocumentStrings}`;
|
|
|
1678
1421
|
restrictToTopic: {
|
|
1679
1422
|
enabled: Boolean(props.guardrails_c),
|
|
1680
1423
|
validTopics: ((_a2 = props.guardrails_c) == null ? void 0 : _a2.validTopics) || [],
|
|
1681
|
-
invalidTopics: ((
|
|
1424
|
+
invalidTopics: ((_b = props.guardrails_c) == null ? void 0 : _b.invalidTopics) || []
|
|
1682
1425
|
}
|
|
1683
1426
|
}
|
|
1684
1427
|
}
|
|
@@ -1704,7 +1447,7 @@ ${nonDocumentStrings}`;
|
|
|
1704
1447
|
props.cloudRestrictToTopic,
|
|
1705
1448
|
props.guardrails_c
|
|
1706
1449
|
]);
|
|
1707
|
-
const headers = (0,
|
|
1450
|
+
const headers = (0, import_react9.useMemo)(() => {
|
|
1708
1451
|
const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {
|
|
1709
1452
|
if (state.status === "authenticated" && state.authHeaders) {
|
|
1710
1453
|
return __spreadValues(__spreadValues({}, acc), Object.entries(state.authHeaders).reduce(
|
|
@@ -1723,17 +1466,17 @@ ${nonDocumentStrings}`;
|
|
|
1723
1466
|
publicApiKey: copilotApiConfig.publicApiKey,
|
|
1724
1467
|
headers,
|
|
1725
1468
|
credentials: copilotApiConfig.credentials,
|
|
1726
|
-
showDevConsole: (
|
|
1469
|
+
showDevConsole: shouldShowDevConsole(props.showDevConsole),
|
|
1727
1470
|
onError: props.onError
|
|
1728
1471
|
});
|
|
1729
|
-
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0,
|
|
1730
|
-
const addChatSuggestionConfiguration = (0,
|
|
1472
|
+
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react9.useState)({});
|
|
1473
|
+
const addChatSuggestionConfiguration = (0, import_react9.useCallback)(
|
|
1731
1474
|
(id, suggestion) => {
|
|
1732
1475
|
setChatSuggestionConfiguration((prev) => __spreadProps(__spreadValues({}, prev), { [id]: suggestion }));
|
|
1733
1476
|
},
|
|
1734
1477
|
[setChatSuggestionConfiguration]
|
|
1735
1478
|
);
|
|
1736
|
-
const removeChatSuggestionConfiguration = (0,
|
|
1479
|
+
const removeChatSuggestionConfiguration = (0, import_react9.useCallback)(
|
|
1737
1480
|
(id) => {
|
|
1738
1481
|
setChatSuggestionConfiguration((prev) => {
|
|
1739
1482
|
const _a2 = prev, { [id]: _ } = _a2, rest = __objRest(_a2, [__restKey(id)]);
|
|
@@ -1742,10 +1485,10 @@ ${nonDocumentStrings}`;
|
|
|
1742
1485
|
},
|
|
1743
1486
|
[setChatSuggestionConfiguration]
|
|
1744
1487
|
);
|
|
1745
|
-
const [availableAgents, setAvailableAgents] = (0,
|
|
1746
|
-
const [coagentStates, setCoagentStates] = (0,
|
|
1747
|
-
const coagentStatesRef = (0,
|
|
1748
|
-
const setCoagentStatesWithRef = (0,
|
|
1488
|
+
const [availableAgents, setAvailableAgents] = (0, import_react9.useState)([]);
|
|
1489
|
+
const [coagentStates, setCoagentStates] = (0, import_react9.useState)({});
|
|
1490
|
+
const coagentStatesRef = (0, import_react9.useRef)({});
|
|
1491
|
+
const setCoagentStatesWithRef = (0, import_react9.useCallback)(
|
|
1749
1492
|
(value) => {
|
|
1750
1493
|
const newValue = typeof value === "function" ? value(coagentStatesRef.current) : value;
|
|
1751
1494
|
coagentStatesRef.current = newValue;
|
|
@@ -1755,8 +1498,8 @@ ${nonDocumentStrings}`;
|
|
|
1755
1498
|
},
|
|
1756
1499
|
[]
|
|
1757
1500
|
);
|
|
1758
|
-
const hasLoadedAgents = (0,
|
|
1759
|
-
(0,
|
|
1501
|
+
const hasLoadedAgents = (0, import_react9.useRef)(false);
|
|
1502
|
+
(0, import_react9.useEffect)(() => {
|
|
1760
1503
|
if (hasLoadedAgents.current)
|
|
1761
1504
|
return;
|
|
1762
1505
|
const fetchData = () => __async(this, null, function* () {
|
|
@@ -1775,8 +1518,8 @@ ${nonDocumentStrings}`;
|
|
|
1775
1518
|
agentName: props.agent
|
|
1776
1519
|
};
|
|
1777
1520
|
}
|
|
1778
|
-
const [agentSession, setAgentSession] = (0,
|
|
1779
|
-
(0,
|
|
1521
|
+
const [agentSession, setAgentSession] = (0, import_react9.useState)(initialAgentSession);
|
|
1522
|
+
(0, import_react9.useEffect)(() => {
|
|
1780
1523
|
if (props.agent) {
|
|
1781
1524
|
setAgentSession({
|
|
1782
1525
|
agentName: props.agent
|
|
@@ -1785,8 +1528,8 @@ ${nonDocumentStrings}`;
|
|
|
1785
1528
|
setAgentSession(null);
|
|
1786
1529
|
}
|
|
1787
1530
|
}, [props.agent]);
|
|
1788
|
-
const [internalThreadId, setInternalThreadId] = (0,
|
|
1789
|
-
const setThreadId = (0,
|
|
1531
|
+
const [internalThreadId, setInternalThreadId] = (0, import_react9.useState)(props.threadId || (0, import_shared9.randomUUID)());
|
|
1532
|
+
const setThreadId = (0, import_react9.useCallback)(
|
|
1790
1533
|
(value) => {
|
|
1791
1534
|
if (props.threadId) {
|
|
1792
1535
|
throw new Error("Cannot call setThreadId() when threadId is provided via props.");
|
|
@@ -1795,16 +1538,16 @@ ${nonDocumentStrings}`;
|
|
|
1795
1538
|
},
|
|
1796
1539
|
[props.threadId]
|
|
1797
1540
|
);
|
|
1798
|
-
(0,
|
|
1541
|
+
(0, import_react9.useEffect)(() => {
|
|
1799
1542
|
if (props.threadId !== void 0) {
|
|
1800
1543
|
setInternalThreadId(props.threadId);
|
|
1801
1544
|
}
|
|
1802
1545
|
}, [props.threadId]);
|
|
1803
|
-
const [runId, setRunId] = (0,
|
|
1804
|
-
const chatAbortControllerRef = (0,
|
|
1805
|
-
const showDevConsole = (
|
|
1806
|
-
const [langGraphInterruptAction, _setLangGraphInterruptAction] = (0,
|
|
1807
|
-
const setLangGraphInterruptAction = (0,
|
|
1546
|
+
const [runId, setRunId] = (0, import_react9.useState)(null);
|
|
1547
|
+
const chatAbortControllerRef = (0, import_react9.useRef)(null);
|
|
1548
|
+
const showDevConsole = shouldShowDevConsole(props.showDevConsole);
|
|
1549
|
+
const [langGraphInterruptAction, _setLangGraphInterruptAction] = (0, import_react9.useState)(null);
|
|
1550
|
+
const setLangGraphInterruptAction = (0, import_react9.useCallback)((action) => {
|
|
1808
1551
|
_setLangGraphInterruptAction((prev) => {
|
|
1809
1552
|
if (prev == null)
|
|
1810
1553
|
return action;
|
|
@@ -1817,23 +1560,24 @@ ${nonDocumentStrings}`;
|
|
|
1817
1560
|
return __spreadProps(__spreadValues(__spreadValues({}, prev), action), { event });
|
|
1818
1561
|
});
|
|
1819
1562
|
}, []);
|
|
1820
|
-
const removeLangGraphInterruptAction = (0,
|
|
1563
|
+
const removeLangGraphInterruptAction = (0, import_react9.useCallback)(() => {
|
|
1821
1564
|
setLangGraphInterruptAction(null);
|
|
1822
1565
|
}, []);
|
|
1823
|
-
const memoizedChildren = (0,
|
|
1824
|
-
const [
|
|
1825
|
-
const
|
|
1566
|
+
const memoizedChildren = (0, import_react9.useMemo)(() => children, [children]);
|
|
1567
|
+
const [bannerError, setBannerError] = (0, import_react9.useState)(null);
|
|
1568
|
+
const [suggestions, setSuggestions] = (0, import_react9.useState)([]);
|
|
1569
|
+
const agentLock = (0, import_react9.useMemo)(() => {
|
|
1826
1570
|
var _a2;
|
|
1827
1571
|
return (_a2 = props.agent) != null ? _a2 : null;
|
|
1828
1572
|
}, [props.agent]);
|
|
1829
|
-
const forwardedParameters = (0,
|
|
1573
|
+
const forwardedParameters = (0, import_react9.useMemo)(
|
|
1830
1574
|
() => {
|
|
1831
1575
|
var _a2;
|
|
1832
1576
|
return (_a2 = props.forwardedParameters) != null ? _a2 : {};
|
|
1833
1577
|
},
|
|
1834
1578
|
[props.forwardedParameters]
|
|
1835
1579
|
);
|
|
1836
|
-
const updateExtensions = (0,
|
|
1580
|
+
const updateExtensions = (0, import_react9.useCallback)(
|
|
1837
1581
|
(newExtensions) => {
|
|
1838
1582
|
setExtensions((prev) => {
|
|
1839
1583
|
const resolved = typeof newExtensions === "function" ? newExtensions(prev) : newExtensions;
|
|
@@ -1845,7 +1589,7 @@ ${nonDocumentStrings}`;
|
|
|
1845
1589
|
},
|
|
1846
1590
|
[setExtensions]
|
|
1847
1591
|
);
|
|
1848
|
-
const updateAuthStates = (0,
|
|
1592
|
+
const updateAuthStates = (0, import_react9.useCallback)(
|
|
1849
1593
|
(newAuthStates) => {
|
|
1850
1594
|
setAuthStates((prev) => {
|
|
1851
1595
|
const resolved = typeof newAuthStates === "function" ? newAuthStates(prev) : newAuthStates;
|
|
@@ -1857,7 +1601,7 @@ ${nonDocumentStrings}`;
|
|
|
1857
1601
|
},
|
|
1858
1602
|
[setAuthStates]
|
|
1859
1603
|
);
|
|
1860
|
-
return /* @__PURE__ */ (0,
|
|
1604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1861
1605
|
CopilotContext.Provider,
|
|
1862
1606
|
{
|
|
1863
1607
|
value: {
|
|
@@ -1912,9 +1656,22 @@ ${nonDocumentStrings}`;
|
|
|
1912
1656
|
removeLangGraphInterruptAction,
|
|
1913
1657
|
onError: props.onError,
|
|
1914
1658
|
suggestions,
|
|
1915
|
-
setSuggestions
|
|
1659
|
+
setSuggestions,
|
|
1660
|
+
bannerError,
|
|
1661
|
+
setBannerError
|
|
1916
1662
|
},
|
|
1917
|
-
children:
|
|
1663
|
+
children: [
|
|
1664
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CopilotMessages, { children: memoizedChildren }),
|
|
1665
|
+
bannerError && showDevConsole && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1666
|
+
UsageBanner,
|
|
1667
|
+
{
|
|
1668
|
+
severity: bannerError.severity,
|
|
1669
|
+
message: bannerError.message,
|
|
1670
|
+
onClose: () => setBannerError(null),
|
|
1671
|
+
actions: getErrorActions(bannerError)
|
|
1672
|
+
}
|
|
1673
|
+
)
|
|
1674
|
+
]
|
|
1918
1675
|
}
|
|
1919
1676
|
);
|
|
1920
1677
|
}
|