@copilotkit/react-native 2.0.0-rc.3 → 2.0.0-rc.31

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 (84) hide show
  1. package/dist/{CopilotKitProvider-CE4bc6CP.mjs → CopilotKitProvider-BXpkAl1Y.mjs} +55 -42
  2. package/dist/CopilotKitProvider-BXpkAl1Y.mjs.map +1 -0
  3. package/dist/{CopilotKitProvider-Byw3cqe2.cjs → CopilotKitProvider-DDPbJkHS.cjs} +53 -40
  4. package/dist/CopilotKitProvider-DDPbJkHS.cjs.map +1 -0
  5. package/dist/CopilotKitProvider-F7Pn5kp4.d.cts +65 -0
  6. package/dist/CopilotKitProvider-Khgz5dQo.d.mts +65 -0
  7. package/dist/{Markdown-C_9Re36O.cjs → Markdown-CaYHlD4j.cjs} +8 -8
  8. package/dist/Markdown-CaYHlD4j.cjs.map +1 -0
  9. package/dist/{Markdown-1ips7myr.d.cts → Markdown-DzjnSuu5.d.cts} +3 -3
  10. package/dist/{Markdown-C6AsLHmd.mjs → Markdown-SE9MfY2U.mjs} +4 -4
  11. package/dist/Markdown-SE9MfY2U.mjs.map +1 -0
  12. package/dist/{Markdown-JsYh7oSA.d.mts → Markdown-a-rdG22_.d.mts} +3 -3
  13. package/dist/{MarkdownRendererContext-CAnuohIS.mjs → MarkdownRendererContext-B_AKdPAN.mjs} +1 -1
  14. package/dist/{MarkdownRendererContext-CAnuohIS.mjs.map → MarkdownRendererContext-B_AKdPAN.mjs.map} +1 -1
  15. package/dist/components/index.cjs +73 -172
  16. package/dist/components/index.cjs.map +1 -1
  17. package/dist/components/index.d.cts +2 -2
  18. package/dist/components/index.d.mts +2 -2
  19. package/dist/components/index.mjs +75 -174
  20. package/dist/components/index.mjs.map +1 -1
  21. package/dist/headless.cjs +2 -1
  22. package/dist/headless.d.cts +2 -2
  23. package/dist/headless.d.mts +2 -2
  24. package/dist/headless.mjs +2 -1
  25. package/dist/index.cjs +126 -158
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +35 -17
  28. package/dist/index.d.mts +36 -18
  29. package/dist/index.mjs +130 -161
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/polyfills/encoding.cjs +5 -5
  32. package/dist/polyfills/encoding.cjs.map +1 -1
  33. package/dist/polyfills/encoding.mjs +5 -4
  34. package/dist/polyfills/encoding.mjs.map +1 -1
  35. package/dist/polyfills.cjs +2 -1
  36. package/dist/polyfills.cjs.map +1 -1
  37. package/dist/polyfills.mjs +2 -1
  38. package/dist/polyfills.mjs.map +1 -1
  39. package/dist/{streaming-fetch-Dm1oN4f2.mjs → streaming-fetch-CLHG3Z1H.mjs} +1 -1
  40. package/dist/{streaming-fetch-Dm1oN4f2.mjs.map → streaming-fetch-CLHG3Z1H.mjs.map} +1 -1
  41. package/dist/{streaming-fetch-Bm91EsRc.cjs → streaming-fetch-DbDALGya.cjs} +1 -1
  42. package/dist/{streaming-fetch-Bm91EsRc.cjs.map → streaming-fetch-DbDALGya.cjs.map} +1 -1
  43. package/dist/utf8-BIN9t4Oy.mjs +113 -0
  44. package/dist/utf8-BIN9t4Oy.mjs.map +1 -0
  45. package/dist/utf8-Cf3Ssy33.cjs +125 -0
  46. package/dist/utf8-Cf3Ssy33.cjs.map +1 -0
  47. package/package.json +12 -21
  48. package/scripts/verify-polyfill-barrel.mjs +4 -6
  49. package/src/CopilotChat.tsx +114 -93
  50. package/src/CopilotKitProvider.tsx +87 -130
  51. package/src/CopilotPopup.tsx +2 -2
  52. package/src/CopilotSidebar.tsx +7 -5
  53. package/src/__mocks__/react-native.ts +31 -0
  54. package/src/__mocks__/test-copilotkit.tsx +9 -3
  55. package/src/__tests__/attachments-integration.test.tsx +15 -2
  56. package/src/__tests__/copilot-chat-agentid.test.tsx +15 -2
  57. package/src/__tests__/copilot-chat-attachments.test.tsx +15 -2
  58. package/src/__tests__/copilot-chat-configuration.test.tsx +82 -0
  59. package/src/__tests__/copilot-chat-threads.test.tsx +232 -0
  60. package/src/__tests__/copilot-popup.test.tsx +15 -2
  61. package/src/__tests__/copilot-sidebar.test.tsx +15 -2
  62. package/src/__tests__/copilotkit-provider.test.tsx +68 -73
  63. package/src/__tests__/headless-integration.test.tsx +11 -1
  64. package/src/__tests__/use-attachments.test.ts +27 -2
  65. package/src/components/CopilotChat.tsx +106 -233
  66. package/src/components/CopilotModal.tsx +1 -1
  67. package/src/components/Markdown.tsx +4 -4
  68. package/src/components/__tests__/CopilotChat-edge-cases.test.tsx +5 -1
  69. package/src/components/__tests__/CopilotChat.test.tsx +12 -4
  70. package/src/components/__tests__/CopilotChatInterrupt.test.tsx +208 -0
  71. package/src/components/__tests__/Markdown.code-alias.test.tsx +1 -1
  72. package/src/components/messages/AssistantMessage.tsx +3 -3
  73. package/src/components/messages/TypingIndicator.tsx +4 -4
  74. package/src/hooks/use-attachments.ts +95 -139
  75. package/src/polyfills/__tests__/utf8.test.ts +112 -0
  76. package/src/polyfills/encoding.ts +5 -4
  77. package/src/polyfills/utf8.ts +151 -0
  78. package/src/types.d.ts +0 -13
  79. package/dist/CopilotKitProvider-BWjzCdHN.d.mts +0 -121
  80. package/dist/CopilotKitProvider-Btm10msB.d.cts +0 -121
  81. package/dist/CopilotKitProvider-Byw3cqe2.cjs.map +0 -1
  82. package/dist/CopilotKitProvider-CE4bc6CP.mjs.map +0 -1
  83. package/dist/Markdown-C6AsLHmd.mjs.map +0 -1
  84. package/dist/Markdown-C_9Re36O.cjs.map +0 -1
@@ -1,7 +1,8 @@
1
- import { t as MarkdownRendererProvider } from "./MarkdownRendererContext-CAnuohIS.mjs";
1
+ import { t as MarkdownRendererProvider } from "./MarkdownRendererContext-B_AKdPAN.mjs";
2
2
  import React, { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { CopilotKitContext, LicenseContext } from "@copilotkit/react-core/context";
4
- import { CopilotKitCoreReact } from "@copilotkit/react-core/headless";
4
+ import { CopilotKitCoreReact, ɵuseOwnedCore } from "@copilotkit/react-core/headless";
5
+ import { ɵreportProviderConfigDiagnostics, ɵresolveProviderConfig } from "@copilotkit/core";
5
6
  import { createLicenseContextValue } from "@copilotkit/shared";
6
7
  import { jsx } from "react/jsx-runtime";
7
8
 
@@ -33,48 +34,67 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
33
34
  const resolvedHeaders = typeof headersProp === "function" ? headersProp() : headersProp;
34
35
  const stableHeaders = useMemo(() => resolvedHeaders ?? {}, [JSON.stringify(resolvedHeaders)]);
35
36
  const stableProperties = useMemo(() => properties ?? {}, [JSON.stringify(properties)]);
36
- const copilotkitRef = useRef(null);
37
- if (copilotkitRef.current === null) {
38
- const instance = new CopilotKitCoreReact({
39
- runtimeUrl,
40
- runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
37
+ const resolvedConfig = useMemo(() => ɵresolveProviderConfig({
38
+ runtimeUrl,
39
+ useSingleEndpoint,
40
+ properties: stableProperties
41
+ }), [
42
+ runtimeUrl,
43
+ useSingleEndpoint,
44
+ stableProperties
45
+ ]);
46
+ const loggedDiagnosticsRef = useRef(/* @__PURE__ */ new Set());
47
+ ɵreportProviderConfigDiagnostics(resolvedConfig.diagnostics, {
48
+ isProduction: process.env.NODE_ENV === "production",
49
+ logged: loggedDiagnosticsRef.current
50
+ });
51
+ const copilotkit = ɵuseOwnedCore(useRef(null), () => new CopilotKitCoreReact({
52
+ runtimeUrl: resolvedConfig.runtimeUrl,
53
+ runtimeTransport: resolvedConfig.runtimeTransport,
54
+ deferInitialConnection: true,
55
+ headers: stableHeaders,
56
+ credentials,
57
+ messageFilter,
58
+ properties: resolvedConfig.properties,
59
+ debug,
60
+ defaultThrottleMs,
61
+ onError
62
+ }));
63
+ useEffect(() => {
64
+ copilotkit.setErrorHandler(onError);
65
+ }, [copilotkit, onError]);
66
+ useEffect(() => {
67
+ copilotkit.ɵupdateConfig({
68
+ messageFilter,
69
+ runtimeUrl: resolvedConfig.runtimeUrl,
70
+ runtimeTransport: resolvedConfig.runtimeTransport,
41
71
  headers: stableHeaders,
42
72
  credentials,
43
- messageFilter,
44
- properties: stableProperties,
45
- debug
73
+ properties: resolvedConfig.properties,
74
+ debug,
75
+ defaultThrottleMs
46
76
  });
47
- if (defaultThrottleMs !== void 0) instance.setDefaultThrottleMs(defaultThrottleMs);
48
- copilotkitRef.current = instance;
49
- }
50
- const copilotkit = copilotkitRef.current;
51
- useEffect(() => {
52
- copilotkit.setRuntimeUrl(runtimeUrl);
53
- copilotkit.setRuntimeTransport(useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto");
54
- copilotkit.setHeaders(stableHeaders);
55
- copilotkit.setCredentials(credentials);
56
- copilotkit.setMessageFilter(messageFilter);
57
- copilotkit.setProperties(stableProperties);
58
- copilotkit.setDebug(debug);
77
+ copilotkit.connect();
59
78
  }, [
60
- runtimeUrl,
61
- useSingleEndpoint,
79
+ copilotkit,
80
+ messageFilter,
81
+ resolvedConfig.runtimeUrl,
82
+ resolvedConfig.runtimeTransport,
62
83
  stableHeaders,
63
84
  credentials,
64
- messageFilter,
65
- stableProperties,
85
+ resolvedConfig.properties,
66
86
  debug,
67
- copilotkit
87
+ defaultThrottleMs
68
88
  ]);
69
- useEffect(() => {
70
- copilotkit.setDefaultThrottleMs(defaultThrottleMs);
71
- }, [copilotkit, defaultThrottleMs]);
72
89
  const [executingToolCallIds, setExecutingToolCallIds] = useState(() => /* @__PURE__ */ new Set());
73
- const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState(void 0);
74
- const onErrorRef = useRef(onError);
90
+ const [runtimeInfo, setRuntimeInfo] = useState(null);
91
+ const runtimeLicenseStatus = runtimeInfo?.licenseStatus;
75
92
  useEffect(() => {
76
- onErrorRef.current = onError;
77
- }, [onError]);
93
+ const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);
94
+ const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);
95
+ syncRuntimeInfo();
96
+ return unsubscribe;
97
+ }, [copilotkit]);
78
98
  useEffect(() => {
79
99
  const subscription = copilotkit.subscribe({
80
100
  onToolExecutionStart: ({ toolCallId }) => {
@@ -92,13 +112,6 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
92
112
  next.delete(toolCallId);
93
113
  return next;
94
114
  });
95
- },
96
- onError: (event) => {
97
- if (onErrorRef.current) onErrorRef.current(event);
98
- else console.error(`[CopilotKit] Error (${event.code}):`, event.error, event.context ?? {});
99
- },
100
- onRuntimeConnectionStatusChanged: () => {
101
- setRuntimeLicenseStatus(copilotkit.licenseStatus);
102
115
  }
103
116
  });
104
117
  return () => subscription.unsubscribe();
@@ -122,4 +135,4 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
122
135
 
123
136
  //#endregion
124
137
  export { CopilotKitProvider as t };
125
- //# sourceMappingURL=CopilotKitProvider-CE4bc6CP.mjs.map
138
+ //# sourceMappingURL=CopilotKitProvider-BXpkAl1Y.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopilotKitProvider-BXpkAl1Y.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 {\n CopilotKitCoreReact,\n ɵuseOwnedCore,\n} from \"@copilotkit/react-core/headless\";\nimport type {\n ɵCopilotKitProviderBaseOptions,\n ɵRuntimeInfo,\n} from \"@copilotkit/core\";\nimport {\n ɵreportProviderConfigDiagnostics,\n ɵresolveProviderConfig,\n} from \"@copilotkit/core\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps extends Pick<\n ɵCopilotKitProviderBaseOptions,\n | \"credentials\"\n | \"messageFilter\"\n | \"useSingleEndpoint\"\n | \"properties\"\n | \"onError\"\n | \"debug\"\n | \"defaultThrottleMs\"\n> {\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 * 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 // Transport mapping and config checks come from core.\n const resolvedConfig = useMemo(\n () =>\n ɵresolveProviderConfig({\n runtimeUrl,\n useSingleEndpoint,\n properties: stableProperties,\n }),\n [runtimeUrl, useSingleEndpoint, stableProperties],\n );\n const loggedDiagnosticsRef = useRef(new Set<string>());\n ɵreportProviderConfigDiagnostics(resolvedConfig.diagnostics, {\n isProduction: process.env.NODE_ENV === \"production\",\n logged: loggedDiagnosticsRef.current,\n });\n\n // One core for the provider lifetime, disposed on unmount (StrictMode\n // safe, see `ɵuseOwnedCore`).\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n const copilotkit = ɵuseOwnedCore(\n copilotkitRef,\n (): CopilotKitCoreReactInstance =>\n new CopilotKitCoreReact({\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n // `/info` starts from the effect below, so a render React discards\n // never fetches it (#5801).\n deferInitialConnection: true,\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: resolvedConfig.properties,\n debug,\n // Set at construction so child hooks see it on their first render.\n defaultThrottleMs,\n onError,\n }),\n );\n\n // Core calls `onError`, and logs the error itself when there is none.\n useEffect(() => {\n copilotkit.setErrorHandler(onError);\n }, [copilotkit, onError]);\n\n // Sync props to the core. Core applies only what changed.\n useEffect(() => {\n copilotkit.ɵupdateConfig({\n messageFilter,\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n headers: stableHeaders,\n credentials,\n properties: resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n });\n copilotkit.connect();\n }, [\n copilotkit,\n messageFilter,\n resolvedConfig.runtimeUrl,\n resolvedConfig.runtimeTransport,\n stableHeaders,\n credentials,\n resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n ]);\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 [runtimeInfo, setRuntimeInfo] = useState<ɵRuntimeInfo | null>(null);\n const runtimeLicenseStatus = runtimeInfo?.licenseStatus;\n\n // Project core's runtime info snapshot; the catch-up read reflects a status\n // that settled before this effect ran.\n useEffect(() => {\n const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);\n const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);\n syncRuntimeInfo();\n return unsubscribe;\n }, [copilotkit]);\n\n // Tool execution tracking.\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 });\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,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;CAGD,MAAM,iBAAiB,cAEnB,uBAAuB;EACrB;EACA;EACA,YAAY;EACb,CAAC,EACJ;EAAC;EAAY;EAAmB;EAAiB,CAClD;CACD,MAAM,uBAAuB,uBAAO,IAAI,KAAa,CAAC;AACtD,kCAAiC,eAAe,aAAa;EAC3D,cAAc,QAAQ,IAAI,aAAa;EACvC,QAAQ,qBAAqB;EAC9B,CAAC;CAKF,MAAM,aAAa,cADG,OAA2C,KAAK,QAIlE,IAAI,oBAAoB;EACtB,YAAY,eAAe;EAC3B,kBAAkB,eAAe;EAGjC,wBAAwB;EACxB,SAAS;EACT;EACA;EACA,YAAY,eAAe;EAC3B;EAEA;EACA;EACD,CAAC,CACL;AAGD,iBAAgB;AACd,aAAW,gBAAgB,QAAQ;IAClC,CAAC,YAAY,QAAQ,CAAC;AAGzB,iBAAgB;AACd,aAAW,cAAc;GACvB;GACA,YAAY,eAAe;GAC3B,kBAAkB,eAAe;GACjC,SAAS;GACT;GACA,YAAY,eAAe;GAC3B;GACA;GACD,CAAC;AACF,aAAW,SAAS;IACnB;EACD;EACA;EACA,eAAe;EACf,eAAe;EACf;EACA;EACA,eAAe;EACf;EACA;EACD,CAAC;CAKF,MAAM,CAAC,sBAAsB,2BAA2B,+BAEhD,IAAI,KAAK,CAAC;CAElB,MAAM,CAAC,aAAa,kBAAkB,SAA8B,KAAK;CACzE,MAAM,uBAAuB,aAAa;AAI1C,iBAAgB;EACd,MAAM,wBAAwB,eAAe,WAAW,aAAa;EACrE,MAAM,cAAc,WAAW,wBAAwB,gBAAgB;AACvE,mBAAiB;AACjB,SAAO;IACN,CAAC,WAAW,CAAC;AAKhB,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;;GAEL,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"}
@@ -3,6 +3,7 @@ let react = require("react");
3
3
  react = require_MarkdownRendererContext.__toESM(react);
4
4
  let _copilotkit_react_core_context = require("@copilotkit/react-core/context");
5
5
  let _copilotkit_react_core_headless = require("@copilotkit/react-core/headless");
6
+ let _copilotkit_core = require("@copilotkit/core");
6
7
  let _copilotkit_shared = require("@copilotkit/shared");
7
8
  let react_jsx_runtime = require("react/jsx-runtime");
8
9
 
@@ -34,48 +35,67 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
34
35
  const resolvedHeaders = typeof headersProp === "function" ? headersProp() : headersProp;
35
36
  const stableHeaders = (0, react.useMemo)(() => resolvedHeaders ?? {}, [JSON.stringify(resolvedHeaders)]);
36
37
  const stableProperties = (0, react.useMemo)(() => properties ?? {}, [JSON.stringify(properties)]);
37
- const copilotkitRef = (0, react.useRef)(null);
38
- if (copilotkitRef.current === null) {
39
- const instance = new _copilotkit_react_core_headless.CopilotKitCoreReact({
40
- runtimeUrl,
41
- runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
38
+ const resolvedConfig = (0, react.useMemo)(() => (0, _copilotkit_core.ɵresolveProviderConfig)({
39
+ runtimeUrl,
40
+ useSingleEndpoint,
41
+ properties: stableProperties
42
+ }), [
43
+ runtimeUrl,
44
+ useSingleEndpoint,
45
+ stableProperties
46
+ ]);
47
+ const loggedDiagnosticsRef = (0, react.useRef)(/* @__PURE__ */ new Set());
48
+ (0, _copilotkit_core.ɵreportProviderConfigDiagnostics)(resolvedConfig.diagnostics, {
49
+ isProduction: process.env.NODE_ENV === "production",
50
+ logged: loggedDiagnosticsRef.current
51
+ });
52
+ const copilotkit = (0, _copilotkit_react_core_headless.ɵuseOwnedCore)((0, react.useRef)(null), () => new _copilotkit_react_core_headless.CopilotKitCoreReact({
53
+ runtimeUrl: resolvedConfig.runtimeUrl,
54
+ runtimeTransport: resolvedConfig.runtimeTransport,
55
+ deferInitialConnection: true,
56
+ headers: stableHeaders,
57
+ credentials,
58
+ messageFilter,
59
+ properties: resolvedConfig.properties,
60
+ debug,
61
+ defaultThrottleMs,
62
+ onError
63
+ }));
64
+ (0, react.useEffect)(() => {
65
+ copilotkit.setErrorHandler(onError);
66
+ }, [copilotkit, onError]);
67
+ (0, react.useEffect)(() => {
68
+ copilotkit.ɵupdateConfig({
69
+ messageFilter,
70
+ runtimeUrl: resolvedConfig.runtimeUrl,
71
+ runtimeTransport: resolvedConfig.runtimeTransport,
42
72
  headers: stableHeaders,
43
73
  credentials,
44
- messageFilter,
45
- properties: stableProperties,
46
- debug
74
+ properties: resolvedConfig.properties,
75
+ debug,
76
+ defaultThrottleMs
47
77
  });
48
- if (defaultThrottleMs !== void 0) instance.setDefaultThrottleMs(defaultThrottleMs);
49
- copilotkitRef.current = instance;
50
- }
51
- const copilotkit = copilotkitRef.current;
52
- (0, react.useEffect)(() => {
53
- copilotkit.setRuntimeUrl(runtimeUrl);
54
- copilotkit.setRuntimeTransport(useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto");
55
- copilotkit.setHeaders(stableHeaders);
56
- copilotkit.setCredentials(credentials);
57
- copilotkit.setMessageFilter(messageFilter);
58
- copilotkit.setProperties(stableProperties);
59
- copilotkit.setDebug(debug);
78
+ copilotkit.connect();
60
79
  }, [
61
- runtimeUrl,
62
- useSingleEndpoint,
80
+ copilotkit,
81
+ messageFilter,
82
+ resolvedConfig.runtimeUrl,
83
+ resolvedConfig.runtimeTransport,
63
84
  stableHeaders,
64
85
  credentials,
65
- messageFilter,
66
- stableProperties,
86
+ resolvedConfig.properties,
67
87
  debug,
68
- copilotkit
88
+ defaultThrottleMs
69
89
  ]);
70
- (0, react.useEffect)(() => {
71
- copilotkit.setDefaultThrottleMs(defaultThrottleMs);
72
- }, [copilotkit, defaultThrottleMs]);
73
90
  const [executingToolCallIds, setExecutingToolCallIds] = (0, react.useState)(() => /* @__PURE__ */ new Set());
74
- const [runtimeLicenseStatus, setRuntimeLicenseStatus] = (0, react.useState)(void 0);
75
- const onErrorRef = (0, react.useRef)(onError);
91
+ const [runtimeInfo, setRuntimeInfo] = (0, react.useState)(null);
92
+ const runtimeLicenseStatus = runtimeInfo?.licenseStatus;
76
93
  (0, react.useEffect)(() => {
77
- onErrorRef.current = onError;
78
- }, [onError]);
94
+ const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);
95
+ const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);
96
+ syncRuntimeInfo();
97
+ return unsubscribe;
98
+ }, [copilotkit]);
79
99
  (0, react.useEffect)(() => {
80
100
  const subscription = copilotkit.subscribe({
81
101
  onToolExecutionStart: ({ toolCallId }) => {
@@ -93,13 +113,6 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
93
113
  next.delete(toolCallId);
94
114
  return next;
95
115
  });
96
- },
97
- onError: (event) => {
98
- if (onErrorRef.current) onErrorRef.current(event);
99
- else console.error(`[CopilotKit] Error (${event.code}):`, event.error, event.context ?? {});
100
- },
101
- onRuntimeConnectionStatusChanged: () => {
102
- setRuntimeLicenseStatus(copilotkit.licenseStatus);
103
116
  }
104
117
  });
105
118
  return () => subscription.unsubscribe();
@@ -128,4 +141,4 @@ Object.defineProperty(exports, 'CopilotKitProvider', {
128
141
  return CopilotKitProvider;
129
142
  }
130
143
  });
131
- //# sourceMappingURL=CopilotKitProvider-Byw3cqe2.cjs.map
144
+ //# sourceMappingURL=CopilotKitProvider-DDPbJkHS.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopilotKitProvider-DDPbJkHS.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 {\n CopilotKitCoreReact,\n ɵuseOwnedCore,\n} from \"@copilotkit/react-core/headless\";\nimport type {\n ɵCopilotKitProviderBaseOptions,\n ɵRuntimeInfo,\n} from \"@copilotkit/core\";\nimport {\n ɵreportProviderConfigDiagnostics,\n ɵresolveProviderConfig,\n} from \"@copilotkit/core\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps extends Pick<\n ɵCopilotKitProviderBaseOptions,\n | \"credentials\"\n | \"messageFilter\"\n | \"useSingleEndpoint\"\n | \"properties\"\n | \"onError\"\n | \"debug\"\n | \"defaultThrottleMs\"\n> {\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 * 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 // Transport mapping and config checks come from core.\n const resolvedConfig = useMemo(\n () =>\n ɵresolveProviderConfig({\n runtimeUrl,\n useSingleEndpoint,\n properties: stableProperties,\n }),\n [runtimeUrl, useSingleEndpoint, stableProperties],\n );\n const loggedDiagnosticsRef = useRef(new Set<string>());\n ɵreportProviderConfigDiagnostics(resolvedConfig.diagnostics, {\n isProduction: process.env.NODE_ENV === \"production\",\n logged: loggedDiagnosticsRef.current,\n });\n\n // One core for the provider lifetime, disposed on unmount (StrictMode\n // safe, see `ɵuseOwnedCore`).\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n const copilotkit = ɵuseOwnedCore(\n copilotkitRef,\n (): CopilotKitCoreReactInstance =>\n new CopilotKitCoreReact({\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n // `/info` starts from the effect below, so a render React discards\n // never fetches it (#5801).\n deferInitialConnection: true,\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: resolvedConfig.properties,\n debug,\n // Set at construction so child hooks see it on their first render.\n defaultThrottleMs,\n onError,\n }),\n );\n\n // Core calls `onError`, and logs the error itself when there is none.\n useEffect(() => {\n copilotkit.setErrorHandler(onError);\n }, [copilotkit, onError]);\n\n // Sync props to the core. Core applies only what changed.\n useEffect(() => {\n copilotkit.ɵupdateConfig({\n messageFilter,\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n headers: stableHeaders,\n credentials,\n properties: resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n });\n copilotkit.connect();\n }, [\n copilotkit,\n messageFilter,\n resolvedConfig.runtimeUrl,\n resolvedConfig.runtimeTransport,\n stableHeaders,\n credentials,\n resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n ]);\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 [runtimeInfo, setRuntimeInfo] = useState<ɵRuntimeInfo | null>(null);\n const runtimeLicenseStatus = runtimeInfo?.licenseStatus;\n\n // Project core's runtime info snapshot; the catch-up read reflects a status\n // that settled before this effect ran.\n useEffect(() => {\n const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);\n const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);\n syncRuntimeInfo();\n return unsubscribe;\n }, [copilotkit]);\n\n // Tool execution tracking.\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 });\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,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;CAGD,MAAM,uFAEqB;EACrB;EACA;EACA,YAAY;EACb,CAAC,EACJ;EAAC;EAAY;EAAmB;EAAiB,CAClD;CACD,MAAM,yDAA8B,IAAI,KAAa,CAAC;AACtD,wDAAiC,eAAe,aAAa;EAC3D,cAAc,QAAQ,IAAI,aAAa;EACvC,QAAQ,qBAAqB;EAC9B,CAAC;CAKF,MAAM,kFAD2D,KAAK,QAIlE,IAAIA,oDAAoB;EACtB,YAAY,eAAe;EAC3B,kBAAkB,eAAe;EAGjC,wBAAwB;EACxB,SAAS;EACT;EACA;EACA,YAAY,eAAe;EAC3B;EAEA;EACA;EACD,CAAC,CACL;AAGD,4BAAgB;AACd,aAAW,gBAAgB,QAAQ;IAClC,CAAC,YAAY,QAAQ,CAAC;AAGzB,4BAAgB;AACd,aAAW,cAAc;GACvB;GACA,YAAY,eAAe;GAC3B,kBAAkB,eAAe;GACjC,SAAS;GACT;GACA,YAAY,eAAe;GAC3B;GACA;GACD,CAAC;AACF,aAAW,SAAS;IACnB;EACD;EACA;EACA,eAAe;EACf,eAAe;EACf;EACA;EACA,eAAe;EACf;EACA;EACD,CAAC;CAKF,MAAM,CAAC,sBAAsB,qEAErB,IAAI,KAAK,CAAC;CAElB,MAAM,CAAC,aAAa,sCAAgD,KAAK;CACzE,MAAM,uBAAuB,aAAa;AAI1C,4BAAgB;EACd,MAAM,wBAAwB,eAAe,WAAW,aAAa;EACrE,MAAM,cAAc,WAAW,wBAAwB,gBAAgB;AACvE,mBAAiB;AACjB,SAAO;IACN,CAAC,WAAW,CAAC;AAKhB,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;;GAEL,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"}
@@ -0,0 +1,65 @@
1
+ import { r as MarkdownStyle } from "./Markdown-DzjnSuu5.cjs";
2
+ import React, { ReactNode } from "react";
3
+ import { ɵCopilotKitProviderBaseOptions } from "@copilotkit/core";
4
+
5
+ //#region src/components/MarkdownRendererContext.d.ts
6
+ interface NativeMarkdownRendererProps {
7
+ content: string;
8
+ isStreaming?: boolean;
9
+ }
10
+ type NativeMarkdownRenderer = React.ComponentType<NativeMarkdownRendererProps>;
11
+ /** Config for the built-in RN renderer (pass instead of a component). */
12
+ interface DefaultMarkdownRendererProps {
13
+ style?: MarkdownStyle;
14
+ animate?: boolean;
15
+ }
16
+ type MarkdownRendererValue = NativeMarkdownRenderer | DefaultMarkdownRendererProps;
17
+ declare const MarkdownRendererProvider: React.FC<{
18
+ renderer?: MarkdownRendererValue;
19
+ children: React.ReactNode;
20
+ }>;
21
+ declare function useMarkdownRenderer(): MarkdownRendererValue | undefined;
22
+ //#endregion
23
+ //#region src/CopilotKitProvider.d.ts
24
+ interface CopilotKitNativeProviderProps extends Pick<ɵCopilotKitProviderBaseOptions, "credentials" | "messageFilter" | "useSingleEndpoint" | "properties" | "onError" | "debug" | "defaultThrottleMs"> {
25
+ children: ReactNode;
26
+ /** URL of the CopilotKit runtime endpoint */
27
+ runtimeUrl: string;
28
+ /** Custom headers sent with every request */
29
+ headers?: Record<string, string> | (() => Record<string, string>);
30
+ /**
31
+ * Custom markdown renderer for assistant messages. Either a component (escape
32
+ * hatch — receives `content` and an optional `isStreaming` flag) used instead
33
+ * of the built-in renderer, or a `{ style, animate }` config object to
34
+ * configure the built-in React Native renderer (the `CopilotMarkdown` used by
35
+ * the default `AssistantMessage`) without writing a wrapper.
36
+ */
37
+ markdownRenderer?: MarkdownRendererValue;
38
+ }
39
+ /**
40
+ * CopilotKit provider for React Native.
41
+ *
42
+ * A lightweight alternative to the web CopilotKitProvider that avoids
43
+ * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
44
+ *
45
+ * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
46
+ * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
47
+ * required (though it remains available for advanced use).
48
+ *
49
+ * Usage:
50
+ * ```tsx
51
+ * import { CopilotKitProvider } from "@copilotkit/react-native";
52
+ *
53
+ * function App() {
54
+ * return (
55
+ * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
56
+ * <ChatScreen />
57
+ * </CopilotKitProvider>
58
+ * );
59
+ * }
60
+ * ```
61
+ */
62
+ declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
63
+ //#endregion
64
+ export { NativeMarkdownRendererProps as a, NativeMarkdownRenderer as i, CopilotKitProvider as n, useMarkdownRenderer as o, MarkdownRendererProvider as r, CopilotKitNativeProviderProps as t };
65
+ //# sourceMappingURL=CopilotKitProvider-F7Pn5kp4.d.cts.map
@@ -0,0 +1,65 @@
1
+ import { r as MarkdownStyle } from "./Markdown-a-rdG22_.mjs";
2
+ import React, { ReactNode } from "react";
3
+ import { ɵCopilotKitProviderBaseOptions } from "@copilotkit/core";
4
+
5
+ //#region src/components/MarkdownRendererContext.d.ts
6
+ interface NativeMarkdownRendererProps {
7
+ content: string;
8
+ isStreaming?: boolean;
9
+ }
10
+ type NativeMarkdownRenderer = React.ComponentType<NativeMarkdownRendererProps>;
11
+ /** Config for the built-in RN renderer (pass instead of a component). */
12
+ interface DefaultMarkdownRendererProps {
13
+ style?: MarkdownStyle;
14
+ animate?: boolean;
15
+ }
16
+ type MarkdownRendererValue = NativeMarkdownRenderer | DefaultMarkdownRendererProps;
17
+ declare const MarkdownRendererProvider: React.FC<{
18
+ renderer?: MarkdownRendererValue;
19
+ children: React.ReactNode;
20
+ }>;
21
+ declare function useMarkdownRenderer(): MarkdownRendererValue | undefined;
22
+ //#endregion
23
+ //#region src/CopilotKitProvider.d.ts
24
+ interface CopilotKitNativeProviderProps extends Pick<ɵCopilotKitProviderBaseOptions, "credentials" | "messageFilter" | "useSingleEndpoint" | "properties" | "onError" | "debug" | "defaultThrottleMs"> {
25
+ children: ReactNode;
26
+ /** URL of the CopilotKit runtime endpoint */
27
+ runtimeUrl: string;
28
+ /** Custom headers sent with every request */
29
+ headers?: Record<string, string> | (() => Record<string, string>);
30
+ /**
31
+ * Custom markdown renderer for assistant messages. Either a component (escape
32
+ * hatch — receives `content` and an optional `isStreaming` flag) used instead
33
+ * of the built-in renderer, or a `{ style, animate }` config object to
34
+ * configure the built-in React Native renderer (the `CopilotMarkdown` used by
35
+ * the default `AssistantMessage`) without writing a wrapper.
36
+ */
37
+ markdownRenderer?: MarkdownRendererValue;
38
+ }
39
+ /**
40
+ * CopilotKit provider for React Native.
41
+ *
42
+ * A lightweight alternative to the web CopilotKitProvider that avoids
43
+ * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
44
+ *
45
+ * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
46
+ * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
47
+ * required (though it remains available for advanced use).
48
+ *
49
+ * Usage:
50
+ * ```tsx
51
+ * import { CopilotKitProvider } from "@copilotkit/react-native";
52
+ *
53
+ * function App() {
54
+ * return (
55
+ * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
56
+ * <ChatScreen />
57
+ * </CopilotKitProvider>
58
+ * );
59
+ * }
60
+ * ```
61
+ */
62
+ declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
63
+ //#endregion
64
+ export { NativeMarkdownRendererProps as a, NativeMarkdownRenderer as i, CopilotKitProvider as n, useMarkdownRenderer as o, MarkdownRendererProvider as r, CopilotKitNativeProviderProps as t };
65
+ //# sourceMappingURL=CopilotKitProvider-Khgz5dQo.d.mts.map
@@ -2,8 +2,8 @@ const require_MarkdownRendererContext = require('./MarkdownRendererContext-BRNe8
2
2
  let react = require("react");
3
3
  react = require_MarkdownRendererContext.__toESM(react);
4
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");
5
+ let _copilotkit_markdown_react_native = require("@copilotkit/markdown/react-native");
6
+ let _copilotkit_markdown = require("@copilotkit/markdown");
7
7
 
8
8
  //#region src/components/Markdown.tsx
9
9
  /**
@@ -12,12 +12,12 @@ let _copilotkit_markdown_renderer = require("@copilotkit/markdown-renderer");
12
12
  * @public
13
13
  */
14
14
  const defaultMarkdownStyles = {
15
- ..._copilotkit_markdown_renderer_react_native.defaultMarkdownStyles,
16
- code: _copilotkit_markdown_renderer_react_native.defaultMarkdownStyles.inlineCode
15
+ ..._copilotkit_markdown_react_native.defaultMarkdownStyles,
16
+ code: _copilotkit_markdown_react_native.defaultMarkdownStyles.inlineCode
17
17
  };
18
18
  /**
19
19
  * GFM markdown renderer for React Native. Delegates to the shared
20
- * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
20
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown/react-native`.
21
21
  *
22
22
  * Public API is backward-compatible with the previous basic renderer:
23
23
  * - `CopilotMarkdownProps` — same shape.
@@ -27,7 +27,7 @@ const defaultMarkdownStyles = {
27
27
  * @public
28
28
  */
29
29
  function CopilotMarkdown({ content, style, streamingAnimation = false }) {
30
- (0, _copilotkit_markdown_renderer.warnUnsupportedRichSyntaxOnce)(content);
30
+ (0, _copilotkit_markdown.warnUnsupportedRichSyntaxOnce)(content);
31
31
  let resolvedStyle = style;
32
32
  if (style?.code !== void 0) {
33
33
  const { code, ...rest } = style;
@@ -36,7 +36,7 @@ function CopilotMarkdown({ content, style, streamingAnimation = false }) {
36
36
  inlineCode: rest.inlineCode ?? code
37
37
  };
38
38
  }
39
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_markdown_renderer_react_native.StreamingMarkdownRenderer, {
39
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_markdown_react_native.StreamingMarkdownRenderer, {
40
40
  content,
41
41
  isComplete: true,
42
42
  style: resolvedStyle,
@@ -57,4 +57,4 @@ Object.defineProperty(exports, 'defaultMarkdownStyles', {
57
57
  return defaultMarkdownStyles;
58
58
  }
59
59
  });
60
- //# sourceMappingURL=Markdown-C_9Re36O.cjs.map
60
+ //# sourceMappingURL=Markdown-CaYHlD4j.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown-CaYHlD4j.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/react-native\";\nimport type { MarkdownStyle as StreamingMarkdownStyle } from \"@copilotkit/markdown/react-native\";\nimport { warnUnsupportedRichSyntaxOnce } from \"@copilotkit/markdown\";\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/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,wDAAwB;CAC/B;;;;;;;;;;;;AA0BD,SAAgB,gBAAgB,EAC9B,SACA,OACA,qBAAqB,SAC6B;AAOlD,yDAA8B,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"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { MarkdownStyle } from "@copilotkit/markdown-renderer/react-native";
2
+ import { MarkdownStyle } from "@copilotkit/markdown/react-native";
3
3
 
4
4
  //#region src/components/Markdown.d.ts
5
5
  /**
@@ -33,7 +33,7 @@ interface CopilotMarkdownProps {
33
33
  }
34
34
  /**
35
35
  * GFM markdown renderer for React Native. Delegates to the shared
36
- * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
36
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown/react-native`.
37
37
  *
38
38
  * Public API is backward-compatible with the previous basic renderer:
39
39
  * - `CopilotMarkdownProps` — same shape.
@@ -49,4 +49,4 @@ declare function CopilotMarkdown({
49
49
  }: CopilotMarkdownProps): React.ReactElement | null;
50
50
  //#endregion
51
51
  export { defaultMarkdownStyles as i, CopilotMarkdownProps as n, MarkdownStyle$1 as r, CopilotMarkdown as t };
52
- //# sourceMappingURL=Markdown-1ips7myr.d.cts.map
52
+ //# sourceMappingURL=Markdown-DzjnSuu5.d.cts.map
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { StreamingMarkdownRenderer, defaultMarkdownStyles } from "@copilotkit/markdown-renderer/react-native";
4
- import { warnUnsupportedRichSyntaxOnce } from "@copilotkit/markdown-renderer";
3
+ import { StreamingMarkdownRenderer, defaultMarkdownStyles } from "@copilotkit/markdown/react-native";
4
+ import { warnUnsupportedRichSyntaxOnce } from "@copilotkit/markdown";
5
5
 
6
6
  //#region src/components/Markdown.tsx
7
7
  /**
@@ -15,7 +15,7 @@ const defaultMarkdownStyles$1 = {
15
15
  };
16
16
  /**
17
17
  * GFM markdown renderer for React Native. Delegates to the shared
18
- * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
18
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown/react-native`.
19
19
  *
20
20
  * Public API is backward-compatible with the previous basic renderer:
21
21
  * - `CopilotMarkdownProps` — same shape.
@@ -44,4 +44,4 @@ function CopilotMarkdown({ content, style, streamingAnimation = false }) {
44
44
 
45
45
  //#endregion
46
46
  export { defaultMarkdownStyles$1 as n, CopilotMarkdown as t };
47
- //# sourceMappingURL=Markdown-C6AsLHmd.mjs.map
47
+ //# sourceMappingURL=Markdown-SE9MfY2U.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown-SE9MfY2U.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/react-native\";\nimport type { MarkdownStyle as StreamingMarkdownStyle } from \"@copilotkit/markdown/react-native\";\nimport { warnUnsupportedRichSyntaxOnce } from \"@copilotkit/markdown\";\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/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"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { MarkdownStyle } from "@copilotkit/markdown-renderer/react-native";
2
+ import { MarkdownStyle } from "@copilotkit/markdown/react-native";
3
3
 
4
4
  //#region src/components/Markdown.d.ts
5
5
  /**
@@ -33,7 +33,7 @@ interface CopilotMarkdownProps {
33
33
  }
34
34
  /**
35
35
  * GFM markdown renderer for React Native. Delegates to the shared
36
- * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.
36
+ * `StreamingMarkdownRenderer` from `@copilotkit/markdown/react-native`.
37
37
  *
38
38
  * Public API is backward-compatible with the previous basic renderer:
39
39
  * - `CopilotMarkdownProps` — same shape.
@@ -49,4 +49,4 @@ declare function CopilotMarkdown({
49
49
  }: CopilotMarkdownProps): React.ReactElement | null;
50
50
  //#endregion
51
51
  export { defaultMarkdownStyles$1 as i, CopilotMarkdownProps as n, MarkdownStyle$1 as r, CopilotMarkdown as t };
52
- //# sourceMappingURL=Markdown-JsYh7oSA.d.mts.map
52
+ //# sourceMappingURL=Markdown-a-rdG22_.d.mts.map
@@ -18,4 +18,4 @@ function useMarkdownRenderer() {
18
18
 
19
19
  //#endregion
20
20
  export { isNativeComponentRenderer as n, useMarkdownRenderer as r, MarkdownRendererProvider as t };
21
- //# sourceMappingURL=MarkdownRendererContext-CAnuohIS.mjs.map
21
+ //# sourceMappingURL=MarkdownRendererContext-B_AKdPAN.mjs.map
@@ -1 +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"}
1
+ {"version":3,"file":"MarkdownRendererContext-B_AKdPAN.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"}