@copilotkit/react-core 1.70.2 → 1.70.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-B1jSvZeb.mjs → copilotkit-Ap_yisA5.mjs} +220 -18
- package/dist/{copilotkit-DcFo270Y.cjs.map → copilotkit-Ap_yisA5.mjs.map} +1 -1
- package/dist/{copilotkit-DcFo270Y.cjs → copilotkit-BU3OvveB.cjs} +218 -16
- package/dist/copilotkit-BU3OvveB.cjs.map +1 -0
- package/dist/{copilotkit--Jyzm6hS.d.mts → copilotkit-Bs98akp9.d.mts} +2 -2
- package/dist/{copilotkit--Jyzm6hS.d.mts.map → copilotkit-Bs98akp9.d.mts.map} +1 -1
- package/dist/{copilotkit-BLYaCGcz.d.cts → copilotkit-X2eGbOwf.d.cts} +2 -2
- package/dist/{copilotkit-BLYaCGcz.d.cts.map → copilotkit-X2eGbOwf.d.cts.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +217 -15
- package/dist/index.umd.js.map +1 -1
- package/dist/v2/headless.cjs +41 -2
- package/dist/v2/headless.cjs.map +1 -1
- package/dist/v2/headless.d.cts.map +1 -1
- package/dist/v2/headless.d.mts.map +1 -1
- package/dist/v2/headless.mjs +41 -2
- package/dist/v2/headless.mjs.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.mjs +1 -1
- package/dist/v2/index.umd.js +217 -15
- package/dist/v2/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/skills/react-core/SKILL.md +1 -1
- package/dist/copilotkit-B1jSvZeb.mjs.map +0 -1
package/dist/v2/headless.cjs
CHANGED
|
@@ -1578,6 +1578,29 @@ const ToolCallRenderer = react.default.memo(function ToolCallRenderer({ toolCall
|
|
|
1578
1578
|
if (prevProps.RenderComponent !== nextProps.RenderComponent) return false;
|
|
1579
1579
|
return true;
|
|
1580
1580
|
});
|
|
1581
|
+
const IS_DEVELOPMENT = process.env.NODE_ENV !== "production";
|
|
1582
|
+
/**
|
|
1583
|
+
* Reports tool calls that resolved to no renderer.
|
|
1584
|
+
*
|
|
1585
|
+
* A tool call with no renderer paints an empty message container and says
|
|
1586
|
+
* nothing else, so the only signal a developer gets today is a blank space in
|
|
1587
|
+
* the chat. This names the call and the renderers that *are* registered, which
|
|
1588
|
+
* is the whole diagnosis when the cause is a name that does not match.
|
|
1589
|
+
*
|
|
1590
|
+
* @param toolNames - The unmatched tool names collected during render.
|
|
1591
|
+
* @param registered - The registry as it stands now, re-read at report time.
|
|
1592
|
+
* @param alreadyWarned - Names already reported, mutated to keep this once per name.
|
|
1593
|
+
*/
|
|
1594
|
+
function warnAboutUnrenderedToolCalls(toolNames, registered, alreadyWarned) {
|
|
1595
|
+
const registeredNames = Array.from(new Set(registered.map((rc) => rc.name)));
|
|
1596
|
+
const hasWildcard = registeredNames.includes("*");
|
|
1597
|
+
for (const toolName of toolNames) {
|
|
1598
|
+
if (hasWildcard || registeredNames.includes(toolName)) continue;
|
|
1599
|
+
if (alreadyWarned.has(toolName)) continue;
|
|
1600
|
+
alreadyWarned.add(toolName);
|
|
1601
|
+
console.warn(`[CopilotKit] The agent called the tool "${toolName}", and no renderer is registered for it, so that message rendered nothing. ` + (registeredNames.length === 0 ? "No tool-call renderers are registered. " : `Registered renderers: ${registeredNames.map((name) => `"${name}"`).join(", ")}. `) + `Register one with useRenderTool({ name: "${toolName}", ... }), or call useDefaultRenderTool() for a built-in card that covers every tool the agent calls. This warning is development-only.`);
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1581
1604
|
/**
|
|
1582
1605
|
* Hook that returns a function to render tool calls based on the render functions
|
|
1583
1606
|
* defined in CopilotKitProvider.
|
|
@@ -1587,13 +1610,18 @@ const ToolCallRenderer = react.default.memo(function ToolCallRenderer({ toolCall
|
|
|
1587
1610
|
function useRenderToolCall() {
|
|
1588
1611
|
const { copilotkit, executingToolCallIds } = (0, _copilotkit_react_core_v2_context.useCopilotKit)();
|
|
1589
1612
|
const agentId = useCopilotChatConfiguration()?.agentId ?? _copilotkit_shared.DEFAULT_AGENT_ID;
|
|
1613
|
+
const unrenderedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
1614
|
+
const warnedToolNames = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
1590
1615
|
const renderToolCalls = (0, react.useSyncExternalStore)((callback) => {
|
|
1591
1616
|
return copilotkit.subscribe({ onRenderToolCallsChanged: callback }).unsubscribe;
|
|
1592
1617
|
}, () => copilotkit.renderToolCalls, () => copilotkit.renderToolCalls);
|
|
1593
|
-
|
|
1618
|
+
const renderToolCall = (0, react.useCallback)(({ toolCall, toolMessage }) => {
|
|
1594
1619
|
const exactMatches = renderToolCalls.filter((rc) => rc.name === toolCall.function.name);
|
|
1595
1620
|
const renderConfig = exactMatches.find((rc) => rc.agentId === agentId) || exactMatches.find((rc) => !rc.agentId) || exactMatches[0] || renderToolCalls.find((rc) => rc.name === "*");
|
|
1596
|
-
if (!renderConfig)
|
|
1621
|
+
if (!renderConfig) {
|
|
1622
|
+
if (IS_DEVELOPMENT) unrenderedToolNames.current.add(toolCall.function.name);
|
|
1623
|
+
return null;
|
|
1624
|
+
}
|
|
1597
1625
|
const RenderComponent = renderConfig.render;
|
|
1598
1626
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolCallRenderer, {
|
|
1599
1627
|
toolCall,
|
|
@@ -1606,6 +1634,17 @@ function useRenderToolCall() {
|
|
|
1606
1634
|
executingToolCallIds,
|
|
1607
1635
|
agentId
|
|
1608
1636
|
]);
|
|
1637
|
+
(0, react.useEffect)(() => {
|
|
1638
|
+
if (!IS_DEVELOPMENT) return;
|
|
1639
|
+
if (unrenderedToolNames.current.size === 0) return;
|
|
1640
|
+
const timer = setTimeout(() => {
|
|
1641
|
+
const pending = Array.from(unrenderedToolNames.current);
|
|
1642
|
+
unrenderedToolNames.current.clear();
|
|
1643
|
+
warnAboutUnrenderedToolCalls(pending, copilotkit.renderToolCalls, warnedToolNames.current);
|
|
1644
|
+
}, 0);
|
|
1645
|
+
return () => clearTimeout(timer);
|
|
1646
|
+
});
|
|
1647
|
+
return renderToolCall;
|
|
1609
1648
|
}
|
|
1610
1649
|
|
|
1611
1650
|
//#endregion
|