@copilotkit/vue 2.0.0-rc.3 → 2.0.0-rc.31

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 (343) hide show
  1. package/CONTRIBUTOR_GUIDE.md +1 -1
  2. package/PARITY.md +3 -3
  3. package/dist/hooks/use-copilot-action.d.ts.map +1 -1
  4. package/dist/hooks/use-frontend-tool.d.ts +1 -1
  5. package/dist/hooks/use-frontend-tool.d.ts.map +1 -1
  6. package/dist/hooks/zod-parameters.d.ts +14 -0
  7. package/dist/hooks/zod-parameters.d.ts.map +1 -0
  8. package/dist/index.cjs +1 -73
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.mjs +365 -16920
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/use-render-activity-message-BMTHA_P2.js +15901 -0
  13. package/dist/use-render-activity-message-BMTHA_P2.js.map +1 -0
  14. package/dist/use-render-activity-message-CH3beu7z.cjs +113 -0
  15. package/dist/use-render-activity-message-CH3beu7z.cjs.map +1 -0
  16. package/dist/v2/components/A2UIMessageRenderer.d.ts +14 -0
  17. package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
  18. package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +10 -3
  19. package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
  20. package/dist/v2/components/CopilotKitInspector.vue.d.ts +5 -1
  21. package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -1
  22. package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -1
  23. package/dist/v2/components/LicenseWarningBanner.vue.d.ts +2 -2
  24. package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
  25. package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -1
  26. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +13 -59
  27. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
  28. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +3 -11
  29. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
  30. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +10 -15
  31. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
  32. package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +14 -130
  33. package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -1
  34. package/dist/v2/components/a2ui/catalog.d.ts.map +1 -1
  35. package/dist/v2/components/a2ui/utils.d.ts +3 -15
  36. package/dist/v2/components/a2ui/utils.d.ts.map +1 -1
  37. package/dist/v2/components/a2ui.d.ts +9 -8
  38. package/dist/v2/components/a2ui.d.ts.map +1 -1
  39. package/dist/v2/components/chat/CopilotChat.vue.d.ts +2 -2
  40. package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
  41. package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
  42. package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
  43. package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -1
  44. package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +4 -8
  45. package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -1
  46. package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +1 -1
  47. package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -1
  48. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +7 -286
  49. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
  50. package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -1
  51. package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -1
  52. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +1 -1
  53. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
  54. package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
  55. package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +1 -1
  56. package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -1
  57. package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
  58. package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +1 -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 +3 -3
  62. package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
  63. package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -1
  64. package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
  65. package/dist/v2/components/chat/CopilotPopup.vue.d.ts +8 -3
  66. package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
  67. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +5 -3
  68. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
  69. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +5 -3
  70. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
  71. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +8 -3
  72. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
  73. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +6 -4
  74. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
  75. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +6 -4
  76. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
  77. package/dist/v2/components/chat/CopilotThreadsDrawer.vue.d.ts.map +1 -1
  78. package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts +1 -0
  79. package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
  80. package/dist/v2/components/chat/audioRecorder.d.ts +3 -4
  81. package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -1
  82. package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +4 -4
  83. package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
  84. package/dist/v2/components/chat/forwarded-slots.d.ts +12 -0
  85. package/dist/v2/components/chat/forwarded-slots.d.ts.map +1 -0
  86. package/dist/v2/components/chat/index.d.ts +34 -31
  87. package/dist/v2/components/chat/index.d.ts.map +1 -1
  88. package/dist/v2/components/chat/inspector-shortcuts.d.ts +2 -1
  89. package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -1
  90. package/dist/v2/components/chat/message-feedback.d.ts +38 -49
  91. package/dist/v2/components/chat/message-feedback.d.ts.map +1 -1
  92. package/dist/v2/components/chat/tool-call-display-context.d.ts +4 -19
  93. package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -1
  94. package/dist/v2/components/chat/tool-call-group-parts.d.ts +7 -20
  95. package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -1
  96. package/dist/v2/components/chat/turn-work.d.ts +0 -2
  97. package/dist/v2/components/chat/turn-work.d.ts.map +1 -1
  98. package/dist/v2/components/chat/types.d.ts +9 -4
  99. package/dist/v2/components/chat/types.d.ts.map +1 -1
  100. package/dist/v2/components/chat/use-chat-labels.d.ts +8 -0
  101. package/dist/v2/components/chat/use-chat-labels.d.ts.map +1 -0
  102. package/dist/v2/components/chat/use-copy-feedback.d.ts +11 -0
  103. package/dist/v2/components/chat/use-copy-feedback.d.ts.map +1 -0
  104. package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -1
  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 +1 -1
  108. package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -1
  109. package/dist/v2/hooks/use-agent-context.d.ts +2 -3
  110. package/dist/v2/hooks/use-agent-context.d.ts.map +1 -1
  111. package/dist/v2/hooks/use-agent.d.ts +4 -1
  112. package/dist/v2/hooks/use-agent.d.ts.map +1 -1
  113. package/dist/v2/hooks/use-attachments.d.ts +7 -0
  114. package/dist/v2/hooks/use-attachments.d.ts.map +1 -1
  115. package/dist/v2/hooks/use-capabilities.d.ts.map +1 -1
  116. package/dist/v2/hooks/use-component.d.ts +1 -0
  117. package/dist/v2/hooks/use-component.d.ts.map +1 -1
  118. package/dist/v2/hooks/use-configure-suggestions.d.ts +4 -9
  119. package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -1
  120. package/dist/v2/hooks/use-default-render-tool.d.ts +2 -7
  121. package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -1
  122. package/dist/v2/hooks/use-frontend-tool.d.ts +5 -0
  123. package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -1
  124. package/dist/v2/hooks/use-human-in-the-loop.d.ts +2 -1
  125. package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -1
  126. package/dist/v2/hooks/use-interrupt.d.ts +0 -1
  127. package/dist/v2/hooks/use-interrupt.d.ts.map +1 -1
  128. package/dist/v2/hooks/use-keyboard-height.d.ts +1 -1
  129. package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -1
  130. package/dist/v2/hooks/use-pin-to-send.d.ts +4 -12
  131. package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -1
  132. package/dist/v2/hooks/use-render-activity-message.d.ts +13 -9
  133. package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
  134. package/dist/v2/hooks/use-render-custom-messages.d.ts +5 -7
  135. package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -1
  136. package/dist/v2/hooks/use-render-tool.d.ts +1 -1
  137. package/dist/v2/hooks/use-render-tool.d.ts.map +1 -1
  138. package/dist/v2/hooks/use-suggestions.d.ts.map +1 -1
  139. package/dist/v2/hooks/use-threads.d.ts +6 -23
  140. package/dist/v2/hooks/use-threads.d.ts.map +1 -1
  141. package/dist/v2/index.cjs +1 -1
  142. package/dist/v2/index.mjs +197 -200
  143. package/dist/v2/index.mjs.map +1 -1
  144. package/dist/v2/lib/processPartialHtml.d.ts +1 -2
  145. package/dist/v2/lib/processPartialHtml.d.ts.map +1 -1
  146. package/dist/v2/lib/shallow-stable.d.ts.map +1 -1
  147. package/dist/v2/lib/vue-core.d.ts +33 -19
  148. package/dist/v2/lib/vue-core.d.ts.map +1 -1
  149. package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
  150. package/dist/v2/providers/CopilotKitProvider.types.d.ts +9 -129
  151. package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
  152. package/dist/v2/providers/CopilotKitProvider.vue.d.ts +9 -10
  153. package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
  154. package/dist/v2/providers/chat-configuration-store-key.d.ts +8 -0
  155. package/dist/v2/providers/chat-configuration-store-key.d.ts.map +1 -0
  156. package/dist/v2/providers/markdown-renderer.d.ts +4 -2
  157. package/dist/v2/providers/markdown-renderer.d.ts.map +1 -1
  158. package/dist/v2/providers/types.d.ts +3 -46
  159. package/dist/v2/providers/types.d.ts.map +1 -1
  160. package/dist/v2/providers/use-inspector-thread-override.d.ts +5 -0
  161. package/dist/v2/providers/use-inspector-thread-override.d.ts.map +1 -1
  162. package/dist/v2/types/defineToolCallRenderer.d.ts +1 -1
  163. package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -1
  164. package/dist/v2/types/human-in-the-loop.d.ts +8 -29
  165. package/dist/v2/types/human-in-the-loop.d.ts.map +1 -1
  166. package/dist/v2/types/interrupt.d.ts +1 -22
  167. package/dist/v2/types/interrupt.d.ts.map +1 -1
  168. package/dist/v2/types/vue-activity-message-renderer.d.ts +16 -15
  169. package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -1
  170. package/dist/v2/types/vue-custom-message-renderer.d.ts +7 -16
  171. package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -1
  172. package/dist/v2/types/vue-tool-call-renderer.d.ts +16 -35
  173. package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
  174. package/package.json +12 -13
  175. package/src/__tests__/build-entries.test.ts +29 -0
  176. package/src/hooks/__tests__/zod-parameters.test.ts +520 -0
  177. package/src/hooks/use-copilot-action.ts +2 -1
  178. package/src/hooks/use-frontend-tool.ts +3 -6
  179. package/src/hooks/zod-parameters.ts +162 -0
  180. package/src/v2/__tests__/exports.test.ts +10 -0
  181. package/src/v2/__tests__/mocks/web-inspector.ts +6 -0
  182. package/src/v2/__tests__/utils/test-helpers.ts +34 -4
  183. package/src/v2/components/A2UIMessageRenderer.ts +98 -68
  184. package/src/v2/components/A2UISurfaceActivityRenderer.vue +68 -103
  185. package/src/v2/components/CopilotKitInspector.vue +104 -51
  186. package/src/v2/components/InlineFeatureWarning.vue +20 -21
  187. package/src/v2/components/LicenseWarningBanner.vue +27 -135
  188. package/src/v2/components/MCPAppsActivityRenderer.ts +75 -201
  189. package/src/v2/components/OpenGenerativeUIRenderer.ts +122 -446
  190. package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +171 -8
  191. package/src/v2/components/__tests__/CopilotKitInspector.test.ts +42 -0
  192. package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +60 -0
  193. package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +64 -8
  194. package/src/v2/components/__tests__/OpenGenerativeUIToolRenderer.test.ts +38 -0
  195. package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +6 -26
  196. package/src/v2/components/a2ui/A2UICatalogContext.ts +27 -185
  197. package/src/v2/components/a2ui/A2UIRecoveryStates.ts +127 -327
  198. package/src/v2/components/a2ui/catalog.ts +3 -3
  199. package/src/v2/components/a2ui/utils.ts +13 -65
  200. package/src/v2/components/a2ui.ts +15 -22
  201. package/src/v2/components/chat/CopilotChat.vue +121 -498
  202. package/src/v2/components/chat/CopilotChatAssistantMessage.vue +47 -184
  203. package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +36 -55
  204. package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +14 -6
  205. package/src/v2/components/chat/CopilotChatAudioRecorder.vue +19 -246
  206. package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +12 -77
  207. package/src/v2/components/chat/CopilotChatInput.vue +139 -654
  208. package/src/v2/components/chat/CopilotChatInspectorButton.vue +45 -108
  209. package/src/v2/components/chat/CopilotChatLightbox.vue +10 -31
  210. package/src/v2/components/chat/CopilotChatMessageView.vue +96 -274
  211. package/src/v2/components/chat/CopilotChatReasoningMessage.vue +27 -62
  212. package/src/v2/components/chat/CopilotChatToolCallGroup.vue +63 -71
  213. package/src/v2/components/chat/CopilotChatToolCallItem.vue +8 -6
  214. package/src/v2/components/chat/CopilotChatToolCallsView.vue +31 -32
  215. package/src/v2/components/chat/CopilotChatUserMessage.vue +24 -112
  216. package/src/v2/components/chat/CopilotChatView.vue +123 -161
  217. package/src/v2/components/chat/CopilotChatWorkSummary.vue +26 -36
  218. package/src/v2/components/chat/CopilotModalHeader.vue +11 -23
  219. package/src/v2/components/chat/CopilotPopup.vue +23 -25
  220. package/src/v2/components/chat/CopilotPopupView.vue +10 -39
  221. package/src/v2/components/chat/CopilotPopupViewInternal.vue +49 -185
  222. package/src/v2/components/chat/CopilotSidebar.vue +23 -25
  223. package/src/v2/components/chat/CopilotSidebarView.vue +10 -39
  224. package/src/v2/components/chat/CopilotSidebarViewInternal.vue +56 -100
  225. package/src/v2/components/chat/CopilotThreadsDrawer.vue +43 -105
  226. package/src/v2/components/chat/StreamingMarkdownDefault.vue +15 -28
  227. package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
  228. package/src/v2/components/chat/__tests__/CopilotChat.test.ts +12 -10
  229. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +26 -9
  230. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +5 -5
  231. package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +28 -0
  232. package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +132 -1
  233. package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +247 -403
  234. package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +1 -99
  235. package/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.ts +43 -1
  236. package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +90 -1
  237. package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +19 -0
  238. package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +90 -1
  239. package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +32 -8
  240. package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +2 -1
  241. package/src/v2/components/chat/__tests__/StreamingMarkdownDefault.test.ts +54 -0
  242. package/src/v2/components/chat/audioRecorder.ts +4 -7
  243. package/src/v2/components/chat/copilotChatToolCallItemRender.ts +25 -90
  244. package/src/v2/components/chat/forwarded-slots.ts +17 -0
  245. package/src/v2/components/chat/index.ts +0 -1
  246. package/src/v2/components/chat/inspector-shortcuts.ts +10 -16
  247. package/src/v2/components/chat/message-feedback.ts +92 -195
  248. package/src/v2/components/chat/tool-call-display-context.ts +6 -22
  249. package/src/v2/components/chat/tool-call-group-parts.ts +47 -108
  250. package/src/v2/components/chat/turn-work.ts +0 -9
  251. package/src/v2/components/chat/types.ts +12 -4
  252. package/src/v2/components/chat/use-chat-labels.ts +16 -0
  253. package/src/v2/components/chat/use-copy-feedback.ts +21 -0
  254. package/src/v2/components/chat/use-lightbox.ts +15 -33
  255. package/src/v2/components/icons/__tests__/icons.test.ts +72 -68
  256. package/src/v2/components/icons/index.ts +109 -27
  257. package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +5 -3
  258. package/src/v2/hooks/__tests__/use-agent-stability.test.ts +25 -4
  259. package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +5 -1
  260. package/src/v2/hooks/__tests__/use-agent.test.ts +6 -3
  261. package/src/v2/hooks/__tests__/use-component.test.ts +21 -0
  262. package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +30 -1
  263. package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +10 -10
  264. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +66 -1
  265. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +6 -1
  266. package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +187 -12
  267. package/src/v2/hooks/__tests__/use-interrupt.test.ts +97 -0
  268. package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +106 -0
  269. package/src/v2/hooks/__tests__/use-render-tool.test.ts +3 -6
  270. package/src/v2/hooks/__tests__/use-threads.test.ts +48 -6
  271. package/src/v2/hooks/__tests__/zod-regression.test.ts +5 -4
  272. package/src/v2/hooks/use-agent-context.ts +4 -10
  273. package/src/v2/hooks/use-agent.ts +86 -290
  274. package/src/v2/hooks/use-attachments.ts +48 -168
  275. package/src/v2/hooks/use-capabilities.ts +2 -7
  276. package/src/v2/hooks/use-component.ts +7 -4
  277. package/src/v2/hooks/use-configure-suggestions.ts +29 -220
  278. package/src/v2/hooks/use-default-render-tool.ts +31 -152
  279. package/src/v2/hooks/use-frontend-tool.ts +15 -25
  280. package/src/v2/hooks/use-human-in-the-loop.ts +11 -80
  281. package/src/v2/hooks/use-interrupt.ts +29 -308
  282. package/src/v2/hooks/use-keyboard-height.ts +17 -40
  283. package/src/v2/hooks/use-pin-to-send.ts +15 -99
  284. package/src/v2/hooks/use-render-activity-message.ts +35 -57
  285. package/src/v2/hooks/use-render-custom-messages.ts +24 -88
  286. package/src/v2/hooks/use-render-tool.ts +2 -4
  287. package/src/v2/hooks/use-suggestions.ts +17 -36
  288. package/src/v2/hooks/use-threads.ts +49 -288
  289. package/src/v2/lib/__tests__/shallow-stable.test.ts +54 -0
  290. package/src/v2/lib/__tests__/vue-core-renderers.test.ts +42 -0
  291. package/src/v2/lib/processPartialHtml.ts +6 -21
  292. package/src/v2/lib/shallow-stable.ts +2 -16
  293. package/src/v2/lib/vue-core.ts +90 -85
  294. package/src/v2/providers/CopilotChatConfigurationProvider.vue +48 -186
  295. package/src/v2/providers/CopilotKitProvider.types.ts +12 -132
  296. package/src/v2/providers/CopilotKitProvider.vue +291 -641
  297. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +22 -2
  298. package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +38 -2
  299. package/src/v2/providers/__tests__/CopilotKitProvider.config.test.ts +124 -0
  300. package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +3 -3
  301. package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +3 -1
  302. package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +4 -1
  303. package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +88 -28
  304. package/src/v2/providers/chat-configuration-store-key.ts +9 -0
  305. package/src/v2/providers/markdown-renderer.ts +8 -2
  306. package/src/v2/providers/types.ts +3 -49
  307. package/src/v2/providers/use-inspector-thread-override.ts +22 -80
  308. package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +28 -33
  309. package/src/v2/types/defineToolCallRenderer.ts +7 -6
  310. package/src/v2/types/human-in-the-loop.ts +8 -32
  311. package/src/v2/types/interrupt.ts +7 -31
  312. package/src/v2/types/vue-activity-message-renderer.ts +24 -15
  313. package/src/v2/types/vue-custom-message-renderer.ts +12 -16
  314. package/src/v2/types/vue-tool-call-renderer.ts +23 -38
  315. package/tsconfig.json +0 -1
  316. package/vite.config.ts +8 -5
  317. package/vitest.config.ts +12 -7
  318. package/dist/v2/components/chat/BasicMarkdown.vue.d.ts +0 -9
  319. package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +0 -1
  320. package/dist/v2/components/chat/normalize-auto-scroll.d.ts +0 -3
  321. package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +0 -1
  322. package/dist/v2/components/chat/tool-call-layout.d.ts +0 -115
  323. package/dist/v2/components/chat/tool-call-layout.d.ts.map +0 -1
  324. package/dist/v2/lib/is-mobile-viewport.d.ts +0 -15
  325. package/dist/v2/lib/is-mobile-viewport.d.ts.map +0 -1
  326. package/dist/v2/lib/message-feedback.d.ts +0 -33
  327. package/dist/v2/lib/message-feedback.d.ts.map +0 -1
  328. package/dist/v2/lib/transcription-client.d.ts +0 -19
  329. package/dist/v2/lib/transcription-client.d.ts.map +0 -1
  330. package/src/v2/components/__tests__/A2UICatalogContext.test.ts +0 -63
  331. package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +0 -175
  332. package/src/v2/components/chat/BasicMarkdown.vue +0 -160
  333. package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +0 -69
  334. package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +0 -39
  335. package/src/v2/components/chat/normalize-auto-scroll.ts +0 -17
  336. package/src/v2/components/chat/tool-call-layout.ts +0 -304
  337. package/src/v2/lib/__tests__/is-mobile-viewport.test.ts +0 -48
  338. package/src/v2/lib/__tests__/message-feedback.test.ts +0 -152
  339. package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -84
  340. package/src/v2/lib/__tests__/transcription-client.test.ts +0 -67
  341. package/src/v2/lib/is-mobile-viewport.ts +0 -23
  342. package/src/v2/lib/message-feedback.ts +0 -120
  343. package/src/v2/lib/transcription-client.ts +0 -151
@@ -1,34 +1,14 @@
1
- import { computed, onScopeDispose, ref, toValue, watch } from "vue";
1
+ import { computed, onScopeDispose, shallowRef, toValue, watch } from "vue";
2
2
  import type { MaybeRefOrGetter, Ref } from "vue";
3
- import {
4
- CopilotKitCoreRuntimeConnectionStatus,
5
- ɵcreateThreadStore,
6
- ɵselectHasNextPage,
7
- ɵselectIsFetchingNextPage,
8
- ɵselectIsMutating,
9
- ɵselectThreads,
10
- ɵselectThreadsError,
11
- ɵselectFetchMoreError,
12
- ɵselectThreadsIsLoading,
13
- } from "@copilotkit/core";
14
- import type { ɵThreadRuntimeContext, ɵThreadStore } from "@copilotkit/core";
3
+ import { ɵThreadsController, ɵcreateThreadStore } from "@copilotkit/core";
4
+ import type { ɵThreadSummary } from "@copilotkit/core";
15
5
  import { useCopilotKit } from "../providers/useCopilotKit";
16
6
 
17
- export interface Thread {
18
- id: string;
19
- agentId: string;
20
- name: string | null;
21
- archived: boolean;
22
- createdAt: string;
23
- updatedAt: string;
24
- /**
25
- * ISO-8601 timestamp of the most recent agent run on this thread. Absent
26
- * when the thread has never been run. Prefer this over `updatedAt` for
27
- * user-facing "last activity" displays — it is not bumped by metadata-only
28
- * actions like rename or archive.
29
- */
30
- lastRunAt?: string;
31
- }
7
+ /**
8
+ * One thread as the hook returns it. This is core's thread summary, the same
9
+ * type React and Angular expose, so the adapters cannot drift apart.
10
+ */
11
+ export type Thread = ɵThreadSummary;
32
12
 
33
13
  export interface UseThreadsInput {
34
14
  agentId: MaybeRefOrGetter<string>;
@@ -67,283 +47,64 @@ export interface UseThreadsResult {
67
47
  deleteThread: (threadId: string) => Promise<void>;
68
48
  }
69
49
 
70
- function bindThreadStoreSelector<T>(
71
- store: ɵThreadStore,
72
- selector: (state: ReturnType<ɵThreadStore["getState"]>) => T,
73
- target: Ref<T>,
74
- ): void {
75
- target.value = selector(store.getState());
76
- const subscription = store.select(selector).subscribe(() => {
77
- target.value = selector(store.getState());
78
- });
79
- onScopeDispose(() => subscription.unsubscribe());
80
- }
81
-
82
- /**
83
- * Vue composable for listing and managing CopilotKit Intelligence threads.
84
- *
85
- * The hook fetches threads for the runtime-authenticated user and the given
86
- * `agentId`, then keeps the result in sync via the core thread store's realtime
87
- * channel when available. Inputs accept refs/computeds to make thread context
88
- * changes reactive.
89
- */
90
50
  export function useThreads(input: UseThreadsInput): UseThreadsResult {
91
51
  const { copilotkit } = useCopilotKit();
92
- const store = ɵcreateThreadStore({
93
- fetch: copilotkit.value.ɵruntimeFetch,
52
+ const readInput = () => ({
53
+ core: copilotkit.value,
54
+ agentId: toValue(input.agentId),
55
+ includeArchived: toValue(input.includeArchived),
56
+ limit: toValue(input.limit),
57
+ enabled: toValue(input.enabled) ?? true,
94
58
  });
95
59
 
96
- const resolvedAgentId = computed(() => toValue(input.agentId));
97
- const resolvedIncludeArchived = computed(() =>
98
- toValue(input.includeArchived),
60
+ // Core's ɵThreadsController owns the view model: thread projection, the
61
+ // configuration errors, the gated and de-duplicated context dispatch, the
62
+ // registry claim and the mutation guard. This composable feeds it and
63
+ // projects its snapshot.
64
+ const controller = new ɵThreadsController(
65
+ ɵcreateThreadStore({ fetch: copilotkit.value.ɵruntimeFetch }),
66
+ readInput(),
99
67
  );
100
- const resolvedLimit = computed(() => toValue(input.limit));
101
- const resolvedEnabled = computed(() => toValue(input.enabled) ?? true);
102
-
103
- // Thread-endpoint capability, derived from the runtime's `/info` payload.
104
- // `threadEndpoints` is `undefined` on legacy runtimes that don't advertise
105
- // the capability, so we treat "not explicitly false" as supported (matching
106
- // React's `!== false` semantics) to preserve legacy thread behavior.
107
- const threadListEndpointSupported = computed(
108
- () => copilotkit.value.threadEndpoints?.list !== false,
109
- );
110
- const threadMutationsSupported = computed(
111
- () => copilotkit.value.threadEndpoints?.mutations !== false,
112
- );
113
- // Connected, but the runtime explicitly does not serve the list endpoint.
114
- const threadEndpointsUnavailable = computed(
115
- () =>
116
- !!copilotkit.value.runtimeUrl &&
117
- copilotkit.value.runtimeConnectionStatus ===
118
- CopilotKitCoreRuntimeConnectionStatus.Connected &&
119
- !threadListEndpointSupported.value,
120
- );
121
- const threadEndpointsError = computed<Error | null>(() =>
122
- threadEndpointsUnavailable.value
123
- ? new Error(
124
- "Thread endpoints are not available on this CopilotKit runtime",
125
- )
126
- : null,
127
- );
128
- const threadMutationsError = computed<Error | null>(() =>
129
- threadMutationsSupported.value
130
- ? null
131
- : new Error(
132
- "Thread mutations are not available on this CopilotKit runtime",
133
- ),
134
- );
135
-
136
- // Keyed on the source's generation, not on header VALUES: a builder's
137
- // returned token can change on every resolution without a new source ever
138
- // being set, and this must not re-dispatch the thread context on that (see
139
- // #1937).
140
- const headersKey = computed(() => copilotkit.value.ɵheadersGeneration);
141
-
142
- const threads = ref<Thread[]>([]);
143
- const storeIsLoading = ref(false);
144
- const storeError = ref<Error | null>(null);
145
- const fetchMoreError = ref<Error | null>(null);
146
- const hasMoreThreads = ref(false);
147
- const isFetchingMoreThreads = ref(false);
148
- const isMutating = ref(false);
149
-
150
- bindThreadStoreSelector(store, ɵselectThreads, threads as Ref<Thread[]>);
151
- bindThreadStoreSelector(store, ɵselectThreadsIsLoading, storeIsLoading);
152
- bindThreadStoreSelector(store, ɵselectThreadsError, storeError);
153
- bindThreadStoreSelector(store, ɵselectFetchMoreError, fetchMoreError);
154
- bindThreadStoreSelector(store, ɵselectHasNextPage, hasMoreThreads);
155
- bindThreadStoreSelector(
156
- store,
157
- ɵselectIsFetchingNextPage,
158
- isFetchingMoreThreads,
159
- );
160
- bindThreadStoreSelector(store, ɵselectIsMutating, isMutating);
161
-
162
- store.start();
68
+ const snapshot = shallowRef(controller.getSnapshot());
69
+ const unsubscribe = controller.subscribe(() => {
70
+ snapshot.value = controller.getSnapshot();
71
+ });
72
+ const stop = controller.start();
163
73
  onScopeDispose(() => {
164
- store.stop();
74
+ stop();
75
+ unsubscribe();
76
+ controller.dispose();
165
77
  });
166
78
 
167
- // Register this store in core's single-slot thread-store registry so other
168
- // surfaces (e.g. the chat view) can resolve the same store for the agent.
169
- //
170
- // Gated on `resolvedEnabled`: a disabled (e.g. unlicensed) drawer must not
171
- // claim the agentId slot. The registry is single-slot/last-writer-wins, so
172
- // registering an inert store would evict — and on unmount tear down — a
173
- // co-mounted live store for the same agent. Staying unregistered while
174
- // disabled leaves the live store's registration intact.
175
- watch(
176
- [resolvedEnabled, resolvedAgentId],
177
- ([enabled, agentId], _prev, onCleanup) => {
178
- if (!enabled) return;
179
- copilotkit.value.registerThreadStore(agentId, store);
180
- onCleanup(() => {
181
- copilotkit.value.unregisterThreadStore(agentId);
182
- });
183
- },
184
- { immediate: true },
185
- );
186
-
187
- // Tracks whether we've dispatched the first real context to the store.
188
- // The store itself starts with `isLoading: false`, so before we dispatch
189
- // consumers would otherwise see an empty, non-loading state (empty-list
190
- // flash). While runtimeUrl is set and we haven't dispatched yet, we
191
- // synthesize `isLoading: true` so the UI keeps its loading indicator until
192
- // the first fetch is in flight (at which point the store's own
193
- // isLoading takes over).
194
- const hasDispatchedContext = ref(false);
195
-
196
- // Defer setting the context until the runtime reports Connected. Before
197
- // `/info` resolves we don't know `intelligence.wsUrl`, so dispatching the
198
- // context early would issue a list fetch with `wsUrl: undefined`, then a
199
- // second list fetch (and a `/threads/subscribe`) once the flag lands.
200
- // Waiting lets the hook issue just one `/threads?…` + one `/threads/subscribe`.
201
- //
202
- // When `runtimeUrl` is absent we dispatch `null` to clear the store. For
203
- // transient states (Disconnected/Connecting/Error with a URL still set) we
204
- // leave the previously-dispatched context in place — any in-flight
205
- // realtime subscription or cached thread list stays usable while the
206
- // runtime recovers, and we don't re-trigger a fetch storm on transitions.
207
79
  watch(
208
80
  [
81
+ readInput,
209
82
  () => copilotkit.value.runtimeUrl,
210
83
  () => copilotkit.value.runtimeConnectionStatus,
211
- headersKey,
84
+ () => copilotkit.value.ɵheadersGeneration,
212
85
  () => copilotkit.value.intelligence?.wsUrl,
213
- resolvedAgentId,
214
- resolvedIncludeArchived,
215
- resolvedLimit,
216
- resolvedEnabled,
217
- threadListEndpointSupported,
86
+ () => copilotkit.value.threadEndpoints?.list,
87
+ () => copilotkit.value.threadEndpoints?.mutations,
218
88
  ],
219
- ([
220
- runtimeUrl,
221
- runtimeStatus,
222
- ,
223
- wsUrl,
224
- agentId,
225
- includeArchived,
226
- limit,
227
- enabled,
228
- listEndpointSupported,
229
- ]) => {
230
- if (!runtimeUrl || !enabled) {
231
- store.setContext(null);
232
- hasDispatchedContext.value = false;
233
- return;
234
- }
235
-
236
- if (runtimeStatus !== CopilotKitCoreRuntimeConnectionStatus.Connected) {
237
- return;
238
- }
239
-
240
- // Connected, but the runtime explicitly does not serve the list
241
- // endpoint: stay inert so no `/threads` fetch fires. The
242
- // `threadEndpointsError` surfaces via `error` instead.
243
- if (!listEndpointSupported) {
244
- store.setContext(null);
245
- hasDispatchedContext.value = false;
246
- return;
247
- }
248
-
249
- // No `headers` here: the store's `fetch` is `copilotkit.value.ɵruntimeFetch`,
250
- // which already resolves and overlays the current core headers at send
251
- // time (#1937) — a snapshot here would go stale the moment the builder
252
- // returns something new.
253
- const context: ɵThreadRuntimeContext = {
254
- runtimeUrl,
255
- wsUrl,
256
- agentId,
257
- includeArchived,
258
- limit,
259
- };
260
-
261
- store.setContext(context);
262
- hasDispatchedContext.value = true;
263
- },
89
+ ([next]) => controller.update(next),
264
90
  { immediate: true },
265
91
  );
266
92
 
267
- const runtimeError = computed<Error | null>(() =>
268
- copilotkit.value.runtimeUrl
269
- ? null
270
- : new Error("Runtime URL is not configured"),
271
- );
272
-
273
- const preConnectLoading = computed(
274
- () =>
275
- !!copilotkit.value.runtimeUrl &&
276
- resolvedEnabled.value &&
277
- !threadEndpointsUnavailable.value &&
278
- !hasDispatchedContext.value,
279
- );
280
-
281
- const isLoading = computed(() =>
282
- runtimeError.value || threadEndpointsError.value
283
- ? false
284
- : preConnectLoading.value || storeIsLoading.value,
285
- );
286
-
287
- // Folds developer/config errors (missing runtime URL, runtime without
288
- // thread endpoints) together with genuine store errors. `listError` below
289
- // deliberately excludes the config errors.
290
- const error = computed<Error | null>(
291
- () => runtimeError.value ?? threadEndpointsError.value ?? storeError.value,
292
- );
293
-
294
- // Genuine store errors only. Unlike `error`, this omits the dev/config
295
- // `runtimeError`/`threadEndpointsError` strings so they are never shown in
296
- // user-facing error UI.
297
- const listError = computed<Error | null>(() => storeError.value);
298
-
299
- // Reject mutations locally (before touching the network) when the runtime
300
- // reports mutations are unsupported, matching React's `guardMutation`.
301
- function guardMutation<TArgs extends unknown[]>(
302
- mutation: (...args: TArgs) => Promise<void>,
303
- ): (...args: TArgs) => Promise<void> {
304
- return (...args: TArgs) => {
305
- if (threadMutationsError.value) {
306
- return Promise.reject(threadMutationsError.value);
307
- }
308
- return mutation(...args);
309
- };
310
- }
311
-
312
93
  return {
313
- threads: computed(() =>
314
- threads.value.map(
315
- ({ id, agentId, name, archived, createdAt, updatedAt, lastRunAt }) => ({
316
- id,
317
- agentId,
318
- name,
319
- archived,
320
- createdAt,
321
- updatedAt,
322
- ...(lastRunAt !== undefined ? { lastRunAt } : {}),
323
- }),
324
- ),
325
- ),
326
- isLoading,
327
- error,
328
- listError,
329
- fetchMoreError,
330
- hasMoreThreads,
331
- isFetchingMoreThreads,
332
- isMutating,
333
- fetchMoreThreads: () => store.fetchNextPage(),
334
- refetchThreads: () => store.refetchThreads(),
335
- startNewThread: () => store.startNewThread(),
336
- renameThread: guardMutation((threadId: string, name: string) =>
337
- store.renameThread(threadId, name),
338
- ),
339
- archiveThread: guardMutation((threadId: string) =>
340
- store.archiveThread(threadId),
341
- ),
342
- unarchiveThread: guardMutation((threadId: string) =>
343
- store.unarchiveThread(threadId),
344
- ),
345
- deleteThread: guardMutation((threadId: string) =>
346
- store.deleteThread(threadId),
347
- ),
94
+ threads: computed(() => snapshot.value.threads),
95
+ isLoading: computed(() => snapshot.value.isLoading),
96
+ error: computed(() => snapshot.value.error),
97
+ listError: computed(() => snapshot.value.listError),
98
+ fetchMoreError: computed(() => snapshot.value.fetchMoreError),
99
+ hasMoreThreads: computed(() => snapshot.value.hasMoreThreads),
100
+ isFetchingMoreThreads: computed(() => snapshot.value.isFetchingMoreThreads),
101
+ isMutating: computed(() => snapshot.value.isMutating),
102
+ fetchMoreThreads: controller.fetchMoreThreads,
103
+ refetchThreads: controller.refetchThreads,
104
+ startNewThread: controller.startNewThread,
105
+ renameThread: controller.renameThread,
106
+ archiveThread: controller.archiveThread,
107
+ unarchiveThread: controller.unarchiveThread,
108
+ deleteThread: controller.deleteThread,
348
109
  };
349
110
  }
@@ -0,0 +1,54 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { nextTick, shallowRef } from "vue";
3
+ import { useShallowStableRef } from "../shallow-stable";
4
+
5
+ /** A stable ref over a source the test replaces with `set(next)`. */
6
+ function stableOver<T>(initial: T) {
7
+ const source = shallowRef(initial);
8
+ const stable = useShallowStableRef(source);
9
+ const set = async (next: T) => {
10
+ source.value = next;
11
+ await nextTick();
12
+ };
13
+ return { stable, set };
14
+ }
15
+
16
+ describe("useShallowStableRef", () => {
17
+ it("keeps the reference for a shallowly equal plain object", async () => {
18
+ const { stable, set } = stableOver({ a: 1 });
19
+ const first = stable.value;
20
+
21
+ await set({ a: 1 });
22
+
23
+ expect(stable.value).toBe(first);
24
+ });
25
+
26
+ it("updates the reference when a value changes", async () => {
27
+ const { stable, set } = stableOver({ a: 1 });
28
+
29
+ await set({ a: 2 });
30
+
31
+ expect(stable.value).toEqual({ a: 2 });
32
+ });
33
+
34
+ it("updates the reference when a different key holds undefined", async () => {
35
+ const { stable, set } = stableOver<{ a?: number; b?: number }>({
36
+ a: undefined,
37
+ });
38
+ const first = stable.value;
39
+
40
+ await set({ b: undefined });
41
+
42
+ expect(stable.value).not.toBe(first);
43
+ expect(stable.value).toEqual({ b: undefined });
44
+ });
45
+
46
+ it("compares arrays by reference", async () => {
47
+ const { stable, set } = stableOver([1, 2]);
48
+ const first = stable.value;
49
+
50
+ await set([1, 2]);
51
+
52
+ expect(stable.value).not.toBe(first);
53
+ });
54
+ });
@@ -0,0 +1,42 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { ref } from "vue";
3
+ import { CopilotKitCoreVue } from "../vue-core";
4
+ import type { VueActivityMessageRenderer } from "../../types";
5
+
6
+ const planRenderer: VueActivityMessageRenderer<unknown> = {
7
+ activityType: "plan",
8
+ content: {
9
+ "~standard": {
10
+ version: 1,
11
+ vendor: "test",
12
+ validate: (value) => ({ value }),
13
+ },
14
+ },
15
+ render: () => null,
16
+ };
17
+
18
+ describe("CopilotKitCoreVue renderer lists", () => {
19
+ it("notifies subscribers when activity renderers change", () => {
20
+ const core = new CopilotKitCoreVue({});
21
+ const seen: string[][] = [];
22
+ core.subscribe({
23
+ onRenderActivityMessagesChanged: ({ renderActivityMessages }) => {
24
+ seen.push(renderActivityMessages.map((r) => r.activityType));
25
+ },
26
+ });
27
+
28
+ core.setRenderActivityMessages([planRenderer]);
29
+
30
+ expect(seen).toEqual([["plan"]]);
31
+ });
32
+
33
+ it("keeps working behind a Vue reactive proxy", () => {
34
+ const wrapped = ref(new CopilotKitCoreVue({}));
35
+
36
+ wrapped.value.addHookRenderToolCall({ name: "search", render: () => null });
37
+
38
+ expect(wrapped.value.renderToolCalls.map((r) => r.name)).toEqual([
39
+ "search",
40
+ ]);
41
+ });
42
+ });
@@ -1,21 +1,6 @@
1
- export function extractCompleteStyles(html: string): string {
2
- const matches = html.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi);
3
- return matches ? matches.join("") : "";
4
- }
5
-
6
- export function processPartialHtml(html: string): string {
7
- let result = html;
8
-
9
- result = result.replace(/<[^>]*$/, "");
10
- result = result.replace(/<(style|script|head)\b[^>]*>[\s\S]*?<\/\1>/gi, "");
11
- result = result.replace(/<(style|script|head)\b[^>]*>[\s\S]*$/gi, "");
12
- result = result.replace(/&[a-zA-Z0-9#]*$/, "");
13
-
14
- const bodyMatch = result.match(/<body[^>]*>([\s\S]*)/i);
15
- if (bodyMatch) {
16
- result = bodyMatch[1]!;
17
- result = result.replace(/<\/body>[\s\S]*/i, "");
18
- }
19
-
20
- return result;
21
- }
1
+ // The partial-HTML helpers live in @copilotkit/core; these names stay for
2
+ // existing imports.
3
+ export {
4
+ ɵextractCompleteStyles as extractCompleteStyles,
5
+ ɵprocessPartialHtml as processPartialHtml,
6
+ } from "@copilotkit/core";
@@ -1,21 +1,7 @@
1
+ import { ɵshallowEqualRecord } from "@copilotkit/core";
1
2
  import { shallowRef, toValue, watch } from "vue";
2
3
  import type { MaybeRefOrGetter, ShallowRef } from "vue";
3
4
 
4
- function shallowEqualObjects(
5
- first: Record<string, unknown>,
6
- second: Record<string, unknown>,
7
- ): boolean {
8
- const firstKeys = Object.keys(first);
9
- const secondKeys = Object.keys(second);
10
- if (firstKeys.length !== secondKeys.length) return false;
11
-
12
- for (const key of firstKeys) {
13
- if (first[key] !== second[key]) return false;
14
- }
15
-
16
- return true;
17
- }
18
-
19
5
  function isPlainObject(value: unknown): value is Record<string, unknown> {
20
6
  return (
21
7
  value !== null &&
@@ -40,7 +26,7 @@ export function useShallowStableRef<T>(
40
26
  if (previous === next) return;
41
27
 
42
28
  if (isPlainObject(previous) && isPlainObject(next)) {
43
- if (shallowEqualObjects(previous, next)) {
29
+ if (ɵshallowEqualRecord(previous, next)) {
44
30
  return;
45
31
  }
46
32
  }