@copilotkit/react-core 0.0.0-fix-debug-infosys-20251107162427 → 0.0.0-fix-restore-handle-method-node-http-20260105204107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +309 -4
- package/dist/chunk-36KQV2NA.mjs +1 -0
- package/dist/{chunk-OKCYPO4I.mjs → chunk-3MHWEKFN.mjs} +5 -5
- package/dist/chunk-4RRMC7L2.mjs +32 -0
- package/dist/chunk-4RRMC7L2.mjs.map +1 -0
- package/dist/{chunk-E3624YDU.mjs → chunk-53K6WNJG.mjs} +8 -6
- package/dist/{chunk-E3624YDU.mjs.map → chunk-53K6WNJG.mjs.map} +1 -1
- package/dist/{chunk-N4WEHORG.mjs → chunk-6PUNP7CD.mjs} +4 -4
- package/dist/chunk-6PUNP7CD.mjs.map +1 -0
- package/dist/chunk-7DTB7S5V.mjs +83 -0
- package/dist/chunk-7DTB7S5V.mjs.map +1 -0
- package/dist/{chunk-BBUQMG45.mjs → chunk-7IBF6RBW.mjs} +3 -3
- package/dist/{chunk-BBUQMG45.mjs.map → chunk-7IBF6RBW.mjs.map} +1 -1
- package/dist/chunk-A6NKSGH3.mjs +1 -0
- package/dist/{chunk-MGWRDFBE.mjs → chunk-ABWT4DRT.mjs} +2 -2
- package/dist/{chunk-EUX2P2E7.mjs → chunk-AFNWX62Q.mjs} +11 -9
- package/dist/chunk-AFNWX62Q.mjs.map +1 -0
- package/dist/{chunk-MQYWH4E6.mjs → chunk-BUSWSDYO.mjs} +2 -2
- package/dist/chunk-CDUIA2WM.mjs +60 -0
- package/dist/chunk-CDUIA2WM.mjs.map +1 -0
- package/dist/chunk-CYDWEPFL.mjs +1 -0
- package/dist/{chunk-ZLQVRPDS.mjs → chunk-DMLQZG75.mjs} +1 -1
- package/dist/chunk-DMLQZG75.mjs.map +1 -0
- package/dist/{chunk-U7QULEVO.mjs → chunk-E7SE25ZU.mjs} +3 -3
- package/dist/chunk-F555TVE4.mjs +33 -0
- package/dist/chunk-F555TVE4.mjs.map +1 -0
- package/dist/chunk-FD6FGKYY.mjs +1 -0
- package/dist/chunk-FDOMAPJY.mjs +59 -0
- package/dist/chunk-FDOMAPJY.mjs.map +1 -0
- package/dist/{chunk-OAGAFMUM.mjs → chunk-FQFXYAV7.mjs} +6 -5
- package/dist/{chunk-OAGAFMUM.mjs.map → chunk-FQFXYAV7.mjs.map} +1 -1
- package/dist/chunk-GPEJNVE5.mjs +80 -0
- package/dist/chunk-GPEJNVE5.mjs.map +1 -0
- package/dist/chunk-I76HKHPJ.mjs +32 -0
- package/dist/chunk-I76HKHPJ.mjs.map +1 -0
- package/dist/{chunk-C6IANC2R.mjs → chunk-INPM7YKW.mjs} +9 -45
- package/dist/chunk-INPM7YKW.mjs.map +1 -0
- package/dist/chunk-JD7BAH7U.mjs +1 -0
- package/dist/chunk-LSHFN2Y5.mjs +349 -0
- package/dist/chunk-LSHFN2Y5.mjs.map +1 -0
- package/dist/chunk-NB2FKV2V.mjs +1 -0
- package/dist/chunk-NBK4KBLX.mjs +54 -0
- package/dist/chunk-NBK4KBLX.mjs.map +1 -0
- package/dist/chunk-QNUAXSDP.mjs +166 -0
- package/dist/chunk-QNUAXSDP.mjs.map +1 -0
- package/dist/chunk-RB2TXKFP.mjs +551 -0
- package/dist/chunk-RB2TXKFP.mjs.map +1 -0
- package/dist/{chunk-EDBI5PCJ.mjs → chunk-RW2Y52HO.mjs} +2 -2
- package/dist/chunk-RW2Y52HO.mjs.map +1 -0
- package/dist/{chunk-N4VN2B5S.mjs → chunk-SNON4QA6.mjs} +4 -4
- package/dist/chunk-SPCZTZCY.mjs +1 -0
- package/dist/chunk-SPCZTZCY.mjs.map +1 -0
- package/dist/chunk-VV56AVPB.mjs +125 -0
- package/dist/chunk-VV56AVPB.mjs.map +1 -0
- package/dist/chunk-WF65O6HX.mjs +66 -0
- package/dist/chunk-WF65O6HX.mjs.map +1 -0
- package/dist/chunk-XDFVCQD3.mjs +27 -0
- package/dist/chunk-XDFVCQD3.mjs.map +1 -0
- package/dist/{chunk-GT5WI3AF.mjs → chunk-YTQHRJUA.mjs} +7 -9
- package/dist/chunk-YTQHRJUA.mjs.map +1 -0
- package/dist/{chunk-5FHSUKQL.mjs → chunk-YYN33GSG.mjs} +5 -2
- package/dist/chunk-YYN33GSG.mjs.map +1 -0
- package/dist/chunk-Z6JV2LRY.mjs +37 -0
- package/dist/chunk-Z6JV2LRY.mjs.map +1 -0
- package/dist/chunk-ZVF5Q6IH.mjs +29 -0
- package/dist/chunk-ZVF5Q6IH.mjs.map +1 -0
- package/dist/chunk-ZYTXB6HH.mjs +151 -0
- package/dist/chunk-ZYTXB6HH.mjs.map +1 -0
- package/dist/components/CopilotListeners.d.ts +3 -0
- package/dist/components/CopilotListeners.js +101 -0
- package/dist/components/CopilotListeners.js.map +1 -0
- package/dist/components/CopilotListeners.mjs +9 -0
- package/dist/components/CopilotListeners.mjs.map +1 -0
- package/dist/components/copilot-provider/copilot-messages.js +14 -48
- package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
- package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
- package/dist/components/copilot-provider/copilotkit-props.d.ts +15 -2
- package/dist/components/copilot-provider/copilotkit-props.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.d.ts +2 -1
- package/dist/components/copilot-provider/copilotkit.js +491 -1361
- package/dist/components/copilot-provider/copilotkit.js.map +1 -1
- package/dist/components/copilot-provider/copilotkit.mjs +15 -13
- package/dist/components/copilot-provider/index.d.ts +2 -1
- package/dist/components/copilot-provider/index.js +491 -1361
- package/dist/components/copilot-provider/index.js.map +1 -1
- package/dist/components/copilot-provider/index.mjs +16 -13
- package/dist/components/dev-console/console-trigger.js +10 -8
- package/dist/components/dev-console/console-trigger.js.map +1 -1
- package/dist/components/dev-console/console-trigger.mjs +226 -6
- package/dist/components/dev-console/console-trigger.mjs.map +1 -1
- package/dist/components/dev-console/developer-console-modal.js +10 -8
- package/dist/components/dev-console/developer-console-modal.js.map +1 -1
- package/dist/components/dev-console/developer-console-modal.mjs +3 -3
- package/dist/components/error-boundary/error-boundary.d.ts +7 -7
- package/dist/components/error-boundary/error-boundary.js +3 -3
- package/dist/components/error-boundary/error-boundary.js.map +1 -1
- package/dist/components/error-boundary/error-boundary.mjs +3 -3
- package/dist/components/error-boundary/error-utils.d.ts +1 -1
- package/dist/components/error-boundary/error-utils.js +3 -3
- package/dist/components/error-boundary/error-utils.js.map +1 -1
- package/dist/components/error-boundary/error-utils.mjs +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +491 -1361
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +17 -13
- package/dist/components/toast/exclamation-mark-icon.d.ts +2 -2
- package/dist/components/toast/toast-provider.d.ts +3 -3
- package/dist/components/usage-banner.d.ts +2 -2
- package/dist/context/coagent-state-renders-context.d.ts +24 -0
- package/dist/context/coagent-state-renders-context.js +91 -0
- package/dist/context/coagent-state-renders-context.js.map +1 -0
- package/dist/context/coagent-state-renders-context.mjs +12 -0
- package/dist/context/coagent-state-renders-context.mjs.map +1 -0
- package/dist/context/copilot-context.d.ts +1 -1
- package/dist/context/copilot-context.js +10 -8
- package/dist/context/copilot-context.js.map +1 -1
- package/dist/context/copilot-context.mjs +1 -1
- package/dist/context/copilot-messages-context.d.ts +18 -11
- package/dist/context/copilot-messages-context.js.map +1 -1
- package/dist/context/copilot-messages-context.mjs +1 -1
- package/dist/context/index.d.ts +6 -2
- package/dist/context/index.js +110 -10
- package/dist/context/index.js.map +1 -1
- package/dist/context/index.mjs +23 -7
- package/dist/context/threads-context.d.ts +16 -0
- package/dist/context/threads-context.js +59 -0
- package/dist/context/threads-context.js.map +1 -0
- package/dist/context/threads-context.mjs +12 -0
- package/dist/context/threads-context.mjs.map +1 -0
- package/dist/{copilot-context-cf9de848.d.ts → copilot-context-ec77e921.d.ts} +36 -32
- package/dist/hooks/index.d.ts +9 -6
- package/dist/hooks/index.js +1109 -1841
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +45 -53
- package/dist/hooks/use-agent-nodename.d.ts +3 -0
- package/dist/hooks/use-agent-nodename.js +56 -0
- package/dist/hooks/use-agent-nodename.js.map +1 -0
- package/dist/hooks/use-agent-nodename.mjs +8 -0
- package/dist/hooks/use-agent-nodename.mjs.map +1 -0
- package/dist/hooks/use-coagent-state-render-bridge.d.ts +100 -0
- package/dist/hooks/use-coagent-state-render-bridge.js +214 -0
- package/dist/hooks/use-coagent-state-render-bridge.js.map +1 -0
- package/dist/hooks/use-coagent-state-render-bridge.mjs +15 -0
- package/dist/hooks/use-coagent-state-render-bridge.mjs.map +1 -0
- package/dist/hooks/use-coagent-state-render.js +31 -20
- package/dist/hooks/use-coagent-state-render.js.map +1 -1
- package/dist/hooks/use-coagent-state-render.mjs +3 -2
- package/dist/hooks/use-coagent.d.ts +2 -14
- package/dist/hooks/use-coagent.js +138 -1898
- package/dist/hooks/use-coagent.js.map +1 -1
- package/dist/hooks/use-coagent.mjs +2 -30
- package/dist/hooks/use-configure-chat-suggestions.d.ts +36 -0
- package/dist/hooks/use-configure-chat-suggestions.js +79 -0
- package/dist/hooks/use-configure-chat-suggestions.js.map +1 -0
- package/dist/hooks/use-configure-chat-suggestions.mjs +47 -0
- package/dist/hooks/use-configure-chat-suggestions.mjs.map +1 -0
- package/dist/hooks/use-copilot-action.d.ts +8 -45
- package/dist/hooks/use-copilot-action.js +219 -349
- package/dist/hooks/use-copilot-action.js.map +1 -1
- package/dist/hooks/use-copilot-action.mjs +4 -5
- package/dist/hooks/use-copilot-additional-instructions.js +10 -8
- package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
- package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
- package/dist/hooks/use-copilot-authenticated-action.js +236 -248
- package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
- package/dist/hooks/use-copilot-authenticated-action.mjs +6 -6
- package/dist/hooks/use-copilot-chat-headless_c.d.ts +2 -10
- package/dist/hooks/use-copilot-chat-headless_c.js +585 -1374
- package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
- package/dist/hooks/use-copilot-chat-headless_c.mjs +12 -22
- package/dist/hooks/use-copilot-chat-suggestions.d.ts +35 -0
- package/dist/hooks/use-copilot-chat-suggestions.js +60 -0
- package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
- package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
- package/dist/hooks/use-copilot-chat-suggestions.mjs.map +1 -0
- package/dist/hooks/use-copilot-chat.d.ts +2 -10
- package/dist/hooks/use-copilot-chat.js +579 -1393
- package/dist/hooks/use-copilot-chat.js.map +1 -1
- package/dist/hooks/use-copilot-chat.mjs +12 -22
- package/dist/hooks/use-copilot-chat_internal.d.ts +77 -14
- package/dist/hooks/use-copilot-chat_internal.js +577 -1367
- package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
- package/dist/hooks/use-copilot-chat_internal.mjs +13 -23
- package/dist/hooks/use-copilot-readable.d.ts +1 -1
- package/dist/hooks/use-copilot-readable.js +25 -152
- package/dist/hooks/use-copilot-readable.js.map +1 -1
- package/dist/hooks/use-copilot-readable.mjs +1 -2
- package/dist/hooks/use-default-tool.js +216 -349
- package/dist/hooks/use-default-tool.js.map +1 -1
- package/dist/hooks/use-default-tool.mjs +5 -6
- package/dist/hooks/use-flat-category-store.js +4 -1
- package/dist/hooks/use-flat-category-store.js.map +1 -1
- package/dist/hooks/use-flat-category-store.mjs +1 -1
- package/dist/hooks/use-frontend-tool.d.ts +3 -3
- package/dist/hooks/use-frontend-tool.js +42 -370
- package/dist/hooks/use-frontend-tool.js.map +1 -1
- package/dist/hooks/use-frontend-tool.mjs +1 -6
- package/dist/hooks/use-human-in-the-loop.d.ts +4 -3
- package/dist/hooks/use-human-in-the-loop.js +61 -393
- package/dist/hooks/use-human-in-the-loop.js.map +1 -1
- package/dist/hooks/use-human-in-the-loop.mjs +1 -6
- package/dist/hooks/use-langgraph-interrupt-render.d.ts +3 -2
- package/dist/hooks/use-langgraph-interrupt-render.js +157 -37
- package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt-render.mjs +7 -4
- package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
- package/dist/hooks/use-langgraph-interrupt.js +24 -1642
- package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
- package/dist/hooks/use-langgraph-interrupt.mjs +2 -23
- package/dist/hooks/use-lazy-tool-renderer.d.ts +6 -0
- package/dist/hooks/use-lazy-tool-renderer.js +53 -0
- package/dist/hooks/use-lazy-tool-renderer.js.map +1 -0
- package/dist/hooks/use-lazy-tool-renderer.mjs +8 -0
- package/dist/hooks/use-lazy-tool-renderer.mjs.map +1 -0
- package/dist/hooks/use-make-copilot-document-readable.js +11 -9
- package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
- package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
- package/dist/hooks/use-render-tool-call.d.ts +7 -6
- package/dist/hooks/use-render-tool-call.js +36 -386
- package/dist/hooks/use-render-tool-call.js.map +1 -1
- package/dist/hooks/use-render-tool-call.mjs +1 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +1456 -3033
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -68
- package/dist/lib/copilot-task.d.ts +2 -2
- package/dist/lib/copilot-task.js +1 -0
- package/dist/lib/copilot-task.js.map +1 -1
- package/dist/lib/copilot-task.mjs +18 -14
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +18 -14
- package/dist/setupTests.d.ts +2 -2
- package/dist/types/frontend-action.d.ts +5 -5
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +2 -1
- package/dist/types/interrupt-action.d.ts +1 -1
- package/dist/types/interrupt-action.js.map +1 -1
- package/dist/types/interrupt-action.mjs +1 -0
- package/dist/utils/index.d.ts +0 -12
- package/dist/utils/index.js +6 -325
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -21
- package/dist/utils/utils.js.map +1 -1
- package/dist/v2/index.css +4 -0
- package/dist/v2/index.css.map +1 -0
- package/dist/v2/index.d.ts +2 -0
- package/dist/v2/index.js +27 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/index.mjs +6 -0
- package/dist/v2/index.mjs.map +1 -0
- package/jest.config.js +12 -0
- package/package.json +24 -10
- package/src/components/CopilotListeners.tsx +81 -0
- package/src/components/copilot-provider/copilot-messages.tsx +6 -48
- package/src/components/copilot-provider/copilotkit-props.tsx +15 -1
- package/src/components/copilot-provider/copilotkit.tsx +189 -148
- package/src/components/error-boundary/error-utils.tsx +3 -3
- package/src/context/coagent-state-renders-context.tsx +76 -0
- package/src/context/copilot-context.tsx +21 -21
- package/src/context/copilot-messages-context.tsx +3 -3
- package/src/context/index.ts +8 -0
- package/src/context/threads-context.tsx +41 -0
- package/src/hooks/__tests__/use-coagent-config.test.ts +189 -129
- package/src/hooks/index.ts +12 -3
- package/src/hooks/use-agent-nodename.ts +30 -0
- package/src/hooks/use-coagent-state-render-bridge.tsx +293 -0
- package/src/hooks/use-coagent-state-render.ts +4 -7
- package/src/hooks/use-coagent.ts +136 -247
- package/src/hooks/use-configure-chat-suggestions.tsx +86 -0
- package/src/hooks/use-copilot-action.ts +88 -199
- package/src/hooks/use-copilot-chat-headless_c.ts +2 -1
- package/src/hooks/use-copilot-chat-suggestions.tsx +124 -0
- package/src/hooks/use-copilot-chat.ts +4 -1
- package/src/hooks/use-copilot-chat_internal.ts +410 -263
- package/src/hooks/use-copilot-readable.ts +23 -25
- package/src/hooks/use-flat-category-store.ts +4 -3
- package/src/hooks/use-frontend-tool.ts +86 -8
- package/src/hooks/use-human-in-the-loop.ts +111 -13
- package/src/hooks/use-langgraph-interrupt-render.ts +108 -40
- package/src/hooks/use-langgraph-interrupt.ts +18 -48
- package/src/hooks/use-lazy-tool-renderer.tsx +30 -0
- package/src/hooks/use-make-copilot-document-readable.ts +1 -1
- package/src/hooks/use-render-tool-call.ts +73 -13
- package/src/lib/copilot-task.ts +1 -1
- package/src/types/index.ts +1 -0
- package/src/types/interrupt-action.ts +8 -7
- package/src/utils/index.ts +0 -3
- package/src/utils/utils.ts +7 -0
- package/src/v2/index.css +1 -0
- package/src/v2/index.ts +4 -0
- package/tsup.config.ts +1 -1
- package/dist/chunk-5FHSUKQL.mjs.map +0 -1
- package/dist/chunk-6GPVUMBU.mjs +0 -13
- package/dist/chunk-6GPVUMBU.mjs.map +0 -1
- package/dist/chunk-AKR2SSUJ.mjs +0 -22
- package/dist/chunk-AKR2SSUJ.mjs.map +0 -1
- package/dist/chunk-BXXJQ2BL.mjs +0 -239
- package/dist/chunk-BXXJQ2BL.mjs.map +0 -1
- package/dist/chunk-C6IANC2R.mjs.map +0 -1
- package/dist/chunk-DXEQPN43.mjs +0 -231
- package/dist/chunk-DXEQPN43.mjs.map +0 -1
- package/dist/chunk-DZTU6PGS.mjs +0 -1
- package/dist/chunk-EDBI5PCJ.mjs.map +0 -1
- package/dist/chunk-EUX2P2E7.mjs.map +0 -1
- package/dist/chunk-EVVO67QO.mjs +0 -25
- package/dist/chunk-EVVO67QO.mjs.map +0 -1
- package/dist/chunk-GGLAHG3I.mjs +0 -804
- package/dist/chunk-GGLAHG3I.mjs.map +0 -1
- package/dist/chunk-GT5WI3AF.mjs.map +0 -1
- package/dist/chunk-HDOG2RTM.mjs +0 -37
- package/dist/chunk-HDOG2RTM.mjs.map +0 -1
- package/dist/chunk-MIXSWZSB.mjs +0 -71
- package/dist/chunk-MIXSWZSB.mjs.map +0 -1
- package/dist/chunk-N4WEHORG.mjs.map +0 -1
- package/dist/chunk-NSBAWITG.mjs +0 -332
- package/dist/chunk-NSBAWITG.mjs.map +0 -1
- package/dist/chunk-OT5NHMEC.mjs +0 -723
- package/dist/chunk-OT5NHMEC.mjs.map +0 -1
- package/dist/chunk-T3376SZS.mjs +0 -142
- package/dist/chunk-T3376SZS.mjs.map +0 -1
- package/dist/chunk-YPBKY4KY.mjs +0 -1
- package/dist/chunk-YPSGKPDA.mjs +0 -1
- package/dist/chunk-ZLQVRPDS.mjs.map +0 -1
- package/dist/chunk-ZVOLWJCY.mjs +0 -47
- package/dist/chunk-ZVOLWJCY.mjs.map +0 -1
- package/dist/hooks/use-chat.d.ts +0 -145
- package/dist/hooks/use-chat.js +0 -1129
- package/dist/hooks/use-chat.js.map +0 -1
- package/dist/hooks/use-chat.mjs +0 -14
- package/dist/index-1f5b66ac.d.ts +0 -36
- package/dist/utils/extract.d.ts +0 -43
- package/dist/utils/extract.js +0 -208
- package/dist/utils/extract.js.map +0 -1
- package/dist/utils/extract.mjs +0 -25
- package/dist/utils/suggestions.d.ts +0 -11
- package/dist/utils/suggestions.js +0 -343
- package/dist/utils/suggestions.js.map +0 -1
- package/dist/utils/suggestions.mjs +0 -25
- package/src/hooks/use-chat.ts +0 -1142
- package/src/utils/extract.ts +0 -215
- package/src/utils/suggestions.ts +0 -208
- /package/dist/{chunk-DZTU6PGS.mjs.map → chunk-36KQV2NA.mjs.map} +0 -0
- /package/dist/{chunk-OKCYPO4I.mjs.map → chunk-3MHWEKFN.mjs.map} +0 -0
- /package/dist/{chunk-YPBKY4KY.mjs.map → chunk-A6NKSGH3.mjs.map} +0 -0
- /package/dist/{chunk-MGWRDFBE.mjs.map → chunk-ABWT4DRT.mjs.map} +0 -0
- /package/dist/{chunk-MQYWH4E6.mjs.map → chunk-BUSWSDYO.mjs.map} +0 -0
- /package/dist/{chunk-YPSGKPDA.mjs.map → chunk-CYDWEPFL.mjs.map} +0 -0
- /package/dist/{chunk-U7QULEVO.mjs.map → chunk-E7SE25ZU.mjs.map} +0 -0
- /package/dist/{hooks/use-chat.mjs.map → chunk-FD6FGKYY.mjs.map} +0 -0
- /package/dist/{utils/extract.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
- /package/dist/{utils/suggestions.mjs.map → chunk-NB2FKV2V.mjs.map} +0 -0
- /package/dist/{chunk-N4VN2B5S.mjs.map → chunk-SNON4QA6.mjs.map} +0 -0
package/dist/chunk-GGLAHG3I.mjs
DELETED
|
@@ -1,804 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ConsoleTrigger
|
|
3
|
-
} from "./chunk-DXEQPN43.mjs";
|
|
4
|
-
import {
|
|
5
|
-
CopilotErrorBoundary
|
|
6
|
-
} from "./chunk-N4VN2B5S.mjs";
|
|
7
|
-
import {
|
|
8
|
-
CopilotMessages,
|
|
9
|
-
MessagesTapProvider
|
|
10
|
-
} from "./chunk-C6IANC2R.mjs";
|
|
11
|
-
import {
|
|
12
|
-
shouldShowDevConsole
|
|
13
|
-
} from "./chunk-ICIK2BSB.mjs";
|
|
14
|
-
import {
|
|
15
|
-
use_tree_default
|
|
16
|
-
} from "./chunk-RKTVJRK7.mjs";
|
|
17
|
-
import {
|
|
18
|
-
use_flat_category_store_default
|
|
19
|
-
} from "./chunk-5FHSUKQL.mjs";
|
|
20
|
-
import {
|
|
21
|
-
useCopilotRuntimeClient
|
|
22
|
-
} from "./chunk-6ESSSQ7Q.mjs";
|
|
23
|
-
import {
|
|
24
|
-
ToastProvider
|
|
25
|
-
} from "./chunk-EFL5OBKN.mjs";
|
|
26
|
-
import {
|
|
27
|
-
UsageBanner,
|
|
28
|
-
getErrorActions
|
|
29
|
-
} from "./chunk-6ZLPNY7X.mjs";
|
|
30
|
-
import {
|
|
31
|
-
CopilotContext
|
|
32
|
-
} from "./chunk-EUX2P2E7.mjs";
|
|
33
|
-
import {
|
|
34
|
-
__async,
|
|
35
|
-
__objRest,
|
|
36
|
-
__restKey,
|
|
37
|
-
__spreadProps,
|
|
38
|
-
__spreadValues
|
|
39
|
-
} from "./chunk-SKC7AJIV.mjs";
|
|
40
|
-
|
|
41
|
-
// src/utils/extract.ts
|
|
42
|
-
import {
|
|
43
|
-
actionParametersToJsonSchema as actionParametersToJsonSchema2
|
|
44
|
-
} from "@copilotkit/shared";
|
|
45
|
-
import {
|
|
46
|
-
Role,
|
|
47
|
-
TextMessage,
|
|
48
|
-
convertGqlOutputToMessages,
|
|
49
|
-
CopilotRequestType as CopilotRequestType2
|
|
50
|
-
} from "@copilotkit/runtime-client-gql";
|
|
51
|
-
|
|
52
|
-
// src/components/copilot-provider/copilotkit.tsx
|
|
53
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
54
|
-
import { flushSync } from "react-dom";
|
|
55
|
-
import {
|
|
56
|
-
COPILOT_CLOUD_CHAT_URL,
|
|
57
|
-
COPILOT_CLOUD_PUBLIC_API_KEY_HEADER,
|
|
58
|
-
randomUUID,
|
|
59
|
-
ConfigurationError,
|
|
60
|
-
MissingPublicApiKeyError
|
|
61
|
-
} from "@copilotkit/shared";
|
|
62
|
-
|
|
63
|
-
// src/utils/suggestions.ts
|
|
64
|
-
import { actionParametersToJsonSchema } from "@copilotkit/shared";
|
|
65
|
-
import { CopilotRequestType } from "@copilotkit/runtime-client-gql";
|
|
66
|
-
var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggestions, abortControllerRef) => __async(void 0, null, function* () {
|
|
67
|
-
const abortController = abortControllerRef.current;
|
|
68
|
-
if (abortController == null ? void 0 : abortController.signal.aborted) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const setSuggestionsIfNotAborted = (suggestions) => {
|
|
72
|
-
if (!(abortController == null ? void 0 : abortController.signal.aborted) && abortControllerRef.current === abortController) {
|
|
73
|
-
setCurrentSuggestions(suggestions);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
try {
|
|
77
|
-
const tools = JSON.stringify(
|
|
78
|
-
Object.values(context.actions).map((action) => ({
|
|
79
|
-
name: action.name,
|
|
80
|
-
description: action.description,
|
|
81
|
-
jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters))
|
|
82
|
-
}))
|
|
83
|
-
);
|
|
84
|
-
const allSuggestions = [];
|
|
85
|
-
let hasSuccessfulSuggestions = false;
|
|
86
|
-
let hasErrors = false;
|
|
87
|
-
let lastError = null;
|
|
88
|
-
const enabledConfigs = Object.values(chatSuggestionConfiguration).filter(
|
|
89
|
-
(config) => config.instructions && config.instructions.trim().length > 0
|
|
90
|
-
);
|
|
91
|
-
if (enabledConfigs.length === 0) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
setSuggestionsIfNotAborted([]);
|
|
95
|
-
for (const config of enabledConfigs) {
|
|
96
|
-
if (abortController == null ? void 0 : abortController.signal.aborted) {
|
|
97
|
-
setSuggestionsIfNotAborted([]);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
const result = yield extract({
|
|
102
|
-
context,
|
|
103
|
-
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. ",
|
|
104
|
-
data: `${config.instructions}
|
|
105
|
-
|
|
106
|
-
Available tools: ${tools}
|
|
107
|
-
|
|
108
|
-
`,
|
|
109
|
-
requestType: CopilotRequestType.Task,
|
|
110
|
-
parameters: [
|
|
111
|
-
{
|
|
112
|
-
name: "suggestions",
|
|
113
|
-
type: "object[]",
|
|
114
|
-
attributes: [
|
|
115
|
-
{
|
|
116
|
-
name: "title",
|
|
117
|
-
description: "The title of the suggestion. This is shown as a button and should be short.",
|
|
118
|
-
type: "string"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
name: "message",
|
|
122
|
-
description: "The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.",
|
|
123
|
-
type: "string"
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
}
|
|
127
|
-
],
|
|
128
|
-
include: {
|
|
129
|
-
messages: true,
|
|
130
|
-
readable: true
|
|
131
|
-
},
|
|
132
|
-
abortSignal: abortController == null ? void 0 : abortController.signal,
|
|
133
|
-
stream: ({ status, args }) => {
|
|
134
|
-
if (abortController == null ? void 0 : abortController.signal.aborted) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const suggestions = args.suggestions || [];
|
|
138
|
-
const newSuggestions = [];
|
|
139
|
-
for (let i = 0; i < suggestions.length; i++) {
|
|
140
|
-
if (config.maxSuggestions !== void 0 && i >= config.maxSuggestions) {
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
const suggestion = suggestions[i];
|
|
144
|
-
if (!suggestion || typeof suggestion !== "object") {
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
const { title, message } = suggestion;
|
|
148
|
-
const hasValidTitle = title && typeof title === "string" && title.trim().length > 0;
|
|
149
|
-
const hasValidMessage = message && typeof message === "string" && message.trim().length > 0;
|
|
150
|
-
if (!hasValidTitle) {
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
const partial = i === suggestions.length - 1 && status !== "complete";
|
|
154
|
-
newSuggestions.push({
|
|
155
|
-
title: title.trim(),
|
|
156
|
-
message: hasValidMessage ? message.trim() : "",
|
|
157
|
-
// Use title as fallback
|
|
158
|
-
partial,
|
|
159
|
-
className: config.className
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
setSuggestionsIfNotAborted([...allSuggestions, ...newSuggestions]);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
if ((result == null ? void 0 : result.suggestions) && Array.isArray(result.suggestions)) {
|
|
166
|
-
const validSuggestions = result.suggestions.filter(
|
|
167
|
-
(suggestion) => suggestion && typeof suggestion.title === "string" && suggestion.title.trim().length > 0
|
|
168
|
-
).map((suggestion) => ({
|
|
169
|
-
title: suggestion.title.trim(),
|
|
170
|
-
message: suggestion.message && typeof suggestion.message === "string" && suggestion.message.trim() ? suggestion.message.trim() : suggestion.title.trim()
|
|
171
|
-
}));
|
|
172
|
-
if (validSuggestions.length > 0) {
|
|
173
|
-
allSuggestions.push(...validSuggestions);
|
|
174
|
-
hasSuccessfulSuggestions = true;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
} catch (error) {
|
|
178
|
-
hasErrors = true;
|
|
179
|
-
lastError = error instanceof Error ? error : new Error(String(error));
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (hasSuccessfulSuggestions && allSuggestions.length > 0) {
|
|
183
|
-
const uniqueSuggestions = allSuggestions.filter(
|
|
184
|
-
(suggestion, index, self) => index === self.findIndex((s) => s.message === suggestion.message)
|
|
185
|
-
);
|
|
186
|
-
setSuggestionsIfNotAborted(uniqueSuggestions);
|
|
187
|
-
} else if (hasErrors) {
|
|
188
|
-
const errorMessage = lastError ? lastError.message : "Failed to generate suggestions due to API errors";
|
|
189
|
-
throw new Error(errorMessage);
|
|
190
|
-
}
|
|
191
|
-
} catch (error) {
|
|
192
|
-
throw error;
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
// src/components/copilot-provider/copilotkit.tsx
|
|
197
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
198
|
-
function CopilotKit(_a) {
|
|
199
|
-
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
200
|
-
const enabled = shouldShowDevConsole(props.showDevConsole);
|
|
201
|
-
const publicApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
202
|
-
return /* @__PURE__ */ jsx(ToastProvider, { enabled, children: /* @__PURE__ */ jsx(CopilotErrorBoundary, { publicApiKey, showUsageBanner: enabled, children: /* @__PURE__ */ jsx(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) }) });
|
|
203
|
-
}
|
|
204
|
-
function CopilotKitInternal(cpkProps) {
|
|
205
|
-
var _b;
|
|
206
|
-
const _a = cpkProps, { children } = _a, props = __objRest(_a, ["children"]);
|
|
207
|
-
validateProps(cpkProps);
|
|
208
|
-
const publicApiKey = props.publicLicenseKey || props.publicApiKey;
|
|
209
|
-
const chatApiEndpoint = props.runtimeUrl || COPILOT_CLOUD_CHAT_URL;
|
|
210
|
-
const [actions, setActions] = useState({});
|
|
211
|
-
const [coAgentStateRenders, setCoAgentStateRenders] = useState({});
|
|
212
|
-
const chatComponentsCache = useRef({
|
|
213
|
-
actions: {},
|
|
214
|
-
coAgentStateRenders: {}
|
|
215
|
-
});
|
|
216
|
-
const { addElement, removeElement, printTree, getAllElements } = use_tree_default();
|
|
217
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
218
|
-
const [chatInstructions, setChatInstructions] = useState("");
|
|
219
|
-
const [authStates, setAuthStates] = useState({});
|
|
220
|
-
const [extensions, setExtensions] = useState({});
|
|
221
|
-
const [additionalInstructions, setAdditionalInstructions] = useState([]);
|
|
222
|
-
const {
|
|
223
|
-
addElement: addDocument,
|
|
224
|
-
removeElement: removeDocument,
|
|
225
|
-
allElements: allDocuments
|
|
226
|
-
} = use_flat_category_store_default();
|
|
227
|
-
const setAction = useCallback((id, action) => {
|
|
228
|
-
setActions((prevPoints) => {
|
|
229
|
-
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
230
|
-
[id]: action
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
}, []);
|
|
234
|
-
const removeAction = useCallback((id) => {
|
|
235
|
-
setActions((prevPoints) => {
|
|
236
|
-
const newPoints = __spreadValues({}, prevPoints);
|
|
237
|
-
delete newPoints[id];
|
|
238
|
-
return newPoints;
|
|
239
|
-
});
|
|
240
|
-
}, []);
|
|
241
|
-
const setCoAgentStateRender = useCallback((id, stateRender) => {
|
|
242
|
-
setCoAgentStateRenders((prevPoints) => {
|
|
243
|
-
return __spreadProps(__spreadValues({}, prevPoints), {
|
|
244
|
-
[id]: stateRender
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
}, []);
|
|
248
|
-
const removeCoAgentStateRender = useCallback((id) => {
|
|
249
|
-
setCoAgentStateRenders((prevPoints) => {
|
|
250
|
-
const newPoints = __spreadValues({}, prevPoints);
|
|
251
|
-
delete newPoints[id];
|
|
252
|
-
return newPoints;
|
|
253
|
-
});
|
|
254
|
-
}, []);
|
|
255
|
-
const getContextString = useCallback(
|
|
256
|
-
(documents, categories) => {
|
|
257
|
-
const documentsString = documents.map((document) => {
|
|
258
|
-
return `${document.name} (${document.sourceApplication}):
|
|
259
|
-
${document.getContents()}`;
|
|
260
|
-
}).join("\n\n");
|
|
261
|
-
const nonDocumentStrings = printTree(categories);
|
|
262
|
-
return `${documentsString}
|
|
263
|
-
|
|
264
|
-
${nonDocumentStrings}`;
|
|
265
|
-
},
|
|
266
|
-
[printTree]
|
|
267
|
-
);
|
|
268
|
-
const addContext = useCallback(
|
|
269
|
-
(context, parentId, categories = defaultCopilotContextCategories) => {
|
|
270
|
-
return addElement(context, categories, parentId);
|
|
271
|
-
},
|
|
272
|
-
[addElement]
|
|
273
|
-
);
|
|
274
|
-
const removeContext = useCallback(
|
|
275
|
-
(id) => {
|
|
276
|
-
removeElement(id);
|
|
277
|
-
},
|
|
278
|
-
[removeElement]
|
|
279
|
-
);
|
|
280
|
-
const getAllContext = useCallback(() => {
|
|
281
|
-
return getAllElements();
|
|
282
|
-
}, [getAllElements]);
|
|
283
|
-
const getFunctionCallHandler = useCallback(
|
|
284
|
-
(customEntryPoints) => {
|
|
285
|
-
return entryPointsToFunctionCallHandler(Object.values(customEntryPoints || actions));
|
|
286
|
-
},
|
|
287
|
-
[actions]
|
|
288
|
-
);
|
|
289
|
-
const getDocumentsContext = useCallback(
|
|
290
|
-
(categories) => {
|
|
291
|
-
return allDocuments(categories);
|
|
292
|
-
},
|
|
293
|
-
[allDocuments]
|
|
294
|
-
);
|
|
295
|
-
const addDocumentContext = useCallback(
|
|
296
|
-
(documentPointer, categories = defaultCopilotContextCategories) => {
|
|
297
|
-
return addDocument(documentPointer, categories);
|
|
298
|
-
},
|
|
299
|
-
[addDocument]
|
|
300
|
-
);
|
|
301
|
-
const removeDocumentContext = useCallback(
|
|
302
|
-
(documentId) => {
|
|
303
|
-
removeDocument(documentId);
|
|
304
|
-
},
|
|
305
|
-
[removeDocument]
|
|
306
|
-
);
|
|
307
|
-
const copilotApiConfig = useMemo(() => {
|
|
308
|
-
var _a2, _b2;
|
|
309
|
-
let cloud = void 0;
|
|
310
|
-
if (publicApiKey) {
|
|
311
|
-
cloud = {
|
|
312
|
-
guardrails: {
|
|
313
|
-
input: {
|
|
314
|
-
restrictToTopic: {
|
|
315
|
-
enabled: Boolean(props.guardrails_c),
|
|
316
|
-
validTopics: ((_a2 = props.guardrails_c) == null ? void 0 : _a2.validTopics) || [],
|
|
317
|
-
invalidTopics: ((_b2 = props.guardrails_c) == null ? void 0 : _b2.invalidTopics) || []
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
return __spreadProps(__spreadValues({
|
|
324
|
-
publicApiKey
|
|
325
|
-
}, cloud ? { cloud } : {}), {
|
|
326
|
-
chatApiEndpoint,
|
|
327
|
-
headers: props.headers || {},
|
|
328
|
-
properties: props.properties || {},
|
|
329
|
-
transcribeAudioUrl: props.transcribeAudioUrl,
|
|
330
|
-
textToSpeechUrl: props.textToSpeechUrl,
|
|
331
|
-
credentials: props.credentials
|
|
332
|
-
});
|
|
333
|
-
}, [
|
|
334
|
-
publicApiKey,
|
|
335
|
-
props.headers,
|
|
336
|
-
props.properties,
|
|
337
|
-
props.transcribeAudioUrl,
|
|
338
|
-
props.textToSpeechUrl,
|
|
339
|
-
props.credentials,
|
|
340
|
-
props.cloudRestrictToTopic,
|
|
341
|
-
props.guardrails_c
|
|
342
|
-
]);
|
|
343
|
-
const headers = useMemo(() => {
|
|
344
|
-
const authHeaders = Object.values(authStates || {}).reduce((acc, state) => {
|
|
345
|
-
if (state.status === "authenticated" && state.authHeaders) {
|
|
346
|
-
return __spreadValues(__spreadValues({}, acc), Object.entries(state.authHeaders).reduce(
|
|
347
|
-
(headers2, [key, value]) => __spreadProps(__spreadValues({}, headers2), {
|
|
348
|
-
[key.startsWith("X-Custom-") ? key : `X-Custom-${key}`]: value
|
|
349
|
-
}),
|
|
350
|
-
{}
|
|
351
|
-
));
|
|
352
|
-
}
|
|
353
|
-
return acc;
|
|
354
|
-
}, {});
|
|
355
|
-
return __spreadValues(__spreadValues(__spreadValues({}, copilotApiConfig.headers || {}), copilotApiConfig.publicApiKey ? { [COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: copilotApiConfig.publicApiKey } : {}), authHeaders);
|
|
356
|
-
}, [copilotApiConfig.headers, copilotApiConfig.publicApiKey, authStates]);
|
|
357
|
-
const [internalErrorHandlers, _setInternalErrorHandler] = useState({});
|
|
358
|
-
const setInternalErrorHandler = useCallback((handler) => {
|
|
359
|
-
_setInternalErrorHandler((prev) => __spreadValues(__spreadValues({}, prev), handler));
|
|
360
|
-
}, []);
|
|
361
|
-
const removeInternalErrorHandler = useCallback((key) => {
|
|
362
|
-
_setInternalErrorHandler((prev) => {
|
|
363
|
-
const _a2 = prev, { [key]: _removed } = _a2, rest = __objRest(_a2, [__restKey(key)]);
|
|
364
|
-
return rest;
|
|
365
|
-
});
|
|
366
|
-
}, []);
|
|
367
|
-
const onErrorRef = useRef(props.onError);
|
|
368
|
-
useEffect(() => {
|
|
369
|
-
onErrorRef.current = props.onError;
|
|
370
|
-
}, [props.onError]);
|
|
371
|
-
const internalHandlersRef = useRef({});
|
|
372
|
-
useEffect(() => {
|
|
373
|
-
internalHandlersRef.current = internalErrorHandlers;
|
|
374
|
-
}, [internalErrorHandlers]);
|
|
375
|
-
const handleErrors = useCallback(
|
|
376
|
-
(error) => __async(this, null, function* () {
|
|
377
|
-
if (copilotApiConfig.publicApiKey && onErrorRef.current) {
|
|
378
|
-
try {
|
|
379
|
-
yield onErrorRef.current(error);
|
|
380
|
-
} catch (e) {
|
|
381
|
-
console.error("Error in public onError handler:", e);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
const handlers = Object.values(internalHandlersRef.current);
|
|
385
|
-
yield Promise.all(
|
|
386
|
-
handlers.map(
|
|
387
|
-
(h) => Promise.resolve(h(error)).catch(
|
|
388
|
-
(e) => console.error("Error in internal error handler:", e)
|
|
389
|
-
)
|
|
390
|
-
)
|
|
391
|
-
);
|
|
392
|
-
}),
|
|
393
|
-
[copilotApiConfig.publicApiKey]
|
|
394
|
-
);
|
|
395
|
-
const runtimeClient = useCopilotRuntimeClient({
|
|
396
|
-
url: copilotApiConfig.chatApiEndpoint,
|
|
397
|
-
publicApiKey,
|
|
398
|
-
headers,
|
|
399
|
-
credentials: copilotApiConfig.credentials,
|
|
400
|
-
showDevConsole: shouldShowDevConsole(props.showDevConsole),
|
|
401
|
-
onError: handleErrors
|
|
402
|
-
});
|
|
403
|
-
const [chatSuggestionConfiguration, setChatSuggestionConfiguration] = useState({});
|
|
404
|
-
const addChatSuggestionConfiguration = useCallback(
|
|
405
|
-
(id, suggestion) => {
|
|
406
|
-
setChatSuggestionConfiguration((prev) => __spreadProps(__spreadValues({}, prev), { [id]: suggestion }));
|
|
407
|
-
},
|
|
408
|
-
[setChatSuggestionConfiguration]
|
|
409
|
-
);
|
|
410
|
-
const removeChatSuggestionConfiguration = useCallback(
|
|
411
|
-
(id) => {
|
|
412
|
-
setChatSuggestionConfiguration((prev) => {
|
|
413
|
-
const _a2 = prev, { [id]: _ } = _a2, rest = __objRest(_a2, [__restKey(id)]);
|
|
414
|
-
return rest;
|
|
415
|
-
});
|
|
416
|
-
},
|
|
417
|
-
[setChatSuggestionConfiguration]
|
|
418
|
-
);
|
|
419
|
-
const [availableAgents, setAvailableAgents] = useState([]);
|
|
420
|
-
const [coagentStates, setCoagentStates] = useState({});
|
|
421
|
-
const coagentStatesRef = useRef({});
|
|
422
|
-
const setCoagentStatesWithRef = useCallback(
|
|
423
|
-
(value) => {
|
|
424
|
-
const newValue = typeof value === "function" ? value(coagentStatesRef.current) : value;
|
|
425
|
-
coagentStatesRef.current = newValue;
|
|
426
|
-
setCoagentStates((prev) => {
|
|
427
|
-
return newValue;
|
|
428
|
-
});
|
|
429
|
-
},
|
|
430
|
-
[]
|
|
431
|
-
);
|
|
432
|
-
const hasLoadedAgents = useRef(false);
|
|
433
|
-
useEffect(() => {
|
|
434
|
-
if (hasLoadedAgents.current)
|
|
435
|
-
return;
|
|
436
|
-
const fetchData = () => __async(this, null, function* () {
|
|
437
|
-
var _a2;
|
|
438
|
-
const result = yield runtimeClient.availableAgents();
|
|
439
|
-
if ((_a2 = result.data) == null ? void 0 : _a2.availableAgents) {
|
|
440
|
-
setAvailableAgents(result.data.availableAgents.agents);
|
|
441
|
-
}
|
|
442
|
-
hasLoadedAgents.current = true;
|
|
443
|
-
});
|
|
444
|
-
void fetchData();
|
|
445
|
-
}, []);
|
|
446
|
-
let initialAgentSession = null;
|
|
447
|
-
if (props.agent) {
|
|
448
|
-
initialAgentSession = {
|
|
449
|
-
agentName: props.agent
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
const [agentSession, setAgentSession] = useState(initialAgentSession);
|
|
453
|
-
useEffect(() => {
|
|
454
|
-
if (props.agent) {
|
|
455
|
-
setAgentSession({
|
|
456
|
-
agentName: props.agent
|
|
457
|
-
});
|
|
458
|
-
} else {
|
|
459
|
-
setAgentSession(null);
|
|
460
|
-
}
|
|
461
|
-
}, [props.agent]);
|
|
462
|
-
const [internalThreadId, setInternalThreadId] = useState(props.threadId || randomUUID());
|
|
463
|
-
const setThreadId = useCallback(
|
|
464
|
-
(value) => {
|
|
465
|
-
if (props.threadId) {
|
|
466
|
-
throw new Error("Cannot call setThreadId() when threadId is provided via props.");
|
|
467
|
-
}
|
|
468
|
-
setInternalThreadId(value);
|
|
469
|
-
},
|
|
470
|
-
[props.threadId]
|
|
471
|
-
);
|
|
472
|
-
useEffect(() => {
|
|
473
|
-
if (props.threadId !== void 0) {
|
|
474
|
-
setInternalThreadId(props.threadId);
|
|
475
|
-
}
|
|
476
|
-
}, [props.threadId]);
|
|
477
|
-
const [runId, setRunId] = useState(null);
|
|
478
|
-
const chatAbortControllerRef = useRef(null);
|
|
479
|
-
const showDevConsole = shouldShowDevConsole(props.showDevConsole);
|
|
480
|
-
const [langGraphInterruptActions, _setLangGraphInterruptAction] = useState({});
|
|
481
|
-
const setLangGraphInterruptAction = useCallback(
|
|
482
|
-
(threadId, action) => {
|
|
483
|
-
_setLangGraphInterruptAction((prev) => {
|
|
484
|
-
var _a2, _b2, _c;
|
|
485
|
-
if (action == null)
|
|
486
|
-
return __spreadProps(__spreadValues({}, prev), {
|
|
487
|
-
[threadId]: null
|
|
488
|
-
});
|
|
489
|
-
let event = (_a2 = prev[threadId]) == null ? void 0 : _a2.event;
|
|
490
|
-
if (action.event) {
|
|
491
|
-
event = __spreadValues(__spreadValues({}, ((_b2 = prev[threadId]) == null ? void 0 : _b2.event) || {}), action.event);
|
|
492
|
-
}
|
|
493
|
-
return __spreadProps(__spreadValues({}, prev), {
|
|
494
|
-
[threadId]: __spreadProps(__spreadValues(__spreadValues({}, (_c = prev[threadId]) != null ? _c : {}), action), { event })
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
},
|
|
498
|
-
[]
|
|
499
|
-
);
|
|
500
|
-
const removeLangGraphInterruptAction = useCallback((threadId) => {
|
|
501
|
-
setLangGraphInterruptAction(threadId, null);
|
|
502
|
-
}, []);
|
|
503
|
-
const memoizedChildren = useMemo(() => children, [children]);
|
|
504
|
-
const [bannerError, setBannerError] = useState(null);
|
|
505
|
-
const agentLock = useMemo(() => {
|
|
506
|
-
var _a2;
|
|
507
|
-
return (_a2 = props.agent) != null ? _a2 : null;
|
|
508
|
-
}, [props.agent]);
|
|
509
|
-
const forwardedParameters = useMemo(
|
|
510
|
-
() => {
|
|
511
|
-
var _a2;
|
|
512
|
-
return (_a2 = props.forwardedParameters) != null ? _a2 : {};
|
|
513
|
-
},
|
|
514
|
-
[props.forwardedParameters]
|
|
515
|
-
);
|
|
516
|
-
const updateExtensions = useCallback(
|
|
517
|
-
(newExtensions) => {
|
|
518
|
-
setExtensions((prev) => {
|
|
519
|
-
const resolved = typeof newExtensions === "function" ? newExtensions(prev) : newExtensions;
|
|
520
|
-
const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;
|
|
521
|
-
const isEqual = isSameLength && // @ts-ignore
|
|
522
|
-
Object.entries(resolved).every(([key, value]) => prev[key] === value);
|
|
523
|
-
return isEqual ? prev : resolved;
|
|
524
|
-
});
|
|
525
|
-
},
|
|
526
|
-
[setExtensions]
|
|
527
|
-
);
|
|
528
|
-
const updateAuthStates = useCallback(
|
|
529
|
-
(newAuthStates) => {
|
|
530
|
-
setAuthStates((prev) => {
|
|
531
|
-
const resolved = typeof newAuthStates === "function" ? newAuthStates(prev) : newAuthStates;
|
|
532
|
-
const isSameLength = Object.keys(resolved).length === Object.keys(prev).length;
|
|
533
|
-
const isEqual = isSameLength && // @ts-ignore
|
|
534
|
-
Object.entries(resolved).every(([key, value]) => prev[key] === value);
|
|
535
|
-
return isEqual ? prev : resolved;
|
|
536
|
-
});
|
|
537
|
-
},
|
|
538
|
-
[setAuthStates]
|
|
539
|
-
);
|
|
540
|
-
return /* @__PURE__ */ jsxs(
|
|
541
|
-
CopilotContext.Provider,
|
|
542
|
-
{
|
|
543
|
-
value: {
|
|
544
|
-
actions,
|
|
545
|
-
chatComponentsCache,
|
|
546
|
-
getFunctionCallHandler,
|
|
547
|
-
setAction,
|
|
548
|
-
removeAction,
|
|
549
|
-
coAgentStateRenders,
|
|
550
|
-
setCoAgentStateRender,
|
|
551
|
-
removeCoAgentStateRender,
|
|
552
|
-
getContextString,
|
|
553
|
-
addContext,
|
|
554
|
-
removeContext,
|
|
555
|
-
getAllContext,
|
|
556
|
-
getDocumentsContext,
|
|
557
|
-
addDocumentContext,
|
|
558
|
-
removeDocumentContext,
|
|
559
|
-
copilotApiConfig,
|
|
560
|
-
isLoading,
|
|
561
|
-
setIsLoading,
|
|
562
|
-
chatSuggestionConfiguration,
|
|
563
|
-
addChatSuggestionConfiguration,
|
|
564
|
-
removeChatSuggestionConfiguration,
|
|
565
|
-
chatInstructions,
|
|
566
|
-
setChatInstructions,
|
|
567
|
-
additionalInstructions,
|
|
568
|
-
setAdditionalInstructions,
|
|
569
|
-
showDevConsole,
|
|
570
|
-
coagentStates,
|
|
571
|
-
setCoagentStates,
|
|
572
|
-
coagentStatesRef,
|
|
573
|
-
setCoagentStatesWithRef,
|
|
574
|
-
agentSession,
|
|
575
|
-
setAgentSession,
|
|
576
|
-
runtimeClient,
|
|
577
|
-
forwardedParameters,
|
|
578
|
-
agentLock,
|
|
579
|
-
threadId: internalThreadId,
|
|
580
|
-
setThreadId,
|
|
581
|
-
runId,
|
|
582
|
-
setRunId,
|
|
583
|
-
chatAbortControllerRef,
|
|
584
|
-
availableAgents,
|
|
585
|
-
authConfig_c: props.authConfig_c,
|
|
586
|
-
authStates_c: authStates,
|
|
587
|
-
setAuthStates_c: updateAuthStates,
|
|
588
|
-
extensions,
|
|
589
|
-
setExtensions: updateExtensions,
|
|
590
|
-
langGraphInterruptAction: (_b = langGraphInterruptActions[internalThreadId]) != null ? _b : null,
|
|
591
|
-
setLangGraphInterruptAction,
|
|
592
|
-
removeLangGraphInterruptAction,
|
|
593
|
-
bannerError,
|
|
594
|
-
setBannerError,
|
|
595
|
-
onError: handleErrors,
|
|
596
|
-
internalErrorHandlers,
|
|
597
|
-
setInternalErrorHandler,
|
|
598
|
-
removeInternalErrorHandler
|
|
599
|
-
},
|
|
600
|
-
children: [
|
|
601
|
-
/* @__PURE__ */ jsx(MessagesTapProvider, { children: /* @__PURE__ */ jsxs(CopilotMessages, { children: [
|
|
602
|
-
memoizedChildren,
|
|
603
|
-
showDevConsole && /* @__PURE__ */ jsx(ConsoleTrigger, {})
|
|
604
|
-
] }) }),
|
|
605
|
-
bannerError && showDevConsole && /* @__PURE__ */ jsx(
|
|
606
|
-
UsageBanner,
|
|
607
|
-
{
|
|
608
|
-
severity: bannerError.severity,
|
|
609
|
-
message: bannerError.message,
|
|
610
|
-
onClose: () => setBannerError(null),
|
|
611
|
-
actions: getErrorActions(bannerError)
|
|
612
|
-
}
|
|
613
|
-
)
|
|
614
|
-
]
|
|
615
|
-
}
|
|
616
|
-
);
|
|
617
|
-
}
|
|
618
|
-
var defaultCopilotContextCategories = ["global"];
|
|
619
|
-
function entryPointsToFunctionCallHandler(actions) {
|
|
620
|
-
return (_0) => __async(this, [_0], function* ({ name, args }) {
|
|
621
|
-
let actionsByFunctionName = {};
|
|
622
|
-
for (let action2 of actions) {
|
|
623
|
-
actionsByFunctionName[action2.name] = action2;
|
|
624
|
-
}
|
|
625
|
-
const action = actionsByFunctionName[name];
|
|
626
|
-
let result = void 0;
|
|
627
|
-
if (action) {
|
|
628
|
-
yield new Promise((resolve, reject) => {
|
|
629
|
-
flushSync(() => __async(this, null, function* () {
|
|
630
|
-
var _a;
|
|
631
|
-
try {
|
|
632
|
-
result = yield (_a = action.handler) == null ? void 0 : _a.call(action, args);
|
|
633
|
-
resolve();
|
|
634
|
-
} catch (error) {
|
|
635
|
-
reject(error);
|
|
636
|
-
}
|
|
637
|
-
}));
|
|
638
|
-
});
|
|
639
|
-
yield new Promise((resolve) => setTimeout(resolve, 20));
|
|
640
|
-
}
|
|
641
|
-
return result;
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
function formatFeatureName(featureName) {
|
|
645
|
-
return featureName.replace(/_c$/, "").split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
646
|
-
}
|
|
647
|
-
function validateProps(props) {
|
|
648
|
-
const cloudFeatures = Object.keys(props).filter((key) => key.endsWith("_c"));
|
|
649
|
-
const hasApiKey = props.publicApiKey || props.publicLicenseKey;
|
|
650
|
-
if (!props.runtimeUrl && !hasApiKey) {
|
|
651
|
-
throw new ConfigurationError(
|
|
652
|
-
"Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'"
|
|
653
|
-
);
|
|
654
|
-
}
|
|
655
|
-
if (cloudFeatures.length > 0 && !hasApiKey) {
|
|
656
|
-
throw new MissingPublicApiKeyError(
|
|
657
|
-
`Missing required prop: 'publicApiKey' or 'publicLicenseKey' to use cloud features: ${cloudFeatures.map(formatFeatureName).join(", ")}`
|
|
658
|
-
);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
// src/utils/extract.ts
|
|
663
|
-
import {
|
|
664
|
-
convertMessagesToGqlInput,
|
|
665
|
-
filterAgentStateMessages
|
|
666
|
-
} from "@copilotkit/runtime-client-gql";
|
|
667
|
-
function extract(_0) {
|
|
668
|
-
return __async(this, arguments, function* ({
|
|
669
|
-
context,
|
|
670
|
-
instructions,
|
|
671
|
-
parameters,
|
|
672
|
-
include,
|
|
673
|
-
data,
|
|
674
|
-
abortSignal,
|
|
675
|
-
stream,
|
|
676
|
-
requestType = CopilotRequestType2.Task,
|
|
677
|
-
forwardedParameters
|
|
678
|
-
}) {
|
|
679
|
-
var _a, _b;
|
|
680
|
-
const { messages } = context;
|
|
681
|
-
const action = {
|
|
682
|
-
name: "extract",
|
|
683
|
-
description: instructions,
|
|
684
|
-
parameters,
|
|
685
|
-
handler: (args) => {
|
|
686
|
-
}
|
|
687
|
-
};
|
|
688
|
-
const includeReadable = (_a = include == null ? void 0 : include.readable) != null ? _a : false;
|
|
689
|
-
const includeMessages = (_b = include == null ? void 0 : include.messages) != null ? _b : false;
|
|
690
|
-
let contextString = "";
|
|
691
|
-
if (data) {
|
|
692
|
-
contextString = (typeof data === "string" ? data : JSON.stringify(data)) + "\n\n";
|
|
693
|
-
}
|
|
694
|
-
if (includeReadable) {
|
|
695
|
-
contextString += context.getContextString([], defaultCopilotContextCategories);
|
|
696
|
-
}
|
|
697
|
-
const systemMessage = new TextMessage({
|
|
698
|
-
content: makeSystemMessage(contextString, instructions),
|
|
699
|
-
role: Role.System
|
|
700
|
-
});
|
|
701
|
-
const instructionsMessage = new TextMessage({
|
|
702
|
-
content: makeInstructionsMessage(instructions),
|
|
703
|
-
role: Role.User
|
|
704
|
-
});
|
|
705
|
-
const response = context.runtimeClient.asStream(
|
|
706
|
-
context.runtimeClient.generateCopilotResponse({
|
|
707
|
-
data: {
|
|
708
|
-
frontend: {
|
|
709
|
-
actions: [
|
|
710
|
-
{
|
|
711
|
-
name: action.name,
|
|
712
|
-
description: action.description || "",
|
|
713
|
-
jsonSchema: JSON.stringify(actionParametersToJsonSchema2(action.parameters || []))
|
|
714
|
-
}
|
|
715
|
-
],
|
|
716
|
-
url: window.location.href
|
|
717
|
-
},
|
|
718
|
-
messages: convertMessagesToGqlInput(
|
|
719
|
-
includeMessages ? [systemMessage, instructionsMessage, ...filterAgentStateMessages(messages)] : [systemMessage, instructionsMessage]
|
|
720
|
-
),
|
|
721
|
-
metadata: {
|
|
722
|
-
requestType
|
|
723
|
-
},
|
|
724
|
-
forwardedParameters: __spreadProps(__spreadValues({}, forwardedParameters != null ? forwardedParameters : {}), {
|
|
725
|
-
toolChoice: "function",
|
|
726
|
-
toolChoiceFunctionName: action.name
|
|
727
|
-
})
|
|
728
|
-
},
|
|
729
|
-
properties: context.copilotApiConfig.properties,
|
|
730
|
-
signal: abortSignal
|
|
731
|
-
})
|
|
732
|
-
);
|
|
733
|
-
const reader = response.getReader();
|
|
734
|
-
let isInitial = true;
|
|
735
|
-
let actionExecutionMessage = void 0;
|
|
736
|
-
while (true) {
|
|
737
|
-
const { done, value } = yield reader.read();
|
|
738
|
-
if (done) {
|
|
739
|
-
break;
|
|
740
|
-
}
|
|
741
|
-
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
742
|
-
throw new Error("Aborted");
|
|
743
|
-
}
|
|
744
|
-
actionExecutionMessage = convertGqlOutputToMessages(
|
|
745
|
-
value.generateCopilotResponse.messages
|
|
746
|
-
).find((msg) => msg.isActionExecutionMessage());
|
|
747
|
-
if (!actionExecutionMessage) {
|
|
748
|
-
continue;
|
|
749
|
-
}
|
|
750
|
-
stream == null ? void 0 : stream({
|
|
751
|
-
status: isInitial ? "initial" : "inProgress",
|
|
752
|
-
args: actionExecutionMessage.arguments
|
|
753
|
-
});
|
|
754
|
-
isInitial = false;
|
|
755
|
-
}
|
|
756
|
-
if (!actionExecutionMessage) {
|
|
757
|
-
throw new Error("extract() failed: No function call occurred");
|
|
758
|
-
}
|
|
759
|
-
stream == null ? void 0 : stream({
|
|
760
|
-
status: "complete",
|
|
761
|
-
args: actionExecutionMessage.arguments
|
|
762
|
-
});
|
|
763
|
-
return actionExecutionMessage.arguments;
|
|
764
|
-
});
|
|
765
|
-
}
|
|
766
|
-
function makeInstructionsMessage(instructions) {
|
|
767
|
-
return `
|
|
768
|
-
The user has given you the following task to complete:
|
|
769
|
-
|
|
770
|
-
\`\`\`
|
|
771
|
-
${instructions}
|
|
772
|
-
\`\`\`
|
|
773
|
-
|
|
774
|
-
Any additional messages provided are for providing context only and should not be used to ask questions or engage in conversation.
|
|
775
|
-
`;
|
|
776
|
-
}
|
|
777
|
-
function makeSystemMessage(contextString, instructions) {
|
|
778
|
-
return `
|
|
779
|
-
Please act as an efficient, competent, conscientious, and industrious professional assistant.
|
|
780
|
-
|
|
781
|
-
Help the user achieve their goals, and you do so in a way that is as efficient as possible, without unnecessary fluff, but also without sacrificing professionalism.
|
|
782
|
-
Always be polite and respectful, and prefer brevity over verbosity.
|
|
783
|
-
|
|
784
|
-
The user has provided you with the following context:
|
|
785
|
-
\`\`\`
|
|
786
|
-
${contextString}
|
|
787
|
-
\`\`\`
|
|
788
|
-
|
|
789
|
-
They have also provided you with a function called extract you MUST call to initiate actions on their behalf.
|
|
790
|
-
|
|
791
|
-
Please assist them as best you can.
|
|
792
|
-
|
|
793
|
-
This is not a conversation, so please do not ask questions. Just call the function without saying anything else.
|
|
794
|
-
`;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
export {
|
|
798
|
-
extract,
|
|
799
|
-
reloadSuggestions,
|
|
800
|
-
CopilotKit,
|
|
801
|
-
CopilotKitInternal,
|
|
802
|
-
defaultCopilotContextCategories
|
|
803
|
-
};
|
|
804
|
-
//# sourceMappingURL=chunk-GGLAHG3I.mjs.map
|