@copilotkit/react-core 1.9.2-next.20 → 1.9.2-next.22

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 (68) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{chunk-MTAJI7HV.mjs → chunk-6ZLSC4KB.mjs} +20 -15
  3. package/dist/chunk-6ZLSC4KB.mjs.map +1 -0
  4. package/dist/{chunk-R2LNRHJP.mjs → chunk-BSAVFYRQ.mjs} +5 -5
  5. package/dist/{chunk-R2LNRHJP.mjs.map → chunk-BSAVFYRQ.mjs.map} +1 -1
  6. package/dist/{chunk-3SLA7Q2N.mjs → chunk-CUAFWKTQ.mjs} +4 -4
  7. package/dist/{chunk-K42OD3J6.mjs → chunk-GEE5AMYL.mjs} +8 -8
  8. package/dist/{chunk-KWQPQ4MM.mjs → chunk-GIMSRCVW.mjs} +6 -6
  9. package/dist/{chunk-ZOMEQ3XC.mjs → chunk-KLENTCQV.mjs} +33 -7
  10. package/dist/{chunk-ZOMEQ3XC.mjs.map → chunk-KLENTCQV.mjs.map} +1 -1
  11. package/dist/{chunk-UGJGKBFB.mjs → chunk-NGQN3JRJ.mjs} +2 -2
  12. package/dist/{chunk-SJJNFYGQ.mjs → chunk-SGF6C7I6.mjs} +4 -4
  13. package/dist/components/copilot-provider/copilot-messages.js +1 -1
  14. package/dist/components/copilot-provider/copilot-messages.js.map +1 -1
  15. package/dist/components/copilot-provider/copilot-messages.mjs +2 -2
  16. package/dist/components/copilot-provider/copilotkit.js +1 -1
  17. package/dist/components/copilot-provider/copilotkit.js.map +1 -1
  18. package/dist/components/copilot-provider/copilotkit.mjs +8 -8
  19. package/dist/components/copilot-provider/index.js +1 -1
  20. package/dist/components/copilot-provider/index.js.map +1 -1
  21. package/dist/components/copilot-provider/index.mjs +8 -8
  22. package/dist/components/error-boundary/error-boundary.mjs +2 -2
  23. package/dist/components/index.js +1 -1
  24. package/dist/components/index.js.map +1 -1
  25. package/dist/components/index.mjs +8 -8
  26. package/dist/context/index.mjs +4 -4
  27. package/dist/hooks/index.js +42 -11
  28. package/dist/hooks/index.js.map +1 -1
  29. package/dist/hooks/index.mjs +14 -14
  30. package/dist/hooks/use-chat.js +16 -11
  31. package/dist/hooks/use-chat.js.map +1 -1
  32. package/dist/hooks/use-chat.mjs +3 -3
  33. package/dist/hooks/use-coagent.js +42 -11
  34. package/dist/hooks/use-coagent.js.map +1 -1
  35. package/dist/hooks/use-coagent.mjs +13 -13
  36. package/dist/hooks/use-copilot-chat.js +16 -11
  37. package/dist/hooks/use-copilot-chat.js.map +1 -1
  38. package/dist/hooks/use-copilot-chat.mjs +12 -12
  39. package/dist/hooks/use-langgraph-interrupt-render.mjs +1 -1
  40. package/dist/hooks/use-langgraph-interrupt.js +16 -11
  41. package/dist/hooks/use-langgraph-interrupt.js.map +1 -1
  42. package/dist/hooks/use-langgraph-interrupt.mjs +13 -13
  43. package/dist/index.js +43 -12
  44. package/dist/index.js.map +1 -1
  45. package/dist/index.mjs +18 -18
  46. package/dist/lib/copilot-task.mjs +10 -10
  47. package/dist/lib/index.mjs +10 -10
  48. package/dist/setupTests.d.ts +2 -0
  49. package/dist/setupTests.js +26 -0
  50. package/dist/setupTests.js.map +1 -0
  51. package/dist/setupTests.mjs +24 -0
  52. package/dist/setupTests.mjs.map +1 -0
  53. package/dist/utils/extract.mjs +8 -8
  54. package/dist/utils/index.mjs +8 -8
  55. package/jest.config.js +4 -0
  56. package/package.json +6 -3
  57. package/src/components/copilot-provider/copilot-messages.tsx +1 -1
  58. package/src/hooks/__tests__/use-coagent-config.test.ts +284 -0
  59. package/src/hooks/use-chat.ts +2 -0
  60. package/src/hooks/use-coagent.ts +36 -0
  61. package/src/setupTests.ts +26 -0
  62. package/tsconfig.json +2 -2
  63. package/dist/chunk-MTAJI7HV.mjs.map +0 -1
  64. /package/dist/{chunk-3SLA7Q2N.mjs.map → chunk-CUAFWKTQ.mjs.map} +0 -0
  65. /package/dist/{chunk-K42OD3J6.mjs.map → chunk-GEE5AMYL.mjs.map} +0 -0
  66. /package/dist/{chunk-KWQPQ4MM.mjs.map → chunk-GIMSRCVW.mjs.map} +0 -0
  67. /package/dist/{chunk-UGJGKBFB.mjs.map → chunk-NGQN3JRJ.mjs.map} +0 -0
  68. /package/dist/{chunk-SJJNFYGQ.mjs.map → chunk-SGF6C7I6.mjs.map} +0 -0
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  useLangGraphInterrupt
3
- } from "../chunk-UGJGKBFB.mjs";
4
- import "../chunk-K42OD3J6.mjs";
5
- import "../chunk-KWQPQ4MM.mjs";
6
- import "../chunk-SJJNFYGQ.mjs";
7
- import "../chunk-R2LNRHJP.mjs";
3
+ } from "../chunk-NGQN3JRJ.mjs";
4
+ import "../chunk-GEE5AMYL.mjs";
5
+ import "../chunk-6ZLSC4KB.mjs";
6
+ import "../chunk-4CEQJ2X6.mjs";
7
+ import "../chunk-GIMSRCVW.mjs";
8
+ import "../chunk-SGF6C7I6.mjs";
9
+ import "../chunk-BSAVFYRQ.mjs";
10
+ import "../chunk-PMAFHQ7P.mjs";
8
11
  import "../chunk-5FHSUKQL.mjs";
9
12
  import "../chunk-RKTVJRK7.mjs";
10
- import "../chunk-PMAFHQ7P.mjs";
11
- import "../chunk-57K2ZJ5F.mjs";
12
- import "../chunk-YPSGKPDA.mjs";
13
- import "../chunk-DCTJZ742.mjs";
14
- import "../chunk-MTAJI7HV.mjs";
15
- import "../chunk-4CEQJ2X6.mjs";
16
- import "../chunk-3OQM3NEK.mjs";
17
- import "../chunk-O7ARI5CV.mjs";
18
13
  import "../chunk-JWAXDYOW.mjs";
19
14
  import "../chunk-GFJW4RIM.mjs";
15
+ import "../chunk-3OQM3NEK.mjs";
16
+ import "../chunk-O7ARI5CV.mjs";
20
17
  import "../chunk-YAF2LATQ.mjs";
18
+ import "../chunk-57K2ZJ5F.mjs";
19
+ import "../chunk-YPSGKPDA.mjs";
21
20
  import "../chunk-DKZTPL66.mjs";
21
+ import "../chunk-DCTJZ742.mjs";
22
22
  import "../chunk-SKC7AJIV.mjs";
23
23
  export {
24
24
  useLangGraphInterrupt
package/dist/index.js CHANGED
@@ -873,7 +873,7 @@ function CopilotMessages({ children }) {
873
873
  }
874
874
  });
875
875
  void fetchMessages();
876
- }, [threadId, agentSession == null ? void 0 : agentSession.agentName, runtimeClient]);
876
+ }, [threadId, agentSession == null ? void 0 : agentSession.agentName]);
877
877
  const memoizedChildren = (0, import_react6.useMemo)(() => children, [children]);
878
878
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
879
879
  CopilotMessagesContext.Provider,
@@ -2444,17 +2444,22 @@ function useChat(options) {
2444
2444
  lastAgentStateMessage.state.messages
2445
2445
  );
2446
2446
  }
2447
- setCoagentStatesWithRef((prevAgentStates) => __spreadProps(__spreadValues({}, prevAgentStates), {
2448
- [lastAgentStateMessage.agentName]: {
2449
- name: lastAgentStateMessage.agentName,
2450
- state: lastAgentStateMessage.state,
2451
- running: lastAgentStateMessage.running,
2452
- active: lastAgentStateMessage.active,
2453
- threadId: lastAgentStateMessage.threadId,
2454
- nodeName: lastAgentStateMessage.nodeName,
2455
- runId: lastAgentStateMessage.runId
2456
- }
2457
- }));
2447
+ setCoagentStatesWithRef((prevAgentStates) => {
2448
+ var _a2;
2449
+ return __spreadProps(__spreadValues({}, prevAgentStates), {
2450
+ [lastAgentStateMessage.agentName]: {
2451
+ name: lastAgentStateMessage.agentName,
2452
+ state: lastAgentStateMessage.state,
2453
+ running: lastAgentStateMessage.running,
2454
+ active: lastAgentStateMessage.active,
2455
+ threadId: lastAgentStateMessage.threadId,
2456
+ nodeName: lastAgentStateMessage.nodeName,
2457
+ runId: lastAgentStateMessage.runId,
2458
+ // Preserve existing config from previous state
2459
+ config: (_a2 = prevAgentStates[lastAgentStateMessage.agentName]) == null ? void 0 : _a2.config
2460
+ }
2461
+ });
2462
+ });
2458
2463
  if (lastAgentStateMessage.running) {
2459
2464
  setAgentSession({
2460
2465
  threadId: lastAgentStateMessage.threadId,
@@ -3354,6 +3359,32 @@ function useCoAgent(options) {
3354
3359
  // reset initialstate on reset
3355
3360
  coagentStates[name] === void 0
3356
3361
  ]);
3362
+ (0, import_react17.useEffect)(() => {
3363
+ const newConfig = options.config ? options.config : options.configurable ? { configurable: options.configurable } : void 0;
3364
+ if (newConfig === void 0)
3365
+ return;
3366
+ setCoagentStatesWithRef((prev) => {
3367
+ var _a;
3368
+ const existing = (_a = prev[name]) != null ? _a : {
3369
+ name,
3370
+ state: isInternalStateManagementWithInitial(options) ? options.initialState : {},
3371
+ config: {},
3372
+ running: false,
3373
+ active: false,
3374
+ threadId: void 0,
3375
+ nodeName: void 0,
3376
+ runId: void 0
3377
+ };
3378
+ if (JSON.stringify(existing.config) === JSON.stringify(newConfig)) {
3379
+ return prev;
3380
+ }
3381
+ return __spreadProps(__spreadValues({}, prev), {
3382
+ [name]: __spreadProps(__spreadValues({}, existing), {
3383
+ config: newConfig
3384
+ })
3385
+ });
3386
+ });
3387
+ }, [JSON.stringify(options.config), JSON.stringify(options.configurable)]);
3357
3388
  const runAgentCallback = useAsyncCallback(
3358
3389
  (hint) => __async(this, null, function* () {
3359
3390
  yield runAgent(name, context, appendMessage, runChatCompletion, hint);