@copilotkit/react-core 1.3.16-mme-reset-chat.10 → 1.3.16-mme-revert-rxjs-changes.10

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 (89) hide show
  1. package/CHANGELOG.md +8 -48
  2. package/dist/{chunk-PHP2YMMH.mjs → chunk-27IPQFJP.mjs} +2 -2
  3. package/dist/{chunk-WBBL7MG6.mjs → chunk-2MPUQRAY.mjs} +2 -10
  4. package/dist/{chunk-WBBL7MG6.mjs.map → chunk-2MPUQRAY.mjs.map} +1 -1
  5. package/dist/{chunk-UFSLLJZY.mjs → chunk-6YEMNWKE.mjs} +3 -12
  6. package/dist/{chunk-UFSLLJZY.mjs.map → chunk-6YEMNWKE.mjs.map} +1 -1
  7. package/dist/{chunk-I7XLZC4D.mjs → chunk-7DFHFZJT.mjs} +2 -2
  8. package/dist/{chunk-ZDYUMEE5.mjs → chunk-ANOG3W5S.mjs} +2 -2
  9. package/dist/{chunk-24ALPG2R.mjs → chunk-G2K6T2QU.mjs} +8 -16
  10. package/dist/chunk-G2K6T2QU.mjs.map +1 -0
  11. package/dist/{chunk-KJ3U5SXS.mjs → chunk-MX2OYLRS.mjs} +6 -36
  12. package/dist/chunk-MX2OYLRS.mjs.map +1 -0
  13. package/dist/{chunk-FXT6XSUB.mjs → chunk-RYDEG77L.mjs} +2 -2
  14. package/dist/{chunk-N57PDRVX.mjs → chunk-TRXKPXDE.mjs} +2 -2
  15. package/dist/{chunk-KNKSEGAE.mjs → chunk-XACBOJF5.mjs} +5 -23
  16. package/dist/chunk-XACBOJF5.mjs.map +1 -0
  17. package/dist/{chunk-A6THC3F6.mjs → chunk-ZM6HV22S.mjs} +2 -2
  18. package/dist/components/copilot-provider/copilotkit.js +2 -19
  19. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  20. package/dist/components/copilot-provider/copilotkit.mjs +2 -2
  21. package/dist/components/copilot-provider/index.js +2 -19
  22. package/dist/components/copilot-provider/index.js.map +1 -1
  23. package/dist/components/copilot-provider/index.mjs +2 -2
  24. package/dist/components/index.js +2 -19
  25. package/dist/components/index.js.map +1 -1
  26. package/dist/components/index.mjs +2 -2
  27. package/dist/context/copilot-context.d.ts +0 -6
  28. package/dist/context/copilot-context.js +1 -9
  29. package/dist/context/copilot-context.js.map +1 -1
  30. package/dist/context/copilot-context.mjs +1 -1
  31. package/dist/context/index.js +1 -9
  32. package/dist/context/index.js.map +1 -1
  33. package/dist/context/index.mjs +1 -1
  34. package/dist/hooks/index.d.ts +1 -2
  35. package/dist/hooks/index.js +11 -78
  36. package/dist/hooks/index.js.map +1 -1
  37. package/dist/hooks/index.mjs +9 -15
  38. package/dist/hooks/use-chat.d.ts +0 -20
  39. package/dist/hooks/use-chat.js +7 -15
  40. package/dist/hooks/use-chat.js.map +1 -1
  41. package/dist/hooks/use-chat.mjs +1 -1
  42. package/dist/hooks/use-coagent-state-render.js +1 -9
  43. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  44. package/dist/hooks/use-coagent-state-render.mjs +2 -2
  45. package/dist/hooks/use-coagent.d.ts +3 -16
  46. package/dist/hooks/use-coagent.js +11 -78
  47. package/dist/hooks/use-coagent.js.map +1 -1
  48. package/dist/hooks/use-coagent.mjs +5 -11
  49. package/dist/hooks/use-copilot-action.js +1 -9
  50. package/dist/hooks/use-copilot-action.js.map +1 -1
  51. package/dist/hooks/use-copilot-action.mjs +2 -2
  52. package/dist/hooks/use-copilot-chat.d.ts +0 -1
  53. package/dist/hooks/use-copilot-chat.js +10 -56
  54. package/dist/hooks/use-copilot-chat.js.map +1 -1
  55. package/dist/hooks/use-copilot-chat.mjs +4 -4
  56. package/dist/hooks/use-copilot-readable.js +1 -9
  57. package/dist/hooks/use-copilot-readable.js.map +1 -1
  58. package/dist/hooks/use-copilot-readable.mjs +2 -2
  59. package/dist/hooks/use-make-copilot-document-readable.js +1 -9
  60. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  61. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  62. package/dist/index.d.ts +1 -1
  63. package/dist/index.js +12 -88
  64. package/dist/index.js.map +1 -1
  65. package/dist/index.mjs +11 -17
  66. package/dist/lib/copilot-task.js.map +1 -1
  67. package/dist/lib/copilot-task.mjs +3 -3
  68. package/dist/lib/index.js.map +1 -1
  69. package/dist/lib/index.mjs +3 -3
  70. package/dist/utils/extract.js.map +1 -1
  71. package/dist/utils/extract.mjs +3 -3
  72. package/dist/utils/index.js.map +1 -1
  73. package/dist/utils/index.mjs +3 -3
  74. package/package.json +5 -5
  75. package/src/components/copilot-provider/copilotkit.tsx +0 -10
  76. package/src/context/copilot-context.tsx +0 -21
  77. package/src/hooks/index.ts +1 -1
  78. package/src/hooks/use-chat.ts +7 -40
  79. package/src/hooks/use-coagent.ts +6 -23
  80. package/src/hooks/use-copilot-chat.ts +4 -35
  81. package/dist/chunk-24ALPG2R.mjs.map +0 -1
  82. package/dist/chunk-KJ3U5SXS.mjs.map +0 -1
  83. package/dist/chunk-KNKSEGAE.mjs.map +0 -1
  84. /package/dist/{chunk-PHP2YMMH.mjs.map → chunk-27IPQFJP.mjs.map} +0 -0
  85. /package/dist/{chunk-I7XLZC4D.mjs.map → chunk-7DFHFZJT.mjs.map} +0 -0
  86. /package/dist/{chunk-ZDYUMEE5.mjs.map → chunk-ANOG3W5S.mjs.map} +0 -0
  87. /package/dist/{chunk-FXT6XSUB.mjs.map → chunk-RYDEG77L.mjs.map} +0 -0
  88. /package/dist/{chunk-N57PDRVX.mjs.map → chunk-TRXKPXDE.mjs.map} +0 -0
  89. /package/dist/{chunk-A6THC3F6.mjs.map → chunk-ZM6HV22S.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -87,9 +87,6 @@ __export(src_exports, {
87
87
  CopilotTask: () => CopilotTask,
88
88
  defaultCopilotContextCategories: () => defaultCopilotContextCategories,
89
89
  extract: () => extract,
90
- runAgent: () => runAgent,
91
- startAgent: () => startAgent,
92
- stopAgent: () => stopAgent,
93
90
  useCoAgent: () => useCoAgent,
94
91
  useCoAgentStateRender: () => useCoAgentStateRender,
95
92
  useCopilotAction: () => useCopilotAction,
@@ -154,15 +151,7 @@ var emptyCopilotContext = {
154
151
  },
155
152
  agentSession: null,
156
153
  setAgentSession: () => {
157
- },
158
- agentLock: null,
159
- threadId: null,
160
- setThreadId: () => {
161
- },
162
- runId: null,
163
- setRunId: () => {
164
- },
165
- chatAbortControllerRef: { current: null }
154
+ }
166
155
  };
167
156
  var CopilotContext = import_react.default.createContext(emptyCopilotContext);
168
157
  function useCopilotContext() {
@@ -576,9 +565,6 @@ ${nonDocumentStrings}`;
576
565
  };
577
566
  }
578
567
  const [agentSession, setAgentSession] = (0, import_react6.useState)(initialAgentSession);
579
- const [threadId, setThreadId] = (0, import_react6.useState)(null);
580
- const [runId, setRunId] = (0, import_react6.useState)(null);
581
- const chatAbortControllerRef = (0, import_react6.useRef)(null);
582
568
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
583
569
  CopilotContext.Provider,
584
570
  {
@@ -609,13 +595,7 @@ ${nonDocumentStrings}`;
609
595
  coagentStates,
610
596
  setCoagentStates,
611
597
  agentSession,
612
- setAgentSession,
613
- agentLock: props.agent || null,
614
- threadId,
615
- setThreadId,
616
- runId,
617
- setRunId,
618
- chatAbortControllerRef
598
+ setAgentSession
619
599
  },
620
600
  children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CopilotMessages, { children })
621
601
  }
@@ -671,22 +651,16 @@ function useChat(options) {
671
651
  setCoagentStates,
672
652
  coagentStates,
673
653
  agentSession,
674
- setAgentSession,
675
- threadId,
676
- setThreadId,
677
- runId,
678
- setRunId,
679
- chatAbortControllerRef
654
+ setAgentSession
680
655
  } = options;
656
+ const abortControllerRef = (0, import_react7.useRef)();
657
+ const threadIdRef = (0, import_react7.useRef)(null);
658
+ const runIdRef = (0, import_react7.useRef)(null);
681
659
  const runChatCompletionRef = (0, import_react7.useRef)();
682
660
  const coagentStatesRef = (0, import_react7.useRef)(coagentStates);
683
661
  coagentStatesRef.current = coagentStates;
684
662
  const agentSessionRef = (0, import_react7.useRef)(agentSession);
685
663
  agentSessionRef.current = agentSession;
686
- const threadIdRef = (0, import_react7.useRef)(threadId);
687
- threadIdRef.current = threadId;
688
- const runIdRef = (0, import_react7.useRef)(runId);
689
- runIdRef.current = runId;
690
664
  const publicApiKey = copilotConfig.publicApiKey;
691
665
  const headers = __spreadValues(__spreadValues({}, copilotConfig.headers || {}), publicApiKey ? { [import_shared4.COPILOT_CLOUD_PUBLIC_API_KEY_HEADER]: publicApiKey } : {});
692
666
  const runtimeClient = new import_runtime_client_gql.CopilotRuntimeClient({
@@ -705,7 +679,7 @@ function useChat(options) {
705
679
  })
706
680
  ];
707
681
  const abortController = new AbortController();
708
- chatAbortControllerRef.current = abortController;
682
+ abortControllerRef.current = abortController;
709
683
  setMessages([...previousMessages, ...newMessages]);
710
684
  const systemMessage = makeSystemMessageCallback();
711
685
  const messagesWithContext = [systemMessage, ...initialMessages || [], ...previousMessages];
@@ -745,7 +719,7 @@ function useChat(options) {
745
719
  }))
746
720
  }),
747
721
  properties: copilotConfig.properties,
748
- signal: (_d = chatAbortControllerRef.current) == null ? void 0 : _d.signal
722
+ signal: (_d = abortControllerRef.current) == null ? void 0 : _d.signal
749
723
  })
750
724
  );
751
725
  const guardrailsEnabled = ((_g = (_f = (_e = copilotConfig.cloud) == null ? void 0 : _e.guardrails) == null ? void 0 : _f.input) == null ? void 0 : _g.restrictToTopic.enabled) || false;
@@ -764,8 +738,6 @@ function useChat(options) {
764
738
  }
765
739
  threadIdRef.current = value.generateCopilotResponse.threadId || null;
766
740
  runIdRef.current = value.generateCopilotResponse.runId || null;
767
- setThreadId(threadIdRef.current);
768
- setRunId(runIdRef.current);
769
741
  const messages2 = (0, import_runtime_client_gql.convertGqlOutputToMessages)(
770
742
  (0, import_runtime_client_gql.filterAdjacentAgentStateMessages)(value.generateCopilotResponse.messages)
771
743
  );
@@ -894,7 +866,7 @@ function useChat(options) {
894
866
  });
895
867
  const stop = () => {
896
868
  var _a;
897
- (_a = chatAbortControllerRef.current) == null ? void 0 : _a.abort();
869
+ (_a = abortControllerRef.current) == null ? void 0 : _a.abort();
898
870
  };
899
871
  return {
900
872
  append,
@@ -922,13 +894,7 @@ function useCopilotChat(_a = {}) {
922
894
  setCoagentStates,
923
895
  coAgentStateRenders,
924
896
  agentSession,
925
- setAgentSession,
926
- agentLock,
927
- threadId,
928
- setThreadId,
929
- runId,
930
- setRunId,
931
- chatAbortControllerRef
897
+ setAgentSession
932
898
  } = useCopilotContext();
933
899
  const { messages, setMessages } = useCopilotMessagesContext();
934
900
  const latestGetContextString = useUpdatedRef(getContextString);
@@ -978,12 +944,7 @@ function useCopilotChat(_a = {}) {
978
944
  coagentStates,
979
945
  setCoagentStates,
980
946
  agentSession,
981
- setAgentSession,
982
- threadId,
983
- setThreadId,
984
- runId,
985
- setRunId,
986
- chatAbortControllerRef
947
+ setAgentSession
987
948
  }));
988
949
  const latestAppend = useUpdatedRef(append);
989
950
  const latestAppendFunc = (0, import_react8.useCallback)(
@@ -1014,24 +975,6 @@ function useCopilotChat(_a = {}) {
1014
975
  },
1015
976
  [latestSetMessages]
1016
977
  );
1017
- const reset = (0, import_react8.useCallback)(() => {
1018
- latestStopFunc();
1019
- setMessages([]);
1020
- setThreadId(null);
1021
- setRunId(null);
1022
- setCoagentStates({});
1023
- let initialAgentSession = null;
1024
- if (agentLock) {
1025
- initialAgentSession = {
1026
- agentName: agentLock
1027
- };
1028
- }
1029
- setAgentSession(initialAgentSession);
1030
- }, [latestStopFunc, setMessages, setThreadId, setCoagentStates, setAgentSession, agentLock]);
1031
- const latestReset = useUpdatedRef(reset);
1032
- const latestResetFunc = (0, import_react8.useCallback)(() => {
1033
- return latestReset.current();
1034
- }, [latestReset]);
1035
978
  return {
1036
979
  visibleMessages: messages,
1037
980
  appendMessage: latestAppendFunc,
@@ -1039,7 +982,6 @@ function useCopilotChat(_a = {}) {
1039
982
  reloadMessages: latestReloadFunc,
1040
983
  stopGeneration: latestStopFunc,
1041
984
  deleteMessage: latestDeleteFunc,
1042
- reset: latestResetFunc,
1043
985
  isLoading
1044
986
  };
1045
987
  }
@@ -1264,11 +1206,7 @@ function useCoAgent(options) {
1264
1206
  } else if (coagentStates[name] === void 0) {
1265
1207
  setState(options.initialState === void 0 ? {} : options.initialState);
1266
1208
  }
1267
- }, [
1268
- isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0,
1269
- // reset initial state on reset
1270
- coagentStates[name] === void 0
1271
- ]);
1209
+ }, [isExternalStateManagement(options) ? JSON.stringify(options.state) : void 0]);
1272
1210
  return {
1273
1211
  name,
1274
1212
  nodeName: coagentState.nodeName,
@@ -1296,17 +1234,6 @@ function stopAgent(name, context) {
1296
1234
  const { agentSession, setAgentSession } = context;
1297
1235
  if (agentSession && agentSession.agentName === name) {
1298
1236
  setAgentSession(null);
1299
- context.setCoagentStates((prevAgentStates) => {
1300
- return __spreadProps(__spreadValues({}, prevAgentStates), {
1301
- [name]: __spreadProps(__spreadValues({}, prevAgentStates[name]), {
1302
- running: false,
1303
- active: false,
1304
- threadId: void 0,
1305
- nodeName: void 0,
1306
- runId: void 0
1307
- })
1308
- });
1309
- });
1310
1237
  } else {
1311
1238
  console.warn(`No agent session found for ${name}`);
1312
1239
  }
@@ -1585,9 +1512,6 @@ This is not a conversation, so please do not ask questions. Just call the functi
1585
1512
  CopilotTask,
1586
1513
  defaultCopilotContextCategories,
1587
1514
  extract,
1588
- runAgent,
1589
- startAgent,
1590
- stopAgent,
1591
1515
  useCoAgent,
1592
1516
  useCoAgentStateRender,
1593
1517
  useCopilotAction,