@copilotkit/react-native 2.0.0-rc.38 → 2.0.0-rc.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +334 -2
  2. package/USAGE.md +382 -21
  3. package/dist/{CopilotKitProvider-F7Pn5kp4.d.cts → CopilotKitProvider-Cbfrm_7u.d.mts} +2 -2
  4. package/dist/{CopilotKitProvider-DDPbJkHS.cjs → CopilotKitProvider-CvJYytjn.cjs} +4 -3
  5. package/dist/{CopilotKitProvider-DDPbJkHS.cjs.map → CopilotKitProvider-CvJYytjn.cjs.map} +1 -1
  6. package/dist/{CopilotKitProvider-Khgz5dQo.d.mts → CopilotKitProvider-Dv3ISMKf.d.cts} +2 -2
  7. package/dist/{CopilotKitProvider-BXpkAl1Y.mjs → CopilotKitProvider-oTdmylSY.mjs} +2 -2
  8. package/dist/{CopilotKitProvider-BXpkAl1Y.mjs.map → CopilotKitProvider-oTdmylSY.mjs.map} +1 -1
  9. package/dist/{Markdown-CaYHlD4j.cjs → Markdown-DLopAh5W.cjs} +3 -3
  10. package/dist/{Markdown-CaYHlD4j.cjs.map → Markdown-DLopAh5W.cjs.map} +1 -1
  11. package/dist/{Markdown-a-rdG22_.d.mts → Markdown-Du-b_Qpr.d.mts} +1 -1
  12. package/dist/{Markdown-DzjnSuu5.d.cts → Markdown-UXZdDjzs.d.cts} +1 -1
  13. package/dist/{Markdown-SE9MfY2U.mjs → Markdown-VxtPJ_yh.mjs} +1 -1
  14. package/dist/{Markdown-SE9MfY2U.mjs.map → Markdown-VxtPJ_yh.mjs.map} +1 -1
  15. package/dist/{MarkdownRendererContext-B_AKdPAN.mjs → MarkdownRendererContext-EobUsERg.mjs} +1 -1
  16. package/dist/{MarkdownRendererContext-B_AKdPAN.mjs.map → MarkdownRendererContext-EobUsERg.mjs.map} +1 -1
  17. package/dist/MarkdownRendererContext-cDEHvbw9.cjs +40 -0
  18. package/dist/{MarkdownRendererContext-BRNe808d.cjs.map → MarkdownRendererContext-cDEHvbw9.cjs.map} +1 -1
  19. package/dist/chunk-C0xms8kb.cjs +34 -0
  20. package/dist/components/index.cjs +6 -4
  21. package/dist/components/index.cjs.map +1 -1
  22. package/dist/components/index.d.cts +1 -1
  23. package/dist/components/index.d.mts +1 -1
  24. package/dist/components/index.mjs +3 -2
  25. package/dist/components/index.mjs.map +1 -1
  26. package/dist/generative-ui/index.cjs +612 -0
  27. package/dist/generative-ui/index.cjs.map +1 -0
  28. package/dist/generative-ui/index.d.cts +341 -0
  29. package/dist/generative-ui/index.d.mts +341 -0
  30. package/dist/generative-ui/index.mjs +549 -0
  31. package/dist/generative-ui/index.mjs.map +1 -0
  32. package/dist/headless.cjs +2 -3
  33. package/dist/headless.d.cts +2 -2
  34. package/dist/headless.d.mts +2 -2
  35. package/dist/headless.mjs +1 -2
  36. package/dist/index.cjs +8 -7
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +3 -3
  39. package/dist/index.d.mts +2 -2
  40. package/dist/index.mjs +4 -4
  41. package/dist/polyfills/encoding.cjs +113 -3
  42. package/dist/polyfills/encoding.cjs.map +1 -1
  43. package/dist/polyfills/encoding.d.cts +31 -1
  44. package/dist/polyfills/encoding.d.mts +31 -1
  45. package/dist/polyfills/encoding.mjs +109 -3
  46. package/dist/polyfills/encoding.mjs.map +1 -1
  47. package/dist/polyfills/streams.cjs +1 -1
  48. package/dist/polyfills.cjs +218 -3
  49. package/dist/polyfills.cjs.map +1 -1
  50. package/dist/polyfills.mjs +217 -2
  51. package/dist/polyfills.mjs.map +1 -1
  52. package/package.json +13 -5
  53. package/project.json +6 -1
  54. package/scripts/__tests__/verify-polyfill-barrel.test.mjs +150 -0
  55. package/scripts/verify-polyfill-barrel.mjs +154 -5
  56. package/src/__tests__/generative-ui-harness.tsx +243 -0
  57. package/src/__tests__/generative-ui-provider-props.test-d.tsx +106 -0
  58. package/src/__tests__/generative-ui-rn-mock.tsx +54 -0
  59. package/src/__tests__/generative-ui-wiring.test.tsx +720 -0
  60. package/src/__tests__/generative-ui.test.tsx +1000 -0
  61. package/src/__tests__/headless-entry-surface.test.ts +979 -60
  62. package/src/components/index.ts +6 -0
  63. package/src/generative-ui/GenerativeUIActivity.tsx +235 -0
  64. package/src/generative-ui/GenerativeUIProvider.tsx +171 -0
  65. package/src/generative-ui/GenerativeUISurface.tsx +303 -0
  66. package/src/generative-ui/host.tsx +138 -0
  67. package/src/generative-ui/index.ts +93 -0
  68. package/src/generative-ui/internal.ts +55 -0
  69. package/src/index.ts +8 -3
  70. package/src/polyfills/__tests__/{utf8.test.ts → encoding-utf8.test.ts} +1 -1
  71. package/src/polyfills/encoding.ts +156 -1
  72. package/tsdown.config.ts +1 -0
  73. package/dist/MarkdownRendererContext-BRNe808d.cjs +0 -72
  74. package/dist/streaming-fetch-CLHG3Z1H.mjs +0 -219
  75. package/dist/streaming-fetch-CLHG3Z1H.mjs.map +0 -1
  76. package/dist/streaming-fetch-DbDALGya.cjs +0 -225
  77. package/dist/streaming-fetch-DbDALGya.cjs.map +0 -1
  78. package/dist/utf8-BIN9t4Oy.mjs +0 -113
  79. package/dist/utf8-BIN9t4Oy.mjs.map +0 -1
  80. package/dist/utf8-Cf3Ssy33.cjs +0 -125
  81. package/dist/utf8-Cf3Ssy33.cjs.map +0 -1
  82. package/src/polyfills/utf8.ts +0 -151
package/USAGE.md CHANGED
@@ -2,23 +2,25 @@
2
2
 
3
3
  ## Prerequisites
4
4
 
5
- Install all required peer dependencies:
5
+ Install the peer dependencies the Quick Start below uses:
6
6
 
7
7
  ```bash
8
- npm install react react-native @gorhom/bottom-sheet react-native-gesture-handler react-native-reanimated
8
+ npm install react react-native zod @gorhom/bottom-sheet react-native-gesture-handler react-native-reanimated expo-document-picker expo-file-system
9
9
  ```
10
10
 
11
- `@gorhom/bottom-sheet`, `react-native-gesture-handler`, and `react-native-reanimated` are required peer dependencies for the UI components. `CopilotMarkdown` now uses a built-in basic-GFM renderer — no extra markdown library install required.
11
+ `zod` 4.2 or later is what you write tool parameters and generative UI catalogs with. `@copilotkit/react-core` depends on zod 4, and the `child()` and `childList()` helpers return zod 4 schemas.
12
+
13
+ The other packages are optional peer dependencies. The default entry (`@copilotkit/react-native`) re-exports `useAttachments`, which imports `expo-document-picker` and `expo-file-system`, so Metro needs both whenever an app imports from it. `@gorhom/bottom-sheet`, `react-native-gesture-handler` and `react-native-reanimated` are used by the prebuilt components in `@copilotkit/react-native/components`. An app that only imports `@copilotkit/react-native/headless` or `/generative-ui` needs none of them (see "Headless Import Path" below). `CopilotMarkdown` uses a built-in basic-GFM renderer — no extra markdown library install required.
12
14
 
13
15
  ## Quick Start
14
16
 
17
+ The provider and the hooks come from `@copilotkit/react-native`. The prebuilt
18
+ chat UI comes from `@copilotkit/react-native/components`.
19
+
15
20
  ```tsx
16
21
  import "@copilotkit/react-native/polyfills";
17
- import {
18
- CopilotKitProvider,
19
- CopilotChat,
20
- useFrontendTool,
21
- } from "@copilotkit/react-native";
22
+ import { CopilotKitProvider, useFrontendTool } from "@copilotkit/react-native";
23
+ import { CopilotChat } from "@copilotkit/react-native/components";
22
24
  import { z } from "zod";
23
25
 
24
26
  function App() {
@@ -35,7 +37,8 @@ function ChatScreen() {
35
37
  name: "showWeather",
36
38
  description: "Show weather info",
37
39
  parameters: z.object({ city: z.string() }),
38
- render: ({ args }) => <WeatherCard city={args.city} />,
40
+ // `args` is partial while the agent is still writing the call.
41
+ render: ({ args }) => <WeatherCard city={args.city ?? ""} />,
39
42
  });
40
43
 
41
44
  return <CopilotChat placeholder="Ask anything..." />;
@@ -44,22 +47,31 @@ function ChatScreen() {
44
47
 
45
48
  ## Available Components
46
49
 
50
+ The components in this section are the prebuilt UI, and they are exported only
51
+ by `@copilotkit/react-native/components`. The package root exports a
52
+ `CopilotChat` and a `CopilotModal` too, but those are headless: they render
53
+ no UI and take no `placeholder` or `headerTitle` (see
54
+ [Headless chat components](#headless-chat-components)).
55
+
47
56
  ### CopilotChat
48
57
 
49
58
  Inline chat panel. Renders a message list with an input bar.
50
59
 
51
60
  ```tsx
52
- import { CopilotChat } from "@copilotkit/react-native";
61
+ import { CopilotChat } from "@copilotkit/react-native/components";
53
62
 
54
63
  <CopilotChat placeholder="Type a message..." />;
55
64
  ```
56
65
 
57
66
  ### CopilotModal
58
67
 
59
- Modal chat overlay. Open/close programmatically via a ref.
68
+ Modal chat overlay (a bottom sheet). Open/close programmatically via a ref.
60
69
 
61
70
  ```tsx
62
- import { CopilotModal, type CopilotModalRef } from "@copilotkit/react-native";
71
+ import {
72
+ CopilotModal,
73
+ type CopilotModalRef,
74
+ } from "@copilotkit/react-native/components";
63
75
  import { useRef } from "react";
64
76
 
65
77
  const modalRef = useRef<CopilotModalRef>(null);
@@ -75,7 +87,7 @@ modalRef.current?.open();
75
87
  Renders Markdown text with sensible React Native styling.
76
88
 
77
89
  ```tsx
78
- import { CopilotMarkdown } from "@copilotkit/react-native";
90
+ import { CopilotMarkdown } from "@copilotkit/react-native/components";
79
91
 
80
92
  <CopilotMarkdown content="**Hello** from CopilotKit!" />;
81
93
  ```
@@ -85,7 +97,10 @@ import { CopilotMarkdown } from "@copilotkit/react-native";
85
97
  Individual message bubbles. Useful when building a custom chat UI.
86
98
 
87
99
  ```tsx
88
- import { AssistantMessage, UserMessage } from "@copilotkit/react-native";
100
+ import {
101
+ AssistantMessage,
102
+ UserMessage,
103
+ } from "@copilotkit/react-native/components";
89
104
 
90
105
  <UserMessage content="What's the weather?" />
91
106
  <AssistantMessage content="It's sunny!" isLoading={false} />
@@ -108,7 +123,7 @@ useFrontendTool({
108
123
  name: "showChart",
109
124
  description: "Display a chart",
110
125
  parameters: z.object({ data: z.record(z.unknown()) }),
111
- render: ({ args }) => <ChartView data={args.data} />,
126
+ render: ({ args }) => <ChartView data={args.data ?? {}} />,
112
127
  });
113
128
  ```
114
129
 
@@ -177,12 +192,34 @@ untyped, so it still compiles there).
177
192
  See the [`useRenderTool` reference](https://docs.copilotkit.ai/reference/react-native/hooks/useRenderTool)
178
193
  for the full migration table.
179
194
 
180
- ## Alternative Import Path
195
+ ## Headless chat components
181
196
 
182
- Components can also be imported from the `/components` subpath:
197
+ `CopilotChat` and `CopilotModal` from the package root render no UI. They wire
198
+ up the agent and render their children, which read the chat state with
199
+ `useCopilotChatContext()`:
183
200
 
184
201
  ```tsx
185
- import { CopilotChat, CopilotModal } from "@copilotkit/react-native/components";
202
+ import { Pressable, Text, View } from "react-native";
203
+ import { CopilotChat, useCopilotChatContext } from "@copilotkit/react-native";
204
+
205
+ function MyChatUI() {
206
+ const { messages, isRunning, submitMessage } = useCopilotChatContext();
207
+ return (
208
+ <View>
209
+ <Text>{`${messages.length} messages`}</Text>
210
+ <Pressable
211
+ disabled={isRunning}
212
+ onPress={() => void submitMessage("Hello!")}
213
+ >
214
+ <Text>Say hello</Text>
215
+ </Pressable>
216
+ </View>
217
+ );
218
+ }
219
+
220
+ <CopilotChat agentId="my-agent">
221
+ <MyChatUI />
222
+ </CopilotChat>;
186
223
  ```
187
224
 
188
225
  ## Headless Import Path (custom UI, no chat/attachment native deps)
@@ -200,9 +237,10 @@ import {
200
237
  ```
201
238
 
202
239
  The default barrel (`@copilotkit/react-native`) statically re-exports the
203
- prebuilt chat components (`CopilotChat` / `CopilotModal` / `CopilotSidebar` /
204
- `CopilotPopup`, which import `@gorhom/bottom-sheet`) and `useAttachments` (which
205
- imports `expo-document-picker` + `expo-file-system`). Even though those are
240
+ chat components (`CopilotChat` / `CopilotModal` / `CopilotSidebar` /
241
+ `CopilotPopup`) and `useAttachments` (which imports `expo-document-picker` +
242
+ `expo-file-system`). The bottom-sheet modal that needs `@gorhom/bottom-sheet`
243
+ lives in `@copilotkit/react-native/components`. Even though those are
206
244
  optional peer dependencies, the static re-export forces Metro to resolve them at
207
245
  bundle time — so a headless consumer previously had to install every chat and
208
246
  attachment native dep, or stub them in `metro.config.js`, to get past
@@ -214,3 +252,326 @@ the render-tool registry, and the core/AG-UI types — none of the chat UI or
214
252
  `metro.config.js` stub workaround is no longer needed. Polyfills are still
215
253
  auto-installed, so no separate `import "@copilotkit/react-native/polyfills"` is
216
254
  required.
255
+
256
+ ## Generative UI (experimental)
257
+
258
+ `@copilotkit/react-native/generative-ui` lets the agent render a catalog of your
259
+ own native components with the `render_ui` tool. Write the catalog with `zod`
260
+ 4.2 or later: `child()` and `childList()` return zod 4 schemas. The runtime needs no change by default: `CopilotRuntime` adds the
261
+ tool when the app sends a catalog with at least one component, unless the
262
+ server sets `generativeUI: false` or limits it with
263
+ `generativeUI: { agents: [...] }`. This example needs a `home` agent on the
264
+ runtime: once the runtime has connected, `useAgent` throws without it.
265
+
266
+ ```tsx
267
+ import { useCallback, useEffect, useRef, useState } from "react";
268
+ import {
269
+ ActivityIndicator,
270
+ Pressable,
271
+ ScrollView,
272
+ Text,
273
+ View,
274
+ } from "react-native";
275
+ import { z } from "zod";
276
+ import {
277
+ CopilotKitCoreErrorCode,
278
+ CopilotKitCoreRuntimeConnectionStatus,
279
+ CopilotKitProvider,
280
+ useAgent,
281
+ useAgentContext,
282
+ useCopilotKit,
283
+ } from "@copilotkit/react-native/headless";
284
+ import {
285
+ GenerativeUIActivity,
286
+ GenerativeUIProvider,
287
+ createGenerativeUI,
288
+ isGenerativeUIActivity,
289
+ useGenerativeUIRuntime,
290
+ type GenerativeUIActivityMessage,
291
+ } from "@copilotkit/react-native/generative-ui";
292
+
293
+ const ui = createGenerativeUI({
294
+ id: "acme/bank@1",
295
+ components: {
296
+ BalanceCard: {
297
+ component: ({ account, amount }: { account: string; amount: number }) => (
298
+ <View>
299
+ <Text>{account}</Text>
300
+ <Text>{amount}</Text>
301
+ </View>
302
+ ),
303
+ description:
304
+ "The balance of one account. Copy the values from the context.",
305
+ props: z.object({ account: z.string(), amount: z.number() }),
306
+ },
307
+ },
308
+ });
309
+
310
+ type CopilotKit = ReturnType<typeof useCopilotKit>["copilotkit"];
311
+ type Agent = ReturnType<typeof useAgent>["agent"];
312
+
313
+ /**
314
+ * The errors that end a run. A failed tool call is not one of them
315
+ * (TOOL_HANDLER_FAILED, TOOL_ARGUMENT_PARSE_FAILED): its error goes back to
316
+ * the model as the result of the call, and the run goes on.
317
+ */
318
+ const RUN_FAILURES: ReadonlySet<CopilotKitCoreErrorCode> = new Set([
319
+ CopilotKitCoreErrorCode.AGENT_RUN_FAILED,
320
+ CopilotKitCoreErrorCode.AGENT_RUN_FAILED_EVENT,
321
+ CopilotKitCoreErrorCode.AGENT_RUN_ERROR_EVENT,
322
+ CopilotKitCoreErrorCode.AGENT_THREAD_LOCKED,
323
+ ]);
324
+
325
+ // Date.now() alone repeats within a millisecond; with a counter, ids do not.
326
+ let sent = 0;
327
+
328
+ /**
329
+ * Sends one user message and runs the agent. Resolves with the run's error,
330
+ * or undefined; it never rejects. It counts every run failure of this agent
331
+ * while it waits, so start one run of an agent at a time.
332
+ */
333
+ async function runTurn(copilotkit: CopilotKit, agent: Agent, content: string) {
334
+ const before = agent.messages.map((message) => message.id);
335
+ const { threadId } = agent;
336
+ let failure: Error | undefined;
337
+ const subscription = copilotkit.subscribe({
338
+ onError: ({ error, code, context }) => {
339
+ if (context.agentId === agent.agentId && RUN_FAILURES.has(code)) {
340
+ failure ??= error;
341
+ }
342
+ },
343
+ });
344
+ try {
345
+ sent += 1;
346
+ agent.addMessage({
347
+ id: `user-${Date.now()}-${sent}`,
348
+ role: "user",
349
+ content,
350
+ });
351
+ await copilotkit.runAgent({ agent });
352
+ } catch (error) {
353
+ failure ??= error instanceof Error ? error : new Error(String(error));
354
+ } finally {
355
+ subscription.unsubscribe();
356
+ }
357
+ try {
358
+ if (failure) takeBack(agent, before, threadId);
359
+ } catch (error) {
360
+ console.error("Could not take the failed turn back:", error);
361
+ }
362
+ return failure;
363
+ }
364
+
365
+ /**
366
+ * Removes the messages added since `before` (their ids), such as the user
367
+ * message and a partial reply. It keeps the surfaces: the provider keeps
368
+ * every surface that a run rendered, and the model still sees it, so the
369
+ * screen shows it too.
370
+ */
371
+ function takeBack(
372
+ agent: Agent,
373
+ before: readonly string[],
374
+ threadId: string | undefined,
375
+ ) {
376
+ // The agent moved to another thread: those messages are not this turn's.
377
+ if (agent.threadId !== threadId) return;
378
+ const kept = new Set(before);
379
+ agent.setMessages(
380
+ agent.messages.filter(
381
+ (message) => kept.has(message.id) || isGenerativeUIActivity(message),
382
+ ),
383
+ );
384
+ }
385
+
386
+ /**
387
+ * An activity message that GenerativeUIActivity draws: its surface is aimed at
388
+ * the chat (the target it shows) and the agent has not deleted it.
389
+ */
390
+ function isChatSurface(message: GenerativeUIActivityMessage) {
391
+ if (!isGenerativeUIActivity(message)) return false;
392
+ const content = message.content as {
393
+ target?: unknown;
394
+ operations?: unknown;
395
+ } | null;
396
+ const operations = Array.isArray(content?.operations)
397
+ ? content.operations
398
+ : [];
399
+ return (
400
+ content?.target === "chat" &&
401
+ !operations.some(
402
+ (op) => typeof op === "object" && op !== null && "deleteSurface" in op,
403
+ )
404
+ );
405
+ }
406
+
407
+ /**
408
+ * The chat surfaces that this device built, each message id with its operations,
409
+ * to tell whether a run rendered or updated one here. The operations alone: each
410
+ * call of the agent also refills the list of rejected operations, so a call whose
411
+ * updates were all rejected changes the content but not the surface. A surface
412
+ * whose createSurface the app rejected (`failed`) does not count: the app checks
413
+ * the operations again, prop values included, and GenerativeUIActivity then shows
414
+ * only an error line.
415
+ */
416
+ function chatSurfaces(
417
+ messages: readonly GenerativeUIActivityMessage[],
418
+ failed: (surfaceId: string) => boolean,
419
+ ) {
420
+ const built = new Map<string | undefined, string>();
421
+ for (const message of messages.filter(isChatSurface)) {
422
+ const { surfaceId, operations } = message.content as {
423
+ surfaceId?: unknown;
424
+ operations?: unknown;
425
+ };
426
+ if (typeof surfaceId === "string" && failed(surfaceId)) continue;
427
+ built.set(message.id, JSON.stringify(operations));
428
+ }
429
+ return built;
430
+ }
431
+
432
+ // Your app's data. The agent sees only what you give it with useAgentContext.
433
+ const accounts = [
434
+ { account: "Chequing", amount: 3482.1 },
435
+ { account: "Savings", amount: 6150 },
436
+ ];
437
+
438
+ function Home() {
439
+ const { copilotkit } = useCopilotKit();
440
+ // Until the runtime connects, `agent` is a stand-in (`isReady` is false). The
441
+ // registered agent replaces it, so a run started on the stand-in is lost.
442
+ // Once the runtime has connected, useAgent throws if it has no `home` agent.
443
+ const { agent, isReady } = useAgent({ agentId: "home" });
444
+ const runtime = useGenerativeUIRuntime();
445
+ // The thread it last checked: a ref, so StrictMode's second effect run sees it.
446
+ const checkedThread = useRef<string | undefined>(undefined);
447
+ const composing = useRef(false); // a ref, so a second tap is ignored at once
448
+ const [checked, setChecked] = useState(false);
449
+ const [busy, setBusy] = useState(false);
450
+ const [error, setError] = useState<string>();
451
+
452
+ useAgentContext({
453
+ description:
454
+ "The user's accounts. Show only these, with these exact balances.",
455
+ value: accounts,
456
+ });
457
+
458
+ const failed = useCallback(
459
+ (surfaceId: string) =>
460
+ !!runtime?.manager.getFailedSurface(agent.threadId, surfaceId),
461
+ [runtime, agent],
462
+ );
463
+
464
+ const compose = useCallback(async () => {
465
+ // A stand-in agent (not ready) would lose the run.
466
+ if (composing.current || !isReady) return;
467
+ composing.current = true;
468
+ setBusy(true);
469
+ setError(undefined);
470
+ try {
471
+ const before = agent.messages.map((message) => message.id);
472
+ const { threadId } = agent;
473
+ const shownBefore = chatSurfaces(agent.messages, failed);
474
+ const failure = await runTurn(copilotkit, agent, "Show my balances.");
475
+ const shownAfter = chatSurfaces(agent.messages, failed);
476
+ if (failure) {
477
+ // runTurn took the prompt back, so a retry sends it once.
478
+ setError(failure.message);
479
+ } else if (
480
+ ![...shownAfter].some(
481
+ ([id, content]) => shownBefore.get(id) !== content,
482
+ )
483
+ ) {
484
+ // This run rendered or updated nothing here. Take its prompt back too.
485
+ takeBack(agent, before, threadId);
486
+ setError("The agent rendered nothing for this screen.");
487
+ }
488
+ } catch (reason) {
489
+ setError(reason instanceof Error ? reason.message : String(reason));
490
+ } finally {
491
+ composing.current = false;
492
+ setBusy(false);
493
+ }
494
+ }, [agent, copilotkit, failed, isReady]);
495
+
496
+ // The agent and its messages live in the core and outlive this screen. Run only
497
+ // when the registered agent has no surface here yet and is not running, so a
498
+ // screen that mounts again shows what it has instead of composing it again.
499
+ // Check again when the agent moves to another thread, once it is not running
500
+ // and no compose is under way (`busy` reruns this when one ends).
501
+ useEffect(() => {
502
+ if (
503
+ !isReady ||
504
+ busy ||
505
+ composing.current ||
506
+ agent.isRunning ||
507
+ checkedThread.current === agent.threadId
508
+ ) {
509
+ return;
510
+ }
511
+ checkedThread.current = agent.threadId;
512
+ setChecked(true);
513
+ setError(undefined);
514
+ if (chatSurfaces(agent.messages, failed).size === 0) {
515
+ void compose();
516
+ }
517
+ }, [isReady, busy, agent, agent.threadId, agent.isRunning, compose, failed]);
518
+
519
+ const surfaces = agent.messages.filter(isChatSurface);
520
+ const built = chatSurfaces(agent.messages, failed);
521
+ const unreachable =
522
+ copilotkit.runtimeConnectionStatus ===
523
+ CopilotKitCoreRuntimeConnectionStatus.Error;
524
+ const waiting = !isReady || !checked || busy || agent.isRunning;
525
+
526
+ return (
527
+ <ScrollView contentContainerStyle={{ padding: 16 }}>
528
+ {surfaces.map((message) => (
529
+ <GenerativeUIActivity
530
+ key={message.id}
531
+ message={message}
532
+ agent={agent}
533
+ />
534
+ ))}
535
+ {unreachable ? (
536
+ <Text accessibilityRole="alert">
537
+ Can't reach the agent. Check the runtime URL.
538
+ </Text>
539
+ ) : waiting ? (
540
+ <ActivityIndicator />
541
+ ) : error || built.size === 0 ? (
542
+ <Pressable accessibilityRole="button" onPress={() => void compose()}>
543
+ <Text>
544
+ Couldn't load your balances{error ? ` (${error})` : ""}. Tap to try
545
+ again.
546
+ </Text>
547
+ </Pressable>
548
+ ) : null}
549
+ </ScrollView>
550
+ );
551
+ }
552
+
553
+ export default function App() {
554
+ return (
555
+ <CopilotKitProvider runtimeUrl="https://your-server/api/copilotkit">
556
+ <GenerativeUIProvider ui={ui}>
557
+ <Home />
558
+ </GenerativeUIProvider>
559
+ </CopilotKitProvider>
560
+ );
561
+ }
562
+ ```
563
+
564
+ `GenerativeUIActivity` renders the surface of one activity message, in your own
565
+ message list or on a screen with no chat. Like the web chat, it shows only
566
+ surfaces aimed at the chat; pass `target` to show another target. It renders
567
+ nothing (and warns in development) without a `GenerativeUIProvider`, under a
568
+ provider without `ui`, or while the agent has no `threadId`. The example shows
569
+ a spinner, an unreachable runtime and a retry with the reason. A failed run's
570
+ prompt is taken back, but the surfaces it rendered stay: the provider and the
571
+ model keep them. The docs add a chat list.
572
+ `GenerativeUISurface` marks a named place in the app; `style` applies while its
573
+ fallback shows too. Tool transport only; there is no standard catalog, no
574
+ `theme` prop (a `theme` passed from JavaScript is dropped with a development
575
+ warning) and no `openUrl` (it fails with "openUrl is not available on this
576
+ platform"), and the prebuilt `CopilotChat` does not draw surfaces yet. See the
577
+ [React Native docs](https://docs.copilotkit.ai/react-native#generative-ui-with-your-own-components).
@@ -1,4 +1,4 @@
1
- import { r as MarkdownStyle } from "./Markdown-DzjnSuu5.cjs";
1
+ import { r as MarkdownStyle } from "./Markdown-Du-b_Qpr.mjs";
2
2
  import React, { ReactNode } from "react";
3
3
  import { ɵCopilotKitProviderBaseOptions } from "@copilotkit/core";
4
4
 
@@ -62,4 +62,4 @@ interface CopilotKitNativeProviderProps extends Pick<ɵCopilotKitProviderBaseOpt
62
62
  declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
63
63
  //#endregion
64
64
  export { NativeMarkdownRendererProps as a, NativeMarkdownRenderer as i, CopilotKitProvider as n, useMarkdownRenderer as o, MarkdownRendererProvider as r, CopilotKitNativeProviderProps as t };
65
- //# sourceMappingURL=CopilotKitProvider-F7Pn5kp4.d.cts.map
65
+ //# sourceMappingURL=CopilotKitProvider-Cbfrm_7u.d.mts.map
@@ -1,6 +1,7 @@
1
- const require_MarkdownRendererContext = require('./MarkdownRendererContext-BRNe808d.cjs');
1
+ const require_chunk = require('./chunk-C0xms8kb.cjs');
2
+ const require_MarkdownRendererContext = require('./MarkdownRendererContext-cDEHvbw9.cjs');
2
3
  let react = require("react");
3
- react = require_MarkdownRendererContext.__toESM(react);
4
+ react = require_chunk.__toESM(react);
4
5
  let _copilotkit_react_core_context = require("@copilotkit/react-core/context");
5
6
  let _copilotkit_react_core_headless = require("@copilotkit/react-core/headless");
6
7
  let _copilotkit_core = require("@copilotkit/core");
@@ -141,4 +142,4 @@ Object.defineProperty(exports, 'CopilotKitProvider', {
141
142
  return CopilotKitProvider;
142
143
  }
143
144
  });
144
- //# sourceMappingURL=CopilotKitProvider-DDPbJkHS.cjs.map
145
+ //# sourceMappingURL=CopilotKitProvider-CvJYytjn.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopilotKitProvider-DDPbJkHS.cjs","names":["CopilotKitCoreReact","CopilotKitContext","LicenseContext","MarkdownRendererProvider"],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport {\n CopilotKitCoreReact,\n ɵuseOwnedCore,\n} from \"@copilotkit/react-core/headless\";\nimport type {\n ɵCopilotKitProviderBaseOptions,\n ɵRuntimeInfo,\n} from \"@copilotkit/core\";\nimport {\n ɵreportProviderConfigDiagnostics,\n ɵresolveProviderConfig,\n} from \"@copilotkit/core\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps extends Pick<\n ɵCopilotKitProviderBaseOptions,\n | \"credentials\"\n | \"messageFilter\"\n | \"useSingleEndpoint\"\n | \"properties\"\n | \"onError\"\n | \"debug\"\n | \"defaultThrottleMs\"\n> {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n // Transport mapping and config checks come from core.\n const resolvedConfig = useMemo(\n () =>\n ɵresolveProviderConfig({\n runtimeUrl,\n useSingleEndpoint,\n properties: stableProperties,\n }),\n [runtimeUrl, useSingleEndpoint, stableProperties],\n );\n const loggedDiagnosticsRef = useRef(new Set<string>());\n ɵreportProviderConfigDiagnostics(resolvedConfig.diagnostics, {\n isProduction: process.env.NODE_ENV === \"production\",\n logged: loggedDiagnosticsRef.current,\n });\n\n // One core for the provider lifetime, disposed on unmount (StrictMode\n // safe, see `ɵuseOwnedCore`).\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n const copilotkit = ɵuseOwnedCore(\n copilotkitRef,\n (): CopilotKitCoreReactInstance =>\n new CopilotKitCoreReact({\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n // `/info` starts from the effect below, so a render React discards\n // never fetches it (#5801).\n deferInitialConnection: true,\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: resolvedConfig.properties,\n debug,\n // Set at construction so child hooks see it on their first render.\n defaultThrottleMs,\n onError,\n }),\n );\n\n // Core calls `onError`, and logs the error itself when there is none.\n useEffect(() => {\n copilotkit.setErrorHandler(onError);\n }, [copilotkit, onError]);\n\n // Sync props to the core. Core applies only what changed.\n useEffect(() => {\n copilotkit.ɵupdateConfig({\n messageFilter,\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n headers: stableHeaders,\n credentials,\n properties: resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n });\n copilotkit.connect();\n }, [\n copilotkit,\n messageFilter,\n resolvedConfig.runtimeUrl,\n resolvedConfig.runtimeTransport,\n stableHeaders,\n credentials,\n resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n ]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeInfo, setRuntimeInfo] = useState<ɵRuntimeInfo | null>(null);\n const runtimeLicenseStatus = runtimeInfo?.licenseStatus;\n\n // Project core's runtime info snapshot; the catch-up read reflects a status\n // that settled before this effect ran.\n useEffect(() => {\n const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);\n const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);\n syncRuntimeInfo();\n return unsubscribe;\n }, [copilotkit]);\n\n // Tool execution tracking.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,eACA,mBACA,YACA,SACA,OACA,mBACA,uBACI;CAEJ,MAAM,kBACJ,OAAO,gBAAgB,aAAa,aAAa,GAAG;CAKtD,MAAM,yCACE,m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,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEL,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,yCACG;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,iGAC4B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,2CAACC,iDAAkB;EAAS,OAAO;YACjC,2CAACC,8CAAe;GAAS,OAAO;aAC9B,2CAACC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC"}
1
+ {"version":3,"file":"CopilotKitProvider-CvJYytjn.cjs","names":["CopilotKitCoreReact","CopilotKitContext","LicenseContext","MarkdownRendererProvider"],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport {\n CopilotKitCoreReact,\n ɵuseOwnedCore,\n} from \"@copilotkit/react-core/headless\";\nimport type {\n ɵCopilotKitProviderBaseOptions,\n ɵRuntimeInfo,\n} from \"@copilotkit/core\";\nimport {\n ɵreportProviderConfigDiagnostics,\n ɵresolveProviderConfig,\n} from \"@copilotkit/core\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps extends Pick<\n ɵCopilotKitProviderBaseOptions,\n | \"credentials\"\n | \"messageFilter\"\n | \"useSingleEndpoint\"\n | \"properties\"\n | \"onError\"\n | \"debug\"\n | \"defaultThrottleMs\"\n> {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n // Transport mapping and config checks come from core.\n const resolvedConfig = useMemo(\n () =>\n ɵresolveProviderConfig({\n runtimeUrl,\n useSingleEndpoint,\n properties: stableProperties,\n }),\n [runtimeUrl, useSingleEndpoint, stableProperties],\n );\n const loggedDiagnosticsRef = useRef(new Set<string>());\n ɵreportProviderConfigDiagnostics(resolvedConfig.diagnostics, {\n isProduction: process.env.NODE_ENV === \"production\",\n logged: loggedDiagnosticsRef.current,\n });\n\n // One core for the provider lifetime, disposed on unmount (StrictMode\n // safe, see `ɵuseOwnedCore`).\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n const copilotkit = ɵuseOwnedCore(\n copilotkitRef,\n (): CopilotKitCoreReactInstance =>\n new CopilotKitCoreReact({\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n // `/info` starts from the effect below, so a render React discards\n // never fetches it (#5801).\n deferInitialConnection: true,\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: resolvedConfig.properties,\n debug,\n // Set at construction so child hooks see it on their first render.\n defaultThrottleMs,\n onError,\n }),\n );\n\n // Core calls `onError`, and logs the error itself when there is none.\n useEffect(() => {\n copilotkit.setErrorHandler(onError);\n }, [copilotkit, onError]);\n\n // Sync props to the core. Core applies only what changed.\n useEffect(() => {\n copilotkit.ɵupdateConfig({\n messageFilter,\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n headers: stableHeaders,\n credentials,\n properties: resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n });\n copilotkit.connect();\n }, [\n copilotkit,\n messageFilter,\n resolvedConfig.runtimeUrl,\n resolvedConfig.runtimeTransport,\n stableHeaders,\n credentials,\n resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n ]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeInfo, setRuntimeInfo] = useState<ɵRuntimeInfo | null>(null);\n const runtimeLicenseStatus = runtimeInfo?.licenseStatus;\n\n // Project core's runtime info snapshot; the catch-up read reflects a status\n // that settled before this effect ran.\n useEffect(() => {\n const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);\n const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);\n syncRuntimeInfo();\n return unsubscribe;\n }, [copilotkit]);\n\n // Tool execution tracking.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,sBAA+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AAC;AAKhB,4BAAgB;EACd,MAAM,eAAe,WAAW,UAAU;GACxC,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEL,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,yCACG;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,iGAC4B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,2CAACC,iDAAkB;EAAS,OAAO;YACjC,2CAACC,8CAAe;GAAS,OAAO;aAC9B,2CAACC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC"}
@@ -1,4 +1,4 @@
1
- import { r as MarkdownStyle } from "./Markdown-a-rdG22_.mjs";
1
+ import { r as MarkdownStyle } from "./Markdown-UXZdDjzs.cjs";
2
2
  import React, { ReactNode } from "react";
3
3
  import { ɵCopilotKitProviderBaseOptions } from "@copilotkit/core";
4
4
 
@@ -62,4 +62,4 @@ interface CopilotKitNativeProviderProps extends Pick<ɵCopilotKitProviderBaseOpt
62
62
  declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
63
63
  //#endregion
64
64
  export { NativeMarkdownRendererProps as a, NativeMarkdownRenderer as i, CopilotKitProvider as n, useMarkdownRenderer as o, MarkdownRendererProvider as r, CopilotKitNativeProviderProps as t };
65
- //# sourceMappingURL=CopilotKitProvider-Khgz5dQo.d.mts.map
65
+ //# sourceMappingURL=CopilotKitProvider-Dv3ISMKf.d.cts.map
@@ -1,4 +1,4 @@
1
- import { t as MarkdownRendererProvider } from "./MarkdownRendererContext-B_AKdPAN.mjs";
1
+ import { t as MarkdownRendererProvider } from "./MarkdownRendererContext-EobUsERg.mjs";
2
2
  import React, { useEffect, useMemo, useRef, useState } from "react";
3
3
  import { CopilotKitContext, LicenseContext } from "@copilotkit/react-core/context";
4
4
  import { CopilotKitCoreReact, ɵuseOwnedCore } from "@copilotkit/react-core/headless";
@@ -135,4 +135,4 @@ const CopilotKitProvider = ({ children, runtimeUrl, headers: headersProp, creden
135
135
 
136
136
  //#endregion
137
137
  export { CopilotKitProvider as t };
138
- //# sourceMappingURL=CopilotKitProvider-BXpkAl1Y.mjs.map
138
+ //# sourceMappingURL=CopilotKitProvider-oTdmylSY.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopilotKitProvider-BXpkAl1Y.mjs","names":[],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport {\n CopilotKitCoreReact,\n ɵuseOwnedCore,\n} from \"@copilotkit/react-core/headless\";\nimport type {\n ɵCopilotKitProviderBaseOptions,\n ɵRuntimeInfo,\n} from \"@copilotkit/core\";\nimport {\n ɵreportProviderConfigDiagnostics,\n ɵresolveProviderConfig,\n} from \"@copilotkit/core\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps extends Pick<\n ɵCopilotKitProviderBaseOptions,\n | \"credentials\"\n | \"messageFilter\"\n | \"useSingleEndpoint\"\n | \"properties\"\n | \"onError\"\n | \"debug\"\n | \"defaultThrottleMs\"\n> {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n // Transport mapping and config checks come from core.\n const resolvedConfig = useMemo(\n () =>\n ɵresolveProviderConfig({\n runtimeUrl,\n useSingleEndpoint,\n properties: stableProperties,\n }),\n [runtimeUrl, useSingleEndpoint, stableProperties],\n );\n const loggedDiagnosticsRef = useRef(new Set<string>());\n ɵreportProviderConfigDiagnostics(resolvedConfig.diagnostics, {\n isProduction: process.env.NODE_ENV === \"production\",\n logged: loggedDiagnosticsRef.current,\n });\n\n // One core for the provider lifetime, disposed on unmount (StrictMode\n // safe, see `ɵuseOwnedCore`).\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n const copilotkit = ɵuseOwnedCore(\n copilotkitRef,\n (): CopilotKitCoreReactInstance =>\n new CopilotKitCoreReact({\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n // `/info` starts from the effect below, so a render React discards\n // never fetches it (#5801).\n deferInitialConnection: true,\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: resolvedConfig.properties,\n debug,\n // Set at construction so child hooks see it on their first render.\n defaultThrottleMs,\n onError,\n }),\n );\n\n // Core calls `onError`, and logs the error itself when there is none.\n useEffect(() => {\n copilotkit.setErrorHandler(onError);\n }, [copilotkit, onError]);\n\n // Sync props to the core. Core applies only what changed.\n useEffect(() => {\n copilotkit.ɵupdateConfig({\n messageFilter,\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n headers: stableHeaders,\n credentials,\n properties: resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n });\n copilotkit.connect();\n }, [\n copilotkit,\n messageFilter,\n resolvedConfig.runtimeUrl,\n resolvedConfig.runtimeTransport,\n stableHeaders,\n credentials,\n resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n ]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeInfo, setRuntimeInfo] = useState<ɵRuntimeInfo | null>(null);\n const runtimeLicenseStatus = runtimeInfo?.licenseStatus;\n\n // Project core's runtime info snapshot; the catch-up read reflects a status\n // that settled before this effect ran.\n useEffect(() => {\n const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);\n const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);\n syncRuntimeInfo();\n return unsubscribe;\n }, [copilotkit]);\n\n // Tool execution tracking.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,eACA,mBACA,YACA,SACA,OACA,mBACA,uBACI;CAEJ,MAAM,kBACJ,OAAO,gBAAgB,aAAa,aAA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C,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEL,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,eAAuC,eACpC;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,sBAAsB,cACpB,0BAA0B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,oBAAC,kBAAkB;EAAS,OAAO;YACjC,oBAAC,eAAe;GAAS,OAAO;aAC9B,oBAAC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC"}
1
+ {"version":3,"file":"CopilotKitProvider-oTdmylSY.mjs","names":[],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport {\n CopilotKitCoreReact,\n ɵuseOwnedCore,\n} from \"@copilotkit/react-core/headless\";\nimport type {\n ɵCopilotKitProviderBaseOptions,\n ɵRuntimeInfo,\n} from \"@copilotkit/core\";\nimport {\n ɵreportProviderConfigDiagnostics,\n ɵresolveProviderConfig,\n} from \"@copilotkit/core\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps extends Pick<\n ɵCopilotKitProviderBaseOptions,\n | \"credentials\"\n | \"messageFilter\"\n | \"useSingleEndpoint\"\n | \"properties\"\n | \"onError\"\n | \"debug\"\n | \"defaultThrottleMs\"\n> {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n // Transport mapping and config checks come from core.\n const resolvedConfig = useMemo(\n () =>\n ɵresolveProviderConfig({\n runtimeUrl,\n useSingleEndpoint,\n properties: stableProperties,\n }),\n [runtimeUrl, useSingleEndpoint, stableProperties],\n );\n const loggedDiagnosticsRef = useRef(new Set<string>());\n ɵreportProviderConfigDiagnostics(resolvedConfig.diagnostics, {\n isProduction: process.env.NODE_ENV === \"production\",\n logged: loggedDiagnosticsRef.current,\n });\n\n // One core for the provider lifetime, disposed on unmount (StrictMode\n // safe, see `ɵuseOwnedCore`).\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n const copilotkit = ɵuseOwnedCore(\n copilotkitRef,\n (): CopilotKitCoreReactInstance =>\n new CopilotKitCoreReact({\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n // `/info` starts from the effect below, so a render React discards\n // never fetches it (#5801).\n deferInitialConnection: true,\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: resolvedConfig.properties,\n debug,\n // Set at construction so child hooks see it on their first render.\n defaultThrottleMs,\n onError,\n }),\n );\n\n // Core calls `onError`, and logs the error itself when there is none.\n useEffect(() => {\n copilotkit.setErrorHandler(onError);\n }, [copilotkit, onError]);\n\n // Sync props to the core. Core applies only what changed.\n useEffect(() => {\n copilotkit.ɵupdateConfig({\n messageFilter,\n runtimeUrl: resolvedConfig.runtimeUrl,\n runtimeTransport: resolvedConfig.runtimeTransport,\n headers: stableHeaders,\n credentials,\n properties: resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n });\n copilotkit.connect();\n }, [\n copilotkit,\n messageFilter,\n resolvedConfig.runtimeUrl,\n resolvedConfig.runtimeTransport,\n stableHeaders,\n credentials,\n resolvedConfig.properties,\n debug,\n defaultThrottleMs,\n ]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeInfo, setRuntimeInfo] = useState<ɵRuntimeInfo | null>(null);\n const runtimeLicenseStatus = runtimeInfo?.licenseStatus;\n\n // Project core's runtime info snapshot; the catch-up read reflects a status\n // that settled before this effect ran.\n useEffect(() => {\n const syncRuntimeInfo = () => setRuntimeInfo(copilotkit.ɵruntimeInfo);\n const unsubscribe = copilotkit.ɵsubscribeToRuntimeInfo(syncRuntimeInfo);\n syncRuntimeInfo();\n return unsubscribe;\n }, [copilotkit]);\n\n // Tool execution tracking.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"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gB;EACd,MAAM,wBAAwB,eAAe,WAAW,aAAa;EACrE,MAAM,cAAc,WAAW,wBAAwB,gBAAgB;AACvE,mBAAiB;AACjB,SAAO;IACN,CAAC,WAAW,CAAC;AAKhB,iBAAgB;EACd,MAAM,eAAe,WAAW,UAAU;GACxC,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEL,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,eAAuC,eACpC;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,sBAAsB,cACpB,0BAA0B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,oBAAC,kBAAkB;EAAS,OAAO;YACjC,oBAAC,eAAe;GAAS,OAAO;aAC9B,oBAAC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC"}
@@ -1,6 +1,6 @@
1
- const require_MarkdownRendererContext = require('./MarkdownRendererContext-BRNe808d.cjs');
1
+ const require_chunk = require('./chunk-C0xms8kb.cjs');
2
2
  let react = require("react");
3
- react = require_MarkdownRendererContext.__toESM(react);
3
+ react = require_chunk.__toESM(react);
4
4
  let react_jsx_runtime = require("react/jsx-runtime");
5
5
  let _copilotkit_markdown_react_native = require("@copilotkit/markdown/react-native");
6
6
  let _copilotkit_markdown = require("@copilotkit/markdown");
@@ -57,4 +57,4 @@ Object.defineProperty(exports, 'defaultMarkdownStyles', {
57
57
  return defaultMarkdownStyles;
58
58
  }
59
59
  });
60
- //# sourceMappingURL=Markdown-CaYHlD4j.cjs.map
60
+ //# sourceMappingURL=Markdown-DLopAh5W.cjs.map