@copilotkit/vue 2.0.0-rc.0 → 2.0.0-rc.10

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 (317) hide show
  1. package/PARITY.md +13 -12
  2. package/README.md +1 -2
  3. package/dist/components/copilot-provider/CopilotKit.vue.d.ts +3 -1
  4. package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -1
  5. package/dist/hooks/use-copilot-action.d.ts.map +1 -1
  6. package/dist/hooks/use-frontend-tool.d.ts +1 -1
  7. package/dist/hooks/use-frontend-tool.d.ts.map +1 -1
  8. package/dist/hooks/zod-parameters.d.ts +14 -0
  9. package/dist/hooks/zod-parameters.d.ts.map +1 -0
  10. package/dist/index.cjs +1 -76
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.mjs +384 -14275
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/use-render-activity-message-CTR_ziWV.js +18097 -0
  15. package/dist/use-render-activity-message-CTR_ziWV.js.map +1 -0
  16. package/dist/use-render-activity-message-Dky9_GRG.cjs +92 -0
  17. package/dist/use-render-activity-message-Dky9_GRG.cjs.map +1 -0
  18. package/dist/v2/components/A2UIMessageRenderer.d.ts +7 -0
  19. package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
  20. package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
  21. package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
  22. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +13 -45
  23. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
  24. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +11 -2
  25. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
  26. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +1 -1
  27. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
  28. package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +144 -0
  29. package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -0
  30. package/dist/v2/components/a2ui.d.ts +3 -7
  31. package/dist/v2/components/a2ui.d.ts.map +1 -1
  32. package/dist/v2/components/chat/CopilotChat.vue.d.ts +1 -0
  33. package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
  34. package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +3 -1
  35. package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
  36. package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts +16 -0
  37. package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts.map +1 -0
  38. package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
  39. package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -1
  40. package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -1
  41. package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +22 -0
  42. package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -0
  43. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +21 -232
  44. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
  45. package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts +12 -0
  46. package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -0
  47. package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts +22 -0
  48. package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -0
  49. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +20 -0
  50. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
  51. package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
  52. package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts.map +1 -1
  53. package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -1
  54. package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -1
  55. package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +32 -0
  56. package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -0
  57. package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
  58. package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +11 -1
  59. package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
  60. package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -1
  61. package/dist/v2/components/chat/CopilotChatView.vue.d.ts +1 -0
  62. package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
  63. package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts +5 -0
  64. package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -0
  65. package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
  66. package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -1
  67. package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -1
  68. package/dist/v2/components/chat/CopilotPopup.vue.d.ts +1 -0
  69. package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
  70. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +1 -0
  71. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
  72. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +1 -0
  73. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
  74. package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -1
  75. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +2 -0
  76. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
  77. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +2 -0
  78. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
  79. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +2 -0
  80. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
  81. package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -1
  82. package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
  83. package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +0 -1
  84. package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
  85. package/dist/v2/components/chat/index.d.ts +17 -1
  86. package/dist/v2/components/chat/index.d.ts.map +1 -1
  87. package/dist/v2/components/chat/inspector-shortcuts.d.ts +12 -0
  88. package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -0
  89. package/dist/v2/components/chat/message-feedback.d.ts +89 -0
  90. package/dist/v2/components/chat/message-feedback.d.ts.map +1 -0
  91. package/dist/v2/components/chat/tool-call-capture.d.ts +39 -0
  92. package/dist/v2/components/chat/tool-call-capture.d.ts.map +1 -0
  93. package/dist/v2/components/chat/tool-call-display-context.d.ts +22 -0
  94. package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -0
  95. package/dist/v2/components/chat/tool-call-group-parts.d.ts +131 -0
  96. package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -0
  97. package/dist/v2/components/chat/turn-work.d.ts +33 -0
  98. package/dist/v2/components/chat/turn-work.d.ts.map +1 -0
  99. package/dist/v2/components/chat/types.d.ts +104 -5
  100. package/dist/v2/components/chat/types.d.ts.map +1 -1
  101. package/dist/v2/components/chat/use-chat-labels.d.ts +8 -0
  102. package/dist/v2/components/chat/use-chat-labels.d.ts.map +1 -0
  103. package/dist/v2/components/chat/use-lightbox.d.ts +18 -0
  104. package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -0
  105. package/dist/v2/components/icons/index.d.ts +968 -1
  106. package/dist/v2/components/icons/index.d.ts.map +1 -1
  107. package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts +55 -0
  108. package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -0
  109. package/dist/v2/components/ui/CopilotPopover.vue.d.ts +40 -0
  110. package/dist/v2/components/ui/CopilotPopover.vue.d.ts.map +1 -0
  111. package/dist/v2/components/ui/CopilotTooltip.vue.d.ts +37 -0
  112. package/dist/v2/components/ui/CopilotTooltip.vue.d.ts.map +1 -0
  113. package/dist/v2/components/ui/dropdown-menu.d.ts +14 -0
  114. package/dist/v2/components/ui/dropdown-menu.d.ts.map +1 -0
  115. package/dist/v2/components/ui/floating.d.ts +84 -0
  116. package/dist/v2/components/ui/floating.d.ts.map +1 -0
  117. package/dist/v2/components/ui/presence.d.ts +9 -0
  118. package/dist/v2/components/ui/presence.d.ts.map +1 -0
  119. package/dist/v2/components/ui/use-id.d.ts +9 -0
  120. package/dist/v2/components/ui/use-id.d.ts.map +1 -0
  121. package/dist/v2/hooks/use-default-render-tool.d.ts +6 -0
  122. package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -1
  123. package/dist/v2/hooks/use-frontend-tool.d.ts +5 -0
  124. package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -1
  125. package/dist/v2/hooks/use-render-activity-message.d.ts +13 -9
  126. package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
  127. package/dist/v2/hooks/use-render-custom-messages.d.ts +5 -7
  128. package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -1
  129. package/dist/v2/hooks/use-render-tool.d.ts +4 -0
  130. package/dist/v2/hooks/use-render-tool.d.ts.map +1 -1
  131. package/dist/v2/index.cjs +1 -1
  132. package/dist/v2/index.d.cts +3 -0
  133. package/dist/v2/index.d.mts +3 -0
  134. package/dist/v2/index.d.ts +3 -0
  135. package/dist/v2/index.d.ts.map +1 -1
  136. package/dist/v2/index.mjs +197 -197
  137. package/dist/v2/index.mjs.map +1 -1
  138. package/dist/v2/lib/message-feedback.d.ts +33 -0
  139. package/dist/v2/lib/message-feedback.d.ts.map +1 -0
  140. package/dist/v2/lib/processPartialHtml.d.ts +1 -2
  141. package/dist/v2/lib/processPartialHtml.d.ts.map +1 -1
  142. package/dist/v2/lib/vue-core.d.ts +0 -1
  143. package/dist/v2/lib/vue-core.d.ts.map +1 -1
  144. package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
  145. package/dist/v2/providers/CopilotKitProvider.types.d.ts +56 -6
  146. package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
  147. package/dist/v2/providers/CopilotKitProvider.vue.d.ts +6 -2
  148. package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
  149. package/dist/v2/providers/index.d.ts +1 -1
  150. package/dist/v2/providers/index.d.ts.map +1 -1
  151. package/dist/v2/providers/keys.d.ts +8 -0
  152. package/dist/v2/providers/keys.d.ts.map +1 -1
  153. package/dist/v2/providers/types.d.ts +3 -37
  154. package/dist/v2/providers/types.d.ts.map +1 -1
  155. package/dist/v2/styles/CopilotKitStyles.d.ts +18 -0
  156. package/dist/v2/styles/CopilotKitStyles.d.ts.map +1 -0
  157. package/dist/v2/types/defineToolCallRenderer.d.ts +2 -0
  158. package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -1
  159. package/dist/v2/types/human-in-the-loop.d.ts +8 -29
  160. package/dist/v2/types/human-in-the-loop.d.ts.map +1 -1
  161. package/dist/v2/types/interrupt.d.ts +1 -22
  162. package/dist/v2/types/interrupt.d.ts.map +1 -1
  163. package/dist/v2/types/vue-activity-message-renderer.d.ts +16 -15
  164. package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -1
  165. package/dist/v2/types/vue-custom-message-renderer.d.ts +7 -16
  166. package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -1
  167. package/dist/v2/types/vue-tool-call-renderer.d.ts +16 -28
  168. package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
  169. package/package.json +14 -27
  170. package/src/__tests__/build-entries.test.ts +27 -0
  171. package/src/components/copilot-provider/CopilotKit.vue +4 -1
  172. package/src/hooks/__tests__/zod-parameters.test.ts +520 -0
  173. package/src/hooks/use-copilot-action.ts +2 -1
  174. package/src/hooks/use-frontend-tool.ts +3 -6
  175. package/src/hooks/zod-parameters.ts +162 -0
  176. package/src/v2/__tests__/exports.test.ts +4 -2
  177. package/src/v2/components/A2UIMessageRenderer.ts +56 -68
  178. package/src/v2/components/A2UISurfaceActivityRenderer.vue +11 -23
  179. package/src/v2/components/LicenseWarningBanner.vue +31 -15
  180. package/src/v2/components/OpenGenerativeUIRenderer.ts +51 -373
  181. package/src/v2/components/__tests__/A2UIBasicCatalogColors.test.ts +8 -9
  182. package/src/v2/components/__tests__/A2UICatalogContext.test.ts +1 -1
  183. package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +63 -36
  184. package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +20 -0
  185. package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +55 -6
  186. package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +15 -258
  187. package/src/v2/components/a2ui/A2UICatalogContext.ts +10 -102
  188. package/src/v2/components/a2ui/A2UIRecoveryStates.ts +444 -0
  189. package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +175 -0
  190. package/src/v2/components/a2ui.ts +1 -1
  191. package/src/v2/components/chat/CopilotChat.vue +26 -40
  192. package/src/v2/components/chat/CopilotChatAssistantMessage.vue +267 -67
  193. package/src/v2/components/chat/CopilotChatAssistantToolbarButton.vue +46 -0
  194. package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +150 -173
  195. package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +77 -20
  196. package/src/v2/components/chat/CopilotChatAudioRecorder.vue +2 -2
  197. package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +240 -0
  198. package/src/v2/components/chat/CopilotChatInput.vue +250 -191
  199. package/src/v2/components/chat/CopilotChatInspectorButton.vue +331 -0
  200. package/src/v2/components/chat/CopilotChatLightbox.vue +105 -0
  201. package/src/v2/components/chat/CopilotChatMessageView.vue +262 -87
  202. package/src/v2/components/chat/CopilotChatReasoningMessage.vue +52 -35
  203. package/src/v2/components/chat/CopilotChatSuggestionPill.vue +5 -14
  204. package/src/v2/components/chat/CopilotChatSuggestionView.vue +1 -4
  205. package/src/v2/components/chat/CopilotChatToggleButton.vue +3 -9
  206. package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +1 -1
  207. package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +1 -1
  208. package/src/v2/components/chat/CopilotChatToolCallGroup.vue +353 -0
  209. package/src/v2/components/chat/CopilotChatToolCallItem.vue +24 -14
  210. package/src/v2/components/chat/CopilotChatToolCallsView.vue +194 -21
  211. package/src/v2/components/chat/CopilotChatUserMessage.vue +105 -42
  212. package/src/v2/components/chat/CopilotChatView.vue +37 -42
  213. package/src/v2/components/chat/CopilotChatWorkSummary.vue +111 -0
  214. package/src/v2/components/chat/CopilotModalHeader.vue +10 -8
  215. package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +7 -6
  216. package/src/v2/components/chat/CopilotModalHeaderTitle.ts +1 -4
  217. package/src/v2/components/chat/CopilotPopup.vue +3 -0
  218. package/src/v2/components/chat/CopilotPopupView.vue +1 -0
  219. package/src/v2/components/chat/CopilotPopupViewInternal.vue +9 -19
  220. package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +5 -8
  221. package/src/v2/components/chat/CopilotSidebar.vue +5 -0
  222. package/src/v2/components/chat/CopilotSidebarView.vue +2 -0
  223. package/src/v2/components/chat/CopilotSidebarViewInternal.vue +24 -17
  224. package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +7 -10
  225. package/src/v2/components/chat/StreamingMarkdownDefault.vue +3 -5
  226. package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
  227. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +26 -9
  228. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.inspector.test.ts +269 -0
  229. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +760 -0
  230. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +3 -5
  231. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +2 -2
  232. package/src/v2/components/chat/__tests__/CopilotChatInput.addMenu.test.ts +328 -0
  233. package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +6 -3
  234. package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +55 -14
  235. package/src/v2/components/chat/__tests__/CopilotChatLightbox.test.ts +160 -0
  236. package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +247 -403
  237. package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +637 -0
  238. package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +1 -1
  239. package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +3 -1
  240. package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.learning.test.ts +75 -0
  241. package/src/v2/components/chat/__tests__/CopilotChatUserMessage.attachments.test.ts +143 -0
  242. package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +5 -4
  243. package/src/v2/components/chat/__tests__/CopilotChatView.rootWidth.test.ts +7 -33
  244. package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +1 -1
  245. package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +3 -3
  246. package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +126 -0
  247. package/src/v2/components/chat/__tests__/messageFeedbackDefaults.test.ts +33 -0
  248. package/src/v2/components/chat/__tests__/modalChatDisplayProps.test.ts +44 -0
  249. package/src/v2/components/chat/copilotChatToolCallItemRender.ts +3 -19
  250. package/src/v2/components/chat/index.ts +2 -1
  251. package/src/v2/components/chat/inspector-shortcuts.ts +34 -0
  252. package/src/v2/components/chat/message-feedback.ts +291 -0
  253. package/src/v2/components/chat/tool-call-capture.ts +55 -0
  254. package/src/v2/components/chat/tool-call-display-context.ts +28 -0
  255. package/src/v2/components/chat/tool-call-group-parts.ts +251 -0
  256. package/src/v2/components/chat/turn-work.ts +52 -0
  257. package/src/v2/components/chat/types.ts +114 -4
  258. package/src/v2/components/chat/use-chat-labels.ts +16 -0
  259. package/src/v2/components/chat/use-lightbox.ts +64 -0
  260. package/src/v2/components/icons/__tests__/icons.test.ts +72 -68
  261. package/src/v2/components/icons/index.ts +109 -23
  262. package/src/v2/components/ui/CopilotDropdownMenuContent.vue +465 -0
  263. package/src/v2/components/ui/CopilotPopover.vue +138 -0
  264. package/src/v2/components/ui/CopilotTooltip.vue +237 -0
  265. package/src/v2/components/ui/__tests__/CopilotTooltip.test.ts +168 -0
  266. package/src/v2/components/ui/dropdown-menu.ts +15 -0
  267. package/src/v2/components/ui/floating.ts +321 -0
  268. package/src/v2/components/ui/presence.ts +54 -0
  269. package/src/v2/components/ui/use-id.ts +16 -0
  270. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +62 -1
  271. package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +105 -0
  272. package/src/v2/hooks/__tests__/use-render-tool.test.ts +3 -6
  273. package/src/v2/hooks/__tests__/zod-regression.test.ts +5 -4
  274. package/src/v2/hooks/use-default-render-tool.ts +123 -62
  275. package/src/v2/hooks/use-frontend-tool.ts +10 -10
  276. package/src/v2/hooks/use-render-activity-message.ts +27 -48
  277. package/src/v2/hooks/use-render-custom-messages.ts +14 -35
  278. package/src/v2/hooks/use-render-tool.ts +8 -0
  279. package/src/v2/index.ts +3 -0
  280. package/src/v2/lib/__tests__/message-feedback.test.ts +152 -0
  281. package/src/v2/lib/message-feedback.ts +120 -0
  282. package/src/v2/lib/processPartialHtml.ts +6 -21
  283. package/src/v2/lib/vue-core.ts +3 -5
  284. package/src/v2/providers/CopilotChatConfigurationProvider.vue +29 -2
  285. package/src/v2/providers/CopilotKitProvider.types.ts +57 -5
  286. package/src/v2/providers/CopilotKitProvider.vue +177 -114
  287. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.openThread.test.ts +69 -0
  288. package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +1 -1
  289. package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +3 -3
  290. package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +536 -0
  291. package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +17 -33
  292. package/src/v2/providers/index.ts +4 -1
  293. package/src/v2/providers/keys.ts +12 -0
  294. package/src/v2/providers/types.ts +3 -38
  295. package/src/v2/styles/CopilotKitStyles.ts +95 -0
  296. package/src/v2/styles/__tests__/CopilotKitStyles.client.test.ts +149 -0
  297. package/src/v2/styles/__tests__/CopilotKitStyles.ssr.test.ts +71 -0
  298. package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +28 -33
  299. package/src/v2/types/defineToolCallRenderer.ts +9 -4
  300. package/src/v2/types/human-in-the-loop.ts +8 -32
  301. package/src/v2/types/interrupt.ts +7 -31
  302. package/src/v2/types/vue-activity-message-renderer.ts +24 -15
  303. package/src/v2/types/vue-custom-message-renderer.ts +12 -16
  304. package/src/v2/types/vue-tool-call-renderer.ts +23 -31
  305. package/vite.config.ts +5 -5
  306. package/dist/styles.css +0 -2
  307. package/dist/v2/components/chat/BasicMarkdown.vue.d.ts +0 -9
  308. package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +0 -1
  309. package/dist/v2/lib/transcription-client.d.ts +0 -19
  310. package/dist/v2/lib/transcription-client.d.ts.map +0 -1
  311. package/scripts/scope-preflight.mjs +0 -100
  312. package/src/styles/globals.css +0 -233
  313. package/src/v2/components/chat/BasicMarkdown.vue +0 -158
  314. package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +0 -69
  315. package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -84
  316. package/src/v2/lib/__tests__/transcription-client.test.ts +0 -67
  317. package/src/v2/lib/transcription-client.ts +0 -151
@@ -0,0 +1,291 @@
1
+ import type { AssistantMessage } from "@ag-ui/core";
2
+ import type { CopilotKitCore } from "@copilotkit/core";
3
+ import { computed, inject, onBeforeUnmount, ref, shallowRef, watch } from "vue";
4
+ import type { ComputedRef, InjectionKey, Ref } from "vue";
5
+ import {
6
+ getMessageFeedback,
7
+ setMessageFeedback,
8
+ subscribeToMessageFeedback,
9
+ } from "../../lib/message-feedback";
10
+ import type {
11
+ MessageFeedback,
12
+ MessageFeedbackRating,
13
+ } from "../../lib/message-feedback";
14
+
15
+ /** The chat whose assistant messages collect feedback for Learning. */
16
+ export interface MessageFeedbackScope {
17
+ readonly copilotkit: CopilotKitCore;
18
+ readonly agentId: string;
19
+ readonly threadId: string;
20
+ }
21
+
22
+ /**
23
+ * Provided by the message view while Learning is on for this chat. Assistant
24
+ * messages without it show thumbs only when the app passes its own handlers
25
+ * or thumb slots.
26
+ * @internal
27
+ */
28
+ export const MessageFeedbackScopeKey: InjectionKey<
29
+ Ref<MessageFeedbackScope | null>
30
+ > = Symbol("CopilotMessageFeedbackScope");
31
+
32
+ // Cores that captured since Learning was configured, for chats that mount
33
+ // while capture reconnects or is stopped. A Core leaves when its config goes.
34
+ const capturedCores = new WeakSet<CopilotKitCore>();
35
+
36
+ const rememberCapture = (copilotkit: CopilotKitCore) => {
37
+ if (capturedCores.has(copilotkit)) return;
38
+ capturedCores.add(copilotkit);
39
+ const unsubscribe = copilotkit.ɵsubscribeToLearningConfigured(() => {
40
+ if (copilotkit.ɵlearningConfigured) return;
41
+ capturedCores.delete(copilotkit);
42
+ unsubscribe();
43
+ });
44
+ };
45
+
46
+ /**
47
+ * Whether the thumbs record feedback for Learning. True once a Trajectory of
48
+ * this Core has started and as long as Learning stays configured, also while
49
+ * capture reconnects or is stopped, so the buttons do not flicker. Ratings
50
+ * given meanwhile still show but, like any Trajectory event, are not sent.
51
+ * @internal
52
+ */
53
+ export function useLearningFeedbackEnabled(
54
+ copilotkit: Ref<CopilotKitCore>,
55
+ ): ComputedRef<boolean> {
56
+ const configured = ref(false);
57
+ const capturing = ref(false);
58
+
59
+ watch(
60
+ copilotkit,
61
+ (core, _previous, onCleanup) => {
62
+ const read = () => {
63
+ configured.value = core.ɵlearningConfigured;
64
+ capturing.value = core.trajectoryId !== null;
65
+ if (capturing.value) rememberCapture(core);
66
+ };
67
+ read();
68
+ const unsubscribeConfigured = core.ɵsubscribeToLearningConfigured(read);
69
+ const subscription = core.subscribe({ onTrajectoryChanged: read });
70
+ onCleanup(() => {
71
+ unsubscribeConfigured();
72
+ subscription.unsubscribe();
73
+ });
74
+ },
75
+ { immediate: true },
76
+ );
77
+
78
+ return computed(
79
+ () =>
80
+ configured.value &&
81
+ (capturing.value || capturedCores.has(copilotkit.value)),
82
+ );
83
+ }
84
+
85
+ /** Current feedback for one assistant message, and how to change it. */
86
+ export interface MessageFeedbackControls {
87
+ readonly feedback: MessageFeedback | undefined;
88
+ /** Gives `rating`; a different rating than before starts without a comment. */
89
+ readonly rate: (rating: MessageFeedbackRating) => void;
90
+ /** Removes the rating and its comment. */
91
+ readonly clear: () => void;
92
+ /** Sets the current rating's comment; an empty one removes it. */
93
+ readonly comment: (comment: string) => void;
94
+ }
95
+
96
+ /** Feedback controls for `message`, or `null` when this chat collects none. */
97
+ export function useMessageFeedback(
98
+ message: Ref<AssistantMessage>,
99
+ ): ComputedRef<MessageFeedbackControls | null> {
100
+ const scope = inject(MessageFeedbackScopeKey, ref(null));
101
+ // Bumped by the store whenever a rating in this Thread changes.
102
+ const version = ref(0);
103
+
104
+ watch(
105
+ scope,
106
+ (current, _previous, onCleanup) => {
107
+ if (!current) return;
108
+ onCleanup(
109
+ subscribeToMessageFeedback(current.agentId, current.threadId, () => {
110
+ version.value++;
111
+ }),
112
+ );
113
+ },
114
+ { immediate: true },
115
+ );
116
+
117
+ return computed(() => {
118
+ const current = scope.value;
119
+ if (!current) return null;
120
+ void version.value;
121
+ const target = message.value;
122
+ const feedback = getMessageFeedback(
123
+ current.agentId,
124
+ current.threadId,
125
+ target.id,
126
+ );
127
+ const save = (next: MessageFeedback | null) =>
128
+ setMessageFeedback({ ...current, message: target, feedback: next });
129
+ return {
130
+ feedback,
131
+ rate: (rating) => {
132
+ if (feedback?.rating !== rating) save({ rating });
133
+ },
134
+ clear: () => {
135
+ if (feedback) save(null);
136
+ },
137
+ comment: (comment) => {
138
+ if (feedback) save({ rating: feedback.rating, comment });
139
+ },
140
+ };
141
+ });
142
+ }
143
+
144
+ /**
145
+ * How long the pointer may be away from the rating and its comment before the
146
+ * comment closes: enough to cross the gap between them, short enough that
147
+ * passing over a rating does not leave it open.
148
+ */
149
+ export const FEEDBACK_COMMENT_CLOSE_DELAY_MS = 150;
150
+
151
+ /** The comment popover of one rated message: when it shows and what it holds. */
152
+ export interface FeedbackComment {
153
+ readonly open: Ref<boolean>;
154
+ /** The comment being edited. */
155
+ readonly draft: Ref<string>;
156
+ /** Grows each time the field should take focus: after a keyboard rating. */
157
+ readonly focusRequest: Ref<number>;
158
+ /** Whether a focus request waits; reading it answers the request. */
159
+ readonly takeFocusRequest: () => boolean;
160
+ /** The comment field, for moving focus into it. */
161
+ readonly input: Ref<HTMLInputElement | null>;
162
+ /** Opens with `comment` in the field. */
163
+ readonly show: (options: { comment: string; focus: boolean }) => void;
164
+ /** The pointer or focus reached the rating or the popover. */
165
+ readonly enter: (via?: "pointer" | "focus") => void;
166
+ /**
167
+ * It left them: close soon, unless the user is editing the comment or, when
168
+ * focus left, the pointer is still on the rating or the popover.
169
+ */
170
+ readonly leave: (via?: "pointer" | "focus") => void;
171
+ /** Tracks whether focus is in the comment form. */
172
+ readonly setEditing: (editing: boolean) => void;
173
+ /** Closes, saving a changed comment unless `save` is false. */
174
+ readonly close: (options?: { save?: boolean }) => void;
175
+ /** Moves focus back to the thumb without opening the comment again. */
176
+ readonly returnFocus: (target: HTMLElement | null) => void;
177
+ }
178
+
179
+ /**
180
+ * Drives the comment popover of a rated message, as React's
181
+ * `useFeedbackComment` does.
182
+ *
183
+ * It opens when a rating is given and whenever the pointer or keyboard focus
184
+ * reaches the chosen thumb, with the saved comment in the field. It closes by
185
+ * itself shortly after the pointer leaves the thumb and the popover, unless
186
+ * focus is in the field: then it stays until focus moves away, Enter, or
187
+ * Escape. Closing saves a changed comment; Escape, a click on a thumb, and
188
+ * removing the rating discard it.
189
+ * @internal
190
+ */
191
+ export function useFeedbackComment(
192
+ controls: Ref<MessageFeedbackControls | null>,
193
+ ): FeedbackComment {
194
+ const open = ref(false);
195
+ const draft = ref("");
196
+ const focusRequest = ref(0);
197
+ const input = shallowRef<HTMLInputElement | null>(null);
198
+ let timer: ReturnType<typeof setTimeout> | undefined;
199
+ let editing = false;
200
+ let focusWaiting = false;
201
+ // Whether the pointer is on the chosen thumb or the popover. Browsers that
202
+ // do not focus a clicked button move focus to nothing while it stays there.
203
+ let pointerOver = false;
204
+ // Set while focus moves back to the thumb, whose focus would open it again.
205
+ let returning = false;
206
+
207
+ const takeFocusRequest = () => {
208
+ const waiting = focusWaiting;
209
+ focusWaiting = false;
210
+ return waiting;
211
+ };
212
+
213
+ const cancelClose = () => {
214
+ if (timer === undefined) return;
215
+ clearTimeout(timer);
216
+ timer = undefined;
217
+ };
218
+
219
+ const savedComment = () => controls.value?.feedback?.comment ?? "";
220
+
221
+ const close = ({ save = true }: { save?: boolean } = {}) => {
222
+ cancelClose();
223
+ focusWaiting = false;
224
+ pointerOver = false;
225
+ if (!open.value) return;
226
+ const current = controls.value;
227
+ if (save && current?.feedback && draft.value.trim() !== savedComment())
228
+ current.comment(draft.value);
229
+ editing = false;
230
+ open.value = false;
231
+ };
232
+
233
+ const show = ({ comment, focus }: { comment: string; focus: boolean }) => {
234
+ cancelClose();
235
+ draft.value = comment;
236
+ if (focus) {
237
+ focusWaiting = true;
238
+ focusRequest.value++;
239
+ }
240
+ open.value = true;
241
+ };
242
+
243
+ // A message that unmounts (scrolled out of a virtual list) keeps its edit.
244
+ onBeforeUnmount(() => {
245
+ cancelClose();
246
+ const current = controls.value;
247
+ if (
248
+ open.value &&
249
+ current?.feedback &&
250
+ draft.value.trim() !== savedComment()
251
+ )
252
+ current.comment(draft.value);
253
+ });
254
+
255
+ return {
256
+ open,
257
+ draft,
258
+ focusRequest,
259
+ takeFocusRequest,
260
+ input,
261
+ show,
262
+ enter: (via = "focus") => {
263
+ cancelClose();
264
+ if (via === "pointer") pointerOver = true;
265
+ if (returning) return;
266
+ if (!open.value && controls.value?.feedback)
267
+ show({ comment: savedComment(), focus: false });
268
+ },
269
+ leave: (via = "focus") => {
270
+ if (via === "pointer") pointerOver = false;
271
+ else if (pointerOver) return;
272
+ cancelClose();
273
+ timer = setTimeout(() => {
274
+ timer = undefined;
275
+ if (!editing) close();
276
+ }, FEEDBACK_COMMENT_CLOSE_DELAY_MS);
277
+ },
278
+ setEditing: (value) => {
279
+ editing = value;
280
+ },
281
+ close,
282
+ returnFocus: (target) => {
283
+ returning = true;
284
+ try {
285
+ target?.focus();
286
+ } finally {
287
+ returning = false;
288
+ }
289
+ },
290
+ };
291
+ }
@@ -0,0 +1,55 @@
1
+ import { defineComponent, h, ref, watch } from "vue";
2
+ import type { PropType, Ref } from "vue";
3
+ import type { CopilotKitCore } from "@copilotkit/core";
4
+
5
+ /**
6
+ * Whether interaction capture is configured on the core. Driven by the
7
+ * learning config, not by the Trajectory, so a wrapper keyed on it does not
8
+ * remount the tool UI on every reconnect.
9
+ * @internal
10
+ */
11
+ export function useLearningConfigured(
12
+ copilotkit: Ref<CopilotKitCore>,
13
+ ): Readonly<Ref<boolean>> {
14
+ const configured = ref(false);
15
+ watch(
16
+ copilotkit,
17
+ (core, _previous, onCleanup) => {
18
+ configured.value = core.ɵlearningConfigured;
19
+ onCleanup(
20
+ core.ɵsubscribeToLearningConfigured(() => {
21
+ configured.value = core.ɵlearningConfigured;
22
+ }),
23
+ );
24
+ },
25
+ { immediate: true },
26
+ );
27
+ return configured;
28
+ }
29
+
30
+ /**
31
+ * Wraps a tool call's UI in `data-tool-call-id` while learning is configured,
32
+ * so interaction capture can attribute clicks to the tool call. The wrapper
33
+ * uses `display: contents`, so it does not change the layout.
34
+ * @internal
35
+ */
36
+ export const ToolCallCaptureScope = defineComponent({
37
+ name: "ToolCallCaptureScope",
38
+ props: {
39
+ toolCallId: { type: String, required: true },
40
+ enabled: { type: Boolean as PropType<boolean>, required: true },
41
+ },
42
+ setup(props, { slots }) {
43
+ return () =>
44
+ props.enabled
45
+ ? h(
46
+ "div",
47
+ {
48
+ "data-tool-call-id": props.toolCallId,
49
+ style: { display: "contents" },
50
+ },
51
+ slots.default?.(),
52
+ )
53
+ : slots.default?.();
54
+ },
55
+ });
@@ -0,0 +1,28 @@
1
+ import type { ComputedRef, InjectionKey } from "vue";
2
+ import type { ɵToolCallDisplayContextValue } from "@copilotkit/core";
3
+
4
+ /**
5
+ * Provided by the message view so each message's tool calls follow the view's
6
+ * `toolCallDisplay` without every layer passing it along.
7
+ * @internal
8
+ */
9
+ export const ToolCallDisplayContextKey: InjectionKey<
10
+ ComputedRef<ɵToolCallDisplayContextValue>
11
+ > = Symbol("CopilotChatToolCallDisplay");
12
+
13
+ /**
14
+ * Provided by a group around the calls it shows, so CopilotKit's built-in tool
15
+ * card draws itself as a compact row that fits the group instead of a card.
16
+ * @internal
17
+ */
18
+ export interface ToolCallGroupContextValue {
19
+ appearance: "card" | "line" | "stack";
20
+ failedIds: ReadonlySet<string>;
21
+ /** The agent may still finish the group's calls; see `isActive`. */
22
+ active: boolean;
23
+ }
24
+
25
+ /** @internal */
26
+ export const ToolCallGroupContextKey: InjectionKey<
27
+ ComputedRef<ToolCallGroupContextValue | null>
28
+ > = Symbol("CopilotChatToolCallGroup");
@@ -0,0 +1,251 @@
1
+ import { defineComponent, h, onMounted, ref, watch } from "vue";
2
+ import type { PropType } from "vue";
3
+ import {
4
+ ɵcountFailedToolCalls,
5
+ ɵformatLabel,
6
+ ɵgetArgumentPreview,
7
+ ɵstringifyToolCallPayload,
8
+ } from "@copilotkit/core";
9
+ import type {
10
+ CopilotChatLabels,
11
+ ToolCallEntry,
12
+ ɵToolCallRowStatus,
13
+ } from "@copilotkit/core";
14
+ import {
15
+ IconCheck,
16
+ IconChevronRight,
17
+ IconCircle,
18
+ IconLoader2,
19
+ IconX,
20
+ } from "../icons";
21
+ import { useCopilotId } from "../ui/use-id";
22
+ import { useChatLabels } from "./use-chat-labels";
23
+
24
+ /**
25
+ * The label for a tool call's status ("Running", "Done", ...).
26
+ * @internal
27
+ */
28
+ export function toolCallStatusLabel(
29
+ labels: Readonly<CopilotChatLabels>,
30
+ status: ɵToolCallRowStatus,
31
+ ) {
32
+ switch (status) {
33
+ case "running":
34
+ return labels.toolCallStatusRunningLabel;
35
+ case "done":
36
+ return labels.toolCallStatusDoneLabel;
37
+ case "failed":
38
+ return labels.toolCallStatusFailedLabel;
39
+ case "stopped":
40
+ return labels.toolCallStatusStoppedLabel;
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Height transition between closed and its content's height. Closed content
46
+ * stays mounted (so its state survives) but is inert.
47
+ * @internal
48
+ */
49
+ export const CopilotChatCollapsible = defineComponent({
50
+ name: "CopilotChatCollapsible",
51
+ props: {
52
+ open: { type: Boolean, required: true },
53
+ id: { type: String, default: undefined },
54
+ },
55
+ setup(props, { slots }) {
56
+ const root = ref<HTMLElement | null>(null);
57
+ // Set as an attribute, so closed content leaves the tab order everywhere.
58
+ const syncInert = () => root.value?.toggleAttribute("inert", !props.open);
59
+ onMounted(syncInert);
60
+ watch(() => props.open, syncInert, { flush: "post" });
61
+ return () =>
62
+ h(
63
+ "div",
64
+ {
65
+ ref: root,
66
+ id: props.id,
67
+ class: "cpk-collapsible",
68
+ style: { gridTemplateRows: props.open ? "1fr" : "0fr" },
69
+ },
70
+ [h("div", { class: "cpk-collapsible-content" }, slots.default?.())],
71
+ );
72
+ },
73
+ });
74
+
75
+ /** @internal */
76
+ export const ToolCallStatusIcon = defineComponent({
77
+ name: "ToolCallStatusIcon",
78
+ props: {
79
+ status: {
80
+ type: String as PropType<ɵToolCallRowStatus>,
81
+ required: true,
82
+ },
83
+ },
84
+ setup(props) {
85
+ return () =>
86
+ h(
87
+ {
88
+ running: IconLoader2,
89
+ done: IconCheck,
90
+ failed: IconX,
91
+ stopped: IconCircle,
92
+ }[props.status],
93
+ {
94
+ "aria-hidden": "true",
95
+ class: [
96
+ "cpk-tool-call-status-icon",
97
+ props.status === "running" && "cpk-tool-call-status-icon-running",
98
+ props.status === "failed" && "cpk-tool-call-status-icon-failed",
99
+ ],
100
+ },
101
+ );
102
+ },
103
+ });
104
+
105
+ /** @internal */
106
+ export const ToolCallChevron = defineComponent({
107
+ name: "ToolCallChevron",
108
+ props: { open: { type: Boolean, required: true } },
109
+ setup(props) {
110
+ return () =>
111
+ h(IconChevronRight, {
112
+ "aria-hidden": "true",
113
+ class: [
114
+ "cpk-tool-call-chevron",
115
+ props.open && "cpk-tool-call-chevron-open",
116
+ ],
117
+ });
118
+ },
119
+ });
120
+
121
+ /** "2 failed", or nothing. @internal */
122
+ export const ToolCallFailedCount = defineComponent({
123
+ name: "ToolCallFailedCount",
124
+ props: {
125
+ calls: { type: Array as PropType<ToolCallEntry[]>, required: true },
126
+ },
127
+ setup(props) {
128
+ const labels = useChatLabels();
129
+ return () => {
130
+ const failed = ɵcountFailedToolCalls(props.calls);
131
+ if (!failed) return null;
132
+ return h(
133
+ "span",
134
+ { class: "cpk-tool-call-failed-count" },
135
+ ɵformatLabel(labels.value.toolCallFailedCountLabel, { count: failed }),
136
+ );
137
+ };
138
+ },
139
+ });
140
+
141
+ function payload(label: string, value: unknown) {
142
+ return h("div", [
143
+ h("div", { class: "cpk-tool-call-payload-label" }, label),
144
+ h(
145
+ "pre",
146
+ { class: "cpk-tool-call-payload-code" },
147
+ ɵstringifyToolCallPayload(value),
148
+ ),
149
+ ]);
150
+ }
151
+
152
+ /**
153
+ * The built-in tool card drawn as a row inside a group: status, name and main
154
+ * argument, opening to the payloads.
155
+ * @internal
156
+ */
157
+ export const ToolCallRow = defineComponent({
158
+ name: "ToolCallRow",
159
+ props: {
160
+ name: { type: String, required: true },
161
+ parameters: { type: null, default: undefined },
162
+ result: { type: null, default: undefined },
163
+ status: {
164
+ type: String as PropType<ɵToolCallRowStatus>,
165
+ required: true,
166
+ },
167
+ appearance: {
168
+ type: String as PropType<"card" | "line" | "stack">,
169
+ required: true,
170
+ },
171
+ },
172
+ setup(props) {
173
+ const open = ref(false);
174
+ const detailsId = useCopilotId("cpk-tool-call-row");
175
+ const labels = useChatLabels();
176
+ return () => {
177
+ const preview = ɵgetArgumentPreview(props.parameters);
178
+ // Rows draw their own divider: a wrapper with `display: contents`
179
+ // around each call would escape a parent's divide-y.
180
+ return h(
181
+ "div",
182
+ {
183
+ "data-copilotkit": "",
184
+ class: ["cpk-tool-call-row", `cpk-tool-call-row-${props.appearance}`],
185
+ },
186
+ [
187
+ h(
188
+ "button",
189
+ {
190
+ type: "button",
191
+ "aria-expanded": open.value ? "true" : "false",
192
+ "aria-controls": detailsId,
193
+ onClick: () => {
194
+ open.value = !open.value;
195
+ },
196
+ class: "cpk-tool-call-row-button",
197
+ },
198
+ [
199
+ h(ToolCallStatusIcon, { status: props.status }),
200
+ h(
201
+ "span",
202
+ {
203
+ "data-testid": "copilot-tool-render-name",
204
+ class: [
205
+ "cpk-tool-call-row-name",
206
+ props.status === "running" && "cpk-shimmer",
207
+ ],
208
+ },
209
+ props.name,
210
+ ),
211
+ preview
212
+ ? h("span", { class: "cpk-tool-call-row-preview" }, preview)
213
+ : null,
214
+ h(
215
+ "span",
216
+ {
217
+ "data-testid": "copilot-tool-render-status",
218
+ class: "cpk-tool-call-row-status",
219
+ },
220
+ toolCallStatusLabel(labels.value, props.status),
221
+ ),
222
+ h(IconChevronRight, {
223
+ "aria-hidden": "true",
224
+ class: [
225
+ "cpk-tool-call-chevron",
226
+ open.value && "cpk-tool-call-chevron-open",
227
+ "cpk-tool-call-row-chevron",
228
+ ],
229
+ }),
230
+ ],
231
+ ),
232
+ h(CopilotChatCollapsible, { open: open.value, id: detailsId }, () => [
233
+ h(
234
+ "div",
235
+ { class: "cpk-tool-call-payloads cpk-tool-call-row-payloads" },
236
+ [
237
+ payload(
238
+ labels.value.toolCallArgumentsLabel,
239
+ props.parameters ?? {},
240
+ ),
241
+ props.result !== undefined
242
+ ? payload(labels.value.toolCallResultLabel, props.result)
243
+ : null,
244
+ ],
245
+ ),
246
+ ]),
247
+ ],
248
+ );
249
+ };
250
+ },
251
+ });
@@ -0,0 +1,52 @@
1
+ import { defineComponent, h, inject } from "vue";
2
+ import type { FunctionalComponent } from "vue";
3
+ import { CopilotChatCollapsible } from "./tool-call-group-parts";
4
+ import { ToolCallDisplayContextKey } from "./tool-call-display-context";
5
+
6
+ /**
7
+ * Folds its content away with a reply's work in the `"turn"` display. Without
8
+ * `open` (any other display) it renders the content as is.
9
+ * @internal
10
+ */
11
+ export const TurnWorkFold: FunctionalComponent<{ open?: boolean }> = (
12
+ props,
13
+ { slots },
14
+ ) =>
15
+ props.open === undefined
16
+ ? slots.default?.()
17
+ : h(CopilotChatCollapsible, { open: props.open }, slots);
18
+ TurnWorkFold.props = ["open"];
19
+
20
+ /**
21
+ * In the `"turn"` tool-call display, text in a reply's working phase was
22
+ * narration: it fades to muted once a call follows it, and folds away with the
23
+ * rest of the work when the reply is done. The wrapper is there for every
24
+ * message in that display, so text that turns into narration keeps its node
25
+ * (and its place) rather than remounting.
26
+ * @internal
27
+ */
28
+ export const CopilotChatWorkText = defineComponent({
29
+ name: "CopilotChatWorkText",
30
+ props: { messageId: { type: String, required: true } },
31
+ setup(props, { slots }) {
32
+ const context = inject(ToolCallDisplayContextKey, null);
33
+ return () => {
34
+ if (context?.value.display !== "turn") return slots.default?.();
35
+ const open = context.value.workTextOpen.get(props.messageId);
36
+ return h(
37
+ CopilotChatCollapsible,
38
+ { open: open ?? true, class: "cpk-assistant-message-work-text" },
39
+ () => [
40
+ h(
41
+ "div",
42
+ {
43
+ class: "cpk-assistant-message-work-text-content",
44
+ "data-work-text": open === undefined ? "reply" : "narration",
45
+ },
46
+ slots.default?.(),
47
+ ),
48
+ ],
49
+ );
50
+ };
51
+ },
52
+ });