@copilotkit/vue 1.57.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 (437) hide show
  1. package/AGENTS.md +50 -0
  2. package/CHANGELOG.md +13 -0
  3. package/PARITY.md +434 -0
  4. package/README.md +396 -0
  5. package/dist/components/copilot-provider/CopilotKit.vue.d.ts +20 -0
  6. package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -0
  7. package/dist/components/copilot-provider/index.d.ts +3 -0
  8. package/dist/components/copilot-provider/index.d.ts.map +1 -0
  9. package/dist/components/copilot-provider/types.d.ts +22 -0
  10. package/dist/components/copilot-provider/types.d.ts.map +1 -0
  11. package/dist/hooks/index.d.ts +7 -0
  12. package/dist/hooks/index.d.ts.map +1 -0
  13. package/dist/hooks/use-copilot-action.d.ts +27 -0
  14. package/dist/hooks/use-copilot-action.d.ts.map +1 -0
  15. package/dist/hooks/use-copilot-readable.d.ts +20 -0
  16. package/dist/hooks/use-copilot-readable.d.ts.map +1 -0
  17. package/dist/hooks/use-frontend-tool.d.ts +21 -0
  18. package/dist/hooks/use-frontend-tool.d.ts.map +1 -0
  19. package/dist/index.cjs +2 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.cts +10 -0
  22. package/dist/index.d.mts +10 -0
  23. package/dist/index.d.ts +10 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.mjs +252 -0
  26. package/dist/index.mjs.map +1 -0
  27. package/dist/styles.css +2 -0
  28. package/dist/use-render-activity-message-BRL1Rpl-.cjs +85 -0
  29. package/dist/use-render-activity-message-BRL1Rpl-.cjs.map +1 -0
  30. package/dist/use-render-activity-message-CqtxiFSs.js +8927 -0
  31. package/dist/use-render-activity-message-CqtxiFSs.js.map +1 -0
  32. package/dist/v2/components/A2UIMessageRenderer.d.ts +9 -0
  33. package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -0
  34. package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +16 -0
  35. package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -0
  36. package/dist/v2/components/CopilotKitInspector.vue.d.ts +7 -0
  37. package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -0
  38. package/dist/v2/components/InlineFeatureWarning.vue.d.ts +6 -0
  39. package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -0
  40. package/dist/v2/components/LicenseWarningBanner.vue.d.ts +18 -0
  41. package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -0
  42. package/dist/v2/components/MCPAppsActivityRenderer.d.ts +88 -0
  43. package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -0
  44. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +154 -0
  45. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -0
  46. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +19 -0
  47. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -0
  48. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +16 -0
  49. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -0
  50. package/dist/v2/components/a2ui/VueSurface.d.ts +62 -0
  51. package/dist/v2/components/a2ui/VueSurface.d.ts.map +1 -0
  52. package/dist/v2/components/a2ui/adapter.d.ts +38 -0
  53. package/dist/v2/components/a2ui/adapter.d.ts.map +1 -0
  54. package/dist/v2/components/a2ui/catalog.d.ts +29 -0
  55. package/dist/v2/components/a2ui/catalog.d.ts.map +1 -0
  56. package/dist/v2/components/a2ui/index.d.ts +5 -0
  57. package/dist/v2/components/a2ui/index.d.ts.map +1 -0
  58. package/dist/v2/components/a2ui/utils.d.ts +18 -0
  59. package/dist/v2/components/a2ui/utils.d.ts.map +1 -0
  60. package/dist/v2/components/a2ui.d.ts +12 -0
  61. package/dist/v2/components/a2ui.d.ts.map +1 -0
  62. package/dist/v2/components/chat/CopilotChat.vue.d.ts +50 -0
  63. package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -0
  64. package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +164 -0
  65. package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -0
  66. package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts +12 -0
  67. package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -0
  68. package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts +7 -0
  69. package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -0
  70. package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +12 -0
  71. package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -0
  72. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +290 -0
  73. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -0
  74. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +72 -0
  75. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -0
  76. package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts +65 -0
  77. package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -0
  78. package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts +27 -0
  79. package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts.map +1 -0
  80. package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts +26 -0
  81. package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -0
  82. package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts +17 -0
  83. package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -0
  84. package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts +5 -0
  85. package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts.map +1 -0
  86. package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts +5 -0
  87. package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts.map +1 -0
  88. package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +21 -0
  89. package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -0
  90. package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts +34 -0
  91. package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -0
  92. package/dist/v2/components/chat/CopilotChatView.vue.d.ts +106 -0
  93. package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -0
  94. package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts +15 -0
  95. package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -0
  96. package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts +5 -0
  97. package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -0
  98. package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts +5 -0
  99. package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -0
  100. package/dist/v2/components/chat/CopilotPopup.vue.d.ts +50 -0
  101. package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -0
  102. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +55 -0
  103. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -0
  104. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +55 -0
  105. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -0
  106. package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts +28 -0
  107. package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -0
  108. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +48 -0
  109. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -0
  110. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +62 -0
  111. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -0
  112. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +53 -0
  113. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -0
  114. package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts +28 -0
  115. package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -0
  116. package/dist/v2/components/chat/audioRecorder.d.ts +11 -0
  117. package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -0
  118. package/dist/v2/components/chat/index.d.ts +682 -0
  119. package/dist/v2/components/chat/index.d.ts.map +1 -0
  120. package/dist/v2/components/chat/last-user-message-context.d.ts +29 -0
  121. package/dist/v2/components/chat/last-user-message-context.d.ts.map +1 -0
  122. package/dist/v2/components/chat/normalize-auto-scroll.d.ts +3 -0
  123. package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +1 -0
  124. package/dist/v2/components/chat/types.d.ts +380 -0
  125. package/dist/v2/components/chat/types.d.ts.map +1 -0
  126. package/dist/v2/components/icons/index.d.ts +2 -0
  127. package/dist/v2/components/icons/index.d.ts.map +1 -0
  128. package/dist/v2/components/index.d.ts +8 -0
  129. package/dist/v2/components/index.d.ts.map +1 -0
  130. package/dist/v2/hooks/index.d.ts +24 -0
  131. package/dist/v2/hooks/index.d.ts.map +1 -0
  132. package/dist/v2/hooks/use-agent-context.d.ts +24 -0
  133. package/dist/v2/hooks/use-agent-context.d.ts.map +1 -0
  134. package/dist/v2/hooks/use-agent.d.ts +53 -0
  135. package/dist/v2/hooks/use-agent.d.ts.map +1 -0
  136. package/dist/v2/hooks/use-attachments.d.ts +21 -0
  137. package/dist/v2/hooks/use-attachments.d.ts.map +1 -0
  138. package/dist/v2/hooks/use-capabilities.d.ts +16 -0
  139. package/dist/v2/hooks/use-capabilities.d.ts.map +1 -0
  140. package/dist/v2/hooks/use-component.d.ts +13 -0
  141. package/dist/v2/hooks/use-component.d.ts.map +1 -0
  142. package/dist/v2/hooks/use-configure-suggestions.d.ts +24 -0
  143. package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -0
  144. package/dist/v2/hooks/use-default-render-tool.d.ts +14 -0
  145. package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -0
  146. package/dist/v2/hooks/use-frontend-tool.d.ts +19 -0
  147. package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -0
  148. package/dist/v2/hooks/use-human-in-the-loop.d.ts +19 -0
  149. package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -0
  150. package/dist/v2/hooks/use-interrupt.d.ts +36 -0
  151. package/dist/v2/hooks/use-interrupt.d.ts.map +1 -0
  152. package/dist/v2/hooks/use-katex-styles.d.ts +22 -0
  153. package/dist/v2/hooks/use-katex-styles.d.ts.map +1 -0
  154. package/dist/v2/hooks/use-keyboard-height.d.ts +33 -0
  155. package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -0
  156. package/dist/v2/hooks/use-pin-to-send.d.ts +28 -0
  157. package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -0
  158. package/dist/v2/hooks/use-render-activity-message.d.ts +21 -0
  159. package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -0
  160. package/dist/v2/hooks/use-render-custom-messages.d.ts +27 -0
  161. package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -0
  162. package/dist/v2/hooks/use-render-tool.d.ts +36 -0
  163. package/dist/v2/hooks/use-render-tool.d.ts.map +1 -0
  164. package/dist/v2/hooks/use-suggestions.d.ts +26 -0
  165. package/dist/v2/hooks/use-suggestions.d.ts.map +1 -0
  166. package/dist/v2/hooks/use-threads.d.ts +42 -0
  167. package/dist/v2/hooks/use-threads.d.ts.map +1 -0
  168. package/dist/v2/index.cjs +2 -0
  169. package/dist/v2/index.cjs.map +1 -0
  170. package/dist/v2/index.d.cts +9 -0
  171. package/dist/v2/index.d.mts +9 -0
  172. package/dist/v2/index.d.ts +9 -0
  173. package/dist/v2/index.d.ts.map +1 -0
  174. package/dist/v2/index.mjs +75 -0
  175. package/dist/v2/index.mjs.map +1 -0
  176. package/dist/v2/lib/processPartialHtml.d.ts +3 -0
  177. package/dist/v2/lib/processPartialHtml.d.ts.map +1 -0
  178. package/dist/v2/lib/shallow-stable.d.ts +7 -0
  179. package/dist/v2/lib/shallow-stable.d.ts.map +1 -0
  180. package/dist/v2/lib/transcription-client.d.ts +19 -0
  181. package/dist/v2/lib/transcription-client.d.ts.map +1 -0
  182. package/dist/v2/lib/vue-core.d.ts +47 -0
  183. package/dist/v2/lib/vue-core.d.ts.map +1 -0
  184. package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts +15 -0
  185. package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts.map +1 -0
  186. package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts +17 -0
  187. package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -0
  188. package/dist/v2/providers/CopilotKitProvider.types.d.ts +61 -0
  189. package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -0
  190. package/dist/v2/providers/CopilotKitProvider.vue.d.ts +37 -0
  191. package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -0
  192. package/dist/v2/providers/SandboxFunctionsContext.d.ts +4 -0
  193. package/dist/v2/providers/SandboxFunctionsContext.d.ts.map +1 -0
  194. package/dist/v2/providers/index.d.ts +13 -0
  195. package/dist/v2/providers/index.d.ts.map +1 -0
  196. package/dist/v2/providers/keys.d.ts +17 -0
  197. package/dist/v2/providers/keys.d.ts.map +1 -0
  198. package/dist/v2/providers/license-context.d.ts +7 -0
  199. package/dist/v2/providers/license-context.d.ts.map +1 -0
  200. package/dist/v2/providers/types.d.ts +38 -0
  201. package/dist/v2/providers/types.d.ts.map +1 -0
  202. package/dist/v2/providers/useCopilotChatConfiguration.d.ts +4 -0
  203. package/dist/v2/providers/useCopilotChatConfiguration.d.ts.map +1 -0
  204. package/dist/v2/providers/useCopilotKit.d.ts +2 -0
  205. package/dist/v2/providers/useCopilotKit.d.ts.map +1 -0
  206. package/dist/v2/providers/useLicenseContext.d.ts +14 -0
  207. package/dist/v2/providers/useLicenseContext.d.ts.map +1 -0
  208. package/dist/v2/types/a2ui.d.ts +5 -0
  209. package/dist/v2/types/a2ui.d.ts.map +1 -0
  210. package/dist/v2/types/defineToolCallRenderer.d.ts +15 -0
  211. package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -0
  212. package/dist/v2/types/frontend-tool.d.ts +6 -0
  213. package/dist/v2/types/frontend-tool.d.ts.map +1 -0
  214. package/dist/v2/types/human-in-the-loop.d.ts +29 -0
  215. package/dist/v2/types/human-in-the-loop.d.ts.map +1 -0
  216. package/dist/v2/types/index.d.ts +10 -0
  217. package/dist/v2/types/index.d.ts.map +1 -0
  218. package/dist/v2/types/interrupt.d.ts +14 -0
  219. package/dist/v2/types/interrupt.d.ts.map +1 -0
  220. package/dist/v2/types/sandbox-function.d.ts +8 -0
  221. package/dist/v2/types/sandbox-function.d.ts.map +1 -0
  222. package/dist/v2/types/vue-activity-message-renderer.d.ts +18 -0
  223. package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -0
  224. package/dist/v2/types/vue-custom-message-renderer.d.ts +19 -0
  225. package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -0
  226. package/dist/v2/types/vue-tool-call-renderer.d.ts +37 -0
  227. package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -0
  228. package/env.d.ts +7 -0
  229. package/eslint.config.mjs +42 -0
  230. package/package.json +130 -0
  231. package/scripts/scope-preflight.mjs +100 -0
  232. package/src/components/copilot-provider/CopilotKit.vue +18 -0
  233. package/src/components/copilot-provider/index.ts +2 -0
  234. package/src/components/copilot-provider/types.ts +24 -0
  235. package/src/hooks/index.ts +9 -0
  236. package/src/hooks/use-copilot-action.ts +168 -0
  237. package/src/hooks/use-copilot-readable.ts +75 -0
  238. package/src/hooks/use-frontend-tool.ts +76 -0
  239. package/src/index.ts +12 -0
  240. package/src/styles/globals.css +314 -0
  241. package/src/v2/__tests__/exports.test.ts +35 -0
  242. package/src/v2/__tests__/mocks/web-inspector.ts +5 -0
  243. package/src/v2/__tests__/setup.ts +141 -0
  244. package/src/v2/__tests__/utils/agents.ts +391 -0
  245. package/src/v2/__tests__/utils/mount.ts +83 -0
  246. package/src/v2/__tests__/utils/test-helpers.ts +712 -0
  247. package/src/v2/components/A2UIMessageRenderer.ts +125 -0
  248. package/src/v2/components/A2UISurfaceActivityRenderer.vue +186 -0
  249. package/src/v2/components/CopilotKitInspector.vue +42 -0
  250. package/src/v2/components/InlineFeatureWarning.vue +35 -0
  251. package/src/v2/components/LicenseWarningBanner.vue +196 -0
  252. package/src/v2/components/MCPAppsActivityRenderer.ts +778 -0
  253. package/src/v2/components/OpenGenerativeUIRenderer.ts +550 -0
  254. package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +271 -0
  255. package/src/v2/components/__tests__/CopilotKitInspector.test.ts +57 -0
  256. package/src/v2/components/__tests__/MCPAppsActivityRenderer.e2e.test.ts +851 -0
  257. package/src/v2/components/__tests__/MCPAppsActivityRenderer.test.ts +237 -0
  258. package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +516 -0
  259. package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +295 -0
  260. package/src/v2/components/a2ui/A2UICatalogContext.ts +190 -0
  261. package/src/v2/components/a2ui/VueSurface.ts +144 -0
  262. package/src/v2/components/a2ui/adapter.ts +156 -0
  263. package/src/v2/components/a2ui/catalog.ts +858 -0
  264. package/src/v2/components/a2ui/index.ts +7 -0
  265. package/src/v2/components/a2ui/utils.ts +67 -0
  266. package/src/v2/components/a2ui.ts +30 -0
  267. package/src/v2/components/chat/CopilotChat.vue +777 -0
  268. package/src/v2/components/chat/CopilotChatAssistantMessage.vue +891 -0
  269. package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +411 -0
  270. package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +87 -0
  271. package/src/v2/components/chat/CopilotChatAudioRecorder.vue +269 -0
  272. package/src/v2/components/chat/CopilotChatInput.vue +1271 -0
  273. package/src/v2/components/chat/CopilotChatMessageView.vue +476 -0
  274. package/src/v2/components/chat/CopilotChatReasoningMessage.vue +247 -0
  275. package/src/v2/components/chat/CopilotChatSuggestionPill.vue +56 -0
  276. package/src/v2/components/chat/CopilotChatSuggestionView.vue +93 -0
  277. package/src/v2/components/chat/CopilotChatToggleButton.vue +145 -0
  278. package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +17 -0
  279. package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +18 -0
  280. package/src/v2/components/chat/CopilotChatToolCallsView.vue +161 -0
  281. package/src/v2/components/chat/CopilotChatUserMessage.vue +322 -0
  282. package/src/v2/components/chat/CopilotChatView.vue +740 -0
  283. package/src/v2/components/chat/CopilotModalHeader.vue +73 -0
  284. package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +38 -0
  285. package/src/v2/components/chat/CopilotModalHeaderTitle.ts +22 -0
  286. package/src/v2/components/chat/CopilotPopup.vue +182 -0
  287. package/src/v2/components/chat/CopilotPopupView.vue +168 -0
  288. package/src/v2/components/chat/CopilotPopupViewInternal.vue +453 -0
  289. package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +140 -0
  290. package/src/v2/components/chat/CopilotSidebar.vue +178 -0
  291. package/src/v2/components/chat/CopilotSidebarView.vue +172 -0
  292. package/src/v2/components/chat/CopilotSidebarViewInternal.vue +366 -0
  293. package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +142 -0
  294. package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.ts +237 -0
  295. package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.ts +1240 -0
  296. package/src/v2/components/chat/__tests__/CopilotChat.licenseWarning.test.ts +138 -0
  297. package/src/v2/components/chat/__tests__/CopilotChat.onError.test.ts +85 -0
  298. package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.ts +141 -0
  299. package/src/v2/components/chat/__tests__/CopilotChat.test.ts +652 -0
  300. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +683 -0
  301. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +768 -0
  302. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +1108 -0
  303. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.thumbs.test.ts +87 -0
  304. package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +277 -0
  305. package/src/v2/components/chat/__tests__/CopilotChatAttachmentRenderer.test.ts +124 -0
  306. package/src/v2/components/chat/__tests__/CopilotChatCopyButton.clipboard.test.ts +230 -0
  307. package/src/v2/components/chat/__tests__/CopilotChatInput.bottomAnchored.test.ts +83 -0
  308. package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +1139 -0
  309. package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +1051 -0
  310. package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.ts +141 -0
  311. package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +494 -0
  312. package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.ts +181 -0
  313. package/src/v2/components/chat/__tests__/CopilotChatReasoningMessage.test.ts +73 -0
  314. package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +73 -0
  315. package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +674 -0
  316. package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.test.ts +91 -0
  317. package/src/v2/components/chat/__tests__/CopilotChatToggleButton.test.ts +93 -0
  318. package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.test.ts +382 -0
  319. package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.ts +1019 -0
  320. package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.ts +516 -0
  321. package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.ts +701 -0
  322. package/src/v2/components/chat/__tests__/CopilotChatUserMessage.test.ts +337 -0
  323. package/src/v2/components/chat/__tests__/CopilotChatView.connectingGate.test.ts +135 -0
  324. package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +278 -0
  325. package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.ts +1082 -0
  326. package/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.ts +166 -0
  327. package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.ts +1145 -0
  328. package/src/v2/components/chat/__tests__/CopilotChatView.test.ts +374 -0
  329. package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +636 -0
  330. package/src/v2/components/chat/__tests__/CopilotModalHeader.test.ts +112 -0
  331. package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +58 -0
  332. package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +725 -0
  333. package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +112 -0
  334. package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +58 -0
  335. package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.ts +603 -0
  336. package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +214 -0
  337. package/src/v2/components/chat/__tests__/MCPAppsUiMessage.e2e.test.ts +394 -0
  338. package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.ts +82 -0
  339. package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +39 -0
  340. package/src/v2/components/chat/audioRecorder.ts +15 -0
  341. package/src/v2/components/chat/index.ts +52 -0
  342. package/src/v2/components/chat/last-user-message-context.ts +39 -0
  343. package/src/v2/components/chat/normalize-auto-scroll.ts +17 -0
  344. package/src/v2/components/chat/types.ts +481 -0
  345. package/src/v2/components/icons/__tests__/icons.test.ts +86 -0
  346. package/src/v2/components/icons/index.ts +22 -0
  347. package/src/v2/components/index.ts +7 -0
  348. package/src/v2/hooks/__tests__/standard-schema-types.test.ts +149 -0
  349. package/src/v2/hooks/__tests__/standard-schema.test.ts +315 -0
  350. package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.ts +144 -0
  351. package/src/v2/hooks/__tests__/use-agent-context.test.ts +271 -0
  352. package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +64 -0
  353. package/src/v2/hooks/__tests__/use-agent-stability.test.ts +268 -0
  354. package/src/v2/hooks/__tests__/use-agent-thread-isolation.test.ts +433 -0
  355. package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +747 -0
  356. package/src/v2/hooks/__tests__/use-agent.e2e.test.ts +187 -0
  357. package/src/v2/hooks/__tests__/use-agent.test.ts +126 -0
  358. package/src/v2/hooks/__tests__/use-attachments.test.ts +181 -0
  359. package/src/v2/hooks/__tests__/use-component.test.ts +145 -0
  360. package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.ts +527 -0
  361. package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +399 -0
  362. package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +214 -0
  363. package/src/v2/hooks/__tests__/use-frontend-tool-available.test.ts +220 -0
  364. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +2320 -0
  365. package/src/v2/hooks/__tests__/use-frontend-tool.test.ts +648 -0
  366. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +1379 -0
  367. package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +282 -0
  368. package/src/v2/hooks/__tests__/use-interrupt.test.ts +345 -0
  369. package/src/v2/hooks/__tests__/use-katex-styles.test.ts +69 -0
  370. package/src/v2/hooks/__tests__/use-keyboard-height.test.ts +199 -0
  371. package/src/v2/hooks/__tests__/use-pin-to-send.test.ts +363 -0
  372. package/src/v2/hooks/__tests__/use-render-tool.test.ts +329 -0
  373. package/src/v2/hooks/__tests__/use-suggestions.e2e.test.ts +397 -0
  374. package/src/v2/hooks/__tests__/use-suggestions.test.ts +198 -0
  375. package/src/v2/hooks/__tests__/use-threads.test.ts +1041 -0
  376. package/src/v2/hooks/__tests__/zod-regression.test.ts +339 -0
  377. package/src/v2/hooks/index.ts +29 -0
  378. package/src/v2/hooks/use-agent-context.ts +55 -0
  379. package/src/v2/hooks/use-agent.ts +345 -0
  380. package/src/v2/hooks/use-attachments.ts +261 -0
  381. package/src/v2/hooks/use-capabilities.ts +30 -0
  382. package/src/v2/hooks/use-component.ts +46 -0
  383. package/src/v2/hooks/use-configure-suggestions.ts +252 -0
  384. package/src/v2/hooks/use-default-render-tool.ts +130 -0
  385. package/src/v2/hooks/use-frontend-tool.ts +68 -0
  386. package/src/v2/hooks/use-human-in-the-loop.ts +90 -0
  387. package/src/v2/hooks/use-interrupt.ts +257 -0
  388. package/src/v2/hooks/use-katex-styles.ts +44 -0
  389. package/src/v2/hooks/use-keyboard-height.ts +87 -0
  390. package/src/v2/hooks/use-pin-to-send.ts +160 -0
  391. package/src/v2/hooks/use-render-activity-message.ts +92 -0
  392. package/src/v2/hooks/use-render-custom-messages.ts +129 -0
  393. package/src/v2/hooks/use-render-tool.ts +128 -0
  394. package/src/v2/hooks/use-suggestions.ts +98 -0
  395. package/src/v2/hooks/use-threads.ts +208 -0
  396. package/src/v2/index.ts +11 -0
  397. package/src/v2/lib/__tests__/processPartialHtml.test.ts +84 -0
  398. package/src/v2/lib/__tests__/transcription-client.test.ts +65 -0
  399. package/src/v2/lib/processPartialHtml.ts +21 -0
  400. package/src/v2/lib/shallow-stable.ts +54 -0
  401. package/src/v2/lib/transcription-client.ts +151 -0
  402. package/src/v2/lib/vue-core.ts +161 -0
  403. package/src/v2/providers/CopilotChatConfigurationProvider.types.ts +15 -0
  404. package/src/v2/providers/CopilotChatConfigurationProvider.vue +95 -0
  405. package/src/v2/providers/CopilotKitProvider.types.ts +66 -0
  406. package/src/v2/providers/CopilotKitProvider.vue +653 -0
  407. package/src/v2/providers/SandboxFunctionsContext.ts +11 -0
  408. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +309 -0
  409. package/src/v2/providers/__tests__/CopilotKitProvider.debug.test.ts +295 -0
  410. package/src/v2/providers/__tests__/CopilotKitProvider.license.test.ts +110 -0
  411. package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.ts +67 -0
  412. package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.ts +901 -0
  413. package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +141 -0
  414. package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.ts +871 -0
  415. package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +603 -0
  416. package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.ts +104 -0
  417. package/src/v2/providers/index.ts +21 -0
  418. package/src/v2/providers/keys.ts +25 -0
  419. package/src/v2/providers/license-context.ts +16 -0
  420. package/src/v2/providers/types.ts +40 -0
  421. package/src/v2/providers/useCopilotChatConfiguration.ts +11 -0
  422. package/src/v2/providers/useCopilotKit.ts +11 -0
  423. package/src/v2/providers/useLicenseContext.ts +21 -0
  424. package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +157 -0
  425. package/src/v2/types/a2ui.ts +5 -0
  426. package/src/v2/types/defineToolCallRenderer.ts +32 -0
  427. package/src/v2/types/frontend-tool.ts +8 -0
  428. package/src/v2/types/human-in-the-loop.ts +38 -0
  429. package/src/v2/types/index.ts +9 -0
  430. package/src/v2/types/interrupt.ts +15 -0
  431. package/src/v2/types/sandbox-function.ts +8 -0
  432. package/src/v2/types/vue-activity-message-renderer.ts +22 -0
  433. package/src/v2/types/vue-custom-message-renderer.ts +24 -0
  434. package/src/v2/types/vue-tool-call-renderer.ts +44 -0
  435. package/tsconfig.json +27 -0
  436. package/vite.config.ts +49 -0
  437. package/vitest.config.ts +23 -0
@@ -0,0 +1,683 @@
1
+ import {
2
+ cleanup,
3
+ fireEvent,
4
+ render,
5
+ screen,
6
+ waitFor,
7
+ } from "@testing-library/vue";
8
+ import { defineComponent, ref, toRaw } from "vue";
9
+ import { afterEach, describe, expect, it, vi } from "vitest";
10
+ import type { AbstractAgent } from "@ag-ui/client";
11
+ import { EventType } from "@ag-ui/client";
12
+ import type { A2UITheme as Theme } from "../../../types";
13
+ import { IntelligenceAgent } from "@copilotkit/core";
14
+ import CopilotChat from "../CopilotChat.vue";
15
+ import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
16
+ import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
17
+ import { getThreadClone } from "../../../hooks/use-agent";
18
+ import { useCopilotKit } from "../../../providers/useCopilotKit";
19
+ import { createA2UIMessageRenderer } from "../../../components/A2UIMessageRenderer";
20
+ import {
21
+ activitySnapshotEvent,
22
+ MockReconnectableAgent,
23
+ MockStepwiseAgent,
24
+ renderWithCopilotKit,
25
+ runFinishedEvent,
26
+ runStartedEvent,
27
+ testId,
28
+ } from "../../../__tests__/utils/test-helpers";
29
+
30
+ const {
31
+ mockWebsandboxCreate,
32
+ mockWebsandboxDestroy,
33
+ mockPhoenixSockets,
34
+ MockPhoenixSocket,
35
+ } = vi.hoisted(() => {
36
+ const mockDestroy = vi.fn();
37
+ const mockCreate = vi.fn(() => ({
38
+ iframe: document.createElement("iframe"),
39
+ promise: Promise.resolve(),
40
+ run: vi.fn().mockResolvedValue(undefined),
41
+ destroy: mockDestroy,
42
+ }));
43
+
44
+ // Colocated Phoenix mock infrastructure (mirrors the React file).
45
+ // Kept here rather than in the generic Vue test helper because the
46
+ // gateway-replay package is the only suite that needs it.
47
+ const mockSockets: MockPhoenixSocket[] = [];
48
+
49
+ class MockPhoenixPush {
50
+ private callbacks = new Map<string, (response?: unknown) => void>();
51
+
52
+ receive(
53
+ status: string,
54
+ callback: (response?: unknown) => void,
55
+ ): MockPhoenixPush {
56
+ this.callbacks.set(status, callback);
57
+ return this;
58
+ }
59
+
60
+ trigger(status: string, response?: unknown): void {
61
+ this.callbacks.get(status)?.(response);
62
+ }
63
+ }
64
+
65
+ class MockPhoenixChannel {
66
+ public topic: string;
67
+ public params: Record<string, unknown>;
68
+ public left = false;
69
+
70
+ private handlers = new Map<
71
+ string,
72
+ Array<{ ref: number; callback: (payload: unknown) => void }>
73
+ >();
74
+ private joinPush = new MockPhoenixPush();
75
+ private nextRef = 1;
76
+
77
+ constructor(topic: string, params: Record<string, unknown>) {
78
+ this.topic = topic;
79
+ this.params = params;
80
+ }
81
+
82
+ on(event: string, callback: (payload: unknown) => void): number {
83
+ if (!this.handlers.has(event)) {
84
+ this.handlers.set(event, []);
85
+ }
86
+ const ref = this.nextRef;
87
+ this.nextRef += 1;
88
+ this.handlers.get(event)?.push({ ref, callback });
89
+ return ref;
90
+ }
91
+
92
+ off(event: string, ref?: number): void {
93
+ if (ref === undefined) {
94
+ this.handlers.delete(event);
95
+ return;
96
+ }
97
+ this.handlers.set(
98
+ event,
99
+ (this.handlers.get(event) ?? []).filter(
100
+ (handler) => handler.ref !== ref,
101
+ ),
102
+ );
103
+ }
104
+
105
+ join(): MockPhoenixPush {
106
+ return this.joinPush;
107
+ }
108
+
109
+ leave(): void {
110
+ this.left = true;
111
+ }
112
+
113
+ triggerJoin(status: string, response?: unknown): void {
114
+ this.joinPush.trigger(status, response);
115
+ }
116
+
117
+ serverPush(event: string, payload: unknown): void {
118
+ for (const { callback } of this.handlers.get(event) ?? []) {
119
+ callback(payload);
120
+ }
121
+ }
122
+ }
123
+
124
+ class MockPhoenixSocket {
125
+ public channels: MockPhoenixChannel[] = [];
126
+
127
+ constructor(
128
+ public url: string,
129
+ public opts: Record<string, unknown>,
130
+ ) {
131
+ mockSockets.push(this);
132
+ }
133
+
134
+ connect(): void {}
135
+
136
+ disconnect(): void {}
137
+
138
+ onOpen(): void {}
139
+
140
+ onError(): void {}
141
+
142
+ channel(
143
+ topic: string,
144
+ params: Record<string, unknown>,
145
+ ): MockPhoenixChannel {
146
+ const channel = new MockPhoenixChannel(topic, params);
147
+ this.channels.push(channel);
148
+ return channel;
149
+ }
150
+ }
151
+
152
+ return {
153
+ mockWebsandboxCreate: mockCreate,
154
+ mockWebsandboxDestroy: mockDestroy,
155
+ mockPhoenixSockets: mockSockets,
156
+ MockPhoenixSocket,
157
+ };
158
+ });
159
+
160
+ vi.mock("phoenix", () => ({
161
+ Socket: MockPhoenixSocket,
162
+ }));
163
+
164
+ vi.mock("@jetbrains/websandbox", () => ({
165
+ default: {
166
+ create: (...args: unknown[]) => mockWebsandboxCreate(...args),
167
+ },
168
+ }));
169
+
170
+ function jsonResponse(body: unknown, status = 200): Response {
171
+ return {
172
+ ok: status >= 200 && status < 300,
173
+ status,
174
+ statusText: status === 200 ? "OK" : "Error",
175
+ json: async () => body,
176
+ text: async () => JSON.stringify(body),
177
+ } as Response;
178
+ }
179
+
180
+ async function submitMessageAndWaitForUserMessage(value: string) {
181
+ await waitFor(() => {
182
+ expect(screen.queryByTestId("copilot-chat-cursor")).toBeNull();
183
+ });
184
+
185
+ const input = await screen.findByRole("textbox");
186
+ await fireEvent.update(input, value);
187
+ await fireEvent.keyDown(input, { key: "Enter", code: "Enter" });
188
+
189
+ await waitFor(() => {
190
+ expect(screen.getByText(value)).toBeDefined();
191
+ });
192
+ }
193
+
194
+ const CopilotkitProbe = defineComponent({
195
+ setup() {
196
+ const { copilotkit } = useCopilotKit();
197
+ return { copilotkit };
198
+ },
199
+ template: `
200
+ <div data-testid="copilotkit-probe">
201
+ {{ String(!!copilotkit) }}
202
+ </div>
203
+ `,
204
+ });
205
+
206
+ afterEach(() => {
207
+ cleanup();
208
+ });
209
+
210
+ describe("CopilotChat activity message rendering", () => {
211
+ it("renders custom components for activity snapshots", async () => {
212
+ const agent = new MockStepwiseAgent();
213
+ const agentId = "search-agent";
214
+ agent.agentId = agentId;
215
+
216
+ const Host = defineComponent({
217
+ components: { CopilotChat },
218
+ template: `
219
+ <CopilotChat :welcome-screen="false">
220
+ <template #activity-search-progress="{ content, agent }">
221
+ <div data-testid="activity-card">
222
+ {{ String(content?.status ?? "") }} · {{ String(content?.percent ?? "") }}% · {{ String(agent?.agentId ?? "") }}
223
+ </div>
224
+ </template>
225
+ </CopilotChat>
226
+ `,
227
+ });
228
+
229
+ renderWithCopilotKit({
230
+ agent,
231
+ agentId,
232
+ children: Host,
233
+ });
234
+
235
+ await submitMessageAndWaitForUserMessage("Start search");
236
+
237
+ await agent.emit(runStartedEvent());
238
+ await agent.emit(
239
+ activitySnapshotEvent({
240
+ messageId: testId("activity"),
241
+ activityType: "search-progress",
242
+ content: { status: "Fetching", percent: 30 },
243
+ }),
244
+ );
245
+ await agent.emit(runFinishedEvent());
246
+ await waitFor(() => {
247
+ const textContent = screen.getByTestId("activity-card").textContent ?? "";
248
+ expect(textContent).toContain("Fetching");
249
+ expect(textContent).toContain(agentId);
250
+ });
251
+ });
252
+
253
+ it("skips unmatched activity types when no renderer exists", async () => {
254
+ const agent = new MockStepwiseAgent();
255
+ renderWithCopilotKit({ agent });
256
+
257
+ await submitMessageAndWaitForUserMessage("Start search");
258
+
259
+ await agent.emit(runStartedEvent());
260
+ await agent.emit(
261
+ activitySnapshotEvent({
262
+ messageId: testId("activity-unmatched"),
263
+ activityType: "unknown",
264
+ content: { note: "no-op" },
265
+ }),
266
+ );
267
+ await agent.emit(runFinishedEvent());
268
+
269
+ await waitFor(() => {
270
+ expect(screen.queryByTestId("activity-card")).toBeNull();
271
+ });
272
+ });
273
+
274
+ it("useCopilotKit provides valid copilotkit instance inside activity message renderer", async () => {
275
+ const agent = new MockStepwiseAgent();
276
+ const agentId = "test-agent";
277
+ agent.agentId = agentId;
278
+
279
+ const Host = defineComponent({
280
+ components: { CopilotChat, CopilotkitProbe },
281
+ template: `
282
+ <CopilotChat :welcome-screen="false">
283
+ <template #activity-test-activity="{ content }">
284
+ <div data-testid="activity-render">
285
+ {{ String(content?.message ?? "") }}
286
+ <CopilotkitProbe />
287
+ </div>
288
+ </template>
289
+ </CopilotChat>
290
+ `,
291
+ });
292
+
293
+ renderWithCopilotKit({
294
+ agent,
295
+ agentId,
296
+ children: Host,
297
+ });
298
+
299
+ await submitMessageAndWaitForUserMessage("Test message");
300
+
301
+ await agent.emit(runStartedEvent());
302
+ await agent.emit(
303
+ activitySnapshotEvent({
304
+ messageId: testId("activity"),
305
+ activityType: "test-activity",
306
+ content: { message: "Rendered content" },
307
+ }),
308
+ );
309
+ await agent.emit(runFinishedEvent());
310
+
311
+ await waitFor(() => {
312
+ expect(screen.getByTestId("activity-render")).toBeDefined();
313
+ });
314
+
315
+ expect(screen.getByTestId("copilotkit-probe").textContent).toBe("true");
316
+ });
317
+
318
+ it("passes the per-thread clone (not the registry agent) to activity message renderers", async () => {
319
+ const agent = new MockStepwiseAgent();
320
+ const agentId = "action-agent";
321
+ agent.agentId = agentId;
322
+ const threadId = "thread-for-action-test";
323
+ const capturedAgent = ref<AbstractAgent | undefined>();
324
+
325
+ const Host = defineComponent({
326
+ components: { CopilotChat },
327
+ setup() {
328
+ const captureAgent = (nextAgent: AbstractAgent | undefined) => {
329
+ capturedAgent.value = nextAgent;
330
+ return "";
331
+ };
332
+ return {
333
+ captureAgent,
334
+ };
335
+ },
336
+ template: `
337
+ <CopilotChat :welcome-screen="false">
338
+ <template #activity-button-action="{ content, agent }">
339
+ <button data-testid="action-button">
340
+ {{ String(content?.label ?? "") }}{{ captureAgent(agent) }}
341
+ </button>
342
+ </template>
343
+ </CopilotChat>
344
+ `,
345
+ });
346
+
347
+ renderWithCopilotKit({
348
+ agent,
349
+ agentId,
350
+ threadId,
351
+ children: Host,
352
+ });
353
+
354
+ await submitMessageAndWaitForUserMessage("show me buttons");
355
+
356
+ await agent.emit(runStartedEvent());
357
+ await agent.emit(
358
+ activitySnapshotEvent({
359
+ messageId: testId("activity-action"),
360
+ activityType: "button-action",
361
+ content: { label: "Click Me" },
362
+ }),
363
+ );
364
+ await agent.emit(runFinishedEvent());
365
+
366
+ await waitFor(() => {
367
+ expect(screen.getByTestId("action-button")).toBeDefined();
368
+ });
369
+
370
+ const clone = getThreadClone(agent, threadId);
371
+ expect(clone).toBeDefined();
372
+ expect(toRaw(capturedAgent.value!)).toBe(clone);
373
+ expect(toRaw(capturedAgent.value!)).not.toBe(agent);
374
+ });
375
+
376
+ it("restores a completed A2UI surface after reconnect from an event-native baseline", async () => {
377
+ const agent = new MockReconnectableAgent();
378
+ const threadId = testId("a2ui-thread");
379
+ const surfaceId = testId("surface");
380
+ const a2uiRenderer = createA2UIMessageRenderer({
381
+ theme: {} as Theme,
382
+ });
383
+
384
+ const { unmount } = renderWithCopilotKit({
385
+ agent,
386
+ threadId,
387
+ renderActivityMessages: [a2uiRenderer],
388
+ });
389
+
390
+ // Allow the /connect bootstrap cycle to settle before submitting.
391
+ // In Vue, the connect watch fires synchronously during mount (unlike
392
+ // React's useEffect which defers). The connectAgent path calls
393
+ // setMessages([]) which would race with the submit's addMessage.
394
+ await waitFor(() => {
395
+ expect(
396
+ screen.queryByTestId("copilot-chat-view"),
397
+ ).not.toBeNull();
398
+ });
399
+ await new Promise((r) => setTimeout(r, 50));
400
+
401
+ await submitMessageAndWaitForUserMessage("Show me the restored UI");
402
+
403
+ await agent.emit(runStartedEvent());
404
+ await agent.emit(
405
+ activitySnapshotEvent({
406
+ messageId: testId("a2ui-activity"),
407
+ activityType: "a2ui-surface",
408
+ content: {
409
+ a2ui_operations: [
410
+ {
411
+ version: "v0.9",
412
+ createSurface: {
413
+ surfaceId,
414
+ catalogId:
415
+ "https://a2ui.org/specification/v0_9/basic_catalog.json",
416
+ },
417
+ },
418
+ {
419
+ version: "v0.9",
420
+ updateComponents: {
421
+ surfaceId,
422
+ components: [
423
+ {
424
+ id: "root",
425
+ component: "Text",
426
+ text: "Restored dashboard",
427
+ variant: "body",
428
+ },
429
+ ],
430
+ },
431
+ },
432
+ ],
433
+ },
434
+ }),
435
+ );
436
+ await agent.emit(runFinishedEvent());
437
+ await agent.complete();
438
+
439
+ await waitFor(
440
+ () => {
441
+ expect(
442
+ document.querySelector(`[data-surface-id='${surfaceId}']`),
443
+ ).not.toBeNull();
444
+ },
445
+ { timeout: 5000 },
446
+ );
447
+
448
+ unmount();
449
+ agent.reset();
450
+
451
+ renderWithCopilotKit({
452
+ agent,
453
+ threadId,
454
+ renderActivityMessages: [a2uiRenderer],
455
+ });
456
+
457
+ await waitFor(
458
+ () => {
459
+ expect(
460
+ document.querySelector(`[data-surface-id='${surfaceId}']`),
461
+ ).not.toBeNull();
462
+ },
463
+ { timeout: 5000 },
464
+ );
465
+ });
466
+
467
+ it("restores a completed A2UI surface from IntelligenceAgent /connect gateway replay", async () => {
468
+ const threadId = testId("intelligence-connect-thread");
469
+ const surfaceId = testId("intelligence-connect-surface");
470
+ const fetchMock = vi.fn().mockResolvedValueOnce(
471
+ jsonResponse({
472
+ threadId,
473
+ runId: null,
474
+ joinToken: "join-token-1",
475
+ realtime: {
476
+ clientUrl: "ws://localhost:4000/client",
477
+ topic: `thread:${threadId}`,
478
+ },
479
+ }),
480
+ );
481
+ vi.stubGlobal("fetch", fetchMock);
482
+ mockPhoenixSockets.length = 0;
483
+
484
+ const agent = new IntelligenceAgent({
485
+ url: "ws://localhost:4000/client",
486
+ runtimeUrl: "http://localhost:4000",
487
+ agentId: "my-agent",
488
+ });
489
+ const a2uiRenderer = createA2UIMessageRenderer({
490
+ theme: {} as Theme,
491
+ });
492
+
493
+ try {
494
+ renderWithCopilotKit({
495
+ agent,
496
+ threadId,
497
+ renderActivityMessages: [a2uiRenderer],
498
+ });
499
+
500
+ await waitFor(() => {
501
+ expect(fetchMock).toHaveBeenCalledTimes(1);
502
+ });
503
+
504
+ await waitFor(() => {
505
+ expect(mockPhoenixSockets).toHaveLength(1);
506
+ expect(mockPhoenixSockets[0]?.channels).toHaveLength(1);
507
+ });
508
+
509
+ const channel = mockPhoenixSockets[0]!.channels[0]!;
510
+ expect(channel.topic).toBe(`thread:${threadId}`);
511
+ expect(channel.params).toEqual({
512
+ stream_mode: "connect",
513
+ last_seen_event_id: null,
514
+ });
515
+
516
+ channel.triggerJoin("ok");
517
+ channel.serverPush("ag_ui_event", {
518
+ type: EventType.RUN_STARTED,
519
+ threadId,
520
+ run_id: "backend-run-1",
521
+ input: {
522
+ messages: [
523
+ {
524
+ id: testId("connect-user-message"),
525
+ role: "user",
526
+ content: "show me the restored ui",
527
+ },
528
+ ],
529
+ },
530
+ });
531
+ channel.serverPush("ag_ui_event", {
532
+ type: EventType.ACTIVITY_SNAPSHOT,
533
+ messageId: testId("connect-a2ui-activity"),
534
+ activityType: "a2ui-surface",
535
+ content: {
536
+ a2ui_operations: [
537
+ {
538
+ version: "v0.9",
539
+ createSurface: {
540
+ surfaceId,
541
+ catalogId:
542
+ "https://a2ui.org/specification/v0_9/basic_catalog.json",
543
+ },
544
+ },
545
+ {
546
+ version: "v0.9",
547
+ updateComponents: {
548
+ surfaceId,
549
+ components: [
550
+ {
551
+ id: "root",
552
+ component: "Text",
553
+ text: "Restored dashboard",
554
+ variant: "body",
555
+ },
556
+ ],
557
+ },
558
+ },
559
+ ],
560
+ },
561
+ });
562
+ channel.serverPush("ag_ui_event", {
563
+ type: EventType.RUN_FINISHED,
564
+ });
565
+ channel.serverPush("stream_idle", { latestEventId: "event-3" });
566
+
567
+ await waitFor(() => {
568
+ expect(screen.getByText("show me the restored ui")).toBeDefined();
569
+ });
570
+ await waitFor(() => {
571
+ expect(
572
+ document.querySelector(`[data-surface-id='${surfaceId}']`),
573
+ ).not.toBeNull();
574
+ });
575
+
576
+ const [url, options] = fetchMock.mock.calls[0] as [string, RequestInit];
577
+ expect(url).toContain("/agent/my-agent/connect");
578
+ expect(options.method).toBe("POST");
579
+
580
+ const requestBody = JSON.parse(String(options.body)) as {
581
+ threadId: string;
582
+ lastSeenEventId: string | null;
583
+ messages: unknown[];
584
+ };
585
+ expect(requestBody.threadId).toBe(threadId);
586
+ expect(requestBody.lastSeenEventId).toBeNull();
587
+ expect(requestBody.messages).toEqual([]);
588
+ } finally {
589
+ vi.unstubAllGlobals();
590
+ }
591
+ });
592
+
593
+ it("restores a completed Open Generative UI activity after reconnect from an event-native baseline", async () => {
594
+ mockWebsandboxCreate.mockClear();
595
+ mockWebsandboxDestroy.mockClear();
596
+
597
+ const agent = new MockReconnectableAgent();
598
+ const threadId = testId("open-generative-ui-thread");
599
+ const restoredHtml =
600
+ "<head></head><body><div>Restored open generative UI</div></body>";
601
+
602
+ const renderOpenGenerativeUIChat = () => {
603
+ const Host = defineComponent({
604
+ components: {
605
+ CopilotKitProvider,
606
+ CopilotChatConfigurationProvider,
607
+ CopilotChat,
608
+ },
609
+ setup() {
610
+ return {
611
+ agents: { default: agent },
612
+ openGenerativeUI: {},
613
+ threadId,
614
+ };
615
+ },
616
+ template: `
617
+ <CopilotKitProvider
618
+ :agents__unsafe_dev_only="agents"
619
+ :open-generative-u-i="openGenerativeUI"
620
+ >
621
+ <CopilotChatConfigurationProvider :thread-id="threadId">
622
+ <div style="height: 400px;">
623
+ <CopilotChat :welcome-screen="false" />
624
+ </div>
625
+ </CopilotChatConfigurationProvider>
626
+ </CopilotKitProvider>
627
+ `,
628
+ });
629
+ return render(Host);
630
+ };
631
+
632
+ const { unmount } = renderOpenGenerativeUIChat();
633
+
634
+ // Allow the /connect bootstrap cycle to settle before submitting.
635
+ // See the A2UI reconnect test above for the full rationale.
636
+ await waitFor(() => {
637
+ expect(
638
+ screen.queryByTestId("copilot-chat-view"),
639
+ ).not.toBeNull();
640
+ });
641
+ await new Promise((r) => setTimeout(r, 50));
642
+
643
+ await submitMessageAndWaitForUserMessage("Show me the restored app");
644
+
645
+ await agent.emit(runStartedEvent());
646
+ await agent.emit(
647
+ activitySnapshotEvent({
648
+ messageId: testId("open-generative-ui-activity"),
649
+ activityType: "open-generative-ui",
650
+ content: {
651
+ initialHeight: 180,
652
+ generating: false,
653
+ html: [restoredHtml],
654
+ htmlComplete: true,
655
+ },
656
+ }),
657
+ );
658
+ await agent.emit(runFinishedEvent());
659
+ await agent.complete();
660
+
661
+ await waitFor(() => {
662
+ expect(mockWebsandboxCreate).toHaveBeenCalledTimes(1);
663
+ });
664
+ expect(mockWebsandboxCreate.mock.calls[0]?.[1]).toMatchObject({
665
+ frameContent: restoredHtml,
666
+ });
667
+
668
+ unmount();
669
+
670
+ agent.reset();
671
+
672
+ renderOpenGenerativeUIChat();
673
+
674
+ await waitFor(() => {
675
+ expect(mockWebsandboxCreate).toHaveBeenCalledTimes(2);
676
+ });
677
+ expect(mockWebsandboxCreate.mock.calls[1]?.[1]).toMatchObject({
678
+ frameContent: restoredHtml,
679
+ });
680
+
681
+ expect(mockWebsandboxDestroy).toHaveBeenCalledTimes(1);
682
+ });
683
+ });