@copilotkit/react-native 1.71.1 → 1.72.0

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.
package/USAGE.md CHANGED
@@ -163,20 +163,19 @@ useRenderTool({
163
163
  });
164
164
  ```
165
165
 
166
- **Deprecated on React Native, for one release.** React Native used to export a
167
- _different_ hook under this name — one that registered a tool as well as a
168
- renderer — so `useRenderTool` here is currently a compatibility shim over both
169
- react-core hooks, scheduled for removal in the next minor. Your existing call
170
- still works: `name: "*"` always registers a renderer only, and any other name
171
- carrying `description` or `handler` is routed to `useFrontendTool` the way the
172
- old hook did. Either way it warns in development (dev only, once per tool name)
173
- and tells you what to rename the call to. One thing does not carry over: on a
174
- named renderer the render props are `parameters`, not `args`, so a typed
175
- `render: ({ args }) => …` fails with `TS2339` (the wildcard's props are untyped,
176
- so it still compiles there).
166
+ **Migrating from React Native's old `useRenderTool`.** React Native used to
167
+ export a _different_ hook under this name — one that registered a tool as well
168
+ as a renderer, which meant `name: "*"` registered a frontend tool literally
169
+ called `*`. It was replaced by react-core's hook in 1.68 and kept working
170
+ behind a deprecated compatibility shim, which has now been removed. A call
171
+ carrying `description` or `handler` no longer type-checks and no longer
172
+ registers a tool — rename it to `useFrontendTool`, same config object.
173
+ On a named renderer the render props are `parameters`, not `args`, so a typed
174
+ `render: ({ args }) => …` fails with `TS2339` (the wildcard's props are
175
+ untyped, so it still compiles there).
177
176
 
178
177
  See the [`useRenderTool` reference](https://docs.copilotkit.ai/reference/react-native/hooks/useRenderTool)
179
- for the routing rules, the warnings, and the full migration table.
178
+ for the full migration table.
180
179
 
181
180
  ## Alternative Import Path
182
181
 
@@ -0,0 +1,118 @@
1
+ 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";
4
+ import { createLicenseContextValue } from "@copilotkit/shared";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/CopilotKitProvider.tsx
8
+ /**
9
+ * CopilotKit provider for React Native.
10
+ *
11
+ * A lightweight alternative to the web CopilotKitProvider that avoids
12
+ * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
13
+ *
14
+ * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
15
+ * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
16
+ * required (though it remains available for advanced use).
17
+ *
18
+ * Usage:
19
+ * ```tsx
20
+ * import { CopilotKitProvider } from "@copilotkit/react-native";
21
+ *
22
+ * function App() {
23
+ * return (
24
+ * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
25
+ * <ChatScreen />
26
+ * </CopilotKitProvider>
27
+ * );
28
+ * }
29
+ * ```
30
+ */
31
+ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, credentials, useSingleEndpoint, properties, onError, debug, defaultThrottleMs }) => {
32
+ const resolvedHeaders = typeof headersProp === "function" ? headersProp() : headersProp;
33
+ const stableHeaders = useMemo(() => resolvedHeaders ?? {}, [JSON.stringify(resolvedHeaders)]);
34
+ const stableProperties = useMemo(() => properties ?? {}, [JSON.stringify(properties)]);
35
+ const copilotkitRef = useRef(null);
36
+ if (copilotkitRef.current === null) {
37
+ const instance = new CopilotKitCoreReact({
38
+ runtimeUrl,
39
+ runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
40
+ headers: stableHeaders,
41
+ credentials,
42
+ properties: stableProperties,
43
+ debug
44
+ });
45
+ if (defaultThrottleMs !== void 0) instance.setDefaultThrottleMs(defaultThrottleMs);
46
+ copilotkitRef.current = instance;
47
+ }
48
+ const copilotkit = copilotkitRef.current;
49
+ useEffect(() => {
50
+ copilotkit.setRuntimeUrl(runtimeUrl);
51
+ copilotkit.setRuntimeTransport(useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto");
52
+ copilotkit.setHeaders(stableHeaders);
53
+ copilotkit.setCredentials(credentials);
54
+ copilotkit.setProperties(stableProperties);
55
+ copilotkit.setDebug(debug);
56
+ }, [
57
+ runtimeUrl,
58
+ useSingleEndpoint,
59
+ stableHeaders,
60
+ credentials,
61
+ stableProperties,
62
+ debug,
63
+ copilotkit
64
+ ]);
65
+ useEffect(() => {
66
+ copilotkit.setDefaultThrottleMs(defaultThrottleMs);
67
+ }, [copilotkit, defaultThrottleMs]);
68
+ const [executingToolCallIds, setExecutingToolCallIds] = useState(() => /* @__PURE__ */ new Set());
69
+ const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState(void 0);
70
+ const onErrorRef = useRef(onError);
71
+ useEffect(() => {
72
+ onErrorRef.current = onError;
73
+ }, [onError]);
74
+ useEffect(() => {
75
+ const subscription = copilotkit.subscribe({
76
+ onToolExecutionStart: ({ toolCallId }) => {
77
+ setExecutingToolCallIds((prev) => {
78
+ if (prev.has(toolCallId)) return prev;
79
+ const next = new Set(prev);
80
+ next.add(toolCallId);
81
+ return next;
82
+ });
83
+ },
84
+ onToolExecutionEnd: ({ toolCallId }) => {
85
+ setExecutingToolCallIds((prev) => {
86
+ if (!prev.has(toolCallId)) return prev;
87
+ const next = new Set(prev);
88
+ next.delete(toolCallId);
89
+ return next;
90
+ });
91
+ },
92
+ onError: (event) => {
93
+ if (onErrorRef.current) onErrorRef.current(event);
94
+ else console.error(`[CopilotKit] Error (${event.code}):`, event.error, event.context ?? {});
95
+ },
96
+ onRuntimeConnectionStatusChanged: () => {
97
+ setRuntimeLicenseStatus(copilotkit.licenseStatus);
98
+ }
99
+ });
100
+ return () => subscription.unsubscribe();
101
+ }, [copilotkit]);
102
+ const contextValue = useMemo(() => ({
103
+ copilotkit,
104
+ executingToolCallIds
105
+ }), [copilotkit, executingToolCallIds]);
106
+ const licenseContextValue = useMemo(() => createLicenseContextValue(runtimeLicenseStatus), [runtimeLicenseStatus]);
107
+ return /* @__PURE__ */ jsx(CopilotKitContext.Provider, {
108
+ value: contextValue,
109
+ children: /* @__PURE__ */ jsx(LicenseContext.Provider, {
110
+ value: licenseContextValue,
111
+ children
112
+ })
113
+ });
114
+ };
115
+
116
+ //#endregion
117
+ export { CopilotKitProvider as t };
118
+ //# sourceMappingURL=CopilotKitProvider-Bpj5_ayo.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopilotKitProvider-Bpj5_ayo.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/v2/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/v2/context\";\nimport { CopilotKitCoreReact } from \"@copilotkit/react-core/v2/headless\";\nimport type { CopilotKitCoreErrorCode } from \"@copilotkit/core\";\nimport type { DebugConfig, RuntimeLicenseStatus } from \"@copilotkit/shared\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\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 /** 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 // 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 useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\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 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.setProperties(stableProperties);\n copilotkit.setDebug(debug);\n }, [\n runtimeUrl,\n useSingleEndpoint,\n stableHeaders,\n credentials,\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 {children}\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,mBACA,YACA,SACA,OACA,wBACI;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,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,cAAc,iBAAiB;AAC1C,aAAW,SAAS,MAAM;IACzB;EACD;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;GAC7B;IACuB;GACC"}
@@ -0,0 +1,67 @@
1
+ import React, { ReactNode } from "react";
2
+ import { CopilotKitCoreErrorCode } from "@copilotkit/core";
3
+ import { DebugConfig } from "@copilotkit/shared";
4
+
5
+ //#region src/CopilotKitProvider.d.ts
6
+ interface CopilotKitNativeProviderProps {
7
+ children: ReactNode;
8
+ /** URL of the CopilotKit runtime endpoint */
9
+ runtimeUrl: string;
10
+ /** Custom headers sent with every request */
11
+ headers?: Record<string, string> | (() => Record<string, string>);
12
+ /**
13
+ * Credentials mode for fetch requests (e.g., "include" for HTTP-only cookies in cross-origin requests).
14
+ */
15
+ credentials?: RequestCredentials;
16
+ /** Whether the runtime uses a single-route endpoint */
17
+ useSingleEndpoint?: boolean;
18
+ /** Custom properties forwarded to agents */
19
+ properties?: Record<string, unknown>;
20
+ /**
21
+ * Error handler called when CopilotKit encounters an error.
22
+ * Fires for all error types (runtime connection failures, agent errors, tool errors).
23
+ * If not provided, errors are logged to console.error.
24
+ */
25
+ onError?: (event: {
26
+ error: Error;
27
+ code: CopilotKitCoreErrorCode;
28
+ context: Record<string, any>;
29
+ }) => void | Promise<void>;
30
+ /**
31
+ * Enable debug logging for the client-side event pipeline.
32
+ * When `true`, enables verbose logging from the core instance.
33
+ */
34
+ debug?: DebugConfig;
35
+ /**
36
+ * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`
37
+ * subscriptions. Individual subscriptions can override with their own `throttleMs`.
38
+ */
39
+ defaultThrottleMs?: number;
40
+ }
41
+ /**
42
+ * CopilotKit provider for React Native.
43
+ *
44
+ * A lightweight alternative to the web CopilotKitProvider that avoids
45
+ * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
46
+ *
47
+ * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
48
+ * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
49
+ * required (though it remains available for advanced use).
50
+ *
51
+ * Usage:
52
+ * ```tsx
53
+ * import { CopilotKitProvider } from "@copilotkit/react-native";
54
+ *
55
+ * function App() {
56
+ * return (
57
+ * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
58
+ * <ChatScreen />
59
+ * </CopilotKitProvider>
60
+ * );
61
+ * }
62
+ * ```
63
+ */
64
+ declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
65
+ //#endregion
66
+ export { CopilotKitProvider as n, CopilotKitNativeProviderProps as t };
67
+ //# sourceMappingURL=CopilotKitProvider-DsAKy9gw.d.cts.map
@@ -0,0 +1,67 @@
1
+ import React, { ReactNode } from "react";
2
+ import { DebugConfig } from "@copilotkit/shared";
3
+ import { CopilotKitCoreErrorCode } from "@copilotkit/core";
4
+
5
+ //#region src/CopilotKitProvider.d.ts
6
+ interface CopilotKitNativeProviderProps {
7
+ children: ReactNode;
8
+ /** URL of the CopilotKit runtime endpoint */
9
+ runtimeUrl: string;
10
+ /** Custom headers sent with every request */
11
+ headers?: Record<string, string> | (() => Record<string, string>);
12
+ /**
13
+ * Credentials mode for fetch requests (e.g., "include" for HTTP-only cookies in cross-origin requests).
14
+ */
15
+ credentials?: RequestCredentials;
16
+ /** Whether the runtime uses a single-route endpoint */
17
+ useSingleEndpoint?: boolean;
18
+ /** Custom properties forwarded to agents */
19
+ properties?: Record<string, unknown>;
20
+ /**
21
+ * Error handler called when CopilotKit encounters an error.
22
+ * Fires for all error types (runtime connection failures, agent errors, tool errors).
23
+ * If not provided, errors are logged to console.error.
24
+ */
25
+ onError?: (event: {
26
+ error: Error;
27
+ code: CopilotKitCoreErrorCode;
28
+ context: Record<string, any>;
29
+ }) => void | Promise<void>;
30
+ /**
31
+ * Enable debug logging for the client-side event pipeline.
32
+ * When `true`, enables verbose logging from the core instance.
33
+ */
34
+ debug?: DebugConfig;
35
+ /**
36
+ * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`
37
+ * subscriptions. Individual subscriptions can override with their own `throttleMs`.
38
+ */
39
+ defaultThrottleMs?: number;
40
+ }
41
+ /**
42
+ * CopilotKit provider for React Native.
43
+ *
44
+ * A lightweight alternative to the web CopilotKitProvider that avoids
45
+ * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
46
+ *
47
+ * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
48
+ * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
49
+ * required (though it remains available for advanced use).
50
+ *
51
+ * Usage:
52
+ * ```tsx
53
+ * import { CopilotKitProvider } from "@copilotkit/react-native";
54
+ *
55
+ * function App() {
56
+ * return (
57
+ * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
58
+ * <ChatScreen />
59
+ * </CopilotKitProvider>
60
+ * );
61
+ * }
62
+ * ```
63
+ */
64
+ declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
65
+ //#endregion
66
+ export { CopilotKitProvider as n, CopilotKitNativeProviderProps as t };
67
+ //# sourceMappingURL=CopilotKitProvider-OJzclDZY.d.mts.map
@@ -0,0 +1,125 @@
1
+ const require_chunk = require('./chunk-C0xms8kb.cjs');
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");
6
+ let _copilotkit_shared = require("@copilotkit/shared");
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+
9
+ //#region src/CopilotKitProvider.tsx
10
+ /**
11
+ * CopilotKit provider for React Native.
12
+ *
13
+ * A lightweight alternative to the web CopilotKitProvider that avoids
14
+ * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
15
+ *
16
+ * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
17
+ * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
18
+ * required (though it remains available for advanced use).
19
+ *
20
+ * Usage:
21
+ * ```tsx
22
+ * import { CopilotKitProvider } from "@copilotkit/react-native";
23
+ *
24
+ * function App() {
25
+ * return (
26
+ * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
27
+ * <ChatScreen />
28
+ * </CopilotKitProvider>
29
+ * );
30
+ * }
31
+ * ```
32
+ */
33
+ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, credentials, useSingleEndpoint, properties, onError, debug, defaultThrottleMs }) => {
34
+ const resolvedHeaders = typeof headersProp === "function" ? headersProp() : headersProp;
35
+ const stableHeaders = (0, react.useMemo)(() => resolvedHeaders ?? {}, [JSON.stringify(resolvedHeaders)]);
36
+ 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_v2_headless.CopilotKitCoreReact({
40
+ runtimeUrl,
41
+ runtimeTransport: useSingleEndpoint === true ? "single" : useSingleEndpoint === false ? "rest" : "auto",
42
+ headers: stableHeaders,
43
+ credentials,
44
+ properties: stableProperties,
45
+ debug
46
+ });
47
+ if (defaultThrottleMs !== void 0) instance.setDefaultThrottleMs(defaultThrottleMs);
48
+ copilotkitRef.current = instance;
49
+ }
50
+ const copilotkit = copilotkitRef.current;
51
+ (0, react.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.setProperties(stableProperties);
57
+ copilotkit.setDebug(debug);
58
+ }, [
59
+ runtimeUrl,
60
+ useSingleEndpoint,
61
+ stableHeaders,
62
+ credentials,
63
+ stableProperties,
64
+ debug,
65
+ copilotkit
66
+ ]);
67
+ (0, react.useEffect)(() => {
68
+ copilotkit.setDefaultThrottleMs(defaultThrottleMs);
69
+ }, [copilotkit, defaultThrottleMs]);
70
+ const [executingToolCallIds, setExecutingToolCallIds] = (0, react.useState)(() => /* @__PURE__ */ new Set());
71
+ const [runtimeLicenseStatus, setRuntimeLicenseStatus] = (0, react.useState)(void 0);
72
+ const onErrorRef = (0, react.useRef)(onError);
73
+ (0, react.useEffect)(() => {
74
+ onErrorRef.current = onError;
75
+ }, [onError]);
76
+ (0, react.useEffect)(() => {
77
+ const subscription = copilotkit.subscribe({
78
+ onToolExecutionStart: ({ toolCallId }) => {
79
+ setExecutingToolCallIds((prev) => {
80
+ if (prev.has(toolCallId)) return prev;
81
+ const next = new Set(prev);
82
+ next.add(toolCallId);
83
+ return next;
84
+ });
85
+ },
86
+ onToolExecutionEnd: ({ toolCallId }) => {
87
+ setExecutingToolCallIds((prev) => {
88
+ if (!prev.has(toolCallId)) return prev;
89
+ const next = new Set(prev);
90
+ next.delete(toolCallId);
91
+ return next;
92
+ });
93
+ },
94
+ onError: (event) => {
95
+ if (onErrorRef.current) onErrorRef.current(event);
96
+ else console.error(`[CopilotKit] Error (${event.code}):`, event.error, event.context ?? {});
97
+ },
98
+ onRuntimeConnectionStatusChanged: () => {
99
+ setRuntimeLicenseStatus(copilotkit.licenseStatus);
100
+ }
101
+ });
102
+ return () => subscription.unsubscribe();
103
+ }, [copilotkit]);
104
+ const contextValue = (0, react.useMemo)(() => ({
105
+ copilotkit,
106
+ executingToolCallIds
107
+ }), [copilotkit, executingToolCallIds]);
108
+ const licenseContextValue = (0, react.useMemo)(() => (0, _copilotkit_shared.createLicenseContextValue)(runtimeLicenseStatus), [runtimeLicenseStatus]);
109
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_context.CopilotKitContext.Provider, {
110
+ value: contextValue,
111
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_context.LicenseContext.Provider, {
112
+ value: licenseContextValue,
113
+ children
114
+ })
115
+ });
116
+ };
117
+
118
+ //#endregion
119
+ Object.defineProperty(exports, 'CopilotKitProvider', {
120
+ enumerable: true,
121
+ get: function () {
122
+ return CopilotKitProvider;
123
+ }
124
+ });
125
+ //# sourceMappingURL=CopilotKitProvider-_pvFePrv.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopilotKitProvider-_pvFePrv.cjs","names":["CopilotKitCoreReact","CopilotKitContext","LicenseContext"],"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/v2/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/v2/context\";\nimport { CopilotKitCoreReact } from \"@copilotkit/react-core/v2/headless\";\nimport type { CopilotKitCoreErrorCode } from \"@copilotkit/core\";\nimport type { DebugConfig, RuntimeLicenseStatus } from \"@copilotkit/shared\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\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 /** 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 // 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 useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\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 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.setProperties(stableProperties);\n copilotkit.setDebug(debug);\n }, [\n runtimeUrl,\n useSingleEndpoint,\n stableHeaders,\n credentials,\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 {children}\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,mBACA,YACA,SACA,OACA,wBACI;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,uDAAoB;GACpE;GACA,kBACE,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA;GACR,SAAS;GACT;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,cAAc,iBAAiB;AAC1C,aAAW,SAAS,MAAM;IACzB;EACD;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,oDAAkB;EAAS,OAAO;YACjC,2CAACC,iDAAe;GAAS,OAAO;GAC7B;IACuB;GACC"}
package/dist/headless.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_chunk = require('./chunk-C0xms8kb.cjs');
3
3
  require('./polyfills.cjs');
4
- const require_useRenderTool = require('./useRenderTool-L3Rw6SYD.cjs');
4
+ const require_CopilotKitProvider = require('./CopilotKitProvider-_pvFePrv.cjs');
5
5
  let _copilotkit_react_core_v2_context = require("@copilotkit/react-core/v2/context");
6
6
  let _copilotkit_react_core_v2_headless = require("@copilotkit/react-core/v2/headless");
7
7
  let _copilotkit_core = require("@copilotkit/core");
@@ -37,7 +37,7 @@ Object.defineProperty(exports, 'CopilotKitCoreRuntimeConnectionStatus', {
37
37
  return _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus;
38
38
  }
39
39
  });
40
- exports.CopilotKitProvider = require_useRenderTool.CopilotKitProvider;
40
+ exports.CopilotKitProvider = require_CopilotKitProvider.CopilotKitProvider;
41
41
  Object.defineProperty(exports, 'ToolCallStatus', {
42
42
  enumerable: true,
43
43
  get: function () {
@@ -116,7 +116,12 @@ Object.defineProperty(exports, 'useLicenseContext', {
116
116
  return _copilotkit_react_core_v2_context.useLicenseContext;
117
117
  }
118
118
  });
119
- exports.useRenderTool = require_useRenderTool.useRenderTool;
119
+ Object.defineProperty(exports, 'useRenderTool', {
120
+ enumerable: true,
121
+ get: function () {
122
+ return _copilotkit_react_core_v2_headless.useRenderTool;
123
+ }
124
+ });
120
125
  Object.defineProperty(exports, 'useRenderToolCall', {
121
126
  enumerable: true,
122
127
  get: function () {
@@ -1,6 +1,6 @@
1
- import { n as CopilotKitNativeProviderProps, r as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-DFz206nL.cjs";
1
+ import { n as CopilotKitProvider, t as CopilotKitNativeProviderProps } from "./CopilotKitProvider-DsAKy9gw.cjs";
2
2
  import React from "react";
3
- import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, ReactToolCallRenderer as ReactToolCallRenderer$1, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderToolCall, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
3
+ import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, ReactToolCallRenderer as ReactToolCallRenderer$1, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useRenderToolCall, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
4
4
  import { CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Suggestion, ToolCallStatus } from "@copilotkit/core";
5
5
  import { CopilotKitContext, CopilotKitContextValue, useCopilotKit, useLicenseContext } from "@copilotkit/react-core/v2/context";
6
6
  import { AbstractAgent, AgentCapabilities, AssistantMessage as AssistantMessageType, Message, ToolCall, ToolMessage } from "@ag-ui/client";
@@ -1,7 +1,7 @@
1
- import { n as CopilotKitNativeProviderProps, r as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-DsCxzyAP.mjs";
1
+ import { n as CopilotKitProvider, t as CopilotKitNativeProviderProps } from "./CopilotKitProvider-OJzclDZY.mjs";
2
2
  import React from "react";
3
3
  import { CopilotKitContext, CopilotKitContextValue, useCopilotKit, useLicenseContext } from "@copilotkit/react-core/v2/context";
4
- import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, ReactToolCallRenderer as ReactToolCallRenderer$1, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderToolCall, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
4
+ import { AgentContextInput, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, ReactToolCallRenderer as ReactToolCallRenderer$1, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Thread, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useRenderToolCall, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
5
5
  import { CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, Suggestion, ToolCallStatus } from "@copilotkit/core";
6
6
  import { AbstractAgent, AgentCapabilities, AssistantMessage as AssistantMessageType, Message, ToolCall, ToolMessage } from "@ag-ui/client";
7
7
 
package/dist/headless.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./polyfills.mjs";
2
- import { n as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-pLM3upcs.mjs";
2
+ import { t as CopilotKitProvider } from "./CopilotKitProvider-Bpj5_ayo.mjs";
3
3
  import { CopilotKitContext, useCopilotKit, useLicenseContext } from "@copilotkit/react-core/v2/context";
4
- import { CopilotChatDefaultLabels, UseAgentUpdate, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderToolCall, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
4
+ import { CopilotChatDefaultLabels, UseAgentUpdate, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useFrontendTool, useHumanInTheLoop, useInterrupt, useRenderTool, useRenderToolCall, useSuggestions, useThreads } from "@copilotkit/react-core/v2/headless";
5
5
  import { CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus } from "@copilotkit/core";
6
6
  import { AbstractAgent } from "@ag-ui/client";
7
7
 
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_chunk = require('./chunk-C0xms8kb.cjs');
3
- const require_useRenderTool = require('./useRenderTool-L3Rw6SYD.cjs');
3
+ const require_CopilotKitProvider = require('./CopilotKitProvider-_pvFePrv.cjs');
4
4
  require('./headless.cjs');
5
5
  let react = require("react");
6
6
  react = require_chunk.__toESM(react);
@@ -737,7 +737,7 @@ Object.defineProperty(exports, 'CopilotKitCoreRuntimeConnectionStatus', {
737
737
  return _copilotkit_core.CopilotKitCoreRuntimeConnectionStatus;
738
738
  }
739
739
  });
740
- exports.CopilotKitProvider = require_useRenderTool.CopilotKitProvider;
740
+ exports.CopilotKitProvider = require_CopilotKitProvider.CopilotKitProvider;
741
741
  exports.CopilotModal = CopilotModal;
742
742
  exports.CopilotPopup = CopilotPopup;
743
743
  exports.CopilotSidebar = CopilotSidebar;
@@ -821,7 +821,12 @@ Object.defineProperty(exports, 'useLicenseContext', {
821
821
  return _copilotkit_react_core_v2_context.useLicenseContext;
822
822
  }
823
823
  });
824
- exports.useRenderTool = require_useRenderTool.useRenderTool;
824
+ Object.defineProperty(exports, 'useRenderTool', {
825
+ enumerable: true,
826
+ get: function () {
827
+ return _copilotkit_react_core_v2_headless.useRenderTool;
828
+ }
829
+ });
825
830
  Object.defineProperty(exports, 'useRenderToolCall', {
826
831
  enumerable: true,
827
832
  get: function () {
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { n as CopilotKitNativeProviderProps, r as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-DFz206nL.cjs";
2
- import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, FrontendToolRenderFunction, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderToolCall, useSuggestions, useThreads } from "./headless.cjs";
1
+ import { n as CopilotKitProvider, t as CopilotKitNativeProviderProps } from "./CopilotKitProvider-DsAKy9gw.cjs";
2
+ import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, FrontendToolRenderFunction, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useSuggestions, useThreads } from "./headless.cjs";
3
3
  import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
  import React, { ReactNode } from "react";
5
5
  import { ViewStyle } from "react-native";
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { n as CopilotKitNativeProviderProps, r as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-DsCxzyAP.mjs";
2
- import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, FrontendToolRenderFunction, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderToolCall, useSuggestions, useThreads } from "./headless.mjs";
1
+ import { n as CopilotKitProvider, t as CopilotKitNativeProviderProps } from "./CopilotKitProvider-OJzclDZY.mjs";
2
+ import { AbstractAgent, AgentCapabilities, AgentContextInput, AssistantMessageType, CopilotChatConfigurationValue, CopilotChatDefaultLabels, CopilotChatLabels, CopilotKitContext, CopilotKitContextValue, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, FrontendTool, FrontendToolRenderFunction, Interrupt, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, JsonSerializable, Message, ReactFrontendTool, ReactHumanInTheLoop, ReactToolCallRenderer, RenderToolCompleteProps, RenderToolExecutingProps, RenderToolInProgressProps, RenderToolProps, ResumeEntry, ResumeStatus, Suggestion, Thread, ToolCall, ToolCallStatus, ToolMessage, UseAgentUpdate, UseInterruptConfig, UseThreadsInput, UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useSuggestions, useThreads } from "./headless.mjs";
3
3
  import React, { ReactNode } from "react";
4
4
  import { Attachment, AttachmentUploadErrorReason, AttachmentUploadResult } from "@copilotkit/shared";
5
5
  import * as react_jsx_runtime0 from "react/jsx-runtime";
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { n as CopilotKitProvider, t as useRenderTool } from "./useRenderTool-pLM3upcs.mjs";
2
- import { AbstractAgent, CopilotChatDefaultLabels, CopilotKitContext, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus, UseAgentUpdate, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderToolCall, useSuggestions, useThreads } from "./headless.mjs";
1
+ import { t as CopilotKitProvider } from "./CopilotKitProvider-Bpj5_ayo.mjs";
2
+ import { AbstractAgent, CopilotChatDefaultLabels, CopilotKitContext, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, ToolCallStatus, UseAgentUpdate, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotKit, useFrontendTool, useHumanInTheLoop, useInterrupt, useLicenseContext, useRenderTool, useRenderToolCall, useSuggestions, useThreads } from "./headless.mjs";
3
3
  import React, { createContext, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from "react";
4
4
  import { useCopilotKit as useCopilotKit$1 } from "@copilotkit/react-core/v2/context";
5
5
  import { useAgent as useAgent$1 } from "@copilotkit/react-core/v2/headless";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/react-native",
3
- "version": "1.71.1",
3
+ "version": "1.72.0",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "ai",
@@ -76,9 +76,9 @@
76
76
  "@ag-ui/client": "0.0.59",
77
77
  "text-encoding": "^0.7.0",
78
78
  "web-streams-polyfill": "^4.2.0",
79
- "@copilotkit/core": "1.71.1",
80
- "@copilotkit/shared": "1.71.1",
81
- "@copilotkit/react-core": "1.71.1"
79
+ "@copilotkit/core": "1.72.0",
80
+ "@copilotkit/shared": "1.72.0",
81
+ "@copilotkit/react-core": "1.72.0"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@testing-library/react": "^16.3.0",