@copilotkitnext/react 0.0.9-alpha.0 → 0.0.9-alpha.2
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 +27 -8
- package/dist/index.d.ts +27 -8
- package/dist/index.js +22 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -30
- 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);
|
|
@@ -1126,8 +1130,7 @@ function useRenderToolCall() {
|
|
|
1126
1130
|
const renderToolCall = useCallback(
|
|
1127
1131
|
({
|
|
1128
1132
|
toolCall,
|
|
1129
|
-
toolMessage
|
|
1130
|
-
isRunning
|
|
1133
|
+
toolMessage
|
|
1131
1134
|
}) => {
|
|
1132
1135
|
const exactMatches = currentRenderToolCalls.filter(
|
|
1133
1136
|
(rc) => rc.name === toolCall.function.name
|
|
@@ -1161,7 +1164,7 @@ function useRenderToolCall() {
|
|
|
1161
1164
|
},
|
|
1162
1165
|
toolCall.id
|
|
1163
1166
|
);
|
|
1164
|
-
} else
|
|
1167
|
+
} else {
|
|
1165
1168
|
return /* @__PURE__ */ jsx8(
|
|
1166
1169
|
RenderComponent,
|
|
1167
1170
|
{
|
|
@@ -1172,17 +1175,6 @@ function useRenderToolCall() {
|
|
|
1172
1175
|
},
|
|
1173
1176
|
toolCall.id
|
|
1174
1177
|
);
|
|
1175
|
-
} else {
|
|
1176
|
-
return /* @__PURE__ */ jsx8(
|
|
1177
|
-
RenderComponent,
|
|
1178
|
-
{
|
|
1179
|
-
name: toolName,
|
|
1180
|
-
args,
|
|
1181
|
-
status: ToolCallStatus.Complete,
|
|
1182
|
-
result: ""
|
|
1183
|
-
},
|
|
1184
|
-
toolCall.id
|
|
1185
|
-
);
|
|
1186
1178
|
}
|
|
1187
1179
|
},
|
|
1188
1180
|
[currentRenderToolCalls, executingToolCallIds, agentId]
|
|
@@ -1379,8 +1371,7 @@ import React7 from "react";
|
|
|
1379
1371
|
import { Fragment as Fragment2, jsx as jsx9 } from "react/jsx-runtime";
|
|
1380
1372
|
function CopilotChatToolCallsView({
|
|
1381
1373
|
message,
|
|
1382
|
-
messages = []
|
|
1383
|
-
isRunning = false
|
|
1374
|
+
messages = []
|
|
1384
1375
|
}) {
|
|
1385
1376
|
const renderToolCall = useRenderToolCall();
|
|
1386
1377
|
if (!message.toolCalls || message.toolCalls.length === 0) {
|
|
@@ -1392,8 +1383,7 @@ function CopilotChatToolCallsView({
|
|
|
1392
1383
|
);
|
|
1393
1384
|
return /* @__PURE__ */ jsx9(React7.Fragment, { children: renderToolCall({
|
|
1394
1385
|
toolCall,
|
|
1395
|
-
toolMessage
|
|
1396
|
-
isRunning
|
|
1386
|
+
toolMessage
|
|
1397
1387
|
}) }, toolCall.id);
|
|
1398
1388
|
}) });
|
|
1399
1389
|
}
|
|
@@ -1492,10 +1482,11 @@ function CopilotChatAssistantMessage({
|
|
|
1492
1482
|
CopilotChatToolCallsView_default,
|
|
1493
1483
|
{
|
|
1494
1484
|
message,
|
|
1495
|
-
messages
|
|
1496
|
-
isRunning
|
|
1485
|
+
messages
|
|
1497
1486
|
}
|
|
1498
1487
|
);
|
|
1488
|
+
const hasContent = !!(message.content && message.content.trim().length > 0);
|
|
1489
|
+
const shouldShowToolbar = toolbarVisible && hasContent;
|
|
1499
1490
|
if (children) {
|
|
1500
1491
|
return /* @__PURE__ */ jsx10(Fragment3, { children: children({
|
|
1501
1492
|
markdownRenderer: boundMarkdownRenderer,
|
|
@@ -1514,7 +1505,7 @@ function CopilotChatAssistantMessage({
|
|
|
1514
1505
|
onReadAloud,
|
|
1515
1506
|
onRegenerate,
|
|
1516
1507
|
additionalToolbarItems,
|
|
1517
|
-
toolbarVisible
|
|
1508
|
+
toolbarVisible: shouldShowToolbar
|
|
1518
1509
|
}) });
|
|
1519
1510
|
}
|
|
1520
1511
|
return /* @__PURE__ */ jsxs4(
|
|
@@ -1529,7 +1520,7 @@ function CopilotChatAssistantMessage({
|
|
|
1529
1520
|
children: [
|
|
1530
1521
|
boundMarkdownRenderer,
|
|
1531
1522
|
boundToolCallsView,
|
|
1532
|
-
|
|
1523
|
+
shouldShowToolbar && boundToolbar
|
|
1533
1524
|
]
|
|
1534
1525
|
}
|
|
1535
1526
|
);
|
|
@@ -2394,11 +2385,12 @@ function CopilotChat({
|
|
|
2394
2385
|
}
|
|
2395
2386
|
|
|
2396
2387
|
// src/types/defineToolCallRender.ts
|
|
2388
|
+
import { z as z2 } from "zod";
|
|
2397
2389
|
function defineToolCallRender(def) {
|
|
2390
|
+
const argsSchema = def.name === "*" && !def.args ? z2.any() : def.args;
|
|
2398
2391
|
return {
|
|
2399
2392
|
name: def.name,
|
|
2400
|
-
args:
|
|
2401
|
-
// Coerce to ComponentType to align with ReactToolCallRender
|
|
2393
|
+
args: argsSchema,
|
|
2402
2394
|
render: def.render,
|
|
2403
2395
|
...def.agentId ? { agentId: def.agentId } : {}
|
|
2404
2396
|
};
|