@copilotkitnext/react 0.0.9-alpha.1 → 0.0.9-alpha.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/index.d.mts CHANGED
@@ -2,8 +2,8 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
3
  import React__default, { ReactNode } from 'react';
4
4
  import { AssistantMessage, Message, UserMessage, ToolCall, ToolMessage } from '@ag-ui/core';
5
- import { ToolCallStatus, FrontendTool, CopilotKitCore } from '@copilotkitnext/core';
6
5
  import { z } from 'zod';
6
+ import { ToolCallStatus, FrontendTool, CopilotKitCore } from '@copilotkitnext/core';
7
7
  import { AbstractAgent, Context } from '@ag-ui/client';
8
8
 
9
9
  declare const CopilotChatDefaultLabels: {
@@ -118,9 +118,8 @@ declare namespace CopilotChatInput {
118
118
  type CopilotChatToolCallsViewProps = {
119
119
  message: AssistantMessage;
120
120
  messages?: Message[];
121
- isRunning?: boolean;
122
121
  };
123
- declare function CopilotChatToolCallsView({ message, messages, isRunning, }: CopilotChatToolCallsViewProps): react_jsx_runtime.JSX.Element | null;
122
+ declare function CopilotChatToolCallsView({ message, messages, }: CopilotChatToolCallsViewProps): react_jsx_runtime.JSX.Element | null;
124
123
 
125
124
  type CopilotChatAssistantMessageProps = WithSlots<{
126
125
  markdownRenderer: typeof CopilotChatAssistantMessage.MarkdownRenderer;
@@ -262,10 +261,11 @@ type CopilotChatProps = Omit<CopilotChatViewProps, "messages"> & {
262
261
  };
263
262
  declare function CopilotChat({ agentId, threadId, ...props }: CopilotChatProps): react_jsx_runtime.JSX.Element;
264
263
 
264
+ declare const WildcardToolCallRender: ReactToolCallRender<any>;
265
+
265
266
  interface UseRenderToolCallProps {
266
267
  toolCall: ToolCall;
267
268
  toolMessage?: ToolMessage;
268
- isRunning: boolean;
269
269
  }
270
270
  /**
271
271
  * Hook that returns a function to render tool calls based on the render functions
@@ -273,7 +273,7 @@ interface UseRenderToolCallProps {
273
273
  *
274
274
  * @returns A function that takes a tool call and optional tool message and returns the rendered component
275
275
  */
276
- declare function useRenderToolCall(): ({ toolCall, toolMessage, isRunning, }: UseRenderToolCallProps) => React__default.ReactElement | null;
276
+ declare function useRenderToolCall(): ({ toolCall, toolMessage, }: UseRenderToolCallProps) => React__default.ReactElement | null;
277
277
 
278
278
  interface ReactToolCallRender<T> {
279
279
  name: string;
@@ -351,7 +351,7 @@ declare function useAgentContext(context: Context): void;
351
351
 
352
352
  interface CopilotKitContextValue {
353
353
  copilotkit: CopilotKitCore;
354
- renderToolCalls: ReactToolCallRender<unknown>[];
354
+ renderToolCalls: ReactToolCallRender<any>[];
355
355
  currentRenderToolCalls: ReactToolCallRender<unknown>[];
356
356
  setCurrentRenderToolCalls: React__default.Dispatch<React__default.SetStateAction<ReactToolCallRender<unknown>[]>>;
357
357
  }
@@ -360,8 +360,8 @@ interface CopilotKitProviderProps {
360
360
  runtimeUrl?: string;
361
361
  headers?: Record<string, string>;
362
362
  properties?: Record<string, unknown>;
363
- agents?: Record<string, AbstractAgent>;
364
- renderToolCalls?: ReactToolCallRender<unknown>[];
363
+ agents__unsafe_dev_only?: Record<string, AbstractAgent>;
364
+ renderToolCalls?: ReactToolCallRender<any>[];
365
365
  frontendTools?: ReactFrontendTool[];
366
366
  humanInTheLoop?: ReactHumanInTheLoop[];
367
367
  }
@@ -403,4 +403,4 @@ declare function defineToolCallRender<S extends z.ZodTypeAny>(def: {
403
403
  agentId?: string;
404
404
  }): ReactToolCallRender<z.infer<S>>;
405
405
 
406
- export { AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitProvider, type CopilotKitProviderProps, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRender, type ToolsMenuItem, defineToolCallRender, useAgent, useAgentContext, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderToolCall };
406
+ export { AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitProvider, type CopilotKitProviderProps, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRender, type ToolsMenuItem, WildcardToolCallRender, defineToolCallRender, useAgent, useAgentContext, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderToolCall };
package/dist/index.d.ts CHANGED
@@ -2,8 +2,8 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as React$1 from 'react';
3
3
  import React__default, { ReactNode } from 'react';
4
4
  import { AssistantMessage, Message, UserMessage, ToolCall, ToolMessage } from '@ag-ui/core';
5
- import { ToolCallStatus, FrontendTool, CopilotKitCore } from '@copilotkitnext/core';
6
5
  import { z } from 'zod';
6
+ import { ToolCallStatus, FrontendTool, CopilotKitCore } from '@copilotkitnext/core';
7
7
  import { AbstractAgent, Context } from '@ag-ui/client';
8
8
 
9
9
  declare const CopilotChatDefaultLabels: {
@@ -118,9 +118,8 @@ declare namespace CopilotChatInput {
118
118
  type CopilotChatToolCallsViewProps = {
119
119
  message: AssistantMessage;
120
120
  messages?: Message[];
121
- isRunning?: boolean;
122
121
  };
123
- declare function CopilotChatToolCallsView({ message, messages, isRunning, }: CopilotChatToolCallsViewProps): react_jsx_runtime.JSX.Element | null;
122
+ declare function CopilotChatToolCallsView({ message, messages, }: CopilotChatToolCallsViewProps): react_jsx_runtime.JSX.Element | null;
124
123
 
125
124
  type CopilotChatAssistantMessageProps = WithSlots<{
126
125
  markdownRenderer: typeof CopilotChatAssistantMessage.MarkdownRenderer;
@@ -262,10 +261,11 @@ type CopilotChatProps = Omit<CopilotChatViewProps, "messages"> & {
262
261
  };
263
262
  declare function CopilotChat({ agentId, threadId, ...props }: CopilotChatProps): react_jsx_runtime.JSX.Element;
264
263
 
264
+ declare const WildcardToolCallRender: ReactToolCallRender<any>;
265
+
265
266
  interface UseRenderToolCallProps {
266
267
  toolCall: ToolCall;
267
268
  toolMessage?: ToolMessage;
268
- isRunning: boolean;
269
269
  }
270
270
  /**
271
271
  * Hook that returns a function to render tool calls based on the render functions
@@ -273,7 +273,7 @@ interface UseRenderToolCallProps {
273
273
  *
274
274
  * @returns A function that takes a tool call and optional tool message and returns the rendered component
275
275
  */
276
- declare function useRenderToolCall(): ({ toolCall, toolMessage, isRunning, }: UseRenderToolCallProps) => React__default.ReactElement | null;
276
+ declare function useRenderToolCall(): ({ toolCall, toolMessage, }: UseRenderToolCallProps) => React__default.ReactElement | null;
277
277
 
278
278
  interface ReactToolCallRender<T> {
279
279
  name: string;
@@ -351,7 +351,7 @@ declare function useAgentContext(context: Context): void;
351
351
 
352
352
  interface CopilotKitContextValue {
353
353
  copilotkit: CopilotKitCore;
354
- renderToolCalls: ReactToolCallRender<unknown>[];
354
+ renderToolCalls: ReactToolCallRender<any>[];
355
355
  currentRenderToolCalls: ReactToolCallRender<unknown>[];
356
356
  setCurrentRenderToolCalls: React__default.Dispatch<React__default.SetStateAction<ReactToolCallRender<unknown>[]>>;
357
357
  }
@@ -360,8 +360,8 @@ interface CopilotKitProviderProps {
360
360
  runtimeUrl?: string;
361
361
  headers?: Record<string, string>;
362
362
  properties?: Record<string, unknown>;
363
- agents?: Record<string, AbstractAgent>;
364
- renderToolCalls?: ReactToolCallRender<unknown>[];
363
+ agents__unsafe_dev_only?: Record<string, AbstractAgent>;
364
+ renderToolCalls?: ReactToolCallRender<any>[];
365
365
  frontendTools?: ReactFrontendTool[];
366
366
  humanInTheLoop?: ReactHumanInTheLoop[];
367
367
  }
@@ -403,4 +403,4 @@ declare function defineToolCallRender<S extends z.ZodTypeAny>(def: {
403
403
  agentId?: string;
404
404
  }): ReactToolCallRender<z.infer<S>>;
405
405
 
406
- export { AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitProvider, type CopilotKitProviderProps, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRender, type ToolsMenuItem, defineToolCallRender, useAgent, useAgentContext, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderToolCall };
406
+ export { AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitProvider, type CopilotKitProviderProps, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRender, type ToolsMenuItem, WildcardToolCallRender, defineToolCallRender, useAgent, useAgentContext, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderToolCall };
package/dist/index.js CHANGED
@@ -41,6 +41,7 @@ __export(index_exports, {
41
41
  CopilotChatUserMessage: () => CopilotChatUserMessage_default,
42
42
  CopilotChatView: () => CopilotChatView_default,
43
43
  CopilotKitProvider: () => CopilotKitProvider,
44
+ WildcardToolCallRender: () => WildcardToolCallRender,
44
45
  defineToolCallRender: () => defineToolCallRender,
45
46
  useAgent: () => useAgent,
46
47
  useAgentContext: () => useAgentContext,
@@ -972,7 +973,7 @@ var CopilotKitProvider = ({
972
973
  runtimeUrl,
973
974
  headers = {},
974
975
  properties = {},
975
- agents = {},
976
+ agents__unsafe_dev_only: agents = {},
976
977
  renderToolCalls,
977
978
  frontendTools,
978
979
  humanInTheLoop
@@ -1161,8 +1162,7 @@ function useRenderToolCall() {
1161
1162
  const renderToolCall = (0, import_react6.useCallback)(
1162
1163
  ({
1163
1164
  toolCall,
1164
- toolMessage,
1165
- isRunning
1165
+ toolMessage
1166
1166
  }) => {
1167
1167
  const exactMatches = currentRenderToolCalls.filter(
1168
1168
  (rc) => rc.name === toolCall.function.name
@@ -1196,7 +1196,7 @@ function useRenderToolCall() {
1196
1196
  },
1197
1197
  toolCall.id
1198
1198
  );
1199
- } else if (isRunning) {
1199
+ } else {
1200
1200
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1201
1201
  RenderComponent,
1202
1202
  {
@@ -1207,17 +1207,6 @@ function useRenderToolCall() {
1207
1207
  },
1208
1208
  toolCall.id
1209
1209
  );
1210
- } else {
1211
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1212
- RenderComponent,
1213
- {
1214
- name: toolName,
1215
- args,
1216
- status: import_core2.ToolCallStatus.Complete,
1217
- result: ""
1218
- },
1219
- toolCall.id
1220
- );
1221
1210
  }
1222
1211
  },
1223
1212
  [currentRenderToolCalls, executingToolCallIds, agentId]
@@ -1414,8 +1403,7 @@ var import_react12 = __toESM(require("react"));
1414
1403
  var import_jsx_runtime9 = require("react/jsx-runtime");
1415
1404
  function CopilotChatToolCallsView({
1416
1405
  message,
1417
- messages = [],
1418
- isRunning = false
1406
+ messages = []
1419
1407
  }) {
1420
1408
  const renderToolCall = useRenderToolCall();
1421
1409
  if (!message.toolCalls || message.toolCalls.length === 0) {
@@ -1427,8 +1415,7 @@ function CopilotChatToolCallsView({
1427
1415
  );
1428
1416
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react12.default.Fragment, { children: renderToolCall({
1429
1417
  toolCall,
1430
- toolMessage,
1431
- isRunning
1418
+ toolMessage
1432
1419
  }) }, toolCall.id);
1433
1420
  }) });
1434
1421
  }
@@ -1527,8 +1514,7 @@ function CopilotChatAssistantMessage({
1527
1514
  CopilotChatToolCallsView_default,
1528
1515
  {
1529
1516
  message,
1530
- messages,
1531
- isRunning
1517
+ messages
1532
1518
  }
1533
1519
  );
1534
1520
  const hasContent = !!(message.content && message.content.trim().length > 0);
@@ -2441,6 +2427,70 @@ function defineToolCallRender(def) {
2441
2427
  ...def.agentId ? { agentId: def.agentId } : {}
2442
2428
  };
2443
2429
  }
2430
+
2431
+ // src/components/WildcardToolCallRender.tsx
2432
+ var import_react17 = require("react");
2433
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2434
+ var WildcardToolCallRender = defineToolCallRender({
2435
+ name: "*",
2436
+ render: ({ args, result, name, status }) => {
2437
+ const [isExpanded, setIsExpanded] = (0, import_react17.useState)(false);
2438
+ const statusString = String(status);
2439
+ const isActive = statusString === "inProgress" || statusString === "executing";
2440
+ const isComplete = statusString === "complete";
2441
+ const statusStyles = isActive ? "bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-400" : isComplete ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-500/15 dark:text-emerald-400" : "bg-zinc-100 text-zinc-800 dark:bg-zinc-700/40 dark:text-zinc-300";
2442
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "mt-2 pb-2", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "rounded-xl border border-zinc-200/60 dark:border-zinc-800/60 bg-white/70 dark:bg-zinc-900/50 shadow-sm backdrop-blur p-4", children: [
2443
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2444
+ "div",
2445
+ {
2446
+ className: "flex items-center justify-between gap-3 cursor-pointer",
2447
+ onClick: () => setIsExpanded(!isExpanded),
2448
+ children: [
2449
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-2 min-w-0", children: [
2450
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2451
+ "svg",
2452
+ {
2453
+ className: `h-4 w-4 text-zinc-500 dark:text-zinc-400 transition-transform ${isExpanded ? "rotate-90" : ""}`,
2454
+ fill: "none",
2455
+ viewBox: "0 0 24 24",
2456
+ strokeWidth: 2,
2457
+ stroke: "currentColor",
2458
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2459
+ "path",
2460
+ {
2461
+ strokeLinecap: "round",
2462
+ strokeLinejoin: "round",
2463
+ d: "M8.25 4.5l7.5 7.5-7.5 7.5"
2464
+ }
2465
+ )
2466
+ }
2467
+ ),
2468
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-blue-500" }),
2469
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "truncate text-sm font-medium text-zinc-900 dark:text-zinc-100", children: name })
2470
+ ] }),
2471
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2472
+ "span",
2473
+ {
2474
+ className: `inline-flex items-center rounded-full px-2 py-1 text-xs font-medium ${statusStyles}`,
2475
+ children: String(status)
2476
+ }
2477
+ )
2478
+ ]
2479
+ }
2480
+ ),
2481
+ isExpanded && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "mt-3 grid gap-4", children: [
2482
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
2483
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Arguments" }),
2484
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: JSON.stringify(args ?? {}, null, 2) })
2485
+ ] }),
2486
+ result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
2487
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "text-xs uppercase tracking-wide text-zinc-500 dark:text-zinc-400", children: "Result" }),
2488
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("pre", { className: "mt-2 max-h-64 overflow-auto rounded-md bg-zinc-50 dark:bg-zinc-800/60 p-3 text-xs leading-relaxed text-zinc-800 dark:text-zinc-200 whitespace-pre-wrap break-words", children: typeof result === "string" ? result : JSON.stringify(result, null, 2) })
2489
+ ] })
2490
+ ] })
2491
+ ] }) });
2492
+ }
2493
+ });
2444
2494
  // Annotate the CommonJS export names for ESM import in node:
2445
2495
  0 && (module.exports = {
2446
2496
  AudioRecorderError,
@@ -2454,6 +2504,7 @@ function defineToolCallRender(def) {
2454
2504
  CopilotChatUserMessage,
2455
2505
  CopilotChatView,
2456
2506
  CopilotKitProvider,
2507
+ WildcardToolCallRender,
2457
2508
  defineToolCallRender,
2458
2509
  useAgent,
2459
2510
  useAgentContext,