@copilotkit/react-core 1.76.0 → 1.77.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.
- package/dist/{copilotkit-dHdNF7H5.cjs → copilotkit-CFPkj9B9.cjs} +89 -24
- package/dist/copilotkit-CFPkj9B9.cjs.map +1 -0
- package/dist/{copilotkit-LD7Gp2aV.mjs → copilotkit-CP9qPAqV.mjs} +89 -24
- package/dist/copilotkit-CP9qPAqV.mjs.map +1 -0
- package/dist/{copilotkit-B90cY0Zg.d.mts → copilotkit-Cqa0TfEo.d.mts} +28 -3
- package/dist/copilotkit-Cqa0TfEo.d.mts.map +1 -0
- package/dist/{copilotkit-W-bV_OSs.d.cts → copilotkit-DGc2YiW9.d.cts} +33 -3
- package/dist/copilotkit-DGc2YiW9.d.cts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +70 -16
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/context.cjs.map +1 -1
- package/dist/v2/context.d.cts +5 -0
- package/dist/v2/context.d.cts.map +1 -1
- package/dist/v2/context.d.mts +5 -0
- package/dist/v2/context.d.mts.map +1 -1
- package/dist/v2/context.mjs.map +1 -1
- package/dist/v2/headless.cjs +19 -0
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts +5 -0
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +20 -1
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +88 -23
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +8 -8
- package/dist/copilotkit-B90cY0Zg.d.mts.map +0 -1
- package/dist/copilotkit-LD7Gp2aV.mjs.map +0 -1
- package/dist/copilotkit-W-bV_OSs.d.cts.map +0 -1
- package/dist/copilotkit-dHdNF7H5.cjs.map +0 -1
|
@@ -171,6 +171,25 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
|
|
|
171
171
|
parentConfig?.threadId,
|
|
172
172
|
activeThreadOverride
|
|
173
173
|
]);
|
|
174
|
+
const copilotkit = (0, react.useContext)(_copilotkit_react_core_v2_context.CopilotKitContext)?.copilotkit;
|
|
175
|
+
const openThreadRef = (0, react.useRef)(null);
|
|
176
|
+
const latestThreadIdRef = (0, react.useRef)(resolvedThreadId);
|
|
177
|
+
latestThreadIdRef.current = resolvedThreadId;
|
|
178
|
+
(0, react.useEffect)(() => {
|
|
179
|
+
if (copilotkit === void 0) return;
|
|
180
|
+
const registration = copilotkit.registerOpenThread({
|
|
181
|
+
agentId: resolvedAgentId,
|
|
182
|
+
threadId: latestThreadIdRef.current
|
|
183
|
+
});
|
|
184
|
+
openThreadRef.current = registration;
|
|
185
|
+
return () => {
|
|
186
|
+
registration.unregister();
|
|
187
|
+
openThreadRef.current = null;
|
|
188
|
+
};
|
|
189
|
+
}, [copilotkit, resolvedAgentId]);
|
|
190
|
+
(0, react.useEffect)(() => {
|
|
191
|
+
openThreadRef.current?.update(resolvedThreadId);
|
|
192
|
+
}, [resolvedThreadId]);
|
|
174
193
|
const resolvedHasExplicitThreadId = (threadIdPropIsAuthoritative ? true : activeThreadOverride?.explicit ?? hasExplicitThreadId ?? false) || !!parentConfig?.hasExplicitThreadId;
|
|
175
194
|
const [internalModalOpen, setInternalModalOpen] = (0, react.useState)(isModalDefaultOpen ?? true);
|
|
176
195
|
const hasExplicitDefault = isModalDefaultOpen !== void 0;
|
|
@@ -1636,7 +1655,7 @@ function useRenderToolCall() {
|
|
|
1636
1655
|
|
|
1637
1656
|
//#endregion
|
|
1638
1657
|
//#region package.json
|
|
1639
|
-
var version = "1.
|
|
1658
|
+
var version = "1.77.0";
|
|
1640
1659
|
|
|
1641
1660
|
//#endregion
|
|
1642
1661
|
//#region src/v2/components/CopilotKitInspector.tsx
|
|
@@ -1872,12 +1891,14 @@ function InlineFeatureWarning({ featureName }) {
|
|
|
1872
1891
|
* Fetches resource content on-demand via proxied MCP requests. The React shell
|
|
1873
1892
|
* owns the iframe; `bindMcpApp` owns the protocol.
|
|
1874
1893
|
*/
|
|
1875
|
-
const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agent }) {
|
|
1894
|
+
const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, message, agent }) {
|
|
1876
1895
|
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
1896
|
+
const messageId = message?.id;
|
|
1877
1897
|
const containerRef = (0, react.useRef)(null);
|
|
1878
1898
|
const iframeRef = (0, react.useRef)(null);
|
|
1879
1899
|
const sessionRef = (0, react.useRef)(null);
|
|
1880
1900
|
const [error, setError] = (0, react.useState)(null);
|
|
1901
|
+
const [contentError, setContentError] = (0, react.useState)(null);
|
|
1881
1902
|
const [isLoading, setIsLoading] = (0, react.useState)(true);
|
|
1882
1903
|
const [iframeSize, setIframeSize] = (0, react.useState)({});
|
|
1883
1904
|
const [fetchedResource, setFetchedResource] = (0, react.useState)(null);
|
|
@@ -1896,6 +1917,7 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
1896
1917
|
let mounted = true;
|
|
1897
1918
|
setIsLoading(true);
|
|
1898
1919
|
setError(null);
|
|
1920
|
+
setContentError(null);
|
|
1899
1921
|
const iframe = document.createElement("iframe");
|
|
1900
1922
|
iframe.style.width = "100%";
|
|
1901
1923
|
iframe.style.height = "100px";
|
|
@@ -1918,6 +1940,7 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
1918
1940
|
getContent: () => contentRef.current,
|
|
1919
1941
|
getAgent: () => agentRef.current,
|
|
1920
1942
|
host: copilotkit,
|
|
1943
|
+
messageId,
|
|
1921
1944
|
hooks: {
|
|
1922
1945
|
onResource: (resource) => {
|
|
1923
1946
|
if (!mounted) return;
|
|
@@ -1927,6 +1950,9 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
1927
1950
|
onSizeChanged: (size) => {
|
|
1928
1951
|
if (mounted) setIframeSize(size);
|
|
1929
1952
|
},
|
|
1953
|
+
onContentError: (err) => {
|
|
1954
|
+
if (mounted) setContentError(err);
|
|
1955
|
+
},
|
|
1930
1956
|
onError: (err) => {
|
|
1931
1957
|
if (!mounted) return;
|
|
1932
1958
|
setError(err);
|
|
@@ -1935,9 +1961,7 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
1935
1961
|
}
|
|
1936
1962
|
});
|
|
1937
1963
|
sessionRef.current = session;
|
|
1938
|
-
|
|
1939
|
-
if (current.toolInput) session.sendToolInput(current.toolInput);
|
|
1940
|
-
if (current.result) session.sendToolResult(current.result);
|
|
1964
|
+
session.syncContent(contentRef.current);
|
|
1941
1965
|
} catch (err) {
|
|
1942
1966
|
console.error("[MCPAppsRenderer] Setup error:", err);
|
|
1943
1967
|
if (mounted) {
|
|
@@ -1957,6 +1981,7 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
1957
1981
|
}, [
|
|
1958
1982
|
agent,
|
|
1959
1983
|
copilotkit,
|
|
1984
|
+
messageId,
|
|
1960
1985
|
content.resourceUri,
|
|
1961
1986
|
content.serverHash,
|
|
1962
1987
|
content.serverId
|
|
@@ -1971,11 +1996,8 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
1971
1996
|
}
|
|
1972
1997
|
}, [iframeSize]);
|
|
1973
1998
|
(0, react.useEffect)(() => {
|
|
1974
|
-
|
|
1975
|
-
}, [content.toolInput]);
|
|
1976
|
-
(0, react.useEffect)(() => {
|
|
1977
|
-
if (content.result) sessionRef.current?.sendToolResult(content.result);
|
|
1978
|
-
}, [content.result]);
|
|
1999
|
+
sessionRef.current?.syncContent(contentRef.current);
|
|
2000
|
+
}, [content.toolInput, content.result]);
|
|
1979
2001
|
const borderStyle = fetchedResource?._meta?.ui?.prefersBorder === true ? {
|
|
1980
2002
|
borderRadius: "8px",
|
|
1981
2003
|
backgroundColor: "#f9f9f9",
|
|
@@ -1997,12 +2019,12 @@ const MCPAppsActivityRenderer = function MCPAppsActivityRenderer({ content, agen
|
|
|
1997
2019
|
color: "#666"
|
|
1998
2020
|
},
|
|
1999
2021
|
children: "Loading..."
|
|
2000
|
-
}), error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2022
|
+
}), (error ?? contentError) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2001
2023
|
style: {
|
|
2002
2024
|
color: "red",
|
|
2003
2025
|
padding: "1rem"
|
|
2004
2026
|
},
|
|
2005
|
-
children: ["Error: ", error.message]
|
|
2027
|
+
children: ["Error: ", (error ?? contentError).message]
|
|
2006
2028
|
})]
|
|
2007
2029
|
});
|
|
2008
2030
|
};
|
|
@@ -3400,7 +3422,7 @@ function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
|
|
|
3400
3422
|
}, [value, warningMessage]);
|
|
3401
3423
|
return value;
|
|
3402
3424
|
}
|
|
3403
|
-
const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, messageFilter, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug }) => {
|
|
3425
|
+
const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY_HEADERS, credentials, messageFilter, publicApiKey, publicLicenseKey, licenseToken, properties = EMPTY_PROPERTIES, agents__unsafe_dev_only: agents = EMPTY_AGENTS, selfManagedAgents = EMPTY_AGENTS, renderToolCalls, renderActivityMessages, renderCustomMessages, frontendTools, humanInTheLoop, openGenerativeUI, enableInspector, agentId, showIntelligenceIndicator = true, useSingleEndpoint, onError, a2ui, defaultThrottleMs, debug, learning }) => {
|
|
3404
3426
|
const [shouldRenderInspector, setShouldRenderInspector] = (0, react.useState)(false);
|
|
3405
3427
|
const [inspectorVisible, setInspectorVisible] = (0, react.useState)(false);
|
|
3406
3428
|
(0, react.useEffect)(() => {
|
|
@@ -3635,7 +3657,8 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3635
3657
|
renderToolCalls: allRenderToolCalls,
|
|
3636
3658
|
renderActivityMessages: allActivityRenderers,
|
|
3637
3659
|
renderCustomMessages: renderCustomMessagesList,
|
|
3638
|
-
debug
|
|
3660
|
+
debug,
|
|
3661
|
+
learning
|
|
3639
3662
|
});
|
|
3640
3663
|
if (defaultThrottleMs !== void 0) copilotkitRef.current.setDefaultThrottleMs(defaultThrottleMs);
|
|
3641
3664
|
}
|
|
@@ -3740,6 +3763,32 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3740
3763
|
useSingleEndpoint,
|
|
3741
3764
|
debug
|
|
3742
3765
|
]);
|
|
3766
|
+
const learningEnabled = learning !== void 0;
|
|
3767
|
+
const trajectoryId = learning?.trajectoryId;
|
|
3768
|
+
const learningContainerIdsRef = (0, react.useRef)(learning?.learningContainerIds);
|
|
3769
|
+
(0, react.useEffect)(() => {
|
|
3770
|
+
copilotkit.setLearningConfig(learning);
|
|
3771
|
+
learningContainerIdsRef.current = learning?.learningContainerIds;
|
|
3772
|
+
if (learning?.sink === void 0 && learning?.trajectoryId === void 0 && learning?.learningContainerIds !== void 0) console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture does not assign Learning Containers; remove learningContainerIds from the capture options.");
|
|
3773
|
+
}, [copilotkit, learning]);
|
|
3774
|
+
(0, react.useEffect)(() => {
|
|
3775
|
+
if (!learningEnabled) return;
|
|
3776
|
+
let disposed = false;
|
|
3777
|
+
if (trajectoryId !== void 0) copilotkit.startTrajectory({
|
|
3778
|
+
trajectoryId,
|
|
3779
|
+
learningContainerIds: learningContainerIdsRef.current
|
|
3780
|
+
}).catch(() => {
|
|
3781
|
+
if (!disposed) console.warn("[CopilotKit] Failed to start interaction capture.");
|
|
3782
|
+
});
|
|
3783
|
+
return () => {
|
|
3784
|
+
disposed = true;
|
|
3785
|
+
copilotkit.stopTrajectory();
|
|
3786
|
+
};
|
|
3787
|
+
}, [
|
|
3788
|
+
copilotkit,
|
|
3789
|
+
learningEnabled,
|
|
3790
|
+
trajectoryId
|
|
3791
|
+
]);
|
|
3743
3792
|
const didMountRef = (0, react.useRef)(false);
|
|
3744
3793
|
(0, react.useEffect)(() => {
|
|
3745
3794
|
if (!didMountRef.current) return;
|
|
@@ -3802,8 +3851,13 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp = EMPTY
|
|
|
3802
3851
|
]);
|
|
3803
3852
|
const contextValue = (0, react.useMemo)(() => ({
|
|
3804
3853
|
copilotkit,
|
|
3805
|
-
executingToolCallIds
|
|
3806
|
-
|
|
3854
|
+
executingToolCallIds,
|
|
3855
|
+
showIntelligenceIndicator
|
|
3856
|
+
}), [
|
|
3857
|
+
copilotkit,
|
|
3858
|
+
executingToolCallIds,
|
|
3859
|
+
showIntelligenceIndicator
|
|
3860
|
+
]);
|
|
3807
3861
|
const retryableRuntimeEntitlementFailure = runtimeEntitlements?.status !== "ready" && runtimeEntitlements?.error.retryable === true;
|
|
3808
3862
|
const hasNonReadyRuntimeEntitlement = runtimeEntitlements !== void 0 && runtimeEntitlements.status !== "ready";
|
|
3809
3863
|
const hasLegacyRuntimeEntitlementFallback = runtimeLicenseStatus === "valid" || runtimeLicenseStatus === "expiring";
|
|
@@ -6037,13 +6091,23 @@ function useLearningContainersInCurrentThread({ learningContainers }) {
|
|
|
6037
6091
|
//#region src/v2/components/chat/CopilotChatToolCallsView.tsx
|
|
6038
6092
|
function CopilotChatToolCallsView({ message, messages = [] }) {
|
|
6039
6093
|
const renderToolCall = useRenderToolCall();
|
|
6094
|
+
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
6095
|
+
const subscribe = (0, react.useCallback)((onChange) => copilotkit.ɵsubscribeToLearningConfigured(onChange), [copilotkit]);
|
|
6096
|
+
const getSnapshot = () => copilotkit.ɵlearningConfigured;
|
|
6097
|
+
const learningConfigured = (0, react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
6040
6098
|
if (!message.toolCalls || message.toolCalls.length === 0) return null;
|
|
6041
6099
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: message.toolCalls.map((toolCall) => {
|
|
6042
|
-
const
|
|
6043
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: renderToolCall({
|
|
6100
|
+
const rendered = renderToolCall({
|
|
6044
6101
|
toolCall,
|
|
6045
|
-
toolMessage
|
|
6046
|
-
})
|
|
6102
|
+
toolMessage: messages.find((m) => m.role === "tool" && m.toolCallId === toolCall.id)
|
|
6103
|
+
});
|
|
6104
|
+
if (rendered === null) return null;
|
|
6105
|
+
if (!learningConfigured) return rendered;
|
|
6106
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6107
|
+
"data-tool-call-id": toolCall.id,
|
|
6108
|
+
style: { display: "contents" },
|
|
6109
|
+
children: rendered
|
|
6110
|
+
}, toolCall.id);
|
|
6047
6111
|
}) });
|
|
6048
6112
|
}
|
|
6049
6113
|
|
|
@@ -6387,6 +6451,7 @@ function CopilotChatAssistantMessage({ message, messages, isRunning, isLatest, o
|
|
|
6387
6451
|
const shouldShowToolbar = toolbarVisible && (hasContent || showInspectorShortcut) && !(isRunning && isLatestAssistantMessage);
|
|
6388
6452
|
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
6389
6453
|
"data-copilotkit": true,
|
|
6454
|
+
"data-message-id": message.id,
|
|
6390
6455
|
style: { display: "contents" },
|
|
6391
6456
|
children: children({
|
|
6392
6457
|
markdownRenderer: boundMarkdownRenderer,
|
|
@@ -7624,7 +7689,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7624
7689
|
const isPinnedToBottom = (0, react.useContext)(ScrollPinnedContext);
|
|
7625
7690
|
const renderCustomMessage = useRenderCustomMessages();
|
|
7626
7691
|
const { renderActivityMessage } = useRenderActivityMessage();
|
|
7627
|
-
const { copilotkit } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
7692
|
+
const { copilotkit, showIntelligenceIndicator = true } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
7628
7693
|
const config = useCopilotChatConfiguration();
|
|
7629
7694
|
const [, forceUpdate] = (0, react.useReducer)((x) => x + 1, 0);
|
|
7630
7695
|
(0, react.useEffect)(() => {
|
|
@@ -7811,7 +7876,7 @@ function CopilotChatMessageView({ messages = [], assistantMessage, userMessage,
|
|
|
7811
7876
|
renderCustomMessage,
|
|
7812
7877
|
stateSnapshot
|
|
7813
7878
|
}, `${rowKey}-custom-after`));
|
|
7814
|
-
const intelligenceTurnId = intelligenceTurnAnchors.get(message.id);
|
|
7879
|
+
const intelligenceTurnId = showIntelligenceIndicator ? intelligenceTurnAnchors.get(message.id) : void 0;
|
|
7815
7880
|
if (intelligenceTurnId !== void 0) elements.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntelligenceIndicator, {
|
|
7816
7881
|
message,
|
|
7817
7882
|
agentId: config?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID,
|
|
@@ -9938,7 +10003,7 @@ function CopilotPopupViewInternal({ header, toggleButton, width, height, clickOu
|
|
|
9938
10003
|
const popupAnimationClass = isPopupOpen && !isAnimatingOut ? "cpk:pointer-events-auto cpk:translate-y-0 cpk:opacity-100 cpk:md:scale-100" : "cpk:pointer-events-none cpk:translate-y-4 cpk:opacity-0 cpk:md:translate-y-5 cpk:md:scale-[0.95]";
|
|
9939
10004
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [toggleButtonElement, isRendered ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
9940
10005
|
"data-copilotkit": true,
|
|
9941
|
-
className: cn("cpk:fixed cpk:inset-0 cpk:z-[1200] cpk:flex cpk:max-w-full cpk:flex-col cpk:items-stretch", "cpk:md:inset-auto cpk:md:bottom-24 cpk:md:right-6 cpk:md:items-end cpk:md:gap-4"),
|
|
10006
|
+
className: cn("cpk:fixed cpk:inset-0 cpk:z-[1200] cpk:flex cpk:max-w-full cpk:flex-col cpk:items-stretch cpk:bg-transparent", "cpk:md:inset-auto cpk:md:bottom-24 cpk:md:right-6 cpk:md:items-end cpk:md:gap-4"),
|
|
9942
10007
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
9943
10008
|
ref: containerRef,
|
|
9944
10009
|
tabIndex: -1,
|
|
@@ -13141,4 +13206,4 @@ Object.defineProperty(exports, 'useToast', {
|
|
|
13141
13206
|
return useToast;
|
|
13142
13207
|
}
|
|
13143
13208
|
});
|
|
13144
|
-
//# sourceMappingURL=copilotkit-
|
|
13209
|
+
//# sourceMappingURL=copilotkit-CFPkj9B9.cjs.map
|