@copilotkit/react-native 2.0.0-rc.20 → 2.0.0-rc.22

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.
@@ -23,17 +23,20 @@ function createMockCore() {
23
23
  capturedSubscriber = subscriber;
24
24
  return { unsubscribe: unsubscribeMock };
25
25
  }),
26
- setRuntimeUrl: vi.fn(),
27
- setRuntimeTransport: vi.fn(),
28
- setHeaders: vi.fn(),
29
- setCredentials: vi.fn(),
30
- setProperties: vi.fn(),
31
- setMessageFilter: vi.fn(),
32
- setDebug: vi.fn(),
33
- setDefaultThrottleMs: vi.fn(),
26
+ ɵupdateConfig: vi.fn(),
27
+ ɵruntimeInfo: { status: "disconnected" },
28
+ ɵsubscribeToRuntimeInfo: vi.fn(() => () => {}),
29
+ setErrorHandler: vi.fn(),
30
+ connect: vi.fn(),
31
+ dispose: vi.fn(),
34
32
  };
35
33
  }
36
34
 
35
+ /** The last config patch the provider pushed to the core. */
36
+ function lastPatch() {
37
+ return mockCoreInstance.ɵupdateConfig.mock.calls.at(-1)?.[0];
38
+ }
39
+
37
40
  let mockCoreInstance: ReturnType<typeof createMockCore>;
38
41
 
39
42
  /** Keeps the final turn only — the shape #1482 asks for. */
@@ -41,14 +44,16 @@ const keepLastTurn = (messages: any[]) => messages.slice(-1);
41
44
  /** A second, distinguishable filter, for asserting a swap took effect. */
42
45
  const keepLastTwo = (messages: any[]) => messages.slice(-2);
43
46
 
44
- vi.mock("@copilotkit/react-core/headless", () => {
47
+ vi.mock("@copilotkit/react-core/headless", async (importOriginal) => {
48
+ const actual =
49
+ await importOriginal<typeof import("@copilotkit/react-core/headless")>();
45
50
  // Regular function (not arrow) so it's new-able
46
51
  function CopilotKitCoreReact(this: any, ...args: any[]) {
47
52
  hoisted.MockCoreConstructor(...args);
48
53
  const instance = hoisted.MockCoreConstructor.mock.results.at(-1)?.value;
49
54
  if (instance) Object.assign(this, instance);
50
55
  }
51
- return { CopilotKitCoreReact };
56
+ return { ...actual, CopilotKitCoreReact };
52
57
  });
53
58
 
54
59
  vi.mock("@copilotkit/react-core/context", () => {
@@ -70,7 +75,8 @@ vi.mock("@copilotkit/react-core/context", () => {
70
75
  };
71
76
  });
72
77
 
73
- vi.mock("@copilotkit/shared", () => ({
78
+ vi.mock("@copilotkit/shared", async (importOriginal) => ({
79
+ ...(await importOriginal<typeof import("@copilotkit/shared")>()),
74
80
  createLicenseContextValue: () => ({
75
81
  status: null,
76
82
  license: null,
@@ -197,9 +203,7 @@ describe("CopilotKitProvider (React Native)", () => {
197
203
  </CopilotKitProvider>,
198
204
  );
199
205
 
200
- expect(mockCoreInstance.setRuntimeUrl).toHaveBeenCalledWith(
201
- "https://api.test/v2",
202
- );
206
+ expect(lastPatch()?.runtimeUrl).toBe("https://api.test/v2");
203
207
  });
204
208
 
205
209
  it("calls setHeaders when headers content changes", () => {
@@ -209,7 +213,7 @@ describe("CopilotKitProvider (React Native)", () => {
209
213
  </CopilotKitProvider>,
210
214
  );
211
215
 
212
- mockCoreInstance.setHeaders.mockClear();
216
+ mockCoreInstance.ɵupdateConfig.mockClear();
213
217
 
214
218
  rerender(
215
219
  <CopilotKitProvider runtimeUrl="https://api.test" headers={{ b: "2" }}>
@@ -217,7 +221,7 @@ describe("CopilotKitProvider (React Native)", () => {
217
221
  </CopilotKitProvider>,
218
222
  );
219
223
 
220
- expect(mockCoreInstance.setHeaders).toHaveBeenCalledWith({ b: "2" });
224
+ expect(lastPatch()?.headers).toEqual({ b: "2" });
221
225
  });
222
226
 
223
227
  it("does not re-fire setHeaders when content is identical (JSON-stabilized)", () => {
@@ -227,7 +231,7 @@ describe("CopilotKitProvider (React Native)", () => {
227
231
  </CopilotKitProvider>,
228
232
  );
229
233
 
230
- mockCoreInstance.setHeaders.mockClear();
234
+ mockCoreInstance.ɵupdateConfig.mockClear();
231
235
 
232
236
  // New object reference but same content
233
237
  rerender(
@@ -236,7 +240,7 @@ describe("CopilotKitProvider (React Native)", () => {
236
240
  </CopilotKitProvider>,
237
241
  );
238
242
 
239
- expect(mockCoreInstance.setHeaders).not.toHaveBeenCalled();
243
+ expect(mockCoreInstance.ɵupdateConfig).not.toHaveBeenCalled();
240
244
  });
241
245
 
242
246
  // #1482: parity with the React, Vue and Angular providers. The filter's own
@@ -267,7 +271,7 @@ describe("CopilotKitProvider (React Native)", () => {
267
271
  </CopilotKitProvider>,
268
272
  );
269
273
 
270
- mockCoreInstance.setMessageFilter.mockClear();
274
+ mockCoreInstance.ɵupdateConfig.mockClear();
271
275
 
272
276
  rerender(
273
277
  <CopilotKitProvider
@@ -278,9 +282,7 @@ describe("CopilotKitProvider (React Native)", () => {
278
282
  </CopilotKitProvider>,
279
283
  );
280
284
 
281
- expect(mockCoreInstance.setMessageFilter).toHaveBeenCalledWith(
282
- keepLastTwo,
283
- );
285
+ expect(lastPatch()?.messageFilter).toBe(keepLastTwo);
284
286
  });
285
287
 
286
288
  it("clears the filter when the prop goes away", () => {
@@ -293,7 +295,7 @@ describe("CopilotKitProvider (React Native)", () => {
293
295
  </CopilotKitProvider>,
294
296
  );
295
297
 
296
- mockCoreInstance.setMessageFilter.mockClear();
298
+ mockCoreInstance.ɵupdateConfig.mockClear();
297
299
 
298
300
  rerender(
299
301
  <CopilotKitProvider runtimeUrl="https://api.test">
@@ -301,7 +303,9 @@ describe("CopilotKitProvider (React Native)", () => {
301
303
  </CopilotKitProvider>,
302
304
  );
303
305
 
304
- expect(mockCoreInstance.setMessageFilter).toHaveBeenCalledWith(undefined);
306
+ const patch = lastPatch();
307
+ expect(patch && "messageFilter" in patch).toBe(true);
308
+ expect(patch?.messageFilter).toBeUndefined();
305
309
  });
306
310
  });
307
311
 
@@ -403,7 +407,9 @@ describe("CopilotKitProvider (React Native)", () => {
403
407
  // ── Error handling ────────────────────────────────────────────────────
404
408
 
405
409
  describe("error handling", () => {
406
- it("forwards errors to onError prop when provided", () => {
410
+ // Core calls the handler, and logs when there is none (core tests cover
411
+ // that). The provider's job is handing the handler over.
412
+ it("passes onError to the core at construction", () => {
407
413
  const onError = vi.fn();
408
414
  render(
409
415
  <CopilotKitProvider runtimeUrl="https://api.test" onError={onError}>
@@ -411,47 +417,12 @@ describe("CopilotKitProvider (React Native)", () => {
411
417
  </CopilotKitProvider>,
412
418
  );
413
419
 
414
- const testError = new Error("test error");
415
- act(() => {
416
- capturedSubscriber.onError({
417
- error: testError,
418
- code: "RUNTIME_ERROR",
419
- context: { detail: "info" },
420
- });
421
- });
422
-
423
- expect(onError).toHaveBeenCalledWith({
424
- error: testError,
425
- code: "RUNTIME_ERROR",
426
- context: { detail: "info" },
427
- });
428
- });
429
-
430
- it("logs to console.error when onError is not provided", () => {
431
- const spy = vi.spyOn(console, "error").mockImplementation(() => {});
432
- render(
433
- <CopilotKitProvider runtimeUrl="https://api.test">
434
- <div />
435
- </CopilotKitProvider>,
436
- );
437
-
438
- act(() => {
439
- capturedSubscriber.onError({
440
- error: new Error("fail"),
441
- code: "AGENT_ERROR",
442
- context: {},
443
- });
444
- });
445
-
446
- expect(spy).toHaveBeenCalledWith(
447
- expect.stringContaining("AGENT_ERROR"),
448
- expect.any(Error),
449
- expect.any(Object),
420
+ expect(hoisted.MockCoreConstructor).toHaveBeenCalledWith(
421
+ expect.objectContaining({ onError }),
450
422
  );
451
- spy.mockRestore();
452
423
  });
453
424
 
454
- it("picks up new onError callback without resubscribing (ref pattern)", () => {
425
+ it("hands a new onError to the core", () => {
455
426
  const onError1 = vi.fn();
456
427
  const onError2 = vi.fn();
457
428
 
@@ -467,16 +438,9 @@ describe("CopilotKitProvider (React Native)", () => {
467
438
  </CopilotKitProvider>,
468
439
  );
469
440
 
470
- act(() => {
471
- capturedSubscriber.onError({
472
- error: new Error("test"),
473
- code: "RUNTIME_ERROR",
474
- context: {},
475
- });
476
- });
477
-
478
- expect(onError1).not.toHaveBeenCalled();
479
- expect(onError2).toHaveBeenCalled();
441
+ expect(mockCoreInstance.setErrorHandler).toHaveBeenLastCalledWith(
442
+ onError2,
443
+ );
480
444
  });
481
445
  });
482
446
 
@@ -494,5 +458,36 @@ describe("CopilotKitProvider (React Native)", () => {
494
458
 
495
459
  expect(unsubscribeMock).toHaveBeenCalled();
496
460
  });
461
+
462
+ it("disposes the core after unmount", async () => {
463
+ const { unmount } = render(
464
+ <CopilotKitProvider runtimeUrl="https://api.test">
465
+ <div />
466
+ </CopilotKitProvider>,
467
+ );
468
+
469
+ unmount();
470
+
471
+ await vi.waitFor(() =>
472
+ expect(mockCoreInstance.dispose).toHaveBeenCalledTimes(1),
473
+ );
474
+ });
475
+ });
476
+
477
+ // ── Runtime connection ──────────────────────────────────────────────
478
+
479
+ describe("runtime connection", () => {
480
+ it("defers /info to an effect", () => {
481
+ render(
482
+ <CopilotKitProvider runtimeUrl="https://api.test">
483
+ <div />
484
+ </CopilotKitProvider>,
485
+ );
486
+
487
+ expect(hoisted.MockCoreConstructor).toHaveBeenCalledWith(
488
+ expect.objectContaining({ deferInitialConnection: true }),
489
+ );
490
+ expect(mockCoreInstance.connect).toHaveBeenCalled();
491
+ });
497
492
  });
498
493
  });
@@ -88,6 +88,12 @@ function createMockCore() {
88
88
  setMessageFilter: vi.fn(),
89
89
  setDebug: vi.fn(),
90
90
  setDefaultThrottleMs: vi.fn(),
91
+ ɵupdateConfig: vi.fn(),
92
+ ɵruntimeInfo: { status: "disconnected" },
93
+ ɵsubscribeToRuntimeInfo: vi.fn(() => () => {}),
94
+ setErrorHandler: vi.fn(),
95
+ connect: vi.fn(),
96
+ dispose: vi.fn(),
91
97
  getAgent: vi.fn(() => undefined),
92
98
  runtimeUrl: "https://api.test",
93
99
  runtimeTransport: "auto",
@@ -107,7 +113,10 @@ function createMockCore() {
107
113
 
108
114
  let mockCoreInstance: ReturnType<typeof createMockCore>;
109
115
 
110
- vi.mock("@copilotkit/react-core/headless", () => {
116
+ vi.mock("@copilotkit/react-core/headless", async (importOriginal) => {
117
+ // The real entry, so the provider gets the real `ɵuseOwnedCore`.
118
+ const actual =
119
+ await importOriginal<typeof import("@copilotkit/react-core/headless")>();
111
120
  // Regular function (not arrow) so it's new-able
112
121
  function CopilotKitCoreReact(this: any, ...args: any[]) {
113
122
  hoisted.MockCoreConstructor(...args);
@@ -115,6 +124,7 @@ vi.mock("@copilotkit/react-core/headless", () => {
115
124
  if (instance) Object.assign(this, instance);
116
125
  }
117
126
  return {
127
+ ...actual,
118
128
  CopilotKitCoreReact,
119
129
  useAgent: () => {
120
130
  const ctx = require("react").useContext(hoisted.RealContext);
@@ -1 +0,0 @@
1
- {"version":3,"file":"CopilotKitProvider-DbI3aQam.cjs","names":["CopilotKitCoreReact","CopilotKitContext","LicenseContext","MarkdownRendererProvider"],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport { CopilotKitCoreReact } from \"@copilotkit/react-core/headless\";\nimport type {\n CopilotKitCoreErrorCode,\n CopilotKitMessageFilter,\n} from \"@copilotkit/core\";\nimport type { DebugConfig, RuntimeLicenseStatus } from \"@copilotkit/shared\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Credentials mode for fetch requests (e.g., \"include\" for HTTP-only cookies in cross-origin requests).\n */\n credentials?: RequestCredentials;\n /**\n * Rewrites the message list sent to runtime agents on every run.\n *\n * CopilotKit sends the whole thread each time. When your agent already\n * stores the conversation, most of that payload is waste, and an agent that\n * merges the inbound list with its own store can show the model every turn\n * twice. Return the messages to send:\n *\n * ```tsx\n * <CopilotKitProvider\n * runtimeUrl=\"/api/copilotkit\"\n * messageFilter={(messages) => messages.slice(-1)}\n * />\n * ```\n *\n * The filter changes the request body only. The transcript the UI renders is\n * untouched. Broken tool-call pairs are repaired before the request is sent,\n * so a filter this blunt cannot strand a tool result mid-HITL.\n *\n * Agents reached through your CopilotRuntime honor this. An agent your app\n * passes in directly does not, and neither Intelligence runs nor suggestion\n * runs are ever filtered.\n *\n * Prefer a stable reference (`useCallback`). An inline arrow re-registers the\n * filter on every render, which is harmless but needless.\n */\n messageFilter?: CopilotKitMessageFilter;\n /** Whether the runtime uses a single-route endpoint */\n useSingleEndpoint?: boolean;\n /** Custom properties forwarded to agents */\n properties?: Record<string, unknown>;\n /**\n * Error handler called when CopilotKit encounters an error.\n * Fires for all error types (runtime connection failures, agent errors, tool errors).\n * If not provided, errors are logged to console.error.\n */\n onError?: (event: {\n error: Error;\n code: CopilotKitCoreErrorCode;\n context: Record<string, any>;\n }) => void | Promise<void>;\n /**\n * Enable debug logging for the client-side event pipeline.\n * `true` logs event and lifecycle summaries. Pass `{ verbose: true }` for\n * full event payloads.\n */\n debug?: DebugConfig;\n /**\n * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`\n * subscriptions. Individual subscriptions can override with their own `throttleMs`.\n */\n defaultThrottleMs?: number;\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n\n if (copilotkitRef.current === null) {\n const instance: CopilotKitCoreReactInstance = new CopilotKitCoreReact({\n runtimeUrl,\n runtimeTransport:\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: stableProperties,\n debug,\n });\n // Set initial defaultThrottleMs synchronously so child hooks see the\n // correct value on their first render (before useEffect fires).\n if (defaultThrottleMs !== undefined) {\n instance.setDefaultThrottleMs(defaultThrottleMs);\n }\n copilotkitRef.current = instance;\n }\n\n const copilotkit = copilotkitRef.current;\n\n // Sync props to core instance\n useEffect(() => {\n copilotkit.setRuntimeUrl(runtimeUrl);\n copilotkit.setRuntimeTransport(\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n );\n copilotkit.setHeaders(stableHeaders);\n copilotkit.setCredentials(credentials);\n copilotkit.setMessageFilter(messageFilter);\n copilotkit.setProperties(stableProperties);\n copilotkit.setDebug(debug);\n }, [\n runtimeUrl,\n useSingleEndpoint,\n stableHeaders,\n credentials,\n messageFilter,\n stableProperties,\n debug,\n copilotkit,\n ]);\n\n // Sync defaultThrottleMs to the core instance on prop changes.\n // Initial value is set synchronously during instance creation (inside the\n // ref guard above), so this only handles subsequent updates.\n useEffect(() => {\n copilotkit.setDefaultThrottleMs(defaultThrottleMs);\n }, [copilotkit, defaultThrottleMs]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState<\n RuntimeLicenseStatus | undefined\n >(undefined);\n\n // Use ref to avoid subscription churn when onError changes\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n // Single subscription for tool execution tracking and error handling.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n onError: (event) => {\n if (onErrorRef.current) {\n void onErrorRef.current(event);\n } else {\n console.error(\n `[CopilotKit] Error (${event.code}):`,\n event.error,\n event.context ?? {},\n );\n }\n },\n onRuntimeConnectionStatusChanged: () => {\n setRuntimeLicenseStatus(copilotkit.licenseStatus);\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,eACA,mBACA,YACA,SACA,OACA,mBACA,uBACI;CAEJ,MAAM,kBACJ,OAAO,gBAAgB,aAAa,aAAa,GAAG;CAKtD,MAAM,yCACE,mBAAmB,EAAE,EAC3B,CAAC,KAAK,UAAU,gBAAgB,CAAC,CAClC;CAED,MAAM,4CACE,cAAc,EAAE,EACtB,CAAC,KAAK,UAAU,WAAW,CAAC,CAC7B;CAED,MAAM,kCAA2D,KAAK;AAEtE,KAAI,cAAc,YAAY,MAAM;EAClC,MAAM,WAAwC,IAAIA,oDAAoB;GACpE;GACA,kBACE,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA;GACR,SAAS;GACT;GACA;GACA,YAAY;GACZ;GACD,CAAC;AAGF,MAAI,sBAAsB,OACxB,UAAS,qBAAqB,kBAAkB;AAElD,gBAAc,UAAU;;CAG1B,MAAM,aAAa,cAAc;AAGjC,4BAAgB;AACd,aAAW,cAAc,WAAW;AACpC,aAAW,oBACT,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA,OACP;AACD,aAAW,WAAW,cAAc;AACpC,aAAW,eAAe,YAAY;AACtC,aAAW,iBAAiB,cAAc;AAC1C,aAAW,cAAc,iBAAiB;AAC1C,aAAW,SAAS,MAAM;IACzB;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAKF,4BAAgB;AACd,aAAW,qBAAqB,kBAAkB;IACjD,CAAC,YAAY,kBAAkB,CAAC;CAKnC,MAAM,CAAC,sBAAsB,qEAErB,IAAI,KAAK,CAAC;CAElB,MAAM,CAAC,sBAAsB,+CAE3B,OAAU;CAGZ,MAAM,+BAAoB,QAAQ;AAClC,4BAAgB;AACd,aAAW,UAAU;IACpB,CAAC,QAAQ,CAAC;AAKb,4BAAgB;EACd,MAAM,eAAe,WAAW,UAAU;GACxC,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEJ,UAAU,UAAU;AAClB,QAAI,WAAW,QACb,CAAK,WAAW,QAAQ,MAAM;QAE9B,SAAQ,MACN,uBAAuB,MAAM,KAAK,KAClC,MAAM,OACN,MAAM,WAAW,EAAE,CACpB;;GAGL,wCAAwC;AACtC,4BAAwB,WAAW,cAAc;;GAEpD,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,yCACG;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,iGAC4B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,2CAACC,iDAAkB;EAAS,OAAO;YACjC,2CAACC,8CAAe;GAAS,OAAO;aAC9B,2CAACC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"CopilotKitProvider-DlP73sLt.mjs","names":[],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport { CopilotKitCoreReact } from \"@copilotkit/react-core/headless\";\nimport type {\n CopilotKitCoreErrorCode,\n CopilotKitMessageFilter,\n} from \"@copilotkit/core\";\nimport type { DebugConfig, RuntimeLicenseStatus } from \"@copilotkit/shared\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Credentials mode for fetch requests (e.g., \"include\" for HTTP-only cookies in cross-origin requests).\n */\n credentials?: RequestCredentials;\n /**\n * Rewrites the message list sent to runtime agents on every run.\n *\n * CopilotKit sends the whole thread each time. When your agent already\n * stores the conversation, most of that payload is waste, and an agent that\n * merges the inbound list with its own store can show the model every turn\n * twice. Return the messages to send:\n *\n * ```tsx\n * <CopilotKitProvider\n * runtimeUrl=\"/api/copilotkit\"\n * messageFilter={(messages) => messages.slice(-1)}\n * />\n * ```\n *\n * The filter changes the request body only. The transcript the UI renders is\n * untouched. Broken tool-call pairs are repaired before the request is sent,\n * so a filter this blunt cannot strand a tool result mid-HITL.\n *\n * Agents reached through your CopilotRuntime honor this. An agent your app\n * passes in directly does not, and neither Intelligence runs nor suggestion\n * runs are ever filtered.\n *\n * Prefer a stable reference (`useCallback`). An inline arrow re-registers the\n * filter on every render, which is harmless but needless.\n */\n messageFilter?: CopilotKitMessageFilter;\n /** Whether the runtime uses a single-route endpoint */\n useSingleEndpoint?: boolean;\n /** Custom properties forwarded to agents */\n properties?: Record<string, unknown>;\n /**\n * Error handler called when CopilotKit encounters an error.\n * Fires for all error types (runtime connection failures, agent errors, tool errors).\n * If not provided, errors are logged to console.error.\n */\n onError?: (event: {\n error: Error;\n code: CopilotKitCoreErrorCode;\n context: Record<string, any>;\n }) => void | Promise<void>;\n /**\n * Enable debug logging for the client-side event pipeline.\n * `true` logs event and lifecycle summaries. Pass `{ verbose: true }` for\n * full event payloads.\n */\n debug?: DebugConfig;\n /**\n * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`\n * subscriptions. Individual subscriptions can override with their own `throttleMs`.\n */\n defaultThrottleMs?: number;\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n\n if (copilotkitRef.current === null) {\n const instance: CopilotKitCoreReactInstance = new CopilotKitCoreReact({\n runtimeUrl,\n runtimeTransport:\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: stableProperties,\n debug,\n });\n // Set initial defaultThrottleMs synchronously so child hooks see the\n // correct value on their first render (before useEffect fires).\n if (defaultThrottleMs !== undefined) {\n instance.setDefaultThrottleMs(defaultThrottleMs);\n }\n copilotkitRef.current = instance;\n }\n\n const copilotkit = copilotkitRef.current;\n\n // Sync props to core instance\n useEffect(() => {\n copilotkit.setRuntimeUrl(runtimeUrl);\n copilotkit.setRuntimeTransport(\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n );\n copilotkit.setHeaders(stableHeaders);\n copilotkit.setCredentials(credentials);\n copilotkit.setMessageFilter(messageFilter);\n copilotkit.setProperties(stableProperties);\n copilotkit.setDebug(debug);\n }, [\n runtimeUrl,\n useSingleEndpoint,\n stableHeaders,\n credentials,\n messageFilter,\n stableProperties,\n debug,\n copilotkit,\n ]);\n\n // Sync defaultThrottleMs to the core instance on prop changes.\n // Initial value is set synchronously during instance creation (inside the\n // ref guard above), so this only handles subsequent updates.\n useEffect(() => {\n copilotkit.setDefaultThrottleMs(defaultThrottleMs);\n }, [copilotkit, defaultThrottleMs]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState<\n RuntimeLicenseStatus | undefined\n >(undefined);\n\n // Use ref to avoid subscription churn when onError changes\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n // Single subscription for tool execution tracking and error handling.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n onError: (event) => {\n if (onErrorRef.current) {\n void onErrorRef.current(event);\n } else {\n console.error(\n `[CopilotKit] Error (${event.code}):`,\n event.error,\n event.context ?? {},\n );\n }\n },\n onRuntimeConnectionStatusChanged: () => {\n setRuntimeLicenseStatus(copilotkit.licenseStatus);\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,eACA,mBACA,YACA,SACA,OACA,mBACA,uBACI;CAEJ,MAAM,kBACJ,OAAO,gBAAgB,aAAa,aAAa,GAAG;CAKtD,MAAM,gBAAgB,cACd,mBAAmB,EAAE,EAC3B,CAAC,KAAK,UAAU,gBAAgB,CAAC,CAClC;CAED,MAAM,mBAAmB,cACjB,cAAc,EAAE,EACtB,CAAC,KAAK,UAAU,WAAW,CAAC,CAC7B;CAED,MAAM,gBAAgB,OAA2C,KAAK;AAEtE,KAAI,cAAc,YAAY,MAAM;EAClC,MAAM,WAAwC,IAAI,oBAAoB;GACpE;GACA,kBACE,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA;GACR,SAAS;GACT;GACA;GACA,YAAY;GACZ;GACD,CAAC;AAGF,MAAI,sBAAsB,OACxB,UAAS,qBAAqB,kBAAkB;AAElD,gBAAc,UAAU;;CAG1B,MAAM,aAAa,cAAc;AAGjC,iBAAgB;AACd,aAAW,cAAc,WAAW;AACpC,aAAW,oBACT,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA,OACP;AACD,aAAW,WAAW,cAAc;AACpC,aAAW,eAAe,YAAY;AACtC,aAAW,iBAAiB,cAAc;AAC1C,aAAW,cAAc,iBAAiB;AAC1C,aAAW,SAAS,MAAM;IACzB;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAKF,iBAAgB;AACd,aAAW,qBAAqB,kBAAkB;IACjD,CAAC,YAAY,kBAAkB,CAAC;CAKnC,MAAM,CAAC,sBAAsB,2BAA2B,+BAEhD,IAAI,KAAK,CAAC;CAElB,MAAM,CAAC,sBAAsB,2BAA2B,SAEtD,OAAU;CAGZ,MAAM,aAAa,OAAO,QAAQ;AAClC,iBAAgB;AACd,aAAW,UAAU;IACpB,CAAC,QAAQ,CAAC;AAKb,iBAAgB;EACd,MAAM,eAAe,WAAW,UAAU;GACxC,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEJ,UAAU,UAAU;AAClB,QAAI,WAAW,QACb,CAAK,WAAW,QAAQ,MAAM;QAE9B,SAAQ,MACN,uBAAuB,MAAM,KAAK,KAClC,MAAM,OACN,MAAM,WAAW,EAAE,CACpB;;GAGL,wCAAwC;AACtC,4BAAwB,WAAW,cAAc;;GAEpD,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,eAAuC,eACpC;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,sBAAsB,cACpB,0BAA0B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,oBAAC,kBAAkB;EAAS,OAAO;YACjC,oBAAC,eAAe;GAAS,OAAO;aAC9B,oBAAC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC"}
@@ -1,122 +0,0 @@
1
- import { r as MarkdownStyle } from "./Markdown-DzjnSuu5.cjs";
2
- import React, { ReactNode } from "react";
3
- import { CopilotKitCoreErrorCode, CopilotKitMessageFilter } from "@copilotkit/core";
4
- import { DebugConfig } from "@copilotkit/shared";
5
-
6
- //#region src/components/MarkdownRendererContext.d.ts
7
- interface NativeMarkdownRendererProps {
8
- content: string;
9
- isStreaming?: boolean;
10
- }
11
- type NativeMarkdownRenderer = React.ComponentType<NativeMarkdownRendererProps>;
12
- /** Config for the built-in RN renderer (pass instead of a component). */
13
- interface DefaultMarkdownRendererProps {
14
- style?: MarkdownStyle;
15
- animate?: boolean;
16
- }
17
- type MarkdownRendererValue = NativeMarkdownRenderer | DefaultMarkdownRendererProps;
18
- declare const MarkdownRendererProvider: React.FC<{
19
- renderer?: MarkdownRendererValue;
20
- children: React.ReactNode;
21
- }>;
22
- declare function useMarkdownRenderer(): MarkdownRendererValue | undefined;
23
- //#endregion
24
- //#region src/CopilotKitProvider.d.ts
25
- interface CopilotKitNativeProviderProps {
26
- children: ReactNode;
27
- /** URL of the CopilotKit runtime endpoint */
28
- runtimeUrl: string;
29
- /** Custom headers sent with every request */
30
- headers?: Record<string, string> | (() => Record<string, string>);
31
- /**
32
- * Credentials mode for fetch requests (e.g., "include" for HTTP-only cookies in cross-origin requests).
33
- */
34
- credentials?: RequestCredentials;
35
- /**
36
- * Rewrites the message list sent to runtime agents on every run.
37
- *
38
- * CopilotKit sends the whole thread each time. When your agent already
39
- * stores the conversation, most of that payload is waste, and an agent that
40
- * merges the inbound list with its own store can show the model every turn
41
- * twice. Return the messages to send:
42
- *
43
- * ```tsx
44
- * <CopilotKitProvider
45
- * runtimeUrl="/api/copilotkit"
46
- * messageFilter={(messages) => messages.slice(-1)}
47
- * />
48
- * ```
49
- *
50
- * The filter changes the request body only. The transcript the UI renders is
51
- * untouched. Broken tool-call pairs are repaired before the request is sent,
52
- * so a filter this blunt cannot strand a tool result mid-HITL.
53
- *
54
- * Agents reached through your CopilotRuntime honor this. An agent your app
55
- * passes in directly does not, and neither Intelligence runs nor suggestion
56
- * runs are ever filtered.
57
- *
58
- * Prefer a stable reference (`useCallback`). An inline arrow re-registers the
59
- * filter on every render, which is harmless but needless.
60
- */
61
- messageFilter?: CopilotKitMessageFilter;
62
- /** Whether the runtime uses a single-route endpoint */
63
- useSingleEndpoint?: boolean;
64
- /** Custom properties forwarded to agents */
65
- properties?: Record<string, unknown>;
66
- /**
67
- * Error handler called when CopilotKit encounters an error.
68
- * Fires for all error types (runtime connection failures, agent errors, tool errors).
69
- * If not provided, errors are logged to console.error.
70
- */
71
- onError?: (event: {
72
- error: Error;
73
- code: CopilotKitCoreErrorCode;
74
- context: Record<string, any>;
75
- }) => void | Promise<void>;
76
- /**
77
- * Enable debug logging for the client-side event pipeline.
78
- * `true` logs event and lifecycle summaries. Pass `{ verbose: true }` for
79
- * full event payloads.
80
- */
81
- debug?: DebugConfig;
82
- /**
83
- * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`
84
- * subscriptions. Individual subscriptions can override with their own `throttleMs`.
85
- */
86
- defaultThrottleMs?: number;
87
- /**
88
- * Custom markdown renderer for assistant messages. Either a component (escape
89
- * hatch — receives `content` and an optional `isStreaming` flag) used instead
90
- * of the built-in renderer, or a `{ style, animate }` config object to
91
- * configure the built-in React Native renderer (the `CopilotMarkdown` used by
92
- * the default `AssistantMessage`) without writing a wrapper.
93
- */
94
- markdownRenderer?: MarkdownRendererValue;
95
- }
96
- /**
97
- * CopilotKit provider for React Native.
98
- *
99
- * A lightweight alternative to the web CopilotKitProvider that avoids
100
- * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
101
- *
102
- * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
103
- * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
104
- * required (though it remains available for advanced use).
105
- *
106
- * Usage:
107
- * ```tsx
108
- * import { CopilotKitProvider } from "@copilotkit/react-native";
109
- *
110
- * function App() {
111
- * return (
112
- * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
113
- * <ChatScreen />
114
- * </CopilotKitProvider>
115
- * );
116
- * }
117
- * ```
118
- */
119
- declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
120
- //#endregion
121
- export { NativeMarkdownRendererProps as a, NativeMarkdownRenderer as i, CopilotKitProvider as n, useMarkdownRenderer as o, MarkdownRendererProvider as r, CopilotKitNativeProviderProps as t };
122
- //# sourceMappingURL=CopilotKitProvider-lfVMYSby.d.cts.map
@@ -1,122 +0,0 @@
1
- import { r as MarkdownStyle } from "./Markdown-a-rdG22_.mjs";
2
- import React, { ReactNode } from "react";
3
- import { DebugConfig } from "@copilotkit/shared";
4
- import { CopilotKitCoreErrorCode, CopilotKitMessageFilter } from "@copilotkit/core";
5
-
6
- //#region src/components/MarkdownRendererContext.d.ts
7
- interface NativeMarkdownRendererProps {
8
- content: string;
9
- isStreaming?: boolean;
10
- }
11
- type NativeMarkdownRenderer = React.ComponentType<NativeMarkdownRendererProps>;
12
- /** Config for the built-in RN renderer (pass instead of a component). */
13
- interface DefaultMarkdownRendererProps {
14
- style?: MarkdownStyle;
15
- animate?: boolean;
16
- }
17
- type MarkdownRendererValue = NativeMarkdownRenderer | DefaultMarkdownRendererProps;
18
- declare const MarkdownRendererProvider: React.FC<{
19
- renderer?: MarkdownRendererValue;
20
- children: React.ReactNode;
21
- }>;
22
- declare function useMarkdownRenderer(): MarkdownRendererValue | undefined;
23
- //#endregion
24
- //#region src/CopilotKitProvider.d.ts
25
- interface CopilotKitNativeProviderProps {
26
- children: ReactNode;
27
- /** URL of the CopilotKit runtime endpoint */
28
- runtimeUrl: string;
29
- /** Custom headers sent with every request */
30
- headers?: Record<string, string> | (() => Record<string, string>);
31
- /**
32
- * Credentials mode for fetch requests (e.g., "include" for HTTP-only cookies in cross-origin requests).
33
- */
34
- credentials?: RequestCredentials;
35
- /**
36
- * Rewrites the message list sent to runtime agents on every run.
37
- *
38
- * CopilotKit sends the whole thread each time. When your agent already
39
- * stores the conversation, most of that payload is waste, and an agent that
40
- * merges the inbound list with its own store can show the model every turn
41
- * twice. Return the messages to send:
42
- *
43
- * ```tsx
44
- * <CopilotKitProvider
45
- * runtimeUrl="/api/copilotkit"
46
- * messageFilter={(messages) => messages.slice(-1)}
47
- * />
48
- * ```
49
- *
50
- * The filter changes the request body only. The transcript the UI renders is
51
- * untouched. Broken tool-call pairs are repaired before the request is sent,
52
- * so a filter this blunt cannot strand a tool result mid-HITL.
53
- *
54
- * Agents reached through your CopilotRuntime honor this. An agent your app
55
- * passes in directly does not, and neither Intelligence runs nor suggestion
56
- * runs are ever filtered.
57
- *
58
- * Prefer a stable reference (`useCallback`). An inline arrow re-registers the
59
- * filter on every render, which is harmless but needless.
60
- */
61
- messageFilter?: CopilotKitMessageFilter;
62
- /** Whether the runtime uses a single-route endpoint */
63
- useSingleEndpoint?: boolean;
64
- /** Custom properties forwarded to agents */
65
- properties?: Record<string, unknown>;
66
- /**
67
- * Error handler called when CopilotKit encounters an error.
68
- * Fires for all error types (runtime connection failures, agent errors, tool errors).
69
- * If not provided, errors are logged to console.error.
70
- */
71
- onError?: (event: {
72
- error: Error;
73
- code: CopilotKitCoreErrorCode;
74
- context: Record<string, any>;
75
- }) => void | Promise<void>;
76
- /**
77
- * Enable debug logging for the client-side event pipeline.
78
- * `true` logs event and lifecycle summaries. Pass `{ verbose: true }` for
79
- * full event payloads.
80
- */
81
- debug?: DebugConfig;
82
- /**
83
- * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`
84
- * subscriptions. Individual subscriptions can override with their own `throttleMs`.
85
- */
86
- defaultThrottleMs?: number;
87
- /**
88
- * Custom markdown renderer for assistant messages. Either a component (escape
89
- * hatch — receives `content` and an optional `isStreaming` flag) used instead
90
- * of the built-in renderer, or a `{ style, animate }` config object to
91
- * configure the built-in React Native renderer (the `CopilotMarkdown` used by
92
- * the default `AssistantMessage`) without writing a wrapper.
93
- */
94
- markdownRenderer?: MarkdownRendererValue;
95
- }
96
- /**
97
- * CopilotKit provider for React Native.
98
- *
99
- * A lightweight alternative to the web CopilotKitProvider that avoids
100
- * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
101
- *
102
- * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
103
- * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
104
- * required (though it remains available for advanced use).
105
- *
106
- * Usage:
107
- * ```tsx
108
- * import { CopilotKitProvider } from "@copilotkit/react-native";
109
- *
110
- * function App() {
111
- * return (
112
- * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
113
- * <ChatScreen />
114
- * </CopilotKitProvider>
115
- * );
116
- * }
117
- * ```
118
- */
119
- declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
120
- //#endregion
121
- export { NativeMarkdownRendererProps as a, NativeMarkdownRenderer as i, CopilotKitProvider as n, useMarkdownRenderer as o, MarkdownRendererProvider as r, CopilotKitNativeProviderProps as t };
122
- //# sourceMappingURL=CopilotKitProvider-mVDI6DLx.d.mts.map