@copilotkit/react-core 1.51.4-next.7 → 1.51.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 +26 -0
- package/README.md +18 -12
- 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-VKNLTZJE.mjs → chunk-6ABVYB2U.mjs} +28 -19
- package/dist/chunk-6ABVYB2U.mjs.map +1 -0
- 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-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-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-LHERIF3L.mjs → chunk-LD34IXVT.mjs} +8 -5
- package/dist/chunk-LD34IXVT.mjs.map +1 -0
- package/dist/{chunk-7DTB7S5V.mjs → chunk-LNGBARXE.mjs} +5 -2
- package/dist/chunk-LNGBARXE.mjs.map +1 -0
- package/dist/{chunk-DQXCQWSG.mjs → chunk-LRPWSPXG.mjs} +85 -50
- package/dist/chunk-LRPWSPXG.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-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-VP43SLSZ.mjs → chunk-R2DP4APC.mjs} +10 -5
- package/dist/chunk-R2DP4APC.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-YCG6SNAU.mjs → chunk-SBRCWA4S.mjs} +186 -32
- package/dist/chunk-SBRCWA4S.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-HE22TZMF.mjs → chunk-SLM6CLAH.mjs} +16 -7
- package/dist/chunk-SLM6CLAH.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-4RRMC7L2.mjs → chunk-SYMT73HM.mjs} +16 -5
- package/dist/chunk-SYMT73HM.mjs.map +1 -0
- 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 +3 -3
- 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 +25 -25
- 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 +11 -11
- 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 +11 -11
- 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 +10 -10
- 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 +35 -35
- 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 +7 -8
- 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
|
@@ -40,7 +40,9 @@ function processActionsForRuntimeRequest(actions) {
|
|
|
40
40
|
return {
|
|
41
41
|
name: action.name,
|
|
42
42
|
description: action.description || "",
|
|
43
|
-
jsonSchema: JSON.stringify(
|
|
43
|
+
jsonSchema: JSON.stringify(
|
|
44
|
+
(0, import_shared.actionParametersToJsonSchema)(action.parameters || [])
|
|
45
|
+
),
|
|
44
46
|
available
|
|
45
47
|
};
|
|
46
48
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/frontend-action.ts"],"sourcesContent":["import { ActionInputAvailability } from \"@copilotkit/runtime-client-gql\";\nimport {\n Action,\n Parameter,\n MappedParameterTypes,\n actionParametersToJsonSchema,\n} from \"@copilotkit/shared\";\nimport React from \"react\";\n\ninterface InProgressState<T extends Parameter[] | [] = []> {\n status: \"inProgress\";\n args: Partial<MappedParameterTypes<T>>;\n result: undefined;\n}\n\ninterface ExecutingState<T extends Parameter[] | [] = []> {\n status: \"executing\";\n args: MappedParameterTypes<T>;\n result: undefined;\n}\n\ninterface CompleteState<T extends Parameter[] | [] = []> {\n status: \"complete\";\n args: MappedParameterTypes<T>;\n result: any;\n}\n\ninterface InProgressStateNoArgs<T extends Parameter[] | [] = []> {\n status: \"inProgress\";\n args: Partial<MappedParameterTypes<T>>;\n result: undefined;\n}\n\ninterface ExecutingStateNoArgs<T extends Parameter[] | [] = []> {\n status: \"executing\";\n args: MappedParameterTypes<T>;\n result: undefined;\n}\n\ninterface CompleteStateNoArgs<T extends Parameter[] | [] = []> {\n status: \"complete\";\n args: MappedParameterTypes<T>;\n result: any;\n}\n\ninterface InProgressStateWait<T extends Parameter[] | [] = []> {\n status: \"inProgress\";\n args: Partial<MappedParameterTypes<T>>;\n /** @deprecated use respond instead */\n handler: undefined;\n respond: undefined;\n result: undefined;\n}\n\ninterface ExecutingStateWait<T extends Parameter[] | [] = []> {\n status: \"executing\";\n args: MappedParameterTypes<T>;\n /** @deprecated use respond instead */\n handler: (result: any) => void;\n respond: (result: any) => void;\n result: undefined;\n}\n\ninterface CompleteStateWait<T extends Parameter[] | [] = []> {\n status: \"complete\";\n args: MappedParameterTypes<T>;\n /** @deprecated use respond instead */\n handler: undefined;\n respond: undefined;\n result: any;\n}\n\ninterface InProgressStateNoArgsWait<T extends Parameter[] | [] = []> {\n status: \"inProgress\";\n args: Partial<MappedParameterTypes<T>>;\n /** @deprecated use respond instead */\n handler: undefined;\n respond: undefined;\n result: undefined;\n}\n\ninterface ExecutingStateNoArgsWait<T extends Parameter[] | [] = []> {\n status: \"executing\";\n args: MappedParameterTypes<T>;\n /** @deprecated use respond instead */\n handler: (result: any) => void;\n respond: (result: any) => void;\n result: undefined;\n}\n\ninterface CompleteStateNoArgsWait<T extends Parameter[] | [] = []> {\n status: \"complete\";\n args: MappedParameterTypes<T>;\n /** @deprecated use respond instead */\n handler: undefined;\n respond: undefined;\n}\n\nexport type ActionRenderProps<T extends Parameter[] | [] = []> =\n | CompleteState<T>\n | ExecutingState<T>\n | InProgressState<T>;\n\nexport type ActionRenderPropsNoArgs<T extends Parameter[] | [] = []> =\n | CompleteStateNoArgs<T>\n | ExecutingStateNoArgs<T>\n | InProgressStateNoArgs<T>;\n\nexport type ActionRenderPropsWait<T extends Parameter[] | [] = []> =\n | CompleteStateWait<T>\n | ExecutingStateWait<T>\n | InProgressStateWait<T>;\n\nexport type ActionRenderPropsNoArgsWait<T extends Parameter[] | [] = []> =\n | CompleteStateNoArgsWait<T>\n | ExecutingStateNoArgsWait<T>\n | InProgressStateNoArgsWait<T>;\n\nexport type CatchAllActionRenderProps<T extends Parameter[] | [] = []> =\n | (CompleteState<T> & {\n name: string;\n })\n | (ExecutingState<T> & {\n name: string;\n })\n | (InProgressState<T> & {\n name: string;\n });\n\nexport type FrontendActionAvailability
|
|
1
|
+
{"version":3,"sources":["../../src/types/frontend-action.ts"],"sourcesContent":["import { ActionInputAvailability } from \"@copilotkit/runtime-client-gql\";\nimport {\n Action,\n Parameter,\n MappedParameterTypes,\n actionParametersToJsonSchema,\n} from \"@copilotkit/shared\";\nimport React from \"react\";\n\ninterface InProgressState<T extends Parameter[] | [] = []> {\n status: \"inProgress\";\n args: Partial<MappedParameterTypes<T>>;\n result: undefined;\n}\n\ninterface ExecutingState<T extends Parameter[] | [] = []> {\n status: \"executing\";\n args: MappedParameterTypes<T>;\n result: undefined;\n}\n\ninterface CompleteState<T extends Parameter[] | [] = []> {\n status: \"complete\";\n args: MappedParameterTypes<T>;\n result: any;\n}\n\ninterface InProgressStateNoArgs<T extends Parameter[] | [] = []> {\n status: \"inProgress\";\n args: Partial<MappedParameterTypes<T>>;\n result: undefined;\n}\n\ninterface ExecutingStateNoArgs<T extends Parameter[] | [] = []> {\n status: \"executing\";\n args: MappedParameterTypes<T>;\n result: undefined;\n}\n\ninterface CompleteStateNoArgs<T extends Parameter[] | [] = []> {\n status: \"complete\";\n args: MappedParameterTypes<T>;\n result: any;\n}\n\ninterface InProgressStateWait<T extends Parameter[] | [] = []> {\n status: \"inProgress\";\n args: Partial<MappedParameterTypes<T>>;\n /** @deprecated use respond instead */\n handler: undefined;\n respond: undefined;\n result: undefined;\n}\n\ninterface ExecutingStateWait<T extends Parameter[] | [] = []> {\n status: \"executing\";\n args: MappedParameterTypes<T>;\n /** @deprecated use respond instead */\n handler: (result: any) => void;\n respond: (result: any) => void;\n result: undefined;\n}\n\ninterface CompleteStateWait<T extends Parameter[] | [] = []> {\n status: \"complete\";\n args: MappedParameterTypes<T>;\n /** @deprecated use respond instead */\n handler: undefined;\n respond: undefined;\n result: any;\n}\n\ninterface InProgressStateNoArgsWait<T extends Parameter[] | [] = []> {\n status: \"inProgress\";\n args: Partial<MappedParameterTypes<T>>;\n /** @deprecated use respond instead */\n handler: undefined;\n respond: undefined;\n result: undefined;\n}\n\ninterface ExecutingStateNoArgsWait<T extends Parameter[] | [] = []> {\n status: \"executing\";\n args: MappedParameterTypes<T>;\n /** @deprecated use respond instead */\n handler: (result: any) => void;\n respond: (result: any) => void;\n result: undefined;\n}\n\ninterface CompleteStateNoArgsWait<T extends Parameter[] | [] = []> {\n status: \"complete\";\n args: MappedParameterTypes<T>;\n /** @deprecated use respond instead */\n handler: undefined;\n respond: undefined;\n}\n\nexport type ActionRenderProps<T extends Parameter[] | [] = []> =\n | CompleteState<T>\n | ExecutingState<T>\n | InProgressState<T>;\n\nexport type ActionRenderPropsNoArgs<T extends Parameter[] | [] = []> =\n | CompleteStateNoArgs<T>\n | ExecutingStateNoArgs<T>\n | InProgressStateNoArgs<T>;\n\nexport type ActionRenderPropsWait<T extends Parameter[] | [] = []> =\n | CompleteStateWait<T>\n | ExecutingStateWait<T>\n | InProgressStateWait<T>;\n\nexport type ActionRenderPropsNoArgsWait<T extends Parameter[] | [] = []> =\n | CompleteStateNoArgsWait<T>\n | ExecutingStateNoArgsWait<T>\n | InProgressStateNoArgsWait<T>;\n\nexport type CatchAllActionRenderProps<T extends Parameter[] | [] = []> =\n | (CompleteState<T> & {\n name: string;\n })\n | (ExecutingState<T> & {\n name: string;\n })\n | (InProgressState<T> & {\n name: string;\n });\n\nexport type FrontendActionAvailability =\n | \"disabled\"\n | \"enabled\"\n | \"remote\"\n | \"frontend\";\n\nexport type FrontendAction<\n T extends Parameter[] | [] = [],\n N extends string = string,\n> = Action<T> & {\n name: Exclude<N, \"*\">;\n /**\n * @deprecated Use `available` instead.\n */\n disabled?: boolean;\n available?: FrontendActionAvailability;\n pairedAction?: string;\n followUp?: boolean;\n} & (\n | {\n render?:\n | string\n | (T extends []\n ? (\n props: ActionRenderPropsNoArgs<T>,\n ) => string | React.ReactElement\n : (props: ActionRenderProps<T>) => string | React.ReactElement);\n /** @deprecated use renderAndWaitForResponse instead */\n renderAndWait?: never;\n renderAndWaitForResponse?: never;\n }\n | {\n render?: never;\n /** @deprecated use renderAndWaitForResponse instead */\n renderAndWait?: T extends []\n ? (props: ActionRenderPropsNoArgsWait<T>) => React.ReactElement\n : (props: ActionRenderPropsWait<T>) => React.ReactElement;\n renderAndWaitForResponse?: T extends []\n ? (props: ActionRenderPropsNoArgsWait<T>) => React.ReactElement\n : (props: ActionRenderPropsWait<T>) => React.ReactElement;\n handler?: never;\n }\n );\n\nexport type CatchAllFrontendAction = {\n name: \"*\";\n render: (props: CatchAllActionRenderProps<any>) => React.ReactElement;\n};\n\nexport type RenderFunctionStatus = ActionRenderProps<any>[\"status\"];\n\nexport function processActionsForRuntimeRequest(\n actions: FrontendAction<any>[],\n) {\n const filteredActions = actions\n .filter(\n (action) =>\n action.available !== ActionInputAvailability.Disabled &&\n action.disabled !== true &&\n action.name !== \"*\" &&\n action.available != \"frontend\" &&\n !action.pairedAction,\n )\n .map((action) => {\n let available: ActionInputAvailability | undefined =\n ActionInputAvailability.Enabled;\n if (action.disabled) {\n available = ActionInputAvailability.Disabled;\n } else if (action.available === \"disabled\") {\n available = ActionInputAvailability.Disabled;\n } else if (action.available === \"remote\") {\n available = ActionInputAvailability.Remote;\n }\n return {\n name: action.name,\n description: action.description || \"\",\n jsonSchema: JSON.stringify(\n actionParametersToJsonSchema(action.parameters || []),\n ),\n available,\n };\n });\n return filteredActions;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAwC;AACxC,oBAKO;AA8KA,SAAS,gCACd,SACA;AACA,QAAM,kBAAkB,QACrB;AAAA,IACC,CAAC,WACC,OAAO,cAAc,kDAAwB,YAC7C,OAAO,aAAa,QACpB,OAAO,SAAS,OAChB,OAAO,aAAa,cACpB,CAAC,OAAO;AAAA,EACZ,EACC,IAAI,CAAC,WAAW;AACf,QAAI,YACF,kDAAwB;AAC1B,QAAI,OAAO,UAAU;AACnB,kBAAY,kDAAwB;AAAA,IACtC,WAAW,OAAO,cAAc,YAAY;AAC1C,kBAAY,kDAAwB;AAAA,IACtC,WAAW,OAAO,cAAc,UAAU;AACxC,kBAAY,kDAAwB;AAAA,IACtC;AACA,WAAO;AAAA,MACL,MAAM,OAAO;AAAA,MACb,aAAa,OAAO,eAAe;AAAA,MACnC,YAAY,KAAK;AAAA,YACf,4CAA6B,OAAO,cAAc,CAAC,CAAC;AAAA,MACtD;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/interrupt-action.ts"],"sourcesContent":["import { LangGraphInterruptEvent } from \"@copilotkit/runtime-client-gql\";\nimport { AgentSession } from \"../context/copilot-context\";\n\nexport interface LangGraphInterruptRenderHandlerProps<TEventValue = any> {\n event: LangGraphInterruptEvent<TEventValue>;\n resolve: (resolution: string) => void;\n}\n\nexport interface LangGraphInterruptRenderProps<TEventValue = any> {\n result: unknown;\n event: LangGraphInterruptEvent<TEventValue>;\n resolve: (resolution: string) => void;\n}\n\nexport interface LangGraphInterruptRender<TEventValue = any> {\n id: string;\n /**\n * The handler function to handle the event.\n */\n handler?: (props: LangGraphInterruptRenderHandlerProps<TEventValue
|
|
1
|
+
{"version":3,"sources":["../../src/types/interrupt-action.ts"],"sourcesContent":["import { LangGraphInterruptEvent } from \"@copilotkit/runtime-client-gql\";\nimport { AgentSession } from \"../context/copilot-context\";\n\nexport interface LangGraphInterruptRenderHandlerProps<TEventValue = any> {\n event: LangGraphInterruptEvent<TEventValue>;\n resolve: (resolution: string) => void;\n}\n\nexport interface LangGraphInterruptRenderProps<TEventValue = any> {\n result: unknown;\n event: LangGraphInterruptEvent<TEventValue>;\n resolve: (resolution: string) => void;\n}\n\nexport interface LangGraphInterruptRender<TEventValue = any> {\n id: string;\n /**\n * The handler function to handle the event.\n */\n handler?: (\n props: LangGraphInterruptRenderHandlerProps<TEventValue>,\n ) => any | Promise<any>;\n /**\n * The render function to handle the event.\n */\n render?: (\n props: LangGraphInterruptRenderProps<TEventValue>,\n ) => string | React.ReactElement;\n /**\n * Method that returns a boolean, indicating if the interrupt action should run\n * Useful when using multiple interrupts\n */\n enabled?: (args: {\n eventValue: TEventValue;\n agentMetadata: AgentSession;\n }) => boolean;\n}\n\nexport type LangGraphInterruptAction = LangGraphInterruptRender & {\n event?: LangGraphInterruptEvent;\n};\n\nexport type LangGraphInterruptActionSetterArgs =\n Partial<LangGraphInterruptRender> | null;\nexport type LangGraphInterruptActionSetter = (\n action: LangGraphInterruptActionSetterArgs,\n) => void;\n\nexport interface QueuedInterruptEvent {\n eventId: string; // Generated unique ID for tracking\n threadId: string;\n event: LangGraphInterruptEvent;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/v2/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../../../../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode"],"mappings":"4ZAAA,SAAqBA,EAAKC,QACX,IAARA,IAAiBA,EAAM,CAAA,GAC5B,IAAIC,EAAWD,EAAIC,SAEnB,GAAgC,oBAAbC,SAAnB,CAEA,IAAIC,EAAOD,SAASC,MAAQD,SAASE,qBAAqB,QAAQ,GAC9DC,EAAQH,SAASI,cAAc,SACnCD,EAAME,KAAO,WAEI,QAAbN,GACEE,EAAKK,WACPL,EAAKM,aAAaJ,EAAOF,EAAKK,YAKhCL,EAAKO,YAAYL,GAGfA,EAAMM,WACRN,EAAMM,WAAWC,QAAUb,EAE3BM,EAAMK,YAAYR,SAASW,eAAed,GAnBW,CAqBzD","x_google_ignoreList":[0]}
|
package/jest.config.js
CHANGED
|
@@ -10,6 +10,7 @@ module.exports = {
|
|
|
10
10
|
moduleNameMapper: {
|
|
11
11
|
"^@/(.*)$": "<rootDir>/src/$1",
|
|
12
12
|
"\\.(css|less|scss|sass)$": "identity-obj-proxy",
|
|
13
|
+
"^@segment/analytics-node$": "<rootDir>/src/__mocks__/analytics-node.js",
|
|
13
14
|
},
|
|
14
15
|
transformIgnorePatterns: [
|
|
15
16
|
"node_modules/(?!(react-markdown|streamdown|@copilotkitnext)/)",
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.51.4
|
|
12
|
+
"version": "1.51.4",
|
|
13
13
|
"sideEffects": [
|
|
14
14
|
"**/*.css"
|
|
15
15
|
],
|
|
@@ -53,18 +53,18 @@
|
|
|
53
53
|
"tsup": "^6.7.0",
|
|
54
54
|
"typescript": "^5.2.3",
|
|
55
55
|
"zod": ">=3.0.0",
|
|
56
|
-
"eslint-config-custom": "1.4.
|
|
57
|
-
"tsconfig": "1.4.
|
|
56
|
+
"eslint-config-custom": "1.4.8",
|
|
57
|
+
"tsconfig": "1.4.8"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@ag-ui/client": "^0.0.43",
|
|
61
61
|
"@scarf/scarf": "^1.3.0",
|
|
62
62
|
"react-markdown": "^8.0.7",
|
|
63
63
|
"untruncate-json": "^0.0.1",
|
|
64
|
-
"@copilotkit/runtime-client-gql": "1.51.4
|
|
65
|
-
"@copilotkit/shared": "1.51.4
|
|
66
|
-
"@copilotkitnext/core": "1.51.4
|
|
67
|
-
"@copilotkitnext/react": "1.51.4
|
|
64
|
+
"@copilotkit/runtime-client-gql": "1.51.4",
|
|
65
|
+
"@copilotkit/shared": "1.51.4",
|
|
66
|
+
"@copilotkitnext/core": "1.51.4",
|
|
67
|
+
"@copilotkitnext/react": "1.51.4"
|
|
68
68
|
},
|
|
69
69
|
"keywords": [
|
|
70
70
|
"copilotkit",
|
|
@@ -83,7 +83,6 @@
|
|
|
83
83
|
"dev": "tsup --watch",
|
|
84
84
|
"test": "jest",
|
|
85
85
|
"check-types": "tsc --noEmit",
|
|
86
|
-
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf .next",
|
|
87
86
|
"link:global": "pnpm link --global",
|
|
88
87
|
"unlink:global": "pnpm unlink --global"
|
|
89
88
|
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
useAgent,
|
|
4
|
+
useCopilotChatConfiguration,
|
|
5
|
+
useCopilotKit,
|
|
6
|
+
} from "@copilotkitnext/react";
|
|
3
7
|
import { CopilotKitError, parseJson } from "@copilotkit/shared";
|
|
4
8
|
import { useCopilotContext } from "../context";
|
|
5
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
AbstractAgent,
|
|
11
|
+
AgentSubscriber,
|
|
12
|
+
AGUIConnectNotImplementedError,
|
|
13
|
+
} from "@ag-ui/client";
|
|
6
14
|
import { useErrorToast } from "./error-boundary/error-utils";
|
|
7
15
|
import { CopilotKitCoreSubscriber } from "@copilotkitnext/core";
|
|
8
16
|
import { useToast } from "./toast/toast-provider";
|
|
@@ -30,7 +38,10 @@ const usePredictStateSubscription = (agent?: AbstractAgent) => {
|
|
|
30
38
|
|
|
31
39
|
const emittedState =
|
|
32
40
|
typeof partialToolCallArgs === "string"
|
|
33
|
-
? parseJson(
|
|
41
|
+
? parseJson(
|
|
42
|
+
partialToolCallArgs as unknown as string,
|
|
43
|
+
partialToolCallArgs,
|
|
44
|
+
)
|
|
34
45
|
: partialToolCallArgs;
|
|
35
46
|
|
|
36
47
|
agent.setState({
|
|
@@ -66,8 +77,13 @@ export function CopilotListeners() {
|
|
|
66
77
|
useEffect(() => {
|
|
67
78
|
const subscriber: CopilotKitCoreSubscriber = {
|
|
68
79
|
onError: ({ error }) => {
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
setBannerError(
|
|
81
|
+
new CopilotKitLowLevelError({
|
|
82
|
+
error,
|
|
83
|
+
message: error.message,
|
|
84
|
+
url: typeof window !== "undefined" ? window.location.href : "",
|
|
85
|
+
}),
|
|
86
|
+
);
|
|
71
87
|
},
|
|
72
88
|
};
|
|
73
89
|
const subscription = copilotkit.subscribe(subscriber);
|
|
@@ -64,7 +64,9 @@ describe("CopilotKit onError types", () => {
|
|
|
64
64
|
|
|
65
65
|
it("should handle async error handlers", async () => {
|
|
66
66
|
// RED: Will fail - testing async handler support
|
|
67
|
-
const asyncHandler: CopilotErrorHandler = async (
|
|
67
|
+
const asyncHandler: CopilotErrorHandler = async (
|
|
68
|
+
errorEvent: CopilotErrorEvent,
|
|
69
|
+
) => {
|
|
68
70
|
await Promise.resolve();
|
|
69
71
|
return;
|
|
70
72
|
};
|
|
@@ -93,11 +93,16 @@ const MessagesTapContext = createContext<MessagesTap | null>(null);
|
|
|
93
93
|
|
|
94
94
|
export function useMessagesTap() {
|
|
95
95
|
const tap = useContext(MessagesTapContext);
|
|
96
|
-
if (!tap)
|
|
96
|
+
if (!tap)
|
|
97
|
+
throw new Error("useMessagesTap must be used inside <MessagesTapProvider>");
|
|
97
98
|
return tap;
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
export function MessagesTapProvider({
|
|
101
|
+
export function MessagesTapProvider({
|
|
102
|
+
children,
|
|
103
|
+
}: {
|
|
104
|
+
children: React.ReactNode;
|
|
105
|
+
}) {
|
|
101
106
|
const messagesRef = useRef<Message[]>([]);
|
|
102
107
|
|
|
103
108
|
const tapRef = useRef<MessagesTap>({
|
|
@@ -108,7 +113,9 @@ export function MessagesTapProvider({ children }: { children: React.ReactNode })
|
|
|
108
113
|
});
|
|
109
114
|
|
|
110
115
|
return (
|
|
111
|
-
<MessagesTapContext.Provider value={tapRef.current}>
|
|
116
|
+
<MessagesTapContext.Provider value={tapRef.current}>
|
|
117
|
+
{children}
|
|
118
|
+
</MessagesTapContext.Provider>
|
|
112
119
|
);
|
|
113
120
|
}
|
|
114
121
|
|
|
@@ -124,7 +131,8 @@ export function CopilotMessages({ children }: { children: ReactNode }) {
|
|
|
124
131
|
|
|
125
132
|
const { updateTapMessages } = useMessagesTap();
|
|
126
133
|
|
|
127
|
-
const { threadId, agentSession, showDevConsole, onError, copilotApiConfig } =
|
|
134
|
+
const { threadId, agentSession, showDevConsole, onError, copilotApiConfig } =
|
|
135
|
+
useCopilotContext();
|
|
128
136
|
const { setBannerError } = useToast();
|
|
129
137
|
|
|
130
138
|
// Helper function to trace UI errors (similar to useCopilotRuntimeClient)
|
|
@@ -146,8 +154,14 @@ export function CopilotMessages({ children }: { children: ReactNode }) {
|
|
|
146
154
|
},
|
|
147
155
|
technical: {
|
|
148
156
|
environment: "browser",
|
|
149
|
-
userAgent:
|
|
150
|
-
|
|
157
|
+
userAgent:
|
|
158
|
+
typeof navigator !== "undefined"
|
|
159
|
+
? navigator.userAgent
|
|
160
|
+
: undefined,
|
|
161
|
+
stackTrace:
|
|
162
|
+
originalError instanceof Error
|
|
163
|
+
? originalError.stack
|
|
164
|
+
: undefined,
|
|
151
165
|
},
|
|
152
166
|
},
|
|
153
167
|
error,
|
|
@@ -160,17 +174,25 @@ export function CopilotMessages({ children }: { children: ReactNode }) {
|
|
|
160
174
|
[onError, copilotApiConfig.publicApiKey, copilotApiConfig.chatApiEndpoint],
|
|
161
175
|
);
|
|
162
176
|
|
|
163
|
-
const createStructuredError = (
|
|
177
|
+
const createStructuredError = (
|
|
178
|
+
gqlError: GraphQLError,
|
|
179
|
+
): CopilotKitError | null => {
|
|
164
180
|
const extensions = gqlError.extensions;
|
|
165
181
|
const originalError = extensions?.originalError as any;
|
|
166
182
|
|
|
167
183
|
// Priority: Check stack trace for discovery errors first
|
|
168
184
|
if (originalError?.stack) {
|
|
169
185
|
if (originalError.stack.includes("CopilotApiDiscoveryError")) {
|
|
170
|
-
return new CopilotKitApiDiscoveryError({
|
|
186
|
+
return new CopilotKitApiDiscoveryError({
|
|
187
|
+
message: originalError.message,
|
|
188
|
+
});
|
|
171
189
|
}
|
|
172
|
-
if (
|
|
173
|
-
|
|
190
|
+
if (
|
|
191
|
+
originalError.stack.includes("CopilotKitRemoteEndpointDiscoveryError")
|
|
192
|
+
) {
|
|
193
|
+
return new CopilotKitRemoteEndpointDiscoveryError({
|
|
194
|
+
message: originalError.message,
|
|
195
|
+
});
|
|
174
196
|
}
|
|
175
197
|
if (originalError.stack.includes("CopilotKitAgentDiscoveryError")) {
|
|
176
198
|
return new CopilotKitAgentDiscoveryError({
|
|
@@ -203,7 +225,10 @@ export function CopilotMessages({ children }: { children: ReactNode }) {
|
|
|
203
225
|
const isDev = shouldShowDevConsole(showDevConsole);
|
|
204
226
|
|
|
205
227
|
if (!isDev) {
|
|
206
|
-
console.error(
|
|
228
|
+
console.error(
|
|
229
|
+
"CopilotKit Error (hidden in production):",
|
|
230
|
+
gqlError.message,
|
|
231
|
+
);
|
|
207
232
|
return;
|
|
208
233
|
}
|
|
209
234
|
|
|
@@ -13,7 +13,10 @@ import { CopilotKitProviderProps } from "@copilotkitnext/react";
|
|
|
13
13
|
*
|
|
14
14
|
* TODO: Remove this `Omit` once this is resolved.
|
|
15
15
|
*/
|
|
16
|
-
export interface CopilotKitProps extends Omit<
|
|
16
|
+
export interface CopilotKitProps extends Omit<
|
|
17
|
+
CopilotKitProviderProps,
|
|
18
|
+
"children"
|
|
19
|
+
> {
|
|
17
20
|
/**
|
|
18
21
|
* Your Copilot Cloud API key.
|
|
19
22
|
*
|
|
@@ -14,7 +14,14 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
useCallback,
|
|
19
|
+
useEffect,
|
|
20
|
+
useMemo,
|
|
21
|
+
useRef,
|
|
22
|
+
useState,
|
|
23
|
+
SetStateAction,
|
|
24
|
+
} from "react";
|
|
18
25
|
import {
|
|
19
26
|
CopilotChatConfigurationProvider,
|
|
20
27
|
CopilotKitInspector,
|
|
@@ -30,7 +37,10 @@ import {
|
|
|
30
37
|
useCopilotContext,
|
|
31
38
|
} from "../../context/copilot-context";
|
|
32
39
|
import useTree from "../../hooks/use-tree";
|
|
33
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
CopilotChatSuggestionConfiguration,
|
|
42
|
+
DocumentPointer,
|
|
43
|
+
} from "../../types";
|
|
34
44
|
import { flushSync } from "react-dom";
|
|
35
45
|
import {
|
|
36
46
|
COPILOT_CLOUD_CHAT_URL,
|
|
@@ -75,7 +85,10 @@ export function CopilotKit({ children, ...props }: CopilotKitProps) {
|
|
|
75
85
|
|
|
76
86
|
return (
|
|
77
87
|
<ToastProvider enabled={enabled}>
|
|
78
|
-
<CopilotErrorBoundary
|
|
88
|
+
<CopilotErrorBoundary
|
|
89
|
+
publicApiKey={publicApiKey}
|
|
90
|
+
showUsageBanner={enabled}
|
|
91
|
+
>
|
|
79
92
|
<ThreadsProvider threadId={props.threadId}>
|
|
80
93
|
<CopilotKitNextProvider
|
|
81
94
|
{...props}
|
|
@@ -119,7 +132,10 @@ function CopilotKitErrorBridge() {
|
|
|
119
132
|
},
|
|
120
133
|
technical: {
|
|
121
134
|
environment: "browser",
|
|
122
|
-
userAgent:
|
|
135
|
+
userAgent:
|
|
136
|
+
typeof navigator !== "undefined"
|
|
137
|
+
? navigator.userAgent
|
|
138
|
+
: undefined,
|
|
123
139
|
stackTrace: event.error.stack,
|
|
124
140
|
},
|
|
125
141
|
// Add additional context from v2.x event
|
|
@@ -157,7 +173,9 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
157
173
|
|
|
158
174
|
const chatApiEndpoint = props.runtimeUrl || COPILOT_CLOUD_CHAT_URL;
|
|
159
175
|
|
|
160
|
-
const [actions, setActions] = useState<Record<string, FrontendAction<any>>>(
|
|
176
|
+
const [actions, setActions] = useState<Record<string, FrontendAction<any>>>(
|
|
177
|
+
{},
|
|
178
|
+
);
|
|
161
179
|
|
|
162
180
|
// State for registered actions from useCopilotAction
|
|
163
181
|
const [registeredActionConfigs, setRegisteredActionConfigs] = useState<
|
|
@@ -174,7 +192,9 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
174
192
|
const [chatInstructions, setChatInstructions] = useState("");
|
|
175
193
|
const [authStates, setAuthStates] = useState<Record<string, AuthState>>({});
|
|
176
194
|
const [extensions, setExtensions] = useState<ExtensionsInput>({});
|
|
177
|
-
const [additionalInstructions, setAdditionalInstructions] = useState<
|
|
195
|
+
const [additionalInstructions, setAdditionalInstructions] = useState<
|
|
196
|
+
string[]
|
|
197
|
+
>([]);
|
|
178
198
|
|
|
179
199
|
const {
|
|
180
200
|
addElement: addDocument,
|
|
@@ -239,7 +259,9 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
239
259
|
|
|
240
260
|
const getFunctionCallHandler = useCallback(
|
|
241
261
|
(customEntryPoints?: Record<string, FrontendAction<any>>) => {
|
|
242
|
-
return entryPointsToFunctionCallHandler(
|
|
262
|
+
return entryPointsToFunctionCallHandler(
|
|
263
|
+
Object.values(customEntryPoints || actions),
|
|
264
|
+
);
|
|
243
265
|
},
|
|
244
266
|
[actions],
|
|
245
267
|
);
|
|
@@ -252,7 +274,10 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
252
274
|
);
|
|
253
275
|
|
|
254
276
|
const addDocumentContext = useCallback(
|
|
255
|
-
(
|
|
277
|
+
(
|
|
278
|
+
documentPointer: DocumentPointer,
|
|
279
|
+
categories: string[] = defaultCopilotContextCategories,
|
|
280
|
+
) => {
|
|
256
281
|
return addDocument(documentPointer, categories);
|
|
257
282
|
},
|
|
258
283
|
[addDocument],
|
|
@@ -323,7 +348,10 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
323
348
|
return {
|
|
324
349
|
...(copilotApiConfig.headers || {}),
|
|
325
350
|
...(copilotApiConfig.publicApiKey
|
|
326
|
-
? {
|
|
351
|
+
? {
|
|
352
|
+
[COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]:
|
|
353
|
+
copilotApiConfig.publicApiKey,
|
|
354
|
+
}
|
|
327
355
|
: {}),
|
|
328
356
|
...authHeaders,
|
|
329
357
|
};
|
|
@@ -332,12 +360,15 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
332
360
|
const [internalErrorHandlers, _setInternalErrorHandler] = useState<
|
|
333
361
|
Record<string, CopilotErrorHandler>
|
|
334
362
|
>({});
|
|
335
|
-
const setInternalErrorHandler = useCallback(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
363
|
+
const setInternalErrorHandler = useCallback(
|
|
364
|
+
(handler: Record<string, CopilotErrorHandler>) => {
|
|
365
|
+
_setInternalErrorHandler((prev: Record<string, CopilotErrorHandler>) => ({
|
|
366
|
+
...prev,
|
|
367
|
+
...handler,
|
|
368
|
+
}));
|
|
369
|
+
},
|
|
370
|
+
[],
|
|
371
|
+
);
|
|
341
372
|
const removeInternalErrorHandler = useCallback((key: string) => {
|
|
342
373
|
_setInternalErrorHandler((prev) => {
|
|
343
374
|
const { [key]: _removed, ...rest } = prev;
|
|
@@ -377,9 +408,10 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
377
408
|
[copilotApiConfig.publicApiKey],
|
|
378
409
|
);
|
|
379
410
|
|
|
380
|
-
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] =
|
|
381
|
-
|
|
382
|
-
|
|
411
|
+
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] =
|
|
412
|
+
useState<{
|
|
413
|
+
[key: string]: CopilotChatSuggestionConfiguration;
|
|
414
|
+
}>({});
|
|
383
415
|
|
|
384
416
|
const addChatSuggestionConfiguration = useCallback(
|
|
385
417
|
(id: string, suggestion: CopilotChatSuggestionConfiguration) => {
|
|
@@ -399,15 +431,20 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
399
431
|
);
|
|
400
432
|
|
|
401
433
|
const [availableAgents, setAvailableAgents] = useState<Agent[]>([]);
|
|
402
|
-
const [coagentStates, setCoagentStates] = useState<
|
|
434
|
+
const [coagentStates, setCoagentStates] = useState<
|
|
435
|
+
Record<string, CoagentState>
|
|
436
|
+
>({});
|
|
403
437
|
const coagentStatesRef = useRef<Record<string, CoagentState>>({});
|
|
404
438
|
const setCoagentStatesWithRef = useCallback(
|
|
405
439
|
(
|
|
406
440
|
value:
|
|
407
441
|
| Record<string, CoagentState>
|
|
408
|
-
| ((
|
|
442
|
+
| ((
|
|
443
|
+
prev: Record<string, CoagentState>,
|
|
444
|
+
) => Record<string, CoagentState>),
|
|
409
445
|
) => {
|
|
410
|
-
const newValue =
|
|
446
|
+
const newValue =
|
|
447
|
+
typeof value === "function" ? value(coagentStatesRef.current) : value;
|
|
411
448
|
coagentStatesRef.current = newValue;
|
|
412
449
|
setCoagentStates((prev) => {
|
|
413
450
|
return newValue;
|
|
@@ -423,7 +460,9 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
423
460
|
};
|
|
424
461
|
}
|
|
425
462
|
|
|
426
|
-
const [agentSession, setAgentSession] = useState<AgentSession | null>(
|
|
463
|
+
const [agentSession, setAgentSession] = useState<AgentSession | null>(
|
|
464
|
+
initialAgentSession,
|
|
465
|
+
);
|
|
427
466
|
|
|
428
467
|
// Update agentSession when props.agent changes
|
|
429
468
|
useEffect(() => {
|
|
@@ -441,7 +480,9 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
441
480
|
const setThreadId = useCallback(
|
|
442
481
|
(value: SetStateAction<string>) => {
|
|
443
482
|
if (props.threadId) {
|
|
444
|
-
throw new Error(
|
|
483
|
+
throw new Error(
|
|
484
|
+
"Cannot call setThreadId() when threadId is provided via props.",
|
|
485
|
+
);
|
|
445
486
|
}
|
|
446
487
|
setInternalThreadId(value);
|
|
447
488
|
},
|
|
@@ -457,18 +498,24 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
457
498
|
const [interruptActions, _setInterruptActions] = useState<
|
|
458
499
|
Record<string, LangGraphInterruptRender>
|
|
459
500
|
>({});
|
|
460
|
-
const setInterruptAction = useCallback(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
501
|
+
const setInterruptAction = useCallback(
|
|
502
|
+
(action: LangGraphInterruptActionSetterArgs) => {
|
|
503
|
+
_setInterruptActions((prev) => {
|
|
504
|
+
if (action == null || !action.id) {
|
|
505
|
+
// Cannot set action without id
|
|
506
|
+
return prev;
|
|
507
|
+
}
|
|
508
|
+
return {
|
|
509
|
+
...prev,
|
|
510
|
+
[action.id]: {
|
|
511
|
+
...(prev[action.id] ?? {}),
|
|
512
|
+
...action,
|
|
513
|
+
} as LangGraphInterruptRender,
|
|
514
|
+
};
|
|
515
|
+
});
|
|
516
|
+
},
|
|
517
|
+
[],
|
|
518
|
+
);
|
|
472
519
|
const removeInterruptAction = useCallback((actionId: string): void => {
|
|
473
520
|
_setInterruptActions((prev) => {
|
|
474
521
|
const { [actionId]: _, ...rest } = prev;
|
|
@@ -520,8 +567,12 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
520
567
|
const updateExtensions = useCallback(
|
|
521
568
|
(newExtensions: SetStateAction<ExtensionsInput>) => {
|
|
522
569
|
setExtensions((prev: ExtensionsInput) => {
|
|
523
|
-
const resolved =
|
|
524
|
-
|
|
570
|
+
const resolved =
|
|
571
|
+
typeof newExtensions === "function"
|
|
572
|
+
? newExtensions(prev)
|
|
573
|
+
: newExtensions;
|
|
574
|
+
const isSameLength =
|
|
575
|
+
Object.keys(resolved).length === Object.keys(prev).length;
|
|
525
576
|
const isEqual =
|
|
526
577
|
isSameLength &&
|
|
527
578
|
// @ts-ignore
|
|
@@ -536,8 +587,12 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
536
587
|
const updateAuthStates = useCallback(
|
|
537
588
|
(newAuthStates: SetStateAction<Record<string, AuthState>>) => {
|
|
538
589
|
setAuthStates((prev) => {
|
|
539
|
-
const resolved =
|
|
540
|
-
|
|
590
|
+
const resolved =
|
|
591
|
+
typeof newAuthStates === "function"
|
|
592
|
+
? newAuthStates(prev)
|
|
593
|
+
: newAuthStates;
|
|
594
|
+
const isSameLength =
|
|
595
|
+
Object.keys(resolved).length === Object.keys(prev).length;
|
|
541
596
|
const isEqual =
|
|
542
597
|
isSameLength &&
|
|
543
598
|
// @ts-ignore
|
|
@@ -549,15 +604,18 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
549
604
|
[setAuthStates],
|
|
550
605
|
);
|
|
551
606
|
|
|
552
|
-
const handleSetRegisteredActions = useCallback(
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
607
|
+
const handleSetRegisteredActions = useCallback(
|
|
608
|
+
(actionConfig: any): string => {
|
|
609
|
+
const key = actionConfig.action.name || randomUUID();
|
|
610
|
+
setRegisteredActionConfigs((prev) => {
|
|
611
|
+
const newMap = new Map(prev);
|
|
612
|
+
newMap.set(key, actionConfig);
|
|
613
|
+
return newMap;
|
|
614
|
+
});
|
|
615
|
+
return key;
|
|
616
|
+
},
|
|
617
|
+
[],
|
|
618
|
+
);
|
|
561
619
|
|
|
562
620
|
const handleRemoveRegisteredAction = useCallback((actionKey: string) => {
|
|
563
621
|
setRegisteredActionConfigs((prev) => {
|
|
@@ -671,8 +729,16 @@ export function CopilotKitInternal(cpkProps: CopilotKitProps) {
|
|
|
671
729
|
|
|
672
730
|
export const defaultCopilotContextCategories = ["global"];
|
|
673
731
|
|
|
674
|
-
function entryPointsToFunctionCallHandler(
|
|
675
|
-
|
|
732
|
+
function entryPointsToFunctionCallHandler(
|
|
733
|
+
actions: FrontendAction<any>[],
|
|
734
|
+
): FunctionCallHandler {
|
|
735
|
+
return async ({
|
|
736
|
+
name,
|
|
737
|
+
args,
|
|
738
|
+
}: {
|
|
739
|
+
name: string;
|
|
740
|
+
args: Record<string, any>;
|
|
741
|
+
}) => {
|
|
676
742
|
let actionsByFunctionName: Record<string, FrontendAction<any>> = {};
|
|
677
743
|
for (let action of actions) {
|
|
678
744
|
actionsByFunctionName[action.name] = action;
|