@copilotkit/react-core 1.9.2-next.11 → 1.9.2-next.12

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 (40) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/{chunk-7BYXCFPB.mjs → chunk-ENLPADPJ.mjs} +3 -3
  3. package/dist/{chunk-U4LIYN3I.mjs → chunk-FXK6RQIN.mjs} +2 -2
  4. package/dist/{chunk-OIPDW3UR.mjs → chunk-GPCFFQHF.mjs} +2 -2
  5. package/dist/{chunk-AFDL5JI3.mjs → chunk-IF2M6XIO.mjs} +27 -13
  6. package/dist/{chunk-AFDL5JI3.mjs.map → chunk-IF2M6XIO.mjs.map} +1 -1
  7. package/dist/{chunk-RYREGU4E.mjs → chunk-UHEKBL6C.mjs} +5 -5
  8. package/dist/{chunk-BEDNUHSA.mjs → chunk-WOGURSAL.mjs} +4 -4
  9. package/dist/components/copilot-provider/copilotkit.mjs +5 -5
  10. package/dist/components/copilot-provider/index.mjs +5 -5
  11. package/dist/components/index.mjs +5 -5
  12. package/dist/hooks/index.js +23 -9
  13. package/dist/hooks/index.js.map +1 -1
  14. package/dist/hooks/index.mjs +25 -25
  15. package/dist/hooks/use-chat.js +23 -9
  16. package/dist/hooks/use-chat.js.map +1 -1
  17. package/dist/hooks/use-chat.mjs +3 -3
  18. package/dist/hooks/use-coagent.js +23 -9
  19. package/dist/hooks/use-coagent.js.map +1 -1
  20. package/dist/hooks/use-coagent.mjs +9 -9
  21. package/dist/hooks/use-copilot-chat.js +23 -9
  22. package/dist/hooks/use-copilot-chat.js.map +1 -1
  23. package/dist/hooks/use-copilot-chat.mjs +8 -8
  24. package/dist/hooks/use-langgraph-interrupt.js +23 -9
  25. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  26. package/dist/hooks/use-langgraph-interrupt.mjs +9 -9
  27. package/dist/index.js +23 -9
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +26 -26
  30. package/dist/lib/copilot-task.mjs +6 -6
  31. package/dist/lib/index.mjs +6 -6
  32. package/dist/utils/extract.mjs +5 -5
  33. package/dist/utils/index.mjs +5 -5
  34. package/package.json +3 -3
  35. package/src/hooks/use-chat.ts +31 -9
  36. /package/dist/{chunk-7BYXCFPB.mjs.map → chunk-ENLPADPJ.mjs.map} +0 -0
  37. /package/dist/{chunk-U4LIYN3I.mjs.map → chunk-FXK6RQIN.mjs.map} +0 -0
  38. /package/dist/{chunk-OIPDW3UR.mjs.map → chunk-GPCFFQHF.mjs.map} +0 -0
  39. /package/dist/{chunk-RYREGU4E.mjs.map → chunk-UHEKBL6C.mjs.map} +0 -0
  40. /package/dist/{chunk-BEDNUHSA.mjs.map → chunk-WOGURSAL.mjs.map} +0 -0
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  useChat
3
- } from "../chunk-AFDL5JI3.mjs";
3
+ } from "../chunk-IF2M6XIO.mjs";
4
4
  import "../chunk-4CEQJ2X6.mjs";
5
- import "../chunk-55QZ2SVJ.mjs";
6
- import "../chunk-GFJW4RIM.mjs";
7
5
  import "../chunk-3OQM3NEK.mjs";
8
6
  import "../chunk-O7ARI5CV.mjs";
7
+ import "../chunk-55QZ2SVJ.mjs";
8
+ import "../chunk-GFJW4RIM.mjs";
9
9
  import "../chunk-YAF2LATQ.mjs";
10
10
  import "../chunk-XFOTNHYA.mjs";
11
11
  import "../chunk-SKC7AJIV.mjs";
@@ -982,21 +982,35 @@ function useChat(options) {
982
982
  [isLoading, messages, setMessages, runChatCompletionAndHandleFunctionCall]
983
983
  );
984
984
  const reload = useAsyncCallback(
985
- (messageId) => __async(this, null, function* () {
985
+ (reloadMessageId) => __async(this, null, function* () {
986
986
  if (isLoading || messages.length === 0) {
987
987
  return;
988
988
  }
989
- const index = messages.findIndex((msg) => msg.id === messageId);
990
- if (index === -1) {
991
- console.warn(`Message with id ${messageId} not found`);
989
+ const reloadMessageIndex = messages.findIndex((msg) => msg.id === reloadMessageId);
990
+ if (reloadMessageIndex === -1) {
991
+ console.warn(`Message with id ${reloadMessageId} not found`);
992
992
  return;
993
993
  }
994
- let newMessages = messages.slice(0, index);
995
- if (newMessages.length > 0 && newMessages[newMessages.length - 1].isAgentStateMessage()) {
996
- newMessages = newMessages.slice(0, newMessages.length - 1);
994
+ const reloadMessageRole = messages[reloadMessageIndex].role;
995
+ if (reloadMessageRole !== import_runtime_client_gql3.MessageRole.Assistant) {
996
+ console.warn(`Regenerate cannot be performed on ${reloadMessageRole} role`);
997
+ return;
997
998
  }
998
- setMessages(newMessages);
999
- return runChatCompletionAndHandleFunctionCall(newMessages);
999
+ let historyCutoff = [];
1000
+ if (messages.length > 2) {
1001
+ const lastUserMessageBeforeRegenerate = messages.slice(0, reloadMessageIndex).reverse().find(
1002
+ (msg) => (
1003
+ // @ts-expect-error -- message has role
1004
+ msg.role === import_runtime_client_gql3.MessageRole.User
1005
+ )
1006
+ );
1007
+ const indexOfLastUserMessageBeforeRegenerate = messages.findIndex(
1008
+ (msg) => msg.id === lastUserMessageBeforeRegenerate.id
1009
+ );
1010
+ historyCutoff = messages.slice(0, indexOfLastUserMessageBeforeRegenerate + 1);
1011
+ }
1012
+ setMessages(historyCutoff);
1013
+ return runChatCompletionAndHandleFunctionCall(historyCutoff);
1000
1014
  }),
1001
1015
  [isLoading, messages, setMessages, runChatCompletionAndHandleFunctionCall]
1002
1016
  );