Skip to content

Commit 20184e1

Browse files
committed
feat(react-native): export full v2 API surface with attachment support
15+ type re-exports from headless layer. expo-document-picker and expo-file-system as optional peer deps. InterruptEvent, ReactFrontendTool, ReactHumanInTheLoop added to headless.ts.
1 parent 018a696 commit 20184e1

3 files changed

Lines changed: 117 additions & 5 deletions

File tree

packages/react-core/src/v2/headless.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ export { useAgent, type UseAgentUpdate } from "./hooks/use-agent";
2626
export { useFrontendTool } from "./hooks/use-frontend-tool";
2727
export { useComponent } from "./hooks/use-component";
2828
export { useHumanInTheLoop } from "./hooks/use-human-in-the-loop";
29-
export { useInterrupt, type UseInterruptConfig } from "./hooks/use-interrupt";
29+
export {
30+
useInterrupt,
31+
type UseInterruptConfig,
32+
type InterruptEvent,
33+
type InterruptHandlerProps,
34+
type InterruptRenderProps,
35+
} from "./hooks/use-interrupt";
3036
export { useSuggestions } from "./hooks/use-suggestions";
3137
export { useConfigureSuggestions } from "./hooks/use-configure-suggestions";
3238
export {
@@ -40,3 +46,19 @@ export {
4046
type UseThreadsInput,
4147
type UseThreadsResult,
4248
} from "./hooks/use-threads";
49+
50+
export {
51+
useRenderTool,
52+
type RenderToolProps,
53+
type RenderToolInProgressProps,
54+
type RenderToolExecutingProps,
55+
type RenderToolCompleteProps,
56+
} from "./hooks/use-render-tool";
57+
export { defineToolCallRenderer } from "./types/defineToolCallRenderer";
58+
59+
// Platform-agnostic types
60+
export type { ReactFrontendTool } from "./types/frontend-tool";
61+
export type { ReactHumanInTheLoop } from "./types/human-in-the-loop";
62+
63+
// Platform-agnostic capability introspection
64+
export { useCapabilities } from "./hooks/use-capabilities";

packages/react-native/package.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"type": "module",
2020
"sideEffects": [
21+
"./dist/index.*",
2122
"./dist/polyfills.*",
2223
"./dist/polyfills/**/*"
2324
],
@@ -69,6 +70,7 @@
6970
"unlink:global": "pnpm unlink --global"
7071
},
7172
"dependencies": {
73+
"@ag-ui/client": "0.0.53",
7274
"@copilotkit/core": "workspace:*",
7375
"@copilotkit/react-core": "workspace:*",
7476
"@copilotkit/shared": "workspace:*",
@@ -86,7 +88,21 @@
8688
"vitest": "^3.2.4"
8789
},
8890
"peerDependencies": {
91+
"expo-document-picker": ">=12.0.0",
92+
"expo-file-system": ">=17.0.0",
8993
"react": "^18 || ^19",
90-
"react-native": ">=0.70"
94+
"react-native": ">=0.70",
95+
"zod": ">=3.0.0"
96+
},
97+
"peerDependenciesMeta": {
98+
"expo-document-picker": {
99+
"optional": true
100+
},
101+
"expo-file-system": {
102+
"optional": true
103+
},
104+
"zod": {
105+
"optional": true
106+
}
91107
}
92108
}

packages/react-native/src/index.ts

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,51 @@
44
* React Native bindings for CopilotKit. Provides a lightweight provider
55
* and re-exports platform-agnostic hooks from @copilotkit/react-core.
66
*
7+
* Polyfills (DOMException, ReadableStream, TextEncoder, etc.) are
8+
* auto-imported when this module loads -- no manual
9+
* `import "@copilotkit/react-native/polyfills"` needed.
10+
*
711
* Quick start:
812
* ```tsx
913
* import { CopilotKitProvider, useAgent, useCopilotKit } from "@copilotkit/react-native";
1014
* ```
1115
*/
1216

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+
1321
// React Native provider (no web dependencies)
1422
export { CopilotKitProvider } from "./CopilotKitProvider";
1523
export type { CopilotKitNativeProviderProps } from "./CopilotKitProvider";
1624

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)
29+
export { CopilotChat, useCopilotChatContext } from "./CopilotChat";
30+
export type { CopilotChatProps, CopilotChatContextValue } from "./CopilotChat";
31+
export { CopilotModal } from "./CopilotModal";
32+
export type { CopilotModalProps } from "./CopilotModal";
33+
34+
// Native attachments hook and types
35+
export { useAttachments } from "./hooks/use-attachments";
36+
export type {
37+
NativeAttachmentsConfig,
38+
NativeFileInput,
39+
UseNativeAttachmentsProps,
40+
UseNativeAttachmentsReturn,
41+
} from "./hooks/use-attachments";
42+
43+
// Pre-built UI components
44+
export { CopilotSidebar } from "./CopilotSidebar";
45+
export type {
46+
CopilotSidebarProps,
47+
CopilotSidebarHandle,
48+
} from "./CopilotSidebar";
49+
export { CopilotPopup } from "./CopilotPopup";
50+
export type { CopilotPopupProps, CopilotPopupHandle } from "./CopilotPopup";
51+
1752
// Re-export context and hooks from react-core (platform-agnostic)
1853
export {
1954
useCopilotKit,
@@ -34,11 +69,50 @@ export {
3469
useConfigureSuggestions,
3570
useAgentContext,
3671
useThreads,
72+
useRenderTool,
73+
useCapabilities,
74+
defineToolCallRenderer,
75+
CopilotChatDefaultLabels,
3776
type UseAgentUpdate,
77+
type UseInterruptConfig,
78+
type AgentContextInput,
79+
type JsonSerializable,
80+
type Thread,
81+
type UseThreadsInput,
82+
type UseThreadsResult,
83+
type CopilotChatLabels,
84+
type CopilotChatConfigurationValue,
85+
type InterruptEvent,
86+
type InterruptHandlerProps,
87+
type InterruptRenderProps,
88+
type ReactFrontendTool,
89+
type ReactHumanInTheLoop,
90+
type RenderToolProps,
91+
type RenderToolInProgressProps,
92+
type RenderToolExecutingProps,
93+
type RenderToolCompleteProps,
3894
} from "@copilotkit/react-core/v2/headless";
3995

96+
// useRenderToolCall — web-specific (depends on DOM elements via DefaultToolCallRenderer)
97+
// useRenderCustomMessages — web-specific (tightly coupled to web chat UI rendering pipeline)
98+
// useRenderActivityMessage — web-specific (tightly coupled to web chat UI rendering pipeline)
99+
// useDefaultRenderTool — web-specific (DefaultToolCallRenderer uses <div>, <svg>, etc.)
100+
40101
// Re-export core types commonly needed
41-
export {
42-
type CopilotKitCoreRuntimeConnectionStatus,
43-
type CopilotKitCoreErrorCode,
102+
export type {
103+
CopilotKitCoreRuntimeConnectionStatus,
104+
CopilotKitCoreErrorCode,
105+
Suggestion,
106+
FrontendTool,
107+
ToolCallStatus,
44108
} from "@copilotkit/core";
109+
110+
// Re-export AG-UI types for consumer convenience (matches web SDK surface)
111+
export type {
112+
Message,
113+
AssistantMessage,
114+
ToolCall,
115+
ToolMessage,
116+
AbstractAgent,
117+
AgentCapabilities,
118+
} from "@ag-ui/client";

0 commit comments

Comments
 (0)