@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/index.js
CHANGED
|
@@ -98,7 +98,9 @@ __export(src_exports, {
|
|
|
98
98
|
useCopilotAction: () => useCopilotAction,
|
|
99
99
|
useCopilotAdditionalInstructions: () => useCopilotAdditionalInstructions,
|
|
100
100
|
useCopilotAuthenticatedAction_c: () => useCopilotAuthenticatedAction_c,
|
|
101
|
-
useCopilotChat: () =>
|
|
101
|
+
useCopilotChat: () => useCopilotChat2,
|
|
102
|
+
useCopilotChatInternal: () => useCopilotChat,
|
|
103
|
+
useCopilotChatLight: () => useCopilotChatLight,
|
|
102
104
|
useCopilotContext: () => useCopilotContext,
|
|
103
105
|
useCopilotMessagesContext: () => useCopilotMessagesContext,
|
|
104
106
|
useCopilotReadable: () => useCopilotReadable,
|
|
@@ -188,6 +190,9 @@ var emptyCopilotContext = {
|
|
|
188
190
|
removeLangGraphInterruptAction: () => null,
|
|
189
191
|
onError: void 0,
|
|
190
192
|
suggestions: [],
|
|
193
|
+
bannerError: null,
|
|
194
|
+
setBannerError: () => {
|
|
195
|
+
},
|
|
191
196
|
setSuggestions: () => {
|
|
192
197
|
}
|
|
193
198
|
};
|
|
@@ -731,8 +736,16 @@ function ToastProvider({
|
|
|
731
736
|
}
|
|
732
737
|
|
|
733
738
|
// src/utils/dev-console.ts
|
|
739
|
+
function isLocalhost() {
|
|
740
|
+
if (typeof window === "undefined")
|
|
741
|
+
return false;
|
|
742
|
+
return window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "0.0.0.0";
|
|
743
|
+
}
|
|
734
744
|
function shouldShowDevConsole(showDevConsole) {
|
|
735
|
-
|
|
745
|
+
if (showDevConsole !== void 0) {
|
|
746
|
+
return showDevConsole;
|
|
747
|
+
}
|
|
748
|
+
return isLocalhost();
|
|
736
749
|
}
|
|
737
750
|
|
|
738
751
|
// src/components/copilot-provider/copilot-messages.tsx
|
|
@@ -892,10 +905,207 @@ function CopilotMessages({ children }) {
|
|
|
892
905
|
);
|
|
893
906
|
}
|
|
894
907
|
|
|
908
|
+
// src/components/usage-banner.tsx
|
|
909
|
+
var import_shared5 = require("@copilotkit/shared");
|
|
910
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
911
|
+
function UsageBanner({
|
|
912
|
+
severity = import_shared5.Severity.CRITICAL,
|
|
913
|
+
message = "",
|
|
914
|
+
onClose,
|
|
915
|
+
actions
|
|
916
|
+
}) {
|
|
917
|
+
if (!message || !severity) {
|
|
918
|
+
return null;
|
|
919
|
+
}
|
|
920
|
+
const themes = {
|
|
921
|
+
[import_shared5.Severity.INFO]: {
|
|
922
|
+
bg: "#f8fafc",
|
|
923
|
+
border: "#e2e8f0",
|
|
924
|
+
text: "#475569",
|
|
925
|
+
accent: "#3b82f6"
|
|
926
|
+
},
|
|
927
|
+
[import_shared5.Severity.WARNING]: {
|
|
928
|
+
bg: "#fffbeb",
|
|
929
|
+
border: "#fbbf24",
|
|
930
|
+
text: "#92400e",
|
|
931
|
+
accent: "#f59e0b"
|
|
932
|
+
},
|
|
933
|
+
[import_shared5.Severity.CRITICAL]: {
|
|
934
|
+
bg: "#fef2f2",
|
|
935
|
+
border: "#fecaca",
|
|
936
|
+
text: "#dc2626",
|
|
937
|
+
accent: "#ef4444"
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
const theme = themes[severity];
|
|
941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
942
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
|
|
943
|
+
@keyframes slideUp {
|
|
944
|
+
from { opacity: 0; transform: translateX(-50%) translateY(8px); }
|
|
945
|
+
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
.usage-banner {
|
|
949
|
+
position: fixed;
|
|
950
|
+
bottom: 24px;
|
|
951
|
+
left: 50%;
|
|
952
|
+
transform: translateX(-50%);
|
|
953
|
+
width: min(600px, calc(100vw - 32px));
|
|
954
|
+
z-index: 10000;
|
|
955
|
+
animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
.banner-content {
|
|
959
|
+
background: linear-gradient(135deg, ${theme.bg} 0%, ${theme.bg}f5 100%);
|
|
960
|
+
border: 1px solid ${theme.border};
|
|
961
|
+
border-radius: 12px;
|
|
962
|
+
padding: 18px 20px;
|
|
963
|
+
box-shadow:
|
|
964
|
+
0 4px 24px rgba(0, 0, 0, 0.08),
|
|
965
|
+
0 2px 8px rgba(0, 0, 0, 0.04),
|
|
966
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.7);
|
|
967
|
+
display: flex;
|
|
968
|
+
align-items: center;
|
|
969
|
+
gap: 16px;
|
|
970
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
|
|
971
|
+
backdrop-filter: blur(12px);
|
|
972
|
+
position: relative;
|
|
973
|
+
overflow: hidden;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
.banner-content::before {
|
|
977
|
+
content: '';
|
|
978
|
+
position: absolute;
|
|
979
|
+
top: 0;
|
|
980
|
+
left: 0;
|
|
981
|
+
right: 0;
|
|
982
|
+
height: 1px;
|
|
983
|
+
background: linear-gradient(90deg, transparent, ${theme.accent}40, transparent);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
.banner-message {
|
|
987
|
+
color: ${theme.text};
|
|
988
|
+
font-size: 14px;
|
|
989
|
+
line-height: 1.5;
|
|
990
|
+
font-weight: 500;
|
|
991
|
+
flex: 1;
|
|
992
|
+
letter-spacing: -0.01em;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
.close-btn {
|
|
996
|
+
background: rgba(0, 0, 0, 0.05);
|
|
997
|
+
border: none;
|
|
998
|
+
color: ${theme.text};
|
|
999
|
+
cursor: pointer;
|
|
1000
|
+
padding: 0;
|
|
1001
|
+
border-radius: 6px;
|
|
1002
|
+
opacity: 0.6;
|
|
1003
|
+
transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
|
|
1004
|
+
font-size: 14px;
|
|
1005
|
+
line-height: 1;
|
|
1006
|
+
flex-shrink: 0;
|
|
1007
|
+
width: 24px;
|
|
1008
|
+
height: 24px;
|
|
1009
|
+
display: flex;
|
|
1010
|
+
align-items: center;
|
|
1011
|
+
justify-content: center;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
.close-btn:hover {
|
|
1015
|
+
opacity: 1;
|
|
1016
|
+
background: rgba(0, 0, 0, 0.08);
|
|
1017
|
+
transform: scale(1.05);
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
.btn-primary {
|
|
1021
|
+
background: linear-gradient(135deg, ${theme.accent} 0%, ${theme.accent}e6 100%);
|
|
1022
|
+
color: white;
|
|
1023
|
+
border: none;
|
|
1024
|
+
border-radius: 8px;
|
|
1025
|
+
padding: 10px 18px;
|
|
1026
|
+
font-size: 13px;
|
|
1027
|
+
font-weight: 600;
|
|
1028
|
+
cursor: pointer;
|
|
1029
|
+
transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
|
|
1030
|
+
font-family: inherit;
|
|
1031
|
+
flex-shrink: 0;
|
|
1032
|
+
box-shadow:
|
|
1033
|
+
0 2px 8px ${theme.accent}30,
|
|
1034
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.2);
|
|
1035
|
+
letter-spacing: -0.01em;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
.btn-primary:hover {
|
|
1039
|
+
transform: translateY(-1px) scale(1.02);
|
|
1040
|
+
box-shadow:
|
|
1041
|
+
0 4px 12px ${theme.accent}40,
|
|
1042
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.25);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
.btn-primary:active {
|
|
1046
|
+
transform: translateY(0) scale(0.98);
|
|
1047
|
+
transition: all 0.08s cubic-bezier(0.16, 1, 0.3, 1);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
@media (max-width: 640px) {
|
|
1051
|
+
.usage-banner {
|
|
1052
|
+
width: calc(100vw - 24px);
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
.banner-content {
|
|
1056
|
+
padding: 16px;
|
|
1057
|
+
gap: 12px;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
.banner-message {
|
|
1061
|
+
font-size: 13px;
|
|
1062
|
+
line-height: 1.45;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
.btn-primary {
|
|
1066
|
+
padding: 8px 14px;
|
|
1067
|
+
font-size: 12px;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
.close-btn {
|
|
1071
|
+
width: 22px;
|
|
1072
|
+
height: 22px;
|
|
1073
|
+
font-size: 12px;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
` }),
|
|
1077
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "usage-banner", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "banner-content", children: [
|
|
1078
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "banner-message", children: message }),
|
|
1079
|
+
(actions == null ? void 0 : actions.primary) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "btn-primary", onClick: actions.primary.onClick, children: actions.primary.label }),
|
|
1080
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { className: "close-btn", onClick: onClose, title: "Close", children: "\xD7" })
|
|
1081
|
+
] }) })
|
|
1082
|
+
] });
|
|
1083
|
+
}
|
|
1084
|
+
var getErrorActions = (error) => {
|
|
1085
|
+
switch (error.code) {
|
|
1086
|
+
case import_shared5.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR:
|
|
1087
|
+
return {
|
|
1088
|
+
primary: {
|
|
1089
|
+
label: "Get Free API Key",
|
|
1090
|
+
onClick: () => window.open("https://cloud.copilotkit.ai", "_blank", "noopener,noreferrer")
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
case import_shared5.CopilotKitErrorCode.UPGRADE_REQUIRED_ERROR:
|
|
1094
|
+
return {
|
|
1095
|
+
primary: {
|
|
1096
|
+
label: "Upgrade",
|
|
1097
|
+
onClick: () => window.open("https://cloud.copilotkit.ai", "_blank", "noopener,noreferrer")
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
default:
|
|
1101
|
+
return void 0;
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
|
|
895
1105
|
// src/hooks/use-copilot-runtime-client.ts
|
|
896
1106
|
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
897
1107
|
var import_react7 = require("react");
|
|
898
|
-
var
|
|
1108
|
+
var import_shared6 = require("@copilotkit/shared");
|
|
899
1109
|
var useCopilotRuntimeClient = (options) => {
|
|
900
1110
|
const { setBannerError } = useToast();
|
|
901
1111
|
const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
|
|
@@ -937,7 +1147,7 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
937
1147
|
const extensions = gqlError.extensions;
|
|
938
1148
|
const visibility = extensions == null ? void 0 : extensions.visibility;
|
|
939
1149
|
const isDev = shouldShowDevConsole(showDevConsole != null ? showDevConsole : false);
|
|
940
|
-
if (visibility ===
|
|
1150
|
+
if (visibility === import_shared6.ErrorVisibility.SILENT) {
|
|
941
1151
|
console.error("CopilotKit Silent Error:", gqlError.message);
|
|
942
1152
|
return;
|
|
943
1153
|
}
|
|
@@ -956,9 +1166,9 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
956
1166
|
setBannerError(ckError);
|
|
957
1167
|
traceUIError(ckError, gqlError);
|
|
958
1168
|
} else {
|
|
959
|
-
const fallbackError = new
|
|
1169
|
+
const fallbackError = new import_shared6.CopilotKitError({
|
|
960
1170
|
message: gqlError.message,
|
|
961
|
-
code:
|
|
1171
|
+
code: import_shared6.CopilotKitErrorCode.UNKNOWN
|
|
962
1172
|
});
|
|
963
1173
|
setBannerError(fallbackError);
|
|
964
1174
|
traceUIError(fallbackError, gqlError);
|
|
@@ -970,9 +1180,9 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
970
1180
|
if (!isDev) {
|
|
971
1181
|
console.error("CopilotKit Error (hidden in production):", error);
|
|
972
1182
|
} else {
|
|
973
|
-
const fallbackError = new
|
|
1183
|
+
const fallbackError = new import_shared6.CopilotKitError({
|
|
974
1184
|
message: (error == null ? void 0 : error.message) || String(error),
|
|
975
|
-
code:
|
|
1185
|
+
code: import_shared6.CopilotKitErrorCode.UNKNOWN
|
|
976
1186
|
});
|
|
977
1187
|
setBannerError(fallbackError);
|
|
978
1188
|
traceUIError(fallbackError, error);
|
|
@@ -981,9 +1191,9 @@ var useCopilotRuntimeClient = (options) => {
|
|
|
981
1191
|
},
|
|
982
1192
|
handleGQLWarning: (message) => {
|
|
983
1193
|
console.warn(message);
|
|
984
|
-
const warningError = new
|
|
1194
|
+
const warningError = new import_shared6.CopilotKitError({
|
|
985
1195
|
message,
|
|
986
|
-
code:
|
|
1196
|
+
code: import_shared6.CopilotKitErrorCode.UNKNOWN
|
|
987
1197
|
});
|
|
988
1198
|
setBannerError(warningError);
|
|
989
1199
|
}
|
|
@@ -998,16 +1208,16 @@ function createStructuredError(gqlError) {
|
|
|
998
1208
|
const message = (originalError == null ? void 0 : originalError.message) || gqlError.message;
|
|
999
1209
|
const code = extensions == null ? void 0 : extensions.code;
|
|
1000
1210
|
if (code) {
|
|
1001
|
-
return new
|
|
1211
|
+
return new import_shared6.CopilotKitError({ message, code });
|
|
1002
1212
|
}
|
|
1003
1213
|
if ((_a = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _a.includes("CopilotApiDiscoveryError")) {
|
|
1004
|
-
return new
|
|
1214
|
+
return new import_shared6.CopilotKitApiDiscoveryError({ message });
|
|
1005
1215
|
}
|
|
1006
1216
|
if ((_b = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _b.includes("CopilotKitRemoteEndpointDiscoveryError")) {
|
|
1007
|
-
return new
|
|
1217
|
+
return new import_shared6.CopilotKitRemoteEndpointDiscoveryError({ message });
|
|
1008
1218
|
}
|
|
1009
1219
|
if ((_c = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _c.includes("CopilotKitAgentDiscoveryError")) {
|
|
1010
|
-
return new
|
|
1220
|
+
return new import_shared6.CopilotKitAgentDiscoveryError({
|
|
1011
1221
|
agentName: "",
|
|
1012
1222
|
availableAgents: []
|
|
1013
1223
|
});
|
|
@@ -1016,7 +1226,7 @@ function createStructuredError(gqlError) {
|
|
|
1016
1226
|
}
|
|
1017
1227
|
|
|
1018
1228
|
// src/utils/extract.ts
|
|
1019
|
-
var
|
|
1229
|
+
var import_shared7 = require("@copilotkit/shared");
|
|
1020
1230
|
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
1021
1231
|
var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
|
|
1022
1232
|
function extract(_0) {
|
|
@@ -1065,7 +1275,7 @@ function extract(_0) {
|
|
|
1065
1275
|
{
|
|
1066
1276
|
name: action.name,
|
|
1067
1277
|
description: action.description || "",
|
|
1068
|
-
jsonSchema: JSON.stringify((0,
|
|
1278
|
+
jsonSchema: JSON.stringify((0, import_shared7.actionParametersToJsonSchema)(action.parameters || []))
|
|
1069
1279
|
}
|
|
1070
1280
|
],
|
|
1071
1281
|
url: window.location.href
|
|
@@ -1150,7 +1360,7 @@ This is not a conversation, so please do not ask questions. Just call the functi
|
|
|
1150
1360
|
}
|
|
1151
1361
|
|
|
1152
1362
|
// src/utils/suggestions.ts
|
|
1153
|
-
var
|
|
1363
|
+
var import_shared8 = require("@copilotkit/shared");
|
|
1154
1364
|
var import_runtime_client_gql5 = require("@copilotkit/runtime-client-gql");
|
|
1155
1365
|
var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggestions, abortControllerRef) => __async(void 0, null, function* () {
|
|
1156
1366
|
const abortController = abortControllerRef.current;
|
|
@@ -1167,7 +1377,7 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
|
|
|
1167
1377
|
Object.values(context.actions).map((action) => ({
|
|
1168
1378
|
name: action.name,
|
|
1169
1379
|
description: action.description,
|
|
1170
|
-
jsonSchema: JSON.stringify((0,
|
|
1380
|
+
jsonSchema: JSON.stringify((0, import_shared8.actionParametersToJsonSchema)(action.parameters))
|
|
1171
1381
|
}))
|
|
1172
1382
|
);
|
|
1173
1383
|
const allSuggestions = [];
|
|
@@ -1294,7 +1504,7 @@ var import_react9 = __toESM(require("react"));
|
|
|
1294
1504
|
var import_shared10 = require("@copilotkit/shared");
|
|
1295
1505
|
|
|
1296
1506
|
// src/lib/status-checker.ts
|
|
1297
|
-
var
|
|
1507
|
+
var import_shared9 = require("@copilotkit/shared");
|
|
1298
1508
|
var STATUS_CHECK_INTERVAL = 1e3 * 60 * 5;
|
|
1299
1509
|
var StatusChecker = class {
|
|
1300
1510
|
constructor() {
|
|
@@ -1312,10 +1522,10 @@ var StatusChecker = class {
|
|
|
1312
1522
|
clearInterval(this.intervalId);
|
|
1313
1523
|
const checkStatus = () => __async(this, null, function* () {
|
|
1314
1524
|
try {
|
|
1315
|
-
const response = yield fetch(`${
|
|
1525
|
+
const response = yield fetch(`${import_shared9.COPILOT_CLOUD_API_URL}/ciu`, {
|
|
1316
1526
|
method: "GET",
|
|
1317
1527
|
headers: {
|
|
1318
|
-
[
|
|
1528
|
+
[import_shared9.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey
|
|
1319
1529
|
}
|
|
1320
1530
|
}).then((response2) => response2.json());
|
|
1321
1531
|
this.lastResponse = response;
|
|
@@ -1347,349 +1557,6 @@ var StatusChecker = class {
|
|
|
1347
1557
|
}
|
|
1348
1558
|
};
|
|
1349
1559
|
|
|
1350
|
-
// src/components/usage-banner.tsx
|
|
1351
|
-
var import_shared9 = require("@copilotkit/shared");
|
|
1352
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1353
|
-
var defaultIcons = {
|
|
1354
|
-
[import_shared9.Severity.CRITICAL]: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1355
|
-
"svg",
|
|
1356
|
-
{
|
|
1357
|
-
viewBox: "0 0 24 24",
|
|
1358
|
-
width: "16",
|
|
1359
|
-
height: "16",
|
|
1360
|
-
stroke: "currentColor",
|
|
1361
|
-
strokeWidth: "2.5",
|
|
1362
|
-
fill: "none",
|
|
1363
|
-
strokeLinecap: "round",
|
|
1364
|
-
strokeLinejoin: "round",
|
|
1365
|
-
children: [
|
|
1366
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
1367
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
|
|
1368
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
|
|
1369
|
-
]
|
|
1370
|
-
}
|
|
1371
|
-
),
|
|
1372
|
-
[import_shared9.Severity.WARNING]: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1373
|
-
"svg",
|
|
1374
|
-
{
|
|
1375
|
-
viewBox: "0 0 24 24",
|
|
1376
|
-
width: "16",
|
|
1377
|
-
height: "16",
|
|
1378
|
-
stroke: "currentColor",
|
|
1379
|
-
strokeWidth: "2.5",
|
|
1380
|
-
fill: "none",
|
|
1381
|
-
strokeLinecap: "round",
|
|
1382
|
-
strokeLinejoin: "round",
|
|
1383
|
-
children: [
|
|
1384
|
-
/* @__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" }),
|
|
1385
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "9", x2: "12", y2: "13" }),
|
|
1386
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })
|
|
1387
|
-
]
|
|
1388
|
-
}
|
|
1389
|
-
),
|
|
1390
|
-
[import_shared9.Severity.INFO]: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1391
|
-
"svg",
|
|
1392
|
-
{
|
|
1393
|
-
viewBox: "0 0 24 24",
|
|
1394
|
-
width: "16",
|
|
1395
|
-
height: "16",
|
|
1396
|
-
stroke: "currentColor",
|
|
1397
|
-
strokeWidth: "2.5",
|
|
1398
|
-
fill: "none",
|
|
1399
|
-
strokeLinecap: "round",
|
|
1400
|
-
strokeLinejoin: "round",
|
|
1401
|
-
children: [
|
|
1402
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
1403
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "16", x2: "12", y2: "12" }),
|
|
1404
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "12", y1: "8", x2: "12.01", y2: "8" })
|
|
1405
|
-
]
|
|
1406
|
-
}
|
|
1407
|
-
)
|
|
1408
|
-
};
|
|
1409
|
-
function UsageBanner({
|
|
1410
|
-
severity = import_shared9.Severity.CRITICAL,
|
|
1411
|
-
message = "",
|
|
1412
|
-
icon,
|
|
1413
|
-
onClose,
|
|
1414
|
-
actions
|
|
1415
|
-
}) {
|
|
1416
|
-
if (!message || !severity) {
|
|
1417
|
-
return null;
|
|
1418
|
-
}
|
|
1419
|
-
const parseMessage = (rawMessage) => {
|
|
1420
|
-
if (rawMessage.toLowerCase().includes("authentication") || rawMessage.toLowerCase().includes("api key")) {
|
|
1421
|
-
return "Authentication failed. Please check your API key.";
|
|
1422
|
-
}
|
|
1423
|
-
if (rawMessage.toLowerCase().includes("rate limit")) {
|
|
1424
|
-
return "Rate limit exceeded. Please try again later.";
|
|
1425
|
-
}
|
|
1426
|
-
if (rawMessage.toLowerCase().includes("checkpointer")) {
|
|
1427
|
-
return "Agent configuration error. Please check your setup.";
|
|
1428
|
-
}
|
|
1429
|
-
let cleanMessage2 = rawMessage;
|
|
1430
|
-
cleanMessage2 = cleanMessage2.split(" - ")[0];
|
|
1431
|
-
cleanMessage2 = cleanMessage2.split(": Error code")[0];
|
|
1432
|
-
cleanMessage2 = cleanMessage2.split(": 401")[0];
|
|
1433
|
-
cleanMessage2 = cleanMessage2.split(": 403")[0];
|
|
1434
|
-
cleanMessage2 = cleanMessage2.split(": 404")[0];
|
|
1435
|
-
cleanMessage2 = cleanMessage2.split(": 500")[0];
|
|
1436
|
-
cleanMessage2 = cleanMessage2.replace(/See more:.*$/g, "").trim();
|
|
1437
|
-
if (cleanMessage2.includes("{") || cleanMessage2.includes("'") || cleanMessage2.length > 60) {
|
|
1438
|
-
return "Configuration error. Please check your setup.";
|
|
1439
|
-
}
|
|
1440
|
-
return cleanMessage2 || "An error occurred. Please check your configuration.";
|
|
1441
|
-
};
|
|
1442
|
-
const cleanMessage = parseMessage(message);
|
|
1443
|
-
const Icon = icon || defaultIcons[severity];
|
|
1444
|
-
const themeConfigs = {
|
|
1445
|
-
[import_shared9.Severity.INFO]: {
|
|
1446
|
-
bg: "rgba(239, 246, 255, 0.95)",
|
|
1447
|
-
border: "#93c5fd",
|
|
1448
|
-
text: "#1e40af",
|
|
1449
|
-
icon: "#3b82f6",
|
|
1450
|
-
primaryBtn: "#3b82f6",
|
|
1451
|
-
primaryBtnHover: "#2563eb"
|
|
1452
|
-
},
|
|
1453
|
-
[import_shared9.Severity.WARNING]: {
|
|
1454
|
-
bg: "rgba(255, 251, 235, 0.95)",
|
|
1455
|
-
border: "#fbbf24",
|
|
1456
|
-
text: "#92400e",
|
|
1457
|
-
icon: "#f59e0b",
|
|
1458
|
-
primaryBtn: "#f59e0b",
|
|
1459
|
-
primaryBtnHover: "#d97706"
|
|
1460
|
-
},
|
|
1461
|
-
[import_shared9.Severity.CRITICAL]: {
|
|
1462
|
-
bg: "rgba(254, 242, 242, 0.95)",
|
|
1463
|
-
border: "#f87171",
|
|
1464
|
-
text: "#991b1b",
|
|
1465
|
-
icon: "#ef4444",
|
|
1466
|
-
primaryBtn: "#ef4444",
|
|
1467
|
-
primaryBtnHover: "#dc2626"
|
|
1468
|
-
}
|
|
1469
|
-
};
|
|
1470
|
-
const themeConfig = themeConfigs[severity] || themeConfigs[import_shared9.Severity.CRITICAL];
|
|
1471
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1472
|
-
"div",
|
|
1473
|
-
{
|
|
1474
|
-
style: {
|
|
1475
|
-
position: "fixed",
|
|
1476
|
-
bottom: "24px",
|
|
1477
|
-
left: "50%",
|
|
1478
|
-
transform: "translateX(-50%)",
|
|
1479
|
-
width: "400px",
|
|
1480
|
-
maxWidth: "90vw",
|
|
1481
|
-
zIndex: 1e4,
|
|
1482
|
-
animation: "bannerSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1)"
|
|
1483
|
-
},
|
|
1484
|
-
children: [
|
|
1485
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
|
|
1486
|
-
@keyframes bannerSlideIn {
|
|
1487
|
-
from {
|
|
1488
|
-
opacity: 0;
|
|
1489
|
-
transform: translateX(-50%) translateY(20px);
|
|
1490
|
-
scale: 0.95;
|
|
1491
|
-
}
|
|
1492
|
-
to {
|
|
1493
|
-
opacity: 1;
|
|
1494
|
-
transform: translateX(-50%) translateY(0);
|
|
1495
|
-
scale: 1;
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
` }),
|
|
1499
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1500
|
-
"div",
|
|
1501
|
-
{
|
|
1502
|
-
style: {
|
|
1503
|
-
borderRadius: "12px",
|
|
1504
|
-
border: `1px solid ${themeConfig.border}`,
|
|
1505
|
-
background: themeConfig.bg,
|
|
1506
|
-
padding: "14px",
|
|
1507
|
-
boxShadow: "0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08)",
|
|
1508
|
-
position: "relative",
|
|
1509
|
-
backdropFilter: "blur(12px)",
|
|
1510
|
-
WebkitBackdropFilter: "blur(12px)",
|
|
1511
|
-
boxSizing: "border-box",
|
|
1512
|
-
overflow: "hidden"
|
|
1513
|
-
},
|
|
1514
|
-
children: [
|
|
1515
|
-
onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1516
|
-
"button",
|
|
1517
|
-
{
|
|
1518
|
-
onClick: onClose,
|
|
1519
|
-
style: {
|
|
1520
|
-
position: "absolute",
|
|
1521
|
-
top: "8px",
|
|
1522
|
-
right: "8px",
|
|
1523
|
-
background: "rgba(255, 255, 255, 0.9)",
|
|
1524
|
-
border: "none",
|
|
1525
|
-
color: themeConfig.text,
|
|
1526
|
-
cursor: "pointer",
|
|
1527
|
-
fontSize: "16px",
|
|
1528
|
-
lineHeight: "1",
|
|
1529
|
-
padding: "4px",
|
|
1530
|
-
borderRadius: "4px",
|
|
1531
|
-
width: "20px",
|
|
1532
|
-
height: "20px",
|
|
1533
|
-
display: "flex",
|
|
1534
|
-
alignItems: "center",
|
|
1535
|
-
justifyContent: "center"
|
|
1536
|
-
},
|
|
1537
|
-
title: "Close",
|
|
1538
|
-
children: "\xD7"
|
|
1539
|
-
}
|
|
1540
|
-
),
|
|
1541
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1542
|
-
"div",
|
|
1543
|
-
{
|
|
1544
|
-
style: {
|
|
1545
|
-
fontSize: "14px",
|
|
1546
|
-
fontWeight: 500,
|
|
1547
|
-
color: themeConfig.text,
|
|
1548
|
-
lineHeight: "1.4",
|
|
1549
|
-
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
|
|
1550
|
-
paddingRight: onClose ? "30px" : "0",
|
|
1551
|
-
marginBottom: actions ? "12px" : "0",
|
|
1552
|
-
wordBreak: "break-word",
|
|
1553
|
-
overflow: "hidden",
|
|
1554
|
-
textOverflow: "ellipsis",
|
|
1555
|
-
display: "-webkit-box",
|
|
1556
|
-
WebkitLineClamp: 2,
|
|
1557
|
-
WebkitBoxOrient: "vertical"
|
|
1558
|
-
},
|
|
1559
|
-
children: cleanMessage
|
|
1560
|
-
}
|
|
1561
|
-
),
|
|
1562
|
-
actions && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1563
|
-
"div",
|
|
1564
|
-
{
|
|
1565
|
-
style: {
|
|
1566
|
-
display: "flex",
|
|
1567
|
-
gap: "8px",
|
|
1568
|
-
flexWrap: "wrap"
|
|
1569
|
-
},
|
|
1570
|
-
children: [
|
|
1571
|
-
actions.secondary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1572
|
-
"button",
|
|
1573
|
-
{
|
|
1574
|
-
onClick: actions.secondary.onClick,
|
|
1575
|
-
style: {
|
|
1576
|
-
borderRadius: "8px",
|
|
1577
|
-
padding: "6px 12px",
|
|
1578
|
-
fontSize: "13px",
|
|
1579
|
-
fontWeight: 500,
|
|
1580
|
-
color: themeConfig.text,
|
|
1581
|
-
backgroundColor: "rgba(255, 255, 255, 0.9)",
|
|
1582
|
-
border: `1px solid ${themeConfig.border}`,
|
|
1583
|
-
cursor: "pointer",
|
|
1584
|
-
transition: "all 0.2s ease",
|
|
1585
|
-
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
1586
|
-
},
|
|
1587
|
-
onMouseOver: (e) => {
|
|
1588
|
-
e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 1)";
|
|
1589
|
-
e.currentTarget.style.transform = "translateY(-1px)";
|
|
1590
|
-
},
|
|
1591
|
-
onMouseOut: (e) => {
|
|
1592
|
-
e.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.9)";
|
|
1593
|
-
e.currentTarget.style.transform = "translateY(0)";
|
|
1594
|
-
},
|
|
1595
|
-
children: actions.secondary.label
|
|
1596
|
-
}
|
|
1597
|
-
),
|
|
1598
|
-
actions.primary && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1599
|
-
"button",
|
|
1600
|
-
{
|
|
1601
|
-
onClick: actions.primary.onClick,
|
|
1602
|
-
style: {
|
|
1603
|
-
borderRadius: "8px",
|
|
1604
|
-
padding: "6px 12px",
|
|
1605
|
-
fontSize: "13px",
|
|
1606
|
-
fontWeight: 600,
|
|
1607
|
-
color: "#fff",
|
|
1608
|
-
backgroundColor: themeConfig.primaryBtn,
|
|
1609
|
-
border: "none",
|
|
1610
|
-
cursor: "pointer",
|
|
1611
|
-
transition: "all 0.2s ease",
|
|
1612
|
-
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
|
|
1613
|
-
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
|
|
1614
|
-
},
|
|
1615
|
-
onMouseOver: (e) => {
|
|
1616
|
-
e.currentTarget.style.backgroundColor = themeConfig.primaryBtnHover;
|
|
1617
|
-
e.currentTarget.style.transform = "translateY(-1px)";
|
|
1618
|
-
e.currentTarget.style.boxShadow = "0 4px 12px rgba(0, 0, 0, 0.2)";
|
|
1619
|
-
},
|
|
1620
|
-
onMouseOut: (e) => {
|
|
1621
|
-
e.currentTarget.style.backgroundColor = themeConfig.primaryBtn;
|
|
1622
|
-
e.currentTarget.style.transform = "translateY(0)";
|
|
1623
|
-
e.currentTarget.style.boxShadow = "0 2px 8px rgba(0, 0, 0, 0.15)";
|
|
1624
|
-
},
|
|
1625
|
-
children: actions.primary.label
|
|
1626
|
-
}
|
|
1627
|
-
)
|
|
1628
|
-
]
|
|
1629
|
-
}
|
|
1630
|
-
)
|
|
1631
|
-
]
|
|
1632
|
-
}
|
|
1633
|
-
)
|
|
1634
|
-
]
|
|
1635
|
-
}
|
|
1636
|
-
);
|
|
1637
|
-
}
|
|
1638
|
-
function renderCopilotKitUsage(error, onClose) {
|
|
1639
|
-
if (error.visibility !== import_shared9.ErrorVisibility.BANNER) {
|
|
1640
|
-
return null;
|
|
1641
|
-
}
|
|
1642
|
-
const extractUrlFromMessage = (message) => {
|
|
1643
|
-
const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
1644
|
-
const match = linkRegex.exec(message);
|
|
1645
|
-
return match ? match[2] : null;
|
|
1646
|
-
};
|
|
1647
|
-
const getErrorActions = (error2) => {
|
|
1648
|
-
switch (error2.name) {
|
|
1649
|
-
case import_shared9.ERROR_NAMES.MISSING_PUBLIC_API_KEY_ERROR:
|
|
1650
|
-
return {
|
|
1651
|
-
primary: {
|
|
1652
|
-
label: "Sign In",
|
|
1653
|
-
onClick: () => window.location.href = "https://cloud.copilotkit.ai"
|
|
1654
|
-
}
|
|
1655
|
-
};
|
|
1656
|
-
case import_shared9.ERROR_NAMES.UPGRADE_REQUIRED_ERROR:
|
|
1657
|
-
return {
|
|
1658
|
-
primary: {
|
|
1659
|
-
label: "Upgrade",
|
|
1660
|
-
onClick: () => window.location.href = "https://copilotkit.ai/"
|
|
1661
|
-
}
|
|
1662
|
-
};
|
|
1663
|
-
case import_shared9.ERROR_NAMES.COPILOT_API_DISCOVERY_ERROR:
|
|
1664
|
-
case import_shared9.ERROR_NAMES.COPILOT_REMOTE_ENDPOINT_DISCOVERY_ERROR:
|
|
1665
|
-
case import_shared9.ERROR_NAMES.COPILOT_KIT_AGENT_DISCOVERY_ERROR:
|
|
1666
|
-
return {
|
|
1667
|
-
primary: {
|
|
1668
|
-
label: "View Docs",
|
|
1669
|
-
onClick: () => {
|
|
1670
|
-
var _a;
|
|
1671
|
-
const urlFromMessage = extractUrlFromMessage(error2.message);
|
|
1672
|
-
const urlFromExtensions = (_a = error2.extensions) == null ? void 0 : _a.troubleshootingUrl;
|
|
1673
|
-
const url = urlFromMessage || urlFromExtensions || "https://docs.copilotkit.ai/troubleshooting/common-issues";
|
|
1674
|
-
window.open(url, "_blank");
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
};
|
|
1678
|
-
default:
|
|
1679
|
-
return void 0;
|
|
1680
|
-
}
|
|
1681
|
-
};
|
|
1682
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1683
|
-
UsageBanner,
|
|
1684
|
-
{
|
|
1685
|
-
severity: error.severity || import_shared9.Severity.CRITICAL,
|
|
1686
|
-
message: error.message,
|
|
1687
|
-
onClose,
|
|
1688
|
-
actions: getErrorActions(error)
|
|
1689
|
-
}
|
|
1690
|
-
);
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
1560
|
// src/components/error-boundary/error-utils.tsx
|
|
1694
1561
|
var import_react8 = require("react");
|
|
1695
1562
|
|
|
@@ -1838,22 +1705,17 @@ var CopilotErrorBoundary = class extends import_react9.default.Component {
|
|
|
1838
1705
|
console.error("CopilotKit Error:", error, errorInfo);
|
|
1839
1706
|
}
|
|
1840
1707
|
render() {
|
|
1841
|
-
var _a, _b;
|
|
1708
|
+
var _a, _b, _c, _d;
|
|
1842
1709
|
if (this.state.hasError) {
|
|
1843
1710
|
if (this.state.error instanceof import_shared10.CopilotKitError) {
|
|
1844
|
-
if (this.state.error.visibility === import_shared10.ErrorVisibility.BANNER) {
|
|
1845
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ErrorToast2, { error: this.state.error, children: renderCopilotKitUsage(
|
|
1846
|
-
this.state.error,
|
|
1847
|
-
() => this.setState({ hasError: false, error: void 0 })
|
|
1848
|
-
) });
|
|
1849
|
-
}
|
|
1850
1711
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1851
1712
|
this.props.children,
|
|
1852
1713
|
this.props.showUsageBanner && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1853
1714
|
UsageBanner,
|
|
1854
1715
|
{
|
|
1855
|
-
severity: (_a = this.state.status) == null ? void 0 : _a.severity,
|
|
1856
|
-
message: (
|
|
1716
|
+
severity: (_b = (_a = this.state.status) == null ? void 0 : _a.severity) != null ? _b : this.state.error.severity,
|
|
1717
|
+
message: (_d = (_c = this.state.status) == null ? void 0 : _c.message) != null ? _d : this.state.error.message,
|
|
1718
|
+
actions: getErrorActions(this.state.error)
|
|
1857
1719
|
}
|
|
1858
1720
|
)
|
|
1859
1721
|
] });
|
|
@@ -1863,29 +1725,15 @@ var CopilotErrorBoundary = class extends import_react9.default.Component {
|
|
|
1863
1725
|
return this.props.children;
|
|
1864
1726
|
}
|
|
1865
1727
|
};
|
|
1866
|
-
function ErrorToast2({ error, children }) {
|
|
1867
|
-
const addErrorToast = useErrorToast();
|
|
1868
|
-
(0, import_react9.useEffect)(() => {
|
|
1869
|
-
if (error) {
|
|
1870
|
-
addErrorToast([error]);
|
|
1871
|
-
}
|
|
1872
|
-
}, [error, addErrorToast]);
|
|
1873
|
-
if (!error)
|
|
1874
|
-
throw error;
|
|
1875
|
-
return children;
|
|
1876
|
-
}
|
|
1877
1728
|
|
|
1878
1729
|
// src/components/copilot-provider/copilotkit.tsx
|
|
1879
1730
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1880
1731
|
function CopilotKit(_a) {
|
|
1881
1732
|
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
1882
|
-
|
|
1883
|
-
const showDevConsole = (_a2 = props.showDevConsole) != null ? _a2 : false;
|
|
1884
|
-
const enabled = shouldShowDevConsole(showDevConsole);
|
|
1733
|
+
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
1885
1734
|
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 })) }) });
|
|
1886
1735
|
}
|
|
1887
1736
|
function CopilotKitInternal(cpkProps) {
|
|
1888
|
-
var _b, _c;
|
|
1889
1737
|
const _a = cpkProps, { children } = _a, props = __objRest(_a, ["children"]);
|
|
1890
1738
|
validateProps(cpkProps);
|
|
1891
1739
|
const chatApiEndpoint = props.runtimeUrl || import_shared11.COPILOT_CLOUD_CHAT_URL;
|
|
@@ -1989,7 +1837,7 @@ ${nonDocumentStrings}`;
|
|
|
1989
1837
|
[removeDocument]
|
|
1990
1838
|
);
|
|
1991
1839
|
const copilotApiConfig = (0, import_react10.useMemo)(() => {
|
|
1992
|
-
var _a2,
|
|
1840
|
+
var _a2, _b;
|
|
1993
1841
|
let cloud = void 0;
|
|
1994
1842
|
if (props.publicApiKey) {
|
|
1995
1843
|
cloud = {
|
|
@@ -1998,7 +1846,7 @@ ${nonDocumentStrings}`;
|
|
|
1998
1846
|
restrictToTopic: {
|
|
1999
1847
|
enabled: Boolean(props.guardrails_c),
|
|
2000
1848
|
validTopics: ((_a2 = props.guardrails_c) == null ? void 0 : _a2.validTopics) || [],
|
|
2001
|
-
invalidTopics: ((
|
|
1849
|
+
invalidTopics: ((_b = props.guardrails_c) == null ? void 0 : _b.invalidTopics) || []
|
|
2002
1850
|
}
|
|
2003
1851
|
}
|
|
2004
1852
|
}
|
|
@@ -2043,7 +1891,7 @@ ${nonDocumentStrings}`;
|
|
|
2043
1891
|
publicApiKey: copilotApiConfig.publicApiKey,
|
|
2044
1892
|
headers,
|
|
2045
1893
|
credentials: copilotApiConfig.credentials,
|
|
2046
|
-
showDevConsole: (
|
|
1894
|
+
showDevConsole: shouldShowDevConsole(props.showDevConsole),
|
|
2047
1895
|
onError: props.onError
|
|
2048
1896
|
});
|
|
2049
1897
|
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = (0, import_react10.useState)({});
|
|
@@ -2122,7 +1970,7 @@ ${nonDocumentStrings}`;
|
|
|
2122
1970
|
}, [props.threadId]);
|
|
2123
1971
|
const [runId, setRunId] = (0, import_react10.useState)(null);
|
|
2124
1972
|
const chatAbortControllerRef = (0, import_react10.useRef)(null);
|
|
2125
|
-
const showDevConsole = (
|
|
1973
|
+
const showDevConsole = shouldShowDevConsole(props.showDevConsole);
|
|
2126
1974
|
const [langGraphInterruptAction, _setLangGraphInterruptAction] = (0, import_react10.useState)(null);
|
|
2127
1975
|
const setLangGraphInterruptAction = (0, import_react10.useCallback)((action) => {
|
|
2128
1976
|
_setLangGraphInterruptAction((prev) => {
|
|
@@ -2141,6 +1989,7 @@ ${nonDocumentStrings}`;
|
|
|
2141
1989
|
setLangGraphInterruptAction(null);
|
|
2142
1990
|
}, []);
|
|
2143
1991
|
const memoizedChildren = (0, import_react10.useMemo)(() => children, [children]);
|
|
1992
|
+
const [bannerError, setBannerError] = (0, import_react10.useState)(null);
|
|
2144
1993
|
const [suggestions, setSuggestions] = (0, import_react10.useState)([]);
|
|
2145
1994
|
const agentLock = (0, import_react10.useMemo)(() => {
|
|
2146
1995
|
var _a2;
|
|
@@ -2177,7 +2026,7 @@ ${nonDocumentStrings}`;
|
|
|
2177
2026
|
},
|
|
2178
2027
|
[setAuthStates]
|
|
2179
2028
|
);
|
|
2180
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.
|
|
2029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2181
2030
|
CopilotContext.Provider,
|
|
2182
2031
|
{
|
|
2183
2032
|
value: {
|
|
@@ -2232,9 +2081,22 @@ ${nonDocumentStrings}`;
|
|
|
2232
2081
|
removeLangGraphInterruptAction,
|
|
2233
2082
|
onError: props.onError,
|
|
2234
2083
|
suggestions,
|
|
2235
|
-
setSuggestions
|
|
2084
|
+
setSuggestions,
|
|
2085
|
+
bannerError,
|
|
2086
|
+
setBannerError
|
|
2236
2087
|
},
|
|
2237
|
-
children:
|
|
2088
|
+
children: [
|
|
2089
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CopilotMessages, { children: memoizedChildren }),
|
|
2090
|
+
bannerError && showDevConsole && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2091
|
+
UsageBanner,
|
|
2092
|
+
{
|
|
2093
|
+
severity: bannerError.severity,
|
|
2094
|
+
message: bannerError.message,
|
|
2095
|
+
onClose: () => setBannerError(null),
|
|
2096
|
+
actions: getErrorActions(bannerError)
|
|
2097
|
+
}
|
|
2098
|
+
)
|
|
2099
|
+
]
|
|
2238
2100
|
}
|
|
2239
2101
|
);
|
|
2240
2102
|
}
|
|
@@ -2280,6 +2142,9 @@ function validateProps(props) {
|
|
|
2280
2142
|
}
|
|
2281
2143
|
|
|
2282
2144
|
// src/hooks/use-copilot-chat.ts
|
|
2145
|
+
var import_react14 = require("react");
|
|
2146
|
+
|
|
2147
|
+
// src/hooks/use-copilot-chat_internal.ts
|
|
2283
2148
|
var import_react13 = require("react");
|
|
2284
2149
|
|
|
2285
2150
|
// src/hooks/use-chat.ts
|
|
@@ -2970,7 +2835,7 @@ function getPairedFeAction(actions, message) {
|
|
|
2970
2835
|
);
|
|
2971
2836
|
}
|
|
2972
2837
|
|
|
2973
|
-
// src/hooks/use-copilot-
|
|
2838
|
+
// src/hooks/use-copilot-chat_internal.ts
|
|
2974
2839
|
var import_runtime_client_gql8 = require("@copilotkit/runtime-client-gql");
|
|
2975
2840
|
|
|
2976
2841
|
// src/hooks/use-langgraph-interrupt-render.ts
|
|
@@ -3012,7 +2877,7 @@ function useLangGraphInterruptRender() {
|
|
|
3012
2877
|
});
|
|
3013
2878
|
}
|
|
3014
2879
|
|
|
3015
|
-
// src/hooks/use-copilot-
|
|
2880
|
+
// src/hooks/use-copilot-chat_internal.ts
|
|
3016
2881
|
var globalSuggestionPromise = null;
|
|
3017
2882
|
function useCopilotChat(options = {}) {
|
|
3018
2883
|
var _a;
|
|
@@ -3295,14 +3160,82 @@ In case of a function error:
|
|
|
3295
3160
|
${additionalInstructions}` : "");
|
|
3296
3161
|
}
|
|
3297
3162
|
|
|
3298
|
-
// src/hooks/use-copilot-
|
|
3163
|
+
// src/hooks/use-copilot-chat.ts
|
|
3299
3164
|
var import_shared14 = require("@copilotkit/shared");
|
|
3300
|
-
var
|
|
3165
|
+
var createNonFunctionalReturn = () => ({
|
|
3166
|
+
visibleMessages: [],
|
|
3167
|
+
appendMessage: () => __async(void 0, null, function* () {
|
|
3168
|
+
}),
|
|
3169
|
+
setMessages: () => {
|
|
3170
|
+
},
|
|
3171
|
+
deleteMessage: () => {
|
|
3172
|
+
},
|
|
3173
|
+
reloadMessages: () => __async(void 0, null, function* () {
|
|
3174
|
+
}),
|
|
3175
|
+
stopGeneration: () => {
|
|
3176
|
+
},
|
|
3177
|
+
reset: () => {
|
|
3178
|
+
},
|
|
3179
|
+
isLoading: false,
|
|
3180
|
+
runChatCompletion: () => __async(void 0, null, function* () {
|
|
3181
|
+
return [];
|
|
3182
|
+
}),
|
|
3183
|
+
mcpServers: [],
|
|
3184
|
+
setMcpServers: () => {
|
|
3185
|
+
},
|
|
3186
|
+
suggestions: [],
|
|
3187
|
+
setSuggestions: () => {
|
|
3188
|
+
},
|
|
3189
|
+
generateSuggestions: () => __async(void 0, null, function* () {
|
|
3190
|
+
}),
|
|
3191
|
+
resetSuggestions: () => {
|
|
3192
|
+
},
|
|
3193
|
+
isLoadingSuggestions: false,
|
|
3194
|
+
interrupt: null
|
|
3195
|
+
});
|
|
3196
|
+
function useCopilotChat2(options = {}) {
|
|
3197
|
+
const { copilotApiConfig, setBannerError } = useCopilotContext();
|
|
3198
|
+
const hasPublicApiKey = Boolean(copilotApiConfig.publicApiKey);
|
|
3199
|
+
const internalResult = useCopilotChat(options);
|
|
3200
|
+
(0, import_react14.useEffect)(() => {
|
|
3201
|
+
if (!hasPublicApiKey) {
|
|
3202
|
+
setBannerError(
|
|
3203
|
+
new import_shared14.CopilotKitError({
|
|
3204
|
+
message: "As of v1.10.0, useCopilotChat requires a publicApiKey to function.",
|
|
3205
|
+
code: import_shared14.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
|
|
3206
|
+
severity: import_shared14.Severity.CRITICAL,
|
|
3207
|
+
visibility: import_shared14.ErrorVisibility.BANNER
|
|
3208
|
+
})
|
|
3209
|
+
);
|
|
3210
|
+
import_shared14.styledConsole.logCopilotKitPlatformMessage();
|
|
3211
|
+
} else {
|
|
3212
|
+
setBannerError(null);
|
|
3213
|
+
}
|
|
3214
|
+
}, [hasPublicApiKey]);
|
|
3215
|
+
if (hasPublicApiKey) {
|
|
3216
|
+
return internalResult;
|
|
3217
|
+
}
|
|
3218
|
+
return createNonFunctionalReturn();
|
|
3219
|
+
}
|
|
3220
|
+
|
|
3221
|
+
// src/hooks/use-copilot-chat-light.ts
|
|
3222
|
+
function useCopilotChatLight(options = {}) {
|
|
3223
|
+
const { appendMessage, setSuggestions, generateSuggestions } = useCopilotChat(options);
|
|
3224
|
+
return {
|
|
3225
|
+
appendMessage,
|
|
3226
|
+
setSuggestions,
|
|
3227
|
+
generateSuggestions
|
|
3228
|
+
};
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
// src/hooks/use-copilot-action.ts
|
|
3232
|
+
var import_shared15 = require("@copilotkit/shared");
|
|
3233
|
+
var import_react15 = require("react");
|
|
3301
3234
|
function useCopilotAction(action, dependencies) {
|
|
3302
3235
|
const { setAction, removeAction, actions, chatComponentsCache } = useCopilotContext();
|
|
3303
|
-
const idRef = (0,
|
|
3304
|
-
const renderAndWaitRef = (0,
|
|
3305
|
-
const activatingMessageIdRef = (0,
|
|
3236
|
+
const idRef = (0, import_react15.useRef)((0, import_shared15.randomId)());
|
|
3237
|
+
const renderAndWaitRef = (0, import_react15.useRef)(null);
|
|
3238
|
+
const activatingMessageIdRef = (0, import_react15.useRef)(null);
|
|
3306
3239
|
const { addToast } = useToast();
|
|
3307
3240
|
action = __spreadValues({}, action);
|
|
3308
3241
|
if (
|
|
@@ -3364,7 +3297,7 @@ function useCopilotAction(action, dependencies) {
|
|
|
3364
3297
|
return renderAndWait(waitProps);
|
|
3365
3298
|
}
|
|
3366
3299
|
}
|
|
3367
|
-
return (0,
|
|
3300
|
+
return (0, import_react15.createElement)(import_react15.Fragment);
|
|
3368
3301
|
};
|
|
3369
3302
|
}
|
|
3370
3303
|
if (dependencies === void 0) {
|
|
@@ -3379,7 +3312,7 @@ function useCopilotAction(action, dependencies) {
|
|
|
3379
3312
|
}
|
|
3380
3313
|
}
|
|
3381
3314
|
}
|
|
3382
|
-
(0,
|
|
3315
|
+
(0, import_react15.useEffect)(() => {
|
|
3383
3316
|
const hasDuplicate = Object.values(actions).some(
|
|
3384
3317
|
(otherAction) => otherAction.name === action.name && otherAction !== actions[idRef.current]
|
|
3385
3318
|
);
|
|
@@ -3391,7 +3324,7 @@ function useCopilotAction(action, dependencies) {
|
|
|
3391
3324
|
});
|
|
3392
3325
|
}
|
|
3393
3326
|
}, [actions]);
|
|
3394
|
-
(0,
|
|
3327
|
+
(0, import_react15.useEffect)(() => {
|
|
3395
3328
|
setAction(idRef.current, action);
|
|
3396
3329
|
if (chatComponentsCache.current !== null && action.render !== void 0) {
|
|
3397
3330
|
chatComponentsCache.current.actions[action.name] = action.render;
|
|
@@ -3420,8 +3353,8 @@ function isFrontendAction(action) {
|
|
|
3420
3353
|
}
|
|
3421
3354
|
|
|
3422
3355
|
// src/hooks/use-coagent-state-render.ts
|
|
3423
|
-
var
|
|
3424
|
-
var
|
|
3356
|
+
var import_react16 = require("react");
|
|
3357
|
+
var import_shared16 = require("@copilotkit/shared");
|
|
3425
3358
|
function useCoAgentStateRender(action, dependencies) {
|
|
3426
3359
|
const {
|
|
3427
3360
|
setCoAgentStateRender,
|
|
@@ -3429,13 +3362,13 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
3429
3362
|
coAgentStateRenders,
|
|
3430
3363
|
chatComponentsCache,
|
|
3431
3364
|
availableAgents
|
|
3432
|
-
} = (0,
|
|
3433
|
-
const idRef = (0,
|
|
3365
|
+
} = (0, import_react16.useContext)(CopilotContext);
|
|
3366
|
+
const idRef = (0, import_react16.useRef)((0, import_shared16.randomId)());
|
|
3434
3367
|
const { setBannerError, addToast } = useToast();
|
|
3435
|
-
(0,
|
|
3368
|
+
(0, import_react16.useEffect)(() => {
|
|
3436
3369
|
if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === action.name)) {
|
|
3437
3370
|
const message = `(useCoAgentStateRender): Agent "${action.name}" not found. Make sure the agent exists and is properly configured.`;
|
|
3438
|
-
const agentError = new
|
|
3371
|
+
const agentError = new import_shared16.CopilotKitAgentDiscoveryError({
|
|
3439
3372
|
agentName: action.name,
|
|
3440
3373
|
availableAgents: availableAgents.map((a) => ({ name: a.name, id: a.id }))
|
|
3441
3374
|
});
|
|
@@ -3453,7 +3386,7 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
3453
3386
|
}
|
|
3454
3387
|
}
|
|
3455
3388
|
}
|
|
3456
|
-
(0,
|
|
3389
|
+
(0, import_react16.useEffect)(() => {
|
|
3457
3390
|
const currentId = idRef.current;
|
|
3458
3391
|
const hasDuplicate = Object.entries(coAgentStateRenders).some(([id, otherAction]) => {
|
|
3459
3392
|
if (id === currentId)
|
|
@@ -3477,7 +3410,7 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
3477
3410
|
});
|
|
3478
3411
|
}
|
|
3479
3412
|
}, [coAgentStateRenders]);
|
|
3480
|
-
(0,
|
|
3413
|
+
(0, import_react16.useEffect)(() => {
|
|
3481
3414
|
setCoAgentStateRender(idRef.current, action);
|
|
3482
3415
|
if (chatComponentsCache.current !== null && action.render !== void 0) {
|
|
3483
3416
|
chatComponentsCache.current.coAgentStateRenders[key] = action.render;
|
|
@@ -3497,11 +3430,11 @@ function useCoAgentStateRender(action, dependencies) {
|
|
|
3497
3430
|
}
|
|
3498
3431
|
|
|
3499
3432
|
// src/hooks/use-make-copilot-document-readable.ts
|
|
3500
|
-
var
|
|
3433
|
+
var import_react17 = require("react");
|
|
3501
3434
|
function useMakeCopilotDocumentReadable(document, categories, dependencies = []) {
|
|
3502
3435
|
const { addDocumentContext, removeDocumentContext } = useCopilotContext();
|
|
3503
|
-
const idRef = (0,
|
|
3504
|
-
(0,
|
|
3436
|
+
const idRef = (0, import_react17.useRef)();
|
|
3437
|
+
(0, import_react17.useEffect)(() => {
|
|
3505
3438
|
const id = addDocumentContext(document, categories);
|
|
3506
3439
|
idRef.current = id;
|
|
3507
3440
|
return () => {
|
|
@@ -3512,7 +3445,7 @@ function useMakeCopilotDocumentReadable(document, categories, dependencies = [])
|
|
|
3512
3445
|
}
|
|
3513
3446
|
|
|
3514
3447
|
// src/hooks/use-copilot-readable.ts
|
|
3515
|
-
var
|
|
3448
|
+
var import_react18 = require("react");
|
|
3516
3449
|
function convertToJSON(description, value) {
|
|
3517
3450
|
return `${description}: ${typeof value === "string" ? value : JSON.stringify(value)}`;
|
|
3518
3451
|
}
|
|
@@ -3525,10 +3458,10 @@ function useCopilotReadable({
|
|
|
3525
3458
|
available = "enabled"
|
|
3526
3459
|
}, dependencies) {
|
|
3527
3460
|
const { addContext, removeContext } = useCopilotContext();
|
|
3528
|
-
const idRef = (0,
|
|
3461
|
+
const idRef = (0, import_react18.useRef)();
|
|
3529
3462
|
convert = convert || convertToJSON;
|
|
3530
3463
|
const information = convert(description, value);
|
|
3531
|
-
(0,
|
|
3464
|
+
(0, import_react18.useEffect)(() => {
|
|
3532
3465
|
if (available === "disabled")
|
|
3533
3466
|
return;
|
|
3534
3467
|
const id = addContext(information, parentId, categories);
|
|
@@ -3541,20 +3474,20 @@ function useCopilotReadable({
|
|
|
3541
3474
|
}
|
|
3542
3475
|
|
|
3543
3476
|
// src/hooks/use-coagent.ts
|
|
3544
|
-
var
|
|
3545
|
-
var
|
|
3477
|
+
var import_react19 = require("react");
|
|
3478
|
+
var import_shared17 = require("@copilotkit/shared");
|
|
3546
3479
|
function useCoAgent(options) {
|
|
3547
3480
|
const generalContext = useCopilotContext();
|
|
3548
3481
|
const { availableAgents } = generalContext;
|
|
3549
3482
|
const { setBannerError } = useToast();
|
|
3550
|
-
const lastLoadedThreadId = (0,
|
|
3551
|
-
const lastLoadedState = (0,
|
|
3483
|
+
const lastLoadedThreadId = (0, import_react19.useRef)();
|
|
3484
|
+
const lastLoadedState = (0, import_react19.useRef)();
|
|
3552
3485
|
const { name } = options;
|
|
3553
|
-
(0,
|
|
3486
|
+
(0, import_react19.useEffect)(() => {
|
|
3554
3487
|
if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === name)) {
|
|
3555
3488
|
const message = `(useCoAgent): Agent "${name}" not found. Make sure the agent exists and is properly configured.`;
|
|
3556
3489
|
console.warn(message);
|
|
3557
|
-
const agentError = new
|
|
3490
|
+
const agentError = new import_shared17.CopilotKitAgentDiscoveryError({
|
|
3558
3491
|
agentName: name,
|
|
3559
3492
|
availableAgents: availableAgents.map((a) => ({ name: a.name, id: a.id }))
|
|
3560
3493
|
});
|
|
@@ -3573,7 +3506,7 @@ function useCoAgent(options) {
|
|
|
3573
3506
|
credentials: copilotApiConfig.credentials,
|
|
3574
3507
|
showDevConsole: context.showDevConsole
|
|
3575
3508
|
});
|
|
3576
|
-
const setState = (0,
|
|
3509
|
+
const setState = (0, import_react19.useCallback)(
|
|
3577
3510
|
(newState) => {
|
|
3578
3511
|
let coagentState = getCoagentState({ coagentStates, name, options });
|
|
3579
3512
|
const updatedState = typeof newState === "function" ? newState(coagentState.state) : newState;
|
|
@@ -3585,7 +3518,7 @@ function useCoAgent(options) {
|
|
|
3585
3518
|
},
|
|
3586
3519
|
[coagentStates, name]
|
|
3587
3520
|
);
|
|
3588
|
-
(0,
|
|
3521
|
+
(0, import_react19.useEffect)(() => {
|
|
3589
3522
|
const fetchAgentState = () => __async(this, null, function* () {
|
|
3590
3523
|
var _a, _b, _c, _d;
|
|
3591
3524
|
if (!threadId || threadId === lastLoadedThreadId.current)
|
|
@@ -3603,13 +3536,13 @@ function useCoAgent(options) {
|
|
|
3603
3536
|
if (((_d = (_c = result.data) == null ? void 0 : _c.loadAgentState) == null ? void 0 : _d.threadExists) && newState && newState != "{}") {
|
|
3604
3537
|
lastLoadedState.current = newState;
|
|
3605
3538
|
lastLoadedThreadId.current = threadId;
|
|
3606
|
-
const fetchedState = (0,
|
|
3539
|
+
const fetchedState = (0, import_shared17.parseJson)(newState, {});
|
|
3607
3540
|
isExternalStateManagement(options) ? options.setState(fetchedState) : setState(fetchedState);
|
|
3608
3541
|
}
|
|
3609
3542
|
});
|
|
3610
3543
|
void fetchAgentState();
|
|
3611
3544
|
}, [threadId]);
|
|
3612
|
-
(0,
|
|
3545
|
+
(0, import_react19.useEffect)(() => {
|
|
3613
3546
|
if (isExternalStateManagement(options)) {
|
|
3614
3547
|
setState(options.state);
|
|
3615
3548
|
} else if (coagentStates[name] === void 0) {
|
|
@@ -3620,7 +3553,7 @@ function useCoAgent(options) {
|
|
|
3620
3553
|
// reset initialstate on reset
|
|
3621
3554
|
coagentStates[name] === void 0
|
|
3622
3555
|
]);
|
|
3623
|
-
(0,
|
|
3556
|
+
(0, import_react19.useEffect)(() => {
|
|
3624
3557
|
const newConfig = options.config ? options.config : options.configurable ? { configurable: options.configurable } : void 0;
|
|
3625
3558
|
if (newConfig === void 0)
|
|
3626
3559
|
return;
|
|
@@ -3652,7 +3585,7 @@ function useCoAgent(options) {
|
|
|
3652
3585
|
}),
|
|
3653
3586
|
[name, context, appendMessage, runChatCompletion]
|
|
3654
3587
|
);
|
|
3655
|
-
return (0,
|
|
3588
|
+
return (0, import_react19.useMemo)(() => {
|
|
3656
3589
|
const coagentState = getCoagentState({ coagentStates, name, options });
|
|
3657
3590
|
return {
|
|
3658
3591
|
name,
|
|
@@ -3749,28 +3682,28 @@ var getCoagentState = ({
|
|
|
3749
3682
|
};
|
|
3750
3683
|
|
|
3751
3684
|
// src/hooks/use-copilot-authenticated-action.ts
|
|
3752
|
-
var
|
|
3753
|
-
var
|
|
3685
|
+
var import_react20 = require("react");
|
|
3686
|
+
var import_react21 = __toESM(require("react"));
|
|
3754
3687
|
function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
3755
3688
|
const { authConfig_c, authStates_c, setAuthStates_c } = useCopilotContext();
|
|
3756
|
-
const pendingActionRef = (0,
|
|
3757
|
-
const executeAction2 = (0,
|
|
3689
|
+
const pendingActionRef = (0, import_react20.useRef)(null);
|
|
3690
|
+
const executeAction2 = (0, import_react20.useCallback)(
|
|
3758
3691
|
(props) => {
|
|
3759
3692
|
if (typeof action.render === "function") {
|
|
3760
3693
|
return action.render(props);
|
|
3761
3694
|
}
|
|
3762
|
-
return action.render ||
|
|
3695
|
+
return action.render || import_react21.default.createElement(import_react20.Fragment);
|
|
3763
3696
|
},
|
|
3764
3697
|
[action]
|
|
3765
3698
|
);
|
|
3766
|
-
const wrappedRender = (0,
|
|
3699
|
+
const wrappedRender = (0, import_react20.useCallback)(
|
|
3767
3700
|
(props) => {
|
|
3768
3701
|
const isAuthenticated = Object.values(authStates_c || {}).some(
|
|
3769
3702
|
(state) => state.status === "authenticated"
|
|
3770
3703
|
);
|
|
3771
3704
|
if (!isAuthenticated) {
|
|
3772
3705
|
pendingActionRef.current = props;
|
|
3773
|
-
return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ?
|
|
3706
|
+
return (authConfig_c == null ? void 0 : authConfig_c.SignInComponent) ? import_react21.default.createElement(authConfig_c.SignInComponent, {
|
|
3774
3707
|
onSignInComplete: (authState) => {
|
|
3775
3708
|
setAuthStates_c == null ? void 0 : setAuthStates_c((prev) => __spreadProps(__spreadValues({}, prev), { [action.name]: authState }));
|
|
3776
3709
|
if (pendingActionRef.current) {
|
|
@@ -3778,7 +3711,7 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
3778
3711
|
pendingActionRef.current = null;
|
|
3779
3712
|
}
|
|
3780
3713
|
}
|
|
3781
|
-
}) :
|
|
3714
|
+
}) : import_react21.default.createElement(import_react20.Fragment);
|
|
3782
3715
|
}
|
|
3783
3716
|
return executeAction2(props);
|
|
3784
3717
|
},
|
|
@@ -3793,29 +3726,29 @@ function useCopilotAuthenticatedAction_c(action, dependencies) {
|
|
|
3793
3726
|
}
|
|
3794
3727
|
|
|
3795
3728
|
// src/hooks/use-langgraph-interrupt.ts
|
|
3796
|
-
var
|
|
3797
|
-
var
|
|
3729
|
+
var import_react22 = require("react");
|
|
3730
|
+
var import_shared18 = require("@copilotkit/shared");
|
|
3798
3731
|
function useLangGraphInterrupt(action, dependencies) {
|
|
3799
3732
|
var _a;
|
|
3800
|
-
const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } = (0,
|
|
3733
|
+
const { setLangGraphInterruptAction, removeLangGraphInterruptAction, langGraphInterruptAction } = (0, import_react22.useContext)(CopilotContext);
|
|
3801
3734
|
const { runChatCompletion } = useCopilotChat();
|
|
3802
3735
|
const { addToast } = useToast();
|
|
3803
|
-
const actionId = (0,
|
|
3804
|
-
const hasAction = (0,
|
|
3736
|
+
const actionId = (0, import_shared18.dataToUUID)(JSON.stringify(action), "lgAction");
|
|
3737
|
+
const hasAction = (0, import_react22.useMemo)(
|
|
3805
3738
|
() => Boolean(langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id),
|
|
3806
3739
|
[langGraphInterruptAction]
|
|
3807
3740
|
);
|
|
3808
|
-
const isCurrentAction = (0,
|
|
3741
|
+
const isCurrentAction = (0, import_react22.useMemo)(
|
|
3809
3742
|
() => (langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id) && (langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.id) === actionId,
|
|
3810
3743
|
[langGraphInterruptAction]
|
|
3811
3744
|
);
|
|
3812
|
-
(0,
|
|
3745
|
+
(0, import_react22.useEffect)(() => {
|
|
3813
3746
|
var _a2;
|
|
3814
3747
|
if (hasAction && isCurrentAction && ((_a2 = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event) == null ? void 0 : _a2.response)) {
|
|
3815
3748
|
runChatCompletion();
|
|
3816
3749
|
}
|
|
3817
3750
|
}, [(_a = langGraphInterruptAction == null ? void 0 : langGraphInterruptAction.event) == null ? void 0 : _a.response, runChatCompletion, hasAction, isCurrentAction]);
|
|
3818
|
-
(0,
|
|
3751
|
+
(0, import_react22.useEffect)(() => {
|
|
3819
3752
|
if (!action)
|
|
3820
3753
|
return;
|
|
3821
3754
|
if (hasAction && !isCurrentAction && !action.enabled) {
|
|
@@ -3840,10 +3773,10 @@ function useLangGraphInterrupt(action, dependencies) {
|
|
|
3840
3773
|
}
|
|
3841
3774
|
|
|
3842
3775
|
// src/hooks/use-copilot-additional-instructions.ts
|
|
3843
|
-
var
|
|
3776
|
+
var import_react23 = require("react");
|
|
3844
3777
|
function useCopilotAdditionalInstructions({ instructions, available = "enabled" }, dependencies) {
|
|
3845
3778
|
const { setAdditionalInstructions } = useCopilotContext();
|
|
3846
|
-
(0,
|
|
3779
|
+
(0, import_react23.useEffect)(() => {
|
|
3847
3780
|
if (available === "disabled")
|
|
3848
3781
|
return;
|
|
3849
3782
|
setAdditionalInstructions((prevInstructions) => [...prevInstructions || [], instructions]);
|
|
@@ -3971,6 +3904,8 @@ ${instructions}
|
|
|
3971
3904
|
useCopilotAdditionalInstructions,
|
|
3972
3905
|
useCopilotAuthenticatedAction_c,
|
|
3973
3906
|
useCopilotChat,
|
|
3907
|
+
useCopilotChatInternal,
|
|
3908
|
+
useCopilotChatLight,
|
|
3974
3909
|
useCopilotContext,
|
|
3975
3910
|
useCopilotMessagesContext,
|
|
3976
3911
|
useCopilotReadable,
|