@copilotkit/react-native 1.66.0 → 1.66.1-canary.rn-tool-render

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.
@@ -1,6 +1,6 @@
1
- import { a as useRenderToolRegistry, i as RenderToolProvider, n as useRenderTool, o as CopilotKitNativeProviderProps, r as RenderToolProps, s as CopilotKitProvider, t as UseRenderToolOptions } from "./useRenderTool-BugVTDoM.cjs";
1
+ import { a as UseRenderToolOptions, c as RenderToolProvider, d as CopilotKitProvider, i as useComponent, l as useRenderToolRegistry, n as RenderableToolCall, o as useRenderTool, r as useRenderToolCall, s as RenderToolProps, t as RenderToolCallInput, u as CopilotKitNativeProviderProps } from "./useRenderToolCall-BToS3UWC.cjs";
2
2
  import { CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Suggestion, ToolCallStatus } from "@copilotkit/core";
3
3
  import { CopilotKitContext, CopilotKitContextValue, useCopilotKit, useLicenseContext } from "@copilotkit/react-core/v2/context";
4
- import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
4
+ import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
5
5
  import { AbstractAgent, AgentCapabilities, AssistantMessage as AssistantMessageType, Message, ToolCall, ToolMessage } from "@ag-ui/client";
6
- export { type AbstractAgent, type AgentCapabilities, type AgentContextInput, type AssistantMessageType, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitContext, type CopilotKitContextValue, type CopilotKitCoreErrorCode, type CopilotKitCoreRuntimeConnectionStatus, type CopilotKitNativeProviderProps, type CopilotKitNativeProviderProps as CopilotKitProviderProps, CopilotKitProvider, type FrontendTool, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type Message, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, RenderToolProvider, type ResumeEntry, type ResumeStatus, type Suggestion, type Thread, type ToolCall, type ToolCallStatus, type ToolMessage, type UseAgentUpdate, type UseInterruptConfig, type UseRenderToolOptions, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolRegistry, useSuggestions, useThreads };
6
+ export { type AbstractAgent, type AgentCapabilities, type AgentContextInput, type AssistantMessageType, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitContext, type CopilotKitContextValue, type CopilotKitCoreErrorCode, type CopilotKitCoreRuntimeConnectionStatus, type CopilotKitNativeProviderProps, type CopilotKitNativeProviderProps as CopilotKitProviderProps, CopilotKitProvider, type FrontendTool, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type Message, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCallInput, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, RenderToolProvider, type RenderableToolCall, type ResumeEntry, type ResumeStatus, type Suggestion, type Thread, type ToolCall, type ToolCallStatus, type ToolMessage, type UseAgentUpdate, type UseInterruptConfig, type UseRenderToolOptions, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useRenderToolRegistry, useSuggestions, useThreads };
@@ -1,6 +1,6 @@
1
- import { a as useRenderToolRegistry, i as RenderToolProvider, n as useRenderTool, o as CopilotKitNativeProviderProps, r as RenderToolProps, s as CopilotKitProvider, t as UseRenderToolOptions } from "./useRenderTool-9YDIfZ0D.mjs";
1
+ import { a as UseRenderToolOptions, c as RenderToolProvider, d as CopilotKitProvider, i as useComponent, l as useRenderToolRegistry, n as RenderableToolCall, o as useRenderTool, r as useRenderToolCall, s as RenderToolProps, t as RenderToolCallInput, u as CopilotKitNativeProviderProps } from "./useRenderToolCall-DAvPBgpB.mjs";
2
2
  import { CopilotKitContext, CopilotKitContextValue, useCopilotKit, useLicenseContext } from "@copilotkit/react-core/v2/context";
3
- import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
3
+ import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
4
4
  import { CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Suggestion, ToolCallStatus } from "@copilotkit/core";
5
5
  import { AbstractAgent, AgentCapabilities, AssistantMessage as AssistantMessageType, Message, ToolCall, ToolMessage } from "@ag-ui/client";
6
- export { type AbstractAgent, type AgentCapabilities, type AgentContextInput, type AssistantMessageType, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitContext, type CopilotKitContextValue, type CopilotKitCoreErrorCode, type CopilotKitCoreRuntimeConnectionStatus, type CopilotKitNativeProviderProps, type CopilotKitNativeProviderProps as CopilotKitProviderProps, CopilotKitProvider, type FrontendTool, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type Message, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, RenderToolProvider, type ResumeEntry, type ResumeStatus, type Suggestion, type Thread, type ToolCall, type ToolCallStatus, type ToolMessage, type UseAgentUpdate, type UseInterruptConfig, type UseRenderToolOptions, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolRegistry, useSuggestions, useThreads };
6
+ export { type AbstractAgent, type AgentCapabilities, type AgentContextInput, type AssistantMessageType, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitContext, type CopilotKitContextValue, type CopilotKitCoreErrorCode, type CopilotKitCoreRuntimeConnectionStatus, type CopilotKitNativeProviderProps, type CopilotKitNativeProviderProps as CopilotKitProviderProps, CopilotKitProvider, type FrontendTool, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type Message, type ReactFrontendTool, type ReactHumanInTheLoop, type RenderToolCallInput, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, RenderToolProvider, type RenderableToolCall, type ResumeEntry, type ResumeStatus, type Suggestion, type Thread, type ToolCall, type ToolCallStatus, type ToolMessage, type UseAgentUpdate, type UseInterruptConfig, type UseRenderToolOptions, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useRenderToolRegistry, useSuggestions, useThreads };
package/dist/headless.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { r as useRenderToolRegistry, t as RenderToolProvider } from "./RenderToolContext-D8M-JhD1.mjs";
2
- import { n as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-DUqpS97B.mjs";
2
+ import { i as CopilotKitProvider, n as useComponent, r as useRenderTool, t as useRenderToolCall } from "./useRenderToolCall-DjhQb8Ki.mjs";
3
3
  import { CopilotKitContext, useCopilotKit, useLicenseContext } from "@copilotkit/react-core/v2/context";
4
- import { CopilotChatDefaultLabels, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
4
+ import { CopilotChatDefaultLabels, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
5
5
 
6
- export { CopilotChatDefaultLabels, CopilotKitContext, CopilotKitProvider, RenderToolProvider, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolRegistry, useSuggestions, useThreads };
6
+ export { CopilotChatDefaultLabels, CopilotKitContext, CopilotKitProvider, RenderToolProvider, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useRenderToolRegistry, useSuggestions, useThreads };
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_RenderToolContext = require('./RenderToolContext-CBNKcJqz.cjs');
3
- const require_useRenderTool = require('./useRenderTool-DLavcsVB.cjs');
3
+ const require_useRenderToolCall = require('./useRenderToolCall-DawGeFfu.cjs');
4
4
  let react = require("react");
5
5
  react = require_RenderToolContext.__toESM(react);
6
6
  let _copilotkit_react_core_v2_context = require("@copilotkit/react-core/v2/context");
@@ -716,7 +716,7 @@ Object.defineProperty(exports, 'CopilotKitContext', {
716
716
  return _copilotkit_react_core_v2_context.CopilotKitContext;
717
717
  }
718
718
  });
719
- exports.CopilotKitProvider = require_useRenderTool.CopilotKitProvider;
719
+ exports.CopilotKitProvider = require_useRenderToolCall.CopilotKitProvider;
720
720
  exports.CopilotModal = CopilotModal;
721
721
  exports.CopilotPopup = CopilotPopup;
722
722
  exports.CopilotSidebar = CopilotSidebar;
@@ -746,12 +746,7 @@ Object.defineProperty(exports, 'useCapabilities', {
746
746
  return _copilotkit_react_core_v2_headless.useCapabilities;
747
747
  }
748
748
  });
749
- Object.defineProperty(exports, 'useComponent', {
750
- enumerable: true,
751
- get: function () {
752
- return _copilotkit_react_core_v2_headless.useComponent;
753
- }
754
- });
749
+ exports.useComponent = require_useRenderToolCall.useComponent;
755
750
  Object.defineProperty(exports, 'useConfigureSuggestions', {
756
751
  enumerable: true,
757
752
  get: function () {
@@ -789,7 +784,8 @@ Object.defineProperty(exports, 'useLicenseContext', {
789
784
  return _copilotkit_react_core_v2_context.useLicenseContext;
790
785
  }
791
786
  });
792
- exports.useRenderTool = require_useRenderTool.useRenderTool;
787
+ exports.useRenderTool = require_useRenderToolCall.useRenderTool;
788
+ exports.useRenderToolCall = require_useRenderToolCall.useRenderToolCall;
793
789
  exports.useRenderToolRegistry = require_RenderToolContext.useRenderToolRegistry;
794
790
  Object.defineProperty(exports, 'useSuggestions', {
795
791
  enumerable: true,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as useRenderToolRegistry, i as RenderToolProvider, n as useRenderTool, o as CopilotKitNativeProviderProps, r as RenderToolProps, s as CopilotKitProvider, t as UseRenderToolOptions } from "./useRenderTool-BugVTDoM.cjs";
2
- import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useSuggestions, useThreads } from "./headless.cjs";
1
+ import { a as UseRenderToolOptions, c as RenderToolProvider, d as CopilotKitProvider, i as useComponent, l as useRenderToolRegistry, n as RenderableToolCall, o as useRenderTool, r as useRenderToolCall, s as RenderToolProps, t as RenderToolCallInput, u as CopilotKitNativeProviderProps } from "./useRenderToolCall-BToS3UWC.cjs";
2
+ import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useSuggestions, useThreads } from "./headless.cjs";
3
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
  import React, { ReactNode } from "react";
5
5
  import { ViewStyle } from "react-native";
@@ -375,5 +375,5 @@ interface CopilotPopupHandle {
375
375
  */
376
376
  declare const CopilotPopup: React.ForwardRefExoticComponent<CopilotPopupProps & React.RefAttributes<CopilotPopupHandle>>;
377
377
  //#endregion
378
- export { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChat, CopilotChatConfigurationValue, type CopilotChatContextValue, CopilotChatDefaultLabels, CopilotChatLabels, type CopilotChatProps, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, CopilotKitNativeProviderProps, CopilotKitNativeProviderProps as CopilotKitProviderProps, CopilotKitProvider, CopilotModal, type CopilotModalProps, CopilotPopup, type CopilotPopupHandle, type CopilotPopupProps, CopilotSidebar, type CopilotSidebarHandle, type CopilotSidebarProps, FrontendTool, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, type NativeAttachmentsConfig, type NativeFileInput, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, RenderToolProvider, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, type UseNativeAttachmentsProps, type UseNativeAttachmentsReturn, UseRenderToolOptions, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatContext, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolRegistry, useSuggestions, useThreads };
378
+ export { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChat, CopilotChatConfigurationValue, type CopilotChatContextValue, CopilotChatDefaultLabels, CopilotChatLabels, type CopilotChatProps, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, CopilotKitNativeProviderProps, CopilotKitNativeProviderProps as CopilotKitProviderProps, CopilotKitProvider, CopilotModal, type CopilotModalProps, CopilotPopup, type CopilotPopupHandle, type CopilotPopupProps, CopilotSidebar, type CopilotSidebarHandle, type CopilotSidebarProps, FrontendTool, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, type NativeAttachmentsConfig, type NativeFileInput, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCallInput, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, RenderToolProvider, RenderableToolCall, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, type UseNativeAttachmentsProps, type UseNativeAttachmentsReturn, UseRenderToolOptions, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatContext, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useRenderToolRegistry, useSuggestions, useThreads };
379
379
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as useRenderToolRegistry, i as RenderToolProvider, n as useRenderTool, o as CopilotKitNativeProviderProps, r as RenderToolProps, s as CopilotKitProvider, t as UseRenderToolOptions } from "./useRenderTool-9YDIfZ0D.mjs";
2
- import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useSuggestions, useThreads } from "./headless.mjs";
1
+ import { a as UseRenderToolOptions, c as RenderToolProvider, d as CopilotKitProvider, i as useComponent, l as useRenderToolRegistry, n as RenderableToolCall, o as useRenderTool, r as useRenderToolCall, s as RenderToolProps, t as RenderToolCallInput, u as CopilotKitNativeProviderProps } from "./useRenderToolCall-DAvPBgpB.mjs";
2
+ import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useSuggestions, useThreads } from "./headless.mjs";
3
3
  import React, { ReactNode } from "react";
4
4
  import { Attachment, AttachmentUploadErrorReason, AttachmentUploadResult } from "@copilotkit/shared";
5
5
  import * as react_jsx_runtime0 from "react/jsx-runtime";
@@ -375,5 +375,5 @@ interface CopilotPopupHandle {
375
375
  */
376
376
  declare const CopilotPopup: React.ForwardRefExoticComponent<CopilotPopupProps & React.RefAttributes<CopilotPopupHandle>>;
377
377
  //#endregion
378
- export { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChat, CopilotChatConfigurationValue, type CopilotChatContextValue, CopilotChatDefaultLabels, CopilotChatLabels, type CopilotChatProps, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, CopilotKitNativeProviderProps, CopilotKitNativeProviderProps as CopilotKitProviderProps, CopilotKitProvider, CopilotModal, type CopilotModalProps, CopilotPopup, type CopilotPopupHandle, type CopilotPopupProps, CopilotSidebar, type CopilotSidebarHandle, type CopilotSidebarProps, FrontendTool, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, type NativeAttachmentsConfig, type NativeFileInput, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, RenderToolProvider, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, type UseNativeAttachmentsProps, type UseNativeAttachmentsReturn, UseRenderToolOptions, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatContext, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolRegistry, useSuggestions, useThreads };
378
+ export { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChat, CopilotChatConfigurationValue, type CopilotChatContextValue, CopilotChatDefaultLabels, CopilotChatLabels, type CopilotChatProps, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, CopilotKitNativeProviderProps, CopilotKitNativeProviderProps as CopilotKitProviderProps, CopilotKitProvider, CopilotModal, type CopilotModalProps, CopilotPopup, type CopilotPopupHandle, type CopilotPopupProps, CopilotSidebar, type CopilotSidebarHandle, type CopilotSidebarProps, FrontendTool, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, type NativeAttachmentsConfig, type NativeFileInput, ReactFrontendTool, ReactHumanInTheLoop, RenderToolCallInput, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, RenderToolProvider, RenderableToolCall, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, type UseNativeAttachmentsProps, type UseNativeAttachmentsReturn, UseRenderToolOptions, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatContext, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useRenderToolRegistry, useSuggestions, useThreads };
379
379
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { r as useRenderToolRegistry, t as RenderToolProvider } from "./RenderToolContext-D8M-JhD1.mjs";
2
- import { n as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-DUqpS97B.mjs";
3
- import { CopilotChatDefaultLabels, CopilotKitContext, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useSuggestions, useThreads } from "./headless.mjs";
2
+ import { i as CopilotKitProvider, n as useComponent, r as useRenderTool, t as useRenderToolCall } from "./useRenderToolCall-DjhQb8Ki.mjs";
3
+ import { CopilotChatDefaultLabels, CopilotKitContext, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useSuggestions, useThreads } from "./headless.mjs";
4
4
  import React, { createContext, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from "react";
5
5
  import { useCopilotKit as useCopilotKit$1 } from "@copilotkit/react-core/v2/context";
6
6
  import { useAgent as useAgent$1 } from "@copilotkit/react-core/v2/headless";
@@ -700,5 +700,5 @@ const styles = StyleSheet.create({
700
700
  });
701
701
 
702
702
  //#endregion
703
- export { CopilotChat, CopilotChatDefaultLabels, CopilotKitContext, CopilotKitProvider, CopilotModal, CopilotPopup, CopilotSidebar, RenderToolProvider, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatContext, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolRegistry, useSuggestions, useThreads };
703
+ export { CopilotChat, CopilotChatDefaultLabels, CopilotKitContext, CopilotKitProvider, CopilotModal, CopilotPopup, CopilotSidebar, RenderToolProvider, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatContext, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useRenderToolRegistry, useSuggestions, useThreads };
704
704
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
- import React, { ReactNode } from "react";
2
- import { DebugConfig, StandardSchemaV1 } from "@copilotkit/shared";
3
1
  import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import React, { ComponentType, ReactElement, ReactNode } from "react";
4
3
  import { CopilotKitCoreErrorCode } from "@copilotkit/core";
4
+ import { DebugConfig, StandardSchemaV1 } from "@copilotkit/shared";
5
5
 
6
6
  //#region src/CopilotKitProvider.d.ts
7
7
  interface CopilotKitNativeProviderProps {
@@ -69,8 +69,21 @@ declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
69
69
  * Props passed to a render tool function.
70
70
  */
71
71
  interface RenderToolProps<T = Record<string, unknown>> {
72
- args: T;
73
- status: "executing" | "complete";
72
+ /**
73
+ * The tool call arguments.
74
+ *
75
+ * While the call is still streaming (`status: "inProgress"`) these are PARTIAL: the model has not
76
+ * finished writing the JSON, so fields arrive progressively and arrays fill in. Renderers must
77
+ * tolerate missing fields — that is what allows UI to build as the agent writes it rather than
78
+ * appearing all at once when the call completes.
79
+ */
80
+ args: Partial<T> & Record<string, unknown>;
81
+ /**
82
+ * "inProgress" — arguments are still streaming; `args` is incomplete.
83
+ * "executing" — arguments are complete and the handler (if any) is running.
84
+ * "complete" — the handler finished; `result` is populated.
85
+ */
86
+ status: "inProgress" | "executing" | "complete";
74
87
  result?: string;
75
88
  }
76
89
  /**
@@ -160,5 +173,78 @@ interface UseRenderToolOptions<T extends Record<string, unknown>> {
160
173
  */
161
174
  declare function useRenderTool<T extends Record<string, unknown> = Record<string, unknown>>(options: UseRenderToolOptions<T>, deps?: ReadonlyArray<unknown>): void;
162
175
  //#endregion
163
- export { useRenderToolRegistry as a, RenderToolProvider as i, useRenderTool as n, CopilotKitNativeProviderProps as o, RenderToolProps as r, CopilotKitProvider as s, UseRenderToolOptions as t };
164
- //# sourceMappingURL=useRenderTool-9YDIfZ0D.d.mts.map
176
+ //#region src/hooks/useComponent.d.ts
177
+ /**
178
+ * Register a component the agent can choose to display — the controlled generative-UI primitive,
179
+ * for React Native.
180
+ *
181
+ * `@copilotkit/react-core` has a `useComponent` of the same shape, but it registers into react-core's
182
+ * own render registry, which this package's renderers do not read. On React Native that meant a
183
+ * component registered with it rendered nowhere: not in `CopilotChat`, and not on a custom surface.
184
+ * This version registers into THIS package's registry, so one registration renders in the chat and
185
+ * anywhere you call `useRenderToolCall()`.
186
+ *
187
+ * Like react-core's, it is render-only: there is no handler, because displaying the component IS the
188
+ * effect. Props are the tool arguments, spread directly, so a component can be used as-is.
189
+ *
190
+ * Arguments stream, so props may be INCOMPLETE on early renders (see `RenderToolProps.args`). Write
191
+ * components that tolerate missing fields — that is what lets UI build as the agent writes it.
192
+ *
193
+ * @example
194
+ * ```tsx
195
+ * useComponent({
196
+ * name: "showWeatherCard",
197
+ * description: "Show the weather for a city.",
198
+ * parameters: z.object({ city: z.string() }),
199
+ * render: ({ city }) => <Text>{city}</Text>,
200
+ * });
201
+ * ```
202
+ */
203
+ declare function useComponent<TSchema extends StandardSchemaV1<unknown, Record<string, unknown>>>(config: {
204
+ /** Tool name the agent calls. */name: string; /** What this component shows, and when the agent should choose it. */
205
+ description?: string; /** Schema for the component's props. */
206
+ parameters: TSchema; /** The component to render. Receives the tool arguments as props. */
207
+ render: ComponentType<any>; /** Scope to a single agent. */
208
+ agentId?: string;
209
+ }, deps?: ReadonlyArray<unknown>): void;
210
+ //#endregion
211
+ //#region src/hooks/useRenderToolCall.d.ts
212
+ /** A tool call as it appears on an assistant message. */
213
+ interface RenderableToolCall {
214
+ id: string;
215
+ function: {
216
+ name: string;
217
+ arguments?: string;
218
+ };
219
+ }
220
+ interface RenderToolCallInput {
221
+ toolCall: RenderableToolCall;
222
+ /** The matching tool result message, when the call has produced one. */
223
+ toolMessage?: {
224
+ content?: string;
225
+ } | undefined;
226
+ }
227
+ /**
228
+ * Render a tool call using the render function registered for it, ANYWHERE in your app.
229
+ *
230
+ * `CopilotChat` renders tool calls inline in its own message list, which is the right default for a
231
+ * chat. But plenty of React Native surfaces are not chats — an in-car stage, a kiosk, a dashboard —
232
+ * and they still want the agent to drive the UI. Without this hook there was no public way to render
233
+ * a registered component outside the chat, which also made `useComponent` unusable on those surfaces.
234
+ *
235
+ * Arguments are partial-JSON-parsed, so a component paints as the agent writes the call
236
+ * (`status: "inProgress"`) and fills in as more arrives — the same progressive behaviour the web
237
+ * renderer has. Renderers therefore need to tolerate incomplete `args`.
238
+ *
239
+ * @example
240
+ * ```tsx
241
+ * const renderToolCall = useRenderToolCall();
242
+ *
243
+ * // panels the agent has called this turn, laid out however you like
244
+ * return <View>{toolCalls.map((tc) => renderToolCall({ toolCall: tc }))}</View>;
245
+ * ```
246
+ */
247
+ declare function useRenderToolCall(): (input: RenderToolCallInput) => ReactElement | null;
248
+ //#endregion
249
+ export { UseRenderToolOptions as a, RenderToolProvider as c, CopilotKitProvider as d, useComponent as i, useRenderToolRegistry as l, RenderableToolCall as n, useRenderTool as o, useRenderToolCall as r, RenderToolProps as s, RenderToolCallInput as t, CopilotKitNativeProviderProps as u };
250
+ //# sourceMappingURL=useRenderToolCall-BToS3UWC.d.cts.map
@@ -1,7 +1,7 @@
1
+ import React, { ComponentType, ReactElement, ReactNode } from "react";
2
+ import { DebugConfig, StandardSchemaV1 } from "@copilotkit/shared";
1
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
2
- import React, { ReactNode } from "react";
3
4
  import { CopilotKitCoreErrorCode } from "@copilotkit/core";
4
- import { DebugConfig, StandardSchemaV1 } from "@copilotkit/shared";
5
5
 
6
6
  //#region src/CopilotKitProvider.d.ts
7
7
  interface CopilotKitNativeProviderProps {
@@ -69,8 +69,21 @@ declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
69
69
  * Props passed to a render tool function.
70
70
  */
71
71
  interface RenderToolProps<T = Record<string, unknown>> {
72
- args: T;
73
- status: "executing" | "complete";
72
+ /**
73
+ * The tool call arguments.
74
+ *
75
+ * While the call is still streaming (`status: "inProgress"`) these are PARTIAL: the model has not
76
+ * finished writing the JSON, so fields arrive progressively and arrays fill in. Renderers must
77
+ * tolerate missing fields — that is what allows UI to build as the agent writes it rather than
78
+ * appearing all at once when the call completes.
79
+ */
80
+ args: Partial<T> & Record<string, unknown>;
81
+ /**
82
+ * "inProgress" — arguments are still streaming; `args` is incomplete.
83
+ * "executing" — arguments are complete and the handler (if any) is running.
84
+ * "complete" — the handler finished; `result` is populated.
85
+ */
86
+ status: "inProgress" | "executing" | "complete";
74
87
  result?: string;
75
88
  }
76
89
  /**
@@ -160,5 +173,78 @@ interface UseRenderToolOptions<T extends Record<string, unknown>> {
160
173
  */
161
174
  declare function useRenderTool<T extends Record<string, unknown> = Record<string, unknown>>(options: UseRenderToolOptions<T>, deps?: ReadonlyArray<unknown>): void;
162
175
  //#endregion
163
- export { useRenderToolRegistry as a, RenderToolProvider as i, useRenderTool as n, CopilotKitNativeProviderProps as o, RenderToolProps as r, CopilotKitProvider as s, UseRenderToolOptions as t };
164
- //# sourceMappingURL=useRenderTool-BugVTDoM.d.cts.map
176
+ //#region src/hooks/useComponent.d.ts
177
+ /**
178
+ * Register a component the agent can choose to display — the controlled generative-UI primitive,
179
+ * for React Native.
180
+ *
181
+ * `@copilotkit/react-core` has a `useComponent` of the same shape, but it registers into react-core's
182
+ * own render registry, which this package's renderers do not read. On React Native that meant a
183
+ * component registered with it rendered nowhere: not in `CopilotChat`, and not on a custom surface.
184
+ * This version registers into THIS package's registry, so one registration renders in the chat and
185
+ * anywhere you call `useRenderToolCall()`.
186
+ *
187
+ * Like react-core's, it is render-only: there is no handler, because displaying the component IS the
188
+ * effect. Props are the tool arguments, spread directly, so a component can be used as-is.
189
+ *
190
+ * Arguments stream, so props may be INCOMPLETE on early renders (see `RenderToolProps.args`). Write
191
+ * components that tolerate missing fields — that is what lets UI build as the agent writes it.
192
+ *
193
+ * @example
194
+ * ```tsx
195
+ * useComponent({
196
+ * name: "showWeatherCard",
197
+ * description: "Show the weather for a city.",
198
+ * parameters: z.object({ city: z.string() }),
199
+ * render: ({ city }) => <Text>{city}</Text>,
200
+ * });
201
+ * ```
202
+ */
203
+ declare function useComponent<TSchema extends StandardSchemaV1<unknown, Record<string, unknown>>>(config: {
204
+ /** Tool name the agent calls. */name: string; /** What this component shows, and when the agent should choose it. */
205
+ description?: string; /** Schema for the component's props. */
206
+ parameters: TSchema; /** The component to render. Receives the tool arguments as props. */
207
+ render: ComponentType<any>; /** Scope to a single agent. */
208
+ agentId?: string;
209
+ }, deps?: ReadonlyArray<unknown>): void;
210
+ //#endregion
211
+ //#region src/hooks/useRenderToolCall.d.ts
212
+ /** A tool call as it appears on an assistant message. */
213
+ interface RenderableToolCall {
214
+ id: string;
215
+ function: {
216
+ name: string;
217
+ arguments?: string;
218
+ };
219
+ }
220
+ interface RenderToolCallInput {
221
+ toolCall: RenderableToolCall;
222
+ /** The matching tool result message, when the call has produced one. */
223
+ toolMessage?: {
224
+ content?: string;
225
+ } | undefined;
226
+ }
227
+ /**
228
+ * Render a tool call using the render function registered for it, ANYWHERE in your app.
229
+ *
230
+ * `CopilotChat` renders tool calls inline in its own message list, which is the right default for a
231
+ * chat. But plenty of React Native surfaces are not chats — an in-car stage, a kiosk, a dashboard —
232
+ * and they still want the agent to drive the UI. Without this hook there was no public way to render
233
+ * a registered component outside the chat, which also made `useComponent` unusable on those surfaces.
234
+ *
235
+ * Arguments are partial-JSON-parsed, so a component paints as the agent writes the call
236
+ * (`status: "inProgress"`) and fills in as more arrives — the same progressive behaviour the web
237
+ * renderer has. Renderers therefore need to tolerate incomplete `args`.
238
+ *
239
+ * @example
240
+ * ```tsx
241
+ * const renderToolCall = useRenderToolCall();
242
+ *
243
+ * // panels the agent has called this turn, laid out however you like
244
+ * return <View>{toolCalls.map((tc) => renderToolCall({ toolCall: tc }))}</View>;
245
+ * ```
246
+ */
247
+ declare function useRenderToolCall(): (input: RenderToolCallInput) => ReactElement | null;
248
+ //#endregion
249
+ export { UseRenderToolOptions as a, RenderToolProvider as c, CopilotKitProvider as d, useComponent as i, useRenderToolRegistry as l, RenderableToolCall as n, useRenderTool as o, useRenderToolCall as r, RenderToolProps as s, RenderToolCallInput as t, CopilotKitNativeProviderProps as u };
250
+ //# sourceMappingURL=useRenderToolCall-DAvPBgpB.d.mts.map
@@ -160,6 +160,91 @@ function useRenderTool(options, deps) {
160
160
  }, [name, register]);
161
161
  }
162
162
 
163
+ //#endregion
164
+ //#region src/hooks/useComponent.tsx
165
+ /**
166
+ * Register a component the agent can choose to display — the controlled generative-UI primitive,
167
+ * for React Native.
168
+ *
169
+ * `@copilotkit/react-core` has a `useComponent` of the same shape, but it registers into react-core's
170
+ * own render registry, which this package's renderers do not read. On React Native that meant a
171
+ * component registered with it rendered nowhere: not in `CopilotChat`, and not on a custom surface.
172
+ * This version registers into THIS package's registry, so one registration renders in the chat and
173
+ * anywhere you call `useRenderToolCall()`.
174
+ *
175
+ * Like react-core's, it is render-only: there is no handler, because displaying the component IS the
176
+ * effect. Props are the tool arguments, spread directly, so a component can be used as-is.
177
+ *
178
+ * Arguments stream, so props may be INCOMPLETE on early renders (see `RenderToolProps.args`). Write
179
+ * components that tolerate missing fields — that is what lets UI build as the agent writes it.
180
+ *
181
+ * @example
182
+ * ```tsx
183
+ * useComponent({
184
+ * name: "showWeatherCard",
185
+ * description: "Show the weather for a city.",
186
+ * parameters: z.object({ city: z.string() }),
187
+ * render: ({ city }) => <Text>{city}</Text>,
188
+ * });
189
+ * ```
190
+ */
191
+ function useComponent(config, deps) {
192
+ const prefix = `Use this tool to display the "${config.name}" component to the user. This tool renders a visual UI component.`;
193
+ const description = config.description ? `${prefix}\n\n${config.description}` : prefix;
194
+ const Component = config.render;
195
+ useRenderTool({
196
+ name: config.name,
197
+ description,
198
+ parameters: config.parameters,
199
+ render: ({ args }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, { ...args }),
200
+ agentId: config.agentId
201
+ }, deps);
202
+ }
203
+
204
+ //#endregion
205
+ //#region src/hooks/useRenderToolCall.ts
206
+ /**
207
+ * Render a tool call using the render function registered for it, ANYWHERE in your app.
208
+ *
209
+ * `CopilotChat` renders tool calls inline in its own message list, which is the right default for a
210
+ * chat. But plenty of React Native surfaces are not chats — an in-car stage, a kiosk, a dashboard —
211
+ * and they still want the agent to drive the UI. Without this hook there was no public way to render
212
+ * a registered component outside the chat, which also made `useComponent` unusable on those surfaces.
213
+ *
214
+ * Arguments are partial-JSON-parsed, so a component paints as the agent writes the call
215
+ * (`status: "inProgress"`) and fills in as more arrives — the same progressive behaviour the web
216
+ * renderer has. Renderers therefore need to tolerate incomplete `args`.
217
+ *
218
+ * @example
219
+ * ```tsx
220
+ * const renderToolCall = useRenderToolCall();
221
+ *
222
+ * // panels the agent has called this turn, laid out however you like
223
+ * return <View>{toolCalls.map((tc) => renderToolCall({ toolCall: tc }))}</View>;
224
+ * ```
225
+ */
226
+ function useRenderToolCall() {
227
+ const toolRenderers = require_RenderToolContext.useRenderToolRegistry();
228
+ const { executingToolCallIds } = (0, _copilotkit_react_core_v2_headless.useCopilotKit)();
229
+ return (0, react.useCallback)(({ toolCall, toolMessage }) => {
230
+ const renderer = toolRenderers.get(toolCall.function.name);
231
+ if (!renderer) return null;
232
+ const raw = toolCall.function.arguments || "{}";
233
+ const args = (0, _copilotkit_shared.partialJSONParse)(raw);
234
+ let argsComplete = true;
235
+ try {
236
+ JSON.parse(raw);
237
+ } catch {
238
+ argsComplete = false;
239
+ }
240
+ return renderer({
241
+ args,
242
+ status: !argsComplete ? "inProgress" : toolMessage !== void 0 ? "complete" : executingToolCallIds?.has(toolCall.id) ? "executing" : "complete",
243
+ result: toolMessage?.content
244
+ });
245
+ }, [toolRenderers, executingToolCallIds]);
246
+ }
247
+
163
248
  //#endregion
164
249
  Object.defineProperty(exports, 'CopilotKitProvider', {
165
250
  enumerable: true,
@@ -167,10 +252,22 @@ Object.defineProperty(exports, 'CopilotKitProvider', {
167
252
  return CopilotKitProvider;
168
253
  }
169
254
  });
255
+ Object.defineProperty(exports, 'useComponent', {
256
+ enumerable: true,
257
+ get: function () {
258
+ return useComponent;
259
+ }
260
+ });
170
261
  Object.defineProperty(exports, 'useRenderTool', {
171
262
  enumerable: true,
172
263
  get: function () {
173
264
  return useRenderTool;
174
265
  }
175
266
  });
176
- //# sourceMappingURL=useRenderTool-DLavcsVB.cjs.map
267
+ Object.defineProperty(exports, 'useRenderToolCall', {
268
+ enumerable: true,
269
+ get: function () {
270
+ return useRenderToolCall;
271
+ }
272
+ });
273
+ //# sourceMappingURL=useRenderToolCall-DawGeFfu.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRenderToolCall-DawGeFfu.cjs","names":["CopilotKitCoreReact","CopilotKitContext","LicenseContext","RenderToolProvider","useRenderToolContext","useRenderToolRegistry"],"sources":["../src/CopilotKitProvider.tsx","../src/hooks/useRenderTool.ts","../src/hooks/useComponent.tsx","../src/hooks/useRenderToolCall.ts"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/v2/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/v2/context\";\nimport { CopilotKitCoreReact } from \"@copilotkit/react-core/v2/headless\";\nimport type { CopilotKitCoreErrorCode } from \"@copilotkit/core\";\nimport type { DebugConfig, RuntimeLicenseStatus } from \"@copilotkit/shared\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { RenderToolProvider } from \"./hooks/RenderToolContext\";\n\nexport interface CopilotKitNativeProviderProps {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Credentials mode for fetch requests (e.g., \"include\" for HTTP-only cookies in cross-origin requests).\n */\n credentials?: RequestCredentials;\n /** Whether the runtime uses a single-route endpoint */\n useSingleEndpoint?: boolean;\n /** Custom properties forwarded to agents */\n properties?: Record<string, unknown>;\n /**\n * Error handler called when CopilotKit encounters an error.\n * Fires for all error types (runtime connection failures, agent errors, tool errors).\n * If not provided, errors are logged to console.error.\n */\n onError?: (event: {\n error: Error;\n code: CopilotKitCoreErrorCode;\n context: Record<string, any>;\n }) => void | Promise<void>;\n /**\n * Enable debug logging for the client-side event pipeline.\n * When `true`, enables verbose logging from the core instance.\n */\n debug?: DebugConfig;\n /**\n * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`\n * subscriptions. Individual subscriptions can override with their own `throttleMs`.\n */\n defaultThrottleMs?: number;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n\n if (copilotkitRef.current === null) {\n const instance: CopilotKitCoreReactInstance = new CopilotKitCoreReact({\n runtimeUrl,\n runtimeTransport:\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n headers: stableHeaders,\n credentials,\n properties: stableProperties,\n debug,\n });\n // Set initial defaultThrottleMs synchronously so child hooks see the\n // correct value on their first render (before useEffect fires).\n if (defaultThrottleMs !== undefined) {\n instance.setDefaultThrottleMs(defaultThrottleMs);\n }\n copilotkitRef.current = instance;\n }\n\n const copilotkit = copilotkitRef.current;\n\n // Sync props to core instance\n useEffect(() => {\n copilotkit.setRuntimeUrl(runtimeUrl);\n copilotkit.setRuntimeTransport(\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n );\n copilotkit.setHeaders(stableHeaders);\n copilotkit.setCredentials(credentials);\n copilotkit.setProperties(stableProperties);\n copilotkit.setDebug(debug);\n }, [\n runtimeUrl,\n useSingleEndpoint,\n stableHeaders,\n credentials,\n stableProperties,\n debug,\n copilotkit,\n ]);\n\n // Sync defaultThrottleMs to the core instance on prop changes.\n // Initial value is set synchronously during instance creation (inside the\n // ref guard above), so this only handles subsequent updates.\n useEffect(() => {\n copilotkit.setDefaultThrottleMs(defaultThrottleMs);\n }, [copilotkit, defaultThrottleMs]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState<\n RuntimeLicenseStatus | undefined\n >(undefined);\n\n // Use ref to avoid subscription churn when onError changes\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n // Single subscription for tool execution tracking and error handling.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n onError: (event) => {\n if (onErrorRef.current) {\n onErrorRef.current(event);\n } else {\n console.error(\n `[CopilotKit] Error (${event.code}):`,\n event.error,\n event.context ?? {},\n );\n }\n },\n onRuntimeConnectionStatusChanged: () => {\n setRuntimeLicenseStatus(copilotkit.licenseStatus);\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <RenderToolProvider>{children}</RenderToolProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n","import { useEffect, useRef } from \"react\";\nimport { useFrontendTool } from \"@copilotkit/react-core/v2/headless\";\nimport type { StandardSchemaV1 } from \"@copilotkit/shared\";\nimport type { RenderToolFunction } from \"./RenderToolContext\";\nimport { useRenderToolContext } from \"./RenderToolContext\";\n\n/**\n * Options for the useRenderTool hook.\n */\nexport interface UseRenderToolOptions<T extends Record<string, unknown>> {\n /** Unique name for the tool. Must match what the agent calls. */\n name: string;\n /** Human-readable description shown to the agent. */\n description: string;\n /**\n * Schema describing the tool's parameters.\n * Accepts any StandardSchemaV1-compatible schema (Zod, Valibot, ArkType, etc.).\n */\n parameters: StandardSchemaV1<unknown, T>;\n /**\n * Render function that returns a React Native element for the tool call.\n * Called by CopilotChat when it encounters a tool call message for this tool.\n *\n * Returns ReactElement | null (not ReactNode) because React Native's\n * FlatList cannot render strings or portals.\n */\n render: RenderToolFunction<T>;\n /**\n * Optional handler executed when the tool is called.\n * If omitted, the tool is render-only (the render function shows UI\n * but the tool returns no result to the agent).\n */\n handler?: (args: T) => Promise<unknown>;\n /**\n * Optional agent ID to scope this tool to a specific agent.\n */\n agentId?: string;\n}\n\n/**\n * Hook that registers a frontend tool AND a render function for it.\n *\n * This bridges `useFrontendTool` (which handles tool registration and\n * handler execution) with a render registry so that CopilotChat can\n * render React Native elements inline when it encounters tool call messages.\n *\n * @example\n * ```tsx\n * useRenderTool({\n * name: \"showWeather\",\n * description: \"Display weather information\",\n * parameters: z.object({ city: z.string(), temp: z.number() }),\n * render: ({ args, status }) => (\n * <View>\n * <Text>{args.city}: {args.temp}</Text>\n * {status === \"executing\" && <ActivityIndicator />}\n * </View>\n * ),\n * handler: async ({ city }) => {\n * return { forecast: \"sunny\" };\n * },\n * });\n * ```\n */\nexport function useRenderTool<\n T extends Record<string, unknown> = Record<string, unknown>,\n>(options: UseRenderToolOptions<T>, deps?: ReadonlyArray<unknown>): void {\n const { name, description, parameters, render, handler, agentId } = options;\n const { register } = useRenderToolContext();\n\n // Register the tool with the core system via useFrontendTool\n useFrontendTool<T>(\n {\n name,\n description,\n parameters,\n handler,\n agentId,\n },\n deps,\n );\n\n // Use a ref so the effect cleanup always has the latest render function\n const renderRef = useRef(render);\n renderRef.current = render;\n\n // Register the render function in the RenderToolContext\n useEffect(() => {\n // Wrap in a stable function that delegates to the ref\n const stableRender: RenderToolFunction<T> = (props) =>\n renderRef.current(props);\n\n const unregister = register(name, stableRender as RenderToolFunction);\n return unregister;\n }, [name, register]);\n}\n","import React from \"react\";\nimport type { ComponentType } from \"react\";\nimport type { StandardSchemaV1 } from \"@copilotkit/shared\";\nimport { useRenderTool } from \"./useRenderTool\";\n\n/**\n * Register a component the agent can choose to display — the controlled generative-UI primitive,\n * for React Native.\n *\n * `@copilotkit/react-core` has a `useComponent` of the same shape, but it registers into react-core's\n * own render registry, which this package's renderers do not read. On React Native that meant a\n * component registered with it rendered nowhere: not in `CopilotChat`, and not on a custom surface.\n * This version registers into THIS package's registry, so one registration renders in the chat and\n * anywhere you call `useRenderToolCall()`.\n *\n * Like react-core's, it is render-only: there is no handler, because displaying the component IS the\n * effect. Props are the tool arguments, spread directly, so a component can be used as-is.\n *\n * Arguments stream, so props may be INCOMPLETE on early renders (see `RenderToolProps.args`). Write\n * components that tolerate missing fields — that is what lets UI build as the agent writes it.\n *\n * @example\n * ```tsx\n * useComponent({\n * name: \"showWeatherCard\",\n * description: \"Show the weather for a city.\",\n * parameters: z.object({ city: z.string() }),\n * render: ({ city }) => <Text>{city}</Text>,\n * });\n * ```\n */\nexport function useComponent<\n TSchema extends StandardSchemaV1<unknown, Record<string, unknown>>,\n>(\n config: {\n /** Tool name the agent calls. */\n name: string;\n /** What this component shows, and when the agent should choose it. */\n description?: string;\n /** Schema for the component's props. */\n parameters: TSchema;\n /** The component to render. Receives the tool arguments as props. */\n render: ComponentType<any>;\n /** Scope to a single agent. */\n agentId?: string;\n },\n deps?: ReadonlyArray<unknown>,\n): void {\n const prefix = `Use this tool to display the \"${config.name}\" component to the user. This tool renders a visual UI component.`;\n const description = config.description\n ? `${prefix}\\n\\n${config.description}`\n : prefix;\n\n const Component = config.render;\n\n useRenderTool(\n {\n name: config.name,\n description,\n parameters: config.parameters,\n // Props are the arguments, spread — the component needs no knowledge of CopilotKit.\n render: ({ args }) => (\n <Component {...(args as Record<string, unknown>)} />\n ),\n agentId: config.agentId,\n },\n deps,\n );\n}\n","import { useCallback } from \"react\";\nimport type { ReactElement } from \"react\";\nimport { partialJSONParse } from \"@copilotkit/shared\";\nimport { useCopilotKit } from \"@copilotkit/react-core/v2/headless\";\nimport { useRenderToolRegistry } from \"./RenderToolContext\";\n\n/** A tool call as it appears on an assistant message. */\nexport interface RenderableToolCall {\n id: string;\n function: { name: string; arguments?: string };\n}\n\nexport interface RenderToolCallInput {\n toolCall: RenderableToolCall;\n /** The matching tool result message, when the call has produced one. */\n toolMessage?: { content?: string } | undefined;\n}\n\n/**\n * Render a tool call using the render function registered for it, ANYWHERE in your app.\n *\n * `CopilotChat` renders tool calls inline in its own message list, which is the right default for a\n * chat. But plenty of React Native surfaces are not chats — an in-car stage, a kiosk, a dashboard —\n * and they still want the agent to drive the UI. Without this hook there was no public way to render\n * a registered component outside the chat, which also made `useComponent` unusable on those surfaces.\n *\n * Arguments are partial-JSON-parsed, so a component paints as the agent writes the call\n * (`status: \"inProgress\"`) and fills in as more arrives — the same progressive behaviour the web\n * renderer has. Renderers therefore need to tolerate incomplete `args`.\n *\n * @example\n * ```tsx\n * const renderToolCall = useRenderToolCall();\n *\n * // panels the agent has called this turn, laid out however you like\n * return <View>{toolCalls.map((tc) => renderToolCall({ toolCall: tc }))}</View>;\n * ```\n */\nexport function useRenderToolCall(): (\n input: RenderToolCallInput,\n) => ReactElement | null {\n // The registry Map, same source CopilotChat renders from — so a component registered once\n // works in the chat and on a custom surface without registering twice.\n const toolRenderers = useRenderToolRegistry();\n const { executingToolCallIds } = useCopilotKit();\n\n return useCallback(\n ({ toolCall, toolMessage }: RenderToolCallInput) => {\n const renderer = toolRenderers.get(toolCall.function.name);\n if (!renderer) return null;\n\n const raw = toolCall.function.arguments || \"{}\";\n const args = partialJSONParse(raw);\n\n // Incomplete JSON means the model is still writing this call.\n let argsComplete = true;\n try {\n JSON.parse(raw);\n } catch {\n argsComplete = false;\n }\n\n const status = !argsComplete\n ? \"inProgress\"\n : toolMessage !== undefined\n ? \"complete\"\n : executingToolCallIds?.has(toolCall.id)\n ? \"executing\"\n : \"complete\";\n\n return renderer({ args, status, result: toolMessage?.content });\n },\n [toolRenderers, executingToolCallIds],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,mBACA,YACA,SACA,OACA,wBACI;CAEJ,MAAM,kBACJ,OAAO,gBAAgB,aAAa,aAAa,GAAG;CAKtD,MAAM,yCACE,mBAAmB,EAAE,EAC3B,CAAC,KAAK,UAAU,gBAAgB,CAAC,CAClC;CAED,MAAM,4CACE,cAAc,EAAE,EACtB,CAAC,KAAK,UAAU,WAAW,CAAC,CAC7B;CAED,MAAM,kCAA2D,KAAK;AAEtE,KAAI,cAAc,YAAY,MAAM;EAClC,MAAM,WAAwC,IAAIA,uDAAoB;GACpE;GACA,kBACE,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA;GACR,SAAS;GACT;GACA,YAAY;GACZ;GACD,CAAC;AAGF,MAAI,sBAAsB,OACxB,UAAS,qBAAqB,kBAAkB;AAElD,gBAAc,UAAU;;CAG1B,MAAM,aAAa,cAAc;AAGjC,4BAAgB;AACd,aAAW,cAAc,WAAW;AACpC,aAAW,oBACT,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA,OACP;AACD,aAAW,WAAW,cAAc;AACpC,aAAW,eAAe,YAAY;AACtC,aAAW,cAAc,iBAAiB;AAC1C,aAAW,SAAS,MAAM;IACzB;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAKF,4BAAgB;AACd,aAAW,qBAAqB,kBAAkB;IACjD,CAAC,YAAY,kBAAkB,CAAC;CAKnC,MAAM,CAAC,sBAAsB,qEAErB,IAAI,KAAK,CAAC;CAElB,MAAM,CAAC,sBAAsB,+CAE3B,OAAU;CAGZ,MAAM,+BAAoB,QAAQ;AAClC,4BAAgB;AACd,aAAW,UAAU;IACpB,CAAC,QAAQ,CAAC;AAKb,4BAAgB;EACd,MAAM,eAAe,WAAW,UAAU;GACxC,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEJ,UAAU,UAAU;AAClB,QAAI,WAAW,QACb,YAAW,QAAQ,MAAM;QAEzB,SAAQ,MACN,uBAAuB,MAAM,KAAK,KAClC,MAAM,OACN,MAAM,WAAW,EAAE,CACpB;;GAGL,wCAAwC;AACtC,4BAAwB,WAAW,cAAc;;GAEpD,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,yCACG;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,iGAC4B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,2CAACC,oDAAkB;EAAS,OAAO;YACjC,2CAACC,iDAAe;GAAS,OAAO;aAC9B,2CAACC,gDAAoB,WAA8B;IAC3B;GACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC5KjC,SAAgB,cAEd,SAAkC,MAAqC;CACvE,MAAM,EAAE,MAAM,aAAa,YAAY,QAAQ,SAAS,YAAY;CACpE,MAAM,EAAE,aAAaC,gDAAsB;AAG3C,yDACE;EACE;EACA;EACA;EACA;EACA;EACD,EACD,KACD;CAGD,MAAM,8BAAmB,OAAO;AAChC,WAAU,UAAU;AAGpB,4BAAgB;EAEd,MAAM,gBAAuC,UAC3C,UAAU,QAAQ,MAAM;AAG1B,SADmB,SAAS,MAAM,aAAmC;IAEpE,CAAC,MAAM,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC/DtB,SAAgB,aAGd,QAYA,MACM;CACN,MAAM,SAAS,iCAAiC,OAAO,KAAK;CAC5D,MAAM,cAAc,OAAO,cACvB,GAAG,OAAO,MAAM,OAAO,gBACvB;CAEJ,MAAM,YAAY,OAAO;AAEzB,eACE;EACE,MAAM,OAAO;EACb;EACA,YAAY,OAAO;EAEnB,SAAS,EAAE,WACT,2CAAC,aAAU,GAAK,OAAoC;EAEtD,SAAS,OAAO;EACjB,EACD,KACD;;;;;;;;;;;;;;;;;;;;;;;;;AC7BH,SAAgB,oBAES;CAGvB,MAAM,gBAAgBC,iDAAuB;CAC7C,MAAM,EAAE,gFAAwC;AAEhD,gCACG,EAAE,UAAU,kBAAuC;EAClD,MAAM,WAAW,cAAc,IAAI,SAAS,SAAS,KAAK;AAC1D,MAAI,CAAC,SAAU,QAAO;EAEtB,MAAM,MAAM,SAAS,SAAS,aAAa;EAC3C,MAAM,gDAAwB,IAAI;EAGlC,IAAI,eAAe;AACnB,MAAI;AACF,QAAK,MAAM,IAAI;UACT;AACN,kBAAe;;AAWjB,SAAO,SAAS;GAAE;GAAM,QART,CAAC,eACZ,eACA,gBAAgB,SACd,aACA,sBAAsB,IAAI,SAAS,GAAG,GACpC,cACA;GAEwB,QAAQ,aAAa;GAAS,CAAC;IAEjE,CAAC,eAAe,qBAAqB,CACtC"}