@copilotkit/react-native 1.70.3 → 1.71.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.
Files changed (33) hide show
  1. package/USAGE.md +76 -5
  2. package/dist/headless.cjs +1 -1
  3. package/dist/headless.d.cts +59 -3
  4. package/dist/headless.d.mts +59 -3
  5. package/dist/headless.mjs +1 -1
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.cts +3 -3
  8. package/dist/index.d.mts +3 -3
  9. package/dist/index.mjs +1 -1
  10. package/dist/useRenderTool-DFz206nL.d.cts +149 -0
  11. package/dist/useRenderTool-DsCxzyAP.d.mts +149 -0
  12. package/dist/useRenderTool-L3Rw6SYD.cjs +298 -0
  13. package/dist/useRenderTool-L3Rw6SYD.cjs.map +1 -0
  14. package/dist/useRenderTool-pLM3upcs.mjs +285 -0
  15. package/dist/useRenderTool-pLM3upcs.mjs.map +1 -0
  16. package/package.json +4 -4
  17. package/src/__mocks__/test-copilotkit.tsx +14 -2
  18. package/src/__tests__/frontend-tool-render.test-d.tsx +148 -0
  19. package/src/__tests__/headless-entry-surface.test.ts +232 -2
  20. package/src/__tests__/headless-value-exports.test.ts +16 -5
  21. package/src/components/__tests__/CopilotChatToolCalls.test.tsx +26 -22
  22. package/src/headless.ts +79 -7
  23. package/src/hooks/__tests__/render-tool-call.integration.test.tsx +17 -15
  24. package/src/hooks/__tests__/useRenderTool.test.tsx +733 -202
  25. package/src/hooks/useRenderTool.ts +482 -49
  26. package/dist/useRenderTool-BBxnOOeJ.d.mts +0 -161
  27. package/dist/useRenderTool-BWo11PCL.d.cts +0 -161
  28. package/dist/useRenderTool-CKEPq7MQ.cjs +0 -162
  29. package/dist/useRenderTool-CKEPq7MQ.cjs.map +0 -1
  30. package/dist/useRenderTool-l7M-I8rT.mjs +0 -149
  31. package/dist/useRenderTool-l7M-I8rT.mjs.map +0 -1
  32. package/src/hooks/index.ts +0 -3
  33. package/src/hooks/render-tool-types.ts +0 -55
package/USAGE.md CHANGED
@@ -17,7 +17,7 @@ import "@copilotkit/react-native/polyfills";
17
17
  import {
18
18
  CopilotKitProvider,
19
19
  CopilotChat,
20
- useRenderTool,
20
+ useFrontendTool,
21
21
  } from "@copilotkit/react-native";
22
22
  import { z } from "zod";
23
23
 
@@ -31,7 +31,7 @@ function App() {
31
31
 
32
32
  function ChatScreen() {
33
33
  // parameters accepts any StandardSchemaV1-compatible schema (Zod, Valibot, ArkType, etc.)
34
- useRenderTool({
34
+ useFrontendTool({
35
35
  name: "showWeather",
36
36
  description: "Show weather info",
37
37
  parameters: z.object({ city: z.string() }),
@@ -93,13 +93,18 @@ import { AssistantMessage, UserMessage } from "@copilotkit/react-native";
93
93
 
94
94
  ## Hooks
95
95
 
96
- ### useRenderTool
96
+ The package re-exports react-core's hooks. The two that draw tool calls are
97
+ worth telling apart.
98
+
99
+ ### useFrontendTool
97
100
 
98
- Register a React Native component to render inline when the agent calls a tool.
101
+ Registers a **tool** and, optionally, its renderer. The tool is advertised to the
102
+ model on every run, so it takes a `description` and (if it should do something on
103
+ the device) a `handler`. Render props carry the parsed arguments as `args`.
99
104
 
100
105
  ```tsx
101
106
  // parameters accepts any StandardSchemaV1-compatible schema (Zod, Valibot, ArkType, etc.)
102
- useRenderTool({
107
+ useFrontendTool({
103
108
  name: "showChart",
104
109
  description: "Display a chart",
105
110
  parameters: z.object({ data: z.record(z.unknown()) }),
@@ -107,6 +112,72 @@ useRenderTool({
107
112
  });
108
113
  ```
109
114
 
115
+ Its `render` is a `React.ComponentType`, so the return type is `ReactNode` and a
116
+ bare string typechecks — then throws _Text strings must be rendered within a
117
+ `<Text>` component_ on a device. `FrontendToolRenderFunction<T>` is an opt-in
118
+ type that narrows the return to `ReactElement | null`; annotate the renderer with
119
+ it and the compiler rejects the string:
120
+
121
+ ```tsx
122
+ import type { FrontendToolRenderFunction } from "@copilotkit/react-native";
123
+
124
+ const renderChart: FrontendToolRenderFunction<{
125
+ data: Record<string, unknown>;
126
+ }> = ({ args }) => <ChartView data={args.data ?? {}} />;
127
+
128
+ useFrontendTool({
129
+ name: "showChart",
130
+ description: "Display a chart",
131
+ parameters: z.object({ data: z.record(z.unknown()) }),
132
+ render: renderChart,
133
+ });
134
+ ```
135
+
136
+ ### useRenderTool
137
+
138
+ Registers a **renderer only** — nothing is advertised to the model and nothing
139
+ becomes callable. Use it to draw a tool call somebody else owns, such as a
140
+ server-side tool. Render props carry the parsed arguments as `parameters`, and
141
+ `parameters` is required on a named renderer. `render` is already narrowed to
142
+ `ReactElement | null` here, so no annotation is needed.
143
+
144
+ ```tsx
145
+ useRenderTool({
146
+ name: "showChart",
147
+ parameters: z.object({ data: z.record(z.unknown()) }),
148
+ render: ({ status, parameters }) => {
149
+ // `parameters` is Partial while the agent is still writing the call.
150
+ if (status === "inProgress") return <Text>Preparing…</Text>;
151
+ return <ChartView data={parameters.data} />;
152
+ },
153
+ });
154
+ ```
155
+
156
+ `name: "*"` registers a fallback for every tool call with no renderer of its own,
157
+ and is the one case that takes no schema:
158
+
159
+ ```tsx
160
+ useRenderTool({
161
+ name: "*",
162
+ render: ({ name, status }) => <Text>{`${name}: ${status}`}</Text>,
163
+ });
164
+ ```
165
+
166
+ **Deprecated on React Native, for one release.** React Native used to export a
167
+ _different_ hook under this name — one that registered a tool as well as a
168
+ renderer — so `useRenderTool` here is currently a compatibility shim over both
169
+ react-core hooks, scheduled for removal in the next minor. Your existing call
170
+ still works: `name: "*"` always registers a renderer only, and any other name
171
+ carrying `description` or `handler` is routed to `useFrontendTool` the way the
172
+ old hook did. Either way it warns in development (dev only, once per tool name)
173
+ and tells you what to rename the call to. One thing does not carry over: on a
174
+ named renderer the render props are `parameters`, not `args`, so a typed
175
+ `render: ({ args }) => …` fails with `TS2339` (the wildcard's props are untyped,
176
+ so it still compiles there).
177
+
178
+ See the [`useRenderTool` reference](https://docs.copilotkit.ai/reference/react-native/hooks/useRenderTool)
179
+ for the routing rules, the warnings, and the full migration table.
180
+
110
181
  ## Alternative Import Path
111
182
 
112
183
  Components can also be imported from the `/components` subpath:
package/dist/headless.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_chunk = require('./chunk-C0xms8kb.cjs');
3
3
  require('./polyfills.cjs');
4
- const require_useRenderTool = require('./useRenderTool-CKEPq7MQ.cjs');
4
+ const require_useRenderTool = require('./useRenderTool-L3Rw6SYD.cjs');
5
5
  let _copilotkit_react_core_v2_context = require("@copilotkit/react-core/v2/context");
6
6
  let _copilotkit_react_core_v2_headless = require("@copilotkit/react-core/v2/headless");
7
7
  let _copilotkit_core = require("@copilotkit/core");
@@ -1,6 +1,62 @@
1
- import { a as CopilotKitNativeProviderProps, i as RenderToolProps, n as useRenderTool, o as CopilotKitProvider, r as RenderToolFunction, t as UseRenderToolOptions } from "./useRenderTool-BWo11PCL.cjs";
1
+ import { n as CopilotKitNativeProviderProps, r as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-DFz206nL.cjs";
2
+ import React from "react";
3
+ import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, ReactToolCallRenderer as ReactToolCallRenderer$1, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderToolCall, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
2
4
  import { CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Suggestion, ToolCallStatus } from "@copilotkit/core";
3
5
  import { CopilotKitContext, CopilotKitContextValue, useCopilotKit, useLicenseContext } from "@copilotkit/react-core/v2/context";
4
- import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderToolCall, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
5
6
  import { AbstractAgent, AgentCapabilities, AssistantMessage as AssistantMessageType, Message, ToolCall, ToolMessage } from "@ag-ui/client";
6
- export { AbstractAgent, type AgentCapabilities, type AgentContextInput, type AssistantMessageType, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitContext, type CopilotKitContextValue, CopilotKitCoreErrorCode, 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 ReactToolCallRenderer, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolFunction, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Suggestion, type Thread, type ToolCall, ToolCallStatus, type ToolMessage, UseAgentUpdate, type UseInterruptConfig, type UseRenderToolOptions, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
7
+
8
+ //#region src/headless.d.ts
9
+ /**
10
+ * A tool-call render function whose return type is narrowed to React Native's
11
+ * `ReactElement | null`. Annotate a `useFrontendTool` renderer with it to have
12
+ * the compiler reject a return React Native cannot draw.
13
+ *
14
+ * `useFrontendTool`'s `render` is `ReactToolCallRenderer<T>["render"]`, i.e. a
15
+ * `React.ComponentType`, so it returns `ReactNode` — which means
16
+ * `render: ({ args }) => \`Weather in ${args.city}\`` typechecks and then throws
17
+ * *Text strings must be rendered within a `<Text>` component* on a device. This
18
+ * type is what rejects it at `check-types` instead. (core's `useRenderTool`
19
+ * already declares its own `render` as `ReactElement | null`, so the gap is
20
+ * `useFrontendTool`'s.)
21
+ *
22
+ * OPT-IN, and only that. It changes no hook signature: a renderer written
23
+ * inline in a `useFrontendTool` call is still checked against core's
24
+ * `ReactNode`-returning contract, and a bare string still compiles there. This
25
+ * type gives the narrowing back on renderers you annotate; it does not make the
26
+ * package safe.
27
+ *
28
+ * DERIVED from core's canonical `ReactToolCallRenderer` contract rather than
29
+ * declared separately: the props come from it unchanged through
30
+ * `React.ComponentProps`, and only the return type is React Native's. That is
31
+ * deliberate — the last time this package declared its own render-prop shape it
32
+ * drifted from the contract (`{ args: T; status: "executing" | "complete";
33
+ * result?: string }`: no `name`, no `toolCallId`, no in-progress arm, and `args`
34
+ * unconditionally complete). Deriving means a change to the contract changes
35
+ * this type with it, and `check-types` names every renderer that breaks.
36
+ *
37
+ * @typeParam T - The parsed tool arguments; the same `T` as `useFrontendTool`'s.
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * import { useFrontendTool } from "@copilotkit/react-native/headless";
42
+ * import type { FrontendToolRenderFunction } from "@copilotkit/react-native/headless";
43
+ * import { Text } from "react-native";
44
+ * import { z } from "zod";
45
+ *
46
+ * const renderWeather: FrontendToolRenderFunction<{ city: string }> = ({
47
+ * args,
48
+ * }) => <Text>{args.city}</Text>;
49
+ *
50
+ * useFrontendTool({
51
+ * name: "showWeather",
52
+ * description: "Show the weather",
53
+ * parameters: z.object({ city: z.string() }),
54
+ * handler: async ({ city }) => city,
55
+ * render: renderWeather,
56
+ * });
57
+ * ```
58
+ */
59
+ type FrontendToolRenderFunction<T extends Record<string, unknown> = Record<string, unknown>> = (props: React.ComponentProps<ReactToolCallRenderer$1<T>["render"]>) => React.ReactElement | null;
60
+ //#endregion
61
+ export { AbstractAgent, type AgentCapabilities, type AgentContextInput, type AssistantMessageType, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitContext, type CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, type CopilotKitNativeProviderProps, type CopilotKitNativeProviderProps as CopilotKitProviderProps, CopilotKitProvider, type FrontendTool, FrontendToolRenderFunction, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type Message, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Suggestion, type Thread, type ToolCall, ToolCallStatus, type ToolMessage, UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
62
+ //# sourceMappingURL=headless.d.cts.map
@@ -1,6 +1,62 @@
1
- import { a as CopilotKitNativeProviderProps, i as RenderToolProps, n as useRenderTool, o as CopilotKitProvider, r as RenderToolFunction, t as UseRenderToolOptions } from "./useRenderTool-BBxnOOeJ.mjs";
1
+ import { n as CopilotKitNativeProviderProps, r as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-DsCxzyAP.mjs";
2
+ import React from "react";
2
3
  import { CopilotKitContext, CopilotKitContextValue, useCopilotKit, useLicenseContext } from "@copilotkit/react-core/v2/context";
3
- import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderToolCall, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
4
+ import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, ReactToolCallRenderer as ReactToolCallRenderer$1, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderToolCall, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
4
5
  import { CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Suggestion, ToolCallStatus } from "@copilotkit/core";
5
6
  import { AbstractAgent, AgentCapabilities, AssistantMessage as AssistantMessageType, Message, ToolCall, ToolMessage } from "@ag-ui/client";
6
- export { AbstractAgent, type AgentCapabilities, type AgentContextInput, type AssistantMessageType, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitContext, type CopilotKitContextValue, CopilotKitCoreErrorCode, 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 ReactToolCallRenderer, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolFunction, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Suggestion, type Thread, type ToolCall, ToolCallStatus, type ToolMessage, UseAgentUpdate, type UseInterruptConfig, type UseRenderToolOptions, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
7
+
8
+ //#region src/headless.d.ts
9
+ /**
10
+ * A tool-call render function whose return type is narrowed to React Native's
11
+ * `ReactElement | null`. Annotate a `useFrontendTool` renderer with it to have
12
+ * the compiler reject a return React Native cannot draw.
13
+ *
14
+ * `useFrontendTool`'s `render` is `ReactToolCallRenderer<T>["render"]`, i.e. a
15
+ * `React.ComponentType`, so it returns `ReactNode` — which means
16
+ * `render: ({ args }) => \`Weather in ${args.city}\`` typechecks and then throws
17
+ * *Text strings must be rendered within a `<Text>` component* on a device. This
18
+ * type is what rejects it at `check-types` instead. (core's `useRenderTool`
19
+ * already declares its own `render` as `ReactElement | null`, so the gap is
20
+ * `useFrontendTool`'s.)
21
+ *
22
+ * OPT-IN, and only that. It changes no hook signature: a renderer written
23
+ * inline in a `useFrontendTool` call is still checked against core's
24
+ * `ReactNode`-returning contract, and a bare string still compiles there. This
25
+ * type gives the narrowing back on renderers you annotate; it does not make the
26
+ * package safe.
27
+ *
28
+ * DERIVED from core's canonical `ReactToolCallRenderer` contract rather than
29
+ * declared separately: the props come from it unchanged through
30
+ * `React.ComponentProps`, and only the return type is React Native's. That is
31
+ * deliberate — the last time this package declared its own render-prop shape it
32
+ * drifted from the contract (`{ args: T; status: "executing" | "complete";
33
+ * result?: string }`: no `name`, no `toolCallId`, no in-progress arm, and `args`
34
+ * unconditionally complete). Deriving means a change to the contract changes
35
+ * this type with it, and `check-types` names every renderer that breaks.
36
+ *
37
+ * @typeParam T - The parsed tool arguments; the same `T` as `useFrontendTool`'s.
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * import { useFrontendTool } from "@copilotkit/react-native/headless";
42
+ * import type { FrontendToolRenderFunction } from "@copilotkit/react-native/headless";
43
+ * import { Text } from "react-native";
44
+ * import { z } from "zod";
45
+ *
46
+ * const renderWeather: FrontendToolRenderFunction<{ city: string }> = ({
47
+ * args,
48
+ * }) => <Text>{args.city}</Text>;
49
+ *
50
+ * useFrontendTool({
51
+ * name: "showWeather",
52
+ * description: "Show the weather",
53
+ * parameters: z.object({ city: z.string() }),
54
+ * handler: async ({ city }) => city,
55
+ * render: renderWeather,
56
+ * });
57
+ * ```
58
+ */
59
+ type FrontendToolRenderFunction<T extends Record<string, unknown> = Record<string, unknown>> = (props: React.ComponentProps<ReactToolCallRenderer$1<T>["render"]>) => React.ReactElement | null;
60
+ //#endregion
61
+ export { AbstractAgent, type AgentCapabilities, type AgentContextInput, type AssistantMessageType, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitContext, type CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, type CopilotKitNativeProviderProps, type CopilotKitNativeProviderProps as CopilotKitProviderProps, CopilotKitProvider, type FrontendTool, FrontendToolRenderFunction, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type Message, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Suggestion, type Thread, type ToolCall, ToolCallStatus, type ToolMessage, UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
62
+ //# sourceMappingURL=headless.d.mts.map
package/dist/headless.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./polyfills.mjs";
2
- import { n as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-l7M-I8rT.mjs";
2
+ import { n as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-pLM3upcs.mjs";
3
3
  import { CopilotKitContext, useCopilotKit, useLicenseContext } from "@copilotkit/react-core/v2/context";
4
4
  import { CopilotChatDefaultLabels, UseAgentUpdate, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderToolCall, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
5
5
  import { CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus } from "@copilotkit/core";
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_chunk = require('./chunk-C0xms8kb.cjs');
3
- const require_useRenderTool = require('./useRenderTool-CKEPq7MQ.cjs');
3
+ const require_useRenderTool = require('./useRenderTool-L3Rw6SYD.cjs');
4
4
  require('./headless.cjs');
5
5
  let react = require("react");
6
6
  react = require_chunk.__toESM(react);
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as CopilotKitNativeProviderProps, i as RenderToolProps, n as useRenderTool, o as CopilotKitProvider, r as RenderToolFunction, t as UseRenderToolOptions } from "./useRenderTool-BWo11PCL.cjs";
2
- import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, 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, useRenderToolCall, useSuggestions, useThreads } from "./headless.cjs";
1
+ import { n as CopilotKitNativeProviderProps, r as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-DFz206nL.cjs";
2
+ import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, FrontendToolRenderFunction, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderToolCall, 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, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolFunction, RenderToolInProgressProps, RenderToolProps, 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, 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, FrontendToolRenderFunction, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, type NativeAttachmentsConfig, type NativeFileInput, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, type UseNativeAttachmentsProps, type UseNativeAttachmentsReturn, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatContext, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
379
379
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as CopilotKitNativeProviderProps, i as RenderToolProps, n as useRenderTool, o as CopilotKitProvider, r as RenderToolFunction, t as UseRenderToolOptions } from "./useRenderTool-BBxnOOeJ.mjs";
2
- import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, 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, useRenderToolCall, useSuggestions, useThreads } from "./headless.mjs";
1
+ import { n as CopilotKitNativeProviderProps, r as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-DsCxzyAP.mjs";
2
+ import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, FrontendToolRenderFunction, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderToolCall, 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, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolFunction, RenderToolInProgressProps, RenderToolProps, 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, 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, FrontendToolRenderFunction, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, type NativeAttachmentsConfig, type NativeFileInput, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, type UseNativeAttachmentsProps, type UseNativeAttachmentsReturn, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useAttachments, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatContext, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
379
379
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-l7M-I8rT.mjs";
1
+ import { n as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-pLM3upcs.mjs";
2
2
  import { AbstractAgent, CopilotChatDefaultLabels, CopilotKitContext, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus, UseAgentUpdate, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderToolCall, useSuggestions, useThreads } from "./headless.mjs";
3
3
  import React, { createContext, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from "react";
4
4
  import { useCopilotKit as useCopilotKit$1 } from "@copilotkit/react-core/v2/context";
@@ -0,0 +1,149 @@
1
+ import React$1, { ReactNode } from "react";
2
+ import { RenderToolProps } from "@copilotkit/react-core/v2/headless";
3
+ import { CopilotKitCoreErrorCode, FrontendToolHandlerContext } from "@copilotkit/core";
4
+ import { DebugConfig, InferSchemaOutput, StandardSchemaV1 } from "@copilotkit/shared";
5
+
6
+ //#region src/CopilotKitProvider.d.ts
7
+ interface CopilotKitNativeProviderProps {
8
+ children: ReactNode;
9
+ /** URL of the CopilotKit runtime endpoint */
10
+ runtimeUrl: string;
11
+ /** Custom headers sent with every request */
12
+ headers?: Record<string, string> | (() => Record<string, string>);
13
+ /**
14
+ * Credentials mode for fetch requests (e.g., "include" for HTTP-only cookies in cross-origin requests).
15
+ */
16
+ credentials?: RequestCredentials;
17
+ /** Whether the runtime uses a single-route endpoint */
18
+ useSingleEndpoint?: boolean;
19
+ /** Custom properties forwarded to agents */
20
+ properties?: Record<string, unknown>;
21
+ /**
22
+ * Error handler called when CopilotKit encounters an error.
23
+ * Fires for all error types (runtime connection failures, agent errors, tool errors).
24
+ * If not provided, errors are logged to console.error.
25
+ */
26
+ onError?: (event: {
27
+ error: Error;
28
+ code: CopilotKitCoreErrorCode;
29
+ context: Record<string, any>;
30
+ }) => void | Promise<void>;
31
+ /**
32
+ * Enable debug logging for the client-side event pipeline.
33
+ * When `true`, enables verbose logging from the core instance.
34
+ */
35
+ debug?: DebugConfig;
36
+ /**
37
+ * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`
38
+ * subscriptions. Individual subscriptions can override with their own `throttleMs`.
39
+ */
40
+ defaultThrottleMs?: number;
41
+ }
42
+ /**
43
+ * CopilotKit provider for React Native.
44
+ *
45
+ * A lightweight alternative to the web CopilotKitProvider that avoids
46
+ * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
47
+ *
48
+ * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
49
+ * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
50
+ * required (though it remains available for advanced use).
51
+ *
52
+ * Usage:
53
+ * ```tsx
54
+ * import { CopilotKitProvider } from "@copilotkit/react-native";
55
+ *
56
+ * function App() {
57
+ * return (
58
+ * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
59
+ * <ChatScreen />
60
+ * </CopilotKitProvider>
61
+ * );
62
+ * }
63
+ * ```
64
+ */
65
+ declare const CopilotKitProvider: React$1.FC<CopilotKitNativeProviderProps>;
66
+ //#endregion
67
+ //#region src/hooks/useRenderTool.d.ts
68
+ /**
69
+ * Fields the OLD React Native hook accepted, kept optional here so the call
70
+ * shapes the compiler cannot see (hoisted / spread / untyped) still type-check
71
+ * and get routed rather than silently dropped.
72
+ *
73
+ * @typeParam A - The parsed argument type a legacy `handler` receives.
74
+ */
75
+ interface LegacyToolFields<A> {
76
+ /**
77
+ * @deprecated A description is a TOOL field: it is what gets advertised to
78
+ * the model. Supplying it routes this call to `useFrontendTool` — rename the
79
+ * call to `useFrontendTool` instead.
80
+ */
81
+ description?: string;
82
+ /**
83
+ * @deprecated A handler is a TOOL field: it is what the model's call
84
+ * executes. Supplying it routes this call to `useFrontendTool` — rename the
85
+ * call to `useFrontendTool` instead. Note that core's handler receives a
86
+ * SECOND argument (the {@link FrontendToolHandlerContext}, carrying
87
+ * `stopAgent()`'s abort signal), which the old React Native hook dropped.
88
+ */
89
+ handler?: (args: A, context: FrontendToolHandlerContext) => Promise<unknown>;
90
+ }
91
+ /** The wildcard call shape: a fallback renderer for every unclaimed tool call. */
92
+ type WildcardConfig = {
93
+ name: "*";
94
+ render: (props: any) => React.ReactElement | null;
95
+ agentId?: string;
96
+ } & LegacyToolFields<Record<string, unknown>> & {
97
+ /**
98
+ * @deprecated A wildcard renderer paints tool calls it does not own, so it
99
+ * has no schema of its own — core's wildcard path ignores this. Remove it.
100
+ */
101
+ parameters?: StandardSchemaV1;
102
+ };
103
+ /** The name-scoped call shape. */
104
+ type NamedConfig<S extends StandardSchemaV1> = {
105
+ name: string;
106
+ parameters: S;
107
+ render: (props: RenderToolProps<S>) => React.ReactElement | null;
108
+ agentId?: string;
109
+ } & LegacyToolFields<InferSchemaOutput<S>>;
110
+ /**
111
+ * TEST-ONLY escape hatch for the per-name dedup above.
112
+ *
113
+ * Not re-exported from any package entry (`src/headless.ts` exports only the
114
+ * hook), so it is not public API. It exists because the dedup key is the tool
115
+ * NAME and lives for the lifetime of the module: the wildcard's name is the
116
+ * same `"*"` for every caller, so without this the second test to assert the
117
+ * wildcard's warning would silently observe zero calls and have to be written
118
+ * order-dependently instead.
119
+ */
120
+ /**
121
+ * Registers a wildcard (`"*"`) renderer for tool calls.
122
+ *
123
+ * @deprecated Use `useRenderTool` from `@copilotkit/react-core` (re-exported by
124
+ * `@copilotkit/react-native/headless` once this shim is gone) for a
125
+ * renderer-only registration, or `useFrontendTool` to register a tool and its
126
+ * renderer together. This shim is scheduled for removal in the next minor.
127
+ *
128
+ * @param config - Wildcard renderer configuration.
129
+ * @param deps - Optional dependencies to refresh registration.
130
+ */
131
+ declare function useRenderTool(config: WildcardConfig, deps?: ReadonlyArray<unknown>): void;
132
+ /**
133
+ * Registers a name-scoped renderer for tool calls — or, if `description` or
134
+ * `handler` is supplied, a frontend tool and its renderer (what the old React
135
+ * Native hook did), with a development warning.
136
+ *
137
+ * @deprecated Use `useRenderTool` from `@copilotkit/react-core` (re-exported by
138
+ * `@copilotkit/react-native/headless` once this shim is gone) for a
139
+ * renderer-only registration, or `useFrontendTool` to register a tool and its
140
+ * renderer together. This shim is scheduled for removal in the next minor.
141
+ *
142
+ * @typeParam S - Schema type describing tool call parameters.
143
+ * @param config - Named renderer configuration.
144
+ * @param deps - Optional dependencies to refresh registration.
145
+ */
146
+ declare function useRenderTool<S extends StandardSchemaV1>(config: NamedConfig<S>, deps?: ReadonlyArray<unknown>): void;
147
+ //#endregion
148
+ export { CopilotKitNativeProviderProps as n, CopilotKitProvider as r, useRenderTool as t };
149
+ //# sourceMappingURL=useRenderTool-DFz206nL.d.cts.map
@@ -0,0 +1,149 @@
1
+ import React$1, { ReactNode } from "react";
2
+ import { RenderToolProps } from "@copilotkit/react-core/v2/headless";
3
+ import { DebugConfig, InferSchemaOutput, StandardSchemaV1 } from "@copilotkit/shared";
4
+ import { CopilotKitCoreErrorCode, FrontendToolHandlerContext } from "@copilotkit/core";
5
+
6
+ //#region src/CopilotKitProvider.d.ts
7
+ interface CopilotKitNativeProviderProps {
8
+ children: ReactNode;
9
+ /** URL of the CopilotKit runtime endpoint */
10
+ runtimeUrl: string;
11
+ /** Custom headers sent with every request */
12
+ headers?: Record<string, string> | (() => Record<string, string>);
13
+ /**
14
+ * Credentials mode for fetch requests (e.g., "include" for HTTP-only cookies in cross-origin requests).
15
+ */
16
+ credentials?: RequestCredentials;
17
+ /** Whether the runtime uses a single-route endpoint */
18
+ useSingleEndpoint?: boolean;
19
+ /** Custom properties forwarded to agents */
20
+ properties?: Record<string, unknown>;
21
+ /**
22
+ * Error handler called when CopilotKit encounters an error.
23
+ * Fires for all error types (runtime connection failures, agent errors, tool errors).
24
+ * If not provided, errors are logged to console.error.
25
+ */
26
+ onError?: (event: {
27
+ error: Error;
28
+ code: CopilotKitCoreErrorCode;
29
+ context: Record<string, any>;
30
+ }) => void | Promise<void>;
31
+ /**
32
+ * Enable debug logging for the client-side event pipeline.
33
+ * When `true`, enables verbose logging from the core instance.
34
+ */
35
+ debug?: DebugConfig;
36
+ /**
37
+ * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`
38
+ * subscriptions. Individual subscriptions can override with their own `throttleMs`.
39
+ */
40
+ defaultThrottleMs?: number;
41
+ }
42
+ /**
43
+ * CopilotKit provider for React Native.
44
+ *
45
+ * A lightweight alternative to the web CopilotKitProvider that avoids
46
+ * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
47
+ *
48
+ * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
49
+ * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
50
+ * required (though it remains available for advanced use).
51
+ *
52
+ * Usage:
53
+ * ```tsx
54
+ * import { CopilotKitProvider } from "@copilotkit/react-native";
55
+ *
56
+ * function App() {
57
+ * return (
58
+ * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
59
+ * <ChatScreen />
60
+ * </CopilotKitProvider>
61
+ * );
62
+ * }
63
+ * ```
64
+ */
65
+ declare const CopilotKitProvider: React$1.FC<CopilotKitNativeProviderProps>;
66
+ //#endregion
67
+ //#region src/hooks/useRenderTool.d.ts
68
+ /**
69
+ * Fields the OLD React Native hook accepted, kept optional here so the call
70
+ * shapes the compiler cannot see (hoisted / spread / untyped) still type-check
71
+ * and get routed rather than silently dropped.
72
+ *
73
+ * @typeParam A - The parsed argument type a legacy `handler` receives.
74
+ */
75
+ interface LegacyToolFields<A> {
76
+ /**
77
+ * @deprecated A description is a TOOL field: it is what gets advertised to
78
+ * the model. Supplying it routes this call to `useFrontendTool` — rename the
79
+ * call to `useFrontendTool` instead.
80
+ */
81
+ description?: string;
82
+ /**
83
+ * @deprecated A handler is a TOOL field: it is what the model's call
84
+ * executes. Supplying it routes this call to `useFrontendTool` — rename the
85
+ * call to `useFrontendTool` instead. Note that core's handler receives a
86
+ * SECOND argument (the {@link FrontendToolHandlerContext}, carrying
87
+ * `stopAgent()`'s abort signal), which the old React Native hook dropped.
88
+ */
89
+ handler?: (args: A, context: FrontendToolHandlerContext) => Promise<unknown>;
90
+ }
91
+ /** The wildcard call shape: a fallback renderer for every unclaimed tool call. */
92
+ type WildcardConfig = {
93
+ name: "*";
94
+ render: (props: any) => React.ReactElement | null;
95
+ agentId?: string;
96
+ } & LegacyToolFields<Record<string, unknown>> & {
97
+ /**
98
+ * @deprecated A wildcard renderer paints tool calls it does not own, so it
99
+ * has no schema of its own — core's wildcard path ignores this. Remove it.
100
+ */
101
+ parameters?: StandardSchemaV1;
102
+ };
103
+ /** The name-scoped call shape. */
104
+ type NamedConfig<S extends StandardSchemaV1> = {
105
+ name: string;
106
+ parameters: S;
107
+ render: (props: RenderToolProps<S>) => React.ReactElement | null;
108
+ agentId?: string;
109
+ } & LegacyToolFields<InferSchemaOutput<S>>;
110
+ /**
111
+ * TEST-ONLY escape hatch for the per-name dedup above.
112
+ *
113
+ * Not re-exported from any package entry (`src/headless.ts` exports only the
114
+ * hook), so it is not public API. It exists because the dedup key is the tool
115
+ * NAME and lives for the lifetime of the module: the wildcard's name is the
116
+ * same `"*"` for every caller, so without this the second test to assert the
117
+ * wildcard's warning would silently observe zero calls and have to be written
118
+ * order-dependently instead.
119
+ */
120
+ /**
121
+ * Registers a wildcard (`"*"`) renderer for tool calls.
122
+ *
123
+ * @deprecated Use `useRenderTool` from `@copilotkit/react-core` (re-exported by
124
+ * `@copilotkit/react-native/headless` once this shim is gone) for a
125
+ * renderer-only registration, or `useFrontendTool` to register a tool and its
126
+ * renderer together. This shim is scheduled for removal in the next minor.
127
+ *
128
+ * @param config - Wildcard renderer configuration.
129
+ * @param deps - Optional dependencies to refresh registration.
130
+ */
131
+ declare function useRenderTool$1(config: WildcardConfig, deps?: ReadonlyArray<unknown>): void;
132
+ /**
133
+ * Registers a name-scoped renderer for tool calls — or, if `description` or
134
+ * `handler` is supplied, a frontend tool and its renderer (what the old React
135
+ * Native hook did), with a development warning.
136
+ *
137
+ * @deprecated Use `useRenderTool` from `@copilotkit/react-core` (re-exported by
138
+ * `@copilotkit/react-native/headless` once this shim is gone) for a
139
+ * renderer-only registration, or `useFrontendTool` to register a tool and its
140
+ * renderer together. This shim is scheduled for removal in the next minor.
141
+ *
142
+ * @typeParam S - Schema type describing tool call parameters.
143
+ * @param config - Named renderer configuration.
144
+ * @param deps - Optional dependencies to refresh registration.
145
+ */
146
+ declare function useRenderTool$1<S extends StandardSchemaV1>(config: NamedConfig<S>, deps?: ReadonlyArray<unknown>): void;
147
+ //#endregion
148
+ export { CopilotKitNativeProviderProps as n, CopilotKitProvider as r, useRenderTool$1 as t };
149
+ //# sourceMappingURL=useRenderTool-DsCxzyAP.d.mts.map