@copilotkit/react-core 1.50.1-next.0 → 1.50.1-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{chunk-BTZ3TJVX.mjs → chunk-4RRMC7L2.mjs} +4 -4
  3. package/dist/{chunk-JZN7YOPM.mjs → chunk-4YZA2BZC.mjs} +13 -13
  4. package/dist/{chunk-ZE4JVTEP.mjs → chunk-53K6WNJG.mjs} +2 -2
  5. package/dist/{chunk-U2ZRVVKT.mjs → chunk-BUSWSDYO.mjs} +2 -2
  6. package/dist/{chunk-T2VBHAAP.mjs → chunk-CDUIA2WM.mjs} +11 -3
  7. package/dist/chunk-CDUIA2WM.mjs.map +1 -0
  8. package/dist/{chunk-4HRUQH6U.mjs → chunk-E7SE25ZU.mjs} +2 -2
  9. package/dist/{chunk-5J7RRLRO.mjs → chunk-FQFXYAV7.mjs} +2 -2
  10. package/dist/{chunk-EG56H77V.mjs → chunk-GPEJNVE5.mjs} +2 -2
  11. package/dist/{chunk-7HI6VLJJ.mjs → chunk-HE22TZMF.mjs} +4 -4
  12. package/dist/{chunk-FESRCHUE.mjs → chunk-LCZZ7YGZ.mjs} +2 -2
  13. package/dist/{chunk-SNON4QA6.mjs → chunk-LHERIF3L.mjs} +4 -4
  14. package/dist/{chunk-LDEWO5XH.mjs → chunk-LSHFN2Y5.mjs} +28 -7
  15. package/dist/chunk-LSHFN2Y5.mjs.map +1 -0
  16. package/dist/{chunk-IUNU4CUG.mjs → chunk-YTQHRJUA.mjs} +4 -4
  17. package/dist/components/copilot-provider/copilot-messages.mjs +2 -2
  18. package/dist/components/copilot-provider/copilotkit.mjs +7 -7
  19. package/dist/components/copilot-provider/index.mjs +7 -7
  20. package/dist/components/error-boundary/error-boundary.mjs +2 -2
  21. package/dist/components/index.mjs +7 -7
  22. package/dist/context/index.mjs +5 -5
  23. package/dist/hooks/index.d.ts +1 -1
  24. package/dist/hooks/index.js +36 -7
  25. package/dist/hooks/index.js.map +1 -1
  26. package/dist/hooks/index.mjs +14 -14
  27. package/dist/hooks/use-coagent-state-render-bridge.mjs +1 -1
  28. package/dist/hooks/use-coagent-state-render.mjs +2 -2
  29. package/dist/hooks/use-copilot-action.js +9 -1
  30. package/dist/hooks/use-copilot-action.js.map +1 -1
  31. package/dist/hooks/use-copilot-action.mjs +2 -2
  32. package/dist/hooks/use-copilot-authenticated-action.js +9 -1
  33. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  34. package/dist/hooks/use-copilot-authenticated-action.mjs +3 -3
  35. package/dist/hooks/use-copilot-chat-headless_c.js +27 -6
  36. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  37. package/dist/hooks/use-copilot-chat-headless_c.mjs +5 -5
  38. package/dist/hooks/use-copilot-chat.js +27 -6
  39. package/dist/hooks/use-copilot-chat.js.map +1 -1
  40. package/dist/hooks/use-copilot-chat.mjs +5 -5
  41. package/dist/hooks/use-copilot-chat_internal.d.ts +24 -2
  42. package/dist/hooks/use-copilot-chat_internal.js +27 -6
  43. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  44. package/dist/hooks/use-copilot-chat_internal.mjs +4 -4
  45. package/dist/hooks/use-default-tool.js +9 -1
  46. package/dist/hooks/use-default-tool.js.map +1 -1
  47. package/dist/hooks/use-default-tool.mjs +3 -3
  48. package/dist/hooks/use-frontend-tool.js +9 -1
  49. package/dist/hooks/use-frontend-tool.js.map +1 -1
  50. package/dist/hooks/use-frontend-tool.mjs +1 -1
  51. package/dist/hooks/use-langgraph-interrupt-render.mjs +1 -1
  52. package/dist/hooks/use-langgraph-interrupt.mjs +2 -2
  53. package/dist/index.d.ts +1 -1
  54. package/dist/index.js +36 -7
  55. package/dist/index.js.map +1 -1
  56. package/dist/index.mjs +39 -39
  57. package/dist/lib/copilot-task.mjs +8 -8
  58. package/dist/lib/index.mjs +8 -8
  59. package/package.json +3 -3
  60. package/src/hooks/index.ts +6 -1
  61. package/src/hooks/use-copilot-chat_internal.ts +59 -3
  62. package/src/hooks/use-frontend-tool.ts +13 -2
  63. package/dist/chunk-LDEWO5XH.mjs.map +0 -1
  64. package/dist/chunk-T2VBHAAP.mjs.map +0 -1
  65. /package/dist/{chunk-BTZ3TJVX.mjs.map → chunk-4RRMC7L2.mjs.map} +0 -0
  66. /package/dist/{chunk-JZN7YOPM.mjs.map → chunk-4YZA2BZC.mjs.map} +0 -0
  67. /package/dist/{chunk-ZE4JVTEP.mjs.map → chunk-53K6WNJG.mjs.map} +0 -0
  68. /package/dist/{chunk-U2ZRVVKT.mjs.map → chunk-BUSWSDYO.mjs.map} +0 -0
  69. /package/dist/{chunk-4HRUQH6U.mjs.map → chunk-E7SE25ZU.mjs.map} +0 -0
  70. /package/dist/{chunk-5J7RRLRO.mjs.map → chunk-FQFXYAV7.mjs.map} +0 -0
  71. /package/dist/{chunk-EG56H77V.mjs.map → chunk-GPEJNVE5.mjs.map} +0 -0
  72. /package/dist/{chunk-7HI6VLJJ.mjs.map → chunk-HE22TZMF.mjs.map} +0 -0
  73. /package/dist/{chunk-FESRCHUE.mjs.map → chunk-LCZZ7YGZ.mjs.map} +0 -0
  74. /package/dist/{chunk-SNON4QA6.mjs.map → chunk-LHERIF3L.mjs.map} +0 -0
  75. /package/dist/{chunk-IUNU4CUG.mjs.map → chunk-YTQHRJUA.mjs.map} +0 -0
@@ -677,7 +677,11 @@ function CoAgentStateRenderBridge(props) {
677
677
 
678
678
  // src/hooks/use-copilot-chat_internal.ts
679
679
  function useCopilotChatInternal({
680
- suggestions
680
+ suggestions,
681
+ onInProgress,
682
+ onSubmitMessage,
683
+ onStopGeneration,
684
+ onReloadMessages
681
685
  } = {}) {
682
686
  var _a, _b, _c;
683
687
  const { copilotkit } = (0, import_react14.useCopilotKit)();
@@ -706,6 +710,9 @@ function useCopilotChatInternal({
706
710
  return () => {
707
711
  };
708
712
  }, [existingConfig == null ? void 0 : existingConfig.threadId, agent, copilotkit, resolvedAgentId]);
713
+ (0, import_react13.useEffect)(() => {
714
+ onInProgress == null ? void 0 : onInProgress(Boolean(agent == null ? void 0 : agent.isRunning));
715
+ }, [agent == null ? void 0 : agent.isRunning, onInProgress]);
709
716
  const interrupt = useLangGraphInterruptRender(agent);
710
717
  const reset = () => {
711
718
  agent == null ? void 0 : agent.setMessages([]);
@@ -786,8 +793,12 @@ function useCopilotChatInternal({
786
793
  console.error("CopilotChat: runAgent failed", error);
787
794
  }
788
795
  }
796
+ if (onSubmitMessage) {
797
+ const content = typeof message.content === "string" ? message.content : message.content && "text" in message.content ? message.content.text : message.content && "filename" in message.content ? message.content.filename : "";
798
+ onSubmitMessage(content);
799
+ }
789
800
  }),
790
- [agent, copilotkit, resolvedAgentId]
801
+ [agent, copilotkit, resolvedAgentId, onSubmitMessage]
791
802
  );
792
803
  const latestAppendFunc = useAsyncCallback(
793
804
  (message, options) => __async(this, null, function* () {
@@ -808,14 +819,24 @@ function useCopilotChatInternal({
808
819
  const latestReload = useUpdatedRef(reload);
809
820
  const latestReloadFunc = useAsyncCallback(
810
821
  (messageId) => __async(this, null, function* () {
822
+ var _a2;
823
+ onReloadMessages == null ? void 0 : onReloadMessages({
824
+ messageId,
825
+ currentAgentName: agent == null ? void 0 : agent.agentId,
826
+ messages: (_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []
827
+ });
811
828
  return yield latestReload.current(messageId);
812
829
  }),
813
- [latestReload]
830
+ [latestReload, agent, onReloadMessages]
814
831
  );
815
832
  const latestStopFunc = (0, import_react13.useCallback)(() => {
816
- var _a2;
817
- return (_a2 = agent == null ? void 0 : agent.abortRun) == null ? void 0 : _a2.call(agent);
818
- }, [agent == null ? void 0 : agent.abortRun]);
833
+ var _a2, _b2;
834
+ onStopGeneration == null ? void 0 : onStopGeneration({
835
+ currentAgentName: agent == null ? void 0 : agent.agentId,
836
+ messages: (_a2 = agent == null ? void 0 : agent.messages) != null ? _a2 : []
837
+ });
838
+ return (_b2 = agent == null ? void 0 : agent.abortRun) == null ? void 0 : _b2.call(agent);
839
+ }, [onStopGeneration, agent]);
819
840
  const latestReset = useUpdatedRef(reset);
820
841
  const latestResetFunc = (0, import_react13.useCallback)(() => {
821
842
  return latestReset.current();
@@ -1069,11 +1090,19 @@ function useFrontendTool(tool, dependencies) {
1069
1090
  return rendered != null ? rendered : null;
1070
1091
  };
1071
1092
  })();
1093
+ const handlerRef = (0, import_react16.useRef)(tool.handler);
1094
+ (0, import_react16.useEffect)(() => {
1095
+ handlerRef.current = tool.handler;
1096
+ }, [tool.handler, ...dependencies != null ? dependencies : []]);
1097
+ const normalizedHandler = tool.handler ? (args) => {
1098
+ var _a;
1099
+ return (_a = handlerRef.current) == null ? void 0 : _a.call(handlerRef, args);
1100
+ } : void 0;
1072
1101
  (0, import_react17.useFrontendTool)({
1073
1102
  name,
1074
1103
  description,
1075
1104
  parameters: zodParameters,
1076
- handler: tool.handler,
1105
+ handler: normalizedHandler,
1077
1106
  followUp,
1078
1107
  render: normalizedRender
1079
1108
  });