@copilotkit/react-core 1.66.2 → 1.66.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.
- package/dist/copilotkit-CBCT7BlL.d.cts.map +1 -1
- package/dist/copilotkit-D0aAnD3i.d.mts.map +1 -1
- package/dist/{copilotkit-DnlgZWST.mjs → copilotkit-nRjRp2_5.mjs} +73 -19
- package/dist/copilotkit-nRjRp2_5.mjs.map +1 -0
- package/dist/{copilotkit-2v7ami2b.cjs → copilotkit-sitn7Oe8.cjs} +73 -19
- package/dist/copilotkit-sitn7Oe8.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +35 -16
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +35 -16
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.mjs +35 -16
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +72 -18
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/dist/copilotkit-2v7ami2b.cjs.map +0 -1
- package/dist/copilotkit-DnlgZWST.mjs.map +0 -1
package/dist/v2/headless.cjs
CHANGED
|
@@ -715,6 +715,8 @@ function useInterrupt(config) {
|
|
|
715
715
|
pendingRef.current = pending;
|
|
716
716
|
const [handlerResult, setHandlerResult] = (0, react.useState)(null);
|
|
717
717
|
const interruptStateRef = (0, react.useRef)(new _copilotkit_core.ɵInterruptState());
|
|
718
|
+
const interruptRunIdsRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
719
|
+
const legacyRunIdRef = (0, react.useRef)(void 0);
|
|
718
720
|
(0, react.useEffect)(() => {
|
|
719
721
|
const interruptState = interruptStateRef.current;
|
|
720
722
|
let localLegacy = null;
|
|
@@ -727,19 +729,26 @@ function useInterrupt(config) {
|
|
|
727
729
|
};
|
|
728
730
|
},
|
|
729
731
|
onRunFinishedEvent: (params) => {
|
|
730
|
-
if (params.outcome === "interrupt")
|
|
732
|
+
if (params.outcome === "interrupt") {
|
|
733
|
+
const runId = params.input.runId;
|
|
734
|
+
for (const interrupt of params.interrupts) interruptRunIdsRef.current.set(interrupt.id, runId);
|
|
735
|
+
localStandard = params.interrupts;
|
|
736
|
+
}
|
|
731
737
|
},
|
|
732
738
|
onRunStartedEvent: () => {
|
|
733
739
|
localLegacy = null;
|
|
734
740
|
localStandard = null;
|
|
741
|
+
interruptRunIdsRef.current.clear();
|
|
742
|
+
legacyRunIdRef.current = void 0;
|
|
735
743
|
interruptState.clear();
|
|
736
744
|
setPending(null);
|
|
737
745
|
},
|
|
738
|
-
onRunFinalized: () => {
|
|
746
|
+
onRunFinalized: (params) => {
|
|
739
747
|
if (localStandard && localStandard.length > 0) {
|
|
740
748
|
interruptState.setStandard(localStandard);
|
|
741
749
|
setPending(interruptState.pending);
|
|
742
750
|
} else if (localLegacy) {
|
|
751
|
+
legacyRunIdRef.current = params.input.runId;
|
|
743
752
|
interruptState.setLegacy(localLegacy);
|
|
744
753
|
setPending(interruptState.pending);
|
|
745
754
|
}
|
|
@@ -749,6 +758,8 @@ function useInterrupt(config) {
|
|
|
749
758
|
onRunFailed: () => {
|
|
750
759
|
localLegacy = null;
|
|
751
760
|
localStandard = null;
|
|
761
|
+
interruptRunIdsRef.current.clear();
|
|
762
|
+
legacyRunIdRef.current = void 0;
|
|
752
763
|
interruptState.clear();
|
|
753
764
|
setPending(null);
|
|
754
765
|
}
|
|
@@ -763,18 +774,22 @@ function useInterrupt(config) {
|
|
|
763
774
|
if (!current) return;
|
|
764
775
|
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.`);
|
|
765
776
|
const decision = interruptStateRef.current.resolve(payload, interruptId);
|
|
766
|
-
if (decision.kind === "legacy-resume")
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
777
|
+
if (decision.kind === "legacy-resume") {
|
|
778
|
+
const runId = legacyRunIdRef.current;
|
|
779
|
+
try {
|
|
780
|
+
return await copilotkit.runAgent({
|
|
781
|
+
agent,
|
|
782
|
+
...runId !== void 0 ? { runId } : {},
|
|
783
|
+
forwardedProps: { command: {
|
|
784
|
+
resume: decision.payload,
|
|
785
|
+
interruptEvent: decision.interruptValue
|
|
786
|
+
} }
|
|
787
|
+
});
|
|
788
|
+
} catch (err) {
|
|
789
|
+
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
790
|
+
setPending(null);
|
|
791
|
+
throw err;
|
|
792
|
+
}
|
|
778
793
|
}
|
|
779
794
|
if (decision.kind === "expired") {
|
|
780
795
|
console.error(`[CopilotKit] useInterrupt: interrupt ${decision.interrupt.id} expired at ${decision.interrupt.expiresAt}; not resuming.`);
|
|
@@ -783,6 +798,7 @@ function useInterrupt(config) {
|
|
|
783
798
|
return;
|
|
784
799
|
}
|
|
785
800
|
if (decision.kind !== "resume") return;
|
|
801
|
+
const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
|
|
786
802
|
for (const toolResult of decision.toolResults) agent.addMessage({
|
|
787
803
|
id: (0, _ag_ui_client.randomUUID)(),
|
|
788
804
|
role: "tool",
|
|
@@ -792,7 +808,8 @@ function useInterrupt(config) {
|
|
|
792
808
|
try {
|
|
793
809
|
return await copilotkit.runAgent({
|
|
794
810
|
agent,
|
|
795
|
-
resume: decision.resume
|
|
811
|
+
resume: decision.resume,
|
|
812
|
+
...runId !== void 0 ? { runId } : {}
|
|
796
813
|
});
|
|
797
814
|
} catch (err) {
|
|
798
815
|
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
@@ -819,6 +836,7 @@ function useInterrupt(config) {
|
|
|
819
836
|
return;
|
|
820
837
|
}
|
|
821
838
|
if (decision.kind !== "resume") return;
|
|
839
|
+
const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
|
|
822
840
|
for (const toolResult of decision.toolResults) agent.addMessage({
|
|
823
841
|
id: (0, _ag_ui_client.randomUUID)(),
|
|
824
842
|
role: "tool",
|
|
@@ -828,7 +846,8 @@ function useInterrupt(config) {
|
|
|
828
846
|
try {
|
|
829
847
|
return await copilotkit.runAgent({
|
|
830
848
|
agent,
|
|
831
|
-
resume: decision.resume
|
|
849
|
+
resume: decision.resume,
|
|
850
|
+
...runId !== void 0 ? { runId } : {}
|
|
832
851
|
});
|
|
833
852
|
} catch (err) {
|
|
834
853
|
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|