@copilotkit/react-native 1.63.2-canary.1784918757 → 1.63.3-canary.rc-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.
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @copilotkit/react-native/headless
3
+ *
4
+ * Lean entry for headless React Native consumers: just the provider and the
5
+ * platform-agnostic agent/tool hooks, with NONE of the prebuilt chat UI.
6
+ *
7
+ * The default barrel (`@copilotkit/react-native`) re-exports the prebuilt chat
8
+ * components (`CopilotChat` / `CopilotModal` / `CopilotSidebar` / `CopilotPopup`,
9
+ * which import `@gorhom/bottom-sheet`) and `useAttachments` (which imports
10
+ * `expo-document-picker` + `expo-file-system`). Those are declared as optional
11
+ * peer dependencies, but a static re-export still forces Metro to resolve them
12
+ * at bundle time — so a consumer that only uses `CopilotKitProvider` + `useAgent`
13
+ * + `useFrontendTool` (a fully custom UI) had to install every chat/attachment
14
+ * native dep or stub them in `metro.config.js`, or the release bundle fails with
15
+ * `Unable to resolve module expo-document-picker`.
16
+ *
17
+ * Import from here to skip that stack entirely:
18
+ * ```tsx
19
+ * import { CopilotKitProvider, useAgent, useFrontendTool } from "@copilotkit/react-native/headless";
20
+ * ```
21
+ *
22
+ * Mirrors `@copilotkit/react-core/v2/headless` (issue #4893 / PR #5883), which
23
+ * this entry builds on. The default barrel re-exports everything here plus the
24
+ * chat UI, so existing imports from `@copilotkit/react-native` are unchanged.
25
+ */
26
+
27
+ // Auto-install polyfills so consumers don't need a manual import.
28
+ // Must run before any CopilotKit code that relies on ReadableStream / fetch streaming.
29
+ import "./polyfills";
30
+
31
+ // React Native provider (no web deps, no bottom-sheet, no expo native modules)
32
+ export { CopilotKitProvider } from "./CopilotKitProvider";
33
+ export type { CopilotKitNativeProviderProps } from "./CopilotKitProvider";
34
+
35
+ // Provider props alias (mirrors web's CopilotKitProviderProps)
36
+ export type { CopilotKitNativeProviderProps as CopilotKitProviderProps } from "./CopilotKitProvider";
37
+
38
+ // Re-export context and hooks from react-core (platform-agnostic)
39
+ export {
40
+ useCopilotKit,
41
+ useLicenseContext,
42
+ CopilotKitContext,
43
+ type CopilotKitContextValue,
44
+ } from "@copilotkit/react-core/v2/context";
45
+
46
+ // Re-export hooks that work without web deps
47
+ // These consume the CopilotKitContext which our provider sets
48
+ export {
49
+ useAgent,
50
+ useFrontendTool,
51
+ useComponent,
52
+ useHumanInTheLoop,
53
+ useInterrupt,
54
+ useSuggestions,
55
+ useConfigureSuggestions,
56
+ useAgentContext,
57
+ useThreads,
58
+ useCapabilities,
59
+ defineToolCallRenderer,
60
+ CopilotChatDefaultLabels,
61
+ type UseAgentUpdate,
62
+ type UseInterruptConfig,
63
+ type AgentContextInput,
64
+ type JsonSerializable,
65
+ type Thread,
66
+ type UseThreadsInput,
67
+ type UseThreadsResult,
68
+ type CopilotChatLabels,
69
+ type CopilotChatConfigurationValue,
70
+ type InterruptEvent,
71
+ type InterruptHandlerProps,
72
+ type InterruptRenderProps,
73
+ type Interrupt,
74
+ type ResumeEntry,
75
+ type ResumeStatus,
76
+ type ReactFrontendTool,
77
+ type ReactHumanInTheLoop,
78
+ type RenderToolInProgressProps,
79
+ type RenderToolExecutingProps,
80
+ type RenderToolCompleteProps,
81
+ } from "@copilotkit/react-core/v2/headless";
82
+
83
+ // Re-export core types commonly needed
84
+ export type {
85
+ CopilotKitCoreRuntimeConnectionStatus,
86
+ CopilotKitCoreErrorCode,
87
+ Suggestion,
88
+ FrontendTool,
89
+ ToolCallStatus,
90
+ } from "@copilotkit/core";
91
+
92
+ // Re-export AG-UI types for consumer convenience (matches web SDK surface)
93
+ export type {
94
+ Message,
95
+ AssistantMessage as AssistantMessageType,
96
+ ToolCall,
97
+ ToolMessage,
98
+ AbstractAgent,
99
+ AgentCapabilities,
100
+ } from "@ag-ui/client";
101
+
102
+ // Render tool hook (React Native version with render registry integration).
103
+ // No DOM and no chat-UI stack: the app supplies the renderers.
104
+ export { useRenderTool } from "./hooks/useRenderTool";
105
+ export type { UseRenderToolOptions } from "./hooks/useRenderTool";
106
+ export {
107
+ RenderToolProvider,
108
+ useRenderToolRegistry,
109
+ } from "./hooks/RenderToolContext";
110
+ export type { RenderToolProps } from "./hooks/RenderToolContext";
package/src/index.ts CHANGED
@@ -14,18 +14,17 @@
14
14
  * ```
15
15
  */
16
16
 
17
- // Auto-install polyfills so consumers don't need a manual import.
18
- // Must run before any CopilotKit code that relies on ReadableStream / fetch streaming.
19
- import "./polyfills";
20
-
21
- // React Native provider (no web dependencies)
22
- export { CopilotKitProvider } from "./CopilotKitProvider";
23
- export type { CopilotKitNativeProviderProps } from "./CopilotKitProvider";
24
-
25
- // Provider props alias (mirrors web's CopilotKitProviderProps)
26
- export type { CopilotKitNativeProviderProps as CopilotKitProviderProps } from "./CopilotKitProvider";
27
-
28
- // Headless chat components (no DOM, consumer provides UI)
17
+ // Headless surface: provider + platform-agnostic hooks + core/AG-UI types.
18
+ // This also side-effect-imports "./polyfills" (as its first statement), so the
19
+ // polyfills install before any chat-UI module below is evaluated. The prebuilt
20
+ // chat components + useAttachments are layered on top here; consumers who don't
21
+ // need them (and want to skip the @gorhom/bottom-sheet + expo-* native deps)
22
+ // can import from "@copilotkit/react-native/headless" instead.
23
+ export * from "./headless";
24
+
25
+ // Prebuilt chat components (import @gorhom/bottom-sheet; not in the
26
+ // /headless entry). Consumers who don't need these can import the provider
27
+ // and hooks from "@copilotkit/react-native/headless" instead.
29
28
  export { CopilotChat, useCopilotChatContext } from "./CopilotChat";
30
29
  export type { CopilotChatProps, CopilotChatContextValue } from "./CopilotChat";
31
30
  export { CopilotModal } from "./CopilotModal";
@@ -49,80 +48,11 @@ export type {
49
48
  export { CopilotPopup } from "./CopilotPopup";
50
49
  export type { CopilotPopupProps, CopilotPopupHandle } from "./CopilotPopup";
51
50
 
52
- // Re-export context and hooks from react-core (platform-agnostic)
53
- export {
54
- useCopilotKit,
55
- useLicenseContext,
56
- CopilotKitContext,
57
- type CopilotKitContextValue,
58
- } from "@copilotkit/react-core/v2/context";
59
-
60
- // Re-export hooks that work without web deps
61
- // These consume the CopilotKitContext which our provider sets
62
- export {
63
- useAgent,
64
- useFrontendTool,
65
- useComponent,
66
- useHumanInTheLoop,
67
- useInterrupt,
68
- useSuggestions,
69
- useConfigureSuggestions,
70
- useAgentContext,
71
- useThreads,
72
- useCapabilities,
73
- defineToolCallRenderer,
74
- CopilotChatDefaultLabels,
75
- type UseAgentUpdate,
76
- type UseInterruptConfig,
77
- type AgentContextInput,
78
- type JsonSerializable,
79
- type Thread,
80
- type UseThreadsInput,
81
- type UseThreadsResult,
82
- type CopilotChatLabels,
83
- type CopilotChatConfigurationValue,
84
- type InterruptEvent,
85
- type InterruptHandlerProps,
86
- type InterruptRenderProps,
87
- type Interrupt,
88
- type ResumeEntry,
89
- type ResumeStatus,
90
- type ReactFrontendTool,
91
- type ReactHumanInTheLoop,
92
- type RenderToolInProgressProps,
93
- type RenderToolExecutingProps,
94
- type RenderToolCompleteProps,
95
- } from "@copilotkit/react-core/v2/headless";
96
-
97
- // useRenderToolCall — web-specific (depends on DOM elements via DefaultToolCallRenderer)
98
- // useRenderCustomMessages — web-specific (tightly coupled to web chat UI rendering pipeline)
99
- // useRenderActivityMessage — web-specific (tightly coupled to web chat UI rendering pipeline)
100
- // useDefaultRenderTool — web-specific (DefaultToolCallRenderer uses <div>, <svg>, etc.)
101
-
102
- // Re-export core types commonly needed
103
- export type {
104
- CopilotKitCoreRuntimeConnectionStatus,
105
- CopilotKitCoreErrorCode,
106
- Suggestion,
107
- FrontendTool,
108
- ToolCallStatus,
109
- } from "@copilotkit/core";
110
-
111
- // Re-export AG-UI types for consumer convenience (matches web SDK surface)
112
- export type {
113
- Message,
114
- AssistantMessage as AssistantMessageType,
115
- ToolCall,
116
- ToolMessage,
117
- AbstractAgent,
118
- AgentCapabilities,
119
- } from "@ag-ui/client";
120
-
121
- // Render tool hook (React Native version with render registry integration)
122
- export { useRenderTool } from "./hooks/useRenderTool";
123
- export type { UseRenderToolOptions } from "./hooks/useRenderTool";
124
- export {
125
- RenderToolProvider,
126
- useRenderToolRegistry,
127
- } from "./hooks/RenderToolContext";
128
- export type { RenderToolProps } from "./hooks/RenderToolContext";
51
+ // The provider, platform-agnostic hooks (useAgent / useFrontendTool / ...),
52
+ // core + AG-UI types, and the render-tool registry are re-exported from
53
+ // "./headless" above (`export * from "./headless"`).
54
+ //
55
+ // Deliberately NOT re-exported (web-specific, from @copilotkit/react-core/v2):
56
+ // useRenderToolCall — depends on DOM elements via DefaultToolCallRenderer
57
+ // useRenderCustomMessages / useRenderActivityMessage — web chat UI pipeline
58
+ // useDefaultRenderTool — DefaultToolCallRenderer uses <div>, <svg>, etc.
package/tsdown.config.ts CHANGED
@@ -3,6 +3,7 @@ import { defineConfig } from "tsdown";
3
3
  export default defineConfig({
4
4
  entry: [
5
5
  "src/index.ts",
6
+ "src/headless.ts",
6
7
  "src/components/index.ts",
7
8
  "src/polyfills.ts",
8
9
  "src/polyfills/streams.ts",