@copilotkit/react-core 1.57.3 → 1.58.0

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 (282) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{copilotkit-CC8DjOiC.mjs → copilotkit-BIn7HE8f.mjs} +2 -2
  3. package/dist/{copilotkit-CC8DjOiC.mjs.map → copilotkit-BIn7HE8f.mjs.map} +1 -1
  4. package/dist/{copilotkit-CtXcs1ea.cjs → copilotkit-Drw-g6zA.cjs} +2 -2
  5. package/dist/{copilotkit-CtXcs1ea.cjs.map → copilotkit-Drw-g6zA.cjs.map} +1 -1
  6. package/dist/index.cjs +3 -77
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +2 -2
  9. package/dist/index.d.mts +2 -2
  10. package/dist/index.mjs +3 -77
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/index.umd.js +3 -77
  13. package/dist/index.umd.js.map +1 -1
  14. package/dist/v2/index.cjs +1 -1
  15. package/dist/v2/index.mjs +1 -1
  16. package/dist/v2/index.umd.js +1 -1
  17. package/dist/v2/index.umd.js.map +1 -1
  18. package/package.json +12 -13
  19. package/skills/react-core/SKILL.md +108 -0
  20. package/skills/react-core/references/agent-access.md +288 -0
  21. package/skills/react-core/references/attachments.md +291 -0
  22. package/skills/react-core/references/capabilities.md +138 -0
  23. package/skills/react-core/references/chat-components.md +221 -0
  24. package/skills/react-core/references/client-side-tools.md +358 -0
  25. package/skills/react-core/references/custom-message-renderers.md +226 -0
  26. package/skills/react-core/references/debug-mode.md +153 -0
  27. package/skills/react-core/references/human-in-the-loop.md +312 -0
  28. package/skills/react-core/references/provider-setup.md +326 -0
  29. package/skills/react-core/references/rendering-activity-messages.md +207 -0
  30. package/skills/react-core/references/rendering-tool-calls.md +319 -0
  31. package/skills/react-core/references/suggestions.md +211 -0
  32. package/skills/react-core/references/switching-agents-recipes.md +160 -0
  33. package/skills/react-core/references/switching-agents.md +231 -0
  34. package/skills/react-core/references/threads.md +226 -0
  35. package/.attw.json +0 -3
  36. package/CHANGELOG.md +0 -5043
  37. package/scripts/scope-preflight.mjs +0 -100
  38. package/src/components/CopilotListeners.tsx +0 -137
  39. package/src/components/__tests__/CopilotListeners.test.tsx +0 -38
  40. package/src/components/copilot-provider/__tests__/copilot-messages-key.test.tsx +0 -92
  41. package/src/components/copilot-provider/__tests__/copilotkit-error.test.tsx +0 -77
  42. package/src/components/copilot-provider/__tests__/error-visibility-prod.test.tsx +0 -70
  43. package/src/components/copilot-provider/__tests__/v1-explicit-threadid-bridge.test.tsx +0 -107
  44. package/src/components/copilot-provider/copilot-messages.tsx +0 -314
  45. package/src/components/copilot-provider/copilotkit-props.tsx +0 -214
  46. package/src/components/copilot-provider/copilotkit.tsx +0 -853
  47. package/src/components/copilot-provider/index.ts +0 -3
  48. package/src/components/dev-console/console-trigger.tsx +0 -283
  49. package/src/components/dev-console/developer-console-modal.tsx +0 -1016
  50. package/src/components/dev-console/icons.tsx +0 -106
  51. package/src/components/error-boundary/error-boundary.tsx +0 -99
  52. package/src/components/error-boundary/error-utils.tsx +0 -105
  53. package/src/components/index.ts +0 -1
  54. package/src/components/toast/exclamation-mark-icon.tsx +0 -27
  55. package/src/components/toast/toast-provider.tsx +0 -448
  56. package/src/components/usage-banner.tsx +0 -266
  57. package/src/context/__tests__/threads-context.test.tsx +0 -141
  58. package/src/context/coagent-state-renders-context.tsx +0 -89
  59. package/src/context/copilot-context.tsx +0 -365
  60. package/src/context/copilot-messages-context.tsx +0 -35
  61. package/src/context/index.ts +0 -22
  62. package/src/context/threads-context.tsx +0 -69
  63. package/src/hooks/__tests__/use-coagent-config.test.ts +0 -352
  64. package/src/hooks/__tests__/use-coagent-state-render-bridge.helpers.test.ts +0 -107
  65. package/src/hooks/__tests__/use-coagent-state-render.e2e.test.tsx +0 -1209
  66. package/src/hooks/__tests__/use-coagent-state-render.test.tsx +0 -356
  67. package/src/hooks/__tests__/use-copilot-chat-internal-connect.test.tsx +0 -241
  68. package/src/hooks/__tests__/use-frontend-tool-available.test.tsx +0 -72
  69. package/src/hooks/__tests__/use-frontend-tool-remount.e2e.test.tsx +0 -102
  70. package/src/hooks/index.ts +0 -33
  71. package/src/hooks/use-agent-nodename.ts +0 -33
  72. package/src/hooks/use-coagent-state-render-bridge.helpers.ts +0 -345
  73. package/src/hooks/use-coagent-state-render-bridge.tsx +0 -222
  74. package/src/hooks/use-coagent-state-render-registry.ts +0 -230
  75. package/src/hooks/use-coagent-state-render.ts +0 -163
  76. package/src/hooks/use-coagent.ts +0 -377
  77. package/src/hooks/use-configure-chat-suggestions.tsx +0 -96
  78. package/src/hooks/use-copilot-action.ts +0 -245
  79. package/src/hooks/use-copilot-additional-instructions.ts +0 -98
  80. package/src/hooks/use-copilot-authenticated-action.ts +0 -73
  81. package/src/hooks/use-copilot-chat-headless_c.ts +0 -264
  82. package/src/hooks/use-copilot-chat-suggestions.tsx +0 -134
  83. package/src/hooks/use-copilot-chat.ts +0 -132
  84. package/src/hooks/use-copilot-chat_internal.ts +0 -875
  85. package/src/hooks/use-copilot-readable.ts +0 -135
  86. package/src/hooks/use-copilot-runtime-client.ts +0 -178
  87. package/src/hooks/use-default-tool.ts +0 -13
  88. package/src/hooks/use-flat-category-store.ts +0 -109
  89. package/src/hooks/use-frontend-tool.ts +0 -113
  90. package/src/hooks/use-human-in-the-loop.ts +0 -138
  91. package/src/hooks/use-langgraph-interrupt.ts +0 -103
  92. package/src/hooks/use-lazy-tool-renderer.tsx +0 -30
  93. package/src/hooks/use-make-copilot-document-readable.ts +0 -30
  94. package/src/hooks/use-render-tool-call.ts +0 -89
  95. package/src/hooks/use-tree.ts +0 -222
  96. package/src/index.tsx +0 -7
  97. package/src/lib/copilot-task.ts +0 -215
  98. package/src/lib/index.ts +0 -1
  99. package/src/lib/status-checker.ts +0 -67
  100. package/src/setupTests.ts +0 -37
  101. package/src/test-helpers/copilot-context.ts +0 -91
  102. package/src/types/chat-suggestion-configuration.ts +0 -23
  103. package/src/types/coagent-action.ts +0 -35
  104. package/src/types/coagent-state.ts +0 -13
  105. package/src/types/crew.ts +0 -89
  106. package/src/types/document-pointer.ts +0 -7
  107. package/src/types/frontend-action.ts +0 -213
  108. package/src/types/index.ts +0 -17
  109. package/src/types/interrupt-action.ts +0 -58
  110. package/src/types/system-message.ts +0 -4
  111. package/src/utils/dev-console.ts +0 -19
  112. package/src/utils/index.ts +0 -2
  113. package/src/utils/suggestions-constants.ts +0 -8
  114. package/src/utils/utils.test.ts +0 -7
  115. package/src/utils/utils.ts +0 -6
  116. package/src/v2/__tests__/A2UIMessageRenderer.test.tsx +0 -240
  117. package/src/v2/__tests__/globalSetup.ts +0 -14
  118. package/src/v2/__tests__/setup.ts +0 -93
  119. package/src/v2/__tests__/utils/test-helpers.tsx +0 -570
  120. package/src/v2/a2ui/A2UICatalogContext.tsx +0 -79
  121. package/src/v2/a2ui/A2UIMessageRenderer.tsx +0 -294
  122. package/src/v2/a2ui/A2UIToolCallRenderer.tsx +0 -290
  123. package/src/v2/components/CopilotKitInspector.tsx +0 -52
  124. package/src/v2/components/MCPAppsActivityRenderer.tsx +0 -815
  125. package/src/v2/components/OpenGenerativeUIRenderer.tsx +0 -598
  126. package/src/v2/components/WildcardToolCallRender.tsx +0 -86
  127. package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.tsx +0 -665
  128. package/src/v2/components/chat/CopilotChat.tsx +0 -664
  129. package/src/v2/components/chat/CopilotChatAssistantMessage.tsx +0 -393
  130. package/src/v2/components/chat/CopilotChatAttachmentQueue.tsx +0 -374
  131. package/src/v2/components/chat/CopilotChatAttachmentRenderer.tsx +0 -159
  132. package/src/v2/components/chat/CopilotChatAudioRecorder.tsx +0 -350
  133. package/src/v2/components/chat/CopilotChatInput.tsx +0 -1412
  134. package/src/v2/components/chat/CopilotChatMessageView.tsx +0 -716
  135. package/src/v2/components/chat/CopilotChatReasoningMessage.tsx +0 -265
  136. package/src/v2/components/chat/CopilotChatSuggestionPill.tsx +0 -59
  137. package/src/v2/components/chat/CopilotChatSuggestionView.tsx +0 -134
  138. package/src/v2/components/chat/CopilotChatToggleButton.tsx +0 -171
  139. package/src/v2/components/chat/CopilotChatToolCallsView.tsx +0 -40
  140. package/src/v2/components/chat/CopilotChatUserMessage.tsx +0 -445
  141. package/src/v2/components/chat/CopilotChatView.tsx +0 -890
  142. package/src/v2/components/chat/CopilotModalHeader.tsx +0 -129
  143. package/src/v2/components/chat/CopilotPopup.tsx +0 -81
  144. package/src/v2/components/chat/CopilotPopupView.tsx +0 -317
  145. package/src/v2/components/chat/CopilotSidebar.tsx +0 -80
  146. package/src/v2/components/chat/CopilotSidebarView.tsx +0 -269
  147. package/src/v2/components/chat/Lightbox.tsx +0 -103
  148. package/src/v2/components/chat/__tests__/CopilotChat.absentThreadConnect.test.tsx +0 -66
  149. package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.tsx +0 -168
  150. package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.tsx +0 -1239
  151. package/src/v2/components/chat/__tests__/CopilotChat.onError.test.tsx +0 -73
  152. package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.tsx +0 -432
  153. package/src/v2/components/chat/__tests__/CopilotChat.suggestionsAlways.test.tsx +0 -183
  154. package/src/v2/components/chat/__tests__/CopilotChat.welcomeGate.test.tsx +0 -184
  155. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.tsx +0 -649
  156. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.tsx +0 -624
  157. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx +0 -702
  158. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.thumbs.test.tsx +0 -72
  159. package/src/v2/components/chat/__tests__/CopilotChatCopyButton.clipboard.test.tsx +0 -241
  160. package/src/v2/components/chat/__tests__/CopilotChatCssClasses.test.tsx +0 -107
  161. package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.tsx +0 -929
  162. package/src/v2/components/chat/__tests__/CopilotChatInput.test.tsx +0 -1567
  163. package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.tsx +0 -1004
  164. package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.tsx +0 -279
  165. package/src/v2/components/chat/__tests__/CopilotChatPerf.e2e.test.tsx +0 -336
  166. package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.tsx +0 -249
  167. package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.tsx +0 -530
  168. package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.tsx +0 -785
  169. package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.tsx +0 -2416
  170. package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.tsx +0 -621
  171. package/src/v2/components/chat/__tests__/CopilotChatView.connectingGate.test.tsx +0 -56
  172. package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.tsx +0 -264
  173. package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.tsx +0 -853
  174. package/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.tsx +0 -94
  175. package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.tsx +0 -1050
  176. package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.tsx +0 -484
  177. package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.tsx +0 -612
  178. package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.tsx +0 -159
  179. package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.tsx +0 -502
  180. package/src/v2/components/chat/__tests__/MCPAppsActivityRenderer.e2e.test.tsx +0 -1068
  181. package/src/v2/components/chat/__tests__/MCPAppsProxy.e2e.test.tsx +0 -589
  182. package/src/v2/components/chat/__tests__/MCPAppsUiMessage.e2e.test.tsx +0 -403
  183. package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.tsx +0 -137
  184. package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +0 -37
  185. package/src/v2/components/chat/__tests__/setup.ts +0 -1
  186. package/src/v2/components/chat/index.ts +0 -90
  187. package/src/v2/components/chat/last-user-message-context.ts +0 -21
  188. package/src/v2/components/chat/normalize-auto-scroll.ts +0 -17
  189. package/src/v2/components/chat/scroll-element-context.ts +0 -13
  190. package/src/v2/components/index.ts +0 -8
  191. package/src/v2/components/intelligence-indicator/IntelligenceIndicator.tsx +0 -286
  192. package/src/v2/components/intelligence-indicator/__tests__/IntelligenceIndicator.e2e.test.tsx +0 -464
  193. package/src/v2/components/intelligence-indicator/index.ts +0 -2
  194. package/src/v2/components/license-warning-banner.tsx +0 -217
  195. package/src/v2/components/ui/button.tsx +0 -124
  196. package/src/v2/components/ui/dropdown-menu.tsx +0 -258
  197. package/src/v2/components/ui/tooltip.tsx +0 -60
  198. package/src/v2/context.ts +0 -62
  199. package/src/v2/headless.ts +0 -64
  200. package/src/v2/hooks/__tests__/standard-schema-types.test.tsx +0 -152
  201. package/src/v2/hooks/__tests__/standard-schema.test.tsx +0 -282
  202. package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.tsx +0 -140
  203. package/src/v2/hooks/__tests__/use-agent-context.test.tsx +0 -401
  204. package/src/v2/hooks/__tests__/use-agent-error-state.test.tsx +0 -44
  205. package/src/v2/hooks/__tests__/use-agent-stability.test.tsx +0 -211
  206. package/src/v2/hooks/__tests__/use-agent-throttle.test.tsx +0 -1029
  207. package/src/v2/hooks/__tests__/use-agent.e2e.test.tsx +0 -159
  208. package/src/v2/hooks/__tests__/use-attachments.test.tsx +0 -169
  209. package/src/v2/hooks/__tests__/use-capabilities.test.tsx +0 -76
  210. package/src/v2/hooks/__tests__/use-component.test.tsx +0 -126
  211. package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.tsx +0 -696
  212. package/src/v2/hooks/__tests__/use-default-render-tool.test.tsx +0 -153
  213. package/src/v2/hooks/__tests__/use-frontend-tool-available.test.tsx +0 -167
  214. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.tsx +0 -2148
  215. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.tsx +0 -1261
  216. package/src/v2/hooks/__tests__/use-interrupt.test.tsx +0 -397
  217. package/src/v2/hooks/__tests__/use-katex-styles.test.tsx +0 -56
  218. package/src/v2/hooks/__tests__/use-keyboard-height.test.tsx +0 -192
  219. package/src/v2/hooks/__tests__/use-pin-to-send.test.tsx +0 -219
  220. package/src/v2/hooks/__tests__/use-render-custom-messages.test.tsx +0 -55
  221. package/src/v2/hooks/__tests__/use-render-tool.test.tsx +0 -259
  222. package/src/v2/hooks/__tests__/use-suggestions.e2e.test.tsx +0 -524
  223. package/src/v2/hooks/__tests__/use-threads.test.tsx +0 -757
  224. package/src/v2/hooks/__tests__/zod-regression.test.tsx +0 -311
  225. package/src/v2/hooks/index.ts +0 -24
  226. package/src/v2/hooks/use-agent-context.tsx +0 -45
  227. package/src/v2/hooks/use-agent.tsx +0 -227
  228. package/src/v2/hooks/use-attachments.tsx +0 -269
  229. package/src/v2/hooks/use-capabilities.tsx +0 -25
  230. package/src/v2/hooks/use-component.tsx +0 -91
  231. package/src/v2/hooks/use-configure-suggestions.tsx +0 -236
  232. package/src/v2/hooks/use-default-render-tool.tsx +0 -271
  233. package/src/v2/hooks/use-frontend-tool.tsx +0 -46
  234. package/src/v2/hooks/use-human-in-the-loop.tsx +0 -81
  235. package/src/v2/hooks/use-interrupt.tsx +0 -305
  236. package/src/v2/hooks/use-keyboard-height.tsx +0 -67
  237. package/src/v2/hooks/use-pin-to-send.ts +0 -94
  238. package/src/v2/hooks/use-render-activity-message.tsx +0 -72
  239. package/src/v2/hooks/use-render-custom-messages.tsx +0 -93
  240. package/src/v2/hooks/use-render-tool-call.tsx +0 -208
  241. package/src/v2/hooks/use-render-tool.tsx +0 -184
  242. package/src/v2/hooks/use-suggestions.tsx +0 -91
  243. package/src/v2/hooks/use-threads.tsx +0 -325
  244. package/src/v2/hooks/useKatexStyles.ts +0 -27
  245. package/src/v2/index.css +0 -1
  246. package/src/v2/index.ts +0 -27
  247. package/src/v2/lib/__tests__/completePartialMarkdown.test.ts +0 -495
  248. package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -112
  249. package/src/v2/lib/__tests__/renderSlot.test.tsx +0 -588
  250. package/src/v2/lib/__tests__/slots.test.ts +0 -56
  251. package/src/v2/lib/processPartialHtml.ts +0 -45
  252. package/src/v2/lib/react-core.ts +0 -156
  253. package/src/v2/lib/slots.tsx +0 -184
  254. package/src/v2/lib/transcription-client.ts +0 -184
  255. package/src/v2/lib/utils.ts +0 -8
  256. package/src/v2/providers/CopilotChatConfigurationProvider.tsx +0 -196
  257. package/src/v2/providers/CopilotKitProvider.tsx +0 -800
  258. package/src/v2/providers/SandboxFunctionsContext.ts +0 -10
  259. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.tsx +0 -652
  260. package/src/v2/providers/__tests__/CopilotKitProvider.license.test.tsx +0 -101
  261. package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.tsx +0 -69
  262. package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.tsx +0 -881
  263. package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.tsx +0 -198
  264. package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.tsx +0 -740
  265. package/src/v2/providers/__tests__/CopilotKitProvider.test.tsx +0 -713
  266. package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.tsx +0 -294
  267. package/src/v2/providers/index.ts +0 -21
  268. package/src/v2/styles/globals.css +0 -349
  269. package/src/v2/types/__tests__/defineToolCallRenderer.test.tsx +0 -525
  270. package/src/v2/types/defineToolCallRenderer.ts +0 -68
  271. package/src/v2/types/frontend-tool.ts +0 -8
  272. package/src/v2/types/human-in-the-loop.ts +0 -33
  273. package/src/v2/types/index.ts +0 -8
  274. package/src/v2/types/interrupt.ts +0 -15
  275. package/src/v2/types/react-activity-message-renderer.ts +0 -27
  276. package/src/v2/types/react-custom-message-renderer.ts +0 -17
  277. package/src/v2/types/react-tool-call-renderer.ts +0 -35
  278. package/src/v2/types/sandbox-function.ts +0 -11
  279. package/tsconfig.json +0 -8
  280. package/tsdown.config.ts +0 -193
  281. package/typedoc.json +0 -4
  282. package/vitest.config.mjs +0 -31
@@ -1,785 +0,0 @@
1
- import React from "react";
2
- import { render, screen, fireEvent, waitFor } from "@testing-library/react";
3
- import { z } from "zod";
4
- import {
5
- CopilotKitProvider,
6
- useCopilotKit,
7
- } from "../../../providers/CopilotKitProvider";
8
- import { CopilotChat } from "../CopilotChat";
9
- import {
10
- AbstractAgent,
11
- EventType,
12
- type BaseEvent,
13
- type RunAgentInput,
14
- } from "@ag-ui/client";
15
- import { Observable, Subject } from "rxjs";
16
- import {
17
- defineToolCallRenderer,
18
- ReactToolCallRenderer,
19
- ReactFrontendTool,
20
- } from "../../../types";
21
- import CopilotChatToolCallsView from "../CopilotChatToolCallsView";
22
- import { CopilotChatConfigurationProvider } from "../../../providers/CopilotChatConfigurationProvider";
23
- import { AssistantMessage, Message, ToolMessage } from "@ag-ui/core";
24
- import { ToolCallStatus } from "@copilotkit/core";
25
- import { useFrontendTool } from "../../../hooks/use-frontend-tool";
26
-
27
- // A minimal mock agent that streams a tool call and a result
28
- class MockStreamingAgent extends AbstractAgent {
29
- clone(): MockStreamingAgent {
30
- return new MockStreamingAgent();
31
- }
32
-
33
- async detachActiveRun(): Promise<void> {}
34
-
35
- run(_input: RunAgentInput): Observable<BaseEvent> {
36
- return new Observable<BaseEvent>((observer) => {
37
- const messageId = `m_${Date.now()}`;
38
- const toolCallId = `tc_${Date.now()}`;
39
-
40
- // Start run
41
- observer.next({ type: EventType.RUN_STARTED } as BaseEvent);
42
-
43
- // Stream assistant text chunks
44
- observer.next({
45
- type: EventType.TEXT_MESSAGE_CHUNK,
46
- messageId,
47
- delta: "I will check the weather.",
48
- } as BaseEvent);
49
-
50
- // Start tool call (first chunk contains name + first args)
51
- observer.next({
52
- type: EventType.TOOL_CALL_CHUNK,
53
- toolCallId,
54
- toolCallName: "getWeather",
55
- parentMessageId: messageId,
56
- delta: '{"location":"Paris","unit":"c',
57
- } as BaseEvent);
58
-
59
- // Continue tool call args
60
- observer.next({
61
- type: EventType.TOOL_CALL_CHUNK,
62
- toolCallId,
63
- parentMessageId: messageId,
64
- delta: 'elsius"}',
65
- } as BaseEvent);
66
-
67
- // Tool result
68
- observer.next({
69
- type: EventType.TOOL_CALL_RESULT,
70
- toolCallId,
71
- messageId: `${messageId}_result`,
72
- content: JSON.stringify({ temperature: 21, unit: "celsius" }),
73
- } as BaseEvent);
74
-
75
- // Finish run
76
- observer.next({ type: EventType.RUN_FINISHED } as BaseEvent);
77
- observer.complete();
78
-
79
- return () => {};
80
- });
81
- }
82
- }
83
-
84
- describe("CopilotChat tool rendering with mock agent", () => {
85
- function renderWithProvider() {
86
- const agents = { default: new MockStreamingAgent() };
87
- const renderToolCalls = [
88
- defineToolCallRenderer({
89
- name: "getWeather",
90
- args: z.object({
91
- location: z.string(),
92
- unit: z.string(),
93
- }),
94
- render: ({ name, args, result }) => (
95
- <div data-testid="weather-result">
96
- Tool: {name} | args: {args.location}-{args.unit} | result:{" "}
97
- {String(result ?? "")}
98
- </div>
99
- ),
100
- }),
101
- ] as unknown as ReactToolCallRenderer<unknown>[];
102
-
103
- return render(
104
- <CopilotKitProvider
105
- agents__unsafe_dev_only={agents}
106
- renderToolCalls={renderToolCalls}
107
- >
108
- <div style={{ height: 400 }}>
109
- <CopilotChat />
110
- </div>
111
- </CopilotKitProvider>,
112
- );
113
- }
114
-
115
- it("renders the tool component when the agent emits a tool call and result", async () => {
116
- renderWithProvider();
117
-
118
- // Type a message and submit
119
- const input = await screen.findByRole("textbox");
120
- fireEvent.change(input, { target: { value: "What is the weather?" } });
121
- fireEvent.keyDown(input, { key: "Enter", code: "Enter" });
122
-
123
- // Assert that our tool render appears with the expected test id
124
- const tool = await screen.findByTestId("weather-result");
125
- expect(tool).toBeDefined();
126
-
127
- // Optionally, ensure result content shows up (from our mock agent)
128
- await waitFor(() => {
129
- expect(tool.textContent).toMatch(/temperature/);
130
- expect(tool.textContent).toMatch(/celsius/);
131
- });
132
- });
133
- });
134
-
135
- describe("Tool render status narrowing", () => {
136
- function renderStatusWithProvider({
137
- isRunning,
138
- withResult,
139
- }: {
140
- isRunning: boolean;
141
- withResult: boolean;
142
- }) {
143
- const renderToolCalls = [
144
- defineToolCallRenderer({
145
- name: "getWeather",
146
- args: z.object({ city: z.string().optional() }),
147
- render: ({ status, args, result }) => {
148
- if (status === ToolCallStatus.InProgress) {
149
- return (
150
- <div data-testid="status">
151
- INPROGRESS {String(args.city ?? "")}
152
- </div>
153
- );
154
- }
155
- if (status === ToolCallStatus.Executing) {
156
- return <div data-testid="status">EXECUTING {args.city}</div>;
157
- }
158
- // ToolCallStatus.Complete
159
- return (
160
- <div data-testid="status">
161
- COMPLETE {args.city} {String(result ?? "")}
162
- </div>
163
- );
164
- },
165
- }),
166
- ] as unknown as ReactToolCallRenderer<unknown>[];
167
-
168
- const toolCallId = "tc_status_1";
169
-
170
- const assistantMessage: AssistantMessage = {
171
- id: "a1",
172
- role: "assistant",
173
- content: "",
174
- toolCalls: [
175
- {
176
- id: toolCallId,
177
- type: "function",
178
- function: { name: "getWeather", arguments: '{"city":"Berlin"}' },
179
- } as any,
180
- ],
181
- } as AssistantMessage;
182
-
183
- const messages: Message[] = [];
184
- if (withResult) {
185
- messages.push({
186
- id: "t1",
187
- role: "tool",
188
- toolCallId,
189
- content: "Sunny",
190
- } as ToolMessage as any);
191
- }
192
-
193
- return render(
194
- <CopilotKitProvider renderToolCalls={renderToolCalls}>
195
- <CopilotChatConfigurationProvider
196
- agentId="default"
197
- threadId="test-thread"
198
- >
199
- <CopilotChatToolCallsView
200
- message={assistantMessage}
201
- messages={messages}
202
- />
203
- </CopilotChatConfigurationProvider>
204
- </CopilotKitProvider>,
205
- );
206
- }
207
-
208
- it("renders InProgress when running and no result", async () => {
209
- renderStatusWithProvider({ isRunning: true, withResult: false });
210
- const el = await screen.findByTestId("status");
211
- expect(el.textContent).toMatch(/INPROGRESS/);
212
- expect(el.textContent).toMatch(/Berlin/);
213
- });
214
-
215
- it("renders Complete with result when tool message exists", async () => {
216
- renderStatusWithProvider({ isRunning: false, withResult: true });
217
- const el = await screen.findByTestId("status");
218
- expect(el.textContent).toMatch(/COMPLETE/);
219
- expect(el.textContent).toMatch(/Berlin/);
220
- expect(el.textContent).toMatch(/Sunny/);
221
- });
222
-
223
- it("renders InProgress when not running and no tool result", async () => {
224
- renderStatusWithProvider({ isRunning: false, withResult: false });
225
- const el = await screen.findByTestId("status");
226
- expect(el.textContent).toMatch(/INPROGRESS/);
227
- expect(el.textContent).toMatch(/Berlin/);
228
- });
229
- });
230
-
231
- // A controllable streaming agent to step through events deterministically
232
- class MockStepwiseAgent extends AbstractAgent {
233
- private subject = new Subject<BaseEvent>();
234
-
235
- emit(event: BaseEvent) {
236
- if (event.type === EventType.RUN_STARTED) {
237
- this.isRunning = true;
238
- } else if (
239
- event.type === EventType.RUN_FINISHED ||
240
- event.type === EventType.RUN_ERROR
241
- ) {
242
- this.isRunning = false;
243
- }
244
- this.subject.next(event);
245
- }
246
-
247
- complete() {
248
- this.isRunning = false;
249
- this.subject.complete();
250
- }
251
-
252
- clone(): MockStepwiseAgent {
253
- const cloned = new MockStepwiseAgent();
254
- cloned.agentId = this.agentId;
255
- (cloned as unknown as { subject: Subject<BaseEvent> }).subject =
256
- this.subject;
257
- return cloned;
258
- }
259
-
260
- async detachActiveRun(): Promise<void> {}
261
-
262
- run(_input: RunAgentInput): Observable<BaseEvent> {
263
- return this.subject.asObservable();
264
- }
265
- }
266
-
267
- describe("Streaming in-progress without timers", () => {
268
- it("shows InProgress for partial args and Complete after result", async () => {
269
- const agent = new MockStepwiseAgent();
270
-
271
- const renderToolCalls = [
272
- defineToolCallRenderer({
273
- name: "getWeather",
274
- args: z.object({
275
- location: z.string(),
276
- unit: z.string(),
277
- }),
278
- render: ({ name, status, args, result }) => (
279
- <div data-testid="tool-status">
280
- {name}{" "}
281
- {status === ToolCallStatus.InProgress ? "INPROGRESS" : "COMPLETE"}{" "}
282
- {String(args.location ?? "")} - {String(args.unit ?? "")}{" "}
283
- {String(result ?? "")}
284
- </div>
285
- ),
286
- }),
287
- ] as unknown as ReactToolCallRenderer<unknown>[];
288
-
289
- render(
290
- <CopilotKitProvider
291
- agents__unsafe_dev_only={{ default: agent }}
292
- renderToolCalls={renderToolCalls}
293
- >
294
- <div style={{ height: 400 }}>
295
- <CopilotChat />
296
- </div>
297
- </CopilotKitProvider>,
298
- );
299
-
300
- // Submit a user message to trigger runAgent
301
- const input = await screen.findByRole("textbox");
302
- fireEvent.change(input, { target: { value: "Weather please" } });
303
- fireEvent.keyDown(input, { key: "Enter", code: "Enter" });
304
-
305
- // Allow React to process the state update
306
- await waitFor(() => {
307
- expect(screen.getByText("Weather please")).toBeDefined();
308
- });
309
-
310
- const messageId = "m_step";
311
- const toolCallId = "tc_step";
312
-
313
- // Begin run and stream partial tool-call args
314
- agent.emit({ type: EventType.RUN_STARTED } as BaseEvent);
315
- agent.emit({
316
- type: EventType.TEXT_MESSAGE_CHUNK,
317
- messageId,
318
- delta: "Checking weather",
319
- } as BaseEvent);
320
-
321
- // First emit just the tool call start with partial args
322
- agent.emit({
323
- type: EventType.TOOL_CALL_CHUNK,
324
- toolCallId,
325
- toolCallName: "getWeather",
326
- parentMessageId: messageId,
327
- delta: '{"location":"Paris"',
328
- } as BaseEvent);
329
-
330
- // Wait for the tool status element to show partial args
331
- await waitFor(async () => {
332
- const el = await screen.findByTestId("tool-status");
333
- expect(el.textContent).toContain("getWeather INPROGRESS");
334
- expect(el.textContent).toContain("Paris");
335
- });
336
-
337
- // Continue streaming more partial data
338
- agent.emit({
339
- type: EventType.TOOL_CALL_CHUNK,
340
- toolCallId,
341
- parentMessageId: messageId,
342
- delta: ',"unit":"celsius"}',
343
- } as BaseEvent);
344
-
345
- // Wait for the tool status element and check it shows complete args but no result yet
346
- await waitFor(
347
- async () => {
348
- const el = await screen.findByTestId("tool-status");
349
- expect(el.textContent).toContain("getWeather");
350
- expect(el.textContent).toContain("Paris");
351
- expect(el.textContent).toContain("celsius");
352
- // Since we haven't sent a result yet, it should be INPROGRESS
353
- expect(el.textContent).toMatch(/INPROGRESS/);
354
- },
355
- { timeout: 3000 },
356
- );
357
-
358
- // Now send the tool result
359
- agent.emit({
360
- type: EventType.TOOL_CALL_RESULT,
361
- toolCallId,
362
- messageId: `${messageId}_result`,
363
- content: JSON.stringify({ temperature: 21, unit: "celsius" }),
364
- } as BaseEvent);
365
-
366
- // Check result appears and status changes to COMPLETE
367
- await waitFor(async () => {
368
- const el = await screen.findByTestId("tool-status");
369
- expect(el.textContent).toMatch(/COMPLETE/);
370
- expect(el.textContent).toContain("temperature");
371
- expect(el.textContent).toContain("21");
372
- });
373
-
374
- agent.emit({ type: EventType.RUN_FINISHED } as BaseEvent);
375
- agent.complete();
376
- });
377
- });
378
-
379
- describe("Executing State Transitions", () => {
380
- it("should show Executing status while tool handler is running", async () => {
381
- const agent = new MockStepwiseAgent();
382
- let resolveHandler: (() => void) | undefined;
383
-
384
- const ToolWithDeferredHandler: React.FC = () => {
385
- const tool: ReactFrontendTool<{ value: string }> = {
386
- name: "slowTool",
387
- parameters: z.object({ value: z.string() }),
388
- handler: async () =>
389
- new Promise((resolve) => {
390
- resolveHandler = () => resolve({ result: "done" });
391
- }),
392
- render: ({ name, status, args, result }) => (
393
- <div data-testid="slow-tool-status">
394
- Tool: {name} | Status: {status} | Value: {args.value} | Result:{" "}
395
- {result ? "Complete" : "Pending"}
396
- </div>
397
- ),
398
- };
399
-
400
- useFrontendTool(tool);
401
- return null;
402
- };
403
-
404
- render(
405
- <CopilotKitProvider agents__unsafe_dev_only={{ default: agent }}>
406
- <ToolWithDeferredHandler />
407
- <div style={{ height: 400 }}>
408
- <CopilotChat />
409
- </div>
410
- </CopilotKitProvider>,
411
- );
412
-
413
- const input = await screen.findByRole("textbox");
414
- fireEvent.change(input, { target: { value: "Run slow tool" } });
415
- fireEvent.keyDown(input, { key: "Enter", code: "Enter" });
416
-
417
- await waitFor(() => {
418
- expect(screen.getByText("Run slow tool")).toBeDefined();
419
- });
420
-
421
- const messageId = "m_exec";
422
- const toolCallId = "tc_exec";
423
-
424
- agent.emit({ type: EventType.RUN_STARTED } as BaseEvent);
425
- agent.emit({
426
- type: EventType.TOOL_CALL_CHUNK,
427
- toolCallId,
428
- toolCallName: "slowTool",
429
- parentMessageId: messageId,
430
- delta: '{"value":"test"}',
431
- } as BaseEvent);
432
-
433
- await waitFor(() => {
434
- const status = screen.getByTestId("slow-tool-status");
435
- expect(status.textContent).toMatch(/Status: inProgress/i);
436
- expect(status.textContent).toMatch(/Value: test/);
437
- });
438
-
439
- agent.emit({ type: EventType.RUN_FINISHED } as BaseEvent);
440
- agent.complete();
441
-
442
- await waitFor(() => {
443
- const status = screen.getByTestId("slow-tool-status");
444
- expect(status.textContent).toMatch(/Status: executing/i);
445
- expect(resolveHandler).toBeTruthy();
446
- });
447
-
448
- if (resolveHandler) {
449
- resolveHandler();
450
- }
451
-
452
- await waitFor(() => {
453
- const status = screen.getByTestId("slow-tool-status");
454
- expect(status.textContent).toMatch(/Status: complete/i);
455
- expect(status.textContent).toMatch(/Result: Complete/);
456
- });
457
- });
458
- });
459
-
460
- describe("Multiple Tool Calls in Same Message", () => {
461
- it("should render multiple tools independently with their own status", async () => {
462
- const agent = new MockStepwiseAgent();
463
-
464
- const renderToolCalls = [
465
- defineToolCallRenderer({
466
- name: "tool1",
467
- args: z.object({ id: z.string() }),
468
- render: ({ status, args, result }) => (
469
- <div data-testid={`tool1-${args.id}`}>
470
- Tool1[{args.id}]: {status} -{" "}
471
- {result ? JSON.stringify(result) : "waiting"}
472
- </div>
473
- ),
474
- }),
475
- defineToolCallRenderer({
476
- name: "tool2",
477
- args: z.object({ id: z.string() }),
478
- render: ({ status, args, result }) => (
479
- <div data-testid={`tool2-${args.id}`}>
480
- Tool2[{args.id}]: {status} -{" "}
481
- {result ? JSON.stringify(result) : "waiting"}
482
- </div>
483
- ),
484
- }),
485
- ] as unknown as ReactToolCallRenderer<unknown>[];
486
-
487
- render(
488
- <CopilotKitProvider
489
- agents__unsafe_dev_only={{ default: agent }}
490
- renderToolCalls={renderToolCalls}
491
- >
492
- <div style={{ height: 400 }}>
493
- <CopilotChat />
494
- </div>
495
- </CopilotKitProvider>,
496
- );
497
-
498
- // Submit message
499
- const input = await screen.findByRole("textbox");
500
- fireEvent.change(input, { target: { value: "Multiple tools" } });
501
- fireEvent.keyDown(input, { key: "Enter", code: "Enter" });
502
-
503
- // Allow React to process the state update
504
- await waitFor(() => {
505
- expect(screen.getByText("Multiple tools")).toBeDefined();
506
- });
507
-
508
- const messageId = "m_multi";
509
- const toolCallId1 = "tc_1";
510
- const toolCallId2 = "tc_2";
511
- const toolCallId3 = "tc_3";
512
-
513
- agent.emit({ type: EventType.RUN_STARTED } as BaseEvent);
514
-
515
- // Stream three tool calls (2 of tool1, 1 of tool2)
516
- agent.emit({
517
- type: EventType.TOOL_CALL_CHUNK,
518
- toolCallId: toolCallId1,
519
- toolCallName: "tool1",
520
- parentMessageId: messageId,
521
- delta: '{"id":"first"}',
522
- } as BaseEvent);
523
-
524
- agent.emit({
525
- type: EventType.TOOL_CALL_CHUNK,
526
- toolCallId: toolCallId2,
527
- toolCallName: "tool2",
528
- parentMessageId: messageId,
529
- delta: '{"id":"second"}',
530
- } as BaseEvent);
531
-
532
- agent.emit({
533
- type: EventType.TOOL_CALL_CHUNK,
534
- toolCallId: toolCallId3,
535
- toolCallName: "tool1",
536
- parentMessageId: messageId,
537
- delta: '{"id":"third"}',
538
- } as BaseEvent);
539
-
540
- // All three should render
541
- await waitFor(() => {
542
- expect(screen.getByTestId("tool1-first")).toBeDefined();
543
- expect(screen.getByTestId("tool2-second")).toBeDefined();
544
- expect(screen.getByTestId("tool1-third")).toBeDefined();
545
- });
546
-
547
- // Send results in different order
548
- agent.emit({
549
- type: EventType.TOOL_CALL_RESULT,
550
- toolCallId: toolCallId2,
551
- messageId: `${messageId}_r2`,
552
- content: JSON.stringify({ result: "B" }),
553
- } as BaseEvent);
554
-
555
- await waitFor(() => {
556
- const tool2 = screen.getByTestId("tool2-second");
557
- expect(tool2.textContent).toContain("B");
558
- });
559
-
560
- agent.emit({
561
- type: EventType.TOOL_CALL_RESULT,
562
- toolCallId: toolCallId1,
563
- messageId: `${messageId}_r1`,
564
- content: JSON.stringify({ result: "A" }),
565
- } as BaseEvent);
566
-
567
- agent.emit({
568
- type: EventType.TOOL_CALL_RESULT,
569
- toolCallId: toolCallId3,
570
- messageId: `${messageId}_r3`,
571
- content: JSON.stringify({ result: "C" }),
572
- } as BaseEvent);
573
-
574
- // All results should be visible
575
- await waitFor(() => {
576
- expect(screen.getByTestId("tool1-first").textContent).toContain("A");
577
- expect(screen.getByTestId("tool2-second").textContent).toContain("B");
578
- expect(screen.getByTestId("tool1-third").textContent).toContain("C");
579
- });
580
-
581
- agent.emit({ type: EventType.RUN_FINISHED } as BaseEvent);
582
- agent.complete();
583
- });
584
- });
585
-
586
- describe("Partial Args Accumulation", () => {
587
- it("should properly show InProgress status with accumulating partial args", async () => {
588
- const agent = new MockStepwiseAgent();
589
-
590
- const renderToolCalls = [
591
- defineToolCallRenderer({
592
- name: "complexTool",
593
- args: z.object({
594
- name: z.string().optional(),
595
- age: z.number().optional(),
596
- city: z.string().optional(),
597
- }),
598
- render: ({ status, args }) => (
599
- <div data-testid="complex-tool">
600
- <div>Status: {status}</div>
601
- <div>Name: {args.name || "pending"}</div>
602
- <div>Age: {args.age !== undefined ? args.age : "pending"}</div>
603
- <div>City: {args.city || "pending"}</div>
604
- </div>
605
- ),
606
- }),
607
- ] as unknown as ReactToolCallRenderer<unknown>[];
608
-
609
- render(
610
- <CopilotKitProvider
611
- agents__unsafe_dev_only={{ default: agent }}
612
- renderToolCalls={renderToolCalls}
613
- >
614
- <div style={{ height: 400 }}>
615
- <CopilotChat />
616
- </div>
617
- </CopilotKitProvider>,
618
- );
619
-
620
- // Submit message
621
- const input = await screen.findByRole("textbox");
622
- fireEvent.change(input, { target: { value: "Complex tool test" } });
623
- fireEvent.keyDown(input, { key: "Enter", code: "Enter" });
624
-
625
- // Allow React to process the state update
626
- await waitFor(() => {
627
- expect(screen.getByText("Complex tool test")).toBeDefined();
628
- });
629
-
630
- const messageId = "m_partial";
631
- const toolCallId = "tc_partial";
632
-
633
- agent.emit({ type: EventType.RUN_STARTED } as BaseEvent);
634
-
635
- // Stream args piece by piece
636
- agent.emit({
637
- type: EventType.TOOL_CALL_CHUNK,
638
- toolCallId,
639
- toolCallName: "complexTool",
640
- parentMessageId: messageId,
641
- delta: '{"name":"',
642
- } as BaseEvent);
643
-
644
- // Let React update with the partial data
645
- await waitFor(() => {
646
- const tool = screen.queryByTestId("complex-tool");
647
- expect(tool).toBeDefined();
648
- });
649
-
650
- agent.emit({
651
- type: EventType.TOOL_CALL_CHUNK,
652
- toolCallId,
653
- parentMessageId: messageId,
654
- delta: 'Alice"',
655
- } as BaseEvent);
656
-
657
- await waitFor(() => {
658
- const tool = screen.getByTestId("complex-tool");
659
- expect(tool.textContent).toContain("Name: Alice");
660
- expect(tool.textContent).toContain("Age: pending");
661
- });
662
-
663
- agent.emit({
664
- type: EventType.TOOL_CALL_CHUNK,
665
- toolCallId,
666
- parentMessageId: messageId,
667
- delta: ',"age":30',
668
- } as BaseEvent);
669
-
670
- await waitFor(() => {
671
- const tool = screen.getByTestId("complex-tool");
672
- expect(tool.textContent).toContain("Age: 30");
673
- expect(tool.textContent).toContain("City: pending");
674
- });
675
-
676
- agent.emit({
677
- type: EventType.TOOL_CALL_CHUNK,
678
- toolCallId,
679
- parentMessageId: messageId,
680
- delta: ',"city":"Paris"}',
681
- } as BaseEvent);
682
-
683
- await waitFor(() => {
684
- const tool = screen.getByTestId("complex-tool");
685
- expect(tool.textContent).toContain("City: Paris");
686
- // All args complete but no result yet - status shows inProgress until result is received
687
- expect(tool.textContent).toMatch(/Status: (complete|inProgress)/i);
688
- });
689
-
690
- agent.emit({ type: EventType.RUN_FINISHED } as BaseEvent);
691
- agent.complete();
692
- });
693
- });
694
-
695
- describe("Status Persistence After Agent Stops", () => {
696
- it("should remain in InProgress status after agent stops if no result", async () => {
697
- const agent = new MockStepwiseAgent();
698
-
699
- const renderToolCalls = [
700
- defineToolCallRenderer({
701
- name: "testTool",
702
- args: z.object({ value: z.string() }),
703
- render: ({ args, status }) => (
704
- <div data-testid="tool-render">
705
- <span data-testid="status">{status}</span>
706
- <span data-testid="value">{args.value}</span>
707
- </div>
708
- ),
709
- }),
710
- ] as unknown as ReactToolCallRenderer<unknown>[];
711
-
712
- render(
713
- <CopilotKitProvider
714
- agents__unsafe_dev_only={{ default: agent }}
715
- renderToolCalls={renderToolCalls}
716
- >
717
- <CopilotChat />
718
- </CopilotKitProvider>,
719
- );
720
-
721
- // Submit message to trigger tool call
722
- const input = await screen.findByRole("textbox");
723
- fireEvent.change(input, { target: { value: "Test message" } });
724
- fireEvent.keyDown(input, { key: "Enter", code: "Enter" });
725
-
726
- // Wait for user message to appear
727
- await waitFor(() => {
728
- expect(screen.getByText("Test message")).toBeDefined();
729
- });
730
-
731
- const messageId = "msg_status";
732
- const toolCallId = "tc_status";
733
-
734
- // Start run and emit tool call
735
- agent.emit({ type: EventType.RUN_STARTED } as BaseEvent);
736
-
737
- agent.emit({
738
- type: EventType.TOOL_CALL_CHUNK,
739
- toolCallId,
740
- toolCallName: "testTool",
741
- parentMessageId: messageId,
742
- delta: '{"value":"test"}',
743
- } as BaseEvent);
744
-
745
- // Tool should be in InProgress while agent is running
746
- await waitFor(() => {
747
- const statusElement = screen.getByTestId("status");
748
- expect(statusElement.textContent).toBe("inProgress");
749
- });
750
-
751
- // Finish the run without providing a tool result
752
- agent.emit({ type: EventType.RUN_FINISHED } as BaseEvent);
753
-
754
- // Important: tool should REMAIN in InProgress status, not Complete
755
- // Verify status remains inProgress (not changing to complete)
756
- await waitFor(() => {
757
- const statusElement = screen.getByTestId("status");
758
- expect(statusElement.textContent).toBe("inProgress");
759
- });
760
-
761
- const statusElement = screen.getByTestId("status");
762
- expect(statusElement.textContent).toBe("inProgress");
763
- expect(statusElement.textContent).not.toBe("complete");
764
-
765
- // To provide result after run finished, we need to start a new run
766
- agent.emit({ type: EventType.RUN_STARTED } as BaseEvent);
767
-
768
- // Now provide the tool result
769
- agent.emit({
770
- type: EventType.TOOL_CALL_RESULT,
771
- toolCallId,
772
- messageId: `${messageId}_result`,
773
- content: JSON.stringify({ result: "Tool execution completed" }),
774
- } as BaseEvent);
775
-
776
- // NOW it should be complete
777
- await waitFor(() => {
778
- const statusEl = screen.getByTestId("status");
779
- expect(statusEl.textContent).toBe("complete");
780
- });
781
-
782
- agent.emit({ type: EventType.RUN_FINISHED } as BaseEvent);
783
- agent.complete();
784
- });
785
- });