@copilotkit/react-core 1.75.2 → 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-D9iy3p2l.mjs → copilotkit-LD7Gp2aV.mjs} +72 -35
  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-Beiw32bn.cjs → copilotkit-dHdNF7H5.cjs} +68 -32
  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 +21 -29
  18. package/dist/index.umd.js.map +1 -1
  19. package/dist/v2/headless.cjs +17 -24
  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 +18 -25
  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 +370 -155
  31. package/dist/v2/index.umd.js.map +1 -1
  32. package/package.json +10 -10
  33. package/dist/copilotkit-Beiw32bn.cjs.map +0 -1
  34. package/dist/copilotkit-CGlSOKHM.d.mts.map +0 -1
  35. package/dist/copilotkit-Cjj9wDI8.d.cts.map +0 -1
  36. package/dist/copilotkit-D9iy3p2l.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,7 +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 legacyRunIdRef = (0, react.useRef)(void 0);
894
894
  (0, react.useEffect)(() => {
895
895
  const interruptState = interruptStateRef.current;
896
896
  let localLegacy = null;
@@ -908,16 +908,14 @@ function useInterrupt(config) {
908
908
  onRunStartedEvent: () => {
909
909
  localLegacy = null;
910
910
  localStandard = null;
911
- legacyRunIdRef.current = void 0;
912
911
  interruptState.clear();
913
912
  setPending(null);
914
913
  },
915
- onRunFinalized: (params) => {
914
+ onRunFinalized: () => {
916
915
  if (localStandard && localStandard.length > 0) {
917
916
  interruptState.setStandard(localStandard);
918
917
  setPending(interruptState.pending);
919
918
  } else if (localLegacy) {
920
- legacyRunIdRef.current = params.input.runId;
921
919
  interruptState.setLegacy(localLegacy);
922
920
  setPending(interruptState.pending);
923
921
  }
@@ -927,7 +925,6 @@ function useInterrupt(config) {
927
925
  onRunFailed: () => {
928
926
  localLegacy = null;
929
927
  localStandard = null;
930
- legacyRunIdRef.current = void 0;
931
928
  interruptState.clear();
932
929
  setPending(null);
933
930
  }
@@ -942,22 +939,18 @@ function useInterrupt(config) {
942
939
  if (!current) return;
943
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.`);
944
941
  const decision = interruptStateRef.current.resolve(payload, interruptId);
945
- if (decision.kind === "legacy-resume") {
946
- const runId = legacyRunIdRef.current;
947
- try {
948
- return await copilotkit.runAgent({
949
- agent,
950
- ...runId !== void 0 ? { runId } : {},
951
- forwardedProps: { command: {
952
- resume: decision.payload,
953
- interruptEvent: decision.interruptValue
954
- } }
955
- });
956
- } catch (err) {
957
- console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
958
- setPending(null);
959
- throw err;
960
- }
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;
961
954
  }
962
955
  if (decision.kind === "expired") {
963
956
  console.error(`[CopilotKit] useInterrupt: interrupt ${decision.interrupt.id} expired at ${decision.interrupt.expiresAt}; not resuming.`);
@@ -1656,7 +1649,7 @@ const ToolCallRenderer = react.default.memo(function ToolCallRenderer({ toolCall
1656
1649
  toolCallId: toolCall.id,
1657
1650
  args,
1658
1651
  status: _copilotkit_core.ToolCallStatus.Complete,
1659
- result: toolMessage.content
1652
+ result: (0, _ag_ui_core.contentToText)(toolMessage.content)
1660
1653
  });
1661
1654
  else if (isExecuting) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderComponent, {
1662
1655
  name: toolName,