@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,42 @@
1
+ import js from "@eslint/js";
2
+ import globals from "globals";
3
+ import pluginVue from "eslint-plugin-vue";
4
+ import tseslint from "typescript-eslint";
5
+ import vueParser from "vue-eslint-parser";
6
+
7
+ export default [
8
+ {
9
+ ignores: ["node_modules/**", "dist/**"],
10
+ },
11
+ {
12
+ languageOptions: {
13
+ ecmaVersion: "latest",
14
+ sourceType: "module",
15
+ globals: {
16
+ ...globals.browser,
17
+ ...globals.node,
18
+ },
19
+ },
20
+ },
21
+ js.configs.recommended,
22
+ ...tseslint.configs.recommended,
23
+ ...pluginVue.configs["flat/essential"],
24
+ {
25
+ files: ["**/*.{ts,mts,cts,tsx}"],
26
+ languageOptions: {
27
+ parser: tseslint.parser,
28
+ },
29
+ },
30
+ {
31
+ files: ["**/*.vue"],
32
+ languageOptions: {
33
+ parser: vueParser,
34
+ parserOptions: {
35
+ parser: tseslint.parser,
36
+ ecmaVersion: "latest",
37
+ sourceType: "module",
38
+ extraFileExtensions: [".vue"],
39
+ },
40
+ },
41
+ },
42
+ ];
package/package.json ADDED
@@ -0,0 +1,130 @@
1
+ {
2
+ "name": "@copilotkit/vue",
3
+ "version": "1.57.1",
4
+ "private": false,
5
+ "description": "Vue 3 components and composables for CopilotKit",
6
+ "keywords": [
7
+ "ai",
8
+ "assistant",
9
+ "automation",
10
+ "copilot",
11
+ "copilotkit",
12
+ "javascript",
13
+ "vue",
14
+ "vue3"
15
+ ],
16
+ "homepage": "https://github.com/CopilotKit/CopilotKit",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/CopilotKit/CopilotKit.git"
21
+ },
22
+ "type": "module",
23
+ "sideEffects": [
24
+ "**/*.css"
25
+ ],
26
+ "main": "./dist/index.cjs",
27
+ "module": "./dist/index.mjs",
28
+ "types": "./dist/index.d.cts",
29
+ "typesVersions": {
30
+ "*": {
31
+ "v2": [
32
+ "./dist/v2/index.d.cts"
33
+ ]
34
+ }
35
+ },
36
+ "exports": {
37
+ ".": {
38
+ "import": {
39
+ "types": "./dist/index.d.mts",
40
+ "default": "./dist/index.mjs"
41
+ },
42
+ "require": {
43
+ "types": "./dist/index.d.cts",
44
+ "default": "./dist/index.cjs"
45
+ }
46
+ },
47
+ "./v2": {
48
+ "import": {
49
+ "types": "./dist/v2/index.d.mts",
50
+ "default": "./dist/v2/index.mjs"
51
+ },
52
+ "require": {
53
+ "types": "./dist/v2/index.d.cts",
54
+ "default": "./dist/v2/index.cjs"
55
+ }
56
+ },
57
+ "./styles.css": "./dist/styles.css",
58
+ "./package.json": "./package.json"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
62
+ },
63
+ "scripts": {
64
+ "build": "vite build && pnpm build:css && pnpm build:types",
65
+ "build:css": "npx @tailwindcss/cli -i ./src/styles/globals.css -o ./dist/styles.css -m && node scripts/scope-preflight.mjs ./dist/styles.css",
66
+ "build:types": "vue-tsc -p tsconfig.json --declaration --emitDeclarationOnly --outDir dist --skipLibCheck && cp ./dist/index.d.ts ./dist/index.d.mts && cp ./dist/index.d.ts ./dist/index.d.cts && cp ./dist/v2/index.d.ts ./dist/v2/index.d.mts && cp ./dist/v2/index.d.ts ./dist/v2/index.d.cts",
67
+ "dev:css": "npx @tailwindcss/cli -i ./src/styles/globals.css -o ./dist/styles.css --watch --minify",
68
+ "dev": "concurrently \"pnpm dev:css\" \"vite build --watch\"",
69
+ "test": "vitest run",
70
+ "test:watch": "vitest",
71
+ "test:coverage": "vitest run --coverage",
72
+ "test:ui": "vitest --ui",
73
+ "lint": "eslint .",
74
+ "check-types": "vue-tsc --noEmit",
75
+ "publint": "publint .",
76
+ "attw": "attw --pack . --profile node16 --exclude-entrypoints ./styles.css --ignore-rules internal-resolution-error",
77
+ "clean": "rm -rf dist"
78
+ },
79
+ "dependencies": {
80
+ "@a2ui/web_core": "0.9.0",
81
+ "@ag-ui/client": "0.0.53",
82
+ "@ag-ui/core": "0.0.53",
83
+ "@copilotkit/core": "workspace:*",
84
+ "@copilotkit/shared": "workspace:*",
85
+ "@copilotkit/web-inspector": "workspace:*",
86
+ "@jetbrains/websandbox": "^1.1.3",
87
+ "katex": "^0.16.27",
88
+ "lucide-vue-next": "^0.525.0",
89
+ "streamdown-vue": "^1.0.29",
90
+ "zod": "^3.25.75",
91
+ "zod-to-json-schema": "^3.24.5"
92
+ },
93
+ "devDependencies": {
94
+ "@copilotkit/typescript-config": "workspace:*",
95
+ "@eslint/js": "^9.39.2",
96
+ "@tailwindcss/cli": "^4.1.11",
97
+ "@tailwindcss/postcss": "^4.1.11",
98
+ "@tailwindcss/typography": "^0.5.16",
99
+ "@testing-library/vue": "^8.1.0",
100
+ "@types/node": "^22.15.3",
101
+ "@vitejs/plugin-vue": "^5.2.1",
102
+ "@vue/compiler-sfc": "^3.5.14",
103
+ "@vue/test-utils": "^2.4.6",
104
+ "arktype": "^2.1.29",
105
+ "concurrently": "^9.1.0",
106
+ "eslint": "^9.30.0",
107
+ "eslint-plugin-vue": "^10.8.0",
108
+ "globals": "^16.5.0",
109
+ "jsdom": "^26.1.0",
110
+ "phoenix": "^1.8.4",
111
+ "postcss": "^8.5.6",
112
+ "rxjs": "7.8.1",
113
+ "tailwindcss": "^4.0.8",
114
+ "tw-animate-css": "^1.3.5",
115
+ "typescript": "5.8.2",
116
+ "typescript-eslint": "^8.52.0",
117
+ "valibot": "^1.3.0",
118
+ "vite": "^6.0.0",
119
+ "vitest": "^4.1.3",
120
+ "vue": "^3.5.28",
121
+ "vue-eslint-parser": "^10.4.0",
122
+ "vue-tsc": "^2.1.10"
123
+ },
124
+ "peerDependencies": {
125
+ "vue": ">=3.3.0"
126
+ },
127
+ "engines": {
128
+ "node": ">=18"
129
+ }
130
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Post-processes compiled Tailwind CSS to scope all @layer base rules
3
+ * under [data-copilotkit], preventing CopilotKit styles from leaking
4
+ * into the host application.
5
+ *
6
+ * Run after `tailwindcss` CLI: node scripts/scope-preflight.mjs <file>
7
+ */
8
+
9
+ import { readFileSync, writeFileSync } from "fs";
10
+ import { parse } from "postcss";
11
+
12
+ const SCOPE = "[data-copilotkit]";
13
+ const file = process.argv[2];
14
+ if (!file) {
15
+ console.error("Usage: node scripts/scope-preflight.mjs <css-file>");
16
+ process.exit(1);
17
+ }
18
+
19
+ /** Selectors that are already scoped and should be left alone. */
20
+ function isAlreadyScoped(selector) {
21
+ return (
22
+ selector.includes("[data-copilot") || selector.includes("[data-sidebar")
23
+ );
24
+ }
25
+
26
+ /** Rewrite a single selector to be scoped under [data-copilotkit]. */
27
+ function scopeSelector(sel) {
28
+ sel = sel.trim();
29
+
30
+ // Already scoped — keep as-is
31
+ if (isAlreadyScoped(sel)) return sel;
32
+
33
+ // html, :host → [data-copilotkit]
34
+ if (sel === "html" || sel === ":host" || sel === "html,:host") {
35
+ return SCOPE;
36
+ }
37
+
38
+ // body → null (remove)
39
+ if (sel === "body") return null;
40
+
41
+ // ::backdrop → null (cannot be scoped to a container)
42
+ if (sel === "::backdrop") return null;
43
+
44
+ // Bare universal selector → scope to container + descendants
45
+ if (sel === "*") return `${SCOPE}, ${SCOPE} *`;
46
+
47
+ // Pseudo-elements (::) and vendor pseudo-classes (:-) → descendant only
48
+ // These can't be combined with an attribute selector suffix
49
+ if (sel.startsWith(":")) {
50
+ return `${SCOPE} ${sel}`;
51
+ }
52
+
53
+ // Element / attribute selectors → descendant AND self-matching
54
+ // e.g. button → [data-copilotkit] button, button[data-copilotkit]
55
+ // This ensures <button data-copilotkit> also receives the preflight reset
56
+ return `${SCOPE} ${sel}, ${sel}${SCOPE}`;
57
+ }
58
+
59
+ function scopeRule(rule) {
60
+ const newSelectors = [];
61
+
62
+ for (const sel of rule.selectors) {
63
+ const scoped = scopeSelector(sel);
64
+ if (scoped !== null) {
65
+ // scopeSelector may return comma-separated selectors (for *)
66
+ if (typeof scoped === "string" && scoped.includes(", ")) {
67
+ newSelectors.push(...scoped.split(", "));
68
+ } else if (scoped) {
69
+ newSelectors.push(scoped);
70
+ }
71
+ }
72
+ }
73
+
74
+ if (newSelectors.length === 0) {
75
+ rule.remove();
76
+ } else {
77
+ rule.selectors = newSelectors;
78
+ }
79
+ }
80
+
81
+ /** Recursively scope all rules within a node (handles @supports, @media, etc.) */
82
+ function scopeChildren(node) {
83
+ node.walk((child) => {
84
+ if (child.type === "rule") {
85
+ scopeRule(child);
86
+ }
87
+ // @supports / @media blocks are walked automatically
88
+ });
89
+ }
90
+
91
+ // --- Main ---
92
+ const css = readFileSync(file, "utf8");
93
+ const root = parse(css);
94
+
95
+ root.walkAtRules("layer", (layer) => {
96
+ if (layer.params !== "base") return;
97
+ scopeChildren(layer);
98
+ });
99
+
100
+ writeFileSync(file, root.toString());
@@ -0,0 +1,18 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * V1 compatibility wrapper for CopilotKitProvider.
4
+ *
5
+ * Accepts the same props as CopilotKitProvider plus legacy v1 props
6
+ * (publicApiKey, publicLicenseKey) and delegates to the v2 provider.
7
+ */
8
+ import type { CopilotKitProps } from "./types";
9
+ import CopilotKitProvider from "../../v2/providers/CopilotKitProvider.vue";
10
+
11
+ const props = defineProps<CopilotKitProps>();
12
+ </script>
13
+
14
+ <template>
15
+ <CopilotKitProvider v-bind="props">
16
+ <slot />
17
+ </CopilotKitProvider>
18
+ </template>
@@ -0,0 +1,2 @@
1
+ export { default as CopilotKit } from "./CopilotKit.vue";
2
+ export type { CopilotKitProps } from "./types";
@@ -0,0 +1,24 @@
1
+ import type { CopilotKitProviderProps } from "../../v2/providers/CopilotKitProvider.types";
2
+
3
+ /**
4
+ * V1 CopilotKit component props.
5
+ *
6
+ * Extends the v2 CopilotKitProviderProps with legacy v1-specific fields.
7
+ */
8
+ export interface CopilotKitProps extends CopilotKitProviderProps {
9
+ /**
10
+ * Your Copilot Cloud API key.
11
+ * @deprecated Use publicLicenseKey with the v2 CopilotKitProvider instead.
12
+ */
13
+ publicApiKey?: string;
14
+
15
+ /**
16
+ * Your public license key for accessing premium CopilotKit features.
17
+ */
18
+ publicLicenseKey?: string;
19
+
20
+ /**
21
+ * The endpoint for the Copilot Runtime instance.
22
+ */
23
+ runtimeUrl?: string;
24
+ }
@@ -0,0 +1,9 @@
1
+ export { useCopilotAction } from "./use-copilot-action";
2
+ export type {
3
+ FrontendAction,
4
+ CatchAllFrontendAction,
5
+ } from "./use-copilot-action";
6
+ export { useFrontendTool } from "./use-frontend-tool";
7
+ export type { UseFrontendToolArgs } from "./use-frontend-tool";
8
+ export { useCopilotReadable } from "./use-copilot-readable";
9
+ export type { UseCopilotReadableOptions } from "./use-copilot-readable";
@@ -0,0 +1,168 @@
1
+ /**
2
+ * V1 compatibility wrapper for useCopilotAction.
3
+ *
4
+ * Accepts the legacy Parameter[] action format and routes to the appropriate
5
+ * v2 composable (useFrontendTool, useHumanInTheLoop, or useRenderTool).
6
+ */
7
+ import type { WatchSource } from "vue";
8
+ import type { Parameter, MappedParameterTypes } from "@copilotkit/shared";
9
+ import { getZodParameters, parseJson } from "@copilotkit/shared";
10
+ import { useFrontendTool as useFrontendToolV2 } from "../v2/hooks/use-frontend-tool";
11
+ import { useHumanInTheLoop as useHumanInTheLoopV2 } from "../v2/hooks/use-human-in-the-loop";
12
+ import { useRenderTool as useRenderToolV2 } from "../v2/hooks/use-render-tool";
13
+ import type { VueFrontendTool, VueHumanInTheLoop } from "../v2/types";
14
+
15
+ // Wraps a v1 render function so a JSON-string `result` is parsed before being
16
+ // passed through. Mirrors the v1 React behavior. If render is a Component
17
+ // (object) rather than a function, returns it unchanged — Components receive
18
+ // props through Vue's prop system and the user is responsible for parsing.
19
+ function wrapRenderWithJsonResult<R>(render: R): R {
20
+ if (typeof render !== "function") return render;
21
+ return ((props: { result?: unknown }) => {
22
+ const next =
23
+ typeof props.result === "string"
24
+ ? { ...props, result: parseJson(props.result, props.result) }
25
+ : props;
26
+ return (render as (p: unknown) => unknown)(next);
27
+ }) as R;
28
+ }
29
+
30
+ export interface FrontendAction<T extends Parameter[] | [] = []> {
31
+ name: string;
32
+ description?: string;
33
+ parameters?: T;
34
+ handler?: (args: MappedParameterTypes<T>) => unknown | Promise<unknown>;
35
+ followUp?: boolean;
36
+ available?: "disabled" | "enabled" | "remote" | "frontend";
37
+ render?: VueFrontendTool<MappedParameterTypes<T>>["render"];
38
+ renderAndWaitForResponse?: VueFrontendTool<MappedParameterTypes<T>>["render"];
39
+ renderAndWait?: VueFrontendTool<MappedParameterTypes<T>>["render"];
40
+ agentId?: string;
41
+ }
42
+
43
+ export interface CatchAllFrontendAction {
44
+ name: "*";
45
+ render: (props: unknown) => unknown;
46
+ }
47
+
48
+ export function useCopilotAction<const T extends Parameter[] | [] = []>(
49
+ action: FrontendAction<T> | CatchAllFrontendAction,
50
+ deps?: WatchSource<unknown>[],
51
+ ): void {
52
+ const zodParameters =
53
+ "parameters" in action
54
+ ? getZodParameters(action.parameters as T)
55
+ : undefined;
56
+
57
+ // Catch-all render action
58
+ if (action.name === "*") {
59
+ useRenderToolV2(
60
+ {
61
+ name: "*",
62
+ render: wrapRenderWithJsonResult(
63
+ (action as CatchAllFrontendAction).render,
64
+ ),
65
+ ...("agentId" in action
66
+ ? { agentId: (action as FrontendAction<T>).agentId }
67
+ : {}),
68
+ },
69
+ deps,
70
+ );
71
+ return;
72
+ }
73
+
74
+ const typedAction = action as FrontendAction<T>;
75
+
76
+ // Human-in-the-loop: has renderAndWaitForResponse or renderAndWait
77
+ if (
78
+ "renderAndWaitForResponse" in typedAction ||
79
+ "renderAndWait" in typedAction
80
+ ) {
81
+ const render =
82
+ typedAction.render ??
83
+ typedAction.renderAndWaitForResponse ??
84
+ typedAction.renderAndWait;
85
+
86
+ if (!render) {
87
+ console.warn(
88
+ `[CopilotKit] useCopilotAction: HITL action '${typedAction.name}' ` +
89
+ `has no render function. Skipping.`,
90
+ );
91
+ return;
92
+ }
93
+
94
+ useHumanInTheLoopV2<MappedParameterTypes<T>>(
95
+ {
96
+ name: typedAction.name,
97
+ description: typedAction.description,
98
+ parameters: zodParameters,
99
+ render: wrapRenderWithJsonResult(render) as VueHumanInTheLoop<
100
+ MappedParameterTypes<T>
101
+ >["render"],
102
+ agentId: typedAction.agentId,
103
+ },
104
+ deps,
105
+ );
106
+ return;
107
+ }
108
+
109
+ // Render-only: available is "frontend" or "disabled" (no handler invoked remotely)
110
+ if (
111
+ typedAction.available === "frontend" ||
112
+ typedAction.available === "disabled"
113
+ ) {
114
+ if (typedAction.render && zodParameters) {
115
+ useRenderToolV2(
116
+ {
117
+ name: typedAction.name,
118
+ parameters: zodParameters,
119
+ render: wrapRenderWithJsonResult(
120
+ typedAction.render as (props: unknown) => unknown,
121
+ ),
122
+ agentId: typedAction.agentId,
123
+ },
124
+ deps,
125
+ );
126
+ } else {
127
+ console.warn(
128
+ `[CopilotKit] useCopilotAction: action '${typedAction.name}' ` +
129
+ `with available="${typedAction.available}" requires both ` +
130
+ `'render' and 'parameters'. Skipping registration.`,
131
+ );
132
+ }
133
+ return;
134
+ }
135
+
136
+ // Default: frontend tool with handler
137
+ // Wrap the v1 handler (single-arg) to match v2's (args, context) => Promise<unknown> signature
138
+ const normalizedHandler = typedAction.handler
139
+ ? (args: MappedParameterTypes<T>) =>
140
+ Promise.resolve(typedAction.handler!(args))
141
+ : undefined;
142
+
143
+ // Convert v1 available (string enum) to v2 available (boolean)
144
+ // At this point, "frontend" and "disabled" have been handled above,
145
+ // so remaining values are "enabled", "remote", or undefined.
146
+ // "remote" means server-only: register the tool but mark it as not
147
+ // available on the frontend (matches React's ActionInputAvailability.Remote).
148
+ let normalizedAvailable: boolean | undefined;
149
+ if (typedAction.available === "remote") {
150
+ normalizedAvailable = false;
151
+ } else if (typedAction.available !== undefined) {
152
+ normalizedAvailable = true;
153
+ }
154
+
155
+ useFrontendToolV2<MappedParameterTypes<T>>(
156
+ {
157
+ name: typedAction.name,
158
+ description: typedAction.description,
159
+ parameters: zodParameters,
160
+ handler: normalizedHandler,
161
+ followUp: typedAction.followUp,
162
+ render: wrapRenderWithJsonResult(typedAction.render),
163
+ available: normalizedAvailable,
164
+ agentId: typedAction.agentId,
165
+ },
166
+ deps,
167
+ );
168
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * V1 compatibility wrapper for useCopilotReadable.
3
+ *
4
+ * Provides app-state and other information to the Copilot context.
5
+ * Delegates directly to the v2 CopilotKitCoreVue instance.
6
+ */
7
+ import { watch, ref, type Ref } from "vue";
8
+ import type { WatchSource } from "vue";
9
+ import { useCopilotKit } from "../v2/providers/useCopilotKit";
10
+
11
+ export interface UseCopilotReadableOptions {
12
+ /** The description of the information to be added to the Copilot context. */
13
+ description: string;
14
+ /** The value to be added to the Copilot context. Object values are automatically stringified. */
15
+ value: unknown;
16
+ /** Whether the context is available to the Copilot. */
17
+ available?: "enabled" | "disabled";
18
+ /** Custom conversion function to serialize the value to a string. */
19
+ convert?: (description: string, value: unknown) => string;
20
+ }
21
+
22
+ export function useCopilotReadable(
23
+ options: UseCopilotReadableOptions,
24
+ deps?: WatchSource<unknown>[],
25
+ ): Ref<string | undefined> {
26
+ const { copilotkit } = useCopilotKit();
27
+ const ctxIdRef = ref<string | undefined>(undefined);
28
+
29
+ const extraDeps = deps ?? [];
30
+
31
+ watch(
32
+ [
33
+ () => options.description,
34
+ () => options.value,
35
+ () => options.convert,
36
+ () => options.available,
37
+ ...extraDeps,
38
+ ],
39
+ (_newValues, _old, onCleanup) => {
40
+ const core = copilotkit.value;
41
+ if (!core) return;
42
+
43
+ const { description, value, convert, available } = options;
44
+
45
+ let serializedValue: string;
46
+ try {
47
+ serializedValue = convert
48
+ ? convert(description, value)
49
+ : JSON.stringify(value);
50
+ } catch (err) {
51
+ console.warn(
52
+ `[CopilotKit] useCopilotReadable: failed to serialize ` +
53
+ `value for "${description}":`,
54
+ err,
55
+ );
56
+ serializedValue = String(value);
57
+ }
58
+
59
+ if (available === "disabled") return;
60
+
61
+ ctxIdRef.value = core.addContext({
62
+ description,
63
+ value: serializedValue,
64
+ });
65
+
66
+ onCleanup(() => {
67
+ if (!ctxIdRef.value) return;
68
+ core.removeContext(ctxIdRef.value);
69
+ });
70
+ },
71
+ { immediate: true },
72
+ );
73
+
74
+ return ctxIdRef;
75
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * V1 compatibility wrapper for useFrontendTool.
3
+ *
4
+ * Accepts the legacy Parameter[] format and converts to Zod via getZodParameters,
5
+ * then delegates to the v2 composable.
6
+ */
7
+ import type { WatchSource } from "vue";
8
+ import {
9
+ type Parameter,
10
+ type MappedParameterTypes,
11
+ getZodParameters,
12
+ parseJson,
13
+ } from "@copilotkit/shared";
14
+ import { useFrontendTool as useFrontendToolV2 } from "../v2/hooks/use-frontend-tool";
15
+ import type { VueFrontendTool } from "../v2/types";
16
+
17
+ export interface UseFrontendToolArgs<T extends Parameter[] | [] = []> {
18
+ name: string;
19
+ description?: string;
20
+ parameters?: T;
21
+ handler?: (args: MappedParameterTypes<T>) => unknown | Promise<unknown>;
22
+ followUp?: boolean;
23
+ available?: "disabled" | "enabled";
24
+ render?: VueFrontendTool<MappedParameterTypes<T>>["render"];
25
+ agentId?: string;
26
+ }
27
+
28
+ export function useFrontendTool<const T extends Parameter[] = []>(
29
+ tool: UseFrontendToolArgs<T>,
30
+ deps?: WatchSource<unknown>[],
31
+ ) {
32
+ const {
33
+ name,
34
+ description,
35
+ parameters,
36
+ handler,
37
+ followUp,
38
+ available,
39
+ render,
40
+ agentId,
41
+ } = tool;
42
+ const zodParameters = getZodParameters(parameters);
43
+
44
+ // Wrap the v1 handler (single-arg) to match v2's (args, context) => Promise<unknown> signature
45
+ const normalizedHandler = handler
46
+ ? (args: MappedParameterTypes<T>) => Promise.resolve(handler(args))
47
+ : undefined;
48
+
49
+ // Wrap render to parse JSON-string results before passing them to the
50
+ // user's render function — matches the v1 React behavior. If render is a
51
+ // Component rather than a function, leave it unchanged.
52
+ const normalizedRender =
53
+ typeof render === "function"
54
+ ? ((props: { result?: unknown }) => {
55
+ const renderProps =
56
+ typeof props.result === "string"
57
+ ? { ...props, result: parseJson(props.result, props.result) }
58
+ : props;
59
+ return (render as (p: unknown) => unknown)(renderProps);
60
+ })
61
+ : render;
62
+
63
+ useFrontendToolV2<MappedParameterTypes<T>>(
64
+ {
65
+ name,
66
+ description,
67
+ parameters: zodParameters,
68
+ handler: normalizedHandler,
69
+ followUp,
70
+ render: normalizedRender,
71
+ available: available === undefined ? undefined : available !== "disabled",
72
+ agentId,
73
+ },
74
+ deps,
75
+ );
76
+ }
package/src/index.ts ADDED
@@ -0,0 +1,12 @@
1
+ // V1 compat entry -- re-exports v2 with backward-compat wrappers
2
+ export * from "./v2";
3
+
4
+ // V1 wrapper overrides (these shadow v2 exports where the API differs)
5
+ export { useCopilotAction } from "./hooks";
6
+ export type { FrontendAction, CatchAllFrontendAction } from "./hooks";
7
+ export { useFrontendTool } from "./hooks";
8
+ export type { UseFrontendToolArgs } from "./hooks";
9
+ export { useCopilotReadable } from "./hooks";
10
+ export type { UseCopilotReadableOptions } from "./hooks";
11
+ export { CopilotKit } from "./components/copilot-provider";
12
+ export type { CopilotKitProps } from "./components/copilot-provider";