@copilotkit/react-core 1.66.2 → 1.66.4
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/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_copilotkit = require('../copilotkit-
|
|
4
|
+
const require_copilotkit = require('../copilotkit-sitn7Oe8.cjs');
|
|
5
5
|
require("./index.css");
|
|
6
6
|
let _copilotkit_a2ui_renderer = require("@copilotkit/a2ui-renderer");
|
|
7
7
|
|
package/dist/v2/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { $ as useCapabilities, A as CopilotChatMessageView, At as CopilotChatConfigurationProvider, B as CopilotChatAssistantMessage_default, C as CopilotModalHeader, Ct as CopilotKitInspector, D as CopilotChat, Dt as CopilotChatInput_default, E as DefaultOpenIcon, Et as CopilotKitCoreReact, F as CopilotChatSuggestionView, G as useLearnFromUserActionInCurrentThread, H as useLearningContainersInCurrentThread, I as CopilotChatSuggestionPill, J as useThreads, K as useLearnFromUserAction, L as CopilotChatReasoningMessage_default, M as IntelligenceIndicator, N as getIntelligenceTurnAnchors, O as CopilotChatView_default, Ot as AudioRecorderError, P as IntelligenceIndicatorView, Q as useAgentContext, R as CopilotChatUserMessage_default, S as CopilotSidebarView, St as ɵrunMcpFollowUp, T as DefaultCloseIcon, Tt as useCopilotKit, U as useLearningContainers, V as CopilotChatToolCallsView, W as useAttachments, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, _ as WildcardToolCallRender, _t as SandboxFunctionsContext, at as useComponent, b as CopilotSidebar, bt as MCPAppsActivityRenderer, ct as useRenderCustomMessages, dt as createA2UIMessageRenderer, et as UseAgentUpdate, ft as GenerateSandboxedUiArgsSchema, gt as OpenGenerativeUIToolRenderer, ht as OpenGenerativeUIContentSchema, it as useRenderTool, j as INTELLIGENCE_TURN_HEAD, jt as useCopilotChatConfiguration, k as CopilotChatAttachmentQueue, kt as CopilotChatAudioRecorder, lt as CopilotKitProvider, mt as OpenGenerativeUIActivityType, nt as useHumanInTheLoop, ot as useFrontendTool, pt as OpenGenerativeUIActivityRenderer, q as useMemories, rt as useDefaultRenderTool, st as useRenderActivityMessage, t as CopilotKit, tt as useAgent, ut as defineToolCallRenderer, v as CopilotThreadsDrawer, vt as useSandboxFunctions, w as CopilotChatToggleButton, wt as useRenderToolCall, x as CopilotPopupView, xt as MCPAppsActivityType, y as CopilotPopup, yt as MCPAppsActivityContentSchema, z as CopilotChatAttachmentRenderer } from "../copilotkit-
|
|
3
|
+
import { $ as useCapabilities, A as CopilotChatMessageView, At as CopilotChatConfigurationProvider, B as CopilotChatAssistantMessage_default, C as CopilotModalHeader, Ct as CopilotKitInspector, D as CopilotChat, Dt as CopilotChatInput_default, E as DefaultOpenIcon, Et as CopilotKitCoreReact, F as CopilotChatSuggestionView, G as useLearnFromUserActionInCurrentThread, H as useLearningContainersInCurrentThread, I as CopilotChatSuggestionPill, J as useThreads, K as useLearnFromUserAction, L as CopilotChatReasoningMessage_default, M as IntelligenceIndicator, N as getIntelligenceTurnAnchors, O as CopilotChatView_default, Ot as AudioRecorderError, P as IntelligenceIndicatorView, Q as useAgentContext, R as CopilotChatUserMessage_default, S as CopilotSidebarView, St as ɵrunMcpFollowUp, T as DefaultCloseIcon, Tt as useCopilotKit, U as useLearningContainers, V as CopilotChatToolCallsView, W as useAttachments, X as useConfigureSuggestions, Y as useInterrupt, Z as useSuggestions, _ as WildcardToolCallRender, _t as SandboxFunctionsContext, at as useComponent, b as CopilotSidebar, bt as MCPAppsActivityRenderer, ct as useRenderCustomMessages, dt as createA2UIMessageRenderer, et as UseAgentUpdate, ft as GenerateSandboxedUiArgsSchema, gt as OpenGenerativeUIToolRenderer, ht as OpenGenerativeUIContentSchema, it as useRenderTool, j as INTELLIGENCE_TURN_HEAD, jt as useCopilotChatConfiguration, k as CopilotChatAttachmentQueue, kt as CopilotChatAudioRecorder, lt as CopilotKitProvider, mt as OpenGenerativeUIActivityType, nt as useHumanInTheLoop, ot as useFrontendTool, pt as OpenGenerativeUIActivityRenderer, q as useMemories, rt as useDefaultRenderTool, st as useRenderActivityMessage, t as CopilotKit, tt as useAgent, ut as defineToolCallRenderer, v as CopilotThreadsDrawer, vt as useSandboxFunctions, w as CopilotChatToggleButton, wt as useRenderToolCall, x as CopilotPopupView, xt as MCPAppsActivityType, y as CopilotPopup, yt as MCPAppsActivityContentSchema, z as CopilotChatAttachmentRenderer } from "../copilotkit-nRjRp2_5.mjs";
|
|
4
4
|
import "./index.css";
|
|
5
5
|
import { defaultTheme as a2uiDefaultTheme } from "@copilotkit/a2ui-renderer";
|
|
6
6
|
|
package/dist/v2/index.umd.js
CHANGED
|
@@ -4921,6 +4921,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4921
4921
|
pendingRef.current = pending;
|
|
4922
4922
|
const [handlerResult, setHandlerResult] = (0, react.useState)(null);
|
|
4923
4923
|
const interruptStateRef = (0, react.useRef)(new _copilotkit_core.ɵInterruptState());
|
|
4924
|
+
const interruptRunIdsRef = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
4925
|
+
const legacyRunIdRef = (0, react.useRef)(void 0);
|
|
4924
4926
|
(0, react.useEffect)(() => {
|
|
4925
4927
|
const interruptState = interruptStateRef.current;
|
|
4926
4928
|
let localLegacy = null;
|
|
@@ -4933,19 +4935,26 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4933
4935
|
};
|
|
4934
4936
|
},
|
|
4935
4937
|
onRunFinishedEvent: (params) => {
|
|
4936
|
-
if (params.outcome === "interrupt")
|
|
4938
|
+
if (params.outcome === "interrupt") {
|
|
4939
|
+
const runId = params.input.runId;
|
|
4940
|
+
for (const interrupt of params.interrupts) interruptRunIdsRef.current.set(interrupt.id, runId);
|
|
4941
|
+
localStandard = params.interrupts;
|
|
4942
|
+
}
|
|
4937
4943
|
},
|
|
4938
4944
|
onRunStartedEvent: () => {
|
|
4939
4945
|
localLegacy = null;
|
|
4940
4946
|
localStandard = null;
|
|
4947
|
+
interruptRunIdsRef.current.clear();
|
|
4948
|
+
legacyRunIdRef.current = void 0;
|
|
4941
4949
|
interruptState.clear();
|
|
4942
4950
|
setPending(null);
|
|
4943
4951
|
},
|
|
4944
|
-
onRunFinalized: () => {
|
|
4952
|
+
onRunFinalized: (params) => {
|
|
4945
4953
|
if (localStandard && localStandard.length > 0) {
|
|
4946
4954
|
interruptState.setStandard(localStandard);
|
|
4947
4955
|
setPending(interruptState.pending);
|
|
4948
4956
|
} else if (localLegacy) {
|
|
4957
|
+
legacyRunIdRef.current = params.input.runId;
|
|
4949
4958
|
interruptState.setLegacy(localLegacy);
|
|
4950
4959
|
setPending(interruptState.pending);
|
|
4951
4960
|
}
|
|
@@ -4955,6 +4964,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4955
4964
|
onRunFailed: () => {
|
|
4956
4965
|
localLegacy = null;
|
|
4957
4966
|
localStandard = null;
|
|
4967
|
+
interruptRunIdsRef.current.clear();
|
|
4968
|
+
legacyRunIdRef.current = void 0;
|
|
4958
4969
|
interruptState.clear();
|
|
4959
4970
|
setPending(null);
|
|
4960
4971
|
}
|
|
@@ -4969,18 +4980,22 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4969
4980
|
if (!current) return;
|
|
4970
4981
|
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.`);
|
|
4971
4982
|
const decision = interruptStateRef.current.resolve(payload, interruptId);
|
|
4972
|
-
if (decision.kind === "legacy-resume")
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4983
|
+
if (decision.kind === "legacy-resume") {
|
|
4984
|
+
const runId = legacyRunIdRef.current;
|
|
4985
|
+
try {
|
|
4986
|
+
return await copilotkit.runAgent({
|
|
4987
|
+
agent,
|
|
4988
|
+
...runId !== void 0 ? { runId } : {},
|
|
4989
|
+
forwardedProps: { command: {
|
|
4990
|
+
resume: decision.payload,
|
|
4991
|
+
interruptEvent: decision.interruptValue
|
|
4992
|
+
} }
|
|
4993
|
+
});
|
|
4994
|
+
} catch (err) {
|
|
4995
|
+
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
4996
|
+
setPending(null);
|
|
4997
|
+
throw err;
|
|
4998
|
+
}
|
|
4984
4999
|
}
|
|
4985
5000
|
if (decision.kind === "expired") {
|
|
4986
5001
|
console.error(`[CopilotKit] useInterrupt: interrupt ${decision.interrupt.id} expired at ${decision.interrupt.expiresAt}; not resuming.`);
|
|
@@ -4989,6 +5004,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4989
5004
|
return;
|
|
4990
5005
|
}
|
|
4991
5006
|
if (decision.kind !== "resume") return;
|
|
5007
|
+
const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
|
|
4992
5008
|
for (const toolResult of decision.toolResults) agent.addMessage({
|
|
4993
5009
|
id: (0, _ag_ui_client.randomUUID)(),
|
|
4994
5010
|
role: "tool",
|
|
@@ -4998,7 +5014,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
4998
5014
|
try {
|
|
4999
5015
|
return await copilotkit.runAgent({
|
|
5000
5016
|
agent,
|
|
5001
|
-
resume: decision.resume
|
|
5017
|
+
resume: decision.resume,
|
|
5018
|
+
...runId !== void 0 ? { runId } : {}
|
|
5002
5019
|
});
|
|
5003
5020
|
} catch (err) {
|
|
5004
5021
|
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
@@ -5025,6 +5042,7 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5025
5042
|
return;
|
|
5026
5043
|
}
|
|
5027
5044
|
if (decision.kind !== "resume") return;
|
|
5045
|
+
const runId = decision.resume.map((entry) => interruptRunIdsRef.current.get(entry.interruptId)).find((candidate) => candidate !== void 0);
|
|
5028
5046
|
for (const toolResult of decision.toolResults) agent.addMessage({
|
|
5029
5047
|
id: (0, _ag_ui_client.randomUUID)(),
|
|
5030
5048
|
role: "tool",
|
|
@@ -5034,7 +5052,8 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
5034
5052
|
try {
|
|
5035
5053
|
return await copilotkit.runAgent({
|
|
5036
5054
|
agent,
|
|
5037
|
-
resume: decision.resume
|
|
5055
|
+
resume: decision.resume,
|
|
5056
|
+
...runId !== void 0 ? { runId } : {}
|
|
5038
5057
|
});
|
|
5039
5058
|
} catch (err) {
|
|
5040
5059
|
console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing", err);
|
|
@@ -7049,6 +7068,37 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
7049
7068
|
*
|
|
7050
7069
|
* @internal Exported for unit testing only — not part of the public API.
|
|
7051
7070
|
*/
|
|
7071
|
+
/**
|
|
7072
|
+
* Collapse tool calls that share an id, keeping first-seen order.
|
|
7073
|
+
*
|
|
7074
|
+
* AG-UI's TOOL_CALL_START handler appends to the parent message's `toolCalls`
|
|
7075
|
+
* without checking whether that id is already present. So whenever a start
|
|
7076
|
+
* event is applied twice — which the human-in-the-loop flow triggers when the
|
|
7077
|
+
* run syncs after `respond()` — the message ends up carrying the same call
|
|
7078
|
+
* twice. The second copy has EMPTY `arguments`, because a start event carries
|
|
7079
|
+
* none; the args arrive later as TOOL_CALL_ARGS deltas addressed to the first
|
|
7080
|
+
* copy.
|
|
7081
|
+
*
|
|
7082
|
+
* Left alone that renders the same tool call twice: once populated and once
|
|
7083
|
+
* blank (an approval card with no transaction id, offering live buttons for an
|
|
7084
|
+
* action already taken), and React warns "Encountered two children with the
|
|
7085
|
+
* same key" because the call id is the render key.
|
|
7086
|
+
*
|
|
7087
|
+
* The empty copy is the redundant one, so prefer whichever entry actually
|
|
7088
|
+
* carries arguments rather than blindly taking the first.
|
|
7089
|
+
*/
|
|
7090
|
+
function dedupeToolCalls(toolCalls) {
|
|
7091
|
+
const byId = /* @__PURE__ */ new Map();
|
|
7092
|
+
for (const toolCall of toolCalls) {
|
|
7093
|
+
const existing = byId.get(toolCall.id);
|
|
7094
|
+
if (!existing) {
|
|
7095
|
+
byId.set(toolCall.id, toolCall);
|
|
7096
|
+
continue;
|
|
7097
|
+
}
|
|
7098
|
+
if (!existing.function?.arguments && toolCall.function?.arguments) byId.set(toolCall.id, toolCall);
|
|
7099
|
+
}
|
|
7100
|
+
return byId.size === toolCalls.length ? toolCalls : [...byId.values()];
|
|
7101
|
+
}
|
|
7052
7102
|
function deduplicateMessages(messages) {
|
|
7053
7103
|
const acc = /* @__PURE__ */ new Map();
|
|
7054
7104
|
for (const message of messages) {
|
|
@@ -7060,9 +7110,13 @@ window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/sandbox-proxy-
|
|
|
7060
7110
|
...existing,
|
|
7061
7111
|
...message,
|
|
7062
7112
|
content,
|
|
7063
|
-
toolCalls
|
|
7113
|
+
toolCalls: toolCalls ? dedupeToolCalls(toolCalls) : toolCalls
|
|
7064
7114
|
});
|
|
7065
|
-
} else acc.set(message.id,
|
|
7115
|
+
} else if (message.role === "assistant" && message.toolCalls) acc.set(message.id, {
|
|
7116
|
+
...message,
|
|
7117
|
+
toolCalls: dedupeToolCalls(message.toolCalls)
|
|
7118
|
+
});
|
|
7119
|
+
else acc.set(message.id, message);
|
|
7066
7120
|
}
|
|
7067
7121
|
return [...acc.values()];
|
|
7068
7122
|
}
|