@copilotkit/react-core 1.75.1 → 1.76.0

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 (36) hide show
  1. package/dist/{copilotkit-CGlSOKHM.d.mts → copilotkit-B90cY0Zg.d.mts} +18 -17
  2. package/dist/copilotkit-B90cY0Zg.d.mts.map +1 -0
  3. package/dist/{copilotkit-DfsHZUuo.mjs → copilotkit-LD7Gp2aV.mjs} +75 -49
  4. package/dist/copilotkit-LD7Gp2aV.mjs.map +1 -0
  5. package/dist/{copilotkit-Cjj9wDI8.d.cts → copilotkit-W-bV_OSs.d.cts} +5 -4
  6. package/dist/copilotkit-W-bV_OSs.d.cts.map +1 -0
  7. package/dist/{copilotkit-DIudpHkM.cjs → copilotkit-dHdNF7H5.cjs} +71 -46
  8. package/dist/copilotkit-dHdNF7H5.cjs.map +1 -0
  9. package/dist/index.cjs +2 -2
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +1 -1
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts +1 -1
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs +4 -4
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/index.umd.js +24 -43
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/v2/headless.cjs +20 -38
  20. package/dist/v2/headless.cjs.map +1 -1
  21. package/dist/v2/headless.d.cts.map +1 -1
  22. package/dist/v2/headless.d.mts +2 -2
  23. package/dist/v2/headless.d.mts.map +1 -1
  24. package/dist/v2/headless.mjs +21 -39
  25. package/dist/v2/headless.mjs.map +1 -1
  26. package/dist/v2/index.cjs +302 -121
  27. package/dist/v2/index.d.cts +2 -2
  28. package/dist/v2/index.d.mts +2 -2
  29. package/dist/v2/index.mjs +2 -2
  30. package/dist/v2/index.umd.js +373 -169
  31. package/dist/v2/index.umd.js.map +1 -1
  32. package/package.json +10 -10
  33. package/dist/copilotkit-CGlSOKHM.d.mts.map +0 -1
  34. package/dist/copilotkit-Cjj9wDI8.d.cts.map +0 -1
  35. package/dist/copilotkit-DIudpHkM.cjs.map +0 -1
  36. package/dist/copilotkit-DfsHZUuo.mjs.map +0 -1
@@ -31,9 +31,10 @@ let react = require("react");
31
31
  react = __toESM(react);
32
32
  let _copilotkit_shared = require("@copilotkit/shared");
33
33
  let react_jsx_runtime = require("react/jsx-runtime");
34
- let _ag_ui_client = require("@ag-ui/client");
35
34
  let _copilotkit_core = require("@copilotkit/core");
35
+ let _ag_ui_client = require("@ag-ui/client");
36
36
  let zod = require("zod");
37
+ let _ag_ui_core = require("@ag-ui/core");
37
38
 
38
39
  //#region src/v2/lib/shallow-stable-ref.ts
39
40
  /**
@@ -522,7 +523,7 @@ function useAgent({ agentId, threadId, runtimeAgentId, updates, throttleMs } = {
522
523
  updateFlags
523
524
  ]);
524
525
  (0, react.useEffect)(() => {
525
- if (agent instanceof _ag_ui_client.HttpAgent) copilotkit.applyHeadersToAgent(agent);
526
+ if ((0, _copilotkit_core.ɵisHttpAgent)(agent)) copilotkit.applyHeadersToAgent(agent);
526
527
  if (agent instanceof _copilotkit_core.ProxiedCopilotRuntimeAgent) agent.credentials = copilotkit.credentials;
527
528
  }, [
528
529
  agent,
@@ -890,8 +891,6 @@ function useInterrupt(config) {
890
891
  pendingRef.current = pending;
891
892
  const [handlerResult, setHandlerResult] = (0, react.useState)(null);
892
893
  const interruptStateRef = (0, react.useRef)(new _copilotkit_core.ɵInterruptState());
893
- const interruptRunIdsRef = (0, react.useRef)(/* @__PURE__ */ new Map());
894
- const legacyRunIdRef = (0, react.useRef)(void 0);
895
894
  (0, react.useEffect)(() => {
896
895
  const interruptState = interruptStateRef.current;
897
896
  let localLegacy = null;
@@ -904,26 +903,19 @@ function useInterrupt(config) {
904
903
  };
905
904
  },
906
905
  onRunFinishedEvent: (params) => {
907
- if (params.outcome === "interrupt") {
908
- const runId = params.input.runId;
909
- for (const interrupt of params.interrupts) interruptRunIdsRef.current.set(interrupt.id, runId);
910
- localStandard = params.interrupts;
911
- }
906
+ if (params.outcome === "interrupt") localStandard = params.interrupts;
912
907
  },
913
908
  onRunStartedEvent: () => {
914
909
  localLegacy = null;
915
910
  localStandard = null;
916
- interruptRunIdsRef.current.clear();
917
- legacyRunIdRef.current = void 0;
918
911
  interruptState.clear();
919
912
  setPending(null);
920
913
  },
921
- onRunFinalized: (params) => {
914
+ onRunFinalized: () => {
922
915
  if (localStandard && localStandard.length > 0) {
923
916
  interruptState.setStandard(localStandard);
924
917
  setPending(interruptState.pending);
925
918
  } else if (localLegacy) {
926
- legacyRunIdRef.current = params.input.runId;
927
919
  interruptState.setLegacy(localLegacy);
928
920
  setPending(interruptState.pending);
929
921
  }
@@ -933,8 +925,6 @@ function useInterrupt(config) {
933
925
  onRunFailed: () => {
934
926
  localLegacy = null;
935
927
  localStandard = null;
936
- interruptRunIdsRef.current.clear();
937
- legacyRunIdRef.current = void 0;
938
928
  interruptState.clear();
939
929
  setPending(null);
940
930
  }
@@ -949,22 +939,18 @@ function useInterrupt(config) {
949
939
  if (!current) return;
950
940
  if (current.kind === "standard" && current.interrupts.length > 1 && interruptId === void 0) console.warn(`[CopilotKit] useInterrupt: resolve()/cancel() called without an interruptId while ${current.interrupts.length} interrupts are open; defaulting to the first. Pass an interruptId to address a specific interrupt.`);
951
941
  const decision = interruptStateRef.current.resolve(payload, interruptId);
952
- if (decision.kind === "legacy-resume") {
953
- const runId = legacyRunIdRef.current;
954
- try {
955
- return await copilotkit.runAgent({
956
- agent,
957
- ...runId !== void 0 ? { runId } : {},
958
- forwardedProps: { command: {
959
- resume: decision.payload,
960
- interruptEvent: decision.interruptValue
961
- } }
962
- });
963
- } catch (err) {
964
- console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
965
- setPending(null);
966
- throw err;
967
- }
942
+ if (decision.kind === "legacy-resume") try {
943
+ return await copilotkit.runAgent({
944
+ agent,
945
+ forwardedProps: { command: {
946
+ resume: decision.payload,
947
+ interruptEvent: decision.interruptValue
948
+ } }
949
+ });
950
+ } catch (err) {
951
+ console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
952
+ setPending(null);
953
+ throw err;
968
954
  }
969
955
  if (decision.kind === "expired") {
970
956
  console.error(`[CopilotKit] useInterrupt: interrupt ${decision.interrupt.id} expired at ${decision.interrupt.expiresAt}; not resuming.`);
@@ -973,7 +959,6 @@ function useInterrupt(config) {
973
959
  return;
974
960
  }
975
961
  if (decision.kind !== "resume") return;
976
- const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
977
962
  for (const toolResult of decision.toolResults) agent.addMessage({
978
963
  id: (0, _ag_ui_client.randomUUID)(),
979
964
  role: "tool",
@@ -983,8 +968,7 @@ function useInterrupt(config) {
983
968
  try {
984
969
  return await copilotkit.runAgent({
985
970
  agent,
986
- resume: decision.resume,
987
- ...runId !== void 0 ? { runId } : {}
971
+ resume: decision.resume
988
972
  });
989
973
  } catch (err) {
990
974
  console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
@@ -1011,7 +995,6 @@ function useInterrupt(config) {
1011
995
  return;
1012
996
  }
1013
997
  if (decision.kind !== "resume") return;
1014
- const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
1015
998
  for (const toolResult of decision.toolResults) agent.addMessage({
1016
999
  id: (0, _ag_ui_client.randomUUID)(),
1017
1000
  role: "tool",
@@ -1021,8 +1004,7 @@ function useInterrupt(config) {
1021
1004
  try {
1022
1005
  return await copilotkit.runAgent({
1023
1006
  agent,
1024
- resume: decision.resume,
1025
- ...runId !== void 0 ? { runId } : {}
1007
+ resume: decision.resume
1026
1008
  });
1027
1009
  } catch (err) {
1028
1010
  console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
@@ -1667,7 +1649,7 @@ const ToolCallRenderer = react.default.memo(function ToolCallRenderer({ toolCall
1667
1649
  toolCallId: toolCall.id,
1668
1650
  args,
1669
1651
  status: _copilotkit_core.ToolCallStatus.Complete,
1670
- result: toolMessage.content
1652
+ result: (0, _ag_ui_core.contentToText)(toolMessage.content)
1671
1653
  });
1672
1654
  else if (isExecuting) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderComponent, {
1673
1655
  name: toolName,