@copilotkit/react-core 1.51.5-next.0 → 1.51.5-next.2
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 +19 -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 +21 -21
- 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-2JZZD4RP.mjs +0 -628
- package/dist/chunk-2JZZD4RP.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-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-DAQORGBP.mjs +0 -125
- package/dist/chunk-DAQORGBP.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-IGYMBU43.mjs +0 -43
- package/dist/chunk-IGYMBU43.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-LNGBARXE.mjs +0 -86
- package/dist/chunk-LNGBARXE.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-NINJMAND.mjs +0 -86
- package/dist/chunk-NINJMAND.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-R7BV32X4.mjs +0 -146
- package/dist/chunk-R7BV32X4.mjs.map +0 -1
- package/dist/chunk-S65UEHGI.mjs +0 -95
- package/dist/chunk-S65UEHGI.mjs.map +0 -1
- package/dist/chunk-SBRCWA4S.mjs +0 -913
- package/dist/chunk-SBRCWA4S.mjs.map +0 -1
- package/dist/chunk-SFOKX4MH.mjs +0 -195
- package/dist/chunk-SFOKX4MH.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-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-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
package/dist/chunk-2JZZD4RP.mjs
DELETED
|
@@ -1,628 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CopilotErrorBoundary
|
|
3
|
-
} from "./chunk-NINJMAND.mjs";
|
|
4
|
-
import {
|
|
5
|
-
CopilotMessages,
|
|
6
|
-
MessagesTapProvider
|
|
7
|
-
} from "./chunk-SFOKX4MH.mjs";
|
|
8
|
-
import {
|
|
9
|
-
shouldShowDevConsole
|
|
10
|
-
} from "./chunk-ICIK2BSB.mjs";
|
|
11
|
-
import {
|
|
12
|
-
use_tree_default
|
|
13
|
-
} from "./chunk-R7BV32X4.mjs";
|
|
14
|
-
import {
|
|
15
|
-
use_flat_category_store_default
|
|
16
|
-
} from "./chunk-K5OXUXCG.mjs";
|
|
17
|
-
import {
|
|
18
|
-
UsageBanner,
|
|
19
|
-
getErrorActions
|
|
20
|
-
} from "./chunk-L7GPCF2V.mjs";
|
|
21
|
-
import {
|
|
22
|
-
CoAgentStateRenderBridge
|
|
23
|
-
} from "./chunk-G7SUZGGB.mjs";
|
|
24
|
-
import {
|
|
25
|
-
CoAgentStateRendersProvider
|
|
26
|
-
} from "./chunk-IHMMKEFG.mjs";
|
|
27
|
-
import {
|
|
28
|
-
CopilotContext,
|
|
29
|
-
useCopilotContext
|
|
30
|
-
} from "./chunk-C7HSVDHD.mjs";
|
|
31
|
-
import {
|
|
32
|
-
ThreadsProvider,
|
|
33
|
-
useThreads
|
|
34
|
-
} from "./chunk-SK2XMJUD.mjs";
|
|
35
|
-
import {
|
|
36
|
-
CopilotListeners
|
|
37
|
-
} from "./chunk-WRALJIW5.mjs";
|
|
38
|
-
import {
|
|
39
|
-
ToastProvider
|
|
40
|
-
} from "./chunk-ZP2IMXFY.mjs";
|
|
41
|
-
import {
|
|
42
|
-
__async,
|
|
43
|
-
__objRest,
|
|
44
|
-
__restKey,
|
|
45
|
-
__spreadProps,
|
|
46
|
-
__spreadValues
|
|
47
|
-
} from "./chunk-SKC7AJIV.mjs";
|
|
48
|
-
|
|
49
|
-
// src/components/copilot-provider/copilotkit.tsx
|
|
50
|
-
import {
|
|
51
|
-
useCallback,
|
|
52
|
-
useEffect,
|
|
53
|
-
useMemo,
|
|
54
|
-
useRef,
|
|
55
|
-
useState
|
|
56
|
-
} from "react";
|
|
57
|
-
import {
|
|
58
|
-
CopilotChatConfigurationProvider,
|
|
59
|
-
CopilotKitProvider as CopilotKitNextProvider,
|
|
60
|
-
useCopilotKit
|
|
61
|
-
} from "@copilotkitnext/react";
|
|
62
|
-
import { flushSync } from "react-dom";
|
|
63
|
-
import {
|
|
64
|
-
COPILOT_CLOUD_CHAT_URL,
|
|
65
|
-
COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,
|
|
66
|
-
randomUUID,
|
|
67
|
-
ConfigurationError,
|
|
68
|
-
MissingPublicApiKeyError
|
|
69
|
-
} from "@copilotkit/shared";
|
|
70
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
71
|
-
function CopilotKit(_a) {
|
|
72
|
-
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
73
|
-
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
74
|
-
const showInspector = shouldShowDevConsole(props.enableInspector);
|
|
75
|
-
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
76
|
-
const renderArr = useMemo(() => [{ render: CoAgentStateRenderBridge }], []);
|
|
77
|
-
return /* @__PURE__ */ jsx(ToastProvider, { enabled, children: /* @__PURE__ */ jsx(
|
|
78
|
-
CopilotErrorBoundary,
|
|
79
|
-
{
|
|
80
|
-
publicApiKey,
|
|
81
|
-
showUsageBanner: enabled,
|
|
82
|
-
children: /* @__PURE__ */ jsx(ThreadsProvider, { threadId: props.threadId, children: /* @__PURE__ */ jsx(
|
|
83
|
-
CopilotKitNextProvider,
|
|
84
|
-
__spreadProps(__spreadValues({}, props), {
|
|
85
|
-
showDevConsole: showInspector,
|
|
86
|
-
renderCustomMessages: renderArr,
|
|
87
|
-
useSingleEndpoint: true,
|
|
88
|
-
children: /* @__PURE__ */ jsx(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children }))
|
|
89
|
-
})
|
|
90
|
-
) })
|
|
91
|
-
}
|
|
92
|
-
) });
|
|
93
|
-
}
|
|
94
|
-
function CopilotKitErrorBridge() {
|
|
95
|
-
const { copilotkit } = useCopilotKit();
|
|
96
|
-
const { onError, copilotApiConfig } = useCopilotContext();
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
if (!copilotkit)
|
|
99
|
-
return;
|
|
100
|
-
const subscription = copilotkit.subscribe({
|
|
101
|
-
onError: (event) => __async(this, null, function* () {
|
|
102
|
-
const errorEvent = {
|
|
103
|
-
type: "error",
|
|
104
|
-
timestamp: Date.now(),
|
|
105
|
-
context: __spreadValues({
|
|
106
|
-
source: "agent",
|
|
107
|
-
request: {
|
|
108
|
-
operation: event.code || "unknown",
|
|
109
|
-
url: copilotApiConfig == null ? void 0 : copilotApiConfig.chatApiEndpoint,
|
|
110
|
-
startTime: Date.now()
|
|
111
|
-
},
|
|
112
|
-
technical: {
|
|
113
|
-
environment: "browser",
|
|
114
|
-
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
|
|
115
|
-
stackTrace: event.error.stack
|
|
116
|
-
}
|
|
117
|
-
}, event.context),
|
|
118
|
-
error: event.error
|
|
119
|
-
};
|
|
120
|
-
try {
|
|
121
|
-
yield onError(errorEvent);
|
|
122
|
-
} catch (handlerError) {
|
|
123
|
-
console.error("Error in onError handler:", handlerError);
|
|
124
|
-
}
|
|
125
|
-
})
|
|
126
|
-
});
|
|
127
|
-
return () => {
|
|
128
|
-
subscription.unsubscribe();
|
|
129
|
-
};
|
|
130
|
-
}, [copilotkit, onError, copilotApiConfig]);
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
function CopilotKitInternal(cpkProps) {
|
|
134
|
-
var _b;
|
|
135
|
-
const _a = cpkProps, { children } = _a, props = __objRest(_a, ["children"]);
|
|
136
|
-
validateProps(cpkProps);
|
|
137
|
-
const publicApiKey = props.publicLicenseKey || props.publicApiKey;
|
|
138
|
-
const chatApiEndpoint = props.runtimeUrl || COPILOT_CLOUD_CHAT_URL;
|
|
139
|
-
const [actions, setActions] = useState(
|
|
140
|
-
{}
|
|
141
|
-
);
|
|
142
|
-
const [registeredActionConfigs, setRegisteredActionConfigs] = useState(/* @__PURE__ */ new Map());
|
|
143
|
-
const chatComponentsCache = useRef({
|
|
144
|
-
actions: {},
|
|
145
|
-
coAgentStateRenders: {}
|
|
146
|
-
});
|
|
147
|
-
const { addElement, removeElement, printTree, getAllElements } = use_tree_default();
|
|
148
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
149
|
-
const [chatInstructions, setChatInstructions] = useState("");
|
|
150
|
-
const [authStates, setAuthStates] = useState({});
|
|
151
|
-
const [extensions, setExtensions] = useState({});
|
|
152
|
-
const [additionalInstructions, setAdditionalInstructions] = useState([]);
|
|
153
|
-
const {
|
|
154
|
-
addElement: addDocument,
|
|
155
|
-
removeElement: removeDocument,
|
|
156
|
-
allElements: allDocuments
|
|
157
|
-
} = use_flat_category_store_default();
|
|
158
|
-
const setAction = useCallback((id, action) => {
|
|
159
|
-
setActions((prevPoints) => {
|
|
160
|
-
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
161
|
-
[id]: action
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
}, []);
|
|
165
|
-
const removeAction = useCallback((id) => {
|
|
166
|
-
setActions((prevPoints) => {
|
|
167
|
-
const newPoints = __spreadValues({}, prevPoints);
|
|
168
|
-
delete newPoints[id];
|
|
169
|
-
return newPoints;
|
|
170
|
-
});
|
|
171
|
-
}, []);
|
|
172
|
-
const getContextString = useCallback(
|
|
173
|
-
(documents, categories) => {
|
|
174
|
-
const documentsString = documents.map((document) => {
|
|
175
|
-
return `${document.name} (${document.sourceApplication}):
|
|
176
|
-
${document.getContents()}`;
|
|
177
|
-
}).join("\n\n");
|
|
178
|
-
const nonDocumentStrings = printTree(categories);
|
|
179
|
-
return `${documentsString}
|
|
180
|
-
|
|
181
|
-
${nonDocumentStrings}`;
|
|
182
|
-
},
|
|
183
|
-
[printTree]
|
|
184
|
-
);
|
|
185
|
-
const addContext = useCallback(
|
|
186
|
-
(context, parentId, categories = defaultCopilotContextCategories) => {
|
|
187
|
-
return addElement(context, categories, parentId);
|
|
188
|
-
},
|
|
189
|
-
[addElement]
|
|
190
|
-
);
|
|
191
|
-
const removeContext = useCallback(
|
|
192
|
-
(id) => {
|
|
193
|
-
removeElement(id);
|
|
194
|
-
},
|
|
195
|
-
[removeElement]
|
|
196
|
-
);
|
|
197
|
-
const getAllContext = useCallback(() => {
|
|
198
|
-
return getAllElements();
|
|
199
|
-
}, [getAllElements]);
|
|
200
|
-
const getFunctionCallHandler = useCallback(
|
|
201
|
-
(customEntryPoints) => {
|
|
202
|
-
return entryPointsToFunctionCallHandler(
|
|
203
|
-
Object.values(customEntryPoints || actions)
|
|
204
|
-
);
|
|
205
|
-
},
|
|
206
|
-
[actions]
|
|
207
|
-
);
|
|
208
|
-
const getDocumentsContext = useCallback(
|
|
209
|
-
(categories) => {
|
|
210
|
-
return allDocuments(categories);
|
|
211
|
-
},
|
|
212
|
-
[allDocuments]
|
|
213
|
-
);
|
|
214
|
-
const addDocumentContext = useCallback(
|
|
215
|
-
(documentPointer, categories = defaultCopilotContextCategories) => {
|
|
216
|
-
return addDocument(documentPointer, categories);
|
|
217
|
-
},
|
|
218
|
-
[addDocument]
|
|
219
|
-
);
|
|
220
|
-
const removeDocumentContext = useCallback(
|
|
221
|
-
(documentId) => {
|
|
222
|
-
removeDocument(documentId);
|
|
223
|
-
},
|
|
224
|
-
[removeDocument]
|
|
225
|
-
);
|
|
226
|
-
const copilotApiConfig = useMemo(() => {
|
|
227
|
-
var _a2, _b2;
|
|
228
|
-
let cloud = void 0;
|
|
229
|
-
if (publicApiKey) {
|
|
230
|
-
cloud = {
|
|
231
|
-
guardrails: {
|
|
232
|
-
input: {
|
|
233
|
-
restrictToTopic: {
|
|
234
|
-
enabled: Boolean(props.guardrails_c),
|
|
235
|
-
validTopics: ((_a2 = props.guardrails_c) == null ? void 0 : _a2.validTopics) || [],
|
|
236
|
-
invalidTopics: ((_b2 = props.guardrails_c) == null ? void 0 : _b2.invalidTopics) || []
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
return __spreadProps(__spreadValues({
|
|
243
|
-
publicApiKey
|
|
244
|
-
}, cloud ? { cloud } : {}), {
|
|
245
|
-
chatApiEndpoint,
|
|
246
|
-
headers: props.headers || {},
|
|
247
|
-
properties: props.properties || {},
|
|
248
|
-
transcribeAudioUrl: props.transcribeAudioUrl,
|
|
249
|
-
textToSpeechUrl: props.textToSpeechUrl,
|
|
250
|
-
credentials: props.credentials
|
|
251
|
-
});
|
|
252
|
-
}, [
|
|
253
|
-
publicApiKey,
|
|
254
|
-
props.headers,
|
|
255
|
-
props.properties,
|
|
256
|
-
props.transcribeAudioUrl,
|
|
257
|
-
props.textToSpeechUrl,
|
|
258
|
-
props.credentials,
|
|
259
|
-
props.cloudRestrictToTopic,
|
|
260
|
-
props.guardrails_c
|
|
261
|
-
]);
|
|
262
|
-
const headers = useMemo(() => {
|
|
263
|
-
const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {
|
|
264
|
-
if (state.status === "authenticated" && state.authHeaders) {
|
|
265
|
-
return __spreadValues(__spreadValues({}, acc), Object.entries(state.authHeaders).reduce(
|
|
266
|
-
(headers2, [key, value]) => __spreadProps(__spreadValues({}, headers2), {
|
|
267
|
-
[key.startsWith("X-Custom-") ? key : `X-Custom-${key}`]: value
|
|
268
|
-
}),
|
|
269
|
-
{}
|
|
270
|
-
));
|
|
271
|
-
}
|
|
272
|
-
return acc;
|
|
273
|
-
}, {});
|
|
274
|
-
return __spreadValues(__spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? {
|
|
275
|
-
[COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey
|
|
276
|
-
} : {}), authHeaders);
|
|
277
|
-
}, [copilotApiConfig.headers, copilotApiConfig.publicApiKey, authStates]);
|
|
278
|
-
const [internalErrorHandlers, _setInternalErrorHandler] = useState({});
|
|
279
|
-
const setInternalErrorHandler = useCallback(
|
|
280
|
-
(handler) => {
|
|
281
|
-
_setInternalErrorHandler((prev) => __spreadValues(__spreadValues({}, prev), handler));
|
|
282
|
-
},
|
|
283
|
-
[]
|
|
284
|
-
);
|
|
285
|
-
const removeInternalErrorHandler = useCallback((key) => {
|
|
286
|
-
_setInternalErrorHandler((prev) => {
|
|
287
|
-
const _a2 = prev, { [key]: _removed } = _a2, rest = __objRest(_a2, [__restKey(key)]);
|
|
288
|
-
return rest;
|
|
289
|
-
});
|
|
290
|
-
}, []);
|
|
291
|
-
const onErrorRef = useRef(props.onError);
|
|
292
|
-
useEffect(() => {
|
|
293
|
-
onErrorRef.current = props.onError;
|
|
294
|
-
}, [props.onError]);
|
|
295
|
-
const internalHandlersRef = useRef({});
|
|
296
|
-
useEffect(() => {
|
|
297
|
-
internalHandlersRef.current = internalErrorHandlers;
|
|
298
|
-
}, [internalErrorHandlers]);
|
|
299
|
-
const handleErrors = useCallback(
|
|
300
|
-
(error) => __async(this, null, function* () {
|
|
301
|
-
if (copilotApiConfig.publicApiKey && onErrorRef.current) {
|
|
302
|
-
try {
|
|
303
|
-
yield onErrorRef.current(error);
|
|
304
|
-
} catch (e) {
|
|
305
|
-
console.error("Error in public onError handler:", e);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
const handlers = Object.values(internalHandlersRef.current);
|
|
309
|
-
yield Promise.all(
|
|
310
|
-
handlers.map(
|
|
311
|
-
(h) => Promise.resolve(h(error)).catch(
|
|
312
|
-
(e) => console.error("Error in internal error handler:", e)
|
|
313
|
-
)
|
|
314
|
-
)
|
|
315
|
-
);
|
|
316
|
-
}),
|
|
317
|
-
[copilotApiConfig.publicApiKey]
|
|
318
|
-
);
|
|
319
|
-
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = useState({});
|
|
320
|
-
const addChatSuggestionConfiguration = useCallback(
|
|
321
|
-
(id, suggestion) => {
|
|
322
|
-
setChatSuggestionConfiguration((prev) => __spreadProps(__spreadValues({}, prev), { [id]: suggestion }));
|
|
323
|
-
},
|
|
324
|
-
[setChatSuggestionConfiguration]
|
|
325
|
-
);
|
|
326
|
-
const removeChatSuggestionConfiguration = useCallback(
|
|
327
|
-
(id) => {
|
|
328
|
-
setChatSuggestionConfiguration((prev) => {
|
|
329
|
-
const _a2 = prev, { [id]: _ } = _a2, rest = __objRest(_a2, [__restKey(id)]);
|
|
330
|
-
return rest;
|
|
331
|
-
});
|
|
332
|
-
},
|
|
333
|
-
[setChatSuggestionConfiguration]
|
|
334
|
-
);
|
|
335
|
-
const [availableAgents, setAvailableAgents] = useState([]);
|
|
336
|
-
const [coagentStates, setCoagentStates] = useState({});
|
|
337
|
-
const coagentStatesRef = useRef({});
|
|
338
|
-
const setCoagentStatesWithRef = useCallback(
|
|
339
|
-
(value) => {
|
|
340
|
-
const newValue = typeof value === "function" ? value(coagentStatesRef.current) : value;
|
|
341
|
-
coagentStatesRef.current = newValue;
|
|
342
|
-
setCoagentStates((prev) => {
|
|
343
|
-
return newValue;
|
|
344
|
-
});
|
|
345
|
-
},
|
|
346
|
-
[]
|
|
347
|
-
);
|
|
348
|
-
let initialAgentSession = null;
|
|
349
|
-
if (props.agent) {
|
|
350
|
-
initialAgentSession = {
|
|
351
|
-
agentName: props.agent
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
const [agentSession, setAgentSession] = useState(
|
|
355
|
-
initialAgentSession
|
|
356
|
-
);
|
|
357
|
-
useEffect(() => {
|
|
358
|
-
if (props.agent) {
|
|
359
|
-
setAgentSession({
|
|
360
|
-
agentName: props.agent
|
|
361
|
-
});
|
|
362
|
-
} else {
|
|
363
|
-
setAgentSession(null);
|
|
364
|
-
}
|
|
365
|
-
}, [props.agent]);
|
|
366
|
-
const { threadId, setThreadId: setInternalThreadId } = useThreads();
|
|
367
|
-
const setThreadId = useCallback(
|
|
368
|
-
(value) => {
|
|
369
|
-
if (props.threadId) {
|
|
370
|
-
throw new Error(
|
|
371
|
-
"Cannot call setThreadId() when threadId is provided via props."
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
setInternalThreadId(value);
|
|
375
|
-
},
|
|
376
|
-
[props.threadId]
|
|
377
|
-
);
|
|
378
|
-
const [runId, setRunId] = useState(null);
|
|
379
|
-
const chatAbortControllerRef = useRef(null);
|
|
380
|
-
const showDevConsole = shouldShowDevConsole(props.showDevConsole);
|
|
381
|
-
const [interruptActions, _setInterruptActions] = useState({});
|
|
382
|
-
const setInterruptAction = useCallback(
|
|
383
|
-
(action) => {
|
|
384
|
-
_setInterruptActions((prev) => {
|
|
385
|
-
var _a2;
|
|
386
|
-
if (action == null || !action.id) {
|
|
387
|
-
return prev;
|
|
388
|
-
}
|
|
389
|
-
return __spreadProps(__spreadValues({}, prev), {
|
|
390
|
-
[action.id]: __spreadValues(__spreadValues({}, (_a2 = prev[action.id]) != null ? _a2 : {}), action)
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
|
-
},
|
|
394
|
-
[]
|
|
395
|
-
);
|
|
396
|
-
const removeInterruptAction = useCallback((actionId) => {
|
|
397
|
-
_setInterruptActions((prev) => {
|
|
398
|
-
const _a2 = prev, { [actionId]: _ } = _a2, rest = __objRest(_a2, [__restKey(actionId)]);
|
|
399
|
-
return rest;
|
|
400
|
-
});
|
|
401
|
-
}, []);
|
|
402
|
-
const [interruptEventQueue, setInterruptEventQueue] = useState({});
|
|
403
|
-
const addInterruptEvent = useCallback((queuedEvent) => {
|
|
404
|
-
setInterruptEventQueue((prev) => {
|
|
405
|
-
const threadQueue = prev[queuedEvent.threadId] || [];
|
|
406
|
-
return __spreadProps(__spreadValues({}, prev), {
|
|
407
|
-
[queuedEvent.threadId]: [...threadQueue, queuedEvent]
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
}, []);
|
|
411
|
-
const resolveInterruptEvent = useCallback(
|
|
412
|
-
(threadId2, eventId, response) => {
|
|
413
|
-
setInterruptEventQueue((prev) => {
|
|
414
|
-
const threadQueue = prev[threadId2] || [];
|
|
415
|
-
return __spreadProps(__spreadValues({}, prev), {
|
|
416
|
-
[threadId2]: threadQueue.map(
|
|
417
|
-
(queuedEvent) => queuedEvent.eventId === eventId ? __spreadProps(__spreadValues({}, queuedEvent), { event: __spreadProps(__spreadValues({}, queuedEvent.event), { response }) }) : queuedEvent
|
|
418
|
-
)
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
},
|
|
422
|
-
[]
|
|
423
|
-
);
|
|
424
|
-
const memoizedChildren = useMemo(() => children, [children]);
|
|
425
|
-
const [bannerError, setBannerError] = useState(null);
|
|
426
|
-
const agentLock = useMemo(() => {
|
|
427
|
-
var _a2;
|
|
428
|
-
return (_a2 = props.agent) != null ? _a2 : null;
|
|
429
|
-
}, [props.agent]);
|
|
430
|
-
const forwardedParameters = useMemo(
|
|
431
|
-
() => {
|
|
432
|
-
var _a2;
|
|
433
|
-
return (_a2 = props.forwardedParameters) != null ? _a2 : {};
|
|
434
|
-
},
|
|
435
|
-
[props.forwardedParameters]
|
|
436
|
-
);
|
|
437
|
-
const updateExtensions = useCallback(
|
|
438
|
-
(newExtensions) => {
|
|
439
|
-
setExtensions((prev) => {
|
|
440
|
-
const resolved = typeof newExtensions === "function" ? newExtensions(prev) : newExtensions;
|
|
441
|
-
const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;
|
|
442
|
-
const isEqual = isSameLength && // @ts-ignore
|
|
443
|
-
Object.entries(resolved).every(([key, value]) => prev[key] === value);
|
|
444
|
-
return isEqual ? prev : resolved;
|
|
445
|
-
});
|
|
446
|
-
},
|
|
447
|
-
[setExtensions]
|
|
448
|
-
);
|
|
449
|
-
const updateAuthStates = useCallback(
|
|
450
|
-
(newAuthStates) => {
|
|
451
|
-
setAuthStates((prev) => {
|
|
452
|
-
const resolved = typeof newAuthStates === "function" ? newAuthStates(prev) : newAuthStates;
|
|
453
|
-
const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;
|
|
454
|
-
const isEqual = isSameLength && // @ts-ignore
|
|
455
|
-
Object.entries(resolved).every(([key, value]) => prev[key] === value);
|
|
456
|
-
return isEqual ? prev : resolved;
|
|
457
|
-
});
|
|
458
|
-
},
|
|
459
|
-
[setAuthStates]
|
|
460
|
-
);
|
|
461
|
-
const handleSetRegisteredActions = useCallback(
|
|
462
|
-
(actionConfig) => {
|
|
463
|
-
const key = actionConfig.action.name || randomUUID();
|
|
464
|
-
setRegisteredActionConfigs((prev) => {
|
|
465
|
-
const newMap = new Map(prev);
|
|
466
|
-
newMap.set(key, actionConfig);
|
|
467
|
-
return newMap;
|
|
468
|
-
});
|
|
469
|
-
return key;
|
|
470
|
-
},
|
|
471
|
-
[]
|
|
472
|
-
);
|
|
473
|
-
const handleRemoveRegisteredAction = useCallback((actionKey) => {
|
|
474
|
-
setRegisteredActionConfigs((prev) => {
|
|
475
|
-
const newMap = new Map(prev);
|
|
476
|
-
newMap.delete(actionKey);
|
|
477
|
-
return newMap;
|
|
478
|
-
});
|
|
479
|
-
}, []);
|
|
480
|
-
const RegisteredActionsRenderer = useMemo(() => {
|
|
481
|
-
return () => /* @__PURE__ */ jsx(Fragment, { children: Array.from(registeredActionConfigs.entries()).map(([key, config]) => {
|
|
482
|
-
const Component = config.component;
|
|
483
|
-
return /* @__PURE__ */ jsx(Component, { action: config.action }, key);
|
|
484
|
-
}) });
|
|
485
|
-
}, [registeredActionConfigs]);
|
|
486
|
-
return /* @__PURE__ */ jsx(
|
|
487
|
-
CopilotChatConfigurationProvider,
|
|
488
|
-
{
|
|
489
|
-
agentId: (_b = props.agent) != null ? _b : "default",
|
|
490
|
-
threadId,
|
|
491
|
-
children: /* @__PURE__ */ jsxs(
|
|
492
|
-
CopilotContext.Provider,
|
|
493
|
-
{
|
|
494
|
-
value: {
|
|
495
|
-
actions,
|
|
496
|
-
chatComponentsCache,
|
|
497
|
-
getFunctionCallHandler,
|
|
498
|
-
setAction,
|
|
499
|
-
removeAction,
|
|
500
|
-
setRegisteredActions: handleSetRegisteredActions,
|
|
501
|
-
removeRegisteredAction: handleRemoveRegisteredAction,
|
|
502
|
-
getContextString,
|
|
503
|
-
addContext,
|
|
504
|
-
removeContext,
|
|
505
|
-
getAllContext,
|
|
506
|
-
getDocumentsContext,
|
|
507
|
-
addDocumentContext,
|
|
508
|
-
removeDocumentContext,
|
|
509
|
-
copilotApiConfig,
|
|
510
|
-
isLoading,
|
|
511
|
-
setIsLoading,
|
|
512
|
-
chatSuggestionConfiguration,
|
|
513
|
-
addChatSuggestionConfiguration,
|
|
514
|
-
removeChatSuggestionConfiguration,
|
|
515
|
-
chatInstructions,
|
|
516
|
-
setChatInstructions,
|
|
517
|
-
additionalInstructions,
|
|
518
|
-
setAdditionalInstructions,
|
|
519
|
-
showDevConsole,
|
|
520
|
-
coagentStates,
|
|
521
|
-
setCoagentStates,
|
|
522
|
-
coagentStatesRef,
|
|
523
|
-
setCoagentStatesWithRef,
|
|
524
|
-
agentSession,
|
|
525
|
-
setAgentSession,
|
|
526
|
-
forwardedParameters,
|
|
527
|
-
agentLock,
|
|
528
|
-
threadId,
|
|
529
|
-
setThreadId,
|
|
530
|
-
runId,
|
|
531
|
-
setRunId,
|
|
532
|
-
chatAbortControllerRef,
|
|
533
|
-
availableAgents,
|
|
534
|
-
authConfig_c: props.authConfig_c,
|
|
535
|
-
authStates_c: authStates,
|
|
536
|
-
setAuthStates_c: updateAuthStates,
|
|
537
|
-
extensions,
|
|
538
|
-
setExtensions: updateExtensions,
|
|
539
|
-
interruptActions,
|
|
540
|
-
setInterruptAction,
|
|
541
|
-
removeInterruptAction,
|
|
542
|
-
interruptEventQueue,
|
|
543
|
-
addInterruptEvent,
|
|
544
|
-
resolveInterruptEvent,
|
|
545
|
-
bannerError,
|
|
546
|
-
setBannerError,
|
|
547
|
-
onError: handleErrors,
|
|
548
|
-
internalErrorHandlers,
|
|
549
|
-
setInternalErrorHandler,
|
|
550
|
-
removeInternalErrorHandler
|
|
551
|
-
},
|
|
552
|
-
children: [
|
|
553
|
-
/* @__PURE__ */ jsx(CopilotListeners, {}),
|
|
554
|
-
/* @__PURE__ */ jsx(CopilotKitErrorBridge, {}),
|
|
555
|
-
/* @__PURE__ */ jsxs(CoAgentStateRendersProvider, { children: [
|
|
556
|
-
/* @__PURE__ */ jsx(MessagesTapProvider, { children: /* @__PURE__ */ jsxs(CopilotMessages, { children: [
|
|
557
|
-
memoizedChildren,
|
|
558
|
-
/* @__PURE__ */ jsx(RegisteredActionsRenderer, {})
|
|
559
|
-
] }) }),
|
|
560
|
-
bannerError && showDevConsole && /* @__PURE__ */ jsx(
|
|
561
|
-
UsageBanner,
|
|
562
|
-
{
|
|
563
|
-
severity: bannerError.severity,
|
|
564
|
-
message: bannerError.message,
|
|
565
|
-
onClose: () => setBannerError(null),
|
|
566
|
-
actions: getErrorActions(bannerError)
|
|
567
|
-
}
|
|
568
|
-
)
|
|
569
|
-
] })
|
|
570
|
-
]
|
|
571
|
-
}
|
|
572
|
-
)
|
|
573
|
-
}
|
|
574
|
-
);
|
|
575
|
-
}
|
|
576
|
-
var defaultCopilotContextCategories = ["global"];
|
|
577
|
-
function entryPointsToFunctionCallHandler(actions) {
|
|
578
|
-
return (_0) => __async(this, [_0], function* ({
|
|
579
|
-
name,
|
|
580
|
-
args
|
|
581
|
-
}) {
|
|
582
|
-
let actionsByFunctionName = {};
|
|
583
|
-
for (let action2 of actions) {
|
|
584
|
-
actionsByFunctionName[action2.name] = action2;
|
|
585
|
-
}
|
|
586
|
-
const action = actionsByFunctionName[name];
|
|
587
|
-
let result = void 0;
|
|
588
|
-
if (action) {
|
|
589
|
-
yield new Promise((resolve, reject) => {
|
|
590
|
-
flushSync(() => __async(this, null, function* () {
|
|
591
|
-
var _a;
|
|
592
|
-
try {
|
|
593
|
-
result = yield (_a = action.handler) == null ? void 0 : _a.call(action, args);
|
|
594
|
-
resolve();
|
|
595
|
-
} catch (error) {
|
|
596
|
-
reject(error);
|
|
597
|
-
}
|
|
598
|
-
}));
|
|
599
|
-
});
|
|
600
|
-
yield new Promise((resolve) => setTimeout(resolve, 20));
|
|
601
|
-
}
|
|
602
|
-
return result;
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
function formatFeatureName(featureName) {
|
|
606
|
-
return featureName.replace(/_c$/, "").split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
607
|
-
}
|
|
608
|
-
function validateProps(props) {
|
|
609
|
-
const cloudFeatures = Object.keys(props).filter((key) => key.endsWith("_c"));
|
|
610
|
-
const hasApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
611
|
-
if (!props.runtimeUrl && !hasApiKey) {
|
|
612
|
-
throw new ConfigurationError(
|
|
613
|
-
"Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'"
|
|
614
|
-
);
|
|
615
|
-
}
|
|
616
|
-
if (cloudFeatures.length > 0 && !hasApiKey) {
|
|
617
|
-
throw new MissingPublicApiKeyError(
|
|
618
|
-
`Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`
|
|
619
|
-
);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
export {
|
|
624
|
-
CopilotKit,
|
|
625
|
-
CopilotKitInternal,
|
|
626
|
-
defaultCopilotContextCategories
|
|
627
|
-
};
|
|
628
|
-
//# sourceMappingURL=chunk-2JZZD4RP.mjs.map
|