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

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 +127 -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 @@
1
+ import "@testing-library/jest-dom";
@@ -0,0 +1,79 @@
1
+ export {
2
+ default as CopilotChatInput,
3
+ type CopilotChatInputProps,
4
+ type ToolsMenuItem,
5
+ } from "./CopilotChatInput";
6
+
7
+ export {
8
+ default as CopilotChatAssistantMessage,
9
+ type CopilotChatAssistantMessageProps,
10
+ } from "./CopilotChatAssistantMessage";
11
+
12
+ export {
13
+ default as CopilotChatUserMessage,
14
+ type CopilotChatUserMessageProps,
15
+ } from "./CopilotChatUserMessage";
16
+
17
+ export {
18
+ default as CopilotChatReasoningMessage,
19
+ type CopilotChatReasoningMessageProps,
20
+ } from "./CopilotChatReasoningMessage";
21
+
22
+ export {
23
+ CopilotChatAudioRecorder,
24
+ type AudioRecorderState,
25
+ AudioRecorderError,
26
+ } from "./CopilotChatAudioRecorder";
27
+
28
+ export {
29
+ default as CopilotChatSuggestionPill,
30
+ type CopilotChatSuggestionPillProps,
31
+ } from "./CopilotChatSuggestionPill";
32
+
33
+ export {
34
+ default as CopilotChatSuggestionView,
35
+ type CopilotChatSuggestionViewProps,
36
+ } from "./CopilotChatSuggestionView";
37
+
38
+ export {
39
+ default as CopilotChatMessageView,
40
+ type CopilotChatMessageViewProps,
41
+ } from "./CopilotChatMessageView";
42
+
43
+ export {
44
+ default as CopilotChatToolCallsView,
45
+ type CopilotChatToolCallsViewProps,
46
+ } from "./CopilotChatToolCallsView";
47
+
48
+ export {
49
+ default as CopilotChatView,
50
+ type CopilotChatViewProps,
51
+ } from "./CopilotChatView";
52
+
53
+ export { CopilotChat, type CopilotChatProps } from "./CopilotChat";
54
+
55
+ export {
56
+ CopilotChatToggleButton,
57
+ type CopilotChatToggleButtonProps,
58
+ CopilotChatToggleButtonOpenIcon,
59
+ CopilotChatToggleButtonCloseIcon,
60
+ } from "./CopilotChatToggleButton";
61
+
62
+ export {
63
+ CopilotSidebarView,
64
+ type CopilotSidebarViewProps,
65
+ } from "./CopilotSidebarView";
66
+
67
+ export {
68
+ CopilotPopupView,
69
+ type CopilotPopupViewProps,
70
+ } from "./CopilotPopupView";
71
+
72
+ export {
73
+ CopilotModalHeader,
74
+ type CopilotModalHeaderProps,
75
+ } from "./CopilotModalHeader";
76
+
77
+ export { CopilotSidebar, type CopilotSidebarProps } from "./CopilotSidebar";
78
+
79
+ export { CopilotPopup, type CopilotPopupProps } from "./CopilotPopup";
@@ -0,0 +1,7 @@
1
+ // React components for CopilotKit2
2
+ // Components will be added here
3
+
4
+ export * from "./chat";
5
+ export * from "./WildcardToolCallRender";
6
+ export * from "./CopilotKitInspector";
7
+ export * from "./MCPAppsActivityRenderer";
@@ -0,0 +1,198 @@
1
+ import React from "react";
2
+
3
+ interface LicenseWarningBannerProps {
4
+ type:
5
+ | "no_license"
6
+ | "expired"
7
+ | "expiring"
8
+ | "invalid"
9
+ | "feature_unlicensed";
10
+ featureName?: string;
11
+ expiryDate?: string;
12
+ graceRemaining?: number;
13
+ onDismiss?: () => void;
14
+ }
15
+
16
+ const BANNER_STYLES: Record<string, React.CSSProperties> = {
17
+ base: {
18
+ position: "fixed",
19
+ bottom: "8px",
20
+ left: "50%",
21
+ transform: "translateX(-50%)",
22
+ zIndex: 99999,
23
+ display: "inline-flex",
24
+ alignItems: "center",
25
+ gap: "12px",
26
+ whiteSpace: "nowrap",
27
+ padding: "8px 16px",
28
+ fontSize: "13px",
29
+ fontFamily:
30
+ "-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif",
31
+ borderRadius: "6px",
32
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
33
+ },
34
+ info: {
35
+ backgroundColor: "#eff6ff",
36
+ border: "1px solid #93c5fd",
37
+ color: "#1e40af",
38
+ },
39
+ warning: {
40
+ backgroundColor: "#fffbeb",
41
+ border: "1px solid #fbbf24",
42
+ color: "#92400e",
43
+ },
44
+ critical: {
45
+ backgroundColor: "#fef2f2",
46
+ border: "1px solid #fca5a5",
47
+ color: "#991b1b",
48
+ },
49
+ };
50
+
51
+ function getSeverityStyle(severity: string): React.CSSProperties {
52
+ switch (severity) {
53
+ case "warning":
54
+ return BANNER_STYLES.warning;
55
+ case "critical":
56
+ return BANNER_STYLES.critical;
57
+ default:
58
+ return BANNER_STYLES.info;
59
+ }
60
+ }
61
+
62
+ function BannerShell({
63
+ severity,
64
+ message,
65
+ actionLabel,
66
+ actionUrl,
67
+ onDismiss,
68
+ }: {
69
+ severity: string;
70
+ message: string;
71
+ actionLabel: string;
72
+ actionUrl: string;
73
+ onDismiss?: () => void;
74
+ }) {
75
+ return (
76
+ <div style={{ ...BANNER_STYLES.base, ...getSeverityStyle(severity) }}>
77
+ <span>{message}</span>
78
+ <div style={{ display: "flex", gap: "8px", alignItems: "center" }}>
79
+ <a
80
+ href={actionUrl}
81
+ target="_blank"
82
+ rel="noopener noreferrer"
83
+ style={{
84
+ fontWeight: 600,
85
+ textDecoration: "underline",
86
+ color: "inherit",
87
+ }}
88
+ >
89
+ {actionLabel}
90
+ </a>
91
+ {onDismiss && (
92
+ <button
93
+ onClick={onDismiss}
94
+ style={{
95
+ background: "none",
96
+ border: "none",
97
+ cursor: "pointer",
98
+ color: "inherit",
99
+ fontSize: "16px",
100
+ }}
101
+ >
102
+ ×
103
+ </button>
104
+ )}
105
+ </div>
106
+ </div>
107
+ );
108
+ }
109
+
110
+ export function LicenseWarningBanner({
111
+ type,
112
+ featureName,
113
+ expiryDate,
114
+ graceRemaining,
115
+ onDismiss,
116
+ }: LicenseWarningBannerProps) {
117
+ switch (type) {
118
+ case "no_license":
119
+ return (
120
+ <BannerShell
121
+ severity="info"
122
+ message="Powered by CopilotKit"
123
+ actionLabel="Get a license"
124
+ actionUrl="https://copilotkit.ai/pricing"
125
+ onDismiss={onDismiss}
126
+ />
127
+ );
128
+ case "feature_unlicensed":
129
+ return (
130
+ <BannerShell
131
+ severity="warning"
132
+ message={`⚠ The "${featureName}" feature requires a CopilotKit license.`}
133
+ actionLabel="Get a license"
134
+ actionUrl="https://copilotkit.ai/pricing"
135
+ onDismiss={onDismiss}
136
+ />
137
+ );
138
+ case "expiring":
139
+ return (
140
+ <BannerShell
141
+ severity="warning"
142
+ message={`Your CopilotKit license expires in ${graceRemaining} day${graceRemaining !== 1 ? "s" : ""}. Please renew.`}
143
+ actionLabel="Renew"
144
+ actionUrl="https://cloud.copilotkit.ai"
145
+ onDismiss={onDismiss}
146
+ />
147
+ );
148
+ case "expired":
149
+ return (
150
+ <BannerShell
151
+ severity="critical"
152
+ message={`Your CopilotKit license expired${expiryDate ? ` on ${expiryDate}` : ""}. Please renew at copilotkit.ai/pricing`}
153
+ actionLabel="Renew now"
154
+ actionUrl="https://copilotkit.ai/pricing"
155
+ onDismiss={onDismiss}
156
+ />
157
+ );
158
+ case "invalid":
159
+ return (
160
+ <BannerShell
161
+ severity="critical"
162
+ message="Invalid CopilotKit license token. Please check your configuration."
163
+ actionLabel="Get a license"
164
+ actionUrl="https://copilotkit.ai/pricing"
165
+ onDismiss={onDismiss}
166
+ />
167
+ );
168
+ default:
169
+ return null;
170
+ }
171
+ }
172
+
173
+ export function InlineFeatureWarning({ featureName }: { featureName: string }) {
174
+ return (
175
+ <div
176
+ style={{
177
+ padding: "8px 12px",
178
+ backgroundColor: "#fffbeb",
179
+ border: "1px solid #fbbf24",
180
+ borderRadius: "6px",
181
+ fontSize: "13px",
182
+ color: "#92400e",
183
+ fontFamily:
184
+ "-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif",
185
+ }}
186
+ >
187
+ ⚠ The &quot;{featureName}&quot; feature requires a CopilotKit license.{" "}
188
+ <a
189
+ href="https://copilotkit.ai/pricing"
190
+ target="_blank"
191
+ rel="noopener noreferrer"
192
+ style={{ color: "#b45309", textDecoration: "underline" }}
193
+ >
194
+ Get one at copilotkit.ai/pricing
195
+ </a>
196
+ </div>
197
+ );
198
+ }
@@ -0,0 +1,123 @@
1
+ import * as React from "react";
2
+ import { Slot } from "@radix-ui/react-slot";
3
+ import { cva, type VariantProps } from "class-variance-authority";
4
+
5
+ import { cn } from "../../lib/utils";
6
+
7
+ const buttonVariants = cva(
8
+ "cpk:inline-flex cpk:items-center cpk:justify-center cpk:gap-2 cpk:whitespace-nowrap cpk:rounded-md cpk:text-sm cpk:font-medium cpk:transition-all cpk:disabled:pointer-events-none cpk:disabled:opacity-50 cpk:[&_svg]:pointer-events-none cpk:[&_svg:not([class*='size-'])]:size-4 cpk:shrink-0 cpk:[&_svg]:shrink-0 cpk:outline-none cpk:focus-visible:border-ring cpk:focus-visible:ring-ring/50 cpk:focus-visible:ring-[3px] cpk:aria-invalid:ring-destructive/20 cpk:dark:aria-invalid:ring-destructive/40 cpk:aria-invalid:border-destructive",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default:
13
+ "cpk:bg-primary cpk:text-primary-foreground cpk:shadow-xs cpk:hover:bg-primary/90",
14
+ destructive:
15
+ "cpk:bg-destructive cpk:text-white cpk:shadow-xs cpk:hover:bg-destructive/90 cpk:focus-visible:ring-destructive/20 cpk:dark:focus-visible:ring-destructive/40 cpk:dark:bg-destructive/60",
16
+ outline:
17
+ "cpk:border cpk:bg-background cpk:shadow-xs cpk:hover:bg-accent cpk:hover:text-accent-foreground cpk:dark:bg-input/30 cpk:dark:border-input cpk:dark:hover:bg-input/50",
18
+ secondary:
19
+ "cpk:bg-secondary cpk:text-secondary-foreground cpk:shadow-xs cpk:hover:bg-secondary/80",
20
+ ghost:
21
+ "cpk:hover:bg-accent cpk:hover:text-accent-foreground cpk:dark:hover:bg-accent/50 cpk:cursor-pointer",
22
+ link: "cpk:text-primary cpk:underline-offset-4 cpk:hover:underline",
23
+ assistantMessageToolbarButton: [
24
+ "cpk:cursor-pointer",
25
+ // Background and text
26
+ "cpk:p-0 cpk:text-[rgb(93,93,93)] cpk:hover:bg-[#E8E8E8]",
27
+ // Dark mode - lighter gray for better contrast
28
+ "cpk:dark:text-[rgb(243,243,243)] cpk:dark:hover:bg-[#303030]",
29
+ // Shape and sizing
30
+ "cpk:h-8 cpk:w-8",
31
+ // Interactions
32
+ "cpk:transition-colors",
33
+ // Hover states
34
+ "cpk:hover:text-[rgb(93,93,93)]",
35
+ "cpk:dark:hover:text-[rgb(243,243,243)]",
36
+ ],
37
+ chatInputToolbarPrimary: [
38
+ "cpk:cursor-pointer",
39
+ // Background and text
40
+ "cpk:bg-black cpk:text-white",
41
+ // Dark mode
42
+ "cpk:dark:bg-white cpk:dark:text-black cpk:dark:focus-visible:outline-white",
43
+ // Shape and sizing
44
+ "cpk:rounded-full",
45
+ // Interactions
46
+ "cpk:transition-colors",
47
+ // Focus states
48
+ "cpk:focus:outline-none",
49
+ // Hover states
50
+ "cpk:hover:opacity-70 cpk:disabled:hover:opacity-100",
51
+ // Disabled states
52
+ "cpk:disabled:cursor-not-allowed cpk:disabled:bg-[#00000014] cpk:disabled:text-[rgb(13,13,13)]",
53
+ "cpk:dark:disabled:bg-[#454545] cpk:dark:disabled:text-white ",
54
+ ],
55
+ chatInputToolbarSecondary: [
56
+ "cpk:cursor-pointer",
57
+ // Background and text
58
+ "cpk:bg-transparent cpk:text-[#444444]",
59
+ // Dark mode
60
+ "cpk:dark:text-white cpk:dark:border-[#404040]",
61
+ // Shape and sizing
62
+ "cpk:rounded-full",
63
+ // Interactions
64
+ "cpk:transition-colors",
65
+ // Focus states
66
+ "cpk:focus:outline-none",
67
+ // Hover states
68
+ "cpk:hover:bg-[#f8f8f8] cpk:hover:text-[#333333]",
69
+ "cpk:dark:hover:bg-[#404040] cpk:dark:hover:text-[#FFFFFF]",
70
+ // Disabled states
71
+ "cpk:disabled:cursor-not-allowed cpk:disabled:opacity-50",
72
+ "cpk:disabled:hover:bg-transparent cpk:disabled:hover:text-[#444444]",
73
+ "cpk:dark:disabled:hover:bg-transparent cpk:dark:disabled:hover:text-[#CCCCCC]",
74
+ ],
75
+ },
76
+ size: {
77
+ default: "cpk:h-9 cpk:px-4 cpk:py-2 cpk:has-[>svg]:px-3",
78
+ sm: "cpk:h-8 cpk:rounded-md cpk:gap-1.5 cpk:px-3 cpk:has-[>svg]:px-2.5",
79
+ lg: "cpk:h-10 cpk:rounded-md cpk:px-6 cpk:has-[>svg]:px-4",
80
+ icon: "cpk:size-9",
81
+ chatInputToolbarIcon: [
82
+ // Shape and sizing
83
+ "cpk:h-9 cpk:w-9 cpk:rounded-full",
84
+ ],
85
+ chatInputToolbarIconLabel: [
86
+ // Shape and sizing
87
+ "cpk:h-9 cpk:px-3 cpk:rounded-full",
88
+ // Layout
89
+ "cpk:gap-2",
90
+ // Typography
91
+ "cpk:font-normal",
92
+ ],
93
+ },
94
+ },
95
+ defaultVariants: {
96
+ variant: "default",
97
+ size: "default",
98
+ },
99
+ },
100
+ );
101
+
102
+ function Button({
103
+ className,
104
+ variant,
105
+ size,
106
+ asChild = false,
107
+ ...props
108
+ }: React.ComponentProps<"button"> &
109
+ VariantProps<typeof buttonVariants> & {
110
+ asChild?: boolean;
111
+ }) {
112
+ const Comp = asChild ? Slot : "button";
113
+
114
+ return (
115
+ <Comp
116
+ data-slot="button"
117
+ className={cn(buttonVariants({ variant, size, className }))}
118
+ {...props}
119
+ />
120
+ );
121
+ }
122
+
123
+ export { Button, buttonVariants };
@@ -0,0 +1,258 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
5
+ import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
6
+
7
+ import { cn } from "../../lib/utils";
8
+
9
+ function DropdownMenu({
10
+ ...props
11
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
12
+ return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
13
+ }
14
+
15
+ function DropdownMenuPortal({
16
+ ...props
17
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
18
+ return (
19
+ <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
20
+ );
21
+ }
22
+
23
+ function DropdownMenuTrigger({
24
+ ...props
25
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
26
+ return (
27
+ <DropdownMenuPrimitive.Trigger
28
+ data-slot="dropdown-menu-trigger"
29
+ {...props}
30
+ />
31
+ );
32
+ }
33
+
34
+ function DropdownMenuContent({
35
+ className,
36
+ sideOffset = 4,
37
+ ...props
38
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
39
+ return (
40
+ <DropdownMenuPrimitive.Portal>
41
+ <DropdownMenuPrimitive.Content
42
+ data-copilotkit
43
+ data-slot="dropdown-menu-content"
44
+ sideOffset={sideOffset}
45
+ className={cn(
46
+ "cpk:bg-popover cpk:text-popover-foreground cpk:data-[state=open]:animate-in cpk:data-[state=closed]:animate-out cpk:data-[state=closed]:fade-out-0 cpk:data-[state=open]:fade-in-0 cpk:data-[state=closed]:zoom-out-95 cpk:data-[state=open]:zoom-in-95 cpk:data-[side=bottom]:slide-in-from-top-2 cpk:data-[side=left]:slide-in-from-right-2 cpk:data-[side=right]:slide-in-from-left-2 cpk:data-[side=top]:slide-in-from-bottom-2 cpk:z-50 cpk:max-h-(--radix-dropdown-menu-content-available-height) cpk:min-w-[8rem] cpk:origin-(--radix-dropdown-menu-content-transform-origin) cpk:overflow-x-hidden cpk:overflow-y-auto cpk:rounded-md cpk:border cpk:p-1 cpk:shadow-md",
47
+ className,
48
+ )}
49
+ {...props}
50
+ />
51
+ </DropdownMenuPrimitive.Portal>
52
+ );
53
+ }
54
+
55
+ function DropdownMenuGroup({
56
+ ...props
57
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
58
+ return (
59
+ <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
60
+ );
61
+ }
62
+
63
+ function DropdownMenuItem({
64
+ className,
65
+ inset,
66
+ variant = "default",
67
+ ...props
68
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
69
+ inset?: boolean;
70
+ variant?: "default" | "destructive";
71
+ }) {
72
+ return (
73
+ <DropdownMenuPrimitive.Item
74
+ data-slot="dropdown-menu-item"
75
+ data-inset={inset}
76
+ data-variant={variant}
77
+ className={cn(
78
+ "cpk:focus:bg-accent cpk:focus:text-accent-foreground cpk:data-[variant=destructive]:text-destructive cpk:data-[variant=destructive]:focus:bg-destructive/10 cpk:dark:data-[variant=destructive]:focus:bg-destructive/20 cpk:data-[variant=destructive]:focus:text-destructive cpk:data-[variant=destructive]:*:[svg]:!text-destructive cpk:[&_svg:not([class*='text-'])]:text-muted-foreground cpk:relative cpk:flex cpk:cursor-default cpk:items-center cpk:gap-2 cpk:rounded-sm cpk:px-2 cpk:py-1.5 cpk:text-sm cpk:outline-hidden cpk:select-none cpk:data-[disabled]:pointer-events-none cpk:data-[disabled]:opacity-50 cpk:data-[inset]:pl-8 cpk:[&_svg]:pointer-events-none cpk:[&_svg]:shrink-0 cpk:[&_svg:not([class*='size-'])]:size-4",
79
+ className,
80
+ )}
81
+ {...props}
82
+ />
83
+ );
84
+ }
85
+
86
+ function DropdownMenuCheckboxItem({
87
+ className,
88
+ children,
89
+ checked,
90
+ ...props
91
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
92
+ return (
93
+ <DropdownMenuPrimitive.CheckboxItem
94
+ data-slot="dropdown-menu-checkbox-item"
95
+ className={cn(
96
+ "cpk:focus:bg-accent cpk:focus:text-accent-foreground cpk:relative cpk:flex cpk:cursor-default cpk:items-center cpk:gap-2 cpk:rounded-sm cpk:py-1.5 cpk:pr-2 cpk:pl-8 cpk:text-sm cpk:outline-hidden cpk:select-none cpk:data-[disabled]:pointer-events-none cpk:data-[disabled]:opacity-50 cpk:[&_svg]:pointer-events-none cpk:[&_svg]:shrink-0 cpk:[&_svg:not([class*='size-'])]:size-4",
97
+ className,
98
+ )}
99
+ checked={checked}
100
+ {...props}
101
+ >
102
+ <span className="cpk:pointer-events-none cpk:absolute cpk:left-2 cpk:flex cpk:size-3.5 cpk:items-center cpk:justify-center">
103
+ <DropdownMenuPrimitive.ItemIndicator>
104
+ <CheckIcon className="cpk:size-4" />
105
+ </DropdownMenuPrimitive.ItemIndicator>
106
+ </span>
107
+ {children}
108
+ </DropdownMenuPrimitive.CheckboxItem>
109
+ );
110
+ }
111
+
112
+ function DropdownMenuRadioGroup({
113
+ ...props
114
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
115
+ return (
116
+ <DropdownMenuPrimitive.RadioGroup
117
+ data-slot="dropdown-menu-radio-group"
118
+ {...props}
119
+ />
120
+ );
121
+ }
122
+
123
+ function DropdownMenuRadioItem({
124
+ className,
125
+ children,
126
+ ...props
127
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
128
+ return (
129
+ <DropdownMenuPrimitive.RadioItem
130
+ data-slot="dropdown-menu-radio-item"
131
+ className={cn(
132
+ "cpk:focus:bg-accent cpk:focus:text-accent-foreground cpk:relative cpk:flex cpk:cursor-default cpk:items-center cpk:gap-2 cpk:rounded-sm cpk:py-1.5 cpk:pr-2 cpk:pl-8 cpk:text-sm cpk:outline-hidden cpk:select-none cpk:data-[disabled]:pointer-events-none cpk:data-[disabled]:opacity-50 cpk:[&_svg]:pointer-events-none cpk:[&_svg]:shrink-0 cpk:[&_svg:not([class*='size-'])]:size-4",
133
+ className,
134
+ )}
135
+ {...props}
136
+ >
137
+ <span className="cpk:pointer-events-none cpk:absolute cpk:left-2 cpk:flex cpk:size-3.5 cpk:items-center cpk:justify-center">
138
+ <DropdownMenuPrimitive.ItemIndicator>
139
+ <CircleIcon className="cpk:size-2 cpk:fill-current" />
140
+ </DropdownMenuPrimitive.ItemIndicator>
141
+ </span>
142
+ {children}
143
+ </DropdownMenuPrimitive.RadioItem>
144
+ );
145
+ }
146
+
147
+ function DropdownMenuLabel({
148
+ className,
149
+ inset,
150
+ ...props
151
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
152
+ inset?: boolean;
153
+ }) {
154
+ return (
155
+ <DropdownMenuPrimitive.Label
156
+ data-slot="dropdown-menu-label"
157
+ data-inset={inset}
158
+ className={cn(
159
+ "cpk:px-2 cpk:py-1.5 cpk:text-sm cpk:font-medium cpk:data-[inset]:pl-8",
160
+ className,
161
+ )}
162
+ {...props}
163
+ />
164
+ );
165
+ }
166
+
167
+ function DropdownMenuSeparator({
168
+ className,
169
+ ...props
170
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
171
+ return (
172
+ <DropdownMenuPrimitive.Separator
173
+ data-slot="dropdown-menu-separator"
174
+ className={cn("cpk:bg-border cpk:-mx-1 cpk:my-1 cpk:h-px", className)}
175
+ {...props}
176
+ />
177
+ );
178
+ }
179
+
180
+ function DropdownMenuShortcut({
181
+ className,
182
+ ...props
183
+ }: React.ComponentProps<"span">) {
184
+ return (
185
+ <span
186
+ data-slot="dropdown-menu-shortcut"
187
+ className={cn(
188
+ "cpk:text-muted-foreground cpk:ml-auto cpk:text-xs cpk:tracking-widest",
189
+ className,
190
+ )}
191
+ {...props}
192
+ />
193
+ );
194
+ }
195
+
196
+ function DropdownMenuSub({
197
+ ...props
198
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
199
+ return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />;
200
+ }
201
+
202
+ function DropdownMenuSubTrigger({
203
+ className,
204
+ inset,
205
+ children,
206
+ ...props
207
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
208
+ inset?: boolean;
209
+ }) {
210
+ return (
211
+ <DropdownMenuPrimitive.SubTrigger
212
+ data-slot="dropdown-menu-sub-trigger"
213
+ data-inset={inset}
214
+ className={cn(
215
+ "cpk:focus:bg-accent cpk:focus:text-accent-foreground cpk:data-[state=open]:bg-accent cpk:data-[state=open]:text-accent-foreground cpk:flex cpk:cursor-default cpk:items-center cpk:rounded-sm cpk:px-2 cpk:py-1.5 cpk:text-sm cpk:outline-hidden cpk:select-none cpk:data-[inset]:pl-8",
216
+ className,
217
+ )}
218
+ {...props}
219
+ >
220
+ {children}
221
+ <ChevronRightIcon className="cpk:ml-auto cpk:size-4" />
222
+ </DropdownMenuPrimitive.SubTrigger>
223
+ );
224
+ }
225
+
226
+ function DropdownMenuSubContent({
227
+ className,
228
+ ...props
229
+ }: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
230
+ return (
231
+ <DropdownMenuPrimitive.SubContent
232
+ data-slot="dropdown-menu-sub-content"
233
+ className={cn(
234
+ "cpk:bg-popover cpk:text-popover-foreground cpk:data-[state=open]:animate-in cpk:data-[state=closed]:animate-out cpk:data-[state=closed]:fade-out-0 cpk:data-[state=open]:fade-in-0 cpk:data-[state=closed]:zoom-out-95 cpk:data-[state=open]:zoom-in-95 cpk:data-[side=bottom]:slide-in-from-top-2 cpk:data-[side=left]:slide-in-from-right-2 cpk:data-[side=right]:slide-in-from-left-2 cpk:data-[side=top]:slide-in-from-bottom-2 cpk:z-50 cpk:min-w-[8rem] cpk:origin-(--radix-dropdown-menu-content-transform-origin) cpk:overflow-hidden cpk:rounded-md cpk:border cpk:p-1 cpk:shadow-lg",
235
+ className,
236
+ )}
237
+ {...props}
238
+ />
239
+ );
240
+ }
241
+
242
+ export {
243
+ DropdownMenu,
244
+ DropdownMenuPortal,
245
+ DropdownMenuTrigger,
246
+ DropdownMenuContent,
247
+ DropdownMenuGroup,
248
+ DropdownMenuLabel,
249
+ DropdownMenuItem,
250
+ DropdownMenuCheckboxItem,
251
+ DropdownMenuRadioGroup,
252
+ DropdownMenuRadioItem,
253
+ DropdownMenuSeparator,
254
+ DropdownMenuShortcut,
255
+ DropdownMenuSub,
256
+ DropdownMenuSubTrigger,
257
+ DropdownMenuSubContent,
258
+ };