@copilotkit/react-native 1.83.0 → 2.0.0-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.
Files changed (67) hide show
  1. package/USAGE.md +2 -2
  2. package/dist/{CopilotKitProvider-BUVBq9LN.d.mts → CopilotKitProvider-BWjzCdHN.d.mts} +29 -2
  3. package/dist/{CopilotKitProvider-BVPr5t83.d.cts → CopilotKitProvider-Btm10msB.d.cts} +29 -2
  4. package/dist/{CopilotKitProvider-CjoPnabW.cjs → CopilotKitProvider-Byw3cqe2.cjs} +13 -10
  5. package/dist/CopilotKitProvider-Byw3cqe2.cjs.map +1 -0
  6. package/dist/{CopilotKitProvider-D8sn7G_C.mjs → CopilotKitProvider-CE4bc6CP.mjs} +9 -5
  7. package/dist/CopilotKitProvider-CE4bc6CP.mjs.map +1 -0
  8. package/dist/Markdown-1ips7myr.d.cts +52 -0
  9. package/dist/Markdown-C6AsLHmd.mjs +47 -0
  10. package/dist/Markdown-C6AsLHmd.mjs.map +1 -0
  11. package/dist/Markdown-C_9Re36O.cjs +60 -0
  12. package/dist/Markdown-C_9Re36O.cjs.map +1 -0
  13. package/dist/Markdown-JsYh7oSA.d.mts +52 -0
  14. package/dist/MarkdownRendererContext-BRNe808d.cjs +72 -0
  15. package/dist/MarkdownRendererContext-BRNe808d.cjs.map +1 -0
  16. package/dist/MarkdownRendererContext-CAnuohIS.mjs +21 -0
  17. package/dist/MarkdownRendererContext-CAnuohIS.mjs.map +1 -0
  18. package/dist/components/index.cjs +20 -106
  19. package/dist/components/index.cjs.map +1 -1
  20. package/dist/components/index.d.cts +1 -46
  21. package/dist/components/index.d.mts +1 -46
  22. package/dist/components/index.mjs +13 -98
  23. package/dist/components/index.mjs.map +1 -1
  24. package/dist/headless.cjs +22 -22
  25. package/dist/headless.d.cts +4 -3
  26. package/dist/headless.d.mts +4 -3
  27. package/dist/headless.mjs +3 -3
  28. package/dist/index.cjs +32 -27
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +3 -2
  31. package/dist/index.d.mts +3 -2
  32. package/dist/index.mjs +6 -4
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/polyfills/encoding.cjs +1 -1
  35. package/dist/polyfills/streams.cjs +1 -1
  36. package/package.json +6 -9
  37. package/scripts/measure-headless.mjs +2 -2
  38. package/src/CopilotChat.tsx +2 -2
  39. package/src/CopilotKitProvider.tsx +17 -4
  40. package/src/__mocks__/test-copilotkit.tsx +3 -3
  41. package/src/__tests__/attachments-integration.test.tsx +2 -2
  42. package/src/__tests__/copilot-chat-agentid.test.tsx +2 -2
  43. package/src/__tests__/copilot-chat-attachments.test.tsx +2 -2
  44. package/src/__tests__/copilot-popup.test.tsx +2 -2
  45. package/src/__tests__/copilot-sidebar.test.tsx +2 -2
  46. package/src/__tests__/copilotkit-provider.test.tsx +2 -2
  47. package/src/__tests__/headless-entry-surface.test.ts +33 -12
  48. package/src/__tests__/headless-integration.test.tsx +4 -2
  49. package/src/__tests__/headless-value-exports.test.ts +2 -2
  50. package/src/components/CopilotChat.tsx +2 -5
  51. package/src/components/Markdown.tsx +62 -100
  52. package/src/components/MarkdownRendererContext.tsx +40 -0
  53. package/src/components/__tests__/CopilotChat-edge-cases.test.tsx +2 -2
  54. package/src/components/__tests__/CopilotChat.test.tsx +2 -2
  55. package/src/components/__tests__/Markdown.code-alias.test.tsx +59 -0
  56. package/src/components/__tests__/Markdown.test.tsx +6 -75
  57. package/src/components/messages/AssistantMessage.tsx +22 -1
  58. package/src/components/messages/__tests__/AssistantMessage.provider-renderer.test.tsx +73 -0
  59. package/src/components/messages/__tests__/markdown-renderer-config.test.tsx +66 -0
  60. package/src/headless.ts +8 -8
  61. package/src/index.ts +19 -2
  62. package/tsdown.config.ts +0 -1
  63. package/vitest.config.mjs +0 -7
  64. package/dist/CopilotKitProvider-CjoPnabW.cjs.map +0 -1
  65. package/dist/CopilotKitProvider-D8sn7G_C.mjs.map +0 -1
  66. package/dist/chunk-C0xms8kb.cjs +0 -34
  67. package/src/__mocks__/react-native-streamdown.ts +0 -16
package/USAGE.md CHANGED
@@ -5,10 +5,10 @@
5
5
  Install all required peer dependencies:
6
6
 
7
7
  ```bash
8
- npm install react react-native @gorhom/bottom-sheet react-native-gesture-handler react-native-reanimated react-native-streamdown
8
+ npm install react react-native @gorhom/bottom-sheet react-native-gesture-handler react-native-reanimated
9
9
  ```
10
10
 
11
- `@gorhom/bottom-sheet`, `react-native-gesture-handler`, `react-native-reanimated`, and `react-native-streamdown` are required peer dependencies for the UI components.
11
+ `@gorhom/bottom-sheet`, `react-native-gesture-handler`, and `react-native-reanimated` are required peer dependencies for the UI components. `CopilotMarkdown` now uses a built-in basic-GFM renderer — no extra markdown library install required.
12
12
 
13
13
  ## Quick Start
14
14
 
@@ -1,7 +1,26 @@
1
+ import { r as MarkdownStyle } from "./Markdown-JsYh7oSA.mjs";
1
2
  import React, { ReactNode } from "react";
2
3
  import { DebugConfig } from "@copilotkit/shared";
3
4
  import { CopilotKitCoreErrorCode, CopilotKitMessageFilter } from "@copilotkit/core";
4
5
 
6
+ //#region src/components/MarkdownRendererContext.d.ts
7
+ interface NativeMarkdownRendererProps {
8
+ content: string;
9
+ isStreaming?: boolean;
10
+ }
11
+ type NativeMarkdownRenderer = React.ComponentType<NativeMarkdownRendererProps>;
12
+ /** Config for the built-in RN renderer (pass instead of a component). */
13
+ interface DefaultMarkdownRendererProps {
14
+ style?: MarkdownStyle;
15
+ animate?: boolean;
16
+ }
17
+ type MarkdownRendererValue = NativeMarkdownRenderer | DefaultMarkdownRendererProps;
18
+ declare const MarkdownRendererProvider: React.FC<{
19
+ renderer?: MarkdownRendererValue;
20
+ children: React.ReactNode;
21
+ }>;
22
+ declare function useMarkdownRenderer(): MarkdownRendererValue | undefined;
23
+ //#endregion
5
24
  //#region src/CopilotKitProvider.d.ts
6
25
  interface CopilotKitNativeProviderProps {
7
26
  children: ReactNode;
@@ -64,6 +83,14 @@ interface CopilotKitNativeProviderProps {
64
83
  * subscriptions. Individual subscriptions can override with their own `throttleMs`.
65
84
  */
66
85
  defaultThrottleMs?: number;
86
+ /**
87
+ * Custom markdown renderer for assistant messages. Either a component (escape
88
+ * hatch — receives `content` and an optional `isStreaming` flag) used instead
89
+ * of the built-in renderer, or a `{ style, animate }` config object to
90
+ * configure the built-in React Native renderer (the `CopilotMarkdown` used by
91
+ * the default `AssistantMessage`) without writing a wrapper.
92
+ */
93
+ markdownRenderer?: MarkdownRendererValue;
67
94
  }
68
95
  /**
69
96
  * CopilotKit provider for React Native.
@@ -90,5 +117,5 @@ interface CopilotKitNativeProviderProps {
90
117
  */
91
118
  declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
92
119
  //#endregion
93
- export { CopilotKitProvider as n, CopilotKitNativeProviderProps as t };
94
- //# sourceMappingURL=CopilotKitProvider-BUVBq9LN.d.mts.map
120
+ export { NativeMarkdownRendererProps as a, NativeMarkdownRenderer as i, CopilotKitProvider as n, useMarkdownRenderer as o, MarkdownRendererProvider as r, CopilotKitNativeProviderProps as t };
121
+ //# sourceMappingURL=CopilotKitProvider-BWjzCdHN.d.mts.map
@@ -1,7 +1,26 @@
1
+ import { r as MarkdownStyle } from "./Markdown-1ips7myr.cjs";
1
2
  import React, { ReactNode } from "react";
2
3
  import { CopilotKitCoreErrorCode, CopilotKitMessageFilter } from "@copilotkit/core";
3
4
  import { DebugConfig } from "@copilotkit/shared";
4
5
 
6
+ //#region src/components/MarkdownRendererContext.d.ts
7
+ interface NativeMarkdownRendererProps {
8
+ content: string;
9
+ isStreaming?: boolean;
10
+ }
11
+ type NativeMarkdownRenderer = React.ComponentType<NativeMarkdownRendererProps>;
12
+ /** Config for the built-in RN renderer (pass instead of a component). */
13
+ interface DefaultMarkdownRendererProps {
14
+ style?: MarkdownStyle;
15
+ animate?: boolean;
16
+ }
17
+ type MarkdownRendererValue = NativeMarkdownRenderer | DefaultMarkdownRendererProps;
18
+ declare const MarkdownRendererProvider: React.FC<{
19
+ renderer?: MarkdownRendererValue;
20
+ children: React.ReactNode;
21
+ }>;
22
+ declare function useMarkdownRenderer(): MarkdownRendererValue | undefined;
23
+ //#endregion
5
24
  //#region src/CopilotKitProvider.d.ts
6
25
  interface CopilotKitNativeProviderProps {
7
26
  children: ReactNode;
@@ -64,6 +83,14 @@ interface CopilotKitNativeProviderProps {
64
83
  * subscriptions. Individual subscriptions can override with their own `throttleMs`.
65
84
  */
66
85
  defaultThrottleMs?: number;
86
+ /**
87
+ * Custom markdown renderer for assistant messages. Either a component (escape
88
+ * hatch — receives `content` and an optional `isStreaming` flag) used instead
89
+ * of the built-in renderer, or a `{ style, animate }` config object to
90
+ * configure the built-in React Native renderer (the `CopilotMarkdown` used by
91
+ * the default `AssistantMessage`) without writing a wrapper.
92
+ */
93
+ markdownRenderer?: MarkdownRendererValue;
67
94
  }
68
95
  /**
69
96
  * CopilotKit provider for React Native.
@@ -90,5 +117,5 @@ interface CopilotKitNativeProviderProps {
90
117
  */
91
118
  declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
92
119
  //#endregion
93
- export { CopilotKitProvider as n, CopilotKitNativeProviderProps as t };
94
- //# sourceMappingURL=CopilotKitProvider-BVPr5t83.d.cts.map
120
+ export { NativeMarkdownRendererProps as a, NativeMarkdownRenderer as i, CopilotKitProvider as n, useMarkdownRenderer as o, MarkdownRendererProvider as r, CopilotKitNativeProviderProps as t };
121
+ //# sourceMappingURL=CopilotKitProvider-Btm10msB.d.cts.map
@@ -1,8 +1,8 @@
1
- const require_chunk = require('./chunk-C0xms8kb.cjs');
1
+ const require_MarkdownRendererContext = require('./MarkdownRendererContext-BRNe808d.cjs');
2
2
  let react = require("react");
3
- react = require_chunk.__toESM(react);
4
- let _copilotkit_react_core_v2_context = require("@copilotkit/react-core/v2/context");
5
- let _copilotkit_react_core_v2_headless = require("@copilotkit/react-core/v2/headless");
3
+ react = require_MarkdownRendererContext.__toESM(react);
4
+ let _copilotkit_react_core_context = require("@copilotkit/react-core/context");
5
+ let _copilotkit_react_core_headless = require("@copilotkit/react-core/headless");
6
6
  let _copilotkit_shared = require("@copilotkit/shared");
7
7
  let react_jsx_runtime = require("react/jsx-runtime");
8
8
 
@@ -30,13 +30,13 @@ let react_jsx_runtime = require("react/jsx-runtime");
30
30
  * }
31
31
  * ```
32
32
  */
33
- const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, credentials, messageFilter, useSingleEndpoint, properties, onError, debug, defaultThrottleMs }) => {
33
+ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, credentials, messageFilter, useSingleEndpoint, properties, onError, debug, defaultThrottleMs, markdownRenderer }) => {
34
34
  const resolvedHeaders = typeof headersProp === "function" ? headersProp() : headersProp;
35
35
  const stableHeaders = (0, react.useMemo)(() => resolvedHeaders ?? {}, [JSON.stringify(resolvedHeaders)]);
36
36
  const stableProperties = (0, react.useMemo)(() => properties ?? {}, [JSON.stringify(properties)]);
37
37
  const copilotkitRef = (0, react.useRef)(null);
38
38
  if (copilotkitRef.current === null) {
39
- const instance = new _copilotkit_react_core_v2_headless.CopilotKitCoreReact({
39
+ const instance = new _copilotkit_react_core_headless.CopilotKitCoreReact({
40
40
  runtimeUrl,
41
41
  runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
42
42
  headers: stableHeaders,
@@ -109,11 +109,14 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
109
109
  executingToolCallIds
110
110
  }), [copilotkit, executingToolCallIds]);
111
111
  const licenseContextValue = (0, react.useMemo)(() => (0, _copilotkit_shared.createLicenseContextValue)(runtimeLicenseStatus), [runtimeLicenseStatus]);
112
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_context.CopilotKitContext.Provider, {
112
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_context.CopilotKitContext.Provider, {
113
113
  value: contextValue,
114
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_context.LicenseContext.Provider, {
114
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_context.LicenseContext.Provider, {
115
115
  value: licenseContextValue,
116
- children
116
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MarkdownRendererContext.MarkdownRendererProvider, {
117
+ renderer: markdownRenderer,
118
+ children
119
+ })
117
120
  })
118
121
  });
119
122
  };
@@ -125,4 +128,4 @@ Object.defineProperty(exports, 'CopilotKitProvider', {
125
128
  return CopilotKitProvider;
126
129
  }
127
130
  });
128
- //# sourceMappingURL=CopilotKitProvider-CjoPnabW.cjs.map
131
+ //# sourceMappingURL=CopilotKitProvider-Byw3cqe2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopilotKitProvider-Byw3cqe2.cjs","names":["CopilotKitCoreReact","CopilotKitContext","LicenseContext","MarkdownRendererProvider"],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport { CopilotKitCoreReact } from \"@copilotkit/react-core/headless\";\nimport type {\n CopilotKitCoreErrorCode,\n CopilotKitMessageFilter,\n} from \"@copilotkit/core\";\nimport type { DebugConfig, RuntimeLicenseStatus } from \"@copilotkit/shared\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Credentials mode for fetch requests (e.g., \"include\" for HTTP-only cookies in cross-origin requests).\n */\n credentials?: RequestCredentials;\n /**\n * Rewrites the message list sent to runtime agents on every run.\n *\n * CopilotKit sends the whole thread each time. When your agent already\n * stores the conversation, most of that payload is waste, and an agent that\n * merges the inbound list with its own store can show the model every turn\n * twice. Return the messages to send:\n *\n * ```tsx\n * <CopilotKitProvider\n * runtimeUrl=\"/api/copilotkit\"\n * messageFilter={(messages) => messages.slice(-1)}\n * />\n * ```\n *\n * The filter changes the request body only. The transcript the UI renders is\n * untouched. Broken tool-call pairs are repaired before the request is sent,\n * so a filter this blunt cannot strand a tool result mid-HITL.\n *\n * Agents reached through your CopilotRuntime honor this. An agent your app\n * passes in directly does not, and neither Intelligence runs nor suggestion\n * runs are ever filtered.\n *\n * Prefer a stable reference (`useCallback`). An inline arrow re-registers the\n * filter on every render, which is harmless but needless.\n */\n messageFilter?: CopilotKitMessageFilter;\n /** Whether the runtime uses a single-route endpoint */\n useSingleEndpoint?: boolean;\n /** Custom properties forwarded to agents */\n properties?: Record<string, unknown>;\n /**\n * Error handler called when CopilotKit encounters an error.\n * Fires for all error types (runtime connection failures, agent errors, tool errors).\n * If not provided, errors are logged to console.error.\n */\n onError?: (event: {\n error: Error;\n code: CopilotKitCoreErrorCode;\n context: Record<string, any>;\n }) => void | Promise<void>;\n /**\n * Enable debug logging for the client-side event pipeline.\n * When `true`, enables verbose logging from the core instance.\n */\n debug?: DebugConfig;\n /**\n * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`\n * subscriptions. Individual subscriptions can override with their own `throttleMs`.\n */\n defaultThrottleMs?: number;\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n\n if (copilotkitRef.current === null) {\n const instance: CopilotKitCoreReactInstance = new CopilotKitCoreReact({\n runtimeUrl,\n runtimeTransport:\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: stableProperties,\n debug,\n });\n // Set initial defaultThrottleMs synchronously so child hooks see the\n // correct value on their first render (before useEffect fires).\n if (defaultThrottleMs !== undefined) {\n instance.setDefaultThrottleMs(defaultThrottleMs);\n }\n copilotkitRef.current = instance;\n }\n\n const copilotkit = copilotkitRef.current;\n\n // Sync props to core instance\n useEffect(() => {\n copilotkit.setRuntimeUrl(runtimeUrl);\n copilotkit.setRuntimeTransport(\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n );\n copilotkit.setHeaders(stableHeaders);\n copilotkit.setCredentials(credentials);\n copilotkit.setMessageFilter(messageFilter);\n copilotkit.setProperties(stableProperties);\n copilotkit.setDebug(debug);\n }, [\n runtimeUrl,\n useSingleEndpoint,\n stableHeaders,\n credentials,\n messageFilter,\n stableProperties,\n debug,\n copilotkit,\n ]);\n\n // Sync defaultThrottleMs to the core instance on prop changes.\n // Initial value is set synchronously during instance creation (inside the\n // ref guard above), so this only handles subsequent updates.\n useEffect(() => {\n copilotkit.setDefaultThrottleMs(defaultThrottleMs);\n }, [copilotkit, defaultThrottleMs]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState<\n RuntimeLicenseStatus | undefined\n >(undefined);\n\n // Use ref to avoid subscription churn when onError changes\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n // Single subscription for tool execution tracking and error handling.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n onError: (event) => {\n if (onErrorRef.current) {\n onErrorRef.current(event);\n } else {\n console.error(\n `[CopilotKit] Error (${event.code}):`,\n event.error,\n event.context ?? {},\n );\n }\n },\n onRuntimeConnectionStatusChanged: () => {\n setRuntimeLicenseStatus(copilotkit.licenseStatus);\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmHA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,eACA,mBACA,YACA,SACA,OACA,mBACA,uBACI;CAEJ,MAAM,kBACJ,OAAO,gBAAgB,aAAa,aAAa,GAAG;CAKtD,MAAM,yCACE,mBAAmB,EAAE,EAC3B,CAAC,KAAK,UAAU,gBAAgB,CAAC,CAClC;CAED,MAAM,4CACE,cAAc,EAAE,EACtB,CAAC,KAAK,UAAU,WAAW,CAAC,CAC7B;CAED,MAAM,kCAA2D,KAAK;AAEtE,KAAI,cAAc,YAAY,MAAM;EAClC,MAAM,WAAwC,IAAIA,oDAAoB;GACpE;GACA,kBACE,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA;GACR,SAAS;GACT;GACA;GACA,YAAY;GACZ;GACD,CAAC;AAGF,MAAI,sBAAsB,OACxB,UAAS,qBAAqB,kBAAkB;AAElD,gBAAc,UAAU;;CAG1B,MAAM,aAAa,cAAc;AAGjC,4BAAgB;AACd,aAAW,cAAc,WAAW;AACpC,aAAW,oBACT,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA,OACP;AACD,aAAW,WAAW,cAAc;AACpC,aAAW,eAAe,YAAY;AACtC,aAAW,iBAAiB,cAAc;AAC1C,aAAW,cAAc,iBAAiB;AAC1C,aAAW,SAAS,MAAM;IACzB;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAKF,4BAAgB;AACd,aAAW,qBAAqB,kBAAkB;IACjD,CAAC,YAAY,kBAAkB,CAAC;CAKnC,MAAM,CAAC,sBAAsB,qEAErB,IAAI,KAAK,CAAC;CAElB,MAAM,CAAC,sBAAsB,+CAE3B,OAAU;CAGZ,MAAM,+BAAoB,QAAQ;AAClC,4BAAgB;AACd,aAAW,UAAU;IACpB,CAAC,QAAQ,CAAC;AAKb,4BAAgB;EACd,MAAM,eAAe,WAAW,UAAU;GACxC,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEJ,UAAU,UAAU;AAClB,QAAI,WAAW,QACb,YAAW,QAAQ,MAAM;QAEzB,SAAQ,MACN,uBAAuB,MAAM,KAAK,KAClC,MAAM,OACN,MAAM,WAAW,EAAE,CACpB;;GAGL,wCAAwC;AACtC,4BAAwB,WAAW,cAAc;;GAEpD,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,yCACG;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,iGAC4B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,2CAACC,iDAAkB;EAAS,OAAO;YACjC,2CAACC,8CAAe;GAAS,OAAO;aAC9B,2CAACC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC"}
@@ -1,6 +1,7 @@
1
+ import { t as MarkdownRendererProvider } from "./MarkdownRendererContext-CAnuohIS.mjs";
1
2
  import React, { useEffect, useMemo, useRef, useState } from "react";
2
- import { CopilotKitContext, LicenseContext } from "@copilotkit/react-core/v2/context";
3
- import { CopilotKitCoreReact } from "@copilotkit/react-core/v2/headless";
3
+ import { CopilotKitContext, LicenseContext } from "@copilotkit/react-core/context";
4
+ import { CopilotKitCoreReact } from "@copilotkit/react-core/headless";
4
5
  import { createLicenseContextValue } from "@copilotkit/shared";
5
6
  import { jsx } from "react/jsx-runtime";
6
7
 
@@ -28,7 +29,7 @@ import { jsx } from "react/jsx-runtime";
28
29
  * }
29
30
  * ```
30
31
  */
31
- const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, credentials, messageFilter, useSingleEndpoint, properties, onError, debug, defaultThrottleMs }) => {
32
+ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, credentials, messageFilter, useSingleEndpoint, properties, onError, debug, defaultThrottleMs, markdownRenderer }) => {
32
33
  const resolvedHeaders = typeof headersProp === "function" ? headersProp() : headersProp;
33
34
  const stableHeaders = useMemo(() => resolvedHeaders ?? {}, [JSON.stringify(resolvedHeaders)]);
34
35
  const stableProperties = useMemo(() => properties ?? {}, [JSON.stringify(properties)]);
@@ -111,11 +112,14 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
111
112
  value: contextValue,
112
113
  children: /* @__PURE__ */ jsx(LicenseContext.Provider, {
113
114
  value: licenseContextValue,
114
- children
115
+ children: /* @__PURE__ */ jsx(MarkdownRendererProvider, {
116
+ renderer: markdownRenderer,
117
+ children
118
+ })
115
119
  })
116
120
  });
117
121
  };
118
122
 
119
123
  //#endregion
120
124
  export { CopilotKitProvider as t };
121
- //# sourceMappingURL=CopilotKitProvider-D8sn7G_C.mjs.map
125
+ //# sourceMappingURL=CopilotKitProvider-CE4bc6CP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopilotKitProvider-CE4bc6CP.mjs","names":[],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport { CopilotKitCoreReact } from \"@copilotkit/react-core/headless\";\nimport type {\n CopilotKitCoreErrorCode,\n CopilotKitMessageFilter,\n} from \"@copilotkit/core\";\nimport type { DebugConfig, RuntimeLicenseStatus } from \"@copilotkit/shared\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Credentials mode for fetch requests (e.g., \"include\" for HTTP-only cookies in cross-origin requests).\n */\n credentials?: RequestCredentials;\n /**\n * Rewrites the message list sent to runtime agents on every run.\n *\n * CopilotKit sends the whole thread each time. When your agent already\n * stores the conversation, most of that payload is waste, and an agent that\n * merges the inbound list with its own store can show the model every turn\n * twice. Return the messages to send:\n *\n * ```tsx\n * <CopilotKitProvider\n * runtimeUrl=\"/api/copilotkit\"\n * messageFilter={(messages) => messages.slice(-1)}\n * />\n * ```\n *\n * The filter changes the request body only. The transcript the UI renders is\n * untouched. Broken tool-call pairs are repaired before the request is sent,\n * so a filter this blunt cannot strand a tool result mid-HITL.\n *\n * Agents reached through your CopilotRuntime honor this. An agent your app\n * passes in directly does not, and neither Intelligence runs nor suggestion\n * runs are ever filtered.\n *\n * Prefer a stable reference (`useCallback`). An inline arrow re-registers the\n * filter on every render, which is harmless but needless.\n */\n messageFilter?: CopilotKitMessageFilter;\n /** Whether the runtime uses a single-route endpoint */\n useSingleEndpoint?: boolean;\n /** Custom properties forwarded to agents */\n properties?: Record<string, unknown>;\n /**\n * Error handler called when CopilotKit encounters an error.\n * Fires for all error types (runtime connection failures, agent errors, tool errors).\n * If not provided, errors are logged to console.error.\n */\n onError?: (event: {\n error: Error;\n code: CopilotKitCoreErrorCode;\n context: Record<string, any>;\n }) => void | Promise<void>;\n /**\n * Enable debug logging for the client-side event pipeline.\n * When `true`, enables verbose logging from the core instance.\n */\n debug?: DebugConfig;\n /**\n * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`\n * subscriptions. Individual subscriptions can override with their own `throttleMs`.\n */\n defaultThrottleMs?: number;\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n\n if (copilotkitRef.current === null) {\n const instance: CopilotKitCoreReactInstance = new CopilotKitCoreReact({\n runtimeUrl,\n runtimeTransport:\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: stableProperties,\n debug,\n });\n // Set initial defaultThrottleMs synchronously so child hooks see the\n // correct value on their first render (before useEffect fires).\n if (defaultThrottleMs !== undefined) {\n instance.setDefaultThrottleMs(defaultThrottleMs);\n }\n copilotkitRef.current = instance;\n }\n\n const copilotkit = copilotkitRef.current;\n\n // Sync props to core instance\n useEffect(() => {\n copilotkit.setRuntimeUrl(runtimeUrl);\n copilotkit.setRuntimeTransport(\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n );\n copilotkit.setHeaders(stableHeaders);\n copilotkit.setCredentials(credentials);\n copilotkit.setMessageFilter(messageFilter);\n copilotkit.setProperties(stableProperties);\n copilotkit.setDebug(debug);\n }, [\n runtimeUrl,\n useSingleEndpoint,\n stableHeaders,\n credentials,\n messageFilter,\n stableProperties,\n debug,\n copilotkit,\n ]);\n\n // Sync defaultThrottleMs to the core instance on prop changes.\n // Initial value is set synchronously during instance creation (inside the\n // ref guard above), so this only handles subsequent updates.\n useEffect(() => {\n copilotkit.setDefaultThrottleMs(defaultThrottleMs);\n }, [copilotkit, defaultThrottleMs]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState<\n RuntimeLicenseStatus | undefined\n >(undefined);\n\n // Use ref to avoid subscription churn when onError changes\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n // Single subscription for tool execution tracking and error handling.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n onError: (event) => {\n if (onErrorRef.current) {\n onErrorRef.current(event);\n } else {\n console.error(\n `[CopilotKit] Error (${event.code}):`,\n event.error,\n event.context ?? {},\n );\n }\n },\n onRuntimeConnectionStatusChanged: () => {\n setRuntimeLicenseStatus(copilotkit.licenseStatus);\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmHA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,eACA,mBACA,YACA,SACA,OACA,mBACA,uBACI;CAEJ,MAAM,kBACJ,OAAO,gBAAgB,aAAa,aAAa,GAAG;CAKtD,MAAM,gBAAgB,cACd,mBAAmB,EAAE,EAC3B,CAAC,KAAK,UAAU,gBAAgB,CAAC,CAClC;CAED,MAAM,mBAAmB,cACjB,cAAc,EAAE,EACtB,CAAC,KAAK,UAAU,WAAW,CAAC,CAC7B;CAED,MAAM,gBAAgB,OAA2C,KAAK;AAEtE,KAAI,cAAc,YAAY,MAAM;EAClC,MAAM,WAAwC,IAAI,oBAAoB;GACpE;GACA,kBACE,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA;GACR,SAAS;GACT;GACA;GACA,YAAY;GACZ;GACD,CAAC;AAGF,MAAI,sBAAsB,OACxB,UAAS,qBAAqB,kBAAkB;AAElD,gBAAc,UAAU;;CAG1B,MAAM,aAAa,cAAc;AAGjC,iBAAgB;AACd,aAAW,cAAc,WAAW;AACpC,aAAW,oBACT,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA,OACP;AACD,aAAW,WAAW,cAAc;AACpC,aAAW,eAAe,YAAY;AACtC,aAAW,iBAAiB,cAAc;AAC1C,aAAW,cAAc,iBAAiB;AAC1C,aAAW,SAAS,MAAM;IACzB;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAKF,iBAAgB;AACd,aAAW,qBAAqB,kBAAkB;IACjD,CAAC,YAAY,kBAAkB,CAAC;CAKnC,MAAM,CAAC,sBAAsB,2BAA2B,+BAEhD,IAAI,KAAK,CAAC;CAElB,MAAM,CAAC,sBAAsB,2BAA2B,SAEtD,OAAU;CAGZ,MAAM,aAAa,OAAO,QAAQ;AAClC,iBAAgB;AACd,aAAW,UAAU;IACpB,CAAC,QAAQ,CAAC;AAKb,iBAAgB;EACd,MAAM,eAAe,WAAW,UAAU;GACxC,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEJ,UAAU,UAAU;AAClB,QAAI,WAAW,QACb,YAAW,QAAQ,MAAM;QAEzB,SAAQ,MACN,uBAAuB,MAAM,KAAK,KAClC,MAAM,OACN,MAAM,WAAW,EAAE,CACpB;;GAGL,wCAAwC;AACtC,4BAAwB,WAAW,cAAc;;GAEpD,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,eAAuC,eACpC;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,sBAAsB,cACpB,0BAA0B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,oBAAC,kBAAkB;EAAS,OAAO;YACjC,oBAAC,eAAe;GAAS,OAAO;aAC9B,oBAAC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC"}
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import { MarkdownStyle } from "@copilotkit/markdown-renderer/react-native";
3
+
4
+ //#region src/components/Markdown.d.ts
5
+ /**
6
+ * Style map for CopilotMarkdown. Each key maps a node type to a React Native
7
+ * style object. Extends the streaming renderer's style keys with a `code`
8
+ * shorthand kept for backward compatibility (`list` already exists on the
9
+ * base style and needs no alias).
10
+ *
11
+ * @public
12
+ */
13
+ type MarkdownStyle$1 = MarkdownStyle & {
14
+ /** Alias for `inlineCode`; kept for backward compatibility. */code?: Record<string, unknown>;
15
+ };
16
+ /**
17
+ * Default styles that ship with CopilotMarkdown.
18
+ *
19
+ * @public
20
+ */
21
+ declare const defaultMarkdownStyles: MarkdownStyle$1;
22
+ interface CopilotMarkdownProps {
23
+ content: string;
24
+ style?: MarkdownStyle$1;
25
+ /**
26
+ * Toggles `Intl.Segmenter`-based token segmentation in the parser. Defaults
27
+ * to `false` (Hermes-safe: no Segmenter needed). Note: the React Native
28
+ * renderer renders text directly and does not perform per-token fade-in
29
+ * animation, so this currently has no visual effect — it is accepted for
30
+ * backward compatibility.
31
+ */
32
+ streamingAnimation?: boolean;
33
+ }
34
+ /**
35
+ * GFM markdown renderer for React Native. Delegates to the shared
36
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
37
+ *
38
+ * Public API is backward-compatible with the previous basic renderer:
39
+ * - `CopilotMarkdownProps` — same shape.
40
+ * - `MarkdownStyle` / `defaultMarkdownStyles` — same exports.
41
+ * - `streamingAnimation` maps to `animate` (defaults `false` = Hermes-safe).
42
+ *
43
+ * @public
44
+ */
45
+ declare function CopilotMarkdown({
46
+ content,
47
+ style,
48
+ streamingAnimation
49
+ }: CopilotMarkdownProps): React.ReactElement | null;
50
+ //#endregion
51
+ export { defaultMarkdownStyles as i, CopilotMarkdownProps as n, MarkdownStyle$1 as r, CopilotMarkdown as t };
52
+ //# sourceMappingURL=Markdown-1ips7myr.d.cts.map
@@ -0,0 +1,47 @@
1
+ import React from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { StreamingMarkdownRenderer, defaultMarkdownStyles } from "@copilotkit/markdown-renderer/react-native";
4
+ import { warnUnsupportedRichSyntaxOnce } from "@copilotkit/markdown-renderer";
5
+
6
+ //#region src/components/Markdown.tsx
7
+ /**
8
+ * Default styles that ship with CopilotMarkdown.
9
+ *
10
+ * @public
11
+ */
12
+ const defaultMarkdownStyles$1 = {
13
+ ...defaultMarkdownStyles,
14
+ code: defaultMarkdownStyles.inlineCode
15
+ };
16
+ /**
17
+ * GFM markdown renderer for React Native. Delegates to the shared
18
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
19
+ *
20
+ * Public API is backward-compatible with the previous basic renderer:
21
+ * - `CopilotMarkdownProps` — same shape.
22
+ * - `MarkdownStyle` / `defaultMarkdownStyles` — same exports.
23
+ * - `streamingAnimation` maps to `animate` (defaults `false` = Hermes-safe).
24
+ *
25
+ * @public
26
+ */
27
+ function CopilotMarkdown({ content, style, streamingAnimation = false }) {
28
+ warnUnsupportedRichSyntaxOnce(content);
29
+ let resolvedStyle = style;
30
+ if (style?.code !== void 0) {
31
+ const { code, ...rest } = style;
32
+ resolvedStyle = {
33
+ ...rest,
34
+ inlineCode: rest.inlineCode ?? code
35
+ };
36
+ }
37
+ return /* @__PURE__ */ jsx(StreamingMarkdownRenderer, {
38
+ content,
39
+ isComplete: true,
40
+ style: resolvedStyle,
41
+ animate: streamingAnimation
42
+ });
43
+ }
44
+
45
+ //#endregion
46
+ export { defaultMarkdownStyles$1 as n, CopilotMarkdown as t };
47
+ //# sourceMappingURL=Markdown-C6AsLHmd.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown-C6AsLHmd.mjs","names":["defaultMarkdownStyles","_streamingDefaultStyles"],"sources":["../src/components/Markdown.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n StreamingMarkdownRenderer,\n defaultMarkdownStyles as _streamingDefaultStyles,\n} from \"@copilotkit/markdown-renderer/react-native\";\nimport type { MarkdownStyle as StreamingMarkdownStyle } from \"@copilotkit/markdown-renderer/react-native\";\nimport { warnUnsupportedRichSyntaxOnce } from \"@copilotkit/markdown-renderer\";\n\n/**\n * Style map for CopilotMarkdown. Each key maps a node type to a React Native\n * style object. Extends the streaming renderer's style keys with a `code`\n * shorthand kept for backward compatibility (`list` already exists on the\n * base style and needs no alias).\n *\n * @public\n */\nexport type MarkdownStyle = StreamingMarkdownStyle & {\n /** Alias for `inlineCode`; kept for backward compatibility. */\n code?: Record<string, unknown>;\n};\n\n/**\n * Default styles that ship with CopilotMarkdown.\n *\n * @public\n */\nexport const defaultMarkdownStyles: MarkdownStyle = {\n ..._streamingDefaultStyles,\n // Back-compat alias: `code` = same as `inlineCode`\n code: _streamingDefaultStyles.inlineCode,\n};\n\nexport interface CopilotMarkdownProps {\n content: string;\n style?: MarkdownStyle;\n /**\n * Toggles `Intl.Segmenter`-based token segmentation in the parser. Defaults\n * to `false` (Hermes-safe: no Segmenter needed). Note: the React Native\n * renderer renders text directly and does not perform per-token fade-in\n * animation, so this currently has no visual effect — it is accepted for\n * backward compatibility.\n */\n streamingAnimation?: boolean;\n}\n\n/**\n * GFM markdown renderer for React Native. Delegates to the shared\n * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.\n *\n * Public API is backward-compatible with the previous basic renderer:\n * - `CopilotMarkdownProps` — same shape.\n * - `MarkdownStyle` / `defaultMarkdownStyles` — same exports.\n * - `streamingAnimation` maps to `animate` (defaults `false` = Hermes-safe).\n *\n * @public\n */\nexport function CopilotMarkdown({\n content,\n style,\n streamingAnimation = false,\n}: CopilotMarkdownProps): React.ReactElement | null {\n // Translate the back-compat `code` alias onto `inlineCode` — the key the\n // streaming renderer actually reads. Without this, a caller migrating from\n // the previous renderer who passes `style={{ code: ... }}` would silently\n // lose inline-code styling. An explicit `inlineCode` wins over the alias.\n // Dev-only: nudge upgraders from the bundled Streamdown default when their\n // content needs math/syntax highlighting the built-in renderer doesn't do.\n warnUnsupportedRichSyntaxOnce(content);\n\n let resolvedStyle = style as StreamingMarkdownStyle | undefined;\n if (style?.code !== undefined) {\n const { code, ...rest } = style;\n resolvedStyle = {\n ...(rest as StreamingMarkdownStyle),\n inlineCode: (rest as StreamingMarkdownStyle).inlineCode ?? code,\n };\n }\n return (\n <StreamingMarkdownRenderer\n content={content}\n isComplete={true}\n style={resolvedStyle}\n animate={streamingAnimation}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AA0BA,MAAaA,0BAAuC;CAClD,GAAGC;CAEH,MAAMA,sBAAwB;CAC/B;;;;;;;;;;;;AA0BD,SAAgB,gBAAgB,EAC9B,SACA,OACA,qBAAqB,SAC6B;AAOlD,+BAA8B,QAAQ;CAEtC,IAAI,gBAAgB;AACpB,KAAI,OAAO,SAAS,QAAW;EAC7B,MAAM,EAAE,MAAM,GAAG,SAAS;AAC1B,kBAAgB;GACd,GAAI;GACJ,YAAa,KAAgC,cAAc;GAC5D;;AAEH,QACE,oBAAC;EACU;EACT,YAAY;EACZ,OAAO;EACP,SAAS;GACT"}
@@ -0,0 +1,60 @@
1
+ const require_MarkdownRendererContext = require('./MarkdownRendererContext-BRNe808d.cjs');
2
+ let react = require("react");
3
+ react = require_MarkdownRendererContext.__toESM(react);
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+ let _copilotkit_markdown_renderer_react_native = require("@copilotkit/markdown-renderer/react-native");
6
+ let _copilotkit_markdown_renderer = require("@copilotkit/markdown-renderer");
7
+
8
+ //#region src/components/Markdown.tsx
9
+ /**
10
+ * Default styles that ship with CopilotMarkdown.
11
+ *
12
+ * @public
13
+ */
14
+ const defaultMarkdownStyles = {
15
+ ..._copilotkit_markdown_renderer_react_native.defaultMarkdownStyles,
16
+ code: _copilotkit_markdown_renderer_react_native.defaultMarkdownStyles.inlineCode
17
+ };
18
+ /**
19
+ * GFM markdown renderer for React Native. Delegates to the shared
20
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
21
+ *
22
+ * Public API is backward-compatible with the previous basic renderer:
23
+ * - `CopilotMarkdownProps` — same shape.
24
+ * - `MarkdownStyle` / `defaultMarkdownStyles` — same exports.
25
+ * - `streamingAnimation` maps to `animate` (defaults `false` = Hermes-safe).
26
+ *
27
+ * @public
28
+ */
29
+ function CopilotMarkdown({ content, style, streamingAnimation = false }) {
30
+ (0, _copilotkit_markdown_renderer.warnUnsupportedRichSyntaxOnce)(content);
31
+ let resolvedStyle = style;
32
+ if (style?.code !== void 0) {
33
+ const { code, ...rest } = style;
34
+ resolvedStyle = {
35
+ ...rest,
36
+ inlineCode: rest.inlineCode ?? code
37
+ };
38
+ }
39
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_markdown_renderer_react_native.StreamingMarkdownRenderer, {
40
+ content,
41
+ isComplete: true,
42
+ style: resolvedStyle,
43
+ animate: streamingAnimation
44
+ });
45
+ }
46
+
47
+ //#endregion
48
+ Object.defineProperty(exports, 'CopilotMarkdown', {
49
+ enumerable: true,
50
+ get: function () {
51
+ return CopilotMarkdown;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, 'defaultMarkdownStyles', {
55
+ enumerable: true,
56
+ get: function () {
57
+ return defaultMarkdownStyles;
58
+ }
59
+ });
60
+ //# sourceMappingURL=Markdown-C_9Re36O.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown-C_9Re36O.cjs","names":["_streamingDefaultStyles","StreamingMarkdownRenderer"],"sources":["../src/components/Markdown.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n StreamingMarkdownRenderer,\n defaultMarkdownStyles as _streamingDefaultStyles,\n} from \"@copilotkit/markdown-renderer/react-native\";\nimport type { MarkdownStyle as StreamingMarkdownStyle } from \"@copilotkit/markdown-renderer/react-native\";\nimport { warnUnsupportedRichSyntaxOnce } from \"@copilotkit/markdown-renderer\";\n\n/**\n * Style map for CopilotMarkdown. Each key maps a node type to a React Native\n * style object. Extends the streaming renderer's style keys with a `code`\n * shorthand kept for backward compatibility (`list` already exists on the\n * base style and needs no alias).\n *\n * @public\n */\nexport type MarkdownStyle = StreamingMarkdownStyle & {\n /** Alias for `inlineCode`; kept for backward compatibility. */\n code?: Record<string, unknown>;\n};\n\n/**\n * Default styles that ship with CopilotMarkdown.\n *\n * @public\n */\nexport const defaultMarkdownStyles: MarkdownStyle = {\n ..._streamingDefaultStyles,\n // Back-compat alias: `code` = same as `inlineCode`\n code: _streamingDefaultStyles.inlineCode,\n};\n\nexport interface CopilotMarkdownProps {\n content: string;\n style?: MarkdownStyle;\n /**\n * Toggles `Intl.Segmenter`-based token segmentation in the parser. Defaults\n * to `false` (Hermes-safe: no Segmenter needed). Note: the React Native\n * renderer renders text directly and does not perform per-token fade-in\n * animation, so this currently has no visual effect — it is accepted for\n * backward compatibility.\n */\n streamingAnimation?: boolean;\n}\n\n/**\n * GFM markdown renderer for React Native. Delegates to the shared\n * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.\n *\n * Public API is backward-compatible with the previous basic renderer:\n * - `CopilotMarkdownProps` — same shape.\n * - `MarkdownStyle` / `defaultMarkdownStyles` — same exports.\n * - `streamingAnimation` maps to `animate` (defaults `false` = Hermes-safe).\n *\n * @public\n */\nexport function CopilotMarkdown({\n content,\n style,\n streamingAnimation = false,\n}: CopilotMarkdownProps): React.ReactElement | null {\n // Translate the back-compat `code` alias onto `inlineCode` — the key the\n // streaming renderer actually reads. Without this, a caller migrating from\n // the previous renderer who passes `style={{ code: ... }}` would silently\n // lose inline-code styling. An explicit `inlineCode` wins over the alias.\n // Dev-only: nudge upgraders from the bundled Streamdown default when their\n // content needs math/syntax highlighting the built-in renderer doesn't do.\n warnUnsupportedRichSyntaxOnce(content);\n\n let resolvedStyle = style as StreamingMarkdownStyle | undefined;\n if (style?.code !== undefined) {\n const { code, ...rest } = style;\n resolvedStyle = {\n ...(rest as StreamingMarkdownStyle),\n inlineCode: (rest as StreamingMarkdownStyle).inlineCode ?? code,\n };\n }\n return (\n <StreamingMarkdownRenderer\n content={content}\n isComplete={true}\n style={resolvedStyle}\n animate={streamingAnimation}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,MAAa,wBAAuC;CAClD,GAAGA;CAEH,MAAMA,iEAAwB;CAC/B;;;;;;;;;;;;AA0BD,SAAgB,gBAAgB,EAC9B,SACA,OACA,qBAAqB,SAC6B;AAOlD,kEAA8B,QAAQ;CAEtC,IAAI,gBAAgB;AACpB,KAAI,OAAO,SAAS,QAAW;EAC7B,MAAM,EAAE,MAAM,GAAG,SAAS;AAC1B,kBAAgB;GACd,GAAI;GACJ,YAAa,KAAgC,cAAc;GAC5D;;AAEH,QACE,2CAACC;EACU;EACT,YAAY;EACZ,OAAO;EACP,SAAS;GACT"}
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import { MarkdownStyle } from "@copilotkit/markdown-renderer/react-native";
3
+
4
+ //#region src/components/Markdown.d.ts
5
+ /**
6
+ * Style map for CopilotMarkdown. Each key maps a node type to a React Native
7
+ * style object. Extends the streaming renderer's style keys with a `code`
8
+ * shorthand kept for backward compatibility (`list` already exists on the
9
+ * base style and needs no alias).
10
+ *
11
+ * @public
12
+ */
13
+ type MarkdownStyle$1 = MarkdownStyle & {
14
+ /** Alias for `inlineCode`; kept for backward compatibility. */code?: Record<string, unknown>;
15
+ };
16
+ /**
17
+ * Default styles that ship with CopilotMarkdown.
18
+ *
19
+ * @public
20
+ */
21
+ declare const defaultMarkdownStyles$1: MarkdownStyle$1;
22
+ interface CopilotMarkdownProps {
23
+ content: string;
24
+ style?: MarkdownStyle$1;
25
+ /**
26
+ * Toggles `Intl.Segmenter`-based token segmentation in the parser. Defaults
27
+ * to `false` (Hermes-safe: no Segmenter needed). Note: the React Native
28
+ * renderer renders text directly and does not perform per-token fade-in
29
+ * animation, so this currently has no visual effect — it is accepted for
30
+ * backward compatibility.
31
+ */
32
+ streamingAnimation?: boolean;
33
+ }
34
+ /**
35
+ * GFM markdown renderer for React Native. Delegates to the shared
36
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
37
+ *
38
+ * Public API is backward-compatible with the previous basic renderer:
39
+ * - `CopilotMarkdownProps` — same shape.
40
+ * - `MarkdownStyle` / `defaultMarkdownStyles` — same exports.
41
+ * - `streamingAnimation` maps to `animate` (defaults `false` = Hermes-safe).
42
+ *
43
+ * @public
44
+ */
45
+ declare function CopilotMarkdown({
46
+ content,
47
+ style,
48
+ streamingAnimation
49
+ }: CopilotMarkdownProps): React.ReactElement | null;
50
+ //#endregion
51
+ export { defaultMarkdownStyles$1 as i, CopilotMarkdownProps as n, MarkdownStyle$1 as r, CopilotMarkdown as t };
52
+ //# sourceMappingURL=Markdown-JsYh7oSA.d.mts.map
@@ -0,0 +1,72 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+ let react = require("react");
29
+ react = __toESM(react);
30
+ let react_jsx_runtime = require("react/jsx-runtime");
31
+
32
+ //#region src/components/MarkdownRendererContext.tsx
33
+ /** A component is a function or an object carrying React's `$$typeof` (forwardRef/memo). */
34
+ function isNativeComponentRenderer(value) {
35
+ if (typeof value === "function") return true;
36
+ return !!value && typeof value === "object" && "$$typeof" in value;
37
+ }
38
+ const Ctx = (0, react.createContext)(void 0);
39
+ const MarkdownRendererProvider = ({ renderer, children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Ctx.Provider, {
40
+ value: renderer,
41
+ children
42
+ });
43
+ function useMarkdownRenderer() {
44
+ return (0, react.useContext)(Ctx);
45
+ }
46
+
47
+ //#endregion
48
+ Object.defineProperty(exports, 'MarkdownRendererProvider', {
49
+ enumerable: true,
50
+ get: function () {
51
+ return MarkdownRendererProvider;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, '__toESM', {
55
+ enumerable: true,
56
+ get: function () {
57
+ return __toESM;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, 'isNativeComponentRenderer', {
61
+ enumerable: true,
62
+ get: function () {
63
+ return isNativeComponentRenderer;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, 'useMarkdownRenderer', {
67
+ enumerable: true,
68
+ get: function () {
69
+ return useMarkdownRenderer;
70
+ }
71
+ });
72
+ //# sourceMappingURL=MarkdownRendererContext-BRNe808d.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownRendererContext-BRNe808d.cjs","names":[],"sources":["../src/components/MarkdownRendererContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport type { MarkdownStyle } from \"./Markdown\";\n\nexport interface NativeMarkdownRendererProps {\n content: string;\n isStreaming?: boolean;\n}\n\nexport type NativeMarkdownRenderer =\n React.ComponentType<NativeMarkdownRendererProps>;\n\n/** Config for the built-in RN renderer (pass instead of a component). */\nexport interface DefaultMarkdownRendererProps {\n style?: MarkdownStyle;\n animate?: boolean;\n}\nexport type MarkdownRendererValue =\n | NativeMarkdownRenderer\n | DefaultMarkdownRendererProps;\n\n/** A component is a function or an object carrying React's `$$typeof` (forwardRef/memo). */\nexport function isNativeComponentRenderer(\n value: unknown,\n): value is NativeMarkdownRenderer {\n if (typeof value === \"function\") return true;\n return !!value && typeof value === \"object\" && \"$$typeof\" in value;\n}\n\nconst Ctx = createContext<MarkdownRendererValue | undefined>(undefined);\n\nexport const MarkdownRendererProvider: React.FC<{\n renderer?: MarkdownRendererValue;\n children: React.ReactNode;\n}> = ({ renderer, children }) => (\n <Ctx.Provider value={renderer}>{children}</Ctx.Provider>\n);\n\nexport function useMarkdownRenderer(): MarkdownRendererValue | undefined {\n return useContext(Ctx);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,0BACd,OACiC;AACjC,KAAI,OAAO,UAAU,WAAY,QAAO;AACxC,QAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,cAAc;;AAG/D,MAAM,+BAAuD,OAAU;AAEvE,MAAa,4BAGP,EAAE,UAAU,eAChB,2CAAC,IAAI;CAAS,OAAO;CAAW;EAAwB;AAG1D,SAAgB,sBAAyD;AACvE,8BAAkB,IAAI"}
@@ -0,0 +1,21 @@
1
+ import React, { createContext, useContext } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+
4
+ //#region src/components/MarkdownRendererContext.tsx
5
+ /** A component is a function or an object carrying React's `$$typeof` (forwardRef/memo). */
6
+ function isNativeComponentRenderer(value) {
7
+ if (typeof value === "function") return true;
8
+ return !!value && typeof value === "object" && "$$typeof" in value;
9
+ }
10
+ const Ctx = createContext(void 0);
11
+ const MarkdownRendererProvider = ({ renderer, children }) => /* @__PURE__ */ jsx(Ctx.Provider, {
12
+ value: renderer,
13
+ children
14
+ });
15
+ function useMarkdownRenderer() {
16
+ return useContext(Ctx);
17
+ }
18
+
19
+ //#endregion
20
+ export { isNativeComponentRenderer as n, useMarkdownRenderer as r, MarkdownRendererProvider as t };
21
+ //# sourceMappingURL=MarkdownRendererContext-CAnuohIS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownRendererContext-CAnuohIS.mjs","names":[],"sources":["../src/components/MarkdownRendererContext.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport type { MarkdownStyle } from \"./Markdown\";\n\nexport interface NativeMarkdownRendererProps {\n content: string;\n isStreaming?: boolean;\n}\n\nexport type NativeMarkdownRenderer =\n React.ComponentType<NativeMarkdownRendererProps>;\n\n/** Config for the built-in RN renderer (pass instead of a component). */\nexport interface DefaultMarkdownRendererProps {\n style?: MarkdownStyle;\n animate?: boolean;\n}\nexport type MarkdownRendererValue =\n | NativeMarkdownRenderer\n | DefaultMarkdownRendererProps;\n\n/** A component is a function or an object carrying React's `$$typeof` (forwardRef/memo). */\nexport function isNativeComponentRenderer(\n value: unknown,\n): value is NativeMarkdownRenderer {\n if (typeof value === \"function\") return true;\n return !!value && typeof value === \"object\" && \"$$typeof\" in value;\n}\n\nconst Ctx = createContext<MarkdownRendererValue | undefined>(undefined);\n\nexport const MarkdownRendererProvider: React.FC<{\n renderer?: MarkdownRendererValue;\n children: React.ReactNode;\n}> = ({ renderer, children }) => (\n <Ctx.Provider value={renderer}>{children}</Ctx.Provider>\n);\n\nexport function useMarkdownRenderer(): MarkdownRendererValue | undefined {\n return useContext(Ctx);\n}\n"],"mappings":";;;;;AAqBA,SAAgB,0BACd,OACiC;AACjC,KAAI,OAAO,UAAU,WAAY,QAAO;AACxC,QAAO,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,cAAc;;AAG/D,MAAM,MAAM,cAAiD,OAAU;AAEvE,MAAa,4BAGP,EAAE,UAAU,eAChB,oBAAC,IAAI;CAAS,OAAO;CAAW;EAAwB;AAG1D,SAAgB,sBAAyD;AACvE,QAAO,WAAW,IAAI"}