@copilotkit/react-ui 1.1.3-feat-runtime-remote-actions.2 → 1.2.1

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 (212) hide show
  1. package/CHANGELOG.md +21 -19
  2. package/dist/components/chat/Button.d.mts +7 -0
  3. package/dist/components/chat/Button.js.map +1 -1
  4. package/dist/components/chat/Button.mjs +30 -6
  5. package/dist/components/chat/Button.mjs.map +1 -1
  6. package/dist/components/chat/Chat.d.mts +87 -0
  7. package/dist/components/chat/Chat.d.ts +2 -2
  8. package/dist/components/chat/Chat.js +8 -107
  9. package/dist/components/chat/Chat.js.map +1 -1
  10. package/dist/components/chat/Chat.mjs +1754 -20
  11. package/dist/components/chat/Chat.mjs.map +1 -1
  12. package/dist/components/chat/ChatContext.d.mts +105 -0
  13. package/dist/components/chat/ChatContext.d.ts +1 -1
  14. package/dist/components/chat/ChatContext.mjs +228 -7
  15. package/dist/components/chat/ChatContext.mjs.map +1 -1
  16. package/dist/components/chat/CodeBlock.d.mts +14 -0
  17. package/dist/components/chat/CodeBlock.js +1 -2
  18. package/dist/components/chat/CodeBlock.js.map +1 -1
  19. package/dist/components/chat/CodeBlock.mjs +482 -8
  20. package/dist/components/chat/CodeBlock.mjs.map +1 -1
  21. package/dist/components/chat/Header.d.mts +7 -0
  22. package/dist/components/chat/Header.mjs +23 -6
  23. package/dist/components/chat/Header.mjs.map +1 -1
  24. package/dist/components/chat/Icons.d.mts +18 -0
  25. package/dist/components/chat/Icons.mjs +271 -16
  26. package/dist/components/chat/Icons.mjs.map +1 -1
  27. package/dist/components/chat/Input.d.mts +7 -0
  28. package/dist/components/chat/Input.js +2 -4
  29. package/dist/components/chat/Input.js.map +1 -1
  30. package/dist/components/chat/Input.mjs +255 -8
  31. package/dist/components/chat/Input.mjs.map +1 -1
  32. package/dist/components/chat/Markdown.d.mts +8 -0
  33. package/dist/components/chat/Markdown.js +1 -2
  34. package/dist/components/chat/Markdown.js.map +1 -1
  35. package/dist/components/chat/Markdown.mjs +546 -7
  36. package/dist/components/chat/Markdown.mjs.map +1 -1
  37. package/dist/components/chat/Messages.d.mts +7 -0
  38. package/dist/components/chat/Messages.js +3 -48
  39. package/dist/components/chat/Messages.js.map +1 -1
  40. package/dist/components/chat/Messages.mjs +678 -8
  41. package/dist/components/chat/Messages.mjs.map +1 -1
  42. package/dist/components/chat/Modal.d.mts +51 -0
  43. package/dist/components/chat/Modal.d.ts +1 -1
  44. package/dist/components/chat/Modal.js +9 -107
  45. package/dist/components/chat/Modal.js.map +1 -1
  46. package/dist/components/chat/Modal.mjs +1956 -22
  47. package/dist/components/chat/Modal.mjs.map +1 -1
  48. package/dist/components/chat/Popup.d.mts +13 -0
  49. package/dist/components/chat/Popup.js +9 -107
  50. package/dist/components/chat/Popup.js.map +1 -1
  51. package/dist/components/chat/Popup.mjs +1965 -23
  52. package/dist/components/chat/Popup.mjs.map +1 -1
  53. package/dist/components/chat/Response.d.mts +7 -0
  54. package/dist/components/chat/Response.mjs +23 -6
  55. package/dist/components/chat/Response.mjs.map +1 -1
  56. package/dist/components/chat/Sidebar.d.mts +13 -0
  57. package/dist/components/chat/Sidebar.js +10 -107
  58. package/dist/components/chat/Sidebar.js.map +1 -1
  59. package/dist/components/chat/Sidebar.mjs +1977 -23
  60. package/dist/components/chat/Sidebar.mjs.map +1 -1
  61. package/dist/components/chat/Suggestion.d.mts +14 -0
  62. package/dist/components/chat/Suggestion.js.map +1 -1
  63. package/dist/components/chat/Suggestion.mjs +152 -5
  64. package/dist/components/chat/Suggestion.mjs.map +1 -1
  65. package/dist/components/chat/Textarea.d.mts +13 -0
  66. package/dist/components/chat/Textarea.js.map +1 -1
  67. package/dist/components/chat/Textarea.mjs +48 -4
  68. package/dist/components/chat/Textarea.mjs.map +1 -1
  69. package/dist/components/chat/Window.d.mts +7 -0
  70. package/dist/components/chat/Window.js.map +1 -1
  71. package/dist/components/chat/Window.mjs +125 -6
  72. package/dist/components/chat/Window.mjs.map +1 -1
  73. package/dist/components/chat/index.d.mts +11 -0
  74. package/dist/components/chat/index.js +10 -107
  75. package/dist/components/chat/index.js.map +1 -1
  76. package/dist/components/chat/index.mjs +1983 -31
  77. package/dist/components/chat/index.mjs.map +1 -1
  78. package/dist/components/chat/props.d.mts +35 -0
  79. package/dist/components/chat/props.d.ts +1 -1
  80. package/dist/components/chat/props.mjs +0 -1
  81. package/dist/components/dev-console/console.d.mts +10 -0
  82. package/dist/components/dev-console/console.js +0 -52
  83. package/dist/components/dev-console/console.js.map +1 -1
  84. package/dist/components/dev-console/console.mjs +426 -8
  85. package/dist/components/dev-console/console.mjs.map +1 -1
  86. package/dist/components/dev-console/icons.d.mts +9 -0
  87. package/dist/components/dev-console/icons.mjs +83 -8
  88. package/dist/components/dev-console/icons.mjs.map +1 -1
  89. package/dist/components/dev-console/index.d.mts +5 -0
  90. package/dist/components/dev-console/index.js +0 -52
  91. package/dist/components/dev-console/index.js.map +1 -1
  92. package/dist/components/dev-console/index.mjs +424 -10
  93. package/dist/components/dev-console/index.mjs.map +1 -1
  94. package/dist/components/dev-console/types.d.mts +9 -0
  95. package/dist/components/dev-console/types.d.ts +1 -1
  96. package/dist/components/dev-console/utils.d.mts +9 -0
  97. package/dist/components/dev-console/utils.d.ts +1 -2
  98. package/dist/components/dev-console/utils.js +0 -53
  99. package/dist/components/dev-console/utils.js.map +1 -1
  100. package/dist/components/dev-console/utils.mjs +103 -9
  101. package/dist/components/dev-console/utils.mjs.map +1 -1
  102. package/dist/components/index.d.mts +11 -0
  103. package/dist/components/index.js +10 -107
  104. package/dist/components/index.js.map +1 -1
  105. package/dist/components/index.mjs +1983 -32
  106. package/dist/components/index.mjs.map +1 -1
  107. package/dist/context/index.d.mts +2 -0
  108. package/dist/context/index.d.ts +1 -1
  109. package/dist/context/index.mjs +0 -1
  110. package/dist/hooks/index.d.mts +1 -0
  111. package/dist/hooks/index.mjs +24 -5
  112. package/dist/hooks/index.mjs.map +1 -1
  113. package/dist/hooks/use-copilot-chat-suggestions.d.mts +83 -0
  114. package/dist/hooks/use-copilot-chat-suggestions.mjs +24 -4
  115. package/dist/hooks/use-copilot-chat-suggestions.mjs.map +1 -1
  116. package/dist/hooks/use-copy-to-clipboard.d.mts +9 -0
  117. package/dist/hooks/use-copy-to-clipboard.d.ts +1 -1
  118. package/dist/hooks/use-copy-to-clipboard.mjs +21 -4
  119. package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -1
  120. package/dist/hooks/use-push-to-talk.d.mts +19 -0
  121. package/dist/hooks/use-push-to-talk.d.ts +1 -1
  122. package/dist/hooks/use-push-to-talk.js.map +1 -1
  123. package/dist/hooks/use-push-to-talk.mjs +148 -6
  124. package/dist/hooks/use-push-to-talk.mjs.map +1 -1
  125. package/dist/index.css +1 -747
  126. package/dist/index.d.mts +13 -0
  127. package/dist/index.js +17 -107
  128. package/dist/index.js.map +1 -1
  129. package/dist/index.mjs +2015 -38
  130. package/dist/index.mjs.map +1 -1
  131. package/dist/lib/utils.d.mts +4 -0
  132. package/dist/lib/utils.mjs +20 -3
  133. package/dist/lib/utils.mjs.map +1 -1
  134. package/dist/lib/utils.test.d.mts +2 -0
  135. package/dist/lib/utils.test.d.ts +1 -1
  136. package/dist/types/css.d.mts +16 -0
  137. package/dist/types/css.d.ts +1 -1
  138. package/dist/types/index.d.mts +2 -0
  139. package/dist/types/index.mjs +0 -1
  140. package/dist/types/suggestions.d.mts +8 -0
  141. package/dist/types/suggestions.d.ts +1 -1
  142. package/package.json +19 -11
  143. package/src/components/chat/Chat.tsx +2 -5
  144. package/src/components/chat/Messages.tsx +2 -83
  145. package/src/components/chat/Modal.tsx +1 -0
  146. package/src/components/chat/Popup.tsx +1 -4
  147. package/src/components/chat/Sidebar.tsx +2 -3
  148. package/src/components/chat/Suggestion.tsx +0 -2
  149. package/src/components/dev-console/console.tsx +0 -6
  150. package/src/components/dev-console/utils.ts +0 -56
  151. package/tsup.config.ts +59 -15
  152. package/dist/chunk-54JAUBUJ.mjs +0 -26
  153. package/dist/chunk-54JAUBUJ.mjs.map +0 -1
  154. package/dist/chunk-5HHVL5WK.mjs +0 -29
  155. package/dist/chunk-5HHVL5WK.mjs.map +0 -1
  156. package/dist/chunk-B2KQEX2R.mjs +0 -91
  157. package/dist/chunk-B2KQEX2R.mjs.map +0 -1
  158. package/dist/chunk-BJPGMY3I.mjs +0 -70
  159. package/dist/chunk-BJPGMY3I.mjs.map +0 -1
  160. package/dist/chunk-EFZPSZWO.mjs +0 -1
  161. package/dist/chunk-EFZPSZWO.mjs.map +0 -1
  162. package/dist/chunk-FL4ETWFB.mjs +0 -21
  163. package/dist/chunk-FL4ETWFB.mjs.map +0 -1
  164. package/dist/chunk-FLV3J3VX.mjs +0 -18
  165. package/dist/chunk-FLV3J3VX.mjs.map +0 -1
  166. package/dist/chunk-FO7Z5LAL.mjs +0 -118
  167. package/dist/chunk-FO7Z5LAL.mjs.map +0 -1
  168. package/dist/chunk-FOZVHL73.mjs +0 -171
  169. package/dist/chunk-FOZVHL73.mjs.map +0 -1
  170. package/dist/chunk-FZC7X5PK.mjs +0 -262
  171. package/dist/chunk-FZC7X5PK.mjs.map +0 -1
  172. package/dist/chunk-H7TM5JE6.mjs +0 -146
  173. package/dist/chunk-H7TM5JE6.mjs.map +0 -1
  174. package/dist/chunk-HR36Y2FQ.mjs +0 -167
  175. package/dist/chunk-HR36Y2FQ.mjs.map +0 -1
  176. package/dist/chunk-I4QG2ZZU.mjs +0 -220
  177. package/dist/chunk-I4QG2ZZU.mjs.map +0 -1
  178. package/dist/chunk-IU3WTXLQ.mjs +0 -1
  179. package/dist/chunk-IU3WTXLQ.mjs.map +0 -1
  180. package/dist/chunk-JD7BAH7U.mjs +0 -1
  181. package/dist/chunk-JD7BAH7U.mjs.map +0 -1
  182. package/dist/chunk-MRFF7GSQ.mjs +0 -1
  183. package/dist/chunk-MRFF7GSQ.mjs.map +0 -1
  184. package/dist/chunk-MRXNTQOX.mjs +0 -59
  185. package/dist/chunk-MRXNTQOX.mjs.map +0 -1
  186. package/dist/chunk-OTPAZXVR.mjs +0 -92
  187. package/dist/chunk-OTPAZXVR.mjs.map +0 -1
  188. package/dist/chunk-QOEAEMUQ.mjs +0 -30
  189. package/dist/chunk-QOEAEMUQ.mjs.map +0 -1
  190. package/dist/chunk-T26KLXLH.mjs +0 -1
  191. package/dist/chunk-T26KLXLH.mjs.map +0 -1
  192. package/dist/chunk-U6J5DGOE.mjs +0 -83
  193. package/dist/chunk-U6J5DGOE.mjs.map +0 -1
  194. package/dist/chunk-UPTB2MVO.mjs +0 -395
  195. package/dist/chunk-UPTB2MVO.mjs.map +0 -1
  196. package/dist/chunk-V7W6IM2V.mjs +0 -1
  197. package/dist/chunk-V7W6IM2V.mjs.map +0 -1
  198. package/dist/chunk-VOBX4JOA.mjs +0 -138
  199. package/dist/chunk-VOBX4JOA.mjs.map +0 -1
  200. package/dist/chunk-WB3YULQ4.mjs +0 -1
  201. package/dist/chunk-WB3YULQ4.mjs.map +0 -1
  202. package/dist/chunk-WCPLXRZX.mjs +0 -106
  203. package/dist/chunk-WCPLXRZX.mjs.map +0 -1
  204. package/dist/chunk-XSUSSWDS.mjs +0 -18
  205. package/dist/chunk-XSUSSWDS.mjs.map +0 -1
  206. package/dist/chunk-YOH25I6N.mjs +0 -25
  207. package/dist/chunk-YOH25I6N.mjs.map +0 -1
  208. package/dist/chunk-YQ3D5IQV.mjs +0 -75
  209. package/dist/chunk-YQ3D5IQV.mjs.map +0 -1
  210. package/dist/chunk-YQFVRDNC.mjs +0 -53
  211. package/dist/chunk-YQFVRDNC.mjs.map +0 -1
  212. package/dist/index.css.map +0 -1
@@ -17,7 +17,6 @@
17
17
  *
18
18
  * ```tsx
19
19
  * import { CopilotChat } from "@copilotkit/react-ui";
20
- * import "@copilotkit/react-ui/styles.css";
21
20
  *
22
21
  * <CopilotChat
23
22
  * labels={{
@@ -30,10 +29,8 @@
30
29
  * ### Look & Feel
31
30
  *
32
31
  * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
33
- * ```tsx fileName="YourRootComponent.tsx" {2}
32
+ * ```tsx fileName="YourRootComponent.tsx"
34
33
  * ...
35
- * import "@copilotkit/react-ui/styles.css";
36
- *
37
34
  * export function YourRootComponent() {
38
35
  * return (
39
36
  * <CopilotKit>
@@ -230,7 +227,7 @@ const SUGGESTIONS_DEBOUNCE_TIMEOUT = 1000;
230
227
  export const useCopilotChatLogic = (
231
228
  makeSystemMessage?: SystemMessageFunction,
232
229
  onInProgress?: (isLoading: boolean) => void,
233
- onSubmitMessage?: (messageContent: string) => Promise<void> | void,
230
+ onSubmitMessage?: (messageContent: string) => void,
234
231
  ) => {
235
232
  const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } =
236
233
  useCopilotChat({
@@ -10,9 +10,7 @@ import {
10
10
  ResultMessage,
11
11
  TextMessage,
12
12
  Role,
13
- AgentStateMessage,
14
13
  } from "@copilotkit/runtime-client-gql";
15
- import { CoagentInChatRenderFunction } from "@copilotkit/react-core/dist/context/copilot-context";
16
14
 
17
15
  export const Messages = ({ messages, inProgress, children }: MessagesProps) => {
18
16
  const { chatComponentsCache } = useCopilotContext();
@@ -75,11 +73,8 @@ export const Messages = ({ messages, inProgress, children }: MessagesProps) => {
75
73
  </div>
76
74
  );
77
75
  } else if (message instanceof ActionExecutionMessage) {
78
- if (
79
- chatComponentsCache.current !== null &&
80
- chatComponentsCache.current.actions[message.name]
81
- ) {
82
- const render = chatComponentsCache.current.actions[message.name];
76
+ if (chatComponentsCache.current !== null && chatComponentsCache.current[message.name]) {
77
+ const render = chatComponentsCache.current[message.name];
83
78
  // render a static string
84
79
  if (typeof render === "string") {
85
80
  // when render is static, we show it only when in progress
@@ -145,82 +140,6 @@ export const Messages = ({ messages, inProgress, children }: MessagesProps) => {
145
140
  </div>
146
141
  );
147
142
  }
148
- } else if (message instanceof AgentStateMessage) {
149
- let render: string | CoagentInChatRenderFunction | undefined;
150
-
151
- if (chatComponentsCache.current !== null) {
152
- render =
153
- chatComponentsCache.current.coagentActions[
154
- `${message.agentName}-${message.nodeName}`
155
- ] || chatComponentsCache.current.coagentActions[`${message.agentName}-global`];
156
- }
157
-
158
- if (render) {
159
- // render a static string
160
- if (typeof render === "string") {
161
- // when render is static, we show it only when in progress
162
- if (isCurrentMessage && inProgress) {
163
- return (
164
- <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>
165
- {context.icons.spinnerIcon} <span className="inProgressLabel">{render}</span>
166
- </div>
167
- );
168
- }
169
- // Done - silent by default to avoid a series of "done" messages
170
- else {
171
- return null;
172
- }
173
- }
174
- // render is a function
175
- else {
176
- const state = message.state;
177
-
178
- let status = message.active ? "inProgress" : "complete";
179
-
180
- const toRender = render({
181
- status: status as any,
182
- state,
183
- nodeName: message.nodeName,
184
- });
185
-
186
- // No result and complete: stay silent
187
- if (!toRender && status === "complete") {
188
- return null;
189
- }
190
-
191
- if (typeof toRender === "string") {
192
- return (
193
- <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>
194
- {isCurrentMessage && inProgress && context.icons.spinnerIcon} {toRender}
195
- </div>
196
- );
197
- } else {
198
- return (
199
- <div key={index} className="copilotKitCustomAssistantMessage">
200
- {toRender}
201
- </div>
202
- );
203
- }
204
- }
205
- }
206
- // No render function found- show the default message
207
- else if (!inProgress || !isCurrentMessage) {
208
- // Done - silent by default to avoid a series of "done" messages
209
- return null;
210
- } else {
211
- // In progress
212
- return (
213
- <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>
214
- {context.icons.spinnerIcon}
215
- </div>
216
- );
217
- }
218
- } else if (message instanceof ResultMessage && inProgress && isCurrentMessage) {
219
- return (
220
- <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>
221
- {context.icons.spinnerIcon}
222
- </div>
223
- );
224
143
  }
225
144
  })}
226
145
  <footer ref={messagesEndRef}>{children}</footer>
@@ -81,6 +81,7 @@ export const CopilotModal = ({
81
81
  const [openState, setOpenState] = React.useState(defaultOpen);
82
82
 
83
83
  const setOpen = (open: boolean) => {
84
+ console.log("setOpen!!", open);
84
85
  onSetOpen?.(open);
85
86
  setOpenState(open);
86
87
  };
@@ -18,7 +18,6 @@
18
18
  *
19
19
  * ```tsx
20
20
  * import { CopilotPopup } from "@copilotkit/react-ui";
21
- * import "@copilotkit/react-ui/styles.css";
22
21
  *
23
22
  * <CopilotPopup
24
23
  * labels={{
@@ -31,10 +30,8 @@
31
30
  * ### Look & Feel
32
31
  *
33
32
  * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
34
- * ```tsx fileName="YourRootComponent.tsx" {2}
33
+ * ```tsx fileName="YourRootComponent.tsx"
35
34
  * ...
36
- * import "@copilotkit/react-ui/styles.css";
37
- *
38
35
  * export function YourRootComponent() {
39
36
  * return (
40
37
  * <CopilotKit>
@@ -18,7 +18,6 @@
18
18
  *
19
19
  * ```tsx
20
20
  * import { CopilotSidebar } from "@copilotkit/react-ui";
21
- * import "@copilotkit/react-ui/styles.css";
22
21
  *
23
22
  * <CopilotSidebar
24
23
  * labels={{
@@ -33,9 +32,8 @@
33
32
  * ### Look & Feel
34
33
  *
35
34
  * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
36
- * ```tsx fileName="YourRootComponent.tsx" {2}
35
+ * ```tsx fileName="YourRootComponent.tsx"
37
36
  * ...
38
- * import "@copilotkit/react-ui/styles.css";
39
37
  *
40
38
  * export function YourRootComponent() {
41
39
  * return (
@@ -60,6 +58,7 @@ export function CopilotSidebar(props: CopilotModalProps) {
60
58
  );
61
59
 
62
60
  const onSetOpen = (open: boolean) => {
61
+ console.log("onSetOpen", open);
63
62
  props.onSetOpen?.(open);
64
63
  setExpandedClassName(open ? "sidebarExpanded" : "");
65
64
  };
@@ -2,7 +2,6 @@ import {
2
2
  CopilotContextParams,
3
3
  extract,
4
4
  CopilotChatSuggestionConfiguration,
5
- useCopilotContext,
6
5
  } from "@copilotkit/react-core";
7
6
  import { SuggestionsProps } from "./props";
8
7
  import { SmallSpinnerIcon } from "./Icons";
@@ -51,7 +50,6 @@ export const reloadSuggestions = async (
51
50
  ? `Produce up to ${config.maxSuggestions} suggestions. ` +
52
51
  `If there are no highly relevant suggestions you can think of, provide an empty array.`
53
52
  : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;
54
-
55
53
  const result = await extract({
56
54
  context,
57
55
  instructions:
@@ -4,7 +4,6 @@ import { useCopilotContext } from "@copilotkit/react-core";
4
4
  import {
5
5
  getPublishedCopilotKitVersion,
6
6
  logActions,
7
- logMessages,
8
7
  logReadables,
9
8
  shouldShowDevConsole,
10
9
  } from "./utils";
@@ -251,11 +250,6 @@ export default function DebugMenuButton({
251
250
  Log Actions
252
251
  </button>
253
252
  </MenuItem>
254
- <MenuItem>
255
- <button className="copilotKitDebugMenuItem" onClick={() => logMessages(context)}>
256
- Log Messages
257
- </button>
258
- </MenuItem>
259
253
  <MenuItem>
260
254
  <button className="copilotKitDebugMenuItem" onClick={() => checkForUpdates(true)}>
261
255
  Check for Updates
@@ -1,7 +1,5 @@
1
1
  import { CopilotContextParams, defaultCopilotContextCategories } from "@copilotkit/react-core";
2
2
  import { CopilotKitVersion } from "./types";
3
- import { ActionExecutionMessage, ResultMessage, TextMessage } from "@copilotkit/runtime-client-gql";
4
- import { AgentStateMessage } from "@copilotkit/runtime-client-gql";
5
3
 
6
4
  export function shouldShowDevConsole(showDevConsole: boolean | "auto"): boolean {
7
5
  if (typeof showDevConsole === "boolean") {
@@ -80,8 +78,6 @@ export async function getPublishedCopilotKitVersion(
80
78
  }
81
79
 
82
80
  export function logReadables(context: CopilotContextParams) {
83
- console.log("%cCurrent Readables:", "font-size: 16px; font-weight: bold;");
84
-
85
81
  const readables = context.getContextString([], defaultCopilotContextCategories).trim();
86
82
  if (readables.length === 0) {
87
83
  console.log("No readables found");
@@ -91,8 +87,6 @@ export function logReadables(context: CopilotContextParams) {
91
87
  }
92
88
 
93
89
  export function logActions(context: CopilotContextParams) {
94
- console.log("%cCurrent Actions:", "font-size: 16px; font-weight: bold;");
95
-
96
90
  if (Object.values(context.actions).length === 0) {
97
91
  console.log("No actions found");
98
92
  return;
@@ -106,53 +100,3 @@ export function logActions(context: CopilotContextParams) {
106
100
  console.groupEnd();
107
101
  }
108
102
  }
109
-
110
- export function logMessages(context: CopilotContextParams) {
111
- console.log("%cCurrent Messages:", "font-size: 16px; font-weight: bold;");
112
-
113
- if (context.messages.length === 0) {
114
- console.log("No messages found");
115
- return;
116
- }
117
-
118
- const tableData = context.messages.map((message) => {
119
- if (message instanceof TextMessage) {
120
- return {
121
- id: message.id,
122
- type: "TextMessage",
123
- role: message.role,
124
- name: undefined,
125
- scope: undefined,
126
- content: message.content,
127
- };
128
- } else if (message instanceof ActionExecutionMessage) {
129
- return {
130
- id: message.id,
131
- type: "ActionExecutionMessage",
132
- role: undefined,
133
- name: message.name,
134
- scope: message.scope,
135
- content: message.arguments,
136
- };
137
- } else if (message instanceof ResultMessage) {
138
- return {
139
- id: message.id,
140
- type: "ResultMessage",
141
- role: undefined,
142
- name: message.actionName,
143
- scope: message.actionExecutionId,
144
- content: message.result,
145
- };
146
- } else if (message instanceof AgentStateMessage) {
147
- return {
148
- id: message.id,
149
- type: `AgentStateMessage (running: ${message.running})`,
150
- role: message.role,
151
- name: undefined,
152
- scope: message.threadId,
153
- content: message.state,
154
- };
155
- }
156
- });
157
- console.table(tableData);
158
- }
package/tsup.config.ts CHANGED
@@ -1,16 +1,60 @@
1
- import { defineConfig, Options } from "tsup";
1
+ import { defineConfig, Options } from "tsup-async-inject-style";
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import postcss from "postcss";
5
+ import autoprefixer from "autoprefixer";
6
+ import tailwindcss from "tailwindcss";
7
+ import cssnano from "cssnano";
8
+ import postcssImport from "postcss-import";
9
+ import postcssNested from "postcss-nested";
2
10
 
3
- export default defineConfig((options: Options) => ({
4
- entry: ["src/**/*.{ts,tsx}"],
5
- format: ["esm", "cjs"],
6
- dts: true,
7
- minify: false,
8
- external: ["react"],
9
- sourcemap: true,
10
- exclude: [
11
- "**/*.test.ts", // Exclude TypeScript test files
12
- "**/*.test.tsx", // Exclude TypeScript React test files
13
- "**/__tests__/*", // Exclude any files inside a __tests__ directory
14
- ],
15
- ...options,
16
- }));
11
+ export default defineConfig((options: Options) => {
12
+ return {
13
+ entry: ["src/**/*.ts", "src/**/*.tsx"],
14
+ format: ["esm", "cjs"],
15
+ dts: true,
16
+ minify: false,
17
+ external: ["react"],
18
+ splitting: false,
19
+ clean: true,
20
+ sourcemap: true,
21
+ exclude: [
22
+ "**/*.test.ts", // Exclude TypeScript test files
23
+ "**/*.test.tsx", // Exclude TypeScript React test files
24
+ "**/__tests__/*", // Exclude any files inside a __tests__ directory
25
+ ],
26
+ onSuccess: async () => {
27
+ // Create index.css file for backwards compatibility
28
+ fs.writeFileSync(
29
+ path.resolve(process.cwd(), "dist/index.css"),
30
+ `/* This is here for backwards compatibility */`,
31
+ );
32
+ },
33
+ injectStyle: async (_, filePath) => {
34
+ const cwd = process.cwd();
35
+ const outputPath = path.resolve(cwd, "dist/index.css");
36
+ const rawCSS = fs.readFileSync(filePath, "utf8");
37
+
38
+ const resultCSS = await postcss([
39
+ postcssImport(),
40
+ postcssNested(),
41
+ tailwindcss,
42
+ autoprefixer,
43
+ cssnano({ preset: "default" }),
44
+ ]).process(rawCSS, { from: filePath, to: outputPath });
45
+
46
+ if (resultCSS.css === undefined) {
47
+ throw new Error("No CSS output");
48
+ }
49
+
50
+ return `
51
+ if (globalThis.hasOwnProperty("document")) {
52
+ const style = document?.createElement("style");
53
+ style.innerHTML = '${resultCSS}';
54
+ document?.head.appendChild(style);
55
+ }
56
+ `;
57
+ },
58
+ ...options,
59
+ };
60
+ });
@@ -1,26 +0,0 @@
1
- // src/hooks/use-copy-to-clipboard.tsx
2
- import * as React from "react";
3
- function useCopyToClipboard({ timeout = 2e3 }) {
4
- const [isCopied, setIsCopied] = React.useState(false);
5
- const copyToClipboard = (value) => {
6
- var _a;
7
- if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
8
- return;
9
- }
10
- if (!value) {
11
- return;
12
- }
13
- navigator.clipboard.writeText(value).then(() => {
14
- setIsCopied(true);
15
- setTimeout(() => {
16
- setIsCopied(false);
17
- }, timeout);
18
- });
19
- };
20
- return { isCopied, copyToClipboard };
21
- }
22
-
23
- export {
24
- useCopyToClipboard
25
- };
26
- //# sourceMappingURL=chunk-54JAUBUJ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/use-copy-to-clipboard.tsx"],"sourcesContent":["import * as React from \"react\";\n\nexport interface useCopyToClipboardProps {\n timeout?: number;\n}\n\nexport function useCopyToClipboard({ timeout = 2000 }: useCopyToClipboardProps) {\n const [isCopied, setIsCopied] = React.useState<Boolean>(false);\n\n const copyToClipboard = (value: string) => {\n if (typeof window === \"undefined\" || !navigator.clipboard?.writeText) {\n return;\n }\n\n if (!value) {\n return;\n }\n\n navigator.clipboard.writeText(value).then(() => {\n setIsCopied(true);\n\n setTimeout(() => {\n setIsCopied(false);\n }, timeout);\n });\n };\n\n return { isCopied, copyToClipboard };\n}\n"],"mappings":";AAAA,YAAY,WAAW;AAMhB,SAAS,mBAAmB,EAAE,UAAU,IAAK,GAA4B;AAC9E,QAAM,CAAC,UAAU,WAAW,IAAU,eAAkB,KAAK;AAE7D,QAAM,kBAAkB,CAAC,UAAkB;AAT7C;AAUI,QAAI,OAAO,WAAW,eAAe,GAAC,eAAU,cAAV,mBAAqB,YAAW;AACpE;AAAA,IACF;AAEA,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,cAAU,UAAU,UAAU,KAAK,EAAE,KAAK,MAAM;AAC9C,kBAAY,IAAI;AAEhB,iBAAW,MAAM;AACf,oBAAY,KAAK;AAAA,MACnB,GAAG,OAAO;AAAA,IACZ,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,UAAU,gBAAgB;AACrC;","names":[]}
@@ -1,29 +0,0 @@
1
- // src/hooks/use-copilot-chat-suggestions.tsx
2
- import { useEffect } from "react";
3
- import { useCopilotContext } from "@copilotkit/react-core";
4
- import { randomId } from "@copilotkit/shared";
5
- function useCopilotChatSuggestions({
6
- instructions,
7
- className,
8
- minSuggestions = 1,
9
- maxSuggestions = 3
10
- }, dependencies = []) {
11
- const context = useCopilotContext();
12
- useEffect(() => {
13
- const id = randomId();
14
- context.addChatSuggestionConfiguration(id, {
15
- instructions,
16
- minSuggestions,
17
- maxSuggestions,
18
- className
19
- });
20
- return () => {
21
- context.removeChatSuggestionConfiguration(id);
22
- };
23
- }, dependencies);
24
- }
25
-
26
- export {
27
- useCopilotChatSuggestions
28
- };
29
- //# sourceMappingURL=chunk-5HHVL5WK.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\n *\n * ### Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\n * }\n * ```\n *\n * In the example above, the suggestions are generated based on the given instructions.\n * The hook monitors `appState`, and updates suggestions accordingly whenever it changes.\n *\n * ### Behavior and Lifecycle\n *\n * The hook registers the configuration with the chat context upon component mount and\n * removes it on unmount, ensuring a clean and efficient lifecycle management.\n */\n\nimport { useEffect } from \"react\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { randomId } from \"@copilotkit/shared\";\n\ninterface UseCopilotChatSuggestionsConfiguration {\n /**\n * A prompt or instructions for the GPT to generate suggestions.\n */\n instructions: string;\n /**\n * The minimum number of suggestions to generate. Defaults to `1`.\n * @default 1\n */\n minSuggestions?: number;\n /**\n * The maximum number of suggestions to generate. Defaults to `3`.\n * @default 1\n */\n maxSuggestions?: number;\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n const id = randomId();\n\n context.addChatSuggestionConfiguration(id, {\n instructions,\n minSuggestions,\n maxSuggestions,\n className,\n });\n\n return () => {\n context.removeChatSuggestionConfiguration(id);\n };\n }, dependencies);\n}\n"],"mappings":";AA6DA,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AAuBlB,SAAS,0BACd;AAAA,EACE;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,UAAM,KAAK,SAAS;AAEpB,YAAQ,+BAA+B,IAAI;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,cAAQ,kCAAkC,EAAE;AAAA,IAC9C;AAAA,EACF,GAAG,YAAY;AACjB;","names":[]}
@@ -1,91 +0,0 @@
1
- import {
2
- Window
3
- } from "./chunk-FO7Z5LAL.mjs";
4
- import {
5
- Header
6
- } from "./chunk-FLV3J3VX.mjs";
7
- import {
8
- Button
9
- } from "./chunk-YOH25I6N.mjs";
10
- import {
11
- CopilotChat
12
- } from "./chunk-HR36Y2FQ.mjs";
13
- import {
14
- Input
15
- } from "./chunk-U6J5DGOE.mjs";
16
- import {
17
- Messages
18
- } from "./chunk-FOZVHL73.mjs";
19
- import {
20
- ResponseButton
21
- } from "./chunk-XSUSSWDS.mjs";
22
- import {
23
- ChatContextProvider
24
- } from "./chunk-BJPGMY3I.mjs";
25
-
26
- // src/components/chat/Modal.tsx
27
- import React from "react";
28
- import { jsx, jsxs } from "react/jsx-runtime";
29
- var CopilotModal = ({
30
- instructions,
31
- defaultOpen = false,
32
- clickOutsideToClose = true,
33
- hitEscapeToClose = true,
34
- onSetOpen,
35
- onSubmitMessage,
36
- shortcut = "/",
37
- icons,
38
- labels,
39
- makeSystemMessage,
40
- showResponseButton = true,
41
- onInProgress,
42
- Window: Window2 = Window,
43
- Button: Button2 = Button,
44
- Header: Header2 = Header,
45
- Messages: Messages2 = Messages,
46
- Input: Input2 = Input,
47
- ResponseButton: ResponseButton2 = ResponseButton,
48
- className,
49
- children
50
- }) => {
51
- const [openState, setOpenState] = React.useState(defaultOpen);
52
- const setOpen = (open) => {
53
- onSetOpen == null ? void 0 : onSetOpen(open);
54
- setOpenState(open);
55
- };
56
- return /* @__PURE__ */ jsxs(ChatContextProvider, { icons, labels, open: openState, setOpen, children: [
57
- children,
58
- /* @__PURE__ */ jsxs("div", { className, children: [
59
- /* @__PURE__ */ jsx(Button2, {}),
60
- /* @__PURE__ */ jsxs(
61
- Window2,
62
- {
63
- clickOutsideToClose,
64
- shortcut,
65
- hitEscapeToClose,
66
- children: [
67
- /* @__PURE__ */ jsx(Header2, {}),
68
- /* @__PURE__ */ jsx(
69
- CopilotChat,
70
- {
71
- instructions,
72
- onSubmitMessage,
73
- makeSystemMessage,
74
- showResponseButton,
75
- onInProgress,
76
- Messages: Messages2,
77
- Input: Input2,
78
- ResponseButton: ResponseButton2
79
- }
80
- )
81
- ]
82
- }
83
- )
84
- ] })
85
- ] });
86
- };
87
-
88
- export {
89
- CopilotModal
90
- };
91
- //# sourceMappingURL=chunk-B2KQEX2R.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/chat/Modal.tsx"],"sourcesContent":["import React from \"react\";\nimport { ChatContextProvider } from \"./ChatContext\";\nimport { ButtonProps, HeaderProps, WindowProps } from \"./props\";\nimport { Window as DefaultWindow } from \"./Window\";\nimport { Button as DefaultButton } from \"./Button\";\nimport { Header as DefaultHeader } from \"./Header\";\nimport { Messages as DefaultMessages } from \"./Messages\";\nimport { Input as DefaultInput } from \"./Input\";\nimport { ResponseButton as DefaultResponseButton } from \"./Response\";\nimport { CopilotChat, CopilotChatProps } from \"./Chat\";\n\nexport interface CopilotModalProps extends CopilotChatProps {\n /**\n * Whether the chat window should be open by default.\n * @default false\n */\n defaultOpen?: boolean;\n\n /**\n * If the chat window should close when the user clicks outside of it.\n * @default true\n */\n clickOutsideToClose?: boolean;\n\n /**\n * If the chat window should close when the user hits the Escape key.\n * @default true\n */\n hitEscapeToClose?: boolean;\n\n /**\n * The shortcut key to open the chat window.\n * Uses Command-[shortcut] on a Mac and Ctrl-[shortcut] on Windows.\n * @default '/'\n */\n shortcut?: string;\n\n /**\n * A callback that gets called when the chat window opens or closes.\n */\n onSetOpen?: (open: boolean) => void;\n\n /**\n * A custom Window component to use instead of the default.\n */\n Window?: React.ComponentType<WindowProps>;\n\n /**\n * A custom Button component to use instead of the default.\n */\n Button?: React.ComponentType<ButtonProps>;\n\n /**\n * A custom Header component to use instead of the default.\n */\n Header?: React.ComponentType<HeaderProps>;\n}\n\nexport const CopilotModal = ({\n instructions,\n defaultOpen = false,\n clickOutsideToClose = true,\n hitEscapeToClose = true,\n onSetOpen,\n onSubmitMessage,\n shortcut = \"/\",\n icons,\n labels,\n makeSystemMessage,\n showResponseButton = true,\n onInProgress,\n Window = DefaultWindow,\n Button = DefaultButton,\n Header = DefaultHeader,\n Messages = DefaultMessages,\n Input = DefaultInput,\n ResponseButton = DefaultResponseButton,\n className,\n children,\n}: CopilotModalProps) => {\n const [openState, setOpenState] = React.useState(defaultOpen);\n\n const setOpen = (open: boolean) => {\n onSetOpen?.(open);\n setOpenState(open);\n };\n\n return (\n <ChatContextProvider icons={icons} labels={labels} open={openState} setOpen={setOpen}>\n {children}\n <div className={className}>\n <Button></Button>\n <Window\n clickOutsideToClose={clickOutsideToClose}\n shortcut={shortcut}\n hitEscapeToClose={hitEscapeToClose}\n >\n <Header />\n <CopilotChat\n instructions={instructions}\n onSubmitMessage={onSubmitMessage}\n makeSystemMessage={makeSystemMessage}\n showResponseButton={showResponseButton}\n onInProgress={onInProgress}\n Messages={Messages}\n Input={Input}\n ResponseButton={ResponseButton}\n />\n </Window>\n </div>\n </ChatContextProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AA2FV,cACA,YADA;AAjCD,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA,qBAAqB;AAAA,EACrB;AAAA,EACA,QAAAA,UAAS;AAAA,EACT,QAAAC,UAAS;AAAA,EACT,QAAAC,UAAS;AAAA,EACT,UAAAC,YAAW;AAAA,EACX,OAAAC,SAAQ;AAAA,EACR,gBAAAC,kBAAiB;AAAA,EACjB;AAAA,EACA;AACF,MAAyB;AACvB,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,WAAW;AAE5D,QAAM,UAAU,CAAC,SAAkB;AACjC,2CAAY;AACZ,iBAAa,IAAI;AAAA,EACnB;AAEA,SACE,qBAAC,uBAAoB,OAAc,QAAgB,MAAM,WAAW,SACjE;AAAA;AAAA,IACD,qBAAC,SAAI,WACH;AAAA,0BAACJ,SAAA,EAAO;AAAA,MACR;AAAA,QAACD;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UAEA;AAAA,gCAACE,SAAA,EAAO;AAAA,YACR;AAAA,cAAC;AAAA;AAAA,gBACC;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,UAAUC;AAAA,gBACV,OAAOC;AAAA,gBACP,gBAAgBC;AAAA;AAAA,YAClB;AAAA;AAAA;AAAA,MACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":["Window","Button","Header","Messages","Input","ResponseButton"]}
@@ -1,70 +0,0 @@
1
- import {
2
- ActivityIcon,
3
- CloseIcon,
4
- HeaderCloseIcon,
5
- OpenIcon,
6
- PushToTalkIcon,
7
- RegenerateIcon,
8
- SendIcon,
9
- SpinnerIcon,
10
- StopIcon
11
- } from "./chunk-FZC7X5PK.mjs";
12
- import {
13
- __spreadValues
14
- } from "./chunk-MRXNTQOX.mjs";
15
-
16
- // src/components/chat/ChatContext.tsx
17
- import React from "react";
18
- import { jsx } from "react/jsx-runtime";
19
- var ChatContext = React.createContext(void 0);
20
- function useChatContext() {
21
- const context = React.useContext(ChatContext);
22
- if (context === void 0) {
23
- throw new Error(
24
- "Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
25
- );
26
- }
27
- return context;
28
- }
29
- var ChatContextProvider = ({
30
- // temperature,
31
- // instructions,
32
- // maxFeedback,
33
- labels,
34
- icons,
35
- children,
36
- open,
37
- setOpen
38
- }) => {
39
- const context = {
40
- labels: __spreadValues(__spreadValues({}, {
41
- initial: "",
42
- title: "CopilotKit",
43
- placeholder: "Type a message...",
44
- error: "\u274C An error occurred. Please try again.",
45
- stopGenerating: "Stop generating",
46
- regenerateResponse: "Regenerate response"
47
- }), labels),
48
- icons: __spreadValues(__spreadValues({}, {
49
- openIcon: OpenIcon,
50
- closeIcon: CloseIcon,
51
- headerCloseIcon: HeaderCloseIcon,
52
- sendIcon: SendIcon,
53
- activityIcon: ActivityIcon,
54
- spinnerIcon: SpinnerIcon,
55
- stopIcon: StopIcon,
56
- regenerateIcon: RegenerateIcon,
57
- pushToTalkIcon: PushToTalkIcon
58
- }), icons),
59
- open,
60
- setOpen
61
- };
62
- return /* @__PURE__ */ jsx(ChatContext.Provider, { value: context, children });
63
- };
64
-
65
- export {
66
- ChatContext,
67
- useChatContext,
68
- ChatContextProvider
69
- };
70
- //# sourceMappingURL=chunk-BJPGMY3I.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/chat/ChatContext.tsx"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const context = {\n labels: {\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n },\n ...labels,\n },\n\n icons: {\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n pushToTalkIcon: DefaultIcons.PushToTalkIcon,\n },\n ...icons,\n },\n open,\n setOpen,\n };\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO,WAAkC;AA6KhC;AA/DF,IAAM,cAAc,MAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,MAAM,WAAW,WAAW;AAC5C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAaO,IAAM,sBAAsB,CAAC;AAAA;AAAA;AAAA;AAAA,EAIlC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAwB;AACtB,QAAM,UAAU;AAAA,IACd,QAAQ,kCACH;AAAA,MACD,SAAS;AAAA,MACT,OAAO;AAAA,MACP,aAAa;AAAA,MACb,OAAO;AAAA,MACP,gBAAgB;AAAA,MAChB,oBAAoB;AAAA,IACtB,IACG;AAAA,IAGL,OAAO,kCACF;AAAA,MACD,UAAuB;AAAA,MACvB,WAAwB;AAAA,MACxB,iBAA8B;AAAA,MAC9B,UAAuB;AAAA,MACvB,cAA2B;AAAA,MAC3B,aAA0B;AAAA,MAC1B,UAAuB;AAAA,MACvB,gBAA6B;AAAA,MAC7B,gBAA6B;AAAA,IAC/B,IACG;AAAA,IAEL;AAAA,IACA;AAAA,EACF;AACA,SAAO,oBAAC,YAAY,UAAZ,EAAqB,OAAO,SAAU,UAAS;AACzD;","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-EFZPSZWO.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,21 +0,0 @@
1
- import {
2
- CopilotModal
3
- } from "./chunk-B2KQEX2R.mjs";
4
- import {
5
- __spreadProps,
6
- __spreadValues
7
- } from "./chunk-MRXNTQOX.mjs";
8
-
9
- // src/components/chat/Popup.tsx
10
- import { jsx } from "react/jsx-runtime";
11
- function CopilotPopup(props) {
12
- props = __spreadProps(__spreadValues({}, props), {
13
- className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
14
- });
15
- return /* @__PURE__ */ jsx(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
16
- }
17
-
18
- export {
19
- CopilotPopup
20
- };
21
- //# sourceMappingURL=chunk-FL4ETWFB.mjs.map