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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/{CopilotKitProvider-CE4bc6CP.mjs → CopilotKitProvider-BXpkAl1Y.mjs} +55 -42
  2. package/dist/CopilotKitProvider-BXpkAl1Y.mjs.map +1 -0
  3. package/dist/{CopilotKitProvider-Byw3cqe2.cjs → CopilotKitProvider-DDPbJkHS.cjs} +53 -40
  4. package/dist/CopilotKitProvider-DDPbJkHS.cjs.map +1 -0
  5. package/dist/CopilotKitProvider-F7Pn5kp4.d.cts +65 -0
  6. package/dist/CopilotKitProvider-Khgz5dQo.d.mts +65 -0
  7. package/dist/{Markdown-C_9Re36O.cjs → Markdown-CaYHlD4j.cjs} +8 -8
  8. package/dist/Markdown-CaYHlD4j.cjs.map +1 -0
  9. package/dist/{Markdown-1ips7myr.d.cts → Markdown-DzjnSuu5.d.cts} +3 -3
  10. package/dist/{Markdown-C6AsLHmd.mjs → Markdown-SE9MfY2U.mjs} +4 -4
  11. package/dist/Markdown-SE9MfY2U.mjs.map +1 -0
  12. package/dist/{Markdown-JsYh7oSA.d.mts → Markdown-a-rdG22_.d.mts} +3 -3
  13. package/dist/{MarkdownRendererContext-CAnuohIS.mjs → MarkdownRendererContext-B_AKdPAN.mjs} +1 -1
  14. package/dist/{MarkdownRendererContext-CAnuohIS.mjs.map → MarkdownRendererContext-B_AKdPAN.mjs.map} +1 -1
  15. package/dist/components/index.cjs +73 -172
  16. package/dist/components/index.cjs.map +1 -1
  17. package/dist/components/index.d.cts +2 -2
  18. package/dist/components/index.d.mts +2 -2
  19. package/dist/components/index.mjs +75 -174
  20. package/dist/components/index.mjs.map +1 -1
  21. package/dist/headless.cjs +2 -1
  22. package/dist/headless.d.cts +2 -2
  23. package/dist/headless.d.mts +2 -2
  24. package/dist/headless.mjs +2 -1
  25. package/dist/index.cjs +126 -158
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +35 -17
  28. package/dist/index.d.mts +36 -18
  29. package/dist/index.mjs +130 -161
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/polyfills/encoding.cjs +5 -5
  32. package/dist/polyfills/encoding.cjs.map +1 -1
  33. package/dist/polyfills/encoding.mjs +5 -4
  34. package/dist/polyfills/encoding.mjs.map +1 -1
  35. package/dist/polyfills.cjs +2 -1
  36. package/dist/polyfills.cjs.map +1 -1
  37. package/dist/polyfills.mjs +2 -1
  38. package/dist/polyfills.mjs.map +1 -1
  39. package/dist/{streaming-fetch-Dm1oN4f2.mjs → streaming-fetch-CLHG3Z1H.mjs} +1 -1
  40. package/dist/{streaming-fetch-Dm1oN4f2.mjs.map → streaming-fetch-CLHG3Z1H.mjs.map} +1 -1
  41. package/dist/{streaming-fetch-Bm91EsRc.cjs → streaming-fetch-DbDALGya.cjs} +1 -1
  42. package/dist/{streaming-fetch-Bm91EsRc.cjs.map → streaming-fetch-DbDALGya.cjs.map} +1 -1
  43. package/dist/utf8-BIN9t4Oy.mjs +113 -0
  44. package/dist/utf8-BIN9t4Oy.mjs.map +1 -0
  45. package/dist/utf8-Cf3Ssy33.cjs +125 -0
  46. package/dist/utf8-Cf3Ssy33.cjs.map +1 -0
  47. package/package.json +12 -21
  48. package/scripts/verify-polyfill-barrel.mjs +4 -6
  49. package/src/CopilotChat.tsx +114 -93
  50. package/src/CopilotKitProvider.tsx +87 -130
  51. package/src/CopilotPopup.tsx +2 -2
  52. package/src/CopilotSidebar.tsx +7 -5
  53. package/src/__mocks__/react-native.ts +31 -0
  54. package/src/__mocks__/test-copilotkit.tsx +9 -3
  55. package/src/__tests__/attachments-integration.test.tsx +15 -2
  56. package/src/__tests__/copilot-chat-agentid.test.tsx +15 -2
  57. package/src/__tests__/copilot-chat-attachments.test.tsx +15 -2
  58. package/src/__tests__/copilot-chat-configuration.test.tsx +82 -0
  59. package/src/__tests__/copilot-chat-threads.test.tsx +232 -0
  60. package/src/__tests__/copilot-popup.test.tsx +15 -2
  61. package/src/__tests__/copilot-sidebar.test.tsx +15 -2
  62. package/src/__tests__/copilotkit-provider.test.tsx +68 -73
  63. package/src/__tests__/headless-integration.test.tsx +11 -1
  64. package/src/__tests__/use-attachments.test.ts +27 -2
  65. package/src/components/CopilotChat.tsx +106 -233
  66. package/src/components/CopilotModal.tsx +1 -1
  67. package/src/components/Markdown.tsx +4 -4
  68. package/src/components/__tests__/CopilotChat-edge-cases.test.tsx +5 -1
  69. package/src/components/__tests__/CopilotChat.test.tsx +12 -4
  70. package/src/components/__tests__/CopilotChatInterrupt.test.tsx +208 -0
  71. package/src/components/__tests__/Markdown.code-alias.test.tsx +1 -1
  72. package/src/components/messages/AssistantMessage.tsx +3 -3
  73. package/src/components/messages/TypingIndicator.tsx +4 -4
  74. package/src/hooks/use-attachments.ts +95 -139
  75. package/src/polyfills/__tests__/utf8.test.ts +112 -0
  76. package/src/polyfills/encoding.ts +5 -4
  77. package/src/polyfills/utf8.ts +151 -0
  78. package/src/types.d.ts +0 -13
  79. package/dist/CopilotKitProvider-BWjzCdHN.d.mts +0 -121
  80. package/dist/CopilotKitProvider-Btm10msB.d.cts +0 -121
  81. package/dist/CopilotKitProvider-Byw3cqe2.cjs.map +0 -1
  82. package/dist/CopilotKitProvider-CE4bc6CP.mjs.map +0 -1
  83. package/dist/Markdown-C6AsLHmd.mjs.map +0 -1
  84. package/dist/Markdown-C_9Re36O.cjs.map +0 -1
@@ -0,0 +1,151 @@
1
+ /**
2
+ * UTF-8 `TextEncoder` and `TextDecoder`, for runtimes that have neither.
3
+ *
4
+ * CopilotKit only reads and writes UTF-8, so these classes support only that
5
+ * encoding. The decoder follows the WHATWG UTF-8 decode algorithm, so its
6
+ * output, including U+FFFD for invalid bytes and `{ stream: true }` chunks,
7
+ * matches the built-in `TextDecoder`.
8
+ */
9
+
10
+ const REPLACEMENT = 0xfffd;
11
+
12
+ export class Utf8TextEncoder {
13
+ readonly encoding = "utf-8";
14
+
15
+ encode(input = ""): Uint8Array {
16
+ const bytes: number[] = [];
17
+ for (const char of input) {
18
+ let codePoint = char.codePointAt(0)!;
19
+ // A lone surrogate is not a Unicode scalar value.
20
+ if (codePoint >= 0xd800 && codePoint <= 0xdfff) codePoint = REPLACEMENT;
21
+ if (codePoint < 0x80) bytes.push(codePoint);
22
+ else if (codePoint < 0x800)
23
+ bytes.push(0xc0 | (codePoint >> 6), 0x80 | (codePoint & 0x3f));
24
+ else if (codePoint < 0x10000)
25
+ bytes.push(
26
+ 0xe0 | (codePoint >> 12),
27
+ 0x80 | ((codePoint >> 6) & 0x3f),
28
+ 0x80 | (codePoint & 0x3f),
29
+ );
30
+ else
31
+ bytes.push(
32
+ 0xf0 | (codePoint >> 18),
33
+ 0x80 | ((codePoint >> 12) & 0x3f),
34
+ 0x80 | ((codePoint >> 6) & 0x3f),
35
+ 0x80 | (codePoint & 0x3f),
36
+ );
37
+ }
38
+ return new Uint8Array(bytes);
39
+ }
40
+ }
41
+
42
+ export class Utf8TextDecoder {
43
+ readonly encoding = "utf-8";
44
+ readonly fatal: boolean;
45
+ readonly ignoreBOM: boolean;
46
+
47
+ #codePoint = 0;
48
+ #bytesNeeded = 0;
49
+ #bytesSeen = 0;
50
+ #lowerBoundary = 0x80;
51
+ #upperBoundary = 0xbf;
52
+ #atStart = true;
53
+
54
+ constructor(
55
+ label = "utf-8",
56
+ options: { fatal?: boolean; ignoreBOM?: boolean } = {},
57
+ ) {
58
+ const normalized = String(label).trim().toLowerCase();
59
+ if (normalized !== "utf-8" && normalized !== "utf8") {
60
+ throw new RangeError(`The "${label}" encoding is not supported.`);
61
+ }
62
+ this.fatal = options.fatal ?? false;
63
+ this.ignoreBOM = options.ignoreBOM ?? false;
64
+ }
65
+
66
+ decode(
67
+ input?: ArrayBuffer | ArrayBufferView,
68
+ options: { stream?: boolean } = {},
69
+ ): string {
70
+ const bytes =
71
+ input === undefined
72
+ ? new Uint8Array(0)
73
+ : ArrayBuffer.isView(input)
74
+ ? new Uint8Array(input.buffer, input.byteOffset, input.byteLength)
75
+ : new Uint8Array(input);
76
+ const codePoints: number[] = [];
77
+
78
+ for (let i = 0; i < bytes.length; i++) {
79
+ const byte = bytes[i];
80
+ if (this.#bytesNeeded === 0) {
81
+ if (byte <= 0x7f) codePoints.push(byte);
82
+ else if (byte >= 0xc2 && byte <= 0xdf) this.#start(1, byte & 0x1f);
83
+ else if (byte >= 0xe0 && byte <= 0xef) {
84
+ if (byte === 0xe0) this.#lowerBoundary = 0xa0;
85
+ if (byte === 0xed) this.#upperBoundary = 0x9f;
86
+ this.#start(2, byte & 0x0f);
87
+ } else if (byte >= 0xf0 && byte <= 0xf4) {
88
+ if (byte === 0xf0) this.#lowerBoundary = 0x90;
89
+ if (byte === 0xf4) this.#upperBoundary = 0x8f;
90
+ this.#start(3, byte & 0x07);
91
+ } else codePoints.push(this.#error());
92
+ continue;
93
+ }
94
+ if (byte < this.#lowerBoundary || byte > this.#upperBoundary) {
95
+ // The sequence ends early. Read this byte again as a new sequence.
96
+ this.#reset();
97
+ codePoints.push(this.#error());
98
+ i--;
99
+ continue;
100
+ }
101
+ this.#lowerBoundary = 0x80;
102
+ this.#upperBoundary = 0xbf;
103
+ this.#codePoint = (this.#codePoint << 6) | (byte & 0x3f);
104
+ if (++this.#bytesSeen === this.#bytesNeeded) {
105
+ codePoints.push(this.#codePoint);
106
+ this.#reset();
107
+ }
108
+ }
109
+
110
+ if (!options.stream && this.#bytesNeeded > 0) {
111
+ this.#reset();
112
+ codePoints.push(this.#error());
113
+ }
114
+ if (this.#atStart && codePoints.length > 0) {
115
+ this.#atStart = false;
116
+ if (!this.ignoreBOM && codePoints[0] === 0xfeff) codePoints.shift();
117
+ }
118
+ if (!options.stream) this.#atStart = true;
119
+ return codePointsToString(codePoints);
120
+ }
121
+
122
+ #start(bytesNeeded: number, codePoint: number): void {
123
+ this.#bytesNeeded = bytesNeeded;
124
+ this.#codePoint = codePoint;
125
+ }
126
+
127
+ #reset(): void {
128
+ this.#codePoint = 0;
129
+ this.#bytesNeeded = 0;
130
+ this.#bytesSeen = 0;
131
+ this.#lowerBoundary = 0x80;
132
+ this.#upperBoundary = 0xbf;
133
+ }
134
+
135
+ #error(): number {
136
+ if (this.fatal) {
137
+ this.#atStart = true;
138
+ throw new TypeError("The encoded data was not valid utf-8.");
139
+ }
140
+ return REPLACEMENT;
141
+ }
142
+ }
143
+
144
+ function codePointsToString(codePoints: number[]): string {
145
+ let out = "";
146
+ // Stay under the engine's limit on function arguments.
147
+ for (let i = 0; i < codePoints.length; i += 0x8000) {
148
+ out += String.fromCodePoint(...codePoints.slice(i, i + 0x8000));
149
+ }
150
+ return out;
151
+ }
package/src/types.d.ts CHANGED
@@ -8,16 +8,3 @@ declare const __DEV__: boolean;
8
8
  // (`g`) instead of repeating `(globalThis as any)` on every line — same pattern as
9
9
  // packages/angular/src/test-setup.ts. Files without imports add `export {}` so
10
10
  // TypeScript treats them as modules with isolated scope.
11
-
12
- declare module "text-encoding" {
13
- export class TextEncoder {
14
- encode(input?: string): Uint8Array;
15
- }
16
- export class TextDecoder {
17
- constructor(label?: string, options?: { fatal?: boolean });
18
- decode(
19
- input?: ArrayBufferView | ArrayBuffer,
20
- options?: { stream?: boolean },
21
- ): string;
22
- }
23
- }
@@ -1,121 +0,0 @@
1
- import { r as MarkdownStyle } from "./Markdown-JsYh7oSA.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
- * When `true`, enables verbose logging from the core instance.
79
- */
80
- debug?: DebugConfig;
81
- /**
82
- * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`
83
- * subscriptions. Individual subscriptions can override with their own `throttleMs`.
84
- */
85
- defaultThrottleMs?: number;
86
- /**
87
- * Custom markdown renderer for assistant messages. Either a component (escape
88
- * hatch — receives `content` and an optional `isStreaming` flag) used instead
89
- * of the built-in renderer, or a `{ style, animate }` config object to
90
- * configure the built-in React Native renderer (the `CopilotMarkdown` used by
91
- * the default `AssistantMessage`) without writing a wrapper.
92
- */
93
- markdownRenderer?: MarkdownRendererValue;
94
- }
95
- /**
96
- * CopilotKit provider for React Native.
97
- *
98
- * A lightweight alternative to the web CopilotKitProvider that avoids
99
- * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
100
- *
101
- * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
102
- * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
103
- * required (though it remains available for advanced use).
104
- *
105
- * Usage:
106
- * ```tsx
107
- * import { CopilotKitProvider } from "@copilotkit/react-native";
108
- *
109
- * function App() {
110
- * return (
111
- * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
112
- * <ChatScreen />
113
- * </CopilotKitProvider>
114
- * );
115
- * }
116
- * ```
117
- */
118
- declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
119
- //#endregion
120
- export { NativeMarkdownRendererProps as a, NativeMarkdownRenderer as i, CopilotKitProvider as n, useMarkdownRenderer as o, MarkdownRendererProvider as r, CopilotKitNativeProviderProps as t };
121
- //# sourceMappingURL=CopilotKitProvider-BWjzCdHN.d.mts.map
@@ -1,121 +0,0 @@
1
- import { r as MarkdownStyle } from "./Markdown-1ips7myr.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
- * When `true`, enables verbose logging from the core instance.
79
- */
80
- debug?: DebugConfig;
81
- /**
82
- * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`
83
- * subscriptions. Individual subscriptions can override with their own `throttleMs`.
84
- */
85
- defaultThrottleMs?: number;
86
- /**
87
- * Custom markdown renderer for assistant messages. Either a component (escape
88
- * hatch — receives `content` and an optional `isStreaming` flag) used instead
89
- * of the built-in renderer, or a `{ style, animate }` config object to
90
- * configure the built-in React Native renderer (the `CopilotMarkdown` used by
91
- * the default `AssistantMessage`) without writing a wrapper.
92
- */
93
- markdownRenderer?: MarkdownRendererValue;
94
- }
95
- /**
96
- * CopilotKit provider for React Native.
97
- *
98
- * A lightweight alternative to the web CopilotKitProvider that avoids
99
- * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).
100
- *
101
- * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,
102
- * so a separate `import "@copilotkit/react-native/polyfills"` is no longer
103
- * required (though it remains available for advanced use).
104
- *
105
- * Usage:
106
- * ```tsx
107
- * import { CopilotKitProvider } from "@copilotkit/react-native";
108
- *
109
- * function App() {
110
- * return (
111
- * <CopilotKitProvider runtimeUrl="https://your-runtime/api/copilotkit">
112
- * <ChatScreen />
113
- * </CopilotKitProvider>
114
- * );
115
- * }
116
- * ```
117
- */
118
- declare const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps>;
119
- //#endregion
120
- export { NativeMarkdownRendererProps as a, NativeMarkdownRenderer as i, CopilotKitProvider as n, useMarkdownRenderer as o, MarkdownRendererProvider as r, CopilotKitNativeProviderProps as t };
121
- //# sourceMappingURL=CopilotKitProvider-Btm10msB.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CopilotKitProvider-Byw3cqe2.cjs","names":["CopilotKitCoreReact","CopilotKitContext","LicenseContext","MarkdownRendererProvider"],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport { CopilotKitCoreReact } from \"@copilotkit/react-core/headless\";\nimport type {\n CopilotKitCoreErrorCode,\n CopilotKitMessageFilter,\n} from \"@copilotkit/core\";\nimport type { DebugConfig, RuntimeLicenseStatus } from \"@copilotkit/shared\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Credentials mode for fetch requests (e.g., \"include\" for HTTP-only cookies in cross-origin requests).\n */\n credentials?: RequestCredentials;\n /**\n * Rewrites the message list sent to runtime agents on every run.\n *\n * CopilotKit sends the whole thread each time. When your agent already\n * stores the conversation, most of that payload is waste, and an agent that\n * merges the inbound list with its own store can show the model every turn\n * twice. Return the messages to send:\n *\n * ```tsx\n * <CopilotKitProvider\n * runtimeUrl=\"/api/copilotkit\"\n * messageFilter={(messages) => messages.slice(-1)}\n * />\n * ```\n *\n * The filter changes the request body only. The transcript the UI renders is\n * untouched. Broken tool-call pairs are repaired before the request is sent,\n * so a filter this blunt cannot strand a tool result mid-HITL.\n *\n * Agents reached through your CopilotRuntime honor this. An agent your app\n * passes in directly does not, and neither Intelligence runs nor suggestion\n * runs are ever filtered.\n *\n * Prefer a stable reference (`useCallback`). An inline arrow re-registers the\n * filter on every render, which is harmless but needless.\n */\n messageFilter?: CopilotKitMessageFilter;\n /** Whether the runtime uses a single-route endpoint */\n useSingleEndpoint?: boolean;\n /** Custom properties forwarded to agents */\n properties?: Record<string, unknown>;\n /**\n * Error handler called when CopilotKit encounters an error.\n * Fires for all error types (runtime connection failures, agent errors, tool errors).\n * If not provided, errors are logged to console.error.\n */\n onError?: (event: {\n error: Error;\n code: CopilotKitCoreErrorCode;\n context: Record<string, any>;\n }) => void | Promise<void>;\n /**\n * Enable debug logging for the client-side event pipeline.\n * When `true`, enables verbose logging from the core instance.\n */\n debug?: DebugConfig;\n /**\n * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`\n * subscriptions. Individual subscriptions can override with their own `throttleMs`.\n */\n defaultThrottleMs?: number;\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n\n if (copilotkitRef.current === null) {\n const instance: CopilotKitCoreReactInstance = new CopilotKitCoreReact({\n runtimeUrl,\n runtimeTransport:\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: stableProperties,\n debug,\n });\n // Set initial defaultThrottleMs synchronously so child hooks see the\n // correct value on their first render (before useEffect fires).\n if (defaultThrottleMs !== undefined) {\n instance.setDefaultThrottleMs(defaultThrottleMs);\n }\n copilotkitRef.current = instance;\n }\n\n const copilotkit = copilotkitRef.current;\n\n // Sync props to core instance\n useEffect(() => {\n copilotkit.setRuntimeUrl(runtimeUrl);\n copilotkit.setRuntimeTransport(\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n );\n copilotkit.setHeaders(stableHeaders);\n copilotkit.setCredentials(credentials);\n copilotkit.setMessageFilter(messageFilter);\n copilotkit.setProperties(stableProperties);\n copilotkit.setDebug(debug);\n }, [\n runtimeUrl,\n useSingleEndpoint,\n stableHeaders,\n credentials,\n messageFilter,\n stableProperties,\n debug,\n copilotkit,\n ]);\n\n // Sync defaultThrottleMs to the core instance on prop changes.\n // Initial value is set synchronously during instance creation (inside the\n // ref guard above), so this only handles subsequent updates.\n useEffect(() => {\n copilotkit.setDefaultThrottleMs(defaultThrottleMs);\n }, [copilotkit, defaultThrottleMs]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState<\n RuntimeLicenseStatus | undefined\n >(undefined);\n\n // Use ref to avoid subscription churn when onError changes\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n // Single subscription for tool execution tracking and error handling.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n onError: (event) => {\n if (onErrorRef.current) {\n onErrorRef.current(event);\n } else {\n console.error(\n `[CopilotKit] Error (${event.code}):`,\n event.error,\n event.context ?? {},\n );\n }\n },\n onRuntimeConnectionStatusChanged: () => {\n setRuntimeLicenseStatus(copilotkit.licenseStatus);\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmHA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,eACA,mBACA,YACA,SACA,OACA,mBACA,uBACI;CAEJ,MAAM,kBACJ,OAAO,gBAAgB,aAAa,aAAa,GAAG;CAKtD,MAAM,yCACE,mBAAmB,EAAE,EAC3B,CAAC,KAAK,UAAU,gBAAgB,CAAC,CAClC;CAED,MAAM,4CACE,cAAc,EAAE,EACtB,CAAC,KAAK,UAAU,WAAW,CAAC,CAC7B;CAED,MAAM,kCAA2D,KAAK;AAEtE,KAAI,cAAc,YAAY,MAAM;EAClC,MAAM,WAAwC,IAAIA,oDAAoB;GACpE;GACA,kBACE,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA;GACR,SAAS;GACT;GACA;GACA,YAAY;GACZ;GACD,CAAC;AAGF,MAAI,sBAAsB,OACxB,UAAS,qBAAqB,kBAAkB;AAElD,gBAAc,UAAU;;CAG1B,MAAM,aAAa,cAAc;AAGjC,4BAAgB;AACd,aAAW,cAAc,WAAW;AACpC,aAAW,oBACT,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA,OACP;AACD,aAAW,WAAW,cAAc;AACpC,aAAW,eAAe,YAAY;AACtC,aAAW,iBAAiB,cAAc;AAC1C,aAAW,cAAc,iBAAiB;AAC1C,aAAW,SAAS,MAAM;IACzB;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAKF,4BAAgB;AACd,aAAW,qBAAqB,kBAAkB;IACjD,CAAC,YAAY,kBAAkB,CAAC;CAKnC,MAAM,CAAC,sBAAsB,qEAErB,IAAI,KAAK,CAAC;CAElB,MAAM,CAAC,sBAAsB,+CAE3B,OAAU;CAGZ,MAAM,+BAAoB,QAAQ;AAClC,4BAAgB;AACd,aAAW,UAAU;IACpB,CAAC,QAAQ,CAAC;AAKb,4BAAgB;EACd,MAAM,eAAe,WAAW,UAAU;GACxC,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEJ,UAAU,UAAU;AAClB,QAAI,WAAW,QACb,YAAW,QAAQ,MAAM;QAEzB,SAAQ,MACN,uBAAuB,MAAM,KAAK,KAClC,MAAM,OACN,MAAM,WAAW,EAAE,CACpB;;GAGL,wCAAwC;AACtC,4BAAwB,WAAW,cAAc;;GAEpD,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,yCACG;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,iGAC4B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,2CAACC,iDAAkB;EAAS,OAAO;YACjC,2CAACC,8CAAe;GAAS,OAAO;aAC9B,2CAACC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"CopilotKitProvider-CE4bc6CP.mjs","names":[],"sources":["../src/CopilotKitProvider.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n CopilotKitContext,\n LicenseContext,\n} from \"@copilotkit/react-core/context\";\nimport type {\n CopilotKitContextValue,\n CopilotKitCoreReact as CopilotKitCoreReactInstance,\n} from \"@copilotkit/react-core/context\";\nimport { CopilotKitCoreReact } from \"@copilotkit/react-core/headless\";\nimport type {\n CopilotKitCoreErrorCode,\n CopilotKitMessageFilter,\n} from \"@copilotkit/core\";\nimport type { DebugConfig, RuntimeLicenseStatus } from \"@copilotkit/shared\";\nimport { createLicenseContextValue } from \"@copilotkit/shared\";\nimport { MarkdownRendererProvider } from \"./components/MarkdownRendererContext\";\nimport type { MarkdownRendererValue } from \"./components/MarkdownRendererContext\";\n\nexport interface CopilotKitNativeProviderProps {\n children: ReactNode;\n /** URL of the CopilotKit runtime endpoint */\n runtimeUrl: string;\n /** Custom headers sent with every request */\n headers?: Record<string, string> | (() => Record<string, string>);\n /**\n * Credentials mode for fetch requests (e.g., \"include\" for HTTP-only cookies in cross-origin requests).\n */\n credentials?: RequestCredentials;\n /**\n * Rewrites the message list sent to runtime agents on every run.\n *\n * CopilotKit sends the whole thread each time. When your agent already\n * stores the conversation, most of that payload is waste, and an agent that\n * merges the inbound list with its own store can show the model every turn\n * twice. Return the messages to send:\n *\n * ```tsx\n * <CopilotKitProvider\n * runtimeUrl=\"/api/copilotkit\"\n * messageFilter={(messages) => messages.slice(-1)}\n * />\n * ```\n *\n * The filter changes the request body only. The transcript the UI renders is\n * untouched. Broken tool-call pairs are repaired before the request is sent,\n * so a filter this blunt cannot strand a tool result mid-HITL.\n *\n * Agents reached through your CopilotRuntime honor this. An agent your app\n * passes in directly does not, and neither Intelligence runs nor suggestion\n * runs are ever filtered.\n *\n * Prefer a stable reference (`useCallback`). An inline arrow re-registers the\n * filter on every render, which is harmless but needless.\n */\n messageFilter?: CopilotKitMessageFilter;\n /** Whether the runtime uses a single-route endpoint */\n useSingleEndpoint?: boolean;\n /** Custom properties forwarded to agents */\n properties?: Record<string, unknown>;\n /**\n * Error handler called when CopilotKit encounters an error.\n * Fires for all error types (runtime connection failures, agent errors, tool errors).\n * If not provided, errors are logged to console.error.\n */\n onError?: (event: {\n error: Error;\n code: CopilotKitCoreErrorCode;\n context: Record<string, any>;\n }) => void | Promise<void>;\n /**\n * Enable debug logging for the client-side event pipeline.\n * When `true`, enables verbose logging from the core instance.\n */\n debug?: DebugConfig;\n /**\n * Default throttle interval (ms) for `onMessagesChanged` / `onStateChanged`\n * subscriptions. Individual subscriptions can override with their own `throttleMs`.\n */\n defaultThrottleMs?: number;\n /**\n * Custom markdown renderer for assistant messages. Either a component (escape\n * hatch — receives `content` and an optional `isStreaming` flag) used instead\n * of the built-in renderer, or a `{ style, animate }` config object to\n * configure the built-in React Native renderer (the `CopilotMarkdown` used by\n * the default `AssistantMessage`) without writing a wrapper.\n */\n markdownRenderer?: MarkdownRendererValue;\n // Cloud features (publicApiKey, licenseToken) — not yet supported on React Native\n}\n\n/**\n * CopilotKit provider for React Native.\n *\n * A lightweight alternative to the web CopilotKitProvider that avoids\n * web-only dependencies (DOM, CSS, Radix UI, Lit, etc).\n *\n * Polyfills are auto-imported when `@copilotkit/react-native` is loaded,\n * so a separate `import \"@copilotkit/react-native/polyfills\"` is no longer\n * required (though it remains available for advanced use).\n *\n * Usage:\n * ```tsx\n * import { CopilotKitProvider } from \"@copilotkit/react-native\";\n *\n * function App() {\n * return (\n * <CopilotKitProvider runtimeUrl=\"https://your-runtime/api/copilotkit\">\n * <ChatScreen />\n * </CopilotKitProvider>\n * );\n * }\n * ```\n */\nexport const CopilotKitProvider: React.FC<CopilotKitNativeProviderProps> = ({\n children,\n runtimeUrl,\n headers: headersProp,\n credentials,\n messageFilter,\n useSingleEndpoint,\n properties,\n onError,\n debug,\n defaultThrottleMs,\n markdownRenderer,\n}) => {\n // Resolve headers from function or static object (matches web provider pattern)\n const resolvedHeaders =\n typeof headersProp === \"function\" ? headersProp() : headersProp;\n\n // Stabilize headers/properties references to avoid effect churn when callers\n // pass inline object literals (e.g. headers={{}} or the undefined default).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableHeaders = useMemo(\n () => resolvedHeaders ?? {},\n [JSON.stringify(resolvedHeaders)],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableProperties = useMemo(\n () => properties ?? {},\n [JSON.stringify(properties)],\n );\n\n const copilotkitRef = useRef<CopilotKitCoreReactInstance | null>(null);\n\n if (copilotkitRef.current === null) {\n const instance: CopilotKitCoreReactInstance = new CopilotKitCoreReact({\n runtimeUrl,\n runtimeTransport:\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n headers: stableHeaders,\n credentials,\n messageFilter,\n properties: stableProperties,\n debug,\n });\n // Set initial defaultThrottleMs synchronously so child hooks see the\n // correct value on their first render (before useEffect fires).\n if (defaultThrottleMs !== undefined) {\n instance.setDefaultThrottleMs(defaultThrottleMs);\n }\n copilotkitRef.current = instance;\n }\n\n const copilotkit = copilotkitRef.current;\n\n // Sync props to core instance\n useEffect(() => {\n copilotkit.setRuntimeUrl(runtimeUrl);\n copilotkit.setRuntimeTransport(\n useSingleEndpoint === true\n ? \"single\"\n : useSingleEndpoint === false\n ? \"rest\"\n : \"auto\",\n );\n copilotkit.setHeaders(stableHeaders);\n copilotkit.setCredentials(credentials);\n copilotkit.setMessageFilter(messageFilter);\n copilotkit.setProperties(stableProperties);\n copilotkit.setDebug(debug);\n }, [\n runtimeUrl,\n useSingleEndpoint,\n stableHeaders,\n credentials,\n messageFilter,\n stableProperties,\n debug,\n copilotkit,\n ]);\n\n // Sync defaultThrottleMs to the core instance on prop changes.\n // Initial value is set synchronously during instance creation (inside the\n // ref guard above), so this only handles subsequent updates.\n useEffect(() => {\n copilotkit.setDefaultThrottleMs(defaultThrottleMs);\n }, [copilotkit, defaultThrottleMs]);\n\n // Track executing tool call IDs at the provider level.\n // Critical for HITL reconnection: onToolExecutionStart fires before child\n // components mount, so we must capture the state here.\n const [executingToolCallIds, setExecutingToolCallIds] = useState<\n ReadonlySet<string>\n >(() => new Set());\n\n const [runtimeLicenseStatus, setRuntimeLicenseStatus] = useState<\n RuntimeLicenseStatus | undefined\n >(undefined);\n\n // Use ref to avoid subscription churn when onError changes\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onErrorRef.current = onError;\n }, [onError]);\n\n // Single subscription for tool execution tracking and error handling.\n // Tool call IDs are tracked at the provider level because onToolExecutionStart\n // fires before child components mount — critical for HITL reconnection.\n useEffect(() => {\n const subscription = copilotkit.subscribe({\n onToolExecutionStart: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.add(toolCallId);\n return next;\n });\n },\n onToolExecutionEnd: ({ toolCallId }) => {\n setExecutingToolCallIds((prev) => {\n if (!prev.has(toolCallId)) return prev;\n const next = new Set(prev);\n next.delete(toolCallId);\n return next;\n });\n },\n onError: (event) => {\n if (onErrorRef.current) {\n onErrorRef.current(event);\n } else {\n console.error(\n `[CopilotKit] Error (${event.code}):`,\n event.error,\n event.context ?? {},\n );\n }\n },\n onRuntimeConnectionStatusChanged: () => {\n setRuntimeLicenseStatus(copilotkit.licenseStatus);\n },\n });\n return () => subscription.unsubscribe();\n }, [copilotkit]);\n\n const contextValue: CopilotKitContextValue = useMemo(\n () => ({\n copilotkit,\n executingToolCallIds,\n }),\n [copilotkit, executingToolCallIds],\n );\n\n // License context — driven by server-reported status via /info endpoint\n const licenseContextValue = useMemo(\n () => createLicenseContextValue(runtimeLicenseStatus),\n [runtimeLicenseStatus],\n );\n\n return (\n <CopilotKitContext.Provider value={contextValue}>\n <LicenseContext.Provider value={licenseContextValue}>\n <MarkdownRendererProvider renderer={markdownRenderer}>\n {children}\n </MarkdownRendererProvider>\n </LicenseContext.Provider>\n </CopilotKitContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmHA,MAAa,sBAA+D,EAC1E,UACA,YACA,SAAS,aACT,aACA,eACA,mBACA,YACA,SACA,OACA,mBACA,uBACI;CAEJ,MAAM,kBACJ,OAAO,gBAAgB,aAAa,aAAa,GAAG;CAKtD,MAAM,gBAAgB,cACd,mBAAmB,EAAE,EAC3B,CAAC,KAAK,UAAU,gBAAgB,CAAC,CAClC;CAED,MAAM,mBAAmB,cACjB,cAAc,EAAE,EACtB,CAAC,KAAK,UAAU,WAAW,CAAC,CAC7B;CAED,MAAM,gBAAgB,OAA2C,KAAK;AAEtE,KAAI,cAAc,YAAY,MAAM;EAClC,MAAM,WAAwC,IAAI,oBAAoB;GACpE;GACA,kBACE,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA;GACR,SAAS;GACT;GACA;GACA,YAAY;GACZ;GACD,CAAC;AAGF,MAAI,sBAAsB,OACxB,UAAS,qBAAqB,kBAAkB;AAElD,gBAAc,UAAU;;CAG1B,MAAM,aAAa,cAAc;AAGjC,iBAAgB;AACd,aAAW,cAAc,WAAW;AACpC,aAAW,oBACT,sBAAsB,OAClB,WACA,sBAAsB,QACpB,SACA,OACP;AACD,aAAW,WAAW,cAAc;AACpC,aAAW,eAAe,YAAY;AACtC,aAAW,iBAAiB,cAAc;AAC1C,aAAW,cAAc,iBAAiB;AAC1C,aAAW,SAAS,MAAM;IACzB;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAKF,iBAAgB;AACd,aAAW,qBAAqB,kBAAkB;IACjD,CAAC,YAAY,kBAAkB,CAAC;CAKnC,MAAM,CAAC,sBAAsB,2BAA2B,+BAEhD,IAAI,KAAK,CAAC;CAElB,MAAM,CAAC,sBAAsB,2BAA2B,SAEtD,OAAU;CAGZ,MAAM,aAAa,OAAO,QAAQ;AAClC,iBAAgB;AACd,aAAW,UAAU;IACpB,CAAC,QAAQ,CAAC;AAKb,iBAAgB;EACd,MAAM,eAAe,WAAW,UAAU;GACxC,uBAAuB,EAAE,iBAAiB;AACxC,6BAAyB,SAAS;AAChC,SAAI,KAAK,IAAI,WAAW,CAAE,QAAO;KACjC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,IAAI,WAAW;AACpB,YAAO;MACP;;GAEJ,qBAAqB,EAAE,iBAAiB;AACtC,6BAAyB,SAAS;AAChC,SAAI,CAAC,KAAK,IAAI,WAAW,CAAE,QAAO;KAClC,MAAM,OAAO,IAAI,IAAI,KAAK;AAC1B,UAAK,OAAO,WAAW;AACvB,YAAO;MACP;;GAEJ,UAAU,UAAU;AAClB,QAAI,WAAW,QACb,YAAW,QAAQ,MAAM;QAEzB,SAAQ,MACN,uBAAuB,MAAM,KAAK,KAClC,MAAM,OACN,MAAM,WAAW,EAAE,CACpB;;GAGL,wCAAwC;AACtC,4BAAwB,WAAW,cAAc;;GAEpD,CAAC;AACF,eAAa,aAAa,aAAa;IACtC,CAAC,WAAW,CAAC;CAEhB,MAAM,eAAuC,eACpC;EACL;EACA;EACD,GACD,CAAC,YAAY,qBAAqB,CACnC;CAGD,MAAM,sBAAsB,cACpB,0BAA0B,qBAAqB,EACrD,CAAC,qBAAqB,CACvB;AAED,QACE,oBAAC,kBAAkB;EAAS,OAAO;YACjC,oBAAC,eAAe;GAAS,OAAO;aAC9B,oBAAC;IAAyB,UAAU;IACjC;KACwB;IACH;GACC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Markdown-C6AsLHmd.mjs","names":["defaultMarkdownStyles","_streamingDefaultStyles"],"sources":["../src/components/Markdown.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n StreamingMarkdownRenderer,\n defaultMarkdownStyles as _streamingDefaultStyles,\n} from \"@copilotkit/markdown-renderer/react-native\";\nimport type { MarkdownStyle as StreamingMarkdownStyle } from \"@copilotkit/markdown-renderer/react-native\";\nimport { warnUnsupportedRichSyntaxOnce } from \"@copilotkit/markdown-renderer\";\n\n/**\n * Style map for CopilotMarkdown. Each key maps a node type to a React Native\n * style object. Extends the streaming renderer's style keys with a `code`\n * shorthand kept for backward compatibility (`list` already exists on the\n * base style and needs no alias).\n *\n * @public\n */\nexport type MarkdownStyle = StreamingMarkdownStyle & {\n /** Alias for `inlineCode`; kept for backward compatibility. */\n code?: Record<string, unknown>;\n};\n\n/**\n * Default styles that ship with CopilotMarkdown.\n *\n * @public\n */\nexport const defaultMarkdownStyles: MarkdownStyle = {\n ..._streamingDefaultStyles,\n // Back-compat alias: `code` = same as `inlineCode`\n code: _streamingDefaultStyles.inlineCode,\n};\n\nexport interface CopilotMarkdownProps {\n content: string;\n style?: MarkdownStyle;\n /**\n * Toggles `Intl.Segmenter`-based token segmentation in the parser. Defaults\n * to `false` (Hermes-safe: no Segmenter needed). Note: the React Native\n * renderer renders text directly and does not perform per-token fade-in\n * animation, so this currently has no visual effect — it is accepted for\n * backward compatibility.\n */\n streamingAnimation?: boolean;\n}\n\n/**\n * GFM markdown renderer for React Native. Delegates to the shared\n * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.\n *\n * Public API is backward-compatible with the previous basic renderer:\n * - `CopilotMarkdownProps` — same shape.\n * - `MarkdownStyle` / `defaultMarkdownStyles` — same exports.\n * - `streamingAnimation` maps to `animate` (defaults `false` = Hermes-safe).\n *\n * @public\n */\nexport function CopilotMarkdown({\n content,\n style,\n streamingAnimation = false,\n}: CopilotMarkdownProps): React.ReactElement | null {\n // Translate the back-compat `code` alias onto `inlineCode` — the key the\n // streaming renderer actually reads. Without this, a caller migrating from\n // the previous renderer who passes `style={{ code: ... }}` would silently\n // lose inline-code styling. An explicit `inlineCode` wins over the alias.\n // Dev-only: nudge upgraders from the bundled Streamdown default when their\n // content needs math/syntax highlighting the built-in renderer doesn't do.\n warnUnsupportedRichSyntaxOnce(content);\n\n let resolvedStyle = style as StreamingMarkdownStyle | undefined;\n if (style?.code !== undefined) {\n const { code, ...rest } = style;\n resolvedStyle = {\n ...(rest as StreamingMarkdownStyle),\n inlineCode: (rest as StreamingMarkdownStyle).inlineCode ?? code,\n };\n }\n return (\n <StreamingMarkdownRenderer\n content={content}\n isComplete={true}\n style={resolvedStyle}\n animate={streamingAnimation}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AA0BA,MAAaA,0BAAuC;CAClD,GAAGC;CAEH,MAAMA,sBAAwB;CAC/B;;;;;;;;;;;;AA0BD,SAAgB,gBAAgB,EAC9B,SACA,OACA,qBAAqB,SAC6B;AAOlD,+BAA8B,QAAQ;CAEtC,IAAI,gBAAgB;AACpB,KAAI,OAAO,SAAS,QAAW;EAC7B,MAAM,EAAE,MAAM,GAAG,SAAS;AAC1B,kBAAgB;GACd,GAAI;GACJ,YAAa,KAAgC,cAAc;GAC5D;;AAEH,QACE,oBAAC;EACU;EACT,YAAY;EACZ,OAAO;EACP,SAAS;GACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Markdown-C_9Re36O.cjs","names":["_streamingDefaultStyles","StreamingMarkdownRenderer"],"sources":["../src/components/Markdown.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n StreamingMarkdownRenderer,\n defaultMarkdownStyles as _streamingDefaultStyles,\n} from \"@copilotkit/markdown-renderer/react-native\";\nimport type { MarkdownStyle as StreamingMarkdownStyle } from \"@copilotkit/markdown-renderer/react-native\";\nimport { warnUnsupportedRichSyntaxOnce } from \"@copilotkit/markdown-renderer\";\n\n/**\n * Style map for CopilotMarkdown. Each key maps a node type to a React Native\n * style object. Extends the streaming renderer's style keys with a `code`\n * shorthand kept for backward compatibility (`list` already exists on the\n * base style and needs no alias).\n *\n * @public\n */\nexport type MarkdownStyle = StreamingMarkdownStyle & {\n /** Alias for `inlineCode`; kept for backward compatibility. */\n code?: Record<string, unknown>;\n};\n\n/**\n * Default styles that ship with CopilotMarkdown.\n *\n * @public\n */\nexport const defaultMarkdownStyles: MarkdownStyle = {\n ..._streamingDefaultStyles,\n // Back-compat alias: `code` = same as `inlineCode`\n code: _streamingDefaultStyles.inlineCode,\n};\n\nexport interface CopilotMarkdownProps {\n content: string;\n style?: MarkdownStyle;\n /**\n * Toggles `Intl.Segmenter`-based token segmentation in the parser. Defaults\n * to `false` (Hermes-safe: no Segmenter needed). Note: the React Native\n * renderer renders text directly and does not perform per-token fade-in\n * animation, so this currently has no visual effect — it is accepted for\n * backward compatibility.\n */\n streamingAnimation?: boolean;\n}\n\n/**\n * GFM markdown renderer for React Native. Delegates to the shared\n * `StreamingMarkdownRenderer` from `@copilotkit/markdown-renderer/react-native`.\n *\n * Public API is backward-compatible with the previous basic renderer:\n * - `CopilotMarkdownProps` — same shape.\n * - `MarkdownStyle` / `defaultMarkdownStyles` — same exports.\n * - `streamingAnimation` maps to `animate` (defaults `false` = Hermes-safe).\n *\n * @public\n */\nexport function CopilotMarkdown({\n content,\n style,\n streamingAnimation = false,\n}: CopilotMarkdownProps): React.ReactElement | null {\n // Translate the back-compat `code` alias onto `inlineCode` — the key the\n // streaming renderer actually reads. Without this, a caller migrating from\n // the previous renderer who passes `style={{ code: ... }}` would silently\n // lose inline-code styling. An explicit `inlineCode` wins over the alias.\n // Dev-only: nudge upgraders from the bundled Streamdown default when their\n // content needs math/syntax highlighting the built-in renderer doesn't do.\n warnUnsupportedRichSyntaxOnce(content);\n\n let resolvedStyle = style as StreamingMarkdownStyle | undefined;\n if (style?.code !== undefined) {\n const { code, ...rest } = style;\n resolvedStyle = {\n ...(rest as StreamingMarkdownStyle),\n inlineCode: (rest as StreamingMarkdownStyle).inlineCode ?? code,\n };\n }\n return (\n <StreamingMarkdownRenderer\n content={content}\n isComplete={true}\n style={resolvedStyle}\n animate={streamingAnimation}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,MAAa,wBAAuC;CAClD,GAAGA;CAEH,MAAMA,iEAAwB;CAC/B;;;;;;;;;;;;AA0BD,SAAgB,gBAAgB,EAC9B,SACA,OACA,qBAAqB,SAC6B;AAOlD,kEAA8B,QAAQ;CAEtC,IAAI,gBAAgB;AACpB,KAAI,OAAO,SAAS,QAAW;EAC7B,MAAM,EAAE,MAAM,GAAG,SAAS;AAC1B,kBAAgB;GACd,GAAI;GACJ,YAAa,KAAgC,cAAc;GAC5D;;AAEH,QACE,2CAACC;EACU;EACT,YAAY;EACZ,OAAO;EACP,SAAS;GACT"}