@copilotkit/react-core 1.50.0-beta.2 → 1.50.0-beta.3

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 (134) hide show
  1. package/dist/{chunk-BPJ6V4YX.mjs → chunk-4HRUQH6U.mjs} +2 -2
  2. package/dist/{chunk-LD3MGPZB.mjs → chunk-7HI6VLJJ.mjs} +5 -5
  3. package/dist/{chunk-D3QSYDJR.mjs → chunk-7IBF6RBW.mjs} +2 -2
  4. package/dist/{chunk-OVYFRPSN.mjs → chunk-ABWT4DRT.mjs} +2 -2
  5. package/dist/{chunk-WVLHXIFP.mjs → chunk-AFNWX62Q.mjs} +2 -2
  6. package/dist/{chunk-WVLHXIFP.mjs.map → chunk-AFNWX62Q.mjs.map} +1 -1
  7. package/dist/{chunk-OAEX7G5G.mjs → chunk-AMUONDZ2.mjs} +2 -2
  8. package/dist/{chunk-SD7TUPQM.mjs → chunk-B66SA6EH.mjs} +44 -49
  9. package/dist/chunk-B66SA6EH.mjs.map +1 -0
  10. package/dist/{chunk-7BYHZLPL.mjs → chunk-BTZ3TJVX.mjs} +6 -6
  11. package/dist/chunk-BTZ3TJVX.mjs.map +1 -0
  12. package/dist/{chunk-BR5YEYZJ.mjs → chunk-IUNU4CUG.mjs} +5 -5
  13. package/dist/{chunk-6F7Q6CPI.mjs → chunk-M7EVKKUZ.mjs} +7 -7
  14. package/dist/{chunk-LHKZJ2ND.mjs → chunk-PMWUKW3Z.mjs} +3 -3
  15. package/dist/{chunk-TGIWTM6S.mjs → chunk-QNUAXSDP.mjs} +2 -2
  16. package/dist/{chunk-TGIWTM6S.mjs.map → chunk-QNUAXSDP.mjs.map} +1 -1
  17. package/dist/{chunk-6SK26J65.mjs → chunk-SHHPDZUK.mjs} +2 -2
  18. package/dist/{chunk-LHERIF3L.mjs → chunk-SNON4QA6.mjs} +4 -4
  19. package/dist/{chunk-ISNVEPPQ.mjs → chunk-VV56AVPB.mjs} +17 -7
  20. package/dist/chunk-VV56AVPB.mjs.map +1 -0
  21. package/dist/{chunk-EHXVGFWN.mjs → chunk-XFXT2VNX.mjs} +3 -3
  22. package/dist/{chunk-WMJVBMUX.mjs → chunk-YCG6SNAU.mjs} +2 -2
  23. package/dist/components/copilot-provider/copilot-messages.js +1 -1
  24. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  25. package/dist/components/copilot-provider/copilot-messages.mjs +3 -3
  26. package/dist/components/copilot-provider/copilotkit-props.d.ts +1 -1
  27. package/dist/components/copilot-provider/copilotkit.d.ts +1 -1
  28. package/dist/components/copilot-provider/copilotkit.js +26 -31
  29. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  30. package/dist/components/copilot-provider/copilotkit.mjs +13 -13
  31. package/dist/components/copilot-provider/index.d.ts +1 -1
  32. package/dist/components/copilot-provider/index.js +26 -31
  33. package/dist/components/copilot-provider/index.js.map +1 -1
  34. package/dist/components/copilot-provider/index.mjs +13 -13
  35. package/dist/components/dev-console/console-trigger.js +1 -1
  36. package/dist/components/dev-console/console-trigger.js.map +1 -1
  37. package/dist/components/dev-console/console-trigger.mjs +3 -3
  38. package/dist/components/dev-console/developer-console-modal.js +1 -1
  39. package/dist/components/dev-console/developer-console-modal.js.map +1 -1
  40. package/dist/components/dev-console/developer-console-modal.mjs +2 -2
  41. package/dist/components/error-boundary/error-boundary.mjs +2 -2
  42. package/dist/components/index.d.ts +1 -1
  43. package/dist/components/index.js +26 -31
  44. package/dist/components/index.js.map +1 -1
  45. package/dist/components/index.mjs +13 -13
  46. package/dist/context/copilot-context.d.ts +1 -1
  47. package/dist/context/copilot-context.js +1 -1
  48. package/dist/context/copilot-context.js.map +1 -1
  49. package/dist/context/copilot-context.mjs +1 -1
  50. package/dist/context/index.d.ts +1 -1
  51. package/dist/context/index.js +1 -1
  52. package/dist/context/index.js.map +1 -1
  53. package/dist/context/index.mjs +6 -6
  54. package/dist/{copilot-context-81022020.d.ts → copilot-context-ec77e921.d.ts} +2 -2
  55. package/dist/hooks/index.d.ts +1 -1
  56. package/dist/hooks/index.js +19 -9
  57. package/dist/hooks/index.js.map +1 -1
  58. package/dist/hooks/index.mjs +15 -15
  59. package/dist/hooks/use-coagent-state-render-bridge.js +1 -1
  60. package/dist/hooks/use-coagent-state-render-bridge.js.map +1 -1
  61. package/dist/hooks/use-coagent-state-render-bridge.mjs +3 -3
  62. package/dist/hooks/use-coagent-state-render.js +1 -1
  63. package/dist/hooks/use-coagent-state-render.js.map +1 -1
  64. package/dist/hooks/use-coagent-state-render.mjs +3 -3
  65. package/dist/hooks/use-copilot-additional-instructions.js +1 -1
  66. package/dist/hooks/use-copilot-additional-instructions.js.map +1 -1
  67. package/dist/hooks/use-copilot-additional-instructions.mjs +2 -2
  68. package/dist/hooks/use-copilot-authenticated-action.js +1 -1
  69. package/dist/hooks/use-copilot-authenticated-action.js.map +1 -1
  70. package/dist/hooks/use-copilot-authenticated-action.mjs +2 -2
  71. package/dist/hooks/use-copilot-chat-headless_c.js +17 -7
  72. package/dist/hooks/use-copilot-chat-headless_c.js.map +1 -1
  73. package/dist/hooks/use-copilot-chat-headless_c.mjs +9 -9
  74. package/dist/hooks/use-copilot-chat.js +17 -7
  75. package/dist/hooks/use-copilot-chat.js.map +1 -1
  76. package/dist/hooks/use-copilot-chat.mjs +9 -9
  77. package/dist/hooks/use-copilot-chat_internal.js +17 -7
  78. package/dist/hooks/use-copilot-chat_internal.js.map +1 -1
  79. package/dist/hooks/use-copilot-chat_internal.mjs +8 -8
  80. package/dist/hooks/use-langgraph-interrupt-render.js +16 -6
  81. package/dist/hooks/use-langgraph-interrupt-render.js.map +1 -1
  82. package/dist/hooks/use-langgraph-interrupt-render.mjs +3 -3
  83. package/dist/hooks/use-langgraph-interrupt.d.ts +1 -1
  84. package/dist/hooks/use-langgraph-interrupt.js +3 -3
  85. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  86. package/dist/hooks/use-langgraph-interrupt.mjs +2 -2
  87. package/dist/hooks/use-make-copilot-document-readable.js +1 -1
  88. package/dist/hooks/use-make-copilot-document-readable.js.map +1 -1
  89. package/dist/hooks/use-make-copilot-document-readable.mjs +2 -2
  90. package/dist/index.d.ts +1 -1
  91. package/dist/index.js +43 -38
  92. package/dist/index.js.map +1 -1
  93. package/dist/index.mjs +44 -44
  94. package/dist/lib/copilot-task.d.ts +1 -1
  95. package/dist/lib/copilot-task.js.map +1 -1
  96. package/dist/lib/copilot-task.mjs +14 -14
  97. package/dist/lib/index.d.ts +1 -1
  98. package/dist/lib/index.js.map +1 -1
  99. package/dist/lib/index.mjs +14 -14
  100. package/dist/types/index.d.ts +1 -1
  101. package/dist/types/index.mjs +1 -1
  102. package/dist/types/interrupt-action.d.ts +1 -1
  103. package/dist/types/interrupt-action.js.map +1 -1
  104. package/dist/utils/index.mjs +3 -3
  105. package/dist/v2/index.css +4 -0
  106. package/dist/v2/index.css.map +1 -0
  107. package/dist/v2/index.js.map +1 -1
  108. package/dist/v2/index.mjs +2 -0
  109. package/dist/v2/index.mjs.map +1 -1
  110. package/package.json +10 -8
  111. package/src/components/copilot-provider/copilotkit.tsx +30 -30
  112. package/src/context/copilot-context.tsx +2 -2
  113. package/src/hooks/use-coagent-state-render-bridge.tsx +2 -2
  114. package/src/hooks/use-langgraph-interrupt-render.ts +15 -5
  115. package/src/hooks/use-langgraph-interrupt.ts +2 -3
  116. package/src/types/interrupt-action.ts +1 -4
  117. package/src/v2/index.ts +2 -0
  118. package/tsup.config.ts +1 -1
  119. package/dist/chunk-7BYHZLPL.mjs.map +0 -1
  120. package/dist/chunk-ISNVEPPQ.mjs.map +0 -1
  121. package/dist/chunk-SD7TUPQM.mjs.map +0 -1
  122. /package/dist/{chunk-BPJ6V4YX.mjs.map → chunk-4HRUQH6U.mjs.map} +0 -0
  123. /package/dist/{chunk-LD3MGPZB.mjs.map → chunk-7HI6VLJJ.mjs.map} +0 -0
  124. /package/dist/{chunk-D3QSYDJR.mjs.map → chunk-7IBF6RBW.mjs.map} +0 -0
  125. /package/dist/{chunk-OVYFRPSN.mjs.map → chunk-ABWT4DRT.mjs.map} +0 -0
  126. /package/dist/{chunk-OAEX7G5G.mjs.map → chunk-AMUONDZ2.mjs.map} +0 -0
  127. /package/dist/{chunk-BR5YEYZJ.mjs.map → chunk-IUNU4CUG.mjs.map} +0 -0
  128. /package/dist/{chunk-6F7Q6CPI.mjs.map → chunk-M7EVKKUZ.mjs.map} +0 -0
  129. /package/dist/{chunk-LHKZJ2ND.mjs.map → chunk-PMWUKW3Z.mjs.map} +0 -0
  130. /package/dist/{chunk-6SK26J65.mjs.map → chunk-SHHPDZUK.mjs.map} +0 -0
  131. /package/dist/{chunk-LHERIF3L.mjs.map → chunk-SNON4QA6.mjs.map} +0 -0
  132. /package/dist/{chunk-EHXVGFWN.mjs.map → chunk-XFXT2VNX.mjs.map} +0 -0
  133. /package/dist/{chunk-WMJVBMUX.mjs.map → chunk-YCG6SNAU.mjs.map} +0 -0
  134. /package/src/v2/{styles.css → index.css} +0 -0
package/dist/index.js CHANGED
@@ -198,7 +198,7 @@ var emptyCopilotContext = {
198
198
  interruptEventQueue: {},
199
199
  addInterruptEvent: () => {
200
200
  },
201
- removeInterruptEvent: () => {
201
+ resolveInterruptEvent: () => {
202
202
  },
203
203
  onError: () => {
204
204
  },
@@ -2522,7 +2522,7 @@ function useCoagentStateRenderBridge(agentId, props) {
2522
2522
  return canRender;
2523
2523
  }
2524
2524
  const renderClaimedByOtherMessage = Object.values(claimsRef.current).find(
2525
- (c) => c.stateRenderId === stateRenderId && (0, import_shared10.dataToUUID)(JSON.stringify(getStateWithoutConstantKeys(c.stateSnapshot))) === (0, import_shared10.dataToUUID)(JSON.stringify(getStateWithoutConstantKeys(renderSnapshot)))
2525
+ (c) => c.stateRenderId === stateRenderId && (0, import_shared10.dataToUUID)(getStateWithoutConstantKeys(c.stateSnapshot)) === (0, import_shared10.dataToUUID)(getStateWithoutConstantKeys(renderSnapshot))
2526
2526
  );
2527
2527
  if (renderClaimedByOtherMessage) {
2528
2528
  if (renderSnapshot && renderClaimedByOtherMessage.stateSnapshot && !areStatesEquals(renderClaimedByOtherMessage.stateSnapshot, renderSnapshot)) {
@@ -2661,14 +2661,7 @@ function CopilotKit(_a) {
2661
2661
  const enabled = shouldShowDevConsole(props.showDevConsole);
2662
2662
  const publicApiKey = props.publicApiKey || props.publicLicenseKey;
2663
2663
  const renderArr = (0, import_react17.useMemo)(() => [{ render: CoAgentStateRenderBridge }], []);
2664
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CopilotErrorBoundary, { publicApiKey, showUsageBanner: enabled, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ThreadsProvider, { threadId: props.threadId, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2665
- import_react18.CopilotKitProvider,
2666
- __spreadProps(__spreadValues({}, props), {
2667
- renderCustomMessages: renderArr,
2668
- useSingleEndpoint: true,
2669
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children }))
2670
- })
2671
- ) }) }) });
2664
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ToastProvider, { enabled, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CopilotErrorBoundary, { publicApiKey, showUsageBanner: enabled, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ThreadsProvider, { threadId: props.threadId, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react18.CopilotKitProvider, __spreadProps(__spreadValues({}, props), { renderCustomMessages: renderArr, useSingleEndpoint: true, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CopilotKitInternal, __spreadProps(__spreadValues({}, props), { children })) })) }) }) });
2672
2665
  }
2673
2666
  function CopilotKitInternal(cpkProps) {
2674
2667
  var _b;
@@ -2906,20 +2899,17 @@ ${nonDocumentStrings}`;
2906
2899
  const chatAbortControllerRef = (0, import_react17.useRef)(null);
2907
2900
  const showDevConsole = shouldShowDevConsole(props.showDevConsole);
2908
2901
  const [interruptActions, _setInterruptActions] = (0, import_react17.useState)({});
2909
- const setInterruptAction = (0, import_react17.useCallback)(
2910
- (threadId2, action) => {
2911
- _setInterruptActions((prev) => {
2912
- var _a2;
2913
- if (action == null || !action.id) {
2914
- return prev;
2915
- }
2916
- return __spreadProps(__spreadValues({}, prev), {
2917
- [action.id]: __spreadValues(__spreadValues({}, (_a2 = prev[action.id]) != null ? _a2 : {}), action)
2918
- });
2902
+ const setInterruptAction = (0, import_react17.useCallback)((action) => {
2903
+ _setInterruptActions((prev) => {
2904
+ var _a2;
2905
+ if (action == null || !action.id) {
2906
+ return prev;
2907
+ }
2908
+ return __spreadProps(__spreadValues({}, prev), {
2909
+ [action.id]: __spreadValues(__spreadValues({}, (_a2 = prev[action.id]) != null ? _a2 : {}), action)
2919
2910
  });
2920
- },
2921
- []
2922
- );
2911
+ });
2912
+ }, []);
2923
2913
  const removeInterruptAction = (0, import_react17.useCallback)((actionId) => {
2924
2914
  _setInterruptActions((prev) => {
2925
2915
  const _a2 = prev, { [actionId]: _ } = _a2, rest = __objRest(_a2, [__restKey(actionId)]);
@@ -2935,14 +2925,19 @@ ${nonDocumentStrings}`;
2935
2925
  });
2936
2926
  });
2937
2927
  }, []);
2938
- const removeInterruptEvent = (0, import_react17.useCallback)((threadId2, eventId) => {
2939
- setInterruptEventQueue((prev) => {
2940
- const threadQueue = prev[threadId2] || [];
2941
- return __spreadProps(__spreadValues({}, prev), {
2942
- [threadId2]: threadQueue.filter((event) => event.eventId !== eventId)
2928
+ const resolveInterruptEvent = (0, import_react17.useCallback)(
2929
+ (threadId2, eventId, response) => {
2930
+ setInterruptEventQueue((prev) => {
2931
+ const threadQueue = prev[threadId2] || [];
2932
+ return __spreadProps(__spreadValues({}, prev), {
2933
+ [threadId2]: threadQueue.map(
2934
+ (queuedEvent) => queuedEvent.eventId === eventId ? __spreadProps(__spreadValues({}, queuedEvent), { event: __spreadProps(__spreadValues({}, queuedEvent.event), { response }) }) : queuedEvent
2935
+ )
2936
+ });
2943
2937
  });
2944
- });
2945
- }, []);
2938
+ },
2939
+ []
2940
+ );
2946
2941
  const memoizedChildren = (0, import_react17.useMemo)(() => children, [children]);
2947
2942
  const [bannerError, setBannerError] = (0, import_react17.useState)(null);
2948
2943
  const agentLock = (0, import_react17.useMemo)(() => {
@@ -3060,7 +3055,7 @@ ${nonDocumentStrings}`;
3060
3055
  removeInterruptAction,
3061
3056
  interruptEventQueue,
3062
3057
  addInterruptEvent,
3063
- removeInterruptEvent,
3058
+ resolveInterruptEvent,
3064
3059
  bannerError,
3065
3060
  setBannerError,
3066
3061
  onError: handleErrors,
@@ -3186,7 +3181,7 @@ function useLangGraphInterruptRender(agent) {
3186
3181
  threadId,
3187
3182
  interruptEventQueue,
3188
3183
  addInterruptEvent,
3189
- removeInterruptEvent
3184
+ resolveInterruptEvent
3190
3185
  } = useCopilotContext();
3191
3186
  const existingConfig = (0, import_react22.useCopilotChatConfiguration)();
3192
3187
  const resolvedAgentId = (_a = existingConfig == null ? void 0 : existingConfig.agentId) != null ? _a : "default";
@@ -3194,6 +3189,7 @@ function useLangGraphInterruptRender(agent) {
3194
3189
  (0, import_react21.useEffect)(() => {
3195
3190
  if (!agent)
3196
3191
  return;
3192
+ let localInterrupt = null;
3197
3193
  const subscriber = {
3198
3194
  onCustomEvent: ({ event }) => {
3199
3195
  if (event.name === "on_interrupt") {
@@ -3202,12 +3198,21 @@ function useLangGraphInterruptRender(agent) {
3202
3198
  type: event.type,
3203
3199
  value: (0, import_shared14.parseJson)(event.value, event.value)
3204
3200
  };
3205
- const eventId = (0, import_shared14.dataToUUID)(JSON.stringify(eventData), "interruptEvents");
3206
- addInterruptEvent({
3201
+ const eventId = (0, import_shared14.dataToUUID)(eventData, "interruptEvents");
3202
+ localInterrupt = {
3207
3203
  eventId,
3208
3204
  threadId,
3209
3205
  event: eventData
3210
- });
3206
+ };
3207
+ }
3208
+ },
3209
+ onRunStartedEvent: () => {
3210
+ localInterrupt = null;
3211
+ },
3212
+ onRunFinalized: () => {
3213
+ if (localInterrupt) {
3214
+ addInterruptEvent(localInterrupt);
3215
+ localInterrupt = null;
3211
3216
  }
3212
3217
  }
3213
3218
  };
@@ -3225,7 +3230,7 @@ function useLangGraphInterruptRender(agent) {
3225
3230
  }
3226
3231
  }
3227
3232
  });
3228
- removeInterruptEvent(threadId, eventId);
3233
+ resolveInterruptEvent(threadId, eventId, response != null ? response : "");
3229
3234
  },
3230
3235
  // eslint-disable-next-line react-hooks/exhaustive-deps
3231
3236
  [agent, threadId]
@@ -4724,11 +4729,11 @@ var import_shared23 = require("@copilotkit/shared");
4724
4729
  function useLangGraphInterrupt(action, dependencies) {
4725
4730
  const { setInterruptAction, removeInterruptAction, interruptActions, threadId } = (0, import_react45.useContext)(CopilotContext);
4726
4731
  const { addToast } = useToast();
4727
- const actionId = (0, import_shared23.dataToUUID)(JSON.stringify(action), "lgAction");
4732
+ const actionId = (0, import_shared23.dataToUUID)(action, "lgAction");
4728
4733
  (0, import_react45.useEffect)(() => {
4729
4734
  if (!action)
4730
4735
  return;
4731
- setInterruptAction(threadId, __spreadProps(__spreadValues({}, action), { id: actionId }));
4736
+ setInterruptAction(__spreadProps(__spreadValues({}, action), { id: actionId }));
4732
4737
  return () => {
4733
4738
  removeInterruptAction(actionId);
4734
4739
  };