@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 CHANGED
@@ -373,12 +373,33 @@ declare const useCopilotKit: () => CopilotKitContextValue;
373
373
  * - Accepts a single object whose keys match ReactToolCallRender's fields: { name, args, render, agentId? }.
374
374
  * - Derives `args` type from the provided Zod schema.
375
375
  * - Ensures the render function param type exactly matches ReactToolCallRender<T>["render"]'s param.
376
+ * - For wildcard tools (name: "*"), args is optional and defaults to z.any()
376
377
  */
377
- type RenderProps<S extends z.ZodTypeAny> = React__default.ComponentProps<ReactToolCallRender<z.infer<S>>["render"]>;
378
+ type RenderProps<T> = {
379
+ name: string;
380
+ args: Partial<T>;
381
+ status: ToolCallStatus.InProgress;
382
+ result: undefined;
383
+ } | {
384
+ name: string;
385
+ args: T;
386
+ status: ToolCallStatus.Executing;
387
+ result: undefined;
388
+ } | {
389
+ name: string;
390
+ args: T;
391
+ status: ToolCallStatus.Complete;
392
+ result: string;
393
+ };
394
+ declare function defineToolCallRender(def: {
395
+ name: "*";
396
+ render: (props: RenderProps<any>) => React__default.ReactElement;
397
+ agentId?: string;
398
+ }): ReactToolCallRender<any>;
378
399
  declare function defineToolCallRender<S extends z.ZodTypeAny>(def: {
379
400
  name: string;
380
401
  args: S;
381
- render: (props: RenderProps<S>) => React__default.ReactElement;
402
+ render: (props: RenderProps<z.infer<S>>) => React__default.ReactElement;
382
403
  agentId?: string;
383
404
  }): ReactToolCallRender<z.infer<S>>;
384
405
 
package/dist/index.d.ts CHANGED
@@ -373,12 +373,33 @@ declare const useCopilotKit: () => CopilotKitContextValue;
373
373
  * - Accepts a single object whose keys match ReactToolCallRender's fields: { name, args, render, agentId? }.
374
374
  * - Derives `args` type from the provided Zod schema.
375
375
  * - Ensures the render function param type exactly matches ReactToolCallRender<T>["render"]'s param.
376
+ * - For wildcard tools (name: "*"), args is optional and defaults to z.any()
376
377
  */
377
- type RenderProps<S extends z.ZodTypeAny> = React__default.ComponentProps<ReactToolCallRender<z.infer<S>>["render"]>;
378
+ type RenderProps<T> = {
379
+ name: string;
380
+ args: Partial<T>;
381
+ status: ToolCallStatus.InProgress;
382
+ result: undefined;
383
+ } | {
384
+ name: string;
385
+ args: T;
386
+ status: ToolCallStatus.Executing;
387
+ result: undefined;
388
+ } | {
389
+ name: string;
390
+ args: T;
391
+ status: ToolCallStatus.Complete;
392
+ result: string;
393
+ };
394
+ declare function defineToolCallRender(def: {
395
+ name: "*";
396
+ render: (props: RenderProps<any>) => React__default.ReactElement;
397
+ agentId?: string;
398
+ }): ReactToolCallRender<any>;
378
399
  declare function defineToolCallRender<S extends z.ZodTypeAny>(def: {
379
400
  name: string;
380
401
  args: S;
381
- render: (props: RenderProps<S>) => React__default.ReactElement;
402
+ render: (props: RenderProps<z.infer<S>>) => React__default.ReactElement;
382
403
  agentId?: string;
383
404
  }): ReactToolCallRender<z.infer<S>>;
384
405
 
package/dist/index.js CHANGED
@@ -946,6 +946,7 @@ var import_core2 = require("@copilotkitnext/core");
946
946
 
947
947
  // src/providers/CopilotKitProvider.tsx
948
948
  var import_react5 = require("react");
949
+ var import_zod = require("zod");
949
950
  var import_core = require("@copilotkitnext/core");
950
951
  var import_jsx_runtime7 = require("react/jsx-runtime");
951
952
  var CopilotKitContext = (0, import_react5.createContext)({
@@ -1039,12 +1040,15 @@ var CopilotKitProvider = ({
1039
1040
  const allRenderToolCalls = (0, import_react5.useMemo)(() => {
1040
1041
  const combined = [...renderToolCallsList];
1041
1042
  frontendToolsList.forEach((tool) => {
1042
- if (tool.render && tool.parameters) {
1043
- combined.push({
1044
- name: tool.name,
1045
- args: tool.parameters,
1046
- render: tool.render
1047
- });
1043
+ if (tool.render) {
1044
+ const args = tool.parameters || (tool.name === "*" ? import_zod.z.any() : void 0);
1045
+ if (args) {
1046
+ combined.push({
1047
+ name: tool.name,
1048
+ args,
1049
+ render: tool.render
1050
+ });
1051
+ }
1048
1052
  }
1049
1053
  });
1050
1054
  combined.push(...processedHumanInTheLoopTools.renderToolCalls);
@@ -1527,6 +1531,8 @@ function CopilotChatAssistantMessage({
1527
1531
  isRunning
1528
1532
  }
1529
1533
  );
1534
+ const hasContent = !!(message.content && message.content.trim().length > 0);
1535
+ const shouldShowToolbar = toolbarVisible && hasContent;
1530
1536
  if (children) {
1531
1537
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: children({
1532
1538
  markdownRenderer: boundMarkdownRenderer,
@@ -1545,7 +1551,7 @@ function CopilotChatAssistantMessage({
1545
1551
  onReadAloud,
1546
1552
  onRegenerate,
1547
1553
  additionalToolbarItems,
1548
- toolbarVisible
1554
+ toolbarVisible: shouldShowToolbar
1549
1555
  }) });
1550
1556
  }
1551
1557
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
@@ -1560,7 +1566,7 @@ function CopilotChatAssistantMessage({
1560
1566
  children: [
1561
1567
  boundMarkdownRenderer,
1562
1568
  boundToolCallsView,
1563
- toolbarVisible && boundToolbar
1569
+ shouldShowToolbar && boundToolbar
1564
1570
  ]
1565
1571
  }
1566
1572
  );
@@ -2425,11 +2431,12 @@ function CopilotChat({
2425
2431
  }
2426
2432
 
2427
2433
  // src/types/defineToolCallRender.ts
2434
+ var import_zod2 = require("zod");
2428
2435
  function defineToolCallRender(def) {
2436
+ const argsSchema = def.name === "*" && !def.args ? import_zod2.z.any() : def.args;
2429
2437
  return {
2430
2438
  name: def.name,
2431
- args: def.args,
2432
- // Coerce to ComponentType to align with ReactToolCallRender
2439
+ args: argsSchema,
2433
2440
  render: def.render,
2434
2441
  ...def.agentId ? { agentId: def.agentId } : {}
2435
2442
  };