@copilotkit/react-core 1.54.1 → 1.55.0-next.7

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 (183) hide show
  1. package/CHANGELOG.md +117 -116
  2. package/dist/copilotkit-B3Mb1yVE.cjs +7975 -0
  3. package/dist/copilotkit-B3Mb1yVE.cjs.map +1 -0
  4. package/dist/copilotkit-DBzgOMby.d.cts +2182 -0
  5. package/dist/copilotkit-DBzgOMby.d.cts.map +1 -0
  6. package/dist/copilotkit-DNYSFuz5.mjs +7562 -0
  7. package/dist/copilotkit-DNYSFuz5.mjs.map +1 -0
  8. package/dist/copilotkit-Dy5w3qEV.d.mts +2182 -0
  9. package/dist/copilotkit-Dy5w3qEV.d.mts.map +1 -0
  10. package/dist/index.cjs +27 -28
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +3 -3
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +3 -3
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +4 -5
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/index.umd.js +1941 -35
  19. package/dist/index.umd.js.map +1 -1
  20. package/dist/v2/index.cjs +77 -7
  21. package/dist/v2/index.css +1 -2
  22. package/dist/v2/index.d.cts +6 -4
  23. package/dist/v2/index.d.mts +6 -4
  24. package/dist/v2/index.mjs +7 -4
  25. package/dist/v2/index.umd.js +5725 -24
  26. package/dist/v2/index.umd.js.map +1 -1
  27. package/package.json +37 -9
  28. package/scripts/scope-preflight.mjs +101 -0
  29. package/src/components/CopilotListeners.tsx +2 -6
  30. package/src/components/copilot-provider/copilot-messages.tsx +1 -1
  31. package/src/components/copilot-provider/copilotkit-props.tsx +1 -1
  32. package/src/components/copilot-provider/copilotkit.tsx +4 -4
  33. package/src/context/copilot-messages-context.tsx +1 -1
  34. package/src/hooks/__tests__/use-coagent-config.test.ts +2 -2
  35. package/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx +2 -2
  36. package/src/hooks/__tests__/use-copilot-chat-internal-connect.test.tsx +3 -7
  37. package/src/hooks/__tests__/use-frontend-tool-available.test.tsx +1 -1
  38. package/src/hooks/__tests__/use-frontend-tool-remount.e2e.test.tsx +4 -4
  39. package/src/hooks/use-agent-nodename.ts +1 -1
  40. package/src/hooks/use-coagent-state-render-bridge.tsx +1 -4
  41. package/src/hooks/use-coagent.ts +1 -1
  42. package/src/hooks/use-configure-chat-suggestions.tsx +2 -2
  43. package/src/hooks/use-copilot-chat-suggestions.tsx +2 -2
  44. package/src/hooks/use-copilot-chat_internal.ts +2 -2
  45. package/src/hooks/use-copilot-readable.ts +1 -1
  46. package/src/hooks/use-frontend-tool.ts +2 -2
  47. package/src/hooks/use-human-in-the-loop.ts +2 -2
  48. package/src/hooks/use-langgraph-interrupt.ts +2 -5
  49. package/src/hooks/use-lazy-tool-renderer.tsx +1 -1
  50. package/src/hooks/use-render-tool-call.ts +1 -1
  51. package/src/lib/copilot-task.ts +1 -1
  52. package/src/setupTests.ts +18 -14
  53. package/src/v2/__tests__/A2UIMessageRenderer.test.tsx +176 -0
  54. package/src/v2/__tests__/globalSetup.ts +14 -0
  55. package/src/v2/__tests__/setup.ts +93 -0
  56. package/src/v2/__tests__/utils/test-helpers.tsx +470 -0
  57. package/src/v2/a2ui/A2UIMessageRenderer.tsx +206 -0
  58. package/src/v2/components/CopilotKitInspector.tsx +50 -0
  59. package/src/v2/components/MCPAppsActivityRenderer.tsx +785 -0
  60. package/src/v2/components/WildcardToolCallRender.tsx +86 -0
  61. package/src/v2/components/__tests__/license-warning-banner.test.tsx +46 -0
  62. package/src/v2/components/chat/CopilotChat.tsx +431 -0
  63. package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +375 -0
  64. package/src/v2/components/chat/CopilotChatAudioRecorder.tsx +350 -0
  65. package/src/v2/components/chat/CopilotChatInput.tsx +1302 -0
  66. package/src/v2/components/chat/CopilotChatMessageView.tsx +556 -0
  67. package/src/v2/components/chat/CopilotChatReasoningMessage.tsx +252 -0
  68. package/src/v2/components/chat/CopilotChatSuggestionPill.tsx +59 -0
  69. package/src/v2/components/chat/CopilotChatSuggestionView.tsx +133 -0
  70. package/src/v2/components/chat/CopilotChatToggleButton.tsx +171 -0
  71. package/src/v2/components/chat/CopilotChatToolCallsView.tsx +40 -0
  72. package/src/v2/components/chat/CopilotChatUserMessage.tsx +388 -0
  73. package/src/v2/components/chat/CopilotChatView.tsx +598 -0
  74. package/src/v2/components/chat/CopilotModalHeader.tsx +129 -0
  75. package/src/v2/components/chat/CopilotPopup.tsx +81 -0
  76. package/src/v2/components/chat/CopilotPopupView.tsx +317 -0
  77. package/src/v2/components/chat/CopilotSidebar.tsx +76 -0
  78. package/src/v2/components/chat/CopilotSidebarView.tsx +255 -0
  79. package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.tsx +1113 -0
  80. package/src/v2/components/chat/__tests__/CopilotChat.onError.test.tsx +73 -0
  81. package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.tsx +432 -0
  82. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +150 -0
  83. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.tsx +624 -0
  84. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx +702 -0
  85. package/src/v2/components/chat/__tests__/CopilotChatCssClasses.test.tsx +107 -0
  86. package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.tsx +929 -0
  87. package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +986 -0
  88. package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.tsx +1004 -0
  89. package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.tsx +169 -0
  90. package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.tsx +530 -0
  91. package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.tsx +782 -0
  92. package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.tsx +2413 -0
  93. package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.tsx +621 -0
  94. package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.tsx +853 -0
  95. package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.tsx +1050 -0
  96. package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.tsx +484 -0
  97. package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.tsx +612 -0
  98. package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.tsx +502 -0
  99. package/src/v2/components/chat/__tests__/MCPAppsActivityRenderer.e2e.test.tsx +1011 -0
  100. package/src/v2/components/chat/__tests__/setup.ts +1 -0
  101. package/src/v2/components/chat/index.ts +79 -0
  102. package/src/v2/components/index.ts +7 -0
  103. package/src/v2/components/license-warning-banner.tsx +198 -0
  104. package/src/v2/components/ui/button.tsx +123 -0
  105. package/src/v2/components/ui/dropdown-menu.tsx +258 -0
  106. package/src/v2/components/ui/tooltip.tsx +60 -0
  107. package/src/v2/hooks/__tests__/standard-schema-types.test.tsx +152 -0
  108. package/src/v2/hooks/__tests__/standard-schema.test.tsx +282 -0
  109. package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.tsx +132 -0
  110. package/src/v2/hooks/__tests__/use-agent-context.test.tsx +401 -0
  111. package/src/v2/hooks/__tests__/use-agent-error-state.test.tsx +44 -0
  112. package/src/v2/hooks/__tests__/use-agent-stability.test.tsx +205 -0
  113. package/src/v2/hooks/__tests__/use-agent.e2e.test.tsx +148 -0
  114. package/src/v2/hooks/__tests__/use-component.test.tsx +123 -0
  115. package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.tsx +696 -0
  116. package/src/v2/hooks/__tests__/use-default-render-tool.test.tsx +153 -0
  117. package/src/v2/hooks/__tests__/use-frontend-tool-available.test.tsx +167 -0
  118. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.tsx +2129 -0
  119. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx +1261 -0
  120. package/src/v2/hooks/__tests__/use-interrupt.test.tsx +397 -0
  121. package/src/v2/hooks/__tests__/use-katex-styles.test.tsx +56 -0
  122. package/src/v2/hooks/__tests__/use-keyboard-height.test.tsx +192 -0
  123. package/src/v2/hooks/__tests__/use-render-tool.test.tsx +259 -0
  124. package/src/v2/hooks/__tests__/use-suggestions.e2e.test.tsx +524 -0
  125. package/src/v2/hooks/__tests__/use-threads.test.tsx +433 -0
  126. package/src/v2/hooks/__tests__/zod-regression.test.tsx +311 -0
  127. package/src/v2/hooks/index.ts +18 -0
  128. package/src/v2/hooks/use-agent-context.tsx +45 -0
  129. package/src/v2/hooks/use-agent.tsx +155 -0
  130. package/src/v2/hooks/use-component.tsx +89 -0
  131. package/src/v2/hooks/use-configure-suggestions.tsx +187 -0
  132. package/src/v2/hooks/use-default-render-tool.tsx +254 -0
  133. package/src/v2/hooks/use-frontend-tool.tsx +43 -0
  134. package/src/v2/hooks/use-human-in-the-loop.tsx +81 -0
  135. package/src/v2/hooks/use-interrupt.tsx +305 -0
  136. package/src/v2/hooks/use-keyboard-height.tsx +67 -0
  137. package/src/v2/hooks/use-render-activity-message.tsx +73 -0
  138. package/src/v2/hooks/use-render-custom-messages.tsx +93 -0
  139. package/src/v2/hooks/use-render-tool-call.tsx +175 -0
  140. package/src/v2/hooks/use-render-tool.tsx +181 -0
  141. package/src/v2/hooks/use-suggestions.tsx +91 -0
  142. package/src/v2/hooks/use-threads.tsx +256 -0
  143. package/src/v2/hooks/useKatexStyles.ts +27 -0
  144. package/src/v2/index.css +1 -1
  145. package/src/v2/index.ts +18 -2
  146. package/src/v2/lib/__tests__/completePartialMarkdown.test.ts +495 -0
  147. package/src/v2/lib/__tests__/renderSlot.test.tsx +588 -0
  148. package/src/v2/lib/react-core.ts +156 -0
  149. package/src/v2/lib/slots.tsx +143 -0
  150. package/src/v2/lib/transcription-client.ts +184 -0
  151. package/src/v2/lib/utils.ts +8 -0
  152. package/src/v2/providers/CopilotChatConfigurationProvider.tsx +162 -0
  153. package/src/v2/providers/CopilotKitProvider.tsx +600 -0
  154. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.tsx +546 -0
  155. package/src/v2/providers/__tests__/CopilotKitProvider.license.test.tsx +101 -0
  156. package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.tsx +69 -0
  157. package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.tsx +881 -0
  158. package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.tsx +740 -0
  159. package/src/v2/providers/__tests__/CopilotKitProvider.test.tsx +642 -0
  160. package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.tsx +294 -0
  161. package/src/v2/providers/index.ts +14 -0
  162. package/src/v2/styles/globals.css +230 -0
  163. package/src/v2/types/__tests__/defineToolCallRenderer.test.tsx +525 -0
  164. package/src/v2/types/defineToolCallRenderer.ts +65 -0
  165. package/src/v2/types/frontend-tool.ts +8 -0
  166. package/src/v2/types/human-in-the-loop.ts +33 -0
  167. package/src/v2/types/index.ts +7 -0
  168. package/src/v2/types/interrupt.ts +15 -0
  169. package/src/v2/types/react-activity-message-renderer.ts +27 -0
  170. package/src/v2/types/react-custom-message-renderer.ts +17 -0
  171. package/src/v2/types/react-tool-call-renderer.ts +32 -0
  172. package/tsdown.config.ts +34 -10
  173. package/vitest.config.mjs +4 -3
  174. package/LICENSE +0 -21
  175. package/dist/copilotkit-BRPQ2sqS.d.cts +0 -670
  176. package/dist/copilotkit-BRPQ2sqS.d.cts.map +0 -1
  177. package/dist/copilotkit-C94ayZbs.cjs +0 -2161
  178. package/dist/copilotkit-C94ayZbs.cjs.map +0 -1
  179. package/dist/copilotkit-CwZMFmSK.d.mts +0 -670
  180. package/dist/copilotkit-CwZMFmSK.d.mts.map +0 -1
  181. package/dist/copilotkit-Yh_Ld_FX.mjs +0 -2031
  182. package/dist/copilotkit-Yh_Ld_FX.mjs.map +0 -1
  183. package/dist/v2/index.css.map +0 -1
@@ -0,0 +1,294 @@
1
+ import { renderHook } from "@testing-library/react";
2
+ import type React from "react";
3
+ import { describe, expect, it, vi } from "vitest";
4
+ import { z } from "zod";
5
+ import type { ReactFrontendTool } from "../../types/frontend-tool";
6
+ import type { ReactHumanInTheLoop } from "../../types/human-in-the-loop";
7
+ import { CopilotKitProvider, useCopilotKit } from "../CopilotKitProvider";
8
+
9
+ describe("CopilotKitProvider - Wildcard Tool", () => {
10
+ describe("Wildcard Frontend Tool", () => {
11
+ it("should register wildcard frontend tool", () => {
12
+ const wildcardHandler = vi.fn();
13
+ const wildcardTool: ReactFrontendTool = {
14
+ name: "*",
15
+ description: "Fallback for undefined tools",
16
+ handler: wildcardHandler,
17
+ };
18
+
19
+ const { result } = renderHook(() => useCopilotKit(), {
20
+ wrapper: ({ children }) => (
21
+ <CopilotKitProvider frontendTools={[wildcardTool]}>
22
+ {children}
23
+ </CopilotKitProvider>
24
+ ),
25
+ });
26
+
27
+ const retrievedTool = result.current.copilotkit.getTool({
28
+ toolName: "*",
29
+ });
30
+ expect(retrievedTool).toBeDefined();
31
+ expect(retrievedTool?.name).toBe("*");
32
+ expect(retrievedTool?.handler).toBe(wildcardHandler);
33
+ });
34
+
35
+ it("should register wildcard alongside specific tools", () => {
36
+ const specificHandler = vi.fn();
37
+ const wildcardHandler = vi.fn();
38
+
39
+ const specificTool: ReactFrontendTool = {
40
+ name: "specific",
41
+ handler: specificHandler,
42
+ };
43
+
44
+ const wildcardTool: ReactFrontendTool = {
45
+ name: "*",
46
+ handler: wildcardHandler,
47
+ };
48
+
49
+ const { result } = renderHook(() => useCopilotKit(), {
50
+ wrapper: ({ children }) => (
51
+ <CopilotKitProvider frontendTools={[specificTool, wildcardTool]}>
52
+ {children}
53
+ </CopilotKitProvider>
54
+ ),
55
+ });
56
+
57
+ expect(
58
+ result.current.copilotkit.getTool({ toolName: "specific" }),
59
+ ).toBeDefined();
60
+ expect(
61
+ result.current.copilotkit.getTool({ toolName: "*" }),
62
+ ).toBeDefined();
63
+ });
64
+
65
+ it("should register wildcard with render component", () => {
66
+ const WildcardRender: React.FC<any> = ({ args }) => (
67
+ <div>Unknown tool: {args.toolName}</div>
68
+ );
69
+
70
+ const wildcardTool: ReactFrontendTool = {
71
+ name: "*",
72
+ description: "Fallback with render",
73
+ parameters: z.object({
74
+ toolName: z.string(),
75
+ args: z.unknown(),
76
+ }),
77
+ render: WildcardRender,
78
+ };
79
+
80
+ const { result } = renderHook(() => useCopilotKit(), {
81
+ wrapper: ({ children }) => (
82
+ <CopilotKitProvider frontendTools={[wildcardTool]}>
83
+ {children}
84
+ </CopilotKitProvider>
85
+ ),
86
+ });
87
+
88
+ const wildcardRender = result.current.copilotkit.renderToolCalls.find(
89
+ (rc) => rc.name === "*",
90
+ );
91
+ expect(wildcardRender).toBeDefined();
92
+ expect(wildcardRender?.render).toBe(WildcardRender);
93
+ });
94
+
95
+ it("should support wildcard with agentId", () => {
96
+ const wildcardHandler = vi.fn();
97
+ const wildcardTool: ReactFrontendTool = {
98
+ name: "*",
99
+ handler: wildcardHandler,
100
+ agentId: "specificAgent",
101
+ };
102
+
103
+ const { result } = renderHook(() => useCopilotKit(), {
104
+ wrapper: ({ children }) => (
105
+ <CopilotKitProvider frontendTools={[wildcardTool]}>
106
+ {children}
107
+ </CopilotKitProvider>
108
+ ),
109
+ });
110
+
111
+ const retrievedTool = result.current.copilotkit.getTool({
112
+ toolName: "*",
113
+ agentId: "specificAgent",
114
+ });
115
+ expect(retrievedTool?.agentId).toBe("specificAgent");
116
+ });
117
+ });
118
+
119
+ describe("Wildcard Human-in-the-Loop", () => {
120
+ it("should register wildcard human-in-the-loop tool", () => {
121
+ const WildcardComponent: React.FC<any> = ({ args }) => (
122
+ <div>Unknown interaction: {args.toolName}</div>
123
+ );
124
+
125
+ const wildcardHitl: ReactHumanInTheLoop = {
126
+ name: "*",
127
+ description: "Fallback interaction",
128
+ parameters: z.object({
129
+ toolName: z.string(),
130
+ args: z.unknown(),
131
+ }),
132
+ render: WildcardComponent,
133
+ };
134
+
135
+ const { result } = renderHook(() => useCopilotKit(), {
136
+ wrapper: ({ children }) => (
137
+ <CopilotKitProvider humanInTheLoop={[wildcardHitl]}>
138
+ {children}
139
+ </CopilotKitProvider>
140
+ ),
141
+ });
142
+
143
+ expect(
144
+ result.current.copilotkit.getTool({ toolName: "*" }),
145
+ ).toBeDefined();
146
+ const wildcardRender = result.current.copilotkit.renderToolCalls.find(
147
+ (rc) => rc.name === "*",
148
+ );
149
+ expect(wildcardRender).toBeDefined();
150
+ expect(wildcardRender?.render).toBe(WildcardComponent);
151
+ });
152
+
153
+ it("should support wildcard human-in-the-loop with agentId", () => {
154
+ const WildcardComponent: React.FC<any> = () => <div>Wildcard</div>;
155
+
156
+ const wildcardHitl: ReactHumanInTheLoop = {
157
+ name: "*",
158
+ parameters: z.object({
159
+ toolName: z.string(),
160
+ args: z.unknown(),
161
+ }),
162
+ render: WildcardComponent,
163
+ agentId: "agent1",
164
+ };
165
+
166
+ const { result } = renderHook(() => useCopilotKit(), {
167
+ wrapper: ({ children }) => (
168
+ <CopilotKitProvider humanInTheLoop={[wildcardHitl]}>
169
+ {children}
170
+ </CopilotKitProvider>
171
+ ),
172
+ });
173
+
174
+ const retrievedTool = result.current.copilotkit.getTool({
175
+ toolName: "*",
176
+ agentId: "agent1",
177
+ });
178
+ expect(retrievedTool?.agentId).toBe("agent1");
179
+ });
180
+ });
181
+
182
+ describe("Wildcard Render Tool Calls", () => {
183
+ it("should register wildcard in renderToolCalls", () => {
184
+ const WildcardRender: React.FC<any> = ({ args }) => (
185
+ <div>Fallback render</div>
186
+ );
187
+
188
+ const renderToolCalls = [
189
+ {
190
+ name: "*",
191
+ args: z.object({
192
+ toolName: z.string(),
193
+ args: z.unknown(),
194
+ }),
195
+ render: WildcardRender,
196
+ },
197
+ ];
198
+
199
+ const { result } = renderHook(() => useCopilotKit(), {
200
+ wrapper: ({ children }) => (
201
+ <CopilotKitProvider renderToolCalls={renderToolCalls}>
202
+ {children}
203
+ </CopilotKitProvider>
204
+ ),
205
+ });
206
+
207
+ const wildcardRender = result.current.copilotkit.renderToolCalls.find(
208
+ (rc) => rc.name === "*",
209
+ );
210
+ expect(wildcardRender).toBeDefined();
211
+ expect(wildcardRender?.render).toBe(WildcardRender);
212
+ });
213
+
214
+ it("should support wildcard render with agentId", () => {
215
+ const WildcardRender: React.FC<any> = () => <div>Agent wildcard</div>;
216
+
217
+ const renderToolCalls = [
218
+ {
219
+ name: "*",
220
+ args: z.object({
221
+ toolName: z.string(),
222
+ args: z.unknown(),
223
+ }),
224
+ render: WildcardRender,
225
+ agentId: "agent1",
226
+ },
227
+ ];
228
+
229
+ const { result } = renderHook(() => useCopilotKit(), {
230
+ wrapper: ({ children }) => (
231
+ <CopilotKitProvider renderToolCalls={renderToolCalls}>
232
+ {children}
233
+ </CopilotKitProvider>
234
+ ),
235
+ });
236
+
237
+ const wildcardRender = result.current.copilotkit.renderToolCalls.find(
238
+ (rc) => rc.name === "*",
239
+ );
240
+ expect(wildcardRender?.agentId).toBe("agent1");
241
+ });
242
+ });
243
+
244
+ describe("Combined wildcard and specific tools", () => {
245
+ it("should handle both wildcard and specific tools together", () => {
246
+ const SpecificRender: React.FC<any> = () => <div>Specific</div>;
247
+ const WildcardRender: React.FC<any> = () => <div>Wildcard</div>;
248
+
249
+ const frontendTools: ReactFrontendTool[] = [
250
+ {
251
+ name: "specificTool",
252
+ handler: vi.fn(),
253
+ parameters: z.object({ value: z.string() }),
254
+ render: SpecificRender,
255
+ },
256
+ {
257
+ name: "*",
258
+ handler: vi.fn(),
259
+ parameters: z.object({
260
+ toolName: z.string(),
261
+ args: z.unknown(),
262
+ }),
263
+ render: WildcardRender,
264
+ },
265
+ ];
266
+
267
+ const { result } = renderHook(() => useCopilotKit(), {
268
+ wrapper: ({ children }) => (
269
+ <CopilotKitProvider frontendTools={frontendTools}>
270
+ {children}
271
+ </CopilotKitProvider>
272
+ ),
273
+ });
274
+
275
+ // Both tools should be registered
276
+ expect(
277
+ result.current.copilotkit.getTool({ toolName: "specificTool" }),
278
+ ).toBeDefined();
279
+ expect(
280
+ result.current.copilotkit.getTool({ toolName: "*" }),
281
+ ).toBeDefined();
282
+
283
+ // Both renders should be registered
284
+ const specificToolRender = result.current.copilotkit.renderToolCalls.find(
285
+ (rc) => rc.name === "specificTool",
286
+ );
287
+ const wildcardRender = result.current.copilotkit.renderToolCalls.find(
288
+ (rc) => rc.name === "*",
289
+ );
290
+ expect(specificToolRender).toBeDefined();
291
+ expect(wildcardRender).toBeDefined();
292
+ });
293
+ });
294
+ });
@@ -0,0 +1,14 @@
1
+ export {
2
+ CopilotChatConfigurationProvider,
3
+ useCopilotChatConfiguration,
4
+ type CopilotChatLabels,
5
+ type CopilotChatConfigurationValue,
6
+ type CopilotChatConfigurationProviderProps,
7
+ } from "./CopilotChatConfigurationProvider";
8
+
9
+ export {
10
+ CopilotKitProvider,
11
+ useCopilotKit,
12
+ type CopilotKitProviderProps,
13
+ type CopilotKitContextValue,
14
+ } from "./CopilotKitProvider";
@@ -0,0 +1,230 @@
1
+ @import "tailwindcss" prefix(cpk);
2
+ @plugin "@tailwindcss/typography";
3
+ @source "../**/*.{ts,tsx}";
4
+ @source "../../../../node_modules/streamdown/dist/index.js";
5
+
6
+ @import "tw-animate-css";
7
+
8
+ @custom-variant dark (&:is(.dark *));
9
+
10
+ [data-copilotkit] {
11
+ --background: oklch(1 0 0);
12
+ --foreground: oklch(0.145 0 0);
13
+ --card: oklch(1 0 0);
14
+ --card-foreground: oklch(0.145 0 0);
15
+ --popover: oklch(1 0 0);
16
+ --popover-foreground: oklch(0.145 0 0);
17
+ --primary: oklch(0.205 0 0);
18
+ --primary-foreground: oklch(0.985 0 0);
19
+ --secondary: oklch(0.97 0 0);
20
+ --secondary-foreground: oklch(0.205 0 0);
21
+ --muted: oklch(0.97 0 0);
22
+ --muted-foreground: oklch(0.556 0 0);
23
+ --accent: oklch(0.97 0 0);
24
+ --accent-foreground: oklch(0.205 0 0);
25
+ --destructive: oklch(0.577 0.245 27.325);
26
+ --destructive-foreground: oklch(0.577 0.245 27.325);
27
+ --border: oklch(0.922 0 0);
28
+ --input: oklch(0.922 0 0);
29
+ --ring: oklch(0.708 0 0);
30
+ --chart-1: oklch(0.646 0.222 41.116);
31
+ --chart-2: oklch(0.6 0.118 184.704);
32
+ --chart-3: oklch(0.398 0.07 227.392);
33
+ --chart-4: oklch(0.828 0.189 84.429);
34
+ --chart-5: oklch(0.769 0.188 70.08);
35
+ --radius: 0.625rem;
36
+ --sidebar: oklch(0.985 0 0);
37
+ --sidebar-foreground: oklch(0.145 0 0);
38
+ --sidebar-primary: oklch(0.205 0 0);
39
+ --sidebar-primary-foreground: oklch(0.985 0 0);
40
+ --sidebar-accent: oklch(0.97 0 0);
41
+ --sidebar-accent-foreground: oklch(0.205 0 0);
42
+ --sidebar-border: oklch(0.922 0 0);
43
+ --sidebar-ring: oklch(0.708 0 0);
44
+ }
45
+
46
+ .dark [data-copilotkit],
47
+ [data-copilotkit].dark {
48
+ --background: oklch(0.145 0 0);
49
+ --foreground: oklch(0.985 0 0);
50
+ --card: oklch(0.145 0 0);
51
+ --card-foreground: oklch(0.985 0 0);
52
+ --popover: oklch(0.145 0 0);
53
+ --popover-foreground: oklch(0.985 0 0);
54
+ --primary: oklch(0.985 0 0);
55
+ --primary-foreground: oklch(0.205 0 0);
56
+ --secondary: oklch(0.269 0 0);
57
+ --secondary-foreground: oklch(0.985 0 0);
58
+ --muted: oklch(0.269 0 0);
59
+ --muted-foreground: oklch(0.708 0 0);
60
+ --accent: oklch(0.269 0 0);
61
+ --accent-foreground: oklch(0.985 0 0);
62
+ --destructive: oklch(0.396 0.141 25.723);
63
+ --destructive-foreground: oklch(0.637 0.237 25.331);
64
+ --border: oklch(0.269 0 0);
65
+ --input: oklch(0.269 0 0);
66
+ --ring: oklch(0.556 0 0);
67
+ --chart-1: oklch(0.488 0.243 264.376);
68
+ --chart-2: oklch(0.696 0.17 162.48);
69
+ --chart-3: oklch(0.769 0.188 70.08);
70
+ --chart-4: oklch(0.627 0.265 303.9);
71
+ --chart-5: oklch(0.645 0.246 16.439);
72
+ --sidebar: oklch(0.205 0 0);
73
+ --sidebar-foreground: oklch(0.985 0 0);
74
+ --sidebar-primary: oklch(0.488 0.243 264.376);
75
+ --sidebar-primary-foreground: oklch(0.985 0 0);
76
+ --sidebar-accent: oklch(0.269 0 0);
77
+ --sidebar-accent-foreground: oklch(0.985 0 0);
78
+ --sidebar-border: oklch(0.269 0 0);
79
+ --sidebar-ring: oklch(0.439 0 0);
80
+ }
81
+
82
+ @theme inline {
83
+ --color-background: var(--background);
84
+ --color-foreground: var(--foreground);
85
+ --color-card: var(--card);
86
+ --color-card-foreground: var(--card-foreground);
87
+ --color-popover: var(--popover);
88
+ --color-popover-foreground: var(--popover-foreground);
89
+ --color-primary: var(--primary);
90
+ --color-primary-foreground: var(--primary-foreground);
91
+ --color-secondary: var(--secondary);
92
+ --color-secondary-foreground: var(--secondary-foreground);
93
+ --color-muted: var(--muted);
94
+ --color-muted-foreground: var(--muted-foreground);
95
+ --color-accent: var(--accent);
96
+ --color-accent-foreground: var(--accent-foreground);
97
+ --color-destructive: var(--destructive);
98
+ --color-destructive-foreground: var(--destructive-foreground);
99
+ --color-border: var(--border);
100
+ --color-input: var(--input);
101
+ --color-ring: var(--ring);
102
+ --color-chart-1: var(--chart-1);
103
+ --color-chart-2: var(--chart-2);
104
+ --color-chart-3: var(--chart-3);
105
+ --color-chart-4: var(--chart-4);
106
+ --color-chart-5: var(--chart-5);
107
+ --radius-sm: calc(var(--radius) - 4px);
108
+ --radius-md: calc(var(--radius) - 2px);
109
+ --radius-lg: var(--radius);
110
+ --radius-xl: calc(var(--radius) + 4px);
111
+ --color-sidebar: var(--sidebar);
112
+ --color-sidebar-foreground: var(--sidebar-foreground);
113
+ --color-sidebar-primary: var(--sidebar-primary);
114
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
115
+ --color-sidebar-accent: var(--sidebar-accent);
116
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
117
+ --color-sidebar-border: var(--sidebar-border);
118
+ --color-sidebar-ring: var(--sidebar-ring);
119
+ }
120
+
121
+ @theme {
122
+ --animate-pulse-cursor: pulse-cursor 0.9s cubic-bezier(0.4, 0, 0.2, 1) infinite;
123
+ @keyframes pulse-cursor {
124
+ 0%,
125
+ 100% {
126
+ transform: scale(1);
127
+ opacity: 1;
128
+ }
129
+ 50% {
130
+ transform: scale(1.5);
131
+ opacity: 0.8;
132
+ }
133
+ }
134
+ }
135
+
136
+ @layer base {
137
+ * {
138
+ @apply cpk:border-border cpk:outline-ring/50;
139
+ }
140
+ /* Apply foreground/background on CopilotKit roots (replaces body rule) */
141
+ [data-copilotkit] {
142
+ color: var(--foreground);
143
+ background-color: var(--background);
144
+ }
145
+
146
+ /* Mobile viewport support */
147
+ @supports (height: 100dvh) {
148
+ [data-copilot-sidebar] {
149
+ height: 100dvh;
150
+ }
151
+ }
152
+
153
+ /* Responsive sidebar width */
154
+ @media (min-width: 768px) {
155
+ [data-copilot-sidebar] {
156
+ width: var(--sidebar-width, 480px) !important;
157
+ }
158
+ }
159
+
160
+ /* Mobile optimizations */
161
+ @media (max-width: 767px) {
162
+ [data-copilot-sidebar] {
163
+ width: 100% !important;
164
+ }
165
+
166
+ /* Improve touch scrolling on iOS */
167
+ [data-copilot-sidebar] {
168
+ -webkit-overflow-scrolling: touch;
169
+ }
170
+
171
+ /* Better scrolling performance */
172
+ [data-sidebar-chat] {
173
+ touch-action: pan-y;
174
+ }
175
+ }
176
+ }
177
+
178
+ [data-copilotkit] div[data-streamdown="code-block"] > pre {
179
+ @apply cpk:mt-0 cpk:mb-0;
180
+ }
181
+
182
+ /* Minimal scrollbar for WebKit browsers (Chrome, Safari, Edge) */
183
+ [data-copilotkit] ::-webkit-scrollbar {
184
+ width: 6px;
185
+ }
186
+ [data-copilotkit] ::-webkit-scrollbar-track {
187
+ background: transparent;
188
+ }
189
+ [data-copilotkit] ::-webkit-scrollbar-thumb {
190
+ background: oklch(0.5 0 0);
191
+ border-radius: 9999px;
192
+ }
193
+ [data-copilotkit] ::-webkit-scrollbar-thumb:hover {
194
+ background: oklch(0.4 0 0);
195
+ }
196
+
197
+ /* Firefox */
198
+ [data-copilotkit] * {
199
+ scrollbar-width: thin;
200
+ scrollbar-color: oklch(0.5 0 0) transparent;
201
+ }
202
+
203
+ [data-copilotkit] .prose input[type="checkbox"] {
204
+ appearance: none;
205
+ background-color: #fff;
206
+ background-origin: border-box;
207
+ border-color: #9b9b9b;
208
+ border-width: 1px;
209
+ color: #004f99;
210
+ display: inline-block;
211
+ flex-shrink: 0;
212
+ height: 1rem;
213
+ padding: 0;
214
+ -webkit-print-color-adjust: exact;
215
+ print-color-adjust: exact;
216
+ -webkit-user-select: none;
217
+ user-select: none;
218
+ vertical-align: middle;
219
+ width: 1rem;
220
+ border-radius: 2px;
221
+ }
222
+
223
+ [data-copilotkit] .prose input[type="checkbox"]:checked {
224
+ background-color: #004f99;
225
+ border-color: #004f99;
226
+ background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E");
227
+ background-position: center;
228
+ background-repeat: no-repeat;
229
+ background-size: 100% 100%;
230
+ }