@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-UA23VX5J.mjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__spreadProps,
|
|
3
|
-
__spreadValues
|
|
4
|
-
} from "./chunk-SKC7AJIV.mjs";
|
|
5
|
-
|
|
6
|
-
// src/hooks/use-frontend-tool.ts
|
|
7
|
-
import React, { useEffect, useMemo, useRef } from "react";
|
|
8
|
-
import {
|
|
9
|
-
getZodParameters
|
|
10
|
-
} from "@copilotkit/shared";
|
|
11
|
-
import { parseJson } from "@copilotkit/shared";
|
|
12
|
-
import {
|
|
13
|
-
useFrontendTool as useFrontendToolVNext
|
|
14
|
-
} from "@copilotkitnext/react";
|
|
15
|
-
function useFrontendTool(tool, dependencies) {
|
|
16
|
-
const { name, description, parameters, render, followUp } = tool;
|
|
17
|
-
const zodParameters = getZodParameters(parameters);
|
|
18
|
-
const renderRef = useRef(render);
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
renderRef.current = render;
|
|
21
|
-
}, [render, ...dependencies != null ? dependencies : []]);
|
|
22
|
-
const normalizedRender = useMemo(() => {
|
|
23
|
-
if (typeof render === "undefined") {
|
|
24
|
-
return void 0;
|
|
25
|
-
}
|
|
26
|
-
return (args) => {
|
|
27
|
-
const currentRender = renderRef.current;
|
|
28
|
-
if (typeof currentRender === "undefined") {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
if (typeof currentRender === "string") {
|
|
32
|
-
return React.createElement(React.Fragment, null, currentRender);
|
|
33
|
-
}
|
|
34
|
-
const renderArgs = __spreadProps(__spreadValues({}, args), {
|
|
35
|
-
result: typeof args.result === "string" ? parseJson(args.result, args.result) : args.result
|
|
36
|
-
});
|
|
37
|
-
const rendered = currentRender(renderArgs);
|
|
38
|
-
if (typeof rendered === "string") {
|
|
39
|
-
return React.createElement(React.Fragment, null, rendered);
|
|
40
|
-
}
|
|
41
|
-
return rendered != null ? rendered : null;
|
|
42
|
-
};
|
|
43
|
-
}, []);
|
|
44
|
-
const handlerRef = useRef(tool.handler);
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
handlerRef.current = tool.handler;
|
|
47
|
-
}, [tool.handler, ...dependencies != null ? dependencies : []]);
|
|
48
|
-
const normalizedHandler = tool.handler ? (args) => {
|
|
49
|
-
var _a;
|
|
50
|
-
return (_a = handlerRef.current) == null ? void 0 : _a.call(handlerRef, args);
|
|
51
|
-
} : void 0;
|
|
52
|
-
useFrontendToolVNext({
|
|
53
|
-
name,
|
|
54
|
-
description,
|
|
55
|
-
parameters: zodParameters,
|
|
56
|
-
handler: normalizedHandler,
|
|
57
|
-
followUp,
|
|
58
|
-
render: normalizedRender
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export {
|
|
63
|
-
useFrontendTool
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=chunk-UA23VX5J.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-frontend-tool.ts"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from \"react\";\nimport { ActionRenderProps, FrontendAction } from \"../types/frontend-action\";\nimport {\n Parameter,\n getZodParameters,\n MappedParameterTypes,\n} from \"@copilotkit/shared\";\nimport { parseJson } from \"@copilotkit/shared\";\nimport { ToolCallStatus } from \"@copilotkitnext/core\";\nimport {\n type ReactFrontendTool,\n useFrontendTool as useFrontendToolVNext,\n} from \"@copilotkitnext/react\";\n\ntype FrontendToolOptions<T extends Parameter[] | []> = ReactFrontendTool<\n MappedParameterTypes<T>\n>;\ntype FrontendToolRenderArgs<T extends Parameter[] | []> =\n | {\n name: string;\n args: Partial<MappedParameterTypes<T>>;\n status: ToolCallStatus.InProgress;\n result: undefined;\n }\n | {\n name: string;\n args: MappedParameterTypes<T>;\n status: ToolCallStatus.Executing;\n result: undefined;\n }\n | {\n name: string;\n args: MappedParameterTypes<T>;\n status: ToolCallStatus.Complete;\n result: string;\n };\n\nexport type UseFrontendToolArgs<T extends Parameter[] | [] = []> = {\n available?: \"disabled\" | \"enabled\";\n} & Pick<\n FrontendAction<T>,\n \"name\" | \"description\" | \"parameters\" | \"handler\" | \"followUp\" | \"render\"\n>;\n\nexport function useFrontendTool<const T extends Parameter[] = []>(\n tool: UseFrontendToolArgs<T>,\n dependencies?: any[],\n) {\n const { name, description, parameters, render, followUp } = tool;\n const zodParameters = getZodParameters(parameters);\n\n const renderRef = useRef<typeof render>(render);\n\n useEffect(() => {\n renderRef.current = render;\n }, [render, ...(dependencies ?? [])]);\n\n const normalizedRender: FrontendToolOptions<T>[\"render\"] | undefined =\n useMemo(() => {\n if (typeof render === \"undefined\") {\n return undefined;\n }\n\n return ((args: FrontendToolRenderArgs<T>) => {\n const currentRender = renderRef.current;\n\n if (typeof currentRender === \"undefined\") {\n return null;\n }\n\n if (typeof currentRender === \"string\") {\n return React.createElement(React.Fragment, null, currentRender);\n }\n\n const renderArgs = {\n ...args,\n result:\n typeof args.result === \"string\"\n ? parseJson(args.result, args.result)\n : args.result,\n } as ActionRenderProps<T>;\n\n const rendered = currentRender(renderArgs);\n\n if (typeof rendered === \"string\") {\n return React.createElement(React.Fragment, null, rendered);\n }\n\n return rendered ?? null;\n }) as FrontendToolOptions<T>[\"render\"];\n }, []);\n\n // Handler ref to avoid stale closures\n const handlerRef = useRef<typeof tool.handler>(tool.handler);\n\n useEffect(() => {\n handlerRef.current = tool.handler;\n }, [tool.handler, ...(dependencies ?? [])]);\n\n const normalizedHandler = tool.handler\n ? (args: MappedParameterTypes<T>) => handlerRef.current?.(args)\n : undefined;\n\n useFrontendToolVNext<MappedParameterTypes<T>>({\n name,\n description,\n parameters: zodParameters,\n handler: normalizedHandler,\n followUp,\n render: normalizedRender,\n });\n}\n"],"mappings":";;;;;;AAAA,OAAO,SAAS,WAAW,SAAS,cAAc;AAElD;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,iBAAiB;AAE1B;AAAA,EAEE,mBAAmB;AAAA,OACd;AAgCA,SAAS,gBACd,MACA,cACA;AACA,QAAM,EAAE,MAAM,aAAa,YAAY,QAAQ,SAAS,IAAI;AAC5D,QAAM,gBAAgB,iBAAiB,UAAU;AAEjD,QAAM,YAAY,OAAsB,MAAM;AAE9C,YAAU,MAAM;AACd,cAAU,UAAU;AAAA,EACtB,GAAG,CAAC,QAAQ,GAAI,sCAAgB,CAAC,CAAE,CAAC;AAEpC,QAAM,mBACJ,QAAQ,MAAM;AACZ,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AAEA,WAAQ,CAAC,SAAoC;AAC3C,YAAM,gBAAgB,UAAU;AAEhC,UAAI,OAAO,kBAAkB,aAAa;AACxC,eAAO;AAAA,MACT;AAEA,UAAI,OAAO,kBAAkB,UAAU;AACrC,eAAO,MAAM,cAAc,MAAM,UAAU,MAAM,aAAa;AAAA,MAChE;AAEA,YAAM,aAAa,iCACd,OADc;AAAA,QAEjB,QACE,OAAO,KAAK,WAAW,WACnB,UAAU,KAAK,QAAQ,KAAK,MAAM,IAClC,KAAK;AAAA,MACb;AAEA,YAAM,WAAW,cAAc,UAAU;AAEzC,UAAI,OAAO,aAAa,UAAU;AAChC,eAAO,MAAM,cAAc,MAAM,UAAU,MAAM,QAAQ;AAAA,MAC3D;AAEA,aAAO,8BAAY;AAAA,IACrB;AAAA,EACF,GAAG,CAAC,CAAC;AAGP,QAAM,aAAa,OAA4B,KAAK,OAAO;AAE3D,YAAU,MAAM;AACd,eAAW,UAAU,KAAK;AAAA,EAC5B,GAAG,CAAC,KAAK,SAAS,GAAI,sCAAgB,CAAC,CAAE,CAAC;AAE1C,QAAM,oBAAoB,KAAK,UAC3B,CAAC,SAA+B;AApGtC;AAoGyC,4BAAW,YAAX,oCAAqB;AAAA,MACxD;AAEJ,uBAA8C;AAAA,IAC5C;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,SAAS;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,EACV,CAAC;AACH;","names":[]}
|
package/dist/chunk-V42VL2JR.mjs
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useAgentNodeName
|
|
3
|
-
} from "./chunk-I76HKHPJ.mjs";
|
|
4
|
-
import {
|
|
5
|
-
useCopilotContext
|
|
6
|
-
} from "./chunk-C7HSVDHD.mjs";
|
|
7
|
-
import {
|
|
8
|
-
__spreadProps,
|
|
9
|
-
__spreadValues
|
|
10
|
-
} from "./chunk-SKC7AJIV.mjs";
|
|
11
|
-
|
|
12
|
-
// src/hooks/use-langgraph-interrupt-render.ts
|
|
13
|
-
import React, { useCallback, useEffect, useMemo } from "react";
|
|
14
|
-
import { MetaEventName } from "@copilotkit/runtime-client-gql";
|
|
15
|
-
import { dataToUUID, parseJson } from "@copilotkit/shared";
|
|
16
|
-
import { useCopilotChatConfiguration } from "@copilotkitnext/react";
|
|
17
|
-
var InterruptRenderer = ({
|
|
18
|
-
event,
|
|
19
|
-
result,
|
|
20
|
-
render,
|
|
21
|
-
resolve
|
|
22
|
-
}) => {
|
|
23
|
-
return render({ event, result, resolve });
|
|
24
|
-
};
|
|
25
|
-
function useLangGraphInterruptRender(agent) {
|
|
26
|
-
var _a;
|
|
27
|
-
const {
|
|
28
|
-
interruptActions,
|
|
29
|
-
agentSession,
|
|
30
|
-
threadId,
|
|
31
|
-
interruptEventQueue,
|
|
32
|
-
addInterruptEvent,
|
|
33
|
-
resolveInterruptEvent
|
|
34
|
-
} = useCopilotContext();
|
|
35
|
-
const existingConfig = useCopilotChatConfiguration();
|
|
36
|
-
const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
|
|
37
|
-
const nodeName = useAgentNodeName(resolvedAgentId);
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (!agent)
|
|
40
|
-
return;
|
|
41
|
-
let localInterrupt = null;
|
|
42
|
-
const subscriber = {
|
|
43
|
-
onCustomEvent: ({ event }) => {
|
|
44
|
-
if (event.name === "on_interrupt") {
|
|
45
|
-
const eventData = {
|
|
46
|
-
name: MetaEventName.LangGraphInterruptEvent,
|
|
47
|
-
type: event.type,
|
|
48
|
-
value: parseJson(event.value, event.value)
|
|
49
|
-
};
|
|
50
|
-
const eventId = dataToUUID(eventData, "interruptEvents");
|
|
51
|
-
localInterrupt = {
|
|
52
|
-
eventId,
|
|
53
|
-
threadId,
|
|
54
|
-
event: eventData
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
onRunStartedEvent: () => {
|
|
59
|
-
localInterrupt = null;
|
|
60
|
-
},
|
|
61
|
-
onRunFinalized: () => {
|
|
62
|
-
if (localInterrupt) {
|
|
63
|
-
addInterruptEvent(localInterrupt);
|
|
64
|
-
localInterrupt = null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const { unsubscribe } = agent.subscribe(subscriber);
|
|
69
|
-
return () => {
|
|
70
|
-
unsubscribe();
|
|
71
|
-
};
|
|
72
|
-
}, [agent, threadId]);
|
|
73
|
-
const handleResolve = useCallback(
|
|
74
|
-
(eventId, response) => {
|
|
75
|
-
agent == null ? void 0 : agent.runAgent({
|
|
76
|
-
forwardedProps: {
|
|
77
|
-
command: {
|
|
78
|
-
resume: response
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
resolveInterruptEvent(threadId, eventId, response != null ? response : "");
|
|
83
|
-
},
|
|
84
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
|
-
[agent, threadId]
|
|
86
|
-
);
|
|
87
|
-
return useMemo(() => {
|
|
88
|
-
const eventQueue = interruptEventQueue[threadId] || [];
|
|
89
|
-
const currentQueuedEvent = eventQueue.find((qe) => !qe.event.response);
|
|
90
|
-
if (!currentQueuedEvent || !agentSession)
|
|
91
|
-
return null;
|
|
92
|
-
const allActions = Object.values(interruptActions);
|
|
93
|
-
const matchingAction = allActions.find((action) => {
|
|
94
|
-
if (!action.enabled)
|
|
95
|
-
return true;
|
|
96
|
-
return action.enabled({
|
|
97
|
-
eventValue: currentQueuedEvent.event.value,
|
|
98
|
-
agentMetadata: __spreadProps(__spreadValues({}, agentSession), {
|
|
99
|
-
nodeName
|
|
100
|
-
})
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
if (!matchingAction)
|
|
104
|
-
return null;
|
|
105
|
-
const { render, handler } = matchingAction;
|
|
106
|
-
const resolveInterrupt = (response) => {
|
|
107
|
-
handleResolve(currentQueuedEvent.eventId, response);
|
|
108
|
-
};
|
|
109
|
-
let result = null;
|
|
110
|
-
if (handler) {
|
|
111
|
-
result = handler({
|
|
112
|
-
event: currentQueuedEvent.event,
|
|
113
|
-
resolve: resolveInterrupt
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
if (!render)
|
|
117
|
-
return null;
|
|
118
|
-
return React.createElement(InterruptRenderer, {
|
|
119
|
-
event: currentQueuedEvent.event,
|
|
120
|
-
result,
|
|
121
|
-
render,
|
|
122
|
-
resolve: resolveInterrupt
|
|
123
|
-
});
|
|
124
|
-
}, [
|
|
125
|
-
interruptActions,
|
|
126
|
-
interruptEventQueue,
|
|
127
|
-
threadId,
|
|
128
|
-
agentSession,
|
|
129
|
-
handleResolve
|
|
130
|
-
]);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export {
|
|
134
|
-
useLangGraphInterruptRender
|
|
135
|
-
};
|
|
136
|
-
//# sourceMappingURL=chunk-V42VL2JR.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-langgraph-interrupt-render.ts"],"sourcesContent":["import { useCopilotContext } from \"../context\";\nimport React, { useCallback, useEffect, useMemo } from \"react\";\nimport type { AbstractAgent, AgentSubscriber } from \"@ag-ui/client\";\nimport { MetaEventName } from \"@copilotkit/runtime-client-gql\";\nimport { dataToUUID, parseJson } from \"@copilotkit/shared\";\nimport { useAgentNodeName } from \"./use-agent-nodename\";\nimport { useCopilotChatConfiguration } from \"@copilotkitnext/react\";\n\ntype InterruptProps = {\n event: any;\n result: any;\n render: (props: {\n event: any;\n result: any;\n resolve: (response: string) => void;\n }) => string | React.ReactElement;\n resolve: (response: string) => void;\n};\n\nconst InterruptRenderer: React.FC<InterruptProps> = ({\n event,\n result,\n render,\n resolve,\n}) => {\n return render({ event, result, resolve });\n};\n\nexport function useLangGraphInterruptRender(\n agent: AbstractAgent,\n): string | React.ReactElement | null {\n const {\n interruptActions,\n agentSession,\n threadId,\n interruptEventQueue,\n addInterruptEvent,\n resolveInterruptEvent,\n } = useCopilotContext();\n const existingConfig = useCopilotChatConfiguration();\n const resolvedAgentId = existingConfig?.agentId ?? \"default\";\n const nodeName = useAgentNodeName(resolvedAgentId);\n\n useEffect(() => {\n if (!agent) return;\n let localInterrupt: any = null;\n const subscriber: AgentSubscriber = {\n onCustomEvent: ({ event }) => {\n if (event.name === \"on_interrupt\") {\n const eventData = {\n name: MetaEventName.LangGraphInterruptEvent,\n type: event.type,\n value: parseJson(event.value, event.value),\n };\n const eventId = dataToUUID(eventData, \"interruptEvents\");\n localInterrupt = {\n eventId,\n threadId,\n event: eventData,\n };\n }\n },\n onRunStartedEvent: () => {\n localInterrupt = null;\n },\n onRunFinalized: () => {\n if (localInterrupt) {\n addInterruptEvent(localInterrupt);\n localInterrupt = null;\n }\n },\n };\n\n const { unsubscribe } = agent.subscribe(subscriber);\n return () => {\n unsubscribe();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [agent, threadId]);\n\n const handleResolve = useCallback(\n (eventId: string, response?: string) => {\n agent?.runAgent({\n forwardedProps: {\n command: {\n resume: response,\n },\n },\n });\n resolveInterruptEvent(threadId, eventId, response ?? \"\");\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [agent, threadId],\n );\n\n return useMemo(() => {\n // Get the queue for this thread and find the first unresponded event\n const eventQueue = interruptEventQueue[threadId] || [];\n const currentQueuedEvent = eventQueue.find((qe) => !qe.event.response);\n\n if (!currentQueuedEvent || !agentSession) return null;\n\n // Find the first matching action from all registered actions\n const allActions = Object.values(interruptActions);\n const matchingAction = allActions.find((action) => {\n if (!action.enabled) return true; // No filter = match all\n return action.enabled({\n eventValue: currentQueuedEvent.event.value,\n agentMetadata: {\n ...agentSession,\n nodeName,\n },\n });\n });\n\n if (!matchingAction) return null;\n\n const { render, handler } = matchingAction;\n\n const resolveInterrupt = (response: string) => {\n handleResolve(currentQueuedEvent.eventId, response);\n };\n\n let result = null;\n if (handler) {\n result = handler({\n event: currentQueuedEvent.event,\n resolve: resolveInterrupt,\n });\n }\n\n if (!render) return null;\n\n return React.createElement(InterruptRenderer, {\n event: currentQueuedEvent.event,\n result,\n render,\n resolve: resolveInterrupt,\n });\n }, [\n interruptActions,\n interruptEventQueue,\n threadId,\n agentSession,\n handleResolve,\n ]);\n}\n"],"mappings":";;;;;;;;;;;;AACA,OAAO,SAAS,aAAa,W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+0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useRenderToolCall
|
|
3
|
-
} from "./chunk-MBJ7OLYI.mjs";
|
|
4
|
-
import {
|
|
5
|
-
useFrontendTool
|
|
6
|
-
} from "./chunk-UA23VX5J.mjs";
|
|
7
|
-
import {
|
|
8
|
-
useHumanInTheLoop
|
|
9
|
-
} from "./chunk-LNGBARXE.mjs";
|
|
10
|
-
import {
|
|
11
|
-
__spreadProps,
|
|
12
|
-
__spreadValues
|
|
13
|
-
} from "./chunk-SKC7AJIV.mjs";
|
|
14
|
-
|
|
15
|
-
// src/hooks/use-copilot-action.ts
|
|
16
|
-
import { useState } from "react";
|
|
17
|
-
function getActionConfig(action) {
|
|
18
|
-
if (action.name === "*") {
|
|
19
|
-
return {
|
|
20
|
-
type: "render",
|
|
21
|
-
action
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
if ("renderAndWaitForResponse" in action || "renderAndWait" in action) {
|
|
25
|
-
let render = action.render;
|
|
26
|
-
if (!render && "renderAndWaitForResponse" in action) {
|
|
27
|
-
render = action.renderAndWaitForResponse;
|
|
28
|
-
}
|
|
29
|
-
if (!render && "renderAndWait" in action) {
|
|
30
|
-
render = action.renderAndWait;
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
type: "hitl",
|
|
34
|
-
action: __spreadProps(__spreadValues({}, action), { render })
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if ("available" in action) {
|
|
38
|
-
if (action.available === "enabled" || action.available === "remote") {
|
|
39
|
-
return {
|
|
40
|
-
type: "frontend",
|
|
41
|
-
action
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
if (action.available === "frontend" || action.available === "disabled") {
|
|
45
|
-
return {
|
|
46
|
-
type: "render",
|
|
47
|
-
action
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if ("handler" in action) {
|
|
52
|
-
return {
|
|
53
|
-
type: "frontend",
|
|
54
|
-
action
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
throw new Error("Invalid action configuration");
|
|
58
|
-
}
|
|
59
|
-
function useCopilotAction(action, dependencies) {
|
|
60
|
-
const [initialActionConfig] = useState(getActionConfig(action));
|
|
61
|
-
const currentActionConfig = getActionConfig(action);
|
|
62
|
-
if (initialActionConfig.type !== currentActionConfig.type) {
|
|
63
|
-
throw new Error("Action configuration changed between renders");
|
|
64
|
-
}
|
|
65
|
-
switch (currentActionConfig.type) {
|
|
66
|
-
case "render":
|
|
67
|
-
return useRenderToolCall(currentActionConfig.action, dependencies);
|
|
68
|
-
case "hitl":
|
|
69
|
-
return useHumanInTheLoop(currentActionConfig.action, dependencies);
|
|
70
|
-
case "frontend":
|
|
71
|
-
return useFrontendTool(currentActionConfig.action, dependencies);
|
|
72
|
-
default:
|
|
73
|
-
throw new Error("Invalid action configuration");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export {
|
|
78
|
-
useCopilotAction
|
|
79
|
-
};
|
|
80
|
-
//# sourceMappingURL=chunk-VZ4NSOFQ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-copilot-action.ts"],"sourcesContent":["/**\n * Example usage of useCopilotAction with complex parameters:\n *\n * @example\n * useCopilotAction({\n * name: \"myAction\",\n * parameters: [\n * { name: \"arg1\", type: \"string\", enum: [\"option1\", \"option2\", \"option3\"], required: false },\n * { name: \"arg2\", type: \"number\" },\n * {\n * name: \"arg3\",\n * type: \"object\",\n * attributes: [\n * { name: \"nestedArg1\", type: \"boolean\" },\n * { name: \"xyz\", required: false },\n * ],\n * },\n * { name: \"arg4\", type: \"number[]\" },\n * ],\n * handler: ({ arg1, arg2, arg3, arg4 }) => {\n * const x = arg3.nestedArg1;\n * const z = arg3.xyz;\n * console.log(arg1, arg2, arg3);\n * },\n * });\n *\n * @example\n * // Simple action without parameters\n * useCopilotAction({\n * name: \"myAction\",\n * handler: () => {\n * console.log(\"No parameters provided.\");\n * },\n * });\n *\n * @example\n * // Interactive action with UI rendering and response handling\n * useCopilotAction({\n * name: \"handleMeeting\",\n * description: \"Handle a meeting by booking or canceling\",\n * parameters: [\n * {\n * name: \"meeting\",\n * type: \"string\",\n * description: \"The meeting to handle\",\n * required: true,\n * },\n * {\n * name: \"date\",\n * type: \"string\",\n * description: \"The date of the meeting\",\n * required: true,\n * },\n * {\n * name: \"title\",\n * type: \"string\",\n * description: \"The title of the meeting\",\n * required: true,\n * },\n * ],\n * renderAndWaitForResponse: ({ args, respond, status }) => {\n * const { meeting, date, title } = args;\n * return (\n * <MeetingConfirmationDialog\n * meeting={meeting}\n * date={date}\n * title={title}\n * onConfirm={() => respond('meeting confirmed')}\n * onCancel={() => respond('meeting canceled')}\n * />\n * );\n * },\n * });\n *\n * @example\n * // Catch all action allows you to render actions that are not defined in the frontend\n * useCopilotAction({\n * name: \"*\",\n * render: ({ name, args, status, result, handler, respond }) => {\n * return <div>Rendering action: {name}</div>;\n * },\n * });\n */\n\n/**\n * <img src=\"https://cdn.copilotkit.ai/docs/copilotkit/images/use-copilot-action/useCopilotAction.gif\" width=\"500\" />\n * `useCopilotAction` is a React hook that you can use in your application to provide\n * custom actions that can be called by the AI. Essentially, it allows the Copilot to\n * execute these actions contextually during a chat, based on the user's interactions\n * and needs.\n *\n * Here's how it works:\n *\n * Use `useCopilotAction` to set up actions that the Copilot can call. To provide\n * more context to the Copilot, you can provide it with a `description` (for example to explain\n * what the action does, under which conditions it can be called, etc.).\n *\n * Then you define the parameters of the action, which can be simple, e.g. primitives like strings or numbers,\n * or complex, e.g. objects or arrays.\n *\n * Finally, you provide a `handler` function that receives the parameters and returns a result.\n * CopilotKit takes care of automatically inferring the parameter types, so you get type safety\n * and autocompletion for free.\n *\n * To render a custom UI for the action, you can provide a `render()` function. This function\n * lets you render a custom component or return a string to display.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * ```tsx\n * useCopilotAction({\n * name: \"sayHello\",\n * description: \"Say hello to someone.\",\n * parameters: [\n * {\n * name: \"name\",\n * type: \"string\",\n * description: \"name of the person to say greet\",\n * },\n * ],\n * handler: async ({ name }) => {\n * alert(`Hello, ${name}!`);\n * },\n * });\n * ```\n *\n * ## Generative UI\n *\n * This hooks enables you to dynamically generate UI elements and render them in the copilot chat. For more information, check out the [Generative UI](/guides/generative-ui) page.\n */\nimport { useEffect, useRef, useState } from \"react\";\nimport { Parameter } from \"@copilotkit/shared\";\nimport {\n CatchAllFrontendAction,\n FrontendAction,\n} from \"../types/frontend-action\";\nimport { useFrontendTool, UseFrontendToolArgs } from \"./use-frontend-tool\";\nimport {\n useRenderToolCall,\n UseRenderToolCallArgs,\n} from \"./use-render-tool-call\";\nimport {\n useHumanInTheLoop,\n UseHumanInTheLoopArgs,\n} from \"./use-human-in-the-loop\";\nimport { useCopilotContext } from \"../context\";\n\n// Helper to determine which component and action config to use\nfunction getActionConfig<const T extends Parameter[] | [] = []>(\n action: FrontendAction<T> | CatchAllFrontendAction,\n) {\n if (action.name === \"*\") {\n return {\n type: \"render\" as const,\n action: action as UseRenderToolCallArgs<T>,\n };\n }\n\n if (\"renderAndWaitForResponse\" in action || \"renderAndWait\" in action) {\n let render = action.render;\n if (!render && \"renderAndWaitForResponse\" in action) {\n // @ts-expect-error -- renderAndWaitForResponse is deprecated, but we need to support it for backwards compatibility\n render = action.renderAndWaitForResponse;\n }\n if (!render && \"renderAndWait\" in action) {\n // @ts-expect-error -- renderAndWait is deprecated, but we need to support it for backwards compatibility\n render = action.renderAndWait;\n }\n\n return {\n type: \"hitl\" as const,\n action: { ...action, render } as UseHumanInTheLoopArgs<T>,\n };\n }\n\n if (\"available\" in action) {\n if (action.available === \"enabled\" || action.available === \"remote\") {\n return {\n type: \"frontend\" as const,\n action: action as UseFrontendToolArgs<T>,\n };\n }\n if (action.available === \"frontend\" || action.available === \"disabled\") {\n return {\n type: \"render\" as const,\n action: action as UseRenderToolCallArgs<T>,\n };\n }\n }\n\n if (\"handler\" in action) {\n return {\n type: \"frontend\" as const,\n action: action as UseFrontendToolArgs<T>,\n };\n }\n\n throw new Error(\"Invalid action configuration\");\n}\n\n/**\n * useCopilotAction is a legacy hook maintained for backwards compatibility.\n *\n * To avoid violating React's Rules of Hooks (which prohibit conditional hook calls),\n * we use a registration pattern:\n * 1. This hook registers the action configuration with the CopilotContext\n * 2. A renderer component in CopilotKit actually renders the appropriate hook wrapper\n * 3. React properly manages hook state since components are rendered, not conditionally called\n *\n * This allows action types to change between renders without corrupting React's hook state.\n */\nexport function useCopilotAction<const T extends Parameter[] | [] = []>(\n action: FrontendAction<T> | CatchAllFrontendAction,\n dependencies?: any[],\n): void {\n const [initialActionConfig] = useState(getActionConfig(action));\n const currentActionConfig = getActionConfig(action);\n\n /**\n * Calling hooks conditionally violates React's Rules of Hooks. This rule exists because\n * React maintains the call stack for hooks like useEffect or useState, and conditionally\n * calling a hook would result in inconsistent call stacks between renders.\n *\n * Unfortunately, useCopilotAction _has_ to conditionally call a hook based on the\n * supplied parameters. In order to avoid breaking React's call stack tracking, while\n * breaking the Rule of Hooks, we use a ref to store the initial action configuration\n * and throw an error if the _configuration_ changes such that we would call a different hook.\n */\n if (initialActionConfig.type !== currentActionConfig.type) {\n throw new Error(\"Action configuration changed between renders\");\n }\n\n switch (currentActionConfig.type) {\n case \"render\":\n return useRenderToolCall(currentActionConfig.action, dependencies);\n case \"hitl\":\n return useHumanInTheLoop(currentActionConfig.action, dependencies);\n case \"frontend\":\n return useFrontendTool(currentActionConfig.action, dependencies);\n default:\n throw new Error(\"Invalid action configuration\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoIA,SAA4B,gBAAgB;AAkB5C,SAAS,gBACP,QACA;AACA,MAAI,OAAO,SAAS,KAAK;AACvB,WAAO;AAAA,MACL,MAAM;AAAA,MACN;AAAA,IACF;AAAA,EACF;AAEA,MAAI,8BAA8B,UAAU,mBAAmB,QAAQ;AACrE,QAAI,SAAS,OAAO;AACpB,QAAI,CAA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-
// src/components/CopilotListeners.tsx
|
|
6
|
-
import { useCallback, useEffect, useRef } from "react";
|
|
7
|
-
import {
|
|
8
|
-
useAgent,
|
|
9
|
-
useCopilotChatConfiguration,
|
|
10
|
-
useCopilotKit
|
|
11
|
-
} from "@copilotkitnext/react";
|
|
12
|
-
import { parseJson } from "@copilotkit/shared";
|
|
13
|
-
import { CopilotKitLowLevelError } from "@copilotkit/shared";
|
|
14
|
-
var usePredictStateSubscription = (agent) => {
|
|
15
|
-
const predictStateToolsRef = useRef([]);
|
|
16
|
-
const getSubscriber = useCallback(
|
|
17
|
-
(agent2) => ({
|
|
18
|
-
onCustomEvent: ({ event }) => {
|
|
19
|
-
if (event.name === "PredictState") {
|
|
20
|
-
predictStateToolsRef.current = event.value;
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
onToolCallArgsEvent: ({ partialToolCallArgs, toolCallName }) => {
|
|
24
|
-
predictStateToolsRef.current.forEach((t) => {
|
|
25
|
-
if ((t == null ? void 0 : t.tool) !== toolCallName)
|
|
26
|
-
return;
|
|
27
|
-
const emittedState = typeof partialToolCallArgs === "string" ? parseJson(
|
|
28
|
-
partialToolCallArgs,
|
|
29
|
-
partialToolCallArgs
|
|
30
|
-
) : partialToolCallArgs;
|
|
31
|
-
agent2.setState({
|
|
32
|
-
[t.state_key]: emittedState[t.state_key]
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}),
|
|
37
|
-
[]
|
|
38
|
-
);
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (!agent)
|
|
41
|
-
return;
|
|
42
|
-
const subscriber = getSubscriber(agent);
|
|
43
|
-
const { unsubscribe } = agent.subscribe(subscriber);
|
|
44
|
-
return () => {
|
|
45
|
-
unsubscribe();
|
|
46
|
-
};
|
|
47
|
-
}, [agent, getSubscriber]);
|
|
48
|
-
};
|
|
49
|
-
function CopilotListeners() {
|
|
50
|
-
const { copilotkit } = useCopilotKit();
|
|
51
|
-
const existingConfig = useCopilotChatConfiguration();
|
|
52
|
-
const resolvedAgentId = existingConfig == null ? void 0 : existingConfig.agentId;
|
|
53
|
-
const { setBannerError } = useToast();
|
|
54
|
-
const { agent } = useAgent({ agentId: resolvedAgentId });
|
|
55
|
-
usePredictStateSubscription(agent);
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
const subscriber = {
|
|
58
|
-
onError: ({ error }) => {
|
|
59
|
-
setBannerError(
|
|
60
|
-
new CopilotKitLowLevelError({
|
|
61
|
-
error,
|
|
62
|
-
message: error.message,
|
|
63
|
-
url: typeof window !== "undefined" ? window.location.href : ""
|
|
64
|
-
})
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const subscription = copilotkit.subscribe(subscriber);
|
|
69
|
-
return () => {
|
|
70
|
-
subscription.unsubscribe();
|
|
71
|
-
};
|
|
72
|
-
}, [copilotkit == null ? void 0 : copilotkit.subscribe]);
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export {
|
|
77
|
-
CopilotListeners
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=chunk-WRALJIW5.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/CopilotListeners.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport {\n useAgent,\n useCopilotChatConfiguration,\n useCopilotKit,\n} from \"@copilotkitnext/react\";\nimport { CopilotKitError, parseJson } from \"@copilotkit/shared\";\nimport { useCopilotContext } from \"../context\";\nimport {\n AbstractAgent,\n AgentSubscriber,\n AGUIConnectNotImplementedError,\n} from \"@ag-ui/client\";\nimport { useErrorToast } from \"./error-boundary/error-utils\";\nimport { CopilotKitCoreSubscriber } from \"@copilotkitnext/core\";\nimport { useToast } from \"./toast/toast-provider\";\nimport { CopilotKitLowLevelError } from \"@copilotkit/shared\";\n\nconst usePredictStateSubscription = (agent?: AbstractAgent) => {\n const predictStateToolsRef = useRef<\n {\n tool: string;\n state_key: string;\n tool_argument: string;\n }[]\n >([]);\n\n const getSubscriber = useCallback(\n (agent: AbstractAgent): AgentSubscriber => ({\n onCustomEvent: ({ event }) => {\n if (event.name === \"PredictState\") {\n predictStateToolsRef.current = event.value;\n }\n },\n onToolCallArgsEvent: ({ partialToolCallArgs, toolCallName }) => {\n predictStateToolsRef.current.forEach((t) => {\n if (t?.tool !== toolCallName) return;\n\n const emittedState =\n typeof partialToolCallArgs === \"string\"\n ? parseJson(\n partialToolCallArgs as unknown as string,\n partialToolCallArgs,\n )\n : partialToolCallArgs;\n\n agent.setState({\n [t.state_key]: emittedState[t.state_key],\n });\n });\n },\n }),\n [],\n );\n\n useEffect(() => {\n if (!agent) return;\n\n const subscriber = getSubscriber(agent);\n const { unsubscribe } = agent.subscribe(subscriber);\n return () => {\n unsubscribe();\n };\n }, [agent, getSubscriber]);\n};\n\nexport function CopilotListeners() {\n const { copilotkit } = useCopilotKit();\n const existingConfig = useCopilotChatConfiguration();\n const resolvedAgentId = existingConfig?.agentId;\n const { setBannerError } = useToast();\n\n const { agent } = useAgent({ agentId: resolvedAgentId });\n\n usePredictStateSubscription(agent);\n\n useEffect(() => {\n const subscriber: CopilotKitCoreSubscriber = {\n onError: ({ error }) => {\n setBannerError(\n new CopilotKitLowLevelError({\n error,\n message: error.message,\n url: typeof window !== \"undefined\" ? window.location.href : \"\",\n }),\n );\n },\n };\n const subscription = copilotkit.subscribe(subscriber);\n\n return () => {\n subscription.unsubscribe();\n };\n }, [copilotkit?.subscribe]);\n\n return null;\n}\n"],"mappings":";;;;;AAAA,SAAS,aAAa,WAAoB,cAAc;AACxD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA0B,iBAAiB;AAU3C,SAAS,+BAA+B;AAExC,IAAM,8BAA8B,CAAC,UAA0B;AAC7D,QAAM,uBAAuB,OAM3B,CAAC,CAAC;AAEJ,QAAM,gBAAgB;AAAA,IACpB,CAACA,YAA2C;AAAA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AO,MAAM;AACX,mBAAa,YAAY;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,yCAAY,SAAS,CAAC;AAE1B,SAAO;AACT;","names":["agent"]}
|
package/dist/chunk-WV2EA7SX.mjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__async
|
|
3
|
-
} from "./chunk-SKC7AJIV.mjs";
|
|
4
|
-
|
|
5
|
-
// src/lib/status-checker.ts
|
|
6
|
-
import {
|
|
7
|
-
COPILOT_CLOUD_API_URL,
|
|
8
|
-
COPILOT_CLOUD_PUBLIC_API_KEY_HEADER
|
|
9
|
-
} from "@copilotkit/shared";
|
|
10
|
-
var STATUS_CHECK_INTERVAL = 1e3 * 60 * 5;
|
|
11
|
-
var StatusChecker = class {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.activeKey = null;
|
|
14
|
-
this.intervalId = null;
|
|
15
|
-
this.instanceCount = 0;
|
|
16
|
-
this.lastResponse = null;
|
|
17
|
-
}
|
|
18
|
-
start(publicApiKey, onUpdate) {
|
|
19
|
-
return __async(this, null, function* () {
|
|
20
|
-
this.instanceCount++;
|
|
21
|
-
if (this.activeKey === publicApiKey)
|
|
22
|
-
return;
|
|
23
|
-
if (this.intervalId)
|
|
24
|
-
clearInterval(this.intervalId);
|
|
25
|
-
const checkStatus = () => __async(this, null, function* () {
|
|
26
|
-
try {
|
|
27
|
-
const response = yield fetch(`${COPILOT_CLOUD_API_URL}/ciu`, {
|
|
28
|
-
method: "GET",
|
|
29
|
-
headers: {
|
|
30
|
-
[COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey
|
|
31
|
-
}
|
|
32
|
-
}).then((response2) => response2.json());
|
|
33
|
-
this.lastResponse = response;
|
|
34
|
-
onUpdate == null ? void 0 : onUpdate(response);
|
|
35
|
-
return response;
|
|
36
|
-
} catch (error) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
const initialResponse = yield checkStatus();
|
|
41
|
-
this.intervalId = setInterval(checkStatus, STATUS_CHECK_INTERVAL);
|
|
42
|
-
this.activeKey = publicApiKey;
|
|
43
|
-
return initialResponse;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
getLastResponse() {
|
|
47
|
-
return this.lastResponse;
|
|
48
|
-
}
|
|
49
|
-
stop() {
|
|
50
|
-
this.instanceCount--;
|
|
51
|
-
if (this.instanceCount === 0) {
|
|
52
|
-
if (this.intervalId) {
|
|
53
|
-
clearInterval(this.intervalId);
|
|
54
|
-
this.intervalId = null;
|
|
55
|
-
this.activeKey = null;
|
|
56
|
-
this.lastResponse = null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export {
|
|
63
|
-
StatusChecker
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=chunk-WV2EA7SX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/status-checker.ts"],"sourcesContent":["import {\n COPILOT_CLOUD_API_URL,\n COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,\n Severity,\n} from \"@copilotkit/shared\";\n\nconst STATUS_CHECK_INTERVAL = 1000 * 60 * 5; // 5 minutes\n\nexport type Status = {\n severity: Severity;\n message: string;\n};\n\nexport class StatusChecker {\n private activeKey: string | null = null;\n private intervalId: ReturnType<typeof setInterval> | null = null;\n private instanceCount = 0;\n private lastResponse: Status | null = null;\n\n async start(\n publicApiKey: string,\n onUpdate?: (status: Status | null) => void,\n ) {\n this.instanceCount++;\n if (this.activeKey === publicApiKey) return;\n\n if (this.intervalId) clearInterval(this.intervalId);\n\n const checkStatus = async () => {\n try {\n const response = await fetch(`${COPILOT_CLOUD_API_URL}/ciu`, {\n method: \"GET\",\n headers: {\n [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey,\n },\n }).then((response) => response.json() as Promise<Status>);\n this.lastResponse = response;\n onUpdate?.(response);\n return response;\n } catch (error) {\n // Silently fail\n return null;\n }\n };\n\n const initialResponse = await checkStatus();\n this.intervalId = setInterval(checkStatus, STATUS_CHECK_INTERVAL);\n this.activeKey = publicApiKey;\n return initialResponse;\n }\n\n getLastResponse() {\n return this.lastResponse;\n }\n\n stop() {\n this.instanceCount--;\n if (this.instanceCount === 0) {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n this.intervalId = null;\n this.activeKey = null;\n this.lastResponse = null;\n }\n }\n }\n}\n"],"mappings":";;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,IAAM,wBAAwB,MAAO,KAAK;AAOnC,IAAM,gBAAN,MAAoB;AAAA,EAApB;AACL,SAAQ,YAA2B;AACnC,SAAQ,aAAoD;AAC5D,SAAQ,gBAAgB;AACxB,SAAQ,eAA8B;AAAA;AAAA,EAEhC,MACJ,cACA,UACA;AAAA;AACA,WAAK;AACL,UAAI,KAAK,cAAc;AAAc;AAErC,UAAI,KAAK;AAAY,sBAAc,KAAK,UAAU;AAElD,YAAM,cAAc,MAAY;AAC9B,YAAI;AACF,gBAAM,WAAW,MAAM,MAAM,GAAG,6BAA6B;AAAA,YAC3D,QAAQ;AAAA,YACR,SAAS;AAAA,cACP,CAAC,mCAAmC,GAAG;AAAA,YACzC;AAAA,UACF,CAAC,EAAE,KAAK,CAACA,cAAaA,UAAS,KAAK,CAAoB;AACxD,eAAK,eAAe;AACpB,+CAAW;AACX,iBAAO;AAAA,QACT,SAAS,OAAP;AAEA,iBAAO;AAAA,QACT;AAAA,MACF;AAEA,YAAM,kBAAkB,MAAM,YAAY;AAC1C,WAAK,aAAa,YAAY,aAAa,qBAAqB;AAChE,WAAK,YAAY;AACjB,aAAO;AAAA,IACT;AAAA;AAAA,EAEA,kBAAkB;AAChB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,OAAO;AACL,SAAK;AACL,QAAI,KAAK,kBAAkB,GAAG;AAC5B,UAAI,KAAK,YAAY;AACnB,sBAAc,KAAK,UAAU;AAC7B,aAAK,aAAa;AAClB,aAAK,YAAY;AACjB,aAAK,eAAe;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AACF;","names":["response"]}
|
package/dist/chunk-Z6JV2LRY.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// src/hooks/use-copilot-readable.ts
|
|
2
|
-
import { useCopilotKit } from "@copilotkitnext/react";
|
|
3
|
-
import { useEffect, useRef } from "react";
|
|
4
|
-
function useCopilotReadable({ description, value, convert, available }, dependencies) {
|
|
5
|
-
const { copilotkit } = useCopilotKit();
|
|
6
|
-
const ctxIdRef = useRef(void 0);
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
if (!copilotkit)
|
|
9
|
-
return;
|
|
10
|
-
const found = Object.entries(copilotkit.context).find(([id, ctxItem]) => {
|
|
11
|
-
return JSON.stringify({ description, value }) == JSON.stringify(ctxItem);
|
|
12
|
-
});
|
|
13
|
-
if (found) {
|
|
14
|
-
ctxIdRef.current = found[0];
|
|
15
|
-
if (available === "disabled")
|
|
16
|
-
copilotkit.removeContext(ctxIdRef.current);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (!found && available === "disabled")
|
|
20
|
-
return;
|
|
21
|
-
ctxIdRef.current = copilotkit.addContext({
|
|
22
|
-
description,
|
|
23
|
-
value: (convert != null ? convert : JSON.stringify)(value)
|
|
24
|
-
});
|
|
25
|
-
return () => {
|
|
26
|
-
if (!ctxIdRef.current)
|
|
27
|
-
return;
|
|
28
|
-
copilotkit.removeContext(ctxIdRef.current);
|
|
29
|
-
};
|
|
30
|
-
}, [description, value, convert]);
|
|
31
|
-
return ctxIdRef.current;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export {
|
|
35
|
-
useCopilotReadable
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=chunk-Z6JV2LRY.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-copilot-readable.ts"],"sourcesContent":["/**\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * ## Usage\n *\n * ### Simple Usage\n *\n * In its most basic usage, useCopilotReadable accepts a single string argument\n * representing any piece of app state, making it available for the Copilot to use\n * as context when responding to user input.\n *\n * ```tsx\n * import { useCopilotReadable } from \"@copilotkit/react-core\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotReadable({\n * description: \"The list of employees\",\n * value: employees,\n * });\n * }\n * ```\n *\n * ### Nested Components\n *\n * Optionally, you can maintain the hierarchical structure of information by passing\n * `parentId`. This allows you to use `useCopilotReadable` in nested components:\n *\n * ```tsx /employeeContextId/1 {17,23}\n * import { useCopilotReadable } from \"@copilotkit/react-core\";\n *\n * function Employee(props: EmployeeProps) {\n * const { employeeName, workProfile, metadata } = props;\n *\n * // propagate any information to copilot\n * const employeeContextId = useCopilotReadable({\n * description: \"Employee name\",\n * value: employeeName\n * });\n *\n * // Pass a parentID to maintain a hierarchical structure.\n * // Especially useful with child React components, list elements, etc.\n * useCopilotReadable({\n * description: \"Work profile\",\n * value: workProfile.description(),\n * parentId: employeeContextId\n * });\n *\n * useCopilotReadable({\n * description: \"Employee metadata\",\n * value: metadata.description(),\n * parentId: employeeContextId\n * });\n *\n * return (\n * // Render as usual...\n * );\n * }\n * ```\n */\nimport { useCopilotKit } from \"@copilotkitnext/react\";\nimport { useEffect, useRef } from \"react\";\n\n/**\n * Options for the useCopilotReadable hook.\n */\nexport interface UseCopilotReadableOptions {\n /**\n * The description of the information to be added to the Copilot context.\n */\n description: string;\n /**\n * The value to be added to the Copilot context. Object values are automatically stringified.\n */\n value: any;\n /**\n * The ID of the parent context, if any.\n */\n parentId?: string;\n /**\n * An array of categories to control which context are visible where. Particularly useful\n * with CopilotTextarea (see `useMakeAutosuggestionFunction`)\n */\n categories?: string[];\n\n /**\n * Whether the context is available to the Copilot.\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * A custom conversion function to use to serialize the value to a string. If not provided, the value\n * will be serialized using `JSON.stringify`.\n */\n convert?: (description: string, value: any) => string;\n}\n\n/**\n * Adds the given information to the Copilot context to make it readable by Copilot.\n */\nexport function useCopilotReadable(\n { description, value, convert, available }: UseCopilotReadableOptions,\n dependencies?: any[],\n): string | undefined {\n const { copilotkit } = useCopilotKit();\n const ctxIdRef = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (!copilotkit) return;\n\n const found = Object.entries(copilotkit.context).find(([id, ctxItem]) => {\n return JSON.stringify({ description, value }) == JSON.stringify(ctxItem);\n });\n if (found) {\n ctxIdRef.current = found[0];\n if (available === \"disabled\") copilotkit.removeContext(ctxIdRef.current);\n return;\n }\n if (!found && available === \"disabled\") return;\n\n ctxIdRef.current = copilotkit.addContext({\n description,\n value: (convert ?? JSON.stringify)(value),\n });\n\n return () => {\n if (!ctxIdRef.current) return;\n copilotkit.removeContext(ctxIdRef.current);\n };\n }, [description, value, convert]);\n\n return ctxIdRef.current;\n}\n"],"mappings":";AA+DA,SAAS,qBAAqB;AAC9B,SAAS,WAAW,cAAc;AAuC3B,SAAS,mBACd,EAAE,aAAa,OAAO,SAAS,UAAU,GACzC,cACoB;AACpB,QAAM,EAAE,WAAW,IAAI,cAAc;AACrC,QAAM,WAAW,OAA2B,MAAS;AACrD,YAAU,MAAM;AACd,QAAI,CAAC;AAAY;AAEjB,UAAM,QAAQ,OAAO,QAAQ,WAAW,OAAO,EAAE,KAAK,CAAC,CAAC,IAAI,OAAO,MAAM;AACvE,aAAO,KAAK,UAAU,EAAE,aAAa,MAAM,CAAC,KAAK,KAAK,UAAU,OAAO;AAAA,IACzE,CAAC;AACD,QAAI,OAAO;AACT,eAAS,UAAU,MAAM,CAAC;AAC1B,UAAI,cAAc;AAAY,mBAAW,cAAc,SAAS,OAAO;AACvE;AAAA,IACF;AACA,QAAI,CAAC,SAAS,cAAc;AAAY;AAExC,aAAS,UAAU,WAAW,WAAW;AAAA,MACvC;AAAA,MACA,QAAQ,4BAAW,KAAK,WAAW,KAAK;AAAA,IAC1C,CAAC;AAED,WAAO,MAAM;AACX,UAAI,CAAC,SAAS;AAAS;AACvB,iBAAW,cAAc,SAAS,OAAO;AAAA,IAC3C;AAAA,EACF,GAAG,CAAC,aAAa,OAAO,OAAO,CAAC;AAEhC,SAAO,SAAS;AAClB;","names":[]}
|