@copilotkit/react-core 1.57.3 → 1.57.4

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 (266) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +12 -13
  3. package/skills/react-core/SKILL.md +108 -0
  4. package/skills/react-core/references/agent-access.md +288 -0
  5. package/skills/react-core/references/attachments.md +291 -0
  6. package/skills/react-core/references/capabilities.md +138 -0
  7. package/skills/react-core/references/chat-components.md +221 -0
  8. package/skills/react-core/references/client-side-tools.md +358 -0
  9. package/skills/react-core/references/custom-message-renderers.md +226 -0
  10. package/skills/react-core/references/debug-mode.md +153 -0
  11. package/skills/react-core/references/human-in-the-loop.md +312 -0
  12. package/skills/react-core/references/provider-setup.md +326 -0
  13. package/skills/react-core/references/rendering-activity-messages.md +207 -0
  14. package/skills/react-core/references/rendering-tool-calls.md +319 -0
  15. package/skills/react-core/references/suggestions.md +211 -0
  16. package/skills/react-core/references/switching-agents-recipes.md +160 -0
  17. package/skills/react-core/references/switching-agents.md +231 -0
  18. package/skills/react-core/references/threads.md +226 -0
  19. package/.attw.json +0 -3
  20. package/CHANGELOG.md +0 -5043
  21. package/scripts/scope-preflight.mjs +0 -100
  22. package/src/components/CopilotListeners.tsx +0 -137
  23. package/src/components/__tests__/CopilotListeners.test.tsx +0 -38
  24. package/src/components/copilot-provider/__tests__/copilot-messages-key.test.tsx +0 -92
  25. package/src/components/copilot-provider/__tests__/copilotkit-error.test.tsx +0 -77
  26. package/src/components/copilot-provider/__tests__/error-visibility-prod.test.tsx +0 -70
  27. package/src/components/copilot-provider/__tests__/v1-explicit-threadid-bridge.test.tsx +0 -107
  28. package/src/components/copilot-provider/copilot-messages.tsx +0 -314
  29. package/src/components/copilot-provider/copilotkit-props.tsx +0 -214
  30. package/src/components/copilot-provider/copilotkit.tsx +0 -853
  31. package/src/components/copilot-provider/index.ts +0 -3
  32. package/src/components/dev-console/console-trigger.tsx +0 -283
  33. package/src/components/dev-console/developer-console-modal.tsx +0 -1016
  34. package/src/components/dev-console/icons.tsx +0 -106
  35. package/src/components/error-boundary/error-boundary.tsx +0 -99
  36. package/src/components/error-boundary/error-utils.tsx +0 -105
  37. package/src/components/index.ts +0 -1
  38. package/src/components/toast/exclamation-mark-icon.tsx +0 -27
  39. package/src/components/toast/toast-provider.tsx +0 -448
  40. package/src/components/usage-banner.tsx +0 -266
  41. package/src/context/__tests__/threads-context.test.tsx +0 -141
  42. package/src/context/coagent-state-renders-context.tsx +0 -89
  43. package/src/context/copilot-context.tsx +0 -365
  44. package/src/context/copilot-messages-context.tsx +0 -35
  45. package/src/context/index.ts +0 -22
  46. package/src/context/threads-context.tsx +0 -69
  47. package/src/hooks/__tests__/use-coagent-config.test.ts +0 -352
  48. package/src/hooks/__tests__/use-coagent-state-render-bridge.helpers.test.ts +0 -107
  49. package/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx +0 -1209
  50. package/src/hooks/__tests__/use-coagent-state-render.test.tsx +0 -356
  51. package/src/hooks/__tests__/use-copilot-chat-internal-connect.test.tsx +0 -241
  52. package/src/hooks/__tests__/use-frontend-tool-available.test.tsx +0 -72
  53. package/src/hooks/__tests__/use-frontend-tool-remount.e2e.test.tsx +0 -102
  54. package/src/hooks/index.ts +0 -33
  55. package/src/hooks/use-agent-nodename.ts +0 -33
  56. package/src/hooks/use-coagent-state-render-bridge.helpers.ts +0 -345
  57. package/src/hooks/use-coagent-state-render-bridge.tsx +0 -222
  58. package/src/hooks/use-coagent-state-render-registry.ts +0 -230
  59. package/src/hooks/use-coagent-state-render.ts +0 -163
  60. package/src/hooks/use-coagent.ts +0 -377
  61. package/src/hooks/use-configure-chat-suggestions.tsx +0 -96
  62. package/src/hooks/use-copilot-action.ts +0 -245
  63. package/src/hooks/use-copilot-additional-instructions.ts +0 -98
  64. package/src/hooks/use-copilot-authenticated-action.ts +0 -73
  65. package/src/hooks/use-copilot-chat-headless_c.ts +0 -264
  66. package/src/hooks/use-copilot-chat-suggestions.tsx +0 -134
  67. package/src/hooks/use-copilot-chat.ts +0 -132
  68. package/src/hooks/use-copilot-chat_internal.ts +0 -875
  69. package/src/hooks/use-copilot-readable.ts +0 -135
  70. package/src/hooks/use-copilot-runtime-client.ts +0 -178
  71. package/src/hooks/use-default-tool.ts +0 -13
  72. package/src/hooks/use-flat-category-store.ts +0 -109
  73. package/src/hooks/use-frontend-tool.ts +0 -113
  74. package/src/hooks/use-human-in-the-loop.ts +0 -138
  75. package/src/hooks/use-langgraph-interrupt.ts +0 -103
  76. package/src/hooks/use-lazy-tool-renderer.tsx +0 -30
  77. package/src/hooks/use-make-copilot-document-readable.ts +0 -30
  78. package/src/hooks/use-render-tool-call.ts +0 -89
  79. package/src/hooks/use-tree.ts +0 -222
  80. package/src/index.tsx +0 -7
  81. package/src/lib/copilot-task.ts +0 -215
  82. package/src/lib/index.ts +0 -1
  83. package/src/lib/status-checker.ts +0 -67
  84. package/src/setupTests.ts +0 -37
  85. package/src/test-helpers/copilot-context.ts +0 -91
  86. package/src/types/chat-suggestion-configuration.ts +0 -23
  87. package/src/types/coagent-action.ts +0 -35
  88. package/src/types/coagent-state.ts +0 -13
  89. package/src/types/crew.ts +0 -89
  90. package/src/types/document-pointer.ts +0 -7
  91. package/src/types/frontend-action.ts +0 -213
  92. package/src/types/index.ts +0 -17
  93. package/src/types/interrupt-action.ts +0 -58
  94. package/src/types/system-message.ts +0 -4
  95. package/src/utils/dev-console.ts +0 -19
  96. package/src/utils/index.ts +0 -2
  97. package/src/utils/suggestions-constants.ts +0 -8
  98. package/src/utils/utils.test.ts +0 -7
  99. package/src/utils/utils.ts +0 -6
  100. package/src/v2/__tests__/A2UIMessageRenderer.test.tsx +0 -240
  101. package/src/v2/__tests__/globalSetup.ts +0 -14
  102. package/src/v2/__tests__/setup.ts +0 -93
  103. package/src/v2/__tests__/utils/test-helpers.tsx +0 -570
  104. package/src/v2/a2ui/A2UICatalogContext.tsx +0 -79
  105. package/src/v2/a2ui/A2UIMessageRenderer.tsx +0 -294
  106. package/src/v2/a2ui/A2UIToolCallRenderer.tsx +0 -290
  107. package/src/v2/components/CopilotKitInspector.tsx +0 -52
  108. package/src/v2/components/MCPAppsActivityRenderer.tsx +0 -815
  109. package/src/v2/components/OpenGenerativeUIRenderer.tsx +0 -598
  110. package/src/v2/components/WildcardToolCallRender.tsx +0 -86
  111. package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.tsx +0 -665
  112. package/src/v2/components/chat/CopilotChat.tsx +0 -664
  113. package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +0 -393
  114. package/src/v2/components/chat/CopilotChatAttachmentQueue.tsx +0 -374
  115. package/src/v2/components/chat/CopilotChatAttachmentRenderer.tsx +0 -159
  116. package/src/v2/components/chat/CopilotChatAudioRecorder.tsx +0 -350
  117. package/src/v2/components/chat/CopilotChatInput.tsx +0 -1412
  118. package/src/v2/components/chat/CopilotChatMessageView.tsx +0 -716
  119. package/src/v2/components/chat/CopilotChatReasoningMessage.tsx +0 -265
  120. package/src/v2/components/chat/CopilotChatSuggestionPill.tsx +0 -59
  121. package/src/v2/components/chat/CopilotChatSuggestionView.tsx +0 -134
  122. package/src/v2/components/chat/CopilotChatToggleButton.tsx +0 -171
  123. package/src/v2/components/chat/CopilotChatToolCallsView.tsx +0 -40
  124. package/src/v2/components/chat/CopilotChatUserMessage.tsx +0 -445
  125. package/src/v2/components/chat/CopilotChatView.tsx +0 -890
  126. package/src/v2/components/chat/CopilotModalHeader.tsx +0 -129
  127. package/src/v2/components/chat/CopilotPopup.tsx +0 -81
  128. package/src/v2/components/chat/CopilotPopupView.tsx +0 -317
  129. package/src/v2/components/chat/CopilotSidebar.tsx +0 -80
  130. package/src/v2/components/chat/CopilotSidebarView.tsx +0 -269
  131. package/src/v2/components/chat/Lightbox.tsx +0 -103
  132. package/src/v2/components/chat/__tests__/CopilotChat.absentThreadConnect.test.tsx +0 -66
  133. package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.tsx +0 -168
  134. package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.tsx +0 -1239
  135. package/src/v2/components/chat/__tests__/CopilotChat.onError.test.tsx +0 -73
  136. package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.tsx +0 -432
  137. package/src/v2/components/chat/__tests__/CopilotChat.suggestionsAlways.test.tsx +0 -183
  138. package/src/v2/components/chat/__tests__/CopilotChat.welcomeGate.test.tsx +0 -184
  139. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +0 -649
  140. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.tsx +0 -624
  141. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx +0 -702
  142. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.thumbs.test.tsx +0 -72
  143. package/src/v2/components/chat/__tests__/CopilotChatCopyButton.clipboard.test.tsx +0 -241
  144. package/src/v2/components/chat/__tests__/CopilotChatCssClasses.test.tsx +0 -107
  145. package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.tsx +0 -929
  146. package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +0 -1567
  147. package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.tsx +0 -1004
  148. package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.tsx +0 -279
  149. package/src/v2/components/chat/__tests__/CopilotChatPerf.e2e.test.tsx +0 -336
  150. package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.tsx +0 -249
  151. package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.tsx +0 -530
  152. package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.tsx +0 -785
  153. package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.tsx +0 -2416
  154. package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.tsx +0 -621
  155. package/src/v2/components/chat/__tests__/CopilotChatView.connectingGate.test.tsx +0 -56
  156. package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.tsx +0 -264
  157. package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.tsx +0 -853
  158. package/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.tsx +0 -94
  159. package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.tsx +0 -1050
  160. package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.tsx +0 -484
  161. package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.tsx +0 -612
  162. package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.tsx +0 -159
  163. package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.tsx +0 -502
  164. package/src/v2/components/chat/__tests__/MCPAppsActivityRenderer.e2e.test.tsx +0 -1068
  165. package/src/v2/components/chat/__tests__/MCPAppsProxy.e2e.test.tsx +0 -589
  166. package/src/v2/components/chat/__tests__/MCPAppsUiMessage.e2e.test.tsx +0 -403
  167. package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.tsx +0 -137
  168. package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +0 -37
  169. package/src/v2/components/chat/__tests__/setup.ts +0 -1
  170. package/src/v2/components/chat/index.ts +0 -90
  171. package/src/v2/components/chat/last-user-message-context.ts +0 -21
  172. package/src/v2/components/chat/normalize-auto-scroll.ts +0 -17
  173. package/src/v2/components/chat/scroll-element-context.ts +0 -13
  174. package/src/v2/components/index.ts +0 -8
  175. package/src/v2/components/intelligence-indicator/IntelligenceIndicator.tsx +0 -286
  176. package/src/v2/components/intelligence-indicator/__tests__/IntelligenceIndicator.e2e.test.tsx +0 -464
  177. package/src/v2/components/intelligence-indicator/index.ts +0 -2
  178. package/src/v2/components/license-warning-banner.tsx +0 -217
  179. package/src/v2/components/ui/button.tsx +0 -124
  180. package/src/v2/components/ui/dropdown-menu.tsx +0 -258
  181. package/src/v2/components/ui/tooltip.tsx +0 -60
  182. package/src/v2/context.ts +0 -62
  183. package/src/v2/headless.ts +0 -64
  184. package/src/v2/hooks/__tests__/standard-schema-types.test.tsx +0 -152
  185. package/src/v2/hooks/__tests__/standard-schema.test.tsx +0 -282
  186. package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.tsx +0 -140
  187. package/src/v2/hooks/__tests__/use-agent-context.test.tsx +0 -401
  188. package/src/v2/hooks/__tests__/use-agent-error-state.test.tsx +0 -44
  189. package/src/v2/hooks/__tests__/use-agent-stability.test.tsx +0 -211
  190. package/src/v2/hooks/__tests__/use-agent-throttle.test.tsx +0 -1029
  191. package/src/v2/hooks/__tests__/use-agent.e2e.test.tsx +0 -159
  192. package/src/v2/hooks/__tests__/use-attachments.test.tsx +0 -169
  193. package/src/v2/hooks/__tests__/use-capabilities.test.tsx +0 -76
  194. package/src/v2/hooks/__tests__/use-component.test.tsx +0 -126
  195. package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.tsx +0 -696
  196. package/src/v2/hooks/__tests__/use-default-render-tool.test.tsx +0 -153
  197. package/src/v2/hooks/__tests__/use-frontend-tool-available.test.tsx +0 -167
  198. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.tsx +0 -2148
  199. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx +0 -1261
  200. package/src/v2/hooks/__tests__/use-interrupt.test.tsx +0 -397
  201. package/src/v2/hooks/__tests__/use-katex-styles.test.tsx +0 -56
  202. package/src/v2/hooks/__tests__/use-keyboard-height.test.tsx +0 -192
  203. package/src/v2/hooks/__tests__/use-pin-to-send.test.tsx +0 -219
  204. package/src/v2/hooks/__tests__/use-render-custom-messages.test.tsx +0 -55
  205. package/src/v2/hooks/__tests__/use-render-tool.test.tsx +0 -259
  206. package/src/v2/hooks/__tests__/use-suggestions.e2e.test.tsx +0 -524
  207. package/src/v2/hooks/__tests__/use-threads.test.tsx +0 -757
  208. package/src/v2/hooks/__tests__/zod-regression.test.tsx +0 -311
  209. package/src/v2/hooks/index.ts +0 -24
  210. package/src/v2/hooks/use-agent-context.tsx +0 -45
  211. package/src/v2/hooks/use-agent.tsx +0 -227
  212. package/src/v2/hooks/use-attachments.tsx +0 -269
  213. package/src/v2/hooks/use-capabilities.tsx +0 -25
  214. package/src/v2/hooks/use-component.tsx +0 -91
  215. package/src/v2/hooks/use-configure-suggestions.tsx +0 -236
  216. package/src/v2/hooks/use-default-render-tool.tsx +0 -271
  217. package/src/v2/hooks/use-frontend-tool.tsx +0 -46
  218. package/src/v2/hooks/use-human-in-the-loop.tsx +0 -81
  219. package/src/v2/hooks/use-interrupt.tsx +0 -305
  220. package/src/v2/hooks/use-keyboard-height.tsx +0 -67
  221. package/src/v2/hooks/use-pin-to-send.ts +0 -94
  222. package/src/v2/hooks/use-render-activity-message.tsx +0 -72
  223. package/src/v2/hooks/use-render-custom-messages.tsx +0 -93
  224. package/src/v2/hooks/use-render-tool-call.tsx +0 -208
  225. package/src/v2/hooks/use-render-tool.tsx +0 -184
  226. package/src/v2/hooks/use-suggestions.tsx +0 -91
  227. package/src/v2/hooks/use-threads.tsx +0 -325
  228. package/src/v2/hooks/useKatexStyles.ts +0 -27
  229. package/src/v2/index.css +0 -1
  230. package/src/v2/index.ts +0 -27
  231. package/src/v2/lib/__tests__/completePartialMarkdown.test.ts +0 -495
  232. package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -112
  233. package/src/v2/lib/__tests__/renderSlot.test.tsx +0 -588
  234. package/src/v2/lib/__tests__/slots.test.ts +0 -56
  235. package/src/v2/lib/processPartialHtml.ts +0 -45
  236. package/src/v2/lib/react-core.ts +0 -156
  237. package/src/v2/lib/slots.tsx +0 -184
  238. package/src/v2/lib/transcription-client.ts +0 -184
  239. package/src/v2/lib/utils.ts +0 -8
  240. package/src/v2/providers/CopilotChatConfigurationProvider.tsx +0 -196
  241. package/src/v2/providers/CopilotKitProvider.tsx +0 -800
  242. package/src/v2/providers/SandboxFunctionsContext.ts +0 -10
  243. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.tsx +0 -652
  244. package/src/v2/providers/__tests__/CopilotKitProvider.license.test.tsx +0 -101
  245. package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.tsx +0 -69
  246. package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.tsx +0 -881
  247. package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.tsx +0 -198
  248. package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.tsx +0 -740
  249. package/src/v2/providers/__tests__/CopilotKitProvider.test.tsx +0 -713
  250. package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.tsx +0 -294
  251. package/src/v2/providers/index.ts +0 -21
  252. package/src/v2/styles/globals.css +0 -349
  253. package/src/v2/types/__tests__/defineToolCallRenderer.test.tsx +0 -525
  254. package/src/v2/types/defineToolCallRenderer.ts +0 -68
  255. package/src/v2/types/frontend-tool.ts +0 -8
  256. package/src/v2/types/human-in-the-loop.ts +0 -33
  257. package/src/v2/types/index.ts +0 -8
  258. package/src/v2/types/interrupt.ts +0 -15
  259. package/src/v2/types/react-activity-message-renderer.ts +0 -27
  260. package/src/v2/types/react-custom-message-renderer.ts +0 -17
  261. package/src/v2/types/react-tool-call-renderer.ts +0 -35
  262. package/src/v2/types/sandbox-function.ts +0 -11
  263. package/tsconfig.json +0 -8
  264. package/tsdown.config.ts +0 -193
  265. package/typedoc.json +0 -4
  266. package/vitest.config.mjs +0 -31
@@ -1,464 +0,0 @@
1
- import React from "react";
2
- import { afterEach, describe, expect, it } from "vitest";
3
- import { fireEvent, render, screen, waitFor } from "@testing-library/react";
4
- import { EventType } from "@ag-ui/client";
5
- import type { BaseEvent, RunAgentInput } from "@ag-ui/client";
6
- import type { Observable } from "rxjs";
7
- import type { Subject } from "rxjs";
8
- import { takeWhile } from "rxjs/operators";
9
- import {
10
- MockStepwiseAgent,
11
- runStartedEvent,
12
- runFinishedEvent,
13
- textMessageStartEvent,
14
- textMessageContentEvent,
15
- textMessageEndEvent,
16
- toolCallChunkEvent,
17
- toolCallResultEvent,
18
- } from "../../../__tests__/utils/test-helpers";
19
- import { CopilotChat } from "../../chat/CopilotChat";
20
- import { CopilotKitProvider } from "../../../providers/CopilotKitProvider";
21
- import { CopilotChatConfigurationProvider } from "../../../providers/CopilotChatConfigurationProvider";
22
- import { useCopilotKit } from "../../../providers/CopilotKitProvider";
23
- import { useAgent } from "../../../hooks/use-agent";
24
-
25
- /**
26
- * Mock agent with accurate per-run `isRunning` lifecycle. The shared
27
- * `MockStepwiseAgent` returns the un-terminating `subject.asObservable()`
28
- * for backward compatibility, so emitting `RUN_FINISHED` on it doesn't
29
- * complete the rxjs pipeline → `isRunning` never flips back. The
30
- * `takeWhile(..., true)` here makes the per-run observable terminate on
31
- * RUN_FINISHED / RUN_ERROR (the `true` is "inclusive" — emit the
32
- * terminal event before completing). That terminates AG-UI's run
33
- * pipeline like a real agent so the indicator sees the falling edge.
34
- */
35
- class IsRunningAccurateMockAgent extends MockStepwiseAgent {
36
- override run(_input: RunAgentInput): Observable<BaseEvent> {
37
- return (this as unknown as { subject: Subject<BaseEvent> }).subject.pipe(
38
- takeWhile(
39
- (event) =>
40
- event.type !== EventType.RUN_FINISHED &&
41
- event.type !== EventType.RUN_ERROR,
42
- true,
43
- ),
44
- );
45
- }
46
- }
47
-
48
- const PILL_TESTID_RE = /^cpk-intelligence-pill-/;
49
-
50
- const expectPillCount = (n: number): void => {
51
- expect(screen.queryAllByTestId(PILL_TESTID_RE).length).toBe(n);
52
- };
53
-
54
- const expectPillOn = (messageId: string): void => {
55
- expect(
56
- screen.getByTestId(`cpk-intelligence-pill-${messageId}`).textContent,
57
- ).toContain("Using CopilotKit Intelligence");
58
- };
59
-
60
- const expectNoPillOn = (messageId: string): void => {
61
- expect(screen.queryByTestId(`cpk-intelligence-pill-${messageId}`)).toBeNull();
62
- };
63
-
64
- const expectNoPillAnywhere = (): void => {
65
- expect(screen.queryAllByTestId(PILL_TESTID_RE).length).toBe(0);
66
- };
67
-
68
- const emitAssistantMessageWithToolCalls = (
69
- agent: MockStepwiseAgent,
70
- messageId: string,
71
- toolCalls: Array<{ id: string; name?: string; arg: string }>,
72
- ): void => {
73
- agent.emit(textMessageStartEvent(messageId));
74
- agent.emit(textMessageEndEvent(messageId));
75
- for (const tc of toolCalls) {
76
- agent.emit(
77
- toolCallChunkEvent({
78
- toolCallId: tc.id,
79
- toolCallName: tc.name ?? "copilotkit_knowledge_base_shell",
80
- parentMessageId: messageId,
81
- delta: tc.arg,
82
- }),
83
- );
84
- }
85
- };
86
-
87
- const emitToolResult = (
88
- agent: MockStepwiseAgent,
89
- toolCallId: string,
90
- resultMessageId: string,
91
- content = "ok",
92
- ): void => {
93
- agent.emit(
94
- toolCallResultEvent({ toolCallId, messageId: resultMessageId, content }),
95
- );
96
- };
97
-
98
- const emitAssistantProse = (
99
- agent: MockStepwiseAgent,
100
- messageId: string,
101
- text: string,
102
- ): void => {
103
- agent.emit(textMessageStartEvent(messageId));
104
- agent.emit(textMessageContentEvent(messageId, text));
105
- agent.emit(textMessageEndEvent(messageId));
106
- };
107
-
108
- const startRun = (agent: MockStepwiseAgent): void => {
109
- agent.emit(runStartedEvent());
110
- };
111
-
112
- /**
113
- * Test harness: drives `copilotkit.runAgent` from a click and force-sets
114
- * `copilotkit.intelligence` on the live core. Apps observe the
115
- * intelligence-set-up state via a real `/info` round trip; tests bypass
116
- * that plumbing by writing directly into the registry's private slot.
117
- */
118
- const RunAgentHarness: React.FC<{ withIntelligence: boolean }> = ({
119
- withIntelligence,
120
- }) => {
121
- const { copilotkit } = useCopilotKit();
122
- const { agent } = useAgent();
123
-
124
- React.useEffect(() => {
125
- const reg = (
126
- copilotkit as unknown as {
127
- agentRegistry: { _intelligence?: { wsUrl: string } };
128
- }
129
- ).agentRegistry;
130
- if (withIntelligence) {
131
- reg._intelligence = { wsUrl: "wss://test/intelligence" };
132
- } else {
133
- reg._intelligence = undefined;
134
- }
135
- }, [copilotkit, withIntelligence]);
136
-
137
- const handleClick = React.useCallback(() => {
138
- if (!agent) return;
139
- copilotkit.runAgent({ agent }).catch((err: unknown) => {
140
- console.error("[test] copilotkit.runAgent rejected:", err);
141
- throw err;
142
- });
143
- }, [copilotkit, agent]);
144
-
145
- return (
146
- <button data-testid="trigger-run" onClick={handleClick}>
147
- run
148
- </button>
149
- );
150
- };
151
-
152
- interface RenderOptions {
153
- withIntelligence?: boolean;
154
- }
155
-
156
- const renderForIndicator = (
157
- agent: MockStepwiseAgent,
158
- options: RenderOptions = {},
159
- ): void => {
160
- const { withIntelligence = true } = options;
161
-
162
- // No `renderCustomMessages` prop is passed — the indicator
163
- // auto-mounts when intelligence is configured.
164
- render(
165
- <CopilotKitProvider agents__unsafe_dev_only={{ default: agent }}>
166
- <CopilotChatConfigurationProvider agentId="default" threadId="t">
167
- <RunAgentHarness withIntelligence={withIntelligence} />
168
- <div style={{ height: 400 }}>
169
- <CopilotChat welcomeScreen={false} />
170
- </div>
171
- </CopilotChatConfigurationProvider>
172
- </CopilotKitProvider>,
173
- );
174
- };
175
-
176
- const triggerRun = async (agent: MockStepwiseAgent): Promise<void> => {
177
- await waitFor(() => expect(agent.isRunning).toBe(false));
178
- fireEvent.click(screen.getByTestId("trigger-run"));
179
- await waitFor(() => expect(agent.isRunning).toBe(true));
180
- };
181
-
182
- /** Phase machine fades over up to ~1780 ms (500 + 800 + 480). */
183
- const FADE_OUT_TIMEOUT_MS = 2500;
184
-
185
- describe('IntelligenceIndicator — "Using CopilotKit Intelligence" (auto-mounted)', () => {
186
- const activeAgents: IsRunningAccurateMockAgent[] = [];
187
- const makeAgent = (): IsRunningAccurateMockAgent => {
188
- const agent = new IsRunningAccurateMockAgent();
189
- activeAgents.push(agent);
190
- return agent;
191
- };
192
- afterEach(() => {
193
- while (activeAgents.length) {
194
- const agent = activeAgents.pop()!;
195
- try {
196
- agent.complete();
197
- } catch (err) {
198
- console.error("[test] agent.complete() threw during cleanup:", err);
199
- }
200
- }
201
- });
202
-
203
- /**
204
- * Walks through the canonical scenario:
205
- *
206
- * RUN A
207
- * m_a1 (assistant) → toolCall bash#1, bash#2
208
- * RUN B
209
- * m_b1 (assistant) → toolCall bash
210
- * m_b2 (assistant) → toolCall bash#1, bash#2
211
- *
212
- * The pill must render only on the last message of the latest
213
- * in-flight run — never on multiple messages, never on stale runs,
214
- * never on a non-last message of the current run.
215
- */
216
- it("renders only on the last message of the latest in-flight run", async () => {
217
- const agent = makeAgent();
218
- renderForIndicator(agent);
219
- await screen.findByTestId("trigger-run");
220
-
221
- expectNoPillAnywhere();
222
-
223
- // ─── Run A: m_a1 with two tool calls → pill on m_a1 ───────────────
224
- await triggerRun(agent);
225
- startRun(agent);
226
- emitAssistantMessageWithToolCalls(agent, "m_a1", [
227
- { id: "tc_a1_1", arg: '{"cmd":"ls"}' },
228
- { id: "tc_a1_2", arg: '{"cmd":"pwd"}' },
229
- ]);
230
- await waitFor(() => expectPillOn("m_a1"));
231
- expectPillCount(1);
232
-
233
- agent.emit(runFinishedEvent());
234
-
235
- // ─── Run B: m_b1 (one bash) ──────────────────────────────────────
236
- await triggerRun(agent);
237
- startRun(agent);
238
- emitAssistantMessageWithToolCalls(agent, "m_b1", [
239
- { id: "tc_b1", arg: '{"cmd":"echo b1"}' },
240
- ]);
241
- await waitFor(() => expectPillOn("m_b1"));
242
- // m_a1's pill may briefly remain in fade-out; lock the post-debounce
243
- // state.
244
- await waitFor(() => expectNoPillOn("m_a1"), {
245
- timeout: FADE_OUT_TIMEOUT_MS,
246
- });
247
- expectPillCount(1);
248
-
249
- // ─── m_b2 streams in — pill moves to m_b2, m_b1 loses pill ────────
250
- emitAssistantMessageWithToolCalls(agent, "m_b2", [
251
- { id: "tc_b2_1", arg: '{"cmd":"echo b2-1"}' },
252
- { id: "tc_b2_2", arg: '{"cmd":"echo b2-2"}' },
253
- ]);
254
- await waitFor(() => expectPillOn("m_b2"));
255
- expectNoPillOn("m_b1");
256
- expectNoPillOn("m_a1");
257
- expectPillCount(1);
258
-
259
- // ─── Run B finishes — pill fades, eventually no pill anywhere ─────
260
- agent.emit(runFinishedEvent());
261
- await waitFor(() => expectNoPillAnywhere(), {
262
- timeout: FADE_OUT_TIMEOUT_MS,
263
- });
264
- });
265
-
266
- // ─── Per-condition focused tests ────────────────────────────────────
267
-
268
- it("condition (last-in-run): never renders on a non-last message of the run", async () => {
269
- const agent = makeAgent();
270
- renderForIndicator(agent);
271
- await screen.findByTestId("trigger-run");
272
-
273
- await triggerRun(agent);
274
- startRun(agent);
275
- emitAssistantMessageWithToolCalls(agent, "m_first", [
276
- { id: "tc_first", arg: "{}" },
277
- ]);
278
- // Wait for m_first to render the pill while it is still the last
279
- // message in the run. Without this gate, both messages would land
280
- // synchronously and m_first's renderer would never have been
281
- // invoked while it was the last — turning a reactive assertion
282
- // into a first-render correctness test by accident.
283
- await waitFor(() => expectPillOn("m_first"));
284
-
285
- emitAssistantMessageWithToolCalls(agent, "m_second", [
286
- { id: "tc_second", arg: "{}" },
287
- ]);
288
-
289
- await waitFor(() => expectPillOn("m_second"));
290
- expectNoPillOn("m_first");
291
- expectPillCount(1);
292
- });
293
-
294
- it("condition (in-flight): pill clears after the run finishes", async () => {
295
- const agent = makeAgent();
296
- renderForIndicator(agent);
297
- await screen.findByTestId("trigger-run");
298
-
299
- await triggerRun(agent);
300
- startRun(agent);
301
- emitAssistantMessageWithToolCalls(agent, "m_only", [
302
- { id: "tc", arg: "{}" },
303
- ]);
304
- await waitFor(() => expectPillOn("m_only"));
305
-
306
- agent.emit(runFinishedEvent());
307
- await waitFor(() => expectNoPillOn("m_only"), {
308
- timeout: FADE_OUT_TIMEOUT_MS,
309
- });
310
- });
311
-
312
- it("condition (latest-run): never renders on a stale run after a newer run starts", async () => {
313
- const agent = makeAgent();
314
- renderForIndicator(agent);
315
- await screen.findByTestId("trigger-run");
316
-
317
- await triggerRun(agent);
318
- startRun(agent);
319
- emitAssistantMessageWithToolCalls(agent, "m_run1", [
320
- { id: "tc_run1", arg: "{}" },
321
- ]);
322
- await waitFor(() => expectPillOn("m_run1"));
323
- agent.emit(runFinishedEvent());
324
-
325
- await triggerRun(agent);
326
- startRun(agent);
327
- emitAssistantMessageWithToolCalls(agent, "m_run2", [
328
- { id: "tc_run2", arg: "{}" },
329
- ]);
330
- await waitFor(() => expectPillOn("m_run2"));
331
- expectNoPillOn("m_run1");
332
- });
333
-
334
- it("condition (tool-match): only renders when a configured tool name matches", async () => {
335
- const agent = makeAgent();
336
- renderForIndicator(agent);
337
- await screen.findByTestId("trigger-run");
338
-
339
- await triggerRun(agent);
340
- startRun(agent);
341
- // First message has only a non-matching tool call; no pill.
342
- emitAssistantMessageWithToolCalls(agent, "m_no_match", [
343
- { id: "tc_no_match", name: "fetch", arg: "{}" },
344
- ]);
345
- await new Promise((r) => setTimeout(r, 80));
346
- expectNoPillOn("m_no_match");
347
-
348
- // Second message has a bash call — pill should appear on it.
349
- emitAssistantMessageWithToolCalls(agent, "m_match", [
350
- { id: "tc_match", name: "copilotkit_knowledge_base_shell", arg: "{}" },
351
- ]);
352
- await waitFor(() => expectPillOn("m_match"));
353
- expectPillCount(1);
354
- });
355
-
356
- it("intelligence gate: does not render when copilotkit.intelligence is undefined", async () => {
357
- const agent = makeAgent();
358
- renderForIndicator(agent, { withIntelligence: false });
359
- await screen.findByTestId("trigger-run");
360
-
361
- await triggerRun(agent);
362
- startRun(agent);
363
- emitAssistantMessageWithToolCalls(agent, "m1", [{ id: "tc1", arg: "{}" }]);
364
-
365
- // Without the gate, the pill would be visible by now.
366
- await new Promise((r) => setTimeout(r, 80));
367
- expectNoPillAnywhere();
368
- });
369
-
370
- it("auto-registration: no renderCustomMessages prop is required", async () => {
371
- // This is the explicit assertion that the indicator auto-mounts.
372
- // `renderForIndicator` does not pass `renderCustomMessages`, yet
373
- // the pill renders solely because intelligence is configured.
374
- const agent = makeAgent();
375
- renderForIndicator(agent);
376
- await screen.findByTestId("trigger-run");
377
-
378
- await triggerRun(agent);
379
- startRun(agent);
380
- emitAssistantMessageWithToolCalls(agent, "m1", [{ id: "tc1", arg: "{}" }]);
381
-
382
- await waitFor(() => expectPillOn("m1"));
383
- expectPillCount(1);
384
- });
385
-
386
- // ─── New gate: tool-call pending past grace window ──────────────────
387
-
388
- it("replay-flash suppression: no pill when tool result arrives within the grace window", async () => {
389
- // Models a `connectAgent` history replay: the tool call and its
390
- // matching `tool`-role result arrive in the same tick, well below
391
- // PENDING_THRESHOLD_MS. The pill timer should be cancelled before
392
- // it fires, so nothing renders.
393
- const agent = makeAgent();
394
- renderForIndicator(agent);
395
- await screen.findByTestId("trigger-run");
396
-
397
- await triggerRun(agent);
398
- startRun(agent);
399
- emitAssistantMessageWithToolCalls(agent, "m_replay", [
400
- { id: "tc_replay", arg: '{"cmd":"ls"}' },
401
- ]);
402
- emitToolResult(agent, "tc_replay", "tr_replay");
403
-
404
- // Wait past the grace window — pill should never appear.
405
- await new Promise((r) => setTimeout(r, 200));
406
- expectNoPillAnywhere();
407
- });
408
-
409
- it("multi-step: pill stays continuously across tool-result interleaving", async () => {
410
- // Tool result arrives, then a second assistant message with bash.
411
- // The pill must not show the completed/fade animation between
412
- // calls — it stays on m_step1 until m_step2 takes over the slot.
413
- const agent = makeAgent();
414
- renderForIndicator(agent);
415
- await screen.findByTestId("trigger-run");
416
-
417
- await triggerRun(agent);
418
- startRun(agent);
419
- emitAssistantMessageWithToolCalls(agent, "m_step1", [
420
- { id: "tc_step1", arg: '{"cmd":"ls"}' },
421
- ]);
422
- await waitFor(() => expectPillOn("m_step1"));
423
-
424
- // Tool result lands. agent.isRunning is still true, no real
425
- // follow-up yet → pill stays on m_step1 in spinner.
426
- emitToolResult(agent, "tc_step1", "tr_step1");
427
- await new Promise((r) => setTimeout(r, 150));
428
- expectPillOn("m_step1");
429
- expectPillCount(1);
430
-
431
- // Second assistant message with bash arrives. Slot moves; old
432
- // instance returns null without a fade animation.
433
- emitAssistantMessageWithToolCalls(agent, "m_step2", [
434
- { id: "tc_step2", arg: '{"cmd":"pwd"}' },
435
- ]);
436
- await waitFor(() => expectPillOn("m_step2"));
437
- expectNoPillOn("m_step1");
438
- expectPillCount(1);
439
- });
440
-
441
- it("real-followup exit: prose assistant message after the tool flow clears the pill", async () => {
442
- // After the tool result the agent emits a final prose message —
443
- // that's a "real follow-up" and should immediately exit the
444
- // spinner (without waiting on isRunning), advancing to check
445
- // → fading → hidden.
446
- const agent = makeAgent();
447
- renderForIndicator(agent);
448
- await screen.findByTestId("trigger-run");
449
-
450
- await triggerRun(agent);
451
- startRun(agent);
452
- emitAssistantMessageWithToolCalls(agent, "m_tool", [
453
- { id: "tc_only", arg: '{"cmd":"ls"}' },
454
- ]);
455
- await waitFor(() => expectPillOn("m_tool"));
456
-
457
- emitToolResult(agent, "tc_only", "tr_only");
458
- emitAssistantProse(agent, "m_prose", "All done.");
459
-
460
- await waitFor(() => expectNoPillAnywhere(), {
461
- timeout: FADE_OUT_TIMEOUT_MS,
462
- });
463
- });
464
- });
@@ -1,2 +0,0 @@
1
- export { IntelligenceIndicator } from "./IntelligenceIndicator";
2
- export type { IntelligenceIndicatorProps } from "./IntelligenceIndicator";
@@ -1,217 +0,0 @@
1
- import React, { useEffect } from "react";
2
-
3
- // Total reserved vertical space for the fixed license banner: banner height
4
- // (~36px) + bottom offset (8px) + visual gap above the chat input (~8px).
5
- const LICENSE_BANNER_OFFSET_PX = 52;
6
- const LICENSE_BANNER_OFFSET_VAR = "--copilotkit-license-banner-offset";
7
-
8
- interface LicenseWarningBannerProps {
9
- type:
10
- | "no_license"
11
- | "expired"
12
- | "expiring"
13
- | "invalid"
14
- | "feature_unlicensed";
15
- featureName?: string;
16
- expiryDate?: string;
17
- graceRemaining?: number;
18
- onDismiss?: () => void;
19
- }
20
-
21
- const BANNER_STYLES: Record<string, React.CSSProperties> = {
22
- base: {
23
- position: "fixed",
24
- bottom: "8px",
25
- left: "50%",
26
- transform: "translateX(-50%)",
27
- zIndex: 99999,
28
- display: "inline-flex",
29
- alignItems: "center",
30
- gap: "12px",
31
- whiteSpace: "nowrap",
32
- padding: "8px 16px",
33
- fontSize: "13px",
34
- fontFamily:
35
- "-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif",
36
- borderRadius: "6px",
37
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
38
- },
39
- info: {
40
- backgroundColor: "#eff6ff",
41
- border: "1px solid #93c5fd",
42
- color: "#1e40af",
43
- },
44
- warning: {
45
- backgroundColor: "#fffbeb",
46
- border: "1px solid #fbbf24",
47
- color: "#92400e",
48
- },
49
- critical: {
50
- backgroundColor: "#fef2f2",
51
- border: "1px solid #fca5a5",
52
- color: "#991b1b",
53
- },
54
- };
55
-
56
- function getSeverityStyle(severity: string): React.CSSProperties {
57
- switch (severity) {
58
- case "warning":
59
- return BANNER_STYLES.warning;
60
- case "critical":
61
- return BANNER_STYLES.critical;
62
- default:
63
- return BANNER_STYLES.info;
64
- }
65
- }
66
-
67
- function BannerShell({
68
- severity,
69
- message,
70
- actionLabel,
71
- actionUrl,
72
- onDismiss,
73
- }: {
74
- severity: string;
75
- message: string;
76
- actionLabel: string;
77
- actionUrl: string;
78
- onDismiss?: () => void;
79
- }) {
80
- // Publish the banner's reserved bottom offset so the chat input can lift
81
- // itself above it via padding-bottom: var(--copilotkit-license-banner-offset).
82
- useEffect(() => {
83
- if (typeof document === "undefined") return;
84
- const root = document.documentElement;
85
- root.style.setProperty(
86
- LICENSE_BANNER_OFFSET_VAR,
87
- `${LICENSE_BANNER_OFFSET_PX}px`,
88
- );
89
- return () => {
90
- root.style.removeProperty(LICENSE_BANNER_OFFSET_VAR);
91
- };
92
- }, []);
93
-
94
- return (
95
- <div style={{ ...BANNER_STYLES.base, ...getSeverityStyle(severity) }}>
96
- <span>{message}</span>
97
- <div style={{ display: "flex", gap: "8px", alignItems: "center" }}>
98
- <a
99
- href={actionUrl}
100
- target="_blank"
101
- rel="noopener noreferrer"
102
- style={{
103
- fontWeight: 600,
104
- textDecoration: "underline",
105
- color: "inherit",
106
- }}
107
- >
108
- {actionLabel}
109
- </a>
110
- {onDismiss && (
111
- <button
112
- onClick={onDismiss}
113
- style={{
114
- background: "none",
115
- border: "none",
116
- cursor: "pointer",
117
- color: "inherit",
118
- fontSize: "16px",
119
- }}
120
- >
121
- ×
122
- </button>
123
- )}
124
- </div>
125
- </div>
126
- );
127
- }
128
-
129
- export function LicenseWarningBanner({
130
- type,
131
- featureName,
132
- expiryDate,
133
- graceRemaining,
134
- onDismiss,
135
- }: LicenseWarningBannerProps) {
136
- switch (type) {
137
- case "no_license":
138
- return (
139
- <BannerShell
140
- severity="info"
141
- message="Powered by CopilotKit"
142
- actionLabel="Get a license"
143
- actionUrl="https://copilotkit.ai/pricing"
144
- onDismiss={onDismiss}
145
- />
146
- );
147
- case "feature_unlicensed":
148
- return (
149
- <BannerShell
150
- severity="warning"
151
- message={`⚠ The "${featureName}" feature requires a CopilotKit license.`}
152
- actionLabel="Get a license"
153
- actionUrl="https://copilotkit.ai/pricing"
154
- onDismiss={onDismiss}
155
- />
156
- );
157
- case "expiring":
158
- return (
159
- <BannerShell
160
- severity="warning"
161
- message={`Your CopilotKit license expires in ${graceRemaining} day${graceRemaining !== 1 ? "s" : ""}. Please renew.`}
162
- actionLabel="Renew"
163
- actionUrl="https://cloud.copilotkit.ai"
164
- onDismiss={onDismiss}
165
- />
166
- );
167
- case "expired":
168
- return (
169
- <BannerShell
170
- severity="critical"
171
- message={`Your CopilotKit license expired${expiryDate ? ` on ${expiryDate}` : ""}. Please renew at copilotkit.ai/pricing`}
172
- actionLabel="Renew now"
173
- actionUrl="https://copilotkit.ai/pricing"
174
- onDismiss={onDismiss}
175
- />
176
- );
177
- case "invalid":
178
- return (
179
- <BannerShell
180
- severity="critical"
181
- message="Invalid CopilotKit license token. Please check your configuration."
182
- actionLabel="Get a license"
183
- actionUrl="https://copilotkit.ai/pricing"
184
- onDismiss={onDismiss}
185
- />
186
- );
187
- default:
188
- return null;
189
- }
190
- }
191
-
192
- export function InlineFeatureWarning({ featureName }: { featureName: string }) {
193
- return (
194
- <div
195
- style={{
196
- padding: "8px 12px",
197
- backgroundColor: "#fffbeb",
198
- border: "1px solid #fbbf24",
199
- borderRadius: "6px",
200
- fontSize: "13px",
201
- color: "#92400e",
202
- fontFamily:
203
- "-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif",
204
- }}
205
- >
206
- ⚠ The &quot;{featureName}&quot; feature requires a CopilotKit license.{" "}
207
- <a
208
- href="https://copilotkit.ai/pricing"
209
- target="_blank"
210
- rel="noopener noreferrer"
211
- style={{ color: "#b45309", textDecoration: "underline" }}
212
- >
213
- Get one at copilotkit.ai/pricing
214
- </a>
215
- </div>
216
- );
217
- }