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