Skip to content

fix(react-native): add /headless subpath so custom-UI consumers skip chat/attachment native deps - #6142

Merged
davidmckayv merged 2 commits into
mainfrom
fix/rn-headless-optional-deps
Jul 24, 2026
Merged

davidmckayv merged 2 commits into
mainfrom
fix/rn-headless-optional-deps

Conversation

@davidmckayv

Copy link
Copy Markdown
Contributor

Problem

@copilotkit/react-native's entry (packages/react-native/src/index.ts) statically re-exports the prebuilt chat UI — CopilotChat / CopilotModal / CopilotSidebar / CopilotPopup, which import @gorhom/bottom-sheet — and useAttachments, which imports expo-document-picker + expo-file-system.

Those are declared as optional peer deps, but a static re-export still forces Metro to resolve them at bundle time. So a headless consumer that mounts only CopilotKitProvider + useAgent + useFrontendTool (a fully custom UI, no prebuilt chat) is still forced to install all of those native deps, or Metro's release bundle fails:

Unable to resolve module expo-document-picker

Today the only workaround is stubbing the modules in metro.config.js.

Fix

Add a lean @copilotkit/react-native/headless subpath entry that re-exports only the provider (CopilotKitProvider), the platform-agnostic hooks (useAgent, useFrontendTool, useCopilotKit, useHumanInTheLoop, useInterrupt, useThreads, useSuggestions, useRenderTool, …), the render-tool registry, and the core/AG-UI types — and none of the chat components or useAttachments. Those native deps therefore never enter the bundle graph:

import { CopilotKitProvider, useAgent, useFrontendTool } from "@copilotkit/react-native/headless";

This retires the metro.config.js stub workaround for headless consumers.

How it mirrors the precedent (#5883)

Directly mirrors @copilotkit/react-core/v2/headless (PR #5883, which cut multi-MB bundle bloat by exposing lean hooks from a dedicated entry — and which this RN provider already consumes):

  • Standalone entry filesrc/headless.ts (the lean surface).
  • tsdown — added to the entry list (RN's tsdown auto-externalizes deps/peerDeps, so the native modules stay external and simply never get imported by this entry).
  • package.json — new ./headless condition in exports, and ./dist/headless.* added to sideEffects (the entry side-effect-imports the polyfills).
  • Regression test — a static import-graph test (headless-entry-surface.test.ts) that walks the transitive graph from src/headless.ts and fails if it ever reaches the chat/attachment modules or @gorhom/bottom-sheet / expo-document-picker / expo-file-system. This is the guarantee a normal typecheck can't catch, since those are optional peers.

Backward compatibility

Fully backward compatible. The default barrel (@copilotkit/react-native) now does export * from "./headless" and layers the chat UI + useAttachments on top, so every existing import from @copilotkit/react-native is unchanged. The polyfills still auto-install from both entries.

🤖 Generated with Claude Code

…chat/attachment native deps

The `@copilotkit/react-native` barrel statically re-exports the prebuilt chat
UI (CopilotChat / CopilotModal / CopilotSidebar / CopilotPopup, which import
`@gorhom/bottom-sheet`) and `useAttachments` (which imports
`expo-document-picker` + `expo-file-system`). Those are optional peer deps, but
a static re-export still forces Metro to resolve them at bundle time. A headless
consumer that uses only `CopilotKitProvider` + `useAgent` + `useFrontendTool`
(a fully custom UI) had to install every chat/attachment native dep or stub them
in `metro.config.js`, or the release bundle fails with
`Unable to resolve module expo-document-picker`.

Add a lean `@copilotkit/react-native/headless` entry that re-exports only the
provider, the platform-agnostic hooks, the render-tool registry, and the
core/AG-UI types — none of the chat UI or `useAttachments` — so those native
deps never enter the bundle graph and the metro-stub workaround is retired.

Mirrors `@copilotkit/react-core/v2/headless` (#5883): a standalone entry file,
wired into the tsdown entry list, the package.json `exports` map, and
`sideEffects` (it side-effect-imports the polyfills). The default barrel now
does `export * from "./headless"` and layers the chat UI on top, so it stays
fully backward compatible. Adds a static import-graph regression test asserting
the headless graph never reaches the chat/attachment modules or their native
peer deps.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

@copilotkit/a2ui-renderer

pnpm add https://pkg.pr.new/@copilotkit/a2ui-renderer@6142

@copilotkit/agentcore-runner

pnpm add https://pkg.pr.new/@copilotkit/agentcore-runner@6142

@copilotkit/angular

pnpm add https://pkg.pr.new/@copilotkit/angular@6142

@copilotkit/channels

pnpm add https://pkg.pr.new/@copilotkit/channels@6142

@copilotkit/channels-core

pnpm add https://pkg.pr.new/@copilotkit/channels-core@6142

@copilotkit/channels-discord

pnpm add https://pkg.pr.new/@copilotkit/channels-discord@6142

@copilotkit/channels-intelligence

pnpm add https://pkg.pr.new/@copilotkit/channels-intelligence@6142

@copilotkit/channels-slack

pnpm add https://pkg.pr.new/@copilotkit/channels-slack@6142

@copilotkit/channels-teams

pnpm add https://pkg.pr.new/@copilotkit/channels-teams@6142

@copilotkit/channels-telegram

pnpm add https://pkg.pr.new/@copilotkit/channels-telegram@6142

@copilotkit/channels-ui

pnpm add https://pkg.pr.new/@copilotkit/channels-ui@6142

@copilotkit/channels-whatsapp

pnpm add https://pkg.pr.new/@copilotkit/channels-whatsapp@6142

@copilotkit/core

pnpm add https://pkg.pr.new/@copilotkit/core@6142

@copilotkit/react-core

pnpm add https://pkg.pr.new/@copilotkit/react-core@6142

@copilotkit/react-native

pnpm add https://pkg.pr.new/@copilotkit/react-native@6142

@copilotkit/react-textarea

pnpm add https://pkg.pr.new/@copilotkit/react-textarea@6142

@copilotkit/react-ui

pnpm add https://pkg.pr.new/@copilotkit/react-ui@6142

@copilotkit/runtime

pnpm add https://pkg.pr.new/@copilotkit/runtime@6142

@copilotkit/runtime-client-gql

pnpm add https://pkg.pr.new/@copilotkit/runtime-client-gql@6142

@copilotkit/sdk-js

pnpm add https://pkg.pr.new/@copilotkit/sdk-js@6142

@copilotkit/shared

pnpm add https://pkg.pr.new/@copilotkit/shared@6142

@copilotkit/sqlite-runner

pnpm add https://pkg.pr.new/@copilotkit/sqlite-runner@6142

@copilotkit/voice

pnpm add https://pkg.pr.new/@copilotkit/voice@6142

@copilotkit/vue

pnpm add https://pkg.pr.new/@copilotkit/vue@6142

@copilotkit/web-components

pnpm add https://pkg.pr.new/@copilotkit/web-components@6142

@copilotkit/web-inspector

pnpm add https://pkg.pr.new/@copilotkit/web-inspector@6142

commit: 5baf058

@github-actions

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 1.19 MB

ℹ️ View Unchanged
Filename Size
packages/a2ui-renderer/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/a2ui-renderer/dist/a2ui-types.cjs 172 B
packages/a2ui-renderer/dist/a2ui-types.mjs 171 B
packages/a2ui-renderer/dist/index.cjs 842 B
packages/a2ui-renderer/dist/index.mjs 563 B
packages/a2ui-renderer/dist/index.umd.js 12.2 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/A2uiSurface.cjs 1.49 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/A2uiSurface.mjs 1.43 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/adapter.cjs 1.07 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/adapter.mjs 1.01 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/AudioPlayer.cjs 904 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/AudioPlayer.mjs 492 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Button.cjs 1 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Button.mjs 596 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Card.cjs 829 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Card.mjs 419 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/CheckBox.cjs 1.1 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/CheckBox.mjs 1.02 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChildList.cjs 799 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChildList.mjs 737 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChoicePicker.cjs 1.63 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChoicePicker.mjs 1.57 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Column.cjs 856 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Column.mjs 802 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/DateTimeInput.cjs 1.12 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/DateTimeInput.mjs 1.05 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Divider.cjs 842 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Divider.mjs 432 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Icon.cjs 877 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Icon.mjs 469 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Image.cjs 995 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Image.mjs 587 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/List.cjs 920 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/List.mjs 508 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Modal.cjs 1.19 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Modal.mjs 1.13 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Row.cjs 855 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Row.mjs 801 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Slider.cjs 1.06 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Slider.mjs 984 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Tabs.cjs 1.1 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Tabs.mjs 1.04 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Text.cjs 903 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Text.mjs 489 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/TextField.cjs 1.21 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/TextField.mjs 1.14 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Video.cjs 788 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Video.mjs 378 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/index.cjs 928 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/index.mjs 855 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/utils.cjs 579 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/utils.mjs 556 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Button.cjs 982 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Button.mjs 580 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/ChildList.cjs 800 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/ChildList.mjs 735 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Column.cjs 1.08 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Column.mjs 1.02 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Row.cjs 1.07 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Row.mjs 1.01 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Text.cjs 894 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Text.mjs 839 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/TextField.cjs 1.21 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/TextField.mjs 802 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/index.cjs 849 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/index.mjs 804 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/index.cjs 310 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/index.mjs 325 B
packages/a2ui-renderer/dist/react-renderer/catalog-utils.cjs 1.59 kB
packages/a2ui-renderer/dist/react-renderer/catalog-utils.mjs 1.52 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIProvider.cjs 1.5 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIProvider.mjs 1.42 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIRenderer.cjs 728 B
packages/a2ui-renderer/dist/react-renderer/core/A2UIRenderer.mjs 671 B
packages/a2ui-renderer/dist/react-renderer/create-catalog.cjs 1.35 kB
packages/a2ui-renderer/dist/react-renderer/create-catalog.mjs 1.28 kB
packages/a2ui-renderer/dist/react-renderer/hooks/useA2UI.cjs 316 B
packages/a2ui-renderer/dist/react-renderer/hooks/useA2UI.mjs 309 B
packages/a2ui-renderer/dist/react-renderer/index.cjs 399 B
packages/a2ui-renderer/dist/react-renderer/index.mjs 515 B
packages/a2ui-renderer/dist/react-renderer/lib/utils.cjs 236 B
packages/a2ui-renderer/dist/react-renderer/lib/utils.mjs 188 B
packages/a2ui-renderer/dist/react-renderer/styles/index.cjs 239 B
packages/a2ui-renderer/dist/react-renderer/styles/index.mjs 231 B
packages/a2ui-renderer/dist/react-renderer/theme/ThemeContext.cjs 436 B
packages/a2ui-renderer/dist/react-renderer/theme/ThemeContext.mjs 381 B
packages/a2ui-renderer/dist/web-components/_virtual/_rolldown/runtime.cjs 260 B
packages/a2ui-renderer/dist/web-components/_virtual/_rolldown/runtime.mjs 258 B
packages/a2ui-renderer/dist/web-components/adapter.cjs 346 B
packages/a2ui-renderer/dist/web-components/adapter.mjs 335 B
packages/a2ui-renderer/dist/web-components/bound-component.cjs 670 B
packages/a2ui-renderer/dist/web-components/bound-component.mjs 662 B
packages/a2ui-renderer/dist/web-components/catalog/basic/audio-player.cjs 536 B
packages/a2ui-renderer/dist/web-components/catalog/basic/audio-player.mjs 492 B
packages/a2ui-renderer/dist/web-components/catalog/basic/button.cjs 647 B
packages/a2ui-renderer/dist/web-components/catalog/basic/button.mjs 604 B
packages/a2ui-renderer/dist/web-components/catalog/basic/card.cjs 448 B
packages/a2ui-renderer/dist/web-components/catalog/basic/card.mjs 402 B
packages/a2ui-renderer/dist/web-components/catalog/basic/check-box.cjs 743 B
packages/a2ui-renderer/dist/web-components/catalog/basic/check-box.mjs 695 B
packages/a2ui-renderer/dist/web-components/catalog/basic/choice-picker.cjs 1.27 kB
packages/a2ui-renderer/dist/web-components/catalog/basic/choice-picker.mjs 1.24 kB
packages/a2ui-renderer/dist/web-components/catalog/basic/column.cjs 474 B
packages/a2ui-renderer/dist/web-components/catalog/basic/column.mjs 431 B
packages/a2ui-renderer/dist/web-components/catalog/basic/components.cjs 482 B
packages/a2ui-renderer/dist/web-components/catalog/basic/components.mjs 424 B
packages/a2ui-renderer/dist/web-components/catalog/basic/date-time-input.cjs 756 B
packages/a2ui-renderer/dist/web-components/catalog/basic/date-time-input.mjs 714 B
packages/a2ui-renderer/dist/web-components/catalog/basic/divider.cjs 450 B
packages/a2ui-renderer/dist/web-components/catalog/basic/divider.mjs 404 B
packages/a2ui-renderer/dist/web-components/catalog/basic/icon.cjs 504 B
packages/a2ui-renderer/dist/web-components/catalog/basic/icon.mjs 455 B
packages/a2ui-renderer/dist/web-components/catalog/basic/ids.cjs 192 B
packages/a2ui-renderer/dist/web-components/catalog/basic/ids.mjs 190 B
packages/a2ui-renderer/dist/web-components/catalog/basic/image.cjs 624 B
packages/a2ui-renderer/dist/web-components/catalog/basic/image.mjs 578 B
packages/a2ui-renderer/dist/web-components/catalog/basic/index.cjs 465 B
packages/a2ui-renderer/dist/web-components/catalog/basic/index.mjs 526 B
packages/a2ui-renderer/dist/web-components/catalog/basic/list.cjs 534 B
packages/a2ui-renderer/dist/web-components/catalog/basic/list.mjs 483 B
packages/a2ui-renderer/dist/web-components/catalog/basic/modal.cjs 842 B
packages/a2ui-renderer/dist/web-components/catalog/basic/modal.mjs 800 B
packages/a2ui-renderer/dist/web-components/catalog/basic/row.cjs 471 B
packages/a2ui-renderer/dist/web-components/catalog/basic/row.mjs 427 B
packages/a2ui-renderer/dist/web-components/catalog/basic/slider.cjs 701 B
packages/a2ui-renderer/dist/web-components/catalog/basic/slider.mjs 653 B
packages/a2ui-renderer/dist/web-components/catalog/basic/tabs.cjs 780 B
packages/a2ui-renderer/dist/web-components/catalog/basic/tabs.mjs 730 B
packages/a2ui-renderer/dist/web-components/catalog/basic/text-field.cjs 857 B
packages/a2ui-renderer/dist/web-components/catalog/basic/text-field.mjs 814 B
packages/a2ui-renderer/dist/web-components/catalog/basic/text.cjs 553 B
packages/a2ui-renderer/dist/web-components/catalog/basic/text.mjs 501 B
packages/a2ui-renderer/dist/web-components/catalog/basic/utils.cjs 484 B
packages/a2ui-renderer/dist/web-components/catalog/basic/utils.mjs 462 B
packages/a2ui-renderer/dist/web-components/catalog/basic/video.cjs 400 B
packages/a2ui-renderer/dist/web-components/catalog/basic/video.mjs 352 B
packages/a2ui-renderer/dist/web-components/catalog/children.cjs 302 B
packages/a2ui-renderer/dist/web-components/catalog/children.mjs 300 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/button.cjs 629 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/button.mjs 584 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/column.cjs 609 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/column.mjs 559 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/components.cjs 245 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/components.mjs 263 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/index.cjs 724 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/index.mjs 654 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/row.cjs 593 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/row.mjs 544 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/text-field.cjs 874 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/text-field.mjs 822 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/text.cjs 509 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/text.mjs 477 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/utils.cjs 291 B
packages/a2ui-renderer/dist/web-components/catalog/minimal/utils.mjs 287 B
packages/a2ui-renderer/dist/web-components/create-catalog.cjs 1.89 kB
packages/a2ui-renderer/dist/web-components/create-catalog.mjs 1.83 kB
packages/a2ui-renderer/dist/web-components/define.cjs 440 B
packages/a2ui-renderer/dist/web-components/define.mjs 341 B
packages/a2ui-renderer/dist/web-components/index.cjs 960 B
packages/a2ui-renderer/dist/web-components/index.mjs 655 B
packages/a2ui-renderer/dist/web-components/node.cjs 1.05 kB
packages/a2ui-renderer/dist/web-components/node.mjs 1.04 kB
packages/a2ui-renderer/dist/web-components/surface.cjs 2.83 kB
packages/a2ui-renderer/dist/web-components/surface.mjs 2.81 kB
packages/core/dist/index.cjs 47.6 kB
packages/core/dist/index.mjs 47.2 kB
packages/core/dist/index.umd.js 50.9 kB
packages/react-core/dist/copilotkit-Dz3ZL1KX.mjs 105 kB
packages/react-core/dist/copilotkit-SnJsXSpP.cjs 107 kB
packages/react-core/dist/index.cjs 16.9 kB
packages/react-core/dist/index.mjs 16.8 kB
packages/react-core/dist/index.umd.js 64.3 kB
packages/react-core/dist/v2/context.cjs 1.55 kB
packages/react-core/dist/v2/context.mjs 1.47 kB
packages/react-core/dist/v2/headless.cjs 12.8 kB
packages/react-core/dist/v2/headless.mjs 12.3 kB
packages/react-core/dist/v2/index.cjs 1.26 kB
packages/react-core/dist/v2/index.mjs 1.12 kB
packages/react-core/dist/v2/index.umd.js 106 kB
packages/react-textarea/dist/index.cjs 18.1 kB
packages/react-textarea/dist/index.mjs 17.4 kB
packages/react-textarea/dist/index.umd.js 18.8 kB
packages/react-ui/dist/index.cjs 24.6 kB
packages/react-ui/dist/index.mjs 23.9 kB
packages/react-ui/dist/index.umd.js 25.8 kB
packages/runtime-client-gql/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/runtime-client-gql/dist/client/conversion.cjs 1.52 kB
packages/runtime-client-gql/dist/client/conversion.mjs 1.45 kB
packages/runtime-client-gql/dist/client/CopilotRuntimeClient.cjs 1.58 kB
packages/runtime-client-gql/dist/client/CopilotRuntimeClient.mjs 1.54 kB
packages/runtime-client-gql/dist/client/types.cjs 701 B
packages/runtime-client-gql/dist/client/types.mjs 642 B
packages/runtime-client-gql/dist/graphql/@generated/gql.cjs 850 B
packages/runtime-client-gql/dist/graphql/@generated/gql.mjs 850 B
packages/runtime-client-gql/dist/graphql/@generated/graphql.cjs 2.4 kB
packages/runtime-client-gql/dist/graphql/@generated/graphql.mjs 2.36 kB
packages/runtime-client-gql/dist/graphql/definitions/mutations.cjs 740 B
packages/runtime-client-gql/dist/graphql/definitions/mutations.mjs 732 B
packages/runtime-client-gql/dist/graphql/definitions/queries.cjs 316 B
packages/runtime-client-gql/dist/graphql/definitions/queries.mjs 304 B
packages/runtime-client-gql/dist/index.cjs 679 B
packages/runtime-client-gql/dist/index.mjs 495 B
packages/runtime-client-gql/dist/index.umd.js 9.58 kB
packages/runtime-client-gql/dist/message-conversion/agui-to-gql.cjs 1.72 kB
packages/runtime-client-gql/dist/message-conversion/agui-to-gql.mjs 1.7 kB
packages/runtime-client-gql/dist/message-conversion/gql-to-agui.cjs 1.56 kB
packages/runtime-client-gql/dist/message-conversion/gql-to-agui.mjs 1.53 kB
packages/runtime-client-gql/dist/package.cjs 181 B
packages/runtime-client-gql/dist/package.mjs 116 B
packages/shared/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/shared/dist/a2ui-prompts.cjs 2.85 kB
packages/shared/dist/a2ui-prompts.mjs 2.85 kB
packages/shared/dist/attachments/utils.cjs 1.74 kB
packages/shared/dist/attachments/utils.mjs 1.7 kB
packages/shared/dist/constants/index.cjs 362 B
packages/shared/dist/constants/index.mjs 345 B
packages/shared/dist/debug.cjs 454 B
packages/shared/dist/debug.mjs 452 B
packages/shared/dist/finalize-events.cjs 1.05 kB
packages/shared/dist/finalize-events.mjs 1 kB
packages/shared/dist/index.cjs 1.99 kB
packages/shared/dist/index.mjs 1.66 kB
packages/shared/dist/index.umd.js 20.3 kB
packages/shared/dist/logger.cjs 112 B
packages/shared/dist/logger.mjs 112 B
packages/shared/dist/package.cjs 181 B
packages/shared/dist/package.mjs 116 B
packages/shared/dist/standard-schema.cjs 740 B
packages/shared/dist/standard-schema.mjs 737 B
packages/shared/dist/telemetry/lambda-client.cjs 1.14 kB
packages/shared/dist/telemetry/lambda-client.mjs 1.13 kB
packages/shared/dist/telemetry/telemetry-client.cjs 1.33 kB
packages/shared/dist/telemetry/telemetry-client.mjs 1.27 kB
packages/shared/dist/telemetry/utils.cjs 321 B
packages/shared/dist/telemetry/utils.mjs 277 B
packages/shared/dist/transcription-errors.cjs 951 B
packages/shared/dist/transcription-errors.mjs 944 B
packages/shared/dist/utils/clipboard.cjs 407 B
packages/shared/dist/utils/clipboard.mjs 405 B
packages/shared/dist/utils/conditions.cjs 540 B
packages/shared/dist/utils/conditions.mjs 536 B
packages/shared/dist/utils/console-styling.cjs 1.24 kB
packages/shared/dist/utils/console-styling.mjs 1.22 kB
packages/shared/dist/utils/errors.cjs 4.51 kB
packages/shared/dist/utils/errors.mjs 4.41 kB
packages/shared/dist/utils/index.cjs 1.39 kB
packages/shared/dist/utils/index.mjs 1.65 kB
packages/shared/dist/utils/json-schema.cjs 1.97 kB
packages/shared/dist/utils/json-schema.mjs 1.91 kB
packages/shared/dist/utils/random-id.cjs 618 B
packages/shared/dist/utils/random-id.mjs 559 B
packages/shared/dist/utils/requests.cjs 706 B
packages/shared/dist/utils/requests.mjs 704 B
packages/shared/dist/utils/types.cjs 161 B
packages/shared/dist/utils/types.mjs 160 B
packages/voice/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/voice/dist/index.cjs 175 B
packages/voice/dist/index.mjs 95 B
packages/voice/dist/index.umd.js 1.5 kB
packages/voice/dist/transcription/transcription-service-openai.cjs 495 B
packages/voice/dist/transcription/transcription-service-openai.mjs 434 B
packages/web-inspector/dist/assets/inspector-logo-icon.cjs 499 B
packages/web-inspector/dist/assets/inspector-logo-icon.mjs 434 B
packages/web-inspector/dist/assets/inspector-logo.cjs 4.32 kB
packages/web-inspector/dist/assets/inspector-logo.mjs 4.23 kB
packages/web-inspector/dist/index.cjs 59.3 kB
packages/web-inspector/dist/index.mjs 59.3 kB
packages/web-inspector/dist/index.umd.js 77.4 kB
packages/web-inspector/dist/lib/context-helpers.cjs 862 B
packages/web-inspector/dist/lib/context-helpers.mjs 830 B
packages/web-inspector/dist/lib/persistence.cjs 1.2 kB
packages/web-inspector/dist/lib/persistence.mjs 1.16 kB
packages/web-inspector/dist/lib/telemetry.cjs 2.54 kB
packages/web-inspector/dist/lib/telemetry.mjs 2.44 kB
packages/web-inspector/dist/package.cjs 181 B
packages/web-inspector/dist/package.mjs 116 B
packages/web-inspector/dist/styles/generated.cjs 6.42 kB
packages/web-inspector/dist/styles/generated.mjs 6.36 kB

compressed-size-action

@davidmckayv
davidmckayv merged commit 563c462 into main Jul 24, 2026
34 checks passed
@davidmckayv
davidmckayv deleted the fix/rn-headless-optional-deps branch July 24, 2026 18:49
samjulien added a commit that referenced this pull request Jul 28, 2026
## What

Expands the React Native docs page from a "get to first chat" quickstart
into a full production guide, matching the depth of the Slack/Teams
frontend pages. The existing quickstart Steps are unchanged; the new
material is added after them.

### Production sections added
- **Headless imports** — `@copilotkit/react-native/headless` for a
custom-UI app, avoiding the chat/attachment native peer deps the default
barrel re-exports.
- **Metro configuration for release bundles** —
`unstable_enablePackageExports` + browser-first
`unstable_conditionNames` so the transitive `jose` dependency resolves
to its browser build (fails only at release-bundle time otherwise).
- **Polyfills** — documents the real auto-installed barrel + granular
subpaths, including the `crypto` polyfill (backed by `Math.random`) and
the recommendation to install a secure RNG for production.
- **Provider options** — the full `CopilotKitProvider` prop surface:
`runtimeUrl`, `headers` (auth), `credentials`, `properties`, `onError`,
`debug`, `defaultThrottleMs`, `useSingleEndpoint`.
- **Runtime and model wiring** — the string model form,
`OPENAI_BASE_URL` (and Anthropic/Google equivalents) for
OpenAI-compatible endpoints, `createCopilotNodeListener` zero-dep
serving, and `BuiltInAgent` options.
- **Connecting from a device or bench** — LAN IP, Android emulator
`10.0.2.2`, `adb reverse` for USB, and Android release cleartext HTTP
via `expo-build-properties`.
- **Frontend tools and generative UI** — `useFrontendTool` with
zod/Standard Schema, the send-a-turn recipe, `useAgent` read-only
subscribe + `threadId`, discriminated-union params, and variable-length
`ScrollView` rendering.
- **Run lifecycle and UI** — `isRunning` outliving the visible compose,
and gating overlays/reveal motion accordingly.
- **Voice and speech-to-text** — DIY STT with a graceful-fallback
warning for de-Googled/automotive hardware.
- Refreshed **What's included** and **Known limitations**, plus a **Next
steps** section.

### Dependency on runtime / react-native fixes

Three of the four fixes this guide relies on are now **merged to
`main`**, so it documents them as current behavior:

- `@copilotkit/react-native/headless` subpath (headless provider + hooks
without chat/attachment deps) — #6142 ✅ merged
- `resolveModel` honoring `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL` /
`GOOGLE_GENERATIVE_AI_BASE_URL` for the string model form — #6140 ✅
merged
- union / `anyOf` / `oneOf` tool-param schemas surviving JSON-schema→zod
conversion — #6143 ✅ merged

The fourth — `useAgent` accepting an optional `threadId` (#6141) — is
**still open**. The guide therefore does **not** document it as working;
it is listed under **Known limitations** instead, and will be promoted
once #6141 lands.

Every API, export, env var, and behavior in the page was independently
re-verified against the package source (three parallel source audits
over `packages/{react-native,react-core,runtime}`). That pass turned up
one overstatement, fixed in 6eefe2b: only `/headless` and the root
barrel side-effect-import the polyfill barrel —
`@copilotkit/react-native/components` does not, so the "all three
surfaces auto-install" wording was corrected.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
BenTaylorDev added a commit that referenced this pull request Aug 27, 2026
… below it (closes OSS-956) (#6725)

## What does this PR do?

The React Native guide imports `CopilotKitProvider`, `useAgent` and
`useCopilotKit` from `@copilotkit/react-native/headless` and names no
version. That subpath first ships in **1.64.0** (#6142), so a project
pinned to 1.63.x or earlier fails every one of those imports with:

```
Unable to resolve module @copilotkit/react-native/headless
```

On Metro that reads like a broken install rather than a version skew,
and it sends the reader into the package-exports and polyfill debugging
the same guide warns about a few sections later. The actual fix is one
word in an import path.

This states the boundary in the three places a reader meets the subpath.
Prose only — no snippet in this page changed.

### The version boundary, verified against the registry

Not inferred from a changelog — `npm view @copilotkit/react-native@<v>
exports` on each:

| version | `./headless` |
| -- | -- |
| 1.62.0, 1.62.2, 1.62.3 | absent |
| 1.63.0, 1.63.1, 1.63.2 | absent |
| **1.64.0** | **present** |
| 1.64.1+, 1.65.0, 1.69.2 | present |

`./components` and the polyfill subpaths exist across all of the above,
so `/headless` is the only path in the guide that carries a version
boundary. Introduced by 0a582df / #6142.

### What changed

- **Intro line** — `/headless` is marked `1.64.0+` where the three
import surfaces are first introduced.
- **Install step** — a `type="warn"` callout, placed where the resolved
version is actually decided. States the boundary, quotes the exact Metro
error, gives `npm ls @copilotkit/react-native` to check what you
resolved, and covers the fallback.
- **Import surfaces table** — a new "Available since" column.
- **Import surfaces prose** — records what `/headless` *is*, which the
guide never said: a lean alternative entry added so custom-UI consumers
skip the chat and attachment native deps — **not** a replacement for the
root barrel, which remains the package's default full surface and
re-exports everything in `/headless`.

### The fallback advice is deliberately not just "import from the root"

On 1.62.2 and 1.63.2 the root barrel does export all three names
(checked in the shipped tarballs, not assumed). But
`package/dist/index.mjs` on those versions statically imports
`expo-document-picker` and `expo-file-system`. A reader who switches to
the root therefore inherits exactly the peer-dependency resolution
failure that this guide's `/headless` choice exists to avoid:

```
Unable to resolve module expo-document-picker
```

So the callout says to prefer upgrading to 1.64.0+, and if you cannot
(because you are matching a pinned `@copilotkit/runtime`), names the
install-or-stub requirement that comes with the root import rather than
presenting it as a free swap.

### Why not backport `./headless` to 1.62.x

That was the alternative the issue floated, and it looks unnecessary.
`/headless` was never intended as the canonical entry that supersedes
the root — #6142's message, `src/index.ts` (`export * from
"./headless"`, with a root quick-start that uses the root), and
`src/headless.ts` ("existing imports from `@copilotkit/react-native` are
unchanged") all agree it is a lean *alternative*. Adding an entry point
in a patch of an older line would also change what "the pinned set"
means for anyone matching client to runtime.

## Related PRs and Issues

- Closes OSS-956
- #6142 — added the `/headless` subpath in 1.64.0
- #5883 — the `@copilotkit/react-core/v2/headless` entry that #6142
mirrors

## Verification

- MDX compiles via `@mdx-js/mdx` + `remark-gfm`, edited and baseline
both
- 4-column Import surfaces table parses; 19/19 `<Callout>` tags balanced
- `commitlint` exit 0
- `pnpm check:intelligence-env-names` passes
- `.mdx` is not in lefthook's `lint-fix` glob, so oxfmt/oxlint never
applied to this file
- This page carries no `doctest=` fences, and no fence in it changed, so
the guide's snippets stay runnable as they were

## Checklist

- [x] I have read the [Contribution
Guide](https://github.com/copilotkit/copilotkit/blob/master/CONTRIBUTING.md)
- [x] If the PR changes or adds functionality, I have updated the
relevant documentation
- [x] "Allow edits by maintainers" is checked

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Naz-Ovh pushed a commit to 0x-fork/CopilotKit that referenced this pull request Aug 27, 2026
… below it (closes OSS-956)

The React Native guide imports `CopilotKitProvider`, `useAgent` and
`useCopilotKit` from `@copilotkit/react-native/headless` and names no version.
That subpath first ships in 1.64.0 (CopilotKit#6142), so a project pinned to 1.63.x or
earlier fails every one of those imports with `Unable to resolve module
@copilotkit/react-native/headless` — which on Metro reads like a broken install
rather than a version skew, and sends the reader into the package-exports and
polyfill debugging the same guide warns about. The actual fix is one word in an
import path.

Verified against the registry rather than inferred: `./headless` is absent from
1.62.0, 1.62.2, 1.62.3, 1.63.0, 1.63.1 and 1.63.2, and present from 1.64.0
onward. `./components` and the polyfill subpaths exist across all of them, so
`/headless` is the only path in the guide with a version boundary.

State the boundary in the three places a reader meets the subpath: the intro
line that introduces the surfaces, a callout in the install step (where the
resolved version is actually decided, with `npm ls` to check it), and an
"Available since" column in the Import surfaces table.

The fallback advice is deliberately not just "import from the root". On 1.62.2
and 1.63.2 the root barrel does export all three names — but its `dist/index.mjs`
statically imports `expo-document-picker` and `expo-file-system`, so a reader who
switches to the root inherits exactly the peer-dependency resolution failure that
this guide's `/headless` choice exists to avoid. The note says so and points at
the stub/install requirement.

Also records what `/headless` is, since the guide never said: a lean alternative
entry added so custom-UI consumers skip the chat and attachment native deps, not
a replacement for the root barrel, which remains the package's default full
surface and re-exports everything in `/headless`.

Prose only — no snippet in this page changed, and the page carries no doctest
fences, so the guide's snippets stay runnable as they were.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants