@copilotkit/react-core 1.51.4-next.6 → 1.51.4-next.8
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 +20 -0
- package/README.md +18 -12
- package/dist/{chunk-DQXCQWSG.mjs → chunk-2JZZD4RP.mjs} +93 -58
- package/dist/chunk-2JZZD4RP.mjs.map +1 -0
- package/dist/{chunk-6ESSSQ7Q.mjs → chunk-2RSAYTXH.mjs} +6 -3
- package/dist/chunk-2RSAYTXH.mjs.map +1 -0
- package/dist/chunk-3LZZ4RVM.mjs +37 -0
- package/dist/{chunk-ABWT4DRT.mjs.map → chunk-3LZZ4RVM.mjs.map} +1 -1
- package/dist/{chunk-QDES5PDW.mjs → chunk-4ZQYMC5F.mjs} +2 -2
- package/dist/{chunk-QDES5PDW.mjs.map → chunk-4ZQYMC5F.mjs.map} +1 -1
- package/dist/{chunk-6PUNP7CD.mjs → chunk-6AWG5FWL.mjs} +2 -2
- package/dist/chunk-6AWG5FWL.mjs.map +1 -0
- package/dist/{chunk-C3YJYDK4.mjs → chunk-7GIBHX6X.mjs} +8 -2
- package/dist/chunk-7GIBHX6X.mjs.map +1 -0
- package/dist/{chunk-PIF5KJYI.mjs → chunk-7PJKPWMD.mjs} +15 -6
- package/dist/chunk-7PJKPWMD.mjs.map +1 -0
- package/dist/{chunk-7JTI6ZL4.mjs → chunk-7U3DNFBF.mjs} +6 -3
- package/dist/chunk-7U3DNFBF.mjs.map +1 -0
- package/dist/{chunk-KNJHRVKW.mjs → chunk-AAGMWZCN.mjs} +45 -14
- package/dist/chunk-AAGMWZCN.mjs.map +1 -0
- package/dist/{chunk-AFNWX62Q.mjs → chunk-C7HSVDHD.mjs} +10 -4
- package/dist/chunk-C7HSVDHD.mjs.map +1 -0
- package/dist/{chunk-ZYTXB6HH.mjs → chunk-CZT7JUIM.mjs} +4 -2
- package/dist/chunk-CZT7JUIM.mjs.map +1 -0
- package/dist/{chunk-VP43SLSZ.mjs → chunk-DAQORGBP.mjs} +10 -5
- package/dist/chunk-DAQORGBP.mjs.map +1 -0
- package/dist/{chunk-BKMJ4LC7.mjs → chunk-G7SUZGGB.mjs} +19 -12
- package/dist/chunk-G7SUZGGB.mjs.map +1 -0
- package/dist/{chunk-7IBF6RBW.mjs → chunk-GY3FQICF.mjs} +2 -2
- package/dist/{chunk-4RRMC7L2.mjs → chunk-IGYMBU43.mjs} +18 -7
- package/dist/chunk-IGYMBU43.mjs.map +1 -0
- package/dist/{chunk-QD7EID4N.mjs → chunk-IHMMKEFG.mjs} +16 -11
- package/dist/chunk-IHMMKEFG.mjs.map +1 -0
- package/dist/{chunk-YYN33GSG.mjs → chunk-K5OXUXCG.mjs} +14 -11
- package/dist/chunk-K5OXUXCG.mjs.map +1 -0
- package/dist/{chunk-6ZLPNY7X.mjs → chunk-L7GPCF2V.mjs} +6 -2
- package/dist/{chunk-6ZLPNY7X.mjs.map → chunk-L7GPCF2V.mjs.map} +1 -1
- package/dist/{chunk-7DTB7S5V.mjs → chunk-LNGBARXE.mjs} +5 -2
- package/dist/chunk-LNGBARXE.mjs.map +1 -0
- package/dist/{chunk-NBK4KBLX.mjs → chunk-MBJ7OLYI.mjs} +9 -5
- package/dist/chunk-MBJ7OLYI.mjs.map +1 -0
- package/dist/{chunk-LHERIF3L.mjs → chunk-NINJMAND.mjs} +10 -7
- package/dist/chunk-NINJMAND.mjs.map +1 -0
- package/dist/{chunk-MA3CUMCY.mjs → chunk-P6ZPE4XJ.mjs} +3 -3
- package/dist/{chunk-MA3CUMCY.mjs.map → chunk-P6ZPE4XJ.mjs.map} +1 -1
- package/dist/{chunk-77IVITG3.mjs → chunk-QXZTCGF4.mjs} +9 -4
- package/dist/chunk-QXZTCGF4.mjs.map +1 -0
- package/dist/{chunk-RKTVJRK7.mjs → chunk-R7BV32X4.mjs} +5 -2
- package/dist/chunk-R7BV32X4.mjs.map +1 -0
- package/dist/{chunk-VKNLTZJE.mjs → chunk-S65UEHGI.mjs} +30 -21
- package/dist/chunk-S65UEHGI.mjs.map +1 -0
- package/dist/{chunk-YCG6SNAU.mjs → chunk-SBRCWA4S.mjs} +186 -32
- package/dist/chunk-SBRCWA4S.mjs.map +1 -0
- package/dist/{chunk-HE22TZMF.mjs → chunk-SFOKX4MH.mjs} +18 -9
- package/dist/chunk-SFOKX4MH.mjs.map +1 -0
- package/dist/{chunk-LMHB2D4J.mjs → chunk-SK2XMJUD.mjs} +13 -4
- package/dist/chunk-SK2XMJUD.mjs.map +1 -0
- package/dist/{chunk-XDFVCQD3.mjs → chunk-SYGQHN3H.mjs} +1 -1
- package/dist/{chunk-XDFVCQD3.mjs.map → chunk-SYGQHN3H.mjs.map} +1 -1
- package/dist/{chunk-SRJT5VVY.mjs → chunk-TFZXOEY4.mjs} +6 -4
- package/dist/{chunk-SRJT5VVY.mjs.map → chunk-TFZXOEY4.mjs.map} +1 -1
- package/dist/{chunk-4CEQJ2X6.mjs → chunk-TPN7WC53.mjs} +4 -2
- package/dist/{chunk-4CEQJ2X6.mjs.map → chunk-TPN7WC53.mjs.map} +1 -1
- package/dist/{chunk-VGL3DGUW.mjs → chunk-UA23VX5J.mjs} +4 -2
- package/dist/chunk-UA23VX5J.mjs.map +1 -0
- package/dist/{chunk-VV56AVPB.mjs → chunk-V42VL2JR.mjs} +15 -4
- package/dist/chunk-V42VL2JR.mjs.map +1 -0
- package/dist/{chunk-RBGVEVWY.mjs → chunk-VZ4NSOFQ.mjs} +4 -4
- package/dist/chunk-VZ4NSOFQ.mjs.map +1 -0
- package/dist/{chunk-WF65O6HX.mjs → chunk-WRALJIW5.mjs} +18 -5
- package/dist/chunk-WRALJIW5.mjs.map +1 -0
- package/dist/{chunk-PMAFHQ7P.mjs → chunk-WV2EA7SX.mjs} +1 -1
- package/dist/chunk-WV2EA7SX.mjs.map +1 -0
- package/dist/{chunk-EFL5OBKN.mjs → chunk-ZP2IMXFY.mjs} +10 -4
- package/dist/chunk-ZP2IMXFY.mjs.map +1 -0
- package/dist/components/CopilotListeners.js +11 -2
- package/dist/components/CopilotListeners.js.map +1 -1
- package/dist/components/CopilotListeners.mjs +2 -2
- package/dist/components/copilot-provider/copilot-messages.d.ts +1 -1
- package/dist/components/copilot-provider/copilot-messages.js +22 -7
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.js +179 -84
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +16 -16
- package/dist/components/copilot-provider/index.js +179 -84
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +16 -16
- package/dist/components/dev-console/console-trigger.d.ts +1 -1
- package/dist/components/dev-console/console-trigger.js +227 -42
- package/dist/components/dev-console/console-trigger.js.map +1 -1
- package/dist/components/dev-console/console-trigger.mjs +24 -8
- package/dist/components/dev-console/console-trigger.mjs.map +1 -1
- package/dist/components/dev-console/developer-console-modal.d.ts +1 -1
- package/dist/components/dev-console/developer-console-modal.js +206 -37
- package/dist/components/dev-console/developer-console-modal.js.map +1 -1
- package/dist/components/dev-console/developer-console-modal.mjs +3 -3
- package/dist/components/dev-console/icons.js +14 -5
- package/dist/components/dev-console/icons.js.map +1 -1
- package/dist/components/dev-console/icons.mjs +1 -1
- package/dist/components/error-boundary/error-boundary.d.ts +1 -1
- package/dist/components/error-boundary/error-boundary.js +9 -2
- package/dist/components/error-boundary/error-boundary.js.map +1 -1
- package/dist/components/error-boundary/error-boundary.mjs +5 -5
- 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.js +179 -84
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +16 -16
- package/dist/components/toast/toast-provider.js +9 -3
- package/dist/components/toast/toast-provider.js.map +1 -1
- package/dist/components/toast/toast-provider.mjs +1 -1
- package/dist/components/usage-banner.js +5 -1
- package/dist/components/usage-banner.js.map +1 -1
- package/dist/components/usage-banner.mjs +1 -1
- package/dist/context/coagent-state-renders-context.d.ts +1 -1
- package/dist/context/coagent-state-renders-context.js +15 -10
- package/dist/context/coagent-state-renders-context.js.map +1 -1
- package/dist/context/coagent-state-renders-context.mjs +1 -1
- package/dist/context/copilot-context.js +9 -3
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/index.js +31 -15
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +7 -7
- package/dist/context/threads-context.d.ts +1 -1
- package/dist/context/threads-context.js +7 -2
- package/dist/context/threads-context.js.map +1 -1
- package/dist/context/threads-context.mjs +1 -1
- package/dist/hooks/index.js +162 -61
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +26 -26
- package/dist/hooks/use-coagent-state-render-bridge.helpers.js +7 -1
- package/dist/hooks/use-coagent-state-render-bridge.helpers.js.map +1 -1
- package/dist/hooks/use-coagent-state-render-bridge.helpers.mjs +1 -1
- package/dist/hooks/use-coagent-state-render-bridge.js +31 -15
- package/dist/hooks/use-coagent-state-render-bridge.js.map +1 -1
- package/dist/hooks/use-coagent-state-render-bridge.mjs +6 -6
- package/dist/hooks/use-coagent-state-render-registry.js +14 -3
- package/dist/hooks/use-coagent-state-render-registry.js.map +1 -1
- package/dist/hooks/use-coagent-state-render-registry.mjs +2 -2
- package/dist/hooks/use-coagent-state-render.js +34 -21
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +4 -4
- package/dist/hooks/use-coagent.js +3 -1
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +1 -1
- package/dist/hooks/use-configure-chat-suggestions.js.map +1 -1
- package/dist/hooks/use-configure-chat-suggestions.mjs.map +1 -1
- package/dist/hooks/use-copilot-action.js +13 -9
- 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.d.ts +1 -1
- package/dist/hooks/use-copilot-additional-instructions.js +26 -7
- 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 +25 -13
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +6 -6
- package/dist/hooks/use-copilot-chat-headless_c.js +81 -27
- package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
- package/dist/hooks/use-copilot-chat-headless_c.mjs +12 -12
- package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -1
- package/dist/hooks/use-copilot-chat-suggestions.mjs +1 -1
- package/dist/hooks/use-copilot-chat.js +81 -27
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +12 -12
- package/dist/hooks/use-copilot-chat_internal.js +81 -27
- package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
- package/dist/hooks/use-copilot-chat_internal.mjs +11 -11
- package/dist/hooks/use-copilot-runtime-client.js +4 -1
- package/dist/hooks/use-copilot-runtime-client.js.map +1 -1
- package/dist/hooks/use-copilot-runtime-client.mjs +2 -2
- package/dist/hooks/use-default-tool.js +17 -10
- package/dist/hooks/use-default-tool.js.map +1 -1
- package/dist/hooks/use-default-tool.mjs +5 -5
- package/dist/hooks/use-flat-category-store.js +13 -10
- package/dist/hooks/use-flat-category-store.js.map +1 -1
- package/dist/hooks/use-flat-category-store.mjs +1 -1
- package/dist/hooks/use-frontend-tool.js.map +1 -1
- package/dist/hooks/use-frontend-tool.mjs +1 -1
- package/dist/hooks/use-human-in-the-loop.js.map +1 -1
- package/dist/hooks/use-human-in-the-loop.mjs +1 -1
- package/dist/hooks/use-langgraph-interrupt-render.js +22 -5
- package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt-render.mjs +4 -4
- package/dist/hooks/use-langgraph-interrupt.js +19 -4
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +3 -3
- package/dist/hooks/use-make-copilot-document-readable.js +9 -3
- 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/hooks/use-render-tool-call.d.ts +1 -1
- package/dist/hooks/use-render-tool-call.js +13 -9
- package/dist/hooks/use-render-tool-call.js.map +1 -1
- package/dist/hooks/use-render-tool-call.mjs +1 -1
- package/dist/hooks/use-tree.js +4 -1
- package/dist/hooks/use-tree.js.map +1 -1
- package/dist/hooks/use-tree.mjs +1 -1
- package/dist/index.js +311 -130
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -52
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/copilot-task.js +10 -3
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +18 -18
- package/dist/lib/index.js +10 -3
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +18 -18
- package/dist/lib/status-checker.js.map +1 -1
- package/dist/lib/status-checker.mjs +1 -1
- package/dist/types/coagent-action.js.map +1 -1
- package/dist/types/frontend-action.js +3 -1
- package/dist/types/frontend-action.js.map +1 -1
- package/dist/types/frontend-action.mjs +1 -1
- package/dist/types/interrupt-action.js.map +1 -1
- package/dist/v2/index.umd.js.map +1 -1
- package/jest.config.js +1 -0
- package/package.json +5 -6
- package/src/__mocks__/analytics-node.js +9 -0
- package/src/components/CopilotListeners.tsx +21 -5
- package/src/components/copilot-provider/__tests__/copilotkit-error.test.tsx +3 -1
- package/src/components/copilot-provider/copilot-messages.tsx +36 -11
- package/src/components/copilot-provider/copilotkit-props.tsx +4 -1
- package/src/components/copilot-provider/copilotkit.tsx +116 -50
- package/src/components/dev-console/console-trigger.tsx +39 -10
- package/src/components/dev-console/developer-console-modal.tsx +207 -57
- package/src/components/dev-console/icons.tsx +6 -1
- package/src/components/error-boundary/error-boundary.tsx +10 -2
- package/src/components/error-boundary/error-utils.tsx +8 -3
- package/src/components/toast/toast-provider.tsx +16 -6
- package/src/components/usage-banner.tsx +9 -2
- package/src/context/coagent-state-renders-context.tsx +24 -12
- package/src/context/copilot-context.tsx +48 -15
- package/src/context/index.ts +8 -2
- package/src/context/threads-context.tsx +14 -3
- package/src/hooks/__tests__/use-coagent-state-render-bridge.helpers.test.ts +11 -4
- package/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx +175 -47
- package/src/hooks/__tests__/use-coagent-state-render.test.tsx +31 -10
- package/src/hooks/__tests__/use-frontend-tool-remount.e2e.test.tsx +10 -2
- package/src/hooks/use-coagent-state-render-bridge.helpers.ts +49 -16
- package/src/hooks/use-coagent-state-render-bridge.tsx +30 -13
- package/src/hooks/use-coagent-state-render-registry.ts +36 -21
- package/src/hooks/use-coagent-state-render.ts +30 -19
- package/src/hooks/use-coagent.ts +15 -4
- package/src/hooks/use-configure-chat-suggestions.tsx +14 -4
- package/src/hooks/use-copilot-action.ts +12 -3
- package/src/hooks/use-copilot-additional-instructions.ts +17 -4
- package/src/hooks/use-copilot-authenticated-action.ts +4 -1
- package/src/hooks/use-copilot-chat-headless_c.ts +8 -2
- package/src/hooks/use-copilot-chat-suggestions.tsx +14 -4
- package/src/hooks/use-copilot-chat.ts +3 -1
- package/src/hooks/use-copilot-chat_internal.ts +72 -19
- package/src/hooks/use-copilot-runtime-client.ts +20 -6
- package/src/hooks/use-default-tool.ts +8 -2
- package/src/hooks/use-flat-category-store.ts +15 -11
- package/src/hooks/use-frontend-tool.ts +35 -25
- package/src/hooks/use-human-in-the-loop.ts +21 -5
- package/src/hooks/use-langgraph-interrupt-render.ts +13 -2
- package/src/hooks/use-langgraph-interrupt.ts +13 -3
- package/src/hooks/use-render-tool-call.ts +20 -11
- package/src/hooks/use-tree.ts +20 -5
- package/src/lib/copilot-task.ts +20 -6
- package/src/lib/status-checker.ts +4 -1
- package/src/types/coagent-action.ts +6 -2
- package/src/types/frontend-action.ts +16 -5
- package/src/types/interrupt-action.ts +15 -5
- package/tsconfig.json +1 -1
- package/dist/chunk-4RRMC7L2.mjs.map +0 -1
- package/dist/chunk-6ESSSQ7Q.mjs.map +0 -1
- package/dist/chunk-6PUNP7CD.mjs.map +0 -1
- package/dist/chunk-77IVITG3.mjs.map +0 -1
- package/dist/chunk-7DTB7S5V.mjs.map +0 -1
- package/dist/chunk-7JTI6ZL4.mjs.map +0 -1
- package/dist/chunk-ABWT4DRT.mjs +0 -24
- package/dist/chunk-AFNWX62Q.mjs.map +0 -1
- package/dist/chunk-BKMJ4LC7.mjs.map +0 -1
- package/dist/chunk-C3YJYDK4.mjs.map +0 -1
- package/dist/chunk-DQXCQWSG.mjs.map +0 -1
- package/dist/chunk-EFL5OBKN.mjs.map +0 -1
- package/dist/chunk-HE22TZMF.mjs.map +0 -1
- package/dist/chunk-KNJHRVKW.mjs.map +0 -1
- package/dist/chunk-LHERIF3L.mjs.map +0 -1
- package/dist/chunk-LMHB2D4J.mjs.map +0 -1
- package/dist/chunk-NBK4KBLX.mjs.map +0 -1
- package/dist/chunk-PIF5KJYI.mjs.map +0 -1
- package/dist/chunk-PMAFHQ7P.mjs.map +0 -1
- package/dist/chunk-QD7EID4N.mjs.map +0 -1
- package/dist/chunk-RBGVEVWY.mjs.map +0 -1
- package/dist/chunk-RKTVJRK7.mjs.map +0 -1
- package/dist/chunk-VGL3DGUW.mjs.map +0 -1
- package/dist/chunk-VKNLTZJE.mjs.map +0 -1
- package/dist/chunk-VP43SLSZ.mjs.map +0 -1
- package/dist/chunk-VV56AVPB.mjs.map +0 -1
- package/dist/chunk-WF65O6HX.mjs.map +0 -1
- package/dist/chunk-YCG6SNAU.mjs.map +0 -1
- package/dist/chunk-YYN33GSG.mjs.map +0 -1
- package/dist/chunk-ZYTXB6HH.mjs.map +0 -1
- /package/dist/{chunk-7IBF6RBW.mjs.map → chunk-GY3FQICF.mjs.map} +0 -0
|
@@ -105,7 +105,9 @@ export function ToastProvider({
|
|
|
105
105
|
children: React.ReactNode;
|
|
106
106
|
}) {
|
|
107
107
|
const [toasts, setToasts] = useState<Toast[]>([]);
|
|
108
|
-
const [bannerError, setBannerErrorState] = useState<CopilotKitError | null>(
|
|
108
|
+
const [bannerError, setBannerErrorState] = useState<CopilotKitError | null>(
|
|
109
|
+
null,
|
|
110
|
+
);
|
|
109
111
|
|
|
110
112
|
const removeToast = useCallback((id: string) => {
|
|
111
113
|
setToasts((prev) => prev.filter((toast) => toast.id !== id));
|
|
@@ -121,7 +123,8 @@ export function ToastProvider({
|
|
|
121
123
|
const id = toast.id ?? Math.random().toString(36).substring(2, 9);
|
|
122
124
|
|
|
123
125
|
setToasts((currentToasts) => {
|
|
124
|
-
if (currentToasts.find((toast) => toast.id === id))
|
|
126
|
+
if (currentToasts.find((toast) => toast.id === id))
|
|
127
|
+
return currentToasts;
|
|
125
128
|
return [...currentToasts, { ...toast, id }];
|
|
126
129
|
});
|
|
127
130
|
|
|
@@ -147,7 +150,9 @@ export function ToastProvider({
|
|
|
147
150
|
|
|
148
151
|
const addGraphQLErrorsToast = useCallback((errors: GraphQLError[]) => {
|
|
149
152
|
// DEPRECATED: All errors now route to banners for consistency
|
|
150
|
-
console.warn(
|
|
153
|
+
console.warn(
|
|
154
|
+
"addGraphQLErrorsToast is deprecated. All errors now show as banners.",
|
|
155
|
+
);
|
|
151
156
|
// Function kept for backward compatibility - does nothing
|
|
152
157
|
}, []);
|
|
153
158
|
|
|
@@ -246,7 +251,9 @@ export function ToastProvider({
|
|
|
246
251
|
let message = bannerError.message;
|
|
247
252
|
|
|
248
253
|
// Try to extract the useful message from JSON first
|
|
249
|
-
const jsonMatch = message.match(
|
|
254
|
+
const jsonMatch = message.match(
|
|
255
|
+
/'message':\s*'([^']+)'/,
|
|
256
|
+
);
|
|
250
257
|
if (jsonMatch) {
|
|
251
258
|
return jsonMatch[1]; // Return the actual error message
|
|
252
259
|
}
|
|
@@ -294,7 +301,9 @@ export function ToastProvider({
|
|
|
294
301
|
|
|
295
302
|
return (
|
|
296
303
|
<button
|
|
297
|
-
onClick={() =>
|
|
304
|
+
onClick={() =>
|
|
305
|
+
window.open(url, "_blank", "noopener,noreferrer")
|
|
306
|
+
}
|
|
298
307
|
style={{
|
|
299
308
|
background: colors.border,
|
|
300
309
|
color: "white",
|
|
@@ -309,7 +318,8 @@ export function ToastProvider({
|
|
|
309
318
|
}}
|
|
310
319
|
onMouseEnter={(e) => {
|
|
311
320
|
e.currentTarget.style.opacity = "0.9";
|
|
312
|
-
e.currentTarget.style.transform =
|
|
321
|
+
e.currentTarget.style.transform =
|
|
322
|
+
"translateY(-1px)";
|
|
313
323
|
}}
|
|
314
324
|
onMouseLeave={(e) => {
|
|
315
325
|
e.currentTarget.style.opacity = "1";
|
|
@@ -234,7 +234,11 @@ export const getErrorActions = (error: CopilotKitError) => {
|
|
|
234
234
|
primary: {
|
|
235
235
|
label: "Upgrade",
|
|
236
236
|
onClick: () =>
|
|
237
|
-
window.open(
|
|
237
|
+
window.open(
|
|
238
|
+
"https://cloud.copilotkit.ai",
|
|
239
|
+
"_blank",
|
|
240
|
+
"noopener,noreferrer",
|
|
241
|
+
),
|
|
238
242
|
},
|
|
239
243
|
};
|
|
240
244
|
default:
|
|
@@ -242,7 +246,10 @@ export const getErrorActions = (error: CopilotKitError) => {
|
|
|
242
246
|
}
|
|
243
247
|
};
|
|
244
248
|
|
|
245
|
-
export function renderCopilotKitUsage(
|
|
249
|
+
export function renderCopilotKitUsage(
|
|
250
|
+
error: CopilotKitError,
|
|
251
|
+
onClose?: () => void,
|
|
252
|
+
) {
|
|
246
253
|
// Route based on error visibility level
|
|
247
254
|
if (error.visibility !== ErrorVisibility.BANNER) {
|
|
248
255
|
return null;
|
|
@@ -21,26 +21,36 @@ type ClaimsRef = Record<string, StateRenderClaim>;
|
|
|
21
21
|
|
|
22
22
|
export interface CoAgentStateRendersContextValue {
|
|
23
23
|
coAgentStateRenders: Record<string, CoAgentStateRender<any>>;
|
|
24
|
-
setCoAgentStateRender: (
|
|
24
|
+
setCoAgentStateRender: (
|
|
25
|
+
id: string,
|
|
26
|
+
stateRender: CoAgentStateRender<any>,
|
|
27
|
+
) => void;
|
|
25
28
|
removeCoAgentStateRender: (id: string) => void;
|
|
26
29
|
claimsRef: RefObject<ClaimsRef>;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
const CoAgentStateRendersContext = createContext<
|
|
30
|
-
undefined
|
|
31
|
-
);
|
|
32
|
+
const CoAgentStateRendersContext = createContext<
|
|
33
|
+
CoAgentStateRendersContextValue | undefined
|
|
34
|
+
>(undefined);
|
|
32
35
|
|
|
33
|
-
export function CoAgentStateRendersProvider({
|
|
36
|
+
export function CoAgentStateRendersProvider({
|
|
37
|
+
children,
|
|
38
|
+
}: {
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
}) {
|
|
34
41
|
const [coAgentStateRenders, setCoAgentStateRenders] = useState<
|
|
35
42
|
Record<string, CoAgentStateRender<any>>
|
|
36
43
|
>({});
|
|
37
44
|
|
|
38
|
-
const setCoAgentStateRender = useCallback(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
const setCoAgentStateRender = useCallback(
|
|
46
|
+
(id: string, stateRender: CoAgentStateRender<any>) => {
|
|
47
|
+
setCoAgentStateRenders((prevPoints) => ({
|
|
48
|
+
...prevPoints,
|
|
49
|
+
[id]: stateRender,
|
|
50
|
+
}));
|
|
51
|
+
},
|
|
52
|
+
[],
|
|
53
|
+
);
|
|
44
54
|
|
|
45
55
|
const removeCoAgentStateRender = useCallback((id: string) => {
|
|
46
56
|
setCoAgentStateRenders((prevPoints) => {
|
|
@@ -69,7 +79,9 @@ export function CoAgentStateRendersProvider({ children }: { children: ReactNode
|
|
|
69
79
|
export function useCoAgentStateRenders() {
|
|
70
80
|
const context = useContext(CoAgentStateRendersContext);
|
|
71
81
|
if (!context) {
|
|
72
|
-
throw new Error(
|
|
82
|
+
throw new Error(
|
|
83
|
+
"useCoAgentStateRenders must be used within CoAgentStateRendersProvider",
|
|
84
|
+
);
|
|
73
85
|
}
|
|
74
86
|
return context;
|
|
75
87
|
}
|
|
@@ -13,7 +13,10 @@ import React from "react";
|
|
|
13
13
|
import { TreeNodeId, Tree } from "../hooks/use-tree";
|
|
14
14
|
import { DocumentPointer } from "../types";
|
|
15
15
|
import { CopilotChatSuggestionConfiguration } from "../types/chat-suggestion-configuration";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
CoAgentStateRender,
|
|
18
|
+
CoAgentStateRenderProps,
|
|
19
|
+
} from "../types/coagent-action";
|
|
17
20
|
import { CoagentState } from "../types/coagent-state";
|
|
18
21
|
import {
|
|
19
22
|
CopilotRuntimeClient,
|
|
@@ -94,8 +97,9 @@ export interface CopilotApiConfig {
|
|
|
94
97
|
mcpServers?: Array<{ endpoint: string; apiKey?: string }>;
|
|
95
98
|
}
|
|
96
99
|
|
|
97
|
-
export type InChatRenderFunction<
|
|
98
|
-
|
|
100
|
+
export type InChatRenderFunction<
|
|
101
|
+
TProps = ActionRenderProps<any> | CatchAllActionRenderProps<any>,
|
|
102
|
+
> = (props: TProps) => string | React.JSX.Element;
|
|
99
103
|
export type CoagentInChatRenderFunction = (
|
|
100
104
|
props: CoAgentStateRenderProps<any>,
|
|
101
105
|
) => string | React.JSX.Element | undefined | null;
|
|
@@ -138,20 +142,32 @@ export interface CopilotContextParams {
|
|
|
138
142
|
) => FunctionCallHandler;
|
|
139
143
|
|
|
140
144
|
// text context
|
|
141
|
-
addContext: (
|
|
145
|
+
addContext: (
|
|
146
|
+
context: string,
|
|
147
|
+
parentId?: string,
|
|
148
|
+
categories?: string[],
|
|
149
|
+
) => TreeNodeId;
|
|
142
150
|
removeContext: (id: TreeNodeId) => void;
|
|
143
151
|
getAllContext: () => Tree;
|
|
144
|
-
getContextString: (
|
|
152
|
+
getContextString: (
|
|
153
|
+
documents: DocumentPointer[],
|
|
154
|
+
categories: string[],
|
|
155
|
+
) => string;
|
|
145
156
|
|
|
146
157
|
// document context
|
|
147
|
-
addDocumentContext: (
|
|
158
|
+
addDocumentContext: (
|
|
159
|
+
documentPointer: DocumentPointer,
|
|
160
|
+
categories?: string[],
|
|
161
|
+
) => TreeNodeId;
|
|
148
162
|
removeDocumentContext: (documentId: string) => void;
|
|
149
163
|
getDocumentsContext: (categories: string[]) => DocumentPointer[];
|
|
150
164
|
|
|
151
165
|
isLoading: boolean;
|
|
152
166
|
setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
153
167
|
|
|
154
|
-
chatSuggestionConfiguration: {
|
|
168
|
+
chatSuggestionConfiguration: {
|
|
169
|
+
[key: string]: CopilotChatSuggestionConfiguration;
|
|
170
|
+
};
|
|
155
171
|
addChatSuggestionConfiguration: (
|
|
156
172
|
id: string,
|
|
157
173
|
suggestion: CopilotChatSuggestionConfiguration,
|
|
@@ -171,7 +187,9 @@ export interface CopilotContextParams {
|
|
|
171
187
|
|
|
172
188
|
// agents
|
|
173
189
|
coagentStates: Record<string, CoagentState>;
|
|
174
|
-
setCoagentStates: React.Dispatch<
|
|
190
|
+
setCoagentStates: React.Dispatch<
|
|
191
|
+
React.SetStateAction<Record<string, CoagentState>>
|
|
192
|
+
>;
|
|
175
193
|
coagentStatesRef: React.RefObject<Record<string, CoagentState>>;
|
|
176
194
|
setCoagentStatesWithRef: (
|
|
177
195
|
value:
|
|
@@ -204,7 +222,9 @@ export interface CopilotContextParams {
|
|
|
204
222
|
* The auth states for the CopilotKit.
|
|
205
223
|
*/
|
|
206
224
|
authStates_c?: Record<ActionName, AuthState>;
|
|
207
|
-
setAuthStates_c?: React.Dispatch<
|
|
225
|
+
setAuthStates_c?: React.Dispatch<
|
|
226
|
+
React.SetStateAction<Record<ActionName, AuthState>>
|
|
227
|
+
>;
|
|
208
228
|
|
|
209
229
|
/**
|
|
210
230
|
* The auth config for the CopilotKit.
|
|
@@ -222,7 +242,11 @@ export interface CopilotContextParams {
|
|
|
222
242
|
removeInterruptAction: (actionId: string) => void;
|
|
223
243
|
interruptEventQueue: Record<string, QueuedInterruptEvent[]>;
|
|
224
244
|
addInterruptEvent: (queuedEvent: QueuedInterruptEvent) => void;
|
|
225
|
-
resolveInterruptEvent: (
|
|
245
|
+
resolveInterruptEvent: (
|
|
246
|
+
threadId: string,
|
|
247
|
+
eventId: string,
|
|
248
|
+
response: string,
|
|
249
|
+
) => void;
|
|
226
250
|
|
|
227
251
|
/**
|
|
228
252
|
* Optional trace handler for comprehensive debugging and observability.
|
|
@@ -236,7 +260,9 @@ export interface CopilotContextParams {
|
|
|
236
260
|
// These are used to handle errors that occur during the execution of the chat.
|
|
237
261
|
// They are not intended for use by the developer. A component can register itself an error listener to be activated somewhere else as needed
|
|
238
262
|
internalErrorHandlers: Record<string, CopilotErrorHandler>;
|
|
239
|
-
setInternalErrorHandler: (
|
|
263
|
+
setInternalErrorHandler: (
|
|
264
|
+
handler: Record<string, CopilotErrorHandler>,
|
|
265
|
+
) => void;
|
|
240
266
|
removeInternalErrorHandler: (id: string) => void;
|
|
241
267
|
}
|
|
242
268
|
|
|
@@ -272,7 +298,9 @@ const emptyCopilotContext: CopilotContextParams = {
|
|
|
272
298
|
|
|
273
299
|
copilotApiConfig: new (class implements CopilotApiConfig {
|
|
274
300
|
get chatApiEndpoint(): string {
|
|
275
|
-
throw new Error(
|
|
301
|
+
throw new Error(
|
|
302
|
+
"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!",
|
|
303
|
+
);
|
|
276
304
|
}
|
|
277
305
|
|
|
278
306
|
get headers(): Record<string, string> {
|
|
@@ -317,16 +345,21 @@ const emptyCopilotContext: CopilotContextParams = {
|
|
|
317
345
|
removeInternalErrorHandler: () => {},
|
|
318
346
|
};
|
|
319
347
|
|
|
320
|
-
export const CopilotContext =
|
|
348
|
+
export const CopilotContext =
|
|
349
|
+
React.createContext<CopilotContextParams>(emptyCopilotContext);
|
|
321
350
|
|
|
322
351
|
export function useCopilotContext(): CopilotContextParams {
|
|
323
352
|
const context = React.useContext(CopilotContext);
|
|
324
353
|
if (context === emptyCopilotContext) {
|
|
325
|
-
throw new Error(
|
|
354
|
+
throw new Error(
|
|
355
|
+
"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!",
|
|
356
|
+
);
|
|
326
357
|
}
|
|
327
358
|
return context;
|
|
328
359
|
}
|
|
329
360
|
|
|
330
361
|
function returnAndThrowInDebug<T>(_value: T): T {
|
|
331
|
-
throw new Error(
|
|
362
|
+
throw new Error(
|
|
363
|
+
"Remember to wrap your app in a `<CopilotKit> {...} </CopilotKit>` !!!",
|
|
364
|
+
);
|
|
332
365
|
}
|
package/src/context/index.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { CopilotContext, useCopilotContext } from "./copilot-context";
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
CopilotMessagesContext,
|
|
4
|
+
useCopilotMessagesContext,
|
|
5
|
+
} from "./copilot-messages-context";
|
|
3
6
|
export {
|
|
4
7
|
CoAgentStateRendersContext,
|
|
5
8
|
CoAgentStateRendersProvider,
|
|
@@ -13,4 +16,7 @@ export type {
|
|
|
13
16
|
} from "./copilot-context";
|
|
14
17
|
export type { CopilotMessagesContextParams } from "./copilot-messages-context";
|
|
15
18
|
export type { CoAgentStateRendersContextValue } from "./coagent-state-renders-context";
|
|
16
|
-
export type {
|
|
19
|
+
export type {
|
|
20
|
+
ThreadsContextValue,
|
|
21
|
+
ThreadsProviderProps,
|
|
22
|
+
} from "./threads-context";
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext,
|
|
4
|
+
useState,
|
|
5
|
+
ReactNode,
|
|
6
|
+
SetStateAction,
|
|
7
|
+
} from "react";
|
|
2
8
|
import { randomUUID } from "@copilotkit/shared";
|
|
3
9
|
|
|
4
10
|
export interface ThreadsContextValue {
|
|
@@ -6,14 +12,19 @@ export interface ThreadsContextValue {
|
|
|
6
12
|
setThreadId: (value: SetStateAction<string>) => void;
|
|
7
13
|
}
|
|
8
14
|
|
|
9
|
-
const ThreadsContext = createContext<ThreadsContextValue | undefined>(
|
|
15
|
+
const ThreadsContext = createContext<ThreadsContextValue | undefined>(
|
|
16
|
+
undefined,
|
|
17
|
+
);
|
|
10
18
|
|
|
11
19
|
export interface ThreadsProviderProps {
|
|
12
20
|
children: ReactNode;
|
|
13
21
|
threadId?: string;
|
|
14
22
|
}
|
|
15
23
|
|
|
16
|
-
export function ThreadsProvider({
|
|
24
|
+
export function ThreadsProvider({
|
|
25
|
+
children,
|
|
26
|
+
threadId: explicitThreadId,
|
|
27
|
+
}: ThreadsProviderProps) {
|
|
17
28
|
const [internalThreadId, setThreadId] = useState<string>(() => randomUUID());
|
|
18
29
|
|
|
19
30
|
const threadId = explicitThreadId ?? internalThreadId;
|
|
@@ -20,7 +20,11 @@ describe("useCoAgentStateRenderBridge helpers", () => {
|
|
|
20
20
|
runId: "run-123",
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const result = resolveClaim({
|
|
23
|
+
const result = resolveClaim({
|
|
24
|
+
claims,
|
|
25
|
+
context,
|
|
26
|
+
stateSnapshot: { step: 1 },
|
|
27
|
+
});
|
|
24
28
|
expect(result.action).toBe(ClaimAction.Existing);
|
|
25
29
|
expect(result.canRender).toBe(true);
|
|
26
30
|
expect(result.updateRunId).toBe("run-123");
|
|
@@ -43,7 +47,11 @@ describe("useCoAgentStateRenderBridge helpers", () => {
|
|
|
43
47
|
messageIndex: 1,
|
|
44
48
|
};
|
|
45
49
|
|
|
46
|
-
const result = resolveClaim({
|
|
50
|
+
const result = resolveClaim({
|
|
51
|
+
claims,
|
|
52
|
+
context,
|
|
53
|
+
stateSnapshot: { step: 2 },
|
|
54
|
+
});
|
|
47
55
|
expect(result.action).toBe(ClaimAction.Override);
|
|
48
56
|
expect(result.canRender).toBe(true);
|
|
49
57
|
expect(result.nextClaim).toMatchObject({
|
|
@@ -53,7 +61,6 @@ describe("useCoAgentStateRenderBridge helpers", () => {
|
|
|
53
61
|
});
|
|
54
62
|
expect(result.lockOthers).toBe(true);
|
|
55
63
|
});
|
|
56
|
-
|
|
57
64
|
});
|
|
58
65
|
|
|
59
66
|
describe("selectSnapshot", () => {
|
|
@@ -67,7 +74,7 @@ describe("useCoAgentStateRenderBridge helpers", () => {
|
|
|
67
74
|
messageId: "msg1",
|
|
68
75
|
stateRenderId: "render-a",
|
|
69
76
|
effectiveRunId: "run-1",
|
|
70
|
-
stateSnapshotProp:
|
|
77
|
+
stateSnapshotProp: '{"phase":"planning"}',
|
|
71
78
|
agentState: { phase: "ignored" },
|
|
72
79
|
agentMessages: [{ id: "assistant-1", role: "assistant" }],
|
|
73
80
|
caches,
|