@copilotkit/react-core 1.51.4 → 1.51.5-next.1
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/.attw.json +3 -0
- package/CHANGELOG.md +21 -0
- package/dist/index.cjs +4010 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1327 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +1327 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3944 -148
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +4075 -39
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/index.cjs +17 -0
- package/dist/v2/index.css +2 -3
- package/dist/v2/index.css.map +1 -1
- package/dist/v2/index.d.cts +2 -0
- package/dist/v2/index.d.mts +2 -0
- package/dist/v2/index.mjs +4 -5
- package/dist/v2/index.umd.js +24 -2
- package/package.json +22 -22
- package/src/components/copilot-provider/__tests__/copilotkit-error.test.tsx +3 -3
- package/src/hooks/__tests__/use-coagent-config.test.ts +23 -22
- package/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx +33 -35
- package/src/hooks/__tests__/use-coagent-state-render.test.tsx +19 -18
- package/src/hooks/__tests__/use-frontend-tool-available.test.tsx +72 -0
- package/src/hooks/__tests__/use-frontend-tool-remount.e2e.test.tsx +9 -7
- package/src/hooks/use-copilot-chat.ts +1 -1
- package/src/hooks/use-frontend-tool.ts +2 -1
- package/src/lib/copilot-task.ts +1 -1
- package/src/setupTests.ts +17 -16
- package/tsconfig.json +1 -1
- package/tsdown.config.ts +94 -0
- package/vitest.config.mjs +30 -0
- package/dist/chunk-2IDV5OHF.mjs +0 -11
- package/dist/chunk-2IDV5OHF.mjs.map +0 -1
- package/dist/chunk-2RSAYTXH.mjs +0 -137
- package/dist/chunk-2RSAYTXH.mjs.map +0 -1
- package/dist/chunk-36KQV2NA.mjs +0 -1
- package/dist/chunk-36KQV2NA.mjs.map +0 -1
- package/dist/chunk-3LZZ4RVM.mjs +0 -37
- package/dist/chunk-3LZZ4RVM.mjs.map +0 -1
- package/dist/chunk-4ZQYMC5F.mjs +0 -36
- package/dist/chunk-4ZQYMC5F.mjs.map +0 -1
- package/dist/chunk-6ABVYB2U.mjs +0 -95
- package/dist/chunk-6ABVYB2U.mjs.map +0 -1
- package/dist/chunk-6AWG5FWL.mjs +0 -102
- package/dist/chunk-6AWG5FWL.mjs.map +0 -1
- package/dist/chunk-6YOKPWQ7.mjs +0 -1
- package/dist/chunk-6YOKPWQ7.mjs.map +0 -1
- package/dist/chunk-7GIBHX6X.mjs +0 -195
- package/dist/chunk-7GIBHX6X.mjs.map +0 -1
- package/dist/chunk-7PJKPWMD.mjs +0 -112
- package/dist/chunk-7PJKPWMD.mjs.map +0 -1
- package/dist/chunk-7U3DNFBF.mjs +0 -20
- package/dist/chunk-7U3DNFBF.mjs.map +0 -1
- package/dist/chunk-A6NKSGH3.mjs +0 -1
- package/dist/chunk-A6NKSGH3.mjs.map +0 -1
- package/dist/chunk-AAGMWZCN.mjs +0 -439
- package/dist/chunk-AAGMWZCN.mjs.map +0 -1
- package/dist/chunk-C7HSVDHD.mjs +0 -116
- package/dist/chunk-C7HSVDHD.mjs.map +0 -1
- package/dist/chunk-CYDWEPFL.mjs +0 -1
- package/dist/chunk-CYDWEPFL.mjs.map +0 -1
- package/dist/chunk-CZT7JUIM.mjs +0 -153
- package/dist/chunk-CZT7JUIM.mjs.map +0 -1
- package/dist/chunk-DMLQZG75.mjs +0 -25
- package/dist/chunk-DMLQZG75.mjs.map +0 -1
- package/dist/chunk-FD6FGKYY.mjs +0 -1
- package/dist/chunk-FD6FGKYY.mjs.map +0 -1
- package/dist/chunk-G7SUZGGB.mjs +0 -126
- package/dist/chunk-G7SUZGGB.mjs.map +0 -1
- package/dist/chunk-GY3FQICF.mjs +0 -23
- package/dist/chunk-GY3FQICF.mjs.map +0 -1
- package/dist/chunk-I76HKHPJ.mjs +0 -32
- package/dist/chunk-I76HKHPJ.mjs.map +0 -1
- package/dist/chunk-ICIK2BSB.mjs +0 -17
- package/dist/chunk-ICIK2BSB.mjs.map +0 -1
- package/dist/chunk-IHMMKEFG.mjs +0 -64
- package/dist/chunk-IHMMKEFG.mjs.map +0 -1
- package/dist/chunk-JD7BAH7U.mjs +0 -1
- package/dist/chunk-JD7BAH7U.mjs.map +0 -1
- package/dist/chunk-K5OXUXCG.mjs +0 -76
- package/dist/chunk-K5OXUXCG.mjs.map +0 -1
- package/dist/chunk-L7GPCF2V.mjs +0 -229
- package/dist/chunk-L7GPCF2V.mjs.map +0 -1
- package/dist/chunk-LD34IXVT.mjs +0 -86
- package/dist/chunk-LD34IXVT.mjs.map +0 -1
- package/dist/chunk-LNGBARXE.mjs +0 -86
- package/dist/chunk-LNGBARXE.mjs.map +0 -1
- package/dist/chunk-LRPWSPXG.mjs +0 -628
- package/dist/chunk-LRPWSPXG.mjs.map +0 -1
- package/dist/chunk-LUGEI4YQ.mjs +0 -1
- package/dist/chunk-LUGEI4YQ.mjs.map +0 -1
- package/dist/chunk-MBJ7OLYI.mjs +0 -58
- package/dist/chunk-MBJ7OLYI.mjs.map +0 -1
- package/dist/chunk-NB2FKV2V.mjs +0 -1
- package/dist/chunk-NB2FKV2V.mjs.map +0 -1
- package/dist/chunk-O7ARI5CV.mjs +0 -31
- package/dist/chunk-O7ARI5CV.mjs.map +0 -1
- package/dist/chunk-P6ZPE4XJ.mjs +0 -86
- package/dist/chunk-P6ZPE4XJ.mjs.map +0 -1
- package/dist/chunk-QXZTCGF4.mjs +0 -163
- package/dist/chunk-QXZTCGF4.mjs.map +0 -1
- package/dist/chunk-R2DP4APC.mjs +0 -125
- package/dist/chunk-R2DP4APC.mjs.map +0 -1
- package/dist/chunk-R7BV32X4.mjs +0 -146
- package/dist/chunk-R7BV32X4.mjs.map +0 -1
- package/dist/chunk-SBRCWA4S.mjs +0 -913
- package/dist/chunk-SBRCWA4S.mjs.map +0 -1
- package/dist/chunk-SK2XMJUD.mjs +0 -42
- package/dist/chunk-SK2XMJUD.mjs.map +0 -1
- package/dist/chunk-SKC7AJIV.mjs +0 -61
- package/dist/chunk-SKC7AJIV.mjs.map +0 -1
- package/dist/chunk-SLM6CLAH.mjs +0 -195
- package/dist/chunk-SLM6CLAH.mjs.map +0 -1
- package/dist/chunk-SPCZTZCY.mjs +0 -1
- package/dist/chunk-SPCZTZCY.mjs.map +0 -1
- package/dist/chunk-SYGQHN3H.mjs +0 -27
- package/dist/chunk-SYGQHN3H.mjs.map +0 -1
- package/dist/chunk-SYMT73HM.mjs +0 -43
- package/dist/chunk-SYMT73HM.mjs.map +0 -1
- package/dist/chunk-TFZXOEY4.mjs +0 -61
- package/dist/chunk-TFZXOEY4.mjs.map +0 -1
- package/dist/chunk-TPN7WC53.mjs +0 -33
- package/dist/chunk-TPN7WC53.mjs.map +0 -1
- package/dist/chunk-UA23VX5J.mjs +0 -65
- package/dist/chunk-UA23VX5J.mjs.map +0 -1
- package/dist/chunk-V42VL2JR.mjs +0 -136
- package/dist/chunk-V42VL2JR.mjs.map +0 -1
- package/dist/chunk-VZ4NSOFQ.mjs +0 -80
- package/dist/chunk-VZ4NSOFQ.mjs.map +0 -1
- package/dist/chunk-WRALJIW5.mjs +0 -79
- package/dist/chunk-WRALJIW5.mjs.map +0 -1
- package/dist/chunk-WV2EA7SX.mjs +0 -65
- package/dist/chunk-WV2EA7SX.mjs.map +0 -1
- package/dist/chunk-Z6JV2LRY.mjs +0 -37
- package/dist/chunk-Z6JV2LRY.mjs.map +0 -1
- package/dist/chunk-ZP2IMXFY.mjs +0 -316
- package/dist/chunk-ZP2IMXFY.mjs.map +0 -1
- package/dist/chunk-ZVF5Q6IH.mjs +0 -29
- package/dist/chunk-ZVF5Q6IH.mjs.map +0 -1
- package/dist/components/CopilotListeners.d.ts +0 -3
- package/dist/components/CopilotListeners.js +0 -110
- package/dist/components/CopilotListeners.js.map +0 -1
- package/dist/components/CopilotListeners.mjs +0 -9
- package/dist/components/CopilotListeners.mjs.map +0 -1
- package/dist/components/copilot-provider/copilot-messages.d.ts +0 -24
- package/dist/components/copilot-provider/copilot-messages.js +0 -366
- package/dist/components/copilot-provider/copilot-messages.js.map +0 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +0 -16
- package/dist/components/copilot-provider/copilot-messages.mjs.map +0 -1
- package/dist/components/copilot-provider/copilotkit-props.d.ts +0 -180
- package/dist/components/copilot-provider/copilotkit-props.js +0 -19
- package/dist/components/copilot-provider/copilotkit-props.js.map +0 -1
- package/dist/components/copilot-provider/copilotkit-props.mjs +0 -1
- package/dist/components/copilot-provider/copilotkit-props.mjs.map +0 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +0 -19
- package/dist/components/copilot-provider/copilotkit.js +0 -2348
- package/dist/components/copilot-provider/copilotkit.js.map +0 -1
- package/dist/components/copilot-provider/copilotkit.mjs +0 -33
- package/dist/components/copilot-provider/copilotkit.mjs.map +0 -1
- package/dist/components/copilot-provider/index.d.ts +0 -14
- package/dist/components/copilot-provider/index.js +0 -2348
- package/dist/components/copilot-provider/index.js.map +0 -1
- package/dist/components/copilot-provider/index.mjs +0 -32
- package/dist/components/copilot-provider/index.mjs.map +0 -1
- package/dist/components/dev-console/console-trigger.d.ts +0 -8
- package/dist/components/dev-console/console-trigger.js +0 -1387
- package/dist/components/dev-console/console-trigger.js.map +0 -1
- package/dist/components/dev-console/console-trigger.mjs +0 -249
- package/dist/components/dev-console/console-trigger.mjs.map +0 -1
- package/dist/components/dev-console/developer-console-modal.d.ts +0 -10
- package/dist/components/dev-console/developer-console-modal.js +0 -1156
- package/dist/components/dev-console/developer-console-modal.js.map +0 -1
- package/dist/components/dev-console/developer-console-modal.mjs +0 -12
- package/dist/components/dev-console/developer-console-modal.mjs.map +0 -1
- package/dist/components/dev-console/icons.d.ts +0 -9
- package/dist/components/dev-console/icons.js +0 -140
- package/dist/components/dev-console/icons.js.map +0 -1
- package/dist/components/dev-console/icons.mjs +0 -16
- package/dist/components/dev-console/icons.mjs.map +0 -1
- package/dist/components/error-boundary/error-boundary.d.ts +0 -31
- package/dist/components/error-boundary/error-boundary.js +0 -507
- package/dist/components/error-boundary/error-boundary.js.map +0 -1
- package/dist/components/error-boundary/error-boundary.mjs +0 -15
- package/dist/components/error-boundary/error-boundary.mjs.map +0 -1
- package/dist/components/error-boundary/error-utils.d.ts +0 -11
- package/dist/components/error-boundary/error-utils.js +0 -190
- package/dist/components/error-boundary/error-utils.js.map +0 -1
- package/dist/components/error-boundary/error-utils.mjs +0 -14
- package/dist/components/error-boundary/error-utils.mjs.map +0 -1
- package/dist/components/index.d.ts +0 -14
- package/dist/components/index.js +0 -2348
- package/dist/components/index.js.map +0 -1
- package/dist/components/index.mjs +0 -33
- package/dist/components/index.mjs.map +0 -1
- package/dist/components/toast/exclamation-mark-icon.d.ts +0 -9
- package/dist/components/toast/exclamation-mark-icon.js +0 -55
- package/dist/components/toast/exclamation-mark-icon.js.map +0 -1
- package/dist/components/toast/exclamation-mark-icon.mjs +0 -8
- package/dist/components/toast/exclamation-mark-icon.mjs.map +0 -1
- package/dist/components/toast/toast-provider.d.ts +0 -27
- package/dist/components/toast/toast-provider.js +0 -353
- package/dist/components/toast/toast-provider.js.map +0 -1
- package/dist/components/toast/toast-provider.mjs +0 -10
- package/dist/components/toast/toast-provider.mjs.map +0 -1
- package/dist/components/usage-banner.d.ts +0 -29
- package/dist/components/usage-banner.js +0 -251
- package/dist/components/usage-banner.js.map +0 -1
- package/dist/components/usage-banner.mjs +0 -12
- package/dist/components/usage-banner.mjs.map +0 -1
- package/dist/context/coagent-state-renders-context.d.ts +0 -25
- package/dist/context/coagent-state-renders-context.js +0 -96
- package/dist/context/coagent-state-renders-context.js.map +0 -1
- package/dist/context/coagent-state-renders-context.mjs +0 -12
- package/dist/context/coagent-state-renders-context.mjs.map +0 -1
- package/dist/context/copilot-context.d.ts +0 -10
- package/dist/context/copilot-context.js +0 -167
- package/dist/context/copilot-context.js.map +0 -1
- package/dist/context/copilot-context.mjs +0 -10
- package/dist/context/copilot-context.mjs.map +0 -1
- package/dist/context/copilot-messages-context.d.ts +0 -18
- package/dist/context/copilot-messages-context.js +0 -60
- package/dist/context/copilot-messages-context.js.map +0 -1
- package/dist/context/copilot-messages-context.mjs +0 -10
- package/dist/context/copilot-messages-context.mjs.map +0 -1
- package/dist/context/index.d.ts +0 -15
- package/dist/context/index.js +0 -301
- package/dist/context/index.js.map +0 -1
- package/dist/context/index.mjs +0 -33
- package/dist/context/index.mjs.map +0 -1
- package/dist/context/threads-context.d.ts +0 -16
- package/dist/context/threads-context.js +0 -64
- package/dist/context/threads-context.js.map +0 -1
- package/dist/context/threads-context.mjs +0 -12
- package/dist/context/threads-context.mjs.map +0 -1
- package/dist/copilot-context-ec77e921.d.ts +0 -209
- package/dist/hooks/index.d.ts +0 -33
- package/dist/hooks/index.js +0 -2190
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/index.mjs +0 -93
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/hooks/use-agent-nodename.d.ts +0 -3
- package/dist/hooks/use-agent-nodename.js +0 -56
- package/dist/hooks/use-agent-nodename.js.map +0 -1
- package/dist/hooks/use-agent-nodename.mjs +0 -8
- package/dist/hooks/use-agent-nodename.mjs.map +0 -1
- package/dist/hooks/use-coagent-state-render-bridge.d.ts +0 -100
- package/dist/hooks/use-coagent-state-render-bridge.helpers.d.ts +0 -92
- package/dist/hooks/use-coagent-state-render-bridge.helpers.js +0 -237
- package/dist/hooks/use-coagent-state-render-bridge.helpers.js.map +0 -1
- package/dist/hooks/use-coagent-state-render-bridge.helpers.mjs +0 -24
- package/dist/hooks/use-coagent-state-render-bridge.helpers.mjs.map +0 -1
- package/dist/hooks/use-coagent-state-render-bridge.js +0 -498
- package/dist/hooks/use-coagent-state-render-bridge.js.map +0 -1
- package/dist/hooks/use-coagent-state-render-bridge.mjs +0 -17
- package/dist/hooks/use-coagent-state-render-bridge.mjs.map +0 -1
- package/dist/hooks/use-coagent-state-render-registry.d.ts +0 -25
- package/dist/hooks/use-coagent-state-render-registry.js +0 -369
- package/dist/hooks/use-coagent-state-render-registry.js.map +0 -1
- package/dist/hooks/use-coagent-state-render-registry.mjs +0 -9
- package/dist/hooks/use-coagent-state-render-registry.mjs.map +0 -1
- package/dist/hooks/use-coagent-state-render.d.ts +0 -55
- package/dist/hooks/use-coagent-state-render.js +0 -268
- package/dist/hooks/use-coagent-state-render.js.map +0 -1
- package/dist/hooks/use-coagent-state-render.mjs +0 -11
- package/dist/hooks/use-coagent-state-render.mjs.map +0 -1
- package/dist/hooks/use-coagent.d.ts +0 -192
- package/dist/hooks/use-coagent.js +0 -235
- package/dist/hooks/use-coagent.js.map +0 -1
- package/dist/hooks/use-coagent.mjs +0 -9
- package/dist/hooks/use-coagent.mjs.map +0 -1
- package/dist/hooks/use-configure-chat-suggestions.d.ts +0 -36
- package/dist/hooks/use-configure-chat-suggestions.js +0 -79
- package/dist/hooks/use-configure-chat-suggestions.js.map +0 -1
- package/dist/hooks/use-configure-chat-suggestions.mjs +0 -47
- package/dist/hooks/use-configure-chat-suggestions.mjs.map +0 -1
- package/dist/hooks/use-copilot-action.d.ts +0 -103
- package/dist/hooks/use-copilot-action.js +0 -302
- package/dist/hooks/use-copilot-action.js.map +0 -1
- package/dist/hooks/use-copilot-action.mjs +0 -11
- package/dist/hooks/use-copilot-action.mjs.map +0 -1
- package/dist/hooks/use-copilot-additional-instructions.d.ts +0 -26
- package/dist/hooks/use-copilot-additional-instructions.js +0 -196
- package/dist/hooks/use-copilot-additional-instructions.js.map +0 -1
- package/dist/hooks/use-copilot-additional-instructions.mjs +0 -9
- package/dist/hooks/use-copilot-additional-instructions.mjs.map +0 -1
- package/dist/hooks/use-copilot-authenticated-action.d.ts +0 -18
- package/dist/hooks/use-copilot-authenticated-action.js +0 -477
- package/dist/hooks/use-copilot-authenticated-action.js.map +0 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +0 -13
- package/dist/hooks/use-copilot-authenticated-action.mjs.map +0 -1
- package/dist/hooks/use-copilot-chat-headless_c.d.ts +0 -25
- package/dist/hooks/use-copilot-chat-headless_c.js +0 -1410
- package/dist/hooks/use-copilot-chat-headless_c.js.map +0 -1
- package/dist/hooks/use-copilot-chat-headless_c.mjs +0 -26
- package/dist/hooks/use-copilot-chat-headless_c.mjs.map +0 -1
- package/dist/hooks/use-copilot-chat-suggestions.d.ts +0 -35
- package/dist/hooks/use-copilot-chat-suggestions.js +0 -60
- package/dist/hooks/use-copilot-chat-suggestions.js.map +0 -1
- package/dist/hooks/use-copilot-chat-suggestions.mjs +0 -8
- package/dist/hooks/use-copilot-chat-suggestions.mjs.map +0 -1
- package/dist/hooks/use-copilot-chat.d.ts +0 -92
- package/dist/hooks/use-copilot-chat.js +0 -1344
- package/dist/hooks/use-copilot-chat.js.map +0 -1
- package/dist/hooks/use-copilot-chat.mjs +0 -23
- package/dist/hooks/use-copilot-chat.mjs.map +0 -1
- package/dist/hooks/use-copilot-chat_internal.d.ts +0 -244
- package/dist/hooks/use-copilot-chat_internal.js +0 -1342
- package/dist/hooks/use-copilot-chat_internal.js.map +0 -1
- package/dist/hooks/use-copilot-chat_internal.mjs +0 -24
- package/dist/hooks/use-copilot-chat_internal.mjs.map +0 -1
- package/dist/hooks/use-copilot-readable.d.ts +0 -37
- package/dist/hooks/use-copilot-readable.js +0 -61
- package/dist/hooks/use-copilot-readable.js.map +0 -1
- package/dist/hooks/use-copilot-readable.mjs +0 -8
- package/dist/hooks/use-copilot-readable.mjs.map +0 -1
- package/dist/hooks/use-copilot-runtime-client.d.ts +0 -10
- package/dist/hooks/use-copilot-runtime-client.js +0 -206
- package/dist/hooks/use-copilot-runtime-client.js.map +0 -1
- package/dist/hooks/use-copilot-runtime-client.mjs +0 -9
- package/dist/hooks/use-copilot-runtime-client.mjs.map +0 -1
- package/dist/hooks/use-default-tool.d.ts +0 -8
- package/dist/hooks/use-default-tool.js +0 -312
- package/dist/hooks/use-default-tool.js.map +0 -1
- package/dist/hooks/use-default-tool.mjs +0 -12
- package/dist/hooks/use-default-tool.mjs.map +0 -1
- package/dist/hooks/use-flat-category-store.d.ts +0 -9
- package/dist/hooks/use-flat-category-store.js +0 -96
- package/dist/hooks/use-flat-category-store.js.map +0 -1
- package/dist/hooks/use-flat-category-store.mjs +0 -8
- package/dist/hooks/use-flat-category-store.mjs.map +0 -1
- package/dist/hooks/use-frontend-tool.d.ts +0 -11
- package/dist/hooks/use-frontend-tool.js +0 -107
- package/dist/hooks/use-frontend-tool.js.map +0 -1
- package/dist/hooks/use-frontend-tool.mjs +0 -8
- package/dist/hooks/use-frontend-tool.mjs.map +0 -1
- package/dist/hooks/use-human-in-the-loop.d.ts +0 -13
- package/dist/hooks/use-human-in-the-loop.js +0 -122
- package/dist/hooks/use-human-in-the-loop.js.map +0 -1
- package/dist/hooks/use-human-in-the-loop.mjs +0 -8
- package/dist/hooks/use-human-in-the-loop.mjs.map +0 -1
- package/dist/hooks/use-langgraph-interrupt-render.d.ts +0 -6
- package/dist/hooks/use-langgraph-interrupt-render.js +0 -335
- package/dist/hooks/use-langgraph-interrupt-render.js.map +0 -1
- package/dist/hooks/use-langgraph-interrupt-render.mjs +0 -14
- package/dist/hooks/use-langgraph-interrupt-render.mjs.map +0 -1
- package/dist/hooks/use-langgraph-interrupt.d.ts +0 -14
- package/dist/hooks/use-langgraph-interrupt.js +0 -216
- package/dist/hooks/use-langgraph-interrupt.js.map +0 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +0 -10
- package/dist/hooks/use-langgraph-interrupt.mjs.map +0 -1
- package/dist/hooks/use-lazy-tool-renderer.d.ts +0 -6
- package/dist/hooks/use-lazy-tool-renderer.js +0 -53
- package/dist/hooks/use-lazy-tool-renderer.js.map +0 -1
- package/dist/hooks/use-lazy-tool-renderer.mjs +0 -8
- package/dist/hooks/use-lazy-tool-renderer.mjs.map +0 -1
- package/dist/hooks/use-make-copilot-document-readable.d.ts +0 -12
- package/dist/hooks/use-make-copilot-document-readable.js +0 -182
- package/dist/hooks/use-make-copilot-document-readable.js.map +0 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +0 -9
- package/dist/hooks/use-make-copilot-document-readable.mjs.map +0 -1
- package/dist/hooks/use-render-tool-call.d.ts +0 -12
- package/dist/hooks/use-render-tool-call.js +0 -94
- package/dist/hooks/use-render-tool-call.js.map +0 -1
- package/dist/hooks/use-render-tool-call.mjs +0 -8
- package/dist/hooks/use-render-tool-call.mjs.map +0 -1
- package/dist/hooks/use-tree.d.ts +0 -19
- package/dist/hooks/use-tree.js +0 -178
- package/dist/hooks/use-tree.js.map +0 -1
- package/dist/hooks/use-tree.mjs +0 -8
- package/dist/hooks/use-tree.mjs.map +0 -1
- package/dist/index.d.ts +0 -43
- package/dist/index.js +0 -4064
- package/dist/index.js.map +0 -1
- package/dist/lib/copilot-task.d.ts +0 -97
- package/dist/lib/copilot-task.js +0 -201
- package/dist/lib/copilot-task.js.map +0 -1
- package/dist/lib/copilot-task.mjs +0 -33
- package/dist/lib/copilot-task.mjs.map +0 -1
- package/dist/lib/index.d.ts +0 -11
- package/dist/lib/index.js +0 -203
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/index.mjs +0 -34
- package/dist/lib/index.mjs.map +0 -1
- package/dist/lib/status-checker.d.ts +0 -17
- package/dist/lib/status-checker.js +0 -102
- package/dist/lib/status-checker.js.map +0 -1
- package/dist/lib/status-checker.mjs +0 -8
- package/dist/lib/status-checker.mjs.map +0 -1
- package/dist/setupTests.d.ts +0 -2
- package/dist/setupTests.js +0 -31
- package/dist/setupTests.js.map +0 -1
- package/dist/setupTests.mjs +0 -29
- package/dist/setupTests.mjs.map +0 -1
- package/dist/test-helpers/copilot-context.d.ts +0 -14
- package/dist/test-helpers/copilot-context.js +0 -128
- package/dist/test-helpers/copilot-context.js.map +0 -1
- package/dist/test-helpers/copilot-context.mjs +0 -74
- package/dist/test-helpers/copilot-context.mjs.map +0 -1
- package/dist/types/chat-suggestion-configuration.d.ts +0 -22
- package/dist/types/chat-suggestion-configuration.js +0 -19
- package/dist/types/chat-suggestion-configuration.js.map +0 -1
- package/dist/types/chat-suggestion-configuration.mjs +0 -1
- package/dist/types/chat-suggestion-configuration.mjs.map +0 -1
- package/dist/types/coagent-action.d.ts +0 -29
- package/dist/types/coagent-action.js +0 -19
- package/dist/types/coagent-action.js.map +0 -1
- package/dist/types/coagent-action.mjs +0 -1
- package/dist/types/coagent-action.mjs.map +0 -1
- package/dist/types/coagent-state.d.ts +0 -15
- package/dist/types/coagent-state.js +0 -19
- package/dist/types/coagent-state.js.map +0 -1
- package/dist/types/coagent-state.mjs +0 -1
- package/dist/types/coagent-state.mjs.map +0 -1
- package/dist/types/crew.d.ts +0 -79
- package/dist/types/crew.js +0 -19
- package/dist/types/crew.js.map +0 -1
- package/dist/types/crew.mjs +0 -2
- package/dist/types/crew.mjs.map +0 -1
- package/dist/types/document-pointer.d.ts +0 -9
- package/dist/types/document-pointer.js +0 -19
- package/dist/types/document-pointer.js.map +0 -1
- package/dist/types/document-pointer.mjs +0 -1
- package/dist/types/document-pointer.mjs.map +0 -1
- package/dist/types/frontend-action.d.ts +0 -127
- package/dist/types/frontend-action.js +0 -55
- package/dist/types/frontend-action.js.map +0 -1
- package/dist/types/frontend-action.mjs +0 -8
- package/dist/types/frontend-action.mjs.map +0 -1
- package/dist/types/index.d.ts +0 -12
- package/dist/types/index.js +0 -19
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -4
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/interrupt-action.d.ts +0 -10
- package/dist/types/interrupt-action.js +0 -19
- package/dist/types/interrupt-action.js.map +0 -1
- package/dist/types/interrupt-action.mjs +0 -2
- package/dist/types/interrupt-action.mjs.map +0 -1
- package/dist/types/system-message.d.ts +0 -3
- package/dist/types/system-message.js +0 -19
- package/dist/types/system-message.js.map +0 -1
- package/dist/types/system-message.mjs +0 -1
- package/dist/types/system-message.mjs.map +0 -1
- package/dist/utils/dev-console.d.ts +0 -3
- package/dist/utils/dev-console.js +0 -41
- package/dist/utils/dev-console.js.map +0 -1
- package/dist/utils/dev-console.mjs +0 -8
- package/dist/utils/dev-console.mjs.map +0 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -52
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/index.mjs +0 -13
- package/dist/utils/index.mjs.map +0 -1
- package/dist/utils/suggestions-constants.d.ts +0 -9
- package/dist/utils/suggestions-constants.js +0 -35
- package/dist/utils/suggestions-constants.js.map +0 -1
- package/dist/utils/suggestions-constants.mjs +0 -8
- package/dist/utils/suggestions-constants.mjs.map +0 -1
- package/dist/utils/utils.d.ts +0 -2
- package/dist/utils/utils.js +0 -19
- package/dist/utils/utils.js.map +0 -1
- package/dist/utils/utils.mjs +0 -1
- package/dist/utils/utils.mjs.map +0 -1
- package/dist/v2/index.d.ts +0 -2
- package/dist/v2/index.js +0 -27
- package/dist/v2/index.js.map +0 -1
- package/dist/v2/index.mjs.map +0 -1
- package/dist/v2/index.umd.js.map +0 -1
- package/jest.config.js +0 -26
- package/rollup.config.mjs +0 -92
- package/src/__mocks__/analytics-node.js +0 -9
- package/tsup.config.ts +0 -16
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* **Open Source Friendly** - Works without requiring a free public license key.
|
|
6
6
|
*
|
|
7
7
|
* <Callout title="Looking for fully headless UI?">
|
|
8
|
-
* Get started with [useCopilotChatHeadless_c](https://docs.copilotkit.ai/reference/hooks/useCopilotChatHeadless_c).
|
|
8
|
+
* Get started with [useCopilotChatHeadless_c](https://docs.copilotkit.ai/reference/v1/hooks/useCopilotChatHeadless_c).
|
|
9
9
|
* </Callout>
|
|
10
10
|
*
|
|
11
11
|
* ## Use Cases
|
|
@@ -46,7 +46,7 @@ export function useFrontendTool<const T extends Parameter[] = []>(
|
|
|
46
46
|
tool: UseFrontendToolArgs<T>,
|
|
47
47
|
dependencies?: any[],
|
|
48
48
|
) {
|
|
49
|
-
const { name, description, parameters, render, followUp } = tool;
|
|
49
|
+
const { name, description, parameters, render, followUp, available } = tool;
|
|
50
50
|
const zodParameters = getZodParameters(parameters);
|
|
51
51
|
|
|
52
52
|
const renderRef = useRef<typeof render>(render);
|
|
@@ -108,5 +108,6 @@ export function useFrontendTool<const T extends Parameter[] = []>(
|
|
|
108
108
|
handler: normalizedHandler,
|
|
109
109
|
followUp,
|
|
110
110
|
render: normalizedRender,
|
|
111
|
+
available: available === undefined ? undefined : available !== "disabled",
|
|
111
112
|
});
|
|
112
113
|
}
|
package/src/lib/copilot-task.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This class is used to execute one-off tasks, for example on button press. It can use the context available via [useCopilotReadable](/reference/hooks/useCopilotReadable) and the actions provided by [useCopilotAction](/reference/hooks/useCopilotAction), or you can provide your own context and actions.
|
|
2
|
+
* This class is used to execute one-off tasks, for example on button press. It can use the context available via [useCopilotReadable](/reference/v1/hooks/useCopilotReadable) and the actions provided by [useCopilotAction](/reference/v1/hooks/useCopilotAction), or you can provide your own context and actions.
|
|
3
3
|
*
|
|
4
4
|
* ## Example
|
|
5
5
|
* In the simplest case, use CopilotTask in the context of your app by giving it instructions on what to do.
|
package/src/setupTests.ts
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
+
import { vi } from "vitest";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
|
|
3
4
|
// Mock modules that cause ES module issues
|
|
4
|
-
|
|
5
|
-
Analytics:
|
|
6
|
-
track:
|
|
7
|
-
identify:
|
|
8
|
-
page:
|
|
9
|
-
group:
|
|
10
|
-
alias:
|
|
5
|
+
vi.mock("@segment/analytics-node", () => ({
|
|
6
|
+
Analytics: vi.fn().mockImplementation(() => ({
|
|
7
|
+
track: vi.fn(),
|
|
8
|
+
identify: vi.fn(),
|
|
9
|
+
page: vi.fn(),
|
|
10
|
+
group: vi.fn(),
|
|
11
|
+
alias: vi.fn(),
|
|
11
12
|
})),
|
|
12
13
|
}));
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
parseJson:
|
|
15
|
+
vi.mock("@copilotkit/shared", () => ({
|
|
16
|
+
parseJson: vi.fn((jsonString, defaultValue) => {
|
|
16
17
|
try {
|
|
17
18
|
return JSON.parse(jsonString);
|
|
18
19
|
} catch {
|
|
19
20
|
return defaultValue;
|
|
20
21
|
}
|
|
21
22
|
}),
|
|
22
|
-
dataToUUID:
|
|
23
|
-
getZodParameters:
|
|
24
|
-
randomId:
|
|
25
|
-
CopilotKitAgentDiscoveryError:
|
|
26
|
-
randomUUID:
|
|
23
|
+
dataToUUID: vi.fn((data) => JSON.stringify(data)),
|
|
24
|
+
getZodParameters: vi.fn(() => z.object({})),
|
|
25
|
+
randomId: vi.fn(() => "test-random-id"),
|
|
26
|
+
CopilotKitAgentDiscoveryError: vi.fn(),
|
|
27
|
+
randomUUID: vi.fn(() => "mock-thread-id"),
|
|
27
28
|
}));
|
|
28
29
|
|
|
29
30
|
// Mock react-dom/test-utils to avoid compatibility issues
|
|
30
|
-
|
|
31
|
-
act:
|
|
31
|
+
vi.mock("react-dom/test-utils", () => ({
|
|
32
|
+
act: vi.fn((fn) => fn()),
|
|
32
33
|
}));
|
package/tsconfig.json
CHANGED
package/tsdown.config.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { defineConfig } from "tsdown";
|
|
2
|
+
|
|
3
|
+
export default defineConfig([
|
|
4
|
+
{
|
|
5
|
+
entry: ["src/index.tsx", "src/v2/index.ts"],
|
|
6
|
+
format: ["esm", "cjs"],
|
|
7
|
+
dts: true,
|
|
8
|
+
sourcemap: true,
|
|
9
|
+
target: "es2022",
|
|
10
|
+
outDir: "dist",
|
|
11
|
+
external: [
|
|
12
|
+
"react",
|
|
13
|
+
"react-dom",
|
|
14
|
+
"@copilotkitnext/core",
|
|
15
|
+
"@copilotkitnext/react",
|
|
16
|
+
],
|
|
17
|
+
exports: {
|
|
18
|
+
customExports: (exports) => ({
|
|
19
|
+
...exports,
|
|
20
|
+
"./v2/styles.css": "./dist/v2/index.css",
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
entry: ["src/index.tsx"],
|
|
26
|
+
format: ["umd"],
|
|
27
|
+
globalName: "CopilotKitReactCore",
|
|
28
|
+
sourcemap: true,
|
|
29
|
+
target: "es2018",
|
|
30
|
+
outDir: "dist",
|
|
31
|
+
external: [
|
|
32
|
+
"react",
|
|
33
|
+
"react-dom",
|
|
34
|
+
"@copilotkit/shared",
|
|
35
|
+
"@copilotkit/runtime-client-gql",
|
|
36
|
+
"@copilotkitnext/core",
|
|
37
|
+
"@copilotkitnext/react",
|
|
38
|
+
"@ag-ui/client",
|
|
39
|
+
"zod",
|
|
40
|
+
],
|
|
41
|
+
codeSplitting: false,
|
|
42
|
+
outputOptions(options) {
|
|
43
|
+
options.entryFileNames = "[name].umd.js";
|
|
44
|
+
options.globals = {
|
|
45
|
+
react: "React",
|
|
46
|
+
"react-dom": "ReactDOM",
|
|
47
|
+
"react/jsx-runtime": "ReactJsxRuntime",
|
|
48
|
+
"@copilotkit/shared": "CopilotKitShared",
|
|
49
|
+
"@copilotkit/runtime-client-gql": "CopilotKitRuntimeClientGQL",
|
|
50
|
+
"@copilotkitnext/core": "CopilotKitNextCore",
|
|
51
|
+
"@copilotkitnext/react": "CopilotKitNextReact",
|
|
52
|
+
"@ag-ui/client": "AgUIClient",
|
|
53
|
+
"react-markdown": "ReactMarkdown",
|
|
54
|
+
zod: "Zod",
|
|
55
|
+
};
|
|
56
|
+
return options;
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
entry: ["src/v2/index.ts"],
|
|
61
|
+
format: ["umd"],
|
|
62
|
+
globalName: "CopilotKitReactCoreV2",
|
|
63
|
+
sourcemap: true,
|
|
64
|
+
target: "es2018",
|
|
65
|
+
outDir: "dist/v2",
|
|
66
|
+
external: [
|
|
67
|
+
"react",
|
|
68
|
+
"react-dom",
|
|
69
|
+
"@copilotkit/shared",
|
|
70
|
+
"@copilotkit/runtime-client-gql",
|
|
71
|
+
"@copilotkitnext/core",
|
|
72
|
+
"@copilotkitnext/react",
|
|
73
|
+
"@ag-ui/client",
|
|
74
|
+
"zod",
|
|
75
|
+
],
|
|
76
|
+
codeSplitting: false,
|
|
77
|
+
outputOptions(options) {
|
|
78
|
+
options.entryFileNames = "[name].umd.js";
|
|
79
|
+
options.globals = {
|
|
80
|
+
react: "React",
|
|
81
|
+
"react-dom": "ReactDOM",
|
|
82
|
+
"react/jsx-runtime": "ReactJsxRuntime",
|
|
83
|
+
"@copilotkit/shared": "CopilotKitShared",
|
|
84
|
+
"@copilotkit/runtime-client-gql": "CopilotKitRuntimeClientGQL",
|
|
85
|
+
"@copilotkitnext/core": "CopilotKitNextCore",
|
|
86
|
+
"@copilotkitnext/react": "CopilotKitNextReact",
|
|
87
|
+
"@ag-ui/client": "AgUIClient",
|
|
88
|
+
"react-markdown": "ReactMarkdown",
|
|
89
|
+
zod: "Zod",
|
|
90
|
+
};
|
|
91
|
+
return options;
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
environment: "jsdom",
|
|
6
|
+
globals: true,
|
|
7
|
+
include: [
|
|
8
|
+
"src/**/__tests__/**/*.{test,spec}.{ts,tsx}",
|
|
9
|
+
"src/**/*.{test,spec}.{ts,tsx}",
|
|
10
|
+
],
|
|
11
|
+
setupFiles: ["./src/setupTests.ts"],
|
|
12
|
+
reporters: [["default", { summary: false }]],
|
|
13
|
+
silent: true,
|
|
14
|
+
server: {
|
|
15
|
+
deps: {
|
|
16
|
+
inline: ["react-markdown", "streamdown", "@copilotkitnext"],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
css: {
|
|
20
|
+
modules: {
|
|
21
|
+
classNameStrategy: "non-scoped",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
resolve: {
|
|
26
|
+
alias: {
|
|
27
|
+
"@": new URL("./src", import.meta.url).pathname,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
package/dist/chunk-2IDV5OHF.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/suggestions-constants.ts"],"sourcesContent":["/**\n * Constants for suggestions retry logic\n */\n\nexport const SUGGESTION_RETRY_CONFIG = {\n MAX_RETRIES: 3,\n COOLDOWN_MS: 5000, // 5 seconds\n} as const;\n"],"mappings":";AAIO,IAAM,0BAA0B;AAAA,EACrC,aAAa;AAAA,EACb,aAAa;AAAA;AACf;","names":[]}
|
package/dist/chunk-2RSAYTXH.mjs
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useToast
|
|
3
|
-
} from "./chunk-ZP2IMXFY.mjs";
|
|
4
|
-
import {
|
|
5
|
-
__async,
|
|
6
|
-
__objRest,
|
|
7
|
-
__spreadProps,
|
|
8
|
-
__spreadValues
|
|
9
|
-
} from "./chunk-SKC7AJIV.mjs";
|
|
10
|
-
|
|
11
|
-
// src/hooks/use-copilot-runtime-client.ts
|
|
12
|
-
import {
|
|
13
|
-
CopilotRuntimeClient
|
|
14
|
-
} from "@copilotkit/runtime-client-gql";
|
|
15
|
-
import { useMemo, useRef } from "react";
|
|
16
|
-
import {
|
|
17
|
-
ErrorVisibility,
|
|
18
|
-
CopilotKitApiDiscoveryError,
|
|
19
|
-
CopilotKitRemoteEndpointDiscoveryError,
|
|
20
|
-
CopilotKitAgentDiscoveryError,
|
|
21
|
-
CopilotKitError,
|
|
22
|
-
CopilotKitErrorCode
|
|
23
|
-
} from "@copilotkit/shared";
|
|
24
|
-
var useCopilotRuntimeClient = (options) => {
|
|
25
|
-
const { setBannerError } = useToast();
|
|
26
|
-
const _a = options, { showDevConsole, onError } = _a, runtimeOptions = __objRest(_a, ["showDevConsole", "onError"]);
|
|
27
|
-
const lastStructuredErrorRef = useRef(null);
|
|
28
|
-
const traceUIError = (error, originalError) => __async(void 0, null, function* () {
|
|
29
|
-
try {
|
|
30
|
-
const errorEvent = {
|
|
31
|
-
type: "error",
|
|
32
|
-
timestamp: Date.now(),
|
|
33
|
-
context: {
|
|
34
|
-
source: "ui",
|
|
35
|
-
request: {
|
|
36
|
-
operation: "runtimeClient",
|
|
37
|
-
url: runtimeOptions.url,
|
|
38
|
-
startTime: Date.now()
|
|
39
|
-
},
|
|
40
|
-
technical: {
|
|
41
|
-
environment: "browser",
|
|
42
|
-
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
43
|
-
stackTrace: originalError instanceof Error ? originalError.stack : void 0
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
error
|
|
47
|
-
};
|
|
48
|
-
yield onError(errorEvent);
|
|
49
|
-
} catch (error2) {
|
|
50
|
-
console.error("Error in onError handler:", error2);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
const runtimeClient = useMemo(() => {
|
|
54
|
-
return new CopilotRuntimeClient(__spreadProps(__spreadValues({}, runtimeOptions), {
|
|
55
|
-
handleGQLErrors: (error) => {
|
|
56
|
-
var _a2;
|
|
57
|
-
if ((_a2 = error.graphQLErrors) == null ? void 0 : _a2.length) {
|
|
58
|
-
const graphQLErrors = error.graphQLErrors;
|
|
59
|
-
const routeError = (gqlError) => {
|
|
60
|
-
const extensions = gqlError.extensions;
|
|
61
|
-
const visibility = extensions == null ? void 0 : extensions.visibility;
|
|
62
|
-
if (visibility === ErrorVisibility.SILENT) {
|
|
63
|
-
console.error("CopilotKit Silent Error:", gqlError.message);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const now = Date.now();
|
|
67
|
-
const errorMessage = gqlError.message;
|
|
68
|
-
if (lastStructuredErrorRef.current && lastStructuredErrorRef.current.message === errorMessage && now - lastStructuredErrorRef.current.timestamp < 150) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
lastStructuredErrorRef.current = {
|
|
72
|
-
message: errorMessage,
|
|
73
|
-
timestamp: now
|
|
74
|
-
};
|
|
75
|
-
const ckError = createStructuredError(gqlError);
|
|
76
|
-
if (ckError) {
|
|
77
|
-
setBannerError(ckError);
|
|
78
|
-
traceUIError(ckError, gqlError);
|
|
79
|
-
} else {
|
|
80
|
-
const fallbackError = new CopilotKitError({
|
|
81
|
-
message: gqlError.message,
|
|
82
|
-
code: CopilotKitErrorCode.UNKNOWN
|
|
83
|
-
});
|
|
84
|
-
setBannerError(fallbackError);
|
|
85
|
-
traceUIError(fallbackError, gqlError);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
graphQLErrors.forEach(routeError);
|
|
89
|
-
} else {
|
|
90
|
-
const fallbackError = new CopilotKitError({
|
|
91
|
-
message: (error == null ? void 0 : error.message) || String(error),
|
|
92
|
-
code: CopilotKitErrorCode.UNKNOWN
|
|
93
|
-
});
|
|
94
|
-
setBannerError(fallbackError);
|
|
95
|
-
traceUIError(fallbackError, error);
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
handleGQLWarning: (message) => {
|
|
99
|
-
console.warn(message);
|
|
100
|
-
const warningError = new CopilotKitError({
|
|
101
|
-
message,
|
|
102
|
-
code: CopilotKitErrorCode.UNKNOWN
|
|
103
|
-
});
|
|
104
|
-
setBannerError(warningError);
|
|
105
|
-
}
|
|
106
|
-
}));
|
|
107
|
-
}, [runtimeOptions, setBannerError, onError]);
|
|
108
|
-
return runtimeClient;
|
|
109
|
-
};
|
|
110
|
-
function createStructuredError(gqlError) {
|
|
111
|
-
var _a, _b, _c;
|
|
112
|
-
const extensions = gqlError.extensions;
|
|
113
|
-
const originalError = extensions == null ? void 0 : extensions.originalError;
|
|
114
|
-
const message = (originalError == null ? void 0 : originalError.message) || gqlError.message;
|
|
115
|
-
const code = extensions == null ? void 0 : extensions.code;
|
|
116
|
-
if (code) {
|
|
117
|
-
return new CopilotKitError({ message, code });
|
|
118
|
-
}
|
|
119
|
-
if ((_a = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _a.includes("CopilotApiDiscoveryError")) {
|
|
120
|
-
return new CopilotKitApiDiscoveryError({ message });
|
|
121
|
-
}
|
|
122
|
-
if ((_b = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _b.includes("CopilotKitRemoteEndpointDiscoveryError")) {
|
|
123
|
-
return new CopilotKitRemoteEndpointDiscoveryError({ message });
|
|
124
|
-
}
|
|
125
|
-
if ((_c = originalError == null ? void 0 : originalError.stack) == null ? void 0 : _c.includes("CopilotKitAgentDiscoveryError")) {
|
|
126
|
-
return new CopilotKitAgentDiscoveryError({
|
|
127
|
-
agentName: "",
|
|
128
|
-
availableAgents: []
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export {
|
|
135
|
-
useCopilotRuntimeClient
|
|
136
|
-
};
|
|
137
|
-
//# sourceMappingURL=chunk-2RSAYTXH.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-copilot-runtime-client.ts"],"sourcesContent":["import {\n CopilotRuntimeClient,\n CopilotRuntimeClientOptions,\n GraphQLError,\n} from \"@copilotkit/runtime-client-gql\";\nimport { useToast } from \"../components/toast/toast-provider\";\nimport { useMemo, useRef } from \"react\";\nimport {\n ErrorVisibility,\n CopilotKitApiDiscoveryError,\n CopilotKitRemoteEndpointDiscoveryError,\n CopilotKitAgentDiscoveryError,\n CopilotKitError,\n CopilotKitErrorCode,\n CopilotErrorHandler,\n CopilotErrorEvent,\n} from \"@copilotkit/shared\";\nimport { shouldShowDevConsole } from \"../utils/dev-console\";\n\nexport interface CopilotRuntimeClientHookOptions extends CopilotRuntimeClientOptions {\n showDevConsole?: boolean;\n onError: CopilotErrorHandler;\n}\n\nexport const useCopilotRuntimeClient = (\n options: CopilotRuntimeClientHookOptions,\n) => {\n const { setBannerError } = useToast();\n const { showDevConsole, onError, ...runtimeOptions } = options;\n\n // Deduplication state for structured errors\n const lastStructuredErrorRef = useRef<{\n message: string;\n timestamp: number;\n } | null>(null);\n\n // Helper function to trace UI errors\n const traceUIError = async (error: CopilotKitError, originalError?: any) => {\n try {\n const errorEvent: CopilotErrorEvent = {\n type: \"error\",\n timestamp: Date.now(),\n context: {\n source: \"ui\",\n request: {\n operation: \"runtimeClient\",\n url: runtimeOptions.url,\n startTime: Date.now(),\n },\n technical: {\n environment: \"browser\",\n userAgent:\n typeof navigator !== \"undefined\"\n ? navigator.userAgent\n : undefined,\n stackTrace:\n originalError instanceof Error ? originalError.stack : undefined,\n },\n },\n error,\n };\n await onError(errorEvent);\n } catch (error) {\n console.error(\"Error in onError handler:\", error);\n }\n };\n\n const runtimeClient = useMemo(() => {\n return new CopilotRuntimeClient({\n ...runtimeOptions,\n handleGQLErrors: (error) => {\n if ((error as any).graphQLErrors?.length) {\n const graphQLErrors = (error as any).graphQLErrors as GraphQLError[];\n\n // Route all errors to banners for consistent UI\n const routeError = (gqlError: GraphQLError) => {\n const extensions = gqlError.extensions;\n const visibility = extensions?.visibility as ErrorVisibility;\n\n // Silent errors - just log\n if (visibility === ErrorVisibility.SILENT) {\n console.error(\"CopilotKit Silent Error:\", gqlError.message);\n return;\n }\n\n // All errors (including DEV_ONLY) show as banners for consistency\n // Deduplicate to prevent spam\n const now = Date.now();\n const errorMessage = gqlError.message;\n if (\n lastStructuredErrorRef.current &&\n lastStructuredErrorRef.current.message === errorMessage &&\n now - lastStructuredErrorRef.current.timestamp < 150\n ) {\n return; // Skip duplicate\n }\n lastStructuredErrorRef.current = {\n message: errorMessage,\n timestamp: now,\n };\n\n const ckError = createStructuredError(gqlError);\n if (ckError) {\n setBannerError(ckError);\n // Trace the error\n traceUIError(ckError, gqlError);\n // TODO: if onError & renderError should work without key, insert here\n } else {\n // Fallback for unstructured errors\n const fallbackError = new CopilotKitError({\n message: gqlError.message,\n code: CopilotKitErrorCode.UNKNOWN,\n });\n setBannerError(fallbackError);\n // Trace the fallback error\n traceUIError(fallbackError, gqlError);\n // TODO: if onError & renderError should work without key, insert here\n }\n };\n\n // Process all errors as banners\n graphQLErrors.forEach(routeError);\n } else {\n // Route non-GraphQL errors to banner as well\n const fallbackError = new CopilotKitError({\n message: error?.message || String(error),\n code: CopilotKitErrorCode.UNKNOWN,\n });\n setBannerError(fallbackError);\n // Trace the non-GraphQL error\n traceUIError(fallbackError, error);\n // TODO: if onError & renderError should work without key, insert here\n }\n },\n handleGQLWarning: (message: string) => {\n console.warn(message);\n // Show warnings as banners too for consistency\n const warningError = new CopilotKitError({\n message,\n code: CopilotKitErrorCode.UNKNOWN,\n });\n setBannerError(warningError);\n },\n });\n }, [runtimeOptions, setBannerError, onError]);\n\n return runtimeClient;\n};\n\n// Create appropriate structured error from GraphQL error\nfunction createStructuredError(gqlError: GraphQLError): CopilotKitError | null {\n const extensions = gqlError.extensions;\n const originalError = extensions?.originalError as any;\n const message = originalError?.message || gqlError.message;\n const code = extensions?.code as CopilotKitErrorCode;\n\n if (code) {\n return new CopilotKitError({ message, code });\n }\n\n // Legacy error detection by stack trace\n if (originalError?.stack?.includes(\"CopilotApiDiscoveryError\")) {\n return new CopilotKitApiDiscoveryError({ message });\n }\n if (\n originalError?.stack?.includes(\"CopilotKitRemoteEndpointDiscoveryError\")\n ) {\n return new CopilotKitRemoteEndpointDiscoveryError({ message });\n }\n if (originalError?.stack?.includes(\"CopilotKitAgentDiscoveryError\")) {\n return new CopilotKitAgentDiscoveryError({\n agentName: \"\",\n availableAgents: [],\n });\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;AAAA;AAAA,EACE;AAAA,OAGK;AAEP,SAAS,SAAS,cAAc;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAQA,IAAM,0BAA0B,CACrC,YACG;AACH,QAAM,EAAE,eAAe,IAAI,SAAS;AACpC,QAAuD,cAA/C,kBAAgB,QA5B1B,IA4ByD,IAAnB,2BAAmB,IAAnB,CAA5B,kBAAgB;AAGxB,QAAM,yBAAyB,OAGrB,IAAI;AAGd,QAAM,eAAe,CAAO,OAAwB,kBAAwB;AAC1E,QAAI;AACF,YAAM,aAAgC;AAAA,QACpC,MAAM;AAAA,QACN,WAAW,KAAK,IAAI;AAAA,QACpB,SAAS;AAAA,UACP,QAAQ;AAAA,UACR,SAAS;AAAA,YACP,WAAW;AAAA,YACX,KAAK,eAAe;AAAA,YACpB,WAAW,KAAK,IAAI;AAAA,UACtB;AAAA,UACA,WAAW;AAAA,YACT,aAAa;AAAA,YACb,WACE,OAAO,cAAc,cACjB,UAAU,YACV;AAAA,YACN,YACE,yBAAyB,QAAQ,cAAc,QAAQ;AAAA,UAC3D;AAAA,QACF;AAAA,QACA;AAAA,MACF;AACA,YAAM,QAAQ,UAAU;AAAA,IAC1B,SAASA,QAAP;AACA,cAAQ,MAAM,6BAA6BA,MAAK;AAAA,IAClD;AAAA,EACF;AAEA,QAAM,gBAAgB,QAAQ,MAAM;AAClC,WAAO,IAAI,qBAAqB,iCAC3B,iBAD2B;AAAA,MAE9B,iBAAiB,CAAC,UAAU;AAtElC,YAAAC;AAuEQ,aAAKA,MAAA,MAAc,kBAAd,gBAAAA,IAA6B,QAAQ;AACxC,gBAAM,gBAAiB,MAAc;AAGrC,gBAAM,aAAa,CAAC,aAA2B;AAC7C,kBAAM,aAAa,SAAS;AAC5B,kBAAM,aAAa,yCAAY;AAG/B,gBAAI,eAAe,gBAAgB,QAAQ;AACzC,sBAAQ,MAAM,4BAA4B,SAAS,OAAO;AAC1D;AAAA,YACF;AAIA,kBAAM,MAAM,KAAK,IAAI;AACrB,kBAAM,eAAe,SAAS;AAC9B,gBACE,uBAAuB,WACvB,uBAAuB,QAAQ,YAAY,gBAC3C,MAAM,uBAAuB,QAAQ,YAAY,KACjD;AACA;AAAA,YACF;AACA,mCAAuB,UAAU;AAAA,cAC/B,SAAS;AAAA,cACT,WAAW;AAAA,YACb;AAEA,kBAAM,UAAU,sBAAsB,QAAQ;AAC9C,gBAAI,SAAS;AACX,6BAAe,OAAO;AAEtB,2BAAa,SAAS,QAAQ;AAAA,YAEhC,OAAO;AAEL,oBAAM,gBAAgB,IAAI,gBAAgB;AAAA,gBACxC,SAAS,SAAS;AAAA,gBAClB,MAAM,oBAAoB;AAAA,cAC5B,CAAC;AACD,6BAAe,aAAa;AAE5B,2BAAa,eAAe,QAAQ;AAAA,YAEtC;AAAA,UACF;AAGA,wBAAc,QAAQ,UAAU;AAAA,QAClC,OAAO;AAEL,gBAAM,gBAAgB,IAAI,gBAAgB;AAAA,YACxC,UAAS,+BAAO,YAAW,OAAO,KAAK;AAAA,YACvC,MAAM,oBAAoB;AAAA,UAC5B,CAAC;AACD,yBAAe,aAAa;AAE5B,uBAAa,eAAe,KAAK;AAAA,QAEnC;AAAA,MACF;AAAA,MACA,kBAAkB,CAAC,YAAoB;AACrC,gBAAQ,KAAK,OAAO;AAEpB,cAAM,eAAe,IAAI,gBAAgB;AAAA,UACvC;AAAA,UACA,MAAM,oBAAoB;AAAA,QAC5B,CAAC;AACD,uBAAe,YAAY;AAAA,MAC7B;AAAA,IACF,EAAC;AAAA,EACH,GAAG,CAAC,gBAAgB,gBAAgB,OAAO,CAAC;AAE5C,SAAO;AACT;AAGA,SAAS,sBAAsB,UAAgD;AAtJ/E;AAuJE,QAAM,aAAa,SAAS;AAC5B,QAAM,gBAAgB,yCAAY;AAClC,QAAM,WAAU,+CAAe,YAAW,SAAS;AACnD,QAAM,OAAO,yCAAY;AAEzB,MAAI,MAAM;AACR,WAAO,IAAI,gBAAgB,EAAE,SAAS,KAAK,CAAC;AAAA,EAC9C;AAGA,OAAI,oDAAe,UAAf,mBAAsB,SAAS,6BAA6B;AAC9D,WAAO,IAAI,4BAA4B,EAAE,QAAQ,CAAC;AAAA,EACpD;AACA,OACE,oDAAe,UAAf,mBAAsB,SAAS,2CAC/B;AACA,WAAO,IAAI,uCAAuC,EAAE,QAAQ,CAAC;AAAA,EAC/D;AACA,OAAI,oDAAe,UAAf,mBAAsB,SAAS,kCAAkC;AACnE,WAAO,IAAI,8BAA8B;AAAA,MACvC,WAAW;AAAA,MACX,iBAAiB,CAAC;AAAA,IACpB,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":["error","_a"]}
|
package/dist/chunk-36KQV2NA.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-36KQV2NA.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/chunk-3LZZ4RVM.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useCopilotContext
|
|
3
|
-
} from "./chunk-C7HSVDHD.mjs";
|
|
4
|
-
|
|
5
|
-
// src/hooks/use-copilot-additional-instructions.ts
|
|
6
|
-
import { useEffect } from "react";
|
|
7
|
-
function useCopilotAdditionalInstructions({
|
|
8
|
-
instructions,
|
|
9
|
-
available = "enabled"
|
|
10
|
-
}, dependencies) {
|
|
11
|
-
const { setAdditionalInstructions } = useCopilotContext();
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (available === "disabled")
|
|
14
|
-
return;
|
|
15
|
-
setAdditionalInstructions((prevInstructions) => [
|
|
16
|
-
...prevInstructions || [],
|
|
17
|
-
instructions
|
|
18
|
-
]);
|
|
19
|
-
return () => {
|
|
20
|
-
setAdditionalInstructions(
|
|
21
|
-
(prevInstructions) => (prevInstructions == null ? void 0 : prevInstructions.filter(
|
|
22
|
-
(instruction) => instruction !== instructions
|
|
23
|
-
)) || []
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
}, [
|
|
27
|
-
available,
|
|
28
|
-
instructions,
|
|
29
|
-
setAdditionalInstructions,
|
|
30
|
-
...dependencies || []
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export {
|
|
35
|
-
useCopilotAdditionalInstructions
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=chunk-3LZZ4RVM.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-copilot-additional-instructions.ts"],"sourcesContent":["/**\n * `useCopilotAdditionalInstructions` is a React hook that provides additional instructions\n * to the Copilot.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * In its most basic usage, useCopilotAdditionalInstructions accepts a single string argument\n * representing the instructions to be added to the Copilot.\n *\n * ```tsx\n * import { useCopilotAdditionalInstructions } from \"@copilotkit/react-core\";\n *\n * export function MyComponent() {\n * useCopilotAdditionalInstructions({\n * instructions: \"Do not answer questions about the weather.\",\n * });\n * }\n * ```\n *\n * ### Conditional Usage\n *\n * You can also conditionally add instructions based on the state of your app.\n *\n * ```tsx\n * import { useCopilotAdditionalInstructions } from \"@copilotkit/react-core\";\n *\n * export function MyComponent() {\n * const [showInstructions, setShowInstructions] = useState(false);\n *\n * useCopilotAdditionalInstructions({\n * available: showInstructions ? \"enabled\" : \"disabled\",\n * instructions: \"Do not answer questions about the weather.\",\n * });\n * }\n * ```\n */\nimport { useEffect } from \"react\";\nimport { useCopilotContext } from \"../context/copilot-context\";\n\n/**\n * Options for the useCopilotAdditionalInstructions hook.\n */\nexport interface UseCopilotAdditionalInstructionsOptions {\n /**\n * The instructions to be added to the Copilot. Will be added to the instructions like so:\n *\n * ```txt\n * You are a helpful assistant.\n * Additionally, follow these instructions:\n * - Do not answer questions about the weather.\n * - Do not answer questions about the stock market.\n * ```\n */\n instructions: string;\n\n /**\n * Whether the instructions are available to the Copilot.\n */\n available?: \"enabled\" | \"disabled\";\n}\n\n/**\n * Adds the given instructions to the Copilot context.\n */\nexport function useCopilotAdditionalInstructions(\n {\n instructions,\n available = \"enabled\",\n }: UseCopilotAdditionalInstructionsOptions,\n dependencies?: any[],\n) {\n const { setAdditionalInstructions } = useCopilotContext();\n\n useEffect(() => {\n if (available === \"disabled\") return;\n\n setAdditionalInstructions((prevInstructions) => [\n ...(prevInstructions || []),\n instructions,\n ]);\n\n return () => {\n setAdditionalInstructions(\n (prevInstructions) =>\n prevInstructions?.filter(\n (instruction) => instruction !== instructions,\n ) || [],\n );\n };\n }, [\n available,\n instructions,\n setAdditionalInstructions,\n ...(dependencies || []),\n ]);\n}\n"],"mappings":";;;;;AAsCA,SAAS,iBAAiB;AA4BnB,SAAS,iCACd;AAAA,EACE;AAAA,EACA,YAAY;AACd,GACA,cACA;AACA,QAAM,EAAE,0BAA0B,IAAI,kBAAkB;AAExD,YAAU,MAAM;AACd,QAAI,cAAc;AAAY;AAE9B,8BAA0B,CAAC,qBAAqB;AAAA,MAC9C,GAAI,oBAAoB,CAAC;AAAA,MACzB;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX;AAAA,QACE,CAAC,sBACC,qDAAkB;AAAA,UAChB,CAAC,gBAAgB,gBAAgB;AAAA,cAC9B,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAI,gBAAgB,CAAC;AAAA,EACvB,CAAC;AACH;","names":[]}
|
package/dist/chunk-4ZQYMC5F.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useCopilotChatInternal
|
|
3
|
-
} from "./chunk-AAGMWZCN.mjs";
|
|
4
|
-
|
|
5
|
-
// src/hooks/use-copilot-chat.ts
|
|
6
|
-
function useCopilotChat(options = {}) {
|
|
7
|
-
const {
|
|
8
|
-
visibleMessages,
|
|
9
|
-
appendMessage,
|
|
10
|
-
reloadMessages,
|
|
11
|
-
stopGeneration,
|
|
12
|
-
reset,
|
|
13
|
-
isLoading,
|
|
14
|
-
isAvailable,
|
|
15
|
-
runChatCompletion,
|
|
16
|
-
mcpServers,
|
|
17
|
-
setMcpServers
|
|
18
|
-
} = useCopilotChatInternal(options);
|
|
19
|
-
return {
|
|
20
|
-
visibleMessages,
|
|
21
|
-
appendMessage,
|
|
22
|
-
reloadMessages,
|
|
23
|
-
stopGeneration,
|
|
24
|
-
reset,
|
|
25
|
-
isLoading,
|
|
26
|
-
isAvailable,
|
|
27
|
-
runChatCompletion,
|
|
28
|
-
mcpServers,
|
|
29
|
-
setMcpServers
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
useCopilotChat
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=chunk-4ZQYMC5F.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-copilot-chat.ts"],"sourcesContent":["/**\n * `useCopilotChat` is a lightweight React hook for headless chat interactions.\n * Perfect for controlling the prebuilt chat components programmatically.\n *\n * **Open Source Friendly** - Works without requiring a free public license key.\n *\n * <Callout title=\"Looking for fully headless UI?\">\n * Get started with [useCopilotChatHeadless_c](https://docs.copilotkit.ai/reference/hooks/useCopilotChatHeadless_c).\n * </Callout>\n *\n * ## Use Cases\n *\n * - **Programmatic Messaging**: Send messages without displaying chat UI\n * - **Programmatic control**: Control prebuilt component programmatically\n * - **Background Operations**: Trigger AI interactions in the background\n * - **Fire-and-Forget**: Send messages without needing to read responses\n *\n * ## Usage\n *\n * ```tsx\n * import { TextMessage, MessageRole } from \"@copilotkit/runtime-client-gql\";\n *\n * const { appendMessage } = useCopilotChat();\n *\n * // Example usage without naming conflicts\n * const handleSendMessage = async (content: string) => {\n * await appendMessage(\n * new TextMessage({\n * role: MessageRole.User,\n * content,\n * })\n * );\n * };\n * ```\n *\n * ## Return Values\n * The following properties are returned from the hook:\n *\n * <PropertyReference name=\"visibleMessages\" type=\"DeprecatedGqlMessage[]\" deprecated>\n * Array of messages in old non-AG-UI format, use for compatibility only\n * </PropertyReference>\n *\n * <PropertyReference name=\"appendMessage\" type=\"(message: DeprecatedGqlMessage, options?) => Promise<void>\" deprecated>\n * Append message using old format, use `sendMessage` instead\n * </PropertyReference>\n *\n * <PropertyReference name=\"reloadMessages\" type=\"(messageId: string) => Promise<void>\">\n * Regenerate the response for a specific message by ID\n * </PropertyReference>\n *\n * <PropertyReference name=\"stopGeneration\" type=\"() => void\">\n * Stop the current message generation process\n * </PropertyReference>\n *\n * <PropertyReference name=\"reset\" type=\"() => void\">\n * Clear all messages and reset chat state completely\n * </PropertyReference>\n *\n * <PropertyReference name=\"isLoading\" type=\"boolean\">\n * Whether the chat is currently generating a response\n * </PropertyReference>\n *\n * <PropertyReference name=\"runChatCompletion\" type=\"() => Promise<Message[]>\">\n * Manually trigger chat completion for advanced usage\n * </PropertyReference>\n *\n * <PropertyReference name=\"mcpServers\" type=\"MCPServerConfig[]\">\n * Array of Model Context Protocol server configurations\n * </PropertyReference>\n *\n * <PropertyReference name=\"setMcpServers\" type=\"(servers: MCPServerConfig[]) => void\">\n * Update MCP server configurations for enhanced context\n * </PropertyReference>\n */\n\nimport {\n UseCopilotChatOptions,\n useCopilotChatInternal,\n UseCopilotChatReturn as UseCopilotChatReturnInternal,\n} from \"./use-copilot-chat_internal\";\n\n// Create a type that excludes message-related properties from the internal type\nexport type UseCopilotChatReturn = Omit<\n UseCopilotChatReturnInternal,\n | \"messages\"\n | \"sendMessage\"\n | \"suggestions\"\n | \"setSuggestions\"\n | \"generateSuggestions\"\n | \"isLoadingSuggestions\"\n | \"resetSuggestions\"\n | \"interrupt\"\n | \"setMessages\"\n | \"deleteMessage\"\n>;\n\n/**\n * A lightweight React hook for headless chat interactions.\n * Perfect for programmatic messaging, background operations, and custom UI implementations.\n *\n * **Open Source Friendly** - Works without requiring a `publicApiKey`.\n */\n// TODO: Do we need this? If so, does it work properly? test.\nexport function useCopilotChat(\n options: UseCopilotChatOptions = {},\n): UseCopilotChatReturn {\n const {\n visibleMessages,\n appendMessage,\n reloadMessages,\n stopGeneration,\n reset,\n isLoading,\n isAvailable,\n runChatCompletion,\n mcpServers,\n setMcpServers,\n } = useCopilotChatInternal(options);\n\n return {\n visibleMessages,\n appendMessage,\n reloadMessages,\n stopGeneration,\n reset,\n isLoading,\n isAvailable,\n runChatCompletion,\n mcpServers,\n setMcpServers,\n };\n}\n"],"mappings":";;;;;AAuGO,SAAS,eACd,UAAiC,CAAC,GACZ;AACtB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,uBAAuB,OAAO;AAElC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
package/dist/chunk-6ABVYB2U.mjs
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useToast
|
|
3
|
-
} from "./chunk-ZP2IMXFY.mjs";
|
|
4
|
-
import {
|
|
5
|
-
useCoAgentStateRenders
|
|
6
|
-
} from "./chunk-IHMMKEFG.mjs";
|
|
7
|
-
import {
|
|
8
|
-
CopilotContext
|
|
9
|
-
} from "./chunk-C7HSVDHD.mjs";
|
|
10
|
-
|
|
11
|
-
// src/hooks/use-coagent-state-render.ts
|
|
12
|
-
import { useRef, useContext, useEffect } from "react";
|
|
13
|
-
import { randomId, CopilotKitAgentDiscoveryError } from "@copilotkit/shared";
|
|
14
|
-
function useCoAgentStateRender(action, dependencies) {
|
|
15
|
-
const { chatComponentsCache, availableAgents } = useContext(CopilotContext);
|
|
16
|
-
const {
|
|
17
|
-
setCoAgentStateRender,
|
|
18
|
-
removeCoAgentStateRender,
|
|
19
|
-
coAgentStateRenders
|
|
20
|
-
} = useCoAgentStateRenders();
|
|
21
|
-
const idRef = useRef(randomId());
|
|
22
|
-
const { setBannerError, addToast } = useToast();
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if ((availableAgents == null ? void 0 : availableAgents.length) && !availableAgents.some((a) => a.name === action.name)) {
|
|
25
|
-
const message = `(useCoAgentStateRender): Agent "${action.name}" not found. Make sure the agent exists and is properly configured.`;
|
|
26
|
-
const agentError = new CopilotKitAgentDiscoveryError({
|
|
27
|
-
agentName: action.name,
|
|
28
|
-
availableAgents: availableAgents.map((a) => ({
|
|
29
|
-
name: a.name,
|
|
30
|
-
id: a.id
|
|
31
|
-
}))
|
|
32
|
-
});
|
|
33
|
-
setBannerError(agentError);
|
|
34
|
-
}
|
|
35
|
-
}, [availableAgents]);
|
|
36
|
-
const key = `${action.name}-${action.nodeName || "global"}`;
|
|
37
|
-
if (dependencies === void 0) {
|
|
38
|
-
if (coAgentStateRenders[idRef.current]) {
|
|
39
|
-
coAgentStateRenders[idRef.current].handler = action.handler;
|
|
40
|
-
if (typeof action.render === "function") {
|
|
41
|
-
if (chatComponentsCache.current !== null) {
|
|
42
|
-
chatComponentsCache.current.coAgentStateRenders[key] = action.render;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
const currentId = idRef.current;
|
|
49
|
-
const hasDuplicate = Object.entries(coAgentStateRenders).some(
|
|
50
|
-
([id, otherAction]) => {
|
|
51
|
-
if (id === currentId)
|
|
52
|
-
return false;
|
|
53
|
-
if (otherAction.name !== action.name)
|
|
54
|
-
return false;
|
|
55
|
-
const hasNodeName = !!action.nodeName;
|
|
56
|
-
const hasOtherNodeName = !!otherAction.nodeName;
|
|
57
|
-
if (!hasNodeName && !hasOtherNodeName)
|
|
58
|
-
return true;
|
|
59
|
-
if (hasNodeName !== hasOtherNodeName)
|
|
60
|
-
return false;
|
|
61
|
-
return action.nodeName === otherAction.nodeName;
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
if (hasDuplicate) {
|
|
65
|
-
const message = action.nodeName ? `Found multiple state renders for agent ${action.name} and node ${action.nodeName}. State renders might get overridden` : `Found multiple state renders for agent ${action.name}. State renders might get overridden`;
|
|
66
|
-
addToast({
|
|
67
|
-
type: "warning",
|
|
68
|
-
message,
|
|
69
|
-
id: `dup-action-${action.name}`
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}, [coAgentStateRenders]);
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
setCoAgentStateRender(idRef.current, action);
|
|
75
|
-
if (chatComponentsCache.current !== null && action.render !== void 0) {
|
|
76
|
-
chatComponentsCache.current.coAgentStateRenders[key] = action.render;
|
|
77
|
-
}
|
|
78
|
-
return () => {
|
|
79
|
-
removeCoAgentStateRender(idRef.current);
|
|
80
|
-
};
|
|
81
|
-
}, [
|
|
82
|
-
setCoAgentStateRender,
|
|
83
|
-
removeCoAgentStateRender,
|
|
84
|
-
action.name,
|
|
85
|
-
// include render only if it's a string
|
|
86
|
-
typeof action.render === "string" ? action.render : void 0,
|
|
87
|
-
// dependencies set by the developer
|
|
88
|
-
...dependencies || []
|
|
89
|
-
]);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export {
|
|
93
|
-
useCoAgentStateRender
|
|
94
|
-
};
|
|
95
|
-
//# sourceMappingURL=chunk-6ABVYB2U.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-coagent-state-render.ts"],"sourcesContent":["/**\n * The useCoAgentStateRender hook allows you to render UI or text based components on a Agentic Copilot's state in the chat.\n * This is particularly useful for showing intermediate state or progress during Agentic Copilot operations.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCoAgentStateRender } from \"@copilotkit/react-core\";\n *\n * type YourAgentState = {\n * agent_state_property: string;\n * }\n *\n * useCoAgentStateRender<YourAgentState>({\n * name: \"basic_agent\",\n * nodeName: \"optionally_specify_a_specific_node\",\n * render: ({ status, state, nodeName }) => {\n * return (\n * <YourComponent\n * agentStateProperty={state.agent_state_property}\n * status={status}\n * nodeName={nodeName}\n * />\n * );\n * },\n * });\n * ```\n *\n * This allows for you to render UI components or text based on what is happening within the agent.\n *\n * ### Example\n * A great example of this is in our Perplexity Clone where we render the progress of an agent's internet search as it is happening.\n * You can play around with it below or learn how to build it with its [demo](/coagents/videos/perplexity-clone).\n *\n * <Callout type=\"info\">\n * This example is hosted on Vercel and may take a few seconds to load.\n * </Callout>\n *\n * <iframe src=\"https://examples-coagents-ai-researcher-ui.vercel.app/\" className=\"w-full rounded-lg border h-[700px] my-4\" />\n */\n\nimport { useRef, useContext, useEffect } from \"react\";\nimport { CopilotContext } from \"../context/copilot-context\";\nimport { randomId, CopilotKitAgentDiscoveryError } from \"@copilotkit/shared\";\nimport { CoAgentStateRender } from \"../types/coagent-action\";\nimport { useToast } from \"../components/toast/toast-provider\";\nimport { useCoAgentStateRenders } from \"../context/coagent-state-renders-context\";\n\n/**\n * This hook is used to render agent state with custom UI components or text. This is particularly\n * useful for showing intermediate state or progress during Agentic Copilot operations.\n * To get started using rendering intermediate state through this hook, checkout the documentation.\n *\n * https://docs.copilotkit.ai/coagents/shared-state/predictive-state-updates\n */\n\n// We implement useCoAgentStateRender dependency handling so that\n// the developer has the option to not provide any dependencies.\n// see useCopilotAction for more details about this approach.\nexport function useCoAgentStateRender<T = any>(\n action: CoAgentStateRender<T>,\n dependencies?: any[],\n): void {\n const { chatComponentsCache, availableAgents } = useContext(CopilotContext);\n const {\n setCoAgentStateRender,\n removeCoAgentStateRender,\n coAgentStateRenders,\n } = useCoAgentStateRenders();\n const idRef = useRef<string>(randomId());\n const { setBannerError, addToast } = useToast();\n\n useEffect(() => {\n if (\n availableAgents?.length &&\n !availableAgents.some((a) => a.name === action.name)\n ) {\n const message = `(useCoAgentStateRender): Agent \"${action.name}\" not found. Make sure the agent exists and is properly configured.`;\n\n // Route to banner instead of toast for consistency\n const agentError = new CopilotKitAgentDiscoveryError({\n agentName: action.name,\n availableAgents: availableAgents.map((a) => ({\n name: a.name,\n id: a.id,\n })),\n });\n setBannerError(agentError);\n }\n }, [availableAgents]);\n\n const key = `${action.name}-${action.nodeName || \"global\"}`;\n\n if (dependencies === undefined) {\n if (coAgentStateRenders[idRef.current]) {\n coAgentStateRenders[idRef.current].handler = action.handler as any;\n if (typeof action.render === \"function\") {\n if (chatComponentsCache.current !== null) {\n chatComponentsCache.current.coAgentStateRenders[key] = action.render;\n }\n }\n }\n }\n\n useEffect(() => {\n // Check for duplicates by comparing against all other actions\n const currentId = idRef.current;\n const hasDuplicate = Object.entries(coAgentStateRenders).some(\n ([id, otherAction]) => {\n // Skip comparing with self\n if (id === currentId) return false;\n\n // Different agent names are never duplicates\n if (otherAction.name !== action.name) return false;\n\n // Same agent names:\n const hasNodeName = !!action.nodeName;\n const hasOtherNodeName = !!otherAction.nodeName;\n\n // If neither has nodeName, they're duplicates\n if (!hasNodeName && !hasOtherNodeName) return true;\n\n // If one has nodeName and other doesn't, they're not duplicates\n if (hasNodeName !== hasOtherNodeName) return false;\n\n // If both have nodeName, they're duplicates only if the names match\n return action.nodeName === otherAction.nodeName;\n },\n );\n\n if (hasDuplicate) {\n const message = action.nodeName\n ? `Found multiple state renders for agent ${action.name} and node ${action.nodeName}. State renders might get overridden`\n : `Found multiple state renders for agent ${action.name}. State renders might get overridden`;\n\n addToast({\n type: \"warning\",\n message,\n id: `dup-action-${action.name}`,\n });\n }\n }, [coAgentStateRenders]);\n\n useEffect(() => {\n setCoAgentStateRender(idRef.current, action as any);\n if (chatComponentsCache.current !== null && action.render !== undefined) {\n chatComponentsCache.current.coAgentStateRenders[key] = action.render;\n }\n return () => {\n removeCoAgentStateRender(idRef.current);\n };\n }, [\n setCoAgentStateRender,\n removeCoAgentStateRender,\n action.name,\n // include render only if it's a string\n typeof action.render === \"string\" ? action.render : undefined,\n // dependencies set by the developer\n ...(dependencies || []),\n ]);\n}\n"],"mappings":";;;;;;;;;;;AA2CA,SAAS,QAAQ,YAAY,iBAAiB;AAE9C,SAAS,UAAU,qCAAqC;AAgBjD,SAAS,sBACd,QACA,cACM;AACN,QAAM,EAAE,qBAAqB,gBAAgB,IAAI,WAAW,cAAc;AAC1E,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,uBAAuB;AAC3B,QAAM,QAAQ,OAAe,SAAS,CAAC;AACvC,QAAM,EAAE,gBAAgB,SAAS,IAAI,SAAS;AAE9C,YAAU,MAAM;AACd,SACE,mDAAiB,WACjB,CAAC,gBAAgB,KAAK,CAAC,MAAM,EAAE,SAAS,OAAO,IAAI,GACnD;AACA,YAAM,UAAU,mCAAmC,OAAO;AAG1D,YAAM,aAAa,IAAI,8BAA8B;AAAA,QACnD,WAAW,OAAO;AAAA,QAClB,iBAAiB,gBAAgB,IAAI,CAAC,OAAO;AAAA,UAC3C,MAAM,EAAE;AAAA,UACR,IAAI,EAAE;AAAA,QACR,EAAE;AAAA,MACJ,CAAC;AACD,qBAAe,UAAU;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,eAAe,CAAC;AAEpB,QAAM,MAAM,GAAG,OAAO,QAAQ,OAAO,YAAY;AAEjD,MAAI,iBAAiB,QAAW;AAC9B,QAAI,oBAAoB,MAAM,OAAO,GAAG;AACtC,0BAAoB,MAAM,OAAO,EAAE,UAAU,OAAO;AACpD,UAAI,OAAO,OAAO,WAAW,YAAY;AACvC,YAAI,oBAAoB,YAAY,MAAM;AACxC,8BAAoB,QAAQ,oBAAoB,GAAG,IAAI,OAAO;AAAA,QAChE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,YAAU,MAAM;AAEd,UAAM,YAAY,MAAM;AACxB,UAAM,eAAe,OAAO,QAAQ,mBAAmB,EAAE;AAAA,MACvD,CAAC,CAAC,IAAI,WAAW,MAAM;AAErB,YAAI,OAAO;AAAW,iBAAO;AAG7B,YAAI,YAAY,SAAS,OAAO;AAAM,iBAAO;AAG7C,cAAM,cAAc,CAAC,CAAC,OAAO;AAC7B,cAAM,mBAAmB,CAAC,CAAC,YAAY;AAGvC,YAAI,CAAC,eAAe,CAAC;AAAkB,iBAAO;AAG9C,YAAI,gBAAgB;AAAkB,iBAAO;AAG7C,eAAO,OAAO,aAAa,YAAY;AAAA,MACzC;AAAA,IACF;AAEA,QAAI,cAAc;AAChB,YAAM,UAAU,OAAO,WACnB,0CAA0C,OAAO,iBAAiB,OAAO,iDACzE,0CAA0C,OAAO;AAErD,eAAS;AAAA,QACP,MAAM;AAAA,QACN;AAAA,QACA,IAAI,cAAc,OAAO;AAAA,MAC3B,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,mBAAmB,CAAC;AAExB,YAAU,MAAM;AACd,0BAAsB,MAAM,SAAS,MAAa;AAClD,QAAI,oBAAoB,YAAY,QAAQ,OAAO,WAAW,QAAW;AACvE,0BAAoB,QAAQ,oBAAoB,GAAG,IAAI,OAAO;AAAA,IAChE;AACA,WAAO,MAAM;AACX,+BAAyB,MAAM,OAAO;AAAA,IACxC;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA,OAAO;AAAA;AAAA,IAEP,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS;AAAA;AAAA,IAEpD,GAAI,gBAAgB,CAAC;AAAA,EACvB,CAAC;AACH;","names":[]}
|