@copilotkitnext/react 0.0.9-alpha.0 → 0.0.9-alpha.1
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/index.d.mts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +17 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -913,6 +913,7 @@ import {
|
|
|
913
913
|
useReducer,
|
|
914
914
|
useRef as useRef3
|
|
915
915
|
} from "react";
|
|
916
|
+
import { z } from "zod";
|
|
916
917
|
import {
|
|
917
918
|
CopilotKitCore
|
|
918
919
|
} from "@copilotkitnext/core";
|
|
@@ -1008,12 +1009,15 @@ var CopilotKitProvider = ({
|
|
|
1008
1009
|
const allRenderToolCalls = useMemo(() => {
|
|
1009
1010
|
const combined = [...renderToolCallsList];
|
|
1010
1011
|
frontendToolsList.forEach((tool) => {
|
|
1011
|
-
if (tool.render
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1012
|
+
if (tool.render) {
|
|
1013
|
+
const args = tool.parameters || (tool.name === "*" ? z.any() : void 0);
|
|
1014
|
+
if (args) {
|
|
1015
|
+
combined.push({
|
|
1016
|
+
name: tool.name,
|
|
1017
|
+
args,
|
|
1018
|
+
render: tool.render
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1017
1021
|
}
|
|
1018
1022
|
});
|
|
1019
1023
|
combined.push(...processedHumanInTheLoopTools.renderToolCalls);
|
|
@@ -1496,6 +1500,8 @@ function CopilotChatAssistantMessage({
|
|
|
1496
1500
|
isRunning
|
|
1497
1501
|
}
|
|
1498
1502
|
);
|
|
1503
|
+
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
1504
|
+
const shouldShowToolbar = toolbarVisible && hasContent;
|
|
1499
1505
|
if (children) {
|
|
1500
1506
|
return /* @__PURE__ */ jsx10(Fragment3, { children: children({
|
|
1501
1507
|
markdownRenderer: boundMarkdownRenderer,
|
|
@@ -1514,7 +1520,7 @@ function CopilotChatAssistantMessage({
|
|
|
1514
1520
|
onReadAloud,
|
|
1515
1521
|
onRegenerate,
|
|
1516
1522
|
additionalToolbarItems,
|
|
1517
|
-
toolbarVisible
|
|
1523
|
+
toolbarVisible: shouldShowToolbar
|
|
1518
1524
|
}) });
|
|
1519
1525
|
}
|
|
1520
1526
|
return /* @__PURE__ */ jsxs4(
|
|
@@ -1529,7 +1535,7 @@ function CopilotChatAssistantMessage({
|
|
|
1529
1535
|
children: [
|
|
1530
1536
|
boundMarkdownRenderer,
|
|
1531
1537
|
boundToolCallsView,
|
|
1532
|
-
|
|
1538
|
+
shouldShowToolbar && boundToolbar
|
|
1533
1539
|
]
|
|
1534
1540
|
}
|
|
1535
1541
|
);
|
|
@@ -2394,11 +2400,12 @@ function CopilotChat({
|
|
|
2394
2400
|
}
|
|
2395
2401
|
|
|
2396
2402
|
// src/types/defineToolCallRender.ts
|
|
2403
|
+
import { z as z2 } from "zod";
|
|
2397
2404
|
function defineToolCallRender(def) {
|
|
2405
|
+
const argsSchema = def.name === "*" && !def.args ? z2.any() : def.args;
|
|
2398
2406
|
return {
|
|
2399
2407
|
name: def.name,
|
|
2400
|
-
args:
|
|
2401
|
-
// Coerce to ComponentType to align with ReactToolCallRender
|
|
2408
|
+
args: argsSchema,
|
|
2402
2409
|
render: def.render,
|
|
2403
2410
|
...def.agentId ? { agentId: def.agentId } : {}
|
|
2404
2411
|
};
|