@copilotkit/react-core 2.0.0-next.1 → 2.0.0-rc.0
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/LICENSE +21 -0
- package/README.md +18 -12
- package/dist/MarkdownRendererContext-B4Us6mwL.d.cts +954 -0
- package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +1 -0
- package/dist/MarkdownRendererContext-CRKFzsEB.d.mts +954 -0
- package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +1 -0
- package/dist/MarkdownSurfaces-C2XZISKn.cjs +3964 -0
- package/dist/MarkdownSurfaces-C2XZISKn.cjs.map +1 -0
- package/dist/MarkdownSurfaces-ChSlVYOk.mjs +3655 -0
- package/dist/MarkdownSurfaces-ChSlVYOk.mjs.map +1 -0
- package/dist/context.cjs +144 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.cts +166 -0
- package/dist/context.d.cts.map +1 -0
- package/dist/context.d.mts +166 -0
- package/dist/context.d.mts.map +1 -0
- package/dist/context.mjs +136 -0
- package/dist/context.mjs.map +1 -0
- package/dist/generative-ui.cjs +8151 -0
- package/dist/generative-ui.cjs.map +1 -0
- package/dist/generative-ui.d.cts +4952 -0
- package/dist/generative-ui.d.cts.map +1 -0
- package/dist/generative-ui.d.mts +4952 -0
- package/dist/generative-ui.d.mts.map +1 -0
- package/dist/generative-ui.mjs +8137 -0
- package/dist/generative-ui.mjs.map +1 -0
- package/dist/headless.cjs +1927 -0
- package/dist/headless.cjs.map +1 -0
- package/dist/headless.d.cts +1117 -0
- package/dist/headless.d.cts.map +1 -0
- package/dist/headless.d.mts +1008 -0
- package/dist/headless.d.mts.map +1 -0
- package/dist/headless.mjs +1869 -0
- package/dist/headless.mjs.map +1 -0
- package/dist/index.cjs +15576 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +2 -0
- package/dist/index.d.cts +3450 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +3433 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +13927 -146
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +18856 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +124 -52
- package/CHANGELOG.md +0 -4210
- package/dist/chunk-2IDV5OHF.mjs +0 -11
- package/dist/chunk-2IDV5OHF.mjs.map +0 -1
- package/dist/chunk-36KQV2NA.mjs +0 -1
- package/dist/chunk-36KQV2NA.mjs.map +0 -1
- package/dist/chunk-3V5TOYKW.mjs +0 -120
- package/dist/chunk-3V5TOYKW.mjs.map +0 -1
- package/dist/chunk-4CEQJ2X6.mjs +0 -31
- package/dist/chunk-4CEQJ2X6.mjs.map +0 -1
- package/dist/chunk-4RRMC7L2.mjs +0 -32
- package/dist/chunk-4RRMC7L2.mjs.map +0 -1
- package/dist/chunk-4YZA2BZC.mjs +0 -551
- package/dist/chunk-4YZA2BZC.mjs.map +0 -1
- package/dist/chunk-53K6WNJG.mjs +0 -36
- package/dist/chunk-53K6WNJG.mjs.map +0 -1
- package/dist/chunk-6ESSSQ7Q.mjs +0 -134
- package/dist/chunk-6ESSSQ7Q.mjs.map +0 -1
- package/dist/chunk-6PUNP7CD.mjs +0 -102
- package/dist/chunk-6PUNP7CD.mjs.map +0 -1
- package/dist/chunk-6YOKPWQ7.mjs +0 -1
- package/dist/chunk-6YOKPWQ7.mjs.map +0 -1
- package/dist/chunk-6ZLPNY7X.mjs +0 -225
- package/dist/chunk-6ZLPNY7X.mjs.map +0 -1
- package/dist/chunk-7DTB7S5V.mjs +0 -83
- package/dist/chunk-7DTB7S5V.mjs.map +0 -1
- package/dist/chunk-7IBF6RBW.mjs +0 -23
- package/dist/chunk-7IBF6RBW.mjs.map +0 -1
- package/dist/chunk-A6NKSGH3.mjs +0 -1
- package/dist/chunk-A6NKSGH3.mjs.map +0 -1
- package/dist/chunk-ABWT4DRT.mjs +0 -24
- package/dist/chunk-ABWT4DRT.mjs.map +0 -1
- package/dist/chunk-AFNWX62Q.mjs +0 -110
- package/dist/chunk-AFNWX62Q.mjs.map +0 -1
- package/dist/chunk-BUSWSDYO.mjs +0 -17
- package/dist/chunk-BUSWSDYO.mjs.map +0 -1
- package/dist/chunk-CDUIA2WM.mjs +0 -60
- package/dist/chunk-CDUIA2WM.mjs.map +0 -1
- package/dist/chunk-CYDWEPFL.mjs +0 -1
- package/dist/chunk-CYDWEPFL.mjs.map +0 -1
- package/dist/chunk-DMLQZG75.mjs +0 -25
- package/dist/chunk-DMLQZG75.mjs.map +0 -1
- package/dist/chunk-E7SE25ZU.mjs +0 -59
- package/dist/chunk-E7SE25ZU.mjs.map +0 -1
- package/dist/chunk-EFL5OBKN.mjs +0 -310
- package/dist/chunk-EFL5OBKN.mjs.map +0 -1
- package/dist/chunk-F555TVE4.mjs +0 -33
- package/dist/chunk-F555TVE4.mjs.map +0 -1
- package/dist/chunk-FD6FGKYY.mjs +0 -1
- package/dist/chunk-FD6FGKYY.mjs.map +0 -1
- package/dist/chunk-FDOMAPJY.mjs +0 -59
- package/dist/chunk-FDOMAPJY.mjs.map +0 -1
- package/dist/chunk-FQFXYAV7.mjs +0 -86
- package/dist/chunk-FQFXYAV7.mjs.map +0 -1
- package/dist/chunk-GPEJNVE5.mjs +0 -80
- package/dist/chunk-GPEJNVE5.mjs.map +0 -1
- package/dist/chunk-HE22TZMF.mjs +0 -186
- package/dist/chunk-HE22TZMF.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-JD7BAH7U.mjs +0 -1
- package/dist/chunk-JD7BAH7U.mjs.map +0 -1
- package/dist/chunk-LHERIF3L.mjs +0 -83
- package/dist/chunk-LHERIF3L.mjs.map +0 -1
- package/dist/chunk-LSHFN2Y5.mjs +0 -349
- package/dist/chunk-LSHFN2Y5.mjs.map +0 -1
- package/dist/chunk-LUGEI4YQ.mjs +0 -1
- package/dist/chunk-LUGEI4YQ.mjs.map +0 -1
- package/dist/chunk-NB2FKV2V.mjs +0 -1
- package/dist/chunk-NB2FKV2V.mjs.map +0 -1
- package/dist/chunk-NBK4KBLX.mjs +0 -54
- package/dist/chunk-NBK4KBLX.mjs.map +0 -1
- package/dist/chunk-O7ARI5CV.mjs +0 -31
- package/dist/chunk-O7ARI5CV.mjs.map +0 -1
- package/dist/chunk-PIF5KJYI.mjs +0 -103
- package/dist/chunk-PIF5KJYI.mjs.map +0 -1
- package/dist/chunk-PMAFHQ7P.mjs +0 -65
- package/dist/chunk-PMAFHQ7P.mjs.map +0 -1
- package/dist/chunk-QNUAXSDP.mjs +0 -166
- package/dist/chunk-QNUAXSDP.mjs.map +0 -1
- package/dist/chunk-RKTVJRK7.mjs +0 -143
- package/dist/chunk-RKTVJRK7.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-VV56AVPB.mjs +0 -125
- package/dist/chunk-VV56AVPB.mjs.map +0 -1
- package/dist/chunk-WF65O6HX.mjs +0 -66
- package/dist/chunk-WF65O6HX.mjs.map +0 -1
- package/dist/chunk-XDFVCQD3.mjs +0 -27
- package/dist/chunk-XDFVCQD3.mjs.map +0 -1
- package/dist/chunk-YCG6SNAU.mjs +0 -759
- package/dist/chunk-YCG6SNAU.mjs.map +0 -1
- package/dist/chunk-YTQHRJUA.mjs +0 -86
- package/dist/chunk-YTQHRJUA.mjs.map +0 -1
- package/dist/chunk-YYN33GSG.mjs +0 -73
- package/dist/chunk-YYN33GSG.mjs.map +0 -1
- package/dist/chunk-Z6JV2LRY.mjs +0 -37
- package/dist/chunk-Z6JV2LRY.mjs.map +0 -1
- package/dist/chunk-ZVF5Q6IH.mjs +0 -29
- package/dist/chunk-ZVF5Q6IH.mjs.map +0 -1
- package/dist/chunk-ZYTXB6HH.mjs +0 -151
- package/dist/chunk-ZYTXB6HH.mjs.map +0 -1
- package/dist/components/CopilotListeners.d.ts +0 -3
- package/dist/components/CopilotListeners.js +0 -101
- 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 -351
- 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 -160
- 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 -1960
- package/dist/components/copilot-provider/copilotkit.js.map +0 -1
- package/dist/components/copilot-provider/copilotkit.mjs +0 -31
- 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 -1960
- package/dist/components/copilot-provider/index.js.map +0 -1
- package/dist/components/copilot-provider/index.mjs +0 -30
- 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 -1202
- package/dist/components/dev-console/console-trigger.js.map +0 -1
- package/dist/components/dev-console/console-trigger.mjs +0 -233
- 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 -987
- 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 -131
- 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 -500
- 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 -1960
- package/dist/components/index.js.map +0 -1
- package/dist/components/index.mjs +0 -31
- 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 -347
- 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 -247
- 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 -24
- package/dist/context/coagent-state-renders-context.js +0 -91
- 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 -161
- 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 -285
- 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 -59
- 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 -1774
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/index.mjs +0 -91
- 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.js +0 -214
- package/dist/hooks/use-coagent-state-render-bridge.js.map +0 -1
- package/dist/hooks/use-coagent-state-render-bridge.mjs +0 -15
- package/dist/hooks/use-coagent-state-render-bridge.mjs.map +0 -1
- package/dist/hooks/use-coagent-state-render.d.ts +0 -55
- package/dist/hooks/use-coagent-state-render.js +0 -255
- 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 -233
- 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 -295
- 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 -177
- 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 -462
- 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 -1044
- package/dist/hooks/use-copilot-chat-headless_c.js.map +0 -1
- package/dist/hooks/use-copilot-chat-headless_c.mjs +0 -24
- 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 -978
- package/dist/hooks/use-copilot-chat.js.map +0 -1
- package/dist/hooks/use-copilot-chat.mjs +0 -21
- 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 -976
- package/dist/hooks/use-copilot-chat_internal.js.map +0 -1
- package/dist/hooks/use-copilot-chat_internal.mjs +0 -22
- 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 -203
- 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 -302
- 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 -93
- 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 -104
- 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 -318
- 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 -201
- 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 -176
- 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 -90
- 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 -175
- 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 -3528
- package/dist/index.js.map +0 -1
- package/dist/lib/copilot-task.d.ts +0 -97
- package/dist/lib/copilot-task.js +0 -194
- package/dist/lib/copilot-task.js.map +0 -1
- package/dist/lib/copilot-task.mjs +0 -31
- package/dist/lib/copilot-task.mjs.map +0 -1
- package/dist/lib/index.d.ts +0 -11
- package/dist/lib/index.js +0 -196
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/index.mjs +0 -32
- 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 -26
- package/dist/setupTests.js.map +0 -1
- package/dist/setupTests.mjs +0 -24
- package/dist/setupTests.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 -53
- 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.css +0 -4
- package/dist/v2/index.css.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 +0 -6
- package/dist/v2/index.mjs.map +0 -1
- package/jest.config.js +0 -25
- package/src/components/CopilotListeners.tsx +0 -81
- package/src/components/copilot-provider/__tests__/copilotkit-error.test.tsx +0 -75
- package/src/components/copilot-provider/copilot-messages.tsx +0 -274
- package/src/components/copilot-provider/copilotkit-props.tsx +0 -169
- package/src/components/copilot-provider/copilotkit.tsx +0 -671
- package/src/components/copilot-provider/index.ts +0 -3
- package/src/components/dev-console/console-trigger.tsx +0 -254
- package/src/components/dev-console/developer-console-modal.tsx +0 -866
- package/src/components/dev-console/icons.tsx +0 -101
- package/src/components/error-boundary/error-boundary.tsx +0 -91
- package/src/components/error-boundary/error-utils.tsx +0 -100
- package/src/components/index.ts +0 -1
- package/src/components/toast/exclamation-mark-icon.tsx +0 -27
- package/src/components/toast/toast-provider.tsx +0 -363
- package/src/components/usage-banner.tsx +0 -259
- package/src/context/coagent-state-renders-context.tsx +0 -76
- package/src/context/copilot-context.tsx +0 -332
- package/src/context/copilot-messages-context.tsx +0 -35
- package/src/context/index.ts +0 -16
- package/src/context/threads-context.tsx +0 -41
- package/src/hooks/__tests__/use-coagent-config.test.ts +0 -351
- package/src/hooks/index.ts +0 -34
- package/src/hooks/use-agent-nodename.ts +0 -30
- package/src/hooks/use-coagent-state-render-bridge.tsx +0 -293
- package/src/hooks/use-coagent-state-render.ts +0 -152
- package/src/hooks/use-coagent.ts +0 -366
- package/src/hooks/use-configure-chat-suggestions.tsx +0 -86
- package/src/hooks/use-copilot-action.ts +0 -236
- package/src/hooks/use-copilot-additional-instructions.ts +0 -85
- package/src/hooks/use-copilot-authenticated-action.ts +0 -70
- package/src/hooks/use-copilot-chat-headless_c.ts +0 -258
- package/src/hooks/use-copilot-chat-suggestions.tsx +0 -124
- package/src/hooks/use-copilot-chat.ts +0 -130
- package/src/hooks/use-copilot-chat_internal.ts +0 -696
- package/src/hooks/use-copilot-readable.ts +0 -135
- package/src/hooks/use-copilot-runtime-client.ts +0 -164
- package/src/hooks/use-default-tool.ts +0 -7
- package/src/hooks/use-flat-category-store.ts +0 -105
- package/src/hooks/use-frontend-tool.ts +0 -96
- package/src/hooks/use-human-in-the-loop.ts +0 -122
- package/src/hooks/use-langgraph-interrupt-render.ts +0 -136
- package/src/hooks/use-langgraph-interrupt.ts +0 -36
- package/src/hooks/use-lazy-tool-renderer.tsx +0 -30
- package/src/hooks/use-make-copilot-document-readable.ts +0 -30
- package/src/hooks/use-render-tool-call.ts +0 -80
- package/src/hooks/use-tree.ts +0 -207
- package/src/index.tsx +0 -7
- package/src/lib/copilot-task.ts +0 -201
- package/src/lib/index.ts +0 -1
- package/src/lib/status-checker.ts +0 -64
- package/src/setupTests.ts +0 -26
- package/src/types/chat-suggestion-configuration.ts +0 -23
- package/src/types/coagent-action.ts +0 -31
- package/src/types/coagent-state.ts +0 -13
- package/src/types/crew.ts +0 -89
- package/src/types/document-pointer.ts +0 -7
- package/src/types/frontend-action.ts +0 -202
- package/src/types/index.ts +0 -17
- package/src/types/interrupt-action.ts +0 -43
- package/src/types/system-message.ts +0 -4
- package/src/utils/dev-console.ts +0 -19
- package/src/utils/index.ts +0 -2
- package/src/utils/suggestions-constants.ts +0 -8
- package/src/utils/utils.test.ts +0 -7
- package/src/utils/utils.ts +0 -8
- package/src/v2/index.css +0 -1
- package/src/v2/index.ts +0 -4
- package/tsconfig.json +0 -8
- package/tsup.config.ts +0 -16
- package/typedoc.json +0 -4
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { useCopilotContext } from "../context";
|
|
2
|
-
import React, { useCallback, useEffect, useMemo } from "react";
|
|
3
|
-
import type { AbstractAgent, AgentSubscriber } from "@ag-ui/client";
|
|
4
|
-
import { MetaEventName } from "@copilotkit/runtime-client-gql";
|
|
5
|
-
import { dataToUUID, parseJson } from "@copilotkit/shared";
|
|
6
|
-
import { useAgentNodeName } from "./use-agent-nodename";
|
|
7
|
-
import { useCopilotChatConfiguration } from "@copilotkitnext/react";
|
|
8
|
-
|
|
9
|
-
type InterruptProps = {
|
|
10
|
-
event: any;
|
|
11
|
-
result: any;
|
|
12
|
-
render: (props: {
|
|
13
|
-
event: any;
|
|
14
|
-
result: any;
|
|
15
|
-
resolve: (response: string) => void;
|
|
16
|
-
}) => string | React.ReactElement;
|
|
17
|
-
resolve: (response: string) => void;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const InterruptRenderer: React.FC<InterruptProps> = ({ event, result, render, resolve }) => {
|
|
21
|
-
return render({ event, result, resolve });
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export function useLangGraphInterruptRender(
|
|
25
|
-
agent: AbstractAgent,
|
|
26
|
-
): string | React.ReactElement | null {
|
|
27
|
-
const {
|
|
28
|
-
interruptActions,
|
|
29
|
-
agentSession,
|
|
30
|
-
threadId,
|
|
31
|
-
interruptEventQueue,
|
|
32
|
-
addInterruptEvent,
|
|
33
|
-
resolveInterruptEvent,
|
|
34
|
-
} = useCopilotContext();
|
|
35
|
-
const existingConfig = useCopilotChatConfiguration();
|
|
36
|
-
const resolvedAgentId = existingConfig?.agentId ?? "default";
|
|
37
|
-
const nodeName = useAgentNodeName(resolvedAgentId);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (!agent) return;
|
|
41
|
-
let localInterrupt: any = null;
|
|
42
|
-
const subscriber: AgentSubscriber = {
|
|
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
|
-
|
|
69
|
-
const { unsubscribe } = agent.subscribe(subscriber);
|
|
70
|
-
return () => {
|
|
71
|
-
unsubscribe();
|
|
72
|
-
};
|
|
73
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
|
-
}, [agent, threadId]);
|
|
75
|
-
|
|
76
|
-
const handleResolve = useCallback(
|
|
77
|
-
(eventId: string, response?: string) => {
|
|
78
|
-
agent?.runAgent({
|
|
79
|
-
forwardedProps: {
|
|
80
|
-
command: {
|
|
81
|
-
resume: response,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
resolveInterruptEvent(threadId, eventId, response ?? "");
|
|
86
|
-
},
|
|
87
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
|
-
[agent, threadId],
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
return useMemo(() => {
|
|
92
|
-
// Get the queue for this thread and find the first unresponded event
|
|
93
|
-
const eventQueue = interruptEventQueue[threadId] || [];
|
|
94
|
-
const currentQueuedEvent = eventQueue.find((qe) => !qe.event.response);
|
|
95
|
-
|
|
96
|
-
if (!currentQueuedEvent || !agentSession) return null;
|
|
97
|
-
|
|
98
|
-
// Find the first matching action from all registered actions
|
|
99
|
-
const allActions = Object.values(interruptActions);
|
|
100
|
-
const matchingAction = allActions.find((action) => {
|
|
101
|
-
if (!action.enabled) return true; // No filter = match all
|
|
102
|
-
return action.enabled({
|
|
103
|
-
eventValue: currentQueuedEvent.event.value,
|
|
104
|
-
agentMetadata: {
|
|
105
|
-
...agentSession,
|
|
106
|
-
nodeName,
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
if (!matchingAction) return null;
|
|
112
|
-
|
|
113
|
-
const { render, handler } = matchingAction;
|
|
114
|
-
|
|
115
|
-
const resolveInterrupt = (response: string) => {
|
|
116
|
-
handleResolve(currentQueuedEvent.eventId, response);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
let result = null;
|
|
120
|
-
if (handler) {
|
|
121
|
-
result = handler({
|
|
122
|
-
event: currentQueuedEvent.event,
|
|
123
|
-
resolve: resolveInterrupt,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (!render) return null;
|
|
128
|
-
|
|
129
|
-
return React.createElement(InterruptRenderer, {
|
|
130
|
-
event: currentQueuedEvent.event,
|
|
131
|
-
result,
|
|
132
|
-
render,
|
|
133
|
-
resolve: resolveInterrupt,
|
|
134
|
-
});
|
|
135
|
-
}, [interruptActions, interruptEventQueue, threadId, agentSession, handleResolve]);
|
|
136
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useMemo } from "react";
|
|
2
|
-
import { CopilotContext } from "../context/copilot-context";
|
|
3
|
-
import { LangGraphInterruptRender } from "../types/interrupt-action";
|
|
4
|
-
import { useToast } from "../components/toast/toast-provider";
|
|
5
|
-
import { dataToUUID } from "@copilotkit/shared";
|
|
6
|
-
|
|
7
|
-
export function useLangGraphInterrupt<TEventValue = any>(
|
|
8
|
-
action: Omit<LangGraphInterruptRender<TEventValue>, "id">,
|
|
9
|
-
dependencies?: any[],
|
|
10
|
-
) {
|
|
11
|
-
const { setInterruptAction, removeInterruptAction, interruptActions, threadId } =
|
|
12
|
-
useContext(CopilotContext);
|
|
13
|
-
const { addToast } = useToast();
|
|
14
|
-
|
|
15
|
-
const actionId = dataToUUID(action, "lgAction");
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (!action) return;
|
|
19
|
-
|
|
20
|
-
// if (!action.enabled) {
|
|
21
|
-
// TODO: if there are any other actions registered, we need to warn the user that a current action without "enabled" might render for everything
|
|
22
|
-
// addToast({
|
|
23
|
-
// type: "warning",
|
|
24
|
-
// message: "An action is already registered for the interrupt event",
|
|
25
|
-
// });
|
|
26
|
-
// return;
|
|
27
|
-
// }
|
|
28
|
-
|
|
29
|
-
setInterruptAction({ ...action, id: actionId });
|
|
30
|
-
|
|
31
|
-
// Cleanup: remove action on unmount
|
|
32
|
-
return () => {
|
|
33
|
-
removeInterruptAction(actionId);
|
|
34
|
-
};
|
|
35
|
-
}, [setInterruptAction, removeInterruptAction, threadId, actionId, ...(dependencies || [])]);
|
|
36
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useRenderToolCall } from "@copilotkitnext/react";
|
|
2
|
-
import { AIMessage, Message, ToolResult } from "@copilotkit/shared";
|
|
3
|
-
import React, { useCallback } from "react";
|
|
4
|
-
|
|
5
|
-
export function useLazyToolRenderer(): (
|
|
6
|
-
message?: AIMessage,
|
|
7
|
-
messages?: Message[],
|
|
8
|
-
) => null | (() => ReturnType<ReturnType<typeof useRenderToolCall>> | null) {
|
|
9
|
-
const renderToolCall = useRenderToolCall();
|
|
10
|
-
|
|
11
|
-
return useCallback(
|
|
12
|
-
(message?: AIMessage, messages?: Message[]) => {
|
|
13
|
-
if (!message?.toolCalls?.length) return null;
|
|
14
|
-
|
|
15
|
-
const toolCall = message.toolCalls[0];
|
|
16
|
-
if (!toolCall) return null;
|
|
17
|
-
|
|
18
|
-
const toolMessage = messages?.find(
|
|
19
|
-
(m) => m.role === "tool" && m.toolCallId === toolCall.id,
|
|
20
|
-
) as ToolResult;
|
|
21
|
-
|
|
22
|
-
return () =>
|
|
23
|
-
renderToolCall({
|
|
24
|
-
toolCall,
|
|
25
|
-
toolMessage,
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
[renderToolCall],
|
|
29
|
-
);
|
|
30
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
import { useCopilotContext } from "../context/copilot-context";
|
|
3
|
-
import { DocumentPointer } from "../types";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Makes a document readable by Copilot.
|
|
7
|
-
* @param document The document to make readable.
|
|
8
|
-
* @param categories The categories to associate with the document.
|
|
9
|
-
* @param dependencies The dependencies to use for the effect.
|
|
10
|
-
* @returns The id of the document.
|
|
11
|
-
*/
|
|
12
|
-
export function useMakeCopilotDocumentReadable(
|
|
13
|
-
document: DocumentPointer,
|
|
14
|
-
categories?: string[],
|
|
15
|
-
dependencies: any[] = [],
|
|
16
|
-
): string | undefined {
|
|
17
|
-
const { addDocumentContext, removeDocumentContext } = useCopilotContext();
|
|
18
|
-
const idRef = useRef<string>(undefined!);
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
const id = addDocumentContext(document, categories);
|
|
22
|
-
idRef.current = id;
|
|
23
|
-
|
|
24
|
-
return () => {
|
|
25
|
-
removeDocumentContext(id);
|
|
26
|
-
};
|
|
27
|
-
}, [addDocumentContext, removeDocumentContext, ...dependencies]);
|
|
28
|
-
|
|
29
|
-
return idRef.current;
|
|
30
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ActionRenderProps,
|
|
3
|
-
ActionRenderPropsNoArgs,
|
|
4
|
-
ActionRenderPropsWait,
|
|
5
|
-
FrontendAction,
|
|
6
|
-
} from "../types";
|
|
7
|
-
import { Parameter, getZodParameters } from "@copilotkit/shared";
|
|
8
|
-
import React, { useEffect, useRef } from "react";
|
|
9
|
-
import { defineToolCallRenderer, useCopilotKit } from "@copilotkitnext/react";
|
|
10
|
-
import { parseJson } from "@copilotkit/shared";
|
|
11
|
-
|
|
12
|
-
type ToolCallRendererDefinition = Parameters<typeof defineToolCallRenderer>[0];
|
|
13
|
-
|
|
14
|
-
export type UseRenderToolCallArgs<T extends Parameter[] | [] = []> = Pick<
|
|
15
|
-
FrontendAction<T>,
|
|
16
|
-
"name" | "description" | "parameters"
|
|
17
|
-
> & {
|
|
18
|
-
available?: "disabled" | "enabled";
|
|
19
|
-
render: T extends []
|
|
20
|
-
? (props: ActionRenderPropsNoArgs<T>) => React.ReactElement
|
|
21
|
-
: (props: ActionRenderProps<T>) => React.ReactElement;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export function useRenderToolCall<const T extends Parameter[] | [] = []>(
|
|
25
|
-
tool: UseRenderToolCallArgs<T>,
|
|
26
|
-
dependencies?: any[],
|
|
27
|
-
) {
|
|
28
|
-
const { copilotkit } = useCopilotKit();
|
|
29
|
-
|
|
30
|
-
// Track whether we've already added this renderer to avoid duplicates
|
|
31
|
-
const hasAddedRef = useRef(false);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const { name, parameters, render } = tool;
|
|
35
|
-
const zodParameters = getZodParameters(parameters);
|
|
36
|
-
|
|
37
|
-
const renderToolCall =
|
|
38
|
-
name === "*"
|
|
39
|
-
? defineToolCallRenderer({
|
|
40
|
-
name: "*",
|
|
41
|
-
render: ((args) => {
|
|
42
|
-
return render({
|
|
43
|
-
...args,
|
|
44
|
-
result: args.result ? parseJson(args.result, args.result) : args.result,
|
|
45
|
-
});
|
|
46
|
-
}) as ToolCallRendererDefinition["render"],
|
|
47
|
-
})
|
|
48
|
-
: defineToolCallRenderer({
|
|
49
|
-
name,
|
|
50
|
-
args: zodParameters,
|
|
51
|
-
render: ((args) => {
|
|
52
|
-
return render({
|
|
53
|
-
...args,
|
|
54
|
-
result: args.result ? parseJson(args.result, args.result) : args.result,
|
|
55
|
-
});
|
|
56
|
-
}) as ToolCallRendererDefinition["render"],
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// Remove any existing renderer with the same name
|
|
60
|
-
const existingIndex = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
|
|
61
|
-
if (existingIndex !== -1) {
|
|
62
|
-
copilotkit.renderToolCalls.splice(existingIndex, 1);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Add the new renderer
|
|
66
|
-
copilotkit.renderToolCalls.push(renderToolCall);
|
|
67
|
-
hasAddedRef.current = true;
|
|
68
|
-
|
|
69
|
-
// Cleanup: remove this renderer when the component unmounts or tool changes
|
|
70
|
-
return () => {
|
|
71
|
-
if (hasAddedRef.current) {
|
|
72
|
-
const index = copilotkit.renderToolCalls.findIndex((r) => r.name === name);
|
|
73
|
-
if (index !== -1) {
|
|
74
|
-
copilotkit.renderToolCalls.splice(index, 1);
|
|
75
|
-
}
|
|
76
|
-
hasAddedRef.current = false;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}, [tool, ...(dependencies ?? [])]);
|
|
80
|
-
}
|
package/src/hooks/use-tree.ts
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { randomId } from "@copilotkit/shared";
|
|
2
|
-
import { useCallback, useReducer } from "react";
|
|
3
|
-
|
|
4
|
-
export type TreeNodeId = string;
|
|
5
|
-
|
|
6
|
-
export interface TreeNode {
|
|
7
|
-
id: TreeNodeId;
|
|
8
|
-
value: string;
|
|
9
|
-
children: TreeNode[];
|
|
10
|
-
parentId?: TreeNodeId;
|
|
11
|
-
categories: Set<string>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type Tree = TreeNode[];
|
|
15
|
-
|
|
16
|
-
export interface UseTreeReturn {
|
|
17
|
-
tree: Tree;
|
|
18
|
-
addElement: (value: string, categories: string[], parentId?: TreeNodeId) => TreeNodeId;
|
|
19
|
-
printTree: (categories: string[]) => string;
|
|
20
|
-
removeElement: (id: TreeNodeId) => void;
|
|
21
|
-
getAllElements: () => Tree;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const findNode = (nodes: Tree, id: TreeNodeId): TreeNode | undefined => {
|
|
25
|
-
for (const node of nodes) {
|
|
26
|
-
if (node.id === id) {
|
|
27
|
-
return node;
|
|
28
|
-
}
|
|
29
|
-
const result = findNode(node.children, id);
|
|
30
|
-
if (result) {
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return undefined;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const removeNode = (nodes: Tree, id: TreeNodeId): Tree => {
|
|
38
|
-
return nodes.reduce((result: Tree, node) => {
|
|
39
|
-
if (node.id !== id) {
|
|
40
|
-
const newNode = { ...node, children: removeNode(node.children, id) };
|
|
41
|
-
result.push(newNode);
|
|
42
|
-
}
|
|
43
|
-
return result;
|
|
44
|
-
}, []);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const addNode = (nodes: Tree, newNode: TreeNode, parentId?: TreeNodeId): Tree => {
|
|
48
|
-
if (!parentId) {
|
|
49
|
-
return [...nodes, newNode];
|
|
50
|
-
}
|
|
51
|
-
return nodes.map((node) => {
|
|
52
|
-
if (node.id === parentId) {
|
|
53
|
-
return { ...node, children: [...node.children, newNode] };
|
|
54
|
-
} else if (node.children.length) {
|
|
55
|
-
return { ...node, children: addNode(node.children, newNode, parentId) };
|
|
56
|
-
}
|
|
57
|
-
return node;
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const treeIndentationRepresentation = (index: number, indentLevel: number): string => {
|
|
62
|
-
if (indentLevel === 0) {
|
|
63
|
-
return (index + 1).toString();
|
|
64
|
-
} else if (indentLevel === 1) {
|
|
65
|
-
return String.fromCharCode(65 + index); // 65 is the ASCII value for 'A'
|
|
66
|
-
} else if (indentLevel === 2) {
|
|
67
|
-
return String.fromCharCode(97 + index); // 97 is the ASCII value for 'a'
|
|
68
|
-
} else {
|
|
69
|
-
return "-";
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const printNode = (node: TreeNode, prefix = "", indentLevel = 0): string => {
|
|
74
|
-
const indent = " ".repeat(3).repeat(indentLevel);
|
|
75
|
-
|
|
76
|
-
const prefixPlusIndentLength = prefix.length + indent.length;
|
|
77
|
-
const subsequentLinesPrefix = " ".repeat(prefixPlusIndentLength);
|
|
78
|
-
|
|
79
|
-
const valueLines = node.value.split("\n");
|
|
80
|
-
|
|
81
|
-
const outputFirstLine = `${indent}${prefix}${valueLines[0]}`;
|
|
82
|
-
const outputSubsequentLines = valueLines
|
|
83
|
-
.slice(1)
|
|
84
|
-
.map((line) => `${subsequentLinesPrefix}${line}`)
|
|
85
|
-
.join("\n");
|
|
86
|
-
|
|
87
|
-
let output = `${outputFirstLine}\n`;
|
|
88
|
-
if (outputSubsequentLines) {
|
|
89
|
-
output += `${outputSubsequentLines}\n`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const childPrePrefix = " ".repeat(prefix.length);
|
|
93
|
-
|
|
94
|
-
node.children.forEach(
|
|
95
|
-
(child, index) =>
|
|
96
|
-
(output += printNode(
|
|
97
|
-
child,
|
|
98
|
-
`${childPrePrefix}${treeIndentationRepresentation(index, indentLevel + 1)}. `,
|
|
99
|
-
indentLevel + 1,
|
|
100
|
-
)),
|
|
101
|
-
);
|
|
102
|
-
return output;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// Action types
|
|
106
|
-
type Action =
|
|
107
|
-
| {
|
|
108
|
-
type: "ADD_NODE";
|
|
109
|
-
value: string;
|
|
110
|
-
parentId?: string;
|
|
111
|
-
id: string;
|
|
112
|
-
categories: string[];
|
|
113
|
-
}
|
|
114
|
-
| { type: "REMOVE_NODE"; id: string };
|
|
115
|
-
|
|
116
|
-
// Reducer function
|
|
117
|
-
function treeReducer(state: Tree, action: Action): Tree {
|
|
118
|
-
switch (action.type) {
|
|
119
|
-
case "ADD_NODE": {
|
|
120
|
-
const { value, parentId, id: newNodeId } = action;
|
|
121
|
-
const newNode: TreeNode = {
|
|
122
|
-
id: newNodeId,
|
|
123
|
-
value,
|
|
124
|
-
children: [],
|
|
125
|
-
categories: new Set(action.categories),
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
try {
|
|
129
|
-
return addNode(state, newNode, parentId);
|
|
130
|
-
} catch (error) {
|
|
131
|
-
console.error(`Error while adding node with id ${newNodeId}: ${error}`);
|
|
132
|
-
return state;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
case "REMOVE_NODE":
|
|
136
|
-
return removeNode(state, action.id);
|
|
137
|
-
default:
|
|
138
|
-
return state;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// useTree hook
|
|
143
|
-
const useTree = (): UseTreeReturn => {
|
|
144
|
-
const [tree, dispatch] = useReducer(treeReducer, []);
|
|
145
|
-
|
|
146
|
-
const addElement = useCallback(
|
|
147
|
-
(value: string, categories: string[], parentId?: string): TreeNodeId => {
|
|
148
|
-
const newNodeId = randomId(); // Generate new ID outside of dispatch
|
|
149
|
-
dispatch({
|
|
150
|
-
type: "ADD_NODE",
|
|
151
|
-
value,
|
|
152
|
-
parentId,
|
|
153
|
-
id: newNodeId,
|
|
154
|
-
categories: categories,
|
|
155
|
-
});
|
|
156
|
-
return newNodeId; // Return the new ID
|
|
157
|
-
},
|
|
158
|
-
[],
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
const removeElement = useCallback((id: TreeNodeId): void => {
|
|
162
|
-
dispatch({ type: "REMOVE_NODE", id });
|
|
163
|
-
}, []);
|
|
164
|
-
|
|
165
|
-
const getAllElements = useCallback(() => {
|
|
166
|
-
return tree;
|
|
167
|
-
}, [tree]);
|
|
168
|
-
|
|
169
|
-
const printTree = useCallback(
|
|
170
|
-
(categories: string[]): string => {
|
|
171
|
-
const categoriesSet = new Set(categories);
|
|
172
|
-
|
|
173
|
-
let output = "";
|
|
174
|
-
tree.forEach((node, index) => {
|
|
175
|
-
// if the node does not have any of the desired categories, continue to the next node
|
|
176
|
-
if (!setsHaveIntersection(categoriesSet, node.categories)) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// add a new line before each node except the first one
|
|
181
|
-
if (index !== 0) {
|
|
182
|
-
output += "\n";
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
output += printNode(node, `${treeIndentationRepresentation(index, 0)}. `);
|
|
186
|
-
});
|
|
187
|
-
return output;
|
|
188
|
-
},
|
|
189
|
-
[tree],
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
return { tree, addElement, printTree, removeElement, getAllElements };
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
export default useTree;
|
|
196
|
-
|
|
197
|
-
function setsHaveIntersection<T>(setA: Set<T>, setB: Set<T>): boolean {
|
|
198
|
-
const [smallerSet, largerSet] = setA.size <= setB.size ? [setA, setB] : [setB, setA];
|
|
199
|
-
|
|
200
|
-
for (let item of smallerSet) {
|
|
201
|
-
if (largerSet.has(item)) {
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return false;
|
|
207
|
-
}
|