@copilotkit/react-core 1.5.15-next.5 → 1.5.15-next.7

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 (53) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/chunk-5M47BILE.mjs +63 -0
  3. package/dist/chunk-5M47BILE.mjs.map +1 -0
  4. package/dist/{chunk-DEPX7JPX.mjs → chunk-AXO32FSG.mjs} +2 -2
  5. package/dist/{chunk-5SGZKEPX.mjs → chunk-BG25THDF.mjs} +15 -6
  6. package/dist/chunk-BG25THDF.mjs.map +1 -0
  7. package/dist/{chunk-H2OR7FUU.mjs → chunk-E64HFWRV.mjs} +2 -2
  8. package/dist/{chunk-6PNZ77RB.mjs → chunk-ET3ABADH.mjs} +2 -2
  9. package/dist/{chunk-IU7OLWWW.mjs → chunk-NXHL6AOE.mjs} +7 -2
  10. package/dist/{chunk-IU7OLWWW.mjs.map → chunk-NXHL6AOE.mjs.map} +1 -1
  11. package/dist/components/copilot-provider/copilot-messages.js +28 -16
  12. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  13. package/dist/components/copilot-provider/copilot-messages.mjs +1 -1
  14. package/dist/components/copilot-provider/copilotkit.js +33 -16
  15. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  16. package/dist/components/copilot-provider/copilotkit.mjs +2 -2
  17. package/dist/components/copilot-provider/index.js +33 -16
  18. package/dist/components/copilot-provider/index.js.map +1 -1
  19. package/dist/components/copilot-provider/index.mjs +2 -2
  20. package/dist/components/index.js +33 -16
  21. package/dist/components/index.js.map +1 -1
  22. package/dist/components/index.mjs +2 -2
  23. package/dist/hooks/index.js +12 -3
  24. package/dist/hooks/index.js.map +1 -1
  25. package/dist/hooks/index.mjs +5 -5
  26. package/dist/hooks/use-coagent.js +12 -3
  27. package/dist/hooks/use-coagent.js.map +1 -1
  28. package/dist/hooks/use-coagent.mjs +4 -4
  29. package/dist/hooks/use-copilot-chat.js.map +1 -1
  30. package/dist/hooks/use-copilot-chat.mjs +3 -3
  31. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  32. package/dist/hooks/use-langgraph-interrupt.mjs +4 -4
  33. package/dist/index.js +45 -19
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +6 -6
  36. package/dist/lib/copilot-task.js.map +1 -1
  37. package/dist/lib/copilot-task.mjs +3 -3
  38. package/dist/lib/index.js.map +1 -1
  39. package/dist/lib/index.mjs +3 -3
  40. package/dist/utils/extract.js.map +1 -1
  41. package/dist/utils/extract.mjs +2 -2
  42. package/dist/utils/index.js.map +1 -1
  43. package/dist/utils/index.mjs +2 -2
  44. package/package.json +3 -3
  45. package/src/components/copilot-provider/copilot-messages.tsx +33 -18
  46. package/src/components/copilot-provider/copilotkit.tsx +5 -0
  47. package/src/hooks/use-coagent.ts +16 -10
  48. package/dist/chunk-5SGZKEPX.mjs.map +0 -1
  49. package/dist/chunk-IHWTLSHY.mjs +0 -51
  50. package/dist/chunk-IHWTLSHY.mjs.map +0 -1
  51. /package/dist/{chunk-DEPX7JPX.mjs.map → chunk-AXO32FSG.mjs.map} +0 -0
  52. /package/dist/{chunk-H2OR7FUU.mjs.map → chunk-E64HFWRV.mjs.map} +0 -0
  53. /package/dist/{chunk-6PNZ77RB.mjs.map → chunk-ET3ABADH.mjs.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  } from "../chunk-ZAU4EMBM.mjs";
5
5
  import {
6
6
  useLangGraphInterrupt
7
- } from "../chunk-6PNZ77RB.mjs";
7
+ } from "../chunk-ET3ABADH.mjs";
8
8
  import {
9
9
  useMakeCopilotDocumentReadable
10
10
  } from "../chunk-XOHLZIZK.mjs";
@@ -16,7 +16,7 @@ import {
16
16
  startAgent,
17
17
  stopAgent,
18
18
  useCoAgent
19
- } from "../chunk-5SGZKEPX.mjs";
19
+ } from "../chunk-BG25THDF.mjs";
20
20
  import {
21
21
  useCopilotAuthenticatedAction_c
22
22
  } from "../chunk-GANI4ZZM.mjs";
@@ -25,13 +25,13 @@ import {
25
25
  } from "../chunk-AL3MOOKF.mjs";
26
26
  import {
27
27
  useCopilotChat
28
- } from "../chunk-DEPX7JPX.mjs";
28
+ } from "../chunk-AXO32FSG.mjs";
29
29
  import {
30
30
  useCopilotReadable
31
31
  } from "../chunk-7HWSAEOY.mjs";
32
- import "../chunk-IU7OLWWW.mjs";
32
+ import "../chunk-NXHL6AOE.mjs";
33
33
  import "../chunk-UMQQA6HK.mjs";
34
- import "../chunk-IHWTLSHY.mjs";
34
+ import "../chunk-5M47BILE.mjs";
35
35
  import "../chunk-MLAS4QUR.mjs";
36
36
  import "../chunk-6U3UH3KO.mjs";
37
37
  import "../chunk-PMAFHQ7P.mjs";
@@ -1003,6 +1003,8 @@ function useCoAgent(options) {
1003
1003
  const generalContext = useCopilotContext();
1004
1004
  const { availableAgents } = generalContext;
1005
1005
  const { addToast } = useToast();
1006
+ const lastLoadedThreadId = (0, import_react9.useRef)();
1007
+ const lastLoadedState = (0, import_react9.useRef)();
1006
1008
  const isExternalStateManagement = (options2) => {
1007
1009
  return "state" in options2 && "setState" in options2;
1008
1010
  };
@@ -1052,13 +1054,20 @@ function useCoAgent(options) {
1052
1054
  };
1053
1055
  (0, import_react9.useEffect)(() => {
1054
1056
  const fetchAgentState = () => __async(this, null, function* () {
1055
- var _a, _b, _c, _d, _e, _f, _g, _h;
1057
+ var _a, _b, _c, _d;
1058
+ if (!threadId || threadId === lastLoadedThreadId.current)
1059
+ return;
1056
1060
  const result = yield runtimeClient.loadAgentState({
1057
1061
  threadId,
1058
1062
  agentName: name
1059
1063
  });
1060
- if (((_b = (_a = result.data) == null ? void 0 : _a.loadAgentState) == null ? void 0 : _b.threadExists) && ((_d = (_c = result.data) == null ? void 0 : _c.loadAgentState) == null ? void 0 : _d.state) && ((_f = (_e = result.data) == null ? void 0 : _e.loadAgentState) == null ? void 0 : _f.state) != "{}") {
1061
- const fetchedState = JSON.parse((_h = (_g = result.data) == null ? void 0 : _g.loadAgentState) == null ? void 0 : _h.state);
1064
+ const newState = (_b = (_a = result.data) == null ? void 0 : _a.loadAgentState) == null ? void 0 : _b.state;
1065
+ if (newState === lastLoadedState.current)
1066
+ return;
1067
+ if (((_d = (_c = result.data) == null ? void 0 : _c.loadAgentState) == null ? void 0 : _d.threadExists) && newState && newState != "{}") {
1068
+ lastLoadedState.current = newState;
1069
+ lastLoadedThreadId.current = threadId;
1070
+ const fetchedState = JSON.parse(newState);
1062
1071
  isExternalStateManagement(options) ? options.setState(fetchedState) : setState(fetchedState);
1063
1072
  }
1064
1073
  });